I often see output from TeX with the warning overfull hbox, badness 10000
. What does this message mean?
-
4Possible duplicate of What are underfull hboxes and vboxes and how can I get rid of them?– TeepeemmCommented Jul 28, 2016 at 21:49
-
20How can this be a duplicate of a question about underfull boxes?– egregCommented Jul 28, 2016 at 23:15
-
1I've added an extension to the main question to make this easier to find.– barbara beetonCommented May 24, 2020 at 18:33
-
Maybe see also xetex - Panic on overfull \hbox - TeX - LaTeX Stack Exchange for how to convert the silent warning to a fatal error so you don't overlook it. // about \texttt in particular see: hyphenation - Overfull hbox - How do I fix this? - TeX - LaTeX Stack Exchange– user202729Commented Aug 12, 2022 at 1:02
5 Answers
Quoting Phil Miller answer, for completeness:
This message means that a line of your document is too long to fit within the horizontal space on the page, and TeX couldn't find a good way to break it apart. This will usually result in text hanging out past the margin, possibly even running off the side of the page. Common causes are long words without proper hyphenation information and long displayed equations.
These warnings can also happen by manually breaking works with -
as commented by Sebastian. This can be fixed by importing the package \usepackage{hyphenat}
and using its command \hyp{}
to break words, i.e., hyphenated\hyp{}word
instead of hyphenated-word
. But as can be easily noted, typing \hyp{}
all the time can be quite annoying. Here come in the babel
package shorthands. See the question How to create an alternative to shortcut "= or \hyp{}?, to learn about the usage of the ~=
shorthand. So you can write like hyphenated~=word
, instead of hyphenated\hyp{}word
.
Badboxes warnings can also be caused by breaking lines with \\
and \hbox
as demonstrated on this other question: How to stop \newsavebox giving me bad boxes warnings or how to use better names with \setbox?
You can control how the overfull hbox, badness
work configuring these latex parameters explained on:
-
badness
is an integer from 0 to 10000 that is a measure of the quality of the spacing in any given box. https://en.wikibooks.org/wiki/TeX/definition/badness -
\tolerance
A parameter that tells TeX how much badness is allowable without error. [number] can range from 0 to 10000, and there are no units. https://en.wikibooks.org/wiki/TeX/tolerance -
The TeX primitive
\pretolerance
is an integer parameter that is used in TeX's line breaking algorithm as described below. The quantity is an integer from -1 to 10000.If
\pretolerance
is an integer from 0 to 10000, then TeX's line breaking algorithm first attempts to break up a paragraph without hyphenation. In this attempt TeX ties to minimize the badness of each line. If TeX can break up a paragraph so that none of the lines have badness greater than\pretolerance
, then TeX accepts it. If this is not possible, TeX will re-attempt to break up the paragraph with the allowance of hyphenation of words. In this second attempt, the integer parameter \tolerance is used instead of\pretolerance
. If TeX is unsuccessful in the second attempt an error is reported in the log file.If
\pretolerance
is-1
, then TeX bypasses the first attempt at breaking a paragraph without hyphenation. https://en.wikibooks.org/wiki/TeX/pretolerance
On these questions there are more related information about line breaking:
- What is the meaning of \fussy, \sloppy, \emergencystretch, \tolerance, \hbadness?
- What's the difference between \tolerance and \badness ?
- Why is Latex hyphenating some words automatically, but others dont?
- Long blank space in the middle of paragraph
Hyphenation:
- Is it still worthwhile to let TeX try line-breaking without hyphenation?
- How to add global hyphenation rules?
- How to manually set where a word is split?
Bad boxes:
- Do I have to care about bad boxes?
- How to avoid using \sloppy document-wide to fix overfull \hbox problems?
- Overfull hbox - How do I fix this?
Table of Contents:
- Fixing overfull hbox in table of contents removes too many dots
- Memoir mysterious overfull hbox in TOC when mathptmx is used
- Overfull \hbox warning for TOC entries when using memoir documentclass
- titletoc: section titles ragged right
- How to typeset the table of contents raggedright in memoir?
- Table of contents: section titles ragged right
Miscellaneous:
- underfull \vbox
- What is the difference between \hspace*{\fill} and \hfill?
- how to suppress "Underfull \vbox (badness 10000) ... while \output is active"?
- https://texfaq.org/FAQ-overfull (La)TeX makes overfull lines
- https://texfaq.org/FAQ-paraparam Why does it ignore paragraph parameters?
The first answer doesn't really help somebody fix the problem, though. Take a look at:
and
http://en.wikibooks.org/wiki/LaTeX/Text_Formatting#Hyphenation
to learn about \tolerance
, \pretolerance
, and \hyphenpenalty
and how they affect the overfull/underfull behavior. Also, if you're fixing the document by hand, you can add hyphenation dictionary entries with \hyphenation
or add discretionary hyphens into words with \-
.
-
4Hyphenation was really it for me - as the word was not know and could not be auto-hyphenated and after adding a manual
\-
things were fine. Commented Oct 29, 2019 at 19:53 -
Is there a way to show those boxes, as a red rectangular frame?– hyiltizCommented Nov 23, 2020 at 18:53
-
-
Thanks,
\setlength{\emergencystretch}{3em}
helped preventing overfull hbox highlighted with black boxes! :) Commented May 31, 2022 at 19:54
This message means that a line of your document is too long to fit within the horizontal space on the page, and TeX couldn't find a good way to break it apart. This will usually result in text hanging out past the margin, possibly even running off the side of the page. Common causes are long words without proper hyphenation information and long displayed equations.
-
84If you use draft mode (\documentclass[draft]{article}) you can see black lines on the side of your document where there is overfull hbox badness. This is a convenient way to find and fix these errors.– OtisCommented Jul 26, 2010 at 19:54
-
16@Otis: Or simply something like
\overfullrule=1mm
so that you don't get the unwanted side effects of the "draft" mode. Commented Jul 26, 2010 at 20:34 -
4Overfull hboxes are not limited to overlong lines on a page. A hbox can overflow anywhere, for example, inside a table. Whithout
\overfullrule
in effect this is often hard to detect. Commented Apr 17, 2011 at 5:06
I always like to see a visual example of these Latex messages. The images below show the most frequent occurrence of Overfull \hbox
. So if you like visuals too, her you go:
-> NOTE: The explanations above are very good, so don't miss out on them.
The problem is, that sometimes Latex is not able to fit certain information in a defined space. As you can see here, the -
overflows the right border which here causes the warning. Hope this helps!
Tip: you can visualize the borders, to simply see the problem locations, f.e. if the overlapping is not caused by text and no error message appears.
Use: \usepackage[showframe]{geometry}
-
1Welcome to TeX.SE! Please explain why this is a valid answer? I do not understand what you are meaning ...– MenschCommented May 14, 2021 at 13:08
-
5@Mensch it seems to answer the question "what is an overfull hbox" with a visual example of an overfull hbox. It is not a complete MWE but it still shows the issue clearly I think.– MarijnCommented May 14, 2021 at 20:47
-
@Mensch Thanks for your comment. I felt that it would be quicker to understand the underlying problem by seeing a visualization of it. I added some more explanation to make it more clear.– LC117Commented May 15, 2021 at 16:31
If you want to know exactly where the overflow is occurring, add this line:
\documentclass[draft]{article}
.
It will put a literal black box there and it'll make it much easier to diagnose.
Note: All images will not show while it is in draft mode.