![以表格形式复制目录](https://linux22.com/image/469863/%E4%BB%A5%E8%A1%A8%E6%A0%BC%E5%BD%A2%E5%BC%8F%E5%A4%8D%E5%88%B6%E7%9B%AE%E5%BD%95.png)
对于我们的一个大型论文项目,我们需要以表格格式添加一个重复的目录,其中包含一些方框,例如\Box
。我正在寻找解决方案,其输出将是这样的:
\documentclass[letterpapter]{report}
\usepackage{multirow}
\usepackage{latexsym}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\begin{document}
\tableofcontents
\chapter{Chapter 1}
\section{Section}
\subsection{SubSection}
\subsubsection{SubSubSection}
\paragraph{Paragraph}
\subparagraph{SubParagraph}
\chapter{Chapter 2}
\chapter{Chapter 3}
\chapter{Chapter 4}
\chapter{Chapter 5}
\chapter{Chapter 6}
\appendix
\chapter{Grade Summary}
\begin{tabular}{ |p{2cm}|p{3cm}|p{1cm}|p{1cm}| }
\hline
\multicolumn{2}{|c|}{\textbf{Sumnmary}} &\multicolumn{2}{|c|}{\textbf{Graded}}\\
\hline
\multicolumn{2}{|c|}{}&\textbf{YES}&\textbf{NO}\\
\hline
1 &\textbf{Chapter 1}&$\Box$& $\Box$ \\
\hline
1.1 &\textbf{Section}&$\Box$& $\Box$ \\
\hline
1.1.1 &\textbf{SubSection}&$\Box$& $\Box$ \\
\hline
1.1.1.1 &SubSubSection&$\Box$& $\Box$ \\
\hline
1.1.1.1.1 &Paragraph&$\Box$& $\Box$ \\
\hline
1.1.1.1.1.1&SubParagraph&$\Box$& $\Box$ \\
\hline
2 &\textbf{Chapter 2}&$\Box$& $\Box$ \\
\hline
\end{tabular}
\end{document}
我正在研究 etoc,但它看起来会改变 TOC 格式,所以不确定这是否是一个值得研究的选项。
非常感谢您的帮助,并提前感谢您的关注。
答案1
以下是如何实现埃托克。
两个微妙之处:
- 如何处理
\\\hline
,我遵循了 etoc 手册 - 如何避免在表格目录中包含最后一章,我使用了 etoc 手册“深度标签”内容。
\documentclass[letterpapter]{report}
\usepackage{multirow}
\usepackage{latexsym}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\usepackage{etoc}
% we will use an etoc device of depth tags
% in order to not include in tabular TOC
% the appendix stuff,
% let's tell etoc to ignore the depth tags
% for time being, we will activate later
\etocignoredepthtags
\begin{document}
\tableofcontents
\chapter{Chapter 1}
\section{Section}
\subsection{SubSection}
\subsubsection{SubSubSection}
\paragraph{Paragraph}
\subparagraph{SubParagraph}
\chapter{Chapter 2}
\chapter{Chapter 3}
\chapter{Chapter 4}
\chapter{Chapter 5}
\chapter{Chapter 6}
\appendix
% let's instruct etoc to not include subsequent
% stuff in the tabular TOC
\etocdepthtag.toc{ignoredbytabular}
\chapter{Grade Summary}
\begingroup
% make definitions influencing etoc rendering but limit
% them to a group
\etocsettocstyle{%
\begin{tabular}{ |p{2cm}|p{3cm}|p{1cm}|p{1cm}| }
\hline
\multicolumn{2}{|c|}{\textbf{Sumnmary}} &\multicolumn{2}{|c|}{\textbf{Graded}}\\
\hline
\multicolumn{2}{|c|}{}&\textbf{YES}&\textbf{NO}%
}
{\\\hline\end{tabular}}
\etocsetstyle{chapter}
{}
{\\\hline}
{\etocnumber &\textbf{\etocname}& $\Box$& $\Box$}
{}
\etocsetstyle{section}
{}
{\\\hline}
{\etocnumber &\textbf{\etocname}& $\Box$& $\Box$}
{}
\etocsetstyle{subsection}
{}
{\\\hline}
{\etocnumber &\textbf{\etocname}& $\Box$& $\Box$}
{}
\etocsetstyle{subsubsection}
{}
{\\\hline}
{\etocnumber &\etocname& $\Box$& $\Box$}
{}
\etocsetstyle{paragraph}
{}
{\\\hline}
{\etocnumber &\etocname& $\Box$& $\Box$}
{}
\etocsetstyle{subparagraph}
{}
{\\\hline}
{\etocnumber &\etocname& $\Box$& $\Box$}
{}
\etocglobaldefs % needed for \etocnumber, \etocname to work in tabular
% tell etoc to obey depth tags, and set the one attached
\etocobeydepthtags
% to chapters the tabular must ignore to be achieve the effect
\etocsettagdepth{ignoredbytabular}{none}
\tableofcontents
\endgroup
\end{document}