Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
1  
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
add comment

2 Answers

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]

\begin{beamercolorbox}{section in head/foot}
Exercício
\end{beamercolorbox}{}
\lipsum[1-2]
\end{frame}

\end{document}

enter image description here

share|improve this answer
add comment

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
          \ifx\inserttheoremaddition\empty\else\ (\inserttheoremaddition)\fi%
      \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}
    

    manual framebreak for a theorem (using the beamer theme Ilmenau)

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

share|improve this answer
    
The first option is very similar to Gonzalo's solution. –  diabonas Apr 2 '12 at 14:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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