Hyphenation in LaTeX (babel, hyphenation, soft hyphen)

LaTeX hyphenates words automatically with the patterns of one language, American English by default. Load babel with the language of the document. For a word that is still broken wrongly, mark the break points with \- or list the word in \hyphenation{...}.

Set the language

\usepackage[ngerman]{babel} loads the German hyphenation patterns; other languages work in the same way. With pdfLaTeX also load fontenc with T1, otherwise words that contain umlauts or accents are hardly hyphenated at all.

Complete document:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\begin{document}
Die Überraschungsmöglichkeiten der Datenbankverwaltung und der
Lebensversicherungsgesellschaft bleiben im Satzspiegel.
\end{document}
Result
The compiled example

Open in the editor

Break points for one occurrence

\- marks a place where the word can be broken. A word that contains \- is broken only at the marked places, and only this one occurrence is affected.

The manu\-script is stored in the data\-base.
Result
The compiled example

Open in the editor

Break points for the whole document

\hyphenation{...} in the preamble takes a list of words separated by spaces, with a hyphen at each allowed break point. It applies to every occurrence. A word listed without a hyphen is never broken.

This goes into the preamble.

\hyphenation{data-base man-u-script LaTeX}

Open in the editor

Prevent hyphenation in one place

\mbox{word} keeps this one occurrence of the word in one piece.

The product is called \mbox{SuperCalculator} in every market.
Result
The compiled example

Open in the editor

Words with a hyphen

A word that contains a hyphen is broken only at that hyphen. With babel and ngerman, "= prints a hyphen and still allows the parts to be hyphenated; "- adds a break point and keeps the automatic ones; "~ prints a hyphen at which the line does not break.

Complete document:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\begin{document}
Die Hochschul"=Informations"=Systeme, das Staats"-examen
und die E"~Mail.
\end{document}
Result
The compiled example

Open in the editor

Pitfalls

Compiled with pdfLaTeX from TeX Live 2023.

Related pages