I have some very long section titles and do not want their entries in the TOC to be hyphenated.
\documentclass{scrreprt}
%\usepackage[ngerman]{babel}
\usepackage{tocloft}
\cftsetindents{section}{0mm}{12mm}
\cftsetindents{chapter}{0mm}{12mm}
\begin{document}
\tableofcontents
\chapter{Introduction}
\section{This kind of problem, that kind of problem, other ones and further considerations}
\section{More problems, even more problems, much worse than these, headline hyphenation, and blablablablablablablablabla and XYZ-blablablablablablablablabla}
\end{document}
From some googling, I got the impression that \renewcommand{\cftsecfont}{\raggedright}
should help, but it does not. Neither does \begingroup \raggedright \tableofcontents \endgroup
from the only (not accepted) answer to a related question. (When I uncomment \usepackage{ngerman]{babel}
, the hyphenation of "consid-erations" changes to "consi-derations", interestingly.)
The problem occurs also when I do not use tocloft
or when I change the document class to book
, for example (with hyphenation at different syllables).
Can I make hyphenation in the TOC go away completely, without resorting to re-defining it for every offending word?! Bonus points if the solution does not make long words go over the line like the final "blabla...", even more bonus points if word combinations that contain a hyphen to begin with ("XYZ-blabla") can be brought on the same line.
\makeatletter \renewcommand{\@tocrmarg}{2.55em plus1fil} \makeatother
. The command\@tocrmarg
fills up the Right side of the TOC MARGin; it needs to be bigger than the Page NUMber WIDTH, or\@pnumwidth
.tocloft
together with a KOMA-Script class.