siunitx icon indicating copy to clipboard operation
siunitx copied to clipboard

retain-explicit-plus does not apply to the exponent in scientifc notation, print-implicit-plus does

Open gvdeynde opened this issue 4 years ago • 3 comments

LuaLaTeX, siuntix 3.0.14

\documentclass{minimal}

\usepackage{siunitx}
\sisetup{
  exponent-mode=scientific,
  group-digits=false,
}

\begin{document}

\num[print-unity-mantissa=false, print-zero-exponent=true, retain-explicit-plus=true]{e+01},
\num[print-unity-mantissa=false, print-zero-exponent=true, retain-explicit-plus=true]{e+00},
\num[print-unity-mantissa=false, print-zero-exponent=true, retain-explicit-plus=true]{e-00},
\num[print-unity-mantissa=false, print-zero-exponent=true, retain-explicit-plus=true]{e-01}

\num[print-unity-mantissa=false, print-zero-exponent=true, print-implicit-plus=true]{e+01},
\num[print-unity-mantissa=false, print-zero-exponent=true, print-implicit-plus=true]{e+00},
\num[print-unity-mantissa=false, print-zero-exponent=true, print-implicit-plus=true]{e-00},
\num[print-unity-mantissa=false, print-zero-exponent=true, print-implicit-plus=true]{e-01}

\end{document}

image

Note that in the first line, the zero exponent (although there is an explicit '+' or '-' in the number in the input) has no sign in the output. In the second line, all four numbers have a sign in the exponent (the '-' does get converted to a '+', though).

It feels a bit "inconsistent". Is this expected behaviour?

How can I have always a sign in the exponent but not in the mantissa?

gvdeynde avatar Jun 21 '21 14:06 gvdeynde

I'll suppress the + for a zero exponent. I'm not sure what to do about your second question - I've never provided a way to print a sign only for the exponent. Can you provide a bit of context?

josephwright avatar Jun 22 '21 07:06 josephwright

It's linked to my question on tex.SE. I want to compare the outcome of the calculation of a set of coefficients by a certain algorithm to a reference solution. I want to put the digits in common in green, digits that differ in red. Since I'm totally not used to programming in LaTeX, I resorted to Python. So I'm calculating the number of correct digits, splitting the number accordingly and Python spews out LaTeX code to format these numbers. But to get a nice alignment in a table, I would like to have a) always a sign for the mantissa and b) always a sign for the exponent.

Screenshot in attachment. On the left side, since those are the reference values, I don't need to "split up" the number and both mantissa and exponent have a sign. On the right side, the newly (and badly for what it's worth) calculated values. I split up mantissa in correct digits that I wrap with a \color{ForestGreen} and the wrong digits that I wrap with \color{OrangeRed}. But then I need to "manually" put the $\times$ and the exponent. And in this last part, it goes "wrong". I cannot force the exponent to have a sign in the exponent but not in the "faked" mantissa of the exponent (which I suppress using [print-unity-mantissa=false].

Hope this makes the use-case a bit more clear.

Thanks for your support, btw.

image

gvdeynde avatar Jun 22 '21 08:06 gvdeynde

The remaining part of this issue is at the enhancement side.

josephwright avatar Jul 04 '21 10:07 josephwright