[Tex/LaTex] Aligning numbers by decimal points in table columns

dcolumnhorizontal alignmentpunctuationsiunitxtables

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?

Best Answer

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}

example