自定义子目录排版

自定义子目录排版

我想要创建一个如下所示的内容表:

A chapter                                     page
   1 section                                  page
     1.1 subsection1                          page
         subsubsection1 - subsubsection2
         subsubsection3 - subsubsection4
     1.2 subsection2                          page
         subsubsection1 - subsubsection2

小节应当不编号,并以列表形式显示,列表会环绕后续行,并且应使用连字符分隔。

我成功实现了章节和节的编号,但我不知道如何实现子节样式。有什么想法吗?对于章节和节,我使用

\renewcommand\thechapter{\Alph{chapter}}
\renewcommand{\thesection}{\arabic{section}}

谢谢您的帮助

答案1

您可以使用titletoc为此打包:

在此处输入图片描述

代码:

\documentclass{book} 
\usepackage{titletoc}

\renewcommand\thechapter{\Alph{chapter}}
\renewcommand{\thesection}{\arabic{section}}

\titlecontents*{subsubsection}
  [7em]
  {\small}
  {\thecontentslabel}
  {}
  {}
  [~---\ ]

\setcounter{tocdepth}{3}

\begin{document}

\tableofcontents
\chapter{A test chapter}
\section{A test section}
\subsection{A test subsection}
\subsubsection{Test subsubsection one one}
\subsubsection{Test subsubsection one two}
\subsubsection{Test subsubsection one three}
\subsubsection{Test subsubsection one four}
\subsection{Another test subsection}
\subsubsection{Test subsubsection two one}
\subsubsection{Test subsubsection two two}
\subsubsection{Test subsubsection two three}
\subsubsection{Test subsubsection two four}
\subsubsection{Test subsubsection two five}
\subsection{Yet another test subsection}
\subsubsection{Test subsubsection three one}

\end{document}

更新

在评论中,有人要求在标题后添加页码;这里有一种方法可以做到;我在标题和页码之间添加了一个逗号和一个不可分割的空格(根据需要调整):

\documentclass{book} 
\usepackage{titletoc}

\renewcommand\thechapter{\Alph{chapter}}
\renewcommand{\thesection}{\arabic{section}}

\titlecontents*{subsubsection}
  [7em]
  {\small}
  {\thecontentslabel}
  {}
  {,~\thecontentspage}
  [~---\ ]

\setcounter{tocdepth}{3}

\begin{document}

\tableofcontents
\chapter{A test chapter}
\section{A test section}
\subsection{A test subsection}
\subsubsection{Test subsubsection one one}
\subsubsection{Test subsubsection one two}
\subsubsection{Test subsubsection one three}
\subsubsection{Test subsubsection one four}
\subsection{Another test subsection}
\subsubsection{Test subsubsection two one}
\subsubsection{Test subsubsection two two}
\subsubsection{Test subsubsection two three}
\subsubsection{Test subsubsection two four}
\subsubsection{Test subsubsection two five}
\subsection{Yet another test subsection}
\subsubsection{Test subsubsection three one}

\end{document}

在此处输入图片描述

相关内容