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.

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.)

share|improve this question
    
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. –  Martin Scharrer Jul 28 '11 at 11:03
add comment

3 Answers 3

up vote 2 down vote accepted

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.

share|improve this answer
    
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 Jul 30 '11 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? –  Stéphane Gimenez Jul 30 '11 at 12:59
add comment

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

share|improve this answer
    
Do you know why it is caused by the \ifx .. \fi? –  Martin Scharrer Jul 28 '11 at 11:17
    
@Martin No idea. –  egreg Jul 28 '11 at 11:24
    
Thank you, at least now I can compile without warnings. But it's not the most definitive solution I guess. –  Archibald Jul 28 '11 at 11:39
2  
That's cheating! :) –  Seamus Jul 28 '11 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 Jul 28 '11 at 15:39
add comment

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.

share|improve this answer
    
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 Jul 28 '11 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. –  Stéphane Gimenez Jul 28 '11 at 13:11
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.