正如您在下面的最小示例中看到的,我每次都调用相同的宏,\section
我想将其自动化。我基本上尝试了电子工具箱(\apptocmd
、\appto
、\gappto
、\csappto
等),但都不起作用。哪一个是正确的,应该如何使用?或者还有其他解决方案?
\documentclass{beamer}
\usepackage{hyperref}
\usepackage{etoolbox}
\makeatletter
\newcommand\listofframes{\@starttoc{lbf}}
\makeatother
\makeatletter
\addtobeamertemplate{frametitle}{}{%
\mode<presentation>
{
\only<1>{
\hypertarget{\insertframetitle}{}%
\addcontentsline{lbf}{section}{\protect\makebox[2em][l]{%
\protect\usebeamercolor[fg]{structure}\scriptsize\insertframenumber\hfill}%
\ifx\insertframesubtitle\@empty%
\scriptsize\protect\hyperlink{\insertframetitle}{\insertframetitle}%
\else%
\scriptsize\protect\hyperlink{\insertframetitle}{\insertframesubtitle}%
\fi%
\par}%
}
}
}
\makeatother
\newcommand{\sectioninlbf}{
\addcontentsline{lbf}{section}{%
\vspace{0.3\baselineskip}
\protect\footnotesize%
\secname\par}%
}
\begin{document}
\begin{frame}
\frametitle{General outline}
\tableofcontents[hideallsubsections]
\end{frame}
\begin{frame}
\frametitle{List of Frames}
\listofframes
\end{frame}
\section{Test section one}\sectioninlbf
\begin{frame}
\frametitle{Test Frame One}
test
\end{frame}
\section{Test section two}\sectioninlbf
\begin{frame}
\frametitle{Test Frame Two}
\framesubtitle{Test Frame Two Subtitle}
test
\end{frame}
\begin{frame}
\frametitle{Test Frame Three}
\uncover<1->{test}
\uncover<2->{test}
\uncover<3->{test}
\end{frame}
\end{document}
答案1
\documentclass{beamer}
\usepackage{hyperref}
\usepackage{etoolbox}
\makeatletter
\newcommand\listofframes{\@starttoc{lbf}}
\makeatother
\makeatletter
\addtobeamertemplate{frametitle}{}{%
\mode<presentation>
{
\only<1>{
\hypertarget{\insertframetitle}{}%
\addcontentsline{lbf}{section}{\protect\makebox[2em][l]{%
\protect\usebeamercolor[fg]{structure}\scriptsize\insertframenumber\hfill}%
\ifx\insertframesubtitle\@empty%
\scriptsize\protect\hyperlink{\insertframetitle}{\insertframetitle}%
\else%
\scriptsize\protect\hyperlink{\insertframetitle}{\insertframesubtitle}%
\fi%
\par}%
}
}
}
\makeatother
\AtBeginSection{%
\addcontentsline{lbf}{section}{%
\vspace{0.3\baselineskip}
\protect\footnotesize%
\secname\par}%
}
\begin{document}
\begin{frame}
\frametitle{General outline}
\tableofcontents[hideallsubsections]
\end{frame}
\begin{frame}
\frametitle{List of Frames}
\listofframes
\end{frame}
\section{Test section one}
\begin{frame}
\frametitle{Test Frame One}
test
\end{frame}
\section{Test section two}
\begin{frame}
\frametitle{Test Frame Two}
\framesubtitle{Test Frame Two Subtitle}
test
\end{frame}
\begin{frame}
\frametitle{Test Frame Three}
\uncover<1->{test}
\uncover<2->{test}
\uncover<3->{test}
\end{frame}
\end{document}