Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
gvdeynde opened this issue Jun 21, 2021 · 3 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@gvdeynde
Copy link

gvdeynde commented Jun 21, 2021

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?

@josephwright josephwright self-assigned this Jun 21, 2021
@josephwright josephwright added the bug Something isn't working label Jun 21, 2021
@josephwright
Copy link
Owner

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?

@gvdeynde
Copy link
Author

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

@josephwright josephwright added enhancement New feature or request and removed bug Something isn't working labels Jul 4, 2021
@josephwright
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants