2

With beamer, I would like to add the frame number to the footer. I am using texlive 20200327.

Here is my code:

\documentclass{beamer}
\usetheme{Warsaw}
\title{Beamer Example}

% https://texblog.net/latex-archive/uncat ... me-number/
\newcommand*\oldmacro{}%
\let\oldmacro\insertshorttitle%
\renewcommand*\insertshorttitle{%
\oldmacro\hfill%
\insertframenumber\,/\,\inserttotalframenumber}

\begin{document}
\begin{frame}
\titlepage
\end{frame}
\section{First section}
\begin{frame}
abc
\end{frame}
\end{document}

There is a problem in the output: enter image description here

The frame number "1 / 2" at the bottom is not aligned to the right of the page.

How to fix that please?

Thank you.

Best regards.

2 Answers 2

1

edit: @samcarter posted an excellent solution with compilable example at the forum thread below:

\setbeamertemplate{page number in head/foot}[totalframenumber]

That's enough and you can remove that whole \insertshorttitle redefinition. I also updated the old blog post you referred to, with samcarter's fix.

So consider my \@gobbletwo fix below just as some way to quickly modify the existing code.


As I already wrote as answer to Beamer: Add the frame number to the footer on LaTeX.org

The footline template of the split theme contains this code:

\insertshorttitle\nobreak\hfill

Because of the \hfill, there's empty space at the right. To remove that space and so getting the frame numbers right aligned, you could use the \@gobbletwo command that ignores the next two commands \nobreak\hfill:

\makeatletter
\renewcommand*\insertshorttitle{%
  \oldmacro\hfill%
  \insertframenumber\,/\,\inserttotalframenumber\@gobbletwo}
\makeatother

It's a quick hack though. See the edit above.

0

I redefined the footline of the template so that the frame number and total frame number move further to the right.

\documentclass{beamer}
\usetheme{Warsaw}
\title{Beamer Example}

\setbeamertemplate{footline}{%
  \leavevmode%
  \hbox{\begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex,leftskip=.3cm plus1fil,rightskip=.3cm]{author in head/foot}%
    \mbox{}\hfill\insertshortauthor
  \end{beamercolorbox}%
  \begin{beamercolorbox}[wd=.5\paperwidth,ht=2.5ex,dp=1.125ex,leftskip=.3cm,rightskip=.3cm plus1fil]{title in head/foot}%
    \usebeamerfont{title in head/foot}\insertshorttitle \hfill \insertframenumber\,/\,\inserttotalframenumber%
  \end{beamercolorbox}}%
  \vskip0pt%
}
  
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\section{First section}
\begin{frame}
abc
\end{frame}
\end{document}

enter image description here

You must log in to answer this question.

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