梅威瑟:
\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}