Using siunitx to Automate Number and Unit Formatting in LaTeX
Stop manually formatting numbers and units in LaTeX. Learn how siunitx automates SI-compliant formatting and centralizes style changes.
20 Aug 2026, 11:37 UTC

The problem with manual unit formatting in LaTeX
In scientific writing, the difference between 10kg, 10 kg, and properly spaced output matters. Manual typing leads to inconsistent spacing, decimal markers, and a maintenance nightmare when journals require style changes across many pages.
Enter siunitx
The siunitx package treats numbers and units as data, not text. It inserts a thin space between a value and its unit, and handles scientific notation, exponentiation, and grouping automatically.
Core macros
\num{...}: Formats a pure number. Handles scientific notation (e.g.,1.2e3) and digit grouping.\si{...}: Formats a unit alone, without a value.\SI{value}{unit}: The workhorse command. Combines a numeric value with a unit, inserting the correct spacing and formatting.
Worked example: a particle‑mass table
Suppose you are writing a table of particle masses. Without siunitx, you would type each mass and unit by hand, and changing the unit from kilograms to grams requires editing every cell.
| Particle | Mass |
|---|---|
| \SI{1.67e-27}{\kilogram} | Proton |
| \SI{9.11e-31}{\kilogram} | Electron |
| \SI{1.0e-30 to 2.0e-30}{\kilogram} | Range |
Compile with pdflatex or lualatex. The output will show a thin space between each number and kg, exponents in math mode, and consistent formatting across rows.
Trade-offs and limitations
Because siunitx parses input strings to determine spacing and formatting, it adds a small overhead at compile time. Documents with tens of thousands of measurements may notice a delay.
Package conflicts can occur if other packages redefine \SI or related commands. Load siunitx after other unit packages, or check the log for Command already defined warnings.
Full Unicode support for unit symbols requires TeX Live 2020 or later; older distributions may fall back to ASCII approximations.
Verification in practice
- Create a minimal
.texfile containing \documentclass{article}, \usepackage{siunitx}, and a line like \SI{2.5}{\kilogram}. - Compile with pdflatex or lualatex.
- Compare the PDF output to a manually typed 2.5 kg. You should see a distinct thin space between the number and the unit, narrower than a normal space but present.
- Change the \sisetup option to group-minimum-digits = 4 and re‑compile to confirm that numbers are grouped with commas or periods according to your locale setting.
Actionable closing
Add \usepackage{siunitx} to your preamble, adopt \SI{} and \num{} for all quantities, and define a \sisetup block that matches your publication’s style. This single change gives you consistent, locale-aware formatting across your entire document, and future style changes require only a single preamble edit.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.