2

I want the text in the column to be aligned by the \pm symbol from amssymb. I know there is a package called siunitx which allows for decimal alignment in tabular by using "S" as a column argument like so: \begin{tabular}{|cSr|} . When you use the package: \usepackage{siunitx}

Is there an equivalent of this for the \pm sign? Perhaps using the same package or another one? The easy option for alignment is making two columns the first right adjusted with r and the \pm column on the right, left adjusted, but this is not what I am asking for.

Example:

\begin{tabular}{l|X|r}
    \toprule
    {Name} & {Value} & {Unit} \\
    \midrule
        Ab  & {$1500,0 \pm 0,5$}  &   Kg \\
        Cd  & {$4,9 \pm 0,1$}   &   s \\
        Ef  & {$209$ \pm 2$}    &   m \\
    \bottomrule
    \end{tabular}

I simply want to know: is there, or is there not an argument "X" for the tabular environment that aligns the \pm signs, and if yes, what package do you need to use to be able to call it?

4

The siunitx package supports this:

\documentclass{article}
\usepackage{siunitx,booktabs}

\sisetup{
  separate-uncertainty,
  output-decimal-marker={,},
}

\begin{document}

\begin{tabular}{l S[table-format=4.1(1)] s}
\toprule
Name & {Value} & {Unit} \\
\midrule
Ab  & 1500,0 \pm 0,5  &  kg \\
Cd  & 4,9    \pm 0,1  &  s \\
Ef  & 209    \pm 2    &  m \\
\bottomrule
\end{tabular}

\end{document}

enter image description here

|improve this answer|||||
  • What does the "table-format=4.1(1)" part mean? Is table 4.1 for +- separation or something? – Vebjorn Oct 28 '19 at 11:01
  • 1
    @Vebjorn It means “four digits in the integral part, one digit in the decimal part and one significant digit for the uncertainty”. – egreg Oct 28 '19 at 11:14
1

Depending on the particulars, but at least in this case, one could use a TABstack:

\documentclass{article}
\usepackage{booktabs,tabularx,tabstackengine}
\begin{document} 
\begin{tabular}{l|c|r}
    \toprule
    {Name} & {Value} & {Unit} \\
    \midrule
        \Centerstack[l]{Ab \\ Cd\\ Ef} &
        \ensurestackMath{\alignCenterstack{
          1500,0 \pm& 0,5\\4,9 \pm& 0,1\\209 \pm& 2}} &
        \Centerstack[r]{Kg \\s \\ m}\\
    \bottomrule
    \end{tabular}
\end{document} 

enter image description here

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.