# Aligning numbers by decimal points in table columns

Let me begin by stating that I did google the answers (and I'll reference to them soon). Yet each of the resources I found discussed one particular method, I'm interested in a comparison of the approaches.

So far, I've found three ways to deal with this problem:

• split the number into two columns (integer and fractional parts), as documented here or here. The LaTeX code is simple, but the approach is a pain when it comes to copying and pasting tables from external sources.

• use dcolumn manually

• use Mike Zhang's automatic converter (description). I have yet to test it.

What do most people use? dcolumn? Are there other options?

-

The newest option is using the S column type of the siunitx package.

\documentclass{article}

\usepackage{siunitx}

\begin{document}
\begin{tabular}{S[table-format=3.2]}% syntax for siunitx v2; for v1 use "tabformat"
555 \\
7.77 \\
99.9
\end{tabular}

\end{document}


-
I didn't know you didn't know. ;-) –  lockstep Sep 4 '10 at 21:37
Indeed, in version 2 of siunitx you will find that there is an implementation that is ~ the same as the dcolumn one, plus a second approach more similar to rccol. –  Joseph Wright Sep 4 '10 at 21:48
This looks great. I can't get it to work though. With pdflatex from texlive 2009 on OSX, I got: ! Package xkeyval Error: table-format' undefined in families key'. –  dank Sep 5 '10 at 13:01
Seems like you're using siunitx v.1.x (the current version is 2). Try tabformat instead of table-format. –  lockstep Sep 5 '10 at 13:58
in response to a comment by daniel kullmann Nov 15 '11 at 10:31 The official way of getting siunitx to ignore bits of text, like headers, is to just wrap them in braces; i.e. {name} will work just as well as \multicolumn{1}{c}{name}. See for instance tex.stackexchange.com/questions/3709/… (would still like newbies to be able to post comments!) –  Sam Mason Sep 23 '12 at 17:41