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}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}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}\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
- A comma as the decimal separator in math mode: $1,5$ prints as "1, 5" with a space after the comma.
- Italic units: $9.81 m/s^2$ sets m and s as variables.
- A space instead of \per: \SI{3}{\metre \second} means metre times second, not metre per second.
- Mixing \num{6.022e23} with a hand-typed 6.022 \times 10^{23}: the same report ends up with two different looks for one kind of number.
See also
- Text in equations in LaTeX
- Mean and standard deviation in LaTeX
- Table in LaTeX
- Chemical formulas in LaTeX
Don't want to memorize commands?
Draw a formula or paste a screenshot, and CamteX turns it into ready LaTeX.