[Tex/LaTex] How to force a line break in the table of contents

header-footerline-breakingtable of contents

I'm writing a pretty long document, and at some point this happened with the table of contents:

I would like to be able to force a line break between 'complex' and 'space', either directly or by imposing suitable limits on line lengths or the separation between the lines and the numbers, or any such relevant lengths.

A minimal working example is below,

\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}

including the headers in use in the document; obviously all of the non-lipsum packages are necessary in the larger document. How can I fix this ugliness?

Best Answer

You could specify your chapter using

\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}{}

The optional argument to \chapter sets the ToC and header entries. So we replicate the usual \chaptermark to correct for inserting a line-break inside the header.

Alternatively, increase the page number width inside the ToC and/or set the alignment of chapter-related entries to include a \raggedright alignment:

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

enter image description here


memoir provides the option of explicitly setting all three possibilities via

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