FormaTeX
FatalTypography & Layout

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

Causes the error
\documentclass{article}
\begin{document}

\rule{100px}{2px}  % px is not a valid LaTeX unit

\end{document}
Fixed
\documentclass{article}
\begin{document}

\rule{100pt}{2pt}  % Use LaTeX units: pt, mm, cm, em, etc.

\end{document}

Related errors

Test the fix live

Paste your LaTeX into the playground and compile instantly.

One quick thing

We track anonymous usage — page views, feature usage, compilation events — to understand what works and what doesn't. No ads, no personal data, no third-party sharing.

Cookie policy