josephwright / siunitx

A comprehensive (SI) units package for LaTeX
LaTeX Project Public License v1.3c
350 stars 25 forks source link

exponent-threshold doesn't remove exponents #711

Closed gasteigerjo closed 5 months ago

gasteigerjo commented 5 months ago

If the input to a number uses exponents, the exponent-thresholds setting is not respected in exponent-mode=threshold. The setting only adds exponents, it doesn't seem to remove them.

Minimal example:

\documentclass{article}

\usepackage{siunitx}
\sisetup{exponent-thresholds=-2:2, exponent-mode=threshold}

\begin{document}
\num{1}, \num{0.1}, \num{0.01}\\
\num{1e0}, \num{1e-1}, \num{1e-2}\\
\num{1}, \num{10}, \num{100}\\
\num{1e0}, \num{1.0e1}, \num{1.00e2}
\end{document}

Lines 1 and 2, as well as lines 3 and 4 should result in the same output, but they don't.

josephwright commented 5 months ago

As detailed in the source for the manual (https://github.com/josephwright/siunitx/blob/main/siunitx.tex#L1529C1-L1532C1):

When the \opt{exponent-mode} is set to \opt{threshold}, values outside of a
threshold range for the exponent are always printed in scientific form. Within
the threshold, they are printed as-given in the input: typically this would be
without an exponent. The threshold range itself is controlled by

So this is explicitly documented - are you submitted a feature request?

gasteigerjo commented 5 months ago

Oh, I didn't read the manual carefully enough then. Thank you for the pointer!

I guess this can be viewed as a feature request then: I find the behavior within the threshold counterintuitive. In my typical use cases, the input data in the Latex source is inconsistently formatted, so I want siunitx to handle the formatting and make it consistent. This is especially true for tables.

josephwright commented 5 months ago

I've given this a bit more thought and looked back at the original feature request. I will adjust: I suspect that whilst there is a logic to the current behaviour, it's likely not expected.