Standardizing Units in LaTeX with siunitx: From Setup to Pitfalls
Standardise unit formatting in LaTeX with siunitx: learn the core commands, configure global styles, integrate with biblatex, and avoid common pitfalls.
27 Jul 2026, 19:14 UTC

Problem
When drafting a technical report, a common source of inconsistency is unit formatting. Numbers like 5.2 and units such as m/s often appear in different styles—sometimes with a space, sometimes without; superscripts may be missing or mis‑formatted. These small typographic errors can undermine the professional quality of a document and cause confusion in scientific communication.
Why siunitx?
The siunitx package centralises unit typesetting in LaTeX. It automatically handles:
- Spacing between the number and the unit.
- Superscript and subscript formatting for powers and fractions.
- Locale‑aware decimal markers (dot vs comma).
- Consistent unit symbols and abbreviations.
By separating the numeric value from the unit symbol using \SI{value}{unit} or \si{unit}, authors cannot accidentally concatenate units or miss superscripts.
Core Features
The package offers two primary commands:
\SI{5.2}{\metre\per\second} % 5.2 m/s
\si{\kilo\metre\per\hour} % km/h
Both commands output the same visual result, but \SI{} is used for a value+unit pair, while \si{} is for unit-only expressions. The internal representation uses siunitx's parsing rules, so you can write complex units like \SI{3.3e-4}{\newton\metre} without worrying about manual formatting.
Configuration Deep Dive
Global styles are set in the preamble with \sisetup{...}. Common options include:
| Option | Description | Typical Value |
|---|---|---|
| output-decimal-marker | Character used for the decimal point. | "." or "," |
| parse-numbers | Whether to treat numbers as numeric data. | true |
| detect-weight | Detects "." or "-" for exponents. | true |
| per-mode | Format units with a slash or a per‑symbol. | symbol |
| scientific-notation | Use engineering or standard scientific notation. | engineering |
Example:
\sisetup{
output-decimal-marker={,},
per-mode=symbol,
scientific-notation=engineering,
}
Local overrides are possible with \sisetup{...} inside a group, but beware: untracked local changes can create subtle inconsistencies. Document the chosen style at the top of your file or in a dedicated style file.
Integration Tips
- With biblatex:
biblatexcan parse unit strings from bibliography entries. When the citation uses\SI{}or raw units,siunitxensures consistent rendering throughout the document. - Cross‑referencing: Use
\SI{}within\labelor\refcontexts; the package preserves the numeric and unit parts separately, avoiding accidental reformatting. - Avoid conflicting packages: Packages like
unitsalso manipulate spacing. Loadsiunitxfirst and use\sisetup{detect-all=true}to let it detect other units automatically.
Trade‑off & Limitations
While siunitx offers great consistency, its extensive option set can clash with other packages that modify spacing or fonts. Also, local \sisetup overrides, if not documented, may lead to hard‑to‑trace style differences in large documents. Finally, the package expects unit names to be defined in its unit database; custom units may require manual definition, which can be error‑prone.
Practical Example
- Create a minimal file
example.tex:\documentclass{article} \usepackage{siunitx} \sisetup{output-decimal-marker={,}, per-mode=symbol} \begin{document} The speed is \SI{5.2}{\metre\per\second}. Another measurement: \SI{3.3e-4}{\newton\metre}. \end{document} - Compile with
lualatex example.tex. - Open the resulting PDF and verify:
- The decimal separator is a comma.
- Units appear with correct superscripts (m/s, N·m).
- There is a single space between the number and the unit.
To confirm the spacing, you can also run pdfinfo or a quick visual inspection. If the decimal marker is incorrect, re‑run with \sisetup{output-decimal-marker={.}} and re‑compile.
Actionable Closing
Adopting siunitx is a low‑effort, high‑impact decision for any technical LaTeX author. Start by adding \usepackage{siunitx} to your preamble, set a global style with \sisetup, and replace manual unit formatting with \SI{} or \si{}. Document the chosen style, avoid local overrides unless necessary, and test a few unit expressions in a PDF before committing the change. With these steps, your documents will consistently display units, improving readability and professionalism.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.