3

When badness exceeds \hbadness, there should be Underfull. When badness exceeds \tolerance, there should be Overfull. Origin story.tex file is

\hrule
\vskip 1in
\centerline{\bf A SHORT STORY}
\vskip 6pt
\centerline{\sl by A. U. Thor}
\vskip .5cm
Once upon a time, in a distant
   galaxy called \"O\"o\c c,
there lived a computer
named R.~J. Drofnats.

Mr.~Drofnats---or ``R. J.,'' as he preferred to be called---% error has been fixed! was happiest when he was at work typesetting beautiful documents. \vskip 1in \hrule \vfill\eject

After tex command, \hsize=1.5in \tolerance=10000\raggedright\hbadness=-1 \input story was input, then \end, but the log file showed

Underfull \hbox (badness 230) in paragraph at lines 7--11
\tenrm in a dis-tant galaxy

\hbox(6.94444+1.94444)x108.405, glue set 1.3203 .\tenrm i .\tenrm n .\glue(\spaceskip) 3.33298 .\tenrm a .\glue(\spaceskip) 3.33298 .etc.

Loose \hbox (badness 15) in paragraph at lines 7--11 \tenrm called []O^^?o^^Xc, there lived

\hbox(9.20636+1.94444)x108.405, glue set 0.53001 .\tenrm c .\tenrm a .\tenrm l .\tenrm l .\tenrm e .etc.

The code above is only a part of all. As \hbadness=-1, so there should be Underfull every line, but why are there Loose and what does Loose mean here?

Y. zeng
  • 1,885
  • 2
    your initial description is wrong. \hbadness does not affect whether or not a box is underfull, just whether there is a warning in the log. \tolerance is unrelated to overfull boxes it is a limit on the total badness in a paragraph, see https://tex.stackexchange.com/questions/241343/what-is-the-meaning-of-fussy-sloppy-emergencystretch-tolerance-hbadness/241355#241355 – David Carlisle Nov 13 '23 at 08:43
  • @DavidCarlisle Yes. What I wanted to say is the \hbadness affects the Underfull in the log file. – Y. zeng Nov 13 '23 at 10:05

1 Answers1

5

As you state \hbadness=-1 is responsible for the classifications underfull and loose. An hbox is underfull if the glue stretches and the badness is 100 or more. If the glue stretches and the badness is less than 100 TeX calls the hbox loose.

If the glue shrinks TeX distinguishes between overfull and tight.

See page 302 of The TeXbook.


The classification occurs when TeX takes lists and packs them into boxes: A horizontal lists is transformed into an hbox and a vertical list into a vbox.

The badness of the constructed hbox is computed. If it is larger than \hbadness TeX writes a message to the log file based on a comparison against the hard-coded value 100; the message depends of the way how the glue has to be changed.

If the glue has to stretch it writes: If the badness is larger than 100 underfull, otherwise loose.

If the glue shrinks it writes: If the badness is larger than 100 overfull, otherwise tight.

(A similar thing is done for vboxes and the parameter \vbadness.)

A second classification occurs with the line breaking algorithm. During this procedure every line is assigned a fitness class based on its badness and the change of the glue, i.e, if it stretches or shrinks: tight, decent, loose, very loose.

A line with badness larger than 12 and glue that shrinks is tight; with glue that stretches and a badness larger than 99 the line is called very loose, with badness larger than 12 and less than 100 loose. A decent line has a badness less than 13 and its glue might stretch or shrink or be kept at the natural width.

Therefore the words 'tight' and 'loose' are used in two different contexts. A line with fitness class decent or tight might be tight or overfull for the packaging; a line with fitness class decent, loose, or very loose loose or underfull.

Udo Wermuth
  • 2,612
  • I have set \badness=-1, so when badness is more than -1, there should be underfull, but why did you say An hbox is underfull if the glue stretches and the badness is 100 or more? I once think 100 is the the default value here, but hbadness=-1 will reset it. – Y. zeng Nov 13 '23 at 08:30
  • 4
    @Y.zeng no, \hbadness has no effect on tex's output, it just affects when boxes are reported in the log. loose is always badness between 13 and 100 – David Carlisle Nov 13 '23 at 08:49
  • @DavidCarlisle May you tell why is there a 13 here? I have never defined it. – Y. zeng Nov 13 '23 at 11:17
  • @Y.zeng it is not something you can define: it is built in to tex see the texbook on the page in Udo's answer. 13 happens to be the badness that means that glue is stretched by 50% of its stretch value (13 is approx 0.5^3*100) – David Carlisle Nov 13 '23 at 11:24
  • @DavidCarlisle On that page and the answer of Udo, only when badness is located between \hbadness and 100, it is loose, which has nothing to do with 13. – Y. zeng Nov 13 '23 at 11:30
  • @Y.zeng oh whatver page chapter 14 \ddanger A line whose badness is 13 or more has a glue set ratio exceeding 50%. We call such a line tight if its glue had to shrink, loose if its glue had to stretch, and {very loose} if it had to stretch so much that the badness is 100 or more. But if the badness is 12 or less we say that the line is {\sl ^{decent}}. Two adjacent lines are said to be {\sl {visually incompatible}/} if their classifications are not adjacent, i.e., if a tight line is next to a loose or very loose line, or if a decent line is next to a very loose one. – David Carlisle Nov 13 '23 at 11:33
  • @DavidCarlisle We do not look at the fitness classes of the line breaking algorithm, which are tight, decent for lines with shrinking glue and decent, loose, and very loose for lines with stretching glue. The distinction about tight and decent and about loose and decent is that the badness for tight and loose is 13 or larger. A line is very loose if the badness is 100 or more. See §§852 and 853 in the code (Vol.B).

    But the question is about the classification during the packaging. In the program (Vol.B) it's described in §660.

    – Udo Wermuth Nov 13 '23 at 11:53
  • @UdoWermuth yes but I think the paragraph I quote is the only one that says why it is 13 – David Carlisle Nov 13 '23 at 11:56
  • @DavidCarlisle Yes your explanation of 13 is right but here we talk about a different classification in which 13 has no relevance. – Udo Wermuth Nov 13 '23 at 11:58
  • @Y.zeng The 100 is a hard coded value in the program and thus independent of any parameter like \pretolerance, \tolerance, or \hbadness. See §660 of the program. – Udo Wermuth Nov 13 '23 at 12:01
  • @UdoWermuth What do you mean of §660? – Y. zeng Nov 13 '23 at 12:04
  • @UdoWermuth If 13 is right, why have the \hbadness=-1 here? What is its function? – Y. zeng Nov 13 '23 at 12:05
  • @Y.zeng The whole program code of TeX is written in WEB that comes in sections. The book TeX: The program that is Volume B in the Computers&Typesetting series (Vol. A is The TeXbook) numbers these sections. §660 stands for section 660 of the WEB program. – Udo Wermuth Nov 13 '23 at 12:08
  • @Y.zeng 13 belongs to a different classification: the socalled fitness classes of the line breaking algorithm. They have nothing to do with the \hbadness. The program just uses tight and loose at two different places for two different things. – Udo Wermuth Nov 13 '23 at 12:10
  • @Y.zeng The fitness classes are used to assign demerits during the line breaking as @DavidCarlisle points out. The \hbadness is a parameter to give information about the packaging und informs the user only through the log. – Udo Wermuth Nov 13 '23 at 12:13
  • @UdoWermuth What is the difference between \hbadness=-1 and \hbadness=12? – Y. zeng Nov 13 '23 at 12:15
  • @Y.zeng The first value logs every loose line but the second only those that have a badness above 12; same for tight lines. – Udo Wermuth Nov 13 '23 at 12:18
  • @UdoWermuth How do you tell tight and loose, by \hbadness? – Y. zeng Nov 13 '23 at 12:23
  • @Y.zeng You see it in the log. \hbadness works for both and you cannot split the logging. – Udo Wermuth Nov 13 '23 at 12:27