# badness for lines without glue?

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?
• if the line can not stretch then it will be infinitely bad (10000) why would you not want to add glue at the end? – David Carlisle Sep 19 '14 at 8:36

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:

\documentclass{article}

\begin{document}

\raggedright

abcdef\linebreak[2]ghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz%
abcdefghijklmnopq\linebreak[3]rstuvwxyzabcdefghijklmnopqrstuvwxyz%
abcdefghijkl\linebreak[3]mnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz%
abcdefghijklmnopqr\linebreak[1]stuvwxyzabcdefghijklmnopqrstuvwxyz%
abcdefghijklmnopqrstuvwxyzabcde\linebreak[0]fghijklmnopqrstuvwxyz%
abcdefgh\linebreak[4]ijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz%
abcdefghijklmnopqr\linebreak[0]stuvwxyzabcdefghijklmnopqrstuvwxyz%
abcdefghijklmnopqrstuvwxyza\linebreak[0]bcdefghijklmnopqrstuvwxyz%
abcdefghijklmn\linebreak[0]opqrstuvwxyzabcdefghijklmnopqrstuvwxyz%

\end{document}


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}}

\bye


which produces

Underfull \hbox (badness 10000) detected at line 1
[]
> 10000.

?
> 0.

?
> 1000000.

?

Overfull \hbox (0.20001pt too wide) detected at line 10
[]|
> 1000000.


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%
\specialpar

\bye


Here's the printed output

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
10.pfb>
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.