What are underfull hboxes and vboxes and how can I get rid of them?

TeX puts elements (letters, lines, paragraphs, pictures,...) in boxes and joins them together on pages using glue (put between them) that can stretch, e.g., to make sure that lines are justified, or that pages are filled to their specified height. In the first example, the line is put in a hbox (horizontal box, or box with material arranged horizontally with respect to one another, words in this case), in the second, the page is put in a vbox (vertical box, or box with material arranged vertically with respect to one another, usually paragraphs and displayed equations in this case).

Such a box is underfull in case TeX has to stretch the glue more than what is specified to be (aestethically) acceptable. In that case there will, e.g., be much whitespace between words of a line (hbox case) or extra whitespace between paragraphs (vbox case).

To avoid underfull hboxes (and also overfull ones), one can, in LaTeX, use the microtype package, which, when used in pdflatex mode (directly generating a .pdf file, and not a .dvi one), can stretch letters as well, which allows TeX to get acceptable whitespace in lines more often.

Another, manual route is to reformulate sentences and paragraphs, or add explicit hyphenation (e.g., hyphen\-ation) to get better linebreaks. One can sometimes even fix bad pagebreaks (overfull vboxes) in this way as well, by shortening or lengthening paragraphs with one line.


An underfull hbox means LaTeX couldn't space the line wide enough to fill the entire width of the page, without increasing word spacing beyond the allowed maximum; the opposite is an overfull hbox, where a line couldn't be broken and extends past the edge of the printable area. Usually it happens if you forced a linebreak yourself (with \\), so if you avoid doing that this should be pretty rare (other causes are weird tabular environments or forced blank lines)


Typically \\ will cause this because you have a blank line with no content (where the TeX algorithm expects content). You could get rid of those and space correctly (if you want extra space between paragraphs, use, e.g., \setlength{\parskip}{6pt}). It also can occur when you have a really long object in a paragraph that is not enough to fill it completely (hence "underfull"). Lastly, in some cases, if you have really long words, the TeX algorithm has a difficult time finding a proper way to justify the paragraph without having underfull boxes (the text doesn't meet the very end of the line). You can avoid this by using some shorter words or rewriting some stuff to accommodate the algorithm.