Tx · LaTeX & TikZ

What Does “Underfull \hbox (badness 10000)” Mean in LaTeX?

Published By the 9to5Science editorial team

At a glance

  1. 1. Read the warning

    LaTeX could not make a paragraph line fill its available width satisfactorily.

  2. 2. Check the context

    Look at the reported source lines, especially narrow parboxes, forced line breaks, and short nonfinal lines.

  3. 3. Choose a remedy

    Allow ragged-right text, widen or reword the paragraph, or adjust line-breaking only when needed.

An Underfull \hbox (badness 10000) message is a typesetting warning, not a fatal error. It says a horizontal box—often a line of a paragraph—was not filled to its target width with acceptable spacing. In a justified paragraph, this often happens in a narrow \parbox, where full justification has little room to work.

The warning usually does not stop LuaLaTeX from producing a PDF. The right response is to inspect the affected paragraph and decide whether its spacing needs attention; suppressing the message without fixing the layout may hide a real problem.

What “underfull” and “badness 10000” mean

In justified text, TeX adjusts the flexible spaces between words so that a line reaches both margins. If it must stretch those spaces too much, the line is underfull. TeX calculates a badness value to describe how undesirable the adjustment is. The value is capped at 10000, so badness 10000 means the line reached or exceeded that maximum—not that there are 10,000 separate errors.

The location, such as at lines 36--37, points to the approximate source lines that contributed to the paragraph. It does not necessarily identify a single faulty command, and it refers to your source file rather than printed page lines.

A \parbox typesets its contents as a paragraph in a fixed-width box. By default, paragraph text is justified, so a narrow box can make some lines difficult to set evenly. A short final line is normally fine: TeX treats the last line of a paragraph differently. The warning is more concerning when it points to an awkwardly spaced line in the middle of a paragraph.

A practical fix for a narrow parbox

If the box is a narrow label, note, or sidebar, ragged-right text is often more natural than forcing every line to reach the right edge. \raggedright is built into LaTeX; no extra package is needed.

\documentclass{article}

\begin{document}
\noindent
\parbox{3cm}{\raggedright
This is a narrow column with a short paragraph. TeX does not need to stretch spaces to make every line reach the right edge.
}
\end{document}

Compile this complete example with LuaLaTeX or another standard LaTeX engine. The key change is \raggedright inside the box. It changes the paragraph’s alignment, so the lines can end unevenly at the right rather than requiring stretched interword spaces. Use it only when that appearance fits the design; for a fully justified paragraph, address the content or width instead.

How to diagnose the affected paragraph

  1. Find the reported source lines and identify the paragraph they belong to. A paragraph can span several source lines, so inspect the whole paragraph, not just the last line number.
  2. Check whether it is inside a \parbox, minipage, table cell, or another narrow container. These contexts give TeX less width for line breaking.
  3. Look for explicit \\ or \newline commands inside the paragraph. Forced breaks can leave TeX with a line that cannot be adjusted as it normally would.
  4. Check for long words, URLs, inline formulas, or text that has few legal break points. TeX may not be able to find a good line division even when the box is not especially narrow.
  5. Inspect the PDF at the reported location. If the line looks acceptable, the warning may not require a change; if the spaces are conspicuously wide, revise the layout or wording.

Other ways to improve the line

  • Widen the box if the design allows it. A small increase can give TeX more possible line breaks and reduce the amount of stretching needed.
  • Reword the paragraph or replace a long phrase with shorter words. This gives TeX more opportunities to form balanced lines.
  • Remove unnecessary forced breaks. Let TeX wrap the paragraph automatically unless a line break is part of the intended design.
  • Use ragged-right alignment for short or narrow text where flush-right edges matter less than even word spacing.
  • Consider a local line-breaking adjustment only when the text must remain justified. For example, if TeX reaches its emergency line-breaking pass, a small \emergencystretch can give it extra flexibility when choosing breaks. Apply adjustments narrowly rather than changing spacing throughout the document.

Common mistakes

Treating the warning as a LuaTeX failure. The message concerns paragraph layout; it does not by itself mean LuaTeX or a font is broken.

Making the whole document \sloppy immediately. This can reduce some warnings by allowing looser spacing, but it may make many paragraphs look worse. Fix the specific box or paragraph first.

Assuming every short line is a problem. A paragraph’s final line is expected to be shorter than the others. Judge the result in the PDF, not by the warning alone.

Confusing underfull with overfull. An overfull \hbox means material could not fit and may protrude into the margin. An underfull \hbox means its contents did not fill the target width cleanly; for a paragraph line, this often means the available glue had to stretch too much. The remedies can differ, so check the exact message.

If the warning points to a \parbox and the PDF shows visibly loose spaces, the most direct options are usually to allow ragged-right text or give the box more width. If the output looks good, the warning can be harmless, but it is worth checking the cited paragraph before ignoring it.

References

  1. The TeXbook, Donald E. Knuth
  2. LaTeX: A Document Preparation System, Leslie Lamport

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.