# Latex beamer verbatim problem with \end{frame} in TeXLive 2017

The following MWE does not compile with beamer 2017/07/13 v3.42 from TeXLive 2017-20170807:

\documentclass{beamer}

\begin{document}
\begin{frame}[fragile]
\begin{verbatim}
\end{frame}
\end{verbatim}
\end{frame}
\end{document}


The problem only occurs when \end{frame} is used within the verbatim environment, despite the use of [fragile]. A different text does not cause the problem. The error produced by lualatex is the following:

Runaway argument?
! File ended while scanning use of \@xverbatim.


However, an older version (e.g. 3.36) of latex beamer from TeXLive 2016-20160801 does compile the MWE correctly without errors.

Further investigation showed that it looks like a regression from commit 0c387de (Fix for github issue #326).

• This only used to work in an old version by accident because scanning for \end{frame} in a fragile slide was broken. – Henri Menke Aug 10 '17 at 23:41

beamer just scans ahead for \end{frame}, so you cannot use \end{frame} inside verbatim inside a frame. This is also documented:

But there is a workaround, which is also documented:

\documentclass{beamer}

\newenvironment{fragileframe}%
{\begin{frame}[fragile,environment=fragileframe]}%
{\end{frame}}

\begin{document}
\begin{fragileframe}
\begin{verbatim}
\end{frame}
\end{verbatim}
\end{fragileframe}
\end{document}

• Thanks for the clarification. The accidental support of older versions was a bit misleading and I didn't look into that direction to find a solution. – Herr Foerster Aug 10 '17 at 23:56