我想在我的论文目录中添加段落。但是,当我这样做时,段落编号与其他段落相比不对齐。前面章节的编号设置为出现在上述章节编号后面的空格末尾的下一行,而段落编号在该空格之前开始。
我希望段落编号直接出现在上述小节编号的第一个字母的下方,如下面的编辑图所示。
我怎样才能做到这一点?
梅威瑟:
\documentclass{book}
\setcounter{tocdepth}{5}
\setcounter{secnumdepth}{5}
\begin{document}
\tableofcontents
\chapter{blah}
\section{blah}
\subsection{blah}
\subsubsection{blah}
\paragraph{blah}
\end{document}
答案1
您希望每个阶段的缩进量增加上一阶段分配给数字的宽度
\documentclass{book}
\setcounter{tocdepth}{5}
\setcounter{secnumdepth}{5}
\makeatletter
% level indent numwidth
\renewcommand*\l@section{\@dottedtocline {1}{1.5em} {2.3em}}
\renewcommand*\l@subsection{\@dottedtocline {2}{3.8em} {3.2em}}
\renewcommand*\l@subsubsection{\@dottedtocline{3}{7.0em} {4.1em}}
\renewcommand*\l@paragraph{\@dottedtocline {4}{11.1em}{5.0em}}
\makeatother
\begin{document}
\tableofcontents
\chapter{blah}
\section{blah}
\subsection{blah}
\subsubsection{blah}
\paragraph{blah}
\end{document}
答案2
使用包的类似输出titletoc
。使用两位数章节号进行测试,以防万一。
\documentclass{book}
\usepackage{showframe}% show the margins
\setcounter{tocdepth}{5}
\setcounter{secnumdepth}{5}
\usepackage{titletoc}
\titlecontents{chapter}
[2em] % left margin from left page margin
{\bfseries}
{\contentslabel{2em}} % before title with label
{\hspace*{-2em}}% before title without label
{\titlerule*[1pc]{.}\contentspage}
\titlecontents{section}
[4.5em] %increase the previous + space for new number
{}
{\contentslabel{2.5em}}
{\hspace*{-2.5em}}
{\titlerule*[1pc]{.}\contentspage}
\titlecontents{subsection}
[7.7em]%increase the previous + space for new number
{}
{\contentslabel{3.2em}}
{\hspace*{-3.2em}}
{\titlerule*[1pc]{.}\contentspage}
\titlecontents{subsubsection}
[11.7em]%increase the previous + space for new number
{}
{\contentslabel{4em}}
{\hspace*{-4em}}
{\titlerule*[1pc]{.}\contentspage}
\titlecontents{paragraph}
[16.5em]%increase the previous + space for new number
{}
{\contentslabel{4.8em}}
{\hspace*{-4.8em}}
{\titlerule*[1pc]{.}\contentspage}
\begin{document}
\tableofcontents
\setcounter{chapter}{20}
\chapter{blah c}
\section{blah s}
\subsection{blah sbs}
\subsubsection{blah sbsbs}
\paragraph{blah p}
\end{document}