1

Consider the following MWE:

\documentclass[10pt]{beamer}

\usepackage{lmodern}
\usetheme{Madrid}

\title{Testing Beamer Title}
\subtitle{With 10pt font}
\author{John Doe}
\date{\today}

\begin{document}
\frame{\titlepage}
\end{document}

As you can see in the first image, the date in the third part of the footer is not properly centered (for instance it is not as centered as the second image where I didn't set the 10pt option). So my question is: how do I center the date in the third part/section of the footer while keeping the frame number to the far right?

enter image description here enter image description here

Edit: The answer provided by Kevin C works great. However I was wondering if instead of redefining the whole footline one could only patch the lines corresponding to date in head/foot with etoolbox like it is done in this answer.

petobens
  • 3,306
  • How "centered" do you want it to be? Do you want it to be centered with respect to the third blue box in the footer? Or centered with respect to the third box excluding the page numbers? – Herr K. Oct 03 '14 at 20:38
  • Mmm whatever option looks better (maybe center it with respect to the third blue box) – petobens Oct 03 '14 at 20:42

1 Answers1

3

The default footline theme with Madrid has the last block right-aligned. Thus the date there is not centered and will be slightly shifted when page numbers change (e.g. when going from single digit to double digits).

To have the the date centered in the last block and unaffected by the changes in the page count, one may define a new footline theme as in the following MWE:

MWE

\documentclass[]{beamer}

\usepackage{etoolbox}
\usepackage{lmodern}
\usetheme{Madrid}

\makeatletter
% change in-box alignment from right to left
\patchcmd{\beamer@@tmpl@footline}% <cmd>
  {right}% <search>
  {left}% <replace>
  {}% <success>
  {}% <failure>

% replace definition of 'date in head/foot' box
\patchcmd{\beamer@@tmpl@footline}% <cmd>
  {\usebeamerfont{date in head/foot}\insertshortdate{}\hspace*{2em}
   \insertframenumber{} / \inserttotalframenumber\hspace*{2ex}}% <search>
  {\rlap{\makebox[.333333\paperwidth][r]{\insertframenumber{} / \inserttotalframenumber \hspace*{2ex}}}
   \usebeamerfont{date in head/foot}\hfill\insertshortdate{}\hfill}% <replace>
  {}% <success>
  {}% <failure>
\makeatother

\title{Testing Beamer Title}
\subtitle{With default font size}
\author{John Doe}
\date{\today}

\begin{document}
\frame{\titlepage}
\frame{test}\frame{test}\frame{test}\frame{test}\frame{test}
\frame{test}\frame{test}\frame{test}\frame{test}\frame{test}
\end{document}

Output

enter image description here

Herr K.
  • 17,946
  • 4
  • 61
  • 118
  • Thanks! Can I just patch the date in head/foot beamercolorbox using etoolbox or xpatch? – petobens Oct 03 '14 at 22:41
  • @petobens: I'm not so sure... I'm not familiar enough with the two packages you mentioned to know if this is do-able. I've only used them to patch macros. But what you're trying to do is a little more complicated than patching macros. – Herr K. Oct 03 '14 at 22:49
  • Since basically I only want to change two lines in the definition of footline template then I thought that it could be done with etoolbox like it is done here. But I'm struggling to make it work. – petobens Oct 03 '14 at 23:07
  • 1
    @petobens: See my updated MWE. Thank you for the follow up questions, since I also learned something new :) – Herr K. Oct 03 '14 at 23:54