
\tableofcontents
我想為in建立以下模板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
模板包含在 a 中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找出最後一段編號。