The Tufte-\LaTeX\ ^tufte_latex document classes define a style similar to the style Edward Tufte uses in his books and handouts. Tufte's style is known for its extensive use of sidenotes, tight integration of graphics with text, and well-set typography.
This style provides a- and b-heads (that is, #
and ##
), demonstrated above.
An error is emitted if you try to use ###
and smaller headings.
\newthought{In his later books}^books_be, Tufte starts each section with a bit of vertical space, a non-indented paragraph, and sets the first few words of the sentence in small caps. To accomplish this using this style, use the \newthought
command as demonstrated at the beginning of this paragraph.
Images and graphics play an integral role in Tufte's work. To place figures or tables in the margin you can use the fig.margin
knitr chunk option. For example:
library(ggplot2) qplot(Sepal.Length, Petal.Length, data = iris, color = Species)
Note the use of the fig.cap
chunk option to provide a figure caption. You can adjust the proportions of figures using the fig.width
and fig.height
chunk options. These are specified in inches, and will be automatically scaled down to fit within the handout margin.
You can also include \LaTeX\ equations in the margin by explicitly invoking the marginfigure
environment.
\begin{marginfigure} $$\frac{d}{dx}\left( \int_{0}^{x} f(u)\,du\right)=f(x).$$ \caption{An equation} \end{marginfigure}
Note the use of the \caption
command to add additional text below the equation.
You can arrange for figures to span across the entire page by using the fig.fullwidth
chunk option.
qplot(wt, mpg, data=mtcars, colour=factor(cyl))
Note the use of the fig.width
and fig.height
chunk options to establish the proportions of the figure. Full width figures look much better if their height is minimized.
Besides margin and full width figures, you can of course also include figures constrained to the main column.
qplot(factor(cyl), mpg, data = mtcars, geom = "boxplot")
One of the most prominent and distinctive features of this style is the extensive use of sidenotes. There is a wide margin to provide ample room for sidenotes and small figures. Any use of a footnote will automatically be converted to a sidenote. ^[This is a sidenote that was entered using a footnote.]
If you'd like to place ancillary information in the margin without the sidenote mark (the superscript number), you can use the \marginnote
command. \marginnote{This is a margin note. Notice that there isn't a number preceding the note.}
Note also that the two footnote references (tufte_latex
and books_be
, both defined below) were also included in the margin on the first page of this document.
You can use the xtable package to format \LaTeX\ tables that integrate well with the rest of the Tufte handout style. Note that it's important to set the xtable.comment
and xtable.booktabs
options as shown below to ensure the table is formatted correctly for inclusion in the document.
library(xtable) options(xtable.comment = FALSE) options(xtable.booktabs = TRUE) xtable(head(mtcars[,1:6]), caption = "First rows of mtcars")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.