使用 \addcontentsline 和 beamer 放错目录的缩进

使用 \addcontentsline 和 beamer 放错目录的缩进

我无法修复错误放置的缩进,见下文。另外,我不应该使用\newlinewithin \addcontentsline

\documentclass{beamer}
%\documentclass[10pt,a4paper]{book}

\usetheme{Antibes} 
\usecolortheme{seahorse}
\useoutertheme{tree}
\setbeamertemplate{footline}[frame number]
\setbeamertemplate{navigation symbols}{}

\begin{document}


    \begin{frame} 
\tableofcontents 
    \end{frame} 


    \begin{frame} 
\section{section one}
    \end{frame} 

    \begin{frame} 
\subsection{subsection one}
\addcontentsline{toc}{subsection}{line added to TOC:  AAA \newline}
    \end{frame} 

    \begin{frame} 
\subsection{subsection two}
\addcontentsline{toc}{subsection}{line added to TOC: BBB \newline}
\addcontentsline{toc}{subsection}{line added to TOC: CCC \newline}
    \end{frame} 

    \begin{frame} 
\subsubsection{subsubsection after addcontentsline: three}
    LAST
    \end{frame} 
\end{document}

在此处输入图片描述

答案1

由于您正在使用目录中的方形子部分模板,因此您可以查看其缩进的程度(https://github.com/josephwright/beamer/blob/main/base/beamerbaseauxtemplates.sty#L268),然后将自定义行缩进相同的量:

\documentclass{beamer}

\usetheme{Antibes} 
\usecolortheme{seahorse}
\useoutertheme{tree}
\setbeamertemplate{footline}[frame number]
\setbeamertemplate{navigation symbols}{}

\begin{document}

\begin{frame} 
\tableofcontents 
\end{frame} 

\section{section one}
\begin{frame} 

\end{frame} 

\subsection{subsection one}
\addtocontents{toc}{\hskip5ex line added to TOC:  AAA \par}
\begin{frame} 

\end{frame} 

\subsection{subsection two}
\addtocontents{toc}{\hskip5ex line added to TOC: BBB \par}
\addtocontents{toc}{\hskip5ex line added to TOC: CCC \par}
\begin{frame} 

\end{frame} 

\subsubsection{subsubsection after addcontentsline: three}
\begin{frame} 
LAST
\end{frame} 
\end{document}

在此处输入图片描述

相关内容