有没有一种不那么复杂的方法可以将章节摘要信息添加到这个 longtable etoc TOC 中?

有没有一种不那么复杂的方法可以将章节摘要信息添加到这个 longtable etoc TOC 中?

subsubsection由于外部原因,我需要为单个部分制作一个实际的表格本地目录,并能够用摘要注释这些部分。我做到了,但我对实现它的方式并不满意。

Latex 自定义命令的目录很接近,但我不确定如何使\registerline那里定义的命令适应etoc,特别是因为etoc使用单个.toc文件。

以下是 MWE:

下面是使用 MWE 渲染的 TeX 文件的图片,从常规目录开始,然后是一个部分,然后是一个带有重复摘要行的表格目录

\documentclass[11pt]{article}
\usepackage{etoc}
\usepackage{lipsum}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{hyperref}

\author{Some Author}
\title{Some Title}

\begin{document}
\maketitle

\setcounter{tocdepth}{1}
\tableofcontents

\section{Super long section}

%% Where I'm trying to make a tabular table of contents
\begingroup % Localize changes here
\etocsetnexttocdepth{3}
\etocglobaldefs % necessary for \etocname etc... to survive &
\etocsettocstyle{
  \textbf{Things Included Here:}
  \begin{longtable}{p{6.5cm}p{0.75cm}p{3.5cm}} \toprule
  Document & Page & Summary \\ \midrule \endhead
}{\end{longtable}}
\etocsetstyle{subsection}
             {}
             {}
             {\etocname & \etocthelinkedpage}
             {}

\etocsetstyle{subsubsection}
             {}
             {}
             {& \hypersetup{hidelinks} {\etocname} \\}
             {}

\localtableofcontents
\endgroup

\subsection{First thing}

\etoctoccontentsline{subsubsection}{Summary of first thing}

\lipsum[1-2]

\subsection{Second thing}%{Summary of second thing}

\etoctoccontentsline{subsubsection}{Summary of second thing}

\lipsum[3]

\subsection{Third thing}%{Summary of third thing}

\etoctoccontentsline{subsubsection}{Summary of third thing}

\lipsum[3]

\end{document}

答案1

我认为您的代码非常合适,唯一的问题是您不能在本节中使用子节。

要解决这个问题,您可以使用自定义“sectionsummary”级别。然后可以使用子子节并将其显示在其他目录中,但不会出现在此本地目录中(其表格设计无论如何都没有空间容纳它们)。

etoc 没有显示数值级别 6,这解释了下面的一些代码。

\documentclass[11pt]{article}
\usepackage{etoc}
\etocsetlevel{sectionsummary}{6}
\usepackage{lipsum}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{hyperref}

\author{Some Author}
\title{Some Title}

\begin{document}
\maketitle

\setcounter{tocdepth}{1}
\tableofcontents

\section{Super long section}

%% Where I'm trying to make a tabular table of contents
\begingroup % Localize changes here
%%%% \etocsetnexttocdepth{3} % moved later for better readability
\etocglobaldefs % necessary for \etocname etc... to survive &
\etocsettocstyle{
  \textbf{Things Included Here:}
  \begin{longtable}{p{6.5cm}p{0.75cm}p{3.5cm}} \toprule
  Document & Page & Summary \\ \midrule \endhead
}{\end{longtable}}
\etocsetstyle{subsection}
             {}
             {}
             {\etocname & \etocthelinkedpage}
             {}
\etocsetlevel{sectionsummary}{3}% unfortunately only numerical value accepted
                                % here, we would have hoped to use subsubsection
\etocsetlevel{subsubsection}{6}% make them invisible in this local TOC
\etocsetstyle{sectionsummary}
             {}
             {}
             {& \hypersetup{hidelinks}{\etocname} \\}% edited to remove stray space token
             {}

\etocsetnexttocdepth{sectionsummary}% here a level name accepted
\localtableofcontents
\endgroup

\subsection{First thing}

\etoctoccontentsline{sectionsummary}{Summary of first thing}

\lipsum[1-2]

\subsection{Second thing}%{Summary of second thing}

\etoctoccontentsline{sectionsummary}{Summary of second thing}

\lipsum[3]

\subsection{Third thing}%{Summary of third thing}

\etoctoccontentsline{sectionsummary}{Summary of third thing}

\lipsum[3]

\end{document}

编辑:我应该使用“subsectionsummary”而不是“sectionsummary”来更好地匹配实际上下文。但这只是代码的装饰细节。

edit2:我从“sectionsummary”样式中删除了一个杂散的空间标记,现在查看输出:

目录

相关内容