LaTeX error "Dimension too large": cause and fix
TeX cannot handle a length of 16384pt or more, which is about 5.76 m. A length in the document, or an intermediate result of a calculation, went over this limit.
Why it happens
- TikZ coordinates are large numbers. Without a unit TikZ reads them as centimetres, so
(800,600)is a point 8 m to the right. - A calculation in TikZ produces a large value, for example
{200*200}in a coordinate or\x*\xin a plot over the range 0 to 200. - A length is written too large directly:
\vspace{600cm}or\rule{600cm}{1pt}. - An image is scaled far beyond the page:
scale=100orwidth=600cmin\includegraphics.
How to fix it
- Set a smaller unit for the picture:
\begin{tikzpicture}[x=0.1mm,y=0.1mm]. The optionscale=0.01does not help, because TikZ turns the coordinate into a length before it scales. - Scale the data before you plot them, for example divide by 1000 and name the factor in the axis label.
- Plot data with large values with
pgfplots. Its axes accept values such as1e9. - Check the unit of a length you typed:
600cmmay have been meant as600ptor6cm.
A document that produces the message
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) rectangle (800,600);
\end{tikzpicture}
\end{document}The corrected document
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[x=0.1mm,y=0.1mm]
\draw (0,0) rectangle (800,600);
\end{tikzpicture}
\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.
Related pages
- Error Illegal unit of measure (pt inserted)
- Error TeX capacity exceeded, sorry [input stack size=10000]
- Package
tikz - Package
pgfplots