LaTeX error: Illegal unit of measure (pt inserted)
Lengths in TeX are a number plus a unit. When a command such as \vspace, \hspace, or \setlength gets a bare number, TeX inserts pt and reports this error (often together with "Missing number, treated as zero").
! Illegal unit of measure (pt inserted).
Try it: this example has the error
Edit the example using the steps below, then press Compile. What pdfTeX printed for it:
! Illegal unit of measure (pt inserted).
<to be read again>
\vskip
l.4 \vspace{2}
Ready. Press Compile (or Ctrl/Cmd + Enter).
Common causes
- A length without a unit:
\vspace{2},\hspace{10}. - A misspelled unit:
2 cms,1 inch(the unit isin). - A width option with only a number:
\includegraphics[width=5]{…}. - A blank or text argument where a length belongs, like
\\[space].
How to fix it
- Add a unit:
pt,mm,cm,in,em(font width), orex(x-height). - For widths relative to the page, use
0.5\linewidthor0.8\textwidth.
The fixed example
\documentclass{article}
\begin{document}
Text.
\vspace{2em}
More.
\end{document}