如何强制在目录中换行?

如何强制在目录中换行?

我正在写一篇很长的文档,在某个时候,目录发生了这种情况:

我希望能够强制在“复杂”和“空间”之间换行,可以直接换行,或者通过对行长度或行与数字之间的分隔或任何此类相关长度施加适当的限制。

下面是一个最小的工作示例,

\documentclass[pdftex,11pt,twoside,a4paper]{report}

\usepackage[a4paper, left=3cm, right=3cm, top=3cm, bottom=2cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{lmodern} % load a font with all the characters
\usepackage[colorlinks,linkcolor=blue,final]{hyperref}
\usepackage{tocloft}

\usepackage{lipsum}


%%% Headers
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\setlength{\headheight}{14pt} 
\fancyhead[LE]{\thepage}
\fancyhead[RE]{Electron dynamics in complex space and complex time}
\fancyhead[LO]{\nouppercase{\leftmark}}
\fancyhead[RO]{\thepage}

\renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}}


\begin{document}

\tableofcontents  
\setcounter{page}{100}
\chapter{Quantum orbits as trajectories through complex time and complex space}
\lipsum[1-16]

\end{document}

包括文档中使用的标题;显然,所有非 Lipsum 包在较大的文档中都是必需的。我该如何修复这个丑陋的问题?

答案1

您可以使用以下方式指定章节

\chapter[Quantum orbits as trajectories through complex time and complex \texorpdfstring{\\}{} space]% ToC/Header
  {Quantum orbits as trajectories through complex time and complex space}% Document
% Correct header setup to not insert a line break
\markboth{\thechapter.\ Quantum orbits as trajectories through complex time and complex space}{}

可选参数\chapter设置 ToC标题条目。因此,我们复制通常的做法\chaptermark,以纠正在标题内插入换行符的情况。

或者,增加ToC 内的page number和/或设置ter 相关条目的对齐方式以包含对齐方式:widthchap\raggedright

\cftsetpnumwidth{3em}% Default is 1.55em
\cftchapfont{\bfseries\raggedright}% Default is \bfseries

在此处输入图片描述


memoir提供了通过以下方式明确设置所有三种可能性的选项

\chapter[<toc>][<head>]{<title>}

相关内容