Illegal unit of measure (pt inserted)
If you are specifying a length in LaTeX, but do not specify the appropriate units, you will generate the error below:
main.tex, line 5
<to be read again> \vskip l.11 \vspace{6} Dimensions can be in units of em, ex, in, pt, pc, cm, mm, dd, cc, nd, nc, bp, or sp; but yours is a new one! I'll assume that you meant to say pt, for printer's points. To recover gracefully from this error, it's best to delete the erroneous units; e.g., type `2' to delete two letters. (See Chapter 27 of The TeXbook.)
See here to learn more about lengths in LaTeX.
Common Causes
Forgetting to include the appropriate unit when specifying a length:
The most common cause of this error is simply forgetting to include a unit when specifying a length in LaTeX. An example of a mistake is shown below
The below image should be 5 centimetres wide
\includegraphics[width=5]{image}
The mistake here is that the the width of the image is written as width=5
. LaTeX does not understand whether the image should be five inches, five metres, five millimetres etc. The correct specification is width=5cm
. This lets LaTeX know that the image should be five centimetres wide.
Using a unit which is not allowed in LaTeX:
Another common reason this error will appear is if you have used a unit which is not allowed in LaTeX. An example of this is shown below, where it was attempted to specify the image to be one foot wide:
The below image should be one foot wide
\includegraphics[width=1ft]{image}
This will generate an error, as feet are not allowed units in LaTeX. The correct way to write this would be to write the image width as width=12in
, which gives a one foot wide image. Below a list of available units in LaTeX:
Abbreviation | Value |
---|---|
pt | a point is approximately 1/72.27 inch, that means about 0.0138 inch or 0.3515 mm (exactly point is defined as 1/864 of American printer’s foot that is 249/250 of English foot) |
mm | a millimeter |
cm | a centimeter |
in | inch |
ex | roughly the height of an 'x' (lowercase) in the current font (it depends on the font used) |
em | roughly the width of an 'M' (uppercase) in the current font (it depends on the font used) |
mu | math unit equal to 1/18 em, where em is taken from the math symbols family |
Having an unexpandable token in the wrong place
The above is actually a case of this. TeX parses lengths as any number of digits followed by an optional dot followed by any number of digits followed by an optional space followed by any valid unit. While TeX searches for a length it expands every expandable token (macro) until it finds the first unexpandable token.
Having a linebreak \\ followed by square brackets:
If a linebreak command \\
is ever followed by square brackets [...]
, it will be taken as an optional argument, and thus a number with a unit will be expected inside the square brackets This is even true if there is whitespace and newlines between the \\
and [...]
commands. This problem often appears in tables, as shown below:
\begin{tabular}{c|c}
[t] & s\\
[I] & A\\
[m] & kg
\end{tabular}
This will generate an error, as on the third line, we have a linebreak followed by squared brackets. LaTeX expects a number with a unit inside the square brackets, but instead finds x
. The correct way to write the above table is to include the square brackets inside curly braces {...}
as shown below or, if the grouping effects of the braces is undesirable, to put a \relax
before it:
\begin{tabular}{c|c}
[t] & s\\
{[I]} & A\\\relax
[m] & kg
\end{tabular}
Using the subfigure package:
The subfigure
package is long outdated, and will generate a 'Illegal unit of measure' error when there is no error present. An example of this is shown below:
% In your preamble
\usepackage{subfigure}
% In the body of your document
\begin{figure}
\centering
\begin{subfigure}[b]{0.3\textwidth}
\includegraphics[scale=0.2]{image}
\caption{A gull}
\label{fig:gull}
\end{subfigure}%
\end{figure}
This will generate an error, as the subfigure package does not recognise \textwidth
as containg a unit, when it is in fact a predefined measurement (equivalent to the constant width of the total text block on a page). The way to resolve this is to use the more updated subcaption
package, which has replaced subfigure
. Writing the same code as above with \usepackage{subcaption}
in the preamble instead of \usepackage{subfigure}
will give the desired result without any error.
Overleaf guides
- Creating a document in Overleaf
- Uploading a project
- Copying a project
- Creating a project from a template
- Using the Overleaf project menu
- Including images in Overleaf
- Exporting your work from Overleaf
- Working offline in Overleaf
- Using Track Changes in Overleaf
- Using bibliographies in Overleaf
- Sharing your work with others
- Using the History feature
- Debugging Compilation timeout errors
- How-to guides
- Guide to Overleaf’s premium features
LaTeX Basics
- Creating your first LaTeX document
- Choosing a LaTeX Compiler
- Paragraphs and new lines
- Bold, italics and underlining
- Lists
- Errors
Mathematics
- Mathematical expressions
- Subscripts and superscripts
- Brackets and Parentheses
- Matrices
- Fractions and Binomials
- Aligning equations
- Operators
- Spacing in math mode
- Integrals, sums and limits
- Display style in math mode
- List of Greek letters and math symbols
- Mathematical fonts
- Using the Symbol Palette in Overleaf
Figures and tables
- Inserting Images
- Tables
- Positioning Images and Tables
- Lists of Tables and Figures
- Drawing Diagrams Directly in LaTeX
- TikZ package
References and Citations
- Bibliography management with bibtex
- Bibliography management with natbib
- Bibliography management with biblatex
- Bibtex bibliography styles
- Natbib bibliography styles
- Natbib citation styles
- Biblatex bibliography styles
- Biblatex citation styles
Languages
- Multilingual typesetting on Overleaf using polyglossia and fontspec
- Multilingual typesetting on Overleaf using babel and fontspec
- International language support
- Quotations and quotation marks
- Arabic
- Chinese
- French
- German
- Greek
- Italian
- Japanese
- Korean
- Portuguese
- Russian
- Spanish
Document structure
- Sections and chapters
- Table of contents
- Cross referencing sections, equations and floats
- Indices
- Glossaries
- Nomenclatures
- Management in a large project
- Multi-file LaTeX projects
- Hyperlinks
Formatting
- Lengths in LaTeX
- Headers and footers
- Page numbering
- Paragraph formatting
- Line breaks and blank spaces
- Text alignment
- Page size and margins
- Single sided and double sided documents
- Multiple columns
- Counters
- Code listing
- Code Highlighting with minted
- Using colours in LaTeX
- Footnotes
- Margin notes
Fonts
Presentations
Commands
Field specific
- Theorems and proofs
- Chemistry formulae
- Feynman diagrams
- Molecular orbital diagrams
- Chess notation
- Knitting patterns
- CircuiTikz package
- Pgfplots package
- Typesetting exams in LaTeX
- Knitr
- Attribute Value Matrices
Class files
- Understanding packages and class files
- List of packages and class files
- Writing your own package
- Writing your own class