From a4fe2979f7d2d423a9075dd5299ef9b4cead2e2d Mon Sep 17 00:00:00 2001 From: Joseph Wright Date: Wed, 2 Oct 2024 10:35:27 +0100 Subject: [PATCH] Support uncertainties in seconds part of arc angles (fixes #749) --- CHANGELOG.md | 2 ++ siunitx-angle.dtx | 50 +++++++++++++++++++++++++++---------- siunitx.tex | 4 +++ testfiles/siunitx-angle.lvt | 9 +++++++ testfiles/siunitx-angle.tlg | 44 ++++++++++++++++++++++++++++++++ 5 files changed, 96 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06f2ab46..6a6df4ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to ### Changed - Automatically convert `~` to `\sim` (see issue [\#746](https://github.com/josephwright/siunitx/issues/746)) +- Support uncertainties in seconds part of arc angles (see issue + [\#749](https://github.com/josephwright/siunitx/issues/749)) - Require LaTeX release 2022-11-01 or later ## [v3.3.22] - 2024-09-30 diff --git a/siunitx-angle.dtx b/siunitx-angle.dtx index 7a4675b6..91fbef1a 100644 --- a/siunitx-angle.dtx +++ b/siunitx-angle.dtx @@ -396,24 +396,45 @@ % To get the sign in the right place whilst dealing with zero filling % means doing some shuffling. That means doing processing of each number % manually. For degrees, auto-conversion can give |-0|, which needs to be -% picked up early to set the sign. +% picked up early to set the sign. A bit of shuffling is needed as only +% the seconds argument is permitted to have an uncertainty. % \begin{macrocode} \cs_new_protected:Npn \@@_arc_sign:nnn #1#2#3 { \group_begin: \@@_suppress_exp: - \@@_suppress_uncert: \tl_clear:N \l_@@_sign_tl \bool_set_false:N \l_@@_signed_bool - \str_if_eq:nnTF {#1} { -0 } - { - \@@_arc_sign:nn { } { degrees } - \@@_suppress_comp: - \tl_set:Nn \l_@@_sign_tl { - } - \bool_set_true:N \l_@@_signed_bool - } - { \@@_arc_sign:nn {#1} { degrees } } - \@@_arc_sign:nn {#2} { minutes } + \group_begin: + \@@_suppress_uncert: + \str_if_eq:nnTF {#1} { -0 } + { + \@@_arc_sign:nn { } { degrees } + \@@_suppress_comp: + \tl_set:Nn \l_@@_sign_tl { - } + \bool_set_true:N \l_@@_signed_bool + } + { \@@_arc_sign:nn {#1} { degrees } } + \@@_arc_sign:nn {#2} { minutes } + \tl_set:Nx \l_@@_tmp_tl + { + \tl_set:Nn \exp_not:N \l_@@_sign_tl + { \exp_not:V \l_@@_sign_tl } + \tl_set:Nn \exp_not:N \l_@@_degrees_tl + { \exp_not:V \l_@@_degrees_tl } + \tl_set:Nn \exp_not:N \l_@@_minutes_tl + { \exp_not:V \l_@@_minutes_tl } + \exp_not:c + { + bool_set_ + \bool_if:NTF \l_@@_signed_bool + { true } + { false } + :N + } + \exp_not:N \l_@@_signed_bool + } + \exp_after:wN \group_end: \l_@@_tmp_tl \@@_arc_sign:nn {#3} { seconds } \tl_if_empty:NF \l_@@_sign_tl { @@ -440,8 +461,11 @@ } { \siunitx_number_parse:nN {#1} \l_@@_tmp_tl - \exp_after:wN \@@_extract_sign:nnnnnnnn \l_@@_tmp_tl {#2} - \bool_set_true:N \l_@@_signed_bool + \tl_if_empty:NF \l_@@_tmp_tl + { + \exp_after:wN \@@_extract_sign:nnnnnnnn \l_@@_tmp_tl {#2} + \bool_set_true:N \l_@@_signed_bool + } } } \cs_new_protected:Npn \@@_arc_sign_auxi:n #1 diff --git a/siunitx.tex b/siunitx.tex index f4b08f93..dd375cb5 100644 --- a/siunitx.tex +++ b/siunitx.tex @@ -3319,6 +3319,10 @@ \subsection{Version~\version{3.3}} \subsection{Version~\version{3.4}} +\begin{itemize} + \item Support uncertainties in seconds part of arc angles +\end{itemize} + \section{Upgrading from version~\version{2}% \label{sec:upgrading}} diff --git a/testfiles/siunitx-angle.lvt b/testfiles/siunitx-angle.lvt index 064ce33b..11723227 100644 --- a/testfiles/siunitx-angle.lvt +++ b/testfiles/siunitx-angle.lvt @@ -213,4 +213,13 @@ \test:nnn { -1 } { -2 } { -3 } } +\TEST { Uncertainties~in~arc~format } + { + \keys_set:nn { siunitx } { angle-mode = arc } + \test:nnn { 10(1) } { } { } + \test:nnn { } { 10(1) } { } + \test:nnn { } { } { 10(1) } + + } + \END diff --git a/testfiles/siunitx-angle.tlg b/testfiles/siunitx-angle.tlg index 9fae6204..b7d353f7 100644 --- a/testfiles/siunitx-angle.tlg +++ b/testfiles/siunitx-angle.tlg @@ -2273,3 +2273,47 @@ An angle given as an arc should have at most one sign: only the first sign will \l_tmpa_box l. ... } ============================================================ +============================================================ +TEST 15: Uncertainties in arc format +============================================================ +! Package siunitx Error: Invalid number '10(1)'. +For immediate help type H . + ... +l. ... } +The input '10(1)' could not be parsed as a number following the format defined in module documentation. +> \box...= +\hbox(0.0+0.0)x0.0 +! OK. + \l_tmpa_box +l. ... } +! Package siunitx Error: Invalid number '10(1)'. +For immediate help type H . + ... +l. ... } +The input '10(1)' could not be parsed as a number following the format defined in module documentation. +> \box...= +\hbox(0.0+0.0)x0.0 +! OK. + \l_tmpa_box +l. ... } +> \box...= +\hbox(7.51782+2.5)x27.88896 +.\mathon +.\OT1/cmr/m/n/10 1 +.\OT1/cmr/m/n/10 0 +.\OT1/cmr/m/n/10 ( +.\OT1/cmr/m/n/10 1 +.\OT1/cmr/m/n/10 ) +.\mathoff +.\penalty 10000 +.\mathon +.\hbox(7.51782+0.0)x5.11111 +..\hbox(0.0+0.0)x0.0 +..\hbox(3.8889+0.0)x5.11111, shifted -3.62892 +...\OMS/cmsy/m/n/7 0 +...\OMS/cmsy/m/n/7 0 +.\mathoff +! OK. + \l_tmpa_box +l. ... } +============================================================