自动重复标题和字幕

自动重复标题和字幕

重复使用上一张 Beamer 幻灯片的标题安德鲁·史黛西给出了重复frametitleframesubtitle进入下一帧的解决方案。

但是它不适用于framesubtitle。我应该如何修改命令才能使其工作?

例子。

\documentclass{beamer}

\usepackage[utf8]{inputenc}

%\url{https://tex.stackexchange.com/q/66274/86}
\makeatletter
\def\beamer@checkframetitle{%
\begingroup
  \edef\temp{%
    \endgroup
    \noexpand\frametitle
    [\unexpanded\expandafter{\beamer@savedshortframetitle}]%
    {\unexpanded\expandafter{\beamer@savedframetitle}}%
  }
\temp
\@ifnextchar\bgroup\beamer@inlineframetitle{}}

\long\def\beamer@@frametitle[#1]#2{%
  \beamer@ifempty{#2}{}{%
    \gdef\insertframetitle{{#2\ifnum\beamer@autobreakcount>0\relax{}\space\usebeamertemplate*{frametitle
continuation}\fi}}%
  \gdef\beamer@frametitle{#2}%
  \gdef\beamer@shortframetitle{#1}%
  \global\let\beamer@savedshortframetitle\beamer@shortframetitle
    \global\let\beamer@savedframetitle\beamer@frametitle
}%
}
  \global\let\beamer@savedshortframetitle\@empty
    \global\let\beamer@savedframetitle\@empty

\makeatother
% \end{add previous title and subtitle}

\title{Test Title}
\author{Pablo}
\date{September 23, 2013}
\institute{Teste Institute}

\begin{document}

\frame{\titlepage}

\frame{
  \frametitle{Title}
  \framesubtitle{Subtitle}
  \begin{itemize}
    \item{Testing}
  \end{itemize}
}

\frame{
  \begin{itemize}
    \item{New item}
  \end{itemize}
}

\end{document}

答案1

当我编写原始代码时,我完全不知道该\framesubtitle命令。原始代码可以处理帧标题和短帧标题,但不能处理 - 正如您所说 - 帧副标题。事实上,副标题更容易,因为代码中有一个钩子,在设置副标题后调用,因此我们可以钩住它并使用它来将副标题保存到全局寄存器中。然后,其余部分只需多加几行即可确保在帧开始时恢复保存的副标题。

\documentclass{beamer}
%\url{http://tex.stackexchange.com/q/134308/86}
\usepackage[utf8]{inputenc}

%\url{http://tex.stackexchange.com/q/66274/86}
\makeatletter
\def\beamer@checkframetitle{%
\begingroup
  \edef\temp{%
    \endgroup
    \noexpand\frametitle
    [\unexpanded\expandafter{\beamer@savedshortframetitle}]%
    {\unexpanded\expandafter{\beamer@savedframetitle}}%
    \noexpand\framesubtitle
    {\unexpanded\expandafter{\beamer@savedframesubtitle}}%
  }
\temp
\@ifnextchar\bgroup\beamer@inlineframetitle{}}

\long\def\beamer@@frametitle[#1]#2{%
  \beamer@ifempty{#2}{}{%
    \gdef\insertframetitle{{#2\ifnum\beamer@autobreakcount>0\relax{}\space\usebeamertemplate*{frametitle
continuation}\fi}}%
  \gdef\beamer@frametitle{#2}%
  \gdef\beamer@shortframetitle{#1}%
  \global\let\beamer@savedshortframetitle\beamer@shortframetitle
    \global\let\beamer@savedframetitle\beamer@frametitle
  }%
}
  \global\let\beamer@savedshortframetitle\@empty
    \global\let\beamer@savedframetitle\@empty
    \global\let\beamer@savedframesubtitle\@empty

\def\beamer@aftersubtitle{%
  \global\let\beamer@savedframesubtitle\insertframesubtitle
}



\makeatother
% \end{add previous title and subtitle}

\title{Test Title}
\author{Pablo}
\date{September 23, 2013}
\institute{Teste Institute}

\begin{document}

\frame{\titlepage}

\frame{
  \frametitle[Subtitle]{Title}
  \framesubtitle{Subtitle}
  \begin{itemize}
    \item{Testing}
  \end{itemize}
}

\frame{
  \begin{itemize}
    \item{New item}
  \end{itemize}
}

\end{document}

相关内容