Toc:第一行的子部分标题与第二行不对齐

Toc:第一行的子部分标题与第二行不对齐

我的小节标题在第二行继续,开头有一个缩进。我希望它与小节标题的第一行对齐。有什么建议吗?

解决方案不应包含 \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

根据ToC:如何使大型条目的第二行不缩进?

\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

相关内容