diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | 150 |
1 files changed, 103 insertions, 47 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index 1cea989b188..f08f221f1d0 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.28} -\def\myfiledate{2024/05/29} +\def\myfileversion{6.28b} +\def\myfiledate{2024/06/29} \RequirePackage{pgfcore} \usepgfmodule{shapes} \RequirePackage{l3keys2e} @@ -30,9 +30,11 @@ {Enhanced arrays with the help of PGF/TikZ} \RequirePackage { amsmath } \RequirePackage { array } -\bool_const:Nn \c__nicematrix_tagging_array_bool { \cs_if_exist_p:N \ar@ialign } +\bool_const:Nn \c__nicematrix_tagging_array_bool + { \IfPackageAtLeastTF { array } { 2024/05/01 } \c_true_bool \c_false_bool } \bool_const:Nn \c__nicematrix_testphase_table_bool - { \IfPackageLoadedTF { latex-lab-testphase-table } \c_true_bool \c_false_bool } + { \IfPackageLoadedTF { latex-lab-testphase-table } \c_true_bool \c_false_bool + } \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 } } @@ -97,12 +99,22 @@ { \__nicematrix_error:n { Internal~error } } #1 } -\cs_new_protected:Npn \__nicematrix_security_test_i:w \ignorespaces #1 +\bool_if:NTF \c__nicematrix_tagging_array_bool { - \peek_meaning:NF \unskip { \__nicematrix_error:n { Internal~error } } - #1 + \cs_new_protected:Npn \__nicematrix_security_test_i:w \ignorespaces #1 + { + \peek_meaning:NF \textonly@unskip { \__nicematrix_error:n { Internal~error } } + #1 + } + } + { + \cs_new_protected:Npn \__nicematrix_security_test_i:w \ignorespaces #1 + { + \peek_meaning:NF \unskip { \__nicematrix_error:n { Internal~error } } + #1 + } } -\hook_gput_code:nnn { begindocument / after } { . } +\hook_gput_code:nnn { begindocument / end } { . } { \IfPackageLoadedTF { mdwtab } { \__nicematrix_fatal:n { mdwtab~loaded } } @@ -146,6 +158,7 @@ \tl_const:Nn \c__nicematrix_dot_tl { . } \tl_const:Nn \c__nicematrix_default_tl { default } \tl_const:Nn \c__nicematrix_star_tl { * } +\str_const:Nn \c__nicematrix_star_str { * } \str_const:Nn \c__nicematrix_r_str { r } \str_const:Nn \c__nicematrix_c_str { c } \str_const:Nn \c__nicematrix_l_str { l } @@ -473,7 +486,6 @@ \bool_new:N \l__nicematrix_p_block_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 \bool_new:N \l__nicematrix_vlines_block_bool \bool_new:N \l__nicematrix_hlines_block_bool @@ -531,6 +543,8 @@ \dim_const:Nn \c__nicematrix_innersep_middle_dim { 0.17 em } } \newcounter { tabularnote } +\int_new:N \g__nicematrix_tabularnote_int +\cs_set:Npn \theHtabularnote { \int_use:N \g__nicematrix_tabularnote_int } \seq_new:N \g__nicematrix_notes_seq \seq_new:N \g__nicematrix_notes_in_caption_seq \tl_new:N \g__nicematrix_tabularnote_tl @@ -646,6 +660,7 @@ } \int_gdecr:N \c@tabularnote \int_set_eq:NN \l_tmpa_int \c@tabularnote + \int_gincr:N \g__nicematrix_tabularnote_int \refstepcounter { tabularnote } \int_compare:nNnT \l_tmpa_int = \c@tabularnote { \int_gincr:N \c@tabularnote } @@ -852,6 +867,7 @@ { ampersand-in-blocks .bool_set:N = \l__nicematrix_amp_in_blocks_bool , ampersand-in-blocks .default:n = true , + &-in-blocks .meta:n = ampersand-in-blocks , no-cell-nodes .code:n = \cs_set_protected:Npn \__nicematrix_node_for_cell: { \box_use_drop:N \l__nicematrix_cell_box } , @@ -2478,7 +2494,8 @@ \str_new:N \c__nicematrix_ignorespaces_str \str_set:Nx \c__nicematrix_ignorespaces_str { \ignorespaces } \str_remove_all:Nn \c__nicematrix_ignorespaces_str { ~ } -\cs_new_protected:Npn \__nicematrix_test_if_empty: { \peek_after:Nw \__nicematrix_test_if_empty_i: } +\cs_new_protected:Npn \__nicematrix_test_if_empty: + { \peek_after:Nw \__nicematrix_test_if_empty_i: } \cs_new_protected:Npn \__nicematrix_test_if_empty_i: { \str_set:Nx \l_tmpa_str { \token_to_meaning:N \l_peek_token } @@ -2486,16 +2503,24 @@ { \__nicematrix_test_if_empty:w } } \cs_new_protected:Npn \__nicematrix_test_if_empty:w \ignorespaces + { \peek_after:Nw \__nicematrix_test_if_empty_ii: } +\cs_new_protected:Npn \__nicematrix_nullify_cell: { - \peek_meaning:NT \unskip + \tl_gput_right:Nn \g__nicematrix_cell_after_hook_tl { - \tl_gput_right:Nn \g__nicematrix_cell_after_hook_tl - { - \box_set_wd:Nn \l__nicematrix_cell_box \c_zero_dim - \skip_horizontal:N \l__nicematrix_col_width_dim - } + \box_set_wd:Nn \l__nicematrix_cell_box \c_zero_dim + \skip_horizontal:N \l__nicematrix_col_width_dim } } +\bool_if:NTF \c__nicematrix_tagging_array_bool + { + \cs_new_protected:Npn \__nicematrix_test_if_empty_ii: + { \peek_meaning:NT \textonly@unskip \__nicematrix_nullify_cell: } + } + { + \cs_new_protected:Npn \__nicematrix_test_if_empty_ii: + { \peek_meaning:NT \unskip \__nicematrix_nullify_cell: } + } \cs_new_protected:Npn \__nicematrix_test_if_empty_for_S: { \peek_meaning:NT \__siunitx_table_skip:n @@ -7082,6 +7107,9 @@ b .value_forbidden:n = true , B .code:n = \str_set:Nn \l__nicematrix_vpos_block_str B , B .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 , p .code:n = \bool_set_true:N \l__nicematrix_p_block_bool , p .value_forbidden:n = true , color .code:n = @@ -7119,12 +7147,12 @@ { \bool_lazy_or:nnTF { \tl_if_blank_p:n { #1 } } - { \str_if_eq_p:nn { #1 } { * } } + { \str_if_eq_p:Vn \c__nicematrix_star_str { #1 } } { \int_set:Nn \l_tmpa_int { 100 } } { \int_set:Nn \l_tmpa_int { #1 } } \bool_lazy_or:nnTF { \tl_if_blank_p:n { #2 } } - { \str_if_eq_p:nn { #2 } { * } } + { \str_if_eq_p:Vn \c__nicematrix_star_str { #2 } } { \int_set:Nn \l_tmpb_int { 100 } } { \int_set:Nn \l_tmpb_int { #2 } } \int_compare:nNnTF \l_tmpb_int = \c_one_int @@ -7145,26 +7173,18 @@ \bool_set_false:N \l_tmpa_bool \bool_if:NT \l__nicematrix_amp_in_blocks_bool { \tl_if_in:nnT { #5 } { & } { \bool_set_true:N \l_tmpa_bool } } - \bool_if:NTF \l_tmpa_bool - { \exp_args:Nee \__nicematrix_Block_vii:nnnnn } - { - \bool_if:NTF \l__nicematrix_p_block_bool - { \exp_args:Nee \__nicematrix_Block_vi:nnnnn } - { - \bool_if:nTF - { - ( - \int_compare_p:nNn \l_tmpa_int = \c_one_int - || - \int_compare_p:nNn \l_tmpb_int = \c_one_int - ) - && ! \tl_if_empty_p:n { #5 } - && ! \l__nicematrix_X_bool - } - { \exp_args:Nee \__nicematrix_Block_iv:nnnnn } - { \exp_args:Nee \__nicematrix_Block_v:nnnnn } - } - } + \bool_case:nF + { + \l_tmpa_bool { \exp_args:Nee \__nicematrix_Block_vii:nnnnn } + \l__nicematrix_p_block_bool { \exp_args:Nee \__nicematrix_Block_vi:nnnnn } + \l__nicematrix_X_bool { \exp_args:Nee \__nicematrix_Block_v:nnnnn } + { \tl_if_empty_p:n { #5 } } { \exp_args:Nee \__nicematrix_Block_v:nnnnn } + { \int_compare_p:nNn \l_tmpa_int = \c_one_int } + { \exp_args:Nee \__nicematrix_Block_iv:nnnnn } + { \int_compare_p:nNn \l_tmpb_int = \c_one_int } + { \exp_args:Nee \__nicematrix_Block_iv:nnnnn } + } + { \exp_args:Nee \__nicematrix_Block_v:nnnnn } { \l_tmpa_int } { \l_tmpb_int } { #3 } { #4 } { #5 } } \cs_new_protected:Npn \__nicematrix_Block_iv:nnnnn #1 #2 #3 #4 #5 @@ -7262,7 +7282,9 @@ } } } - \int_compare:nNnT { #1 } = \c_one_int + \bool_lazy_and:nnT + { \int_compare_p:nNn { #1 } = \c_one_int } + { \str_if_empty_p:N \l__nicematrix_vpos_block_str } { \dim_gset:Nn \g__nicematrix_blocks_ht_dim { @@ -7295,7 +7317,6 @@ { m } { \int_compare:nNnT \c@iRow = \l__nicematrix_last_row_int T } } - } { \box_use_drop:c @@ -7423,6 +7444,9 @@ } \keys_define:nn { NiceMatrix / Block / SecondPass } { + ampersand-in-blocks .bool_set:N = \l__nicematrix_amp_in_blocks_bool , + ampersand-in-blocks .default:n = true , + &-in-blocks .meta:n = ampersand-in-blocks , tikz .code:n = \IfPackageLoadedTF { tikz } { \seq_put_right:Nn \l__nicematrix_tikz_seq { { #1 } } } @@ -7525,9 +7549,18 @@ { \int_compare:nNnTF \l__nicematrix_last_row_int > \g__nicematrix_row_total_int { \msg_error:nnnn { nicematrix } { Block~too~large~1 } { #1 } { #2 } } - { \__nicematrix_Block_v:nnnnnn { #1 } { #2 } { #3 } { #4 } { #5 } { #6 } } + { + \__nicematrix_Block_v:nnVVnn + { #1 } + { #2 } + \l__nicematrix_last_row_int + \l__nicematrix_last_col_int + { #5 } + { #6 } + } } } +\cs_generate_variant:Nn \__nicematrix_Block_v:nnnnnn { n n V V n n } \cs_new_protected:Npn \__nicematrix_Block_v:nnnnnn #1 #2 #3 #4 #5 #6 { \group_begin: @@ -7843,6 +7876,7 @@ \pgf@relevantforpicturesizefalse \bool_lazy_any:nTF { + { \str_if_empty_p:N \l__nicematrix_vpos_block_str } % added 2024/06/29 { \str_if_eq_p:on \l__nicematrix_vpos_block_str { c } } { \str_if_eq_p:on \l__nicematrix_vpos_block_str { T } } { \str_if_eq_p:on \l__nicematrix_vpos_block_str { B } } @@ -7858,6 +7892,15 @@ { \str_case:on \l__nicematrix_vpos_block_str { + { } { % added 2024-06-29 + \str_case:on \l__nicematrix_hpos_block_str + { + c { center } + l { west } + r { east } + j { center } + } + } c { \str_case:on \l__nicematrix_hpos_block_str { @@ -8813,6 +8856,7 @@ { \nullfont \c_math_toggle_token + \colorlet { current-color } { . } \__nicematrix_color:o \l__nicematrix_delimiters_color_tl \left . \vcenter @@ -8824,7 +8868,7 @@ } \right #1 \tl_if_empty:nF { #3 } { _ { \smash { #3 } } } - ^ { \smash { #4 } } + ^ { \color { current-color } \smash { #4 } } \c_math_toggle_token } { #2 } @@ -8844,9 +8888,12 @@ { left-shorten .bool_set:N = \l__nicematrix_brace_left_shorten_bool , left-shorten .default:n = true , + left-shorten .value_forbidden:n = true , right-shorten .bool_set:N = \l__nicematrix_brace_right_shorten_bool , - shorten .meta:n = { left-shorten , right-shorten } , right-shorten .default:n = true , + right-shorten .value_forbidden:n = true , + shorten .meta:n = { left-shorten , right-shorten } , + shorten .value_forbidden:n = true , yshift .dim_set:N = \l__nicematrix_brace_yshift_dim , yshift .value_required:n = true , yshift .initial:n = \c_zero_dim , @@ -9416,7 +9463,7 @@ ~you~try~to~use~more~columns~than~allowed~by~your~ \__nicematrix_full_name_env:.\__nicematrix_message_hdotsfor:\ The~maximal~number~of~columns~is~ \int_use:N \g__nicematrix_static_num_of_col_int\ - ~(plus~the~potential~exterior~ones). + ~(plus~the~potential~exterior~ones).~ This~error~is~fatal. } \__nicematrix_msg_new:nn { columns~not~used } @@ -9964,9 +10011,10 @@ \c__nicematrix_available_keys_str } { - The~available~keys~are~(in~alphabetic~order):~b,~B,~borders,~c,~draw,~fill,~ - hlines,~hvlines,~l,~line-width,~name,~opacity,~rounded-corners,~r,~ - respect-arraystretch,~t,~T,~tikz,~transparent~and~vlines. + The~available~keys~are~(in~alphabetic~order):~&-in-blocks,~ampersand-in-blocks,~ + b,~B,~borders,~c,~draw,~fill,~hlines,~hvlines,~l,~line-width,~name,~ + opacity,~rounded-corners,~r,~respect-arraystretch,~t,~T,~tikz,~transparent~ + and~vlines. } \__nicematrix_msg_new:nnn { Unknown~key~for~Brace } { @@ -10078,7 +10126,9 @@ } { The~available~keys~are~(in~alphabetic~order):~ + &-in-blocks,~ allow-duplicate-names,~ + ampersand-in-blocks,~ caption-above,~ cell-space-bottom-limit,~ cell-space-limits,~ @@ -10131,6 +10181,8 @@ } { The~available~keys~are~(in~alphabetic~order):~ + &-in-blocks,~ + ampersand-in-blocks,~ b,~ baseline,~ c,~ @@ -10188,6 +10240,8 @@ } { The~available~keys~are~(in~alphabetic~order):~ + &-in-blocks,~ + ampersand-in-blocks,~ b,~ baseline,~ c,~ @@ -10248,6 +10302,8 @@ } { The~available~keys~are~(in~alphabetic~order):~ + &-in-blocks,~ + ampersand-in-blocks,~ b,~ baseline,~ c,~ |