Template Edits Breaking Powerpoint Created in RMarkdown

I'm having problems extremely similar to this thread; using template file to generate powerpoint slides via R Markdown - R Markdown - Posit Forum (formerly RStudio Community)

Essentially, I would like to use RMarkdown to create a PowerPoint presentation with a custom template. However, every time I add a reference_doc: rmarkdown produces a PowerPoint that is unreadable (and unrepairable). I have made sure that the template slides are named correctly; this does not help.

The only time this does not occur is when I use the alison_template from apreshill's rmd2ppt templates on GitHub ( rmd2ppt/templates at main · apreshill/rmd2ppt · GitHub, but any edit I make to the template (e.g. changing font colors) results in an unreadable PowerPoint again.

My code looks like this:

---
date: "`r Sys.Date()`"
author: "Your Name"
title: "Untitled"
output: 
  officedown::rpptx_document:
    reference_doc: alison-template.pptx
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, fig.cap = TRUE)
library(officedown)
library(ggplot2)
library(rvg)
```

## Table

```{r layout='Two Content', ph=officer::ph_location_left()}
head(cars)
```

```{r layout='Two Content', ph=officer::ph_location_right()}
head(iris)
```

## Slide with Plot

```{r plot1}
dml(plot(pressure))
```

The same issue occurs when I use powerpoint_presentation: instead of officedown::rpptx_document:.

Could anyone give me an idea of what the issue could be or how to continue troubleshooting?

My R Markdown version is 2.20, and all files are local.

Is this an old reference doc ? How was it built ? In short, Pandoc expect the reference doc to be a certain doc and best is to use one produced by Pandoc already.

What version of Pandoc are you using ? rmarkdown::pandoc_version() ?

I wonder if their could be an upgrade in Pandoc and somehow it requires a new template file.

Possibly template in rmd2ppt are outdated (they are two years old) or they are not used with a correct Pandoc version.

I would try to regenerate a good template for your Pandoc version. Best way to build a template that works with R Markdown and Pandoc:

  • Either by build a PPTX with Rmardown and using that file as a template after
  • Either export default reference doc from Pandoc and use that file. pandoc has new help for this (pandoc::pandoc_export_reference_doc("pptx") - use version = argument that match the pandoc version you are using with rmarkdown (or use version = "rstudio" if this is the bundled version you are using ) - see doc Manage and Run Universal Converter Pandoc from R • pandoc

Hope it helps

1 Like

Hi @cderv,
Thanks so much for your response! Due to time constraints, I ended up creating my PPT using the officer package, which played much better with the template I had to use.

I really appreciate your help and hope someone else is able to use this advice in the future!

1 Like

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.