From 2e3d95041e356e681a88cf3fecaa1aae57116c28 Mon Sep 17 00:00:00 2001 From: Joseph Wright Date: Mon, 6 Nov 2023 17:09:48 +0000 Subject: [PATCH] Fix printing "1" when "print-unity-mantissa = false" Fixes #700. --- CHANGELOG.md | 4 ++++ siunitx-number.dtx | 6 +++++- testfiles/siunitx-number.lvt | 3 +++ testfiles/siunitx-number.tlg | 9 +++++++++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28388816..fa052265 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,10 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to - `\siunitx_declare_unit:Nx` - `\siunitx_declare_unit:Nxn` +### Fixed +- Printing of `1` when `print-unity-mantissa = false` (see issue + [\#700](https://github.com/josephwright/siunitx/issues/700)) + ## [v3.3.7] - 2023-10-07 ### Fixed diff --git a/siunitx-number.dtx b/siunitx-number.dtx index 39917f81..04b302cf 100644 --- a/siunitx-number.dtx +++ b/siunitx-number.dtx @@ -4148,7 +4148,11 @@ { ! \str_if_eq_p:nn { #1 . #2 } { 1. } } { \bool_lazy_and_p:nn - { \str_if_eq_p:nn {#3} { 0 } } + { + \bool_lazy_or_p:nn + { \tl_if_blank_p:n {#3} } + { \str_if_eq_p:nn {#3} { 0 } } + } { ! \l_@@_zero_exponent_bool } } { diff --git a/testfiles/siunitx-number.lvt b/testfiles/siunitx-number.lvt index 9ce5d395..3f69ef85 100644 --- a/testfiles/siunitx-number.lvt +++ b/testfiles/siunitx-number.lvt @@ -705,12 +705,15 @@ { \test:n { 1e10 } \test:n { 1e0 } + \test:n { 1 } \keys_set:nn { siunitx } { print-unity-mantissa = true } \test:n { 1e10 } \test:n { 1e0 } + \test:n { 1 } \keys_set:nn { siunitx } { print-unity-mantissa = false } \test:n { 1e10 } \test:n { 1e0 } + \test:n { 1 } } \TEST { Option~setting~"print-zero-exponent" } diff --git a/testfiles/siunitx-number.tlg b/testfiles/siunitx-number.tlg index 77942a13..eb2c02a3 100644 --- a/testfiles/siunitx-number.tlg +++ b/testfiles/siunitx-number.tlg @@ -1641,18 +1641,27 @@ l. ... } > \l_tmpa_tl=1. } l. ... } +> \l_tmpa_tl=1. + } +l. ... } > \l_tmpa_tl=1\times 10^{10}. } l. ... } > \l_tmpa_tl=1. } l. ... } +> \l_tmpa_tl=1. + } +l. ... } > \l_tmpa_tl=10^{10}. } l. ... } > \l_tmpa_tl=1. } l. ... } +> \l_tmpa_tl=1. + } +l. ... } ============================================================ ============================================================ TEST 53: Option setting "print-zero-exponent"