Illegal Unit of Measure
! Illegal unit of measure (pt inserted).
What this error means
A dimension argument was given a number without a valid unit, or with an unrecognised unit. LaTeX assumes pt and continues, but the result is likely wrong.
Common causes
- Writing \hspace{1} instead of \hspace{1em} or \hspace{1cm}
- Using a CSS unit like px that LaTeX doesn't recognise
- Missing unit in \rule{}{}, \vrule, or \hrule
How to fix it
Always specify a unit when giving dimensions. Valid TeX units include pt, bp, mm, cm, in, em, ex, pc, dd, cc, sp. Relative units like \textwidth and \linewidth also work as dimensions.
Code examples
\documentclass{article}
\begin{document}
\rule{100px}{2px} % px is not a valid LaTeX unit
\end{document}\documentclass{article}
\begin{document}
\rule{100pt}{2pt} % Use LaTeX units: pt, mm, cm, em, etc.
\end{document}Related errors
Overfull \hbox (Line Too Wide)
Overfull \hbox (Xpt too wide) in paragraph at lines N--M.
No Line Here to End (Misplaced \\)
! LaTeX Error: There's no line here to end.
Underfull \hbox (Poor Word Spacing)
Underfull \hbox (badness 10000) in paragraph at lines N--M.
Float Used in Non-Outer-Par Mode
! LaTeX Error: Not in outer par mode.
Test the fix live
Paste your LaTeX into the playground and compile instantly.

