在投影仪演示文稿中重复幻灯片,包括原始帧编号

在投影仪演示文稿中重复幻灯片,包括原始帧编号

随着beamer-班级可以使用 轻松重复帧\againframe。这样做时,帧号会增加一。这通常很有意义。但是,我想给人一种印象,即我真的再次显示了完全相同的帧。因此,帧号也应该跳回。

以下 MWE 可能使我的问题更容易理解:

\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}

如您所见,我找到了一种实现所需行为的解决方案。然而,这个解决方案包括两个\newcounter和四个\setcounter命令。有没有更简单的解决方案?

附言:我的梦想是,有一个选择\againframe,比如\againframe[originalframenumbering]{A}

答案1

忘记我的评论。

Beamer 为此提供了四个宏

  • \beamer@savecounter:保存特定的计数器;
  • \beamer@restorecounter:恢复保存的计数器;
  • \beamer@labelsavecounter:保存该标签下特定的计数器;
  • \beamer@labelrestorecounter:恢复保存的计数器。

所以剩下的问题是:
我应该在哪里以及如何插入它们\beamer@xxxxcounter{c@framenumber}

首先,您需要一个密钥oldframenumbering以及noframenumbering用来指示\againframe应该使用什么数字。

其次,您需要一种continueframenumbering机制,以防c@framenumber万一oldframenumbering发生更改。(我只在必要时才恢复号码。但是您随时都可以恢复它。)

\beamer@@@@frame<#1>[#2]第三,由于 beamer 处理的是 中定义的帧号beamerbaseframe.sty,所以我需要复制并修改它的定义。

所以我最终得到:

\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}

相关内容