# Align numbers and ranges in siunitx column type S

What is the easiest way to mix plain numbers and ranges in a table using column type S from siunitx? For example, say I am doing a literature review for a certain quantity and almost everyone reports a value for the quantity of interest, but a few papers report a range, and I'd like to put all the values in a table. I don't think it makes sense to make separate high and low columns for the range, as suggested in this question, since only a few quantities have a range listed.

For example, here is a MWE that demonstrates the issue.

\documentclass{article}
\usepackage{siunitx}
\begin{document}
\begin{table}
\begin{tabular}{lS}
Ref & {Value} \\
1   & 1.0e2 \\
2   & 1.5e2 \\
3   & \numrange{1.0e2}{2.0e2} \\
4   & 2.0e2
\end{tabular}
\end{table}
\end{document}


One other thing that might help would be to compress the number range when both numbers in the range share the same power of 10, something that can be done with \SIrange like this: \SIrange[range-units=single, range-phrase= --, tight-spacing=true, fixed-exponent=2, scientific-notation=fixed]{1e2}{2e2}{\metre}  but not like this \numrange[range-units=single, range-phrase= --, tight-spacing=true, fixed-exponent=2, scientific-notation=fixed]{1e2}{2e2}.

Ideally, I think the powers of 10 should be aligned in the table and the prefix should be (1.0 to 2.0) or (1.0--2.0).

Edit: Using the answer proposed by @Bernard to use \SIrange{1.0e2}{2.0e2}{} works when the table numbers and the range have the same precision (as in my MWE). But if the precision of the range is lower than the numbers in the column (e.g., \SIrange{1e2}{2e2}{}) then the alignment breaks. For this particular case, I can force alignment using table-figures-exponent = 3 but that seems like a hack and is fragile. Is there a more general way?

• I notice that another David has proposed an edit to this question - are you the original poster? If so, it seems like you have more than one account, meaning you can't edit your question, or accept an answer or gain rep appropriately or anything. You should get these merged and always make sure you use your account in order to get the most out of the site :) – Au101 Nov 3 '16 at 17:01
• @Au101 "David" and "David Slochower" are indeed the same person. – gernot says Reinstate Monica Nov 3 '16 at 17:20
• @Au101 ah yes, there's been some sort of split. I've asked to merge my accounts and it's pending. – David Nov 4 '16 at 4:26

I would use one of these codes:

\documentclass{article}
\usepackage{geometry} \usepackage{siunitx}
\sisetup{range-phrase=--, fixed-exponent=2, scientific-notation = fixed, range-units =single, table-number-alignment =center, table-figures-exponent=1}

\begin{document}

\begin{table}
\centering
\begin{tabular}{l|S}
Ref & {Value} \\
1 & 1.0e2 \\
2 & 1.5e2 \\
3 & \SIrange{1.0e2}{2.0e2}{} \\
4 & 2.0e2
\end{tabular}
\begin{tabular}{l|c}
Ref & {Value} \\
1 & \num{1.0e2} \\
2 & \num{1.5e2} \\
3 & {\SIrange{1.0e2}{2.0e2}{}} \\
4 & \num{2.0e2}
\end{tabular}
\end{table}

\end{document}


• Entries can be centered without alignment in S columns by putting them into braces: {\SIrange{1.0e2}{2.0e2}{}}. \multicolumn{1}{c} is not needed. – Heiko Oberdiek Nov 1 '16 at 17:12
• @Heiko Oberdiek: You're right, but in one of my trials, the code didn't work, so I added this \multicolumn{1}{c}, and I forgot to remove it for the final version. I've updated the code. Thanks for remembering me! – Bernard Nov 1 '16 at 17:24
• @Bernard you are certainly correct for the MWE, but I realized after posting that my range has fewer significant digits than the other numbers (I made an edit to reflect that), do you know of a general way to handle alignment? – David Nov 4 '16 at 4:28