summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/siunitx/siunitx-table.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/siunitx/siunitx-table.dtx')
-rw-r--r--macros/latex/contrib/siunitx/siunitx-table.dtx67
1 files changed, 47 insertions, 20 deletions
diff --git a/macros/latex/contrib/siunitx/siunitx-table.dtx b/macros/latex/contrib/siunitx/siunitx-table.dtx
index d16d2d7780..430a715710 100644
--- a/macros/latex/contrib/siunitx/siunitx-table.dtx
+++ b/macros/latex/contrib/siunitx/siunitx-table.dtx
@@ -315,7 +315,8 @@
%
% \begin{macro}{\@@_collect_loop:}
% \begin{macro}{\@@_collect_group:n}
-% \begin{macro}{\@@_collect_token:N}
+% \begin{macro}{\@@_collect_token:N, \@@_collect_token_aux:N}
+% \begin{macro}{\@@_collect_relax:N}
% \begin{macro}{\@@_collect_search:NnF}
% \begin{macro}{\@@_collect_search_aux:NNn}
% Collecting up the cell content needs a loop: this is done using
@@ -325,7 +326,8 @@
% (\foreign{cf.}~the approach in \pkg{collcell}): the special cases are
% pulled out for manual handling. The flexible lookup approach is more-or-less
% the same idea as in the kernel |case| functions. The |\relax| special case
-% covers the case where |\\| has been expanded in an empty cell.
+% covers the case where |\\| has been expanded in an empty cell. This has to
+% be an explicit token as we can get the same meaning from |\protect|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_collect_loop:
{
@@ -344,14 +346,22 @@
{
\unskip { \@@_collect_loop: }
\end { \tabularnewline \end }
- \relax { \relax }
+ \relax { \@@_collect_relax:N #1 }
\tabularnewline { \tabularnewline }
\siunitx_cell_end: { \siunitx_cell_end: }
}
- {
- \tl_put_right:Nn \l_@@_collect_tl {#1}
- \@@_collect_loop:
- }
+ { \@@_collect_token_aux:N #1 }
+ }
+\cs_new_protected:Npn \@@_collect_token_aux:N #1
+ {
+ \tl_put_right:Nn \l_@@_collect_tl {#1}
+ \@@_collect_loop:
+ }
+\cs_new_protected:Npn \@@_collect_relax:N #1
+ {
+ \str_if_eq:nnTF {#1} { \relax }
+ { \relax }
+ { \@@_collect_token_aux:N #1 }
}
\AtBeginDocument
{
@@ -365,14 +375,11 @@
\tab@setcr { \@@_collect_loop: }
\unskip { \@@_collect_loop: }
\end { \tabularnewline \end }
- \relax { \relax }
+ \relax { \@@_collect_relax:N #1 }
\tabularnewline { \tabularnewline }
\siunitx_cell_end: { \siunitx_cell_end: }
}
- {
- \tl_put_right:Nn \l_@@_collect_tl {#1}
- \@@_collect_loop:
- }
+ { \@@_collect_token_aux:N #1 }
}
}
{ }
@@ -396,6 +403,7 @@
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
%
% \subsection{Separating collected material}
%
@@ -682,16 +690,26 @@
% \begin{macro}{\@@_center_marker:}
% 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.
+% so is best as a short auxiliary. Notice that we need to allow for the width
+% of the decimal marker itself.
% \begin{macrocode}
\cs_new_protected:Npn \@@_center_marker:
{
+ \hbox_set:Nn \l_@@_tmp_box
+ { \ensuremath { \mathord { \l_siunitx_number_output_decimal_tl } } }
\dim_compare:nNnTF
{ \box_wd:N \l_@@_integer_box }
- > { \box_wd:N \l_@@_decimal_box }
+ >
+ {
+ \box_wd:N \l_@@_decimal_box
+ - \box_wd:N \l_@@_tmp_box
+ }
{
\hbox_set_to_wd:Nnn \l_@@_decimal_box
- { \box_wd:N \l_@@_integer_box }
+ {
+ \box_wd:N \l_@@_integer_box
+ + \box_wd:N \l_@@_tmp_box
+ }
{
\hbox_unpack:N \l_@@_decimal_box
\@@_fil:
@@ -699,7 +717,10 @@
}
{
\hbox_set_to_wd:Nnn \l_@@_integer_box
- { \box_wd:N \l_@@_decimal_box }
+ {
+ \box_wd:N \l_@@_decimal_box
+ - \box_wd:N \l_@@_tmp_box
+ }
{
\@@_fil:
\hbox_unpack:N \l_@@_integer_box
@@ -903,8 +924,11 @@
\c_math_toggle_token
\hbox_set_end:
\@@_center_marker:
- \box_use_drop:N \l_@@_integer_box
- \box_use_drop:N \l_@@_decimal_box
+ \use:c { @@_align_ \l_@@_align_text_tl :n }
+ {
+ \box_use_drop:N \l_@@_integer_box
+ \box_use_drop:N \l_@@_decimal_box
+ }
}
% \end{macrocode}
% For the version where there is space reserved, first format and decompose
@@ -1093,8 +1117,11 @@
{ \@@_print_marker_aux:w #4 }
}
\@@_center_marker:
- \box_use_drop:N \l_@@_integer_box
- \box_use_drop:N \l_@@_decimal_box
+ \use:c { @@_align_ \l_@@_align_text_tl :n }
+ {
+ \box_use_drop:N \l_@@_integer_box
+ \box_use_drop:N \l_@@_decimal_box
+ }
}
\cs_new:Npn \@@_print_marker_aux:w
#1 \q_nil #2 \q_nil #3 \q_nil #4 \q_nil #5 \q_nil #6 \q_nil #7 \q_nil