5

I have a chapter title that is too long to fit onto one line in the table of contents, but LaTeX does keep it in one line, producing an overfull line in the TOC. How can I insert a line break into this title so that to break it only in the TOC, not when it appears as a chapter heading?

I tried \protect\linebreak[1], but it did the opposite: it broke the line in the chapter heading but not in the TOC.

Here is a simplified version of my source (not quite a minimal example though):

\documentclass[a4paper,12pt]{scrbook}

\usepackage[utf8]{inputenc}  % UTF-8 input encoding
\usepackage[T1]{fontenc}     % for hyphenation to work with
                             %   accented letters, etc.
\usepackage{lmodern}         % modern latin font

\usepackage[french]{babel}   % language support

\usepackage[hmargin=3.5cm,vmargin=3.5cm]{geometry}

\usepackage{tocstyle}

\usetocstyle{KOMAlike} % defined in tocstyle package

\renewcommand{\thechapter}{\Roman{chapter}}

\begin{document}

\frontmatter

\tableofcontents

\mainmatter

\chapter{Un chapitre}

\chapter{Deux chapitre}

\chapter{Systèmes d'équations différentielles
  linéaires à coefficients \protect\linebreak[1]constants}

\section{Généralités}

\section{Résolution d'un système d'ordre $1$
  par diagonalisation ou par triangularisation}

\end{document}
Alexey
  • 2,099

1 Answers1

6

an alternative form of a title or heading is often provided as an option:

\chapter[optional form](form in chapter}

the \linebreak could then be put only in the optional form.

this, of course, will also mess up running heads, but they can be fixed with

\markboth{left page}{right page}

this question addresses the opposite requirement -- break in the chapter title, but none in the toc: Avoid hyphenation in chapter title

  • I will wait to see if there will be any more answers. Ideally i would like to not to have to type the same title twice, but only to configure line breaking. – Alexey Sep 08 '16 at 15:31
  • the ams document classes offer an alternative mechanism. it's described in the ams author faq, at http://www.ams.org/faq?faq_id=238 -- look for the entry that is surrounded by a red box. i don't know whether it would work with a koma class, but may be worth a try. if if does work, let me know, and i will add the relevant details to this answer. – barbara beeton Sep 08 '16 at 15:40
  • \for and \except do not work for me with scrbook. – Alexey Sep 08 '16 at 17:44