# beamer, verbatim, and \end{frame}

as of current TL2018 a minimal beamer/verbatim file containing a line \end{frame} in the verbatim code fails to compile:

\documentclass{beamer}
\usepackage{fancyvrb}
\begin{document}
\begin{frame}[fragile]
\begin{verbatim}
\documentclass{beamer}
\begin{document}
\begin{frame}{My first slide}
Hello World
\end{frame}
\end{document}
\end{verbatim}
Hello
\end{frame}
\end{document}


If I comment the \end{frame} line in the verbatim block all is fine.

The error is

Runaway argument?
^^M\documentclass{beamer}^^M\begin{document}^^M\begin{frame}{My first\ETC.
! File ended while scanning use of \@xverbatim.
<inserted text>
\par
l.10 \end{frame}

• Yes ... and? Do you want a work-round (basically using the ability to call the 'real' slide environment something else). – Joseph Wright Feb 27 '19 at 15:03
• It's really hackish, but you could trick beamer into ignoring the first \end{frame} by adding something after it, like an ASCII tab, which wouldn't show in the output. – Phelype Oleinik Feb 27 '19 at 15:12
• Note I've had various issues in this area as the common case of e.g. allowing indented frames in general can conflict with convenience for beamer demos. – Joseph Wright Feb 27 '19 at 15:14

Nesting frames for documenting beamer itself is of course a somewhat special case. Here, you can use the ability to create an 'alternative name' environment.

\documentclass{beamer}
\newenvironment{slide}{\begin{frame}[fragile,environment=slide]}{\end{frame}}
\begin{document}
\begin{slide}
\begin{verbatim}
\documentclass{beamer}
\begin{document}
\begin{frame}{My first slide}
Hello World
\end{frame}
\end{document}
\end{verbatim}
Hello
\end{slide}
\end{document}

• Thanks, this indeed works. But the above code was working at least about a year ago - I was reusing a presentation I had and suddenly it stopped compiling. So it is a regression ;-) Anyway, thanks for the quick fix. – norbert Feb 27 '19 at 15:25
• @norbert Not a regression, rather a change where I had to make a choice. Allowing indented frames in general meant breaking the very special case of beamer slides about beamer slides. – Joseph Wright Feb 27 '19 at 15:27
• Thanks for the explanation, but what do you mean with "indented frames"? Does it mean that the final \end{verbatim} now can be indented arbitrarily and doors not need to start at the first column? – norbert Feb 28 '19 at 8:30