[Tex/LaTex] Align numbers and ranges in siunitx column type S

siunitxtables

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}

enter image description here

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?

Best Answer

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}
  \qquad
  \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} 

enter image description here