# Why can words with hyphen char not be hyphenated?

Assume I have a word like Baden-Württemberg. TeX can't hyphenate any of these two word parts. Why?

why isn't it something like this:

where the small ticks indicate possible hyphenation points. A technical (TeXnical) explanation is welcome.

BTW: I am not asking how to circumvent this (by using the babel shorthand "= for example).

• Because so decided Knuth. – egreg Jul 13 '12 at 19:35
• @egreg but why? I mean, what parts of TeX makes decide to disable hyphenation? Is there an explicit "if word contains hyphen char, then exit" somewhere in the hyphenation routine? – topskip Jul 13 '12 at 19:37
• See the posting Switch meaning of hyphenation commands for a LuaLaTeX-based solution, which changes all instances of - on the fly to "= if they (the instances of -) are sandwiched between two letters. Thus, Baden-Württemberg, branchen-üblich, and Gesäß-Muskulatur (and many others!) can automatically be hyphenated at many additional places. :-) – Mico Aug 7 '16 at 19:53
• @0xC0000022L See tex.stackexchange.com/a/55509/243 – topskip Jun 25 '19 at 19:16
• @topskip thanks a bunch! – 0xC0000022L Jun 26 '19 at 7:39

The TeXbook, page 454, last but one double dangerous bend paragraph

If a trial word l1 … ln has been found by this process, hyphenation will still be abandoned unless n ≥ λ + ρ, where λ = max(1,|\lefthyphenmin|) and ρ = max(1,|\righthyphenmin|). (Plain TeX takes λ = 2 and ρ = 3.) Furthermore, the items immediately following the trial word must consist of zero or more characters, ligatures, and implicit kerns, followed immediately by either glue or an explicit kern or a penalty item or a whatsit or an item of vertical mode material from \mark, \insert, or \vadjust. Thus, a box or rule or math formula or discretionary following too closely upon the trial word will inhibit hyphenation. (Since TeX inserts empty discretionaries after explicit hyphens, these rules imply that already-hyphenated compound words will not be further hyphenated by the algorithm.)

An explicit hyphen is a character whose character code matches the font's \hyphenchar value or a ligature that ends with such a character (that's why also -- or --- inhibit hyphenation).

Indeed, if you try the following example, you'll see that TeX hyphenates the compound word:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\begin{document}
\hyphenchar\font=\string"7F

\end{document}


The result is

In
Ba-
den-Würt-
tem-
berg

The T1 encoded fonts have in position 0x7F a character which is identical to the normal hyphen. Changing the \hyphenchar to denote this slot, the normal hyphen does not inhibit hyphenation any more.

• 8 consecutive lines with hyphenated words in the TeXbook (the mentioned paragraph). That should be worth a Knuth-error-award-cheque. – topskip Jul 13 '12 at 19:55
• @PatrickGundlach Read at the bottom of page 451. :) – egreg Jul 13 '12 at 19:59
• This solution works fine for me if I just load fontenc with the T1 encoding so that it uses cm-super. However, if I load lmodern as well, for example, it doesn't seem to work. Looking at the encoding files, both seem to put hyphen.alt in that spot. Does anybody know why it doesn't work with lmodern? – cfr Nov 26 '13 at 23:07
• @egreg Am I right that changing \hyphenchar ist not really a practical »solution«? One would need to change it for all fonts and fonts series in use to get uniform behaviour for a document... (and still a "= may be needed in Baden-Württemberg so there isn't much gained when typing, anyway) – cgnieder Feb 27 '14 at 11:49
• @cgnieder Yes, you're right. IIRC, there should a package that can hook the choice of \hyphenchar at every font loading; but also hyphenation patterns should be modified to have possible breaks at - (the usual hyphen). – egreg Feb 27 '14 at 11:55

The \hyphenchar\font=\string"7F seems not the correct work around for this problem, since it is not font independent.

A better way would be to set the \defaulthyphenchar=127 which seems font independent. Also hyphenation which are defined in acronyms will be correct too. BUT there are still issues when having hyphens in the text like:

Baden-W\"urttemberg
\gls{BP}-Test


If you look at "den-Würt-", it is still not split correctly into two lines. Also the last example "BP-Test" isn't split. The only work around I have found is to use "= instead of - in the text which works for now. But I would appreciate a better solution...

Here is the MWE:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}

%\usepackage{lmodern}
\usepackage{mathptmx}

\usepackage[
nonumberlist,
acronym,
nopostdot,
section]
{glossaries}

\newacronym{BP}{BP}{Borderline-Pers\"onlichkeitsst\"orung}

\defaulthyphenchar=127

\begin{document}