我想要为 创建以下\tableofcontents
模板beamer
。
我能够使用以下 MWE生成sections
列表的代码subsections
\documentclass{beamer}
\usepackage[english]{babel}
\usepackage{tikz}
\setbeamerfont{section in toc}{family*=qag, size=\large,series=\bfseries}
\setbeamerfont{subsection in toc}{size=\normalsize,series=\bfseries}
\setbeamertemplate{subsection in toc}{%
\begin{tikzpicture}[outer sep=0pt, inner sep=0pt,line width=0pt]
\path[use as bounding box] (0,0) rectangle (\textwidth,0);
\node[anchor=base east] at (.7\textwidth,0) { \inserttocsubsection};
\end{tikzpicture}
}
\setbeamertemplate{section in toc}{%
\begin{tikzpicture}[outer sep=0pt, inner sep=0pt,line width=0pt]
\path[use as bounding box] (0,0) rectangle (\textwidth,0);
\node[anchor=base east] at (.7\textwidth,0) { \inserttocsection};
\node[anchor=base west] at (.7\textwidth+4ex+2.2ex,0){\inserttocsectionnumber};
\end{tikzpicture}
}
\begin{document}
\begin{frame}
\tableofcontents
\end{frame}
\section{First Section}
\section{Second Section}
\subsection{A subsection}
\begin{frame}{Some frame}
\end{frame}
\end{document}
但是,我没有找到插入垂直线的巧妙方法。如果我使用模板background
,我可以做到,但定位并不容易(并且很大程度上取决于aspectratio
和)。在 中margins
也会发生同样的情况。我试图找到一种方法将模板封闭在 中,并将每个模板定义为节点集合,但它似乎比我想象的要复杂。例如,使用不是一个好的选择。overlay
tikzpicture
section in toc
tikzpicture
\tableofcontets
\patchcmd
答案1
您可以标记节点,然后从第一部分到最后一部分画线:
\documentclass{beamer}
\usepackage[english]{babel}
\usepackage{tikz}
\setbeamerfont{section in toc}{family*=qag, size=\large,series=\bfseries}
\setbeamerfont{subsection in toc}{size=\normalsize,series=\bfseries}
\setbeamertemplate{subsection in toc}{%
\begin{tikzpicture}[outer sep=0pt, inner sep=0pt,line width=0pt]
\path[use as bounding box] (0,0) rectangle (\textwidth,0);
\node[anchor=base east] at (.7\textwidth,0) { \inserttocsubsection};
\end{tikzpicture}
}
\setbeamertemplate{section in toc}{%
\begin{tikzpicture}[outer sep=0pt, inner sep=0pt,line width=0pt,remember picture]
\path[use as bounding box] (0,0) rectangle (\textwidth,0);
\node[anchor=base east] (toc-\inserttocsectionnumber) at (.7\textwidth,0) { \inserttocsection};
\node[anchor=base west] at (.7\textwidth+4ex+2.2ex,0){\inserttocsectionnumber};
\end{tikzpicture}
}
\makeatletter
\apptocmd{\tableofcontents}{%
\begin{tikzpicture}[remember picture,overlay]
\draw[red,line width=0.1cm] ([xshift=4.1ex,yshift=2ex]toc-1.north east) -- ([xshift=4.1ex,yshift=-2ex]toc-\the\[email protected] east);
\end{tikzpicture}%
}{}{}
\makeatother
\begin{document}
\begin{frame}
\tableofcontents
\end{frame}
\section{First Section}
\begin{frame}
\frametitle{Some frame}
\end{frame}
\section{Second Section}
\subsection{A subsection}
\begin{frame}
\frametitle{Some frame}
\end{frame}
\section{Third Section}
\begin{frame}
\frametitle{Some frame}
\end{frame}
\end{document}
如果你的最后一节要包含小节,你也可以给它们贴上标签,并使用https://topanswers.xyz/tex?q=1987#a2230找出最后一个小节的编号。