Background
I have tried modifying the PowerPoint template to include three content blocks as following:
According to this RStudio Support article, I don't think you're allowed to change the slide masters in the PPTX template because:
The template should contain the following four layouts as its first four layouts [...]
It then specifically lists the slide master layouts as:
Title. Has placeholders for a title and a subtitle. Used for information in the YAML header.
Title and Content. Has placeholders for title and content. Used for headers at the slide level.
Section Header. Has a placeholder for a section header – content will not render on this layout. Used for headers above the slide level.
Two Content. Has placeholders for title and two content. Used for headers at the slide level with content in columns.
Your custom master seems to violate the "two content" format as you have 3 content blocks. (Not only that, but from my experimentation even changing the box sizes in the master slide of a template messes up how the content is inserted.) I think the:
:::::::::::::: {.columns}
::: {.column}
:::
::: {.column}
:::
::::::::::::::
Syntax only works for 2 columns, not 3 like you have.
R Markdown solution for including multiple figures in one column of a 2-column slide in PowerPoint output
If you want to stay in an R Markdown workflow without using officer
, a very easy way to include multiple ggplot2
plots in a single image is to use the recent patchwork
package, and then add the combined plot chunk into one of the columns:
---
output:
powerpoint_presentation:
slide_level: 2 # h1 makes a new section slide, h2 makes a new slide
reference_doc: template.pptx
---
```{r setup, echo=FALSE, message=FALSE}
knitr::opts_chunk$set(
echo = F,
warning = F,
message = F
)
library(tidyverse)
library(patchwork)
```
## Define some plots
```{r, echo=TRUE}
p1 <- ggplot(mtcars) +
geom_point(aes(mpg, disp)) +
ggtitle('Plot 1')
p2 <- ggplot(mtcars) +
geom_boxplot(aes(gear, disp, group = gear)) +
ggtitle('Plot 2')
p3 <- ggplot(mtcars) +
geom_point(aes(hp, wt, colour = mpg)) +
ggtitle('Plot 3')
p4 <- ggplot(mtcars) +
geom_bar(aes(gear)) +
facet_wrap(~cyl) +
ggtitle('Plot 4')
```
## Plot text bullets in 1st column and 4 plots in 2nd column
::::::::: {.columns}
::: {.column}
- here is some text
- in the left column
- to describe the plots
- in the right column
:::
::: {.column}
```{r, fig.width=6, fig.height=4, fig.cap="This is the caption for the figure."}
# Adjust figure dimensions in chunk options
# use layout syntax form the 'patchwork' package
p1 + p2 + p3 + p4 # keeps square arrangement by default
```
:::
:::::::::