在投影機簡報中重複投影片,包括原始影格編號

在投影機簡報中重複投影片,包括原始影格編號

隨著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命令。有沒有更省事的解決方案?

ps 我的夢想是一個選項\againframe,例如\againframe[originalframenumbering]{A}.

答案1

忘記我的評論。

Beamer 為此提供了四個宏

  • \beamer@savecounter:保存具體計數器;
  • \beamer@restorecounter:恢復保存的計數器;
  • \beamer@labelsavecounter:保存標籤下的具體計數器;
  • \beamer@labelrestorecounter:恢復已儲存的計數器。

所以剩下的問題是:
在哪裡以及如何插入這些\beamer@xxxxcounter{c@framenumber}

首先,您需要一個密鑰oldframenumberingnoframenumbering指示\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}

相關內容