不同讲座中的帧编号(自定义 Beamer 模板)

不同讲座中的帧编号(自定义 Beamer 模板)

我正在尝试定义一个自定义模板,并且对框架标题使用以下模板显示帧编号

\insertframenumber~/~\inserttotalframenumber

运行良好直到\includeonlylecture我决定使用和将我的演示文稿分成不同的讲座\lecture。事实上,现在帧编号显示了完整演示文稿的帧编号(即使其他讲座的其他帧在 pdf 上不可用)。

我尝试了几次修改代码和在线搜索,但我所能做的就是用页码替换帧号,这是相当不错除非存在覆盖。

是否有命令可以报告当前帧号演讲而不是根据完整演示计算出的帧号?

以下是完整的 MWE:

\documentclass{beamer}
\usepackage[utf8]{inputenc}

\setbeamertemplate{navigation symbols}{}
\usepackage{tikz}
\definecolor{titleframecolor}{RGB}{52,82,122}
\colorlet{frametitlefc}{white}

\setbeamerfont{framenumber}{size=\scriptsize}
\setbeamerfont{frametitle}{size=\large}

\defbeamertemplate*{frametitle}{x}[1][]
{
  \nointerlineskip
  \begin{beamercolorbox}[wd=\paperwidth,ht=1.2cm]{frametitle}[titleframecolor]
    \begin{tikzpicture}
      \useasboundingbox (0,0) rectangle(\the\paperwidth,1.2cm);
      \fill[titleframecolor] (0,0) rectangle(\the\paperwidth,1.2cm);%
      {\node[anchor=west,frametitlefc,align=left] (frametitle) at ({1cm-1.5ex,0.6cm}){\usebeamerfont{frametitle}\begin{tabular}{l}\insertframetitle\end{tabular}};}%
      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      %%%%% PART THAT MUST BE FIXED
      \node [anchor=south east,white] at (\the\paperwidth,-.5ex) {\usebeamerfont{framenumber}\insertframenumber~/~\inserttotalframenumber};
      %% Alternative
      %\node [anchor=south east,white] at (\the\paperwidth,-.5ex) {\usebeamerfont{framenumber}\insertpagenumber~/~\insertpresentationendpage};
      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      \end{tikzpicture}
    \end{beamercolorbox}
}


\includeonlylecture{l2}


\begin{document}
\lecture{lecture 1}{l1}
\begin{frame}{Lecure 1 Slide 1 -- Should be page 1/1}
    \begin{itemize}
        \item item
        \item item
    \end{itemize}
\end{frame}

\lecture{lecture 2}{l2}
\begin{frame}{Lecture 2 slide 1 -- Should be page 1/3}
    \begin{itemize}
        \item<1-> item
        \item<2-> item
    \end{itemize}
\end{frame}

\begin{frame}{Lecture 2 slide 2 -- Should be page 2/3}
    \begin{itemize}
        \item<1-> item
        \item<2-> item
    \end{itemize}
\end{frame}

\begin{frame}{Lecture 2 slide 3 -- Should be page 3/3}
    \begin{itemize}
        \item item
        \item item
    \end{itemize}
\end{frame}


\lecture{lecture 3}{l3}
\begin{frame}{Lecture 3 slide 1 -- Should be page 1/1}
    \begin{itemize}
        \item item
        \item item
    \end{itemize}
\end{frame}

\end{document}

温暖的问候。

答案1

这不适用于\includeonlylecture,但您可以使用它来获取完整演示文稿中每个讲座的编号,然后将生成的 pdf 拆分为单独的讲座。

\documentclass{beamer}
\usepackage[utf8]{inputenc}

\setbeamertemplate{navigation symbols}{}
\usepackage{tikz}
\definecolor{titleframecolor}{RGB}{52,82,122}
\colorlet{frametitlefc}{white}

\setbeamerfont{framenumber}{size=\scriptsize}
\setbeamerfont{frametitle}{size=\large}

\usepackage{refcount}
\newcounter{lecturestartframe}
\newcounter{lectureendframe}
\newcounter{nextlecturenum}
\newcounter{frameinlecture}

\defbeamertemplate*{frametitle}{x}[1][]
{
  \setcounterref{lecturestartframe}{lec\thelecture}
  \setcounter{nextlecturenum}{\thelecture}
  \addtocounter{nextlecturenum}{1}
  \setcounterref{lectureendframe}{lec\thenextlecturenum} 
  \addtocounter{lectureendframe}{-\thelecturestartframe}
  \setcounter{frameinlecture}{\theframenumber}
  \addtocounter{frameinlecture}{-\thelecturestartframe}
  \nointerlineskip
  \begin{beamercolorbox}[wd=\paperwidth,ht=1.2cm]{frametitle}[titleframecolor]
    \begin{tikzpicture}
      \useasboundingbox (0,0) rectangle(\the\paperwidth,1.2cm);
      \fill[titleframecolor] (0,0) rectangle(\the\paperwidth,1.2cm);%
      {\node[anchor=west,frametitlefc,align=left] (frametitle) at ({1cm-1.5ex,0.6cm}){\usebeamerfont{frametitle}\begin{tabular}{l}\insertframetitle \end{tabular}};}%
      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      %%%%% PART THAT MUST BE FIXED
      \node [anchor=south east,white] at (\the\paperwidth,-.5ex) {\usebeamerfont{framenumber}\theframeinlecture~/~\thelectureendframe~};
      \end{tikzpicture}
    \end{beamercolorbox}
}

\AtBeginLecture{
\begin{frame}[label=lec\thelecture,noframenumbering,plain]
  \begingroup
    \centering
    {\usebeamerfont{part name}\usebeamercolor[fg]{part name}Lecture~\insertlecturenumber}
    \vskip1em\par
    \begin{beamercolorbox}[sep=16pt,center]{part title}
      \usebeamerfont{part title}\insertlecture\par
    \end{beamercolorbox}
  \endgroup
\end{frame}
}


\AtEndDocument{\lecture{foo}{foo}}



\begin{document}
\lecture{Foo}{l1}
\begin{frame}{Lecure 1 Slide 1 -- Should be page 1/1}
    \begin{itemize}
        \item item
        \item item
    \end{itemize}
\end{frame}

\lecture{Bar}{l2}
\begin{frame}{Lecture 2 slide 1 -- Should be page 1/3}
    \begin{itemize}
        \item<1-> item
        \item<2-> item
    \end{itemize}
\end{frame}

\begin{frame}{Lecture 2 slide 2 -- Should be page 2/3}
    \begin{itemize}
        \item<1-> item
        \item<2-> item
    \end{itemize}
\end{frame}

\begin{frame}{Lecture 2 slide 3 -- Should be page 3/3}
    \begin{itemize}
        \item item
        \item item
    \end{itemize}
\end{frame}


\lecture{Baz}{ll}
\begin{frame}[label=foo]{Lecture 3 slide 1 -- Should be page 1/1}
    \begin{itemize}
        \item item
        \item item
    \end{itemize}
\end{frame}


\end{document}

相关内容