# Why does \num{} not work in situnitx's S columns?

Consider the following MWE:

\documentclass{article}

\usepackage{siunitx}

\begin{document}
\begin{tabular}{SS}
0.01    & \num{0.01} \\
0.1     & \num{0.1} \\
1       & \num{1} \\
10      & \num{10} \\
100     & \num{100} \\
\end{tabular}
\end{document}


Which gives:

Why does the left column display as desired, and the right not?

Secondly, I would like to add a range of numbers of the table.

\documentclass{article}

\usepackage{siunitx}

\begin{document}
\begin{tabular}{rS}
0.01        & \num{0.01} \\
0.1         & \num{0.1} \\
1           & \num{1} \\
10          & \num{10} \\
100         & \num{100} \\
101--1000   & \numrange{101}{1000}
\end{tabular}
\end{document}


How would I do that typographically "correct"?

-
I've edited the answer to remove the use of LuaTeX-specific packages, which are not needed for the demo. –  Joseph Wright Nov 23 '11 at 16:18

On the first part of the question, the S column aligns numbers, and treats any other input as 'non-numerical'. So when parsing your second column, the \num macro is a 'non-numerical' value, and the cell content is typeset omitted from alignment. Simply don't use \num to indicate numbers within an S column.

On the second part of the question, ranges intermixed with decimal values are hard to align nicely: to be honest, such a table tends to suggest that there is something wrong with what you are attempting to present. That said, something like

\documentclass{article}

\usepackage{siunitx}

\begin{document}
\begin{tabular}{S[table-format = 3.2,table-align-text-post = false]}
0.01        \\
0.1         \\
1           \\
10          \\
100         \\
101{--1000} \\
\end{tabular}
\end{document}


will work in the case give. The idea here is to ignore the second part of the range for alignment purposes. I've also given a fixed size to the number as a whole, as this gives better alignment in general.

-
Wouldn't {101--1000} be a better choice in the last row? I.e. center it instead of aligning? Then the column will not be too tail heavy –  daleif Nov 23 '11 at 16:51
@daleif It depends on the 'real' case (for example, how many ranges). I guess you should post this as an alternative answer (or I can edit it into mine). –  Joseph Wright Nov 23 '11 at 16:53
That answer couldn't come more first hand. Thanks! –  Ingo Nov 24 '11 at 11:22