手动创建基本投影仪目录

手动创建基本投影仪目录

对于某些应用,例如思维导图中的链接作为投影仪中的目录默认的 Beamer 目录不够灵活

如何手动重新创建一个基本的投影仪目录作为疯狂事物的起点?

答案1

以下代码生成了一个基本的目录,其功能比原始投影仪目录少得多,但它实际上只是意味着作为默认目录中无法实现的更复杂事物的起点。

\documentclass{beamer}

\usepackage{tikz}

\setbeamercolor{subsection in toc}{fg=black}

% total number of sections %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{totcount}
\newcounter{totalsection}
\regtotcounter{totalsection}
\AtBeginDocument{%
  \pretocmd{\section}{\refstepcounter{totalsection}}{}{}%
}%

% number of subsections per section %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xcntperchap}
\RegisterCounters{section}{subsection}
\newcounter{totalsubsection}
\setcounter{totalsubsection}{0}

% creating automatic label %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% based on https://tex.stackexchange.com/a/386557/36296
\AtBeginSection[]{\label{sec:\thesection}}
\AtBeginSubsection[]{\label{subsec:\thesection:\thesubsection}}
\newcounter{currentsub}
\newcounter{totsection}

% custom toc
\newcommand{\mytoc}{%
    \begingroup%
        \usebeamerfont{section in toc}%
      \usebeamercolor[fg]{section in toc}%
    \setcounter{totsection}{\number\totvalue{totalsection}}%
    \foreach \i in {1,...,\thetotsection}{%
        \hyperlink{sec:\thesection}{\nameref{sec:\i}}%
            \setcounter{currentsub}{\ObtainTrackedValueExp[\i]{section}{subsection}}%
            \par%
            \begingroup
                \usebeamerfont{subsection in toc}%
                \usebeamercolor[fg]{subsection in toc}%
                \ifnum\thecurrentsub>0%
                    \foreach \j in {1,...,\thecurrentsub}{%
                        \hspace{1cm}\hyperlink{subsec:\i:\j}{\nameref{subsec:\i:\j}}%
                        \par%
                    }%
                \fi%
            \endgroup
            \vfill
        }% loop over i
    \endgroup
}

\title{Some Title}

\begin{document}

\begin{frame}
    \mytoc
\end{frame}

\section{Section 1}
\subsection{Subsection 1a}
\frame{}
\subsection{Subsection 1b}
\frame{}
\subsection{Subsection 1c}
\frame{}

\section{Section 2}
\frame{}

\section{Section 3}
\subsection{Subsection 3a}
\frame{}
\subsection{Subsection 3b}
\frame{}
\subsection{Subsection 3c}
\frame{}

\end{document}

enter image description here

相关内容