Closed Splines closed 3 months ago
Minimised example
\documentclass{article}
\usepackage{siunitx}
\sisetup{minimum-decimal-digits = 4}
\begin{document}
\qty{5.407 \pm 0.04}{\metre}
\end{document}
The root cause for this is probably the same for the following confusing output:
Off-topic here, but you seem to have missed that siunitx
has native support for multiple uncertainties from v3.1.0, released 2022-04-25.
Thanks a lot for your hot fix 🎉
Unfortunately, users of our library might not be easily able to use an updated version of siunitx. E.g. even for the current LTS Ubuntu (Ubuntu 22.04 jammy), the siunitx version that comes shipped with sudo apt install texlive-science
is 3.0.4
. We do provide an update guide here (at the very bottom), but only up to version 3.1.11 (2022-12-05)
, as this is the last one before we'd have to update other dependencies as well as you make use of the new LaTeX3 layer and expl3
is breaking for us.
That's why I'm asking if there is a workaround when using version 3.1.11 (2022-12-05)
to still get correct output for the following:
\NewDocumentCommand{\UncertStat}{}{_{\text{stat}}}
\NewDocumentCommand{\UncertSys}{}{_{\text{sys}}}
\sisetup{input-digits=0123456789\UncertStat\UncertSys\UncertSystematic}
$$\qty{5.407 \pm 0.010\UncertSys \pm 0.04\UncertStat e-7}{\m}$$
@Splines The auxiliary hasn't changed name, so
\ExplSyntaxOn
\cs_gset:Npn \__siunitx_number_digits_uncert_aux:nn #1#2
{
\exp_not:n {#2}
\int_compare:nNnT
{ \l__siunitx_number_min_decimal_int - \tl_count:n {#1} } > 0
{
\prg_replicate:nn
{ \l__siunitx_number_min_decimal_int - \tl_count:n {#1} } { 0 }
}
}
\ExplSyntaxOff
will locally adjust the code.
I'm still not clear why you are not using the built-in multi-uncertainty support in v3.1.
Thanks a lot!
I'm still not clear why you are not using the built-in multi-uncertainty support in v3.1.
I thought that multi-uncertainty support only referred to being able to add multiple \pm
s to a number. Having looked through the docs again now, I found the uncertainty-descriptors
key and that's exactly what I needed in the first place 🙌. The \NewDocumentCommand
was just a workaround since we didn't know about the other option ;)
We will go ahead and recommend our users to add this to their preamble (or give them a hint they might find this option useful):
\sisetup{uncertainty-descriptor-mode=subscript}
and then generate programatically the following output for quantities:
\qty[uncertainty-descriptors={customlabel1,customlabel2}]{1.2 \pm 0.1 \pm 0.05}{\m}
\qty{5.407 \pm 0.010 \pm 0.04}{\m}
Is there a way to print the 0.04
"as is", i.e. not 0.040
? With round-pad=false
and round-mode=none
and minimum-decimal-digits=0
, we still get 0.040
in version 3.1.11 (2022-12-05)
. Even with you're hotfix (manually applied via your workaround) it's not working as expected. Maybe I have missed a crucial option in the docs?
\qty{5.407 \pm 0.010 \pm 0.04}{\m}
Is there a way to print the
0.04
"as is", i.e. not0.040
? Withround-pad=false
andround-mode=none
andminimum-decimal-digits=0
, we still get0.040
in version3.1.11 (2022-12-05)
. Even with you're hotfix (manually applied via your workaround) it's not working as expected. Maybe I have missed a crucial option in the docs?
No, becaue the main value here has 3 decimal places, so the uncertainty must also be specified to the same precision.
(Or rather that's the internal model siunitx
uses.)
Ah ok and I guess there's also no (easy) way to overwrite that, right?
@Splines I can imagine an approach but that's definitely a non-trivial feature request for the current release not something that can be shoehorned into a past release.
In the case you're willing to put your time and effort into such a feature (which would be much appreciated), we'd like to then also be able to make our users profit from it. That's why I've opened #726 to get to know how users can upgrade to the most recent version of siunitx without having to rethink their entire LaTeX setup.
@Splines Please open a separate issue - including supporting links/PDFs/whatever that show that this approach is used by professionally-typeset material (that's my usual requirement for feature requests).
Presumptions
I use the following sisetup:
Description of problem
I'm wondering why this input:
is printed as
(5.407000 \pm 0.004000) m
in the LaTeX document. Note that siunitx altered the uncertainty from0.04
to0.004
.The root cause for this is probably the same for the following confusing output:
will result in:
note that the
0
is printed after the\text{stat}
. Is there a way to get rid of this trailing0
altogether?Efforts taken
round-mode
as well asround-pad
, but these settings didn't help. Also found out aboutminimum-decimal-digits
.round-pad
in versionv3.0.0
. Searched for "minimum" and found that #601 is fixed inv3.0.50
. As I'm using3.1.11
, I should have this fix available.Additional context
If you're wondering why we need this
\NewDocumentCommand
stuff. A friend of mine and me currently build a Python library calledResultWizard
as an interface between Python code and the siunitx LaTeX package. We're in the second alpha version right now and stumbled upon the described issue here.System Information
I'm using TeX Live in WSL (Ubuntu 22.04 jammy). siunitx version:
3.1.11 (2022-12-05)
.