9

With the beamer-class one can easily repeat frames using \againframe. In doing so the framenumber is increased by one. Very often this makes a lot of sense. However, I would like to give the impression that I really show the exact same frame once again. Therefore, the framenumber should also jump back.

Probably the following MWE makes my question more understandable:

\documentclass{beamer}

\useoutertheme{infolines}

\begin{document}

\newcounter{thisframenumber}
\setcounter{thisframenumber}{\value{framenumber}}
\begin{frame}[label=A]
    Frame A
\end{frame}

\begin{frame}
    Frame B
\end{frame}

% steps frame counter
\againframe{A}

% frame number from previous frame
\againframe[noframenumbering]{A}

% desired behavior
\newcounter{tmpframenumber}
\setcounter{tmpframenumber}{\value{framenumber}}
\setcounter{framenumber}{\value{thisframenumber}}
\againframe{A}
\setcounter{framenumber}{\value{tmpframenumber}}

\begin{frame}
    Frame C
\end{frame}

\end{document}

As you see, I found a solution how to achieve the desired behavior. Yet, this solution includes two \newcounter and four \setcounter commands. Is there a less cumbersome solution?

p.s. My dream would be an option for \againframe, like \againframe[originalframenumbering]{A}.

  • How will the audiences believe that they are looking at the same frame while you are just pressing PgDn all the way? Instead, would you like to design a link showing CLIKE HERE to review and click it in presentation? (Since the PDF reader maintains the browser history, you do not need a CLICK HERE to continue then.) – Symbol 1 Apr 29 '15 at 6:45
  • @Symbol1 My intention was to mention it orally. E.g. I explain a concept that I use twice in my talk. At the second occurence I would mention something like "Again we will use this concept I explained already. Let's go back to repeat the most important points ..." – crixstox Apr 29 '15 at 12:47
  • OK ... so... two hints: ① you do not need a counter to store a number, an arbitrary macro would do the job. ② use TeX count is even shorter. – Symbol 1 Apr 29 '15 at 15:51
  • @Symbol1 Thanks for the hints. The overall idea (i.e. changing the framenumber counter manually at every occurence) remains the same, if I understand you correctly. – crixstox Apr 29 '15 at 19:05
3

Forget my comment.

Beamer provides four macros for this purpose

  • \beamer@savecounter: save the specific counter;
  • \beamer@restorecounter: restore the saved counter;
  • \beamer@labelsavecounter: save the specific counter under the label;
  • \beamer@labelrestorecounter: restore the saved counter.

So the remaining problem is:
where and how can I insert those \beamer@xxxxcounter{c@framenumber}?

First, you need a key oldframenumbering along with noframenumbering to indicate what number this \againframe should use.

Second, you need a continueframenumbering mechanism to restore c@framenumber in case oldframenumbering changes it. (I restore the number only if it is necessary. However you can always restore it.)

Third, since beamer handle the frame number within \beamer@@@@frame<#1>[#2] defined in beamerbaseframe.sty, I need to copy and modify its definition.

So I end up with:

\documentclass[handout,20pt]{beamer}
\useoutertheme{infolines}
\makeatletter

% replacing `noframenumbering' by oldframenumbering
\newif\ifbeamer@oldframenumbering
\beamer@oldframenumberingfalse
\define@key{beamerframe}{oldframenumbering}[true]{\beamer@oldframenumberingtrue}

% replacing `noframenumbering' by continueframenumbering
\newif\ifbeamer@continueframenumbering
\beamer@continueframenumberingfalse

% save framenumber w.r.t. labels
\define@key{beamerframe}{label}{
  \def\beamer@againname{#1}
  {\let\@elt\beamer@labelsavecounter\beamer@overlaycounterresets}
  %%% old definition ↑↑↑
  %%%new code ↓↓↓
  {
    \ifbeamer@continueframenumbering
      \beamer@restorecounter{c@framenumber}
    \fi
    \stepcounter{framenumber}\beamer@labelsavecounter{c@framenumber}\addtocounter{framenumber}{-1}
  }
}

% handling frame number
\def\beamer@@@@frame<#1>[#2]{%
  \framewidth\textwidth
  \beamer@savemode%
  \def\beamer@mode{\mode<all>}%
  \def\beamer@frametemplate{}%
  \def\beamer@againname{}%
  \def\beamer@undolabels{}%
  \def\beamer@cramped{}%
  \def\beamer@displaybreak{}%
  \setbox\beamer@footins=\box\voidb@x%
  \beamer@autobreakcount=0\relax%
  \beamer@autobreaklastheight=16000pt%
  \beamer@zoomcount=0\relax%
  \beamer@containsverbatimfalse%
  \beamer@isfragilefalse%
  \beamer@autobreakfalse%
  \beamer@shrinkfalse%
  \beamer@plainframefalse%
  \global\advance\beamer@zoomframecount by1\relax%
  \csname beamer@dosecondmode\beamer@defaultdosecondmode\endcsname%
  \ifbeamer@centered\setkeys{beamerframe}{c}\else\setkeys{beamerframe}{t}\fi%
  \setkeys{beamerframe}{environment=frame}%
  \setkeys{beamerframe}{#2}%
  \beamer@frametemplate%
  %%% old definition ↑↑↑
  %%% modified `oldframenumbering' code ↓↓↓
  \ifbeamer@noframenumbering
    \beamer@noframenumberingfalse
  \else
    \ifbeamer@continueframenumbering
      \beamer@continueframenumberingfalse
      \beamer@restorecounter{c@framenumber}
    \fi
    \ifbeamer@oldframenumbering
      \beamer@oldframenumberingfalse
      \beamer@continueframenumberingtrue
      \beamer@savecounter{c@framenumber}
      \beamer@labelrestorecounter{c@framenumber}
    \else 
      \stepcounter{framenumber}
    \fi
  \fi%
  %%% old definition ↓↓↓
  {\let\@elt\beamer@savecounter\beamer@overlaycounterresets}
  \gdef\beamer@framestartpage{}%
  \gdef\beamer@whichframes{#1}%
  \ifx\beamer@framerestriction\@undefined\else% restriction stuff
    \expandafter\beamer@checkifinlist\beamer@framerestriction\relax%
  \fi%
  \ifbeamer@inlecture%
  \else%
    \gdef\beamer@whichframes{all:0}%
  \fi%
  \ifx\beamer@againname\@empty%
    \beamer@slideinframe=0\relax%
    \beamer@anotherslidefalse%
    {\beamer@masterdecode{\beamer@whichframes}}%
    \ifbeamer@anotherslide%
        \let\beamer@howtotreatframe\beamer@doseveralframes%
      \ifbeamer@containsverbatim%
        \let\beamer@howtotreatframe\beamer@dosingleframe%
      \fi%
      \ifbeamer@autobreak%
        \let\beamer@howtotreatframe\beamer@autobreakframe%
      \fi%
      \ifbeamer@isfragile%
        \let\beamer@howtotreatframe\beamer@doexternalframe%
      \fi%
    \else% no slides in frame
      \let\beamer@howtotreatframe\beamer@donoframe%
    \fi%
  \else% again mode
    \let\beamer@howtotreatframe\beamer@doseveralframes%
    \ifbeamer@isfragile%
      \let\beamer@howtotreatframe\beamer@doexternalframe%
    \fi%
    \ifbeamer@containsverbatim
      \let\beamer@howtotreatframe\beamer@dosingleframe
    \fi
  \fi%
  \beamer@howtotreatframe}


\begin{document}
\makeatletter
\def\insertshortdate{\Huge\hspace*{-5cm}}\Huge

\frame[label=A]{Alfa}
\frame[label=B]{Bravo}
\againframe[oldframenumbering]{A}
\frame[label=C]{Charlie}
\againframe[oldframenumbering]{B}
\againframe[oldframenumbering]{A}
\frame[label=D]{Delta}
\againframe[oldframenumbering]{C}
\againframe[oldframenumbering]{B}
\againframe[oldframenumbering]{A}
\frame[label=E]{Echo}
\frame{Echo}
\againframe[oldframenumbering]{E}
\frame{Echo}

\saved@A@c@framenumber
\saved@B@c@framenumber
\saved@C@c@framenumber
\saved@D@c@framenumber
\saved@E@c@framenumber

\end{document}
  • In my first test, it works flawlessly! This will surely make it in my personal default preamble for beamer presentations. – crixstox Apr 30 '15 at 9:34

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.