diff options
Diffstat (limited to 'macros/latex/contrib/siunitx/siunitx-table.dtx')
-rw-r--r-- | macros/latex/contrib/siunitx/siunitx-table.dtx | 67 |
1 files changed, 51 insertions, 16 deletions
diff --git a/macros/latex/contrib/siunitx/siunitx-table.dtx b/macros/latex/contrib/siunitx/siunitx-table.dtx index 64ef013e17..75a5a7f011 100644 --- a/macros/latex/contrib/siunitx/siunitx-table.dtx +++ b/macros/latex/contrib/siunitx/siunitx-table.dtx @@ -736,7 +736,8 @@ % When centering on the decimal marker, the easiest approach is to simply % re-box the two parts. That is needed whether or not we are parsing numbers, % so is best as a short auxiliary. Notice that we need to allow for the width -% of the decimal marker itself. +% of the decimal marker itself. When not aligning non-numerical material, we +% put the extra space into the boxes around the number. % \begin{macrocode} \cs_new_protected:Npn \@@_center_marker: { @@ -750,26 +751,53 @@ - \box_wd:N \l_@@_tmp_box } { - \hbox_set_to_wd:Nnn \l_@@_decimal_box + \bool_if:NTF \l_@@_align_after_bool { - \box_wd:N \l_@@_integer_box - + \box_wd:N \l_@@_tmp_box - } - { - \hbox_unpack:N \l_@@_decimal_box - \@@_fil: - } + \@@_center_marker_aux:Nnnn \l_@@_decimal_box + { + \box_wd:N \l_@@_integer_box + + \box_wd:N \l_@@_tmp_box + } + } + { + \@@_center_marker_aux:Nnnn \l_@@_after_box + { + \box_wd:N \l_@@_after_box + + \box_wd:N \l_@@_integer_box + - \box_wd:N \l_@@_decimal_box + + \box_wd:N \l_@@_tmp_box + } + } + { } { \@@_fil: } } { - \hbox_set_to_wd:Nnn \l_@@_integer_box + \bool_if:NTF \l_@@_align_before_bool { - \box_wd:N \l_@@_decimal_box - - \box_wd:N \l_@@_tmp_box + \@@_center_marker_aux:Nnnn \l_@@_integer_box + { + \box_wd:N \l_@@_decimal_box + - \box_wd:N \l_@@_tmp_box + } } { - \@@_fil: - \hbox_unpack:N \l_@@_integer_box + \@@_center_marker_aux:Nnnn \l_@@_before_box + { + \box_wd:N \l_@@_before_box + + \box_wd:N \l_@@_decimal_box + - \box_wd:N \l_@@_integer_box + - \box_wd:N \l_@@_tmp_box + } } + { \@@_fil: } { } + } + } +\cs_new_protected:Npn \@@_center_marker_aux:Nnnn #1#2#3#4 + { + \hbox_set_to_wd:Nnn #1 {#2} + { + #3 + \hbox_unpack:N #1 + #4 } } % \end{macrocode} @@ -967,10 +995,17 @@ \c_math_toggle_token \l_siunitx_number_output_decimal_tl } +% \end{macrocode} +% We set the two alignment booleans here so that a single auxiliary can +% cover this case as well as the one for centering the marker when also +% parsing. +% \begin{macrocode} \cs_new_protected:Npn \@@_direct_marker_end: { \c_math_toggle_token \hbox_set_end: + \bool_set_true:N \l_@@_align_before_bool + \bool_set_true:N \l_@@_align_after_bool \@@_center_marker: \use:c { @@_align_ \l_@@_align_text_tl :n } { @@ -1159,7 +1194,6 @@ \@@_fil: } } - \box_use_drop:N \l_@@_before_box \siunitx_number_parse:nN {#2} \l_@@_tmp_tl \siunitx_number_process:NN \l_@@_tmp_tl \l_@@_tmp_tl \tl_set:Nx \l_@@_tmp_tl @@ -1167,7 +1201,6 @@ \@@_color_check:N \l_@@_tmp_tl \exp_after:wN \@@_print_marker:w \l_@@_tmp_tl \q_stop - \box_use_drop:N \l_@@_after_box } \cs_new_protected:Npn \@@_print_marker:w #1 \q_nil #2 \q_nil #3 \q_nil #4 \q_stop @@ -1182,8 +1215,10 @@ \@@_center_marker: \use:c { @@_align_ \l_@@_align_text_tl :n } { + \box_use_drop:N \l_@@_before_box \box_use_drop:N \l_@@_integer_box \box_use_drop:N \l_@@_decimal_box + \box_use_drop:N \l_@@_after_box } } \cs_new:Npn \@@_print_marker_aux:w |