summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2023-07-31 20:18:52 +0000
committerKarl Berry <karl@freefriends.org>2023-07-31 20:18:52 +0000
commit7acb93c43231a4e62fc5892272164ea0f40b16ef (patch)
tree912bcb48f6824ed1a609b682b8439072619190c2 /Master/texmf-dist/tex
parent09b0073c8ee54754680735a622abb0f86f6ce420 (diff)
siunitx (31jul23)
git-svn-id: svn://tug.org/texlive/trunk@67780 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/siunitx/siunitx.sty3916
1 files changed, 2094 insertions, 1822 deletions
diff --git a/Master/texmf-dist/tex/latex/siunitx/siunitx.sty b/Master/texmf-dist/tex/latex/siunitx/siunitx.sty
index 5ec52bd3900..fa6cde5a381 100644
--- a/Master/texmf-dist/tex/latex/siunitx/siunitx.sty
+++ b/Master/texmf-dist/tex/latex/siunitx/siunitx.sty
@@ -5,11 +5,11 @@
%% The original source files were:
%%
%% siunitx.dtx (with options: `package,init')
+%% siunitx-number.dtx (with options: `package')
%% siunitx-angle.dtx (with options: `package')
%% siunitx-complex.dtx (with options: `package')
%% siunitx-compound.dtx (with options: `package')
%% siunitx-locale.dtx (with options: `package')
-%% siunitx-number.dtx (with options: `package')
%% siunitx-print.dtx (with options: `package')
%% siunitx-table.dtx (with options: `package')
%% siunitx-unit.dtx (with options: `package')
@@ -42,7 +42,7 @@
}%
\endinput
}%
-\ProvidesExplPackage {siunitx} {2023-07-26} {3.2.9}
+\ProvidesExplPackage {siunitx} {2023-07-31} {3.3.0}
{A comprehensive (SI) units package}
\msg_new:nnnn { siunitx } { incompatible-package }
{ Package~'#1'~incompatible. }
@@ -63,1733 +63,6 @@
}
\providecommand \IfFormatAtLeastTF { \@ifl@t@r \fmtversion }
\tl_new:N \l__siunitx_tmp_tl
-\bool_new:N \l__siunitx_angle_tmp_bool
-\dim_new:N \l__siunitx_angle_tmp_dim
-\tl_new:N \l__siunitx_angle_tmp_tl
-\keys_define:nn { siunitx }
- {
- angle-mode .choice: ,
- angle-mode / arc .code:n =
- {
- \bool_set_true:N \l__siunitx_angle_force_arc_bool
- \bool_set_false:N \l__siunitx_angle_force_decimal_bool
- } ,
- angle-mode / decimal .code:n =
- {
- \bool_set_false:N \l__siunitx_angle_force_arc_bool
- \bool_set_true:N \l__siunitx_angle_force_decimal_bool
- } ,
- angle-mode / input .code:n =
- {
- \bool_set_false:N \l__siunitx_angle_force_arc_bool
- \bool_set_false:N \l__siunitx_angle_force_decimal_bool
- } ,
- angle-symbol-degree .tl_set:N =
- \l__siunitx_angle_symbol_degree_tl ,
- angle-symbol-minute .tl_set:N =
- \l__siunitx_angle_symbol_minute_tl ,
- angle-symbol-second .tl_set:N =
- \l__siunitx_angle_symbol_second_tl ,
- angle-symbol-over-decimal .bool_set:N =
- \l__siunitx_angle_astronomy_bool ,
- angle-separator .tl_set:N =
- \l__siunitx_angle_separator_tl ,
- fill-angle-degrees .bool_set:N =
- \l__siunitx_angle_fill_degrees_bool ,
- fill-angle-minutes .bool_set:N =
- \l__siunitx_angle_fill_minutes_bool ,
- fill-angle-seconds .bool_set:N =
- \l__siunitx_angle_fill_seconds_bool ,
- number-angle-product .tl_set:N =
- \l__siunitx_angle_product_tl
- }
-\bool_new:N \l__siunitx_angle_force_arc_bool
-\bool_new:N \l__siunitx_angle_force_decimal_bool
-\cs_new_protected:Npn \siunitx_angle:n #1
- {
- \bool_if:NTF \l_siunitx_number_parse_bool
- { \__siunitx_angle_angle:n {#1} }
- {
- \tl_if_blank:nF {#1}
- {
- \tl_set:Nn \l__siunitx_angle_degrees_tl { \ensuremath {#1} }
- \__siunitx_angle_arc_print:VVV
- \l__siunitx_angle_degrees_tl
- \c_empty_tl
- \c_empty_tl
- }
- }
- }
-\cs_new_protected:Npn \__siunitx_angle_angle:n #1
- {
- \bool_if:NTF \l__siunitx_angle_force_arc_bool
- { \exp_args:Ne \__siunitx_angle_arc_convert:n { \fp_eval:n {#1} } }
- {
- \siunitx_number_parse:nN {#1} \l__siunitx_angle_degrees_tl
- \siunitx_number_process:NN \l__siunitx_angle_degrees_tl \l__siunitx_angle_degrees_tl
- \tl_set:Nx \l__siunitx_angle_degrees_tl
- { \siunitx_number_output:NN \l__siunitx_angle_degrees_tl \q_nil }
- \__siunitx_angle_arc_print:VVV
- \l__siunitx_angle_degrees_tl
- \c_empty_tl
- \c_empty_tl
- }
- }
-\cs_new_protected:Npn \siunitx_angle:nnn #1#2#3
- {
- \bool_if:NTF \l_siunitx_number_parse_bool
- {
- \bool_if:NTF \l__siunitx_angle_force_decimal_bool
- {
- \exp_args:Ne \siunitx_angle:n
- { \fp_eval:n { #1 + (#2) / 60 + (#3) / 3600 } }
- }
- { \__siunitx_angle_arc_sign:nnn {#1} {#2} {#3} }
- }
- {
- \tl_set:Nx \l__siunitx_angle_degrees_tl
- { \tl_if_blank:nF {#1} { \exp_not:n { \ensuremath {#1} } } }
- \tl_set:Nx \l__siunitx_angle_minutes_tl
- { \tl_if_blank:nF {#2} { \exp_not:n { \ensuremath {#2} } } }
- \tl_set:Nx \l__siunitx_angle_seconds_tl
- { \tl_if_blank:nF {#3} { \exp_not:n { \ensuremath {#3} } } }
- \__siunitx_angle_arc_print:VVV
- \l__siunitx_angle_degrees_tl
- \l__siunitx_angle_minutes_tl
- \l__siunitx_angle_seconds_tl
- }
- }
-\cs_new_protected:Npn \__siunitx_angle_arc_convert:n #1
- {
- \use:x
- {
- \siunitx_angle:nnn
- { \fp_eval:n { trunc(#1,0) } }
- { \fp_eval:n { trunc((#1 - trunc(#1,0)) * 60,0) } }
- {
- \fp_eval:n
- {
- (
- (#1 - trunc(#1,0)) * 60
- - trunc((#1 - trunc(#1,0)) * 60,0)
- )
- * 60
- }
- }
- }
- }
-\tl_new:N \l__siunitx_angle_degrees_tl
-\tl_new:N \l__siunitx_angle_minutes_tl
-\tl_new:N \l__siunitx_angle_seconds_tl
-\tl_new:N \l__siunitx_angle_sign_tl
-\cs_new_protected:Npn \__siunitx_angle_arc_sign:nnn #1#2#3
- {
- \group_begin:
- \keys_set:nn { siunitx }
- {
- input-close-uncertainty = ,
- input-exponent-markers = ,
- input-open-uncertainty = ,
- input-uncertainty-signs =
- }
- \tl_clear:N \l__siunitx_angle_sign_tl
- \__siunitx_angle_arc_sign:nn {#1} { degrees }
- \__siunitx_angle_arc_sign:nn {#2} { minutes }
- \__siunitx_angle_arc_sign:nn {#3} { seconds }
- \tl_if_empty:NF \l__siunitx_angle_sign_tl
- {
- \clist_map_inline:nn { degrees , minutes , seconds }
- {
- \tl_if_empty:cF { l__siunitx_angle_ ##1 _tl }
- {
- \tl_set:cx { l__siunitx_angle_ ##1 _tl }
- {
- { }
- { \exp_not:V \l__siunitx_angle_sign_tl }
- \exp_after:wN \exp_after:wN \exp_after:wN
- \__siunitx_angle_sign:nnnnnnn
- \cs:w l__siunitx_angle_ ##1 _tl \cs_end:
- }
- \clist_map_break:
- }
- }
- }
- \clist_map_inline:nn { degrees , minutes , seconds }
- {
- \tl_if_empty:cF { l__siunitx_angle_ ##1 _tl }
- {
- \exp_args:Ncc \siunitx_number_process:NN
- { l__siunitx_angle_ ##1 _tl } { l__siunitx_angle_ ##1 _tl }
- \tl_set:cx { l__siunitx_angle_ ##1 _tl }
- {
- \exp_args:Nc \siunitx_number_output:NN
- { l__siunitx_angle_ ##1 _tl } \q_nil
- }
- }
- }
- \__siunitx_angle_arc_print:VVV
- \l__siunitx_angle_degrees_tl
- \l__siunitx_angle_minutes_tl
- \l__siunitx_angle_seconds_tl
- \group_end:
- }
-\cs_new_protected:Npn \__siunitx_angle_arc_sign:nn #1#2
- {
- \tl_if_blank:nTF {#1}
- {
- \bool_if:cTF { l__siunitx_angle_fill_ #2 _bool }
- {
- \tl_set:cn { l__siunitx_angle_ #2 _tl }
- { { } { } { 0 } { } { } { } { 0 } }
- }
- { \tl_clear:c { l__siunitx_angle_ #2 _tl } }
- }
- {
- \siunitx_number_parse:nN {#1} \l__siunitx_angle_tmp_tl
- \exp_after:wN \__siunitx_angle_extract_sign:nnnnnnnn \l__siunitx_angle_tmp_tl {#2}
- }
- }
-\cs_new_protected:Npn \__siunitx_angle_extract_sign:nnnnnnnn #1#2#3#4#5#6#7#8
- {
- \tl_if_blank:nTF {#2}
- { \tl_set_eq:cN { l__siunitx_angle_ #8 _tl } \l__siunitx_angle_tmp_tl }
- {
- \tl_set:cn { l__siunitx_angle_ #8 _tl }
- { {#1} { } {#3} {#4} {#5} {#6} {#7} }
- \tl_set:Nn \l__siunitx_angle_sign_tl {#2}
- \keys_set:nn { siunitx }
- { input-comparators = , input-signs = }
- }
- }
-\cs_new:Npn \__siunitx_angle_sign:nnnnnnn #1#2#3#4#5#6#7
- { \exp_not:n { {#3} {#4} {#5} {#6} {#7} } }
-\box_new:N \l__siunitx_angle_marker_box
-\box_new:N \l__siunitx_angle_unit_box
-\cs_new_protected:Npn \__siunitx_angle_arc_print:nnn #1#2#3
- {
- \__siunitx_angle_arc_print_auxi:nVn {#1}
- \l__siunitx_angle_symbol_degree_tl {#2#3}
- \__siunitx_angle_arc_print_auxi:nVn {#2}
- \l__siunitx_angle_symbol_minute_tl {#3}
- \__siunitx_angle_arc_print_auxi:nVn {#3}
- \l__siunitx_angle_symbol_second_tl { }
- }
-\cs_generate_variant:Nn \__siunitx_angle_arc_print:nnn { VVV }
-\cs_new_protected:Npn \__siunitx_angle_arc_print_auxi:nnn #1#2#3
- {
- \tl_if_blank:nF {#1}
- {
- \bool_if:NTF \l_siunitx_number_parse_bool
- {
- \bool_if:NTF \l__siunitx_angle_astronomy_bool
- { \__siunitx_angle_arc_print_auxii:nw {#2} #1 \q_stop }
- {
- \__siunitx_angle_arc_print_auxv:w #1 \q_stop
- \__siunitx_angle_arc_print_auxvi:n {#2}
- }
- }
- {
- \siunitx_print_number:n {#1}
- \__siunitx_angle_arc_print_auxvi:n {#2}
- }
- \tl_if_blank:nF {#3}
- {
- \nobreak
- \l__siunitx_angle_separator_tl
- }
- }
- }
-\cs_generate_variant:Nn \__siunitx_angle_arc_print_auxi:nnn { nV }
-\cs_new_protected:Npn \__siunitx_angle_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
- {
- \mode_if_math:TF
- { \bool_set_true:N \l__siunitx_angle_tmp_bool }
- { \bool_set_false:N \l__siunitx_angle_tmp_bool }
- \siunitx_print_number:n {#2#3#4}
- \tl_if_blank:nTF {#6}
- { \__siunitx_angle_arc_print_auxvi:n {#1} }
- {
- \hbox_set:Nn \l__siunitx_angle_marker_box
- {
- \__siunitx_angle_arc_print_auxiii:n
- { \siunitx_print_number:n {#5} }
- }
- \hbox_set:Nn \l__siunitx_angle_unit_box
- {
- \__siunitx_angle_arc_print_auxiii:n
- {
- \siunitx_unit_format:nN {#1} \l__siunitx_angle_tmp_tl
- \siunitx_print_unit:V \l__siunitx_angle_tmp_tl
- \skip_horizontal:n { -\scriptspace }
- }
- }
- \dim_compare:nNnTF { \box_wd:N \l__siunitx_angle_marker_box } >
- { \box_wd:N \l__siunitx_angle_unit_box }
- {
- \__siunitx_angle_arc_print_auxiv:NN
- \l__siunitx_angle_marker_box
- \l__siunitx_angle_unit_box
- }
- {
- \__siunitx_angle_arc_print_auxiv:NN
- \l__siunitx_angle_unit_box
- \l__siunitx_angle_marker_box
- }
- \hbox_set_to_wd:Nnn \l__siunitx_angle_marker_box
- \l__siunitx_angle_tmp_dim
- {
- \hbox_overlap_right:n
- { \box_use_drop:N \l__siunitx_angle_marker_box }
- \hbox_overlap_right:n
- { \box_use_drop:N \l__siunitx_angle_unit_box }
- \tex_hfil:D
- }
- \box_use:N \l__siunitx_angle_marker_box
- \skip_horizontal:N \scriptspace
- \siunitx_print_number:n {#6}
- }
- }
-\cs_new_protected:Npn \__siunitx_angle_arc_print_auxiii:n #1
- {
- \bool_if:NTF \l__siunitx_angle_tmp_bool
- { \ensuremath }
- { \use:n }
- {#1}
- }
-\cs_new_protected:Npn \__siunitx_angle_arc_print_auxiv:NN #1#2
- {
- \dim_set:Nn \l__siunitx_angle_tmp_dim { \box_wd:N #1 }
- \hbox_set_to_wd:Nnn #2
- \l__siunitx_angle_tmp_dim
- {
- \tex_hss:D
- \hbox_unpack_drop:N #2
- \tex_hss:D
- }
- }
-\cs_new_protected:Npn \__siunitx_angle_arc_print_auxv: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 \__siunitx_angle_arc_print_auxvi:n #1
- {
- \nobreak
- \l__siunitx_angle_product_tl
- \siunitx_unit_format:nN {#1} \l__siunitx_angle_tmp_tl
- \siunitx_print_unit:V \l__siunitx_angle_tmp_tl
- }
-\keys_set:nn { siunitx }
- {
- angle-mode = input ,
- angle-symbol-degree = \degree ,
- angle-symbol-minute = \arcminute ,
- angle-symbol-over-decimal = false ,
- angle-symbol-second = \arcsecond ,
- angle-separator = ,
- fill-angle-degrees = false ,
- fill-angle-minutes = false ,
- fill-angle-seconds = false ,
- number-angle-product =
- }
-\fp_new:N \l__siunitx_complex_tmp_fp
-\tl_new:N \l__siunitx_complex_tmp_tl
-\tl_new:N \l__siunitx_complex_input_tl
-\tl_new:N \l__siunitx_complex_comparator_tl
-\tl_new:N \l__siunitx_complex_exp_tl
-\tl_new:N \l__siunitx_complex_real_tl
-\tl_new:N \l__siunitx_complex_img_tl
-\tl_new:N \l__siunitx_complex_mag_tl
-\tl_new:N \l__siunitx_complex_angle_tl
-\tl_new:N \l__siunitx_complex_join_tl
-\tl_new:N \l__siunitx_complex_sign_tl
-\bool_new:N \l__siunitx_complex_root_after_bool
-\bool_new:N \l__siunitx_complex_force_cartesian_bool
-\bool_new:N \l__siunitx_complex_force_polar_bool
-\bool_new:N \l__siunitx_complex_polar_degree_bool
-\keys_define:nn { siunitx }
- {
- complex-mode .choice: ,
- complex-mode / cartesian .code:n =
- {
- \bool_set_true:N \l__siunitx_complex_force_cartesian_bool
- \bool_set_false:N \l__siunitx_complex_force_polar_bool
- } ,
- complex-mode / polar .code:n =
- {
- \bool_set_false:N \l__siunitx_complex_force_cartesian_bool
- \bool_set_true:N \l__siunitx_complex_force_polar_bool
- } ,
- complex-mode / input .code:n =
- {
- \bool_set_false:N \l__siunitx_complex_force_cartesian_bool
- \bool_set_false:N \l__siunitx_complex_force_polar_bool
- } ,
- complex-angle-unit .choice: ,
- complex-angle-unit / degrees .code:n =
- { \bool_set_true:N \l__siunitx_complex_polar_degree_bool } ,
- complex-angle-unit / radians .code:n =
- { \bool_set_false:N \l__siunitx_complex_polar_degree_bool } ,
- complex-root-position .choice: ,
- complex-root-position / after-number .code:n =
- { \bool_set_true:N \l__siunitx_complex_root_after_bool } ,
- complex-root-position / before-number .code:n =
- { \bool_set_false:N \l__siunitx_complex_root_after_bool } ,
- complex-symbol-angle .tl_set:N =
- \l__siunitx_complex_symbol_angle_tl ,
- complex-symbol-degree .tl_set:N =
- \l__siunitx_complex_symbol_degree_tl ,
- input-complex-root .tl_set:N =
- \l__siunitx_complex_input_root_tl ,
- output-complex-root .tl_set:N =
- \l__siunitx_complex_output_root_tl ,
- print-complex-unity .bool_set:N =
- \l__siunitx_complex_print_unity_bool
- }
-\cs_new_protected:Npn \__siunitx_complex_parse:nNN #1#2#3
- {
- \group_begin:
- \__siunitx_complex_parse_clear:
- \protected@edef \l__siunitx_complex_arg_tl {#1}
- \tl_set_eq:NN \l__siunitx_complex_input_tl \l__siunitx_complex_arg_tl
- \siunitx_number_normalize_symbols:N \l__siunitx_complex_arg_tl
- \tl_if_empty:NF \l__siunitx_complex_arg_tl
- { \__siunitx_complex_parse_comparator: }
- \__siunitx_complex_parse_check:
- \cs_set_protected:Npx \__siunitx_complex_parse_end:
- {
- \tl_set:Nn \exp_not:N #2 { \exp_not:V \l__siunitx_complex_real_tl }
- \tl_set:Nn \exp_not:N #3 { \exp_not:V \l__siunitx_complex_img_tl }
- }
- \exp_after:wN \group_end:
- \__siunitx_complex_parse_end:
- }
-\cs_new_protected:Npn \__siunitx_complex_parse_end: { }
-\cs_new_protected:Npn \__siunitx_complex_parse_clear:
- {
- \tl_clear:N \l__siunitx_complex_real_tl
- \tl_clear:N \l__siunitx_complex_img_tl
- \tl_clear:N \l__siunitx_complex_exp_tl
- \tl_clear:N \l__siunitx_complex_sign_tl
- \tl_clear:N \l__siunitx_complex_join_tl
- }
-\cs_new_protected:Npn \__siunitx_complex_parse_check:
- {
- \tl_if_empty:NTF \l__siunitx_complex_img_tl
- { \__siunitx_complex_parse_check:N \l__siunitx_complex_real_tl }
- {
- \tl_if_empty:NTF \l__siunitx_complex_real_tl
- { \__siunitx_complex_parse_check:N \l__siunitx_complex_img_tl }
- {
- \__siunitx_complex_parse_check:N \l__siunitx_complex_real_tl
- \tl_set_eq:NN \l__siunitx_complex_sign_tl \l__siunitx_complex_join_tl
- \__siunitx_complex_parse_check:N \l__siunitx_complex_img_tl
- }
- }
- }
-\cs_new_protected:Npn \__siunitx_complex_parse_check:N #1
- {
- \tl_set:Nx #1
- {
- \exp_not:V \l__siunitx_complex_comparator_tl
- \exp_not:V \l__siunitx_complex_sign_tl
- \exp_not:V #1
- \exp_not:V \l__siunitx_complex_exp_tl
- }
- \tl_clear:N \l__siunitx_complex_comparator_tl
- \tl_clear:N \l__siunitx_complex_sign_tl
- \siunitx_number_parse:VN #1 #1
- }
-\cs_new_protected:Npn \__siunitx_complex_parse_comparator:
- {
- \exp_after:wN \__siunitx_complex_parse_comparator_aux:Nw
- \l__siunitx_complex_arg_tl \q_stop
- }
-\cs_new_protected:Npn \__siunitx_complex_parse_comparator_aux:Nw #1#2 \q_stop
- {
- \tl_if_in:NnTF \l_siunitx_number_input_comparator_tl {#1}
- {
- \tl_set:Nn \l__siunitx_complex_comparator_tl {#1}
- \tl_set:Nn \l__siunitx_complex_arg_tl {#2}
- }
- { \tl_clear:N \l__siunitx_complex_comparator_tl }
- \tl_if_empty:NF \l__siunitx_complex_arg_tl
- { \__siunitx_complex_parse_sign: }
- }
-\cs_new_protected:Npn \__siunitx_complex_parse_exponent:
- {
- \tl_if_empty:NTF \l_siunitx_number_input_exponent_tl
- { \__siunitx_complex_parse_root: }
- {
- \tl_set:Nx \l__siunitx_complex_tmp_tl
- { \tl_head:V \l_siunitx_number_input_exponent_tl }
- \tl_map_inline:Nn \l_siunitx_number_input_exponent_tl
- {
- \tl_replace_all:NnV \l__siunitx_complex_arg_tl
- {##1} \l__siunitx_complex_tmp_tl
- }
- \use:x
- {
- \cs_set_protected:Npn
- \exp_not:N \__siunitx_complex_parse_exponent_auxi:w
- ####1 \exp_not:V \l__siunitx_complex_tmp_tl
- ####2 \exp_not:V \l__siunitx_complex_tmp_tl
- ####3 \exp_not:N \q_stop
- }
- { \__siunitx_complex_parse_exponent_auxii:nn {##1} {##2} }
- \use:x
- {
- \__siunitx_complex_parse_exponent_auxi:w
- \exp_not:V \l__siunitx_complex_arg_tl
- \exp_not:V \l__siunitx_complex_tmp_tl \exp_not:N \q_nil
- \exp_not:V \l__siunitx_complex_tmp_tl \exp_not:N \q_stop
- }
- }
- }
-\cs_new_protected:Npn \__siunitx_complex_parse_exponent_auxi:w { }
-\cs_new_protected:Npn \__siunitx_complex_parse_exponent_auxii:nn #1#2
- {
- \quark_if_nil:nF {#2}
- {
- \tl_set:Nn \l__siunitx_complex_arg_tl {#1}
- \tl_set:Nx \l__siunitx_complex_exp_tl
- { \exp_not:V \l__siunitx_complex_tmp_tl \exp_not:n {#2} }
- }
- \__siunitx_complex_parse_root:
- }
-\cs_new_protected:Npn \__siunitx_complex_parse_root:
- {
- \tl_if_empty:NTF \l__siunitx_complex_input_root_tl
- { \tl_set_eq:NN \l__siunitx_complex_real_tl \l__siunitx_complex_arg_tl }
- {
- \tl_set:Nx \l__siunitx_complex_tmp_tl
- { \tl_head:V \l__siunitx_complex_input_root_tl }
- \tl_map_inline:Nn \l__siunitx_complex_input_root_tl
- {
- \tl_replace_all:NnV \l__siunitx_complex_arg_tl
- {##1} \l__siunitx_complex_tmp_tl
- }
- \use:x
- {
- \cs_set_protected:Npn
- \exp_not:N \__siunitx_complex_parse_root_auxi:w
- ####1 \exp_not:V \l__siunitx_complex_tmp_tl
- ####2 \exp_not:V \l__siunitx_complex_tmp_tl
- ####3 \exp_not:N \q_stop
- }
- { \__siunitx_complex_parse_root_auxii:nn {##1} {##2} }
- \use:x
- {
- \__siunitx_complex_parse_root_auxi:w
- \exp_not:V \l__siunitx_complex_arg_tl
- \exp_not:V \l__siunitx_complex_tmp_tl \exp_not:N \q_nil
- \exp_not:V \l__siunitx_complex_tmp_tl \exp_not:N \q_stop
- }
- }
- }
-\cs_new_protected:Npn \__siunitx_complex_parse_root_auxi:w { }
-\cs_new_protected:Npn \__siunitx_complex_parse_root_auxii:nn #1#2
- {
- \quark_if_nil:nTF {#2}
- { \tl_set:Nn \l__siunitx_complex_real_tl {#1} }
- {
- \tl_set:Nn \l__siunitx_complex_img_tl {#2}
- \tl_if_blank:nTF {#1}
- {
- \tl_if_blank:nT {#2}
- { \tl_set:Nn \l__siunitx_complex_img_tl { 1 } }
- }
- {
- \tl_if_blank:nTF {#2}
- { \__siunitx_complex_parse_split:n {#1} }
- { \__siunitx_complex_parse_sign_check:n {#1} }
- }
- }
- }
-\cs_new_protected:Npn \__siunitx_complex_parse_sign:
- {
- \exp_after:wN \__siunitx_complex_parse_sign_aux:Nw
- \l__siunitx_complex_arg_tl \q_stop
- }
-\cs_new_protected:Npn \__siunitx_complex_parse_sign_aux:Nw #1#2 \q_stop
- {
- \tl_if_in:NnT \l_siunitx_number_input_sign_tl {#1}
- {
- \tl_set:Nn \l__siunitx_complex_sign_tl {#1}
- \tl_set:Nn \l__siunitx_complex_arg_tl {#2}
- }
- \tl_if_empty:NF \l__siunitx_complex_arg_tl
- { \__siunitx_complex_parse_exponent: }
- }
-\cs_new_protected:Npn \__siunitx_complex_parse_sign_check:n #1
- {
- \__siunitx_complex_parse_sign_check:nN { } #1 \q_recursion_tail \q_recursion_stop
- }
-\cs_new_protected:Npn \__siunitx_complex_parse_sign_check:nN #1#2
- {
- \quark_if_recursion_tail_stop_do:Nn #2
- { \__siunitx_complex_parse_clear: }
- \tl_if_in:NnTF \l_siunitx_number_input_sign_tl {#2}
- { \__siunitx_complex_parse_sign_check:nNw {#1} #2 }
- { \__siunitx_complex_parse_sign_check:nN {#1#2} }
- }
-\cs_new_protected:Npn \__siunitx_complex_parse_sign_check:nNw
- #1#2 #3 \q_recursion_tail \q_recursion_stop
- {
- \tl_if_blank:nTF {#3}
- {
- \tl_if_blank:nTF {#1}
- { \__siunitx_complex_parse_clear: }
- {
- \tl_set:Nn \l__siunitx_complex_real_tl {#1}
- \tl_set:Nn \l__siunitx_complex_join_tl {#2}
- }
- }
- { \__siunitx_complex_parse_clear: }
- }
-\cs_new_protected:Npn \__siunitx_complex_parse_split:n #1
- {
- \__siunitx_complex_parse_split:nN { } #1 \q_recursion_tail \q_recursion_stop
- }
-\cs_new_protected:Npn \__siunitx_complex_parse_split:nN #1#2
- {
- \quark_if_recursion_tail_stop_do:Nn #2
- { \tl_set:Nn \l__siunitx_complex_img_tl {#1} }
- \tl_if_in:NnTF \l_siunitx_number_input_sign_tl {#2}
- {
- \tl_set:Nn \l__siunitx_complex_real_tl {#1}
- \tl_set:Nn \l__siunitx_complex_join_tl {#2}
- \__siunitx_complex_parse_split:w
- }
- { \__siunitx_complex_parse_split:nN {#1#2} }
- }
-\cs_new_protected:Npn \__siunitx_complex_parse_split:w #1 \q_recursion_tail \q_recursion_stop
- {
- \tl_set:Nx \l__siunitx_complex_img_tl
- {
- \tl_if_blank:nTF {#1}
- { 1 }
- { \exp_not:n {#1} }
- }
- \tl_if_empty:NT \l__siunitx_complex_real_tl
- { \__siunitx_complex_parse_clear: }
- }
-\cs_new_protected:Npn \__siunitx_complex_parse_polar:nn #1#2
- {
- \bool_if:NTF \l_siunitx_number_parse_bool
- { \siunitx_number_parse:nN {#1} \l__siunitx_complex_mag_tl }
- { \tl_set:Nn \l__siunitx_complex_mag_tl { \ensuremath {#1} } }
- \group_begin:
- \keys_set:nn { siunitx }
- {
- input-comparators = ,
- input-exponent-markers = ,
- input-open-uncertainty = ,
- input-close-uncertainty =
- }
- \siunitx_number_format:nN {#2} \l__siunitx_complex_angle_tl
- \exp_args:NNNV \group_end:
- \tl_set:Nn \l__siunitx_complex_angle_tl \l__siunitx_complex_angle_tl
- }
-\tl_new:N \l__siunitx_complex_bracket_close_tl
-\tl_new:N \l__siunitx_complex_bracket_open_tl
-\tl_set:Nn \l__siunitx_complex_bracket_open_tl { ( }
-\tl_set:Nn \l__siunitx_complex_bracket_close_tl { ) }
-\tl_new:N \l__siunitx_complex_unit_tl
-\cs_new_protected:Npn \siunitx_complex_number:n #1
- {
- \bool_lazy_and:nnTF
- { \l__siunitx_complex_force_polar_bool }
- { \l_siunitx_number_parse_bool }
- {
- \use:e
- {
- \siunitx_complex_number:nn
- \__siunitx_complex_convert_polar:n {#1}
- }
- }
- {
- \bool_if:NTF \l_siunitx_number_parse_bool
- {
- \__siunitx_complex_parse:nNN {#1} \l__siunitx_complex_real_tl \l__siunitx_complex_img_tl
- \__siunitx_complex_format_cartesian:n { }
- }
- {
- \siunitx_number_format:nN {#1} \l__siunitx_complex_tmp_tl
- \siunitx_print_number:V \l__siunitx_complex_tmp_tl
- }
- }
- }
-\cs_new_protected:Npn \siunitx_complex_number:nn #1#2
- {
- \bool_lazy_or:nnTF
- { \tl_if_blank_p:n {#1} }
- { \tl_if_blank_p:n {#2} }
- {
- \msg_error:nnnn { siunitx } { invalid-polar-form }
- {#1} {#2}
- }
- { \__siunitx_complex_number:nn {#1} {#2} }
- }
-\cs_new_protected:Npn \__siunitx_complex_number:nn #1#2
- {
- \bool_lazy_and:nnTF
- { \l__siunitx_complex_force_cartesian_bool }
- { \l_siunitx_number_parse_bool }
- {
- \exp_args:Ne \siunitx_complex_number:n
- { \__siunitx_complex_convert_cartesian:nn {#1} {#2} }
- }
- {
- \__siunitx_complex_parse_polar:nn {#1} {#2}
- \__siunitx_complex_format_polar:n { }
- }
- }
-\cs_new_protected:Npn \siunitx_complex_quantity:nn #1#2
- {
- \bool_lazy_and:nnTF
- { \l__siunitx_complex_force_polar_bool }
- { \l_siunitx_number_parse_bool }
- {
- \use:e
- {
- \siunitx_complex_quantity:nnn
- \__siunitx_complex_convert_polar:n {#1}
- }
- {#2}
- }
- {
- \bool_if:NTF \l_siunitx_number_parse_bool
- {
- \__siunitx_complex_parse:nNN {#1} \l__siunitx_complex_real_tl \l__siunitx_complex_img_tl
- \__siunitx_complex_format_cartesian:n {#2}
- }
- { \siunitx_quantity:nn {#1} {#2} }
- }
- }
-\cs_new_protected:Npn \siunitx_complex_quantity:nnn #1#2#3
- {
- \bool_lazy_or:nnTF
- { \tl_if_blank_p:n {#1} }
- { \tl_if_blank_p:n {#2} }
- {
- \msg_error:nnnn { siunitx } { invalid-polar-form }
- {#1} {#2}
- }
- { \__siunitx_complex_quantity:nnn {#1} {#2} {#3} }
- }
-\cs_new_protected:Npn \__siunitx_complex_quantity:nnn #1#2#3
- {
- \bool_lazy_and:nnTF
- { \l__siunitx_complex_force_cartesian_bool }
- { \l_siunitx_number_parse_bool }
- {
- \exp_args:Ne \siunitx_complex_quantity:nn
- { \__siunitx_complex_convert_cartesian:nn {#1} {#2} }
- {#3}
- }
- {
- \__siunitx_complex_parse_polar:nn {#1} {#2}
- \__siunitx_complex_format_polar:n {#3}
- }
- }
-\cs_new_protected:Npn \__siunitx_complex_format_cartesian:n #1
- {
- \bool_lazy_and:nnF
- { \tl_if_empty_p:N \l__siunitx_complex_real_tl }
- { \tl_if_empty_p:N \l__siunitx_complex_img_tl }
- { \__siunitx_complex_format_cartesian_auxi:n {#1} }
- }
-\cs_new_protected:Npn \__siunitx_complex_format_cartesian_auxi:n #1
- {
- \tl_clear:N \l__siunitx_complex_tmp_tl
- \tl_if_empty:NTF \l__siunitx_complex_img_tl
- {
- \siunitx_number_process:NN \l__siunitx_complex_real_tl \l__siunitx_complex_real_tl
- \tl_set:Nx \l__siunitx_complex_tmp_tl
- { \siunitx_number_output:N \l__siunitx_complex_real_tl }
- }
- { \__siunitx_complex_format_cartesian_auxii:n {#1} }
- \tl_if_blank:nTF {#1}
- { \siunitx_print_number:V \l__siunitx_complex_tmp_tl }
- { \siunitx_quantity_print:VV \l__siunitx_complex_tmp_tl \l__siunitx_complex_unit_tl }
- }
-\cs_new_protected:Npn \__siunitx_complex_format_cartesian_auxii:n #1
- {
- \__siunitx_complex_format_cartesian_units:n {#1}
- \tl_if_empty:NF \l__siunitx_complex_real_tl
- { \exp_after:wN \__siunitx_complex_drop_exponent:nnnnnnn \l__siunitx_complex_real_tl }
- \exp_after:wN \__siunitx_complex_format_sign:nnnnnnn \l__siunitx_complex_img_tl
- \tl_set:Nx \l__siunitx_complex_tmp_tl
- { \siunitx_number_output:NN \l__siunitx_complex_img_tl \q_nil }
- \exp_after:wN \__siunitx_complex_extract_exponent:w \l__siunitx_complex_tmp_tl \q_stop
- \tl_set:Nx \l__siunitx_complex_tmp_tl
- {
- \bool_lazy_or:nnTF
- {
- \bool_lazy_and_p:nn
- { \l_siunitx_number_bracket_ambiguous_bool }
- { ! \tl_if_empty_p:N \l__siunitx_complex_exp_tl }
- }
- {
- ! \bool_lazy_any_p:n
- {
- { \tl_if_blank_p:n {#1} }
- { \tl_if_empty_p:N \l__siunitx_complex_real_tl }
- { \tl_if_empty_p:N \l__siunitx_complex_img_tl }
- }
- }
- { \__siunitx_complex_format_bracket:n }
- { \use:n }
- {
- \siunitx_number_output:N \l__siunitx_complex_real_tl
- \exp_not:V \l__siunitx_complex_sign_tl
- \bool_if:NF \l__siunitx_complex_root_after_bool
- { \exp_not:V \l__siunitx_complex_output_root_tl }
- \exp_not:V \l__siunitx_complex_tmp_tl
- \bool_if:NT \l__siunitx_complex_root_after_bool
- { \exp_not:V \l__siunitx_complex_output_root_tl }
- }
- \exp_not:V \l__siunitx_complex_exp_tl
- }
- }
-\cs_new_protected:Npn \__siunitx_complex_drop_exponent:nnnnnnn #1#2#3#4#5#6#7
- { \tl_set:Nn \l__siunitx_complex_real_tl { {#1} {#2} {#3} {#4} {#5} { } { 0 } } }
-\cs_new_protected:Npn \__siunitx_complex_format_sign:nnnnnnn #1#2#3#4#5#6#7
- {
- \tl_set:Nx \l__siunitx_complex_img_tl
- {
- { }
- {
- \tl_if_blank:nTF {#2}
- { \tl_if_empty:NF \l__siunitx_complex_real_tl { + } }
- { \exp_not:n {#2} }
- }
- \exp_not:n { {#3} {#4} {#5} {#6} {#7} }
- }
- }
-\cs_new_protected:Npn \__siunitx_complex_extract_exponent:w
- #1 \q_nil #2 \q_nil #3 \q_nil #4 \q_nil #5 \q_nil #6 \q_nil #7 \q_nil #8
- \q_nil #9 \q_stop
- {
- \tl_set:Nn \l__siunitx_complex_sign_tl {#1#2}
- \bool_lazy_all:nTF
- {
- { ! \l__siunitx_complex_print_unity_bool }
- { \str_if_eq_p:nn {#3} { 1 } }
- { \tl_if_blank_p:n {#5} }
- }
- { \__siunitx_complex_extract_exponent_aux:nw {#6#7#8} }
- { \__siunitx_complex_extract_exponent_aux:nw {#3#4#5#6#7#8} }
- #9 \q_stop
- }
-\cs_new:Npn \__siunitx_complex_extract_exponent_aux:nw
- #1#2 \q_nil #3 \q_nil #4 \q_stop
- {
- \tl_set:Nn \l__siunitx_complex_tmp_tl {#1#2}
- \tl_set:Nn \l__siunitx_complex_exp_tl {#3#4}
- }
-\cs_new_protected:Npn \__siunitx_complex_format_bracket:n #1
- {
- \exp_not:V \l__siunitx_complex_bracket_open_tl
- #1
- \exp_not:V \l__siunitx_complex_bracket_close_tl
- }
-\cs_new_protected:Npn \__siunitx_complex_format_cartesian_units:n #1
- {
- \tl_if_blank:nTF {#1}
- {
- \siunitx_number_process:NN \l__siunitx_complex_real_tl \l__siunitx_complex_real_tl
- \siunitx_number_process:NN \l__siunitx_complex_img_tl \l__siunitx_complex_img_tl
- }
- {
- \use:c
- { __siunitx_complex_format_cartesian_ \l_siunitx_quantity_prefix_mode_tl :n } {#1}
- }
- }
-\cs_new_protected:cpn { __siunitx_complex_format_cartesian_combine-exponent:n } #1
- {
- \tl_if_empty:NF \l__siunitx_complex_real_tl
- { \siunitx_number_process:NN \l__siunitx_complex_real_tl \l__siunitx_complex_real_tl }
- \siunitx_number_process:NN \l__siunitx_complex_img_tl \l__siunitx_complex_img_tl
- \fp_set:Nn \l__siunitx_complex_tmp_fp
- { \exp_after:wN \__siunitx_complex_extract_exp:nnnnnnn \l__siunitx_complex_img_tl }
- \__siunitx_complex_drop_exp:N \l__siunitx_complex_real_tl
- \__siunitx_complex_drop_exp:N \l__siunitx_complex_img_tl
- \siunitx_unit_format_combine_exponent:nnN {#1}
- \l__siunitx_complex_tmp_fp \l__siunitx_complex_unit_tl
- }
-\cs_new_protected:cpx { __siunitx_complex_format_cartesian_extract-exponent:n } #1
- {
- \exp_not:N \siunitx_unit_format_extract_prefixes:nNN {#1}
- \exp_not:N \l__siunitx_complex_unit_tl \exp_not:N \l__siunitx_complex_tmp_fp
- \exp_not:c { __siunitx_complex_format_extract-exponent:N }
- \exp_not:N \l__siunitx_complex_img_tl
- \exp_not:N \tl_if_empty:NF \exp_not:N \l__siunitx_complex_real_tl
- {
- \exp_not:c { __siunitx_complex_format_extract-exponent:N }
- \exp_not:N \l__siunitx_complex_real_tl
- }
- }
-\cs_new_protected:Npn \__siunitx_complex_format_cartesian_input:n #1
- {
- \siunitx_number_process:NN \l__siunitx_complex_real_tl \l__siunitx_complex_real_tl
- \siunitx_number_process:NN \l__siunitx_complex_img_tl \l__siunitx_complex_img_tl
- \siunitx_unit_format:nN {#1} \l__siunitx_complex_unit_tl
- }
-\cs_new_protected:cpn { __siunitx_complex_format_extract-exponent:N } #1
- {
- \tl_set:Nx #1
- { \siunitx_number_adjust_exponent:Nn #1 \l__siunitx_complex_tmp_fp }
- \siunitx_number_process:NN #1 #1
- }
-\cs_new:Npn \__siunitx_complex_extract_exp:nnnnnnn #1#2#3#4#5#6#7 { #6#7 }
-\cs_new_protected:Npn \__siunitx_complex_drop_exp:N #1
- { \exp_after:wN \__siunitx_complex_drop_exp:nnnnnnnN #1 #1 }
-\cs_new_protected:Npn \__siunitx_complex_drop_exp:nnnnnnnN #1#2#3#4#5#6#7#8
- { \tl_set:Nn #8 { {#1} {#2} {#3} {#4} {#5} { } { 0 } } }
-\cs_new_protected:Npn \__siunitx_complex_format_polar:n #1
- {
- \tl_if_blank:nTF {#1}
- {
- \bool_if:NT \l_siunitx_number_parse_bool
- { \siunitx_number_process:NN \l__siunitx_complex_mag_tl \l__siunitx_complex_mag_tl }
- }
- {
- \bool_if:NTF \l_siunitx_number_parse_bool
- {
- \use:c
- { __siunitx_complex_format_polar_ \l_siunitx_quantity_prefix_mode_tl :n } {#1}
- }
- { \__siunitx_complex_format_polar_input:n {#1} }
- }
- \tl_set:Nx \l__siunitx_complex_tmp_tl
- {
- \bool_if:NTF \l_siunitx_number_parse_bool
- { \siunitx_number_output:N \l__siunitx_complex_mag_tl }
- { \exp_not:V \l__siunitx_complex_mag_tl }
- \exp_not:V \l__siunitx_complex_symbol_angle_tl
- \mathord % TEMP
- \exp_not:V \l__siunitx_complex_angle_tl
- }
- \siunitx_print_number:V \l__siunitx_complex_tmp_tl
- \bool_if:NT \l__siunitx_complex_polar_degree_bool
- {
- \exp_args:NV \siunitx_unit_format:nN \l__siunitx_complex_symbol_degree_tl \l__siunitx_complex_tmp_tl
- \nobreak
- \siunitx_print_unit:V \l__siunitx_complex_tmp_tl
- }
- \siunitx_quantity_print:nV { } \l__siunitx_complex_unit_tl
- }
-\cs_new_protected:cpn { __siunitx_complex_format_polar_combine-exponent:n } #1
- {
- \siunitx_number_process:NN \l__siunitx_complex_mag_tl \l__siunitx_complex_mag_tl
- \fp_set:Nn \l__siunitx_complex_tmp_fp
- { \exp_after:wN \__siunitx_complex_extract_exp:nnnnnnn \l__siunitx_complex_mag_tl }
- \__siunitx_complex_drop_exp:N \l__siunitx_complex_mag_tl
- \siunitx_unit_format_combine_exponent:nnN {#1}
- \l__siunitx_complex_tmp_fp \l__siunitx_complex_unit_tl
- }
-\cs_new_protected:cpx { __siunitx_complex_format_polar_extract-exponent:n } #1
- {
- \exp_not:N \siunitx_unit_format_extract_prefixes:nNN {#1}
- \exp_not:N \l__siunitx_complex_unit_tl \exp_not:N \l__siunitx_complex_tmp_fp
- \exp_not:c { __siunitx_complex_format_extract-exponent:N }
- \exp_not:N \l__siunitx_complex_mag_tl
- }
-\cs_new_protected:Npn \__siunitx_complex_format_polar_input:n #1
- {
- \bool_if:NT \l_siunitx_number_parse_bool
- { \siunitx_number_process:NN \l__siunitx_complex_mag_tl \l__siunitx_complex_mag_tl }
- \siunitx_unit_format:nN {#1} \l__siunitx_complex_unit_tl
- }
-\cs_new:Npn \__siunitx_complex_convert_cartesian:nn #1#2
- {
- \exp_args:Nee \__siunitx_complex_convert_cartesian_aux:nn
- {
- \fp_to_tl:n
- { (#1) * cos \bool_if:NT \l__siunitx_complex_polar_degree_bool { d } (#2) }
- }
- {
- \fp_to_tl:n
- { (#1) * sin \bool_if:NT \l__siunitx_complex_polar_degree_bool { d } (#2) }
- }
- }
-\cs_new:Npn \__siunitx_complex_convert_cartesian_aux:nn #1#2
- {
- \__siunitx_complex_convert_cartesian_aux:w #1 e e \q_mark #2 e e \q_stop
- }
-\cs_new:Npn \__siunitx_complex_convert_cartesian_aux:w
- #1 e #2 e #3 \q_mark #4 e #5 e #6 \q_stop
- {
- \fp_compare:nNnF {#1} = \c_zero_fp
- {#1}
- \fp_compare:nNnF {#4} = \c_zero_fp
- {
- \fp_compare:nNnF {#4} < \c_zero_fp { + }
- #4 i
- }
- \tl_if_blank:nF {#2}
- { e #2 }
- }
-\cs_new:Npn \__siunitx_complex_convert_polar:n #1
- { \__siunitx_complex_convert_polar_auxi:w #1 e e \q_stop }
-\cs_new:Npn \__siunitx_complex_convert_polar_auxi:w #1 e #2 e #3 \q_stop
- { \__siunitx_complex_convert_polar_auxii:nw {#2} #1 \q_stop }
-\cs_new:Npn \__siunitx_complex_convert_polar_auxii:nw #1#2#3 \q_stop
- {
- \bool_lazy_or:nnTF
- { \str_if_eq_p:nn {#2} { i } }
- { \str_if_eq_p:nn {#2#3} { +i } }
- { \__siunitx_complex_convert_polar_auxvi:nnn { } { 1 } {#1} }
- {
- \str_if_eq:nnTF {#2#3} { -i }
- { \__siunitx_complex_convert_polar_auxvi:nnn { } { -1 } {#1} }
- { \__siunitx_complex_convert_polar_auxiii:nnw {#1} {#2} #3 + + \q_stop }
- }
- }
-\cs_new:Npn \__siunitx_complex_convert_polar_auxiii:nnw #1#2#3 + #4 + #5 \q_stop
- {
- \tl_if_blank:nTF {#4}
- { \__siunitx_complex_convert_polar_auxiv:nnw {#1} {#2} #3 - - \q_stop }
- {
- \str_if_eq:nnTF {#4} { i }
- { \__siunitx_complex_convert_polar_auxvi:nnn {#2#3} { 1 } {#1} }
- { \__siunitx_complex_convert_polar_auxv:nnw {#2#3} {#1} #4 i \q_nil i \q_stop }
- }
- }
-\cs_new:Npn \__siunitx_complex_convert_polar_auxiv:nnw #1#2#3 - #4 - #5 \q_stop
- {
- \tl_if_blank:nTF {#4}
- { \__siunitx_complex_convert_polar_auxv:nnw { } {#1} #2#3 i \q_nil i \q_stop }
- {
- \str_if_eq:nnTF {#4} { i }
- { \__siunitx_complex_convert_polar_auxvi:nnn { } { -1 } {#1} }
- { \__siunitx_complex_convert_polar_auxv:nnw {#2#3} {#1} -#4 i \q_nil i \q_stop }
- }
- }
-\cs_new:Npn \__siunitx_complex_convert_polar_auxv:nnw #1#2#3 i #4 i #5 \q_stop
- {
- \quark_if_nil:nTF {#4}
- { { #3 \tl_if_blank:nF {#2} { e#2 } } { 0 } }
- { \__siunitx_complex_convert_polar_auxvi:nnn {#1} {#3} {#2} }
- }
-\cs_new:Npn \__siunitx_complex_convert_polar_auxvi:nnn #1#2#3
- {
- \exp_args:Neee \__siunitx_complex_convert_polar_auxvii:nnn
- { \tl_if_blank:nTF {#1} { 0 } {#1} }
- { \tl_if_blank:nTF {#2} { 0 } {#2} }
- { \tl_if_blank:nF {#3} { e#3 } }
- }
-\cs_new:Npn \__siunitx_complex_convert_polar_auxvii:nnn #1#2#3
- {
- \exp_args:Nee \__siunitx_complex_format_polar_auxviii:nn
- { \fp_eval:n { sqrt ( (#1#3)^2 + (#2#3)^2 ) } }
- {
- \fp_eval:n
- { atan \bool_if:NT \l__siunitx_complex_polar_degree_bool { d } (#2 , #1) }
- }
- }
-\cs_new:Npn \__siunitx_complex_format_polar_auxviii:nn #1#2 { {#1} {#2} }
-\msg_new:nnnn { siunitx } { invalid-polar-form }
- { Invalid~polar~form~"#1:#2". }
- {
- Complex~numbers~in~polar~form~must~have~both~a~magnitude~and~and~
- angle.
- }
-\keys_set:nn { siunitx }
- {
- complex-angle-unit = degrees ,
- complex-mode = input ,
- complex-root-position = after-number ,
- complex-symbol-angle = \angle ,
- complex-symbol-degree = \degree ,
- input-complex-root = ij ,
- output-complex-root = \mathrm { i } ,
- print-complex-unity = false
- }
-\cs_generate_variant:Nn \keys_set:nn { nx }
-\fp_new:N \l__siunitx_compound_tmp_fp
-\seq_new:N \l__siunitx_compound_tmp_seq
-\tl_new:N \l__siunitx_compound_tmp_tl
-\tl_new:N \l__siunitx_compound_first_tl
-\tl_new:N \l__siunitx_compound_exp_tl
-\tl_new:N \l__siunitx_compound_start_tl
-\tl_new:N \l__siunitx_compound_end_tl
-\int_new:N \l__siunitx_compound_count_int
-\bool_new:N \l__siunitx_compound_unit_bool
-\tl_new:N \l__siunitx_compound_unit_tl
-\tl_new:N \l__siunitx_compound_bracket_close_tl
-\tl_new:N \l__siunitx_compound_bracket_open_tl
-\tl_set:Nn \l__siunitx_compound_bracket_open_tl { ( }
-\tl_set:Nn \l__siunitx_compound_bracket_close_tl { ) }
-\bool_new:N \l__siunitx_compound_exp_bracket_bool
-\bool_new:N \l__siunitx_compound_exp_combine_bool
-\bool_new:N \l__siunitx_compound_separator_text_bool
-\bool_new:N \l__siunitx_compound_unit_bracket_bool
-\bool_new:N \l__siunitx_compound_unit_power_bool
-\bool_new:N \l__siunitx_compound_unit_repeat_bool
-\keys_define:nn { siunitx }
- {
- compound-exponents .choice: ,
- compound-exponents / combine .code:n =
- {
- \bool_set_false:N \l__siunitx_compound_exp_bracket_bool
- \bool_set_true:N \l__siunitx_compound_exp_combine_bool
- } ,
- compound-exponents / combine-bracket .code:n =
- {
- \bool_set_true:N \l__siunitx_compound_exp_bracket_bool
- \bool_set_true:N \l__siunitx_compound_exp_combine_bool
- } ,
- compound-exponents / individual .code:n =
- {
- \bool_set_false:N \l__siunitx_compound_exp_bracket_bool
- \bool_set_false:N \l__siunitx_compound_exp_combine_bool
- } ,
- compound-final-separator .tl_set:N =
- \l__siunitx_compound_separator_final_tl ,
- compound-pair-separator .tl_set:N =
- \l__siunitx_compound_separator_pair_tl ,
- compound-separator .tl_set:N =
- \l__siunitx_compound_separator_tl ,
- compound-separator-mode .choice: ,
- compound-separator-mode / number .code:n =
- { \bool_set_false:N \l__siunitx_compound_separator_text_bool } ,
- compound-separator-mode / text .code:n =
- { \bool_set_true:N \l__siunitx_compound_separator_text_bool } ,
- compound-units .choice: ,
- compound-units / bracket .code:n =
- {
- \bool_set_true:N \l__siunitx_compound_unit_bracket_bool
- \bool_set_false:N \l__siunitx_compound_unit_power_bool
- \bool_set_false:N \l__siunitx_compound_unit_repeat_bool
- } ,
- compound-units / bracket-power .code:n =
- {
- \bool_set_true:N \l__siunitx_compound_unit_bracket_bool
- \bool_set_true:N \l__siunitx_compound_unit_power_bool
- \bool_set_false:N \l__siunitx_compound_unit_repeat_bool
- } ,
- compound-units / power .code:n =
- {
- \bool_set_false:N \l__siunitx_compound_unit_bracket_bool
- \bool_set_true:N \l__siunitx_compound_unit_power_bool
- \bool_set_false:N \l__siunitx_compound_unit_repeat_bool
- } ,
- compound-units / repeat .code:n =
- {
- \bool_set_false:N \l__siunitx_compound_unit_bracket_bool
- \bool_set_false:N \l__siunitx_compound_unit_power_bool
- \bool_set_true:N \l__siunitx_compound_unit_repeat_bool
- } ,
- compound-units / single .code:n =
- {
- \bool_set_false:N \l__siunitx_compound_unit_bracket_bool
- \bool_set_false:N \l__siunitx_compound_unit_power_bool
- \bool_set_false:N \l__siunitx_compound_unit_repeat_bool
- }
- }
-\cs_new_protected:Npn \siunitx_compound_number:n #1
- {
- \group_begin:
- \bool_set_false:N \l__siunitx_compound_unit_bool
- \__siunitx_compound_format:nn {#1} { }
- \__siunitx_compound_print:N \siunitx_print_number:x
- \group_end:
- }
-\cs_new_protected:Npn \__siunitx_compound_format:nn #1#2
- {
- \seq_clear:N \l__siunitx_compound_tmp_seq
- \bool_if:NTF \l_siunitx_number_parse_bool
- {
- \exp_args:Nxx \__siunitx_compound_format:nnn
- { \tl_head:n {#1} }
- { \tl_tail:n {#1} }
- {#2}
- }
- { \tl_map_function:nN {#1} \__siunitx_compound_unparsed:n }
- }
-\cs_new_protected:Npn \__siunitx_compound_format:nnn #1#2#3
- {
- \tl_if_blank:nTF {#1}
- {
- \tl_if_blank:nF {#2}
- { \__siunitx_compound_format:nn {#2} {#3} }
- }
- { \__siunitx_compound_format_aux:nnn {#1} {#2} {#3} }
- }
-\cs_new_protected:Npn \__siunitx_compound_format_aux:nnn #1#2#3
- {
- \siunitx_number_parse:nN {#1} \l__siunitx_compound_tmp_tl
- \bool_if:NTF \l__siunitx_compound_unit_bool
- { \__siunitx_compound_format_units:nn {#2} {#3} }
- { \siunitx_number_process:NN \l__siunitx_compound_tmp_tl \l__siunitx_compound_first_tl }
- \bool_lazy_and:nnTF
- { \l__siunitx_compound_exp_combine_bool }
- { \int_compare_p:nNn { \tl_count:n {#2} } > 0 }
- { \__siunitx_compound_extract_exponents: }
- {
- \bool_if:NTF \l__siunitx_compound_unit_bool
- {
- \tl_set:Nx \l__siunitx_compound_tmp_tl
- { \siunitx_number_output:NN \l__siunitx_compound_first_tl \q_nil }
- \tl_set:Nx \l__siunitx_compound_tmp_tl
- { \__siunitx_compound_uncert_bracket:N \l__siunitx_compound_tmp_tl }
- }
- {
- \tl_set:Nx \l__siunitx_compound_tmp_tl
- { \siunitx_number_output:N \l__siunitx_compound_first_tl }
- }
- \seq_put_right:NV \l__siunitx_compound_tmp_seq \l__siunitx_compound_tmp_tl
- }
- \tl_map_function:nN {#2} \__siunitx_compound_parsed:n
- }
-\cs_new_protected:Npn \__siunitx_compound_extract_exponents:
- {
- \tl_set:Nx \l__siunitx_compound_tmp_tl
- { \siunitx_number_output:NN \l__siunitx_compound_first_tl \q_nil }
- \exp_after:wN \__siunitx_compound_extract_exponents_auxi:w
- \l__siunitx_compound_tmp_tl \q_stop
- }
-\cs_new_protected:Npn \__siunitx_compound_extract_exponents_auxi:w
- #1 \q_nil #2 \q_nil #3 \q_nil #4 \q_nil #5 \q_nil #6 \q_nil #7 \q_nil #8
- \q_nil #9 \q_stop
- {
- \__siunitx_compound_extract_exponents_auxii:nw {#1#2#3#4#5#6#7#8} #9 \q_stop
- }
-\cs_new_protected:Npn \__siunitx_compound_extract_exponents_auxii:nw
- #1#2 \q_nil #3 \q_nil #4 \q_stop
- {
- \seq_put_right:Nn \l__siunitx_compound_tmp_seq { #1#2 }
- \tl_set:Nn \l__siunitx_compound_exp_tl { #3#4 }
- \exp_after:wN \__siunitx_compound_extract_exponents_auxiii:nnnnnnn
- \l__siunitx_compound_first_tl
- }
-\cs_new_protected:Npn \__siunitx_compound_extract_exponents_auxiii:nnnnnnn
- #1#2#3#4#5#6#7
- {
- \keys_set:nn { siunitx }
- {
- drop-exponent = true ,
- exponent-mode = fixed ,
- fixed-exponent = #6#7
- }
- }
-\cs_new_protected:Npn \__siunitx_compound_parsed:n #1
- {
- \tl_if_blank:nF {#1}
- { \__siunitx_compound_parsed_aux:n {#1} }
- }
-\cs_new_protected:Npn \__siunitx_compound_parsed_aux:n #1
- {
- \bool_if:NTF \l__siunitx_compound_unit_bool
- {
- \siunitx_number_parse:nN {#1} \l__siunitx_compound_tmp_tl
- \siunitx_number_process:NN \l__siunitx_compound_tmp_tl \l__siunitx_compound_tmp_tl
- \tl_set:Nx \l__siunitx_compound_tmp_tl
- { \siunitx_number_output:NN \l__siunitx_compound_tmp_tl \q_nil }
- \tl_set:Nx \l__siunitx_compound_tmp_tl
- { \__siunitx_compound_uncert_bracket:N \l__siunitx_compound_tmp_tl }
- }
- { \siunitx_number_format:nN {#1} \l__siunitx_compound_tmp_tl }
- \seq_put_right:NV \l__siunitx_compound_tmp_seq \l__siunitx_compound_tmp_tl
- }
-\cs_new_protected:Npn \__siunitx_compound_unparsed:n #1
- {
- \tl_if_blank:nF {#1}
- { \seq_put_right:Nn \l__siunitx_compound_tmp_seq { \ensuremath {#1} } }
- }
-\cs_new_protected:Npn \__siunitx_compound_format_units:nn #1#2
- {
- \bool_if:NTF \l__siunitx_compound_unit_power_bool
- {
- \use:c { __siunitx_compound_format_ \l_siunitx_quantity_prefix_mode_tl :nn }
- {#2} { \tl_count:n {#1} + 1 }
- }
- {
- \use:c { __siunitx_compound_format_ \l_siunitx_quantity_prefix_mode_tl :n } {#2}
- }
- }
-\cs_new_protected:cpx { __siunitx_compound_format_combine-exponent:n } #1
- {
- \exp_not:c { __siunitx_compound_format_combine-exponent_aux:n }
- {
- \exp_not:N \siunitx_unit_format_combine_exponent:nnN
- {#1}
- }
- }
-\cs_new_protected:cpx { __siunitx_compound_format_combine-exponent:nn } #1#2
- {
- \exp_not:c { __siunitx_compound_format_combine-exponent_aux:n }
- {
- \exp_not:N \siunitx_unit_format_multiply_combine_exponent:nnnN
- {#1} {#2}
- }
- }
-\cs_new_protected:cpn { __siunitx_compound_format_combine-exponent_aux:n } #1
- {
- \bool_set_true:N \l__siunitx_compound_exp_combine_bool
- \siunitx_number_process:NN \l__siunitx_compound_tmp_tl \l__siunitx_compound_first_tl
- \exp_args:NV \__siunitx_compound_extract_exp:nN
- \l__siunitx_compound_first_tl \l__siunitx_compound_tmp_fp
- #1 \l__siunitx_compound_tmp_fp \l__siunitx_compound_unit_tl
- }
-\cs_new_protected:cpx { __siunitx_compound_format_extract-exponent:n } #1
- {
- \exp_not:c { __siunitx_compound_format_extract-exponent_aux:n }
- { \exp_not:N \siunitx_unit_format_extract_prefixes:nNN {#1} }
- }
-\cs_new_protected:cpx { __siunitx_compound_format_extract-exponent:nn } #1#2
- {
- \exp_not:c { __siunitx_compound_format_extract-exponent_aux:n }
- {
- \exp_not:N \siunitx_unit_format_multiply_extract_prefixes:nnNN
- {#1} {#2}
- }
- }
-\cs_new_protected:cpn { __siunitx_compound_format_extract-exponent_aux:n } #1
- {
- #1 \l__siunitx_compound_unit_tl \l__siunitx_compound_tmp_fp
- \tl_set:Nx \l__siunitx_compound_tmp_tl
- { \siunitx_number_adjust_exponent:Nn \l__siunitx_compound_tmp_tl \l__siunitx_compound_tmp_fp }
- \siunitx_number_process:NN \l__siunitx_compound_tmp_tl \l__siunitx_compound_first_tl
- \bool_set_true:N \l__siunitx_compound_exp_combine_bool
- }
-\cs_new_protected:Npn \__siunitx_compound_format_input:n #1
- {
- \siunitx_number_process:NN \l__siunitx_compound_tmp_tl \l__siunitx_compound_first_tl
- \siunitx_unit_format:nN {#1} \l__siunitx_compound_unit_tl
- }
-\cs_new_protected:Npn \__siunitx_compound_format_input:nn #1#2
- {
- \siunitx_number_process:NN \l__siunitx_compound_tmp_tl \l__siunitx_compound_first_tl
- \siunitx_unit_format_multiply:nnN {#1} {#2} \l__siunitx_compound_unit_tl
- }
-\cs_new_protected:Npn \__siunitx_compound_extract_exp:nN #1#2
- { \__siunitx_compound_extract_exp:nnnnnnnN #1 #2 }
-\cs_new_protected:Npn \__siunitx_compound_extract_exp:nnnnnnnN #1#2#3#4#5#6#7#8
- { \fp_set:Nn #8 {#6#7} }
-\cs_new_protected:Npn \siunitx_compound_quantity:nn #1#2
- {
- \group_begin:
- \bool_if:NT \l__siunitx_compound_unit_bracket_bool
- { \bool_set_true:N \l__siunitx_compound_exp_bracket_bool }
- \bool_if:NT \l__siunitx_compound_unit_repeat_bool
- { \bool_set_false:N \l__siunitx_compound_exp_combine_bool }
- \bool_lazy_or:nnT
- { \l__siunitx_compound_unit_bracket_bool }
- { ! \l__siunitx_compound_unit_repeat_bool }
- { \bool_set_false:N \l_siunitx_number_bracket_ambiguous_bool }
- \bool_set_true:N \l__siunitx_compound_unit_bool
- \__siunitx_compound_format:nn {#1} {#2}
- \bool_if:NF \l_siunitx_number_parse_bool
- { \siunitx_unit_format:nN {#2} \l__siunitx_compound_unit_tl }
- \str_if_eq:VnT \l_siunitx_quantity_prefix_mode_tl { combine-exponent }
- { \tl_clear:N \l__siunitx_compound_exp_tl }
- \bool_if:NTF \l__siunitx_compound_unit_repeat_bool
- { \__siunitx_compound_print:N \__siunitx_compound_print_quantity:x }
- {
- \bool_lazy_and:nnTF
- { \l__siunitx_compound_unit_bracket_bool }
- { \tl_if_empty_p:N \l__siunitx_compound_exp_tl }
- {
- \siunitx_print_number:V \l__siunitx_compound_bracket_open_tl
- \__siunitx_compound_print:N \siunitx_print_number:x
- \siunitx_print_number:V \l__siunitx_compound_bracket_close_tl
- }
- { \__siunitx_compound_print:N \siunitx_print_number:x }
- \__siunitx_compound_print_quantity:n { \c_empty_tl }
- }
- \group_end:
- }
-\cs_new_protected:Npn \__siunitx_compound_print:N #1
- {
- \bool_lazy_and:nnTF
- { \l__siunitx_compound_exp_bracket_bool }
- { ! \tl_if_empty_p:N \l__siunitx_compound_exp_tl }
- {
- \__siunitx_compound_print:xxN
- { \exp_not:V \l__siunitx_compound_bracket_open_tl }
- {
- \exp_not:V \l__siunitx_compound_bracket_close_tl
- \exp_not:V \l__siunitx_compound_exp_tl
- }
- #1
- }
- { \__siunitx_compound_print:xxN { } { \exp_not:V \l__siunitx_compound_exp_tl } #1 }
- }
-\cs_new_protected:Npn \__siunitx_compound_print:nnN #1#2#3
- {
- \exp_args:Nx \__siunitx_compound_print:nnnN
- { \seq_count:N \l__siunitx_compound_tmp_seq } {#1} {#2} #3
- }
-\cs_generate_variant:Nn \__siunitx_compound_print:nnN { xx }
-\cs_new_protected:Npn \__siunitx_compound_print:nnnN #1#2#3#4
- {
- \int_case:nnF {#1}
- {
- { 0 } { }
- { 1 }
- {
- #4
- { \seq_item:Nn \l__siunitx_compound_tmp_seq { 1 } }
- }
- { 2 }
- {
- #4
- {
- \exp_not:n {#2}
- \seq_item:Nn \l__siunitx_compound_tmp_seq { 1 }
- }
- \__siunitx_compound_print_separator:V \l__siunitx_compound_separator_pair_tl
- #4
- {
- \seq_item:Nn \l__siunitx_compound_tmp_seq { 2 }
- \exp_not:n {#3}
- }
- }
- }
- {
- \int_set:Nn \l__siunitx_compound_count_int {#1}
- \tl_set:Nn \l__siunitx_compound_start_tl {#2}
- \tl_set:Nn \l__siunitx_compound_end_tl {#3}
- \cs_set_eq:NN \__siunitx_compound_print_aux:n #4
- \seq_map_indexed_function:NN
- \l__siunitx_compound_tmp_seq
- \__siunitx_compound_print_aux:nn
- }
- }
-\cs_new_protected:Npn \__siunitx_compound_print_aux:n #1 { }
-\cs_new_protected:Npn \__siunitx_compound_print_aux:nn #1#2
- {
- \int_case:nnF {#1}
- {
- { 1 }
- {
- \__siunitx_compound_print_aux:n
- {
- \exp_not:V \l__siunitx_compound_start_tl
- \exp_not:n {#2}
- }
- \__siunitx_compound_print_separator:V \l__siunitx_compound_separator_tl
- }
- { \l__siunitx_compound_count_int - 1 }
- {
- \__siunitx_compound_print_aux:n { \exp_not:n {#2} }
- \__siunitx_compound_print_separator:V \l__siunitx_compound_separator_final_tl
- }
- { \l__siunitx_compound_count_int }
- {
- \__siunitx_compound_print_aux:n
- {
- \exp_not:n {#2}
- \exp_not:V \l__siunitx_compound_end_tl
- }
- }
- }
- {
- \__siunitx_compound_print_aux:n { \exp_not:n {#2} }
- \__siunitx_compound_print_separator:V \l__siunitx_compound_separator_tl
- }
- }
-\cs_new_protected:Npn \__siunitx_compound_print_quantity:n #1
- { \siunitx_quantity_print:nV {#1} \l__siunitx_compound_unit_tl }
-\cs_generate_variant:Nn \__siunitx_compound_print_quantity:n { x }
-\cs_new_protected:Npn \__siunitx_compound_print_separator:n #1
- {
- \bool_if:NTF \l__siunitx_compound_separator_text_bool
- { #1 }
- { \siunitx_print_number:n {#1} }
- }
-\cs_generate_variant:Nn \__siunitx_compound_print_separator:n { V }
-\cs_new:Npn \__siunitx_compound_uncert_bracket:N #1
- { \exp_after:wN \__siunitx_compound_uncert_bracket:w #1 \q_stop }
-\cs_new:Npn \__siunitx_compound_uncert_bracket:w
- #1 \q_nil #2 \q_nil #3 \q_nil #4 \q_nil #5 \q_nil #6 \q_nil #7 \q_nil
- #8 \q_nil #9 \q_stop
- { \__siunitx_compound_uncert_bracket:nnw {#1#2#3#4#5#6} {#7#8} #9 \q_stop }
-\cs_new:Npn \__siunitx_compound_uncert_bracket:nnw #1#2 #3 \q_nil #4 \q_nil #5 \q_stop
- {
- \bool_lazy_or:nnTF
- { \tl_if_blank_p:n {#2#3} }
- { ! \tl_if_blank_p:n {#5} }
- { \exp_not:n {#1#2#3#4#5} }
- {
- \exp_not:V \l__siunitx_compound_bracket_open_tl
- \exp_not:n {#1#2#3}
- \exp_not:V \l__siunitx_compound_bracket_close_tl
- \exp_not:n {#4#5}
- }
- }
-\tl_new:N \l__siunitx_list_exp_tl
-\tl_new:N \l__siunitx_list_units_tl
-\keys_define:nn { siunitx }
- {
- list-exponents .choices:nn =
- { combine , combine-bracket , individual }
- { \tl_set_eq:NN \l__siunitx_list_exp_tl \l_keys_choice_tl } ,
- list-final-separator .tl_set:N = \l_siunitx_list_separator_final_tl ,
- list-pair-separator .tl_set:N = \l_siunitx_list_separator_pair_tl ,
- list-separator .tl_set:N = \l_siunitx_list_separator_tl ,
- list-units .choices:nn =
- { bracket , repeat , single }
- { \tl_set_eq:NN \l__siunitx_list_units_tl \l_keys_choice_tl }
- }
-\cs_new_protected:Npn \siunitx_number_list:nn #1
- {
- \group_begin:
- \__siunitx_list_aux:
- \siunitx_compound_number:n {#1}
- \group_end:
- }
-\cs_new_protected:Npn \siunitx_quantity_list:nn #1#2
- {
- \group_begin:
- \__siunitx_list_aux:
- \siunitx_compound_quantity:nn {#1} {#2}
- \group_end:
- }
-\cs_new_protected:Npn \__siunitx_list_aux:
- {
- \keys_set:nx { siunitx }
- {
- compound-exponents = \l__siunitx_list_exp_tl ,
- compound-final-separator =
- { \exp_not:V \l_siunitx_list_separator_final_tl } ,
- compound-pair-separator =
- { \exp_not:V \l_siunitx_list_separator_pair_tl } ,
- compound-separator =
- { \exp_not:V \l_siunitx_list_separator_tl } ,
- compound-separator-mode = text ,
- compound-units = \l__siunitx_list_units_tl
- }
- }
-\tl_new:N \l__siunitx_product_exp_tl
-\bool_new:N \l__siunitx_product_phrase_bool
-\tl_new:N \l__siunitx_product_units_tl
-\keys_define:nn { siunitx }
- {
- product-exponents .choices:nn =
- { combine , combine-bracket , individual }
- { \tl_set_eq:NN \l__siunitx_product_exp_tl \l_keys_choice_tl } ,
- product-mode .choice: ,
- product-mode / phrase .code:n =
- { \bool_set_true:N \l__siunitx_product_phrase_bool } ,
- product-mode / symbol .code:n =
- { \bool_set_false:N \l__siunitx_product_phrase_bool } ,
- product-phrase .tl_set:N = \l__siunitx_product_phrase_tl ,
- product-symbol .tl_set:N = \l__siunitx_product_symbol_tl ,
- product-units .choices:nn =
- { bracket , bracket-power , power , repeat , single }
- { \tl_set_eq:NN \l__siunitx_product_units_tl \l_keys_choice_tl }
- }
-\cs_new_protected:Npn \siunitx_number_product:n #1
- {
- \group_begin:
- \__siunitx_product_aux:
- \siunitx_compound_number:n {#1}
- \group_end:
- }
-\cs_new_protected:Npn \siunitx_quantity_product:nn #1#2
- {
- \group_begin:
- \__siunitx_product_aux:
- \siunitx_compound_quantity:nn {#1} {#2}
- \group_end:
- }
-\cs_new_protected:Npn \__siunitx_product_aux:
- {
- \bool_if:NTF \l__siunitx_product_phrase_bool
- { \__siunitx_product_aux:x { \exp_not:V \l__siunitx_product_phrase_tl } }
- { \__siunitx_product_aux:x { { } \exp_not:V \l__siunitx_product_symbol_tl { } } }
- }
-\cs_new_protected:Npn \__siunitx_product_aux:n #1
- {
- \keys_set:nx { siunitx }
- {
- compound-exponents = \l__siunitx_product_exp_tl ,
- compound-final-separator = { \exp_not:n {#1} } ,
- compound-pair-separator = { \exp_not:n {#1} } ,
- compound-separator = { \exp_not:n {#1} } ,
- compound-separator-mode =
- \bool_if:NTF \l__siunitx_product_phrase_bool { text } { number } ,
- compound-units = \l__siunitx_product_units_tl
- }
- }
-\cs_generate_variant:Nn \__siunitx_product_aux:n { x }
-\tl_new:N \l__siunitx_range_exp_tl
-\tl_new:N \l__siunitx_range_units_tl
-\keys_define:nn { siunitx }
- {
- range-exponents .choices:nn =
- { combine , combine-bracket , individual }
- { \tl_set_eq:NN \l__siunitx_range_exp_tl \l_keys_choice_tl } ,
- range-phrase .tl_set:N = \l_siunitx_range_phrase_tl ,
- range-units .choices:nn =
- { bracket , repeat , single }
- { \tl_set_eq:NN \l__siunitx_range_units_tl \l_keys_choice_tl }
- }
-\cs_new_protected:Npn \siunitx_number_range:nn #1#2
- {
- \group_begin:
- \__siunitx_range_aux:
- \siunitx_compound_number:n { {#1} {#2} }
- \group_end:
- }
-\cs_new_protected:Npn \siunitx_quantity_range:nnn #1#2#3
- {
- \group_begin:
- \__siunitx_range_aux:
- \siunitx_compound_quantity:nn { {#1} {#2} } {#3}
- \group_end:
- }
-\cs_new_protected:Npn \__siunitx_range_aux:
- {
- \keys_set:nx { siunitx }
- {
- compound-exponents = \l__siunitx_range_exp_tl ,
- compound-pair-separator = { \exp_not:V \l_siunitx_range_phrase_tl } ,
- compound-separator-mode = text ,
- compound-units = \l__siunitx_range_units_tl
- }
- }
-\keys_set:nn { siunitx }
- {
- compound-exponents = individual ,
- compound-final-separator =
- {
- \ifmmode \ \else \space \fi
- \text { and }
- \ifmmode \ \else \space \fi
- } ,
- compound-pair-separator =
- {
- \ifmmode \ \else \space \fi
- \text { and }
- \ifmmode \ \else \space \fi
- } ,
- compound-separator =
- { , \ifmmode \ \else \space \fi } ,
- compound-separator-mode = text ,
- compound-units = repeat ,
- list-exponents = individual ,
- list-final-separator =
- {
- \ifmmode \ \else \space \fi
- \text { and }
- \ifmmode \ \else \space \fi
- } ,
- list-pair-separator =
- {
- \ifmmode \ \else \space \fi
- \text { and }
- \ifmmode \ \else \space \fi
- } ,
- list-separator =
- { , \ifmmode \ \else \space \fi } ,
- list-units = repeat ,
- product-exponents = individual ,
- product-mode = symbol ,
- product-phrase =
- {
- \ifmmode \ \else \space \fi
- \text { by }
- \ifmmode \ \else \space \fi
- } ,
- product-symbol = \times ,
- product-units = repeat ,
- range-exponents = individual ,
- range-phrase =
- {
- \ifmmode \ \else \space \fi
- \text { to }
- \ifmmode \ \else \space \fi
- } ,
- range-units = repeat
- }
-\keys_define:nn { siunitx }
- {
- locale .choice: ,
- locale / DE .meta:n =
- {
- exponent-product = \cdot ,
- inter-unit-product = \, ,
- output-decimal-marker = { , }
- } ,
- locale / FR .meta:n =
- {
- exponent-product = \times ,
- inter-unit-product = \, ,
- output-decimal-marker = { , }
- } ,
- locale / PL .meta:n =
- {
- exponent-product = \cdot ,
- inter-unit-product = \cdot ,
- output-decimal-marker = { , }
- } ,
- locale / SI .meta:n =
- {
- exponent-product = \times ,
- inter-unit-product = \, ,
- output-decimal-marker = { , }
- } ,
- locale / UK .meta:n =
- {
- exponent-product = \times ,
- inter-unit-product = \, ,
- output-decimal-marker = .
- },
- locale / US .meta:n =
- {
- exponent-product = \times ,
- inter-unit-product = \, ,
- output-decimal-marker = .
- } ,
- locale / ZA .meta:n =
- {
- exponent-product = \times ,
- inter-unit-product = \cdot ,
- output-decimal-marker = { , }
- }
- }
-\file_if_exist:nT { translations.sty }
- {
- \RequirePackage { translations }
- \DeclareTranslation { Catalan } { and } { i }
- \DeclareTranslation { Portuguese } { and } { e }
- \DeclareTranslation { Slovene } { and } { in }
- \DeclareTranslation { Brazilian } { to~(numerical~range) } { a }
- \DeclareTranslation { Catalan } { to~(numerical~range) } { a }
- \DeclareTranslation { English } { to~(numerical~range) } { to }
- \DeclareTranslation { French } { to~(numerical~range) } { à }
- \DeclareTranslation { German } { to~(numerical~range) } { bis }
- \DeclareTranslation { Polish } { to~(numerical~range) } { do }
- \DeclareTranslation { Portuguese } { to~(numerical~range) } { a }
- \DeclareTranslation { Slovene } { to~(numerical~range) } { do }
- \DeclareTranslation { Spanish } { to~(numerical~range) } { a }
- \keys_set:nn { siunitx }
- {
- list-final-separator =
- {
- \ifmmode \ \else \space \fi
- \text { \GetTranslation { and } }
- \ifmmode \ \else \space \fi
- } ,
- list-pair-separator =
- {
- \ifmmode \ \else \space \fi
- \text { \GetTranslation { and } }
- \ifmmode \ \else \space \fi
- } ,
- range-phrase =
- {
- \ifmmode \ \else \space \fi
- \text { \GetTranslation { to~(numerical~range) } }
- \ifmmode \ \else \space \fi
- }
- }
- }
\cs_generate_variant:Nn \tl_if_blank:nTF { f }
\cs_generate_variant:Nn \tl_if_blank_p:n { f }
\cs_generate_variant:Nn \tl_if_in:NnTF { NV }
@@ -1849,6 +122,8 @@
{ \tl_put_right:Nn \l_siunitx_number_input_sign_tl {##1} }
}
} ,
+ input-uncertainty-divider .tl_set:N =
+ \l__siunitx_number_input_uncert_divide_tl ,
parse-numbers .bool_set:N =
\l_siunitx_number_parse_bool ,
retain-explicit-decimal-marker .bool_set:N =
@@ -1869,7 +144,10 @@
\tl_new:N \l__siunitx_number_parsed_tl
\tl_new:N \l__siunitx_number_input_tl
\tl_new:N \l__siunitx_number_partial_tl
+\tl_new:N \l__siunitx_number_tolerance_tl
\tl_new:N \l__siunitx_number_uncert_tl
+\int_new:N \l__siunitx_number_uncert_offset_int
+\tl_new:N \l__siunitx_number_uncert_types_tl
\bool_new:N \l__siunitx_number_validate_bool
\cs_new_protected:Npn \siunitx_number_normalize_symbols:N #1
{
@@ -1914,6 +192,7 @@
\group_begin:
\tl_clear:N \l__siunitx_number_parsed_tl
\tl_clear:N \l__siunitx_number_uncert_tl
+ \tl_clear:N \l__siunitx_number_uncert_types_tl
\tl_map_inline:Nn \l__siunitx_number_input_ignore_tl
{
\token_if_macro:NT ##1
@@ -2286,7 +565,6 @@
\cs_new_protected:Npn \__siunitx_number_parse_loop_main_uncert:NN #1#2
{
\__siunitx_number_parse_loop_main_store:NNN #1 #2 \c_false_bool
- \tl_clear:N \l__siunitx_number_uncert_tl
\__siunitx_number_parse_uncert:N
}
\cs_new_protected:Npn \__siunitx_number_parse_loop_main_sign:NNN #1#2#3
@@ -2335,6 +613,7 @@
{
\tl_clear:N \l__siunitx_number_flex_tl
\tl_clear:N \l__siunitx_number_parsed_tl
+ \tl_clear:N \l__siunitx_number_uncert_tl
}
\cs_new_protected:Npn \__siunitx_number_parse_sign:
{
@@ -2394,7 +673,7 @@
{
\tl_if_in:NnTF \l_siunitx_number_input_decimal_tl {#1}
{ \__siunitx_number_parse_uncert_marker: }
- { \__siunitx_number_parse_loop_break:w }
+ { \__siunitx_number_parse_uncert_auxiv:N #1 }
}
}
\cs_new_protected:Npn \__siunitx_number_parse_uncert_auxii:N #1
@@ -2404,7 +683,7 @@
\__siunitx_number_parse_uncert_auxiii:
\__siunitx_number_parse_uncert_after:N
}
- { \__siunitx_number_parse_loop_break:w }
+ { \__siunitx_number_parse_uncert_auxiv:N #1 }
}
\cs_new_protected:Npn \__siunitx_number_parse_uncert_auxiii:
{
@@ -2413,6 +692,20 @@
{ \tl_if_empty_p:N \l__siunitx_number_partial_tl }
{ \tl_set:Nn \l__siunitx_number_partial_tl { 0 } }
}
+\cs_new_protected:Npn \__siunitx_number_parse_uncert_auxiv:N #1
+ {
+ \tl_if_empty:NTF \l__siunitx_number_tolerance_tl
+ {
+ \tl_if_in:NnTF \l__siunitx_number_input_uncert_divide_tl {#1}
+ {
+ \cs_set_eq:NN \l__siunitx_number_tolerance_tl \l__siunitx_number_partial_tl
+ \tl_clear:N \l__siunitx_number_partial_tl
+ \__siunitx_number_parse_uncert:N
+ }
+ { \__siunitx_number_parse_loop_break:w }
+ }
+ { \__siunitx_number_parse_loop_break:w }
+ }
\cs_new_protected:Npn \__siunitx_number_parse_uncert_marker:
{
\exp_after:wN \__siunitx_number_parse_uncert_marker:nnn
@@ -2447,18 +740,57 @@
\cs_new_protected:Npn \__siunitx_number_parse_uncert_marker:w { }
\cs_new_protected:Npn \__siunitx_number_parse_uncert_marker:nnnnN #1#2#3#4#5
{
+ \tl_set:Nx \l__siunitx_number_tmp_tl { \tl_head:V \l__siunitx_number_input_uncert_divide_tl }
+ \tl_if_empty:NTF \l__siunitx_number_tmp_tl
+ { \__siunitx_number_parse_uncert_marker:nnnnnN {#1} {#2} {#3} {#4} { } #5 }
+ {
+ \use:x
+ {
+ \cs_set_protected:Npn \exp_not:N \__siunitx_number_parse_uncert_marker:w
+ ####1 \l__siunitx_number_tmp_tl ####2 \l__siunitx_number_tmp_tl ####3 \exp_not:N \q_stop
+ {
+ \exp_not:N \tl_if_blank:nTF {####2}
+ {
+ \__siunitx_number_parse_uncert_marker:nnnnnN
+ \exp_not:n { {#1} {#2} {#3} }
+ {####1} { }
+ }
+ {
+ \__siunitx_number_parse_uncert_marker:nnnnnN
+ \exp_not:n { {#1} {#2} {#3} }
+ {####1} { \l__siunitx_number_tmp_tl ####2 }
+ }
+ \exp_not:N #5
+ }
+ \exp_not:N \__siunitx_number_parse_uncert_marker:w #4
+ \l__siunitx_number_tmp_tl \l__siunitx_number_tmp_tl \exp_not:N \q_stop
+ }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_number_parse_uncert_marker:nnnnnN #1#2#3#4#5#6
+ {
+ \exp_args:Ne \__siunitx_number_parse_uncert_marker:nnnnnnN
+ { \int_eval:n { \tl_count:n {#4} } }
+ {#1} {#2} {#3} {#4} {#5} #6
+ }
+\cs_new_protected:Npn \__siunitx_number_parse_uncert_marker:nnnnnnN #1#2#3#4#5#6#7
+ {
+ \bool_lazy_and:nnF
+ { \tl_if_empty_p:N \l__siunitx_number_tolerance_tl }
+ { \tl_if_empty_p:N \l__siunitx_number_uncert_types_tl }
+ {
+ \int_compare:nNnF {#1} = \l__siunitx_number_uncert_offset_int
+ { \__siunitx_number_parse_loop_break:w }
+ }
+ \int_set:Nn \l__siunitx_number_uncert_offset_int {#1}
\tl_set:Nx \l__siunitx_number_parsed_tl
{
- {#1}
{#2}
+ {#3}
{
- #3
+ #4
\prg_replicate:nn
- {
- \int_max:nn
- { 0 }
- { \tl_count:n {#4} - \tl_count:n {#3} }
- }
+ { \int_max:nn { 0 } { #1 - \tl_count:n {#4} } }
{ 0 }
}
}
@@ -2471,7 +803,7 @@
\__siunitx_number_parse_uncert:NNN \c_true_bool
\__siunitx_number_parse_uncert_auxii:N
}
- #4#5
+ #5#6#7
}
\cs_new_protected:Npn \__siunitx_number_parse_uncert_after:N #1
{
@@ -2479,9 +811,26 @@
{
\exp_not:V \l__siunitx_number_uncert_tl
\tl_if_empty:NF \l__siunitx_number_partial_tl
- { { \exp_not:V \l__siunitx_number_partial_tl } }
+ {
+ {
+ \tl_if_empty:NTF \l__siunitx_number_tolerance_tl
+ { \exp_not:V \l__siunitx_number_partial_tl }
+ {
+ { \exp_not:V \l__siunitx_number_tolerance_tl }
+ { \exp_not:V \l__siunitx_number_partial_tl }
+ }
+ }
+ }
+ }
+ \tl_set:Nx \l__siunitx_number_uncert_types_tl
+ {
+ \l__siunitx_number_uncert_types_tl
+ \tl_if_empty:NTF \l__siunitx_number_tolerance_tl
+ { S }
+ { A }
}
\tl_clear:N \l__siunitx_number_partial_tl
+ \tl_clear:N \l__siunitx_number_tolerance_tl
\quark_if_recursion_tail_stop_do:Nn #1
{
\tl_set:Nx \l__siunitx_number_parsed_tl
@@ -2490,17 +839,14 @@
{
\tl_if_empty:NF \l__siunitx_number_uncert_tl
{
- {
- \prg_replicate:nn
- { \tl_count:N \l__siunitx_number_uncert_tl }
- { S }
- }
+ { \l__siunitx_number_uncert_types_tl }
\exp_not:V \l__siunitx_number_uncert_tl
}
}
}
\tl_clear:N \l__siunitx_number_partial_tl
\tl_clear:N \l__siunitx_number_uncert_tl
+ \int_zero:N \l__siunitx_number_uncert_offset_int
}
\tl_if_in:NnTF \l__siunitx_number_input_uncert_open_tl {#1}
{ \__siunitx_number_parse_uncert:N }
@@ -2525,6 +871,9 @@
\l__siunitx_number_min_decimal_int ,
minimum-integer-digits .int_set:N =
\l__siunitx_number_min_integer_int ,
+ round-direction .choices:nn =
+ { down , nearest , up }
+ { \tl_set_eq:NN \l__siunitx_number_round_dir_tl \l_keys_choice_tl } ,
round-half .choice: ,
round-half / even .code:n =
{ \bool_set_true:N \l__siunitx_number_round_half_even_bool } ,
@@ -2540,11 +889,16 @@
round-precision .int_set:N =
\l__siunitx_number_round_precision_int ,
round-zero-positive .bool_set:N =
- \l__siunitx_number_round_positive_bool
+ \l__siunitx_number_round_positive_bool ,
+ uncertainty-round-direction .choices:nn =
+ { down , nearest , up }
+ { \tl_set_eq:NN \l__siunitx_number_round_uncert_dir_tl \l_keys_choice_tl } ,
}
\bool_new:N \l__siunitx_number_round_half_even_bool
\tl_new:N \l__siunitx_number_exponent_mode_tl
+\tl_new:N \l__siunitx_number_round_dir_tl
\tl_new:N \l__siunitx_number_round_mode_tl
+\tl_new:N \l__siunitx_number_round_uncert_dir_tl
\tl_new:N \l__siunitx_number_round_min_tl
\cs_new_protected:Npn \__siunitx_number_set_round_min:n #1
{
@@ -2988,98 +1342,111 @@
}
\cs_new:Npn \__siunitx_number_round:nnn #1#2#3
{
- \__siunitx_number_round_auxi:nnnN {#1} {#2} { }
- #3 \q_recursion_tail \q_recursion_stop
+ \__siunitx_number_round:Vnnn \l__siunitx_number_round_dir_tl
+ {#1} {#2} {#3}
}
\cs_generate_variant:Nn \__siunitx_number_round:nnn { f }
-\cs_new:Npn \__siunitx_number_round_auxi:nnnN #1#2#3#4
+\cs_new:Npn \__siunitx_number_round:nnnn #1#2#3#4
{
- \quark_if_recursion_tail_stop_do:Nn #4
+ \__siunitx_number_round_auxi:nnnnN {#1} {#2} {#3} { }
+ #4 \q_recursion_tail \q_recursion_stop
+ }
+\cs_generate_variant:Nn \__siunitx_number_round:nnnn { V }
+\cs_new:Npn \__siunitx_number_round_auxi:nnnnN #1#2#3#4#5
+ {
+ \quark_if_recursion_tail_stop_do:Nn #5
{
- \__siunitx_number_round_auxii:nnnN {#1} {#3} { } #2
+ \__siunitx_number_round_auxii:nnnnN {#1} {#2} {#4} { } #3
\q_recursion_tail \q_recursion_stop
}
- \__siunitx_number_round_auxi:nnnN {#1} {#2} {#4#3}
+ \__siunitx_number_round_auxi:nnnnN {#1} {#2} {#3} {#5#4}
}
-\cs_new:Npn \__siunitx_number_round_auxii:nnnN #1#2#3#4
+\cs_new:Npn \__siunitx_number_round_auxii:nnnnN #1#2#3#4#5
{
- \quark_if_recursion_tail_stop_do:Nn #4
+ \quark_if_recursion_tail_stop_do:Nn #5
{
- \tl_if_blank:nTF {#2}
+ \tl_if_blank:nTF {#3}
{
- \__siunitx_number_round_auxiv:nnnN {#1} { } { } #3
+ \__siunitx_number_round_auxiv:nnnnN {#2} {#1} { } { } #4
\q_recursion_tail \q_recursion_stop
}
{
- \__siunitx_number_round_auxiii:nnnN {#1} {#3} { } #2
+ \__siunitx_number_round_auxiii:nnnnN {#2} {#1} {#4} { } #3
\q_recursion_tail \q_recursion_stop
}
}
- \__siunitx_number_round_auxii:nnnN {#1} {#2} {#4#3}
+ \__siunitx_number_round_auxii:nnnnN {#1} {#2} {#3} {#5#4}
}
-\cs_new:Npn \__siunitx_number_round_auxiii:nnnN #1#2#3#4
+\cs_new:Npn \__siunitx_number_round_auxiii:nnnnN #1#2#3#4#5
{
- \quark_if_recursion_tail_stop_do:Nn #4
+ \quark_if_recursion_tail_stop_do:Nn #5
{
- \__siunitx_number_round_auxiv:nnnN {#1} { } {#3} #2
+ \__siunitx_number_round_auxiv:nnnnN {#1} {#2} { } {#4} #3
\q_recursion_tail \q_recursion_stop
}
\int_compare:nNnTF {#1} > 0
{
- \exp_args:Nf \__siunitx_number_round_auxiii:nnnN
- { \int_eval:n { #1 - 1 } } {#2} { #4#3 }
+ \exp_args:Nf \__siunitx_number_round_auxiii:nnnnN
+ { \int_eval:n { #1 - 1 } } {#2} {#3} { #5#4 }
}
- { \__siunitx_number_round_auxv:nnN {#3} {#2} #4 }
+ { \__siunitx_number_round_auxv:nnnN {#2} {#4} {#3} #5 }
}
-\cs_new:Npn \__siunitx_number_round_auxiv:nnnN #1#2#3#4
+\cs_new:Npn \__siunitx_number_round_auxiv:nnnnN #1#2#3#4#5
{
- \quark_if_recursion_tail_stop_do:Nn #4
+ \quark_if_recursion_tail_stop_do:Nn #5
{
\int_compare:nNnTF {#1} = 0
{
- \__siunitx_number_round_auxvi:nnN {#3} {#2}
+ \__siunitx_number_round_auxvi:nnnN {#2} {#4} {#3}
0 \q_recursion_tail \q_recursion_stop
}
{ { 0 } { } }
}
\int_compare:nNnTF {#1} > 0
{
- \exp_args:Nf \__siunitx_number_round_auxiv:nnnN
- { \int_eval:n { #1 - 1 } } { #2 0 } { #4#3 }
+ \exp_args:Nf \__siunitx_number_round_auxiv:nnnnN
+ { \int_eval:n { #1 - 1 } } {#2} { #3 0 } { #5#4 }
}
- { \__siunitx_number_round_auxvi:nnN {#3} {#2} #4 }
+ { \__siunitx_number_round_auxvi:nnnN {#2} {#4} {#3} #5 }
}
-\cs_new:Npn \__siunitx_number_round_auxv:nnN #1#2#3
+\cs_new:Npn \__siunitx_number_round_auxv:nnnN #1#2#3#4
{
- \quark_if_recursion_tail_stop_do:Nn #3
+ \quark_if_recursion_tail_stop_do:Nn #4
{
- \__siunitx_number_round_auxvi:nnN
- {#1} { } #2 \q_recursion_tail \q_recursion_stop
+ \__siunitx_number_round_auxvi:nnnN
+ {#1} {#2} { } #3 \q_recursion_tail \q_recursion_stop
}
- \__siunitx_number_round_auxvii:nnTF {#1} {#3}
+ \__siunitx_number_round_auxvii:nnnTF {#1} {#2} {#4}
{ \__siunitx_number_round_final_decimal:nnw }
{ \__siunitx_number_round_auxviii:nnN }
- {#2} { } #3
+ {#3} { } #4
}
-\cs_new:Npn \__siunitx_number_round_auxvi:nnN #1#2#3
+\cs_new:Npn \__siunitx_number_round_auxvi:nnnN #1#2#3#4
{
- \quark_if_recursion_tail_stop_do:Nn #3
+ \quark_if_recursion_tail_stop_do:Nn #4
{ { 0 } { } }
- \__siunitx_number_round_auxvii:nnTF {#1} {#3}
+ \__siunitx_number_round_auxvii:nnnTF {#1} {#2} {#4}
{ \__siunitx_number_round_final_integer:nnw }
{ \__siunitx_number_round_auxix:nnN }
- { } {#2} #3
+ { } {#3} #4
}
-\cs_new:Npn \__siunitx_number_round_auxvii:nnTF #1#2
+\cs_new:Npn \__siunitx_number_round_auxvii:nnnTF #1#2#3
{
- \bool_lazy_or:nnTF
- { \int_compare_p:nNn { 0 \tl_head:n {#1} } < 5 }
+ \str_case:nnF {#1}
{
- \bool_lazy_all_p:n
+ { down } { \use_i:nn }
+ { up } { \use_ii:nn }
+ }
+ {
+ \bool_lazy_or:nnTF
+ { \int_compare_p:nNn { 0 \tl_head:n {#2} } < 5 }
{
- { \l__siunitx_number_round_half_even_bool }
- { ! \int_if_odd_p:n {#2} }
- { \__siunitx_number_round_if_half_p:n {#1} }
+ \bool_lazy_all_p:n
+ {
+ { \l__siunitx_number_round_half_even_bool }
+ { ! \int_if_odd_p:n {#3} }
+ { \__siunitx_number_round_if_half_p:n {#2} }
+ }
}
}
}
@@ -3449,8 +1816,9 @@
\use:e
{
\exp_not:N \__siunitx_number_round_uncertainty:nnnnnn
- \__siunitx_number_round:nnn {#1} { } {#4}
- {#2} {#3} {#1} {#4}
+ \__siunitx_number_round:Vnnn
+ \l__siunitx_number_round_uncert_dir_tl {#1} { } {#4}
+ {#2} {#3} {#1} {#4}
}
}
\cs_new:Npn \__siunitx_number_round_uncertainty:nnnnnn #1#2#3#4#5#6
@@ -4150,6 +2518,7 @@
\__siunitx_number_output_uncert_A:nnnn
\cs_new:Npx \__siunitx_number_output_uncert_A:nnnnn #1#2#3#4#5
{
+ { }
^
{
+
@@ -4421,6 +2790,7 @@
retain-explicit-plus = false ,
retain-negative-zero = false ,
retain-zero-uncertainty = false ,
+ round-direction = nearest ,
round-half = up ,
round-minimum = 0 ,
round-mode = none ,
@@ -4432,12 +2802,1880 @@
uncertainty-descriptor-separator = \ ,
uncertainty-descriptors = ,
uncertainty-mode = compact ,
+ uncertainty-round-direction = nearest ,
uncertainty-separator = ,
zero-decimal-as-symbol = false ,
zero-symbol = \mbox { --- }
}
\keys_set:nx { siunitx }
- { exponent-thresholds = -3 \c_colon_str 3 }
+ {
+ exponent-thresholds = -3 \c_colon_str 3 ,
+ input-uncertainty-divider = \c_colon_str
+ }
+\bool_new:N \l__siunitx_angle_tmp_bool
+\dim_new:N \l__siunitx_angle_tmp_dim
+\tl_new:N \l__siunitx_angle_tmp_tl
+\keys_define:nn { siunitx }
+ {
+ angle-mode .choice: ,
+ angle-mode / arc .code:n =
+ {
+ \bool_set_true:N \l__siunitx_angle_force_arc_bool
+ \bool_set_false:N \l__siunitx_angle_force_decimal_bool
+ } ,
+ angle-mode / decimal .code:n =
+ {
+ \bool_set_false:N \l__siunitx_angle_force_arc_bool
+ \bool_set_true:N \l__siunitx_angle_force_decimal_bool
+ } ,
+ angle-mode / input .code:n =
+ {
+ \bool_set_false:N \l__siunitx_angle_force_arc_bool
+ \bool_set_false:N \l__siunitx_angle_force_decimal_bool
+ } ,
+ angle-symbol-degree .tl_set:N =
+ \l__siunitx_angle_symbol_degree_tl ,
+ angle-symbol-minute .tl_set:N =
+ \l__siunitx_angle_symbol_minute_tl ,
+ angle-symbol-second .tl_set:N =
+ \l__siunitx_angle_symbol_second_tl ,
+ angle-symbol-over-decimal .bool_set:N =
+ \l__siunitx_angle_astronomy_bool ,
+ angle-separator .tl_set:N =
+ \l__siunitx_angle_separator_tl ,
+ fill-angle-degrees .bool_set:N =
+ \l__siunitx_angle_fill_degrees_bool ,
+ fill-angle-minutes .bool_set:N =
+ \l__siunitx_angle_fill_minutes_bool ,
+ fill-angle-seconds .bool_set:N =
+ \l__siunitx_angle_fill_seconds_bool ,
+ number-angle-product .tl_set:N =
+ \l__siunitx_angle_product_tl
+ }
+\bool_new:N \l__siunitx_angle_force_arc_bool
+\bool_new:N \l__siunitx_angle_force_decimal_bool
+\cs_new_protected:Npn \siunitx_angle:n #1
+ {
+ \bool_if:NTF \l_siunitx_number_parse_bool
+ { \__siunitx_angle_angle:n {#1} }
+ {
+ \tl_if_blank:nF {#1}
+ {
+ \tl_set:Nn \l__siunitx_angle_degrees_tl { \ensuremath {#1} }
+ \__siunitx_angle_arc_print:VVV
+ \l__siunitx_angle_degrees_tl
+ \c_empty_tl
+ \c_empty_tl
+ }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_angle_angle:n #1
+ {
+ \bool_if:NTF \l__siunitx_angle_force_arc_bool
+ { \exp_args:Ne \__siunitx_angle_arc_convert:n { \fp_eval:n {#1} } }
+ {
+ \siunitx_number_parse:nN {#1} \l__siunitx_angle_degrees_tl
+ \siunitx_number_process:NN \l__siunitx_angle_degrees_tl \l__siunitx_angle_degrees_tl
+ \tl_set:Nx \l__siunitx_angle_degrees_tl
+ { \siunitx_number_output:NN \l__siunitx_angle_degrees_tl \q_nil }
+ \__siunitx_angle_arc_print:VVV
+ \l__siunitx_angle_degrees_tl
+ \c_empty_tl
+ \c_empty_tl
+ }
+ }
+\cs_new_protected:Npn \siunitx_angle:nnn #1#2#3
+ {
+ \bool_if:NTF \l_siunitx_number_parse_bool
+ {
+ \bool_if:NTF \l__siunitx_angle_force_decimal_bool
+ {
+ \exp_args:Ne \siunitx_angle:n
+ { \fp_eval:n { #1 + (#2) / 60 + (#3) / 3600 } }
+ }
+ { \__siunitx_angle_arc_sign:nnn {#1} {#2} {#3} }
+ }
+ {
+ \tl_set:Nx \l__siunitx_angle_degrees_tl
+ { \tl_if_blank:nF {#1} { \exp_not:n { \ensuremath {#1} } } }
+ \tl_set:Nx \l__siunitx_angle_minutes_tl
+ { \tl_if_blank:nF {#2} { \exp_not:n { \ensuremath {#2} } } }
+ \tl_set:Nx \l__siunitx_angle_seconds_tl
+ { \tl_if_blank:nF {#3} { \exp_not:n { \ensuremath {#3} } } }
+ \__siunitx_angle_arc_print:VVV
+ \l__siunitx_angle_degrees_tl
+ \l__siunitx_angle_minutes_tl
+ \l__siunitx_angle_seconds_tl
+ }
+ }
+\cs_new_protected:Npn \__siunitx_angle_arc_convert:n #1
+ {
+ \use:x
+ {
+ \siunitx_angle:nnn
+ { \fp_eval:n { trunc(#1,0) } }
+ { \fp_eval:n { trunc((#1 - trunc(#1,0)) * 60,0) } }
+ {
+ \fp_eval:n
+ {
+ (
+ (#1 - trunc(#1,0)) * 60
+ - trunc((#1 - trunc(#1,0)) * 60,0)
+ )
+ * 60
+ }
+ }
+ }
+ }
+\tl_new:N \l__siunitx_angle_degrees_tl
+\tl_new:N \l__siunitx_angle_minutes_tl
+\tl_new:N \l__siunitx_angle_seconds_tl
+\tl_new:N \l__siunitx_angle_sign_tl
+\keys_precompile:nnN
+ { siunitx }
+ {
+ input-close-uncertainty = ,
+ input-exponent-markers = ,
+ input-open-uncertainty = ,
+ input-uncertainty-signs =
+ }
+ \l__siunitx_angle_tmp_tl
+\cs_set_protected:Npx \__siunitx_angle_suppress_exp_uncert:
+ { \exp_not:V \l__siunitx_angle_tmp_tl }
+\keys_precompile:nnN
+ { siunitx }
+ { input-comparators = , input-signs = }
+ \l__siunitx_angle_tmp_tl
+\cs_set_protected:Npx \__siunitx_angle_suppress_comp_sign:
+ { \exp_not:V \l__siunitx_angle_tmp_tl }
+\cs_new_protected:Npn \__siunitx_angle_arc_sign:nnn #1#2#3
+ {
+ \group_begin:
+ \__siunitx_angle_suppress_exp_uncert:
+ \tl_clear:N \l__siunitx_angle_sign_tl
+ \__siunitx_angle_arc_sign:nn {#1} { degrees }
+ \__siunitx_angle_arc_sign:nn {#2} { minutes }
+ \__siunitx_angle_arc_sign:nn {#3} { seconds }
+ \tl_if_empty:NF \l__siunitx_angle_sign_tl
+ {
+ \clist_map_inline:nn { degrees , minutes , seconds }
+ {
+ \tl_if_empty:cF { l__siunitx_angle_ ##1 _tl }
+ {
+ \tl_set:cx { l__siunitx_angle_ ##1 _tl }
+ {
+ { }
+ { \exp_not:V \l__siunitx_angle_sign_tl }
+ \exp_after:wN \exp_after:wN \exp_after:wN
+ \__siunitx_angle_sign:nnnnnnn
+ \cs:w l__siunitx_angle_ ##1 _tl \cs_end:
+ }
+ \clist_map_break:
+ }
+ }
+ }
+ \clist_map_inline:nn { degrees , minutes , seconds }
+ {
+ \tl_if_empty:cF { l__siunitx_angle_ ##1 _tl }
+ {
+ \exp_args:Ncc \siunitx_number_process:NN
+ { l__siunitx_angle_ ##1 _tl } { l__siunitx_angle_ ##1 _tl }
+ \tl_set:cx { l__siunitx_angle_ ##1 _tl }
+ {
+ \exp_args:Nc \siunitx_number_output:NN
+ { l__siunitx_angle_ ##1 _tl } \q_nil
+ }
+ }
+ }
+ \__siunitx_angle_arc_print:VVV
+ \l__siunitx_angle_degrees_tl
+ \l__siunitx_angle_minutes_tl
+ \l__siunitx_angle_seconds_tl
+ \group_end:
+ }
+\cs_new_protected:Npn \__siunitx_angle_arc_sign:nn #1#2
+ {
+ \tl_if_blank:nTF {#1}
+ {
+ \bool_if:cTF { l__siunitx_angle_fill_ #2 _bool }
+ {
+ \tl_set:cn { l__siunitx_angle_ #2 _tl }
+ { { } { } { 0 } { } { } { } { 0 } }
+ }
+ { \tl_clear:c { l__siunitx_angle_ #2 _tl } }
+ }
+ {
+ \siunitx_number_parse:nN {#1} \l__siunitx_angle_tmp_tl
+ \exp_after:wN \__siunitx_angle_extract_sign:nnnnnnnn \l__siunitx_angle_tmp_tl {#2}
+ }
+ }
+\cs_new_protected:Npn \__siunitx_angle_extract_sign:nnnnnnnn #1#2#3#4#5#6#7#8
+ {
+ \tl_if_blank:nTF {#2}
+ { \tl_set_eq:cN { l__siunitx_angle_ #8 _tl } \l__siunitx_angle_tmp_tl }
+ {
+ \tl_set:cn { l__siunitx_angle_ #8 _tl }
+ { {#1} { } {#3} {#4} {#5} {#6} {#7} }
+ \tl_set:Nn \l__siunitx_angle_sign_tl {#2}
+ \__siunitx_angle_suppress_comp_sign:
+ }
+ }
+\cs_new:Npn \__siunitx_angle_sign:nnnnnnn #1#2#3#4#5#6#7
+ { \exp_not:n { {#3} {#4} {#5} {#6} {#7} } }
+\box_new:N \l__siunitx_angle_marker_box
+\box_new:N \l__siunitx_angle_unit_box
+\cs_new_protected:Npn \__siunitx_angle_arc_print:nnn #1#2#3
+ {
+ \__siunitx_angle_arc_print_auxi:nVn {#1}
+ \l__siunitx_angle_symbol_degree_tl {#2#3}
+ \__siunitx_angle_arc_print_auxi:nVn {#2}
+ \l__siunitx_angle_symbol_minute_tl {#3}
+ \__siunitx_angle_arc_print_auxi:nVn {#3}
+ \l__siunitx_angle_symbol_second_tl { }
+ }
+\cs_generate_variant:Nn \__siunitx_angle_arc_print:nnn { VVV }
+\cs_new_protected:Npn \__siunitx_angle_arc_print_auxi:nnn #1#2#3
+ {
+ \tl_if_blank:nF {#1}
+ {
+ \bool_if:NTF \l_siunitx_number_parse_bool
+ {
+ \bool_if:NTF \l__siunitx_angle_astronomy_bool
+ { \__siunitx_angle_arc_print_auxii:nw {#2} #1 \q_stop }
+ {
+ \__siunitx_angle_arc_print_auxv:w #1 \q_stop
+ \__siunitx_angle_arc_print_auxvi:n {#2}
+ }
+ }
+ {
+ \siunitx_print_number:n {#1}
+ \__siunitx_angle_arc_print_auxvi:n {#2}
+ }
+ \tl_if_blank:nF {#3}
+ {
+ \nobreak
+ \l__siunitx_angle_separator_tl
+ }
+ }
+ }
+\cs_generate_variant:Nn \__siunitx_angle_arc_print_auxi:nnn { nV }
+\cs_new_protected:Npn \__siunitx_angle_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
+ {
+ \mode_if_math:TF
+ { \bool_set_true:N \l__siunitx_angle_tmp_bool }
+ { \bool_set_false:N \l__siunitx_angle_tmp_bool }
+ \siunitx_print_number:n {#2#3#4}
+ \tl_if_blank:nTF {#6}
+ { \__siunitx_angle_arc_print_auxvi:n {#1} }
+ {
+ \hbox_set:Nn \l__siunitx_angle_marker_box
+ {
+ \__siunitx_angle_arc_print_auxiii:n
+ { \siunitx_print_number:n {#5} }
+ }
+ \hbox_set:Nn \l__siunitx_angle_unit_box
+ {
+ \__siunitx_angle_arc_print_auxiii:n
+ {
+ \siunitx_unit_format:nN {#1} \l__siunitx_angle_tmp_tl
+ \siunitx_print_unit:V \l__siunitx_angle_tmp_tl
+ \skip_horizontal:n { -\scriptspace }
+ }
+ }
+ \dim_compare:nNnTF { \box_wd:N \l__siunitx_angle_marker_box } >
+ { \box_wd:N \l__siunitx_angle_unit_box }
+ {
+ \__siunitx_angle_arc_print_auxiv:NN
+ \l__siunitx_angle_marker_box
+ \l__siunitx_angle_unit_box
+ }
+ {
+ \__siunitx_angle_arc_print_auxiv:NN
+ \l__siunitx_angle_unit_box
+ \l__siunitx_angle_marker_box
+ }
+ \hbox_set_to_wd:Nnn \l__siunitx_angle_marker_box
+ \l__siunitx_angle_tmp_dim
+ {
+ \hbox_overlap_right:n
+ { \box_use_drop:N \l__siunitx_angle_marker_box }
+ \hbox_overlap_right:n
+ { \box_use_drop:N \l__siunitx_angle_unit_box }
+ \tex_hfil:D
+ }
+ \box_use:N \l__siunitx_angle_marker_box
+ \skip_horizontal:N \scriptspace
+ \siunitx_print_number:n {#6}
+ }
+ }
+\cs_new_protected:Npn \__siunitx_angle_arc_print_auxiii:n #1
+ {
+ \bool_if:NTF \l__siunitx_angle_tmp_bool
+ { \ensuremath }
+ { \use:n }
+ {#1}
+ }
+\cs_new_protected:Npn \__siunitx_angle_arc_print_auxiv:NN #1#2
+ {
+ \dim_set:Nn \l__siunitx_angle_tmp_dim { \box_wd:N #1 }
+ \hbox_set_to_wd:Nnn #2
+ \l__siunitx_angle_tmp_dim
+ {
+ \tex_hss:D
+ \hbox_unpack_drop:N #2
+ \tex_hss:D
+ }
+ }
+\cs_new_protected:Npn \__siunitx_angle_arc_print_auxv: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 \__siunitx_angle_arc_print_auxvi:n #1
+ {
+ \nobreak
+ \l__siunitx_angle_product_tl
+ \siunitx_unit_format:nN {#1} \l__siunitx_angle_tmp_tl
+ \siunitx_print_unit:V \l__siunitx_angle_tmp_tl
+ }
+\keys_set:nn { siunitx }
+ {
+ angle-mode = input ,
+ angle-symbol-degree = \degree ,
+ angle-symbol-minute = \arcminute ,
+ angle-symbol-over-decimal = false ,
+ angle-symbol-second = \arcsecond ,
+ angle-separator = ,
+ fill-angle-degrees = false ,
+ fill-angle-minutes = false ,
+ fill-angle-seconds = false ,
+ number-angle-product =
+ }
+\fp_new:N \l__siunitx_complex_tmp_fp
+\tl_new:N \l__siunitx_complex_tmp_tl
+\tl_new:N \l__siunitx_complex_input_tl
+\tl_new:N \l__siunitx_complex_comparator_tl
+\tl_new:N \l__siunitx_complex_exp_tl
+\tl_new:N \l__siunitx_complex_real_tl
+\tl_new:N \l__siunitx_complex_img_tl
+\tl_new:N \l__siunitx_complex_mag_tl
+\tl_new:N \l__siunitx_complex_angle_tl
+\tl_new:N \l__siunitx_complex_join_tl
+\tl_new:N \l__siunitx_complex_sign_tl
+\bool_new:N \l__siunitx_complex_root_after_bool
+\bool_new:N \l__siunitx_complex_force_cartesian_bool
+\bool_new:N \l__siunitx_complex_force_polar_bool
+\bool_new:N \l__siunitx_complex_polar_degree_bool
+\keys_define:nn { siunitx }
+ {
+ complex-mode .choice: ,
+ complex-mode / cartesian .code:n =
+ {
+ \bool_set_true:N \l__siunitx_complex_force_cartesian_bool
+ \bool_set_false:N \l__siunitx_complex_force_polar_bool
+ } ,
+ complex-mode / polar .code:n =
+ {
+ \bool_set_false:N \l__siunitx_complex_force_cartesian_bool
+ \bool_set_true:N \l__siunitx_complex_force_polar_bool
+ } ,
+ complex-mode / input .code:n =
+ {
+ \bool_set_false:N \l__siunitx_complex_force_cartesian_bool
+ \bool_set_false:N \l__siunitx_complex_force_polar_bool
+ } ,
+ complex-angle-unit .choice: ,
+ complex-angle-unit / degrees .code:n =
+ { \bool_set_true:N \l__siunitx_complex_polar_degree_bool } ,
+ complex-angle-unit / radians .code:n =
+ { \bool_set_false:N \l__siunitx_complex_polar_degree_bool } ,
+ complex-root-position .choice: ,
+ complex-root-position / after-number .code:n =
+ { \bool_set_true:N \l__siunitx_complex_root_after_bool } ,
+ complex-root-position / before-number .code:n =
+ { \bool_set_false:N \l__siunitx_complex_root_after_bool } ,
+ complex-symbol-angle .tl_set:N =
+ \l__siunitx_complex_symbol_angle_tl ,
+ complex-symbol-degree .tl_set:N =
+ \l__siunitx_complex_symbol_degree_tl ,
+ input-complex-root .tl_set:N =
+ \l__siunitx_complex_input_root_tl ,
+ output-complex-root .tl_set:N =
+ \l__siunitx_complex_output_root_tl ,
+ print-complex-unity .bool_set:N =
+ \l__siunitx_complex_print_unity_bool
+ }
+\cs_new_protected:Npn \__siunitx_complex_parse:nNN #1#2#3
+ {
+ \group_begin:
+ \__siunitx_complex_parse_clear:
+ \protected@edef \l__siunitx_complex_arg_tl {#1}
+ \tl_set_eq:NN \l__siunitx_complex_input_tl \l__siunitx_complex_arg_tl
+ \siunitx_number_normalize_symbols:N \l__siunitx_complex_arg_tl
+ \tl_if_empty:NF \l__siunitx_complex_arg_tl
+ { \__siunitx_complex_parse_comparator: }
+ \__siunitx_complex_parse_check:
+ \cs_set_protected:Npx \__siunitx_complex_parse_end:
+ {
+ \tl_set:Nn \exp_not:N #2 { \exp_not:V \l__siunitx_complex_real_tl }
+ \tl_set:Nn \exp_not:N #3 { \exp_not:V \l__siunitx_complex_img_tl }
+ }
+ \exp_after:wN \group_end:
+ \__siunitx_complex_parse_end:
+ }
+\cs_new_protected:Npn \__siunitx_complex_parse_end: { }
+\cs_new_protected:Npn \__siunitx_complex_parse_clear:
+ {
+ \tl_clear:N \l__siunitx_complex_real_tl
+ \tl_clear:N \l__siunitx_complex_img_tl
+ \tl_clear:N \l__siunitx_complex_exp_tl
+ \tl_clear:N \l__siunitx_complex_sign_tl
+ \tl_clear:N \l__siunitx_complex_join_tl
+ }
+\cs_new_protected:Npn \__siunitx_complex_parse_check:
+ {
+ \tl_if_empty:NTF \l__siunitx_complex_img_tl
+ { \__siunitx_complex_parse_check:N \l__siunitx_complex_real_tl }
+ {
+ \tl_if_empty:NTF \l__siunitx_complex_real_tl
+ { \__siunitx_complex_parse_check:N \l__siunitx_complex_img_tl }
+ {
+ \__siunitx_complex_parse_check:N \l__siunitx_complex_real_tl
+ \tl_set_eq:NN \l__siunitx_complex_sign_tl \l__siunitx_complex_join_tl
+ \__siunitx_complex_parse_check:N \l__siunitx_complex_img_tl
+ }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_complex_parse_check:N #1
+ {
+ \tl_set:Nx #1
+ {
+ \exp_not:V \l__siunitx_complex_comparator_tl
+ \exp_not:V \l__siunitx_complex_sign_tl
+ \exp_not:V #1
+ \exp_not:V \l__siunitx_complex_exp_tl
+ }
+ \tl_clear:N \l__siunitx_complex_comparator_tl
+ \tl_clear:N \l__siunitx_complex_sign_tl
+ \siunitx_number_parse:VN #1 #1
+ }
+\cs_new_protected:Npn \__siunitx_complex_parse_comparator:
+ {
+ \exp_after:wN \__siunitx_complex_parse_comparator_aux:Nw
+ \l__siunitx_complex_arg_tl \q_stop
+ }
+\cs_new_protected:Npn \__siunitx_complex_parse_comparator_aux:Nw #1#2 \q_stop
+ {
+ \tl_if_in:NnTF \l_siunitx_number_input_comparator_tl {#1}
+ {
+ \tl_set:Nn \l__siunitx_complex_comparator_tl {#1}
+ \tl_set:Nn \l__siunitx_complex_arg_tl {#2}
+ }
+ { \tl_clear:N \l__siunitx_complex_comparator_tl }
+ \tl_if_empty:NF \l__siunitx_complex_arg_tl
+ { \__siunitx_complex_parse_sign: }
+ }
+\cs_new_protected:Npn \__siunitx_complex_parse_exponent:
+ {
+ \tl_if_empty:NTF \l_siunitx_number_input_exponent_tl
+ { \__siunitx_complex_parse_root: }
+ {
+ \tl_set:Nx \l__siunitx_complex_tmp_tl
+ { \tl_head:V \l_siunitx_number_input_exponent_tl }
+ \tl_map_inline:Nn \l_siunitx_number_input_exponent_tl
+ {
+ \tl_replace_all:NnV \l__siunitx_complex_arg_tl
+ {##1} \l__siunitx_complex_tmp_tl
+ }
+ \use:x
+ {
+ \cs_set_protected:Npn
+ \exp_not:N \__siunitx_complex_parse_exponent_auxi:w
+ ####1 \exp_not:V \l__siunitx_complex_tmp_tl
+ ####2 \exp_not:V \l__siunitx_complex_tmp_tl
+ ####3 \exp_not:N \q_stop
+ }
+ { \__siunitx_complex_parse_exponent_auxii:nn {##1} {##2} }
+ \use:x
+ {
+ \__siunitx_complex_parse_exponent_auxi:w
+ \exp_not:V \l__siunitx_complex_arg_tl
+ \exp_not:V \l__siunitx_complex_tmp_tl \exp_not:N \q_nil
+ \exp_not:V \l__siunitx_complex_tmp_tl \exp_not:N \q_stop
+ }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_complex_parse_exponent_auxi:w { }
+\cs_new_protected:Npn \__siunitx_complex_parse_exponent_auxii:nn #1#2
+ {
+ \quark_if_nil:nF {#2}
+ {
+ \tl_set:Nn \l__siunitx_complex_arg_tl {#1}
+ \tl_set:Nx \l__siunitx_complex_exp_tl
+ { \exp_not:V \l__siunitx_complex_tmp_tl \exp_not:n {#2} }
+ }
+ \__siunitx_complex_parse_root:
+ }
+\cs_new_protected:Npn \__siunitx_complex_parse_root:
+ {
+ \tl_if_empty:NTF \l__siunitx_complex_input_root_tl
+ { \tl_set_eq:NN \l__siunitx_complex_real_tl \l__siunitx_complex_arg_tl }
+ {
+ \tl_set:Nx \l__siunitx_complex_tmp_tl
+ { \tl_head:V \l__siunitx_complex_input_root_tl }
+ \tl_map_inline:Nn \l__siunitx_complex_input_root_tl
+ {
+ \tl_replace_all:NnV \l__siunitx_complex_arg_tl
+ {##1} \l__siunitx_complex_tmp_tl
+ }
+ \use:x
+ {
+ \cs_set_protected:Npn
+ \exp_not:N \__siunitx_complex_parse_root_auxi:w
+ ####1 \exp_not:V \l__siunitx_complex_tmp_tl
+ ####2 \exp_not:V \l__siunitx_complex_tmp_tl
+ ####3 \exp_not:N \q_stop
+ }
+ { \__siunitx_complex_parse_root_auxii:nn {##1} {##2} }
+ \use:x
+ {
+ \__siunitx_complex_parse_root_auxi:w
+ \exp_not:V \l__siunitx_complex_arg_tl
+ \exp_not:V \l__siunitx_complex_tmp_tl \exp_not:N \q_nil
+ \exp_not:V \l__siunitx_complex_tmp_tl \exp_not:N \q_stop
+ }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_complex_parse_root_auxi:w { }
+\cs_new_protected:Npn \__siunitx_complex_parse_root_auxii:nn #1#2
+ {
+ \quark_if_nil:nTF {#2}
+ { \tl_set:Nn \l__siunitx_complex_real_tl {#1} }
+ {
+ \tl_set:Nn \l__siunitx_complex_img_tl {#2}
+ \tl_if_blank:nTF {#1}
+ {
+ \tl_if_blank:nT {#2}
+ { \tl_set:Nn \l__siunitx_complex_img_tl { 1 } }
+ }
+ {
+ \tl_if_blank:nTF {#2}
+ { \__siunitx_complex_parse_split:n {#1} }
+ { \__siunitx_complex_parse_sign_check:n {#1} }
+ }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_complex_parse_sign:
+ {
+ \exp_after:wN \__siunitx_complex_parse_sign_aux:Nw
+ \l__siunitx_complex_arg_tl \q_stop
+ }
+\cs_new_protected:Npn \__siunitx_complex_parse_sign_aux:Nw #1#2 \q_stop
+ {
+ \tl_if_in:NnT \l_siunitx_number_input_sign_tl {#1}
+ {
+ \tl_set:Nn \l__siunitx_complex_sign_tl {#1}
+ \tl_set:Nn \l__siunitx_complex_arg_tl {#2}
+ }
+ \tl_if_empty:NF \l__siunitx_complex_arg_tl
+ { \__siunitx_complex_parse_exponent: }
+ }
+\cs_new_protected:Npn \__siunitx_complex_parse_sign_check:n #1
+ {
+ \__siunitx_complex_parse_sign_check:nN { } #1 \q_recursion_tail \q_recursion_stop
+ }
+\cs_new_protected:Npn \__siunitx_complex_parse_sign_check:nN #1#2
+ {
+ \quark_if_recursion_tail_stop_do:Nn #2
+ { \__siunitx_complex_parse_clear: }
+ \tl_if_in:NnTF \l_siunitx_number_input_sign_tl {#2}
+ { \__siunitx_complex_parse_sign_check:nNw {#1} #2 }
+ { \__siunitx_complex_parse_sign_check:nN {#1#2} }
+ }
+\cs_new_protected:Npn \__siunitx_complex_parse_sign_check:nNw
+ #1#2 #3 \q_recursion_tail \q_recursion_stop
+ {
+ \tl_if_blank:nTF {#3}
+ {
+ \tl_if_blank:nTF {#1}
+ { \__siunitx_complex_parse_clear: }
+ {
+ \tl_set:Nn \l__siunitx_complex_real_tl {#1}
+ \tl_set:Nn \l__siunitx_complex_join_tl {#2}
+ }
+ }
+ { \__siunitx_complex_parse_clear: }
+ }
+\cs_new_protected:Npn \__siunitx_complex_parse_split:n #1
+ {
+ \__siunitx_complex_parse_split:nN { } #1 \q_recursion_tail \q_recursion_stop
+ }
+\cs_new_protected:Npn \__siunitx_complex_parse_split:nN #1#2
+ {
+ \quark_if_recursion_tail_stop_do:Nn #2
+ { \tl_set:Nn \l__siunitx_complex_img_tl {#1} }
+ \tl_if_in:NnTF \l_siunitx_number_input_sign_tl {#2}
+ {
+ \tl_set:Nn \l__siunitx_complex_real_tl {#1}
+ \tl_set:Nn \l__siunitx_complex_join_tl {#2}
+ \__siunitx_complex_parse_split:w
+ }
+ { \__siunitx_complex_parse_split:nN {#1#2} }
+ }
+\cs_new_protected:Npn \__siunitx_complex_parse_split:w #1 \q_recursion_tail \q_recursion_stop
+ {
+ \tl_set:Nx \l__siunitx_complex_img_tl
+ {
+ \tl_if_blank:nTF {#1}
+ { 1 }
+ { \exp_not:n {#1} }
+ }
+ \tl_if_empty:NT \l__siunitx_complex_real_tl
+ { \__siunitx_complex_parse_clear: }
+ }
+\cs_new_protected:Npn \__siunitx_complex_parse_polar:nn #1#2
+ {
+ \bool_if:NTF \l_siunitx_number_parse_bool
+ { \siunitx_number_parse:nN {#1} \l__siunitx_complex_mag_tl }
+ { \tl_set:Nn \l__siunitx_complex_mag_tl { \ensuremath {#1} } }
+ \group_begin:
+ \keys_set:nn { siunitx }
+ {
+ input-comparators = ,
+ input-exponent-markers = ,
+ input-open-uncertainty = ,
+ input-close-uncertainty =
+ }
+ \siunitx_number_format:nN {#2} \l__siunitx_complex_angle_tl
+ \exp_args:NNNV \group_end:
+ \tl_set:Nn \l__siunitx_complex_angle_tl \l__siunitx_complex_angle_tl
+ }
+\tl_new:N \l__siunitx_complex_bracket_close_tl
+\tl_new:N \l__siunitx_complex_bracket_open_tl
+\tl_set:Nn \l__siunitx_complex_bracket_open_tl { ( }
+\tl_set:Nn \l__siunitx_complex_bracket_close_tl { ) }
+\tl_new:N \l__siunitx_complex_unit_tl
+\cs_new_protected:Npn \siunitx_complex_number:n #1
+ {
+ \bool_lazy_and:nnTF
+ { \l__siunitx_complex_force_polar_bool }
+ { \l_siunitx_number_parse_bool }
+ {
+ \use:e
+ {
+ \siunitx_complex_number:nn
+ \__siunitx_complex_convert_polar:n {#1}
+ }
+ }
+ {
+ \bool_if:NTF \l_siunitx_number_parse_bool
+ {
+ \__siunitx_complex_parse:nNN {#1} \l__siunitx_complex_real_tl \l__siunitx_complex_img_tl
+ \__siunitx_complex_format_cartesian:n { }
+ }
+ {
+ \siunitx_number_format:nN {#1} \l__siunitx_complex_tmp_tl
+ \siunitx_print_number:V \l__siunitx_complex_tmp_tl
+ }
+ }
+ }
+\cs_new_protected:Npn \siunitx_complex_number:nn #1#2
+ {
+ \bool_lazy_or:nnTF
+ { \tl_if_blank_p:n {#1} }
+ { \tl_if_blank_p:n {#2} }
+ {
+ \msg_error:nnnn { siunitx } { invalid-polar-form }
+ {#1} {#2}
+ }
+ { \__siunitx_complex_number:nn {#1} {#2} }
+ }
+\cs_new_protected:Npn \__siunitx_complex_number:nn #1#2
+ {
+ \bool_lazy_and:nnTF
+ { \l__siunitx_complex_force_cartesian_bool }
+ { \l_siunitx_number_parse_bool }
+ {
+ \exp_args:Ne \siunitx_complex_number:n
+ { \__siunitx_complex_convert_cartesian:nn {#1} {#2} }
+ }
+ {
+ \__siunitx_complex_parse_polar:nn {#1} {#2}
+ \__siunitx_complex_format_polar:n { }
+ }
+ }
+\cs_new_protected:Npn \siunitx_complex_quantity:nn #1#2
+ {
+ \bool_lazy_and:nnTF
+ { \l__siunitx_complex_force_polar_bool }
+ { \l_siunitx_number_parse_bool }
+ {
+ \use:e
+ {
+ \siunitx_complex_quantity:nnn
+ \__siunitx_complex_convert_polar:n {#1}
+ }
+ {#2}
+ }
+ {
+ \bool_if:NTF \l_siunitx_number_parse_bool
+ {
+ \__siunitx_complex_parse:nNN {#1} \l__siunitx_complex_real_tl \l__siunitx_complex_img_tl
+ \__siunitx_complex_format_cartesian:n {#2}
+ }
+ { \siunitx_quantity:nn {#1} {#2} }
+ }
+ }
+\cs_new_protected:Npn \siunitx_complex_quantity:nnn #1#2#3
+ {
+ \bool_lazy_or:nnTF
+ { \tl_if_blank_p:n {#1} }
+ { \tl_if_blank_p:n {#2} }
+ {
+ \msg_error:nnnn { siunitx } { invalid-polar-form }
+ {#1} {#2}
+ }
+ { \__siunitx_complex_quantity:nnn {#1} {#2} {#3} }
+ }
+\cs_new_protected:Npn \__siunitx_complex_quantity:nnn #1#2#3
+ {
+ \bool_lazy_and:nnTF
+ { \l__siunitx_complex_force_cartesian_bool }
+ { \l_siunitx_number_parse_bool }
+ {
+ \exp_args:Ne \siunitx_complex_quantity:nn
+ { \__siunitx_complex_convert_cartesian:nn {#1} {#2} }
+ {#3}
+ }
+ {
+ \__siunitx_complex_parse_polar:nn {#1} {#2}
+ \__siunitx_complex_format_polar:n {#3}
+ }
+ }
+\cs_new_protected:Npn \__siunitx_complex_format_cartesian:n #1
+ {
+ \bool_lazy_and:nnF
+ { \tl_if_empty_p:N \l__siunitx_complex_real_tl }
+ { \tl_if_empty_p:N \l__siunitx_complex_img_tl }
+ { \__siunitx_complex_format_cartesian_auxi:n {#1} }
+ }
+\cs_new_protected:Npn \__siunitx_complex_format_cartesian_auxi:n #1
+ {
+ \tl_clear:N \l__siunitx_complex_tmp_tl
+ \tl_if_empty:NTF \l__siunitx_complex_img_tl
+ {
+ \siunitx_number_process:NN \l__siunitx_complex_real_tl \l__siunitx_complex_real_tl
+ \tl_set:Nx \l__siunitx_complex_tmp_tl
+ { \siunitx_number_output:N \l__siunitx_complex_real_tl }
+ }
+ { \__siunitx_complex_format_cartesian_auxii:n {#1} }
+ \tl_if_blank:nTF {#1}
+ { \siunitx_print_number:V \l__siunitx_complex_tmp_tl }
+ { \siunitx_quantity_print:VV \l__siunitx_complex_tmp_tl \l__siunitx_complex_unit_tl }
+ }
+\cs_new_protected:Npn \__siunitx_complex_format_cartesian_auxii:n #1
+ {
+ \__siunitx_complex_format_cartesian_units:n {#1}
+ \tl_if_empty:NF \l__siunitx_complex_real_tl
+ { \exp_after:wN \__siunitx_complex_drop_exponent:nnnnnnn \l__siunitx_complex_real_tl }
+ \exp_after:wN \__siunitx_complex_format_sign:nnnnnnn \l__siunitx_complex_img_tl
+ \tl_set:Nx \l__siunitx_complex_tmp_tl
+ { \siunitx_number_output:NN \l__siunitx_complex_img_tl \q_nil }
+ \exp_after:wN \__siunitx_complex_extract_exponent:w \l__siunitx_complex_tmp_tl \q_stop
+ \tl_set:Nx \l__siunitx_complex_tmp_tl
+ {
+ \bool_lazy_or:nnTF
+ {
+ \bool_lazy_and_p:nn
+ { \l_siunitx_number_bracket_ambiguous_bool }
+ { ! \tl_if_empty_p:N \l__siunitx_complex_exp_tl }
+ }
+ {
+ ! \bool_lazy_any_p:n
+ {
+ { \tl_if_blank_p:n {#1} }
+ { \tl_if_empty_p:N \l__siunitx_complex_real_tl }
+ { \tl_if_empty_p:N \l__siunitx_complex_img_tl }
+ }
+ }
+ { \__siunitx_complex_format_bracket:n }
+ { \use:n }
+ {
+ \siunitx_number_output:N \l__siunitx_complex_real_tl
+ \exp_not:V \l__siunitx_complex_sign_tl
+ \bool_if:NF \l__siunitx_complex_root_after_bool
+ { \exp_not:V \l__siunitx_complex_output_root_tl }
+ \exp_not:V \l__siunitx_complex_tmp_tl
+ \bool_if:NT \l__siunitx_complex_root_after_bool
+ { \exp_not:V \l__siunitx_complex_output_root_tl }
+ }
+ \exp_not:V \l__siunitx_complex_exp_tl
+ }
+ }
+\cs_new_protected:Npn \__siunitx_complex_drop_exponent:nnnnnnn #1#2#3#4#5#6#7
+ { \tl_set:Nn \l__siunitx_complex_real_tl { {#1} {#2} {#3} {#4} {#5} { } { 0 } } }
+\cs_new_protected:Npn \__siunitx_complex_format_sign:nnnnnnn #1#2#3#4#5#6#7
+ {
+ \tl_set:Nx \l__siunitx_complex_img_tl
+ {
+ { }
+ {
+ \tl_if_blank:nTF {#2}
+ { \tl_if_empty:NF \l__siunitx_complex_real_tl { + } }
+ { \exp_not:n {#2} }
+ }
+ \exp_not:n { {#3} {#4} {#5} {#6} {#7} }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_complex_extract_exponent:w
+ #1 \q_nil #2 \q_nil #3 \q_nil #4 \q_nil #5 \q_nil #6 \q_nil #7 \q_nil #8
+ \q_nil #9 \q_stop
+ {
+ \tl_set:Nn \l__siunitx_complex_sign_tl {#1#2}
+ \bool_lazy_all:nTF
+ {
+ { ! \l__siunitx_complex_print_unity_bool }
+ { \str_if_eq_p:nn {#3} { 1 } }
+ { \tl_if_blank_p:n {#5} }
+ }
+ { \__siunitx_complex_extract_exponent_aux:nw {#6#7#8} }
+ { \__siunitx_complex_extract_exponent_aux:nw {#3#4#5#6#7#8} }
+ #9 \q_stop
+ }
+\cs_new:Npn \__siunitx_complex_extract_exponent_aux:nw
+ #1#2 \q_nil #3 \q_nil #4 \q_stop
+ {
+ \tl_set:Nn \l__siunitx_complex_tmp_tl {#1#2}
+ \tl_set:Nn \l__siunitx_complex_exp_tl {#3#4}
+ }
+\cs_new_protected:Npn \__siunitx_complex_format_bracket:n #1
+ {
+ \exp_not:V \l__siunitx_complex_bracket_open_tl
+ #1
+ \exp_not:V \l__siunitx_complex_bracket_close_tl
+ }
+\cs_new_protected:Npn \__siunitx_complex_format_cartesian_units:n #1
+ {
+ \tl_if_blank:nTF {#1}
+ {
+ \siunitx_number_process:NN \l__siunitx_complex_real_tl \l__siunitx_complex_real_tl
+ \siunitx_number_process:NN \l__siunitx_complex_img_tl \l__siunitx_complex_img_tl
+ }
+ {
+ \use:c
+ { __siunitx_complex_format_cartesian_ \l_siunitx_quantity_prefix_mode_tl :n } {#1}
+ }
+ }
+\cs_new_protected:cpn { __siunitx_complex_format_cartesian_combine-exponent:n } #1
+ {
+ \tl_if_empty:NF \l__siunitx_complex_real_tl
+ { \siunitx_number_process:NN \l__siunitx_complex_real_tl \l__siunitx_complex_real_tl }
+ \siunitx_number_process:NN \l__siunitx_complex_img_tl \l__siunitx_complex_img_tl
+ \fp_set:Nn \l__siunitx_complex_tmp_fp
+ { \exp_after:wN \__siunitx_complex_extract_exp:nnnnnnn \l__siunitx_complex_img_tl }
+ \__siunitx_complex_drop_exp:N \l__siunitx_complex_real_tl
+ \__siunitx_complex_drop_exp:N \l__siunitx_complex_img_tl
+ \siunitx_unit_format_combine_exponent:nnN {#1}
+ \l__siunitx_complex_tmp_fp \l__siunitx_complex_unit_tl
+ }
+\cs_new_protected:cpx { __siunitx_complex_format_cartesian_extract-exponent:n } #1
+ {
+ \exp_not:N \siunitx_unit_format_extract_prefixes:nNN {#1}
+ \exp_not:N \l__siunitx_complex_unit_tl \exp_not:N \l__siunitx_complex_tmp_fp
+ \exp_not:c { __siunitx_complex_format_extract-exponent:N }
+ \exp_not:N \l__siunitx_complex_img_tl
+ \exp_not:N \tl_if_empty:NF \exp_not:N \l__siunitx_complex_real_tl
+ {
+ \exp_not:c { __siunitx_complex_format_extract-exponent:N }
+ \exp_not:N \l__siunitx_complex_real_tl
+ }
+ }
+\cs_new_protected:Npn \__siunitx_complex_format_cartesian_input:n #1
+ {
+ \siunitx_number_process:NN \l__siunitx_complex_real_tl \l__siunitx_complex_real_tl
+ \siunitx_number_process:NN \l__siunitx_complex_img_tl \l__siunitx_complex_img_tl
+ \siunitx_unit_format:nN {#1} \l__siunitx_complex_unit_tl
+ }
+\cs_new_protected:cpn { __siunitx_complex_format_extract-exponent:N } #1
+ {
+ \tl_set:Nx #1
+ { \siunitx_number_adjust_exponent:Nn #1 \l__siunitx_complex_tmp_fp }
+ \siunitx_number_process:NN #1 #1
+ }
+\cs_new:Npn \__siunitx_complex_extract_exp:nnnnnnn #1#2#3#4#5#6#7 { #6#7 }
+\cs_new_protected:Npn \__siunitx_complex_drop_exp:N #1
+ { \exp_after:wN \__siunitx_complex_drop_exp:nnnnnnnN #1 #1 }
+\cs_new_protected:Npn \__siunitx_complex_drop_exp:nnnnnnnN #1#2#3#4#5#6#7#8
+ { \tl_set:Nn #8 { {#1} {#2} {#3} {#4} {#5} { } { 0 } } }
+\cs_new_protected:Npn \__siunitx_complex_format_polar:n #1
+ {
+ \tl_if_blank:nTF {#1}
+ {
+ \bool_if:NT \l_siunitx_number_parse_bool
+ { \siunitx_number_process:NN \l__siunitx_complex_mag_tl \l__siunitx_complex_mag_tl }
+ }
+ {
+ \bool_if:NTF \l_siunitx_number_parse_bool
+ {
+ \use:c
+ { __siunitx_complex_format_polar_ \l_siunitx_quantity_prefix_mode_tl :n } {#1}
+ }
+ { \__siunitx_complex_format_polar_input:n {#1} }
+ }
+ \tl_set:Nx \l__siunitx_complex_tmp_tl
+ {
+ \bool_if:NTF \l_siunitx_number_parse_bool
+ { \siunitx_number_output:N \l__siunitx_complex_mag_tl }
+ { \exp_not:V \l__siunitx_complex_mag_tl }
+ \exp_not:V \l__siunitx_complex_symbol_angle_tl
+ \mathord % TEMP
+ \exp_not:V \l__siunitx_complex_angle_tl
+ }
+ \siunitx_print_number:V \l__siunitx_complex_tmp_tl
+ \bool_if:NT \l__siunitx_complex_polar_degree_bool
+ {
+ \exp_args:NV \siunitx_unit_format:nN \l__siunitx_complex_symbol_degree_tl \l__siunitx_complex_tmp_tl
+ \nobreak
+ \siunitx_print_unit:V \l__siunitx_complex_tmp_tl
+ }
+ \siunitx_quantity_print:nV { } \l__siunitx_complex_unit_tl
+ }
+\cs_new_protected:cpn { __siunitx_complex_format_polar_combine-exponent:n } #1
+ {
+ \siunitx_number_process:NN \l__siunitx_complex_mag_tl \l__siunitx_complex_mag_tl
+ \fp_set:Nn \l__siunitx_complex_tmp_fp
+ { \exp_after:wN \__siunitx_complex_extract_exp:nnnnnnn \l__siunitx_complex_mag_tl }
+ \__siunitx_complex_drop_exp:N \l__siunitx_complex_mag_tl
+ \siunitx_unit_format_combine_exponent:nnN {#1}
+ \l__siunitx_complex_tmp_fp \l__siunitx_complex_unit_tl
+ }
+\cs_new_protected:cpx { __siunitx_complex_format_polar_extract-exponent:n } #1
+ {
+ \exp_not:N \siunitx_unit_format_extract_prefixes:nNN {#1}
+ \exp_not:N \l__siunitx_complex_unit_tl \exp_not:N \l__siunitx_complex_tmp_fp
+ \exp_not:c { __siunitx_complex_format_extract-exponent:N }
+ \exp_not:N \l__siunitx_complex_mag_tl
+ }
+\cs_new_protected:Npn \__siunitx_complex_format_polar_input:n #1
+ {
+ \bool_if:NT \l_siunitx_number_parse_bool
+ { \siunitx_number_process:NN \l__siunitx_complex_mag_tl \l__siunitx_complex_mag_tl }
+ \siunitx_unit_format:nN {#1} \l__siunitx_complex_unit_tl
+ }
+\cs_new:Npn \__siunitx_complex_convert_cartesian:nn #1#2
+ {
+ \exp_args:Nee \__siunitx_complex_convert_cartesian_aux:nn
+ {
+ \fp_to_tl:n
+ { (#1) * cos \bool_if:NT \l__siunitx_complex_polar_degree_bool { d } (#2) }
+ }
+ {
+ \fp_to_tl:n
+ { (#1) * sin \bool_if:NT \l__siunitx_complex_polar_degree_bool { d } (#2) }
+ }
+ }
+\cs_new:Npn \__siunitx_complex_convert_cartesian_aux:nn #1#2
+ {
+ \__siunitx_complex_convert_cartesian_aux:w #1 e e \q_mark #2 e e \q_stop
+ }
+\cs_new:Npn \__siunitx_complex_convert_cartesian_aux:w
+ #1 e #2 e #3 \q_mark #4 e #5 e #6 \q_stop
+ {
+ \fp_compare:nNnF {#1} = \c_zero_fp
+ {#1}
+ \fp_compare:nNnF {#4} = \c_zero_fp
+ {
+ \fp_compare:nNnF {#4} < \c_zero_fp { + }
+ #4 i
+ }
+ \tl_if_blank:nF {#2}
+ { e #2 }
+ }
+\cs_new:Npn \__siunitx_complex_convert_polar:n #1
+ { \__siunitx_complex_convert_polar_auxi:w #1 e e \q_stop }
+\cs_new:Npn \__siunitx_complex_convert_polar_auxi:w #1 e #2 e #3 \q_stop
+ { \__siunitx_complex_convert_polar_auxii:nw {#2} #1 \q_stop }
+\cs_new:Npn \__siunitx_complex_convert_polar_auxii:nw #1#2#3 \q_stop
+ {
+ \bool_lazy_or:nnTF
+ { \str_if_eq_p:nn {#2} { i } }
+ { \str_if_eq_p:nn {#2#3} { +i } }
+ { \__siunitx_complex_convert_polar_auxvi:nnn { } { 1 } {#1} }
+ {
+ \str_if_eq:nnTF {#2#3} { -i }
+ { \__siunitx_complex_convert_polar_auxvi:nnn { } { -1 } {#1} }
+ { \__siunitx_complex_convert_polar_auxiii:nnw {#1} {#2} #3 + + \q_stop }
+ }
+ }
+\cs_new:Npn \__siunitx_complex_convert_polar_auxiii:nnw #1#2#3 + #4 + #5 \q_stop
+ {
+ \tl_if_blank:nTF {#4}
+ { \__siunitx_complex_convert_polar_auxiv:nnw {#1} {#2} #3 - - \q_stop }
+ {
+ \str_if_eq:nnTF {#4} { i }
+ { \__siunitx_complex_convert_polar_auxvi:nnn {#2#3} { 1 } {#1} }
+ { \__siunitx_complex_convert_polar_auxv:nnw {#2#3} {#1} #4 i \q_nil i \q_stop }
+ }
+ }
+\cs_new:Npn \__siunitx_complex_convert_polar_auxiv:nnw #1#2#3 - #4 - #5 \q_stop
+ {
+ \tl_if_blank:nTF {#4}
+ { \__siunitx_complex_convert_polar_auxv:nnw { } {#1} #2#3 i \q_nil i \q_stop }
+ {
+ \str_if_eq:nnTF {#4} { i }
+ { \__siunitx_complex_convert_polar_auxvi:nnn { } { -1 } {#1} }
+ { \__siunitx_complex_convert_polar_auxv:nnw {#2#3} {#1} -#4 i \q_nil i \q_stop }
+ }
+ }
+\cs_new:Npn \__siunitx_complex_convert_polar_auxv:nnw #1#2#3 i #4 i #5 \q_stop
+ {
+ \quark_if_nil:nTF {#4}
+ { { #3 \tl_if_blank:nF {#2} { e#2 } } { 0 } }
+ { \__siunitx_complex_convert_polar_auxvi:nnn {#1} {#3} {#2} }
+ }
+\cs_new:Npn \__siunitx_complex_convert_polar_auxvi:nnn #1#2#3
+ {
+ \exp_args:Neee \__siunitx_complex_convert_polar_auxvii:nnn
+ { \tl_if_blank:nTF {#1} { 0 } {#1} }
+ { \tl_if_blank:nTF {#2} { 0 } {#2} }
+ { \tl_if_blank:nF {#3} { e#3 } }
+ }
+\cs_new:Npn \__siunitx_complex_convert_polar_auxvii:nnn #1#2#3
+ {
+ \exp_args:Nee \__siunitx_complex_format_polar_auxviii:nn
+ { \fp_eval:n { sqrt ( (#1#3)^2 + (#2#3)^2 ) } }
+ {
+ \fp_eval:n
+ { atan \bool_if:NT \l__siunitx_complex_polar_degree_bool { d } (#2 , #1) }
+ }
+ }
+\cs_new:Npn \__siunitx_complex_format_polar_auxviii:nn #1#2 { {#1} {#2} }
+\msg_new:nnnn { siunitx } { invalid-polar-form }
+ { Invalid~polar~form~"#1:#2". }
+ {
+ Complex~numbers~in~polar~form~must~have~both~a~magnitude~and~and~
+ angle.
+ }
+\keys_set:nn { siunitx }
+ {
+ complex-angle-unit = degrees ,
+ complex-mode = input ,
+ complex-root-position = after-number ,
+ complex-symbol-angle = \angle ,
+ complex-symbol-degree = \degree ,
+ input-complex-root = ij ,
+ output-complex-root = \mathrm { i } ,
+ print-complex-unity = false
+ }
+\cs_generate_variant:Nn \keys_set:nn { nx }
+\cs_generate_variant:Nn \seq_use:Nnnn { NVVV }
+\fp_new:N \l__siunitx_compound_tmp_fp
+\seq_new:N \l__siunitx_compound_tmp_seq
+\tl_new:N \l__siunitx_compound_tmp_tl
+\tl_new:N \l__siunitx_compound_first_tl
+\tl_new:N \l__siunitx_compound_exp_tl
+\tl_new:N \l__siunitx_compound_start_tl
+\tl_new:N \l__siunitx_compound_end_tl
+\int_new:N \l__siunitx_compound_count_int
+\bool_new:N \l__siunitx_compound_unit_bool
+\tl_new:N \l__siunitx_compound_unit_tl
+\bool_new:N \l__siunitx_compound_boundary_text_bool
+\bool_new:N \l__siunitx_compound_exp_bracket_bool
+\bool_new:N \l__siunitx_compound_exp_combine_bool
+\bool_new:N \l__siunitx_compound_separator_text_bool
+\bool_new:N \l__siunitx_compound_unit_bracket_bool
+\bool_new:N \l__siunitx_compound_unit_power_bool
+\bool_new:N \l__siunitx_compound_unit_repeat_bool
+\keys_define:nn { siunitx }
+ {
+ compound-boundary-mode .choice: ,
+ compound-boundary-mode / number .code:n =
+ { \bool_set_false:N \l__siunitx_compound_delim_text_bool } ,
+ compound-boundary-mode / text .code:n =
+ { \bool_set_true:N \l__siunitx_compound_delim_text_bool } ,
+ compound-close-boundary .tl_set:N =
+ \l__siunitx_compound_boundary_close_tl ,
+ compound-close-bracket .tl_set:N =
+ \l__siunitx_compound_bracket_close_tl ,
+ compound-exponents .choice: ,
+ compound-exponents / combine .code:n =
+ {
+ \bool_set_false:N \l__siunitx_compound_exp_bracket_bool
+ \bool_set_true:N \l__siunitx_compound_exp_combine_bool
+ } ,
+ compound-exponents / combine-bracket .code:n =
+ {
+ \bool_set_true:N \l__siunitx_compound_exp_bracket_bool
+ \bool_set_true:N \l__siunitx_compound_exp_combine_bool
+ } ,
+ compound-exponents / individual .code:n =
+ {
+ \bool_set_false:N \l__siunitx_compound_exp_bracket_bool
+ \bool_set_false:N \l__siunitx_compound_exp_combine_bool
+ } ,
+ compound-final-separator .tl_set:N =
+ \l__siunitx_compound_separator_final_tl ,
+ compound-independent-prefix .bool_set:N =
+ \l__siunitx_compound_independent_bool ,
+ compound-pair-separator .tl_set:N =
+ \l__siunitx_compound_separator_pair_tl ,
+ compound-open-boundary .tl_set:N =
+ \l__siunitx_compound_boundary_open_tl ,
+ compound-open-bracket .tl_set:N =
+ \l__siunitx_compound_bracket_open_tl ,
+ compound-separator .tl_set:N =
+ \l__siunitx_compound_separator_tl ,
+ compound-separator-mode .choice: ,
+ compound-separator-mode / number .code:n =
+ { \bool_set_false:N \l__siunitx_compound_separator_text_bool } ,
+ compound-separator-mode / text .code:n =
+ { \bool_set_true:N \l__siunitx_compound_separator_text_bool } ,
+ compound-units .choice: ,
+ compound-units / bracket .code:n =
+ {
+ \bool_set_true:N \l__siunitx_compound_unit_bracket_bool
+ \bool_set_false:N \l__siunitx_compound_unit_power_bool
+ \bool_set_false:N \l__siunitx_compound_unit_repeat_bool
+ } ,
+ compound-units / bracket-power .code:n =
+ {
+ \bool_set_true:N \l__siunitx_compound_unit_bracket_bool
+ \bool_set_true:N \l__siunitx_compound_unit_power_bool
+ \bool_set_false:N \l__siunitx_compound_unit_repeat_bool
+ } ,
+ compound-units / power .code:n =
+ {
+ \bool_set_false:N \l__siunitx_compound_unit_bracket_bool
+ \bool_set_true:N \l__siunitx_compound_unit_power_bool
+ \bool_set_false:N \l__siunitx_compound_unit_repeat_bool
+ } ,
+ compound-units / repeat .code:n =
+ {
+ \bool_set_false:N \l__siunitx_compound_unit_bracket_bool
+ \bool_set_false:N \l__siunitx_compound_unit_power_bool
+ \bool_set_true:N \l__siunitx_compound_unit_repeat_bool
+ } ,
+ compound-units / single .code:n =
+ {
+ \bool_set_false:N \l__siunitx_compound_unit_bracket_bool
+ \bool_set_false:N \l__siunitx_compound_unit_power_bool
+ \bool_set_false:N \l__siunitx_compound_unit_repeat_bool
+ }
+ }
+\cs_new_protected:Npn \siunitx_compound_number:n #1
+ {
+ \group_begin:
+ \bool_set_false:N \l__siunitx_compound_unit_bool
+ \__siunitx_compound_format:nn {#1} { }
+ \__siunitx_compound_print:N \siunitx_print_number:x
+ \group_end:
+ }
+\cs_new_protected:Npn \__siunitx_compound_format:nn #1#2
+ {
+ \seq_clear:N \l__siunitx_compound_tmp_seq
+ \bool_if:NTF \l_siunitx_number_parse_bool
+ {
+ \exp_args:Nxx \__siunitx_compound_format:nnn
+ { \tl_head:n {#1} }
+ { \tl_tail:n {#1} }
+ {#2}
+ }
+ { \tl_map_function:nN {#1} \__siunitx_compound_unparsed:n }
+ }
+\cs_new_protected:Npn \__siunitx_compound_format:nnn #1#2#3
+ {
+ \tl_if_blank:nTF {#1}
+ {
+ \tl_if_blank:nF {#2}
+ { \__siunitx_compound_format:nn {#2} {#3} }
+ }
+ { \__siunitx_compound_format_aux:nnn {#1} {#2} {#3} }
+ }
+\cs_new_protected:Npn \__siunitx_compound_format_aux:nnn #1#2#3
+ {
+ \siunitx_number_parse:nN {#1} \l__siunitx_compound_tmp_tl
+ \bool_if:NTF \l__siunitx_compound_unit_bool
+ { \__siunitx_compound_format_units:nn {#2} {#3} }
+ { \siunitx_number_process:NN \l__siunitx_compound_tmp_tl \l__siunitx_compound_first_tl }
+ \bool_lazy_and:nnTF
+ { \l__siunitx_compound_exp_combine_bool }
+ { \int_compare_p:nNn { \tl_count:n {#2} } > 0 }
+ { \__siunitx_compound_extract_exponents: }
+ {
+ \bool_if:NTF \l__siunitx_compound_unit_bool
+ {
+ \tl_set:Nx \l__siunitx_compound_tmp_tl
+ { \siunitx_number_output:NN \l__siunitx_compound_first_tl \q_nil }
+ \tl_set:Nx \l__siunitx_compound_tmp_tl
+ { \__siunitx_compound_uncert_bracket:N \l__siunitx_compound_tmp_tl }
+ }
+ {
+ \tl_set:Nx \l__siunitx_compound_tmp_tl
+ { \siunitx_number_output:N \l__siunitx_compound_first_tl }
+ }
+ \seq_put_right:NV \l__siunitx_compound_tmp_seq \l__siunitx_compound_tmp_tl
+ }
+ \tl_map_function:nN {#2} \__siunitx_compound_parsed:n
+ }
+\cs_new_protected:Npn \__siunitx_compound_extract_exponents:
+ {
+ \tl_set:Nx \l__siunitx_compound_tmp_tl
+ { \siunitx_number_output:NN \l__siunitx_compound_first_tl \q_nil }
+ \exp_after:wN \__siunitx_compound_extract_exponents_auxi:w
+ \l__siunitx_compound_tmp_tl \q_stop
+ }
+\cs_new_protected:Npn \__siunitx_compound_extract_exponents_auxi:w
+ #1 \q_nil #2 \q_nil #3 \q_nil #4 \q_nil #5 \q_nil #6 \q_nil #7 \q_nil #8
+ \q_nil #9 \q_stop
+ {
+ \__siunitx_compound_extract_exponents_auxii:nw {#1#2#3#4#5#6#7#8} #9 \q_stop
+ }
+\cs_new_protected:Npn \__siunitx_compound_extract_exponents_auxii:nw
+ #1#2 \q_nil #3 \q_nil #4 \q_stop
+ {
+ \seq_put_right:Nn \l__siunitx_compound_tmp_seq { #1#2 }
+ \tl_set:Nn \l__siunitx_compound_exp_tl { #3#4 }
+ \exp_after:wN \__siunitx_compound_extract_exponents_auxiii:nnnnnnn
+ \l__siunitx_compound_first_tl
+ }
+\cs_new_protected:Npn \__siunitx_compound_extract_exponents_auxiii:nnnnnnn
+ #1#2#3#4#5#6#7
+ {
+ \keys_set:nn { siunitx }
+ {
+ drop-exponent = true ,
+ exponent-mode = fixed ,
+ fixed-exponent = #6#7
+ }
+ }
+\cs_new_protected:Npn \__siunitx_compound_parsed:n #1
+ {
+ \tl_if_blank:nF {#1}
+ { \__siunitx_compound_parsed_aux:n {#1} }
+ }
+\cs_new_protected:Npn \__siunitx_compound_parsed_aux:n #1
+ {
+ \bool_if:NTF \l__siunitx_compound_unit_bool
+ {
+ \siunitx_number_parse:nN {#1} \l__siunitx_compound_tmp_tl
+ \siunitx_number_process:NN \l__siunitx_compound_tmp_tl \l__siunitx_compound_tmp_tl
+ \tl_set:Nx \l__siunitx_compound_tmp_tl
+ { \siunitx_number_output:NN \l__siunitx_compound_tmp_tl \q_nil }
+ \tl_set:Nx \l__siunitx_compound_tmp_tl
+ { \__siunitx_compound_uncert_bracket:N \l__siunitx_compound_tmp_tl }
+ }
+ { \siunitx_number_format:nN {#1} \l__siunitx_compound_tmp_tl }
+ \seq_put_right:NV \l__siunitx_compound_tmp_seq \l__siunitx_compound_tmp_tl
+ }
+\cs_new_protected:Npn \__siunitx_compound_unparsed:n #1
+ {
+ \tl_if_blank:nF {#1}
+ { \seq_put_right:Nn \l__siunitx_compound_tmp_seq { \ensuremath {#1} } }
+ }
+\cs_new_protected:Npn \__siunitx_compound_format_units:nn #1#2
+ {
+ \bool_if:NTF \l__siunitx_compound_unit_power_bool
+ {
+ \use:c { __siunitx_compound_format_ \l_siunitx_quantity_prefix_mode_tl :nn }
+ {#2} { \tl_count:n {#1} + 1 }
+ }
+ {
+ \use:c { __siunitx_compound_format_ \l_siunitx_quantity_prefix_mode_tl :n } {#2}
+ }
+ }
+\cs_new_protected:cpx { __siunitx_compound_format_combine-exponent:n } #1
+ {
+ \exp_not:c { __siunitx_compound_format_combine-exponent_aux:n }
+ {
+ \exp_not:N \siunitx_unit_format_combine_exponent:nnN
+ {#1}
+ }
+ }
+\cs_new_protected:cpx { __siunitx_compound_format_combine-exponent:nn } #1#2
+ {
+ \exp_not:c { __siunitx_compound_format_combine-exponent_aux:n }
+ {
+ \exp_not:N \siunitx_unit_format_multiply_combine_exponent:nnnN
+ {#1} {#2}
+ }
+ }
+\cs_new_protected:cpn { __siunitx_compound_format_combine-exponent_aux:n } #1
+ {
+ \bool_set_true:N \l__siunitx_compound_exp_combine_bool
+ \siunitx_number_process:NN \l__siunitx_compound_tmp_tl \l__siunitx_compound_first_tl
+ \exp_args:NV \__siunitx_compound_extract_exp:nN
+ \l__siunitx_compound_first_tl \l__siunitx_compound_tmp_fp
+ #1 \l__siunitx_compound_tmp_fp \l__siunitx_compound_unit_tl
+ }
+\cs_new_protected:cpx { __siunitx_compound_format_extract-exponent:n } #1
+ {
+ \exp_not:c { __siunitx_compound_format_extract-exponent_aux:n }
+ { \exp_not:N \siunitx_unit_format_extract_prefixes:nNN {#1} }
+ }
+\cs_new_protected:cpx { __siunitx_compound_format_extract-exponent:nn } #1#2
+ {
+ \exp_not:c { __siunitx_compound_format_extract-exponent_aux:n }
+ {
+ \exp_not:N \siunitx_unit_format_multiply_extract_prefixes:nnNN
+ {#1} {#2}
+ }
+ }
+\cs_new_protected:cpn { __siunitx_compound_format_extract-exponent_aux:n } #1
+ {
+ #1 \l__siunitx_compound_unit_tl \l__siunitx_compound_tmp_fp
+ \tl_set:Nx \l__siunitx_compound_tmp_tl
+ { \siunitx_number_adjust_exponent:Nn \l__siunitx_compound_tmp_tl \l__siunitx_compound_tmp_fp }
+ \siunitx_number_process:NN \l__siunitx_compound_tmp_tl \l__siunitx_compound_first_tl
+ \bool_set_true:N \l__siunitx_compound_exp_combine_bool
+ }
+\cs_new_protected:Npn \__siunitx_compound_format_input:n #1
+ {
+ \siunitx_number_process:NN \l__siunitx_compound_tmp_tl \l__siunitx_compound_first_tl
+ \siunitx_unit_format:nN {#1} \l__siunitx_compound_unit_tl
+ }
+\cs_new_protected:Npn \__siunitx_compound_format_input:nn #1#2
+ {
+ \siunitx_number_process:NN \l__siunitx_compound_tmp_tl \l__siunitx_compound_first_tl
+ \siunitx_unit_format_multiply:nnN {#1} {#2} \l__siunitx_compound_unit_tl
+ }
+\cs_new_protected:Npn \__siunitx_compound_extract_exp:nN #1#2
+ { \__siunitx_compound_extract_exp:nnnnnnnN #1 #2 }
+\cs_new_protected:Npn \__siunitx_compound_extract_exp:nnnnnnnN #1#2#3#4#5#6#7#8
+ { \fp_set:Nn #8 {#6#7} }
+\cs_new_protected:Npn \siunitx_compound_quantity:nn #1#2
+ {
+ \group_begin:
+ \bool_lazy_all:nTF
+ {
+ { \l__siunitx_compound_independent_bool }
+ {
+ \str_if_eq_p:Vn
+ \l_siunitx_quantity_prefix_mode_tl
+ { combine-exponent }
+ }
+ { \int_compare_p:nNn { \tl_count:n {#1} } > 1 }
+ }
+ { \__siunitx_compound_quantity_auxi:nn }
+ { \__siunitx_compound_quantity_auxii:nn }
+ {#1} {#2}
+ \group_end:
+ }
+\cs_new_protected:Npn \__siunitx_compound_quantity_auxi:nn #1#2
+ {
+ \__siunitx_compound_print_boundary:V \l__siunitx_compound_boundary_close_tl
+ \seq_clear:N \l__siunitx_compound_tmp_seq
+ \tl_map_inline:nn {#1}
+ {
+ \seq_put_right:Nn \l__siunitx_compound_tmp_seq
+ { \siunitx_quantity:nn {##1} {#2} }
+ }
+ \seq_use:NVVV \l__siunitx_compound_tmp_seq
+ \l__siunitx_compound_separator_pair_tl
+ \l__siunitx_compound_separator_tl
+ \l__siunitx_compound_separator_final_tl
+ \__siunitx_compound_print_boundary:V \l__siunitx_compound_boundary_close_tl
+ }
+\cs_new_protected:Npn \__siunitx_compound_quantity_auxii:nn #1#2
+ {
+ \bool_if:NT \l__siunitx_compound_unit_bracket_bool
+ { \bool_set_true:N \l__siunitx_compound_exp_bracket_bool }
+ \bool_if:NT \l__siunitx_compound_unit_repeat_bool
+ { \bool_set_false:N \l__siunitx_compound_exp_combine_bool }
+ \bool_lazy_or:nnT
+ { \l__siunitx_compound_unit_bracket_bool }
+ { ! \l__siunitx_compound_unit_repeat_bool }
+ { \bool_set_false:N \l_siunitx_number_bracket_ambiguous_bool }
+ \bool_set_true:N \l__siunitx_compound_unit_bool
+ \__siunitx_compound_format:nn {#1} {#2}
+ \bool_if:NF \l_siunitx_number_parse_bool
+ { \siunitx_unit_format:nN {#2} \l__siunitx_compound_unit_tl }
+ \str_if_eq:VnT \l_siunitx_quantity_prefix_mode_tl { combine-exponent }
+ { \tl_clear:N \l__siunitx_compound_exp_tl }
+ \bool_if:NTF \l__siunitx_compound_unit_repeat_bool
+ { \__siunitx_compound_print:N \__siunitx_compound_print_quantity:x }
+ {
+ \bool_lazy_and:nnTF
+ { \l__siunitx_compound_unit_bracket_bool }
+ { \tl_if_empty_p:N \l__siunitx_compound_exp_tl }
+ {
+ \siunitx_print_number:V \l__siunitx_compound_bracket_open_tl
+ \__siunitx_compound_print:N \siunitx_print_number:x
+ \siunitx_print_number:V \l__siunitx_compound_bracket_close_tl
+ }
+ { \__siunitx_compound_print:N \siunitx_print_number:x }
+ \__siunitx_compound_print_quantity:n { \c_empty_tl }
+ }
+ }
+\cs_new_protected:Npn \__siunitx_compound_print:N #1
+ {
+ \bool_lazy_and:nnTF
+ { \l__siunitx_compound_exp_bracket_bool }
+ { ! \tl_if_empty_p:N \l__siunitx_compound_exp_tl }
+ {
+ \__siunitx_compound_print:xxN
+ { \exp_not:V \l__siunitx_compound_bracket_open_tl }
+ {
+ \exp_not:V \l__siunitx_compound_bracket_close_tl
+ \exp_not:V \l__siunitx_compound_exp_tl
+ }
+ #1
+ }
+ { \__siunitx_compound_print:xxN { } { \exp_not:V \l__siunitx_compound_exp_tl } #1 }
+ }
+\cs_new_protected:Npn \__siunitx_compound_print:nnN #1#2#3
+ {
+ \exp_args:Nx \__siunitx_compound_print:nnnN
+ { \seq_count:N \l__siunitx_compound_tmp_seq } {#1} {#2} #3
+ }
+\cs_generate_variant:Nn \__siunitx_compound_print:nnN { xx }
+\cs_new_protected:Npn \__siunitx_compound_print:nnnN #1#2#3#4
+ {
+ \int_case:nnF {#1}
+ {
+ { 0 } { }
+ { 1 }
+ {
+ #4
+ { \seq_item:Nn \l__siunitx_compound_tmp_seq { 1 } }
+ }
+ { 2 }
+ {
+ \__siunitx_compound_print_boundary:V \l__siunitx_compound_boundary_open_tl
+ #4
+ {
+ \exp_not:n {#2}
+ \seq_item:Nn \l__siunitx_compound_tmp_seq { 1 }
+ }
+ \__siunitx_compound_print_separator:V \l__siunitx_compound_separator_pair_tl
+ #4
+ {
+ \seq_item:Nn \l__siunitx_compound_tmp_seq { 2 }
+ \exp_not:n {#3}
+ }
+ \__siunitx_compound_print_boundary:V \l__siunitx_compound_boundary_open_tl
+ }
+ }
+ {
+ \int_set:Nn \l__siunitx_compound_count_int {#1}
+ \tl_set:Nn \l__siunitx_compound_start_tl {#2}
+ \tl_set:Nn \l__siunitx_compound_end_tl {#3}
+ \cs_set_eq:NN \__siunitx_compound_print_aux:n #4
+ \__siunitx_compound_print_boundary:V \l__siunitx_compound_boundary_open_tl
+ \seq_map_indexed_function:NN
+ \l__siunitx_compound_tmp_seq
+ \__siunitx_compound_print_aux:nn
+ \__siunitx_compound_print_boundary:V \l__siunitx_compound_boundary_close_tl
+ }
+ }
+\cs_new_protected:Npn \__siunitx_compound_print_aux:n #1 { }
+\cs_new_protected:Npn \__siunitx_compound_print_aux:nn #1#2
+ {
+ \int_case:nnF {#1}
+ {
+ { 1 }
+ {
+ \__siunitx_compound_print_aux:n
+ {
+ \exp_not:V \l__siunitx_compound_start_tl
+ \exp_not:n {#2}
+ }
+ \__siunitx_compound_print_separator:V \l__siunitx_compound_separator_tl
+ }
+ { \l__siunitx_compound_count_int - 1 }
+ {
+ \__siunitx_compound_print_aux:n { \exp_not:n {#2} }
+ \__siunitx_compound_print_separator:V \l__siunitx_compound_separator_final_tl
+ }
+ { \l__siunitx_compound_count_int }
+ {
+ \__siunitx_compound_print_aux:n
+ {
+ \exp_not:n {#2}
+ \exp_not:V \l__siunitx_compound_end_tl
+ }
+ }
+ }
+ {
+ \__siunitx_compound_print_aux:n { \exp_not:n {#2} }
+ \__siunitx_compound_print_separator:V \l__siunitx_compound_separator_tl
+ }
+ }
+\cs_new_protected:Npn \__siunitx_compound_print_quantity:n #1
+ { \siunitx_quantity_print:nV {#1} \l__siunitx_compound_unit_tl }
+\cs_generate_variant:Nn \__siunitx_compound_print_quantity:n { x }
+\cs_new_protected:Npn \__siunitx_compound_print_boundary:n #1
+ {
+ \tl_if_blank:nF {#1}
+ {
+ \bool_if:NTF \l__siunitx_compound_boundary_text_bool
+ { #1 }
+ { \siunitx_print_number:n {#1} }
+ }
+ }
+\cs_generate_variant:Nn \__siunitx_compound_print_boundary:n { V }
+\cs_new_protected:Npn \__siunitx_compound_print_separator:n #1
+ {
+ \bool_if:NTF \l__siunitx_compound_separator_text_bool
+ { #1 }
+ { \siunitx_print_number:n {#1} }
+ }
+\cs_generate_variant:Nn \__siunitx_compound_print_separator:n { V }
+\cs_new:Npn \__siunitx_compound_uncert_bracket:N #1
+ { \exp_after:wN \__siunitx_compound_uncert_bracket:w #1 \q_stop }
+\cs_new:Npn \__siunitx_compound_uncert_bracket:w
+ #1 \q_nil #2 \q_nil #3 \q_nil #4 \q_nil #5 \q_nil #6 \q_nil #7 \q_nil
+ #8 \q_nil #9 \q_stop
+ { \__siunitx_compound_uncert_bracket:nnw {#1#2#3#4#5#6} {#7#8} #9 \q_stop }
+\cs_new:Npn \__siunitx_compound_uncert_bracket:nnw #1#2 #3 \q_nil #4 \q_nil #5 \q_stop
+ {
+ \bool_lazy_or:nnTF
+ { \tl_if_blank_p:n {#2#3} }
+ { ! \tl_if_blank_p:n {#5} }
+ { \exp_not:n {#1#2#3#4#5} }
+ {
+ \exp_not:V \l__siunitx_compound_bracket_open_tl
+ \exp_not:n {#1#2#3}
+ \exp_not:V \l__siunitx_compound_bracket_close_tl
+ \exp_not:n {#4#5}
+ }
+ }
+\tl_new:N \l__siunitx_list_exp_tl
+\tl_new:N \l__siunitx_list_units_tl
+\keys_define:nn { siunitx }
+ {
+ list-close-bracket .tl_set:N =
+ \l__siunitx_list_bracket_close_tl ,
+ list-exponents .choices:nn =
+ { combine , combine-bracket , individual }
+ { \tl_set_eq:NN \l__siunitx_list_exp_tl \l_keys_choice_tl } ,
+ list-final-separator .tl_set:N = \l_siunitx_list_separator_final_tl ,
+ list-independent-prefix .bool_set:N =
+ \l__siunitx_list_independent_bool ,
+ list-open-bracket .tl_set:N =
+ \l__siunitx_list_bracket_open_tl ,
+ list-pair-separator .tl_set:N = \l_siunitx_list_separator_pair_tl ,
+ list-separator .tl_set:N = \l_siunitx_list_separator_tl ,
+ list-units .choices:nn =
+ { bracket , independent , repeat , single }
+ { \tl_set_eq:NN \l__siunitx_list_units_tl \l_keys_choice_tl }
+ }
+\cs_new_protected:Npn \siunitx_number_list:nn #1
+ {
+ \group_begin:
+ \__siunitx_list_aux:
+ \siunitx_compound_number:n {#1}
+ \group_end:
+ }
+\cs_new_protected:Npn \siunitx_quantity_list:nn #1#2
+ {
+ \group_begin:
+ \__siunitx_list_aux:
+ \siunitx_compound_quantity:nn {#1} {#2}
+ \group_end:
+ }
+\cs_new_protected:Npn \__siunitx_list_aux:
+ {
+ \keys_set:nx { siunitx }
+ {
+ compound-close-bracket =
+ { \exp_not:V \l__siunitx_list_bracket_close_tl } ,
+ compound-close-boundary = ,
+ compound-exponents = \l__siunitx_list_exp_tl ,
+ compound-final-separator =
+ { \exp_not:V \l_siunitx_list_separator_final_tl } ,
+ compound-independent-prefix =
+ \bool_if:NTF \l__siunitx_list_independent_bool { true } { false } ,
+ compound-open-boundary = ,
+ compound-open-bracket =
+ { \exp_not:V \l__siunitx_list_bracket_open_tl } ,
+ compound-pair-separator =
+ { \exp_not:V \l_siunitx_list_separator_pair_tl } ,
+ compound-separator =
+ { \exp_not:V \l_siunitx_list_separator_tl } ,
+ compound-separator-mode = text ,
+ compound-units = \l__siunitx_list_units_tl
+ }
+ }
+\tl_new:N \l__siunitx_product_exp_tl
+\bool_new:N \l__siunitx_product_phrase_bool
+\tl_new:N \l__siunitx_product_units_tl
+\keys_define:nn { siunitx }
+ {
+ product-close-bracket .tl_set:N =
+ \l__siunitx_product_bracket_close_tl ,
+ product-exponents .choices:nn =
+ { combine , combine-bracket , individual }
+ { \tl_set_eq:NN \l__siunitx_product_exp_tl \l_keys_choice_tl } ,
+ product-independent-prefix .bool_set:N =
+ \l__siunitx_product_independent_bool ,
+ product-mode .choice: ,
+ product-mode / phrase .code:n =
+ { \bool_set_true:N \l__siunitx_product_phrase_bool } ,
+ product-mode / symbol .code:n =
+ { \bool_set_false:N \l__siunitx_product_phrase_bool } ,
+ product-open-bracket .tl_set:N =
+ \l__siunitx_product_bracket_open_tl ,
+ product-phrase .tl_set:N = \l__siunitx_product_phrase_tl ,
+ product-symbol .tl_set:N = \l__siunitx_product_symbol_tl ,
+ product-units .choices:nn =
+ { bracket , bracket-power , independent , power , repeat , single }
+ { \tl_set_eq:NN \l__siunitx_product_units_tl \l_keys_choice_tl }
+ }
+\cs_new_protected:Npn \siunitx_number_product:n #1
+ {
+ \group_begin:
+ \__siunitx_product_aux:
+ \siunitx_compound_number:n {#1}
+ \group_end:
+ }
+\cs_new_protected:Npn \siunitx_quantity_product:nn #1#2
+ {
+ \group_begin:
+ \__siunitx_product_aux:
+ \siunitx_compound_quantity:nn {#1} {#2}
+ \group_end:
+ }
+\cs_new_protected:Npn \__siunitx_product_aux:
+ {
+ \bool_if:NTF \l__siunitx_product_phrase_bool
+ { \__siunitx_product_aux:x { \exp_not:V \l__siunitx_product_phrase_tl } }
+ { \__siunitx_product_aux:x { { } \exp_not:V \l__siunitx_product_symbol_tl { } } }
+ }
+\cs_new_protected:Npn \__siunitx_product_aux:n #1
+ {
+ \keys_set:nx { siunitx }
+ {
+ compound-close-boundary = ,
+ compound-close-bracket =
+ { \exp_not:V \l__siunitx_product_bracket_close_tl } ,
+ compound-exponents = \l__siunitx_product_exp_tl ,
+ compound-final-separator = { \exp_not:n {#1} } ,
+ compound-independent-prefix =
+ \bool_if:NTF \l__siunitx_product_independent_bool { true } { false } ,
+ compound-open-boundary = ,
+ compound-open-bracket =
+ { \exp_not:V \l__siunitx_product_bracket_open_tl } ,
+ compound-pair-separator = { \exp_not:n {#1} } ,
+ compound-separator = { \exp_not:n {#1} } ,
+ compound-separator-mode =
+ \bool_if:NTF \l__siunitx_product_phrase_bool { text } { number } ,
+ compound-units = \l__siunitx_product_units_tl
+ }
+ }
+\cs_generate_variant:Nn \__siunitx_product_aux:n { x }
+\tl_new:N \l__siunitx_range_exp_tl
+\tl_new:N \l__siunitx_range_units_tl
+\keys_define:nn { siunitx }
+ {
+ range-close-bracket .tl_set:N =
+ \l__siunitx_range_bracket_close_tl ,
+ range-exponents .choices:nn =
+ { combine , combine-bracket , individual }
+ { \tl_set_eq:NN \l__siunitx_range_exp_tl \l_keys_choice_tl } ,
+ range-independent-prefix .bool_set:N =
+ \l__siunitx_range_independent_bool ,
+ range-open-bracket .tl_set:N =
+ \l__siunitx_range_bracket_open_tl ,
+ range-open-phrase .tl_set:N = \l__siunitx_range_open_tl ,
+ range-phrase .tl_set:N = \l_siunitx_range_phrase_tl ,
+ range-units .choices:nn =
+ { bracket , independent , repeat , single }
+ { \tl_set_eq:NN \l__siunitx_range_units_tl \l_keys_choice_tl }
+ }
+\cs_new_protected:Npn \siunitx_number_range:nn #1#2
+ {
+ \group_begin:
+ \__siunitx_range_aux:
+ \siunitx_compound_number:n { {#1} {#2} }
+ \group_end:
+ }
+\cs_new_protected:Npn \siunitx_quantity_range:nnn #1#2#3
+ {
+ \group_begin:
+ \__siunitx_range_aux:
+ \siunitx_compound_quantity:nn { {#1} {#2} } {#3}
+ \group_end:
+ }
+\cs_new_protected:Npn \__siunitx_range_aux:
+ {
+ \keys_set:nx { siunitx }
+ {
+ compound-boundary-mode = text ,
+ compound-close-boundary = ,
+ compound-close-bracket =
+ { \exp_not:V \l__siunitx_range_bracket_close_tl } ,
+ compound-exponents = \l__siunitx_range_exp_tl ,
+ compound-independent-prefix =
+ \bool_if:NTF \l__siunitx_range_independent_bool { true } { false } ,
+ compound-open-boundary = { \exp_not:V \l__siunitx_range_open_tl } ,
+ compound-open-bracket =
+ { \exp_not:V \l__siunitx_range_bracket_open_tl } ,
+ compound-pair-separator =
+ { \exp_not:V \l_siunitx_range_phrase_tl } ,
+ compound-separator-mode = text ,
+ compound-units = \l__siunitx_range_units_tl
+ }
+ }
+\keys_set:nn { siunitx }
+ {
+ compound-boundary-mode = text ,
+ compound-close-boundary = , % (
+ compound-close-bracket = ) ,
+ compound-exponents = individual ,
+ compound-final-separator =
+ {
+ \ifmmode \ \else \space \fi
+ \text { and }
+ \ifmmode \ \else \space \fi
+ } ,
+ compound-independent-prefix = false ,
+ compound-open-boundary = ,
+ compound-open-bracket = ( , % )
+ compound-pair-separator =
+ {
+ \ifmmode \ \else \space \fi
+ \text { and }
+ \ifmmode \ \else \space \fi
+ } ,
+ compound-separator =
+ { , \ifmmode \ \else \space \fi } ,
+ compound-separator-mode = text ,
+ compound-units = repeat , % (
+ list-close-bracket = ) ,
+ list-exponents = individual ,
+ list-final-separator =
+ {
+ \ifmmode \ \else \space \fi
+ \text { and }
+ \ifmmode \ \else \space \fi
+ } ,
+ list-independent-prefix = false ,
+ list-open-bracket = ( , % )
+ list-pair-separator =
+ {
+ \ifmmode \ \else \space \fi
+ \text { and }
+ \ifmmode \ \else \space \fi
+ } ,
+ list-separator =
+ { , \ifmmode \ \else \space \fi } ,
+ list-units = repeat , % (
+ product-close-bracket = ) ,
+ product-exponents = individual ,
+ product-independent-prefix = false ,
+ product-mode = symbol ,
+ product-open-bracket = ( , % )
+ product-phrase =
+ {
+ \ifmmode \ \else \space \fi
+ \text { by }
+ \ifmmode \ \else \space \fi
+ } ,
+ product-symbol = \times ,
+ product-units = repeat , % (
+ range-close-bracket = ) ,
+ range-exponents = individual ,
+ range-independent-prefix = false ,
+ range-open-bracket = ( , % )
+ range-open-phrase = ,
+ range-phrase =
+ {
+ \ifmmode \ \else \space \fi
+ \text { to }
+ \ifmmode \ \else \space \fi
+ } ,
+ range-units = repeat
+ }
+\keys_define:nn { siunitx }
+ {
+ locale .choice: ,
+ locale / DE .meta:n =
+ {
+ exponent-product = \cdot ,
+ inter-unit-product = \, ,
+ output-decimal-marker = { , }
+ } ,
+ locale / FR .meta:n =
+ {
+ exponent-product = \times ,
+ inter-unit-product = \, ,
+ output-decimal-marker = { , }
+ } ,
+ locale / IT .meta:n =
+ {
+ exponent-product = \times ,
+ inter-unit-product = \, ,
+ output-decimal-marker = { , }
+ } ,
+ locale / PL .meta:n =
+ {
+ exponent-product = \cdot ,
+ inter-unit-product = \cdot ,
+ output-decimal-marker = { , }
+ } ,
+ locale / SI .meta:n =
+ {
+ exponent-product = \times ,
+ inter-unit-product = \, ,
+ output-decimal-marker = { , }
+ } ,
+ locale / UK .meta:n =
+ {
+ exponent-product = \times ,
+ inter-unit-product = \, ,
+ output-decimal-marker = .
+ },
+ locale / US .meta:n =
+ {
+ exponent-product = \times ,
+ inter-unit-product = \, ,
+ output-decimal-marker = .
+ } ,
+ locale / ZA .meta:n =
+ {
+ exponent-product = \times ,
+ inter-unit-product = \cdot ,
+ output-decimal-marker = { , }
+ }
+ }
+\file_if_exist:nT { translations.sty }
+ {
+ \RequirePackage { translations }
+ \DeclareTranslation { Catalan } { and } { i }
+ \DeclareTranslation { Italian } { and } { e }
+ \DeclareTranslation { Portuguese } { and } { e }
+ \DeclareTranslation { Slovene } { and } { in }
+ \DeclareTranslation { Brazilian } { to~(numerical~range) } { a }
+ \DeclareTranslation { Catalan } { to~(numerical~range) } { a }
+ \DeclareTranslation { English } { to~(numerical~range) } { to }
+ \DeclareTranslation { French } { to~(numerical~range) } { à }
+ \DeclareTranslation { German } { to~(numerical~range) } { bis }
+ \DeclareTranslation { Italian } { to~(numerical~range) } { a }
+ \DeclareTranslation { Polish } { to~(numerical~range) } { do }
+ \DeclareTranslation { Portuguese } { to~(numerical~range) } { a }
+ \DeclareTranslation { Slovene } { to~(numerical~range) } { do }
+ \DeclareTranslation { Spanish } { to~(numerical~range) } { a }
+ \keys_set:nn { siunitx }
+ {
+ list-final-separator =
+ {
+ \ifmmode \ \else \space \fi
+ \text { \GetTranslation { and } }
+ \ifmmode \ \else \space \fi
+ } ,
+ list-pair-separator =
+ {
+ \ifmmode \ \else \space \fi
+ \text { \GetTranslation { and } }
+ \ifmmode \ \else \space \fi
+ } ,
+ range-phrase =
+ {
+ \ifmmode \ \else \space \fi
+ \text { \GetTranslation { to~(numerical~range) } }
+ \ifmmode \ \else \space \fi
+ }
+ }
+ }
\RequirePackage { amstext }
\cs_new_eq:NN \__siunitx_print_ams_text:n \text
\AtBeginDocument { \RequirePackage { color } }
@@ -5306,6 +5544,8 @@
\exp_args:NV \__siunitx_table_generate_model:n \l__siunitx_table_model_tl
\tl_set:Nn \l__siunitx_table_align_mode_tl { format }
} ,
+ table-model-setup .tl_set:N =
+ \l__siunitx_table_model_setup_tl ,
table-number-alignment .choices:nn =
{ center , left , right }
{ \tl_set_eq:NN \l__siunitx_table_align_number_tl \l_keys_choice_tl }
@@ -5620,7 +5860,7 @@
#1 \q_nil #2 \q_mark #3 \q_nil #4 \q_stop
{
\__siunitx_table_color_check:w #3 \q_nil \q_stop
- \__siunitx_table_print_format_box:Nn \l__siunitx_table_tmp_box {#1}
+ \__siunitx_table_print_model_box:Nn \l__siunitx_table_tmp_box {#1}
\bool_if:NTF \l__siunitx_table_align_before_bool
{
\hbox_set_to_wd:Nnn \l__siunitx_table_integer_box
@@ -5644,7 +5884,7 @@
\cs_new_protected:Npn \__siunitx_table_print_format_auxii:w
#1 \q_nil #2 \q_nil #3 \q_mark #4 \q_nil #5 \q_nil #6 \q_stop
{
- \__siunitx_table_print_format_box:Nn \l__siunitx_table_tmp_box {#1#2}
+ \__siunitx_table_print_model_box:Nn \l__siunitx_table_tmp_box {#1#2}
\dim_set:Nn \l__siunitx_table_tmp_dim { \box_wd:N \l__siunitx_table_tmp_box }
\__siunitx_table_print_format_box:Nn \l__siunitx_table_tmp_box {#4#5}
\dim_compare:nNnT { \box_wd:N \l__siunitx_table_tmp_box } > \l__siunitx_table_tmp_dim
@@ -5704,13 +5944,13 @@
\__siunitx_table_fil:
\hbox_unpack:N \l__siunitx_table_before_box
}
- \__siunitx_table_print_format_auxiii:w #3 \q_mark #6 \q_stop
+ \__siunitx_table_print_format_auxiii:w ? #3 \q_mark ? #6 \q_stop
}
\cs_new_protected:Npn \__siunitx_table_print_format_auxiii:w
#1 \q_nil #2 \q_nil #3 \q_mark #4 \q_nil #5 \q_nil #6 \q_stop
{
- \__siunitx_table_print_format_box:Nn \l__siunitx_table_tmp_box {#1#2}
- \__siunitx_table_print_format_box:Nn \l__siunitx_table_decimal_box {#4#5}
+ \__siunitx_table_print_model_box:No \l__siunitx_table_tmp_box { \use_none:n #1#2 }
+ \__siunitx_table_print_format_box:No \l__siunitx_table_decimal_box { \use_none:n #4#5 }
\dim_set:Nn \l__siunitx_table_carry_dim
{
\box_wd:N \l__siunitx_table_tmp_box
@@ -5763,7 +6003,7 @@
#1 \q_nil #2 \q_nil #3 \q_mark
#4 \q_nil #5 \q_nil #6 \q_stop
{
- \__siunitx_table_print_format_box:Nn \l__siunitx_table_tmp_box {#1#2}
+ \__siunitx_table_print_model_box:Nn \l__siunitx_table_tmp_box {#1#2}
\hbox_set_to_wd:Nnn \l__siunitx_table_tmp_box
{
\box_wd:N \l__siunitx_table_uncert_box
@@ -5789,7 +6029,7 @@
#1 \q_nil #2 \q_mark
#3 \q_nil #4 \q_stop
{
- \__siunitx_table_print_format_box:Nn \l__siunitx_table_tmp_box { { } #1 }
+ \__siunitx_table_print_model_box:Nn \l__siunitx_table_tmp_box { { } #1 }
\dim_set:Nn \l__siunitx_table_tmp_dim { \box_wd:N \l__siunitx_table_tmp_box }
\__siunitx_table_print_format_box:Nn \l__siunitx_table_tmp_box { { } #3 }
\__siunitx_table_print_format_auxxii:w #2 \q_mark #4 \q_stop
@@ -5805,7 +6045,7 @@
{
\tl_if_blank:nF {#2}
{
- \__siunitx_table_print_format_box:Nn \l__siunitx_table_tmp_box { { } #1#2 }
+ \__siunitx_table_print_model_box:Nn \l__siunitx_table_tmp_box { { } #1#2 }
\dim_set:Nn \l__siunitx_table_tmp_dim { \box_wd:N \l__siunitx_table_tmp_box }
\__siunitx_table_print_format_box:Nn \l__siunitx_table_tmp_box
{
@@ -5813,7 +6053,7 @@
{ \l__siunitx_table_align_exponent_bool }
{ \tl_if_blank_p:n {#3} }
{
- \__siunitx_table_print_format_box:Nn \l__siunitx_table_tmp_box { { } #1 { } }
+ \__siunitx_table_print_model_box:Nn \l__siunitx_table_tmp_box { { } #1 { } }
\__siunitx_table_skip:n { \box_wd:N \l__siunitx_table_tmp_box }
}
{ } #3#4
@@ -5822,13 +6062,23 @@
}
}
\cs_new_protected:Npn \__siunitx_table_print_format_box:Nn #1#2
+ { \__siunitx_table_print_format_box:nNn { } #1 {#2} }
+\cs_generate_variant:Nn \__siunitx_table_print_format_box:Nn { No }
+\cs_new_protected:Npn \__siunitx_table_print_model_box:Nn #1#2
+ { \__siunitx_table_print_format_box:VNn \l__siunitx_table_model_setup_tl #1 {#2} }
+\cs_generate_variant:Nn \__siunitx_table_print_model_box:Nn { No }
+\cs_new_protected:Npn \__siunitx_table_print_format_box:nNn #1#2#3
{
- \hbox_set:Nn #1
+ \hbox_set:Nn #2
{
- \tl_if_blank:nF {#2}
- { \siunitx_print_number:n {#2} }
+ \tl_if_blank:nF {#3}
+ {
+ #1
+ \siunitx_print_number:n {#3}
+ }
}
}
+\cs_generate_variant:Nn \__siunitx_table_print_format_box:nNn { V }
\cs_new_protected:Npn \__siunitx_table_print_format_after:N #1
{
\bool_if:NTF #1
@@ -7559,6 +7809,9 @@
\siunitx_declare_unit:Nn \nC { \nano \coulomb }
\siunitx_declare_unit:Nn \uC { \micro \coulomb }
\siunitx_declare_unit:Nn \mC { \milli \coulomb }
+\siunitx_declare_unit:Nn \T { \tesla }
+\siunitx_declare_unit:Nn \uT { \micro \tesla }
+\siunitx_declare_unit:Nn \mT { \milli \tesla }
\siunitx_declare_unit:Nn \N { \newton }
\siunitx_declare_unit:Nn \mN { \milli \newton }
\siunitx_declare_unit:Nn \kN { \kilo \newton }
@@ -8333,12 +8586,18 @@
}
\keys_define:nn { siunitx }
{
+ list-input-separator .tl_set:N =
+ \l__siunitx_list_tl ,
+ product-input-separator .tl_set:N =
+ \l__siunitx_product_tl ,
table-column-type .tl_set:N =
\l__siunitx_column_type_tl
}
\keys_set:nn { siunitx }
{
- table-column-type = S
+ list-input-separator = ; ,
+ product-input-separator = x ,
+ table-column-type = S
}
\msg_new:nnn { siunitx } { option-deprecated }
{
@@ -8360,7 +8619,11 @@
}
\IfFormatAtLeastTF { 2020-10-01 }
{ }
- { \RequirePackage { xparse } }
+ {
+ \RequirePackage { xparse }
+ \providecommand \ExpandArgs [1]
+ { \cs_if_exist_use:c { exp_args:N #1 } }
+ }
\NewDocumentCommand \DeclareSIPower { +m +m m }
{
\siunitx_declare_power:NNn #1 #2 {#3}
@@ -8444,8 +8707,12 @@
\siunitx_print_unit:V \l__siunitx_tmp_tl
\group_end:
}
-\NewDocumentCommand \qtylist
- { O { } > { \SplitList { ; } } m > { \TrimSpaces } m }
+\ExpandArgs { Ne } \NewDocumentCommand \qtylist
+ {
+ O { }
+ > { \SplitList { \exp_not:V \l__siunitx_list_tl } } m
+ > { \TrimSpaces } m
+ }
{
\mode_leave_vertical:
\group_begin:
@@ -8454,7 +8721,11 @@
\siunitx_quantity_list:nn {#2} {#3}
\group_end:
}
-\NewDocumentCommand \numlist { O { } > { \SplitList { ; } } m }
+\ExpandArgs { Ne } \NewDocumentCommand \numlist
+ {
+ O { }
+ > { \SplitList { \exp_not:V \l__siunitx_list_tl } } m
+ }
{
\mode_leave_vertical:
\group_begin:
@@ -8462,8 +8733,12 @@
\siunitx_number_list:nn {#2}
\group_end:
}
-\NewDocumentCommand \qtyproduct
- { O { } > { \SplitList { x } } m > { \TrimSpaces } m }
+\ExpandArgs { Ne } \NewDocumentCommand \qtyproduct
+ {
+ O { }
+ > { \SplitList { \exp_not:V \l__siunitx_product_tl } } m
+ > { \TrimSpaces } m
+ }
{
\mode_leave_vertical:
\group_begin:
@@ -8472,8 +8747,11 @@
\siunitx_quantity_product:nn {#2} {#3}
\group_end:
}
-\NewDocumentCommand \numproduct
- { O { } > { \SplitList { x } } > { \TrimSpaces } m }
+\ExpandArgs { Ne } \NewDocumentCommand \numproduct
+ {
+ O { }
+ > { \SplitList { \exp_not:V \l__siunitx_product_tl } } m
+ }
{
\mode_leave_vertical:
\group_begin:
@@ -8498,11 +8776,8 @@
\siunitx_number_range:nn {#2} {#3}
\group_end:
}
-\use:e
- {
- \NewDocumentCommand \exp_not:N \complexnum
- { O { } > { \SplitArgument { 1 } { \c_colon_str } } m }
- }
+\ExpandArgs { Ne } \NewDocumentCommand \complexnum
+ { O { } > { \SplitArgument { 1 } { \c_colon_str } } m }
{
\mode_leave_vertical:
\group_begin:
@@ -8510,11 +8785,8 @@
\__siunitx_complex_number_aux:nn #2
\group_end:
}
-\use:e
- {
- \NewDocumentCommand \exp_not:N \complexqty
- { O { } > { \SplitArgument { 1 } { \c_colon_str } } m m }
- }
+\ExpandArgs { Ne } \NewDocumentCommand \complexqty
+ { O { } > { \SplitArgument { 1 } { \c_colon_str } } m m }
{
\mode_leave_vertical:
\group_begin: