## Introduction

After typesetting a LaTeX document Overleaf will often display messages which report an underfull or overfull \hbox (or \vbox), along with so-called badness values for underfull boxes or amounts by which boxes are overfull. Firstly, it is important to note these messages are not errors—see below for more detail. They are warnings or, more correctly, “diagnostic messages” which originate from inside the TeX engine being used to typeset your LaTeX document.

In this help article we’ll provide some introductory background on the source and cause of those messages and list some common problems with suggested solutions. For readers interested in more detail, we have published an accompanying article in the Overleaf Gallery: Exploring underfull or overfull boxes and badness calculations. A list of additional resources can also be found at the end of this article.

## Does my project have overfull or underfull warnings?

To check if your project reports these warnings, you’ll need to click on the icon shown in the screenshot below. Even though your document may have compiled without error it is very common to see these messages and anyone fairly new to TeX/LaTeX might wonder what they mean and should they be concerned by them.

When typesetting a document LaTeX will try to make parts of your content fit within boundaries of a given “size”; for example, when typesetting paragraphs and breaking lines into a certain length—most easily demonstrated using a command such \parbox. If we try to typeset set the following paragraph using a line width of 50pt:

\parbox{50pt}{Some text typeset using a \texttt{\string\parbox}}


Overleaf reports two Underfull \hbox... warnings:

These Underfull \hbox... warnings arise because the TeX engine cannot produce “nice” linebreaks within the restrictions of this \parbox. Inside of TeX engines each line of a typeset paragraph becomes an \hbox, which the engine will subsequently check and report on, potentially generating warnings for any lines of typeset text the TeX engine classifies as “not desirable”.

As you can see in the following images, the lines of text are extremely spaced out and TeX’s Underfull \hbox... warnings tell you about this—although, in this example, it is clearly visible.

Note, for this example you can avoid these warnings by using \raggedright:

\parbox{50pt}{\raggedright Some text typeset using a \texttt{\string\parbox}}


## Overfull and underfull boxes

The \parbox example demonstrates a much more general issue: when processing your LaTeX code the TeX engine being used to typeset your document (pdfTeX, XeTeX or LuaTeX) might consider that LaTeX’s requests result in typeset content that does not “fit nicely” within the confines of the box provided or requested. If so, the TeX engine issues warnings and your material will be typeset but the result may not, on occasion, be aesthetically desirable and you’ll probably need to fix it. It is worth understanding the meaning of those messages and recognizing when you need to take action to address them.

These box-related warnings take the form

Overfull \hbox (<value>pt too wide) ... at line(s) ...
Overfull \vbox (<value>pt too high) ... at line(s) ...
Underfull \hbox (badness <value> ) ... at line(s) ...
Underfull \vbox (badness <value>) ... at line(s) ...


An \hbox refers to a horizontal box in which a TeX engine places a list of items side-by-side and \vbox refers to a vertical box in which the TeX engine stacks items one on top of another.

If there is too little material the TeX engine will report an Underfull \hbox warning or Underfull \vbox warning:

• Underfull boxes do not have sufficient material to fill the (box) dimensions allocated to contain it and the TeX engine needed to “stretch out” the content in its attempt to fill that space. For underfull boxes Overleaf will also report TeX’s so-called “badness” (badness <value>) which is a measure of how much TeX has needed to “stretch” your content to fill space set aside to contain it. Badness values normally range from 0 to 10000.

If there is too much material the TeX engine will report an Overfull \hbox warning or an Overfull \vbox warning:

• Overfull boxes have too much content to fit the (box) dimensions allocated to contain it and TeX cannot “squeeze it” into the space provided. The TeX engine reports the amount (<value>), in points, by which your content exceeds the available space—your material is too wide for a given \hbox or too high for a given \vbox.

## Overfull or underfull boxes are not errors

As noted, overfull/underfull \hbox or \vbox messages are not errors but “diagnostic warning messages” output by the TeX engine (pdfTeX, XeTeX or LuaTeX) being used to typeset your LaTeX document. Although reported to you by Overleaf, these warnings are not generated by Overleaf: they originate from inside TeX engines. During typesetting, these messages are written to the .log file—a text file produced by the TeX engine to record a range of information as it processes your LaTeX code. Overleaf processes the .log file to extract the TeX engine’s overfull/underfull \hbox or \vbox warning messages and displays them within the Overleaf interface. This helps you locate and identify parts of your document which might need editing to produce the best possible typeset result.

## Should I worry about these warnings?

Users who are new to TeX/LaTeX may be concerned by these warnings, wondering if they indicate a serious problem with their document, but it’s often the case that most of them can be safely ignored. However, these warnings do sometimes highlight a part of your document which does need to be checked and may need editing to improve the visible typeset results.

It can take a little practice to interpret these messages, so if you are new to TeX/LaTeX it is worth taking time to build your experience by locating the point in your source code which generated the warning. By doing that you will soon learn how to spot warnings which do highlight issues you might need to address.

## How can I find the source of the warning?

1. From within the Overleaf interface, click on a warning message and the editor will scroll to the appropriate location in your LaTeX source code.
2. To the left of the location in your source code there will be a small yellow triangle containing an exclamation mark (!).
3. If you place your mouse pointer over the triangle Overleaf will display the warning message.

This short video clip demonstrates the steps above.

## How can I find the PDF location corresponding to my LaTeX code?

After locating the LaTeX code which has generated a particular warning you can jump to the appropriate position in the PDF by using the arrows located on the splitter bar separating the panels containing the editor and typeset PDF.

If you do not see these arrows, our help article How to jump to the source code from the typeset PDF (SyncTeX) shows how to enable them.

## Common problems and how to fix them

• You can use the microtype package which takes advantage of micro-typographic extensions introduced by pdfTeX—producing higher-quality typesetting which can also result in fewer bad boxes.
• If you have problems with URLs and linebreaks you can add the option breaklinks to the hyperref package: \usepackage[breaklinks]{hyperref}.
• Like \parbox, minipage environments can give rise to overfull or underfull box warnings when the TeX engine tries to break paragraphs into lines:

\begin{minipage}{width}
text...
\end{minipage}


If possible, increase the value of width to give the TeX engine a better chance at producing good linebreaks—and/or use the microtype package.

### Notes on using \\

\\ is a macro (a control symbol) whose precise definition can depend on the context in which it is used---an excellent discussion/explanation can be found in this answer on tex.stackexchange.

• \\ should not be used to add vertical space between paragraphs—it is considered very bad practice to do that.
• \\ is intended for line breaks only (similar to Shift-Enter in Microsoft Word). The correct way to generate a new paragraph in LaTeX is to separate your paragraphs with blank lines in the source code.
• Instead of using \\ (or \newline/\vspace) to simulate paragraph breaks, or to increase inter-paragraph spacing, the recommended solution for setting spacing between paragraphs is to load the parskip package: put \usepackage{parskip} in your document’s preamble.
• Using \\ throughout paragraphs in the document can interfere with LaTeX’s algorithms which calculate optimum locations to place floats, break pages, etc. and can cause compilation errors in a large document.
• Legitimate use of \\ is explained in answers on tex.stackexchange. For example, see:

## Controlling which boxes TeX reports to you

TeX engines provide a number of low-level primitive commands you can use to guide TeX’s heuristics and set a threshold value for how “bad” a box needs to be before TeX will report it. Here are some links for readers interested in those commands: