JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 1 | --- |
| 2 | title: "R Markdown Format for reveal.js Presentations" |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 3 | output: github_document |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 4 | --- |
| 5 | |
christophe dervieux | 42886a1 | 2021-09-16 11:36:01 +0200 | [diff] [blame] | 6 | <!-- badges: start --> |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 7 | |
christophe dervieux | 42886a1 | 2021-09-16 11:36:01 +0200 | [diff] [blame] | 8 | [![CRAN status](https://www.r-pkg.org/badges/version/revealjs)](https://CRAN.R-project.org/package=revealjs) |
| 9 | [![R-CMD-check](https://github.com/rstudio/revealjs/workflows/R-CMD-check/badge.svg)](https://github.com/rstudio/revealjs/actions) |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 10 | [![revealjs](https://img.shields.io/badge/revealjs-`r revealjs:::revealjs_version()`-yellow)](https://github.com/rstudio/revealjs/tree/master/inst/reveal.js-`r revealjs:::revealjs_version()`) |
| 11 | |
christophe dervieux | 42886a1 | 2021-09-16 11:36:01 +0200 | [diff] [blame] | 12 | <!-- badges: end --> |
| 13 | |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 14 | ## Overview |
| 15 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 16 | This repository provides an [R Markdown](http://rmarkdown.rstudio.com) custom format for [reveal.js](https://revealjs.com/) HTML presentations. The packages includes _reveal.js_ library in version `r revealjs:::revealjs_version()` |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 17 | |
| 18 | You can use this format in R Markdown documents by installing this package as follows: |
| 19 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 20 | ``` r |
| 21 | install.packages("revealjs") |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 22 | ``` |
| 23 | |
Atsushi Yasumoto | e734cd8 | 2020-08-10 21:48:18 +0900 | [diff] [blame] | 24 | To create a [reveal.js](https://revealjs.com/) 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: |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 25 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 26 | ``` markdown |
| 27 | --- |
| 28 | title: "Habits" |
| 29 | author: John Doe |
| 30 | date: March 22, 2005 |
| 31 | output: revealjs::revealjs_presentation |
| 32 | --- |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 33 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 34 | # In the morning |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 35 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 36 | ## Getting up |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 37 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 38 | - Turn off alarm |
| 39 | - Get out of bed |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 40 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 41 | ## Breakfast |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 42 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 43 | - Eat eggs |
| 44 | - Drink coffee |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 45 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 46 | # In the evening |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 47 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 48 | ## Dinner |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 49 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 50 | - Eat spaghetti |
| 51 | - Drink wine |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 52 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 53 | ## Going to sleep |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 54 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 55 | - Get in bed |
| 56 | - Count sheep |
| 57 | ``` |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 58 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 59 | ## Rendering |
Daniel Chen | 46087c3 | 2016-03-21 17:58:14 -0400 | [diff] [blame] | 60 | |
Daniel Chen | 81a1434 | 2016-03-21 18:00:56 -0400 | [diff] [blame] | 61 | Depending on your use case, there are 3 ways you can render the presentation. |
Daniel Chen | 46087c3 | 2016-03-21 17:58:14 -0400 | [diff] [blame] | 62 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 63 | 1. RStudio |
| 64 | 2. R console |
| 65 | 3. Terminal (e.g., bash) |
Daniel Chen | 46087c3 | 2016-03-21 17:58:14 -0400 | [diff] [blame] | 66 | |
| 67 | ### RStudio |
| 68 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 69 | When creating the presentation in RStudio, there will be a `Knit` button right below the source tabs. By default, it will render the current document and place the rendered `HTML` file in the same directory as the source file, with the same name. |
Daniel Chen | 46087c3 | 2016-03-21 17:58:14 -0400 | [diff] [blame] | 70 | |
| 71 | ### R Console |
| 72 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 73 | The `Knit` button is actually calling the `rmarkdown::render()` function. So, to render the document within the R console: |
Daniel Chen | 46087c3 | 2016-03-21 17:58:14 -0400 | [diff] [blame] | 74 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 75 | ``` r |
Daniel Chen | 46087c3 | 2016-03-21 17:58:14 -0400 | [diff] [blame] | 76 | rmarkdown::render('my_reveal_presentation.Rmd') |
| 77 | ``` |
| 78 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 79 | There are many other output tweaks you can use by directly calling `render`. You can read up on the [documentation](https://pkgs.rstudio.com/rmarkdown/reference/render.html) for more details. |
Daniel Chen | 46087c3 | 2016-03-21 17:58:14 -0400 | [diff] [blame] | 80 | |
| 81 | ### Command Line |
| 82 | |
| 83 | When you need the presentation to be rendered from the command line: |
| 84 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 85 | ``` bash |
Daniel Chen | 46087c3 | 2016-03-21 17:58:14 -0400 | [diff] [blame] | 86 | Rscript -e "rmarkdown::render('my_reveal_presentation.Rmd')" |
| 87 | ``` |
| 88 | |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 89 | ## Display Modes |
| 90 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 91 | The following single character keyboard shortcuts enable alternate display modes: |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 92 | |
| 93 | - `'f'` enable fullscreen mode |
| 94 | |
| 95 | - `'o'` enable overview mode |
| 96 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 97 | - `'b'` enable pause mode with a black screen hiding slide content |
| 98 | |
| 99 | - `'?'` enable help mode to show keyboard shortcut cheatsheet |
| 100 | |
| 101 | - `'s'` enable presentation mode with speaker notes when the Notes plugin is activated |
| 102 | |
| 103 | - `'m'` enable menu mode when the 'menu' plugin is activated |
| 104 | |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 105 | Pressing `Esc` exits all of these modes. |
| 106 | |
| 107 | ## Incremental Bullets |
| 108 | |
| 109 | You can render bullets incrementally by adding the `incremental` option: |
| 110 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 111 | ``` yaml |
| 112 | --- |
| 113 | output: |
| 114 | revealjs::revealjs_presentation: |
| 115 | incremental: true |
| 116 | --- |
| 117 | ``` |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 118 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 119 | If you want to render bullets incrementally for some slides but not others you can use this syntax: |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 120 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 121 | ``` markdown |
| 122 | ::: incremental |
| 123 | |
| 124 | - Eat spaghetti |
| 125 | - Drink wine |
| 126 | |
| 127 | ::: |
| 128 | ``` |
| 129 | |
| 130 | or |
| 131 | |
| 132 | ``` markdown |
| 133 | ::: nonincremental |
| 134 | |
| 135 | - Eat spaghetti |
| 136 | - Drink wine |
| 137 | |
| 138 | ::: |
| 139 | ``` |
| 140 | |
| 141 | ## Incremental Revealing |
| 142 | |
| 143 | You can also add pauses between content on a slide using `. . .` |
| 144 | |
| 145 | ``` markdown |
| 146 | # Slide header |
| 147 | |
| 148 | Content shown first |
| 149 | |
| 150 | . . . |
| 151 | |
| 152 | Content shown next on the same slide |
| 153 | ``` |
| 154 | |
| 155 | Using Fragments explicitly is also possible |
| 156 | |
| 157 | ``` markdown |
| 158 | # Slide header |
| 159 | |
| 160 | Content shown first |
| 161 | |
| 162 | ::: fragment |
| 163 | Content shown next on the same slide |
| 164 | ::: |
| 165 | ``` |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 166 | |
| 167 | ## Appearance and Style |
| 168 | |
| 169 | There are several options that control the appearance of revealjs presentations: |
| 170 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 171 | - `theme` specifies the theme to use for the presentation (available themes are `r knitr::combine_words(setdiff(revealjs:::revealjs_themes(), "default"), before = '"', and = " or ")` |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 172 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 173 | - `highlight` specifies the syntax highlighting style. Supported styles include `r knitr::combine_words(rmarkdown:::highlighters(), before = '"', and = " or ")`. Pass null to prevent syntax highlighting. |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 174 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 175 | - `center` specifies whether you want to vertically center content on slides (this defaults to false). |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 176 | |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 177 | For example: |
| 178 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 179 | ``` yaml |
| 180 | output: |
| 181 | revealjs::revealjs_presentation: |
| 182 | theme: sky |
| 183 | highlight: pygments |
| 184 | center: true |
| 185 | ``` |
| 186 | |
| 187 | [Revealjs documentation about themes](https://revealjs.com/themes/) |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 188 | |
JJ Allaire | 41921d3 | 2016-01-30 19:11:43 -0500 | [diff] [blame] | 189 | ## Slide Transitions |
| 190 | |
Jon Calder | a35857d | 2017-04-11 16:38:58 +0200 | [diff] [blame] | 191 | You can use the `transition` and `background_transition` options to specify the global default slide transition style: |
JJ Allaire | 41921d3 | 2016-01-30 19:11:43 -0500 | [diff] [blame] | 192 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 193 | - `transition` specifies the visual effect when moving between slides. Available transitions are `r (trans <- knitr::combine_words(setdiff(revealjs:::revealjs_transitions(), "default"), before = '"', and = " or "))`. |
JJ Allaire | 41921d3 | 2016-01-30 19:11:43 -0500 | [diff] [blame] | 194 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 195 | - `background_transition` specifies the background transition effect when moving between full page slides. Available transitions are `r trans` |
JJ Allaire | 41921d3 | 2016-01-30 19:11:43 -0500 | [diff] [blame] | 196 | |
| 197 | For example: |
| 198 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 199 | ``` yaml |
| 200 | output: |
| 201 | revealjs::revealjs_presentation: |
| 202 | transition: fade |
| 203 | background_transition: slide |
| 204 | ``` |
JJ Allaire | 41921d3 | 2016-01-30 19:11:43 -0500 | [diff] [blame] | 205 | |
| 206 | You can override the global transition for a specific slide by using the data-transition attribute, for example: |
| 207 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 208 | ``` markdown |
| 209 | ## Use a zoom transition {data-transition="zoom"} |
| 210 | |
| 211 | ## Use a faster speed {data-transition-speed="fast"} |
| 212 | ``` |
| 213 | |
JJ Allaire | 41921d3 | 2016-01-30 19:11:43 -0500 | [diff] [blame] | 214 | You can also use different in and out transitions for the same slide, for example: |
| 215 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 216 | ``` markdown |
| 217 | ## Fade in, Slide out {data-transition="slide-in fade-out"} |
JJ Allaire | 41921d3 | 2016-01-30 19:11:43 -0500 | [diff] [blame] | 218 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 219 | ## Slide in, Fade out {data-transition="fade-in slide-out"} |
| 220 | ``` |
| 221 | |
| 222 | This works also for background transition |
| 223 | |
| 224 | ``` markdown |
| 225 | ## Use a zoomed background transition {data-background-transition="zoom"} |
| 226 | ``` |
| 227 | |
| 228 | [Revealjs documentation about transitions](https://revealjs.com/transitions/) |
JJ Allaire | 41921d3 | 2016-01-30 19:11:43 -0500 | [diff] [blame] | 229 | |
JJ Allaire | 8382c3e | 2016-01-30 19:04:31 -0500 | [diff] [blame] | 230 | ## Slide Backgrounds |
| 231 | |
| 232 | Slides 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. |
| 233 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 234 | ``` markdown |
| 235 | ## CSS color background {data-background-color=#ff0000} |
| 236 | |
| 237 | ## Full size image background {data-background-image="background.jpeg"} |
| 238 | |
| 239 | ## Video background {data-background-video="background.mp4"} |
| 240 | |
| 241 | ## Embed a web page as a background {data-background-iframe="https://example.com"} |
| 242 | ``` |
| 243 | |
| 244 | Backgrounds 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. |
| 245 | |
| 246 | [Revealjs documentation about backgrounds](https://revealjs.com/backgrounds/) |
JJ Allaire | 8382c3e | 2016-01-30 19:04:31 -0500 | [diff] [blame] | 247 | |
Jon Calder | a35857d | 2017-04-11 16:38:58 +0200 | [diff] [blame] | 248 | ## 2-D Presentations |
JJ Allaire | de1ed65 | 2016-01-30 19:41:18 -0500 | [diff] [blame] | 249 | |
| 250 | You 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: |
| 251 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 252 | ``` markdown |
| 253 | # Horizontal Slide 1 |
JJ Allaire | de1ed65 | 2016-01-30 19:41:18 -0500 | [diff] [blame] | 254 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 255 | ## Vertical Slide 1 |
JJ Allaire | de1ed65 | 2016-01-30 19:41:18 -0500 | [diff] [blame] | 256 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 257 | ## Vertical Slide 2 |
JJ Allaire | de1ed65 | 2016-01-30 19:41:18 -0500 | [diff] [blame] | 258 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 259 | # Horizontal Slide 2 |
| 260 | ``` |
| 261 | |
| 262 | With 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". Global reveal option [`navigationMode`](https://revealjs.com/vertical-slides/#navigation-mode) can be tweaked to change this behavior. |
JJ Allaire | de1ed65 | 2016-01-30 19:41:18 -0500 | [diff] [blame] | 263 | |
JJ Allaire | 5f51424 | 2016-07-12 10:28:23 -0400 | [diff] [blame] | 264 | ## Reveal Options |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 265 | |
JJ Allaire | 064552c | 2017-02-10 10:28:41 -0500 | [diff] [blame] | 266 | Reveal.js has many additional options to configure it's behavior. You can specify any of these options using `reveal_options`, for example: |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 267 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 268 | ``` yaml |
| 269 | --- |
| 270 | title: "Habits" |
| 271 | output: |
| 272 | revealjs::revealjs_presentation: |
| 273 | self_contained: false |
| 274 | reveal_options: |
| 275 | slideNumber: true |
| 276 | previewLinks: true |
| 277 | --- |
| 278 | ``` |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 279 | |
| 280 | You can find documentation on the various available Reveal.js options here: <https://github.com/hakimel/reveal.js#configuration>. |
| 281 | |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 282 | ## Figure Options |
| 283 | |
| 284 | There are a number of options that affect the output of figures within reveal.js presentations: |
| 285 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 286 | - `fig_width` and `fig_height` can be used to control the default figure width and height (7x5 is used by default) |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 287 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 288 | - `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. |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 289 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 290 | - `fig_caption` controls whether figures are rendered with captions |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 291 | |
| 292 | For example: |
| 293 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 294 | ``` yaml |
| 295 | --- |
| 296 | title: "Habits" |
| 297 | output: |
| 298 | revealjs::revealjs_presentation: |
| 299 | fig_width: 7 |
| 300 | fig_height: 6 |
| 301 | fig_caption: true |
| 302 | --- |
| 303 | ``` |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 304 | |
| 305 | ## MathJax Equations |
| 306 | |
| 307 | By 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: |
| 308 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 309 | - Specify "default" to use an https URL from the official MathJax CDN. |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 310 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 311 | - 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. |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 312 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 313 | - Specify an alternate URL to load MathJax from another location. |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 314 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 315 | - Specify null to exclude MathJax entirely. |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 316 | |
| 317 | For example, to use a local copy of MathJax: |
| 318 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 319 | ``` yaml |
| 320 | --- |
| 321 | title: "Habits" |
| 322 | output: |
| 323 | revealjs::revealjs_presentation: |
| 324 | mathjax: local |
| 325 | self_contained: false |
| 326 | --- |
| 327 | ``` |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 328 | |
| 329 | To use a self-hosted copy of MathJax: |
| 330 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 331 | ``` yaml |
| 332 | --- |
| 333 | title: "Habits" |
| 334 | output: |
| 335 | revealjs::revealjs_presentation: |
| 336 | mathjax: "http://example.com/mathjax/MathJax.js?config=TeX-AMS-MML_HTMLorMML" |
| 337 | --- |
| 338 | ``` |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 339 | |
| 340 | To exclude MathJax entirely: |
| 341 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 342 | ``` yaml |
| 343 | --- |
| 344 | title: "Habits" |
| 345 | output: |
| 346 | revealjs::revealjs_presentation: |
| 347 | mathjax: null |
| 348 | --- |
| 349 | ``` |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 350 | |
| 351 | ## Document Dependencies |
| 352 | |
Jon Calder | a35857d | 2017-04-11 16:38:58 +0200 | [diff] [blame] | 353 | By 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 keep dependencies in external files you can specify `self_contained: false`. For example: |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 354 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 355 | ``` yaml |
| 356 | --- |
| 357 | title: "Habits" |
| 358 | output: |
| 359 | revealjs::revealjs_presentation: |
| 360 | self_contained: false |
| 361 | --- |
| 362 | ``` |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 363 | |
| 364 | Note 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`. |
| 365 | |
| 366 | One 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: |
| 367 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 368 | ``` yaml |
| 369 | --- |
| 370 | title: "Habits" |
| 371 | output: |
| 372 | revealjs::revealjs_presentation: |
| 373 | self_contained: false |
| 374 | lib_dir: libs |
| 375 | --- |
| 376 | ``` |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 377 | |
JJ Allaire | 5f51424 | 2016-07-12 10:28:23 -0400 | [diff] [blame] | 378 | ## Reveal Plugins |
JJ Allaire | 82a8dee | 2016-07-12 10:25:36 -0400 | [diff] [blame] | 379 | |
| 380 | You can enable various reveal.js plugins using the `reveal_plugins` option. Plugins currently supported include: |
| 381 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 382 | | Plugin | Description | |
| 383 | |------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------| |
| 384 | | [notes](https://revealjs.com/speaker-view/) | Present per-slide notes in a separate browser window. Open Note view pressing `S`. | |
| 385 | | [zoom](http://lab.hakim.se/zoom-js/) | Zoom in and out of selected content with `Alt+Click.` | |
| 386 | | [search](https://github.com/hakimel/reveal.js/blob/master/plugin/search/search.js) | Find a text string anywhere in the slides and show the next occurrence to the user. Open search box using `CTRL + SHIFT + F`. | |
| 387 | | [chalkboard](https://github.com/rajgoel/reveal.js-plugins/tree/master/chalkboard) | Include handwritten notes within a presentation. Press `c` to write on slides, Press `b` to open a whiteboard or chalkboard to write. | |
| 388 | | [menu](https://github.com/denehyg/reveal.js-menu) | Include a navigation menu within a presentation. Press `m` to open the menu. | |
JJ Allaire | 82a8dee | 2016-07-12 10:25:36 -0400 | [diff] [blame] | 389 | |
| 390 | Note that the use of plugins requires that the `self_contained` option be set to false. For example, this presentation includes both the "notes" and "search" plugins: |
| 391 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 392 | ``` yaml |
| 393 | --- |
| 394 | title: "Habits" |
| 395 | output: |
| 396 | revealjs::revealjs_presentation: |
| 397 | self_contained: false |
| 398 | reveal_plugins: ["notes", "search"] |
| 399 | --- |
| 400 | ``` |
JJ Allaire | 82a8dee | 2016-07-12 10:25:36 -0400 | [diff] [blame] | 401 | |
JJ Allaire | 064552c | 2017-02-10 10:28:41 -0500 | [diff] [blame] | 402 | You can specify additional options for the `chalkboard` and `menu` plugins using `reveal_options`, for example: |
JJ Allaire | 375805c | 2016-11-15 08:56:43 -0500 | [diff] [blame] | 403 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 404 | ``` yaml |
| 405 | --- |
| 406 | title: "Habits" |
| 407 | output: |
| 408 | revealjs::revealjs_presentation: |
| 409 | self_contained: false |
| 410 | reveal_plugins: ["chalkboard", "menu"] |
| 411 | reveal_options: |
| 412 | chalkboard: |
| 413 | theme: whiteboard |
| 414 | toggleNotesButton: false |
| 415 | menu: |
| 416 | side: right |
| 417 | --- |
| 418 | ``` |
JJ Allaire | 375805c | 2016-11-15 08:56:43 -0500 | [diff] [blame] | 419 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 420 | No other plugins can be added in `revealjs_presentation()`. You can open feature request for new plugins or you would need to use a custom template to write your own HTML format including custom plugins. |
JJ Allaire | 375805c | 2016-11-15 08:56:43 -0500 | [diff] [blame] | 421 | |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 422 | ## Advanced Customization |
| 423 | |
| 424 | ### Includes |
| 425 | |
| 426 | You 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: |
| 427 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 428 | ``` yaml |
| 429 | --- |
| 430 | title: "Habits" |
| 431 | output: |
| 432 | revealjs::revealjs_presentation: |
| 433 | includes: |
| 434 | in_header: header.html |
| 435 | before_body: doc_prefix.html |
| 436 | after_body: doc_suffix.html |
| 437 | --- |
| 438 | ``` |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 439 | |
| 440 | ### Pandoc Arguments |
| 441 | |
Jon Calder | a35857d | 2017-04-11 16:38:58 +0200 | [diff] [blame] | 442 | If there are pandoc features you want to use that lack equivalents in the YAML options described above you can still use them by passing custom `pandoc_args`. For example: |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 443 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 444 | ``` yaml |
| 445 | --- |
| 446 | title: "Habits" |
| 447 | output: |
| 448 | revealjs::revealjs_presentation: |
| 449 | pandoc_args: [ |
| 450 | "--title-prefix", "Foo", |
| 451 | "--id-prefix", "Bar" |
| 452 | ] |
| 453 | --- |
| 454 | ``` |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 455 | |
Atsushi Yasumoto | e734cd8 | 2020-08-10 21:48:18 +0900 | [diff] [blame] | 456 | Documentation on all available pandoc arguments can be found in the [pandoc user guide](https://pandoc.org/MANUAL.html#options). |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 457 | |
| 458 | ## Shared Options |
| 459 | |
Jon Calder | a35857d | 2017-04-11 16:38:58 +0200 | [diff] [blame] | 460 | If 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 delimiters or enclosing output object are used in this file. For example: |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 461 | |
| 462 | **\_output.yaml** |
| 463 | |
Christophe Dervieux | e1893ae | 2021-10-07 17:09:02 +0200 | [diff] [blame] | 464 | ``` yaml |
JJ Allaire | 5dc9fe0 | 2016-01-30 18:44:51 -0500 | [diff] [blame] | 465 | revealjs::revealjs_presentation: |
| 466 | theme: sky |
| 467 | transition: fade |
| 468 | highlight: pygments |
| 469 | ``` |
| 470 | |
| 471 | All 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. |
Christophe Dervieux | 7f1add5 | 2021-09-15 15:42:07 +0200 | [diff] [blame] | 472 | |
| 473 | ## Code of Conduct |
| 474 | |
| 475 | Please note that the revealjs project is released with a [Contributor Code of Conduct](https://pkgs.rstudio.com/revealjs/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms. |