Skip to content

Commit

Permalink
Support uncertainties in seconds part of arc angles (fixes #749)
Browse files Browse the repository at this point in the history
  • Loading branch information
josephwright committed Oct 2, 2024
1 parent da01371 commit a4fe297
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 37 additions & 13 deletions siunitx-angle.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions siunitx.tex
Original file line number Diff line number Diff line change
Expand Up @@ -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}}

Expand Down
9 changes: 9 additions & 0 deletions testfiles/siunitx-angle.lvt
Original file line number Diff line number Diff line change
Expand Up @@ -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
44 changes: 44 additions & 0 deletions testfiles/siunitx-angle.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -2273,3 +2273,47 @@ An angle given as an arc should have at most one sign: only the first sign will
<argument> \l_tmpa_box
l. ... }
============================================================
============================================================
TEST 15: Uncertainties in arc format
============================================================
! Package siunitx Error: Invalid number '10(1)'.
For immediate help type H <return>.
...
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.
<argument> \l_tmpa_box
l. ... }
! Package siunitx Error: Invalid number '10(1)'.
For immediate help type H <return>.
...
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.
<argument> \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.
<argument> \l_tmpa_box
l. ... }
============================================================

0 comments on commit a4fe297

Please sign in to comment.