siunitx icon indicating copy to clipboard operation
siunitx copied to clipboard

Rounding uncertainty in tables results in different number of digits

Open jankapte opened this issue 10 months ago • 1 comments

I love that package and it works great throughout the body of my article, but I'm having a hard time to apply it in tables:

\usepackage{tabularray}
\UseTblrLibrary{booktabs}

\begin{table}
  \sisetup{uncertainty-mode=separate, round-precision=1, round-mode=uncertainty, table-alignment-mode=format}
  \centering
  \caption{my caption}\label{my label}
  \begin{tblr}{
    hline{1,Z} = {1pt, solid},
    hspan=minimal,
    colspec = {@{}S[table-format=1.1(1)] S[table-format=1.1(1)] S[table-format=1.1(1)] S[table-format=1.1(1)] S[table-format=1.1(1)]@{}},
    row{1} = {font=\bfseries, guard},
    }
    3*std (\unit{\kelvin})                & max (\unit{\kelvin})                 & mean (\unit{\kelvin})                 & rms (\unit{\kelvin})                 & std (\unit{\kelvin})                 \\
    1.88385113 +- 0.27152522 & 1.86174299 +- 0.66771079 & -0.08869092 +- 0.11967722 & 0.64419944 +- 0.09334350 & 0.62795038 +- 0.09050841\\
  \end{tblr}
\end{table}

This renders as

Image

Is there any way to enforce rounding of all numbers to N (say 1) places? I think I understand that rounding the uncertainty rounds to significant digits first and then applies the same precision to the "main" number - but can we enforce something like

\begin{table}
  \sisetup{uncertainty-mode=separate, round-precision=1, round-mode=places, table-alignment-mode=format}
  \centering
  \caption{my caption}\label{my label}
  \begin{tblr}{
    hline{1,Z} = {1pt, solid},
    hspan=minimal,
    colspec = {@{}S[table-format=1.1(1)] S[table-format=1.1(1)] S[table-format=1.1(1)] S[table-format=1.1(1)] S[table-format=1.1(1)]@{}},
    row{1} = {font=\bfseries, guard},
    }
    3*std (\unit{\kelvin})                & max (\unit{\kelvin})                 & mean (\unit{\kelvin})                 & rms (\unit{\kelvin})                 & std (\unit{\kelvin})                 \\
    1.88385113 +- 0.27152522 & 1.86174299 +- 0.66771079 & -0.08869092 +- 0.11967722 & 0.64419944 +- 0.09334350 & 0.62795038 +- 0.09050841\\
  \end{tblr}
\end{table}

Note the round-mode.

This results in

Image

but I'd love to see something like this (which I created by manually rounding the numbers in the table).

Image

Are there any workarounds to achieve my goal? Maybe by splitting the numbers in to two explicit numbers and round those, a la $\num{1.8}\pm\num{0.1}$? How would that work in a table?

Note that my uncertainties are standard deviations of measurement data in reality.

Thanks!

jankapte avatar Jan 05 '26 15:01 jankapte

I've always been wary of rounding uncertainties as they convey somewhat complex information about experimental values. The current rounding mode does as you say first round the uncertainty then the main value: I think that's reasonably defensible and does not distort the experimental values. (That said, I've always wanted to find a good way to avoid rounding uncertainty to 0.1: in my area, we avoid that, so would have two places in these cases.)

My worry here is that whilst in your example 'round to one decimal place' works, input such as `0.569 +- 0.043' would end up with an esd of 0.0 if that was applied automatically, and that's really not something that should happen. So the challenge is finding both and algorithm and a description that make sense.

josephwright avatar Jan 06 '26 08:01 josephwright