5

I have a table listing several properties. Some of them have a unit some don't. All have a uncertainty. Now I want to align them properly in the table using the siunitx package. See following MWE:

\documentclass{article}
\usepackage{siunitx}

\sisetup{separate-uncertainty}
\sisetup{multi-part-units=single}

\begin{document}

\begin{tabular}[b]{|l|S|}
   \hline
    Property    & {Value} \\\hline
    A           & \SI{284.98 \pm 5.2}{\meter} \\\hline
    B           & \SI{3.86 \pm 0.3}{\kilo\gram} \\\hline
    C           & \num{96.4 \pm 42.3} \\\hline
\end{tabular}

\end{document}

The problem is, that none of the values are aligned correctly.

Update: The result should like the following:

A    284.98 +/-  5.2 m
B      3.86 +/-  0.3 kg
C     96.4  +/- 42.3

However, the alignment of the uncertainty is not necessarily required.

1
  • 1
    What's the desired alignment?
    – Troy
    Commented Dec 22, 2017 at 9:24

2 Answers 2

7
\documentclass{article}
\usepackage{siunitx}
\usepackage{booktabs}
\sisetup{separate-uncertainty}
\sisetup{multi-part-units=single}

\begin{document}    
   \begin{tabular}{
l
S[table-format=3.2]@{\,\( \pm \)\,}
S[table-format=2.1]@{\,}
s[table-unit-alignment = left]
}
\toprule
Property    &\multicolumn{3}{c}{Value}  \\
\midrule
A           & 284.98 & 5.2 & \si{\meter} \\
B           & 3.86 & 0.3 & \si{\kilo\gram}  \\
C           & 96.4 & 42.3  \\
\bottomrule
  \end{tabular}
    \end{document}

In this MWE, I have separated the number and the uncertainty into two columns that are automatically separated by the +- sign. With table-format=3.2 I can make sure, that the numbers are aligned correctly with respect to the decimal separator. The units are in a third column and left-aligned. Additionally, I have removed all vertical lines and have replaced \hrules by the lines of the booktabs package.

enter image description here

2
  • You could keep the uncertainties in the same column as the values and use separate-uncertainty
    – Joseph Wright
    Commented Dec 22, 2017 at 9:56
  • @JosephWright I tried this as well, but was unfortunately not able to set up the table-format of this column option correctly.
    – leandriis
    Commented Dec 22, 2017 at 10:15
5

I came across this post as I was looking for the same question (but noch using the plus-minus sign in between the columns). As the current answer does not work anymore, I decided to add a new answer for future reference.

As of v3.0.0 of siunitx (see the Changelog) the option table-unit-alignment and, I guess, with it the s column type were removed.

The new option is probably S[table-text-alignment = left]. At least it works for me:

\documentclass{article}
\usepackage{siunitx}
\usepackage{booktabs}
\sisetup{separate-uncertainty}
\sisetup{multi-part-units=single}

\begin{document}    
   \begin{tabular}{
l
S[table-format=3.2]@{\,\( \pm \)\,}
S[table-format=2.1]@{\,}
S[table-text-alignment = left]
}
\toprule
Property    &\multicolumn{3}{c}{Value}  \\
\midrule
A           & 284.98 & 5.2 & \si{\meter} \\
B           & 3.86 & 0.3 & \si{\kilo\gram}  \\
C           & 96.4 & 42.3  \\
\bottomrule
\end{tabular}
\end{document}

1
  • Welcome to TeX.SE!
    – Mensch
    Commented Oct 7, 2021 at 13:27

You must log in to answer this question.

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