Fix Overfull & Underfull \hbox Warnings in LaTeX
An 'Overfull \hbox' warning means a line is too wide to break cleanly, often a long word or URL. Fix it with hyphenation hints, microtype, or rewording.
An "Overfull \hbox" warning means a line is too wide to break within the text width — usually a long word, an unbreakable URL, or a wide box — and content may poke into the margin. It's a warning, not an error: the PDF still compiles. Fix it by allowing hyphenation, wrapping URLs in \url, loading microtype, or rewording. Here's how to diagnose and fix it.
1. Decide if it matters
LaTeX reports the overflow in points: Overfull \hbox (15.2pt too wide). A few points is often invisible — check the PDF before chasing it. Tens of points usually means something visibly sticks past the margin and should be fixed.
2. The most common cause: long URLs and strings
\usepackage{url} % or hyperref
...
See \url{https://example.com/a/very/long/path/that/overflows}
\url allows breaks at slashes and dots — see hyperref. Long URLs don't hyphenate on their own, so this is the #1 fix.
3. Help LaTeX hyphenate
super\-cali\-fragi\-listic % \- marks allowed break points
\hyphenation{data-base manu-script} % preamble: global hints
\- inserts optional hyphenation points in one word; \hyphenation{} teaches LaTeX to break specific words anywhere they appear.
4. Load microtype (often the single best fix)
\usepackage{microtype}
microtype enables character protrusion and font expansion, which subtly adjusts spacing so far fewer lines overflow — a near-free improvement to any document. Add it to almost every project.
5. Last resorts and Underfull boxes
| Situation | Fix |
|---|---|
| One stubborn paragraph | Wrap in \begin{sloppypar}...\end{sloppypar} |
| Whole document loose breaks | \sloppy (use sparingly) |
| Wide table/image | Resize — see tables, images |
| Underfull \hbox (loose line) | Remove a manual \\, reword |
An Underfull \hbox is the opposite — LaTeX stretched a line to fill the width, leaving loose spacing. Often it's a stray \\ forcing a short line; remove it. Both are on our common LaTeX errors list.
→ Spot and fix spacing warnings with instant visual preview in LetX.
Written by Shihab Shahriar Antor — AI Engineer & Founder of Shahriar Labs, maker of LetX.
Frequently Asked Questions
Is an Overfull \hbox an error or just a warning?
It's a warning, not an error — the document still compiles and produces a PDF. But it signals that a line couldn't be broken within the text width, so content may stick into the margin. LaTeX prints the overflow amount in points; a tiny value (under a few points) is often invisible and safe to ignore, while a large one (tens of points) usually shows a word or box poking past the margin that you should fix.
How do I fix an Overfull \hbox caused by a long URL?
Long URLs don't hyphenate by default, so they overflow. Load the url package (or hyperref) and wrap the address in \url{...}, which allows breaks at sensible points like slashes and dots. For arbitrary long strings, the seqsplit package or inserting \allowbreak at break points helps. As a blunt fix, \sloppy loosens spacing rules for a region, though it can produce loose lines, so prefer \url for addresses.
What does an Underfull \hbox mean and should I worry?
An Underfull \hbox (or \vbox) means LaTeX stretched a line or page more than it likes to fill the width or height, producing loose, widely spaced text. It's a quality warning, not a failure. Common causes are a forced line break with \\ in normal text, a short paragraph in a narrow column, or \sloppy. Often it's harmless; if the spacing looks bad in the PDF, reword the line or remove the manual break.