siunitx icon indicating copy to clipboard operation
siunitx copied to clipboard

[bug] table-format and input in e-notation

Open rlalik opened this issue 1 month ago • 3 comments

I have following code:

\begin{table}[!h]
  \centering
  \begin{tabularx}{1.0\linewidth}{S[table-format=1.3]}
  \toprule
-1.040e+00 \\
-1.000e+00 \\
-9.600e-01 \\
-9.200e-01 \\
  \bottomrule
  \end{tabularx}
\end{table}

which prints numbers as follows:

−1.040
−1.000
−9.600
−9.200

The expected output would be:

−1.040
−1.000
−0.960
−0.920

If \begin{tabularx}{1.0\linewidth}{S[table-format=1.3,exponent-mode=fixed]} is used, then the output is:

−1.040
−1.000
−0.9600
−0.9200

which doesn't fits the requested table-format.

siunitx version: Package: siunitx 2025-05-22 v3.4.12 A comprehensive (SI) units package from Overleaf TeX Live version 2025.

rlalik avatar Oct 29 '25 02:10 rlalik

In the first example, you have given no space for an exponent so siunitx is printing you input as-is but without any exponent - so you see misleading values. In the second case, you need to apply rounding to drop the precision of the values: this does not happen automatically. Basically, it's your task to ensure that the table-format is suitable for the input values you have.

josephwright avatar Oct 29 '25 06:10 josephwright

Note in both cases there is a warning in the log that the tabular boxes are overfull.

josephwright avatar Oct 29 '25 06:10 josephwright

Oh, my bad, I made assumption that if e.g. table-format=+1.3 then siunitx will convert to fixed point, but this works only if exponent-mode=fixed is used. And second bad assumption on my side was that table-format=+2.3 works same like C's %+5.3f. But now I get that this is only for alignment purpose if I understand correctly and it is on my side to put specific number of digits in the input. And the trailing zeros should not be removed because they are some expression of precision.

rlalik avatar Oct 29 '25 11:10 rlalik