![有没有一种不那么复杂的方法可以将章节摘要信息添加到这个 longtable etoc TOC 中?](https://linux22.com/image/468571/%E6%9C%89%E6%B2%A1%E6%9C%89%E4%B8%80%E7%A7%8D%E4%B8%8D%E9%82%A3%E4%B9%88%E5%A4%8D%E6%9D%82%E7%9A%84%E6%96%B9%E6%B3%95%E5%8F%AF%E4%BB%A5%E5%B0%86%E7%AB%A0%E8%8A%82%E6%91%98%E8%A6%81%E4%BF%A1%E6%81%AF%E6%B7%BB%E5%8A%A0%E5%88%B0%E8%BF%99%E4%B8%AA%20longtable%20etoc%20TOC%20%E4%B8%AD%EF%BC%9F.png)
subsubsection
由于外部原因,我需要为单个部分制作一个实际的表格本地目录,并能够用摘要注释这些部分。我做到了,但我对实现它的方式并不满意。
Latex 自定义命令的目录很接近,但我不确定如何使\registerline
那里定义的命令适应etoc
,特别是因为etoc
使用单个.toc
文件。
以下是 MWE:
\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”样式中删除了一个杂散的空间标记,现在查看输出: