1

I'm developing a large set of slides. Some of the slides are about additional material.
These should have a different background color and maybe a little logo to visually stand out.
To not repeat bg and logo many times and also to be able to adapt all of those additional frames at once, I'm thinking of a custom command / environment.

I already found how I can customize the frame environment at https://tex.stackexchange.com/a/224679/71672.
However, I need the fragile option \begin{frame}[fragile]{slide title} because of verbatim knitr outputs.
With the (naive?) code below, I get errors
! Argument of \beamer@processframefirstline has an extra }.
! Paragraph ended before \beamer@processframefirstline was complete.
! Extra }, or forgotten \endgroup.
! LaTeX Error: \begin{myframe} on input line 18 ended by \end{document}.

Is the fragile option somehow possible with the referenced answer?
Should I maybe consider a different approach?

\documentclass{beamer}
\usepackage{environ}

\NewEnviron{myframe}[1][]{%
{\setbeamercolor{background canvas}{bg=yellow}
\begin{frame}[fragile]{#1}
\BODY
\end{frame}
}}

\begin{document}
\begin{frame}[fragile]
\frametitle{first slide}
regular
\end{frame}

\begin{myframe}[some title]
myframe with different bg and maybe also an image
\end{myframe}

\begin{frame}{outro}
regular again
\end{frame}

\end{document}

1 Answer 1

3

Use environment=myframe option:

\documentclass{beamer}

\newenvironment{myframe}[1]{%
\setbeamercolor{background canvas}{bg=yellow}
\begin{frame}[environment=myframe,fragile]{#1}
}{
\end{frame}
}

\begin{document}
\begin{frame}[fragile]
\frametitle{first slide}
regular
\end{frame}

\begin{myframe}{some title}
myframe with different bg and maybe also an image
\end{myframe}

\begin{frame}{outro}
regular again
\end{frame}

\end{document}

enter image description here

1
  • thanks so much!!! Works like a charm
    – Berry
    Jul 19, 2021 at 18:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .