5

While preparing my lectures with beamer, I often find myself having to split a frame into two different ones. For instance, a first version of my slides contains:

\begin{frame}
  \begin{block}{Theorem}
    Blah, blah, blah
  \end{block}
  \begin{block}{Corollary}
    Etc, etc, etc
  \end{block}
\end{frame}

When I complete my slides and add the proofs to these results, I must split it into two different frames

\begin{frame}
  \begin{block}{Theorem}
    Blah, blah, blah
  \end{block}
  \begin{block}{Proof}
    Blah, blah, blah
  \end{block}
\end{frame}

\begin{frame}
  \begin{block}{Corollary}
    Etc, etc, etc
  \end{block}
  \begin{block}{Proof}
    Etc, etc, etc
  \end{block}
\end{frame}

I think that it would be very helpful I if could simply define a command to close and then open the frame environment:

\def\newframe{ \end{frame} \begin{frame} }

\begin{frame}
  \begin{block}{Theorem}
    Blah, blah, blah
  \end{block}
  \begin{block}{Proof}
    Blah, blah, blah
  \end{block}

  \newframe

  \begin{block}{Corollary}
    Etc, etc, etc
  \end{block}
  \begin{block}{Proof}
    Etc, etc, etc
  \end{block}
\end{frame}

However, this approach does not work. Does anyone know if there is any way to define such a command?

5
  • 2
    Welcome to TeX.SX! frame is not really like normal LaTeX environments. Beamer determines the contents of a frame by finding what's between \begin{frame} and \end{frame}; with \newframe it wouldn't see the implied \end{frame}, which would show up only when \newframe is "executed" (and probably give errors).
    – egreg
    Commented Oct 3, 2012 at 9:30
  • beamer provides \framebreak in collaboration with the allowframebreaks option to the frame environment, but it breaks overlay support. Commented Oct 3, 2012 at 11:53
  • Thank you for your comments. Unfortunately, I use tikz in my slides, and hence I have to make my frames fragile. This seems to break the \framebreak option... I'll close and open the environment manually. Commented Oct 4, 2012 at 12:42
  • Try if you can use a keyboard shortcut in your editor that inserts \begin{frame} \end{frame} for you (preferably with a line break inbetween). This way your code becomes clearer. Commented Oct 5, 2012 at 7:24
  • Thanks Hendrik, I can indeed make such a shortcut (I use emacs, so no problem about that), but I wanted a solution more TeXnical ;) Commented Oct 7, 2012 at 15:17

1 Answer 1

3

There is no way to define a macro that issues \end{frame}\begin{frame} in beamer.

This is because frame is a very peculiar environment: when beamer finds \begin{frame} it looks for the next \end{frame} and stores in memory the entire contents without expanding macros; the macro expansion will take place later, when the frame contents will be processed. Such a way to proceed is necessary, because the contents needs to be processed many times, one for each slide in the frame.

Thus \end{frame} must appear explicitly, not hidden in a macro; if you use \newframe defined as

\def\newframe{ \end{frame} \begin{frame} }

the \end{frame} will appear when LaTeX is already processing a frame, where \end{frame} and \begin{frame} mean nothing: so an error will be raised.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .