Home > Tips > Align number by decimals in tables

Align number by decimals in tables

February 24, 2011 Leave a comment Go to comments

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.
💡

Categories: Tips Tags: , , , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: