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