From 25a4aae02e284152fc0a57c6c6ba87e3242dedbc Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 20 Oct 2020 20:40:24 +0000 Subject: nicematrix (20oct20) git-svn-id: svn://tug.org/texlive/trunk@56717 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/latex/nicematrix/nicematrix.sty | 191 +++++++++------------ 1 file changed, 78 insertions(+), 113 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 4801b011bbf..a0d9e5a3c4e 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.4} -\def\myfiledate{2020/10/06} +\def\myfileversion{5.5} +\def\myfiledate{2020/10/20} \RequirePackage{pgfcore} \usepgfmodule{shapes} @@ -32,18 +32,6 @@ \RequirePackage { array } \RequirePackage { amsmath } \RequirePackage { xparse } -\cs_set_eq:NN \box_use_drop_i:N \box_use_drop:N -\cs_set_eq:NN \box_use_drop_ii:N \box_use_drop:N -\cs_set_eq:NN \box_use_drop_iii:N \box_use_drop:N -\cs_set_eq:NN \box_use_drop_iv:N \box_use_drop:N -\cs_set_eq:NN \box_use_drop_v:N \box_use_drop:N -\cs_set_eq:NN \box_use_drop_vi:N \box_use_drop:N -\cs_set_eq:NN \box_use_drop_vii:N \box_use_drop:N -\cs_set_eq:NN \box_use_drop_viii:N \box_use_drop:N -\cs_set_eq:NN \box_use_drop_ix:N \box_use_drop:N -\cs_set_eq:NN \box_use_drop_x:N \box_use_drop:N -\cs_set_eq:NN \box_use_drop_xi:N \box_use_drop:N -\cs_set_eq:NN \box_use_drop_xii:N \box_use_drop:N \cs_new_protected:Npn \__nicematrix_error:n { \msg_error:nn { nicematrix } } \cs_new_protected:Npn \__nicematrix_error:nn { \msg_error:nnn { nicematrix } } \cs_new_protected:Npn \__nicematrix_error:nnn { \msg_error:nnnn { nicematrix } } @@ -783,6 +771,7 @@ } \cs_new_protected:Npn \__nicematrix_Cell: { + \cs_set_eq:NN \CodeAfter \__nicematrix_CodeAfter_i:n \int_gincr:N \c@jCol \int_compare:nNnT \c@jCol = 1 { \int_compare:nNnT \l__nicematrix_first_col_int = 1 \__nicematrix_begin_of_row: } @@ -882,11 +871,11 @@ { \dim_max:nn \g__nicematrix_max_cell_width_dim { \box_wd:N \l__nicematrix_cell_box } } \__nicematrix_update_for_first_and_last_row: \bool_if:NTF \g__nicematrix_empty_cell_bool - { \box_use_drop_i:N \l__nicematrix_cell_box } + { \box_use_drop:N \l__nicematrix_cell_box } { \dim_compare:nNnTF { \box_wd:N \l__nicematrix_cell_box } > \c_zero_dim \__nicematrix_node_for_the_cell: - { \box_use_drop_ii:N \l__nicematrix_cell_box } + { \box_use_drop:N \l__nicematrix_cell_box } } \bool_gset_false:N \g__nicematrix_empty_cell_bool } @@ -903,7 +892,7 @@ \pgfnode { rectangle } { base } - { \box_use_drop_iii:N \l__nicematrix_cell_box } + { \box_use_drop:N \l__nicematrix_cell_box } { \__nicematrix_env: - \int_use:N \c@iRow - \int_use:N \c@jCol } { } \str_if_empty:NF \l__nicematrix_name_str @@ -1081,7 +1070,7 @@ \cs_set_eq:NN \rotate \__nicematrix_rotate: \cs_set_eq:NN \OnlyMainNiceMatrix \__nicematrix_OnlyMainNiceMatrix:n \cs_set_eq:NN \dotfill \__nicematrix_old_dotfill: - \cs_set_eq:NN \CodeAfter \__nicematrix_CodeAfter:n + \cs_set_eq:NN \CodeAfter \__nicematrix_CodeAfter: \cs_set_eq:NN \diagbox \__nicematrix_diagbox:nn \bool_if:NT \l__nicematrix_colortbl_like_bool \__nicematrix_colortbl_like: \bool_if:NT \l__nicematrix_renew_dots_bool \__nicematrix_renew_dots: @@ -1308,20 +1297,7 @@ \int_compare:nNnT \l__nicematrix_first_col_int = 0 { \skip_horizontal:N \col@sep - \dim_if_exist:cTF { g__nicematrix_ block _ width _col _ 0 _ dim } - { - \skip_horizontal:n - { - \dim_max:nn - { - \dim_use:c { g__nicematrix_ block _ width _col _ 0 _ dim } - - 2 \col@sep - } - \g__nicematrix_width_first_col_dim - } - \dim_gzero:c { g__nicematrix_ block _ width _col _ 0 _ dim } - } - { \skip_horizontal:N \g__nicematrix_width_first_col_dim } + \skip_horizontal:N \g__nicematrix_width_first_col_dim } \bool_if:NTF \l__nicematrix_NiceArray_bool { @@ -1375,27 +1351,8 @@ } \bool_if:NT \g__nicematrix_last_col_found_bool { - \dim_if_exist:cTF - { g__nicematrix_ block _ width _col _ \int_use:N \g__nicematrix_col_total_int _ dim } - { - \skip_horizontal:n - { - \dim_max:nn - { - \dim_use:c - { - g__nicematrix_ block _ width _col _ - \int_use:N \g__nicematrix_col_total_int - _ dim - } - } - { \g__nicematrix_width_first_col_dim + \col@sep } - } - } - { - \skip_horizontal:N \g__nicematrix_width_last_col_dim - \skip_horizontal:N \col@sep - } + \skip_horizontal:N \g__nicematrix_width_last_col_dim + \skip_horizontal:N \col@sep } \__nicematrix_after_array: \egroup @@ -1565,7 +1522,7 @@ \hbox_set_end: \bool_if:NT \g__nicematrix_rotate_bool \__nicematrix_rotate_cell_box: \__nicematrix_adjust_width_box: - \makebox [ #4 ] [ #3 ] { \box_use_drop_iv:N \l__nicematrix_cell_box } + \makebox [ #4 ] [ #3 ] { \box_use_drop:N \l__nicematrix_cell_box } } } \int_gincr:N \c@jCol @@ -1608,7 +1565,7 @@ \box_set_ht:Nn \l_tmpa_box { \box_ht:N \l_tmpa_box + \l_tmpa_dim } \box_set_dp:Nn \l_tmpa_box { \box_dp:N \l_tmpa_box + \l_tmpb_dim } \str_if_eq:VnTF \l__nicematrix_baseline_str { c } - { \box_use_drop_v:N \l_tmpa_box } + { \box_use_drop:N \l_tmpa_box } \__nicematrix_put_box_in_flow_i: } \cs_new_protected:Npn \__nicematrix_put_box_in_flow_i: @@ -1649,53 +1606,56 @@ } \dim_gsub:Nn \g_tmpa_dim \pgf@y \endpgfpicture - \box_move_up:nn \g_tmpa_dim { \box_use_drop_vi:N \l_tmpa_box } - \box_use_drop_vii:N \l_tmpa_box + \box_move_up:nn \g_tmpa_dim { \box_use_drop:N \l_tmpa_box } + \box_use_drop:N \l_tmpa_box } \cs_new_protected:Npn \__nicematrix_use_arraybox_with_notes_c: { - \bool_lazy_and:nnTF - { \int_compare_p:nNn \c@tabularnote = 0 } - { \tl_if_empty_p:V \l__nicematrix_tabularnote_tl } - { \box_use_drop_viii:N \l__nicematrix_the_array_box } + \begin { minipage } [ t ] { \box_wd:N \l__nicematrix_the_array_box } + \box_use_drop:N \l__nicematrix_the_array_box + \__nicematrix_create_extra_nodes: + \seq_if_empty:NF \g__nicematrix_blocks_seq \__nicematrix_draw_blocks: + \bool_lazy_or:nnT + { \int_compare_p:nNn \c@tabularnote > 0 } + { ! \tl_if_empty_p:V \l__nicematrix_tabularnote_tl } + \__nicematrix_insert_tabularnotes: + \end { minipage } + } +\cs_new_protected:Npn \__nicematrix_insert_tabularnotes: + { + \skip_vertical:N 0.65ex + \group_begin: + \l__nicematrix_notes_code_before_tl + \tl_if_empty:NF \l__nicematrix_tabularnote_tl { \l__nicematrix_tabularnote_tl \par } + \int_compare:nNnT \c@tabularnote > 0 { - \begin { minipage } { \box_wd:N \l__nicematrix_the_array_box } - \box_use_drop_ix:N \l__nicematrix_the_array_box - \skip_vertical:N 0.65ex - \group_begin: - \l__nicematrix_notes_code_before_tl - \tl_if_empty:NF \l__nicematrix_tabularnote_tl { \l__nicematrix_tabularnote_tl \par } - \int_compare:nNnF \c@tabularnote = 0 + \bool_if:NTF \l__nicematrix_notes_para_bool { - \bool_if:NTF \l__nicematrix_notes_para_bool - { - \begin { tabularnotes* } - \seq_map_inline:Nn \g__nicematrix_tabularnotes_seq { \item ##1 } \strut - \end { tabularnotes* } - \par - } - { - \tabularnotes - \seq_map_inline:Nn \g__nicematrix_tabularnotes_seq { \item ##1 } \strut - \endtabularnotes - } + \begin { tabularnotes* } + \seq_map_inline:Nn \g__nicematrix_tabularnotes_seq { \item ##1 } \strut + \end { tabularnotes* } + \par } - \unskip - \group_end: - \bool_if:NT \l__nicematrix_notes_bottomrule_bool { - \bool_if:NTF \c__nicematrix_booktabs_loaded_bool - { - \skip_vertical:N \aboverulesep - { \CT@arc@ \hrule height \heavyrulewidth } - } - { \__nicematrix_error:n { bottomule~without~booktabs } } + \tabularnotes + \seq_map_inline:Nn \g__nicematrix_tabularnotes_seq { \item ##1 } \strut + \endtabularnotes } - \l__nicematrix_notes_code_after_tl - \end { minipage } - \seq_gclear:N \g__nicematrix_tabularnotes_seq - \int_gzero:N \c@tabularnote } + \unskip + \group_end: + \bool_if:NT \l__nicematrix_notes_bottomrule_bool + { + \bool_if:NTF \c__nicematrix_booktabs_loaded_bool + { + \skip_vertical:N \aboverulesep + { \CT@arc@ \hrule height \heavyrulewidth } + } + { \__nicematrix_error:n { bottomule~without~booktabs } } + } + \l__nicematrix_notes_code_after_tl + \seq_gclear:N \g__nicematrix_tabularnotes_seq + \int_gzero:N \c@tabularnote } \cs_new_protected:Npn \__nicematrix_use_arraybox_with_notes_b: { @@ -1711,7 +1671,7 @@ \dim_gadd:Nn \g_tmpa_dim \g__nicematrix_ht_row_zero_dim \dim_gadd:Nn \g_tmpa_dim \g__nicematrix_dp_row_zero_dim } - \box_move_up:nn \g_tmpa_dim { \__nicematrix_use_arraybox_with_notes_c: } + \box_move_up:nn \g_tmpa_dim { \hbox { \__nicematrix_use_arraybox_with_notes_c: } } } \cs_new_protected:Npn \__nicematrix_use_arraybox_with_notes: { @@ -1750,7 +1710,7 @@ \dim_gadd:Nn \g_tmpa_dim \g__nicematrix_ht_row_zero_dim \dim_gadd:Nn \g_tmpa_dim \g__nicematrix_dp_row_zero_dim } - \box_move_up:nn \g_tmpa_dim { \__nicematrix_use_arraybox_with_notes_c: } + \box_move_up:nn \g_tmpa_dim { \hbox { \__nicematrix_use_arraybox_with_notes_c: } } } \cs_new_protected:Npn \__nicematrix_put_box_in_flow_bis:nn #1 #2 { @@ -2023,7 +1983,7 @@ { \dim_compare:nNnTF { \box_wd:N \l__nicematrix_cell_box } > \c_zero_dim \__nicematrix_node_for_the_cell: - { \box_use_drop_x:N \l__nicematrix_cell_box } + { \box_use_drop:N \l__nicematrix_cell_box } \skip_horizontal:N \l__nicematrix_left_delim_dim \skip_horizontal:N \l__nicematrix_left_margin_dim \skip_horizontal:N \l__nicematrix_extra_left_margin_dim @@ -2223,13 +2183,6 @@ \dim_gzero_new:N \g__nicematrix_delta_x_two_dim \dim_gzero_new:N \g__nicematrix_delta_y_two_dim } - \bool_if:nTF \l__nicematrix_medium_nodes_bool - { - \bool_if:NTF \l__nicematrix_large_nodes_bool - \__nicematrix_create_medium_and_large_nodes: - \__nicematrix_create_medium_nodes: - } - { \bool_if:NT \l__nicematrix_large_nodes_bool \__nicematrix_create_large_nodes: } \int_zero_new:N \l__nicematrix_initial_i_int \int_zero_new:N \l__nicematrix_initial_j_int \int_zero_new:N \l__nicematrix_final_i_int @@ -2256,8 +2209,6 @@ } \bool_if:NT \l__nicematrix_hlines_bool \__nicematrix_draw_hlines: \bool_if:NT \l__nicematrix_vlines_bool \__nicematrix_draw_vlines: - \cs_set_eq:NN \ialign \__nicematrix_old_ialign: - \seq_if_empty:NF \g__nicematrix_blocks_seq \__nicematrix_draw_blocks: \g__nicematrix_internal_code_after_tl \tl_gclear:N \g__nicematrix_internal_code_after_tl \bool_if:NT \c__nicematrix_tikz_loaded_bool @@ -4108,6 +4059,16 @@ } \cs_generate_variant:Nn \dim_min:nn { v n } \cs_generate_variant:Nn \dim_max:nn { v n } +\cs_new_protected:Npn \__nicematrix_create_extra_nodes: + { + \bool_if:nTF \l__nicematrix_medium_nodes_bool + { + \bool_if:NTF \l__nicematrix_large_nodes_bool + \__nicematrix_create_medium_and_large_nodes: + \__nicematrix_create_medium_nodes: + } + { \bool_if:NT \l__nicematrix_large_nodes_bool \__nicematrix_create_large_nodes: } + } \cs_new_protected:Npn \__nicematrix_computations_for_medium_nodes: { \int_step_variable:nnNn \l__nicematrix_first_row_int \g__nicematrix_row_total_int \__nicematrix_i: @@ -4336,7 +4297,7 @@ \hbox_gset:cn { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box } { - \color_ensure_current: + \set@color \bool_if:NTF \l__nicematrix_NiceTabular_bool { \group_begin: @@ -4448,7 +4409,10 @@ unknown .code:n = \__nicematrix_error:n { Unknown~key~for~Block } } \cs_new_protected:Npn \__nicematrix_draw_blocks: - { \seq_map_inline:Nn \g__nicematrix_blocks_seq { \__nicematrix_Block_iii:nnnnnn ##1 } } + { + \cs_set_eq:NN \ialign \__nicematrix_old_ialign: + \seq_map_inline:Nn \g__nicematrix_blocks_seq { \__nicematrix_Block_iii:nnnnnn ##1 } + } \cs_new_protected:Npn \__nicematrix_Block_iii:nnnnnn #1 #2 #3 #4 #5 #6 { \group_begin: @@ -4573,7 +4537,7 @@ r { base~east } } } - { \box_use_drop_xi:N \l__nicematrix_cell_box } { } { } + { \box_use_drop:N \l__nicematrix_cell_box } { } { } } { \int_compare:nNnT \c@jCol = 0 @@ -4604,7 +4568,7 @@ r { east } } } - { \box_use_drop_xii:N \l__nicematrix_cell_box } { } { } + { \box_use_drop:N \l__nicematrix_cell_box } { } { } } \endpgfpicture } @@ -4743,18 +4707,19 @@ { \__nicematrix_math_toggle_token: #6 \__nicematrix_math_toggle_token: } { } { } \endpgfpicture } -\cs_new_protected:Npn \__nicematrix_CodeAfter:n #1 \end +\cs_new:Npn \__nicematrix_CodeAfter: { \omit \__nicematrix_CodeAfter_i:n } +\cs_new_protected:Npn \__nicematrix_CodeAfter_i:n #1 \end { \tl_gput_right:Nn \g_nicematrix_code_after_tl { #1 } - \__nicematrix_CodeAfter_i:n + \__nicematrix_CodeAfter_ii:n } -\cs_new_protected:Npn \__nicematrix_CodeAfter_i:n #1 +\cs_new_protected:Npn \__nicematrix_CodeAfter_ii:n #1 { \str_if_eq:eeTF \@currenvir { #1 } { \end { #1 } } { \tl_gput_right:Nn \g_nicematrix_code_after_tl { \end { #1 } } - \__nicematrix_CodeAfter:n + \__nicematrix_CodeAfter_i:n } } %% \medskip -- cgit v1.2.3