From 4d4e9cf8c67a4f888152eb7e0293798df3de61ac Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 9 Apr 2021 20:05:12 +0000 Subject: nicematrix (9apr21) git-svn-id: svn://tug.org/texlive/trunk@58803 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/latex/nicematrix/nicematrix.sty | 190 ++++++++++++--------- 1 file changed, 108 insertions(+), 82 deletions(-) (limited to 'Master/texmf-dist/tex/latex/nicematrix') diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index da3db9af6f1..1c9828f225f 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{5.13} -\def\myfiledate{2021/03/23} +\def\myfileversion{5.14} +\def\myfiledate{2021/04/08} \RequirePackage{pgfcore} \usepgfmodule{shapes} \RequirePackage{l3keys2e} @@ -323,8 +323,10 @@ \dim_new:N \l__nicematrix_rounded_corners_dim \tl_new:N \l__nicematrix_color_tl \dim_new:N \l__nicematrix_line_width_dim -\tl_new:N \l__nicematrix_pos_of_block_tl -\tl_set:Nn \l__nicematrix_pos_of_block_tl { c } +\tl_new:N \l__nicematrix_hpos_of_block_tl +\tl_set:Nn \l__nicematrix_hpos_of_block_tl { c } +\tl_new:N \l__nicematrix_vpos_of_block_tl +\tl_set:Nn \l__nicematrix_vpos_of_block_tl { c } \bool_new:N \l__nicematrix_draw_first_bool \int_new:N \g__nicematrix_block_box_int \dim_new:N \l__nicematrix_submatrix_extra_height_dim @@ -481,7 +483,7 @@ \bool_new:N \l__nicematrix_exterior_arraycolsep_bool \bool_new:N \l__nicematrix_parallelize_diags_bool \bool_set_true:N \l__nicematrix_parallelize_diags_bool -\clist_new:N \l__nicematrix_except_corners_clist +\clist_new:N \l__nicematrix_corners_clist \dim_new:N \l__nicematrix_notes_above_space_dim \AtBeginDocument { \dim_set:Nn \l__nicematrix_notes_above_space_dim { 1 mm } } \bool_new:N \l__nicematrix_nullify_dots_bool @@ -597,15 +599,15 @@ \keys_define:nn { NiceMatrix / Env } { delimiters/max-width .bool_set:N = \l__nicematrix_delimiters_max_width_bool , - except-corners .clist_set:N = \l__nicematrix_except_corners_clist , - except-corners .default:n = { NW , SW , NE , SE } , hvlines-except-corners .code:n = { - \clist_set:Nn \l__nicematrix_except_corners_clist { #1 } + \clist_set:Nn \l__nicematrix_corners_clist { #1 } \clist_set:Nn \l__nicematrix_vlines_clist { all } \clist_set:Nn \l__nicematrix_hlines_clist { all } } , hvlines-except-corners .default:n = { NW , SW , NE , SE } , + corners .clist_set:N = \l__nicematrix_corners_clist , + corners .default:n = { NW , SW , NE , SE } , code-before .code:n = { \tl_if_empty:nF { #1 } @@ -852,7 +854,6 @@ \int_gincr:N \c@jCol \int_compare:nNnT \c@jCol = 1 { \int_compare:nNnT \l__nicematrix_first_col_int = 1 \__nicematrix_begin_of_row: } - \int_gset:Nn \g__nicematrix_col_total_int { \int_max:nn \g__nicematrix_col_total_int \c@jCol } \hbox_set:Nw \l__nicematrix_cell_box \bool_if:NF \l__nicematrix_NiceTabular_bool { @@ -968,6 +969,7 @@ \__nicematrix_node_for_the_cell: { \box_use_drop:N \l__nicematrix_cell_box } } + \int_gset:Nn \g__nicematrix_col_total_int { \int_max:nn \g__nicematrix_col_total_int \c@jCol } \bool_gset_false:N \g__nicematrix_empty_cell_bool \bool_gset_false:N \g__nicematrix_not_empty_cell_bool } @@ -2509,43 +2511,46 @@ \cs_if_exist:NT \theiRow { \int_gset_eq:NN \c@iRow \l__nicematrix_old_iRow_int } \cs_if_exist:NT \thejCol { \int_gset_eq:NN \c@jCol \l__nicematrix_old_jCol_int } } +\pgfdeclareshape { __nicematrix_diag_node } + { + \savedanchor { \five } + { + \dim_gset_eq:NN \pgf@x \l_tmpa_dim + \dim_gset_eq:NN \pgf@y \l_tmpb_dim + } + \anchor { 5 } { \five } + \anchor { center } { \pgfpointorigin } + } \cs_new_protected:Npn \__nicematrix_create_diag_nodes: { \pgfpicture \pgfrememberpicturepositiononpagetrue - \int_step_inline:nn { \int_max:nn \c@iRow \c@jCol + 1 } + \int_step_inline:nn { \int_max:nn \c@iRow \c@jCol } { - \__nicematrix_qpoint:n { row - \int_min:nn { ##1 } { \c@iRow + 1 } } - \dim_set_eq:NN \l_tmpa_dim \pgf@y \__nicematrix_qpoint:n { col - \int_min:nn { ##1 } { \c@jCol + 1 } } - \pgfcoordinate { \__nicematrix_env: - ##1 } { \pgfpoint \pgf@x \l_tmpa_dim } - } + \dim_set_eq:NN \l_tmpa_dim \pgf@x + \__nicematrix_qpoint:n { row - \int_min:nn { ##1 } { \c@iRow + 1 } } + \dim_set_eq:NN \l_tmpb_dim \pgf@y + \__nicematrix_qpoint:n { col - \int_min:nn { ##1 + 1 } { \c@jCol + 1 } } + \dim_set_eq:NN \l_tmpc_dim \pgf@x + \__nicematrix_qpoint:n { row - \int_min:nn { ##1 + 1 } { \c@iRow + 1 } } + \dim_set_eq:NN \l_tmpd_dim \pgf@y + \pgftransformshift { \pgfpoint \l_tmpa_dim \l_tmpb_dim } + \dim_set:Nn \l_tmpa_dim { ( \l_tmpc_dim - \l_tmpa_dim ) / 2 } + \dim_set:Nn \l_tmpb_dim { ( \l_tmpd_dim - \l_tmpb_dim ) / 2 } + \pgfnode { __nicematrix_diag_node } { center } { } { \__nicematrix_env: - ##1 } { } + } + \int_set:Nn \l_tmpa_int { \int_max:nn \c@iRow \c@jCol + 1 } + \__nicematrix_qpoint:n { row - \int_min:nn { \l_tmpa_int } { \c@iRow + 1 } } + \dim_set_eq:NN \l_tmpa_dim \pgf@y + \__nicematrix_qpoint:n { col - \int_min:nn { \l_tmpa_int } { \c@jCol + 1 } } + \pgfcoordinate + { \__nicematrix_env: - \int_use:N \l_tmpa_int } { \pgfpoint \pgf@x \l_tmpa_dim } \pgfnodealias { \__nicematrix_env: - last } { \__nicematrix_env: - \int_eval:n { \int_max:nn \c@iRow \c@jCol + 1 } } \endpgfpicture } -\bool_if:nT - { \sys_if_engine_xetex_p: || \sys_if_engine_luatex_p: } - { \tl_put_right:Nn \__nicematrix_create_diag_nodes: \__nicematrix_create_half_nodes: } -\cs_new_protected:Npn \__nicematrix_create_half_nodes: - { - \int_step_inline:nn { \int_max:nn \c@iRow \c@jCol } - { - \pgfpicture - \pgfrememberpicturepositiononpagetrue - \pgfcoordinate { \__nicematrix_env: - ##1 ½ } - { - \pgfpointscale { 0.5 } - { - \pgfpointadd - { \__nicematrix_qpoint:n { ##1 } } - { \__nicematrix_qpoint:n { \int_eval:n { ##1 + 1 } } } - } - } - \endpgfpicture - } - } \cs_new_protected:Npn \__nicematrix_find_extremities_of_line:nnnn #1 #2 #3 #4 { \cs_set:cpn { __nicematrix _ dotted _ #1 - #2 } { } @@ -3062,21 +3067,13 @@ { \bool_if:NTF \l__nicematrix_initial_open_bool { - % \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_initial_i_int } - % \dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y \__nicematrix_open_y_initial_dim: - % \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l__nicematrix_initial_j_int } - % \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x \__nicematrix_open_x_initial_dim: } { \__nicematrix_set_initial_coords_from_anchor:n { south~west } } \bool_if:NTF \l__nicematrix_final_open_bool { - % \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l__nicematrix_final_i_int } - % \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y \__nicematrix_open_y_final_dim: - % \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_final_j_int } - % \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x \__nicematrix_open_x_final_dim: } { \__nicematrix_set_final_coords_from_anchor:n { north~east } } @@ -3799,7 +3796,7 @@ \cs_new_protected:Npn \__nicematrix_arraycolor_code_after:nnn #1 #2 #3 { \group_begin: - \clist_set:Nn \l__nicematrix_except_corners_clist { #3 } + \clist_set:Nn \l__nicematrix_corners_clist { #3 } \__nicematrix_compute_corners: \int_step_inline:nn \c@iRow { @@ -3935,8 +3932,13 @@ \tl_if_in:NnTF \l_tmpa_tl { - } { \__nicematrix_cut_on_hyphen:w ##1 \q_stop } { \__nicematrix_cut_on_hyphen:w ##1 - ##1 \q_stop } - \tl_if_empty:NT \l_tmpa_tl { \tl_set:Nn \l_tmpa_tl { 1 } } - \tl_if_empty:NT \l_tmpb_tl + \bool_lazy_or:nnT + { \tl_if_blank_p:V \l_tmpa_tl } + { \str_if_eq_p:Vn \l_tmpa_tl { * } } + { \tl_set:Nn \l_tmpa_tl { 1 } } + \bool_lazy_or:nnT + { \tl_if_blank_p:V \l_tmpb_tl } + { \str_if_eq_p:Vn \l_tmpb_tl { * } } { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } } \int_compare:nNnT \l_tmpb_tl > \c@jCol { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } } @@ -3987,7 +3989,7 @@ } \NewDocumentCommand \__nicematrix_columncolor_preamble { O { } m } { - \int_compare:nNnT \c@iRow = 1 + \int_compare:nNnT \c@jCol > \g__nicematrix_col_total_int { \tl_gput_left:Nx \g_nicematrix_code_before_tl { @@ -4037,7 +4039,7 @@ { \__nicematrix_test_vline_in_block:nnnn ##1 } \seq_map_inline:Nn \g__nicematrix_pos_of_stroken_blocks_seq { \__nicematrix_test_vline_in_stroken_block:nnnn ##1 } - \clist_if_empty:NF \l__nicematrix_except_corners_clist + \clist_if_empty:NF \l__nicematrix_corners_clist \__nicematrix_test_in_corner_v: \bool_if:NTF \g_tmpa_bool { @@ -4163,7 +4165,7 @@ { \__nicematrix_test_hline_in_block:nnnn ##1 } \seq_map_inline:Nn \g__nicematrix_pos_of_stroken_blocks_seq { \__nicematrix_test_hline_in_stroken_block:nnnn ##1 } - \clist_if_empty:NF \l__nicematrix_except_corners_clist \__nicematrix_test_in_corner_h: + \clist_if_empty:NF \l__nicematrix_corners_clist \__nicematrix_test_in_corner_h: \bool_if:NTF \g_tmpa_bool { \tl_if_empty:NT \l_tmpc_tl @@ -4333,7 +4335,7 @@ \cs_new_protected:Npn \__nicematrix_compute_corners: { \seq_clear_new:N \l__nicematrix_empty_corner_cells_seq - \clist_map_inline:Nn \l__nicematrix_except_corners_clist + \clist_map_inline:Nn \l__nicematrix_corners_clist { \str_case:nnF { ##1 } { @@ -4746,12 +4748,16 @@ } \keys_define:nn { NiceMatrix / Block / FirstPass } { - l .code:n = \tl_set:Nn \l__nicematrix_pos_of_block_tl l , + l .code:n = \tl_set:Nn \l__nicematrix_hpos_of_block_tl l , l .value_forbidden:n = true , - r .code:n = \tl_set:Nn \l__nicematrix_pos_of_block_tl r , + r .code:n = \tl_set:Nn \l__nicematrix_hpos_of_block_tl r , r .value_forbidden:n = true , - c .code:n = \tl_set:Nn \l__nicematrix_pos_of_block_tl c , + c .code:n = \tl_set:Nn \l__nicematrix_hpos_of_block_tl c , c .value_forbidden:n = true , + t .code:n = \tl_set:Nn \l__nicematrix_vpos_of_block_tl t , + t .value_forbidden:n = true , + b .code:n = \tl_set:Nn \l__nicematrix_vpos_of_block_tl b , + b .value_forbidden:n = true , color .tl_set:N = \l__nicematrix_color_tl , color .value_required:n = true , } @@ -4776,10 +4782,10 @@ \int_compare:nNnTF \l_tmpb_int = 1 { \tl_if_empty:NTF \l__nicematrix_cell_type_tl - { \tl_set:Nn \l__nicematrix_pos_of_block_tl c } - { \tl_set_eq:NN \l__nicematrix_pos_of_block_tl \l__nicematrix_cell_type_tl } + { \tl_set:Nn \l__nicematrix_hpos_of_block_tl c } + { \tl_set_eq:NN \l__nicematrix_hpos_of_block_tl \l__nicematrix_cell_type_tl } } - { \tl_set:Nn \l__nicematrix_pos_of_block_tl c } + { \tl_set:Nn \l__nicematrix_hpos_of_block_tl c } \keys_set_known:nn { NiceMatrix / Block / FirstPass } { #3 } \tl_set:Nx \l_tmpa_tl { @@ -4822,18 +4828,24 @@ \cs_set:Npn \arraystretch { 1 } \dim_set_eq:NN \extrarowheight \c_zero_dim #4 - \bool_if:NT \g__nicematrix_rotate_bool { \tl_set:Nn \l__nicematrix_pos_of_block_tl c } + \bool_if:NT \g__nicematrix_rotate_bool { \tl_set:Nn \l__nicematrix_hpos_of_block_tl c } \bool_if:NTF \l__nicematrix_NiceTabular_bool { - \exp_args:Nnx \begin { tabular } - { @ { } \l__nicematrix_pos_of_block_tl @ { } } + \use:x + { + \exp_not:N \begin { tabular } [ \l__nicematrix_vpos_of_block_tl ] + { @ { } \l__nicematrix_hpos_of_block_tl @ { } } + } #5 \end { tabular } } { \c_math_toggle_token - \exp_args:Nnx \begin { array } - { @ { } \l__nicematrix_pos_of_block_tl @ { } } + \use:x + { + \exp_not:N \begin { array } [ \l__nicematrix_vpos_of_block_tl ] + { @ { } \l__nicematrix_hpos_of_block_tl @ { } } + } #5 \end { array } \c_math_toggle_token @@ -4883,7 +4895,7 @@ \seq_gput_right:Nx \g__nicematrix_blocks_seq { \l_tmpa_tl - { \exp_not:n { #3 } , \l__nicematrix_pos_of_block_tl } + { \exp_not:n { #3 } , \l__nicematrix_hpos_of_block_tl } { \box_use_drop:c { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box } @@ -4906,9 +4918,12 @@ \dim_set_eq:NN \extrarowheight \c_zero_dim #4 \bool_if:NT \g__nicematrix_rotate_bool - { \tl_set:Nn \l__nicematrix_pos_of_block_tl c } - \exp_args:Nnx \begin { tabular } - { @ { } \l__nicematrix_pos_of_block_tl @ { } } + { \tl_set:Nn \l__nicematrix_hpos_of_block_tl c } + \use:x + { + \exp_not:N \begin { tabular } [ \l__nicematrix_vpos_of_block_tl ] + { @ { } \l__nicematrix_hpos_of_block_tl @ { } } + } #5 \end { tabular } \group_end: @@ -4919,10 +4934,15 @@ \dim_set_eq:NN \extrarowheight \c_zero_dim #4 \bool_if:NT \g__nicematrix_rotate_bool - { \tl_set:Nn \l__nicematrix_pos_of_block_tl c } + { \tl_set:Nn \l__nicematrix_hpos_of_block_tl c } \c_math_toggle_token - \exp_args:Nnx \begin { array } - { @ { } \l__nicematrix_pos_of_block_tl @ { } } #5 \end { array } + \use:x + { + \exp_not:N \begin { array } [ \l__nicematrix_vpos_of_block_tl ] + { @ { } \l__nicematrix_hpos_of_block_tl @ { } } + } + #5 + \end { array } \c_math_toggle_token \group_end: } @@ -4944,12 +4964,16 @@ borders .value_required:n = true , line-width .dim_set:N = \l__nicematrix_line_width_dim , line-width .value_required:n = true , - l .code:n = \tl_set:Nn \l__nicematrix_pos_of_block_tl l , + l .code:n = \tl_set:Nn \l__nicematrix_hpos_of_block_tl l , l .value_forbidden:n = true , - r .code:n = \tl_set:Nn \l__nicematrix_pos_of_block_tl r , + r .code:n = \tl_set:Nn \l__nicematrix_hpos_of_block_tl r , r .value_forbidden:n = true , - c .code:n = \tl_set:Nn \l__nicematrix_pos_of_block_tl c , + c .code:n = \tl_set:Nn \l__nicematrix_hpos_of_block_tl c , c .value_forbidden:n = true , + t .code:n = \tl_set:Nn \l__nicematrix_vpos_of_block_tl t , + t .value_forbidden:n = true , + b .code:n = \tl_set:Nn \l__nicematrix_vpos_of_block_tl b , + b .value_forbidden:n = true , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~Block } } \cs_new_protected:Npn \__nicematrix_draw_blocks: @@ -5122,7 +5146,7 @@ \pgfpointanchor { \__nicematrix_env: - #1 - #2 - block - short } { - \str_case:Vn \l__nicematrix_pos_of_block_tl + \str_case:Vn \l__nicematrix_hpos_of_block_tl { c { center } l { west } @@ -5134,7 +5158,7 @@ \pgfnode { rectangle } { - \str_case:Vn \l__nicematrix_pos_of_block_tl + \str_case:Vn \l__nicematrix_hpos_of_block_tl { c { base } l { base~west } @@ -5145,18 +5169,18 @@ } { \int_compare:nNnT { #2 } = 0 - { \tl_set:Nn \l__nicematrix_pos_of_block_tl r } + { \tl_set:Nn \l__nicematrix_hpos_of_block_tl r } \bool_if:nT \g__nicematrix_last_col_found_bool { \int_compare:nNnT { #2 } = \g__nicematrix_col_total_int - { \tl_set:Nn \l__nicematrix_pos_of_block_tl l } + { \tl_set:Nn \l__nicematrix_hpos_of_block_tl l } } \pgftransformshift { \pgfpointanchor { \__nicematrix_env: - #1 - #2 - block - short } { - \str_case:Vn \l__nicematrix_pos_of_block_tl + \str_case:Vn \l__nicematrix_hpos_of_block_tl { c { center } l { west } @@ -5168,7 +5192,7 @@ \pgfnode { rectangle } { - \str_case:Vn \l__nicematrix_pos_of_block_tl + \str_case:Vn \l__nicematrix_hpos_of_block_tl { c { center } l { west } @@ -6131,7 +6155,7 @@ \__nicematrix_msg_new:nn { bad~corner } { #1~is~an~incorrect~specification~for~a~corner~(in~the~keys~ - 'except-corners'~and~'hvlines-except-corners').~The~available~ + 'corners'~and~'except-corners').~The~available~ values~are:~NW,~SW,~NE~and~SE.\\ If~you~go~on,~this~specification~of~corner~will~be~ignored. } @@ -6305,6 +6329,7 @@ code-for-first-row,~ code-for-last-col,~ code-for-last-row,~ + corners,~ create-extra-nodes,~ create-medium-nodes,~ create-large-nodes,~ @@ -6314,7 +6339,6 @@ first-row,~ hlines,~ hvlines,~ - hvlines-except-corners,~ last-col,~ last-row,~ left-margin,~ @@ -6353,6 +6377,7 @@ code-for-last-row,~ colortbl-like,~ columns-width,~ + corners,~ create-extra-nodes,~ create-medium-nodes,~ create-large-nodes,~ @@ -6363,7 +6388,6 @@ first-row,~ hlines,~ hvlines,~ - hvlines-except-corners,~ last-col,~ last-row,~ left-margin,~ @@ -6377,6 +6401,7 @@ rules~(with~the~subkeys~'color'~and~'width'),~ small,~ t,~ + tabularnote,~ vlines,~ xdots/color,~ xdots/shorten~and~ @@ -6404,6 +6429,7 @@ code-for-last-row,~ colortbl-like,~ columns-width,~ + corners,~ create-extra-nodes,~ create-medium-nodes,~ create-large-nodes,~ @@ -6414,7 +6440,6 @@ first-row,~ hlines,~ hvlines,~ - hvlines-except-corners,~ l,~ last-col,~ last-row,~ @@ -6455,6 +6480,7 @@ code-for-last-row,~ colortbl-like,~ columns-width,~ + corners,~ create-extra-nodes,~ create-medium-nodes,~ create-large-nodes,~ @@ -6464,7 +6490,6 @@ first-row,~ hlines,~ hvlines,~ - hvlines-except-corners,~ last-col,~ last-row,~ left-margin,~ @@ -6477,6 +6502,7 @@ right-margin,~ rules~(with~the~subkeys~'color'~and~'width'),~ t,~ + tabularnote,~ vlines,~ xdots/color,~ xdots/shorten~and~ -- cgit v1.2.3