5

I have [framebreaks] frames in a Beamer presentation. I want to have all generated slides there to have the same slide nubmber, e.g., if I have a listing or some text that spans across two or more slides, but within the same frame I want to prevent slide number increase until I start a new frame. In the MWE below "Slide 1" should be numbered 1/2 for the first 3 PDF slides, whereas "Slide 2" should be 2/2. Using \addtocounter{framenumber}{-1} or \setcounter{framenumber}{x} simply starts counting at current-1 or x. I am aware of this post, but unless I am missing something, I don't see how I can adapt the material there to my problem at this hour.

MWE

\documentclass{beamer}
  \mode<presentation>

\usetheme{Boadilla}
\usepackage{lipsum}

\begin{document}

% "Slide 1"
\begin{frame}[allowframebreaks]
\begin{itemize}
 \item Foo 
 \item Bar
 \item Baz
\end{itemize}
\lipsum[1-5]
\end{frame}

% "Slide 2"
\begin{frame}
test
\end{frame}

\end{document}
1
  • This appears to be more related it seems with \beamber@slidenumber... how would I use that here?
    – Serguei
    Sep 4, 2013 at 4:42

1 Answer 1

6

This can be a solution.

We use a new counter multipleslide where we save the current value of the counter framenumber

\newcounter{multipleslide}

We also define two new commands \multipleframe and \restoreframe to be inserted, respectively, before and after a frame with allowframebreaks

\makeatletter%
\newcommand{\multipleframe}{%
\setcounter{multipleslide}{\value{framenumber}}
\stepcounter{multipleslide}
\patchcmd{\beamer@@tmpl@footline}% <cmd>
  {\insertframenumber}% <search>
  {\themultipleslide}% <replace>
  {}% <success>
  {}% <failure>
}
\newcommand{\restoreframe}{%
\patchcmd{\beamer@@tmpl@footline}% <cmd>
  {\themultipleslide}% <search>
  {\insertframenumber}% <replace>
  {}% <success>
  {}% <failure>
\setcounter{framenumber}{\value{multipleslide}}%
}
\makeatother%

The first one takes care of numbering all the slides with the same number, the latter restores the normal numbering.

The following MWE explains a bit better how it works:

\documentclass{beamer}
  \mode<presentation>

\usetheme{Boadilla}

\usepackage{etoolbox}
\usepackage{lipsum}

\newcounter{multipleslide}

\makeatletter%
\newcommand{\multipleframe}{%
\setcounter{multipleslide}{\value{framenumber}}
\stepcounter{multipleslide}
\patchcmd{\beamer@@tmpl@footline}% <cmd>
  {\insertframenumber}% <search>
  {\themultipleslide}% <replace>
  {}% <success>
  {}% <failure>
}
\newcommand{\restoreframe}{%
\patchcmd{\beamer@@tmpl@footline}% <cmd>
  {\themultipleslide}% <search>
  {\insertframenumber}% <replace>
  {}% <success>
  {}% <failure>
\setcounter{framenumber}{\value{multipleslide}}%
}
\makeatother%

\begin{document}

% "Slide 1"
\multipleframe  %<------------------------------------
\begin{frame}[allowframebreaks]
\begin{itemize}
 \item Foo
 \item Bar
 \item Baz
\end{itemize}
\lipsum[1-5]
\end{frame}
\restoreframe  %<------------------------------------

% "Slide 2"
\begin{frame}
test
\end{frame}

\end{document} 

This is the output

enter image description here

3
  • 1
    Perfect, thanks! Works like a charm. I am unfamiliar with etoolbox... still so many things to learn!
    – Serguei
    Sep 4, 2013 at 12:50
  • It used to work for me, but trying this a few years later again this solution doesn't work for me anymore
    – efie
    Jun 24, 2021 at 13:23
  • I haven't retried recently TBH, maybe newer TeXLive distributions or package distributions changed something that affects it? If I have chance I can retest as well but perhaps @karlkoeller may have some insight
    – Serguei
    Jan 19 at 4:03

You must log in to answer this question.

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