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.

Not sure it worked on your document? Paste it into LetX and compile it, free and in the browser.

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.

Related LaTeX fixes

Browse all LaTeX problems & fixes, or start with the LaTeX guide.

Learn the topic properly

Try the fix in LetX

Open the editor, paste your code, and compile in seconds to see the error clear. Free, in your browser.

Open LetX Free