# How to put siunitx units in a parenthesis or an equation?

I want to put units in an equation. Someone published a paper with units written that way. I need to mimic that. A simple case would be:

$$a = \si{\ell}{(\cm)}$$


or

$$a = \si{\ell}{\cm}$$


But both give Undefined control sequence. I think the problem is that I do not know how to use the package siunitx in an equation.

• The \si command takes only one argument, which is the unit to print. If you want to print a number as well use \SI. To print non-numeric numbers (?) use \SI[parse-numbers=false]{\ell}{\cm}. What do you want the output to look like? – Phelype Oleinik Apr 17 '19 at 20:31
• Did you load siunitx? – Bernard Apr 17 '19 at 20:32
• @PhelypeOleinik Your solution worked. If you write it as an answer, I will accept it – wander95 Apr 17 '19 at 20:36

The \si command takes only one argument, which is the unit to print. If you want to print a number as well use \SI{<number>}{<unit>}.

However, siunitx tries to parse the <number>, and when you give it \ell it tells you:

! Package siunitx Error: Invalid token '\ell ' in numerical input.

For immediate help type H <return>.
...

l.5   a = \SI{\ell}{\cm}

? h

Numbers can only contain tokens defined using the 'input-...' options:
the token '\ell ' is not set up as a valid part of a number.


To have siunitx print a non-numerical input you can disable the parsing mechanism with parse-numbers=false:

$$a = \SI[parse-numbers=false]{\ell}{\cm}$$


or, if you're going to use it several times in the same equation:

$$\sisetup{parse-numbers=false} a = \SI{\ell}{\cm}$$

• It turned out that a simpler solution in the equation environment is \ell \si{(\cm)} – wander95 Apr 17 '19 at 20:45
• @wander95 Note that the spacing is different, though. Try a = \ell\,\si{\cm}. – Phelype Oleinik Apr 17 '19 at 20:50