josephwright / josephwright/siunitx

Rounding uncertainty in tables results in different number of digits

Open
#843 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TeX
Stars
407
Forks
29
Avg merge
11h 20m
Merged PRs (30d)
3

Description

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!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the minimal table examples with siunitx and tabularray, comparing round-mode=uncertainty with round-mode=places. Start by tracing how uncertainty formatting and table alignment interact; done means a documented workaround or supported behavior that rounds both the main values and uncertainties to one decimal place.

Written by the indexing model from the issue text.

Assessment

Tech stack
latex
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.