This dukeslides
example slide deck extends the excellent collaborative work of the xaringan and Remark.js slide tools. With this template, slide authors can compose xaringan slides via R Markdown and present with Duke University branding.
Yihui Xie provides wonderful technical documentation and a wiki for the xaringan package. Some of his documentation is repeated here.
My goal is to present example slides with example R Markdown and xaringan syntax to demonstrate presentation styles.
Many of the cheat sheet examples are displayed in the slide itself. Some of the example code will be found in the presenter notes.
Access presenter notes by pressing the keyboard shortcut p
. (Or, ?
for other shortcuts)
Full detailed R Markdown can always be displayed by opening the rendered HTML slides in your web browser via View Source
.
The CSS style used in this example are
default
)default-fonts
)duke-blue
)hygge-duke
)cc-fonts.css
)figures.css
)You can find these style sheets declared in the yaml
header inside the R Markdown file.
# Display background image with background-image: url()#background-image: url(https://upload.wikimedia.org/wikipedia/commons/thumb/e/e6/Duke_University_logo.svg/640px-Duke_University_logo.svg.png)
Image credit: Wikimedia Commons
---class: inverse, center, middle# Get Started
Install the dukeslides1 package from Github
# monospace font is displayed when code is written # inside of an Rmarkdown code chunkdevtools::install_github("libjohn/dukeslides")
File -> New File -> R Markdown -> From Template -> Slide template for Duke University
Knit
button to compile the slide into rendered HTML[1] dukeslides is a Duke University branded version of xaringan presentation slides.
- List items (bullets) are invoked with a leading,left-justified dash, just like any Rmarkdown<sup>1</sup> document
- List items (bullets) are invoked with a leading,left-justified dash, just like any Rmarkdown<sup>1</sup> document
--
arrow
keys and number keys advance from slide to slide. See more documentation on incrementingAs previously mentioned,
Knit
button to compile the slide into rendered HTMLOr, use the RStudio Addin "Infinite Moon Reader" to live preview the slides (every time you update and save the Rmd document, the slides will be automatically reloaded in RStudio Viewer.
---background-image: url(https://c2.staticflickr.com/6/5729/30943501632_eb0b200eed_b.jpg)class: center, top# Rock Cairn Hiking.footer-note[.tiny[.green[Image Credit: ][Brandon Rasmussen](https://www.flickr.com/photos/137029081@N02/30943501632/in/photostream/)]]
Image Credit: Brandon Rasmussen
---background-image: url(https://c2.staticflickr.com/6/5729/30943501632_eb0b200eed_b.jpg)class: center, top, inverse# Rock Cairn Hiking.footer-note[.tiny[.green[Image Credit: ][Brandon Rasmussen](https://www.flickr.com/photos/137029081@N02/30943501632/in/photostream/)]]
You can generate a left column
by wrapping the left-hand text in .pull-left[
foo ]
TAGS 1
Splunk
You can generate a right column
by wrapping the right-hand text in .pull-right[
foo ]
foo
foo 2
# superscript is wrapped in HTMLTAGS <sup>1</sup>
[1] example foonote 1 -- footnote text wrapped in .footnote[foo]
[2] example footnote 2
Lorem Ipsum
"Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
---class: inverse## inverse### h3Lorem Ipsum"Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
---class: duke-softblue
Lorem Ipsum
"Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
one
three
---class: duke-orange
Lorem Ipsum
"Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
one
three
---class: duke-green
"Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..."
one
three
qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...
.pull-left[ nabisco crackers snackum attackum ... ]
.pull-right[.full-width[ .rotate-left[ .content-box-blue[snackum nabiskum]]]]
background-size: contain
View Source
to see all of the R Markdown for this slideThis is normal size ( LATEX-friendly terms)
Large
large
small
footnotesize
scriptsize
tiny
black
red
blue
green, yellow, orange, purple, gray or grey
You can also use .bold[]
or .bolder[]
to emphasize text
This is bold, this is bolder and this is regular markdown double-star bold (visible differences depend on the font)
Hegge CSS + Duke Color Palette = hegge-duke.css
Use .content-box-blue
(or gray/grey, duke-green, green, purple, red, or yellow) to produce a box with coloured background. Size depends on content.
.content-box-blue[I feel blue]
yields
I feel blue
Wrap in .full-width
to expand the width
I feel wide and red
If you have content in columns then you get
WARNING Look out for minons or bananas
The box to the left was created using .pull-left[.full-width[.content-box-yellow[]]]
Use .content-box-blue
to produce a box with blue background. Size depends on content. color has the following options: .content-box-color
where color is blue | gray | grey | neutral | duke-green | green | purple | red | yellow
blue gray grey neutral
duke-green green purple
red yellow
CSS is the key to managing the style of your slides. The cascading style sheets (CSS) are declared in the yaml header.
output: xaringan::moon_reader: css: ["default", "ubuntu-mono.css"]
User-contributed themes. A theme typically consists of two CSS files foo.css
and foo-fonts.css
, where foo
is the theme name. Below are some existing themes:
names(xaringan:::list_css())
## [1] "chocolate-fonts" "chocolate" "default-fonts" "default" ## [5] "duke-blue" "fc-fonts" "fc" "glasgow_template"## [9] "hygge-duke" "hygge" "ki-fonts" "ki" ## [13] "kunoichi" "lucy-fonts" "lucy" "metropolis-fonts"## [17] "metropolis" "middlebury-fonts" "middlebury" "nhsr-fonts" ## [21] "nhsr" "ninjutsu" "rladies-fonts" "rladies" ## [25] "robot-fonts" "robot" "rutgers-fonts" "rutgers" ## [29] "shinobi" "tamu-fonts" "tamu" "uio-fonts" ## [33] "uio" "uo-fonts" "uo" "uol-fonts" ## [37] "uol" "useR-fonts" "useR" "uwm-fonts" ## [41] "uwm" "wic-fonts" "wic"
To use a theme, you can specify the css
option as an array of CSS filenames (without the .css
extensions), e.g.,
output: xaringan::moon_reader: css: [default, metropolis, metropolis-fonts]
If you want to contribute a theme to xaringan, please read this blog post.
<figure> <img src="foo.png"> <figcaption> Image Credit: foo text here </figcaption></figure># Must declare figure-captions in the YAML header# Must use HTML instead of RMarkdown
Presenter Notes go here use 'p' to toggle the presenter mode or '?' or 'h' to toggle the help / key-shortcut options
Image credit: Wikimedia Commons
Provides an R Markdown output format xaringan::moon_reader
as a wrapper for remark.js, and you can use it in the YAML metadata, e.g.
---title: "A Cool Presentation"output: xaringan::moon_reader yolo: true nature: autoplay: 30000---
See the help page ?xaringan::moon_reader
for all possible options that you can use.
Start with an R Markdown document;
R Markdown (can embed R/other code chunks);
Provide an option autoplay
;
MathJax just works;*
Highlight code with {{}}
;
The RStudio addin "Infinite Moon Reader" automatically refreshes slides on changes;
[*] Not really. See next page.
You can write LaTeX math expressions inside a pair of dollar signs, e.g. $\alpha+\beta$ renders α+β. You can use the display style with double dollar signs:
$$\bar{X}=\frac{1}{n}\sum_{i=1}^nX_i$$
¯X=1nn∑i=1Xi
Limitations:
The source code of a LaTeX math expression must be in one line, unless it is inside a pair of double dollar signs, in which case the starting $$
must appear in the very beginning of a line, followed immediately by a non-space character, and the ending $$
must be at the end of a line, led by a non-space character;
There should not be spaces after the opening $
or before the closing $
.
Math does not work on the title slide (see #61 for a workaround).
# visualizations are cool, duh.par(mar = c(4, 4, 1, .1))plot(cars, pch = 19, col = 'darkgray', las = 1)abline(fit, lwd = 2)
If you want to generate a table, make sure it is in the HTML format (instead of Markdown or other formats), e.g.,
knitr::kable(head(iris), format = 'html')
Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species |
---|---|---|---|---|
5.1 | 3.5 | 1.4 | 0.2 | setosa |
4.9 | 3.0 | 1.4 | 0.2 | setosa |
4.7 | 3.2 | 1.3 | 0.2 | setosa |
4.6 | 3.1 | 1.5 | 0.2 | setosa |
5.0 | 3.6 | 1.4 | 0.2 | setosa |
5.4 | 3.9 | 1.7 | 0.4 | setosa |
Items | Features |
---|---|
Item 1 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin vehicula tempor ex. Morbi malesuada sagittis turpis, at venenatis nisl luctus a. |
Item 2 | In eu urna at magna luctus rhoncus quis in nisl. Fusce in velit varius, posuere risus et, cursus augue. Duis eleifend aliquam ante, a aliquet ex tincidunt in. |
Item 3 | Vivamus venenatis egestas eros ut tempus. Vivamus id est nisi. Aliquam molestie erat et sollicitudin venenatis. In ac lacus at velit scelerisque mattis. |
Documentation for HTML (kable) tables via the library(kableExtra)
package
library(leaflet)leaflet() %>% addTiles() %>% setView(-93.65, 42.0285, zoom = 17)
DT::datatable( head(iris, 10), fillContainer = FALSE, options = list(pageLength = 8))
highlightLines: true
of nature
will highlight code lines that start with *
, or are wrapped in {{ }}
, or have trailing comments #<<
;output: xaringan::moon_reader: nature: highlightLines: true
See examples on the next page.
{{}}
An example using a leading *
:
if (TRUE) {* message("Very important!")}
Output:
if (TRUE) { message("Very important!")}
This is invalid R code, so it is a plain fenced code block that is not executed.
An example using {{}}
:
`{r tidy=FALSE} if (TRUE) { *{{ message("Very important!") }} }
Output:```rif (TRUE) { message("Very important!") }
## Very important!
It is valid R code so you can run it. Note that {{}}
can wrap an R expression of multiple lines.
#<<
An example of using the trailing comment #<<
to highlight lines:
library(ggplot2)ggplot(mtcars) + aes(mpg, disp) + geom_point() + #<< geom_smooth() #<<
Output:
library(ggplot2)ggplot(mtcars) + aes(mpg, disp) + geom_point() + geom_smooth()
You can make Rfun with our resources for R and data science analytics. See the R we having fun yet‽ resource pages.
Data & Visualization Services
This dukeslides
example slide deck extends the excellent collaborative work of the xaringan and Remark.js slide tools. With this template, slide authors can compose xaringan slides via R Markdown and present with Duke University branding.
Yihui Xie provides wonderful technical documentation and a wiki for the xaringan package. Some of his documentation is repeated here.
My goal is to present example slides with example R Markdown and xaringan syntax to demonstrate presentation styles.
Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |