Home > Tips > Align number by decimals in tables

## Align number by decimals in tables

Before finding siunitx, to align decimals I have to use the odd format r@{.}l to align decimals. This isn’t just odd, but it requires a lot of work if you have a lot of data.

Today, I just found about siunitx and I’m in love with it. I’s so easy to align the decimals, but also provides other powerful macros to manipulate numbers and units.

A simple examle for its use

\usepackage{siunitx}
\begin{document}
\begin{tabular}{S[table-format=3.2]}
{Numbers}\\ \hline
555 \\
7.77 \\
99.9
\end{tabular}


where S is a type of column that will align the numbers by the point, the text in the columns should be between braces {}, and lastly you can specify the width of the column by using the table-format, there you say the number of integers and then the number of decimals.
💡