The LaTeX hyphenation is very good. However, how to not apply any hyphen to the last word of every paragraph? Of course, one can use the \mbox{last word}
combination, but this is too complicated.
-
2??? This never should happen! – Bernard Apr 17 '16 at 16:14
-
1An example of a paragraph in which it happens? – User Apr 17 '16 at 16:59
-
@Bernard - Actually, it can happen -- but, realistically, only if the paragraph is fairly short and the final word of the paragraph is very long. – Mico Apr 17 '16 at 17:35
(revised answer after receiving comments by Enrico and Gustavo)
Both Plain-TeX and LaTeX provide the following default setting:
\finalhyphendemerits=5000
This parameter comes into play if the second-to-last line of a paragraph ends with a discretionary hyphen. Changing this setting to \finalhyphendemerits=200000
, say, seriously increases the penalty associated with a discretionary at the end of the second-to-last line of a paragraph -- making it (much) less likely that such a discretionary will occur.
However, if the final word of the paragraph happens to be something like "supercalifragilisticexpialidocious", TeX may still insert a discretionary hyphen in that word even if \finalhyphendemerits=1000000
is in effect, since failing to hyphenate the word could make the paragraph look (even) worse.
Here's an MWE. Observe that the first paragraph, which allows hyphenation of the final instance of "supercalifragilisticexpialidocious" even though \finalhyphendemerits=1000000
is in force, looks a whole lot better than the second paragraph, in which the final word cannot be hyphenated because of the presence of the \mbox
wrapper.
\documentclass[draft]{article} % insert a "slug" at overfull lines
\newcommand\super{supercalifragilisticexpialidocious }
\begin{document}
\finalhyphendemerits=1000000
\noindent
\super\super\super
\noindent
\super\super\mbox{\super}
\end{document}
-
Demerits are in the order of badness squared; there's no concept of infinite demerits – egreg Apr 17 '16 at 17:10
-
-
OOC, where do people learn this stuff? Is there like *The TeX Standard for Dummies" or something? I don't even know how I would begin to find out this information besides internet Q&A sites. – user1717828 Apr 17 '16 at 18:19
-
-
3@user1717828 - Chapter 14 ("How TeX breaks paragraphs into lines") of Knuth's TeXbook and Chapter 19 (title: "Line breaking") of Eijkhout's TeX by Topic are probably the canonical references for line-breaking matters. – Mico Apr 17 '16 at 18:49