有没有办法用 titletoc 为每个目录条目的第二行和后续行添加水平空间,无论条目的标题是否换行到第二行(如下面第一部分所示)或标题是否有手动换行符(如第二部分所示)?在此示例中,空格位于“QUAE”和“EX”之前。
\documentclass[12pt]{article}
\usepackage{titletoc}
\begin{document}
\tableofcontents
\section{CONTEXTUS ORATIONIS ALIQUOT ALCUINI OPERUM QUAE EXIMIA SELECTA SUNT}
Some text
\section{SUPPLEMENTUM B:\\ EX ALCUINI EPISTULA AD CAROLUM MAGNUM}
Some text
\end{document}
答案1
也许您已经想到了命令above-code
的一部分?例如,\titlecontents
您可以使用。\hangindent1em
\documentclass[12pt]{article}
\usepackage{titletoc}
% According to the manual, this approximates the settings for \section
% in the book class ... except for the "\hangindent1em"
\titlecontents{section}
[3.8em] % ie, 1.5em (chapter) + 2.3em
{\hangindent1em}
{\contentslabel{2.3em}}
{\hspace*{-2.3em}}
{\titlerule*[1pc]{.}\contentspage}
\begin{document}
\tableofcontents
\section{CONTEXTUS ORATIONIS ALIQUOT ALCUINI OPERUM QUAE EXIMIA SELECTA SUNT}
Some text
\section{SUPPLEMENTUM B:\\ EX ALCUINI EPISTULA AD CAROLUM MAGNUM}
Some text
\setcounter{secnumdepth}{0}
\section{SUPPLEMENTUM B:\\ EX BEZOS DOCUMENTO AD LECTOREM CANDIDUM ET BENEVOLUM}
Some text
\end{document}