对框架内的幻灯片进行编号

对框架内的幻灯片进行编号

在尝试回答这个问题,我遇到了以下问题。请考虑以下示例。我在 Frame 1 中有三张幻灯片,我想将它们连续打印在讲义的三页上,并将它们编号为1(a)1(b)1(c)。遵循 Martin Scharrer 在这个答案slideinframe,我定义了一个与 具有相同值的计数器\beamer@slideinframe,它跟踪一帧内的当前幻灯片编号。

问题是,当我在正文中使用计数器时,它会产生正确的数字;但是,在页脚中使用时,数字不正确。这里出了什么问题?

\documentclass[handout]{beamer}
\usetheme{Madrid}

% Define counter "slideinframe"
\makeatletter
\def\c@slideinframe{\beamer@slideinframe}
\makeatother

% Define new template style "frame renumbering"
\defbeamertemplate*{footline}{frame renumbering}
{
  \leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}%
    \usebeamerfont{date in head/foot}
    \insertframenumber(\alph{slideinframe}) / \inserttotalframenumber\hspace*{2ex} 
  \end{beamercolorbox}}%
  \vskip0pt%
}

\begin{document}

\begin{frame}{Frame 1}
This is frame \insertframenumber, slide (\alph{slideinframe})
\begin{itemize}
  \item<1| handout:1> Handout 1
  \item<2| handout:2> Handout 2
  \item<3| handout:3> Handout 3
\end{itemize}
\end{frame}

\end{document}

在此处输入图片描述

答案1

问题在于,beamer在进行“装饰”之前,要先对“另一帧”进行计数:

\long\def\beamer@doseveralframes#1{%
  \ifx\beamer@againname\@empty\else%
    % Again stuff
    \expandafter \gdef\csname beamer@again@\beamer@againname\endcsname{{#1}}%
  \fi%
  \beamer@slideinframe=1\relax%
  \loop%
  \beamer@anotherslidefalse%
  \def\beamer@doifnotinframe{}%
  \def\beamer@doifinframe{\begin{beamer@frameslide}%
    #1%
  \end{beamer@frameslide}}%
  {\beamer@masterdecode{\beamer@whichframes}}%
  \beamer@donow%
  \ifbeamer@twoscreenstext%
    \beamer@dosecondscreennow{#1}% two screen stuff
  \fi%
  \ifbeamer@anotherslide
  \advance\beamer@slideinframe by 1\relax Slide number increased here
  \repeat%
  \beamer@writeslidentry% Footlines added here
  \beamer@reseteecodes}

至少通过移动你的例子可以解决这个问题

\documentclass[handout]{beamer}
\usetheme{Madrid}

% Define counter "slideinframe"
\makeatletter
\def\c@slideinframe{\beamer@slideinframe}
\long\def\beamer@doseveralframes#1{%
  \ifx\beamer@againname\@empty\else%
    % Again stuff
    \expandafter \gdef\csname beamer@again@\beamer@againname\endcsname{{#1}}%
  \fi%
  \beamer@slideinframe=1\relax%
  \loop%
  \beamer@anotherslidefalse%
  \def\beamer@doifnotinframe{}%
  \def\beamer@doifinframe{\begin{beamer@frameslide}%
    #1%
  \end{beamer@frameslide}}%
  {\beamer@masterdecode{\beamer@whichframes}}%
  \beamer@donow%
  \ifbeamer@twoscreenstext%
    \beamer@dosecondscreennow{#1}% two screen stuff
  \fi%
  \beamer@writeslidentry% Moved this line
  \ifbeamer@anotherslide
  \advance\beamer@slideinframe by 1\relax
  \repeat%
  \beamer@reseteecodes}
\makeatother

% Define new template style "frame renumbering"
\defbeamertemplate*{footline}{frame renumbering}
{
  \leavevmode%
  \hbox{%
  \begin{beamercolorbox}[wd=\paperwidth,ht=2.25ex,dp=1ex,right]{date in head/foot}%
    \usebeamerfont{date in head/foot}
    \insertframenumber(\alph{slideinframe}) / \inserttotalframenumber\hspace*{2ex} 
  \end{beamercolorbox}}%
  \vskip0pt%
}
\begin{document}

\begin{frame}{Frame 1}
This is frame \insertframenumber, slide (\alph{slideinframe})
\begin{itemize}
  \item<1| handout:1> Handout 1 
  \item<2| handout:2> Handout 2 
  \item<3| handout:3> Handout 3 
\end{itemize}
\end{frame}

\end{document}

我需要看看这是否是一个通用的解决方案:对我来说,这条线确实看起来放错了位置。

相关内容