# Allow theorem split in many frames in beamer

How can a theorem-like environment be (automatically) split into multiple frames if the vertical space it needs is not enough in a frame?

In my document preamble I have

\theoremstyle{definition}
\newtheorem{exercise}{Exercício}


And a given frame in the document has an exercise environment which does not fit into a single frame. So I want it split in more frames.

Any clues?

-
I don't know how easy this is to do. Is there a way to rewrite the exercise so that it fits on one frame? You can use an overprint or overlayarea environment to have the content of the box change from slide to slide. –  Matthew Leingang Apr 2 '12 at 13:43

Since the theorem-like structures use a beamercolorbox, using allowframebreaks option directly won't work in this case. A workaround would be to "simulate" your theorem-like heading with a beamercolorbox and then write the text outside the box with the allowframebreaks option:

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}

\begin{document}

\begin{frame}[allowframebreaks=0.8]

Exercício
\end{beamercolorbox}{}
\lipsum[1-2]
\end{frame}

\end{document}


-

Generally you can use the beamer option allowframebreaks to split a frame automatically if its content doesn't fit on one frame:

\begin{frame}[allowframebreaks]
...
\end{frame}


Sadly, this doesn't work for theorem-like environments, the reason being that these are typeset using a beamercolorbox by default. The contents of a beamercolorbox are gathered in one single box which can't be split across frames.

I only see two possibilities to overcome this at the moment:

1. Make the theorem environments not use a beamercolorbox for the content. This can be done by redefining the beamer templates theorem begin and theorem end:

\documentclass{beamer}
\theoremstyle{definition}
\newtheorem{exercise}{Exercício}
\setbeamertemplate{theorem begin}
{%
\par\vskip\medskipamount%
\begin{beamercolorbox}[colsep*=.75ex]{block title}
\usebeamerfont*{block title}%
\inserttheoremname
\end{beamercolorbox}%
{\parskip0pt\par}%
\ifbeamercolorempty[bg]{block title}
{}
{\ifbeamercolorempty[bg]{block body}{}{\nointerlineskip\vskip-0.5pt}}%
\usebeamerfont{block body}%
\vskip-.25ex\vbox{}%
}
\setbeamertemplate{theorem end}{}
\usepackage{lipsum}
\begin{document}
\begin{frame}[allowframebreaks]
\begin{exercise}
\lipsum[1]
\lipsum[2]
\end{exercise}
\end{frame}
\end{document}


(The lipsum is for creating dummy text, you can remove it and replace it with your own content.)

Note however, that this may considerably change the look of your theorems if you use a theme that has a colored background for theorems. For sober themes like the default one or Montpellier it should be perfectly fine.

2. You can manually issue the frame breaks. To do this, define a new macro \theorembreak that ends the current beamercolorbox, starts a new frame and a new beamercolorbox:

\documentclass{beamer}
\theoremstyle{definition}
\newtheorem{exercise}{Exercício}
\newcommand*{\theorembreak}{\usebeamertemplate{theorem end}\framebreak\usebeamertemplate{theorem begin}}
\usepackage{lipsum}
\begin{document}
\begin{frame}[allowframebreaks]
\begin{exercise}
\lipsum[1]
\theorembreak
\lipsum[2]
\end{exercise}
\end{frame}
\end{document}


This has the advantage that you can keep the exact style of your theorems, but forces you to do the breaking manually.

-
The first option is very similar to Gonzalo's solution. –  diabonas Apr 2 '12 at 14:25
Very nice, the 1st solution can be applied easily. One note (without checking for generality) regarding \theorembreak: for me it worked only once, so I could not devide the theorem in more than two parts with that command. –  matheburg Aug 7 at 12:42