5

See the following code. The first two frame contents (first one code, second one image) do not produce any overfull vbox message.

\documentclass{beamer}

\usepackage{filecontents}

\usepackage{listings}
\lstset{
  language=XML,
  basicstyle=\small
}

\begin{document}

\begin{filecontents}{\jobname code.xml}
<document>
  <part>
    <chapter>
      <section>
        <subsection>
          <subsubsection>
            <paragraph>
              text
            </paragraph>
          </subsubsection>
        </subsection>
      </section>
    </chapter>
  </part>
</document>
\end{filecontents}

\def\putcode{\begin{center}\lstinputlisting{\jobname code.xml}\end{center}}
\def\putimage{\begin{center}\rule{0.9\textwidth}{0.8\textheight}\end{center}}

\begin{frame}
  \putcode
\end{frame}

\begin{frame}
  \putimage
\end{frame}

\begin{frame}
  \begin{overprint}
    \onslide<+>
    \putcode
    \onslide<+>
    \putcode
  \end{overprint}
\end{frame}


\begin{frame}
  \begin{overprint}
    \onslide<+>
    \putimage
    \onslide<+>
    \putimage
  \end{overprint}
\end{frame}

\begin{frame}
  \begin{overprint}
    \onslide<+>
    \putcode
    \onslide<+>
    \putimage
  \end{overprint}
\end{frame}

\end{document}

When you compile the code, you will be able to readily see that, no overfull message is generated when code is overlaid over code, or an image is overlaid over an image.

But for the last overlay, image over code, we get an overfull vbox message (one for each slide).

Overfull \vbox (187.1715pt too high) detected at line 68

While I can decide to ignore the message, that is not sufficient, because the image gets moved upward (by the overfull amount?), in a rather awkward manner.

I understand that the situation can be remedied by a \vspace command or something like that, but I would really like to understand the reason.

3
  • If you make the rule red, the error goes away?!!? – cfr Oct 26 '14 at 17:18
  • @cfr Hard to believe, but actually, it does go away. But as you can see, this is only an MWE, where the rule was used as an image. What to do for the case of a real image? Again, I would award the bounty to one who can give me the inside news. – Masroor Oct 26 '14 at 17:32
  • Sure. It wasn't intended as a solution! I just thought it extremely odd. – cfr Oct 26 '14 at 17:52
6
+100

The problem is that when the image is to be placed in the last slide, TeX is in vertical mode; using \leavevmode solves the problem:

\documentclass{beamer}

\usepackage{filecontents}

\usepackage{listings}
\lstset{
  language=XML,
  basicstyle=\small
}

\begin{document}

\begin{filecontents}{\jobname code.xml}
<document>
  <part>
    <chapter>
      <section>
        <subsection>
          <subsubsection>
            <paragraph>
              text
            </paragraph>
          </subsubsection>
        </subsection>
      </section>
    </chapter>
  </part>
</document>
\end{filecontents}

\def\putcode{\begin{center}\lstinputlisting{\jobname code.xml}\end{center}}
\def\putimage{\begin{center}\rule{0.9\textwidth}{0.8\textheight}\end{center}}

\begin{frame}
  \putcode
\end{frame}

\begin{frame}
  \putimage
\end{frame}

\begin{frame}
  \begin{overprint}
    \onslide<+>
    \putcode
    \onslide<+>
    \putcode
  \end{overprint}
\end{frame}


\begin{frame}
  \begin{overprint}
    \onslide<+>
    \putimage
    \onslide<+>
    \putimage
  \end{overprint}
\end{frame}

\begin{frame}
  \begin{overprint}
    \onslide<+>
    \putcode
    \onslide<+>
    \leavevmode\putimage
  \end{overprint}
\end{frame}

\end{document}
11
  • Why does the message go away when the box is colored red? Anything to do with vertical mode? See the comments to the question. – Masroor Oct 26 '14 at 17:50
  • 1
    @Masroor Wouldn't \color{} put TeX back in horizontal mode? – cfr Oct 26 '14 at 17:53
  • And I do not get the point about last slide. This `\begin{frame} \begin{overprint} \onslide<+> \putimage \onslide<+> \putcode \end{overprint} \end{frame}' also produces the error. And why is not the message there for two overlaid slides of the same kind? – Masroor Oct 26 '14 at 17:54
  • 1
    @Masroor Reply to your first comment: Using \textcolor or \color right before \putimage switches to horizontal mode so the warning disappears. – Gonzalo Medina Oct 26 '14 at 22:20
  • 1
    @cfr at a quarter to 2 in the morning I haven't the faintest idea:-) – David Carlisle Oct 27 '14 at 1:44

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.