beamer:确定附录开始前的最后一帧(即使有)

beamer:确定附录开始前的最后一帧(即使有)
  • 通常我会有类似的东西第 4 帧 / 30在里面footline
  • 总帧数由命令完成\insertframenumber
  • 在我的 beamer 演示文稿中,我有一个详尽的附录/备份。
  • 因此我不希望附录帧被计入总帧数。
  • 我用了问题来做到这一点--导致一个称为的新自定义命令\myLastContentFrame
  • 一切都很好。
  • 现在我使用了overlay specification类似的东西[<+->]\myLastContentFrame遗憾的是也考虑了覆盖。

即使使用了叠加规范,如何确定附录前的最后一帧?在附录帧中我想要例如34 / 30(其中 30 是最后一个内容帧数)。

在此处输入图片描述

\documentclass[c]{beamer}

%% Appearance
% -----------------------
\setbeamercolor{block title}{fg=white,bg=red}
\setbeamercolor{block body}{fg=black,bg=gray}
\setbeamercolor{background canvas}{bg=pink}
% -----------------------

%% Functionality
% -----------------------
\usepackage{xparse}

% https://tex.stackexchange.com/questions/347560
\ExplSyntaxOn
\DeclareExpandableDocumentCommand{\myLastContentFrame}{}
 {
  \fp_to_int:n
   {
     (
      \use:c{beamer@startpageofappendix} - 1 > 0
      ?
      \use:c{beamer@startpageofappendix} - 1 
      :
      \inserttotalframenumber
     )
   }
 }
\ExplSyntaxOff
% -----------------------

\begin{document}

\begin{frame}
\frametitle{Content Frame 1}
\begin{itemize}
\huge
\item \texttt{\textbackslash insertframenumber:} \insertframenumber
\item \texttt{\textbackslash inserttotalframenumber:} \inserttotalframenumber
\item \texttt{\textbackslash myLastContentFrame:} \myLastContentFrame
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Content Frame 1}
\begin{itemize}[<+->]
\huge
\item \texttt{\textbackslash insertframenumber:} \insertframenumber
\item \texttt{\textbackslash inserttotalframenumber:} \inserttotalframenumber
\item \texttt{\textbackslash myLastContentFrame:} \myLastContentFrame
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Last Content Frame}
\begin{itemize}[<+->]
\huge
\item \texttt{\textbackslash insertframenumber:} \insertframenumber
\item \texttt{\textbackslash inserttotalframenumber:} \inserttotalframenumber
\item \texttt{\textbackslash myLastContentFrame:} \myLastContentFrame
\end{itemize}

\begin{block}{Last Content Frame}
The number of this frame -- the last frame befpore the appendix starts -- should be the value of \texttt{\textbackslash myLastContentFrame}.
\end{block}

\end{frame}

\appendix

\begin{frame}
\frametitle{First Appendix Frame}
\Huge \textcolor{red}{Start of Appendix!}
\begin{itemize}
\huge
\item \texttt{\textbackslash insertframenumber:} \insertframenumber
\item \texttt{\textbackslash inserttotalframenumber:} \inserttotalframenumber
\item \texttt{\textbackslash myLastContentFrame:} \myLastContentFrame
\end{itemize}
\end{frame}

\end{document}

答案1

您可以使用包中的framenumber命令暂停计数器,即\SuspendCountersxassoccnt

\SuspendCounters{framenumber}

如果需要重新启用计数,请\ResumeSuspendedCounters{framenumber}稍后再说。

我也改为使用总计数器,即\DeclareTotalAssociatedCounters(需要xassoccntv1.2)

\documentclass[c]{beamer}

\usepackage{xassoccnt}

% Pre version 1.1 of xassoccnt version
\NewTotalDocumentCounter{totalframenumbers}
\DeclareAssociatedCounters{framenumber}{totalframenumbers}

% Version 1.2. of xassoccnt allows this in one go...
%\DeclareTotalAssociatedCounters{framenumber}{totalframenumbers}

%% Appearance
% -----------------------
\setbeamercolor{block title}{fg=white,bg=red}
\setbeamercolor{block body}{fg=black,bg=gray}
\setbeamercolor{background canvas}{bg=pink}
% -----------------------

%% Functionality
% -----------------------
\usepackage{xparse}

% http://tex.stackexchange.com/questions/347560

\newcommand{\myReallyLastContentFrame}{%
  \TotalValue{totalframenumbers}
}
\ExplSyntaxOn
\DeclareExpandableDocumentCommand{\myLastContentFrame}{}
 {
  \fp_to_int:n
   {
     (
      \use:c{beamer@startpageofappendix} - 1 > 0
      ?
      \use:c{beamer@startpageofappendix} - 1 
      :
      \inserttotalframenumber
     )
   }
 }
\ExplSyntaxOff
% -----------------------

\begin{document}

\begin{frame}
\frametitle{Content Frame 1}
\begin{itemize}
\huge
\item \texttt{\textbackslash insertframenumber:} \insertframenumber
\item \texttt{\textbackslash inserttotalframenumber:} \inserttotalframenumber
\item \texttt{\textbackslash myLastContentFrame:} \myReallyLastContentFrame 
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Content Frame 1}
\begin{itemize}[<+->]
\huge
\item \texttt{\textbackslash insertframenumber:} \insertframenumber
\item \texttt{\textbackslash inserttotalframenumber:} \inserttotalframenumber
\item \texttt{\textbackslash myLastContentFrame:} \myReallyLastContentFrame
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Last Content Frame}
\begin{itemize}[<+->]
\huge
\item \texttt{\textbackslash insertframenumber:} \insertframenumber
\item \texttt{\textbackslash inserttotalframenumber:} \inserttotalframenumber
\item \texttt{\textbackslash myLastContentFrame:} \myReallyLastContentFrame
\end{itemize}

\begin{block}{Last Content Frame}
The number of this frame -- the last frame befpore the appendix starts -- should be the value of \texttt{\textbackslash myLastContentFrame}.
\end{block}

\end{frame}

\appendix

\SuspendCounters{framenumber}
\begin{frame}
\frametitle{First Appendix Frame}
\Huge \textcolor{red}{Start of Appendix!}
\begin{itemize}
\huge
\item \texttt{\textbackslash insertframenumber:} \insertframenumber
\item \texttt{\textbackslash inserttotalframenumber:} \inserttotalframenumber
\item \texttt{\textbackslash myLastContentFrame:} \myReallyLastContentFrame
\end{itemize}
\end{frame}

\end{document}

答案2

无需重新发明轮子,appendixnumberbeamer已经为您完成了:

(我唯一改变的是注释掉原始附录定义中的两行,否则附录将从 1 重新开始计数)

\documentclass[c]{beamer}

\usepackage{appendixnumberbeamer}

\setbeamertemplate{footline}{\insertframenumber~/~\inserttotalframenumber}

\makeatletter
\def\appendix{
  \xdef\mainend{\theframenumber}
  \immediate\write\@auxout{\string\global\string\@namedef{mainendframenumber}{\mainend}}
  \appendixorig
%  \gdef\inserttotalframenumber{\appendixtotalframenumber}%
%  \setcounter{framenumber}{0}
}
\makeatother

\begin{document}

\begin{frame}
test
\pause[3]
\end{frame}

\begin{frame}
test
\end{frame}

\appendix

\begin{frame}
Appendix
\end{frame}

\end{document}

相关内容