LaTeX warning "Overfull \hbox (263.664pt too wide) in paragraph at lines 3--6": cause and fix
A line is wider than the text block and sticks out into the right margin by the stated amount. TeX found no place to break the line without stretching or squeezing the spaces more than it may. It is a warning; the PDF is still written. With the class option draft, LaTeX marks each such line with a black bar.
Why it happens
- A long word, a path or a web address has no break point. Text in
\textttis not hyphenated in the default fonts, and the content of\mboxnever breaks. - A table or an image is wider than the text block, for example with
width=1.3\textwidth. - An image with
width=\textwidthbegins a paragraph and is pushed to the right by the paragraph indent. In thearticleclass the line is then 15pt too wide. - An inline formula has no break point, for example a long
\sqrt{...}or\frac{...}{...}. TeX only breaks a formula at relation and operation signs outside braces.
How to fix it
- Put web addresses into
\url{...}from theurlpackage orhyperref. It allows breaks at slashes and dots. - Mark break points in a long word with
\-, or list the word once in the preamble:\hyphenation{data-base}. - Rephrase the sentence so that the long element no longer sits at the end of a line.
- Set
\emergencystretch=3emin the preamble or use\sloppy. TeX may then stretch the spaces further; the lines get looser and can cause Underfull \hbox (badness 10000) in paragraph at lines 3--4 instead. - Limit images to
width=\linewidthand start them with\noindentor put them in acenterenvironment. For wide tables see Fit a table that is too wide in LaTeX.
A document that produces the message
\documentclass{article}
\begin{document}
The data set and all scripts are available for download at
\texttt{https://www.example.org/projects/thesis/data/measurements-2024.html}
and may be reused.
\end{document}The corrected document
\documentclass{article}
\usepackage{url}
\begin{document}
The data set and all scripts are available for download at
\url{https://www.example.org/projects/thesis/data/measurements-2024.html}
and may be reused.
\end{document}Both documents were compiled with pdfLaTeX from TeX Live 2023. The first produces the message, the second compiles without an error.
Finding the line in the editor
The editor lists every error and warning of a compile run with file and line. Select an entry and the cursor jumps to that line. See Error list with jump to the line.