I want to typeset a special paragraph which have some penalty items inside it but no glue. TeX always produces an overfull box for this paragraph.

I have two questions:

  1. What is the line badness if there is no glue inside it? 0, 100 or 10000?
  2. How to make TeX break at some penalty items to produce some underfull boxs rather than an overfull box?
  • 1
    if the line can not stretch then it will be infinitely bad (10000) why would you not want to add glue at the end? Sep 19, 2014 at 8:36

2 Answers 2

  1. Unless the line breaks at exactly \hsize if there is no glue it will be infinitely bad (10000)
  2. TeX's line breaker is a least cost calculation so the only way to allow it to do exactly what you ask is to set \tolerance=10000 which says to accept arbitrarily bad line breaks. TeX will complain a lot in the log file.

Usually it is better to arrange that glue is added to the right hand edge of any line that is short as it has broken at a penalty, that is exactly what \raggedright does, so:

enter image description here






The badness of an overfull line without glue is 1000000 (TeXbook, page 229), but TeX won't complain if the length is between \hsize and \hsize+\hfuzz. It will be 10000 if the line is underfull. Here's an example:

\line{\hbox to\dimexpr\hsize-1sp{\hfill}}

\line{\hbox to\dimexpr\hsize{\hfill}}

\line{\hbox to\dimexpr\hsize+\hfuzz{\hfill}}

\line{\hbox to\dimexpr\hsize+2\hfuzz{\hfill}}


which produces

Underfull \hbox (badness 10000) detected at line 1
> 10000.
l.2 \showthe\badness

> 0.
l.5 \showthe\badness

> 1000000.
l.8 \showthe\badness


Overfull \hbox (0.20001pt too wide) detected at line 10
> 1000000.
l.11 \showthe\badness

You can coerce TeX into typesetting a paragraph without glue, but only penalties, making underfull boxes and without complaining about it:

\def\specialpar{{\hbadness=10000 \tolerance=10000 \par}}

abcdef\break ghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz%
abcdefghijklmnopq\break rstuvwxyzabcdefghijklmnopqrstuvwxyz%
abcdefghijkl\break mnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz%
abcdefghijklmnopqr\break stuvwxyzabcdefghijklmnopqrstuvwxyz%
abcdefghijklmnopqrstuvwxyzabcde\break fghijklmnopqrstuvwxyz%
abcdefgh\break ijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz%
abcdefghijklmnopqr\break stuvwxyzabcdefghijklmnopqrstuvwxyz%
abcdefghijklmnopqrstuvwxyza\break bcdefghijklmnopqrstuvwxyz%
abcdefghijklmn\break opqrstuvwxyzabcdefghijklmnopqrstuvwxyz%


Here's the printed output

enter image description here

and here's the terminal output

> pdftex ufull
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) (preloaded format=pdftex)
 restricted \write18 enabled.
entering extended mode
(./ufull.tex [1{/usr/local/texlive/2014/texmf-var/fonts/map/pdftex/updmap/pdfte
x.map}] )</usr/local/texlive/2014/texmf-dist/fonts/type1/public/amsfonts/cm/cmr
Output written on ufull.pdf (1 page, 16061 bytes).
Transcript written on ufull.log.

Of course, if a chunk has no penalties (here represented by \break, but any penalty will do) and is too wide for a line, there will be an overfull box anyway.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .