[Tex/LaTex] Oddly wide spaces in subsection title

horizontal alignmentline-breakingsectioningspacing

I have a problem, this is what it looks like:

enter image description here

And this is the code:

\subsection{Bakterienst\"amme und Anzuchtbedingungen}

Where does the huge whitespace come from?

Best Answer

Obviously the whitespace comes from fully justifying. It can be fixed by switching to flush left aka ragged-right mode, at least for this heading, for example by

\subsection{\protect\raggedright Bakterienst\"amme und Anzuchtbedingungen}

I used \protect because the command is fragile and needs to be protected in a moving argument such as here. Note, you may decide to use the optional argument to get a different result for the table of contents and the page header, such as

\subsection[Bakterienst\"amme und Anzuchtbedingungen]{%
    \protect\raggedright Bakterienst\"amme und Anzuchtbedingungen}

The ragged2e package provides better commands which even allow hyphenation:

\subsection{\protect\RaggedRight Bakterienst\"amme und Anzuchtbedingungen}

Sadly, you did not provide an example. I simulate the effect of full justification and solution here, see how the small stretching is removed:

\documentclass[12pt]{scrbook}
\usepackage{ragged2e}
\usepackage[textwidth=11.1cm]{geometry}
\usepackage[ngerman]{babel}
\begin{document}
\subsection{\protect\justifying Bakterienst\"amme und Anzuchtbedingungen}
\subsection{\protect\justifying\protect\RaggedRight Bakterienst\"amme
    und Anzuchtbedingungen}
\end{document}

enter image description here

Also consider to improve justification for example by

  • loading the microtype package
  • using babel
  • using T1 font encoding

so making it possible to keep full justification with good results.