# How can I vertically align a beamercolorbox?

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

\hbox{%
\usebeamerfont{title in head/foot}\insertshorttitle{} - \insertshortauthor
\end{beamercolorbox}%
\end{beamercolorbox}
\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?

-
Welcome to TeX.sx! You don't have to sign with your name since it automatically appears in the lower right corner of your post. –  Werner May 17 '12 at 20:17

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

\documentclass{beamer}
\usetheme{Warsaw}

\setbeamertemplate{footline}{%
\hbox{%
\usebeamerfont{title in head/foot}\insertshorttitle{} - \insertshortauthor
\end{beamercolorbox}%
\end{beamercolorbox}%
\end{beamercolorbox}}%
}

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

\begin{document}

\begin{frame}
test
\end{frame}

\end{document}


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

-
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 May 18 '12 at 7:01
@Ger Please, don't forget to mark the answer that you consider best solved your problem as accepted (in case of doubt, please see How do you accept an answer?). Boxes in (La)TeX have three basic dimensions: width, height and depth (the meaning of the first two is obvious). (Cont.) –  Gonzalo Medina May 18 '12 at 13:06
@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). –  Gonzalo Medina May 18 '12 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. –  Gonzalo Medina May 18 '12 at 13:10
Can you add a comment about the "proper value" of dp ? What is the relation between ht and dp ? –  Ger Aug 25 at 8:47

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{%
\vbox to7.25ex{\vfil\hbox{\usebeamerfont{title in head/foot}\insertshorttitle{} - \insertshortauthor}\vfil}%
\end{beamercolorbox}%
\vbox to7.25ex{\vfil\hbox{\usebeamerfont{date in head/foot}\insertshortdate{}}\vfil}%
\end{beamercolorbox}%