blob: 40893a049d1e5060759171bca78089822107357f [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
6 toc_depth: 3
7---
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 Allaire5dc9fe02016-01-30 18:44:51 -0500146## Reveal.js Options
147
148Reveal.js has many additional options to conigure it's behavior. You can specify any of these options using `reveal_options`, for example:
149
150 ---
151 title: "Habits"
152 output:
153 revealjs::revealjs_presentation:
154 self_contained: false
155 reveal_options:
156 slideNumber: true
157 previewLinks: true
158 ---
159
160You can find documentation on the various available Reveal.js options here: <https://github.com/hakimel/reveal.js#configuration>.
161
162
163## Figure Options
164
165There are a number of options that affect the output of figures within reveal.js presentations:
166
167* `fig_width` and `fig_height` can be used to control the default figure width and height (7x5 is used by default)
168
169* `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.
170
171* `fig_caption` controls whether figures are rendered with captions
172
173For example:
174
175 ---
176 title: "Habits"
177 output:
178 revealjs::revealjs_presentation:
179 fig_width: 7
180 fig_height: 6
181 fig_caption: true
182 ---
183
184
185## MathJax Equations
186
187By 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:
188
189* Specify "default" to use an https URL from the official MathJax CDN.
190
191* 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.
192
193* Specify an alternate URL to load MathJax from another location.
194
195* Specify null to exclude MathJax entirely.
196
197For example, to use a local copy of MathJax:
198
199 ---
200 title: "Habits"
201 output:
202 revealjs::revealjs_presentation:
203 mathjax: local
204 self_contained: false
205 ---
206
207To use a self-hosted copy of MathJax:
208
209 ---
210 title: "Habits"
211 output:
212 revealjs::revealjs_presentation:
213 mathjax: "http://example.com/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
214 ---
215
216To exclude MathJax entirely:
217
218 ---
219 title: "Habits"
220 output:
221 revealjs::revealjs_presentation:
222 mathjax: null
223 ---
224
225## Document Dependencies
226
227By 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:
228
229 ---
230 title: "Habits"
231 output:
232 revealjs::revealjs_presentation:
233 self_contained: false
234 ---
235
236Note 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`.
237
238One 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:
239
240 ---
241 title: "Habits"
242 output:
243 revealjs::revealjs_presentation:
244 self_contained: false
245 lib_dir: libs
246 ---
247
248## Advanced Customization
249
250### Includes
251
252You 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:
253
254 ---
255 title: "Habits"
256 output:
257 revealjs::revealjs_presentation:
258 includes:
259 in_header: header.html
260 before_body: doc_prefix.html
261 after_body: doc_suffix.html
262 ---
263
264
265### Pandoc Arguments
266
267If 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:
268
269 ---
270 title: "Habits"
271 output:
272 revealjs::revealjs_presentation:
273 pandoc_args: [
274 "--title-prefix", "Foo",
275 "--id-prefix", "Bar"
276 ]
277 ---
278
279Documentation on all available pandoc arguments can be found in the [pandoc user guide](http://johnmacfarlane.net/pandoc/README.html#options).
280
281## Shared Options
282
283If 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:
284
285**\_output.yaml**
286
287```yaml
288revealjs::revealjs_presentation:
289 theme: sky
290 transition: fade
291 highlight: pygments
292```
293
294All 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.
295
296
297
298
299
300
301
302
303
304
305