How-to

How to Format Units and Numbers in LaTeX

The fix

Use the siunitx package. \num{12345.6} formats numbers with proper digit grouping, \unit{\kilo\gram} typesets units, and \qty{9.81}{\meter\per\second\squared} prints a value with its unit and the correct thin space. It also aligns numbers on the decimal point in tables via the S column type.

Example

\usepackage{siunitx}
% ...
The speed was \qty{3.0e8}{\meter\per\second}.
A mass of \qty{5}{\kilo\gram}.
\num{1234567}   % -> 1 234 567

Frequently asked questions

How do I align numbers on the decimal point in a table?

Use the S column type from siunitx: \begin{tabular}{S} aligns entries on the decimal separator automatically.

The commands \SI and \si do not work.

Recent siunitx (v3) renames them to \qty and \unit; \SI and \si still work for compatibility. Use \qty{value}{unit} in new documents.

Try the fix in LetX

Open the editor, paste your code, and compile in 1 second to see the error clear — free, in your browser.

Open LetX Free