Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News Sign UpSign In
| Download

tufte handout rmarkdown

Project: Testing 18.04
Views: 793
---
title: "An Example Using the Tufte Style" author: "John Smith" output: #tufte::tufte_handout: default #prodcues PDF tufte::tufte_html: default
---

Tufte Handout

knitr::kable( mtcars[1:6, 1:6], caption = 'A subset of mtcars.' )

The package provides two custom hooks for figure placement. The first is marginfigure. Set marginfigure = TRUE in a chuck option to place a figure in the right margin. Optionally, specify the figure size and include a caption. Captions are passed as strings through fig.cap in the chunk options.

library(ggplot2) ggplot(mtcars, aes(y = mpg, x = wt)) + geom_point() + stat_smooth(method = "lm", color = "black", fill = "gray")

The html documents have the body set at a fixed width of 960px. Feel free to edit the css to suit your needs. Html output supports any of the built in Bootstrap themes. Be careful using the fluid grid system, it may break the output for narrow screens.

The second custom hook is fig.star. Setting fig.star = TRUE creates a full-width figure spanning the main body and the margin. The caption goes in the sidebar under the figure. These look pretty sweet! Specify the width and height for best results.

ggplot(faithful, aes(y = eruptions, x = waiting)) + geom_point() + stat_smooth(method = "loess", , color = "black", fill = "gray")

Finally, normal figures are plotted in the main body, with the captions in the margin. The only option necessary here is the caption itself.

ggplot(faithful, aes(x = eruptions)) + geom_histogram(binwidth = .1, fill = "gray") + geom_hline(yintercept = seq(5, 30, 5), col="white", lwd=1)