0

In the following code

\documentclass{beamer}
\makeatletter
\setbeamertemplate{footline}{
  \leavevmode
    \begin{beamercolorbox}[wd=\paperwidth, ht=4ex, left]{author in head/foot}%                                                                                                                              
      \usebeamerfont{author in head/foot}
      \begin{tabular}{|p{0.5\paperwidth}|p{0.5\paperwidth}|}
        entry00 & entry01
      \end{tabular}
    \end{beamercolorbox}%                                                                                                                                                                                   
}
\makeatother

\begin{document}
\begin{frame}
  frame contents
\end{frame}
\end{document}

I try to create a table in a beamer footline to span the width of a beamer frame. The result is not satisfactory as I cannot see the rightmost margin of the table:

enter image description here

How to fix the solution?

3
  • Why do you want to use a table in the footline? Commented Jan 25, 2018 at 17:17
  • @samcarter, to position different fields at predefined places. Can you suggest a better way?
    – Viesturs
    Commented Jan 25, 2018 at 21:18
  • I added an answer without tables. Commented Jan 25, 2018 at 21:47

2 Answers 2

2

There were just two things wrong with your code:

  1. There was an extra implicit space after \hbox{. I fixed it by adding a % after it.
  2. The 0.5\paperwidth is the width of the text. It does not include the \tabcolsep, which separates the text from the vertical rules. I have set it to zero to make the column with exactly 0.5\paperwidth.

Also, as you noted yourself, there is no apparent need for the \hbox, so I removed it

The code:

\documentclass{beamer}
\makeatletter
\setbeamertemplate{footline}{
  \leavevmode
  \begin{beamercolorbox}[wd=\paperwidth, ht=4ex, left]{author in head/foot}
    \usebeamerfont{author in head/foot}
    \setlength{\tabcolsep}{0pt}
    \begin{tabular}{|p{0.5\paperwidth}|p{0.5\paperwidth}|}
      entry00 & entry01
    \end{tabular}
  \end{beamercolorbox}%
}
\makeatother

\begin{document}
\begin{frame}
  frame contents
\end{frame}
\end{document}

Another option to the second problem is to reduce the width of the column by 2\tabcolsep to make it fit, like this:

\documentclass{beamer}
\makeatletter
\setbeamertemplate{footline}{
  \leavevmode
  \begin{beamercolorbox}[wd=\paperwidth, ht=4ex, left]{author in head/foot}
    \usebeamerfont{author in head/foot}
    \begin{tabular}{|p{\dimexpr0.5\paperwidth-2\tabcolsep}|p{\dimexpr0.5\paperwidth-2\tabcolsep}|}
      entry00 & entry01
    \end{tabular}
  \end{beamercolorbox}%
}
\makeatother

\begin{document}
\begin{frame}
  frame contents
\end{frame}
\end{document}

The second option looks better because the text doesn't run over the vertical rule. But if you must have the text running in 0.5\paperwidth then the first one is what you want.

2
  • Do we need the \hbox at all?
    – Viesturs
    Commented Jan 25, 2018 at 15:24
  • @Viesturs Good question. Hold on, I'll check... No, the \hbox has no use there, apparently. I edited the answer. Commented Jan 25, 2018 at 15:25
2

I would not use a table to place different fields besides each other in the footline. In normal beamer themes, this effect is achieved by simply placing several beamercolorboxes besides each other:

\documentclass{beamer}

\makeatletter
\setbeamertemplate{footline}{%
  \leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex,center]{author in head/foot}%
    \usebeamerfont{author in head/foot}\insertshortauthor\expandafter\ifblank\expandafter{\beamer@shortinstitute}{}{~~(\insertshortinstitute)}
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.25ex,dp=1ex,center]{title in head/foot}%
    \usebeamerfont{title in head/foot}\insertshorttitle
  \end{beamercolorbox}%
    }%
  \vskip0pt%
}
\makeatother

\author{names}
\title{title}

\begin{document}
\begin{frame}
  frame contents
\end{frame}
\end{document}

Depending on what you are actually going to add to the footline, the hackthefootline might be a simple alternative:

\documentclass{beamer}
\usepackage[twocols]{hackthefootline}

\author{names}
\title{title}

\begin{document}
\begin{frame}
  frame contents
\end{frame}
\end{document}

You must log in to answer this question.

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