blob: 1223d621b15aa25210430663d8bf653420970ad7 [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
86* `transition` specifies the visual effect when moving between slides. Available transitions are "default", "fade", "slide", "convex", "concave", "zoom" or "none".
87
88* `background_transition` specifies the background transition effect when moving between full page slides. Available transitions are "default", "fade", "slide", "convex", "concave", "zoom" or "none".
89
90* `highlight` specifies the syntax highlighting style. Supported styles include "default", "tango", "pygments", "kate", "monochrome", "espresso", "zenburn", and "haddock". Pass null to prevent syntax highlighting.
91
92* `center` specifies whether you want to vertically center content on slides (this defaults to false).
93
94* `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.
95
96For example:
97
98 ---
99 output:
100 revealjs::revealjs_presentation:
101 theme: sky
102 transition: fade
103 highlight: pygments
104 center: true
105 ---
106
107## Reveal.js Options
108
109Reveal.js has many additional options to conigure it's behavior. You can specify any of these options using `reveal_options`, for example:
110
111 ---
112 title: "Habits"
113 output:
114 revealjs::revealjs_presentation:
115 self_contained: false
116 reveal_options:
117 slideNumber: true
118 previewLinks: true
119 ---
120
121You can find documentation on the various available Reveal.js options here: <https://github.com/hakimel/reveal.js#configuration>.
122
123
124## Figure Options
125
126There are a number of options that affect the output of figures within reveal.js presentations:
127
128* `fig_width` and `fig_height` can be used to control the default figure width and height (7x5 is used by default)
129
130* `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.
131
132* `fig_caption` controls whether figures are rendered with captions
133
134For example:
135
136 ---
137 title: "Habits"
138 output:
139 revealjs::revealjs_presentation:
140 fig_width: 7
141 fig_height: 6
142 fig_caption: true
143 ---
144
145
146## MathJax Equations
147
148By 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:
149
150* Specify "default" to use an https URL from the official MathJax CDN.
151
152* 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.
153
154* Specify an alternate URL to load MathJax from another location.
155
156* Specify null to exclude MathJax entirely.
157
158For example, to use a local copy of MathJax:
159
160 ---
161 title: "Habits"
162 output:
163 revealjs::revealjs_presentation:
164 mathjax: local
165 self_contained: false
166 ---
167
168To use a self-hosted copy of MathJax:
169
170 ---
171 title: "Habits"
172 output:
173 revealjs::revealjs_presentation:
174 mathjax: "http://example.com/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
175 ---
176
177To exclude MathJax entirely:
178
179 ---
180 title: "Habits"
181 output:
182 revealjs::revealjs_presentation:
183 mathjax: null
184 ---
185
186## Document Dependencies
187
188By 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:
189
190 ---
191 title: "Habits"
192 output:
193 revealjs::revealjs_presentation:
194 self_contained: false
195 ---
196
197Note 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`.
198
199One 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:
200
201 ---
202 title: "Habits"
203 output:
204 revealjs::revealjs_presentation:
205 self_contained: false
206 lib_dir: libs
207 ---
208
209## Advanced Customization
210
211### Includes
212
213You 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:
214
215 ---
216 title: "Habits"
217 output:
218 revealjs::revealjs_presentation:
219 includes:
220 in_header: header.html
221 before_body: doc_prefix.html
222 after_body: doc_suffix.html
223 ---
224
225
226### Pandoc Arguments
227
228If 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:
229
230 ---
231 title: "Habits"
232 output:
233 revealjs::revealjs_presentation:
234 pandoc_args: [
235 "--title-prefix", "Foo",
236 "--id-prefix", "Bar"
237 ]
238 ---
239
240Documentation on all available pandoc arguments can be found in the [pandoc user guide](http://johnmacfarlane.net/pandoc/README.html#options).
241
242## Shared Options
243
244If 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:
245
246**\_output.yaml**
247
248```yaml
249revealjs::revealjs_presentation:
250 theme: sky
251 transition: fade
252 highlight: pygments
253```
254
255All 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.
256
257
258
259
260
261
262
263
264
265
266