Skip to content
Martin ‘Kvík’ Baláž edited this page Apr 11, 2023 · 4 revisions

You should use package siunitx for all SI units and decimal numbers. In modules that target HTML they must be enclosed in math mode, in PDF they can be left in regular text.

Commands

siunitx is a very well-written and documented package with lots of features. Some of the most basic commands are

Full form

A unit with quantity is written as \SI{how much}{what unit}. Big numbers should be written in scientific notation. For example

$G = \SI{6.674e-11}{\cubic\metre\per\kilo\gram\per\second\squared}$

siunitx also knows \pm (±), so you can write measurement errors as

d = \SI{2.45 \pm 0.52}{\metre}

Do not use only single characters. \SI{1}{m} might be displayed correctly, but is wrong.

Units only

Short form \si{unit} is used when there is no need for quantities.

Numbers only

Even if you do not need units at all, you might need to format a number. \num{number} can format long numbers, for instance

\num{3.64e16}

renders a nice $3.64 \cdot 10^{16}$ with proper comma/decimal dot, depending on the language.

Angles

siunitx also allows you to write angles \ang{number}. It takes either a decimal number, or degree/minute/second formats, separated by colons (without spaces:

\ang{1;24;17}

renders as $1° 24' 17^"$. You should absolutely NEVER use workarounds such as \textcircle.

Ranges

For ranges, you may use \SIrange{from}{to}{unit}. Default separator is . So

\SIrange{10}{20}{\kilo\gram}

renders nicely as

10 – 20 kg

Lists

Finally you might need a list of various quantities: \SIlist{list}{unit}.

\SIlist{50;70;80;100}{\centi\metre}

renders as

50, 70, 80 and 100 cm

with the word "and" properly translated depending on the language of the document.

Special

Sometimes you might want to change some internal settings for a single occurrence of the command.

Change per mode

In different contexts you might want to display units differently

\si[per-mode=symbol]{\metre\per\second}

results in m/s, while

\si[per-mode=reciprocal]{\metre\per\second}

displays as ms^{-1}.

Non-numbers with SI units

Sometimes it is necessary to use non-numbers to SI units, such as fractions or symbols. You need to turn off the parsing engine

\SI[parse-numbers = false]{\frac{\pi}{3}}{\centi\metre}

Official documentation at CTAN

It can be found here.