I would like to create a command that ends a beamer frame. However, this leads to the error message quoted below - probably due to the same problem that prevents indentation of frame commands, cf. Indenting \end{frame} in fragile slides.
The error message is: ! File ended while scanning use of \next.
Below is a failing MWE that can be made working by commenting out \end{frame} in the definition of \pfooter plus uncommenting it at the bottom.
\documentclass[english,10pt]{beamer}
\usepackage{listings}
\newcommand{\pheader}[1]{%
\section{bla: blabla}
\begin{frame}[fragile]{blabla}
}
\newcommand{\pfooter}{\end{frame}
% some other commands
}
\begin{document}
\pheader{}
\begin{lstlisting}[gobble=4]
1234567890
\end{lstlisting}
bla
\pfooter{}
% \end{frame}
\end{document}
\end{frame}. There are ways around, most of the time they cause more problems than they solve, so please don't do this. – samcarter_is_at_topanswers.xyz Sep 09 '16 at 10:52