5

I am working on my own Beamer theme for use in presentations. Along the bottom (in the footline) I want to have three color boxes in a row which have different colors.

Within my theme.sty file I have done this by:

\setbeamertemplate{footline}{
    \leavevmode
    \begin{beamercolorbox}[wd=0.33\paperwidth,ht=7pt,dp=4pt]{footerbox}
        \centering
        \insertauthor
    \end{beamercolorbox}
    \begin{beamercolorbox}[wd=0.34\paperwidth,ht=7pt,dp=4pt]{footerboxcenter}
        \centering
        \inserttitle
    \end{beamercolorbox}
    \begin{beamercolorbox}[wd=0.33\paperwidth,ht=7pt,dp=4pt]{footerbox}
        \centering
        \insertframenumber/\inserttotalframenumber
    \end{beamercolorbox}
}

What I end up with is

Image showing spacing between colorboxes

This is basically what I want except without the space between the boxes. The exact content and ratios of each box may change - the point here is just multiple color boxes on one line. I've tried playing around with various formatting, columns, minipages, hspace, etc, and have not managed to eliminate this space.

I'm imagining there's some command or argument I'm missing here, or there may be a more "LaTeX-ish" way of accomplishing the effect I want. Is there anything I'm doing obviously wrong? And/or is there a more appropriate way to put several color boxes on one line?

fergu
  • 189

1 Answers1

5

You need % after \end{beamercolorbox}, otherwise the unprotected line ending is like inserting a space. See What is the use of percent signs (%) at the end of lines? for more information about line endings as spaces.

Furthermore you can avoid using \centering in each beamercolorbox if you pass center as option the the beamercolorbox.

\documentclass{beamer}

\setbeamercolor{footerbox}{bg=blue, fg=white}
\setbeamercolor{footerboxcenter}{bg=red}

\setbeamertemplate{footline}{%
    \leavevmode
    \begin{beamercolorbox}[wd=0.33\paperwidth,ht=7pt,dp=4pt,center]{footerbox}
        \insertauthor
    \end{beamercolorbox}% <- added
    \begin{beamercolorbox}[wd=0.34\paperwidth,ht=7pt,dp=4pt,center]{footerboxcenter}
        \inserttitle
    \end{beamercolorbox}% <- added
    \begin{beamercolorbox}[wd=0.33\paperwidth,ht=7pt,dp=4pt,center]{footerbox}
        \insertframenumber/\inserttotalframenumber
    \end{beamercolorbox}
}

\begin{document}

\begin{frame}
    abc
\end{frame} 

\end{document}

enter image description here