2

In a latex-beamer document, I am using a custom headline template. It produces a headline only when in a section. Here is a stripped down version:

\documentclass{beamer}
\usepackage{times} % gets rid of fontsize warnings
\setbeamercolor{section in head}{bg=yellow!80!black,fg=structure} 
%% \setbeamercolor{lower separation line head}{bg=yellow!50!black}
\setbeamertemplate{headline}{
   \ifx\insertsection\empty\else
   \usebeamerfont{section in head}
   \begin{beamercolorbox}[ht=2ex,dp=1ex,leftskip=2ex]{section in head}
     \insertsection 
   \end{beamercolorbox}
   %%\begin{beamercolorbox}[colsep=0.5pt]{lower separation line head}\end{beamercolorbox}
   \fi
   \vspace*{5pt}
}

\begin{document}
\begin{frame}
  % frame has empty headline
\end{frame}
 \section{A Section}
\begin{frame}
  % frame headline shows section title
\end{frame}
\end{document}

However, this code produces an "overfull vbox": Overfull \vbox (9.41396pt too high) has occurred while \output is active []

I could ignore it because the result looks fine, but I'd like to know why this is happening and how I could deal with it, mostly because it is irritatint to see this printed out over 200 times.

(Note: this does not happen when commenting out lines 6 and 12, the ones with \if and \fi.)

1
  • This is indeed very funny. In my tests the \ifx .. \fi also causes the overfull vbox warning and I can't really see or understand why. I tried some variations but without success. Commented Jul 28, 2011 at 11:03

3 Answers 3

2

Modify the line 5 to say:

 \ifx\insertsection\empty\hrule height2ex depth1ex width0pt\else

I believe that what happens is beamer calculates the total height of the head at the beginning of the document, before \insertsection is set, and uses this value to calculate the other dimensions of the page. With the head empty, it expects the size of the head to be 0, and if the head is not empty, the whole page is overfull. Notice that on the pages with the section head, with the original code, the navigation line is pushed out of the page, so it disappears.

2
  • That seems to work! So apparently, beamer can't deal with headlines of variable height (in the sense that it cannot be predicted without parsing the entire document).
    – Archibald
    Commented Jul 30, 2011 at 10:52
  • During my tests I was using \vskip 9.41396pt instead of this 2ex+1ex, any reason this would be the exact size? Or is it just a fair over-approximation? Commented Jul 30, 2011 at 12:59
1

Put \vspace*{-9.41396pt} before the \fi.

5
  • Do you know why it is caused by the \ifx .. \fi? Commented Jul 28, 2011 at 11:17
  • @Martin No idea.
    – egreg
    Commented Jul 28, 2011 at 11:24
  • Thank you, at least now I can compile without warnings. But it's not the most definitive solution I guess.
    – Archibald
    Commented Jul 28, 2011 at 11:39
  • 2
    That's cheating! :)
    – Seamus
    Commented Jul 28, 2011 at 14:02
  • Also, it has the disadvantage that if there is a lower separation line \begin{beamercolorbox}[colsep=0.5pt]{lower separation line head}\end{beamercolorbox} to seperate headline from normal text, it will not be placed correctly.
    – Archibald
    Commented Jul 28, 2011 at 15:39
0

It seems that \ifx\insertsection\undefined\else might be more appropriate here. (no, see comments) And it solves the warning issue. I can't tell what's happening with \empty though.

2
  • Yes, it "solves" the issue because the conditional is always false, so it's equivalent to not putting the conditional at all. But the OP doesn't want the colored band when the section title has not yet been set.
    – egreg
    Commented Jul 28, 2011 at 12:05
  • Hmm, right I thought \insertsection was user supplied, but it's some beamer command. Looking at the code I can't understand what's going on… looks like beamer does multiple passes: using \ifx\insertsection\empty\vskip 30pt\else we can see that the 'non-else' part is taken into account even if the 'else' part is the displayed one. Commented Jul 28, 2011 at 13:11

You must log in to answer this question.

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