5

I am doing a presentation using beamer and it is quite long. It is dividend in sections and at the end of each section I will do a break. Consequently, Iwould like to have a double counter of the current slide. For example: Suppose I am currently at the 3rd slide of section 2 (made of 20 slides) and section 1 is made of 50 slides, the first counter will be 3/20 while the second 53/70 (if there are only two sections).

This is my working environment:

\documentclass[t,10pt,xcolor=dvipsnames]{beamer}
 \mode<presentation>
 {
 \usetheme{AnnArbor}
 \setbeamercovered{transparent}
\useinnertheme{rounded}
   \usecolortheme{spruce}
 }

  \setbeamercolor{section in head/foot}{fg=White}
\section{Sec1}
\subsection{Sub 1}
\begin{frame}{Fra 1}
\end{frame}
\begin{frame}{Fra 2}
\end{frame}
\begin{frame}{Fra 3}
\end{frame}
\section{Sec2}
\subsection{Sub 1}
\begin{frame}{Fra 1}
\end{frame}
\begin{frame}{Fra 2}
\end{frame}
\end{document}

Any help?

  • The second counter is displayed in the footline by default. Where do you want to put the first counter? – Herr K. Feb 17 '15 at 19:48
  • I would like it of the footline as well on the left hand side, where currently I have only my name – ginu Feb 17 '15 at 19:59
4

No new counters are needed, just a bit of calculation. Beamer stores the page numbers where a section starts and ends in macros \insertsectionstartpage and \insertsectionendpage. Thus the number of pages in a section can be calculated by

\insertsectionendpage-\insertsectionstartpage+1

The page number within a section is

\insertframenumber-\insertsectionstartpage+1

where \insertframenumber stores the page number of the current frame.

Patch these using \patchcmd from package etoolbox to the Beamer command that inserts the footline \beamer@@tmpl@footline, and you'll have section page counter on the left and overall page counter on the right in the footline.

Code

\documentclass[t,10pt,xcolor=dvipsnames]{beamer}

\usepackage{etoolbox}

\mode<presentation>
{
  \usetheme{AnnArbor}
  \setbeamercovered{transparent}
  \useinnertheme{rounded}
  \usecolortheme{spruce}
}
\setbeamercolor{section in head/foot}{fg=White}

\makeatletter
% change author box alignment 
\patchcmd{\beamer@@tmpl@footline}% <cmd>
  {center}% <search>
  {left}% <replace>
  {}% <success>
  {}% <failure>

% add page to author box
\patchcmd{\beamer@@tmpl@footline}% <cmd>
  {\usebeamerfont{author in head/foot}\insertshortauthor\expandafter\beamer@ifempty\expandafter{\beamer@shortinstitute}{}{~~(\insertshortinstitute)}}% <search>
  {\def\sectotpage{\number\numexpr\insertsectionendpage-\insertsectionstartpage+1}%
   \def\pageinsec{\number\numexpr\insertframenumber-\insertsectionstartpage+1}%
   \rlap{\hspace*{2ex}\pageinsec{} / \sectotpage} \hfill
  \usebeamerfont{author in head/foot}\insertshortauthor\expandafter\beamer@ifempty\expandafter{\beamer@shortinstitute}{}{~~(\insertshortinstitute)}}% <replace>
  {}% <success>
  {}% <failure>
\makeatother

\author{Author}

\begin{document}
\newcommand\nf{\frame{Frame in Section~\thesection.}}

\section{Sec 1}
\nf\nf\nf\nf\nf

\section{Sec 2}
\nf\nf\nf\nf\nf\nf

\section{Sec 3}
\nf\nf\nf\nf\nf\nf\nf

\end{document}

Output

enter image description here

  • it does not seem to work for my case. The only think I have is that the position of the author is changed from centred to left. Any suggestions? – ginu Feb 17 '15 at 22:44
  • @tom: From what you're describing, it might be the case that this part of the code \rlap{\hspace*{2ex}\pageinsec{} / \sectotpage} \hfill is missing somehow. Could you check to see if it has been comment out accidentally in the process of copying & pasting? – Herr K. Feb 18 '15 at 0:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.