LaTeX error · Lengths and numbers

Missing number, treated as zero

Quick answer

TeX was reading a number or a length and the next token was not a digit. The most common trigger is a line starting with [ after \\: LaTeX takes \\[...] as optional vertical space and tries to read [a, b] as a length. Other causes are an empty or misspelled argument to \setlength, \vspace, \setcounter or \includegraphics. Put {} between \\ and the bracket, or give the command a real number or length.

The error in the log

This is how the message appears in the .log file (and in the compile output). The line starting with l. is the line number where TeX noticed the problem; the real mistake is there or just before it.

! Missing number, treated as zero.
<to be read again> 
                   a
l.4 [a, b]
           in this case.

Why it happens

  • A [ at the start of the line after \\, read as the optional spacing argument of the line break.
  • An empty or non-numeric argument where a number is required: \vspace{}, \setcounter{page}{one}, \hspace{\mylength} with an undefined length.
  • A length or counter name that does not exist, for example a misspelled \textwdith.
  • A command that takes a numeric argument used without it, such as \linewidth in text or \the before a non-register.

How to fix it

If the line after \\ starts with a bracket, separate the two with an empty group: \\{}[a, b]. In a table, \\ \relax works the same way.

Otherwise read the command shown in the log and give it what it expects: a number for counters, a number with a unit for lengths.

Broken: reproduces the error

\documentclass{article}
\begin{document}
The interval is\\
[a, b] in this case.
\end{document}

Try this in Octree — free LaTeX editor with AI, compiles in your browser

Fixed: compiles cleanly

\documentclass{article}
\begin{document}
The interval is\\{}
[a, b] in this case.
\end{document}

Related errors

Frequently Asked Questions

Why does "Missing number" often come with "Illegal unit of measure"?

Both come from the same failed attempt to read a length. TeX first finds no number (and uses zero), then finds no unit (and uses pt). Fixing the first error makes the second one go away.

How do I start a line with a square bracket after \\?

Write \\{} or \\ \relax before the bracket, or use \newline. The empty group stops LaTeX from treating the bracket as the optional spacing argument of the line break.

Can an undefined length cause this error?

Yes. If \mylength was never created with \newlength, using it where a length is expected can produce "Missing number" or "Undefined control sequence". Declare it with \newlength{\mylength} and set it with \setlength first.

Paste your document into Octree — compile errors get a Fix with AI button

When a compile fails, Octree shows the error next to the line that caused it and offers a one-click fix that you can review before applying. Free, nothing to install.

Fix it in Octree →