LaTeX error "Illegal unit of measure (pt inserted)": cause and fix
TeX read a number where a length belongs, and no unit it knows follows the number. A length always consists of a number and a unit such as pt, mm, cm, em or ex. TeX goes on with pt.
Why it happens
- The unit is missing:
\vspace{10}. A zero needs one too, so\setlength{\parindent}{0}fails. - A factor is given without the length it refers to:
\begin{minipage}{0.5}orwidth=0.5in\includegraphics, where0.5\textwidthwas meant. - The unit is a word TeX does not know, as in
\vspace{1 meter}or\hspace{2 lines}. - The error follows Missing number, treated as zero for the same line, for example after an empty
\vspace{}.
How to fix it
- Add a unit:
\vspace{10pt},\setlength{\parindent}{0pt}. - Write relative sizes together with their length:
0.5\textwidth,0.8\linewidth. - Use a unit TeX knows, such as
pt,bp,mm,cm,in,emorex.
A document that produces the message
\documentclass{article}
\begin{document}
First paragraph.
\vspace{10}
Second paragraph.
\end{document}The corrected document
\documentclass{article}
\begin{document}
First paragraph.
\vspace{10pt}
Second paragraph.
\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.