LaTeX error · Lengths and numbers

Dimension too large

Quick answer

TeX stores lengths as fixed-point numbers, and the largest is 16383.99999pt, roughly 5.75 metres. Any length or intermediate calculation beyond that stops with "Dimension too large". In practice it comes from plotting large values in TikZ or pgfplots, scaling an image enormously, or a typo such as 20000pt. Scale the data down, let pgfplots compute the axis (it uses floating point), or correct the 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.

! Dimension too large.
<to be read again> 
                   \relax 
l.3 Left\hspace{20000pt}

Why it happens

  • A length written larger than 16383.99pt, often a typo like \hspace{20000pt} or a missing decimal point.
  • TikZ coordinates or plots with large numbers, for example \draw (0,0) -- (20000,0); or plotting exp(x) over a wide range.
  • pgfplots data with very large or very small values combined with manual axis computations, or axis equal with very different ranges.
  • Scaling a box or image by a large factor with \scalebox or scale=.

How to fix it

Correct or rescale the length so it stays below 16383pt. For a plain typo that is the whole fix.

For plots, let pgfplots do the arithmetic: it computes in floating point and maps the data onto the axis. In TikZ use the fpu library or divide the data by a constant and label the axis with the scale (for example $\times 10^4$). Restricting the plot with domain= and restrict y to domain= avoids huge intermediate values.

Broken: reproduces the error

\documentclass{article}
\begin{document}
Left\hspace{20000pt}Right
\end{document}

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

Fixed: compiles cleanly

\documentclass{article}
\begin{document}
Left\hspace{2cm}Right
\end{document}

Related errors

Frequently Asked Questions

What is the largest length in LaTeX?

16383.99999pt, which is about 575.8 cm or 5.75 m. TeX uses the same limit for every length, including intermediate values inside TikZ and pgfplots calculations.

How do I fix Dimension too large in pgfplots?

Restrict the plotted range with domain= or restrict y to domain=, avoid \addplot expressions that blow up (such as exp of large numbers), and check that the axis is not forced to axis equal across very different ranges. Dividing the data by a constant and noting the scale on the axis also works.

Why does TikZ say Dimension too large with ordinary numbers?

TikZ does its arithmetic in TeX lengths, so a coordinate of a few thousand units in cm already exceeds the limit. Use the fpu library for the calculation, or scale the picture with x= and y= so the coordinates stay small.

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 →