目录缩进不一致

目录缩进不一致

对于较长的目录条目,缩进不一致。 在此处输入图片描述

梅威瑟:

\documentclass[10pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\begin{document}
\tableofcontents
\chapter*{Some Text}
\addcontentsline{toc}{chapter}{The long title the long title the long title the long title the long title the long title }
\end{document}

我说的是类似的事情问题,但针对的是目录。

答案1

您需要添加带星号的部分\protect\numberline{}以获得正确的对齐。

https://latexref.xyz/_005caddcontentsline.html

西弗

% !TeX TS-program = pdflatex

\documentclass[10pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\begin{document}
\tableofcontents
\chapter*{X Some Text}
\addcontentsline{toc}{chapter}{X The long title the long title the long title the long title the long title the long title with *, not aligned}

\chapter{Y The long title the long title the long title  the long title the long title the long title, OK}

\chapter*{Z Some Tex}
\addcontentsline{toc}{chapter}{\protect\numberline{}Z The long title the long title the long title the long title the long title the long title, with *, aligned}

\end{document}

相关内容