summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/siunitx/siunitx-table.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-08-01 03:01:19 +0000
committerNorbert Preining <norbert@preining.info>2023-08-01 03:01:19 +0000
commit84777905249300f2ab97a23141e31f952bceb865 (patch)
tree5621415ee6ecbcbe62e4c500977af3c41aeebd9c /macros/latex/contrib/siunitx/siunitx-table.dtx
parent17d547a1effe2cafcdfbf704bdf8cb0484790ef2 (diff)
CTAN sync 202308010301
Diffstat (limited to 'macros/latex/contrib/siunitx/siunitx-table.dtx')
-rw-r--r--macros/latex/contrib/siunitx/siunitx-table.dtx66
1 files changed, 50 insertions, 16 deletions
diff --git a/macros/latex/contrib/siunitx/siunitx-table.dtx b/macros/latex/contrib/siunitx/siunitx-table.dtx
index 823a20edef..3fe8d34a5d 100644
--- a/macros/latex/contrib/siunitx/siunitx-table.dtx
+++ b/macros/latex/contrib/siunitx/siunitx-table.dtx
@@ -190,6 +190,15 @@
% the same size.
% \end{function}
%
+% \begin{function}{table-model-setup}
+% \begin{syntax}
+% |table-model-setup| = \meta{commands}
+% \end{syntax}
+% Additional commands to be inserted when using the |table-format| to
+% create a model for alignment of cells. Typically this will be used to
+% handle variable-width fonts in columns. The standard setting is empty.
+% \end{function}
+%
% \begin{function}{table-number-alignment}
% \begin{syntax}
% |table-number-alignment| = |center|\verb"|"|left|\verb"|"|right|
@@ -818,7 +827,12 @@
% \end{macro}
%
% \begin{variable}
-% {\l_@@_auto_round_bool, \l_@@_align_mode_tl, \l_@@_align_number_tl}
+% {
+% \l_@@_auto_round_bool,
+% \l_@@_model_setup_tl ,
+% \l_@@_align_mode_tl ,
+% \l_@@_align_number_tl
+% }
% Options for tables with defined space.
% \begin{macrocode}
\keys_define:nn { siunitx }
@@ -842,6 +856,8 @@
\exp_args:NV \@@_generate_model:n \l_@@_model_tl
\tl_set:Nn \l_@@_align_mode_tl { format }
} ,
+ table-model-setup .tl_set:N =
+ \l_@@_model_setup_tl ,
table-number-alignment .choices:nn =
{ center , left , right }
{ \tl_set_eq:NN \l_@@_align_number_tl \l_keys_choice_tl }
@@ -1174,7 +1190,12 @@
% \@@_print_format_auxxii:w ,
% \@@_print_format_auxxiii:w
% }
-% \begin{macro}{\@@_print_format_box:Nn}
+% \begin{macro}
+% {
+% \@@_print_format_box:Nn, \@@_print_format_box:No ,
+% \@@_print_model_box:Nn, \@@_print_model_box:No
+% }
+% \begin{macro}{\@@_print_format_box:nNn, \@@_print_format_box:VNn}
% \begin{macro}{\@@_print_format_after:N}
% \begin{macro}{\@@_print_none:nnn}
% \begin{macrocode}
@@ -1325,7 +1346,7 @@
#1 \q_nil #2 \q_mark #3 \q_nil #4 \q_stop
{
\@@_color_check:w #3 \q_nil \q_stop
- \@@_print_format_box:Nn \l_@@_tmp_box {#1}
+ \@@_print_model_box:Nn \l_@@_tmp_box {#1}
\bool_if:NTF \l_@@_align_before_bool
{
\hbox_set_to_wd:Nnn \l_@@_integer_box
@@ -1365,7 +1386,7 @@
\cs_new_protected:Npn \@@_print_format_auxii:w
#1 \q_nil #2 \q_nil #3 \q_mark #4 \q_nil #5 \q_nil #6 \q_stop
{
- \@@_print_format_box:Nn \l_@@_tmp_box {#1#2}
+ \@@_print_model_box:Nn \l_@@_tmp_box {#1#2}
\dim_set:Nn \l_@@_tmp_dim { \box_wd:N \l_@@_tmp_box }
\@@_print_format_box:Nn \l_@@_tmp_box {#4#5}
\dim_compare:nNnT { \box_wd:N \l_@@_tmp_box } > \l_@@_tmp_dim
@@ -1425,19 +1446,20 @@
\@@_fil:
\hbox_unpack:N \l_@@_before_box
}
- \@@_print_format_auxiii:w #3 \q_mark #6 \q_stop
+ \@@_print_format_auxiii:w ? #3 \q_mark ? #6 \q_stop
}
% \end{macrocode}
% We now deal with the decimal part: there is nothing already in the
% |decimal| box, so the basics are easy. We need to \enquote{carry forward}
% any white space, as where it gets inserted depends on the options for
-% subsequent parts.
+% subsequent parts. The \cs{use_none:n} here remove the two |?| above:
+% those are added to preserve braces around the decimal marker.
% \begin{macrocode}
\cs_new_protected:Npn \@@_print_format_auxiii:w
#1 \q_nil #2 \q_nil #3 \q_mark #4 \q_nil #5 \q_nil #6 \q_stop
{
- \@@_print_format_box:Nn \l_@@_tmp_box {#1#2}
- \@@_print_format_box:Nn \l_@@_decimal_box {#4#5}
+ \@@_print_model_box:No \l_@@_tmp_box { \use_none:n #1#2 }
+ \@@_print_format_box:No \l_@@_decimal_box { \use_none:n #4#5 }
\dim_set:Nn \l_@@_carry_dim
{
\box_wd:N \l_@@_tmp_box
@@ -1505,7 +1527,7 @@
#1 \q_nil #2 \q_nil #3 \q_mark
#4 \q_nil #5 \q_nil #6 \q_stop
{
- \@@_print_format_box:Nn \l_@@_tmp_box {#1#2}
+ \@@_print_model_box:Nn \l_@@_tmp_box {#1#2}
\hbox_set_to_wd:Nnn \l_@@_tmp_box
{
\box_wd:N \l_@@_uncert_box
@@ -1535,7 +1557,7 @@
#1 \q_nil #2 \q_mark
#3 \q_nil #4 \q_stop
{
- \@@_print_format_box:Nn \l_@@_tmp_box { { } #1 }
+ \@@_print_model_box:Nn \l_@@_tmp_box { { } #1 }
\dim_set:Nn \l_@@_tmp_dim { \box_wd:N \l_@@_tmp_box }
\@@_print_format_box:Nn \l_@@_tmp_box { { } #3 }
\@@_print_format_auxxii:w #2 \q_mark #4 \q_stop
@@ -1562,7 +1584,7 @@
{
\tl_if_blank:nF {#2}
{
- \@@_print_format_box:Nn \l_@@_tmp_box { { } #1#2 }
+ \@@_print_model_box:Nn \l_@@_tmp_box { { } #1#2 }
\dim_set:Nn \l_@@_tmp_dim { \box_wd:N \l_@@_tmp_box }
\@@_print_format_box:Nn \l_@@_tmp_box
{
@@ -1570,7 +1592,7 @@
{ \l_@@_align_exponent_bool }
{ \tl_if_blank_p:n {#3} }
{
- \@@_print_format_box:Nn \l_@@_tmp_box { { } #1 { } }
+ \@@_print_model_box:Nn \l_@@_tmp_box { { } #1 { } }
\@@_skip:n { \box_wd:N \l_@@_tmp_box }
}
{ } #3#4
@@ -1580,16 +1602,27 @@
}
% \end{macrocode}
% A simple auxiliary to avoid relatively expensive use of the print routine
-% for empty parts.
+% for empty parts. There is a separate function for the model as this allows
+% for the case where different font widths are in use.
% \begin{macrocode}
\cs_new_protected:Npn \@@_print_format_box:Nn #1#2
+ { \@@_print_format_box:nNn { } #1 {#2} }
+\cs_generate_variant:Nn \@@_print_format_box:Nn { No }
+\cs_new_protected:Npn \@@_print_model_box:Nn #1#2
+ { \@@_print_format_box:VNn \l_@@_model_setup_tl #1 {#2} }
+\cs_generate_variant:Nn \@@_print_model_box:Nn { No }
+\cs_new_protected:Npn \@@_print_format_box:nNn #1#2#3
{
- \hbox_set:Nn #1
+ \hbox_set:Nn #2
{
- \tl_if_blank:nF {#2}
- { \siunitx_print_number:n {#2} }
+ \tl_if_blank:nF {#3}
+ {
+ #1
+ \siunitx_print_number:n {#3}
+ }
}
}
+\cs_generate_variant:Nn \@@_print_format_box:nNn { V }
% \end{macrocode}
% A common routine for placing material after the decimal marker and
% \enquote{shuffling}.
@@ -1653,6 +1686,7 @@
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
%
% \subsection{Standard settings for module options}
%