10

I would like to change text distribution within each frame in my presentation beamer, I tried to use \newenvironment but every time I get an error:

File ended while scanning use of \beamer@collect@@body

my MWE :

\documentclass{beamer}
\usepackage{lipsum}

\newenvironment{myframe}{\begin{frame}{test}
\begin{minipage}{\textwidth}}{\end{minipage}
\end{frame}}

\begin{document}
\begin{frame}{test}
\begin{minipage}{0.7\textwidth}
\lipsum[1]
\end{minipage}
\end{frame}

\begin{myframe}
\lipsum[1]
\end{myframe}

\end{document}

Is there a solution to the problem?

11

The package environ is handy in such situations. Here is how it looks:

\documentclass{beamer}
\usepackage{lipsum}
\usepackage{environ}

\NewEnviron{myframe}[1][]{%
\begin{frame}{#1}
\begin{minipage}{\textwidth}
\BODY
\end{minipage}
\end{frame}
}

\begin{document}
\begin{frame}{test}
\begin{minipage}{\textwidth}
\lipsum[1]
\end{minipage}
\end{frame}

\begin{myframe}[Test]
\lipsum[2]
\end{myframe}

\begin{myframe}
\lipsum[2]
\end{myframe}

\end{document}

enter image description here

I have made the frame title optional in the new environment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.