Basic S Column Alignment with siunitx – How to Align Columns with siunitx Package

siunitxtables

OK, what am I missing here? Why is the S column not aligning on the decimal:

enter image description here

The desired result is the data aligned on the decimal and centered within the column:

enter image description here

Code:

\documentclass{article}
\usepackage{siunitx}

\begin{document}
    \begin{tabular}{S}
    \multicolumn{1}{c}{Measured Values} \\
        \SI{0.003 1}{\meter} \\
        \SI{0.003 123}{\meter} \\
        \SI{0.003 45}{\meter} \\
    \end{tabular} 
\end{document}

Best Answer

In case if you have to use different units for different numbers, you have these possibilities with table-space-text-post and table-align-text-post:

\documentclass{article}
\usepackage{siunitx}

\begin{document}
    \begin{tabular}{S[table-format=1.6,table-space-text-post = \si{\meter}]}
    {Measured Values} \\
        0.0031\si{\meter}   \\
        0.003123\si{\meter} \\
        0.00345\si{\meter}  \\
    \end{tabular}
    \begin{tabular}{S[table-format=1.7,table-align-text-post = false]}  %% note 1.7 here just to align things at center
    {Measured Values} \\
        0.0031\,\si{\meter}   \\
        0.003123\,\si{\meter} \\
        0.00345\,\si{\meter}  \\
    \end{tabular}
\end{document}

enter image description here

There is also pre version of above commands - table-align-text-pre which does the same before the number.