如何用数字和名称之间的固定空格代替 ToC 条目名称的固定缩进?

如何用数字和名称之间的固定空格代替 ToC 条目名称的固定缩进?

如何像第二幅图那样制作缩进?

现在看起来是这样的:

在此处输入图片描述

它看起来应该是这样的:

在此处输入图片描述

梅威瑟:

\documentclass[a4paper, 14pt, english]{extreport}

\usepackage[T2A]{fontenc}   
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{tocloft}
\usepackage[a4paper, left=25mm, right=10mm, top=20mm, bottom=20mm]{geometry}

\linespread{1.3} 
\renewcommand{\rmdefault}{ftm} 
\frenchspacing

\renewcommand{\cftchapfont}{\normalsize  } 
\renewcommand\cftchappagefont{\normalfont} 

\renewcommand{\cftbeforechapskip}{0em} 
\renewcommand{\cftparskip}{-1mm} 
\renewcommand{\cftdotsep}{1} 
\renewcommand{\cftpartleader}{\cftdotfill{\cftdotsep}} 
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}}

\cftsetindents{chapter}{0pt}{10pt} 
\cftsetindents{section}{0pt}{30pt}
\cftsetindents{subsection}{0pt}{40pt}
\cftsetindents{subsubsection}{0pt}{50pt}



\begin{document}

\tableofcontents
\thispagestyle{empty} 
\addtocontents{toc}{\protect\thispagestyle{empty}}

\chapter{test}
\section{test} 
\section{test}
\section{test}
\section{test}
\section{test}
\section{test} 
\section{test}
\section{test}
\section{test}
\section{test}
\section{test} 
\section{test}
\section{test}
\section{test}
\section{test}

\end{document}

答案1

该软件包tocloft支持这种间接方式。然而,这种修改允许所有设置通过tocloft

\documentclass{book}
\usepackage{tocloft}
\makeatletter
\renewcommand{\numberline}[1]{%
  \setbox0\hbox{#1\quad}%
  \hb@xt@\wd0{\@cftbsnum #1\@cftasnum\hfil}\@cftasnumb}
\makeatother
\begin{document}

\tableofcontents
\chapter{foo}
\section{bar}
\section{bar}
\setcounter{section}{170}
\section{bar}
\section{bar}

\end{document}

在此处输入图片描述

答案2

虽然我无法提供tocloft解决方案,但可以通过使用该tocstyle包(KOMA-Script) 及其tocfullflat选项。

\documentclass{report}

\usepackage[tocfullflat]{tocstyle}
\usetocstyle{allwithdot}
\settocstylefeature[0]{entryhook}{\normalfont}
\settocstylefeature[0]{entryvskip}{0pt}

\makeatletter
\renewcommand*{\@dotsep}{1}
\makeatother

\begin{document}

\tableofcontents

\chapter{test}
\section{test} 
\section{test}
\section{test}
\section{test}
\section{test}
\section{test} 
\section{test}
\section{test}
\section{test}
\section{test}
\section{test} 
\section{test}
\section{test}
\section{test}
\section{test}

\end{document}

在此处输入图片描述

相关内容