如何收集 Beamer 中的所有零件?

如何收集 Beamer 中的所有零件?

我想\tableofcontents获取所有部分的内容,beamer仅包括部分名称,不包括节和小节,我该怎么做?

答案1

这里有一些内容可以帮助您入门,但请注意,它不符合beamer的风格,并且零件列表中的条目没有超链接:

\documentclass{beamer}
\usepackage{lipsum}

% for the list of parts
\makeatletter
\AtBeginPart{%
    \addtocontents{parttoc}{\protect\beamer@partintoc{\the\c@part}{\beamer@partnameshort}{\the\c@page}}%
    \frame{\partpage}%
}
\newcommand{\parttableofcontents}{\@starttoc{parttoc}}
\newcommand{\beamer@partintoc}[3]{#2\par}
\makeatother

% for slides to announce the start of a new section
\AtBeginSection[]% do nothing for \section*
{\frame{\sectionpage}}

\begin{document}
    \frame{\frametitle{List of parts}\parttableofcontents}
    \part{one}
    \section{a section}
    \frame{\lipsum[1]}
    \section{another section}
    \frame{\lipsum[2]}
    \part{two}
    \section{yet another section}
    \subsection{subsection}
    \frame{\lipsum[3]}
\end{document}

答案2

据我所知,提高 cyberSingularity 给出的答案的美观度的关键是获得更好的定义\beamer@partintoc。我现在没有时间去想一个,我应该在二十分钟前就上床睡觉,但我却不小心花了一个多小时在这件事上。但是 beamer 对 subsections 的类似命令的定义如下,以及 subsecsections 的定义。通过注意它们之间的差异,应该可以反向推导并找出 parts 的定义应该是什么样子。

\def\subsectionintoc{}
\long\def\beamer@subsectionintoc#1#2#3#4#5#6{%
  \ifnum\c@tocdepth>1%
  \ifnum#5=\beamer@showpartnumber%
  {%
    \beamer@saveanother%
    \gdef\beamer@todo{}%
    \beamer@slideinframe=#1\relax%
    \expandafter\only\beamer@tocsections{\gdef\beamer@todo{%
      \ifbeamer@pausesubsections\pause\fi%
      \beamer@tempcount=#6%
      \advance\beamer@tempcount by\beamer@sectionadjust%
      \edef\inserttocsectionnumber{\the\beamer@tempcount}%
      \def\inserttocsubsectionnumber{#2}%
      \def\inserttocsubsection{\hyperlink{Navigation#4}{#3}}%
      \beamer@tocifnothide{\ifnum\c@section=#1\beamer@toc@css\else\beamer@toc@oss\fi}%
      {%
        \def\beamer@breakhere{\\}%
        \beamer@tocact{\ifnum\c@section=#1\ifnum\c@subsection=#2\beamer@toc@css\else\beamer@toc@oss\fi\else\beamer@toc@ooss\fi}
        {subsection in toc}%
      }%
    }}%
    \beamer@restoreanother%
  }
  \beamer@todo%
  \fi\fi%
}

现在来看看 subsub:

\def\subsubsectionintoc{}
\long\def\beamer@subsubsectionintoc#1#2#3#4#5#6#7{%
  \ifnum\c@tocdepth>2%
  \ifnum#6=\beamer@showpartnumber%
  {
    \beamer@saveanother%
    \gdef\beamer@todo{}%
    \beamer@slideinframe=#1\relax%
    \expandafter\only\beamer@tocsections{\gdef\beamer@todo{%
      \ifbeamer@pausesubsections\pause\fi%
      \beamer@tempcount=#7%
      \advance\beamer@tempcount by\beamer@sectionadjust%
      \edef\inserttocsectionnumber{\the\beamer@tempcount}%
      \def\inserttocsubsectionnumber{#2}%
      \def\inserttocsubsubsectionnumber{#3}%
      \def\inserttocsubsubsection{\hyperlink{Navigation#5}{#4}}%
      \beamer@tocifnothide{\ifnum\c@section=#1\beamer@toc@csss\else\beamer@toc@osss\fi}%
      {%
        \def\beamer@breakhere{\\}%
        \beamer@tocact{\ifnum\c@section=#1\ifnum\c@subsection=#2\ifnum\c@subsubsection=#3\beamer@toc@csss\else\beamer@toc@osss\fi\else\beamer@toc@oosss\fi\else\beamer@toc@ooosss\fi}
        {subsubsection in toc}%
      }%
    }}%
    \beamer@restoreanother%
  }
  \beamer@todo%
  \fi\fi%
}

相关内容