[Tex/LaTex] Overfull/Underfull \hbox warnings when compiling the document

warnings

I have bunch of pgfplots (plots and bar charts in my document) and when I compile I get errors like:

Overfull \hbox (1.17287pt too wide) in paragraph at lines 2121--2122
 [][] 
[35]

Sometimes it also tell underfull as well. What does these mean ? Any general pointers on how to solve them ? Do they mean anything bad ?

Best Answer

Let's start with a quote from Knuth's TeXbook (Chapter 11)

TeX makes complicated pages by starting with simple individual characters and putting together in larger units, and putting these together in still larger units, and so on.

Whenever you look at a (La)TeX document, imagine putting on a pair of glasses that allows you to 'x-ray' the page's structure- what you would see is that each page is made up of boxes.

In particular, there are horizontal boxes (hboxes) and vertical boxes (vboxes). TeX is able to make beautiful documents by making the content of each box fit 'ideally' using its stretchable glue. When something simply will not fit, either because it is too big or too small, then you get overfull and underfull boxes respectively.

When TeX encounters such situations, it is kind enough to tell you in the .log file so that you can make a decision for yourself as to whether you need to make changes; ultimately, you have to decide if you think they mean anything bad. Note that TeX will also give you a badness rating, with 10000 being the worst.

If you prefer a more visual approach, then you can load the draft option to your documentclass, for example

 \documentclass[draft]{article}

which ensures that your output is highlighted with black boxes in any of the offending areas.

For more details see any of the 'related' links on the right hand side of this page, perhaps starting with What does "overfull hbox" mean?

In terms of your 'specific' case, it sounds like one of your graphs is over-stretching its boundaries- perhaps it is going over a minipage, or into the page margin. If you're happy with the output, then you typically don't have to worry too much (unless the people viewing your document are also going to grep your .log file).

Related Question