![Toc:第一行的子部分标题与第二行不对齐](https://linux22.com/image/380926/Toc%EF%BC%9A%E7%AC%AC%E4%B8%80%E8%A1%8C%E7%9A%84%E5%AD%90%E9%83%A8%E5%88%86%E6%A0%87%E9%A2%98%E4%B8%8E%E7%AC%AC%E4%BA%8C%E8%A1%8C%E4%B8%8D%E5%AF%B9%E9%BD%90.png)
我的小节标题在第二行继续,开头有一个缩进。我希望它与小节标题的第一行对齐。有什么建议吗?
解决方案不应包含 \usepackage{tocloft},因为这会干扰之前的设置
\documentclass[11pt,a4paper,doc,donotrepeattitle]{apa6}
\begin{document}
\renewcommand*\contentsname{Table of Contents}
\tableofcontents
\section{Title}
\subsection{Long title that spans over two lines}
\end{document}
答案1
\documentclass[11pt,a4paper,doc]{article}
\usepackage{tocloft}
\renewcommand*\contentsname{Table of Contents}
\setlength{\cftsubsecnumwidth}{0pt}
\renewcommand{\cftsubsecaftersnumb}{\hspace{1.5em}}
\begin{document}
\tableofcontents
\section{Title}
\subsection{Long title that spans over two lines Long title that spans over two lines}
\end{document}
答案2
\makeatletter
\renewcommand*\l@section[2]{%
\ifnum \c@tocdepth >\z@
\addpenalty\@secpenalty
\addvspace{1.0em \@plus\p@}%
\setlength\@tempdima{0em}%
\begingroup
\parindent \z@ \rightskip \@pnumwidth
\parfillskip -\@pnumwidth
\leavevmode \bfseries
\advance\leftskip\@tempdima
\hskip -\leftskip
#1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
\endgroup
\fi}
\renewcommand*\l@subsection{\@dottedtocline{2}{1.5em}{0em}}
\renewcommand*\l@subsubsection{\@dottedtocline{3}{3.8em}{0em}}
\makeatother