-
Notifications
You must be signed in to change notification settings - Fork 2
SI units
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.
siunitx
is a very well-written and documented package with lots of features. Some of the most basic commands are
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.
Short form \si{unit}
is used when there is no need for quantities.
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
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 \textcircle
.
For ranges, you may use \SIrange{from}{to}{unit}
. Default separator is –
.
So
\SIrange{10}{20}{\kilo\gram}
renders nicely as
10 – 20 kg
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.
Sometimes you might want to change some internal settings for a single occurrence of the command.
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}
.
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}
It can be found here.