diff options
author | Karl Berry <karl@freefriends.org> | 2024-04-23 19:29:54 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2024-04-23 19:29:54 +0000 |
commit | ab00113714975aa55e149ffed5ee9c8ac62346b2 (patch) | |
tree | 4516458049be79ca0adc27a8477ce85d2dc7b332 /Master/texmf-dist/tex/latex | |
parent | c228c52577cbf522e12eeff507e7ddd4b0e849e8 (diff) |
nicematrix (23apr24)
git-svn-id: svn://tug.org/texlive/trunk@71045 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | 131 |
1 files changed, 78 insertions, 53 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index 0e93b22e600..8b11c3adce1 100644 --- a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty +++ b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty @@ -18,8 +18,8 @@ %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% -\def\myfileversion{6.27a} -\def\myfiledate{2024/02/19} +\def\myfileversion{6.27b} +\def\myfiledate{2024/04/23} \RequirePackage{pgfcore} \usepgfmodule{shapes} \RequirePackage{l3keys2e} @@ -28,8 +28,9 @@ {\myfiledate} {\myfileversion} {Enhanced arrays with the help of PGF/TikZ} -\RequirePackage { array } \RequirePackage { amsmath } +\RequirePackage { array } +\bool_const:Nn \c__nicematrix_tagging_array_bool { \cs_if_exist_p:N \ar@ialign } \cs_new_protected:Npn \__nicematrix_error:n { \msg_error:nn { nicematrix } } \cs_new_protected:Npn \__nicematrix_warning:n { \msg_warning:nn { nicematrix } } \cs_new_protected:Npn \__nicematrix_error:nn { \msg_error:nnn { nicematrix } } @@ -71,6 +72,8 @@ \__nicematrix_warning:n { #1 } \__nicematrix_gredirect_none:n { #1 } } +\cs_set:Npn \int_if_zero:NT #1 { \int_compare:nNnT #1 = \c_zero_int } +\cs_set:Npn \int_if_zero:NTF #1 { \int_compare:nNnTF #1 = \c_zero_int } \__nicematrix_msg_new:nn { Internal~error } { Potential~problem~when~using~nicematrix.\\ @@ -175,7 +178,6 @@ { \bool_const:Nn \c__nicematrix_revtex_bool \c_false_bool } } } -\cs_generate_variant:Nn \tl_if_single_token_p:n { V } \cs_new_protected:Npn \__nicematrix_provide_pgfsyspdfmark: { \iow_now:Nn \@mainaux @@ -460,7 +462,7 @@ \str_new:N \l__nicematrix_hpos_block_str \str_set:Nn \l__nicematrix_hpos_block_str { c } \bool_new:N \l__nicematrix_hpos_of_block_cap_bool -\bool_new:N \__nicematrix_nocolor_used_bool +\bool_new:N \l__nicematrix_nocolor_used_bool \str_new:N \l__nicematrix_vpos_block_str \str_set:Nn \l__nicematrix_vpos_block_str { c } \bool_new:N \l__nicematrix_draw_first_bool @@ -507,7 +509,7 @@ \cs_set_nopar:Npn \l_tmpa_tl { ##1 } \cs_set_nopar:Npn \l_tmpb_tl { ##1 } } - \int_step_inline:nnn { \l_tmpa_tl } { \l_tmpb_tl } + \int_step_inline:nnn \l_tmpa_tl \l_tmpb_tl { \clist_put_right:Nn \l_tmpa_clist { ####1 } } } \tl_set_eq:NN #1 \l_tmpa_clist @@ -1442,7 +1444,9 @@ \@tabarray [ \str_if_eq:VnTF \l__nicematrix_baseline_tl c c t ] } -\cs_set_eq:NN \__nicematrix_old_ialign: \ialign +\bool_if:NTF \c__nicematrix_tagging_array_bool + { \cs_set_eq:NN \__nicematrix_old_ar@ialign: \ar@ialign } + { \cs_set_eq:NN \__nicematrix_old_ialign: \ialign } \cs_new_protected:Npn \__nicematrix_create_row_node: { \int_compare:nNnT \c@iRow > \g__nicematrix_last_row_node_int @@ -1481,6 +1485,11 @@ \cs_new:Npn \__nicematrix_everycr: { \noalign { \__nicematrix_everycr_i: } } \cs_new_protected:Npn \__nicematrix_everycr_i: { + \bool_if:NT \c__nicematrix_tagging_array_bool + { + \tbl_if_row_was_started:T { \UseTaggingSocket { tbl / row / end } } + \tbl_update_cell_data_for_next_row: + } \int_gzero:N \c@jCol \bool_gset_false:N \g__nicematrix_after_col_zero_bool \bool_if:NF \g__nicematrix_row_of_col_done_bool @@ -1548,6 +1557,20 @@ } { \cs_new_protected:Npn \__nicematrix_patch_booktabs: { } } } +\cs_new_protected:Npn \__nicematrix_some_initialization: + { + \dim_gzero_new:N \g__nicematrix_dp_row_zero_dim + \dim_gset:Nn \g__nicematrix_dp_row_zero_dim { \box_dp:N \@arstrutbox } + \dim_gzero_new:N \g__nicematrix_ht_row_zero_dim + \dim_gset:Nn \g__nicematrix_ht_row_zero_dim { \box_ht:N \@arstrutbox } + \dim_gzero_new:N \g__nicematrix_ht_row_one_dim + \dim_gset:Nn \g__nicematrix_ht_row_one_dim { \box_ht:N \@arstrutbox } + \dim_gzero_new:N \g__nicematrix_dp_ante_last_row_dim + \dim_gzero_new:N \g__nicematrix_ht_last_row_dim + \dim_gset:Nn \g__nicematrix_ht_last_row_dim { \box_ht:N \@arstrutbox } + \dim_gzero_new:N \g__nicematrix_dp_last_row_dim + \dim_gset:Nn \g__nicematrix_dp_last_row_dim { \box_dp:N \@arstrutbox } + } \cs_new_protected:Npn \__nicematrix_pre_array_ii: { \int_gzero:N \g__nicematrix_total_X_weight_int @@ -1570,24 +1593,29 @@ { \__nicematrix_env: - row - \int_use:N \c@iRow - base } } } - \cs_set_nopar:Npn \ialign - { - \__nicematrix_redefine_everycr: - \tabskip = \c_zero_skip - \dim_gzero_new:N \g__nicematrix_dp_row_zero_dim - \dim_gset:Nn \g__nicematrix_dp_row_zero_dim { \box_dp:N \@arstrutbox } - \dim_gzero_new:N \g__nicematrix_ht_row_zero_dim - \dim_gset:Nn \g__nicematrix_ht_row_zero_dim { \box_ht:N \@arstrutbox } - \dim_gzero_new:N \g__nicematrix_ht_row_one_dim - \dim_gset:Nn \g__nicematrix_ht_row_one_dim { \box_ht:N \@arstrutbox } - \dim_gzero_new:N \g__nicematrix_dp_ante_last_row_dim - \dim_gzero_new:N \g__nicematrix_ht_last_row_dim - \dim_gset:Nn \g__nicematrix_ht_last_row_dim { \box_ht:N \@arstrutbox } - \dim_gzero_new:N \g__nicematrix_dp_last_row_dim - \dim_gset:Nn \g__nicematrix_dp_last_row_dim { \box_dp:N \@arstrutbox } - \cs_set_eq:NN \ialign \__nicematrix_old_ialign: - \halign + \bool_if:NTF \c__nicematrix_tagging_array_bool + { + \cs_set_nopar:Npn \ar@ialign + { + \tbl_init_cell_data_for_table: + \__nicematrix_redefine_everycr: + \tabskip = \c_zero_skip + \__nicematrix_some_initialization: + \cs_set_eq:NN \ar@ialign \__nicematrix_old_ar@ialign: + \halign + } + } + { + \cs_set_nopar:Npn \ialign + { + \__nicematrix_redefine_everycr: + \tabskip = \c_zero_skip + \__nicematrix_some_initialization: + \cs_set_eq:NN \ialign \__nicematrix_old_ialign: + \halign + } } + \cs_set_eq:NN \__nicematrix_old_ldots \ldots \cs_set_eq:NN \__nicematrix_old_cdots \cdots \cs_set_eq:NN \__nicematrix_old_vdots \vdots @@ -1625,7 +1653,7 @@ { \cs_set_eq:NN \__nicematrix_tuning_last_row: \prg_do_nothing: } \bool_if:NT \l__nicematrix_renew_dots_bool \__nicematrix_renew_dots: \cs_set_eq:NN \multicolumn \__nicematrix_multicolumn:nnn - \hook_gput_code:nnn { env / tabular / begin } { . } + \hook_gput_code:nnn { env / tabular / begin } { nicematrix } { \cs_set_eq:NN \multicolumn \__nicematrix_old_multicolumn } \__nicematrix_revert_colortbl: \tl_if_exist:NT \l__nicematrix_note_in_caption_tl @@ -2282,7 +2310,7 @@ \__nicematrix_rec_preamble:n } \bool_new:N \l__nicematrix_bar_at_end_of_pream_bool -\keys_define:nn { WithArrows / p-column } +\keys_define:nn { nicematrix / p-column } { r .code:n = \str_set_eq:NN \l__nicematrix_hpos_col_str \c__nicematrix_r_str , r .value_forbidden:n = true , @@ -2346,7 +2374,7 @@ \__nicematrix_make_preamble_ii_iv:nnn { #2 } { minipage } { } } \cs_new_protected:Npn \__nicematrix_keys_p_column:n #1 - { \keys_set_known:nnN { WithArrows / p-column } { #1 } \l_tmpa_tl } + { \keys_set_known:nnN { nicematrix / p-column } { #1 } \l_tmpa_tl } \cs_new_protected:Npn \__nicematrix_make_preamble_ii_iv:nnn #1 #2 #3 { \use:e @@ -2729,7 +2757,7 @@ } \cs_new_protected:Npn \__nicematrix_make_preamble_X:w [ #1 ] { \__nicematrix_make_preamble_X_i:n { #1 } } -\keys_define:nn { WithArrows / X-column } +\keys_define:nn { nicematrix / X-column } { unknown .code:n = \int_set:Nn \l__nicematrix_weight_int { \l_keys_key_str } } \cs_new_protected:Npn \__nicematrix_make_preamble_X_i:n #1 { @@ -2738,7 +2766,7 @@ \int_zero_new:N \l__nicematrix_weight_int \int_set_eq:NN \l__nicematrix_weight_int \c_one_int \__nicematrix_keys_p_column:n { #1 } - \keys_set:no { WithArrows / X-column } \l_tmpa_tl + \keys_set:no { nicematrix / X-column } \l_tmpa_tl \int_compare:nNnT \l__nicematrix_weight_int < \c_zero_int { \__nicematrix_error_or_warning:n { negative~weight } @@ -2796,7 +2824,7 @@ \cs_new:Npn \__nicematrix_multicolumn:nnn #1 #2 #3 { \multispan { #1 } - \cs_set_eq:NN \__nicematrix_update_max_cell_width: \prg_do_nothing: % added 2023-10-04 + \cs_set_eq:NN \__nicematrix_update_max_cell_width: \prg_do_nothing: \begingroup \cs_set:Npn \@addamp { \legacy_if:nTF { @firstamp } { \@firstampfalse } { \@preamerr 5 } } @@ -3476,7 +3504,7 @@ \hbox_overlap_right:n { \skip_horizontal:N \g__nicematrix_width_last_col_dim - \skip_horizontal:N \col@sep % added 2023-11-05 + \skip_horizontal:N \col@sep \bool_if:NT \l__nicematrix_code_before_bool { \pgfsys@markposition @@ -3646,7 +3674,6 @@ { \bool_gset_true:N \g__nicematrix_delims_bool \str_gset:Nn \g__nicematrix_name_env_str { #1 NiceMatrix } - % added 2023/10/01 \int_if_zero:nT \l__nicematrix_last_col_int { \bool_set_true:N \l__nicematrix_last_col_without_value_bool @@ -3660,7 +3687,6 @@ \NewDocumentEnvironment { NiceMatrix } { ! O { } } { \str_gset:Nn \g__nicematrix_name_env_str { NiceMatrix } - % added 2023/10/01 \int_if_zero:nT \l__nicematrix_last_col_int { \bool_set_true:N \l__nicematrix_last_col_without_value_bool @@ -3767,6 +3793,7 @@ } \cs_new_protected:Npn \__nicematrix_after_array: { + \hook_gremove_code:nn { env / tabular / begin } { nicematrix } \group_begin: \bool_if:NT \g__nicematrix_last_col_found_bool { \int_set_eq:NN \l__nicematrix_last_col_int \g__nicematrix_col_total_int } @@ -3877,7 +3904,8 @@ } } { } - \cs_set_eq:NN \ialign \__nicematrix_old_ialign: + \bool_if:NT \c__nicematrix_tagging_array_bool + { \cs_set_eq:NN \ar@ialign \__nicematrix_old_ar@ialign: } \cs_set_eq:NN \SubMatrix \__nicematrix_SubMatrix \cs_set_eq:NN \UnderBrace \__nicematrix_UnderBrace \cs_set_eq:NN \OverBrace \__nicematrix_OverBrace @@ -3888,8 +3916,8 @@ \tl_gclear:N \g__nicematrix_pre_code_after_tl \cs_set_eq:NN \CodeAfter \prg_do_nothing: \seq_gclear:N \g__nicematrix_submatrix_names_seq - \int_compare:nNnT { \char_value_catcode:n { 60 } } = { 13 } - { \__nicematrix_rescan_for_spanish:N \g_nicematrix_code_after_tl } + % \int_compare:nNnT { \char_value_catcode:n { 60 } } = { 13 } + % { \__nicematrix_rescan_for_spanish:N \g_nicematrix_code_after_tl } \bool_set_true:N \l__nicematrix_in_code_after_bool \exp_last_unbraced:No \__nicematrix_CodeAfter_keys: \g_nicematrix_code_after_tl \scan_stop: @@ -5685,7 +5713,7 @@ \dim_compare:nNnTF { #1 } = \c_zero_dim { \bool_if:NTF - \__nicematrix_nocolor_used_bool + \l__nicematrix_nocolor_used_bool \__nicematrix_cartesian_path_normal_ii: { \seq_if_empty:NTF \l__nicematrix_corners_cells_seq @@ -5780,8 +5808,7 @@ \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth } \__nicematrix_qpoint:n { row - ####1 } \dim_set:Nn \l__nicematrix_tmpd_dim { \pgf@y + 0.5 \arrayrulewidth } - \cs_if_exist:cF - { __nicematrix _ ####1 _ ##1 _ nocolor } + \cs_if_exist:cF { __nicematrix _ ####1 _ ##1 _ nocolor } { \pgfpathrectanglecorners { \pgfpoint \l__nicematrix_tmpc_dim \l__nicematrix_tmpd_dim } @@ -5794,7 +5821,7 @@ \cs_new_protected:Npn \__nicematrix_cartesian_path: { \__nicematrix_cartesian_path:n \c_zero_dim } \cs_new_protected:Npn \__nicematrix_cartesian_path_nocolor:n #1 { - \bool_set_true:N \__nicematrix_nocolor_used_bool + \bool_set_true:N \l__nicematrix_nocolor_used_bool \__nicematrix_expand_clist:NN \l__nicematrix_cols_tl \c@jCol \__nicematrix_expand_clist:NN \l__nicematrix_rows_tl \c@iRow \clist_map_inline:Nn \l__nicematrix_rows_tl @@ -5915,7 +5942,7 @@ \cs_set_eq:NN \__nicematrix_old_rowcolor \rowcolor \cs_new_protected:Npn \__nicematrix_revert_colortbl: { - \hook_gput_code:nnn { env / tabular / begin } { . } + \hook_gput_code:nnn { env / tabular / begin } { nicematrix } { \cs_set_eq:NN \cellcolor \__nicematrix_old_cellcolor \cs_set_eq:NN \rowcolor \__nicematrix_old_rowcolor @@ -6138,7 +6165,6 @@ \cs_new_protected:Npn \__nicematrix_vline_v: { \begin {tikzpicture } - % added 2023/09/25 \CT@arc@ \tl_if_empty:NF \l__nicematrix_rule_color_tl { \tl_put_right:Nx \l__nicematrix_tikz_rule_tl { , color = \l__nicematrix_rule_color_tl } } @@ -6341,7 +6367,6 @@ \cs_new_protected:Npn \__nicematrix_hline_v: { \begin { tikzpicture } - % added 2023/09/25 \CT@arc@ \tl_if_empty:NF \l__nicematrix_rule_color_tl { \tl_put_right:Nx \l__nicematrix_tikz_rule_tl { , color = \l__nicematrix_rule_color_tl } } @@ -7212,7 +7237,7 @@ \bool_if:NT \g__nicematrix_rotate_bool { \bool_if:NTF \g__nicematrix_rotate_c_bool - { v-center } + { m } { \int_compare:nNnT \c@iRow = \l__nicematrix_last_row_int T } } @@ -7368,8 +7393,9 @@ T .code:n = \str_set:Nn \l__nicematrix_vpos_block_str T , b .code:n = \str_set:Nn \l__nicematrix_vpos_block_str b , B .code:n = \str_set:Nn \l__nicematrix_vpos_block_str B , - v-center .code:n = \str_set:Nn \l__nicematrix_vpos_block_str { c } , - v-center .value_forbidden:n = true , + m .code:n = \str_set:Nn \l__nicematrix_vpos_block_str { c } , + m .value_forbidden:n = true , + v-center .meta:n = m , name .tl_set:N = \l__nicematrix_block_name_str , name .value_required:n = true , name .initial:n = , @@ -7383,7 +7409,9 @@ } \cs_new_protected:Npn \__nicematrix_draw_blocks: { - \cs_set_eq:NN \ialign \__nicematrix_old_ialign: + \bool_if:NTF \c__nicematrix_tagging_array_bool + { \cs_set_eq:NN \ar@ialign \__nicematrix_old_ar@ialign: } + { \cs_set_eq:NN \ialign \__nicematrix_old_ialign: } \seq_map_inline:Nn \g__nicematrix_blocks_seq { \__nicematrix_Block_iv:nnnnnn ##1 } } \cs_new_protected:Npn \__nicematrix_Block_iv:nnnnnn #1 #2 #3 #4 #5 #6 @@ -7455,13 +7483,10 @@ { \bool_lazy_or:nnT \l__nicematrix_hlines_block_bool \l__nicematrix_vlines_block_bool { \__nicematrix_error:n { hlines~with~color } } - } - \tl_if_empty:NF \l__nicematrix_draw_tl - { \tl_gput_right:Nx \g_nicematrix_code_after_tl { \__nicematrix_stroke_block:nnn - { \exp_not:n { #5 } } % #5 are the options + { \exp_not:n { #5 } } { #1 - #2 } { \int_use:N \l__nicematrix_last_row_int - \int_use:N \l__nicematrix_last_col_int } } @@ -7690,7 +7715,7 @@ - base } } - \dim_sub:Nn \l_tmpa_dim { 0.5 \arrayrulewidth } % added 2023-02-21 + \dim_sub:Nn \l_tmpa_dim { 0.5 \arrayrulewidth } \pgfpointanchor { \__nicematrix_env: - #1 - #2 - block @@ -9194,7 +9219,7 @@ The~preamble~of~your~\__nicematrix_full_name_env:\ announces~\int_use:N \g__nicematrix_static_num_of_col_int\ columns~but~you~use~only~\int_use:N \c@jCol.\\ The~columns~you~did~not~used~won't~be~created.\\ - You~won't~have~similar~error~till~the~end~of~the~document. + You~won't~have~similar~error~message~till~the~end~of~the~document. } \__nicematrix_msg_new:nn { in~first~col } { |