# What is the meaning of \fussy, \sloppy, \emergencystretch, \tolerance, \hbadness?

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

abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl

\sloppy

abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl

\fussy

\textit{abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl}

\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:

\sloppy is a latex macro that does

\def\sloppy{%
\tolerance 9999%
\emergencystretch 3em%
\hfuzz .5\p@
\vfuzz\hfuzz}


\fussy sets the values back to the latex defaults

\def\fussy{%
\emergencystretch\z@
\tolerance 200%
\hfuzz .1\p@
\vfuzz\hfuzz}


\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.

\documentclass[12pt]{article}
\usepackage{showframe}
\begin{document}

\def\test#1{{#1

\texttt{\detokenize{#1}}

abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl

\textit{abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl}

\textit{abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl abcdefghijklabcdefghijkl}

Here is a line with long unbreakable math, sloppy. ${a+b+c+d a+b+c+d}$ ${a+b+c+d a+b+c+d }$

Extreme unbreakable math, sloppy. ${a+b+c+d+e a+b+c+d+e a+b+c+d+e a+b+c+d+e }$ break ${a+b+c+d+e a+b+c+d+e a+b+c+d+e a+b+c+d+e }$

\nobreak\bigskip\hrule\filbreak}}

\test{}

\test{\sloppy}

\test{\setlength\emergencystretch{\hsize}}


• @Maïeul \sloppy will fix some cases that just setting \emergencystretch won't fix, but just setting \emergencystretch has the big advantage that it has no effect on good paragraphs, it only kicks in if the paragraph would otherwise have failed to be within tolerance. \sloppy changes the settings before the linebreaking is affected so can (and typically does) affect paragraphs that would have worked 9and looked better) with the default settings. Nov 26 '15 at 12:17
• @wonderich as I say here generally I'd experiment with setting \emergencystretch before using \sloppy. But there is no single right setting it depends on circumstances. (If there was a clearly best setting for all cases, latex would not have \sloppy and \fussy) Jan 28 '19 at 23:41
• Worth mentioning that one can use localized \sloppy with \begin{sloppypar} ...paragraph text... \end{sloppypar}` Sep 28 '20 at 3:20