# Exercise 6.5 Knuth's TeXbook

Running this exercise according to the suggestions on its answer in Appendix B, I got the following result :

The following lines can be seen in the log:

Loose \hbox <badness 4> ... Corresponding to the line Once upon a time

Underfull \hbox <badness 230> ... Corresponding to the line in a distant galaxy

Loose \hbox <badness 15>... Corresponding to the line called Ööç, there lived

Loose \hbox <badness 0> ... Corresponding to the line a computer named R. J.

Q1) What is the difference between a Loose box and an Underfull box ?

Q2) The 4th message above has badness = 0. So, why the warning ?

-
For an explanation of "overfull" vs. "loose" hboxes, refer to page 302 (last single "dangerous bend" of that page) of the TeXbook. –  Gonzalo Medina May 27 '11 at 18:33
\hbadness=-1 and 0>-1, so the line is reported since it's loose. The two final lines of the paragraphs are not reported as they are "decent" because of the infinite glue in them. –  egreg May 27 '11 at 18:41
@egreg Good point! Thanks. –  bellochio May 27 '11 at 18:48
Could you add the code you ran as well. Not everyone has the TeXBook at hand. –  Alan Munn Jun 18 '11 at 22:32

TeX assigns badness to the boxes it builds with a rule that depends on the amount of glue stretching or shrinking. The rule can be found in the TeXbook or in TeX by Topic.

If a box has badness b<13 it's classified decent; if 13 ≤ b < 100 the box is tight if glue had to shrink or loose if glue had to stretch. If 100 ≤ b < 10000 the box is very loose (this case can't happen with shrinking). The badness can never exceed 10000, in that case the box is underfull. The box can also be overfull, when TeX is not able to shrink the glue to fit the text in the available space; the badness is again 10000.

TeX reports boxes when their badness exceeds a threshold whose value is in the internal parameters \hbadness (for horizontal boxes) and \vbadness (for vertical boxes). In this report the terms tight, loose, underfull and overfull are used in a slightly different sense than before (the former meaning is important when demerits are assessed for typesetting a paragraph):

• loose means positive badness but less than 10000, glue had to stretch
• tight means positive badness but less than 10000, glue had to shrink

In the example, \hbadness has been set to -1, so TeX reports all boxes that are not decent (the badness can never be negative). The final lines of the paragraphs are not reported because the infinite glue in them (from \parfillskip) makes them always decent. Some of them is loose even if the badness is computed as 0 (the badness is computed as non zero and then truncated).

This can be seen with the following example:

\hbadness=-1


causes the following report

Loose \hbox (badness 0) detected at line 2
\tenrm a b

Tight \hbox (badness 0) detected at line 3
\tenrm a b


Yes, TeX is very fussy, sometimes.

-