From 9b2e09588997d0e4d70d4c7f8f805014168299e2 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 26 Dec 2011 23:59:21 +0000 Subject: siunitx 2.4f (26dec11) git-svn-id: svn://tug.org/texlive/trunk@24952 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/source/latex/siunitx/siunitx.dtx | 213 +++++++++++++-------- 1 file changed, 129 insertions(+), 84 deletions(-) (limited to 'Master/texmf-dist/source/latex/siunitx') diff --git a/Master/texmf-dist/source/latex/siunitx/siunitx.dtx b/Master/texmf-dist/source/latex/siunitx/siunitx.dtx index a591e0c4dcd..9bcd9e1fc9d 100644 --- a/Master/texmf-dist/source/latex/siunitx/siunitx.dtx +++ b/Master/texmf-dist/source/latex/siunitx/siunitx.dtx @@ -552,6 +552,10 @@ This work consists of the file siunitx.dtx % where the command clashes with a unit name} %\changes{v2.4e}{2011/12/11}{Fix issue with \pkg{inputenc} package and % some of the recent special symbol changes} +%\changes{v2.4f}{2011/12/21}{Allow easier use of headings when not parsing +% numbers in tables} +%\changes{v2.4f}{2011/12/23}{Fix bug with detection of bold font in table +% cells} % %\begin{abstract} % Physical quantities have both numbers and units, and each physical @@ -889,6 +893,7 @@ This work consists of the file siunitx.dtx % Brochure~\cite{SI:2.1}. %\begin{table} % \caption{SI base units.} +% \tracingall % \label{tab:unit:base} % \centering % \begin{tabular}{lll} @@ -3603,10 +3608,10 @@ This work consists of the file siunitx.dtx % S[table-number-alignment = left] % } % \toprule -% \multicolumn{1}{c}{Some values} -% & \multicolumn{1}{c}{Some values} -% & \multicolumn{1}{c}{Some values} -% & \multicolumn{1}{c}{Some values} \\ +% {Some values} +% & {Some values} +% & {Some values} +% & {Some values} \\ % \midrule % 2.35 & 2.35 & 2.35 & 2.35 \\ % 34.234 & 34.234 & 34.234 & 34.234 \\ @@ -5005,7 +5010,7 @@ This work consists of the file siunitx.dtx % % The usual preliminaries. % \begin{macrocode} -\ProvidesExplPackage {siunitx} {2011/12/11} {2.4e} +\ProvidesExplPackage {siunitx} {2011/12/24} {2.4f} {A comprehensive (SI) units package} % \end{macrocode} % @@ -10836,12 +10841,15 @@ This work consists of the file siunitx.dtx % method only makes these available inside the unit-processing functions % (\cs{SI}, \cs{si} and the \texttt{S} column). % -%\begin{macro}{\l_siunitx_declare_list_tl} +%\begin{macro}{\l_siunitx_declare_list_seq} % A list of all unit and related functions. % \begin{macrocode} -\tl_new:N \l_siunitx_declare_list_tl -\tl_set:Nn \l_siunitx_declare_list_tl - { \of \highlight \per \raiseto \tothe } +\seq_new:N \l_siunitx_declare_list_seq +\seq_put_right:Nn \l_siunitx_declare_list_seq { \of } +\seq_put_right:Nn \l_siunitx_declare_list_seq { \highlight } +\seq_put_right:Nn \l_siunitx_declare_list_seq { \per } +\seq_put_right:Nn \l_siunitx_declare_list_seq { \raiseto } +\seq_put_right:Nn \l_siunitx_declare_list_seq { \tothe } % \end{macrocode} %\end{macro} % @@ -10852,14 +10860,14 @@ This work consists of the file siunitx.dtx % Creating powers is all about storing values. % \begin{macrocode} \cs_new_protected:Npn \siunitx_declare_power_after:Nn #1#2 { - \tl_put_right:Nn \l_siunitx_declare_list_tl {#1} + \seq_put_right:Nn \l_siunitx_declare_list_seq {#1} \cs_set:cpn { siunitx_ \token_to_str:N #1 _literal:w } { \siunitx_textsuperscript:n {#2} } \cs_set:cpn { siunitx_ \token_to_str:N #1 _function:w } { \siunitx_unit_parse_power_after:n {#2} } } \cs_new_protected:Npn \siunitx_declare_power_before:Nn #1#2 { - \tl_put_right:Nn \l_siunitx_declare_list_tl {#1} + \seq_put_right:Nn \l_siunitx_declare_list_seq {#1} \cs_set:cpn { siunitx_ \token_to_str:N #1 _literal:w } ##1 { ##1 \siunitx_textsuperscript:n {#2} } \cs_set:cpn { siunitx_ \token_to_str:N #1 _function:w } @@ -10877,7 +10885,7 @@ This work consists of the file siunitx.dtx % \begin{macrocode} \cs_new_protected:Npn \siunitx_declare_prefix:Nnnn #1#2#3#4 { - \tl_put_right:Nn \l_siunitx_declare_list_tl {#1} + \seq_put_right:Nn \l_siunitx_declare_list_seq {#1} \prop_put:Nnn \l_siunitx_prefix_forward_prop {#1} {#4} \prop_put:Nnn \l_siunitx_prefix_reverse_prop {#4} {#1} \cs_set:cpn { siunitx_ \token_to_str:N #1 _literal:w } {#2} @@ -10898,7 +10906,7 @@ This work consists of the file siunitx.dtx % Qualifiers just need storing. % \begin{macrocode} \cs_new_protected:Npn \siunitx_declare_qualifier:Nn #1#2 { - \tl_put_right:Nn \l_siunitx_declare_list_tl {#1} + \seq_put_right:Nn \l_siunitx_declare_list_seq {#1} \cs_set:cpn { siunitx_ \token_to_str:N #1 _literal:w } { \text { ~ } ( #2 ) } \cs_set:cpn { siunitx_ \token_to_str:N #1 _function:w } @@ -10915,7 +10923,7 @@ This work consists of the file siunitx.dtx % problem with the creation order for units. % \begin{macrocode} \cs_new_protected:Npn \siunitx_declare_unit:Nnn #1#2#3 { - \tl_put_right:Nn \l_siunitx_declare_list_tl {#1} + \seq_put_right:Nn \l_siunitx_declare_list_seq {#1} \cs_set:cpn { siunitx_ \token_to_str:N #1 _literal:w } {#2} \cs_set_protected:cpn { siunitx_ \token_to_str:N #1 _function:w } { @@ -10993,7 +11001,7 @@ This work consists of the file siunitx.dtx \cs_if_exist:NT \cancel { \cs_set_eq:NN \siunitx_cancel:n \cancel - \tl_put_right:Nn \l_siunitx_declare_list_tl { \cancel } + \seq_put_right:Nn \l_siunitx_declare_list_seq { \cancel } \cs_new_protected:cpn { siunitx_ \token_to_str:N \cancel _function:w } { \siunitx_unit_parse_special:n { \siunitx_cancel:n } } @@ -11054,7 +11062,7 @@ This work consists of the file siunitx.dtx % \pkg{hyperref}. % \begin{macrocode} \cs_new_protected:Npn \siunitx_unit_create_empty_functions: { - \tl_map_function:NN \l_siunitx_declare_list_tl + \seq_map_function:NN \l_siunitx_declare_list_seq \siunitx_unit_create_empty_functions_aux:N } \cs_new_protected:Npn @@ -11070,14 +11078,14 @@ This work consists of the file siunitx.dtx % \begin{macrocode} \cs_new_protected:Npn \siunitx_unit_create_functions: { \bool_if:NT \l_siunitx_create_overwrite_bool - { \tl_map_function:NN \l_siunitx_declare_list_tl \cs_undefine:N } + { \seq_map_function:NN \l_siunitx_declare_list_seq \cs_undefine:N } \bool_if:NTF \l_siunitx_create_optional_bool { - \tl_map_function:NN \l_siunitx_declare_list_tl + \seq_map_function:NN \l_siunitx_declare_list_seq \siunitx_unit_create_with_arg:N } { - \tl_map_function:NN \l_siunitx_declare_list_tl + \seq_map_function:NN \l_siunitx_declare_list_seq \siunitx_unit_create:N } \bool_if:NT \l_siunitx_create_xspace_bool @@ -11263,32 +11271,49 @@ This work consists of the file siunitx.dtx % \end{macrocode} %\end{macro} % -%\begin{macro}{\siunitx_unit_if_literal:nTF} -%\begin{macro}[aux]{\siunitx_unit_if_literal_aux:N} -% A test is needed to see if the input only contains unit macros. This -% is done by altering setting all of the unit macros to expand to -% nothing at all. Thus there will only be anything left if there is -% a literal in the unit. -% \begin{macrocode} -\cs_new_protected:Npn \siunitx_unit_if_literal:nTF #1#2#3 { - \group_begin: - \tl_map_function:NN \l_siunitx_declare_list_tl - \siunitx_unit_if_literal_aux:N - \cs_set_eq:NN \of \use_none:n - \cs_set_eq:NN \highlight \use_none:n - \cs_set_eq:NN \raiseto \use_none:n - \cs_set_eq:NN \tothe \use_none:n - \protected@edef \l_siunitx_tmpa_tl {#1} - \exp_args:NNNV \group_end: - \tl_set:Nn \l_siunitx_tmpa_tl \l_siunitx_tmpa_tl - \tl_if_empty:NTF \l_siunitx_tmpa_tl {#3} {#2} -} -\cs_new_protected:Npn \siunitx_unit_if_literal_aux:N #1 { - \cs_set_eq:NN #1 \prg_do_nothing: -} +% \begin{macro}{\siunitx_unit_if_literal:nTF} +% \begin{macro}[aux] +% { +% \siunitx_unit_if_literal_aux:n, +% \siunitx_unit_if_literal_aux_std:n, +% \siunitx_unit_if_literal_aux_skip:n +% } +% A test to see if there is anything in the input which is not know to +% the package. As the full list of names is rather long and there is no +% need to worry about nesting here, the best approach is to look for all +% of the implemetation functions. The only issue with that is dealing with +% the non-standard names, which are sorted out using a set up to gobble +% their argument. +% \begin{macrocode} +\cs_new_protected:Npn \siunitx_unit_if_literal:nTF #1 + { + \bool_set_false:N \l_siunitx_tmp_bool + \tl_map_function:nN {#1} \siunitx_unit_if_literal_aux:n + \bool_if:NTF \l_siunitx_tmp_bool + } +\cs_new_protected:Npn \siunitx_unit_if_literal_aux_std:n #1 + { + \cs_if_exist:cF { siunitx_ \tl_to_str:o { \token_to_str:N #1 } _function:w } + { + \bool_set_true:N \l_siunitx_tmp_bool + \tl_map_break: + } + \tl_if_in:nnT { \of \highlight \raiseto \tothe } {#1} + { + \cs_set_eq:NN \siunitx_unit_if_literal_aux:n + \siunitx_unit_if_literal_aux_skip:n + } + } +\cs_new_protected:Npn \siunitx_unit_if_literal_aux_skip:n #1 + { + \cs_set_eq:NN \siunitx_unit_if_literal_aux:n + \siunitx_unit_if_literal_aux_std:n + } +\cs_new_eq:NN \siunitx_unit_if_literal_aux:n \siunitx_unit_if_literal_aux_std:n +\cs_generate_variant:Nn \tl_to_str:n { o } % \end{macrocode} -%\end{macro} -%\end{macro} +% \end{macro} +% \end{macro} % %\subsection{Parsing macro units} % @@ -11351,25 +11376,21 @@ This work consists of the file siunitx.dtx % \end{macrocode} %\end{macro} % -%\begin{macro}{\siunitx_unit_parse_init:} -%\begin{macro}[aux]{\siunitx_unit_parse_init_aux:N} -% As always, the initialisation is a separate routine to make life a -% little clearer. The definition of \cs{pm} is saved here as it -% is used by units and numbers. +% \begin{macro}{\siunitx_unit_parse_init:} +% As always, the initialisation is a separate routine to make life a +% little clearer. The definition of \cs{pm} is saved here as it +% is used by units and numbers. % \begin{macrocode} -\cs_new_protected:Npn \siunitx_unit_parse_init: { - \prop_clear:N \l_siunitx_unit_prop - \int_zero:N \l_siunitx_unit_int - \bool_set_false:N \l_siunitx_per_bool - \tl_map_function:NN \l_siunitx_declare_list_tl - \siunitx_unit_parse_init_aux:N -} -\cs_new_protected:Npn \siunitx_unit_parse_init_aux:N #1 { - \cs_set_eq:Nc #1 { siunitx_ \token_to_str:N #1 _function:w } -} +\cs_new_protected:Npn \siunitx_unit_parse_init: + { + \prop_clear:N \l_siunitx_unit_prop + \int_zero:N \l_siunitx_unit_int + \bool_set_false:N \l_siunitx_per_bool + \seq_map_inline:Nn \l_siunitx_declare_list_seq + { \cs_set_eq:Nc ##1 { siunitx_ \token_to_str:N ##1 _function:w } } + } % \end{macrocode} %\end{macro} -%\end{macro} % %\begin{macro}{\siunitx_unit_parse_options:n} % Any unit-specific options are loaded, followed by re-applying any @@ -11914,8 +11935,8 @@ This work consists of the file siunitx.dtx \int_zero:N \l_siunitx_unit_prefix_int \int_zero:N \l_siunitx_unit_denominator_int \int_zero:N \l_siunitx_unit_numerator_int - \tl_map_function:NN \l_siunitx_declare_list_tl - \siunitx_unit_print_literal_aux:N + \seq_map_inline:Nn \l_siunitx_declare_list_seq + { \siunitx_unit_print_literal_aux:N ##1 } } % \end{macrocode} %\end{macro} @@ -11932,8 +11953,8 @@ This work consists of the file siunitx.dtx \cs_new_protected:Npn \siunitx_unit_format_literal:n #1 { \int_zero:N \l_siunitx_unit_prefix_int - \tl_map_function:NN \l_siunitx_declare_list_tl - \siunitx_unit_print_literal_aux:N + \seq_map_inline:Nn \l_siunitx_declare_list_seq + { \siunitx_unit_print_literal_aux:N ##1 } \tl_set:Nn \l_siunitx_unit_tl {#1} \tl_set:Nx \l_siunitx_tmpa_tl { \exp_not:N \ensuremath { \exp_not:V \l_siunitx_unit_product_tl } } @@ -13063,7 +13084,7 @@ This work consists of the file siunitx.dtx \siunitx_detect_font: \bool_if:NTF \l_siunitx_number_parse_bool { \siunitx_table_collect_get: } - { \siunitx_table_print_S_direct: } + { \siunitx_table_print_S_direct:N } } % \end{macrocode} %\end{macro} @@ -13860,7 +13881,6 @@ This work consists of the file siunitx.dtx } { \siunitx_table_column_begin:n { \l_siunitx_table_number_align_skip } - \siunitx_detect_font: \bool_if:NTF \l_siunitx_table_parse_only_bool { \siunitx_table_print_S_no_alignment: } { \siunitx_table_print_S_alignment: } @@ -14033,7 +14053,10 @@ This work consists of the file siunitx.dtx } \dim_compare:nNnT { \box_wd:N \l_siunitx_table_pre_box } = \c_zero_skip - { \l_siunitx_table_collect_pre_tl } + { + \l_siunitx_table_collect_pre_tl + \bool_set_false:N \l_siunitx_font_set_bool + } \hbox_set:Nn \l_siunitx_table_post_box { \bool_if:NT \l_siunitx_table_math_bool @@ -14184,10 +14207,10 @@ This work consists of the file siunitx.dtx { \siunitx_number_process_uncertainty: } \siunitx_number_format: \prop_get:NnNT \l_siunitx_table_model_prop { mantissa-decimal-raw } - \l_siunitx_tmp_tl + \l_siunitx_tmpa_tl { \prop_put:NnV \l_siunitx_number_out_prop { mantissa-decimal-raw } - \l_siunitx_tmp_tl + \l_siunitx_tmpa_tl } \prop_set_eq:NN \l_siunitx_table_model_prop \l_siunitx_number_out_prop } @@ -14217,7 +14240,10 @@ This work consists of the file siunitx.dtx } \dim_compare:nNnT { \box_wd:N \l_siunitx_table_pre_box } = \c_zero_skip - { \l_siunitx_table_collect_pre_tl } + { + \l_siunitx_table_collect_pre_tl + \bool_set_false:N \l_siunitx_font_set_bool + } \hbox_set:Nn \l_siunitx_tmp_box { { \l_siunitx_table_pre_tl } } \hbox_set_to_wd:Nnn \l_siunitx_table_pre_box { \box_wd:N \l_siunitx_tmp_box } @@ -14618,18 +14644,37 @@ This work consists of the file siunitx.dtx % \pkg{dcolumn} can be applied, which requires the decimal marker to % be made active in math mode. % -% \begin{macro}{\siunitx_table_print_S_direct:} -% The main part of the system simply does the appropriate math work -% then calls the main function, which will be assigned by the -% key--value system. +% \begin{macro}{\siunitx_table_print_S_direct:N} +% \begin{macro}{\siunitx_table_print_S_direct_text:n} +% The lead-off here first moves the \cs{ignorespaces} in the input to +% avoid picking it up. There is then a test to see if the very first item +% in the cell is a |{|. If it is, then we use the same approach as for +% parsed columns and set the material as text. Otherwise, switch to math +% mode and hand off to the main routine. % \begin{macrocode} -\cs_new_protected:Npn \siunitx_table_print_S_direct: +\cs_new_protected:Npn \siunitx_table_print_S_direct:N #1 + { + #1 + \cs_set:Npn \peek_execute_branches: + { + \if_catcode:w \exp_not:N \l_peek_token \c_group_begin_token + \exp_after:wN \siunitx_table_print_S_direct_text:n + \else: + \m@th + \exp_after:wN \siunitx_table_print_S_direct_main: + \fi: + } + \peek_after:Nw \peek_ignore_spaces_execute_branches: + } +\cs_new_protected:Npn \siunitx_table_print_S_direct_text:n #1 { - \m@th - \siunitx_table_print_S_direct_main: + \siunitx_table_column_begin:n { \l_siunitx_table_text_align_skip } + #1 + \siunitx_table_column_end:n { \l_siunitx_table_text_align_skip } } % \end{macrocode} % \end{macro} +% \end{macro} % % \begin{macro} % { @@ -15512,8 +15557,8 @@ This work consists of the file siunitx.dtx \cs_set_eq:NN \label \use_none:n \cs_set_eq:NN \index \use_none:n \cs_set_eq:NN \glossary \use_none:n - \tl_map_function:NN \l_siunitx_declare_list_tl - \siunitx_contents_add:N + \seq_map_inline:Nn \l_siunitx_declare_list_seq + { \siunitx_contents_add:N ##1 } } { \token_to_str:N \@writefile {#1} {#2} } } @@ -15539,8 +15584,8 @@ This work consists of the file siunitx.dtx % \begin{macrocode} \cs_new_protected:Npn \siunitx_contents_bookmarks: { - \tl_map_function:NN \l_siunitx_declare_list_tl - \siunitx_unit_print_literal_aux:N + \seq_map_inline:Nn \l_siunitx_declare_list_seq + { \siunitx_unit_print_literal_aux:N ##1 } \msg_redirect_name:nnn { xparse } { redefine-command } { none } \cs_set_eq:NN \num \siunitx_bookmark_num:w \cs_set_eq:NN \numrange \siunitx_bookmark_numrange:w @@ -16190,7 +16235,7 @@ This work consists of the file siunitx.dtx % \end{macrocode} % % \begin{macrocode} -\ProvidesExplFile {siunitx-version-1.cfg} {2011/12/11} {2.4e} +\ProvidesExplFile {siunitx-version-1.cfg} {2011/12/24} {2.4f} {siunitx: Version 1 settings} % \end{macrocode} % @@ -17135,7 +17180,7 @@ This work consists of the file siunitx.dtx % \end{macrocode} % % \begin{macrocode} -\ProvidesExplFile {siunitx-abbreviations.cfg} {2011/12/11} {2.4e} +\ProvidesExplFile {siunitx-abbreviations.cfg} {2011/12/24} {2.4f} {siunitx: Abbreviated units} % \end{macrocode} % @@ -17317,7 +17362,7 @@ This work consists of the file siunitx.dtx % \end{macrocode} % % \begin{macrocode} -\ProvidesExplFile {siunitx-binary.cfg} {2011/12/11} {2.4e} +\ProvidesExplFile {siunitx-binary.cfg} {2011/12/24} {2.4f} {siunitx: Binary units} % \end{macrocode} % -- cgit v1.2.3