I just spent an hour trying to get rmarkdown:beamer_presentation
to display a PNG image that fills the whole slide, i.e. without any white borders. The use case is having a regular beamer
presentation with bulleted slides that have titles, sections etc, but having some slides in my presentation that only contain a full screen image or photo.
Using the example code duck.Rmd
below (I used google to search for a duck.png image) I managed to eliminate three of the four white borders, leaving only the left border:
---
title: "Duck"
author: "Gertjan Verhoeven"
date: "3/6/2022"
output: beamer_presentation
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
---
\includegraphics[width=\paperwidth, height=\paperheight]{duck.png}}
Knitting this file to PDF (Beamer) in Rstudio with TeX installed gives me this slide:
Any idea what to do to completely remove all white borders and stretch the image to completely cover the slide? While staying in the Rstudio / Knit to PDF (Beamer) / rmarkdown::beamer_presentation
framework?
With normal beamer, I would change the background canvas for the specific frame and add the picture there. However doing this is a bit tricky in rmarkdown, so I suggest to use TikZ instead (maybe add an empty frametitle #
in front of the tikzpicture if the slide before goes missing):
---
title: "Duck"
author: "Gertjan Verhoeven"
date: "3/6/2022"
output:
beamer_presentation:
keep_tex: true
header-includes:
- \usepackage{tikz}
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
#
\begin{tikzpicture}[remember picture, overlay]
\node at (current page.center) {\includegraphics[width=\paperwidth, height=\paperheight]{example-image-duck}};
\end{tikzpicture}
# next frame
test