There are many way to influence line breaking, and avoiding overfulls on long unbreakable pieces of text. I'm puzzled.
We are told that using \sloppy
document-wide is not good ,
that an alternative solution to \sloppy
is \emergencystretch , that microtype package can help tune linebreaking etc.
Can someone explain the effect of all the enumerated commands?
My own experiment:
\documentclass[12pt]{article}
\usepackage{showframe}
\begin{document}
\fussy
Long made-up words, fussy:
abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl
\sloppy
Long made-up words, sloppy:
abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl
\fussy
Long made-up words, textit, fussy:
\textit{abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl}
\sloppy
Long made-up words, textit, sloppy:
\textit{abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl}
\fussy
Here is a line with long unbreakable rule, fussy. \rule{3cm}{.2cm} \rule{3cm}{.2cm}
\sloppy
Here is a line with long unbreakable rule, sloppy. \rule{3cm}{.2cm} \rule{3cm}{.2cm}
\fussy
Extreme unbreakable rule, fussy. \rule{8cm}{.2cm} \rule{8cm}{.2cm}
\sloppy
Extreme unbreakable rule, sloppy. \rule{8cm}{.2cm} \rule{8cm}{.2cm}
\end{document}
As we can see, \sloppy
helps avoiding overfulls, but not in extreme cases:
Best Answer
\sloppy
is a latex macro that does\fussy
sets the values back to the latex defaults\tolerance
sets the maximum "badness" that tex is allowed to use while setting the paragraph, that is it inserts breakpoints allowing white space to stretch and penalties to be taken, so long as the badness keeps below this threshold. If it can not do that then you get overfull boxes. So different values produce different typeset result.\emergencystretch
(added at TeX3) is used if TeX can not set the paragraph below the\tolerance
badness, but rather than make overfull boxes it tries an extra pass "pretending" that every line has an additional\emergencystretch
of stretchable glue, this allows the overall badness to be kept below 1000 and stops TeX "giving up" and putting all stretch into one line. So\emergencystretch
does not change the setting of "good" paragraphs, it only changes the setting of paragraphs that would have produced over-full boxes. Note that you get warnings about the real badness calculation from TeX even though it retries with\emergencystretch
the extra stretch is used to control the typesetting but it is not considered as good for the purposes of logging.\hfuzz
does not affect the typesetting in any way but just stops TeX complaining if the box is is only slightly over-full.\hbadness
not used in\sloppy
but used in the final example below` is similar, it does not affect the typesetting but stops TeX warning about underfull boxes if the badness is below the given amount.The main problem with
\sloppy
is the setting of\tolerance
to 9999 which is almost infinitely bad. That does not distribute the white space evenly but encourages individual lines of the paragraph to stretch the white space to arbitrarily large amounts. This was an acknowledged deficiency in TeX and why in TeX3 the new parameter\emergencystretch
was added. Unfortunately when adding\emergencystretch
to\sloppy
when definining it for LaTeX2e, we didn't reduce the\tolerance
setting, but left it at 9999, which is probably good for compatibility with LaTeX2.09, but bad for everything else.Note final settings show that often you get a better setting with just setting
\emergencystretch
and not changing\tolerance
at all, the setting is the same in both cases, but\hbadness=10000
silences the warnings. Not everyone would want the final setting without being warned about it, but in automatic typesetting contexts where changing the input is not a possibility and you never want over-full boxes, this is a possibility.