diff options
Diffstat (limited to 'Master/texmf-dist/source')
10 files changed, 414 insertions, 273 deletions
diff --git a/Master/texmf-dist/source/latex/siunitx/siunitx-angle.dtx b/Master/texmf-dist/source/latex/siunitx/siunitx-angle.dtx index da61a09fece..5489fbfec39 100644 --- a/Master/texmf-dist/source/latex/siunitx/siunitx-angle.dtx +++ b/Master/texmf-dist/source/latex/siunitx/siunitx-angle.dtx @@ -62,7 +62,11 @@ % % \section{Formatting angles} % -% \begin{function}{\siunitx_angle:n, \siunitx_angle:nnn} +% \begin{function} +% { +% \siunitx_angle:n, \siunitx_angle:x, +% \siunitx_angle:nnn, \siunitx_angle:xxx +% } % \begin{syntax} % \cs{siunitx_angle:n} \Arg{angle} % \cs{siunitx_angle:nnn} \Arg{degrees} \Arg{minutes} \Arg{seconds} @@ -236,9 +240,9 @@ % \end{macrocode} % \end{variable} % -% \begin{macro}{\siunitx_angle:n, \@@_angle:n} -% \begin{macro}{\siunitx_angle:nnn} -% \begin{macro}{\@@_arc_convert:n} +% \begin{macro}{\siunitx_angle:n, \siunitx_angle:x, \@@_angle:n} +% \begin{macro}{\siunitx_angle:nnn, \siunitx_angle:xxx} +% \begin{macro}{\@@_arc_convert:n, \@@_arc_convert:x} % The first step here is to force format conversion if required. Going to % a decimal is easy, going to arc format is a bit more painful: avoid % repeating calculations mainly for code readability. @@ -258,10 +262,11 @@ } } } +\cs_generate_variant:Nn \siunitx_angle:n { x } \cs_new_protected:Npn \@@_angle:n #1 { \bool_if:NTF \l_@@_force_arc_bool - { \exp_args:Ne \@@_arc_convert:n { \fp_eval:n {#1} } } + { \@@_arc_convert:x { \fp_eval:n {#1} } } { \siunitx_number_parse:nN {#1} \l_@@_degrees_tl \siunitx_number_process:NN \l_@@_degrees_tl \l_@@_degrees_tl @@ -279,7 +284,7 @@ { \bool_if:NTF \l_@@_force_decimal_bool { - \exp_args:Ne \siunitx_angle:n + \siunitx_angle:x { \fp_eval:n { #1 + (#2) / 60 + (#3) / 3600 } } } { \@@_arc_sign:nnn {#1} {#2} {#3} } @@ -297,25 +302,24 @@ \l_@@_seconds_tl } } +\cs_generate_variant:Nn \siunitx_angle:nnn { xxx } \cs_new_protected:Npn \@@_arc_convert:n #1 { - \use:x + \siunitx_angle:xxx + { \fp_eval:n { trunc(#1,0) } } + { \fp_eval:n { trunc((#1 - trunc(#1,0)) * 60,0) } } { - \siunitx_angle:nnn - { \fp_eval:n { trunc(#1,0) } } - { \fp_eval:n { trunc((#1 - trunc(#1,0)) * 60,0) } } + \fp_eval:n { - \fp_eval:n - { - ( - (#1 - trunc(#1,0)) * 60 - - trunc((#1 - trunc(#1,0)) * 60,0) - ) - * 60 - } + ( + (#1 - trunc(#1,0)) * 60 + - trunc((#1 - trunc(#1,0)) * 60,0) + ) + * 60 } } } +\cs_generate_variant:Nn \@@_arc_convert:n { x } % \end{macrocode} % \end{macro} % \end{macro} @@ -399,11 +403,11 @@ { \tl_if_empty:cF { l_@@_ ##1 _tl } { - \exp_args:Ncc \siunitx_number_process:NN + \siunitx_number_process:cc { l_@@_ ##1 _tl } { l_@@_ ##1 _tl } \tl_set:cx { l_@@_ ##1 _tl } { - \exp_args:Nc \siunitx_number_output:NN + \siunitx_number_output:cN { l_@@_ ##1 _tl } \q_nil } } diff --git a/Master/texmf-dist/source/latex/siunitx/siunitx-complex.dtx b/Master/texmf-dist/source/latex/siunitx/siunitx-complex.dtx index 21a8fa3be9b..af0b882c947 100644 --- a/Master/texmf-dist/source/latex/siunitx/siunitx-complex.dtx +++ b/Master/texmf-dist/source/latex/siunitx/siunitx-complex.dtx @@ -66,7 +66,7 @@ % assumptions concerning \LaTeXe{} commands in the submodule beyond those in the % core number and unit submodules. % -% \begin{function}{\siunitx_complex_number:n} +% \begin{function}{\siunitx_complex_number:n, \siunitx_complex_number:x} % \begin{syntax} % \cs{siunitx_complex_number:n} \Arg{number} % \end{syntax} @@ -93,7 +93,12 @@ % \cs{siunitx_complex_number:n}. % \end{function} % -% \begin{function}{\siunitx_complex_quantity:nn, \siunitx_complex_quantity:nnn} +% \begin{function} +% { +% \siunitx_complex_quantity:nn , +% \siunitx_complex_quantity:xn , +% \siunitx_complex_quantity:nnn +% } % \begin{syntax} % \cs{siunitx_complex_quantity:nn} \Arg{number} \Arg{units} % \cs{siunitx_complex_quantity:nnn} \Arg{magnitude} \Arg{angle} \Arg{units} @@ -686,9 +691,9 @@ % \end{macrocode} % \end{variable} % -% \begin{macro}{\siunitx_complex_number:n} +% \begin{macro}{\siunitx_complex_number:n, \siunitx_complex_number:x} % \begin{macro}{\siunitx_complex_number:nn, \@@_number:nn} -% \begin{macro}{\siunitx_complex_quantity:nn} +% \begin{macro}{\siunitx_complex_quantity:nn, \siunitx_complex_quantity:xn} % \begin{macro}{\siunitx_complex_quantity:nnn, \@@_quantity:nnn} % The work here is pretty trivial: only conversion between forms makes % things a bit more intricate. @@ -717,6 +722,7 @@ } } } +\cs_generate_variant:Nn \siunitx_complex_number:n { x } \cs_new_protected:Npn \siunitx_complex_number:nn #1#2 { \bool_lazy_or:nnTF @@ -734,7 +740,7 @@ { \l_@@_force_cartesian_bool } { \l_siunitx_number_parse_bool } { - \exp_args:Ne \siunitx_complex_number:n + \siunitx_complex_number:x { \@@_convert_cartesian:nn {#1} {#2} } } { @@ -764,6 +770,7 @@ { \siunitx_quantity:nn {#1} {#2} } } } +\cs_generate_variant:Nn \siunitx_complex_quantity:nn { x } \cs_new_protected:Npn \siunitx_complex_quantity:nnn #1#2#3 { \bool_lazy_or:nnTF @@ -781,7 +788,7 @@ { \l_@@_force_cartesian_bool } { \l_siunitx_number_parse_bool } { - \exp_args:Ne \siunitx_complex_quantity:nn + \siunitx_complex_quantity:xn { \@@_convert_cartesian:nn {#1} {#2} } {#3} } @@ -1053,7 +1060,7 @@ \siunitx_print_number:V \l_@@_tmp_tl \bool_if:NT \l_@@_polar_degree_bool { - \exp_args:NV \siunitx_unit_format:nN \l_@@_symbol_degree_tl \l_@@_tmp_tl + \siunitx_unit_format:VN \l_@@_symbol_degree_tl \l_@@_tmp_tl \nobreak \siunitx_print_unit:V \l_@@_tmp_tl } @@ -1087,14 +1094,18 @@ % \subsection{Conversion} % % \begin{macro}[EXP] -% {\@@_convert_cartesian:nn, \@@_convert_cartesian_aux:nn} +% { +% \@@_convert_cartesian:nn , +% \@@_convert_cartesian_aux:nn , +% \@@_convert_cartesian_aux:ee +% } % \begin{macro}[EXP]{\@@_convert_cartesian_aux:w} % Conversion to Cartesian form is easy as we have two inputs and need to % do no parsing here at all. % \begin{macrocode} \cs_new:Npn \@@_convert_cartesian:nn #1#2 { - \exp_args:Nee \@@_convert_cartesian_aux:nn + \@@_convert_cartesian_aux:ee { \fp_to_tl:n { (#1) * cos \bool_if:NT \l_@@_polar_degree_bool { d } (#2) } @@ -1108,6 +1119,7 @@ { \@@_convert_cartesian_aux:w #1 e e \q_mark #2 e e \q_stop } +\cs_generate_variant:Nn \@@_convert_cartesian_aux:nn { ee } \cs_new:Npn \@@_convert_cartesian_aux:w #1 e #2 e #3 \q_mark #4 e #5 e #6 \q_stop { @@ -1132,8 +1144,10 @@ % \begin{macro}[EXP]{\@@_convert_polar_auxiv:nnw} % \begin{macro}[EXP]{\@@_convert_polar_auxv:nnw} % \begin{macro}[EXP]{\@@_convert_polar_auxvi:nnn} -% \begin{macro}[EXP]{\@@_convert_polar_auxvii:nnn} -% \begin{macro}[EXP]{\@@_convert_polar_auxviii:nn} +% \begin{macro}[EXP] +% {\@@_convert_polar_auxvii:nnn, \@@_convert_polar_auxvii:eee} +% \begin{macro}[EXP] +% {\@@_convert_polar_auxviii:nn, \@@_convert_polar_auxviii:ee} % A simplified parser for complex numbers which works by expansion, % then converts to polar form. % \begin{macrocode} @@ -1181,21 +1195,23 @@ } \cs_new:Npn \@@_convert_polar_auxvi:nnn #1#2#3 { - \exp_args:Neee \@@_convert_polar_auxvii:nnn + \@@_convert_polar_auxvii:eee { \tl_if_blank:nTF {#1} { 0 } {#1} } { \tl_if_blank:nTF {#2} { 0 } {#2} } { \tl_if_blank:nF {#3} { e#3 } } } \cs_new:Npn \@@_convert_polar_auxvii:nnn #1#2#3 { - \exp_args:Nee \@@_format_polar_auxviii:nn + \@@_format_polar_auxviii:ee { \fp_eval:n { sqrt ( (#1#3)^2 + (#2#3)^2 ) } } { \fp_eval:n { atan \bool_if:NT \l_@@_polar_degree_bool { d } (#2 , #1) } } } +\cs_generate_variant:Nn \@@_convert_polar_auxvii:nnn { eee } \cs_new:Npn \@@_format_polar_auxviii:nn #1#2 { {#1} {#2} } +\cs_generate_variant:Nn \@@_format_polar_auxviii:nn { ee } % \end{macrocode} % \end{macro} % \end{macro} diff --git a/Master/texmf-dist/source/latex/siunitx/siunitx-compound.dtx b/Master/texmf-dist/source/latex/siunitx/siunitx-compound.dtx index 0ce984f4a08..691ebf86c5a 100644 --- a/Master/texmf-dist/source/latex/siunitx/siunitx-compound.dtx +++ b/Master/texmf-dist/source/latex/siunitx/siunitx-compound.dtx @@ -535,7 +535,7 @@ % \begin{macro}{\siunitx_compound_number:n} % \begin{macro}{\@@_format:n} % \begin{macro}{\@@_format:nn} -% \begin{macro}{\@@_format:nnn} +% \begin{macro}{\@@_format:nnn, \@@_format:xxn} % Printing a generic set starts with the question of whether we want to % extract exponents. If we do, then there is the work to do with extraction. % Either way, the printing is handed off to a common function. We do a quick @@ -554,7 +554,7 @@ \seq_clear:N \l_@@_tmp_seq \bool_if:NTF \l_siunitx_number_parse_bool { - \exp_args:Nxx \@@_format:nnn + \@@_format:xxn { \tl_head:n {#1} } { \tl_tail:n {#1} } {#2} @@ -575,6 +575,7 @@ } { \@@_format_aux:nnn {#1} {#2} {#3} } } +\cs_generate_variant:Nn \@@_format:nnn { xx } \cs_new_protected:Npn \@@_format_aux:nnn #1#2#3 { \siunitx_number_parse:nN {#1} \l_@@_tmp_tl @@ -699,7 +700,7 @@ % \@@_format_combine-exponent_aux:n , % \@@_format_extract-exponent_aux:n % } -% \begin{macro}{\@@_extract_exp:nN} +% \begin{macro}{\@@_extract_exp:nN, \@@_extract_exp:VN} % \begin{macro}{\@@_extract_exp:nnnnnnnN} % Actually formatting the units is much the same as is done in % the quantities module, except that we have to cover the multiplication @@ -738,7 +739,7 @@ { \bool_set_true:N \l_@@_exp_combine_bool \siunitx_number_process:NN \l_@@_tmp_tl \l_@@_first_tl - \exp_args:NV \@@_extract_exp:nN + \@@_extract_exp:VN \l_@@_first_tl \l_@@_tmp_fp #1 \l_@@_tmp_fp \l_@@_unit_tl } @@ -775,6 +776,7 @@ } \cs_new_protected:Npn \@@_extract_exp:nN #1#2 { \@@_extract_exp:nnnnnnnN #1 #2 } +\cs_generate_variant:Nn \@@_extract_exp:nN { V } \cs_new_protected:Npn \@@_extract_exp:nnnnnnnN #1#2#3#4#5#6#7#8 { \fp_set:Nn #8 {#6#7} } % \end{macrocode} @@ -820,7 +822,7 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_quantity_auxi:nn #1#2 { - \@@_print_boundary:V \l_@@_boundary_close_tl + \@@_print_boundary:V \l_@@_boundary_open_tl \seq_clear:N \l_@@_tmp_seq \tl_map_inline:nn {#1} { @@ -872,8 +874,8 @@ % \end{macro} % % \begin{macro}{\@@_print:N} -% \begin{macro}{\@@_print:nnN, \@@_print:xxN} -% \begin{macro}{\@@_print:nnnN} +% \begin{macro}{\@@_print:nnN, \@@_print:nVN, \@@_print:xnN, \@@_print:xxN} +% \begin{macro}{\@@_print:nnnN, \@@_print:xnnN} % \begin{macro}{\@@_print_aux:n} % \begin{macro}{\@@_print_aux:nn} % \begin{macro}{\@@_print_quantity:n, \@@_print_quantity:x} @@ -900,14 +902,14 @@ } #1 } - { \@@_print:xxN { } { \exp_not:V \l_@@_exp_tl } #1 } + { \@@_print:nVN { } \l_@@_exp_tl #1 } } \cs_new_protected:Npn \@@_print:nnN #1#2#3 { - \exp_args:Nx \@@_print:nnnN + \@@_print:xnnN { \seq_count:N \l_@@_tmp_seq } {#1} {#2} #3 } -\cs_generate_variant:Nn \@@_print:nnN { xx } +\cs_generate_variant:Nn \@@_print:nnN { nV , x , xx } % \end{macrocode} % A rather long auxiliary as we want a way to have the brackets/exponent % available. The actual flow is simple enough: see how many entries there are @@ -938,7 +940,7 @@ \seq_item:Nn \l_@@_tmp_seq { 2 } \exp_not:n {#3} } - \@@_print_boundary:V \l_@@_boundary_open_tl + \@@_print_boundary:V \l_@@_boundary_close_tl } } { @@ -953,6 +955,7 @@ \@@_print_boundary:V \l_@@_boundary_close_tl } } +\cs_generate_variant:Nn \@@_print:nnnN { x } \cs_new_protected:Npn \@@_print_aux:n #1 { } \cs_new_protected:Npn \@@_print_aux:nn #1#2 { diff --git a/Master/texmf-dist/source/latex/siunitx/siunitx-number.dtx b/Master/texmf-dist/source/latex/siunitx/siunitx-number.dtx index 5bba843ce64..2218e610228 100644 --- a/Master/texmf-dist/source/latex/siunitx/siunitx-number.dtx +++ b/Master/texmf-dist/source/latex/siunitx/siunitx-number.dtx @@ -94,8 +94,8 @@ % \end{quote} % where the two sign parts must be single tokens if present, % and all other components -% must be given in braces. The number will have at least one digit for both the -% \meta{integer} and \meta{exponent} parts: these are required. The +% must be given in braces. The number will have at least one digit for either the +% \meta{integer} and \meta{exponent} parts.. The % \meta{uncertainty} part should either be blank or contain an % \meta{identifier} (as a brace group), followed by one or more data entries. % Valid uncertainty \meta{identifiers} currently are @@ -115,7 +115,7 @@ % \cs{empty}. % \end{function} % -% \begin{function}{\siunitx_number_process:NN} +% \begin{function}{\siunitx_number_process:NN, \siunitx_number_process:cc} % \begin{syntax} % \cs{siunitx_number_process:N} \meta{tl~var1} \meta{tl~var2} % \end{syntax} @@ -131,10 +131,12 @@ % with the result stored in \meta{tl~var2}. % \end{function} % -% \begin{function}[rEXP] +% \begin{function}[EXP] % { -% \siunitx_number_output:N, \siunitx_number_output:n, -% \siunitx_number_output:NN, \siunitx_number_output:nN +% \siunitx_number_output:N, \siunitx_number_output:c +% \siunitx_number_output:n, +% \siunitx_number_output:NN, \siunitx_number_output:cN +% \siunitx_number_output:nN % } % \begin{syntax} % \cs{siunitx_number_output:N} \meta{number} @@ -179,7 +181,8 @@ % \begin{function}[EXP] % { % \siunitx_number_adjust_exponent:Nn , -% \siunitx_number_adjust_exponent:nn +% \siunitx_number_adjust_exponent:nn , +% \siunitx_number_adjust_exponent:Vn % } % \begin{syntax} % \cs{siunitx_number_adjust_exponent:Nn} \meta{number} \Arg{fp~expr} @@ -711,7 +714,7 @@ % Variants not provided by \pkg{expl3}. % \begin{macrocode} \cs_generate_variant:Nn \keys_set:nn { nx } -\cs_generate_variant:Nn \tl_if_blank:nTF { f } +\cs_generate_variant:Nn \tl_if_blank:nTF { e } \cs_generate_variant:Nn \tl_if_in:NnTF { NV } \cs_generate_variant:Nn \tl_if_in:nnTF { nV } \cs_generate_variant:Nn \tl_remove_all:Nn { NV } @@ -799,8 +802,6 @@ % \end{quote} % where all components must be given in braces. \emph{All} of the components % must be present in a stored number (\foreign{i.e.}~at the end of parsing). -% The number must have at least one digit for both the \meta{integer} and -% \meta{exponent} parts. % % A non-empty \meta{uncertainty} must contain one leading brace group % containing an identifier, then zero or more brace groups which contain @@ -1078,7 +1079,7 @@ \tl_put_right:NV \l_@@_uncert_tl \l_@@_flex_tl \tl_if_empty:NF \l_@@_uncert_tl { - \tl_if_blank:fTF { \exp_after:wN \use_iv:nnnn \l_@@_parsed_tl } + \tl_if_blank:eTF { \exp_after:wN \use_iv:nnnn \l_@@_parsed_tl } { \@@_parse_combine_uncert: } { \tl_clear:N \l_@@_parsed_tl } } @@ -1098,11 +1099,21 @@ % \begin{macro}{\@@_parse_combine_uncert:} % \begin{macro}[EXP]{\@@_parse_combine_uncert:nnnn} % \begin{macro}[EXP]{\@@_parse_combine_uncert:nn} -% \begin{macro}[EXP]{\@@_parse_combine_uncert_loop:nnnnnnn} -% \begin{macro}[EXP]{\@@_parse_combine_uncert:nnnnnn} -% \begin{macro}[EXP]{\@@_parse_combine_uncert:nnnnnnn} +% \begin{macro}[EXP] +% { +% \@@_parse_combine_uncert_loop:nnnnnnn , +% \@@_parse_combine_uncert_loop:nnnnnnn +% } +% \begin{macro}[EXP] +% {\@@_parse_combine_uncert:nnnnnn, \@@_parse_combine_uncert:ennnnn} +% \begin{macro}[EXP] +% {\@@_parse_combine_uncert:nnnnnnn, \@@_parse_combine_uncert:ennnnnn} % \begin{macro}[EXP]{\@@_parse_combine_uncert:nnnnn} -% \begin{macro}[EXP]{\@@_parse_combine_uncert_aux:nnnn} +% \begin{macro}[EXP] +% { +% \@@_parse_combine_uncert_aux:nnnn , +% \@@_parse_combine_uncert_aux:eenn +% } % \begin{macro}[EXP]{\@@_parse_combine_uncert:N} % \begin{macro}[EXP]{\@@_parse_combine_uncert:w} % \begin{macro}[EXP]{\@@_parse_combine_uncert_end:nnn} @@ -1148,10 +1159,11 @@ { \quark_if_recursion_tail_stop_do:nn {#4} { \@@_parse_combine_uncert_end:nnn {#1} {#2} {#3} } - \exp_args:Nf \@@_parse_combine_uncert:nnnnnn + \@@_parse_combine_uncert:ennnnn { \int_eval:n { \tl_count:n {#1} - \tl_count:n {#6} } } {#1} {#2} {#3} {#5} {#6} } +\cs_generate_variant:Nn \@@_parse_combine_uncert_loop:nnnnnnn { nee } % \end{macrocode} % The difference in places between the two decimal parts is now found: this % is done just once to avoid having to parse token lists twice. The value @@ -1160,10 +1172,11 @@ % \begin{macrocode} \cs_new:Npn \@@_parse_combine_uncert:nnnnnn #1 { - \exp_args:Nf \@@_parse_combine_uncert:nnnnnnn + \@@_parse_combine_uncert:ennnnnn { \prg_replicate:nn { \int_abs:n {#1} } { 0 } } {#1} } +\cs_generate_variant:Nn \@@_parse_combine_uncert:nnnnnn { e } \cs_new:Npn \@@_parse_combine_uncert:nnnnnnn #1#2#3#4#5#6#7 { \int_compare:nNnTF {#2} > 0 @@ -1176,6 +1189,7 @@ { #3 #1 } {#4} {#5} {#6} {#7} } } +\cs_generate_variant:Nn \@@_parse_combine_uncert:nnnnnnn { e } % \end{macrocode} % We now ensure that the decimal part is never entirely blank \emph{if} there % are decimal-part uncertainty digits. There is also a need to handle the @@ -1184,7 +1198,7 @@ % \begin{macrocode} \cs_new:Npn \@@_parse_combine_uncert:nnnnn #1#2#3#4#5 { - \exp_args:Nee \@@_parse_combine_uncert_aux:nnnn + \@@_parse_combine_uncert_aux:eenn { \bool_lazy_and:nnTF { \tl_if_blank_p:n {#1} } @@ -1201,8 +1215,8 @@ } \cs_new:Npn \@@_parse_combine_uncert_aux:nnnn #1#2#3#4 { - \exp_args:Neee \@@_parse_combine_uncert_loop:nnnnnnn - { \exp_not:n {#1} } + \@@_parse_combine_uncert_loop:neennnn + {#1} { \exp_not:n {#3} \tl_if_blank:nF {#2} { S } @@ -1212,6 +1226,7 @@ \tl_if_blank:nF {#2} { { \exp_not:n {#2} } } } } +\cs_generate_variant:Nn \@@_parse_combine_uncert_aux:nnnn { ee } % \end{macrocode} % A short routine to remove any leading zeros in the uncertainty part, % which are not needed for the compact representation used by the module. @@ -1309,7 +1324,7 @@ { \tl_if_empty:NTF \l_siunitx_number_input_exponent_tl { - \tl_set:Nn \l_@@_exponent_tl { { } 0 } + \tl_set:Nn \l_@@_exponent_tl { { } { } } \tl_if_empty:NF \l_@@_parsed_tl { \@@_parse_loop: } } @@ -1343,7 +1358,7 @@ \cs_new_protected:Npn \@@_parse_exponent_auxii:nn #1#2 { \quark_if_nil:nTF {#2} - { \tl_set:Nn \l_@@_exponent_tl { { } 0 } } + { \tl_set:Nn \l_@@_exponent_tl { { } { } } } { \tl_set:Nn \l_@@_arg_tl {#1} \tl_if_blank:nTF {#2} @@ -1669,7 +1684,7 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_parse_loop_after_decimal:NN #1#2 { - \tl_if_blank:fTF { \exp_after:wN \use_none:n #1 } + \tl_if_blank:eTF { \exp_after:wN \use_none:n #1 } { \quark_if_recursion_tail_stop_do:Nn #2 { \@@_parse_loop_break:w \q_recursion_stop } @@ -1759,7 +1774,11 @@ % \begin{macro}{\@@_parse_uncert_marker:w} % \begin{macro}{\@@_parse_uncert_marker:nnnnN} % \begin{macro}{\@@_parse_uncert_marker:nnnnnN} -% \begin{macro}{\@@_parse_uncert_marker:nnnnnnN} +% \begin{macro} +% { +% \@@_parse_uncert_marker:nnnnnnN , +% \@@_parse_uncert_marker:xnnnnnN +% } % \begin{macro}{\@@_parse_uncert_after:N} % Parsing a combined uncertainty has a very restricted range of allowed % tokens. A closing uncertainty token in the first place is an error, @@ -1935,7 +1954,7 @@ } \cs_new_protected:Npn \@@_parse_uncert_marker:nnnnnN #1#2#3#4#5#6 { - \exp_args:Ne \@@_parse_uncert_marker:nnnnnnN + \@@_parse_uncert_marker:xnnnnnN { \int_eval:n { \tl_count:n {#4} } } {#1} {#2} {#3} {#4} {#5} #6 } @@ -1971,6 +1990,7 @@ } #5#6#7 } +\cs_generate_variant:Nn \@@_parse_uncert_marker:nnnnnnN { x } % \end{macrocode} % At the end of collection, we can either start another one or be done: % either way we move the data around. @@ -2177,7 +2197,7 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\siunitx_number_process:NN} +% \begin{macro}{\siunitx_number_process:NN, \siunitx_number_process:cc} % \begin{macro}{\@@_process:nnnnnnnNN} % A top-level interface for the processing tools. Rounding happens in all % cases, but exponents are only processed if the value is not $0$. @@ -2194,6 +2214,7 @@ \@@_digits:NN #2 #2 } } +\cs_generate_variant:Nn \siunitx_number_process:NN { cc } \cs_new_protected:Npn \@@_process:nnnnnnnNN #1#2#3#4#5#6#7#8#9 { \bool_lazy_and:nnTF @@ -2215,35 +2236,34 @@ % \begin{macro}{\@@_exponent:NN} % \begin{macro}[EXP] % { +% \@@_exponent:nnnnnnn , +% \@@_exponent_aux:nnnnnnn , % \@@_exponent_engineering:nnnnnnn , % \@@_exponent_fixed:nnnnnnn , -% \@@_exponent_input:nnnnnnn , % \@@_exponent_scientific:nnnnnnn % } % \begin{macro}[EXP] % { -% \@@_exponent_fixed:nnnnnnnn , -% \@@_exponent_scientific:nnnnnnnn +% \@@_exponent_fixed:nnnnnnnn , +% \@@_exponent_fixed:ennnnnnn , +% \@@_exponent_scientific:nnnnnnnn , +% \@@_exponent_scientific:ennnnnnn % } % \begin{macro}[EXP]{\@@_exponent_scientific:nnnw} -% \begin{macro}[EXP]{\@@_exponent_shift:nnn,\@@_exponent_shift:nnf} +% \begin{macro}[EXP]{\@@_exponent_shift:nnn, \@@_exponent_shift:nne} % \begin{macro}[EXP]{\@@_exponent_shift_down:nnnw} % \begin{macro}[EXP]{\@@_exponent_shift_down:nnn} % \begin{macro}[EXP]{\@@_exponent_shift_down:nw} % \begin{macro}[EXP]{\@@_exponent_shift_up:nnn} % \begin{macro}[EXP]{\@@_exponent_shift_up:nnw} % \begin{macro}[EXP] -% { -% \@@_exponent_shift_up_aux:nnn , -% \@@_exponent_shift_up_aux:fnn , -% \@@_exponent_shift_up_aux:ffn -% } +% {\@@_exponent_shift_up_aux:nnn, \@@_exponent_shift_up_aux:een} % \begin{macro}[EXP]{\@@_exponent_shift_uncert:nw} % \begin{macro}[EXP] -% {\@@_exponent_shift_uncert_S:nnnn, \@@_exponent_shift_uncert_S:fnnn} +% {\@@_exponent_shift_uncert_S:nnnn, \@@_exponent_shift_uncert_S:ennn} % \begin{macro}[EXP]{\@@_exponent_uncert:n} % \begin{macro}[EXP]{\@@_exponent_finalise:n} -% \begin{macro}[EXP]{\@@_exponent_engineering_aux:nnnnnnn} +% \begin{macro}[EXP]{\@@_exponentcd te_engineering_aux:nnnnnnn} % \begin{macro}[EXP] % { % \@@_exponent_engineering_0:nnnn , @@ -2254,7 +2274,7 @@ % \begin{macro}[EXP]{\@@_exponent_engineering_uncert:nn} % \begin{macro}[EXP]{\@@_exponent_engineering_uncert_S:nnn} % \begin{macro}[EXP]{\@@_exponent_threshold:nnnnnnn} -% \begin{macro}[EXP]{\@@_exponent_threshold:nn} +% \begin{macro}[EXP]{\@@_exponent_threshold:nn, \@@_exponent_threshold:en} % \begin{macro}[EXP]{\@@_exponent_threshold:nnnnnnnn} % Manipulating an exponent is done using a single expansion function % \emph{unless} dealing with engineering-style output. The latter is easier @@ -2265,21 +2285,31 @@ \cs_new_protected:Npn \@@_exponent:NN #1#2 { \tl_set:Nx #2 - { - \cs:w - @@_exponent_ \l_@@_exponent_mode_tl :nnnnnnn - \exp_after:wN - \cs_end: #1 - } + { \exp_after:wN \@@_exponent:nnnnnnn #1 } \str_if_eq:VnT \l_@@_exponent_mode_tl { engineering } { \tl_set:Nx #2 { \exp_after:wN \@@_exponent_engineering_aux:nnnnnnn #2 } } } +\cs_new:Npn \@@_exponent:nnnnnnn #1#2#3#4#5#6#7 + { + \str_if_eq:VnTF \l_@@_exponent_mode_tl { input } + { \exp_not:n { {#1} {#2} {#3} {#4} {#5} {#6} {#7} } } + { + \tl_if_blank:nTF {#7} + { \@@_exponent_aux:nnnnnnn {#1} {#2} {#3} {#4} {#5} {#6} { 0 } } + { \@@_exponent_aux:nnnnnnn {#1} {#2} {#3} {#4} {#5} {#6} {#7} } + } + } +\cs_new:Npn \@@_exponent_aux:nnnnnnn #1#2#3#4#5#6#7 + { + \use:c { @@_exponent_ \l_@@_exponent_mode_tl :nnnnnnn } + {#1} {#2} {#3} {#4} {#5} {#6} {#7} + } \cs_new:Npn \@@_exponent_fixed:nnnnnnn #1#2#3#4#5#6#7 { - \exp_args:Nf \@@_exponent_fixed:nnnnnnnn + \@@_exponent_fixed:ennnnnnn { \int_eval:n { \l_@@_exponent_fixed_int - (#6#7) } } {#1} {#2} {#3} {#4} {#5} {#6} {#7} } @@ -2291,8 +2321,7 @@ { \int_compare:nNnT \l_@@_exponent_fixed_int < 0 { - } } { \int_abs:n \l_@@_exponent_fixed_int } } -\cs_new:Npn \@@_exponent_input:nnnnnnn #1#2#3#4#5#6#7 - { \exp_not:n { {#1} {#2} {#3} {#4} {#5} {#6} {#7} } } +\cs_generate_variant:Nn \@@_exponent_fixed:nnnnnnnn { e } % \end{macrocode} % To convert to scientific notation, the key question is to find the number % of significant places. That is easy enough if the number has a non-zero @@ -2301,7 +2330,7 @@ % \begin{macrocode} \cs_new:Npn \@@_exponent_scientific:nnnnnnn #1#2#3#4#5#6#7 { - \exp_args:Nf \@@_exponent_scientific:nnnnnnnn + \@@_exponent_scientific:ennnnnnn { \int_eval:n { \tl_count:n {#3} } } {#1} {#2} {#3} {#4} {#5} {#6} {#7} } @@ -2323,6 +2352,7 @@ \@@_exponent_finalise:n { #1 + #7#8 - 1 } } } +\cs_generate_variant:Nn \@@_exponent_scientific:nnnnnnnn { e } \cs_new_eq:NN \@@_exponent_engineering:nnnnnnn \@@_exponent_scientific:nnnnnnn \cs_new:Npn \@@_exponent_scientific:nnnw #1#2#3#4#5 \q_stop @@ -2351,7 +2381,7 @@ { {#2} {#3} } } } -\cs_generate_variant:Nn \@@_exponent_shift:nnn { nnf } +\cs_generate_variant:Nn \@@_exponent_shift:nnn { nne } % \end{macrocode} % For shifting the exponent down, there is first a loop to reserve the % integer part before doing the work: that of course has to be undone @@ -2385,7 +2415,7 @@ { \tl_if_blank:nTF {#3} { - \@@_exponent_shift_up_aux:ffn + \@@_exponent_shift_up_aux:een { \int_eval:n { #1 + 1 } } { \str_if_eq:nnF {#2} { 0 } {#2} 0 } { } @@ -2395,7 +2425,7 @@ } \cs_new:Npn \@@_exponent_shift_up:nnw #1#2#3#4 \q_stop { - \@@_exponent_shift_up_aux:ffn + \@@_exponent_shift_up_aux:een { \int_eval:n { #1 + 1 } } { \str_if_eq:nnF {#2} { 0 } {#2} #3 } {#4} @@ -2417,7 +2447,7 @@ { \@@_exponent_shift_up:nnn {#1} {#2} {#3} } } } -\cs_generate_variant:Nn \@@_exponent_shift_up_aux:nnn { f , ff } +\cs_generate_variant:Nn \@@_exponent_shift_up_aux:nnn { ee } % \end{macrocode} % If the shift has put digits into the integer part, we have to adjust the % uncertainty accordingly. First, we grab the data, then adjust by the @@ -2438,7 +2468,7 @@ \@@_exponent_uncert:n { { S } { 0 } } } { - \use:c { @@_exponent_shift_uncert_ \use_i:nn #3 :fnnn } + \@@_exponent_shift_uncert_S:ennn { \prg_replicate:nn {#1} { 0 } } {#2} #3 @@ -2450,7 +2480,7 @@ #2 \@@_exponent_uncert:n { { S } { #4#1 } } } -\cs_generate_variant:Nn \@@_exponent_shift_uncert_S:nnnn { f } +\cs_generate_variant:Nn \@@_exponent_shift_uncert_S:nnnn { e } \cs_new:Npn \@@_exponent_uncert:n #1 { { \exp_not:n {#1} } } % \end{macrocode} % Tidy up the exponent to put the sign in the right place. @@ -2503,7 +2533,7 @@ } { { \exp_not:n {#1} \exp_not:o { \tl_head:w #2 \q_stop } } - { \exp_not:f { \tl_tail:n {#2} } } + { \tl_tail:n {#2} } { \exp_not:n {#3} } } \@@_exponent_finalise:n { #4 - 1 } @@ -2527,7 +2557,7 @@ } { { \exp_not:n {#1#3} \exp_not:o { \tl_head:w #4 \q_stop } } - { \exp_not:f { \tl_tail:n {#4} } } + { \tl_tail:n {#4} } { \exp_not:n {#2} } } } @@ -2552,16 +2582,17 @@ % \begin{macrocode} \cs_new:Npn \@@_exponent_threshold:nnnnnnn #1#2#3#4#5#6#7 { - \exp_args:Ne \@@_exponent_threshold:nn + \@@_exponent_threshold:en { \@@_exponent_scientific:nnnnnnn {#1} {#2} {#3} {#4} {#5} {#6} {#7} } { {#1} {#2} {#3} {#4} {#5} {#6} {#7} } } -\cs_new:Npn \@@_exponent_threshold:nn #1#2 +\cs_new:Npn \@@_exponent_threshold:nn #1#2 { \@@_exponent_threshold:nnnnnnnn #1 {#2} } -\cs_new:Npn \@@_exponent_threshold:nnnnnnnn #1#2#3#4#5#6#7#8 +\cs_generate_variant:Nn \@@_exponent_threshold:nn { e } +\cs_new:Npn \@@_exponent_threshold:nnnnnnnn #1#2#3#4#5#6#7#8 { \bool_lazy_and:nnTF { \int_compare_p:nNn {#6#7} > \l_@@_lower_threshold_int } @@ -2569,7 +2600,6 @@ { \exp_not:n {#8} } { \exp_not:n { {#1} {#2} {#3} {#4} {#5} {#6} {#7} } } } - % \end{macrocode} % \end{macro} % \end{macro} @@ -2751,25 +2781,39 @@ % \end{macro} % \end{macro} % -% \begin{macro}[EXP]{\@@_round:nnn, \@@_round:fnn} +% \begin{macro}[EXP]{\@@_round:nnn, \@@_round:enn} % \begin{macro}[EXP]{\@@_round:nnnn, \@@_round:Vnnn} % \begin{macro}[EXP] % { % \@@_round_auxi:nnnnN , % \@@_round_auxii:nnnnN , % \@@_round_auxiii:nnnnN , -% \@@_round_auxiv:nnnnN +% \@@_round_auxiii:ennnN , +% \@@_round_auxiv:nnnnN , +% \@@_round_auxiv:ennnN % } % \begin{macro}[EXP]{\@@_round_auxv:nnnN, \@@_round_auxvi:nnnN} % \begin{macro}[EXP]{\@@_round_auxvii:nnnTF} % \begin{macro}[EXP]{\@@_round_auxviii:nnN, \@@_round_auxix:nnN} % \begin{macro}[EXP]{\@@_round_final_integer:nnw, \@@_round_final_decimal:nnw} -% \begin{macro}[EXP]{\@@_round_final_signicant:n} -% \begin{macro}[EXP]{\@@_round_final_signicant:N} -% \begin{macro}[EXP]{\@@_round_final_signicant:w} -% \begin{macro}[EXP]{\@@_round_final_output:nn, \@@_round_final_output:ff} -% \begin{macro}[EXP]{\@@_round_final:nn, \@@_round_final:fn} -% \begin{macro}[EXP]{\@@_round_final_shift:nn, \@@_round_final_shift:ff} +% \begin{macro}[EXP] +% {\@@_round_final_significant:n, \@@_round_final_significant:e} +% \begin{macro}[EXP]{\@@_round_final_significant:N} +% \begin{macro}[EXP]{\@@_round_final_significant:w} +% \begin{macro}[EXP] +% { +% \@@_round_final_output:nn , +% \@@_round_final_output:ne , +% \@@_round_final_output:en , +% \@@_round_final_output:ee +% } +% \begin{macro}[EXP]{\@@_round_final:nn, \@@_round_final:en} +% \begin{macro}[EXP] +% { +% \@@_round_final_shift:nn , +% \@@_round_final_shift:en , +% \@@_round_final_shift:ee +% } % \begin{macro}[EXP]{\@@_round_final_shift:Nw} % \begin{macro}[EXP] % { @@ -2779,7 +2823,7 @@ % \@@_round_scientific:nn % } % \begin{macro}[EXP]{\@@_round_engineering:NNNNn} -% \begin{macro}[EXP]{\@@_round_engineering:nnN} +% \begin{macro}[EXP]{\@@_round_engineering:nnN, \@@_round_engineering:VnN} % \begin{macro}[EXP]{\@@_round_truncate:n, \@@_round_truncate_direct:n} % \begin{macro}[EXP]{\@@_round_truncate:nnN} % Actually doing the rounding needs us to work from the least significant @@ -2793,7 +2837,7 @@ \@@_round:Vnnn \l_@@_round_dir_tl {#1} {#2} {#3} } -\cs_generate_variant:Nn \@@_round:nnn { f } +\cs_generate_variant:Nn \@@_round:nnn { e } \cs_new:Npn \@@_round:nnnn #1#2#3#4 { \@@_round_auxi:nnnnN {#1} {#2} {#3} { } @@ -2845,11 +2889,12 @@ } \int_compare:nNnTF {#1} > 0 { - \exp_args:Nf \@@_round_auxiii:nnnnN + \@@_round_auxiii:ennnN { \int_eval:n { #1 - 1 } } {#2} {#3} { #5#4 } } { \@@_round_auxv:nnnN {#2} {#4} {#3} #5 } } +\cs_generate_variant:Nn \@@_round_auxiii:nnnnN { e } \cs_new:Npn \@@_round_auxiv:nnnnN #1#2#3#4#5 { \quark_if_recursion_tail_stop_do:Nn #5 @@ -2863,11 +2908,12 @@ } \int_compare:nNnTF {#1} > 0 { - \exp_args:Nf \@@_round_auxiv:nnnnN + \@@_round_auxiv:ennnN { \int_eval:n { #1 - 1 } } {#2} { #3 0 } { #5#4 } } { \@@_round_auxvi:nnnN {#2} {#4} {#3} #5 } } +\cs_generate_variant:Nn \@@_round_auxiv:nnnnN { e } % \end{macrocode} % We now have the discarded digits, the matching filler and the % next digit. So we can make the decision on rounding: that @@ -2934,7 +2980,7 @@ { \str_if_eq:nnTF {#1} { 0 } { - \@@_round_final_output:ff + \@@_round_final_output:ne { 1 } { \@@_round_truncate:n {#2} } } @@ -2961,7 +3007,7 @@ } } { - \@@_round_final:fn + \@@_round_final:en { \int_eval:n { #3 + 1 } } { \@@_round_final_decimal:nnw {#1} {#2} } } @@ -2973,15 +3019,12 @@ { \tl_if_blank:nTF {#1} { - \@@_round_final_shift:ff - { - \exp_last_unbraced:Nf 1 - { \@@_round_truncate_direct:n {#2} } 0 - } + \@@_round_final_shift:en + { 1 \@@_round_truncate_direct:n {#2} 0 } { } } { - \@@_round_final_shift:ff + \@@_round_final_shift:ee { 1 #2 } { \@@_round_truncate:n {#1} } } @@ -2989,7 +3032,7 @@ \int_compare:nNnTF {#3} = 9 { \@@_round_auxix:nnN {#1} { 0 #2 } } { - \@@_round_final:fn + \@@_round_final:en { \int_eval:n { #3 + 1 } } { \@@_round_final_integer:nnw {#1} {#2} } } @@ -3000,15 +3043,15 @@ \cs_new:Npn \@@_round_final_decimal:nnw #1#2#3 \q_recursion_tail \q_recursion_stop { - \@@_round_final_output:ff + \@@_round_final_output:ee { \tl_reverse:n {#1} } { \tl_reverse:n {#3} #2 } } \cs_new:Npn \@@_round_final_integer:nnw #1#2#3 \q_recursion_tail \q_recursion_stop { - \@@_round_final_output:ff - { \exp_args:Ne \@@_round_final_significant:n { \tl_reverse:n {#3} #2 } } + \@@_round_final_output:en + { \@@_round_final_significant:e { \tl_reverse:n {#3} #2 } } {#1} } \cs_new:Npn \@@_round_final_significant:n #1 @@ -3016,6 +3059,7 @@ \@@_round_final_significant:N #1 \q_recursion_tail \q_recursion_stop } +\cs_generate_variant:Nn \@@_round_final_significant:n { e } \cs_new:Npn \@@_round_final_significant:N #1 { \quark_if_recursion_tail_stop_do:Nn #1 { 0 } @@ -3030,10 +3074,10 @@ #1 \q_recursion_tail \q_recursion_stop {#1} \cs_new:Npn \@@_round_final_output:nn #1#2 { {#1} {#2} } -\cs_generate_variant:Nn \@@_round_final_output:nn { ff } +\cs_generate_variant:Nn \@@_round_final_output:nn { ne , e , ee } \cs_new:Npn \@@_round_final:nn #1#2 { #2 #1 } -\cs_generate_variant:Nn \@@_round_final:nn { f } +\cs_generate_variant:Nn \@@_round_final:nn { e } % \end{macrocode} % Here we deal with the case where rounding applies along with an % exponent set based on number of places. We can only get here if an @@ -3055,7 +3099,7 @@ } { {#1} {#2} } } -\cs_generate_variant:Nn \@@_round_final_shift:nn { ff } +\cs_generate_variant:Nn \@@_round_final_shift:nn { en , ee } \cs_new:Npn \@@_round_engineering:nn #1#2 { \int_compare:nNnTF { \tl_count:n {#1} } = 4 @@ -3072,7 +3116,7 @@ \cs_new:Npn \@@_round_engineering:NNNNn #1#2#3#4#5 { {#1} - \exp_args:NV \@@_round_engineering:nnN + \@@_round_engineering:VnN \l_@@_round_precision_int { } #2#3#4#5 \q_recursion_tail \q_recursion_stop } @@ -3083,6 +3127,7 @@ { \use_i_delimit_by_q_recursion_stop:nw { {#2} } } { \@@_round_engineering:nnN { #1 - 1 } { #2#3 } } } +\cs_generate_variant:Nn \@@_round_engineering:nnN { V } \cs_new:Npn \@@_round_fixed:nn #1#2 { {#1} {#2} } \cs_new:Npn \@@_round_input:nn #1#2 { {#1} {#2} } \cs_new:Npn \@@_round_scientific:nn #1#2 @@ -3092,7 +3137,7 @@ { \str_if_eq_p:Vn \l_@@_round_mode_tl { figures } } { { 1 } { } } { - \@@_exponent_shift:nnf + \@@_exponent_shift:nne { 1 } {#1} { \@@_round_truncate_direct:n {#2} } } \@@_round_final_shift:Nw 1 @@ -3195,7 +3240,8 @@ % % \begin{macro}[EXP]{\@@_round_figures:nnnnnnn, \@@_round_figures_aux:nnnnnnn} % \begin{macro}[EXP]{\@@_round_figures_count:nnN} -% \begin{macro}[EXP]{\@@_round_figures_count:nnnN} +% \begin{macro}[EXP] +% {\@@_round_figures_count:nnnN, \@@_round_figures_count:ennN} % Rounding to figures only makes sense if the number is not $0$, so we start % by filtering out that case. We then check that % there is no uncertainty, and that the number of figures requested is @@ -3245,7 +3291,7 @@ { \int_compare:nNnTF {#1} > \l_@@_round_precision_int { - \@@_round:fnn + \@@_round:enn { \int_eval:n { #1 - \l_@@_round_precision_int } } {#2} {#3} } @@ -3254,9 +3300,10 @@ { \l_@@_round_precision_int - (#1) } {#2} {#3} } } - \exp_args:Nf \@@_round_figures_count:nnnN + \@@_round_figures_count:ennN { \int_eval:n { #1 + 1 } } {#2} {#3} } +\cs_generate_variant:Nn \@@_round_figures_count:nnnN { e } % \end{macrocode} % \end{macro} % \end{macro} @@ -3264,7 +3311,7 @@ % % \begin{macro}[EXP]{\@@_round_places:nnnnnnn} % \begin{macro}[EXP]{\@@_round_places_decimal:nn, \@@_round_places_integer:nn} -% \begin{macro}[EXP]{\@@_round_places_finalise:n} +% \begin{macro}[EXP]{\@@_round_places_finalise:n, \@@_round_places_finalise:e} % \begin{macro}[EXP]{\@@_round_places_finalise:nnnnnnn} % \begin{macro}[EXP]{\@@_round_places_finalise:nnnnn} % The first step when rounding to a fixed number of places is to establish @@ -3277,7 +3324,7 @@ { \tl_if_blank:nTF {#5} { - \exp_args:Ne \@@_round_places_finalise:n + \@@_round_places_finalise:e { \exp_not:n { {#1} {#2} } \int_compare:nNnTF \l_@@_round_precision_int > 0 @@ -3299,7 +3346,7 @@ {#1} {#2} } { - \@@_round:fnn + \@@_round:enn { \int_eval:n { 0 \tl_count:n {#2} - \l_@@_round_precision_int } @@ -3309,7 +3356,7 @@ } \cs_new:Npn \@@_round_places_integer:nn #1#2 { - \@@_round:fnn + \@@_round:enn { \int_eval:n { 0 \tl_count:n {#2} - \l_@@_round_precision_int } @@ -3347,6 +3394,7 @@ } { \exp_not:n { {#1} {#2} {#3} {#4} {#5} {#6} {#7} } } } +\cs_generate_variant:Nn \@@_round_places_finalise:n { e } \cs_new:Npn \@@_round_places_finalise:nnnnn #1#2#3#4#5 { { @@ -3364,17 +3412,28 @@ % \end{macro} % % \begin{macro}[EXP]{\@@_round_uncertainty:nnnnnnn} -% \begin{macro}[EXP]{\@@_round_uncertainty:nnn} -% \begin{macro}[EXP]{\@@_round_uncertainty:nnnn} +% \begin{macro}[EXP]{\@@_round_uncertainty:nnn, \@@_round_uncertainty:nno} +% \begin{macro}[EXP] +% {\@@_round_uncertainty:nnnn, \@@_round_uncertainty:ennn} % \begin{macro}[EXP]{\@@_round_uncertainty:nnnnnn} % \begin{macro}[EXP] % { % \@@_round_uncertainty_auxi:nnnnn , % \@@_round_uncertainty_auxii:nnnnn % } -% \begin{macro}[EXP]{\@@_round_uncertainty_auxiii:nnnnnnn} +% \begin{macro}[EXP] +% { +% \@@_round_uncertainty_auxiii:nnnnnnn , +% \@@_round_uncertainty_auxiii:eennnnn +% } % \begin{macro}[EXP]{\@@_round_uncertainty_zeros:nnnn} -% \begin{macro}[EXP]{\@@_round_uncertainty_auxiv:nnnnnnN} +% \begin{macro}[EXP] +% { +% \@@_round_uncertainty_auxiv:nnnnnnN , +% \@@_round_uncertainty_auxiv:nennnnN , +% \@@_round_uncertainty_auxiv:ennnnnN , +% \@@_round_uncertainty_auxiv:eennnnN +% } % \begin{macro}[EXP]{\@@_round_uncertainty_auxv:nnnN} % \begin{macro}[EXP]{\@@_round_uncertainty_auxvi:nn} % \begin{macro}[EXP]{\@@_round_uncertainty_auxvii:nnNnnn} @@ -3406,7 +3465,7 @@ \str_if_eq:eeTF { \tl_head:n {#5} } { S } { \exp_not:n { {#1} {#2} } - \exp_args:Nnno \@@_round_uncertainty:nnn + \@@_round_uncertainty:nno {#3} {#4} { \use_ii:nn #5 } {#6} {#7} } @@ -3420,13 +3479,14 @@ % \begin{macrocode} \cs_new:Npn \@@_round_uncertainty:nnn #1#2#3 { - \exp_args:Nf \@@_round_uncertainty:nnnn + \@@_round_uncertainty:ennn { \int_eval:n { \tl_count:n {#3} - \l_@@_round_precision_int } } {#1} {#2} {#3} } +\cs_generate_variant:Nn \@@_round_uncertainty:nnn { nno } \cs_new:Npn \@@_round_uncertainty:nnnn #1#2#3#4 { \use:e @@ -3437,6 +3497,7 @@ {#2} {#3} {#1} {#4} } } +\cs_generate_variant:Nn \@@_round_uncertainty:nnnn { e } % \end{macrocode} % The number of digits to remove from the main part and the detail of % zero filling depends on whether we rounded up the uncertainty. So there @@ -3455,7 +3516,7 @@ % \begin{macrocode} \cs_new:Npn \@@_round_uncertainty_auxi:nnnnn #1#2#3#4#5 { - \exp_args:Nf \@@_round_uncertainty_auxiv:nnnnnnN + \@@_round_uncertainty_auxiv:ennnnnN { \@@_round_uncertainty_zeros:nnnn {#1} {#3} {#4} {#5} } {#4} {#2} {#3} {#1} { } @@ -3467,7 +3528,7 @@ % \begin{macrocode} \cs_new:Npn \@@_round_uncertainty_auxii:nnnnn #1#2#3#4#5 { - \exp_args:Nff \@@_round_uncertainty_auxiii:nnnnnnn + \@@_round_uncertainty_auxiii:eennnnn { \tl_count:n {#5} } { \tl_count:n {#3} } {#1} {#2} {#3} {#4} {#5} @@ -3479,26 +3540,21 @@ \bool_lazy_and:nnTF { \int_compare_p:nNn \l_@@_round_precision_int = 2 } { \int_compare_p:nNn {#1} = {#2} } - { - \exp_args:Nnf \@@_round_uncertainty_auxiv:nnnnnnN - { 0 } - } - { - \exp_args:Nnf \@@_round_uncertainty_auxiv:nnnnnnN - { } - } + { \@@_round_uncertainty_auxiv:nennnnN { 0 } } + { \@@_round_uncertainty_auxiv:nennnnN { } } { \int_eval:n { #6 + 1 } } {#4} {#5} { 1 } { } \@@_round_uncertainty_auxvii:nnNnnn } { - \exp_args:Nff \@@_round_uncertainty_auxiv:nnnnnnN + \@@_round_uncertainty_auxiv:eennnnN { \@@_round_uncertainty_zeros:nnnn {#3} {#5} {#6} {#7} } { \int_eval:n { #6 + 1 } } {#4} {#5} { 1 } {#3} \@@_round_uncertainty_auxvii:nnNnnn } } +\cs_generate_variant:Nn \@@_round_uncertainty_auxiii:nnnnnnn { ee } \cs_new:Npn \@@_round_uncertainty_zeros:nnnn #1#2#3#4 { \prg_replicate:nn @@ -3530,6 +3586,7 @@ {#3} #7 \@@_round_end:nnn { { S } { #5#6 #1 } } } +\cs_generate_variant:Nn \@@_round_uncertainty_auxiv:nnnnnnN { ne , e , ee } \cs_new:Npn \@@_round_uncertainty_auxv:nnnN #1#2#3#4 { \int_compare:nNnT { \tl_count:n {#1} } > { \tl_count:n {#3} } @@ -3668,27 +3725,30 @@ % % \subsection{Number modification} % -% \begin{macro}[rEXP]{\siunitx_number_adjust_exponent:nn} -% \begin{macro}[rEXP]{\siunitx_number_adjust_exponent:Nn} -% \begin{macro}[rEXP]{\@@_adjust_exp:nnnnnnnn} -% \begin{macro}[rEXP]{\@@_adjust_exp:nn} -% \begin{macro}[rEXP]{\@@_adjust_exp:nNw} +% \begin{macro}[EXP] +% {\siunitx_number_adjust_exponent:nn, \siunitx_number_adjust_exponent:Vn} +% \begin{macro}[EXP]{\siunitx_number_adjust_exponent:Nn} +% \begin{macro}[EXP]{\@@_adjust_exp:nnnnnnnn} +% \begin{macro}[EXP]{\@@_adjust_exp:nn, \@@_adjust_exp:en} +% \begin{macro}[EXP]{\@@_adjust_exp:nNw} % A simply case of breaking down and rebuilding the number. % \begin{macrocode} \cs_new:Npn \siunitx_number_adjust_exponent:nn #1#2 { \@@_adjust_exp:nnnnnnnn #1 {#2} } +\cs_generate_variant:Nn \siunitx_number_adjust_exponent:nn { V } \cs_new:Npn \siunitx_number_adjust_exponent:Nn #1#2 { \tl_if_empty:NF #1 - { \exp_args:NV \siunitx_number_adjust_exponent:nn #1 {#2} } + { \siunitx_number_adjust_exponent:Vn #1 {#2} } } \cs_new:Npn \@@_adjust_exp:nnnnnnnn #1#2#3#4#5#6#7#8 { \exp_not:n { {#1} {#2} {#3} {#4} {#5} } - \exp_args:Ne \@@_adjust_exp:nn { \fp_eval:n { #6#7 + #8 } } {#6} + \@@_adjust_exp:en { \fp_eval:n { #6#7 + #8 } } {#6} } \cs_new:Npn \@@_adjust_exp:nn #1#2 { \@@_adjust_exp:nNw {#2} #1 \q_stop } +\cs_generate_variant:Nn \@@_adjust_exp:nn { e } \cs_new:Npn \@@_adjust_exp:nNw #1#2#3 \q_stop { \token_if_eq_meaning:NNTF #2 - @@ -3851,87 +3911,88 @@ % \end{macrocode} % \end{variable} % -% \begin{macro}[rEXP]{\siunitx_number_output:N} -% \begin{macro}[rEXP]{\siunitx_number_output:n} -% \begin{macro}[rEXP]{\siunitx_number_output:NN} -% \begin{macro}[rEXP]{\siunitx_number_output:nN} -% \begin{macro}[rEXP]{\@@_output:Nn} -% \begin{macro}[rEXP]{\@@_output:nn} -% \begin{macro}[rEXP]{\@@_output:nnnnnnn} -% \begin{macro}[rEXP]{\@@_output_bracket:nn} -% \begin{macro}[rEXP]{\@@_output_bracket:w} -% \begin{macro}[rEXP]{\@@_output_comparator:nn} -% \begin{macro}[rEXP]{\@@_output_sign:nnn} -% \begin{macro}[rEXP]{\@@_output_sign:nN} -% \begin{macro}[rEXP] +% \begin{macro}[EXP]{\siunitx_number_output:N, \siunitx_number_output:c} +% \begin{macro}[EXP]{\siunitx_number_output:n} +% \begin{macro}[EXP]{\siunitx_number_output:NN, \siunitx_number_output:cN} +% \begin{macro}[EXP]{\siunitx_number_output:nN} +% \begin{macro}[EXP]{\@@_output:Nn} +% \begin{macro}[EXP]{\@@_output:nn} +% \begin{macro}[EXP]{\@@_output:nnnnnnn} +% \begin{macro}[EXP]{\@@_output_bracket:nn} +% \begin{macro}[EXP]{\@@_output_bracket:w} +% \begin{macro}[EXP]{\@@_output_comparator:nn} +% \begin{macro}[EXP]{\@@_output_sign:nnn} +% \begin{macro}[EXP]{\@@_output_sign:nN} +% \begin{macro}[EXP] % {\@@_output_sign_color:w, \@@_output_sign_brackets:w} -% \begin{macro}[rEXP]{\@@_output_integer:nnn} -% \begin{macro}[rEXP]{\@@_output_decimal:nn, \@@_output_decimal:fn} -% \begin{macro}[rEXP]{\@@_output_digits:nn} -% \begin{macro}[rEXP]{\@@_output_digit_separator:N} -% \begin{macro}[rEXP]{\@@_output_integer_3_3:n} -% \begin{macro}[rEXP] +% \begin{macro}[EXP]{\@@_output_integer:nnn} +% \begin{macro}[EXP]{\@@_output_decimal:nn, \@@_output_decimal:en} +% \begin{macro}[EXP]{\@@_output_digits:nn} +% \begin{macro}[EXP]{\@@_output_digit_separator:N} +% \begin{macro}[EXP]{\@@_output_integer_3_3:n} +% \begin{macro}[EXP] % { % \@@_output_integer_aux_0:n, % \@@_output_integer_aux_1:n, % \@@_output_integer_aux_2:n % } -% \begin{macro}[rEXP]{\@@_output_integer_first:nnNN} -% \begin{macro}[rEXP]{\@@_output_integer_loop:NNNN} -% \begin{macro}[rEXP]{\@@_output_integer_first:n} -% \begin{macro}[rEXP]{\@@_output_integer_aux:n} -% \begin{macro}[rEXP]{\@@_output_integer_loop:NnnN} -% \begin{macro}[rEXP]{\@@_output_decimal_3_3:n} -% \begin{macro}[rEXP]{\@@_output_decimal_loop:NNNN} -% \begin{macro}[rEXP]{\@@_output_decimal_3_2:n} -% \begin{macro}[rEXP]{\@@_output_decimal:NNNw} -% \begin{macro}[rEXP]{\@@_output_decimal_loop:NN} -% \begin{macro}[rEXP]{\@@_output_decimal_first:n} -% \begin{macro}[rEXP]{\@@_output_decimal_loop:NnnN} -% \begin{macro}[rEXP]{\@@_output_uncertainty:nnn} -% \begin{macro}[rEXP]{\@@_output_uncertainty_unaligned:n} -% \begin{macro}[rEXP]{\@@_output_uncert:nnnn} -% \begin{macro}[rEXP]{\@@_output_uncert:nnnnn} -% \begin{macro}[rEXP]{\@@_output_uncert_loop:nnN} -% \begin{macro}[rEXP]{\@@_output_uncert_loop:nnNw} -% \begin{macro}[rEXP] +% \begin{macro}[EXP]{\@@_output_integer_first:nnNN} +% \begin{macro}[EXP]{\@@_output_integer_loop:NNNN} +% \begin{macro}[EXP]{\@@_output_integer_first:n} +% \begin{macro}[EXP]{\@@_output_integer_aux:n, \@@_output_integer_aux:e} +% \begin{macro}[EXP]{\@@_output_integer_loop:NnnN} +% \begin{macro}[EXP]{\@@_output_decimal_3_3:n} +% \begin{macro}[EXP]{\@@_output_decimal_loop:NNNN} +% \begin{macro}[EXP]{\@@_output_decimal_3_2:n} +% \begin{macro}[EXP]{\@@_output_decimal:NNNw} +% \begin{macro}[EXP]{\@@_output_decimal_loop:NN} +% \begin{macro}[EXP]{\@@_output_decimal_first:n} +% \begin{macro}[EXP]{\@@_output_decimal_loop:NnnN} +% \begin{macro}[EXP]{\@@_output_uncertainty:nnn} +% \begin{macro}[EXP]{\@@_output_uncertainty_unaligned:n} +% \begin{macro}[EXP]{\@@_output_uncert:nnnn} +% \begin{macro}[EXP]{\@@_output_uncert:nnnnn, \@@_output_uncert:Vnnnn} +% \begin{macro}[EXP]{\@@_output_uncert_loop:nnN} +% \begin{macro}[EXP]{\@@_output_uncert_loop:nnNw} +% \begin{macro}[EXP] % { % \@@_output_uncert_desc_bracket:n , % \@@_output_uncert_desc_bracket-separator:n , % \@@_output_uncert_desc_separator:n , % \@@_output_uncert_desc_subscript:n % } -% \begin{macro}[rEXP]{\@@_output_uncert_A_loop:nnn, \@@_output_uncert_S_loop:nnn} -% \begin{macro}[rEXP]{\@@_output_uncert_S_loop:w} -% \begin{macro}[rEXP]{\@@_output_uncert_A:nnnn, \@@_output_uncert_A_multi:nnnn} -% \begin{macro}[rEXP]{\@@_output_uncert_A:nnnnn} -% \begin{macro}[rEXP] +% \begin{macro}[EXP]{\@@_output_uncert_A_loop:nnn, \@@_output_uncert_S_loop:nnn} +% \begin{macro}[EXP]{\@@_output_uncert_S_loop:w} +% \begin{macro}[EXP]{\@@_output_uncert_A:nnnn, \@@_output_uncert_A_multi:nnnn} +% \begin{macro}[EXP]{\@@_output_uncert_A:nnnnn} +% \begin{macro}[EXP] % { % \@@_output_uncert_S:nnnn , % \@@_output_uncert_S_sep:nnnn , % \@@_output_uncert_S_multi:nnnn % } -% \begin{macro}[rEXP] +% \begin{macro}[EXP] % { % \@@_output_uncert_S_compact:nn , % \@@_output_uncert_S_compact-marker:nn , % \@@_output_uncert_S_full:nn % } -% \begin{macro}[rEXP] +% \begin{macro}[EXP] % {\@@_output_uncert_augment:nnnn} -% \begin{macro}[rEXP] -% {\@@_output_uncert_augment:nnn} -% \begin{macro}[rEXP] -% {\@@_output_uncert_augment:nnnw, \@@_output_uncert_augment:fnnw} -% \begin{macro}[rEXP]{\@@_output_uncert_augment:nnw} -% \begin{macro}[rEXP] +% \begin{macro}[EXP] +% {\@@_output_uncert_augment:nnn, \@@_output_uncert_augment:enn} +% \begin{macro}[EXP] +% {\@@_output_uncert_augment:nnnw, \@@_output_uncert_augment:ennw} +% \begin{macro}[EXP]{\@@_output_uncert_augment:nnw} +% \begin{macro}[EXP] % { % \@@_output_exponent:nnnnn , % \@@_output_exponent_auxi:nnnnn , -% \@@_output_exponent_auxii:nnnnn +% \@@_output_exponent_auxii:nnnnn , +% \@@_output_exponent_auxiii:nnnnn % } -% \begin{macro}[rEXP]{\@@_output_exponent_auxiii:nn} -% \begin{macro}[rEXP]{\@@_output_end:} +% \begin{macro}[EXP]{\@@_output_exponent_auxiv:nn} +% \begin{macro}[EXP]{\@@_output_end:} % The approach to formatting a single number is to split into % the constituent parts. All of the parts are assembled including % inserting tabular alignment markers (which may be empty) for each @@ -3939,10 +4000,12 @@ % \begin{macrocode} \cs_new:Npn \siunitx_number_output:N #1 { \@@_output:Nn #1 { } } +\cs_generate_variant:Nn \siunitx_number_output:N { c } \cs_new:Npn \siunitx_number_output:n #1 { \@@_output:nn #1 { } } \cs_new:Npn \siunitx_number_output:NN #1#2 { \@@_output:Nn #1 {#2} } +\cs_generate_variant:Nn \siunitx_number_output:NN { c } \cs_new:Npn \siunitx_number_output:nN #1#2 { \@@_output:nn #1 {#2} } \cs_new:Npn \@@_output:Nn #1#2 @@ -3982,7 +4045,11 @@ { \bool_lazy_or_p:nn { \l_@@_zero_exponent_bool } - { ! \str_if_eq_p:nn {#2} { 0 } } + { + ! \bool_lazy_or_p:nn + { \tl_if_blank_p:n {#2} } + { \str_if_eq_p:nn {#2} { 0 } } + } } } \@@_output_bracket:w @@ -4118,7 +4185,7 @@ { \@@_output_digits:nn { decimal } {#1} } } } -\cs_generate_variant:Nn \@@_output_decimal:nn { f } +\cs_generate_variant:Nn \@@_output_decimal:nn { e } \cs_new:Npn \@@_output_digits:nn #1#2 { \bool_if:cTF { l_@@_group_ #1 _ bool } @@ -4192,13 +4259,14 @@ % \begin{macrocode} \cs_new:Npn \@@_output_integer_first:n #1 { - \exp_args:Ne \@@_output_integer_aux:n { \tl_reverse:n {#1} } + \@@_output_integer_aux:e { \tl_reverse:n {#1} } } \cs_new:Npn \@@_output_integer_aux:n #1 { \@@_output_integer_loop:NnnN \l_@@_group_first_int { 0 } { } #1 \q_recursion_tail \q_recursion_stop } +\cs_generate_variant:Nn \@@_output_integer_aux:n { e } \cs_new:Npn \@@_output_integer_loop:NnnN #1#2#3#4 { \quark_if_recursion_tail_stop_do:Nn #4 {#3} @@ -4325,7 +4393,7 @@ % \begin{macrocode} \cs_new:Npn \@@_output_uncert:nnnn #1#2#3#4 { - \exp_args:NV \@@_output_uncert:nnnnn \l_@@_uncert_desc_clist + \@@_output_uncert:Vnnnn \l_@@_uncert_desc_clist {#1} {#2} {#3} {#4} } \cs_new:Npn \@@_output_uncert:nnnnn #1#2#3#4#5 @@ -4333,6 +4401,7 @@ \@@_output_uncert_loop:nnN {#2} {#3} #4 \q_recursion_tail #1 , \q_recursion_stop {#5} } +\cs_generate_variant:Nn \@@_output_uncert:nnnnn { V } \cs_new:Npn \@@_output_uncert_loop:nnN #1#2#3 { \quark_if_recursion_tail_stop:N #3 @@ -4473,7 +4542,7 @@ % \begin{macrocode} \cs_new:Npn \@@_output_uncert_augment:nnnn #1#2#3#4 { - \exp_args:Nf \@@_output_uncert_augment:nnn + \@@_output_uncert_augment:enn { \int_eval:n { \tl_count:n {#1} - \tl_count:n {#2} } } {#3} {#4} } @@ -4481,7 +4550,7 @@ { \int_compare:nNnTF {#1} > 0 { - \@@_output_uncert_augment:fnnw + \@@_output_uncert_augment:ennw { \int_eval:n { #1 - 1 } } {#3} { } @@ -4489,7 +4558,7 @@ } { 0 - \@@_output_decimal:fn + \@@_output_decimal:en { \prg_replicate:nn { \int_abs:n {#1} } { 0 } #2 @@ -4497,6 +4566,7 @@ {#3} } } +\cs_generate_variant:Nn \@@_output_uncert_augment:nnn { e } \cs_new:Npn \@@_output_uncert_augment:nnnw #1#2#3#4 { \quark_if_nil:NF #4 @@ -4504,14 +4574,14 @@ \int_compare:nNnTF {#1} = 0 { \@@_output_uncert_augment:nnw {#3#4} {#2} } { - \@@_output_uncert_augment:fnnw + \@@_output_uncert_augment:ennw { \int_eval:n { #1 - 1 } } {#2} {#3#4} } } } -\cs_generate_variant:Nn \@@_output_uncert_augment:nnnw { f } +\cs_generate_variant:Nn \@@_output_uncert_augment:nnnw { e } \cs_new:Npn \@@_output_uncert_augment:nnw #1#2#3 \q_nil { \@@_output_digits:nn { integer } {#1} @@ -4529,18 +4599,28 @@ \cs_new:Npn \@@_output_exponent:nnnnn #1#2#3#4#5 { \exp_not:n {#5} + \str_if_empty:nTF {#2} + { + \bool_if:NTF \l_@@_zero_exponent_bool + { \@@_output_exponent_auxi:nnnnn {#1} { 0 } {#3} {#4} {#5} } + { \exp_not:n {#5} } + } + { \@@_output_exponent_auxi:nnnnn {#1} {#2} {#3} {#4} {#5} } + } +\cs_new:Npn \@@_output_exponent_auxi:nnnnn #1#2#3#4#5 + { \bool_lazy_or:nnTF { \l_@@_zero_exponent_bool } { ! \str_if_eq_p:nn {#2} { 0 } } { \tl_if_empty:NTF \l_@@_output_exp_marker_tl - { \@@_output_exponent_auxi:nnnnn } { \@@_output_exponent_auxii:nnnnn } + { \@@_output_exponent_auxiii:nnnnn } {#1} {#2} {#3} {#4} {#5} } { \exp_not:n {#5} } } -\cs_new:Npn \@@_output_exponent_auxi:nnnnn #1#2#3#4#5 +\cs_new:Npn \@@_output_exponent_auxii:nnnnn #1#2#3#4#5 { \bool_lazy_or:nnT { @@ -4562,15 +4642,15 @@ \exp_not:n {#5} \exp_not:V \l_@@_exponent_base_tl ^ - { \@@_output_exponent_auxiii:nnn { } {#1} {#2} } + { \@@_output_exponent_auxiv:nnn { } {#1} {#2} } } -\cs_new:Npn \@@_output_exponent_auxii:nnnnn #1#2#3#4#5 +\cs_new:Npn \@@_output_exponent_auxiii:nnnnn #1#2#3#4#5 { \exp_not:n {#5} \exp_not:V \l_@@_output_exp_marker_tl - \@@_output_exponent_auxiii:nnn { \mathord } {#1} {#2} + \@@_output_exponent_auxiv:nnn { \mathord } {#1} {#2} } -\cs_new:Npn \@@_output_exponent_auxiii:nnn #1#2#3 +\cs_new:Npn \@@_output_exponent_auxiv:nnn #1#2#3 { \tl_if_blank:nTF {#2} { diff --git a/Master/texmf-dist/source/latex/siunitx/siunitx-print.dtx b/Master/texmf-dist/source/latex/siunitx/siunitx-print.dtx index 6786aba79e1..f802bd7353d 100644 --- a/Master/texmf-dist/source/latex/siunitx/siunitx-print.dtx +++ b/Master/texmf-dist/source/latex/siunitx/siunitx-print.dtx @@ -106,7 +106,7 @@ % { % \siunitx_print_number:n, \siunitx_print_number:V, % \siunitx_print_number:x, -% \siunitx_print_unit:n, \siunitx_print_unit:V, +% \siunitx_print_unit:n, \siunitx_print_unit:V, \siunitx_print_unit:o, % \siunitx_print_unit:x % } % \begin{syntax} @@ -347,12 +347,10 @@ \AtBeginDocument { \RequirePackage { color } } % \end{macrocode} % -% \begin{macro}{\tl_replace_all:NVn} % Required variants. % \begin{macrocode} \cs_generate_variant:Nn \tl_replace_all:Nnn { NV } % \end{macrocode} -% \end{macro} % % \begin{variable}{\l_@@_tmp_tl} % Scratch space. @@ -461,7 +459,7 @@ % { % \siunitx_print_number:n, \siunitx_print_number:V, % \siunitx_print_number:x, -% \siunitx_print_unit:n, \siunitx_print_unit:V, +% \siunitx_print_unit:n, \siunitx_print_unit:V, \siunitx_print_unit:o, % \siunitx_print_unit:x % } % \begin{macro}{\@@_aux:nn} @@ -476,14 +474,14 @@ \cs_generate_variant:Nn \siunitx_print_number:n { V , x } \cs_new_protected:Npn \siunitx_print_unit:n #1 { \@@_aux:nn { unit } {#1} } -\cs_generate_variant:Nn \siunitx_print_unit:n { V , x } +\cs_generate_variant:Nn \siunitx_print_unit:n { V , o , x } \cs_new_protected:Npn \@@_aux:nn #1#2 { \tl_if_empty:oF {#2} { \tl_if_empty:cTF { l_@@_ #1 _color_tl } { \use:n } - { \exp_args:Nv \textcolor { l_@@_ #1 _color_tl } } + { \ExpandArgs { v } \textcolor { l_@@_ #1 _color_tl } } { \use:c { @@ -576,11 +574,12 @@ % \begin{macro}{\@@_math_replace:Nn} % \begin{macro} % { -% \@@_math_auxiii:n, -% \@@_math_auxiv:n, +% \@@_math_auxiii:n , +% \@@_math_auxiii:V , +% \@@_math_auxiv:n , % \@@_math_auxv:n % } -% \begin{macro}{\@@_math_auxvi:Nn} +% \begin{macro}{\@@_math_auxvi:Nn, \@@_math_auxvi:NV} % \begin{macro}{\@@_math_auxvii:N} % \begin{macro}{\@@_math_auxviii:w} % \begin{macro}{\@@_math_auxix:Nn} @@ -677,7 +676,7 @@ \exp_after:wN \@@_math_replace:Nn \l_@@_math_html_tl \q_recursion_tail { } \q_recursion_stop - \exp_args:NV \@@_math_auxiii:n \l_@@_tmp_tl + \@@_math_auxiii:V \l_@@_tmp_tl \group_end: } % \end{macrocode} @@ -718,6 +717,7 @@ { \@@_math_auxiv:n } {#1} } +\cs_generate_variant:Nn \@@_math_auxiii:n { V } % \end{macrocode} % Now we deal with the font selection in math mode. There are two possible % cases. First, we are retaining the current math font, and the active one is @@ -747,6 +747,7 @@ } \cs_new_protected:Npn \@@_math_auxvi:Nn #1#2 { \@@_math_ensure:n { #1 {#2} } } +\cs_generate_variant:Nn \@@_math_auxvi:Nn { NV } \cs_new_protected:Npn \@@_math_auxvii:N #1 { \quark_if_recursion_tail_stop_do:Nn #1 { \@@_math_auxv:n } @@ -775,8 +776,7 @@ \tl_replace_all:Nnn \exp_not:N \l_@@_tmp_tl { ^ } { \exp_not:N \@@_math_super:n } - \exp_not:N \exp_args:NNV \@@_math_auxvi:Nn - #1 \exp_not:N \l_@@_tmp_tl + \@@_math_auxvi:NV #1 \exp_not:N \l_@@_tmp_tl \group_end: } \cs_new_protected:Npx \@@_math_sub:n #1 @@ -831,6 +831,7 @@ % % \begin{macro}{\siunitx_print_text:n} % \begin{macro}{\@@_text_replace:n, \@@_text_replace_aux:n} +% \begin{macro}{\@@_text_replace_font:N} % \begin{macro}[EXP]{\@@_text_replace_first:N} % \begin{macro}{\@@_text_replace:N} % \begin{macro}{\@@_text_replace:NNn} @@ -865,7 +866,8 @@ } { \selectfont } \tl_use:N \l_@@_text_font_tl - \exp_args:NnV \tl_if_head_eq_meaning:nNTF {#1} \l_siunitx_unit_fraction_tl + \exp_last_unbraced:Nno \tl_if_head_eq_meaning:nNTF + {#1} \l_siunitx_unit_fraction_tl { \@@_text_fraction:Nnn #1 } { \@@_text_replace:n {#1} } } @@ -874,6 +876,11 @@ % To get math mode material to print in text mode, various search-and-replace % steps are needed. We use \tn{protected@edef} to deal with commands, partly % for speed and partly as it deals with anything nested inside \cs{mathord}. +% On the other hand, the unit font command has to be handled at exactly one +% level, so that it does not affect anything inside for example +% \cs{ensuremath}. That means preventing any change inside the +% \tn{protected@edef}, hence the \cs{cs_set_eq:NN} to \cs{scan_stop:} +% (for \LaTeXe{} robust commands). % \begin{macrocode} \cs_new_protected:Npn \@@_text_replace:n #1 { @@ -884,8 +891,12 @@ \tl_set:Nn \l_@@_tmp_tl {#1} \tl_if_empty:NF \l_@@_tmp_tl { + \@@_text_replace_font:N \l_@@_tmp_tl \tl_if_empty:NF \l_siunitx_unit_font_tl - { \exp_after:wN \cs_set_eq:NN \l_siunitx_unit_font_tl \use:n } + { + \exp_after:wN + \cs_set_eq:NN \l_siunitx_unit_font_tl \scan_stop: + } \cs_set:Npn \mathord ##1 { \@@_text_replace_first:N ##1 } \group_begin: @@ -911,6 +922,14 @@ \group_end: } \cs_new_protected:Npn \@@_text_replace_aux:n #1 {#1} +\cs_new_protected:Npn \@@_text_replace_font:N #1 + { + \tl_if_empty:NF \l_siunitx_unit_font_tl + { + \tl_replace_all:NVn #1 + \l_siunitx_unit_font_tl { \use:n } + } + } \cs_new:Npn \@@_text_replace_first:N #1 { \str_case:nnF {#1} @@ -939,6 +958,7 @@ \exp_not:N \q_recursion_tail { ? } \exp_not:N \q_recursion_stop + \@@_text_replace_font:N #1 } \cs_new_protected:Npn \@@_text_replace:NNn #1#2#3 { @@ -963,7 +983,8 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_print_replace_frac:n #1 { - \exp_args:NnV \tl_if_head_eq_meaning:nNTF {#1} \l_siunitx_unit_fraction_tl + \exp_last_unbraced:Nno \tl_if_head_eq_meaning:nNTF + {#1} \l_siunitx_unit_fraction_tl { \@@_text_fraction:Nnn #1 } { \mbox { \@@_text_replace:n {#1} } } } @@ -1085,6 +1106,7 @@ % \end{macro} % \end{macro} % \end{macro} +% \end{macro} % % \subsection{Standard settings for module options} % diff --git a/Master/texmf-dist/source/latex/siunitx/siunitx-quantity.dtx b/Master/texmf-dist/source/latex/siunitx/siunitx-quantity.dtx index 2b2e783eedf..a89ee786824 100644 --- a/Master/texmf-dist/source/latex/siunitx/siunitx-quantity.dtx +++ b/Master/texmf-dist/source/latex/siunitx/siunitx-quantity.dtx @@ -222,7 +222,7 @@ % \begin{macro}{\@@_parsed_aux:w} % \begin{macro}{\@@_parsed_aux:nnnw} % \begin{macro}{\@@_parsed_aux:nnnnw} -% \begin{macro}{\@@_parsed_aux:nnnn} +% \begin{macro}{\@@_parsed_aux:nnnn, \@@_parsed_aux:onnn} % \begin{macro}{\@@_parsed_aux:nnn} % For quantities, there is bit to do to combine things. The first question is % whether we are parsing at all: if not, things are quite short. Notice that @@ -268,7 +268,7 @@ \cs_new_protected:cpn { @@_parsed_combine-exponent:n } #1 { \siunitx_number_process:NN \l_@@_number_tl \l_@@_number_tl - \exp_args:NV \@@_extract_exp:nNN + \@@_extract_exp:VNN \l_@@_number_tl \l_@@_tmp_fp \l_@@_number_tl \siunitx_unit_format_combine_exponent:nnN {#1} \l_@@_tmp_fp \l_@@_unit_tl @@ -303,7 +303,7 @@ { \@@_parsed_aux:nnnnw {#1} {#2} {#3} {#4} ? } \cs_new_protected:Npn \@@_parsed_aux:nnnnw #1#2#3#4 #5 \q_nil #6 \q_stop - { \exp_args:No \@@_parsed_aux:nnnn { \use_none:n #5#6 } {#1} {#2} {#3#4} } + { \@@_parsed_aux:onnn { \use_none:n #5#6 } {#1} {#2} {#3#4} } \cs_new_protected:Npn \@@_parsed_aux:nnnn #1#2#3#4 { \tl_if_blank:nTF {#4} @@ -332,6 +332,7 @@ } } } +\cs_generate_variant:Nn \@@_parsed_aux:nnnn { o } % \end{macrocode} % For the case of a separated uncertainty with repeated units, we print the % two parts independently. The third argument here is the exponent if there @@ -353,13 +354,14 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\@@_extract_exp:nNN} +% \begin{macro}{\@@_extract_exp:nNN, \@@_extract_exp:VNN} % \begin{macro}{\@@_extract_exp:nnnnnnnNN} % To extract the exponent part for a combined prefix, we decompose the value % and remove it. % \begin{macrocode} \cs_new_protected:Npn \@@_extract_exp:nNN #1#2#3 { \@@_extract_exp:nnnnnnnNN #1 #2 #3 } +\cs_generate_variant:Nn \@@_extract_exp:nNN { V } \cs_new_protected:Npn \@@_extract_exp:nnnnnnnNN #1#2#3#4#5#6#7#8#9 { \fp_set:Nn #8 {#6#7} @@ -397,9 +399,7 @@ { \nobreak } \siunitx_print_unit:n {#2} } - { - \exp_args:No \siunitx_print_unit:n { \use_none:n #2 } - } + { \siunitx_print_unit:o { \use_none:n #2 } } } } \cs_generate_variant:Nn \siunitx_quantity_print:nn { nV , VV , xV } diff --git a/Master/texmf-dist/source/latex/siunitx/siunitx-symbol.dtx b/Master/texmf-dist/source/latex/siunitx/siunitx-symbol.dtx index 8a7bad09b88..037e39ffc7b 100644 --- a/Master/texmf-dist/source/latex/siunitx/siunitx-symbol.dtx +++ b/Master/texmf-dist/source/latex/siunitx/siunitx-symbol.dtx @@ -286,7 +286,7 @@ { \@ifpackageloaded { hyperref } { - \exp_args:Nx \pdfstringdefDisableCommands + \ExpandArgs { x } \pdfstringdefDisableCommands { \cs_set_eq:NN \siunitx_print_text:n \exp_not:N \use:n \siunitx_declare_unit:Nn \exp_not:N \ohm diff --git a/Master/texmf-dist/source/latex/siunitx/siunitx-table.dtx b/Master/texmf-dist/source/latex/siunitx/siunitx-table.dtx index 3fe8d34a5d5..1eaf959a6b4 100644 --- a/Master/texmf-dist/source/latex/siunitx/siunitx-table.dtx +++ b/Master/texmf-dist/source/latex/siunitx/siunitx-table.dtx @@ -235,6 +235,11 @@ %<@@=siunitx_table> % \end{macrocode} % +% Required core variants. +% \begin{macrocode} +\cs_generate_variant:Nn \keys_set:nn { nx } +% \end{macrocode} +% % \begin{variable}{\l_@@_tmp_box, \l_@@_tmp_dim, \l_@@_tmp_tl} % Scratch space. % \begin{macrocode} @@ -445,7 +450,7 @@ { \exp_args:NNV \group_end: \@@_collect_end:n \l_@@_collect_tl - \exp_args:NV \@@_split:nNNN + \@@_split:VNNN \l_@@_collect_tl \l_@@_before_tl \l_@@_number_tl @@ -487,7 +492,7 @@ % \end{macro} % \end{macro} % -% \begin{macro}{\@@_split:nNNN} +% \begin{macro}{\@@_split:nNNN, \@@_split:VNNN} % \begin{macro}{\@@_split_loop:NNN} % \begin{macro}{\@@_split_group:NNNn} % \begin{macro}{\@@_split_token:NNNN} @@ -504,6 +509,7 @@ \@@_split_tidy:N #2 \@@_split_tidy:N #4 } +\cs_generate_variant:Nn \@@_split:nNNN { V } \cs_new_protected:Npn \@@_split_loop:NNN #1#2#3 { \peek_remove_spaces:n @@ -853,7 +859,7 @@ \l_@@_before_model_tl \l_@@_model_tl \l_@@_after_model_tl - \exp_args:NV \@@_generate_model:n \l_@@_model_tl + \@@_generate_model:V \l_@@_model_tl \tl_set:Nn \l_@@_align_mode_tl { format } } , table-model-setup .tl_set:N = @@ -877,10 +883,10 @@ % \end{macrocode} % \end{variable} % -% \begin{macro}{\@@_generate_model:n} +% \begin{macro}{\@@_generate_model:n, \@@_generate_model:V} % \begin{macro}{\@@_generate_model:nnnnnnn} % \begin{macro}[EXP]{\@@_generate_model_S:nnw} -% \begin{macro}[EXP]{\@@_generate_model_S:nnn} +% \begin{macro}[EXP]{\@@_generate_model_S:nnn, \@@_generate_model_S:een} % Creating a model for a table at this stage means parsing the format and % converting that to an appropriate model. Things are quite straight-forward % other than the uncertainty part. At this stage there is no point in @@ -902,6 +908,7 @@ \l_@@_format_tl } } +\cs_generate_variant:Nn \@@_generate_model:n { V } \cs_new_protected:Npn \@@_generate_model:nnnnnnn #1#2#3#4#5#6#7 { \tl_set:Nx \l_@@_model_tl @@ -922,9 +929,9 @@ } \exp_not:n { {#6} } { - \int_compare:nNnTF {#7} = 0 + \int_compare:nNnTF { 0#7 } = 0 { 0 } - { \prg_replicate:nn {#7} { 8 } } + { \prg_replicate:nn { 0#7 } { 8 } } } } } @@ -932,7 +939,7 @@ { { S } { - \exp_args:Nff \@@_generate_model_S:nnn + \@@_generate_model_S:een { \tl_count:n {#1} } { \tl_count:n {#3} } {#3} } @@ -951,6 +958,7 @@ } { 8 } } +\cs_generate_variant:Nn \@@_generate_model_S:nnn { ee } % \end{macrocode} % \end{macro} % \end{macro} @@ -1271,7 +1279,12 @@ #1 \q_nil #2 \q_nil #3 \q_nil #4 \q_nil #5 \q_nil #6 \q_nil #7 \q_nil #8 \q_stop { - \exp_not:n {#1#2#3#4#5#6} + \bool_lazy_and:nnTF + { \tl_if_blank_p:n {#1#2} } + { ! \tl_if_blank_p:n {#3} } + { { } } + { \exp_not:n {#1#2} } + \exp_not:n {#3#4#5#6} \tl_if_blank:nT {#1#2#3#4#5#6} { { } } \exp_not:n {#7#8} } @@ -1298,7 +1311,7 @@ \group_begin: \bool_if:NT \l_@@_auto_round_bool { - \exp_args:Nx \keys_set:nn { siunitx } + \keys_set:nx { siunitx } { round-mode = places , round-pad = true , diff --git a/Master/texmf-dist/source/latex/siunitx/siunitx-unit.dtx b/Master/texmf-dist/source/latex/siunitx/siunitx-unit.dtx index 34ccb1ec827..ee458b3f883 100644 --- a/Master/texmf-dist/source/latex/siunitx/siunitx-unit.dtx +++ b/Master/texmf-dist/source/latex/siunitx/siunitx-unit.dtx @@ -93,7 +93,7 @@ % % \section{Formatting units} % -% \begin{function}{\siunitx_unit_format:nN} +% \begin{function}{\siunitx_unit_format:nN, \siunitx_unit_format:VN} % \begin{syntax} % \cs{siunitx_unit_format:nN} \Arg{units} \meta{tl~var} % \end{syntax} @@ -1062,7 +1062,7 @@ % \end{macrocode} % \end{variable} % -% \begin{macro}{\siunitx_unit_format:nN} +% \begin{macro}{\siunitx_unit_format:nN, \siunitx_unit_format:VN} % \begin{macro}{\siunitx_unit_format_extract_prefixes:nNN} % \begin{macro}{\siunitx_unit_format_combine_exponent:nnN} % \begin{macro}{\siunitx_unit_format_multiply:nnN} @@ -1098,6 +1098,7 @@ \fp_set:Nn \l_@@_multiple_fp { \c_one_fp } \@@_format:nNN {#1} #2 \l_@@_tmp_fp } +\cs_generate_variant:Nn \siunitx_unit_format:nN { V } \cs_new_protected:Npn \siunitx_unit_format_extract_prefixes:nNN #1#2#3 { \bool_set_true:N \l_@@_prefix_exp_bool @@ -1249,6 +1250,7 @@ { \token_to_str:N ^ } { ^ } \tl_replace_all:Nnn \exp_not:N \l_@@_tmp_tl { \token_to_str:N _ } { \c_@@_math_subscript_tl } + \cs_set_eq:NN \exp_not:N \text \scan_stop: \char_set_active_eq:NN ^ \exp_not:N \@@_format_literal_superscript: \char_set_active_eq:NN _ diff --git a/Master/texmf-dist/source/latex/siunitx/siunitx.dtx b/Master/texmf-dist/source/latex/siunitx/siunitx.dtx index 96f6999841e..f2ec215fa5f 100644 --- a/Master/texmf-dist/source/latex/siunitx/siunitx.dtx +++ b/Master/texmf-dist/source/latex/siunitx/siunitx.dtx @@ -121,7 +121,7 @@ % % Identify the package and give the over all version information. % \begin{macrocode} -\ProvidesExplPackage {siunitx} {2023-08-24} {3.3.4} +\ProvidesExplPackage {siunitx} {2023-08-30} {3.3.5} {A comprehensive (SI) units package} % \end{macrocode} % @@ -572,7 +572,7 @@ \cs_set_protected:Npn \@@_tmp:w \NC@do ##1##2 \NC@do #1 { \NC@list { \NC@do ##1 \NC@do #1 ##2 } } \exp_after:wN \@@_tmp:w \the \NC@list - \exp_args:NNc \renewcommand * { NC@rewrite@ #1 } [ 1 ] [ ] + \ExpandArgs { Nc } \renewcommand * { NC@rewrite@ #1 } [ 1 ] [ ] { \@temptokena \expandafter { @@ -629,7 +629,7 @@ % \begin{macrocode} \cs_new_protected:Npn \@@_bookmark_cmd:Nnn #1#2#3 { - \exp_args:Nc \DeclareExpandableDocumentCommand + \ExpandArgs { c } \DeclareExpandableDocumentCommand { \cs_to_str:N #1 \c_space_tl ( pdfstring ~ context ) } {#2} {#3} } @@ -788,12 +788,13 @@ { 0 \exp_not:N \@@_list_count:w \c_space_tl - #1 \exp_not:n { ; \q_recursion_tail ; \q_recursion_stop } + #1 + \exp_not:n { ; \s_stop \use_none_delimit_by_q_stop:w ; \q_stop } } } \cs_new:Npx \@@_list_count:w #1 ; { - \exp_not:n { \exp_args:Nf \quark_if_recursion_tail_stop:n } {#1} + \exp_not:N \use_none_delimit_by_s_stop:w #1 \exp_not:N \s_stop \exp_not:N \tl_if_blank:nF {#1} { + 1 } \exp_not:N \@@_list_count:w \c_space_tl } |