# Having problems aligning in a table with siunitx when using uncertainties in some power of 10

I'm trying to have a table, with an S column (from the siunitx-package) where the numbers are aligned to the \pm signifying uncertainty. Some values have uncertainties like 1.00 x 10⁴ and that seems to trip up the aligning. Here's a MWE:

\documentclass{article}
\usepackage{booktabs}
\usepackage[separate-uncertainty,bracket-numbers = false]{siunitx}

\begin{document}

\begin{table}
\begin{tabular}{S} \toprule
\num{0.37 \pm 0.07} \\
\num{0 \pm 7e-4} \\ \bottomrule
\end{tabular}
\end{table}

\end{document}


What I'd like is to see the \pm's line up, so what's missing here?

UPDATE: I've been searching around a little and just saw this answer answer on why \num{} doesn't work with S columns, by removing the \num{} environment however, everything after (and including) \pm doesn't show up in the table. This is not an improvement. Should I be thinking up another way of doing this or is there an option for this in the siunitx-package that I can't find?

-

There are several things going on here. First, as you observe in the edit, \num should not be used inside an S column if you want alignment. However, that change alone will not get what you want.

The standard settings for siunitx are designed to maintain decimal place alignment for any input, but at the cost of not being optimal for anything vaguely asymmetrical. With more complex input, you need to set the table-format to indicate what space to reserve for the number.

The second issue is that siunitx is designed to handle numbers of the form (x \pm y) \times 10^{z}. So your input is parsed as (0 \pm 7) \times 10^{-4}, not as (0 \pm 7 \times 10^{-4}). That's mainly for practical reasons (it's the most common input form), but also in part as the history of the uncertainty code in siunitx is to read the more compact form 0.0000(7) = (0.0000 \pm 0.0007).

Now, it is possible to have the output look at least partly as requested:

\documentclass{article}
\usepackage{booktabs}
\usepackage[separate-uncertainty,bracket-numbers = false,
table-align-uncertainty = true, table-align-exponent=false]
{siunitx}

\begin{document}

\begin{table}
\begin{tabular}{S[table-format=1.2(2)e1]}
\toprule
0.37 \pm 0.07 \\
0 \pm 7e-4 \\
\bottomrule
\end{tabular}
\end{table}

\end{document}


You'll see, though, that the end-space is wrong. Personally, I'd go for

\documentclass{article}
\usepackage{booktabs}
\usepackage[separate-uncertainty]
{siunitx}

\begin{document}

\begin{table}
\begin{tabular}{S[table-format=1.4(1)]}
\toprule
0.37   \pm 0.07 \\
0.0000 \pm 0.0007 \\
\bottomrule
\end{tabular}
\end{table}

\end{document}

-
I mark this as a correct answer mostly because this explained a lot to me about the problem :). I'll probably use the second form of the answer (prettier), although if a pretty solution were to be found to align the \pm's with space for the scientific notation trailing behind, I wouldn't mind having that solution posted here ;). –  Jóhann Feb 11 '12 at 15:02