4.4 PowerPoint presentation

To create a PowerPoint presentation from R Markdown, you specify the powerpoint_presentation output format in the YAML metadata of your document. Please note that this output format is only available in rmarkdown >= v1.9, and requires at least Pandoc v2.0.5. You can check the versions of your rmarkdown package and Pandoc with packageVersion('rmarkdown') and rmarkdown::pandoc_version() in R, respectively. The RStudio version 1.1.x ships Pandoc 1.19.2.1, which is not sufficient to generate PowerPoint presentations. You need to either install Pandoc 2.x by yourself if you use RStudio 1.1.x, or install a preview version of RStudio (>= 1.2.633), which has bundled Pandoc 2.x.

Below is a quick example (see Figure 4.5 for a sample slide):

---
title: "Habits"
author: John Doe
date: March 22, 2005
output: powerpoint_presentation
---

# In the morning

## Getting up

- Turn off alarm
- Get out of bed

## Breakfast

- Eat eggs
- Drink coffee

# In the evening

## Dinner

- Eat spaghetti
- Drink wine

---

```{r, cars, fig.cap="A scatterplot.", echo=FALSE}
plot(cars)
```

## Going to sleep

- Get in bed
- Count sheep
A sample slide in a PowerPoint presentation.

FIGURE 4.5: A sample slide in a PowerPoint presentation.

The default slide level (i.e., the heading level that defines individual slides) is determined in the same way as in Beamer slides (Section 4.3.2), and you can specify an explicit level via the slide_level option under powerpoint_presentation. You can also start a new slide without a header using a horizontal rule ---.

You can generate most elements supported by Pandoc’s Markdown (Section 2.5) in PowerPoint output, such as bold/italic text, footnotes, bullets, LaTeX math expressions, images, and tables, etc.

Please note that images and tables will always be placed on new slides. The only elements that can coexist with an image or table on a slide are the slide header and image/table caption. When you have a text paragraph and an image on the same slide, the image will be moved to a new slide automatically. Images will be scaled automatically to fit the slide, and if the automatic size does not work well, you may manually control the image sizes: for static images included via the Markdown syntax ![](), you may use the width and/or height attributes in a pair of curly braces after the image, e.g., ![caption](foo.png){width=40%}; for images generated dynamically from R code chunks, you can use the chunk options fig.width and fig.height to control the sizes.

Please read the section “Producing slide shows with Pandoc” in Pandoc’s manual for more information on slide shows, such as the multi-column layout:

:::::: {.columns}
::: {.column}
Content of the left column.
:::

::: {.column}
Content of the right column.
:::
::::::

4.4.1 Custom templates

Like Word documents (Section 3.4), you can customize the appearance of PowerPoint presentations by passing a custom reference document via the reference_doc option, e.g.,

---
title: "Habits"
output:
  powerpoint_presentation:
    reference_doc: my-styles.pptx
---

Note that the reference_doc option requires a version of rmarkdown higher than 1.9:

if (packageVersion('rmarkdown') <= '1.9') {
  install.packages('rmarkdown')  # update rmarkdown from CRAN
}

Basically any template included in a recent version of Microsoft PowerPoint should work. You can create a new *.pptx file from the PowerPoint menu File -> New with your desired template, save the new file, and use it as the reference document (template) through the reference_doc option. Pandoc will read the styles in the template and apply them to the PowerPoint presentation to be created from R Markdown.

4.4.2 Other features

Refer to Section 3.1 for the documentation of other features of PowerPoint presentations, including table of contents (Section 3.1.1), figure options (Section 3.1.5), data frame printing (Section 3.1.6), keeping Markdown (Section 3.1.10.1), Markdown extensions (Section 3.1.10.4), Pandoc arguments (Section 3.1.10.5), shared options (Section 3.1.11), and incremental slides since Pandoc 2.15 (Section 4.1.2.