From cd10142c66a8a0bf3944f66020e7b1c3cf82df56 Mon Sep 17 00:00:00 2001 From: Joseph Wright Date: Fri, 17 Jan 2025 17:46:35 +0000 Subject: [PATCH] Print exponent part in \ang See #769 --- CHANGELOG.md | 2 + siunitx-angle.dtx | 66 +++++++++++++++++++----------- testfiles/siunitx-angle.luatex.tlg | 20 ++++++++- testfiles/siunitx-angle.tlg | 20 ++++++++- testfiles/siunitx-angle.xetex.tlg | 20 ++++++++- 5 files changed, 99 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1722b628..5b1046cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to ## [Unreleased] ### Fixed +- Printing of exponent part in `\ang` (see issue + [\#769](/~https://github.com/josephwright/siunitx/issues/769)) - Parsing of exponent part in `\ang` (see issue [\#770](/~https://github.com/josephwright/siunitx/issues/770)) diff --git a/siunitx-angle.dtx b/siunitx-angle.dtx index c7defca1..0a1b7822 100644 --- a/siunitx-angle.dtx +++ b/siunitx-angle.dtx @@ -543,10 +543,13 @@ % \@@_arc_print_auxi:nnn, \@@_arc_print_auxi:nVn % } % \begin{macro}{\@@_arc_print_auxii:w} -% \begin{macro}{\@@_arc_print_auxiii:n} -% \begin{macro}{\@@_arc_print_auxiv:NN} -% \begin{macro}{\@@_arc_print_auxv:w} -% \begin{macro}{\@@_arc_print_auxvi:n} +% \begin{macro}{\@@_arc_print_auxiii:nw} +% \begin{macro}{\@@_arc_print_auxiv:nnnnn} +% \begin{macro}{\@@_arc_print_auxv:n} +% \begin{macro}{\@@_arc_print_auxvi:NN} +% \begin{macro}{\@@_arc_print_auxvii:w} +% \begin{macro}{\@@_arc_print_auxiix:w} +% \begin{macro}{\@@_arc_print_auxix:n} % The final stage of printing an angle is to put together the three parts: % this works even for decimal angles as they will blank arguments for the % other two parts The need to handle astronomy-style formatting means that @@ -571,13 +574,13 @@ \bool_if:NTF \l_@@_astronomy_bool { \@@_arc_print_auxii:nw {#2} #1 \q_stop } { - \@@_arc_print_auxv:w #1 \q_stop - \@@_arc_print_auxvi:n {#2} + \@@_arc_print_auxvii:w #1 \q_stop + \@@_arc_print_auxix:n {#2} } } { \siunitx_print_number:n {#1} - \@@_arc_print_auxvi:n {#2} + \@@_arc_print_auxix:n {#2} } \tl_if_blank:nF {#3} { @@ -592,25 +595,36 @@ % for the |\scriptspace|. % \begin{macrocode} \cs_new_protected:Npn \@@_arc_print_auxii:nw - #1#2 \q_nil #3 \q_nil #4 \q_nil #5 \q_nil #6 \q_nil #7 \q_nil #8 \q_stop + #1#2 \q_nil #3 \q_nil #4 \q_nil #5 \q_nil #6 \q_nil #7 \q_stop + { + \@@_arc_print_auxiii:nw {#6} #7 \q_stop + {#2#3#4} {#5} {#1} + } +\cs_new_protected:Npn \@@_arc_print_auxiii:nw + #1#2 \q_nil #3 \q_nil #4 \q_nil #5 \q_nil #6 \q_nil #7 \q_stop + { \@@_arc_print_auxiv:nnnnn {#1} {#6#7} } +\cs_new_protected:Npn \@@_arc_print_auxiv:nnnnn #1#2#3#4#5 { \mode_if_math:TF { \bool_set_true:N \l_@@_tmp_bool } { \bool_set_false:N \l_@@_tmp_bool } - \siunitx_print_number:n {#2#3#4} - \tl_if_blank:nTF {#6} - { \@@_arc_print_auxvi:n {#1} } + \siunitx_print_number:n {#3} + \tl_if_blank:nTF {#1} + { + \siunitx_print_number:n {#2} + \@@_arc_print_auxix:n {#5} + } { \hbox_set:Nn \l_@@_marker_box { - \@@_arc_print_auxiii:n - { \siunitx_print_number:n {#5} } + \@@_arc_print_auxv:n + { \siunitx_print_number:n {#4} } } \hbox_set:Nn \l_@@_unit_box { - \@@_arc_print_auxiii:n + \@@_arc_print_auxv:n { - \siunitx_unit_format:nN {#1} \l_@@_tmp_tl + \siunitx_unit_format:nN {#5} \l_@@_tmp_tl \siunitx_print_unit:V \l_@@_tmp_tl \skip_horizontal:n { -\scriptspace } } @@ -618,12 +632,12 @@ \dim_compare:nNnTF { \box_wd:N \l_@@_marker_box } > { \box_wd:N \l_@@_unit_box } { - \@@_arc_print_auxiv:NN + \@@_arc_print_auxvi:NN \l_@@_marker_box \l_@@_unit_box } { - \@@_arc_print_auxiv:NN + \@@_arc_print_auxvi:NN \l_@@_unit_box \l_@@_marker_box } @@ -638,17 +652,17 @@ } \box_use:N \l_@@_marker_box \skip_horizontal:N \scriptspace - \siunitx_print_number:n {#6} + \siunitx_print_number:n {#1#2} } } -\cs_new_protected:Npn \@@_arc_print_auxiii:n #1 +\cs_new_protected:Npn \@@_arc_print_auxv:n #1 { \bool_if:NTF \l_@@_tmp_bool { \ensuremath } { \use:n } {#1} } -\cs_new_protected:Npn \@@_arc_print_auxiv:NN #1#2 +\cs_new_protected:Npn \@@_arc_print_auxvi:NN #1#2 { \dim_set:Nn \l_@@_tmp_dim { \box_wd:N #1 } \hbox_set_to_wd:Nnn #2 @@ -659,10 +673,13 @@ \tex_hss:D } } -\cs_new_protected:Npn \@@_arc_print_auxv:w +\cs_new_protected:Npn \@@_arc_print_auxvii:w #1 \q_nil #2 \q_nil #3 \q_nil #4 \q_nil #5 \q_nil #6 \q_stop - { \siunitx_print_number:n {#1#2#3#4#5} } -\cs_new_protected:Npn \@@_arc_print_auxvi:n #1 + { \@@_arc_print_auxiix:w {#1#2#3#4#5} #6 \q_stop } +\cs_new_protected:Npn \@@_arc_print_auxiix:w + #1#2 \q_nil #3 \q_nil #4 \q_nil #5 \q_nil #6 \q_nil #7 \q_stop + { \siunitx_print_number:n {#1#6#7} } +\cs_new_protected:Npn \@@_arc_print_auxix:n #1 { \group_begin: \siunitx_unit_options_apply:n {#1} @@ -677,6 +694,9 @@ % \end{macro} % \end{macro} % \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} % % \begin{macrocode} \msg_new:nnnn { siunitx } { arc-multi-sign } diff --git a/testfiles/siunitx-angle.luatex.tlg b/testfiles/siunitx-angle.luatex.tlg index b0d97ac1..6c0ead37 100644 --- a/testfiles/siunitx-angle.luatex.tlg +++ b/testfiles/siunitx-angle.luatex.tlg @@ -88,9 +88,17 @@ l. ... } \l_tmpa_box l. ... } > \box...= -\hbox(6.88586+0.0)x9.59724, direction TLT +\hbox(8.14003+0.83333)x42.55556, direction TLT .\mathon .\OT1/cmr/m/n/10 1 +.\glue(\medmuskip) 2.22217 plus 1.11108 minus 2.22217 +.\OMS/cmsy/m/n/10 ^^B +.\glue(\medmuskip) 2.22217 plus 1.11108 minus 2.22217 +.\OT1/cmr/m/n/10 1 +.\OT1/cmr/m/n/10 0 +.\hbox(4.51111+0.83334)x10.73615, shifted -3.62892, direction TLT +..\OMS/cmsy/m/n/7 ^^@ +..\OT1/cmr/m/n/7 2 .\mathoff .\penalty 10000 .\mathon @@ -291,13 +299,21 @@ l. ... } \l_tmpa_box l. ... } > \box...= -\hbox(7.51782+0.0)x27.88896, direction TLT +\hbox(8.14003+0.83333)x60.84727, direction TLT .\mathon .\OT1/cmr/m/n/10 0 .\OML/cmm/m/it/10 : .\OT1/cmr/m/n/10 2 .\OT1/cmr/m/n/10 3 .\OT1/cmr/m/n/10 4 +.\glue(\medmuskip) 2.22217 plus 1.11108 minus 2.22217 +.\OMS/cmsy/m/n/10 ^^B +.\glue(\medmuskip) 2.22217 plus 1.11108 minus 2.22217 +.\OT1/cmr/m/n/10 1 +.\OT1/cmr/m/n/10 0 +.\hbox(4.51111+0.83334)x10.73615, shifted -3.62892, direction TLT +..\OMS/cmsy/m/n/7 ^^@ +..\OT1/cmr/m/n/7 5 .\mathoff .\penalty 10000 .\mathon diff --git a/testfiles/siunitx-angle.tlg b/testfiles/siunitx-angle.tlg index 43271ba7..dc04ad71 100644 --- a/testfiles/siunitx-angle.tlg +++ b/testfiles/siunitx-angle.tlg @@ -88,9 +88,17 @@ l. ... } \l_tmpa_box l. ... } > \box...= -\hbox(6.88586+0.0)x9.59724 +\hbox(8.14003+0.83333)x42.55556 .\mathon .\OT1/cmr/m/n/10 1 +.\glue(\medmuskip) 2.22217 plus 1.11108 minus 2.22217 +.\OMS/cmsy/m/n/10 ^^B +.\glue(\medmuskip) 2.22217 plus 1.11108 minus 2.22217 +.\OT1/cmr/m/n/10 1 +.\OT1/cmr/m/n/10 0 +.\hbox(4.51111+0.83334)x10.73615, shifted -3.62892 +..\OMS/cmsy/m/n/7 ^^@ +..\OT1/cmr/m/n/7 2 .\mathoff .\penalty 10000 .\mathon @@ -291,13 +299,21 @@ l. ... } \l_tmpa_box l. ... } > \box...= -\hbox(7.51782+0.0)x27.88896 +\hbox(8.14003+0.83333)x60.84727 .\mathon .\OT1/cmr/m/n/10 0 .\OML/cmm/m/it/10 : .\OT1/cmr/m/n/10 2 .\OT1/cmr/m/n/10 3 .\OT1/cmr/m/n/10 4 +.\glue(\medmuskip) 2.22217 plus 1.11108 minus 2.22217 +.\OMS/cmsy/m/n/10 ^^B +.\glue(\medmuskip) 2.22217 plus 1.11108 minus 2.22217 +.\OT1/cmr/m/n/10 1 +.\OT1/cmr/m/n/10 0 +.\hbox(4.51111+0.83334)x10.73615, shifted -3.62892 +..\OMS/cmsy/m/n/7 ^^@ +..\OT1/cmr/m/n/7 5 .\mathoff .\penalty 10000 .\mathon diff --git a/testfiles/siunitx-angle.xetex.tlg b/testfiles/siunitx-angle.xetex.tlg index 152fb4c9..4f65fbb5 100644 --- a/testfiles/siunitx-angle.xetex.tlg +++ b/testfiles/siunitx-angle.xetex.tlg @@ -88,9 +88,17 @@ l. ... } \l_tmpa_box l. ... } > \box...= -\hbox(6.88586+0.0)x9.59724 +\hbox(8.14003+0.83333)x42.55556 .\mathon .\OT1/cmr/m/n/10 1 +.\glue(\medmuskip) 2.22217 plus 1.11108 minus 2.22217 +.\OMS/cmsy/m/n/10 ^^B +.\glue(\medmuskip) 2.22217 plus 1.11108 minus 2.22217 +.\OT1/cmr/m/n/10 1 +.\OT1/cmr/m/n/10 0 +.\hbox(4.51111+0.83334)x10.73615, shifted -3.62892 +..\OMS/cmsy/m/n/7 ^^@ +..\OT1/cmr/m/n/7 2 .\mathoff .\penalty 10000 .\mathon @@ -291,13 +299,21 @@ l. ... } \l_tmpa_box l. ... } > \box...= -\hbox(7.51782+0.0)x27.88896 +\hbox(8.14003+0.83333)x60.84727 .\mathon .\OT1/cmr/m/n/10 0 .\OML/cmm/m/it/10 : .\OT1/cmr/m/n/10 2 .\OT1/cmr/m/n/10 3 .\OT1/cmr/m/n/10 4 +.\glue(\medmuskip) 2.22217 plus 1.11108 minus 2.22217 +.\OMS/cmsy/m/n/10 ^^B +.\glue(\medmuskip) 2.22217 plus 1.11108 minus 2.22217 +.\OT1/cmr/m/n/10 1 +.\OT1/cmr/m/n/10 0 +.\hbox(4.51111+0.83334)x10.73615, shifted -3.62892 +..\OMS/cmsy/m/n/7 ^^@ +..\OT1/cmr/m/n/7 5 .\mathoff .\penalty 10000 .\mathon