diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | 801 |
1 files changed, 535 insertions, 266 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index 8b11c3adce1..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.27b} -\def\myfiledate{2024/04/23} +\def\myfileversion{6.28b} +\def\myfiledate{2024/06/29} \RequirePackage{pgfcore} \usepgfmodule{shapes} \RequirePackage{l3keys2e} @@ -30,7 +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 + } \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 } } @@ -95,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 } } @@ -144,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 } @@ -153,8 +168,8 @@ \str_const:Nn \c__nicematrix_j_str { j } \str_const:Nn \c__nicematrix_si_str { si } \tl_new:N \l__nicematrix_argspec_tl -\cs_generate_variant:Nn \seq_set_split:Nnn { N V n } -\cs_generate_variant:Nn \str_lowercase:n { V } +\cs_generate_variant:Nn \seq_set_split:Nnn { N o n } +\cs_generate_variant:Nn \str_lowercase:n { o } \hook_gput_code:nnn { begindocument } { . } { \IfPackageLoadedTF { tikz } @@ -224,19 +239,19 @@ { } { \cs_set_protected:Npn \CT@arc@ { } - \cs_set:Npn \arrayrulecolor #1 # { \CT@arc { #1 } } - \cs_set:Npn \CT@arc #1 #2 + \cs_set_nopar:Npn \arrayrulecolor #1 # { \CT@arc { #1 } } + \cs_set_nopar:Npn \CT@arc #1 #2 { \dim_compare:nNnT \baselineskip = \c_zero_dim \noalign { \cs_gset_nopar:Npn \CT@arc@ { \color #1 { #2 } } } } - \cs_set:Npn \doublerulesepcolor #1 # { \CT@drs { #1 } } - \cs_set:Npn \CT@drs #1 #2 + \cs_set_nopar:Npn \doublerulesepcolor #1 # { \CT@drs { #1 } } + \cs_set_nopar:Npn \CT@drs #1 #2 { \dim_compare:nNnT \baselineskip = \c_zero_dim \noalign { \cs_gset:Npn \CT@drsc@ { \color #1 { #2 } } } } - \cs_set:Npn \hline + \cs_set_nopar:Npn \hline { \noalign { \ifnum 0 = `} \fi \cs_set_eq:NN \hskip \vskip @@ -248,8 +263,8 @@ } } } -\cs_set:Npn \__nicematrix_standard_cline #1 { \__nicematrix_standard_cline:w #1 \q_stop } -\cs_set:Npn \__nicematrix_standard_cline:w #1-#2 \q_stop +\cs_set_nopar:Npn \__nicematrix_standard_cline #1 { \__nicematrix_standard_cline:w #1 \q_stop } +\cs_set_nopar:Npn \__nicematrix_standard_cline:w #1-#2 \q_stop { \int_if_zero:nT \l__nicematrix_first_col_int { \omit & } \int_compare:nNnT { #1 } > \c_one_int @@ -296,16 +311,16 @@ \tl_if_blank:nF { #1 } { \tl_if_head_eq_meaning:nNTF { #1 } [ - { \cs_set:Npn \CT@arc@ { \color #1 } } - { \cs_set:Npn \CT@arc@ { \color { #1 } } } + { \cs_set_nopar:Npn \CT@arc@ { \color #1 } } + { \cs_set_nopar:Npn \CT@arc@ { \color { #1 } } } } } \cs_generate_variant:Nn \__nicematrix_set_CT@arc@:n { o } \cs_new_protected:Npn \__nicematrix_set_CT@drsc@:n #1 { \tl_if_head_eq_meaning:nNTF { #1 } [ - { \cs_set:Npn \CT@drsc@ { \color #1 } } - { \cs_set:Npn \CT@drsc@ { \color { #1 } } } + { \cs_set_nopar:Npn \CT@drsc@ { \color #1 } } + { \cs_set_nopar:Npn \CT@drsc@ { \color { #1 } } } } \cs_generate_variant:Nn \__nicematrix_set_CT@drsc@:n { o } \cs_new:Npn \__nicematrix_exp_color_arg:Nn #1 #2 @@ -318,7 +333,6 @@ \cs_new_protected:Npn \__nicematrix_color:n #1 { \tl_if_blank:nF { #1 } { \__nicematrix_exp_color_arg:Nn \color { #1 } } } \cs_generate_variant:Nn \__nicematrix_color:n { o } -\cs_set_eq:NN \__nicematrix_old_pgfpointanchor \pgfpointanchor \cs_new_protected:Npn \__nicematrix_rescan_for_spanish:N #1 { \tl_set_rescan:Nno @@ -396,7 +410,7 @@ \bool_new:N \l__nicematrix_bold_row_style_bool \cs_new:Npn \__nicematrix_full_name_env: { - \str_if_eq:VnTF \g__nicematrix_com_or_env_str { command } + \str_if_eq:onTF \g__nicematrix_com_or_env_str { command } { command \space \c_backslash_str \g__nicematrix_name_env_str } { environment \space \{ \g__nicematrix_name_env_str \} } } @@ -407,6 +421,7 @@ \tl_new:N \g__nicematrix_pre_code_after_tl \tl_new:N \g_nicematrix_code_after_tl \bool_new:N \l__nicematrix_in_code_after_bool +\bool_new:N \l__nicematrix_ampersand_bool \int_new:N \l__nicematrix_old_iRow_int \int_new:N \l__nicematrix_old_jCol_int \seq_new:N \l__nicematrix_custom_line_commands_seq @@ -424,8 +439,14 @@ \dim_new:N \l__nicematrix_y_initial_dim \dim_new:N \l__nicematrix_x_final_dim \dim_new:N \l__nicematrix_y_final_dim -\dim_zero_new:N \l__nicematrix_tmpc_dim -\dim_zero_new:N \l__nicematrix_tmpd_dim +\dim_new:N \l__nicematrix_tmpc_dim +\dim_new:N \l__nicematrix_tmpd_dim +\dim_new:N \g__nicematrix_dp_row_zero_dim +\dim_new:N \g__nicematrix_ht_row_zero_dim +\dim_new:N \g__nicematrix_ht_row_one_dim +\dim_new:N \g__nicematrix_dp_ante_last_row_dim +\dim_new:N \g__nicematrix_ht_last_row_dim +\dim_new:N \g__nicematrix_dp_last_row_dim \bool_new:N \g__nicematrix_empty_cell_bool \dim_new:N \g__nicematrix_width_last_col_dim \dim_new:N \g__nicematrix_width_first_col_dim @@ -462,9 +483,9 @@ \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 \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 @@ -522,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 @@ -637,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 } @@ -761,6 +785,7 @@ \bool_new:N \l__nicematrix_light_syntax_expanded_bool \tl_new:N \l__nicematrix_baseline_tl \tl_set:Nn \l__nicematrix_baseline_tl { c } +\bool_new:N \l__nicematrix_amp_in_blocks_bool \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 @@ -840,6 +865,9 @@ } \keys_define:nn { NiceMatrix / Global } { + 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 } , @@ -1442,7 +1470,7 @@ { \cs_set_nopar:Npn \@halignto { } } { \cs_set_nopar:Npx \@halignto { to \dim_use:N \l__nicematrix_tabular_width_dim } } \@tabarray - [ \str_if_eq:VnTF \l__nicematrix_baseline_tl c c t ] + [ \str_if_eq:onTF \l__nicematrix_baseline_tl c c t ] } \bool_if:NTF \c__nicematrix_tagging_array_bool { \cs_set_eq:NN \__nicematrix_old_ar@ialign: \ar@ialign } @@ -1485,7 +1513,7 @@ \cs_new:Npn \__nicematrix_everycr: { \noalign { \__nicematrix_everycr_i: } } \cs_new_protected:Npn \__nicematrix_everycr_i: { - \bool_if:NT \c__nicematrix_tagging_array_bool + \bool_if:NT \c__nicematrix_testphase_table_bool { \tbl_if_row_was_started:T { \UseTaggingSocket { tbl / row / end } } \tbl_update_cell_data_for_next_row: @@ -1533,21 +1561,21 @@ } } \cs_new_protected:Npn \__nicematrix_redefine_everycr: { \everycr { \__nicematrix_everycr: } } -\hook_gput_code:nnn { begindocument } { . } - { - \IfPackageLoadedTF { colortbl } - { - \cs_set_protected:Npn \__nicematrix_redefine_everycr: - { - \CT@everycr - { - \noalign { \cs_gset_eq:NN \CT@row@color \prg_do_nothing: } - \__nicematrix_everycr: - } - } - } - { } - } + \hook_gput_code:nnn { begindocument } { . } + { + \IfPackageLoadedTF { colortbl } + { + \cs_set_protected:Npn \__nicematrix_redefine_everycr: + { + \CT@everycr + { + \noalign { \cs_gset_eq:NN \CT@row@color \prg_do_nothing: } + \__nicematrix_everycr: + } + } + } + { } + } \hook_gput_code:nnn { begindocument } { . } { \IfPackageLoadedTF { booktabs } @@ -1559,16 +1587,11 @@ } \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_eq:NN \g__nicematrix_ht_row_one_dim \g__nicematrix_ht_row_zero_dim + \dim_gzero:N \g__nicematrix_dp_ante_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: @@ -1597,9 +1620,9 @@ { \cs_set_nopar:Npn \ar@ialign { - \tbl_init_cell_data_for_table: + \bool_if:NT \c__nicematrix_testphase_table_bool \tbl_init_cell_data_for_table: \__nicematrix_redefine_everycr: - \tabskip = \c_zero_skip + \dim_zero:N \tabskip \__nicematrix_some_initialization: \cs_set_eq:NN \ar@ialign \__nicematrix_old_ar@ialign: \halign @@ -1609,7 +1632,7 @@ \cs_set_nopar:Npn \ialign { \__nicematrix_redefine_everycr: - \tabskip = \c_zero_skip + \dim_zero:N \tabskip \__nicematrix_some_initialization: \cs_set_eq:NN \ialign \__nicematrix_old_ialign: \halign @@ -1731,6 +1754,8 @@ \dim_gset_eq:NN \l__nicematrix_right_delim_dim \l__nicematrix_left_delim_dim } \hbox_set:Nw \l__nicematrix_the_array_box + \bool_if:NT \c__nicematrix_testphase_table_bool + { \UseTaggingSocket { tbl / hmode / begin } } \skip_horizontal:N \l__nicematrix_left_margin_dim \skip_horizontal:N \l__nicematrix_extra_left_margin_dim \c_math_toggle_token @@ -1931,6 +1956,7 @@ \tl_gset:Nn \g__nicematrix_left_delim_tl { #1 } \tl_gset:Nn \g__nicematrix_right_delim_tl { #2 } \tl_gset:Nn \g__nicematrix_user_preamble_tl { #4 } + \tl_if_empty:NT \g__nicematrix_user_preamble_tl { \__nicematrix_fatal:n { empty~preamble } } \int_gzero:N \g__nicematrix_block_box_int \dim_zero:N \g__nicematrix_width_last_col_dim \dim_zero:N \g__nicematrix_width_first_col_dim @@ -1977,7 +2003,7 @@ { \keys_set:nn { NiceMatrix / NiceArray } } { #3 , #5 } \__nicematrix_set_CT@arc@:o \l__nicematrix_rules_color_tl - \IfBooleanTF { #6 } \__nicematrix_CodeBefore_Body:w \__nicematrix_pre_array: + \bool_if:nTF { #6 } \__nicematrix_CodeBefore_Body:w \__nicematrix_pre_array: } { \bool_if:NTF \l__nicematrix_light_syntax_bool @@ -1986,6 +2012,18 @@ \c_math_toggle_token \skip_horizontal:N \l__nicematrix_right_margin_dim \skip_horizontal:N \l__nicematrix_extra_right_margin_dim + + % % awful workaround + \int_compare:nNnT \g__nicematrix_col_total_int = \c_one_int + { + \dim_compare:nNnT \l__nicematrix_columns_width_dim > \c_zero_dim + { + \skip_horizontal:N - \l__nicematrix_columns_width_dim + \bool_if:NTF \l__nicematrix_tabular_bool + { \skip_horizontal:n { - 2 \tabcolsep } } + { \skip_horizontal:n { - 2 \arraycolsep } } + } + } \hbox_set_end: \bool_if:NT \l__nicematrix_width_used_bool { @@ -2387,7 +2425,7 @@ { \tl_clear:N \exp_not:N \l__nicematrix_hpos_cell_tl } { \cs_set_nopar:Npn \exp_not:N \l__nicematrix_hpos_cell_tl - { \str_lowercase:V \l__nicematrix_hpos_col_str } + { \str_lowercase:o \l__nicematrix_hpos_col_str } } \str_case:on \l__nicematrix_hpos_col_str { @@ -2410,7 +2448,7 @@ { j } { c } { si } { c } } - { \str_lowercase:V \l__nicematrix_hpos_col_str } + { \str_lowercase:o \l__nicematrix_hpos_col_str } } } \int_gincr:N \c@jCol @@ -2427,6 +2465,8 @@ { > { \dim_set:Nn \l__nicematrix_col_width_dim { #2 } + \bool_if:NT \c__nicematrix_testphase_table_bool + { \tag_struct_begin:n { tag = Div } } \__nicematrix_cell_begin:w \use:c { #7 } [ #1 ] { #2 } \everypar @@ -2434,6 +2474,7 @@ \vrule height \box_ht:N \@arstrutbox width \c_zero_dim \everypar { } } + \bool_if:NT \c__nicematrix_testphase_table_bool \tagpdfparaOn #3 \g__nicematrix_row_style_tl \arraybackslash @@ -2446,13 +2487,15 @@ \use:c { end #7 } #4 \__nicematrix_cell_end: + \bool_if:NT \c__nicematrix_testphase_table_bool \tag_struct_end: } } } \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 } @@ -2460,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 @@ -2826,13 +2877,17 @@ \multispan { #1 } \cs_set_eq:NN \__nicematrix_update_max_cell_width: \prg_do_nothing: \begingroup - \cs_set:Npn \@addamp + \bool_if:NT \c__nicematrix_testphase_table_bool + { \tbl_update_multicolumn_cell_data:n { #1 } } + \cs_set_nopar:Npn \@addamp { \legacy_if:nTF { @firstamp } { \@firstampfalse } { \@preamerr 5 } } \tl_gclear:N \g__nicematrix_preamble_tl \__nicematrix_make_m_preamble:n #2 \q_stop \exp_args:No \@mkpream \g__nicematrix_preamble_tl \@addtopreamble \@empty \endgroup + \bool_if:NT \c__nicematrix_testphase_table_bool + { \UseTaggingSocket { tbl / colspan } { #1 } } \int_compare:nNnT { #1 } > \c_one_int { \seq_gput_left:Nx \g__nicematrix_multicolumn_cells_seq @@ -2855,7 +2910,7 @@ { } % for the name of the block } } - \cs_set:Npn \@sharp { #3 } + \cs_set_nopar:Npn \@sharp { #3 } \@arstrut \@preamble \null @@ -3282,7 +3337,7 @@ \tl_set_rescan:Nno \l__nicematrix_end_of_row_tl { } \l__nicematrix_end_of_row_tl \bool_if:NTF \l__nicematrix_light_syntax_expanded_bool \seq_set_split:Nee - \seq_set_split:NVn + \seq_set_split:Non \l__nicematrix_rows_seq \l__nicematrix_end_of_row_tl { #1 } \seq_pop_right:NN \l__nicematrix_rows_seq \l_tmpa_tl \tl_if_empty:NF \l_tmpa_tl @@ -3457,7 +3512,7 @@ { \skip_gset:Nn \g_tmpa_skip { 0 pt~plus 1 fill } } \skip_horizontal:N \g_tmpa_skip \int_gincr:N \g_tmpa_int - \bool_lazy_any:nF % modified 2023/12/13 + \bool_lazy_any:nF { \g__nicematrix_delims_bool \l__nicematrix_tabular_bool @@ -3527,7 +3582,7 @@ \endpgfpicture } } - \cr + % \cr } \tl_const:Nn \c__nicematrix_preamble_first_col_tl { @@ -3735,7 +3790,11 @@ \__nicematrix_settings_for_tabular: \NiceArray { #2 } } - { \endNiceArray } + { + \endNiceArray + \bool_if:NT \c__nicematrix_testphase_table_bool + { \UseTaggingSocket { tbl / hmode / end } } + } \cs_new_protected:Npn \__nicematrix_settings_for_tabular: { \bool_set_true:N \l__nicematrix_tabular_bool @@ -4003,6 +4062,14 @@ } \anchor { 5 } { \five } \anchor { center } { \pgfpointorigin } + \anchor { 1 } { \five \pgf@x = 0.2 \pgf@x \pgf@y = 0.2 \pgf@y } + \anchor { 2 } { \five \pgf@x = 0.4 \pgf@x \pgf@y = 0.4 \pgf@y } + \anchor { 3 } { \five \pgf@x = 0.6 \pgf@x \pgf@y = 0.6 \pgf@y } + \anchor { 4 } { \five \pgf@x = 0.8 \pgf@x \pgf@y = 0.8 \pgf@y } + \anchor { 6 } { \five \pgf@x = 1.2 \pgf@x \pgf@y = 1.2 \pgf@y } + \anchor { 7 } { \five \pgf@x = 1.4 \pgf@x \pgf@y = 1.4 \pgf@y } + \anchor { 8 } { \five \pgf@x = 1.6 \pgf@x \pgf@y = 1.6 \pgf@y } + \anchor { 9 } { \five \pgf@x = 1.8 \pgf@x \pgf@y = 1.8 \pgf@y } } \cs_new_protected:Npn \__nicematrix_create_diag_nodes: { @@ -7017,6 +7084,9 @@ } \keys_define:nn { NiceMatrix / Block / FirstPass } { + j .code:n = \str_set:Nn \l__nicematrix_hpos_block_str j + \bool_set_true:N \l__nicematrix_p_block_bool , + j .value_forbidden:n = true , l .code:n = \str_set:Nn \l__nicematrix_hpos_block_str l , l .value_forbidden:n = true , r .code:n = \str_set:Nn \l__nicematrix_hpos_block_str r , @@ -7037,6 +7107,11 @@ 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 = \__nicematrix_color:n { #1 } \tl_set_rescan:Nnn @@ -7072,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 @@ -7095,18 +7170,21 @@ { \int_eval:n { \c@iRow + \l_tmpa_int - 1 } } { \int_eval:n { \c@jCol + \l_tmpb_int - 1 } } } - \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_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_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 @@ -7159,7 +7237,7 @@ \use:e { \exp_not:N \begin { minipage }% - [ \str_lowercase:V \l__nicematrix_vpos_block_str ] + [ \str_lowercase:o \l__nicematrix_vpos_block_str ] { \l__nicematrix_col_width_dim } \str_case:on \l__nicematrix_hpos_block_str { c \centering r \raggedleft l \raggedright } @@ -7171,7 +7249,7 @@ \use:e { \exp_not:N \begin { tabular }% - [ \str_lowercase:V \l__nicematrix_vpos_block_str ] + [ \str_lowercase:o \l__nicematrix_vpos_block_str ] { @ { } \l__nicematrix_hpos_block_str @ { } } } #5 @@ -7183,7 +7261,7 @@ \use:e { \exp_not:N \begin { array }% - [ \str_lowercase:V \l__nicematrix_vpos_block_str ] + [ \str_lowercase:o \l__nicematrix_vpos_block_str ] { @ { } \l__nicematrix_hpos_block_str @ { } } } #5 @@ -7204,27 +7282,26 @@ } } } - \str_if_eq:VnT \l__nicematrix_vpos_block_str { c } + \bool_lazy_and:nnT + { \int_compare_p:nNn { #1 } = \c_one_int } + { \str_if_empty_p:N \l__nicematrix_vpos_block_str } { - \int_compare:nNnT { #1 } = \c_one_int + \dim_gset:Nn \g__nicematrix_blocks_ht_dim { - \dim_gset:Nn \g__nicematrix_blocks_ht_dim + \dim_max:nn + \g__nicematrix_blocks_ht_dim { - \dim_max:nn - \g__nicematrix_blocks_ht_dim - { - \box_ht:c - { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box } - } + \box_ht:c + { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box } } - \dim_gset:Nn \g__nicematrix_blocks_dp_dim + } + \dim_gset:Nn \g__nicematrix_blocks_dp_dim + { + \dim_max:nn + \g__nicematrix_blocks_dp_dim { - \dim_max:nn - \g__nicematrix_blocks_dp_dim - { - \box_dp:c - { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box } - } + \box_dp:c + { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box } } } } @@ -7240,7 +7317,6 @@ { m } { \int_compare:nNnT \c@iRow = \l__nicematrix_last_row_int T } } - } { \box_use_drop:c @@ -7310,13 +7386,15 @@ { \dim_zero:N \extrarowheight #4 - \use:e - { - \exp_not:N \begin { tabular } [ \l__nicematrix_vpos_block_str ] - { @ { } \l__nicematrix_hpos_block_str @ { } } - } - #5 - \end { tabular } + \bool_if:NT \c__nicematrix_testphase_table_bool + { \tag_stop:n { table } } + \use:e + { + \exp_not:N \begin { tabular } [ \l__nicematrix_vpos_block_str ] + { @ { } \l__nicematrix_hpos_block_str @ { } } + } + #5 + \end { tabular } } \group_end: } @@ -7342,8 +7420,33 @@ } } } +\cs_new_protected:Npn \__nicematrix_Block_vi:nnnnn #1 #2 #3 #4 #5 + { + \seq_gput_right:Nx \g__nicematrix_blocks_seq + { + \l_tmpa_tl + { \exp_not:n { #3 } } + { + \group_begin: + \exp_not:n { #4 #5 } + \group_end: + } + } + } +\cs_new_protected:Npn \__nicematrix_Block_vii:nnnnn #1 #2 #3 #4 #5 + { + \seq_gput_right:Nx \g__nicematrix_blocks_seq + { + \l_tmpa_tl + { \exp_not:n { #3 } } + { \exp_not:n { #4 #5 } } + } + } \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 } } } @@ -7380,6 +7483,8 @@ hlines .default:n = true , line-width .dim_set:N = \l__nicematrix_line_width_dim , line-width .value_required:n = true , + j .code:n = \str_set:Nn \l__nicematrix_hpos_block_str j + \bool_set_true:N \l__nicematrix_p_block_bool , l .code:n = \str_set:Nn \l__nicematrix_hpos_block_str l , r .code:n = \str_set:Nn \l__nicematrix_hpos_block_str r , c .code:n = \str_set:Nn \l__nicematrix_hpos_block_str c , @@ -7393,9 +7498,11 @@ 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 , - m .code:n = \str_set:Nn \l__nicematrix_vpos_block_str { c } , + 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 , name .tl_set:N = \l__nicematrix_block_name_str , name .value_required:n = true , name .initial:n = , @@ -7442,16 +7549,28 @@ { \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: \int_compare:nNnT { #1 } = { #3 } { \str_set:Nn \l__nicematrix_vpos_block_str { t } } \keys_set:nn { NiceMatrix / Block / SecondPass } { #5 } - \bool_if:NT \l__nicematrix_vlines_block_bool + \tl_if_in:nnT { #6 } { & } { \bool_set_true:N \l__nicematrix_ampersand_bool } + \bool_lazy_and:nnT + \l__nicematrix_vlines_block_bool + { ! \l__nicematrix_ampersand_bool } { \tl_gput_right:Nx \g_nicematrix_code_after_tl { @@ -7555,195 +7674,325 @@ { \exp_not:n { ##1 } } { \exp_not:n { ##2 } } } } - \hbox_set:Nn \l__nicematrix_cell_box { \set@color #6 } - \bool_if:NT \g__nicematrix_rotate_bool \__nicematrix_rotate_cell_box: \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgf@relevantforpicturesizefalse + \__nicematrix_qpoint:n { row - #1 } + \dim_set_eq:NN \l_tmpa_dim \pgf@y + \__nicematrix_qpoint:n { col - #2 } + \dim_set_eq:NN \l_tmpb_dim \pgf@x + \__nicematrix_qpoint:n { row - \int_eval:n { \l__nicematrix_last_row_int + 1 } } + \dim_set_eq:NN \l__nicematrix_tmpc_dim \pgf@y + \__nicematrix_qpoint:n { col - \int_eval:n { \l__nicematrix_last_col_int + 1 } } + \dim_set_eq:NN \l__nicematrix_tmpd_dim \pgf@x + \__nicematrix_pgf_rect_node:nnnnn + { \__nicematrix_env: - #1 - #2 - block } + \l_tmpb_dim \l_tmpa_dim \l__nicematrix_tmpd_dim \l__nicematrix_tmpc_dim + \str_if_empty:NF \l__nicematrix_block_name_str + { + \pgfnodealias + { \__nicematrix_env: - \l__nicematrix_block_name_str } + { \__nicematrix_env: - #1 - #2 - block } + \str_if_empty:NF \l__nicematrix_name_str + { + \pgfnodealias + { \l__nicematrix_name_str - \l__nicematrix_block_name_str } + { \__nicematrix_env: - #1 - #2 - block } + } + } + \bool_if:NF \l__nicematrix_hpos_of_block_cap_bool + { + \dim_set_eq:NN \l_tmpb_dim \c_max_dim + \int_step_inline:nnn \l__nicematrix_first_row_int \g__nicematrix_row_total_int + { + \cs_if_exist:cT + { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - #2 } + { + \seq_if_in:NnF \g__nicematrix_multicolumn_cells_seq { ##1 - #2 } + { + \pgfpointanchor { \__nicematrix_env: - ##1 - #2 } { west } + \dim_set:Nn \l_tmpb_dim { \dim_min:nn \l_tmpb_dim \pgf@x } + } + } + } + \dim_compare:nNnT \l_tmpb_dim = \c_max_dim + { + \__nicematrix_qpoint:n { col - #2 } + \dim_set_eq:NN \l_tmpb_dim \pgf@x + } + \dim_set:Nn \l__nicematrix_tmpd_dim { - \c_max_dim } + \int_step_inline:nnn \l__nicematrix_first_row_int \g__nicematrix_row_total_int + { + \cs_if_exist:cT + { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - \int_use:N \l__nicematrix_last_col_int } + { + \seq_if_in:NnF \g__nicematrix_multicolumn_cells_seq { ##1 - #2 } + { + \pgfpointanchor + { \__nicematrix_env: - ##1 - \int_use:N \l__nicematrix_last_col_int } + { east } + \dim_set:Nn \l__nicematrix_tmpd_dim { \dim_max:nn \l__nicematrix_tmpd_dim \pgf@x } + } + } + } + \dim_compare:nNnT \l__nicematrix_tmpd_dim = { - \c_max_dim } + { + \__nicematrix_qpoint:n { col - \int_eval:n { \l__nicematrix_last_col_int + 1 } } + \dim_set_eq:NN \l__nicematrix_tmpd_dim \pgf@x + } + \__nicematrix_pgf_rect_node:nnnnn + { \__nicematrix_env: - #1 - #2 - block - short } + \l_tmpb_dim \l_tmpa_dim \l__nicematrix_tmpd_dim \l__nicematrix_tmpc_dim + } + \bool_if:NT \l__nicematrix_medium_nodes_bool + { + \__nicematrix_pgf_rect_node:nnn + { \__nicematrix_env: - #1 - #2 - block - medium } + { \pgfpointanchor { \__nicematrix_env: - #1 - #2 - medium } { north~west } } + { + \pgfpointanchor + { \__nicematrix_env: + - \int_use:N \l__nicematrix_last_row_int + - \int_use:N \l__nicematrix_last_col_int - medium + } + { south~east } + } + } + \endpgfpicture + \bool_if:NTF \l__nicematrix_ampersand_bool + { + \seq_set_split:Nnn \l_tmpa_seq { & } { #6 } + \int_zero_new:N \l__nicematrix_split_int + \int_set:Nn \l__nicematrix_split_int { \seq_count:N \l_tmpa_seq } + \pgfpicture \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse \__nicematrix_qpoint:n { row - #1 } - \dim_set_eq:NN \l_tmpa_dim \pgf@y - \__nicematrix_qpoint:n { col - #2 } - \dim_set_eq:NN \l_tmpb_dim \pgf@x - \__nicematrix_qpoint:n { row - \int_eval:n { \l__nicematrix_last_row_int + 1 } } \dim_set_eq:NN \l__nicematrix_tmpc_dim \pgf@y - \__nicematrix_qpoint:n { col - \int_eval:n { \l__nicematrix_last_col_int + 1 } } - \dim_set_eq:NN \l__nicematrix_tmpd_dim \pgf@x - \__nicematrix_pgf_rect_node:nnnnn - { \__nicematrix_env: - #1 - #2 - block } - \l_tmpb_dim \l_tmpa_dim \l__nicematrix_tmpd_dim \l__nicematrix_tmpc_dim - \str_if_empty:NF \l__nicematrix_block_name_str + \__nicematrix_qpoint:n { row - \int_eval:n { #3 + 1 } } + \dim_set_eq:NN \l__nicematrix_tmpd_dim \pgf@y + \__nicematrix_qpoint:n { col - #2 } + \dim_set_eq:NN \l_tmpa_dim \pgf@x + \__nicematrix_qpoint:n { col - \int_eval:n { #4 + 1 } } + \dim_set:Nn \l_tmpb_dim + { ( \pgf@x - \l_tmpa_dim ) / \int_use:N \l__nicematrix_split_int } + \bool_lazy_or:nnT + \l__nicematrix_vlines_block_bool + { \tl_if_eq_p:NN \l__nicematrix_vlines_clist \c__nicematrix_all_tl } { - \pgfnodealias - { \__nicematrix_env: - \l__nicematrix_block_name_str } - { \__nicematrix_env: - #1 - #2 - block } - \str_if_empty:NF \l__nicematrix_name_str + \int_step_inline:nn { \l__nicematrix_split_int - 1 } { - \pgfnodealias - { \l__nicematrix_name_str - \l__nicematrix_block_name_str } - { \__nicematrix_env: - #1 - #2 - block } + \pgfpathmoveto + { + \pgfpoint + { \l_tmpa_dim + ##1 \l_tmpb_dim } + \l__nicematrix_tmpc_dim + } + \pgfpathlineto + { + \pgfpoint + { \l_tmpa_dim + ##1 \l_tmpb_dim } + \l__nicematrix_tmpd_dim + } + \CT@arc@ + \pgfsetlinewidth { 1.1 \arrayrulewidth } + \pgfsetrectcap + \pgfusepathqstroke } } - \bool_if:NF \l__nicematrix_hpos_of_block_cap_bool + \__nicematrix_qpoint:n { row - #1 - base } + \dim_set_eq:NN \l__nicematrix_tmpc_dim \pgf@y + \int_step_inline:nn \l__nicematrix_split_int { - \dim_set_eq:NN \l_tmpb_dim \c_max_dim - \int_step_inline:nnn \l__nicematrix_first_row_int \g__nicematrix_row_total_int + \group_begin: + \dim_set:Nn \col@sep + { \bool_if:NTF \l__nicematrix_tabular_bool \tabcolsep \arraycolsep } + \pgftransformshift { - \cs_if_exist:cT - { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - #2 } + \pgfpoint { - \seq_if_in:NnF \g__nicematrix_multicolumn_cells_seq { ##1 - #2 } + \str_case:on \l__nicematrix_hpos_block_str { - \pgfpointanchor { \__nicematrix_env: - ##1 - #2 } { west } - \dim_set:Nn \l_tmpb_dim { \dim_min:nn \l_tmpb_dim \pgf@x } + l { \l_tmpa_dim + ##1 \l_tmpb_dim - \l_tmpb_dim + \col@sep} + c { \l_tmpa_dim + ##1 \l_tmpb_dim - 0.5 \l_tmpb_dim } + r { \l_tmpa_dim + ##1 \l_tmpb_dim - \col@sep } } } + { \l__nicematrix_tmpc_dim } } - \dim_compare:nNnT \l_tmpb_dim = \c_max_dim + \pgfset { - \__nicematrix_qpoint:n { col - #2 } - \dim_set_eq:NN \l_tmpb_dim \pgf@x + inner~xsep = \c_zero_dim , + inner~ysep = \c_zero_dim } - \dim_set:Nn \l__nicematrix_tmpd_dim { - \c_max_dim } - \int_step_inline:nnn \l__nicematrix_first_row_int \g__nicematrix_row_total_int + \pgfnode + { rectangle } { - \cs_if_exist:cT - { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - \int_use:N \l__nicematrix_last_col_int } + \str_case:on \l__nicematrix_hpos_block_str { - \seq_if_in:NnF \g__nicematrix_multicolumn_cells_seq { ##1 - #2 } - { - \pgfpointanchor - { \__nicematrix_env: - ##1 - \int_use:N \l__nicematrix_last_col_int } - { east } - \dim_set:Nn \l__nicematrix_tmpd_dim { \dim_max:nn \l__nicematrix_tmpd_dim \pgf@x } - } + c { base } + l { base~west } + r { base~east } } } - \dim_compare:nNnT \l__nicematrix_tmpd_dim = { - \c_max_dim } - { - \__nicematrix_qpoint:n { col - \int_eval:n { \l__nicematrix_last_col_int + 1 } } - \dim_set_eq:NN \l__nicematrix_tmpd_dim \pgf@x - } - \__nicematrix_pgf_rect_node:nnnnn - { \__nicematrix_env: - #1 - #2 - block - short } - \l_tmpb_dim \l_tmpa_dim \l__nicematrix_tmpd_dim \l__nicematrix_tmpc_dim + { \seq_item:Nn \l_tmpa_seq { ##1 } } { } { } + \group_end: } - \bool_if:NT \l__nicematrix_medium_nodes_bool - { - \__nicematrix_pgf_rect_node:nnn - { \__nicematrix_env: - #1 - #2 - block - medium } - { \pgfpointanchor { \__nicematrix_env: - #1 - #2 - medium } { north~west } } - { - \pgfpointanchor - { \__nicematrix_env: - - \int_use:N \l__nicematrix_last_row_int - - \int_use:N \l__nicematrix_last_col_int - medium + \endpgfpicture + } + { + \bool_if:NTF \l__nicematrix_p_block_bool + { + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgf@relevantforpicturesizefalse + \bool_if:NTF \l__nicematrix_hpos_of_block_cap_bool + { + \__nicematrix_qpoint:n { col - #2 } + \dim_gset_eq:NN \g_tmpa_dim \pgf@x + \__nicematrix_qpoint:n { col - \int_eval:n { \l__nicematrix_last_col_int + 1 } } + } + { + \pgfpointanchor { \__nicematrix_env: - #1 - #2 - block - short } { west } + \dim_gset_eq:NN \g_tmpa_dim \pgf@x + \pgfpointanchor { \__nicematrix_env: - #1 - #2 - block - short } { east } + } + \dim_gset:Nn \g_tmpb_dim { \pgf@x - \g_tmpa_dim } + \endpgfpicture + \hbox_set:Nn \l__nicematrix_cell_box + { + \begin { minipage } [ \str_lowercase:o \l__nicematrix_vpos_block_str ] + { \g_tmpb_dim } + \str_case:on \l__nicematrix_hpos_block_str + { c \centering r \raggedleft l \raggedright j { } } + #6 + \end { minipage } } - { south~east } } - } - \bool_lazy_any:nTF - { - { \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 } } - } - { - \int_if_zero:nT { #2 } { \str_set_eq:NN \l__nicematrix_hpos_block_str \c__nicematrix_r_str } - \bool_if:nT \g__nicematrix_last_col_found_bool + { \hbox_set:Nn \l__nicematrix_cell_box { \set@color #6 } } + \bool_if:NT \g__nicematrix_rotate_bool \__nicematrix_rotate_cell_box: + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgf@relevantforpicturesizefalse + \bool_lazy_any:nTF { - \int_compare:nNnT { #2 } = \g__nicematrix_col_total_int - { \str_set_eq:NN \l__nicematrix_hpos_block_str \c__nicematrix_l_str } + { \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 } } } - \tl_set:Nx \l_tmpa_tl { - \str_case:on \l__nicematrix_vpos_block_str + \int_if_zero:nT { #2 } { \str_set_eq:NN \l__nicematrix_hpos_block_str \c__nicematrix_r_str } + \bool_if:nT \g__nicematrix_last_col_found_bool { - c { - \str_case:on \l__nicematrix_hpos_block_str - { - c { center } - l { west } - r { east } - } + \int_compare:nNnT { #2 } = \g__nicematrix_col_total_int + { \str_set_eq:NN \l__nicematrix_hpos_block_str \c__nicematrix_l_str } + } + \tl_set:Nx \l_tmpa_tl + { + \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 + { + c { center } + l { west } + r { east } + j { center } + } - } - T { - \str_case:on \l__nicematrix_hpos_block_str - { - c { north } - l { north~west } - r { north~east } } + T { + \str_case:on \l__nicematrix_hpos_block_str + { + c { north } + l { north~west } + r { north~east } + j { north } + } - } - B { - \str_case:on \l__nicematrix_hpos_block_str - { - c { south} - l { south~west } - r { south~east } } + B { + \str_case:on \l__nicematrix_hpos_block_str + { + c { south } + l { south~west } + r { south~east } + j { south } + } + } } } - } - \pgftransformshift - { - \pgfpointanchor + \pgftransformshift { - \__nicematrix_env: - #1 - #2 - block - \bool_if:NF \l__nicematrix_hpos_of_block_cap_bool { - short } + \pgfpointanchor + { + \__nicematrix_env: - #1 - #2 - block + \bool_if:NF \l__nicematrix_hpos_of_block_cap_bool { - short } + } + { \l_tmpa_tl } + } + \pgfset + { + inner~xsep = \c_zero_dim , + inner~ysep = \c_zero_dim } + \pgfnode + { rectangle } { \l_tmpa_tl } + { \box_use_drop:N \l__nicematrix_cell_box } { } { } } - \pgfset { - inner~xsep = \c_zero_dim , - inner~ysep = \c_zero_dim - } - \pgfnode - { rectangle } - { \l_tmpa_tl } - { \box_use_drop:N \l__nicematrix_cell_box } { } { } - } - { - \pgfextracty \l_tmpa_dim - { - \__nicematrix_qpoint:n + \pgfextracty \l_tmpa_dim { - row - \str_if_eq:onTF \l__nicematrix_vpos_block_str { b } { #3 } { #1 } - - base + \__nicematrix_qpoint:n + { + row - \str_if_eq:onTF \l__nicematrix_vpos_block_str { b } { #3 } { #1 } + - base + } } - } - \dim_sub:Nn \l_tmpa_dim { 0.5 \arrayrulewidth } - \pgfpointanchor - { - \__nicematrix_env: - #1 - #2 - block - \bool_if:NF \l__nicematrix_hpos_of_block_cap_bool { - short } - } - { - \str_case:on \l__nicematrix_hpos_block_str + \dim_sub:Nn \l_tmpa_dim { 0.5 \arrayrulewidth } + \pgfpointanchor { - c { center } - l { west } - r { east } + \__nicematrix_env: - #1 - #2 - block + \bool_if:NF \l__nicematrix_hpos_of_block_cap_bool { - short } } - } - \pgftransformshift { \pgfpoint \pgf@x \l_tmpa_dim } - \pgfset { inner~sep = \c_zero_dim } - \pgfnode - { rectangle } - { - \str_case:on \l__nicematrix_hpos_block_str { - c { base } - l { base~west } - r { base~east } + \str_case:on \l__nicematrix_hpos_block_str + { + c { center } + l { west } + r { east } + j { center } + } + } + \pgftransformshift { \pgfpoint \pgf@x \l_tmpa_dim } + \pgfset { inner~sep = \c_zero_dim } + \pgfnode + { rectangle } + { + \str_case:on \l__nicematrix_hpos_block_str + { + c { base } + l { base~west } + r { base~east } + j { base } + } } + { \box_use_drop:N \l__nicematrix_cell_box } { } { } } - { \box_use_drop:N \l__nicematrix_cell_box } { } { } + \endpgfpicture } - \endpgfpicture \group_end: } \cs_new_protected:Npn \__nicematrix_stroke_block:nnn #1 #2 #3 @@ -8607,6 +8856,7 @@ { \nullfont \c_math_toggle_token + \colorlet { current-color } { . } \__nicematrix_color:o \l__nicematrix_delimiters_color_tl \left . \vcenter @@ -8618,7 +8868,7 @@ } \right #1 \tl_if_empty:nF { #3 } { _ { \smash { #3 } } } - ^ { \smash { #4 } } + ^ { \color { current-color } \smash { #4 } } \c_math_toggle_token } { #2 } @@ -8638,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 , @@ -8886,9 +9139,9 @@ } \NewDocumentCommand \__nicematrix_ShowCellNames_CodeBefore { } { - \dim_zero_new:N \g__nicematrix_tmpc_dim - \dim_zero_new:N \g__nicematrix_tmpd_dim - \dim_zero_new:N \g__nicematrix_tmpe_dim + \dim_gzero_new:N \g__nicematrix_tmpc_dim + \dim_gzero_new:N \g__nicematrix_tmpd_dim + \dim_gzero_new:N \g__nicematrix_tmpe_dim \int_step_inline:nn \c@iRow { \begin { pgfpicture } @@ -8969,9 +9222,9 @@ \pgfusepathqfill \endpgfpicture } - \dim_zero_new:N \g__nicematrix_tmpc_dim - \dim_zero_new:N \g__nicematrix_tmpd_dim - \dim_zero_new:N \g__nicematrix_tmpe_dim + \dim_gzero_new:N \g__nicematrix_tmpc_dim + \dim_gzero_new:N \g__nicematrix_tmpd_dim + \dim_gzero_new:N \g__nicematrix_tmpe_dim \int_step_inline:nn \c@iRow { \bool_if:NTF \l__nicematrix_in_code_after_bool @@ -9210,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 } @@ -9221,6 +9474,12 @@ The~columns~you~did~not~used~won't~be~created.\\ You~won't~have~similar~error~message~till~the~end~of~the~document. } +\__nicematrix_msg_new:nn { empty~preamble } + { + Empty~preamble.\\ + The~preamble~of~your~\__nicematrix_full_name_env:\ is~empty.\\ + This~error~is~fatal. + } \__nicematrix_msg_new:nn { in~first~col } { Erroneous~use.\\ @@ -9393,7 +9652,7 @@ Incompatible~keys.\\ You~can't~use~the~keys~'hlines',~'vlines'~or~'hvlines'~for~a~ '\token_to_str:N \Block'~when~the~key~'color'~or~'draw'~is~used.\\ - Maybe~it~will~possible~in~future~version.\\ + However,~you~can~put~several~commands~\token_to_str:N \Block.\\ Your~key~will~be~discarded. } \__nicematrix_msg_new:nn { bad~value~for~baseline } @@ -9422,7 +9681,7 @@ \__nicematrix_msg_new:nn { ragged2e~not~loaded } { You~have~to~load~'ragged2e'~in~order~to~use~the~key~'\l_keys_key_str'~in~ - your~column~'\l__nicematrix_vpos_col_str'~(or~'X').~The~key~'\str_lowercase:V + your~column~'\l__nicematrix_vpos_col_str'~(or~'X').~The~key~'\str_lowercase:o \l_keys_key_str'~will~be~used~instead. } \__nicematrix_msg_new:nn { Invalid~name } @@ -9752,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 } { @@ -9866,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,~ @@ -9880,6 +10142,7 @@ create-extra-nodes,~ create-medium-nodes,~ create-large-nodes,~ + custom-line,~ delimiters~(several~subkeys),~ end-of-row,~ first-col,~ @@ -9918,6 +10181,8 @@ } { The~available~keys~are~(in~alphabetic~order):~ + &-in-blocks,~ + ampersand-in-blocks,~ b,~ baseline,~ c,~ @@ -9975,6 +10240,8 @@ } { The~available~keys~are~(in~alphabetic~order):~ + &-in-blocks,~ + ampersand-in-blocks,~ b,~ baseline,~ c,~ @@ -10035,6 +10302,8 @@ } { The~available~keys~are~(in~alphabetic~order):~ + &-in-blocks,~ + ampersand-in-blocks,~ b,~ baseline,~ c,~ |