From 1f21169c727289a07ebcdb4a049efc6457259558 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 14 Sep 2021 20:25:36 +0000 Subject: siunitx (14sep21) git-svn-id: svn://tug.org/texlive/trunk@60510 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/siunitx/CHANGELOG.md | 18 +++- .../texmf-dist/doc/latex/siunitx/siunitx-code.pdf | Bin 1512430 -> 1513922 bytes Master/texmf-dist/doc/latex/siunitx/siunitx.pdf | Bin 636993 -> 637245 bytes .../source/latex/siunitx/siunitx-angle.dtx | 3 + .../source/latex/siunitx/siunitx-print.dtx | 101 ++++++++++++++------- Master/texmf-dist/source/latex/siunitx/siunitx.dtx | 6 +- Master/texmf-dist/source/latex/siunitx/siunitx.tex | 10 +- Master/texmf-dist/tex/latex/siunitx/siunitx.sty | 80 ++++++++++------ 8 files changed, 153 insertions(+), 65 deletions(-) diff --git a/Master/texmf-dist/doc/latex/siunitx/CHANGELOG.md b/Master/texmf-dist/doc/latex/siunitx/CHANGELOG.md index 614260e8454..f12b69375bc 100644 --- a/Master/texmf-dist/doc/latex/siunitx/CHANGELOG.md +++ b/Master/texmf-dist/doc/latex/siunitx/CHANGELOG.md @@ -7,6 +7,21 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to ## [Unreleased] +## [v3.0.30] + +### Changed +- Delay selection of math mode to better support `tex4ht` (issue + [#530](https://github.com/josephwright/siunitx/issues/530)) + +### Fixed +- Ensure that units contain `\text` are correctly formatted when printing + in math mode (issue + [#542](https://github.com/josephwright/siunitx/issues/542)) +- Use `\ExplLoaderFileDate` to test for `expl3` version (issue + [#544](https://github.com/josephwright/siunitx/issues/544)) +- Apply number processing options to angles (issue + [#546](https://github.com/josephwright/siunitx/issues/546)) + ## [v3.0.29] ### Fixed @@ -1564,7 +1579,8 @@ Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to ### Added - First public testing release (as `si`) -[Unreleased]: https://github.com/josephwright/siunitx/compare/v3.0.29...HEAD +[Unreleased]: https://github.com/josephwright/siunitx/compare/v3.0.30...HEAD +[v3.0.30]: https://github.com/josephwright/siunitx/compare/v3.0.29...v3.0.30 [v3.0.29]: https://github.com/josephwright/siunitx/compare/v3.0.28...v3.0.29 [v3.0.28]: https://github.com/josephwright/siunitx/compare/v3.0.27...v3.0.28 [v3.0.27]: https://github.com/josephwright/siunitx/compare/v3.0.26...v3.0.27 diff --git a/Master/texmf-dist/doc/latex/siunitx/siunitx-code.pdf b/Master/texmf-dist/doc/latex/siunitx/siunitx-code.pdf index e674520e65c..9a8ebfd7c0d 100644 Binary files a/Master/texmf-dist/doc/latex/siunitx/siunitx-code.pdf and b/Master/texmf-dist/doc/latex/siunitx/siunitx-code.pdf differ diff --git a/Master/texmf-dist/doc/latex/siunitx/siunitx.pdf b/Master/texmf-dist/doc/latex/siunitx/siunitx.pdf index 6f9ceb00c1c..171b0a74b50 100644 Binary files a/Master/texmf-dist/doc/latex/siunitx/siunitx.pdf and b/Master/texmf-dist/doc/latex/siunitx/siunitx.pdf differ diff --git a/Master/texmf-dist/source/latex/siunitx/siunitx-angle.dtx b/Master/texmf-dist/source/latex/siunitx/siunitx-angle.dtx index a3d46080670..9d9a2ac7531 100644 --- a/Master/texmf-dist/source/latex/siunitx/siunitx-angle.dtx +++ b/Master/texmf-dist/source/latex/siunitx/siunitx-angle.dtx @@ -248,6 +248,7 @@ { \exp_args:Ne \@@_arc_convert:n { \fp_eval:n {#1} } } { \siunitx_number_parse:nN {#1} \l_@@_degrees_tl + \siunitx_number_process:NN \l_@@_degrees_tl \l_@@_degrees_tl \tl_set:Nx \l_@@_degrees_tl { \siunitx_number_output:NN \l_@@_degrees_tl \q_nil } \@@_arc_print:VVV @@ -349,6 +350,8 @@ { \tl_if_empty:cF { l_@@_ ##1 _tl } { + \exp_args:Ncc \siunitx_number_process:NN + { l_@@_ ##1 _tl } { l_@@_ ##1 _tl } \tl_set:cx { l_@@_ ##1 _tl } { \exp_args:Nc \siunitx_number_output:NN diff --git a/Master/texmf-dist/source/latex/siunitx/siunitx-print.dtx b/Master/texmf-dist/source/latex/siunitx/siunitx-print.dtx index 5b14aa123bc..05ba3d64ea1 100644 --- a/Master/texmf-dist/source/latex/siunitx/siunitx-print.dtx +++ b/Master/texmf-dist/source/latex/siunitx/siunitx-print.dtx @@ -303,10 +303,15 @@ % % \subsection{Initial set up} % -% The printing routines depend on \pkg{amstext} for text mode working. +% \begin{macro}{\@@_ams_text:n} +% The printing routines depend on \pkg{amstext} for text mode working. +% We also save the definition of \cs{text} here to use it internally, as the +% nature of the \emph{document} command may need to vary. % \begin{macrocode} \RequirePackage { amstext } +\cs_new_eq:NN \@@_ams_text:n \text % \end{macrocode} +% \end{macro} % % Color support is always required. % \begin{macrocode} @@ -511,6 +516,12 @@ % \end{macrocode} % \end{variable} % +% \begin{variable}{\l_@@_math_html_tl} +% \begin{macrocode} +\tl_new:N \l_@@_math_html_tl +% \end{macrocode} +% \end{variable} +% % \begin{macro}{\siunitx_print_math:n} % \begin{macro}[EXP]{\@@_extract_series:Nw} % \begin{macro}[EXP]{\@@_convert_series:n, \@@_convert_series:v} @@ -519,15 +530,20 @@ % { % \@@_math_auxi:n, % \@@_math_auxii:n, +% } +% \begin{macro}{\@@_math_replace:Nn} +% \begin{macro} +% { % \@@_math_auxiii:n, % \@@_math_auxiv:n, % \@@_math_auxv:n % } -% \begin{macro}{\@@_math_aux:N} -% \begin{macro}{\@@_math_aux:w} -% \begin{macro}{\@@_math_aux:Nn, \@@_math_aux:cn} +% \begin{macro}{\@@_math_auxvi:Nn} +% \begin{macro}{\@@_math_auxvii:N} +% \begin{macro}{\@@_math_auxviii:w} +% \begin{macro}{\@@_math_auxix:Nn} % \begin{macro}{\@@_math_sub:n, \@@_math_super:n, \@@_math_script:n} -% \begin{macro}{\@@_math_text:n} +% \begin{macro}{\@@_math_ensure:n} % The first step in setting in math mode is to check on the math version. % The starting point is the question of whether text series needs to % propagate to math mode: if so, check on the mapping, otherwise check on @@ -603,7 +619,25 @@ % commands have different |\long| status. % \begin{macrocode} \cs_new_protected:Npn \@@_math_auxii:n #1 - { \ensuremath { \@@_math_auxiii:n {#1} } } + { + \group_begin: + \cs_set_protected:Npn \text ##1 + { + \cs_set_eq:NN \text \@@_ams_text:n + \siunitx_print_text:n {##1} + } + \tl_set:Nn \l_@@_tmp_tl {#1} + \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 + \group_end: + } +\cs_new_protected:Npn \@@_math_replace:Nn #1#2 + { + \quark_if_recursion_tail_stop:N #1 + \tl_replace_all:Nnn \l_@@_tmp_tl {#1} {#2} + } \cs_new_protected:Npn \@@_math_auxiii:n #1 { \bool_if:NTF \l_@@_math_family_bool @@ -611,8 +645,8 @@ \str_case_e:nnF { \f@family } { { \rmdefault } { \@@_math_auxv:n } - { \sfdefault } { \@@_math_aux:Nn \mathsf } - { \ttdefault } { \@@_math_aux:Nn \mathtt } + { \sfdefault } { \@@_math_auxix:Nn \mathsf } + { \ttdefault } { \@@_math_auxix:Nn \mathtt } } { \@@_math_auxiv:n } } @@ -630,7 +664,7 @@ { \bool_if:NTF \l_@@_math_font_bool { - \@@_math_aux:N + \@@_math_auxvii:N \mathbf \mathit \mathsf \mathtt \q_recursion_tail \q_recursion_stop } @@ -642,28 +676,30 @@ \bool_lazy_or:nnTF { \int_compare_p:nNn \fam = { -1 } } { \int_compare_p:nNn \fam = \symoperators } - { \use:n } - { \mathrm } + { \@@_math_ensure:n } + { \@@_math_auxvi:Nn \mathrm } {#1} } -\cs_new_protected:Npn \@@_math_aux:N #1 +\cs_new_protected:Npn \@@_math_auxvi:Nn #1#2 + { \@@_math_ensure:n { #1 {#2} } } +\cs_new_protected:Npn \@@_math_auxvii:N #1 { - \quark_if_recursion_tail_stop_do:Nn #1 { \use:n } - \exp_after:wN \exp_after:wN \exp_after:wN \@@_math_aux:w + \quark_if_recursion_tail_stop_do:Nn #1 { \@@_math_auxv:n } + \exp_after:wN \exp_after:wN \exp_after:wN \@@_math_auxviii:w \cs:w \cs_to_str:N #1 \c_space_tl \cs_end: \use@mathgroup ? { -2 } \q_stop #1 } -\cs_new_protected:Npn \@@_math_aux:w #1 \use@mathgroup #2#3 #4 \q_stop #5 +\cs_new_protected:Npn \@@_math_auxviii:w #1 \use@mathgroup #2#3 #4 \q_stop #5 { \int_compare:nNnTF \fam = {#3} - { \use_i_delimit_by_q_recursion_stop:nw { \@@_math_aux:Nn #5 } } - { \@@_math_aux:N } + { \use_i_delimit_by_q_recursion_stop:nw { \@@_math_auxix:Nn #5 } } + { \@@_math_auxvii:N } } % \end{macrocode} % Search-and-replace fun: deal with any font commands in the argument and % also inside sub/superscripts. % \begin{macrocode} -\cs_new_protected:Npx \@@_math_aux:Nn #1#2 +\cs_new_protected:Npx \@@_math_auxix:Nn #1#2 { \group_begin: \tl_set:Nn \exp_not:N \l_@@_tmp_tl {#2} @@ -674,10 +710,10 @@ \tl_replace_all:Nnn \exp_not:N \l_@@_tmp_tl { ^ } { \exp_not:N \@@_math_super:n } - #1 { \exp_not:N \tl_use:N \exp_not:N \l_@@_tmp_tl } + \exp_not:N \exp_args:NNV \@@_math_auxvi:Nn + #1 \exp_not:N \l_@@_tmp_tl \group_end: } -\cs_generate_variant:Nn \@@_math_aux:Nn { c } \cs_new_protected:Npx \@@_math_sub:n #1 { \char_generate:nn { `\_ } { 8 } @@ -693,23 +729,23 @@ \tl_use:N \l_@@_tmp_tl \group_end: } +\cs_new_protected:Npn \@@_math_ensure:n #1 + { + \tl_if_blank:nF {#1} + { + \mode_if_math:TF + {#1} + { $ #1 $ } + } + } % \end{macrocode} % For \pkg{tex4ht}, we need to have category code $12$ |^| tokens in math -% mode. We handle that by intercepting at the first auxiliary that makes -% sense. +% mode. % \begin{macrocode} \AtBeginDocument { \@ifpackageloaded { tex4ht } - { - \cs_set_protected:Npn \@@_math_auxii:n #1 - { - \tl_set:Nn \l_@@_tmp_tl {#1} - \exp_args:NNnx \tl_replace_all:Nnn \l_@@_tmp_tl - { ^ } { \token_to_str:N ^ } - \ensuremath { \exp_args:NV \@@_math_auxiii:n \l_@@_tmp_tl } - } - } + { \tl_set:Nx \l_@@_math_html_tl { ^ { \token_to_str:N ^ } } } { } } % \end{macrocode} @@ -723,6 +759,9 @@ % \end{macro} % \end{macro} % \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} % % \begin{macro}{\siunitx_print_text:n} % \begin{macro}{\@@_text_replace:n} diff --git a/Master/texmf-dist/source/latex/siunitx/siunitx.dtx b/Master/texmf-dist/source/latex/siunitx/siunitx.dtx index 1269e5ff90d..45534b9996c 100644 --- a/Master/texmf-dist/source/latex/siunitx/siunitx.dtx +++ b/Master/texmf-dist/source/latex/siunitx/siunitx.dtx @@ -97,7 +97,7 @@ % Load only the essential support (\pkg{expl3}) \enquote{up-front}, and % only if required. % \begin{macrocode} -\@ifundefined{ExplFileDate} +\@ifundefined{ExplLoaderFileDate} {\RequirePackage{expl3}} {} % \end{macrocode} @@ -106,7 +106,7 @@ % We use \cs{ExplFileDate} as \cs{@ifpackagelater} doesn't work for pre-loaded % \pkg{expl3} in the absence of the package. % \begin{macrocode} -\@ifl@t@r\ExplFileDate{2020-01-09} +\@ifl@t@r\ExplLoaderFileDate{2020-01-09} {} {% \PackageError{siunitx}{Support package expl3 too old} @@ -121,7 +121,7 @@ % % Identify the package and give the over all version information. % \begin{macrocode} -\ProvidesExplPackage {siunitx} {2021-09-06} {3.0.29} +\ProvidesExplPackage {siunitx} {2021-09-14} {3.0.30} {A comprehensive (SI) units package} % \end{macrocode} % diff --git a/Master/texmf-dist/source/latex/siunitx/siunitx.tex b/Master/texmf-dist/source/latex/siunitx/siunitx.tex index 95cad5ca88e..b05cd68fc9b 100644 --- a/Master/texmf-dist/source/latex/siunitx/siunitx.tex +++ b/Master/texmf-dist/source/latex/siunitx/siunitx.tex @@ -297,8 +297,12 @@ Simple lists and ranges of numbers can be handled. \qtyrange{0.13}{0.67}{\milli\metre} \end{LaTeXdemo} -By default, all text is typeset in the current upright math font. This can be -changed by setting the appropriate options. +A wide range of options are available to control the behavior of the package. +For example, with the standard settings all text is typeset in the current +upright math font. This can be adjusted to use text mode, follow various +aspects of the surrounding formatting, \foreign{etc}. Similarly, the standard +settings are based around an English-speaking locale, but can be adjusted +to follow the traditions of other areas. \section{Using the \pkg{siunitx} package} @@ -1490,7 +1494,7 @@ of figures), before rounding the main value to follow. \num{0.12345(23)} \\ \num{0.12345(234)} \end{LaTeXdemo} -Rounding my \enquote{extend} a short number to more digits (or figures): this +Rounding may \enquote{extend} a short number to more digits (or figures): this is controlled by the switch \opt{round-pad}, which is \opt{true} as standard. \begin{LaTeXdemo} \sisetup{round-mode = figures, round-precision = 4}% diff --git a/Master/texmf-dist/tex/latex/siunitx/siunitx.sty b/Master/texmf-dist/tex/latex/siunitx/siunitx.sty index 22386e3533c..6a65457e7ed 100644 --- a/Master/texmf-dist/tex/latex/siunitx/siunitx.sty +++ b/Master/texmf-dist/tex/latex/siunitx/siunitx.sty @@ -28,10 +28,10 @@ \DeclareRelease{2}{2010-05-23}{siunitx-v2.sty} \DeclareRelease{v2}{2010-05-23}{siunitx-v2.sty} \DeclareCurrentRelease{}{2021-05-17} -\@ifundefined{ExplFileDate} +\@ifundefined{ExplLoaderFileDate} {\RequirePackage{expl3}} {} -\@ifl@t@r\ExplFileDate{2020-01-09} +\@ifl@t@r\ExplLoaderFileDate{2020-01-09} {} {% \PackageError{siunitx}{Support package expl3 too old} @@ -42,7 +42,7 @@ }% \endinput }% -\ProvidesExplPackage {siunitx} {2021-09-06} {3.0.29} +\ProvidesExplPackage {siunitx} {2021-09-14} {3.0.30} {A comprehensive (SI) units package} \msg_new:nnnn { siunitx } { incompatible-package } { Package~'#1'~incompatible. } @@ -111,6 +111,7 @@ { \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 @@ -187,6 +188,8 @@ { \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 @@ -3614,6 +3617,7 @@ uncertainty-separator = } \RequirePackage { amstext } +\cs_new_eq:NN \__siunitx_print_ams_text:n \text \RequirePackage { color } \cs_generate_variant:Nn \tl_replace_all:Nnn { NV } \tl_new:N \l__siunitx_print_tmp_tl @@ -3709,6 +3713,7 @@ { \tl_const:cn { c__siunitx_print_series_ #1 _tl } { m } } \clist_map_inline:nn { l , m , b } { \tl_const:cn { c__siunitx_print_series_ #1 _tl } { #1 } } +\tl_new:N \l__siunitx_print_math_html_tl \cs_new_protected:Npn \siunitx_print_math:n #1 { \bool_lazy_and:nnTF @@ -3758,7 +3763,25 @@ } \cs_generate_variant:Nn \__siunitx_print_math_version:nn { V } \cs_new_protected:Npn \__siunitx_print_math_auxii:n #1 - { \ensuremath { \__siunitx_print_math_auxiii:n {#1} } } + { + \group_begin: + \cs_set_protected:Npn \text ##1 + { + \cs_set_eq:NN \text \__siunitx_print_ams_text:n + \siunitx_print_text:n {##1} + } + \tl_set:Nn \l__siunitx_print_tmp_tl {#1} + \exp_after:wN \__siunitx_print_math_replace:Nn + \l__siunitx_print_math_html_tl + \q_recursion_tail { } \q_recursion_stop + \exp_args:NV \__siunitx_print_math_auxiii:n \l__siunitx_print_tmp_tl + \group_end: + } +\cs_new_protected:Npn \__siunitx_print_math_replace:Nn #1#2 + { + \quark_if_recursion_tail_stop:N #1 + \tl_replace_all:Nnn \l__siunitx_print_tmp_tl {#1} {#2} + } \cs_new_protected:Npn \__siunitx_print_math_auxiii:n #1 { \bool_if:NTF \l__siunitx_print_math_family_bool @@ -3766,8 +3789,8 @@ \str_case_e:nnF { \f@family } { { \rmdefault } { \__siunitx_print_math_auxv:n } - { \sfdefault } { \__siunitx_print_math_aux:Nn \mathsf } - { \ttdefault } { \__siunitx_print_math_aux:Nn \mathtt } + { \sfdefault } { \__siunitx_print_math_auxix:Nn \mathsf } + { \ttdefault } { \__siunitx_print_math_auxix:Nn \mathtt } } { \__siunitx_print_math_auxiv:n } } @@ -3778,7 +3801,7 @@ { \bool_if:NTF \l__siunitx_print_math_font_bool { - \__siunitx_print_math_aux:N + \__siunitx_print_math_auxvii:N \mathbf \mathit \mathsf \mathtt \q_recursion_tail \q_recursion_stop } @@ -3790,24 +3813,26 @@ \bool_lazy_or:nnTF { \int_compare_p:nNn \fam = { -1 } } { \int_compare_p:nNn \fam = \symoperators } - { \use:n } - { \mathrm } + { \__siunitx_print_math_ensure:n } + { \__siunitx_print_math_auxvi:Nn \mathrm } {#1} } -\cs_new_protected:Npn \__siunitx_print_math_aux:N #1 +\cs_new_protected:Npn \__siunitx_print_math_auxvi:Nn #1#2 + { \__siunitx_print_math_ensure:n { #1 {#2} } } +\cs_new_protected:Npn \__siunitx_print_math_auxvii:N #1 { - \quark_if_recursion_tail_stop_do:Nn #1 { \use:n } - \exp_after:wN \exp_after:wN \exp_after:wN \__siunitx_print_math_aux:w + \quark_if_recursion_tail_stop_do:Nn #1 { \__siunitx_print_math_auxv:n } + \exp_after:wN \exp_after:wN \exp_after:wN \__siunitx_print_math_auxviii:w \cs:w \cs_to_str:N #1 \c_space_tl \cs_end: \use@mathgroup ? { -2 } \q_stop #1 } -\cs_new_protected:Npn \__siunitx_print_math_aux:w #1 \use@mathgroup #2#3 #4 \q_stop #5 +\cs_new_protected:Npn \__siunitx_print_math_auxviii:w #1 \use@mathgroup #2#3 #4 \q_stop #5 { \int_compare:nNnTF \fam = {#3} - { \use_i_delimit_by_q_recursion_stop:nw { \__siunitx_print_math_aux:Nn #5 } } - { \__siunitx_print_math_aux:N } + { \use_i_delimit_by_q_recursion_stop:nw { \__siunitx_print_math_auxix:Nn #5 } } + { \__siunitx_print_math_auxvii:N } } -\cs_new_protected:Npx \__siunitx_print_math_aux:Nn #1#2 +\cs_new_protected:Npx \__siunitx_print_math_auxix:Nn #1#2 { \group_begin: \tl_set:Nn \exp_not:N \l__siunitx_print_tmp_tl {#2} @@ -3818,10 +3843,10 @@ \tl_replace_all:Nnn \exp_not:N \l__siunitx_print_tmp_tl { ^ } { \exp_not:N \__siunitx_print_math_super:n } - #1 { \exp_not:N \tl_use:N \exp_not:N \l__siunitx_print_tmp_tl } + \exp_not:N \exp_args:NNV \__siunitx_print_math_auxvi:Nn + #1 \exp_not:N \l__siunitx_print_tmp_tl \group_end: } -\cs_generate_variant:Nn \__siunitx_print_math_aux:Nn { c } \cs_new_protected:Npx \__siunitx_print_math_sub:n #1 { \char_generate:nn { `\_ } { 8 } @@ -3837,18 +3862,19 @@ \tl_use:N \l__siunitx_print_tmp_tl \group_end: } -\AtBeginDocument +\cs_new_protected:Npn \__siunitx_print_math_ensure:n #1 { - \@ifpackageloaded { tex4ht } + \tl_if_blank:nF {#1} { - \cs_set_protected:Npn \__siunitx_print_math_auxii:n #1 - { - \tl_set:Nn \l__siunitx_print_tmp_tl {#1} - \exp_args:NNnx \tl_replace_all:Nnn \l__siunitx_print_tmp_tl - { ^ } { \token_to_str:N ^ } - \ensuremath { \exp_args:NV \__siunitx_print_math_auxiii:n \l__siunitx_print_tmp_tl } - } + \mode_if_math:TF + {#1} + { $ #1 $ } } + } +\AtBeginDocument + { + \@ifpackageloaded { tex4ht } + { \tl_set:Nx \l__siunitx_print_math_html_tl { ^ { \token_to_str:N ^ } } } { } } \cs_new_protected:Npn \siunitx_print_text:n #1 -- cgit v1.2.3