5

I have a (German and English) document, which uses the scrbook class fromt he KOMA package, with long German words in the chapter titles. I would like Latex to hyphenate those words when necessary, but I do not know how to do this.

A minimal example looks like this:

\documentclass{scrbook}
\usepackage[ngerman,english]{babel}
\selectlanguage{ngerman}
\hyphenation{men-schen-rechts-ana-logen}
\selectlanguage{english}
\hyphenation{}
\begin{document}
\selectlanguage{ngerman}
\chapter{Noch viel viel mehr zu menschenrechtsanalogen Dingen}
\chapter{Noch viel viel mehr zu men\-schen\-rechts\-ana\-logen Dingen}
\end{document}

I run it with xelatex hyph.tex and I get a chapter line like this:

enter image description here

and I would like to have the word "menschenrechtsanalogen" to get hyphenated.

9

Redefine \raggedsection (see p. 91--92 of the English version of the KOMA-Script manual). One option is to typeset sectioning titles justified:

\documentclass{scrbook}
\renewcommand*{\raggedsection}{}% default is \raggedright
\usepackage[ngerman]{babel}
\hyphenation{men-schen-rechts-ana-logen}
\usepackage{lipsum}
\begin{document}
\chapter{Noch viel viel mehr zu menschenrechtsanalogen Dingen}

\lipsum[1]
\end{document}

enter image description here

Another option is to use the \RaggedRight command of the ragged2e package (this combines alignment to the left and possibility of hyphenation):

\documentclass{scrbook}
\usepackage{ragged2e}
\renewcommand*{\raggedsection}{\RaggedRight}% default is \raggedright
\usepackage[ngerman]{babel}
\hyphenation{men-schen-rechts-ana-logen}
\usepackage{lipsum}
\begin{document}
\chapter{Noch viel viel mehr zu menschenrechtsanalogen Dingen}

\lipsum[1]
\end{document}

enter image description here

Note that both approaches can be combined with specifying hyphenation points manually (with \-) in the argument of \section. The motivation to do so is that there may be hyphenation points which are acceptable in the running text, but somewhat out of place in sectioning titles.

  • ugh. the section heading lines are unattractively spacy. better just to lower the penalty on hyphenation, rather than wiping out the other desirable features of \raggedsection. (i'm not in a position to look up the details at the moment.) – barbara beeton Oct 7 '12 at 11:32
  • @barbarabeeton The ragged2e option should be more attractive. – lockstep Oct 7 '12 at 11:33
  • Is there a way to get hyphenation in one heading and keep the default otherwise? – Stefan Müller Nov 8 '17 at 11:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.