All guides

SI units in LaTeX

Updated:

The siunitx package takes care of the space between a number and its unit, the upright font of units and the decimal marker. You always type a point in the source; the output-decimal-marker option switches the printed marker if a journal or course asks for a comma.

Preamble

\usepackage{siunitx}
\sisetup{separate-uncertainty=true}

The separate-uncertainty option prints results as (2.45 ± 0.03) Ω instead of the compact 2.45(3) Ω. In siunitx version 3 the same setting is called uncertainty-mode=separate; the older name is still accepted.

Copying this from handwritten notes? Snap a photo of the page and CamteX turns the formulas into LaTeX. Try it free

Number with a unit

\SI{9.81}{\metre\per\second\squared}
9.81 m s−29.81\,\mathrm{m\,s^{-2}}

Units are spelled out as macros: \metre, \kilogram, \per for division, \squared for a square. siunitx inserts the thin space and sets the units upright. Version 3 of the package adds the shorter \qty, and \SI keeps working.

Unit typed literally

\SI{9.81}{m/s^2}

You can also type a unit literally. It is shorter, but style options such as per-mode=fraction (division shown as a fraction) only apply to units written with macros. Pick one style and use it throughout the document.

Result with uncertainty

\SI{2.45 +- 0.03}{\ohm}
(2.45±0.03) Ω(2.45 \pm 0.03)\,\Omega

With the preamble above the uncertainty is printed in full and the unit goes after the brackets. Without the option you get the compact form 2.45(3) Ω, common in physics journals.

Number only

\num{6.022e23}
6.022×10236.022 \times 10^{23}

\num turns the e23 notation into a power of ten and groups long numbers in threes: \num{1234567} prints as 1 234 567 with thin spaces, as the SI style guide recommends.

Angles and percentages

\SI{45}{\degree} \quad \SI{12}{\percent}

siunitx prints no space before a degree sign (45°) and a space before the percent sign, following the SI brochure. Typing $^\circ$ by hand tends to come out slightly different each time.

Common mistakes

See also

Don't want to memorize commands?

Draw a formula or paste a screenshot, and CamteX turns it into ready LaTeX.

Try it free