Why Do LaTeX Hyphenation Methods Give Different Breaks?
At a glance
- 1. Know the scope
A \- mark affects one occurrence; \hyphenation defines an exception for a word.
- 2. Check the exception
List every intended break in the word, separated by hyphens, in \hyphenation.
- 3. Check the output
Use \showhyphens to inspect candidate breaks, then test in the actual paragraph.
Title: Why Do LaTeX Hyphenation Methods Give Different Breaks? Category: latex
LaTeX offers two ways to influence hyphenation, but they are not interchangeable. The \- command marks a discretionary break in one occurrence of a word and prevents automatic hyphenation at other points in that occurrence. The \hyphenation{...} command defines an exception for a word in the current language, which LaTeX can use wherever that language is active.
The distinction matters when a word breaks at an unexpected place: adding one \- marks the only permitted hyphenation point in that occurrence, but does not set a word-level exception for other occurrences. To control the word’s hyphenation across occurrences, define an exception with all the break points you want.
What \- does
The command \- inserts a discretionary hyphenation point at its location. TeX may break the line there, printing a hyphen at the end of the line; if the line is not broken there, the hyphen does not appear. It applies to that occurrence only and prevents automatic hyphenation at other points in that occurrence.
For example:
extra\-ordinary
This marks the position after “extra” as a possible break in that instance. It does not register a lasting rule for every occurrence of “extraordinary.” In that occurrence, however, the explicit discretionary point prevents TeX from adding automatic hyphenation points elsewhere in the word.
What \hyphenation{...} does
Use \hyphenation to register a word-level exception. Put hyphens in the word where breaks are allowed:
\hyphenation{ex-tra-or-di-nary}
This tells TeX the permitted break points for the word extraordinary. The hyphens in the command are instructions, not printed characters. Crucially, an exception specifies the word’s break positions; points omitted from the exception are not supplied by the ordinary automatic patterns for that word.
Here is a minimal example:
\documentclass{article}
\hyphenation{ex-tra-or-di-nary}
\begin{document}
\showhyphens{extraordinary}
The word extraordinary may break at the points listed in the exception.
\end{document}
Compile the file and check the log for the output from \showhyphens. This command reports candidate hyphenation points; it does not force a break in the paragraph. TeX chooses an actual break only when it helps fit the text into the available line width and meets its line-breaking rules.
To compare with an occurrence-specific mark, comment out the \hyphenation line and change the paragraph to extra\-ordinary. This marks a break point for that occurrence and prevents automatic hyphenation at other points in it. To compare ordinary automatic behavior, comment out the exception and use extraordinary without \-.
Why the results can differ
The main difference is scope and effect. \- adds a discretionary point at one location and, in that occurrence, suppresses automatic hyphenation elsewhere in the word. \hyphenation declares an exception for a word in the applicable language, and the exception’s listed points take priority over the language’s general hyphenation patterns for that word.
A visible line ending is not a complete list of available breaks. Even if the word could break at several places, TeX may choose just one—or none—based on the paragraph’s line width, neighboring words, penalties, and other layout constraints. Changing the command can also change line breaking elsewhere in the paragraph.
Common mistakes
- Expecting
\-to affect every occurrence. It marks a point only in that occurrence; within it, automatic hyphenation at other points is suppressed. - Listing only one point in an exception when you want several. Include every permitted point, for example
ex-tra-or-di-naryrather thanextraordinaryif you want to allow breaks within that word. - Confusing the command’s hyphens with printed hyphens. In
\hyphenation{ex-tra-or-di-nary}, they indicate break positions and are not typeset as part of the word. - Assuming a marked point must be used. A permitted break is only an option. TeX may keep the word intact if that produces a better line break.
- Testing in a different language or font setup. Automatic patterns depend on the active language and available hyphenation patterns. A word may therefore behave differently after language or font-encoding changes.
Use \- when you need a break opportunity at one particular point in one occurrence, with no other automatic hyphenation points in that occurrence. Use \hyphenation when you need a consistent exception for a word—and list all the break points that should remain available.
References
- The TeXbook, Donald E. Knuth
- LaTeX2e unofficial reference manual
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.