Skip to content

Commit

Permalink
Print exponent part in \ang
Browse files Browse the repository at this point in the history
See #769
  • Loading branch information
josephwright committed Jan 17, 2025
1 parent be4341d commit cd10142
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 29 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
66 changes: 43 additions & 23 deletions siunitx-angle.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
{
Expand All @@ -592,38 +595,49 @@
% 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 }
}
}
\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
}
Expand All @@ -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
Expand All @@ -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}
Expand All @@ -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 }
Expand Down
20 changes: 18 additions & 2 deletions testfiles/siunitx-angle.luatex.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,17 @@ l. ... }
<argument> \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
Expand Down Expand Up @@ -291,13 +299,21 @@ l. ... }
<argument> \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
Expand Down
20 changes: 18 additions & 2 deletions testfiles/siunitx-angle.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,17 @@ l. ... }
<argument> \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
Expand Down Expand Up @@ -291,13 +299,21 @@ l. ... }
<argument> \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
Expand Down
20 changes: 18 additions & 2 deletions testfiles/siunitx-angle.xetex.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,17 @@ l. ... }
<argument> \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
Expand Down Expand Up @@ -291,13 +299,21 @@ l. ... }
<argument> \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
Expand Down

0 comments on commit cd10142

Please sign in to comment.