With beamer frames, this does not work.
\newenvironment{itemframe}[1]{
\begin{frame}{#1}
\begin{itemize}
}{
\end{itemize}
\end{frame}
}
Adding fragile, environment=itemframe
as an optional argument to the frame will solve the issue. But there is also an alternative that avoids making the frame fragile: Exporting everything apart from the frame environments to own commands.
\documentclass{beamer}
\usepackage{xparse}
\newenvironment{itemframe}[1]{
%\NewDocumentEnvironment{itemframe}{m}{
\begin{frame}{#1}
\itemframebegin
}{
\itemframeend
\end{frame}
}
\newcommand\itemframebegin{
\begin{itemize}
}
\newcommand\itemframeend{
\end{itemize}
}
\begin{document}
\begin{itemframe}{Title}
\item A
\item B
\item C
\end{itemframe}
\end{document}
Now when \newenvironment
is replaced with \NewDocumentEnvironment
from the xparse
package, as shown as a comment above, both solutions again fail with
! File ended while scanning use of \beamer@collect@@body.
Is there a possibility to make a \NewDocumentEnvironment
including a frame
? Avoiding the fragile option is preferred.
\end{frame}
hidden in a macro.\NewDocumentEnvironment
seem to play bad with\beamer@collect@@body
. But what's the gain in defining such an environment? I can't see any.