[texhax] TeX Queries 4: Overfull boxes

Reinhard Kotucha reinhard.kotucha at web.de
Thu Aug 2 00:56:41 CEST 2012


On 2012-08-01 at 15:08:56 +0100, Philip TAYLOR wrote:

 > Paul Stanley wrote:
 > > Anything else the list considers important about overfull boxes?
 > 
 > They almost always indicate an error (in thinking, or in
 > coding, or in allowing for boundary conditions, or whatever)
 > but not always; and they can generate horrible black solid
 > boxes (real boxes, at least as far as ink or toner can make
 > a real box) when they occur in typeset lines.

An overfull \hbox actually means that material is printed into the
margin.  In most cases this happens if words cannot be hyphenated.
Though TeX's paragraph formatting algorithm does a very good job in
order to avoid such problems (by trying other breakpoints), there is
not much freedom at the beginning of a paragraph.

In some cases overlong lines cannot be avoided, for instance in
fragments of computer code where the original linebreaks have to be
preserved.

The black boxes which are appended to overfull lines are a feature of
TeX.  The plain TeX format sets \overfullrule=5pt just to indicate
overlong lines visually.  Hence, Phil, they look horrible on purpose. 

If in the final document some overfull \hbox'es are unavoidable, one
can set \overfullrule=0pt and the black boxes will disappear (default
in LaTeX, unfortunately).  However, it's better to increase the value
of \hsize temporarily when computer code is typeset.  This allows to
write into the margin but you'll be warned if the increased value is
exceeded. 

 > > I'll leave "underfull" for another thread, unless the list
 > > considers it relevant.
 > 
 > An underfull box will usually contain more white space than
 > is optimal for the size of the box and the size of the contents.
 > (perhaps "will always contain" : I'd need to think about this).

Didn't you write a TUGboat article about all these things (fine-tuning
TeX documents in order to avoid overfull boxes) many years ago?

 > How the space is distributed is very much a function of the
 > contents of the box.  And of course the "white space" is virtual
 > white space : a gap will be left in the corresponding typeset
 > output, which will then be filled with the default background
 > colour for that region.

Since TeX is not aware of background colours (or colours in general),
it only leaves a gap (interword glue, in TeX parlance).  It doesn't
fill anything with colours.

Backgrounds (either coloured rectangles or pictures) can be inserted
by PostScript or PDF backends via \special or \pdfliteral.  They have
to be inserted immediately after a pagebreak and before anything is
typeset.  It's usually required to hook into the output routine.  

But because TeX passes such instructions literally to backends or
post-processors, all these wonderful things happen behind its back.

Regards,
  Reinhard

-- 
----------------------------------------------------------------------------
Reinhard Kotucha                                      Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover                              mailto:reinhard.kotucha at web.de
----------------------------------------------------------------------------
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.
----------------------------------------------------------------------------


More information about the texhax mailing list