Записки о преподавании, LaTeX и не только
Часто бывает, что в документе появляются слишком длинные, переполненные строки ( Warning: overfull \hbox ). Как избавиться от overfull \hbox в LaTeX? Я расскажу несколько способов. Их можно комбинировать.
Overfull \hbox возникает, когда строка залезает на правое поле страницы. Это происходит, когда совпадают два условия:
— компилятор не может найти правило переноса слова или формулы в конце строки,
— если он уберет это слово целиком в следующую строку, размеры пробелов в текущей строке станут чересчур большими.
Компилятор сдается, формирует переполненную строку и пишет предупреждение в лог.
Итак, два способа:
1. Как указать LaTeX, где можно ставить переносы? Поставить в местах возможного переноса слов символы \-, например: зашифро\-ва\-ние, cipher\-text. Разбить формулу на несколько, т.к. LaTeX не переносит формулу после запятой.
2. Чтобы не расставлять переносы вручную, можно немного изменить настройки окончения строк и страниц в преамбуле документа. Не стоит использовать команду \sloppy , так как после нее текст выглядит неопрятно.
Вот, что я добавил в преамбулу своего .tex файла для аккуратной верстки:
\tolerance 1414 \hbadness 1414 \emergencystretch 1.5em \hfuzz 0.3pt % размер максимального переполнения без warning’a \widowpenalty=10000 % запрещает одиночную строку абзаца в начале страницы \vfuzz \hfuzz \raggedbottom % если на странице мало содержимого, добавить пустое место в конце, а не в середине страницы
Understanding underfull and overfull box warnings
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:
\parbox50pt>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:
\parbox50pt>\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 (pt too wide) . at line(s) . Overfull \vbox (pt too high) . at line(s) . Underfull \hbox (badness ) . at line(s) . Underfull \vbox (badness ) . 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 ) 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 ( ), 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?
- From within the Overleaf interface, click on a warning message and the editor will scroll to the appropriate location in your LaTeX source code.
- To the left of the location in your source code there will be a small yellow triangle containing an exclamation mark (!).
- 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] .
- Like \parbox , minipage environments can give rise to overfull or underfull box warnings when the TeX engine tries to break paragraphs into lines:
\beginminipage>width> text. \endminipage>
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 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:
- When to use \par and when \\ , \newline , or blank lines
- What does \\* do?
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:
- \hfuzz and \vfuzz
- \hbadness and \vbadness
Further reading
For further background reading on TeX’s use of boxes and glue the interested reader is referred to these resources:
- The Overleaf article How TeX Calculates Glue Settings in an \hbox.
- A 17-page Overleaf article written to accompany this help item: Exploring underfull or overfull boxes and badness calculations. That article also discusses the TeX primives \hfuzz and \hbadness .
- The TeX FAQ at https://texfaq.org/FAQ-overfull.html.
- tex.stackexchange contains a wealth of advice from leading TeX/LaTeX experts.
- Documentation Home
- Learn LaTeX in 30 minutes
Overleaf guides
- Creating a document in Overleaf
- Uploading a project
- Copying a project
- Creating a project from a template
- Using the Overleaf project menu
- Including images in Overleaf
- Exporting your work from Overleaf
- Working offline in Overleaf
- Using Track Changes in Overleaf
- Using bibliographies in Overleaf
- Sharing your work with others
- Using the History feature
- Debugging Compilation timeout errors
- How-to guides
- Guide to Overleaf’s premium features
LaTeX Basics
- Creating your first LaTeX document
- Choosing a LaTeX Compiler
- Paragraphs and new lines
- Bold, italics and underlining
- Lists
- Errors
Mathematics
- Mathematical expressions
- Subscripts and superscripts
- Brackets and Parentheses
- Matrices
- Fractions and Binomials
- Aligning equations
- Operators
- Spacing in math mode
- Integrals, sums and limits
- Display style in math mode
- List of Greek letters and math symbols
- Mathematical fonts
- Using the Symbol Palette in Overleaf
Figures and tables
- Inserting Images
- Tables
- Positioning Images and Tables
- Lists of Tables and Figures
- Drawing Diagrams Directly in LaTeX
- TikZ package
References and Citations
- Bibliography management with bibtex
- Bibliography management with natbib
- Bibliography management with biblatex
- Bibtex bibliography styles
- Natbib bibliography styles
- Natbib citation styles
- Biblatex bibliography styles
- Biblatex citation styles
Languages
- Multilingual typesetting on Overleaf using polyglossia and fontspec
- Multilingual typesetting on Overleaf using babel and fontspec
- International language support
- Quotations and quotation marks
- Arabic
- Chinese
- French
- German
- Greek
- Italian
- Japanese
- Korean
- Portuguese
- Russian
- Spanish
Document structure
- Sections and chapters
- Table of contents
- Cross referencing sections, equations and floats
- Indices
- Glossaries
- Nomenclatures
- Management in a large project
- Multi-file LaTeX projects
- Hyperlinks
Formatting
- Lengths in L a T e X
- Headers and footers
- Page numbering
- Paragraph formatting
- Line breaks and blank spaces
- Text alignment
- Page size and margins
- Single sided and double sided documents
- Multiple columns
- Counters
- Code listing
- Code Highlighting with minted
- Using colours in LaTeX
- Footnotes
- Margin notes
Fonts
- Font sizes, families, and styles
- Font typefaces
- Supporting modern fonts with X Ǝ L a T e X
Presentations
Commands
Field specific
- Theorems and proofs
- Chemistry formulae
- Feynman diagrams
- Molecular orbital diagrams
- Chess notation
- Knitting patterns
- CircuiTikz package
- Pgfplots package
- Typesetting exams in LaTeX
- Knitr
- Attribute Value Matrices
Class files
- Understanding packages and class files
- List of packages and class files
- Writing your own package
- Writing your own class
Advanced TeX/LaTeX
Когда латех научится делать нормальные сообщения об ошибках?
Нет ничего лучше, чем набирать текст с формулами в латех, но, блин, нет ничего хуже, чем искать косяки в исходных файлах. 21-й век на дворе, даже gcc научился более менее показывать точное место, где я накосячил, а латех остался в 80-х годах.
Загадка. Что это значит:
(/usr/share/texmf-dist/tex/latex/amsfonts/ueus.fd) (/usr/share/texmf-dist/tex/latex/amsfonts/ueuex.fd) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] Overfull \hbox (7.49167pt too wide) in paragraph at lines 1955--1959 \T2A/ccr/m/n/10 � -�, � --� --�-. --�-� [24] [25] [26] [27] Overfull \hbox (5.7607pt too wide) in paragraph at lines 2267--2271 []\T2A/ccr/m/n/10 . - $[][] \U/eur/m/n/10 v[]$ \T2A/ccr/m/n/10 ---- --� $[][] \OM S/cmsy/m/n/10 k\U/eur/m/n/10 v[]\OMS/cmsy/m/n/10 k$ [28]) Runaway argument? ! File ended while scanning use of \language@active@arg". \par l.82 \sect ?Я не привожу начальную километровую портянку всякой хреноты, которую латех пишет даже когда компиляция идет по плану.
Пишет про overfull \hbox в каких-то строках, но из-за использования \input эти номера строк мне ни о чём не говорят.
Может есть какие-нибудь патчи к латеху или оболочки или ещё хоть что-нибудь, что позволяет искать косяки быстрее чем со скоростью черепахи? Я, наверное, совсем неадекват, но я борюсь тупым бисектом, находя косячный участок в тексте, написанном после последней успешной компиляции. Самому смешно.
Overfull \hbox (1.38991pt too wide) in paragraph at lines, Latex warning even though PDF is getting generated
This below latex code has warning saying Overfull \hbox (1.38991pt too wide) in paragraph at lines ; pdf is getting generated without any issue, I am trying to find out where exactly I am making a mistake to see that warning. Latex code1:
\begin \setbeamertemplate[numbered] \begin \titlepage \end
Latex code2:
%\section% \begin \begin[h!] \centering \begin< p|p> \hline \vspace Title & “CompaRob:The shopping cart assistance robot" \textit \\ \hline \vspace Methodology & \begin \item Radio and ultrasound signals \item Provide freedom of movements for elderly people \end\\ \hline \vspace Demerit & \begin \item Not able to show how to find a product \end\\ \hline \end \end \end