# Why doesn't TeX hyphenate a really long word for which I've indicated some permissible hyphenation points?

Based on Automatic long word breaking in whole document I constructed an example of hyphenating a long word:

\documentclass{report}
\usepackage[english]{babel}
\begin{document}
\selectlanguage{english}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod temporincididuntutlaboreetdoloremagnaaliquaUtenimadminimveniamquisnostrudexercitationullamcolaborisnisiut aliquip ex ea commodo consequat.
\end{document}


However, it doesn't work. Can you help?

• Actually, TeX is working exactly as it is supposed to. See my answer for an analysis of what's problematic about your paragraph that contains a 105-character word with only 2 permissible hyphenation points. – Mico Jan 29 '19 at 6:08
• Another good way to improve the line-breaking is to load microtype with font expansion. It does not currently work in XeTeX, but can dramatically reduce the amount of hyphenation needed. – Davislor Jan 29 '19 at 6:22

The \hyphenation directive doesn't just let you indicate some possible hyphenation points for a given "word" in the directive's argument. Instead, the hyphenation points you indicate are the only possible hyphenation points.

By construction, you are not allowing TeX to hyphenate the three substrings

temporincididuntutlaboreetdolo
remagna


if they occur inside the 105-character [!!] string

temporincididuntutlaboreetdoloremagnaaliquaUtenimadminimveniamquisnostrudexercitationullamcolaborisnisiut


Don't be surprised, then, that TeX does not insert hyphenation points in any of the three substrings.

If full justification of paragraphs is active, which is the case by default, TeX must also obey some fairly stringent rules regarding (a) how much inter-word whitespace is allowed to stretch and (b) the tolerance for under-full lines. For all practical purposes, it suffices to know that overstretched inter-word whitespace is penalized very heavily and that under-full lines are also penalized. To get a sense of just how badly whitespace would have to be stretched in order to line-break your superlong word at one of the two permissible hyphenation points, consider the first paragraph below. It is typeset under the \sloppy directive, which suspends most of TeX's penalties related to (a) the stretchiness of inter-word whitespace and (b) under-full lines. Observe the huge interword spaces in the first two lines and a seriously under-full third line. Not just "sloppy", but an outright assault on one's eyes!!

To restore a semblance of decent typography, it's necessary to issue the directive \raggedright; see the second paragraph. Note that the huge amounts of inter-word whitespace in the first two lines of the paragraph are gone -- at the non-negligible cost of having two additional grossly under-full lines. Observe that the 105-character word does get hyphenated if \raggedright is in effect. This is because \raggedright imposes a penalty for (seriously) over-full lines. By default, the \raggedright setting disables most hyphenation operations, since each "act" of hyphenation carries a sizable TeX penalty. But, for the paragraph at hand, the over-full line carries a larger penalty than does the act of hyphenation.

Incidentally, if one omits the \hyphenation instruction, TeX is able (somewhat surprisingly, to me at least) to find reasonably "decent" hyphenation points.

\documentclass{report}
\usepackage[english]{babel}
%%\selectlanguage{english} % not needed

\usepackage{showframe} % to indicate edges of text block

\begin{document}
\sloppy
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod temporincididuntutlaboreetdoloremagnaaliquaUtenimadminimveniamquisnostrudexercitationullamcolaborisnisiut aliquip ex ea commodo consequat.

\medskip
\fussy % opposite of "\sloppy"
\raggedright % suspend full justification
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod temporincididuntutlaboreetdoloremagnaaliquaUtenimadminimveniamquisnostrudexercitationullamcolaborisnisiut aliquip ex ea commodo consequat.

\end{document}

• also classic tex only looks up a maximum of 64 character words in the hyphenation trie (luatex 256) characters after that are not considered. – David Carlisle Jan 29 '19 at 8:03
• @DavidCarlisle - Thanks for this. For some time now, I've been using LuaLaTeX as the default on my system, and it thust didn't even occur to me this morning to remember that (pdf)(La)TeX has a 64-character limit on maximal word length for hyphenation tries. – Mico Jan 29 '19 at 11:29