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}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.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}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.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}Pitfalls
\showhyphens{word}writes the break points LaTeX knows for a word to the log.- A line that still sticks out into the margin is reported as Overfull \hbox (263.664pt too wide) in paragraph at lines 3--6. The
microtypepackage and\setlength{\emergencystretch}{1em}in the preamble give LaTeX more ways to break such a paragraph. - With
babeland several languages,\hyphenationapplies to the language that is active where the command stands.
Compiled with pdfLaTeX from TeX Live 2023.
Related pages
- Package
babel - Package
fontenc - Package
microtype - Error Overfull \hbox (263.664pt too wide) in paragraph at lines 3--6
- How-to Non-breaking space in LaTeX