16

I am trying to customize a beamer theme. In the footline, information such as author, title, date ... are in several beamercolorboxes.

\hbox{%
\begin{beamercolorbox}[wd=.70\paperwidth,ht=7.25ex,left,leftskip=2ex]{title in head/foot}%
    \usebeamerfont{title in head/foot}\insertshorttitle{} - \insertshortauthor
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.20\paperwidth,ht=7.25ex,center]{date in head/foot}%
    \usebeamerfont{date in head/foot}\insertshortdate{}
\end{beamercolorbox}
\begin{beamercolorbox}[wd=.10\paperwidth,ht=7.25ex,right,rightskip=2ex]{date in head/foot}%
    \insertframenumber{} / \inserttotalframenumber
\end{beamercolorbox}}%

I can easily manage the height and width of the box but the text is still completely at the bottom of the box. I would like this text to be vertically aligned.

How can I do that?

1

2 Answers 2

9

You can set the depth of the boxes to a proper value using dp=<length>:

\documentclass{beamer}
\usetheme{Warsaw}

\setbeamertemplate{footline}{%
\hbox{%
\begin{beamercolorbox}[wd=.70\paperwidth,ht=4.25ex,dp=3ex,left,leftskip=2ex]{title in head/foot}%
    \usebeamerfont{title in head/foot}\insertshorttitle{} - \insertshortauthor
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.20\paperwidth,ht=4.25ex,dp=3ex,center]{date in head/foot}%
    \usebeamerfont{date in head/foot}\insertshortdate{}
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.10\paperwidth,ht=4.25ex,dp=3ex,right,rightskip=2ex]{date in head/foot}%
    \insertframenumber{} / \inserttotalframenumber
\end{beamercolorbox}}%
}

\title{The Title}
\author{The Author}

\begin{document}

\begin{frame}
test
\end{frame}

\end{document}

enter image description here

Notice that you have a spurious blank space at the end of the second beamercolorbox; I removed that space in my example code.

4
  • Thank you it works. However, I do not understand this depth parameter. Is it a sort of z coordinate into the beamercolorbox? I thought that this depth was related to the layer of the page in order to manage stacking of several beamercolorbox. Are beamercolorbox really useful here ? Why beamer theme do not simply use parbox or other more simple box ?
    – Ger
    Commented May 18, 2012 at 7:01
  • 2
    @Ger The depth of a box is the distance betwee the baseline and the botoom of the box; think of the two characters "bg" the box for "b" has a depth of 0pt (there's no downwards strokes), but the depth of the box for "g" is positive (the length of the downwards strokes of the "g" below the baseline). Commented May 18, 2012 at 13:07
  • @Ger beamercolorboxes are, in fact, built using simpler boxes but incorporating ready to use functionality (you can easily control the color, the width, depth, height, the margins, etc.). You could dispense with the use of beamercolorboxes and use only \parboxes or even \vboxes and \hboxes, but then your code would be too lengthy. Commented May 18, 2012 at 13:10
  • Can you add a comment about the "proper value" of dp ? What is the relation between ht and dp ?
    – Ger
    Commented Aug 25, 2014 at 8:47
14

The content of a beamercolorbox is typeset into a box. With the ht=<height> parameter, the height of this box is set to <height>, but the content stays at the bottom. You can use the sep=<dimension> parameter instead, which adds extra to every side of the box, thus centering the content. If you need to set a fixed height, however (which is quite reasonable for a footline), you can use an additional \vbox and \vfil inside the beamercolorbox, as described in this answer:

\documentclass{beamer}
\usetheme{Ilmenau}
\setbeamertemplate{footline}{%
\hbox{%
\begin{beamercolorbox}[wd=.70\paperwidth,ht=7.25ex,left,leftskip=2ex]{title in head/foot}%
    \vbox to7.25ex{\vfil\hbox{\usebeamerfont{title in head/foot}\insertshorttitle{} - \insertshortauthor}\vfil}%
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.20\paperwidth,ht=7.25ex,center]{date in head/foot}%
    \vbox to7.25ex{\vfil\hbox{\usebeamerfont{date in head/foot}\insertshortdate{}}\vfil}%
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.10\paperwidth,ht=7.25ex,right,rightskip=2ex]{date in head/foot}%
    \vbox to7.25ex{\vfil\hbox{\insertframenumber{} / \inserttotalframenumber}\vfil}%
\end{beamercolorbox}}%
}
\author{Author}
\title{Title}
\begin{document}
\frame{}
\end{document}

resulting footline

0

You must log in to answer this question.

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