如何向目录添加自定义信息?

如何向目录添加自定义信息?

我的文档遵循标准分段:

\documentclass{article}

\begin{document}
\section{The technical details}
\subsection{The frame}
\subsubsection{Leveling system}%Model A, Model B
\subsubsection{The Drawbar}
\subsubsection{Underside}

\subsection{The trunk}
\subsubsection{Style}
\subsubsection{The boxes}%Model A
\subsubsection{The doors-table}% Model B
\end{document}

根据这个部分,我需要制作如下表格:带有额外列的目录 手动构建这种表格很容易出错。

我希望能够在 \subsection 和 \subsubsection 级别包含信息,如下所示:

...
\usepackage{amssymb}
...
\section{The technical details}
\modelsubsection{The frame}{Frame}
\modelsubsubsection{Leveling system}{Leveling}{\checkmark}{\checkmark}
\modelsubsubsection{The Drawbar}{Drawbar}{-}{-}
\modelsubsubsection{Underside}{Underside}{-}{-}    
...

我怎能这样做?

答案1

我建议使用etoc允许大量自定义目录的软件包。当然,你应该按照自己的意愿设计所有级别的样式。以下是概念证明:

\documentclass{article}
\usepackage{amssymb}
\usepackage{etoc}

\title{...}


\newcommand{\modelA}{}
\newcommand{\modelB}{}

\newcommand{\modelsubsubsection}[4]{\addtocontents{toc}{\protect\renewcommand\protect\modelA{#3}\protect\renewcommand\protect\modelA{#4}}\subsubsection[#2]{#1}}


\begin{document}

\begingroup\parindent 0pt \parfillskip 0pt \leftskip 0cm \rightskip 0cm
\etocsettocdepth{4}
\etocsetstyle{section}{}{}{}{}
\etocsetstyle{subsection}{}{}{\textbf{\etocname}\par}{}
\etocsetstyle {subsubsection}
              {}
              {}
              {\etocnumber.~\etocname\hfill\etocpage\quad\makebox[3em]{\modelA\quad\modelA}\par}
              {}              
\tableofcontents
\endgroup

\section{The technical details}
\subsection[Frame]{The frame}
\modelsubsubsection{Leveling system}{Leveling}{\checkmark}{\checkmark}
\modelsubsubsection{The Drawbar}{Drawbar}{-}{-}
\modelsubsubsection{Underside}{Underside}{-}{-} 
\end{document}

在此处输入图片描述

答案2

这只是对@Iacobus1983 回答最初是注释,但后来变得太长了。那里有一个拼写错误,\ModelA两次代替了\ModelA\ModelB。这里提出的代码劫持了部分样式来绘制装饰。

\documentclass{article}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{etoc}

\title{...}


\newcommand{\modelA}{}
\newcommand{\modelB}{}

\newcommand{\modelsubsubsection}[4]{\addtocontents{toc}{\protect\renewcommand\protect\modelA{\makebox[2em]{#3}}\protect\renewcommand\protect\modelB{\makebox[2em]{#4}}}\subsubsection[#2]{#1}}


\begin{document}

\begingroup\parindent 0pt \parfillskip 0pt \leftskip 0cm \rightskip 0cm
\etocsettocdepth{4}
% The code here could be simplified (second \rlap and \hspace unneeded) but
% is presented this way to allow easy extension to Model C, Model D etc...
\etocsetstyle{section}{\noindent\hfill\quad\makebox[4em][l]{\rlap{\rotatebox{45}{Model
    A}}\hspace{2em}\rlap{\rotatebox{45}{Model B}}\hspace{2em}}\par}{}{}{}

\etocsetstyle{subsection}{}{}{\textbf{\etocname}\par}{}

\etocsetstyle {subsubsection}
              {}
              {}
              {~~~~\etocname\hfill\etocpage\quad\modelA\modelB\par}
              {}              
\tableofcontents
\endgroup

\section{The technical details}
\subsection[Frame]{The frame}
\modelsubsubsection{Leveling system}{Leveling}{\checkmark}{\checkmark}
\modelsubsubsection{The Drawbar}{Drawbar}{-}{\checkmark}
\modelsubsubsection{Underside}{Underside}{\checkmark}{-} 
\modelsubsubsection{No marks}{No marks}{-}{-} 
\end{document}

带有额外自定义信息的目录

请点赞@Iacobus1983 回答并且只有在再三考虑之后才会考虑对我的投票,这只是一个延伸。

相关内容