Tx · LaTeX & TikZ

How to Distinguish Prefixed and Unprefixed Units in siunitx

Published By the 9to5Science editorial team

At a glance

  1. 1. Name the base unit

    Use the siunitx unit command for the unprefixed unit, such as \metre or \second.

  2. 2. Add a prefix explicitly

    Put the prefix command before the unit command, such as \milli\metre.

  3. 3. Check the rendered symbol

    Compile a small example to confirm the prefixed and unprefixed forms appear as intended.

In siunitx, a prefix is written separately from the unit it modifies. Use the unit command on its own for the unprefixed unit, and put a prefix command before it for the prefixed unit. For example, \unit{\metre} produces metres, while \unit{\milli\metre} produces millimetres.

This approach lets siunitx format the symbol consistently and makes the intended unit clear in your source. You do not need to insert a space between the prefix and unit or redefine the unit just to show the distinction.

Write the prefix and unit separately

In siunitx version 3, use \unit{...} for a unit alone and \qty{...}{...} for a quantity with a number. The prefix command comes immediately before the unit command inside the braces.

\documentclass{article}
\usepackage{siunitx}

\begin{document}
Unprefixed: \unit{\metre} and \qty{3}{\second}.

Prefixed: \unit{\milli\metre} and \qty{3}{\milli\second}.
\end{document}

The first pair displays as m and s; the second pair displays as mm and ms. In the source, \milli is the prefix and \metre or \second is the unit. Use the corresponding prefix command for other prefixes, such as \kilo, \micro, or \centi.

Some siunitx unit names have spelling variants. For example, \metre and \meter are accepted spellings for the metre unit in standard configurations. Use the spelling that fits your document, but keep the prefix and unit as separate commands.

Distinguish similar-looking symbols

The distinction is encoded in the symbol itself: a prefixed unit contains the prefix symbol immediately before the unit symbol. For example, \unit{\metre} is m, while \unit{\milli\metre} is mm. Likewise, \unit{\second} is s, while \unit{\milli\second} is ms.

If readers might confuse two units in a particular context, explain the distinction in the surrounding text or include the unit names. Do not alter the standard symbols merely to make them look more different; the prefix and unit symbols follow established notation.

Use a custom unit when needed

For a nonstandard unit, declare a unit command once and then use that command consistently. For example:

\documentclass{article}
\usepackage{siunitx}
\DeclareSIUnit{\widget}{wdg}

\begin{document}
\unit{\widget}
\end{document}

Here, \widget is a unit command that prints wdg. If the unit should support prefixes, check the siunitx manual for the relevant declaration and parsing options; not every arbitrary symbol or unit convention is automatically equivalent to a standard SI unit. For units with subscripts or other special formatting, a dedicated declaration may be more appropriate than typing the symbol directly each time.

Common mistakes

  • Typing the combined symbol into the unit parser. Prefer \unit{\milli\metre} to \unit{mm}. The separate commands tell siunitx which part is the prefix and which is the unit.
  • Treating the prefix as a separate unit. \milli modifies the following unit; it is not a complete unit by itself. Write \unit{\milli\metre}, not \unit{\milli}.
  • Adding manual spacing between prefix and unit. Prefix and unit symbols are joined, so do not put \, or ordinary text spacing between their commands.
  • Using a prefix where none is intended. \unit{\metre} is the unprefixed unit. Do not include \milli unless the quantity is actually measured in millimetres.
  • Mixing old and new interfaces without checking the version. Older documents commonly use \si{...} and \SI{number}{unit}. In version 3, the corresponding modern commands are \unit{...} and \qty{number}{unit}. Match the syntax to the siunitx version installed on your system.

References

  1. siunitx — A comprehensive (SI) units package, CTAN

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.