2

I'm using siunitx for a column of numbers with uncertainty in my table. Is it possible to align the column so that both the part before and the part after the plus-minus sign are aligned?

enter image description here

\documentclass{memoir}
\usepackage{booktabs}
\usepackage[separate-uncertainty=true]{siunitx}
\begin{document}

Table 1: Desired alignment.\\

\begin{tabular}{lr@{\hspace{2pt}}r@{\hspace{2pt}}rl}
First row & $-2.3$&\textpm&$10.4$&*\\
Second row & $-13.3$&\textpm&$5.6$&**\\
\end{tabular}

\vspace{1cm}

Table 2: What I can get with siunitx.\\

\begin{tabular}{lrl}
First row & \num{-2.3(104)}&*\\
Second row & \num{-13.3(56)}&**\\
\end{tabular}\\

\end{document}

If that isn't possible, is there a way to get the plus-minus signs aligned?

4
  • Have a look at the S column type of siunitx. Feb 1 at 13:34
  • @samcarter_is_at_topanswers.xyz I did check that chapter in the manual but it didn't seem to solve my problem, should I read it again?
    – Anna
    Feb 1 at 13:35
  • 1
    Remember with an S column you should not use \num
    – daleif
    Feb 1 at 13:40
  • Aha, thank you both! I thought the few paragraphs on tabular data was everything about S, but there's several pages more in the chapter on package options.
    – Anna
    Feb 1 at 13:46

1 Answer 1

4

You could let siunitx do the alignment for you if you use an S column:

\documentclass{memoir}
\usepackage[separate-uncertainty=true]{siunitx}
\begin{document}

\begin{tabular}{lS[table-format=-2.1+-2.1]l}
First row & -2.3(104) &*\\
Second row & -13.3(56) &**\\
\end{tabular}

\end{document}

enter image description here

Are you sure that the large gap before the * is what you want? It looks very odd. They would look so much better if they were part of the numbers.

\documentclass{memoir}
\usepackage[separate-uncertainty=true]{siunitx}
\begin{document}

\begin{tabular}{lS[table-format=-2.1+-2.1{**}]}
First row & -2.3(104)*\\
Second row & -13.3(56)**\\
\end{tabular}

\end{document}

enter image description here

1
  • I had missed a part of the S documentation, thank you very much! In my actual document I had shrunk the cell spacing before the asterisks, but having S solve this too looks great!
    – Anna
    Feb 1 at 13:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .