5
votes

I'm trying to transfer a LaTeX/LyX presentation into a Beamer markdown document.

On some slides I suspend the background image (which has logos of funding bodies on it) to make more space for code output.

I previously did this with the following command:

\bgroup
\usebackgroundtemplate{\includegraphics[width=\paperwidth]{background.png}}
\begin{frame}[plain]
Some text here!}
\end{frame}
\egroup

I have tried something like this (which doesn't work):

\bgroup
\pgfdeclareimage[width=\paperwidth]{empty}{Template_blank.png}
\usebackgroundtemplate{\pgfuseimage{empty}}

## New Slide

some text
\egroup

Any ideas?

1

1 Answers

0
votes

Normally switching between different background templates is a piece of cake in beamer, based on https://tex.stackexchange.com/questions/173201/beamer-template-with-different-style-options-for-frames one can simply create a new frame option.

Unfortunately rmarkdown simply ignores user created frame options and only passes on a tiny list of predefined options. To trick rmarkdown one could repurpose a frame option which is normally not used by beamer, the standout frame option (it is only used by the metropolis theme)

---
output: 
  beamer_presentation:
    keep_tex: true
    includes:
      in_header: preamble.tex
---

# frametitle 

test

# frametitle with different background {.standout}

test

# frametitle

test

and preamble.tex

\usepackage{etoolbox}

\defbeamertemplate{background canvas}{mydefault}{%
  \includegraphics[width=\paperwidth,height=\paperheight]{example-image-b}
}
\defbeamertemplate{background canvas}{standout}{%
  \includegraphics[width=\paperwidth,height=\paperheight]{example-image-a}
}

\BeforeBeginEnvironment{frame}{%
  \setbeamertemplate{background canvas}[mydefault]%
}

\makeatletter
\define@key{beamerframe}{standout}[true]{%
  \setbeamertemplate{background canvas}[standout]%
}
\makeatother

enter image description here