Tx · LaTeX & TikZ

How to Fix an Overfull \hbox Warning in eqnarray*

Published By the 9to5Science editorial team

At a glance

  1. 1. Read the warning

    The equation line is wider than the space TeX has available; the warning is not a compilation error.

  2. 2. Find the long row

    Check the reported source lines for a long formula, unbreakable term, or oversized expression.

  3. 3. Break the equation

    Replace eqnarray* with an amsmath environment and split the expression at a meaningful operator.

  4. 4. Compile and check

    Recompile, confirm the warning is gone, and inspect the equation's spacing and alignment.

An “Overfull \hbox (…pt too wide)” message is a warning, not a fatal error. It means TeX has placed content in a horizontal box that extends beyond the width available for it. In an eqnarray* environment, the usual cause is an equation row that is too long to fit on one line.

The practical fix is to choose a sensible place to break the equation. For new documents, use align* from the amsmath package rather than eqnarray*; align* provides better spacing around relation symbols and makes it easy to line up multiple rows.

What the warning tells you

A message such as:

Overfull \hbox (8.2pt too wide) in paragraph at lines 12--14

says the affected horizontal box exceeds its available width by 8.2 points. The line numbers help you locate the relevant source, but the warning may identify a range rather than the exact command causing the overflow.

TeX does not usually break a displayed equation automatically at a plus sign, equals sign, or other mathematical operator. If one row is too wide, it can stick into the margin even though the rest of the document compiles normally. Long inline mathematics, wide matrices, long words, and unbreakable boxes can cause the same kind of warning elsewhere.

Break a long equation with align*

Load amsmath and split a long derivation into rows at meaningful points. Put & before the symbol where you want the rows aligned, and use \\ to end a row.

Here is a complete example that compiles:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align*}
F(x) &= (x+a)(x+b)(x+c) \\
     &= x^3+(a+b+c)x^2 \\
     &\quad +(ab+ac+bc)x+abc.
\end{align*}

\end{document}

The first & in each row aligns the equals signs. The final row uses \quad to indent the continuation. Choose breaks that preserve the logical structure of your calculation; avoid splitting a symbol or an indivisible expression awkwardly just to silence the warning.

If you have only one long equation and do not need alignment at equals signs, multline* may be a better fit:

\begin{multline*}
  a long first part of the equation \\
  {}+ a long continuation
\end{multline*}

The {} supplies an empty math atom before the leading plus sign, which helps ensure the operator is treated as a binary plus. multline* places the first and last lines differently, so check that its layout suits your document.

Why replace eqnarray*?

eqnarray* is an older LaTeX environment. Its spacing around relation symbols such as = is often too wide compared with standard mathematical spacing. The amsmath environments are generally preferred:

  • Use align* for several aligned equations or steps.
  • Use gather* for several centered equations with no alignment point.
  • Use multline* for one equation that needs to continue across lines.

The starred forms suppress equation numbers. If you need numbers, use the corresponding unstarred environment, such as align or gather.

Common mistakes

  • Adding \\ without making the row shorter: A line break starts a new row; it does not divide the content before it. Place it where the equation can naturally continue.
  • Trying to fix a wide equation with \\ at the end: If the entire expression remains before the break, it will still overflow. Split the expression itself across rows.
  • Using \sloppy or shrinking the whole equation immediately: These approaches can hide the warning while producing loose spacing or hard-to-read mathematics. Restructure the equation first.
  • Assuming every warning comes from the equation: If the warning remains after fixing the display, inspect nearby text, inline formulas, tables, and any boxes or figures. The reported line range is a starting point, not proof that eqnarray* is the sole cause.

A small overrun may be visually unobtrusive, but it is worth checking the PDF. The right fix is usually a deliberate line break or a better equation layout—not suppressing the warning without understanding what extends into the margin.

References

  1. The amsmath package

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.