blob: b38705476b1fa18310cca4a1f03b0018de6f8787 [file] [log] [blame]
JJ Allaire5dc9fe02016-01-30 18:44:51 -05001---
2title: "R Markdown Format for reveal.js Presentations"
3output:
4 github_document:
5 toc: true
JJ Allaireb9873562016-01-30 19:26:11 -05006 toc_depth: 2
JJ Allaire5dc9fe02016-01-30 18:44:51 -05007---
8
9## Overview
10
11This repository provides an [R Markdown](http://rmarkdown.rstudio.com) custom format for [reveal.js](http://lab.hakim.se/reveal-js/#/) HTML presentations.
12
13You can use this format in R Markdown documents by installing this package as follows:
14
15```r
16devtools::install_github("jjallaire/revealjs")
17```
18
19
20To create a [reveal.js](http://lab.hakim.se/reveal-js/#/) presentation from R Markdown you specify the `revealjs_presentation` output format in the front-matter of your document. You can create a slide show broken up into sections by using the `#` and `##` heading tags (you can also create a new slide without a header using a horizontal rule (`----`). For example here's a simple slide show:
21
22 ---
23 title: "Habits"
24 author: John Doe
25 date: March 22, 2005
26 output: revealjs::revealjs_presentation
27 ---
28
29 # In the morning
30
31 ## Getting up
32
33 - Turn off alarm
34 - Get out of bed
35
36 ## Breakfast
37
38 - Eat eggs
39 - Drink coffee
40
41 # In the evening
42
43 ## Dinner
44
45 - Eat spaghetti
46 - Drink wine
47
48 ## Going to sleep
49
50 - Get in bed
51 - Count sheep
52
53## Display Modes
54
55The following single character keyboard shortcuts enable alternate
56display modes:
57
58- `'f'` enable fullscreen mode
59
60- `'o'` enable overview mode
61
62Pressing `Esc` exits all of these modes.
63
64## Incremental Bullets
65
66You can render bullets incrementally by adding the `incremental` option:
67
68 ---
69 output:
70 revealjs::revealjs_presentation:
71 incremental: true
72 ---
73
74If you want to render bullets incrementally for some slides but not
75others you can use this syntax:
76
77 > - Eat eggs
78 > - Drink coffee
79
80## Appearance and Style
81
82There are several options that control the appearance of revealjs presentations:
83
84* `theme` specifies the theme to use for the presentation (available themes are "default", "simple", "sky", "beige", "serif", "solarized", "blood", "moon", "night", "black", "league" or "white").
85
JJ Allaire5dc9fe02016-01-30 18:44:51 -050086* `highlight` specifies the syntax highlighting style. Supported styles include "default", "tango", "pygments", "kate", "monochrome", "espresso", "zenburn", and "haddock". Pass null to prevent syntax highlighting.
87
88* `center` specifies whether you want to vertically center content on slides (this defaults to false).
89
90* `smart` indicates whether to produce typographically correct output, converting straight quotes to curly quotes, `---` to em-dashes, `--` to en-dashes, and `...` to ellipses. Note that `smart` is enabled by default.
91
92For example:
93
94 ---
95 output:
96 revealjs::revealjs_presentation:
97 theme: sky
JJ Allaire5dc9fe02016-01-30 18:44:51 -050098 highlight: pygments
99 center: true
100 ---
101
JJ Allaire41921d32016-01-30 19:11:43 -0500102## Slide Transitions
103
104You can use the `transition` and `background_transition` optoins to specify the global default slide transition style:
105
106* `transition` specifies the visual effect when moving between slides. Available transitions are "default", "fade", "slide", "convex", "concave", "zoom" or "none".
107
108* `background_transition` specifies the background transition effect when moving between full page slides. Available transitions are "default", "fade", "slide", "convex", "concave", "zoom" or "none".
109
110For example:
111
112 ---
113 output:
114 revealjs::revealjs_presentation:
115 transition: fade
116 ---
117
118
119You can override the global transition for a specific slide by using the data-transition attribute, for example:
120
121 ## Use a zoom transition {data-transition="zoom"}
122
123 ## Use a faster speed {data-transition-speed="fast"}
124
125You can also use different in and out transitions for the same slide, for example:
126
127 ## Fade in, Slide out {data-transition="slide-in fade-out"}
128
129 ## Slide in, Fade out {data-transition="fade-in slide-out"}
130
131
JJ Allaire8382c3e2016-01-30 19:04:31 -0500132## Slide Backgrounds
133
134Slides are contained within a limited portion of the screen by default to allow them to fit any display and scale uniformly. You can apply full page backgrounds outside of the slide area by adding a data-background attribute to your slide header element. Four different types of backgrounds are supported: color, image, video and iframe. Below are a few examples.
135
136 ## CSS color background {data-background=#ff0000}
137
138 ## Full size image background {data-background="background.jpeg"}
139
140 ## Video background {data-background-video="background.mp4"}
141
142 ## Embed a web page as a background {data-background-iframe="https://example.com"}
143
144Backgrounds transition using a fade animation by default. This can be changed to a linear sliding transition by specifying the `background-transition: slide`. Alternatively you can set data-background-transition on any slide with a background to override that specific transition.
145
JJ Allairede1ed652016-01-30 19:41:18 -0500146## 2-D Presenations
147
148You can use the `slide_level` option to specify which level of heading will be used to denote individual slides. If `slide_level` is 2 (the default), a two-dimensional layout will be produced, with level 1 headers building horizontally and level 2 headers building vertically. For example:
149
150 # Horizontal Slide 1
151
152 ## Vertical Slide 1
153
154 ## Vertical Slide 2
155
156 # Horizontal Slide 2
157
158With this layout horizontal navigation will proceed directly from "Horizontal Slide 1" to "Horizontal Slide 2", with vertical navigation to "Vertical Slide 1", etc. presented as an option on "Horizontal Slide 1".
159
160
161
JJ Allaire5dc9fe02016-01-30 18:44:51 -0500162## Reveal.js Options
163
164Reveal.js has many additional options to conigure it's behavior. You can specify any of these options using `reveal_options`, for example:
165
166 ---
167 title: "Habits"
168 output:
169 revealjs::revealjs_presentation:
170 self_contained: false
171 reveal_options:
172 slideNumber: true
173 previewLinks: true
174 ---
175
176You can find documentation on the various available Reveal.js options here: <https://github.com/hakimel/reveal.js#configuration>.
177
178
179## Figure Options
180
181There are a number of options that affect the output of figures within reveal.js presentations:
182
183* `fig_width` and `fig_height` can be used to control the default figure width and height (7x5 is used by default)
184
185* `fig_retina` Specifies the scaling to perform for retina displays (defaults to 2, which currently works for all widely used retina displays). Note that this only takes effect if you are using knitr >= 1.5.21. Set to `null` to prevent retina scaling.
186
187* `fig_caption` controls whether figures are rendered with captions
188
189For example:
190
191 ---
192 title: "Habits"
193 output:
194 revealjs::revealjs_presentation:
195 fig_width: 7
196 fig_height: 6
197 fig_caption: true
198 ---
199
200
201## MathJax Equations
202
203By default [MathJax](http://www.mathjax.org/) scripts are included in reveal.js presentations for rendering LaTeX and MathML equations. You can use the `mathjax` option to control how MathJax is included:
204
205* Specify "default" to use an https URL from the official MathJax CDN.
206
207* Specify "local" to use a local version of MathJax (which is copied into the output directory). Note that when using "local" you also need to set the `self_contained` option to false.
208
209* Specify an alternate URL to load MathJax from another location.
210
211* Specify null to exclude MathJax entirely.
212
213For example, to use a local copy of MathJax:
214
215 ---
216 title: "Habits"
217 output:
218 revealjs::revealjs_presentation:
219 mathjax: local
220 self_contained: false
221 ---
222
223To use a self-hosted copy of MathJax:
224
225 ---
226 title: "Habits"
227 output:
228 revealjs::revealjs_presentation:
229 mathjax: "http://example.com/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
230 ---
231
232To exclude MathJax entirely:
233
234 ---
235 title: "Habits"
236 output:
237 revealjs::revealjs_presentation:
238 mathjax: null
239 ---
240
241## Document Dependencies
242
243By default R Markdown produces standalone HTML files with no external dependencies, using data: URIs to incorporate the contents of linked scripts, stylesheets, images, and videos. This means you can share or publish the file just like you share Office documents or PDFs. If you'd rather have keep depenencies in external files you can specify `self_contained: false`. For example:
244
245 ---
246 title: "Habits"
247 output:
248 revealjs::revealjs_presentation:
249 self_contained: false
250 ---
251
252Note that even for self contained documents MathJax is still loaded externally (this is necessary because of it's size). If you want to serve MathJax locally then you should specify `mathjax: local` and `self_contained: false`.
253
254One common reason keep dependencies external is for serving R Markdown documents from a website (external dependencies can be cached separately by browsers leading to faster page load times). In the case of serving multiple R Markdown documents you may also want to consolidate dependent library files (e.g. Bootstrap, MathJax, etc.) into a single directory shared by multiple documents. You can use the `lib_dir` option to do this, for example:
255
256 ---
257 title: "Habits"
258 output:
259 revealjs::revealjs_presentation:
260 self_contained: false
261 lib_dir: libs
262 ---
263
264## Advanced Customization
265
266### Includes
267
268You can do more advanced customization of output by including additional HTML content or by replacing the core pandoc template entirely. To include content in the document header or before/after the document body you use the `includes` option as follows:
269
270 ---
271 title: "Habits"
272 output:
273 revealjs::revealjs_presentation:
274 includes:
275 in_header: header.html
276 before_body: doc_prefix.html
277 after_body: doc_suffix.html
278 ---
279
280
281### Pandoc Arguments
282
283If there are pandoc features you want to use that lack equivilants in the YAML options described above you can still use them by passing custom `pandoc_args`. For example:
284
285 ---
286 title: "Habits"
287 output:
288 revealjs::revealjs_presentation:
289 pandoc_args: [
290 "--title-prefix", "Foo",
291 "--id-prefix", "Bar"
292 ]
293 ---
294
295Documentation on all available pandoc arguments can be found in the [pandoc user guide](http://johnmacfarlane.net/pandoc/README.html#options).
296
297## Shared Options
298
299If you want to specify a set of default options to be shared by multiple documents within a directory you can include a file named `_output.yaml` within the directory. Note that no YAML delimeters or enclosing output object are used in this file. For example:
300
301**\_output.yaml**
302
303```yaml
304revealjs::revealjs_presentation:
305 theme: sky
306 transition: fade
307 highlight: pygments
308```
309
310All documents located in the same directory as `_output.yaml` will inherit it's options. Options defined explicitly within documents will override those specified in the shared options file.
311
312
313
314
315
316
317
318
319
320
321