I'm trying to create my own Beamer theme and I have a problem in handling the headline. I would like to create a headline with a coloured line for the frame title, while for other frames I want a classical headline with sections and possibly subsections. Here is the part of the code I use:
\defbeamertemplate*{headline}
{ \ifnum\c@framenumber>1
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=\headerheight,dp=0pt]{}%
\ifx\insertsection\@empty
\else
{
{\usebeamerfont{headsection}\hspace{1em} \color{LightBlue}\insertsection}
\ifx\insertsubsection\@empty
\else
{\hspace{0.5em}$\vert$ \hspace{0.5em}{\usebeamerfont{headsubsection}\color{DarkGray}\insertsubsection}}%
\fi
}
\fi
\end{beamercolorbox}%
} %
\vskip0pt%
\else
\hbox{%
\begin{beamercolorbox}[wd=\paperwidth,ht=20pt,dp=0pt]{linemid}
\end{beamercolorbox}%
}
\fi
}
In such a way I obtain a result which is not satisfactory because the coloured line in title frame is OK, but sections and subsection of the following frames (and so the title and the body of the frame) are shifted down. It seems that beamer keeps the space reserved for the first headline, but I don't want that. Is there a way to fix the problem?
Best Answer
That's right, the
beamer
package only calculates the height of the headline once, at the beginning of the document. The macro responsible for this task is called\beamer@calculateheadfoot
, and is defined inbeamerbaseframecomponents.sty
(ll. 161-182). If the head of your headline changes in the course of the presentation (which doesn't sound like a terribly good idea to my mind, BTW), you'll have to issue this command manually.This can be done for example by adding it to the internal macro
\beamer@@@@frame
: Like this, the head of head- and footlines etc. are recalculated each time a frame is being built:Add this code snippet to your document or your theme file. (The manual change of
framenumber
is necessary to get the correct headline asbeamer
hasn't stepped the counter at this point.)Minimal example: