4.1 ioslides presentation
To create an ioslides presentation from R Markdown, you specify the ioslides_presentation
output format in the YAML metadata 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 is a simple slide show (see Figure 4.1 for two sample slides):
The character # at the beginning of a line means that the rest of the line is interpreted as a section header. The number of #s at the beginning of the line indicates whether it is treated as a section, sub-section, sub-sub-section, etc. Of the document.For instance, Basic Formatting in R Markdown above is preceded by a single #, but Headers at the start of this paragraph was preceded. This saves a version of your RMD file that already has data pre-loaded and will open much faster than re-loading data every time you want to knit the file. 5 MARKDOWN FORMATTING RULES. Examples taken from Adam Pritchard’s Markdown Cheatsheet. 6.4 Cheat Sheet. R Markdown Cheat Sheet. Open a new.Rmd file at File New File R Markdown. Use the wizard that opens to pre-populate the file with a template 1 Write document 2 by editing template Spell Check Publish Show outline Knit document to create report.
FIGURE 4.1: Two sample slides in an ioslides presentation.
You can add a subtitle to a slide or section by including text after the pipe (|
) character. For example:
4.1.1 Display modes
The following single character keyboard shortcuts enable alternate display modes:
'f'
: enable fullscreen mode'w'
: toggle widescreen mode'o'
: enable overview mode'h'
: enable code highlight mode'p'
: show presenter notes
Markdown Syntax Cheat Sheet
Pressing Esc
exits all of these modes. See the sections below on Code Highlighting and Presenter Mode for additional detail on those modes.
4.1.2 Incremental bullets
You can render bullets incrementally by adding the incremental
option:
If you want to render bullets incrementally for some slides but not others you can (ab)use this syntax for blockquotes:
4.1.3 Visual appearance
4.1.3.1 Presentation size
You can display the presentation using a wider form factor using the widescreen
option. You can specify that smaller text be used with the smaller
option. For example:
You can also enable the smaller
option on a slide-by-slide basis by adding the .smaller
attribute to the slide header:
4.1.3.2 Transition speed
You can customize the speed of slide transitions using transition
option. This can be 'default'
, 'slower'
, 'faster'
, or a numeric value with a number of seconds (e.g., 0.5
) . For example:
4.1.3.3 Build slides
Slides can also have a .build
attribute that indicate that their content should be displayed incrementally. For example:
Slide attributes can be combined if you need to specify more than one. For example:
4.1.3.4 Background images
You can specify a background image for a slide using the attribute data-background
, and use other attributes including data-background-size
, data-background-position
, and data-background-repeat
to tweak the style of the image. You need to be familiar with CSS to fully understand these four attributes, and they correspond to the CSS propertiesbackground
, background-size
, background-position
, and background-repeat
, respectively. For example:
4.1.3.5 Custom CSS
You can add your own CSS to an ioslides presentation using the css
option:
You can also target specific slides or classes of slides with custom CSS by adding IDs or classes to the slides headers within your document. For example the following slide header:
Would enable you to apply CSS to all of its content using either of the following CSS selectors:
4.1.4 Code highlighting
It is possible to select subsets of code for additional emphasis by adding a special “highlight” comment around the code. For example:
The highlighted region will be displayed with a bold font. When you want to help the audience focus exclusively on the highlighted region press the h
key and the rest of the code will fade away.
4.1.5 Adding a logo
Markup Language Cheat Sheet
You can add a logo to the presentation using the logo
option (by default, the logo will be displayed in a 85x85 pixel square). For example:
The logo graphic will be rescaled to 85x85 (if necessary) and added to the title slide. A smaller icon version of the logo will be included in the bottom-left footer of each slide.
The logo on the title page and the rectangular element containing it can be customised with CSS. For example:
These selectors are to be placed in the CSS text file.

Similarly, the logo in the footer of each slide can be resized to any desired size. For example:
This will make the footer logo 150 by 75 pixels in size.
4.1.6 Tables
The ioslides template has an attractive default style for tables so you should not hesitate to add tables for presenting more complex sets of information. Pandoc Markdown supports several syntaxes for defining tables, which are described in the Pandoc Manual.
4.1.7 Advanced layout
You can center content on a slide by adding the .flexbox
and .vcenter
attributes to the slide title. For example:
You can horizontally center content by enclosing it in a div
tag with class centered
. For example:
You can do a two-column layout using the columns-2
class. For example:
Markdown Cheatsheet Pdf
Note that content will flow across the columns so if you want to have an image on one side and text on the other you should make sure that the image has sufficient height to force the text to the other side of theslide.
4.1.8 Text color
You can color content using base color classes red
, blue
, green
, yellow
, and gray
(or variations of them, e.g., red2
, red3
, blue2
, blue3
, etc.). For example:
4.1.9 Presenter mode
R Markdown Tutorial
A separate presenter window can also be opened (ideal for when you are presenting on one screen but have another screen that is private to you). The window stays in sync with the main presentation window and also shows presenter notes and a thumbnail of the next slide. To enable presenter mode add ?presentme=true
to the URL of the presentation. For example:
R Markdown Cheat Sheet
The presenter mode window will open and will always re-open with the presentation until it is disabled with:
To add presenter notes to a slide, you include it within a “notes” div
. For example:
4.1.10 Printing and PDF output
Rmd Cheat Sheet
You can print an ioslides presentation from within browsers that have good support for print CSS (as of this writing, Google Chrome has the best support). Printing maintains most of the visual styles of the HTML version of the presentation.
To create a PDF version of a presentation, you can use the menu Print to PDF
from Google Chrome. Alternatively, you can use the function pagedown::chrome_print()
from the pagedown package (Xie et al. 2021), which calls Chrome to print an Rmd or HTML file to PDF.
Rmd File
4.1.11 Custom templates
You can replace the underlying Pandoc template using the template
option:
However, please note that the level of customization that can be achieved is limited compared to the templates of other output formats, because the slides are generated by custom formatting written in Lua, and as such the template used must include the string RENDERED_SLIDES
as can be found in the default template file with the path rmarkdown:::rmarkdown_system_file('rmd/ioslides/default.html')
.
4.1.12 Other features
Refer to Section 3.1 for the documentation of other features of ioslides presentations, including figure options (Section 3.1.5), MathJax equations (Section 3.1.8), data frame printing (Section 3.1.6), Markdown extensions (Section 3.1.10.4), keeping Markdown (Section 3.1.10.1), document dependencies (Section 3.1.9), header and before/after body inclusions (Section 3.1.10.2), Pandoc arguments (Section 3.1.10.5), and shared options (Section 3.1.11).
Rmd file anatomy: Text
The R Markdown file is a text file where you save all the R commands you want to use, plus any text commenting on the work you are doing and the results you get. Parts of the file with a plain white background are normal text.
You can format the text. For example, enclosing a word in asterisks will generate italics, so *my text* in the Rmd file will become my text in the PDF. Using two asterisks instead of one will generate boldface, so **my text** becomes my text. You can also make bulleted lists, numbered lists, section headers, and more. For example,
### Some Text
becomes
Some Text
(a sub-section header). Fewer hashtags make the text even larger, and more make it smaller.
Check out the R Markdown cheat sheet https://github.com/rstudio/cheatsheets/raw/master/rmarkdown-2.0.pdf for more examples.
For instructions on how to include R output and special characters (symbols, subscripts, etc.) in your text, see the document in the “Links and Resources” section of the course Moodle site.
Before moving on, try a few of the tricks you just learned in your Rmd file. Make it pretty!
