From cd3bef34bd0bfcf1625056fd2f2832328c516179 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sat, 2 Jul 2022 03:03:53 +0000 Subject: CTAN sync 202207020303 --- macros/latex/contrib/tabularray/tabularray.sty | 146 ++++++++++++++----------- 1 file changed, 82 insertions(+), 64 deletions(-) (limited to 'macros/latex/contrib/tabularray/tabularray.sty') diff --git a/macros/latex/contrib/tabularray/tabularray.sty b/macros/latex/contrib/tabularray/tabularray.sty index bb8d02f6c4..ba257a4268 100644 --- a/macros/latex/contrib/tabularray/tabularray.sty +++ b/macros/latex/contrib/tabularray/tabularray.sty @@ -12,11 +12,13 @@ %% \DeclareRelease and \DeclareCurrentRelease are added in LaTeX 2018-04-01 \NeedsTeXFormat{LaTeX2e}[2018-04-01] +\providecommand\DeclareRelease[3]{} +\providecommand\DeclareCurrentRelease[2]{} \DeclareRelease{v2021}{2021-01-01}{tabularray-2021.sty} \DeclareCurrentRelease{}{2022-01-01} \RequirePackage{expl3} -\ProvidesExplPackage{tabularray}{2022-06-01}{2022B} +\ProvidesExplPackage{tabularray}{2022-07-01}{2022C} {Typeset tabulars and arrays with LaTeX3} %% \IfFormatAtLeastTF, xparse and lthooks are added in LaTeX 2020-10-01 @@ -24,7 +26,7 @@ \msg_new:nnn { tabularray } { latex-too-old } { Your ~ LaTeX ~ release ~ is ~ too ~ old. \\ - Please ~ update ~ to ~ 2020-10-01 ~ first. + Please ~ update ~ it ~ to ~ 2020-10-01 ~ first. } \@ifl@t@r\fmtversion{2020-10-01}{}{ %% Support TeX Live 2020 on Overleaf @@ -127,16 +129,16 @@ %% Some counters for row and column numbering. %% We may need to restore all LaTeX counters in measuring and building cells, %% so we must not define these counters with \newcounter command. -\int_new:N \c@rownum -\int_new:N \c@colnum -\int_new:N \c@rowcount -\int_new:N \c@colcount +\int_zero_new:N \c@rownum +\int_zero_new:N \c@colnum +\int_zero_new:N \c@rowcount +\int_zero_new:N \c@colcount %% Add missing \therownum, \thecolnum, \therowcount, \thecolcount (issue #129) -\NewExpandableDocumentCommand \therownum {} { \@arabic \c@rownum } -\NewExpandableDocumentCommand \thecolnum {} { \@arabic \c@colnum } -\NewExpandableDocumentCommand \therowcount {} { \@arabic \c@rowcount } -\NewExpandableDocumentCommand \thecolcount {} { \@arabic \c@colcount } +\ProvideExpandableDocumentCommand \therownum {} { \@arabic \c@rownum } +\ProvideExpandableDocumentCommand \thecolnum {} { \@arabic \c@colnum } +\ProvideExpandableDocumentCommand \therowcount {} { \@arabic \c@rowcount } +\ProvideExpandableDocumentCommand \thecolcount {} { \@arabic \c@colcount } %% Some dimensions for row and column spacing \dim_new:N \abovesep @@ -955,8 +957,14 @@ \__tblr_make_xparse_arg_spec:nnN { #2 } { #3 } \l__tblr_a_tl \exp_args:NcV \NewDocumentCommand { __tblr_table_command_ \cs_to_str:N #1 :w } \l__tblr_a_tl { #4 } - \exp_args:NcV \NewDocumentCommand - { __tblr_table_command_ \cs_to_str:N #1 _gobble :w } \l__tblr_a_tl { } + \cs_if_exist:NTF #1 + { + \cs_set_eq:cN { __tblr_table_command_ \cs_to_str:N #1 _saved:w } #1 + } + { + \exp_args:NcV \NewDocumentCommand + { __tblr_table_command_ \cs_to_str:N #1 _saved:w } \l__tblr_a_tl { } + } \IfValueTF { #3 } { \tl_gset:cn { g__tblr_table_cmd_ \cs_to_str:N #1 _arg_numb_tl } {-#2} @@ -977,7 +985,7 @@ \cs_new_protected:Npn \__tblr_disable_table_commands: { \clist_map_inline:Nn \g__tblr_table_commands_clist - { \cs_set_eq:Nc ##1 { __tblr_table_command_ \cs_to_str:N ##1 _gobble:w } } + { \cs_set_eq:Nc ##1 { __tblr_table_command_ \cs_to_str:N ##1 _saved:w } } } \cs_new_protected:Npn \__tblr_execute_table_commands: @@ -2258,12 +2266,12 @@ } \cs_generate_variant:Nn \__tblr_row_unknown_key:n { V } -\NewTableCommand \pagebreak +\NewTableCommand \pagebreak [1] [4] { \hborder { pagebreak = yes } } -\NewTableCommand \nopagebreak +\NewTableCommand \nopagebreak [1] [4] { \hborder { pagebreak = no } } @@ -3206,7 +3214,7 @@ \cs_new_protected:Npn \__tblr_calc_cell_and_line_sizes: { - \__tblr_make_strut_box: + \__tblr_prepare_stretch: \__tblr_calculate_line_sizes: \__tblr_calculate_cell_sizes: \LogTblrTracing { cell, row, column, hline, vline } @@ -3214,54 +3222,60 @@ \__tblr_adjust_sizes_for_span_cells: } -%% make strut box from stretch option of the table - -\box_new:N \l__tblr_strut_ht_box -\box_new:N \l__tblr_strut_dp_box - -\cs_new_protected:Npn \__tblr_make_strut_box: +%% prepare stretch option of the table +\fp_new:N \l__tblr_stretch_fp +\dim_new:N \l__tblr_strut_dp_dim +\dim_new:N \l__tblr_strut_ht_dim +\cs_new_protected:Npn \__tblr_prepare_stretch: { - \tl_set:Nx \l__tblr_s_tl { \__tblr_prop_item:ne { inner } { stretch } } - \fp_compare:nNnTF { \l__tblr_s_tl } > {0} + \fp_set:Nn \l__tblr_stretch_fp + { \__tblr_prop_item:nn { inner } { stretch } } + \fp_compare:nNnTF \l__tblr_stretch_fp > \c_zero_fp + { + \dim_set:Nn \l__tblr_strut_dp_dim + { \fp_use:N \l__tblr_stretch_fp \box_dp:N \strutbox } + \dim_set:Nn \l__tblr_strut_ht_dim + { \fp_use:N \l__tblr_stretch_fp \box_ht:N \strutbox } + \cs_set_eq:NN \__tblr_leave_vmode: \mode_leave_vertical: + \cs_set_eq:NN \__tblr_process_stretch: \__tblr_process_stretch_real: + } { - \hbox_set:Nn \l__tblr_strut_ht_box - { \vrule height \l__tblr_s_tl \box_ht:N \strutbox width ~ 0pt } - \hbox_set:Nn \l__tblr_strut_dp_box - { \vrule depth \l__tblr_s_tl \box_dp:N \strutbox width ~ 0pt } - \cs_set_eq:NN \__tblr_use_strut_ht_box: \__tblr_use_strut_ht_box_real: - \cs_set_eq:NN \__tblr_use_strut_dp_box: \__tblr_use_strut_dp_box_real: + \cs_set_eq:NN \__tblr_process_stretch: \prg_do_nothing: + \fp_compare:nNnTF \l__tblr_stretch_fp < \c_zero_fp + { \cs_set_eq:NN \__tblr_leave_vmode: \@setminipage } % for lists (see issue #99) + { \cs_set_eq:NN \__tblr_leave_vmode: \mode_leave_vertical: } } + } +\cs_new_eq:NN \__tblr_leave_vmode: \mode_leave_vertical: +\cs_new_protected:Npn \__tblr_process_stretch_real: + { + \dim_compare:nNnT \l__tblr_strut_dp_dim > { \box_dp:N \l_tmpb_box } { - \fp_compare:nNnTF { \l__tblr_s_tl } < {0} + \box_set_dp:Nn \l_tmpa_box { - \cs_set_eq:NN \__tblr_use_strut_ht_box: \__tblr_use_strut_ht_box_vmode: + \box_dp:N \l_tmpa_box + - \box_dp:N \l_tmpb_box + + \l__tblr_strut_dp_dim } + \box_set_dp:Nn \l_tmpb_box { \l__tblr_strut_dp_dim } + } + \dim_compare:nNnT \l__tblr_strut_ht_dim > { \box_ht:N \l_tmpa_box } + { + \hbox_set:Nn \l_tmpa_box { \box_use:N \l_tmpa_box } + \hbox_set:Nn \l_tmpb_box { \box_use:N \l_tmpb_box } + \box_set_ht:Nn \l_tmpb_box { - \cs_set_eq:NN \__tblr_use_strut_ht_box: \__tblr_use_strut_ht_box_hmode: + \box_ht:N \l_tmpb_box + - \box_ht:N \l_tmpa_box + + \l__tblr_strut_ht_dim } - \cs_set_eq:NN \__tblr_use_strut_dp_box: \__tblr_use_strut_dp_box_ignore: + \box_set_ht:Nn \l_tmpa_box { \l__tblr_strut_ht_dim } + %% return vbox for vertical-align: \c__tblr_middle_m_tl + \vbox_set_top:Nn \l_tmpa_box { \box_use:N \l_tmpa_box } + \vbox_set:Nn \l_tmpb_box { \box_use:N \l_tmpb_box } } } - -\cs_new_protected:Npn \__tblr_use_strut_ht_box_real: - { - \mode_leave_vertical: - \box_use:N \l__tblr_strut_ht_box - } -\cs_new_protected:Npn \__tblr_use_strut_ht_box_hmode: - { - \mode_leave_vertical: - } -\cs_new_protected:Npn \__tblr_use_strut_ht_box_vmode: - { - \@minipagetrue % for lists (see issue #99) - } - -\cs_new_protected:Npn \__tblr_use_strut_dp_box_real: - { - \box_use:N \l__tblr_strut_dp_box - } -\cs_new_protected:Npn \__tblr_use_strut_dp_box_ignore: { } +\cs_new_eq:NN \__tblr_process_stretch: \__tblr_process_stretch_real: %% Calculate the thickness for every hline and vline \cs_new_protected:Npn \__tblr_calculate_line_sizes: @@ -3309,7 +3323,10 @@ \tl_set:Nx \l__tblr_w_tl { \dim_eval:n { \box_wd:N \l__tblr_b_box } } \__tblr_spec_gput_if_larger:nee { vline } { [#2](##1) / @vline-width } { \l__tblr_w_tl } - \dim_add:Nn \l__tblr_w_dim { \l__tblr_w_tl } + \dim_add:Nn \l__tblr_w_dim + { + \__tblr_spec_item:nn { vline } { [#2](##1) / @vline-width } + } \dim_add:Nn \l__tblr_w_dim { \l__tblr_s_tl } } \dim_add:Nn \l__tblr_w_dim { - \l__tblr_s_tl } @@ -3375,7 +3392,10 @@ } \__tblr_spec_gput_if_larger:nee { hline } { [#1](##1) / @hline-height } { \l__tblr_h_tl } - \dim_add:Nn \l__tblr_h_dim { \l__tblr_h_tl } + \dim_add:Nn \l__tblr_h_dim + { + \__tblr_spec_item:nn { hline } { [#1](##1) / @hline-height } + } \dim_add:Nn \l__tblr_h_dim { \l__tblr_s_tl } } \dim_add:Nn \l__tblr_h_dim { - \l__tblr_s_tl } @@ -3622,9 +3642,11 @@ } \__tblr_restore_counters:n { cell } } + \tl_put_left:NV \l__tblr_c_tl \l__tblr_f_tl \tl_set:Nx \l__tblr_cell_fg_tl { \__tblr_data_item:neen { cell } {#1} {#2} { foreground } } - \tl_put_left:NV \l__tblr_c_tl \l__tblr_f_tl + \tl_if_empty:NF \l__tblr_cell_fg_tl + { \exp_args:NV \color \l__tblr_cell_fg_tl } \__tblr_get_vcell_and_sizes:NN \l__tblr_c_tl \l__tblr_w_tl \group_end: } @@ -3686,10 +3708,9 @@ \cs_new_protected:Npn \__tblr_get_vcell_and_sizes:NN #1 #2 { \group_begin: - \__tblr_save_counters:n { cell } - \vbox_set_top:Nn \l_tmpa_box { \__tblr_make_vcell_text:NN #1 #2 } - \__tblr_restore_counters:n { cell } \vbox_set:Nn \l_tmpb_box { \__tblr_make_vcell_text:NN #1 #2 } + \vbox_set_top:Nn \l_tmpa_box { \vbox_unpack:N \l_tmpb_box } + \__tblr_process_stretch: \dim_gset:Nn \g__tblr_cell_wd_dim { \box_wd:N \l_tmpb_box } \dim_gset:Nn \g__tblr_cell_ht_dim { \box_ht:N \l_tmpb_box + \box_dp:N \l_tmpb_box } @@ -3738,13 +3759,10 @@ \dim_set:Nn \tex_hsize:D { #2 } \TblrParboxRestore \cs:w __tblr_halign_command_ \g__tblr_cell_halign_tl : \cs_end: - %% \mode_leave_vertical: has been moved into \__tblr_use_strut_ht_box: - \__tblr_use_strut_ht_box: - \tl_if_empty:NF \l__tblr_cell_fg_tl { \exp_args:NV \color \l__tblr_cell_fg_tl } + \__tblr_leave_vmode: \bool_if:NTF \l__tblr_cell_math_mode_bool { #1 } { \__tblr_rescan_cell_tokens:N #1 } - \__tblr_use_strut_dp_box: } %% When using verb option, there is an end-of-line character at the end. -- cgit v1.2.3