Skip to content

Commit

Permalink
fixes #53: use margin_references = FALSE in tufte_html() to disable c…
Browse files Browse the repository at this point in the history
…itations in margin instead (changes #49)
  • Loading branch information
yihui committed Jan 12, 2018
1 parent 2445598 commit f9c45cc
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: tufte
Type: Package
Title: Tufte's Styles for R Markdown Documents
Version: 0.2.8
Version: 0.2.9
Date: 2016-02-07
Authors@R: c(
person("Yihui", "Xie", email = "xie@yihui.name", role = c("aut", "cre")),
Expand Down
11 changes: 6 additions & 5 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

## NEW FEATURES

- It is possible to select a subset of some features of the default Tufte style (`tufte-css`) via the `tufte_features` argument of `tufte_html()`.
- It is possible to select a subset of some features of the default Tufte style (`tufte-css`) via the `tufte_features` argument of `tufte_html()`:

- You can disable the `et-book` fonts
- Remove the default light-yellow background color
- Use italics for document headers or not
- Choose whether references from citations should be placed in the document margins or at the bottom
- Disable the `et-book` fonts.
- Remove the default light-yellow background color.
- Use italics for document headers or not.

- A new variant of the Tufte style, `envisioned`, is added to `tufte_html()`. You can use `tufte_html(tufte_variant = 'envisioned')` to enable this style. The major difference with the default Tufte style is: the font family is `Roboto Condensed`, the background color is `#fefefe`, and the text color is `#222` (thanks, @eddelbuettel, #21).

- You can choose whether references from citations should be placed in the document margins or at the bottom using the `margin_references` argument of `tufte_html()` (thanks, @stefanfritsch, #49).

## BUG FIXES

- when `link-citations: no` in YAML, citations should not be moved into the page margin in the HTML output (http://stackoverflow.com/q/39053097/559676)
Expand Down
11 changes: 5 additions & 6 deletions R/html.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
#' @param tufte_features A character vector of style features to enable:
#' \code{fonts} stands for the \code{et-book} fonts in the \code{tufte-css}
#' project, \code{background} means the lightyellow background color of the
#' page, \code{italics} means whether to use italics for the headers, and
#' \code{margin_references} places citations in margin notes. You
#' page, and \code{italics} means whether to use italics for the headers. You
#' can enable a subset of these features, or just disable all of them by
#' \code{NULL}. When this argument is not used and the \code{tufte_variant}
#' argument is not \code{default}, no features are enabled.
Expand All @@ -14,11 +13,12 @@
#' \url{http://nogginfuel.com/envisioned-css/} but essentially just sets the
#' font family to \code{Roboto Condensed}, and changed the
#' background/foregroudn colors).
#' @param margin_references Whether to place citations in margin notes.
#' @rdname tufte_handout
#' @export
tufte_html = function(
..., tufte_features = c('fonts', 'background', 'italics', 'margin_references'),
tufte_variant = c('default', 'envisioned')
..., tufte_features = c('fonts', 'background', 'italics'),
tufte_variant = c('default', 'envisioned'), margin_references = TRUE
) {

tufte_variant = match.arg(tufte_variant)
Expand Down Expand Up @@ -69,8 +69,7 @@ tufte_html = function(
if (length(footnotes$range)) x = x[-footnotes$range]

# replace citations with margin notes
if ('margin_references' %in% tufte_features)
x = margin_references(x)
if (margin_references) x = margin_references(x)

# place figure captions in margin notes
x[x == '<p class="caption">'] = '<p class="caption marginnote shownote">'
Expand Down
9 changes: 5 additions & 4 deletions man/tufte_handout.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f9c45cc

Please sign in to comment.