%% %% This is file `nicematrix.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% nicematrix.dtx (with options: `package') %% %% Copyright (C) 2018-2022 by F. Pantigny %% %% This file may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either %% version 1.3 of this license or (at your option) any later %% version. The latest version of this license is in: %% %% http://www.latex-project.org/lppl.txt %% %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% \def\myfileversion{6.12} \def\myfiledate{2022/07/28} \RequirePackage{pgfcore} \usepgfmodule{shapes} \RequirePackage{l3keys2e} \ProvidesExplPackage {nicematrix} {\myfiledate} {\myfileversion} {Enhanced arrays with the help of PGF/TikZ} \RequirePackage { array } \RequirePackage { amsmath } \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 } } \cs_generate_variant:Nn \__nicematrix_error:nn { n x } \cs_new_protected:Npn \__nicematrix_error:nnn { \msg_error:nnnn { nicematrix } } \cs_new_protected:Npn \__nicematrix_fatal:n { \msg_fatal:nn { nicematrix } } \cs_new_protected:Npn \__nicematrix_fatal:nn { \msg_fatal:nnn { nicematrix } } \cs_new_protected:Npn \__nicematrix_msg_new:nn { \msg_new:nnn { nicematrix } } \cs_new_protected:Npn \__nicematrix_msg_new:nnn #1 #2 #3 { \bool_if:NTF \c__nicematrix_messages_for_Overleaf_bool { \msg_new:nnn { nicematrix } { #1 } { #2 \\ #3 } } { \msg_new:nnnn { nicematrix } { #1 } { #2 } { #3 } } } \cs_new_protected:Npn \__nicematrix_error_or_warning:n { \bool_if:NTF \c__nicematrix_messages_for_Overleaf_bool \__nicematrix_warning:n \__nicematrix_error:n } \str_if_eq:VnT \c_sys_jobname_str { output } { \bool_set_true:N \c__nicematrix_messages_for_Overleaf_bool } \cs_new_protected:Npn \__nicematrix_msg_redirect_name:nn { \msg_redirect_name:nnn { nicematrix } } \cs_new_protected:Npn \__nicematrix_gredirect_none:n #1 { \group_begin: \globaldefs = 1 \__nicematrix_msg_redirect_name:nn { #1 } { none } \group_end: } \cs_new_protected:Npn \__nicematrix_err_gredirect_none:n #1 { \__nicematrix_error:n { #1 } \__nicematrix_gredirect_none:n { #1 } } \cs_new_protected:Npn \__nicematrix_warning_gredirect_none:n #1 { \__nicematrix_warning:n { #1 } \__nicematrix_gredirect_none:n { #1 } } \tl_new:N \l__nicematrix_argspec_tl \cs_generate_variant:Nn \seq_set_split:Nnn { N V n } \cs_generate_variant:Nn \keys_define:nn { n x } \hook_gput_code:nnn { begindocument } { . } { \@ifpackageloaded { varwidth } { \bool_const:Nn \c__nicematrix_varwidth_loaded_bool { \c_true_bool } } { \bool_const:Nn \c__nicematrix_varwidth_loaded_bool { \c_false_bool } } \@ifpackageloaded { booktabs } { \bool_const:Nn \c__nicematrix_booktabs_loaded_bool { \c_true_bool } } { \bool_const:Nn \c__nicematrix_booktabs_loaded_bool { \c_false_bool } } \@ifpackageloaded { enumitem } { \bool_const:Nn \c__nicematrix_enumitem_loaded_bool { \c_true_bool } } { \bool_const:Nn \c__nicematrix_enumitem_loaded_bool { \c_false_bool } } \@ifpackageloaded { tabularx } { \bool_const:Nn \c__nicematrix_tabularx_loaded_bool { \c_true_bool } } { \bool_const:Nn \c__nicematrix_tabularx_loaded_bool { \c_false_bool } } \@ifpackageloaded { floatrow } { \bool_const:Nn \c__nicematrix_floatrow_loaded_bool { \c_true_bool } } { \bool_const:Nn \c__nicematrix_floatrow_loaded_bool { \c_false_bool } } \@ifpackageloaded { tikz } { \bool_const:Nn \c__nicematrix_tikz_loaded_bool \c_true_bool \tl_const:Nn \c__nicematrix_pgfortikzpicture_tl { \exp_not:N \tikzpicture } \tl_const:Nn \c__nicematrix_endpgfortikzpicture_tl { \exp_not:N \endtikzpicture } } { \bool_const:Nn \c__nicematrix_tikz_loaded_bool \c_false_bool \tl_const:Nn \c__nicematrix_pgfortikzpicture_tl { \exp_not:N \pgfpicture } \tl_const:Nn \c__nicematrix_endpgfortikzpicture_tl { \exp_not:N \endpgfpicture } } } \@ifclassloaded { revtex4-1 } { \bool_const:Nn \c__nicematrix_revtex_bool \c_true_bool } { \@ifclassloaded { revtex4-2 } { \bool_const:Nn \c__nicematrix_revtex_bool \c_true_bool } { \cs_if_exist:NT \rvtx@ifformat@geq { \bool_const:Nn \c__nicematrix_revtex_bool \c_true_bool } { \bool_const:Nn \c__nicematrix_revtex_bool \c_false_bool } } } \cs_generate_variant:Nn \tl_if_single_token_p:n { V } \regex_const:Nn \c__nicematrix_columncolor_regex { \c { columncolor } } \cs_new_protected:Npn \__nicematrix_provide_pgfsyspdfmark: { \iow_now:Nn \@mainaux { \ExplSyntaxOn \cs_if_free:NT \pgfsyspdfmark { \cs_set_eq:NN \pgfsyspdfmark \@gobblethree } \ExplSyntaxOff } \cs_gset_eq:NN \__nicematrix_provide_pgfsyspdfmark: \prg_do_nothing: } \ProvideDocumentCommand \iddots { } { \mathinner { \tex_mkern:D 1 mu \box_move_up:nn { 1 pt } { \hbox:n { . } } \tex_mkern:D 2 mu \box_move_up:nn { 4 pt } { \hbox:n { . } } \tex_mkern:D 2 mu \box_move_up:nn { 7 pt } { \vbox:n { \kern 7 pt \hbox:n { . } } } \tex_mkern:D 1 mu } } \hook_gput_code:nnn { begindocument } { . } { \@ifpackageloaded { booktabs } { \iow_now:Nn \@mainaux \nicematrix@redefine@check@rerun } { } } \cs_set_protected:Npn \nicematrix@redefine@check@rerun { \cs_set_eq:NN \__nicematrix_old_pgfutil@check@rerun \pgfutil@check@rerun \cs_set_protected:Npn \pgfutil@check@rerun ##1 ##2 { \str_if_eq:eeF { nm- } { \tl_range:nnn { ##1 } 1 3 } { \__nicematrix_old_pgfutil@check@rerun { ##1 } { ##2 } } } } \bool_new:N \l__nicematrix_colortbl_loaded_bool \hook_gput_code:nnn { begindocument } { . } { \@ifpackageloaded { colortbl } { \bool_set_true:N \l__nicematrix_colortbl_loaded_bool } { \cs_set_protected:Npn \CT@arc@ { } \cs_set:Npn \arrayrulecolor #1 # { \CT@arc { #1 } } \cs_set:Npn \CT@arc #1 #2 { \dim_compare:nNnT \baselineskip = \c_zero_dim \noalign { \cs_gset:Npn \CT@arc@ { \color #1 { #2 } } } } \cs_set:Npn \doublerulesepcolor #1 # { \CT@drs { #1 } } \cs_set: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 { \noalign { \ifnum 0 = `} \fi \cs_set_eq:NN \hskip \vskip \cs_set_eq:NN \vrule \hrule \cs_set_eq:NN \@width \@height { \CT@arc@ \vline } \futurelet \reserved@a \@xhline } } } \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 { \int_compare:nNnT \l__nicematrix_first_col_int = 0 { \omit & } \int_compare:nNnT { #1 } > 1 { \multispan { \int_eval:n { #1 - 1 } } & } \multispan { \int_eval:n { #2 - #1 + 1 } } { \CT@arc@ \leaders \hrule \@height \arrayrulewidth \hfill \skip_horizontal:N \c_zero_dim } \everycr { } \cr \noalign { \skip_vertical:N -\arrayrulewidth } } \cs_set:Npn \__nicematrix_cline { \__nicematrix_cline_i:en \l__nicematrix_first_col_int } \cs_set:Npn \__nicematrix_cline_i:nn #1 #2 { \__nicematrix_cline_i:w #1|#2- \q_stop } \cs_set:Npn \__nicematrix_cline_i:w #1|#2-#3 \q_stop { \tl_if_empty:nTF { #3 } { \__nicematrix_cline_iii:w #1|#2-#2 \q_stop } { \__nicematrix_cline_ii:w #1|#2-#3 \q_stop } } \cs_set:Npn \__nicematrix_cline_ii:w #1|#2-#3-\q_stop { \__nicematrix_cline_iii:w #1|#2-#3 \q_stop } \cs_set:Npn \__nicematrix_cline_iii:w #1|#2-#3 \q_stop { \int_compare:nNnT { #1 } < { #2 } { \multispan { \int_eval:n { #2 - #1 } } & } \multispan { \int_eval:n { #3 - #2 + 1 } } { \CT@arc@ \leaders \hrule \@height \arrayrulewidth \hfill \skip_horizontal:N \c_zero_dim } \peek_meaning_remove_ignore_spaces:NTF \cline { & \__nicematrix_cline_i:en { \int_eval:n { #3 + 1 } } } { \everycr { } \cr } } \cs_generate_variant:Nn \__nicematrix_cline_i:nn { e n } \cs_new:Npn \__nicematrix_math_toggle_token: { \bool_if:NF \l__nicematrix_NiceTabular_bool \c_math_toggle_token } \cs_new_protected:Npn \__nicematrix_set_CT@arc@:n #1 { \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_generate_variant:Nn \__nicematrix_set_CT@arc@:n { V } \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_generate_variant:Nn \__nicematrix_set_CT@drsc@:n { V } \cs_new:Npn \__nicematrix_exp_color_arg:Nn #1 #2 { \tl_if_head_eq_meaning:nNTF { #2 } [ { #1 #2 } { #1 { #2 } } } \cs_generate_variant:Nn \__nicematrix_exp_color_arg:Nn { N V } \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 { V } \cs_set_eq:NN \__nicematrix_old_pgfpointanchor \pgfpointanchor \bool_new:N \l__nicematrix_siunitx_loaded_bool \hook_gput_code:nnn { begindocument } { . } { \@ifpackageloaded { siunitx } { \bool_set_true:N \l__nicematrix_siunitx_loaded_bool } { } } \hook_gput_code:nnn { begindocument } { . } { \bool_if:nTF { ! \l__nicematrix_siunitx_loaded_bool } { \cs_set_eq:NN \__nicematrix_renew_NC@rewrite@S: \prg_do_nothing: } { \cs_new_protected:Npn \__nicematrix_renew_NC@rewrite@S: { \renewcommand*{\NC@rewrite@S}[1][] { \@temptokena \exp_after:wN { \tex_the:D \@temptokena \__nicematrix_S: [ ##1 ] } \NC@find } } } } \int_new:N \g__nicematrix_env_int \cs_new:Npn \__nicematrix_env: { nm - \int_use:N \g__nicematrix_env_int } \NewExpandableDocumentCommand \NiceMatrixLastEnv { } { \int_use:N \g__nicematrix_env_int } \cs_new_protected:Npn \__nicematrix_qpoint:n #1 { \pgfpointanchor { \__nicematrix_env: - #1 } { center } } \int_new:N \g__nicematrix_NiceMatrixBlock_int \int_new:N \l__nicematrix_note_in_caption_int \dim_new:N \l__nicematrix_columns_width_dim \dim_new:N \l__nicematrix_col_width_dim \dim_set:Nn \l__nicematrix_col_width_dim { -1 cm } \int_new:N \g__nicematrix_row_total_int \int_new:N \g__nicematrix_col_total_int \int_new:N \g__nicematrix_last_row_node_int \int_new:N \l__nicematrix_key_nb_rows_int \str_new:N \l__nicematrix_hpos_cell_str \str_set:Nn \l__nicematrix_hpos_cell_str { c } \dim_new:N \g__nicematrix_blocks_wd_dim \dim_new:N \g__nicematrix_blocks_ht_dim \dim_new:N \g__nicematrix_blocks_dp_dim \dim_new:N \l__nicematrix_width_dim \seq_new:N \g__nicematrix_names_seq \bool_new:N \l__nicematrix_in_env_bool \bool_new:N \l__nicematrix_notes_detect_duplicates_bool \bool_set_true:N \l__nicematrix_notes_detect_duplicates_bool \bool_new:N \g__nicematrix_NiceArray_bool \bool_new:N \l__nicematrix_NiceTabular_bool \dim_new:N \l__nicematrix_tabular_width_dim \dim_new:N \l__nicematrix_rule_width_dim \bool_new:N \l__nicematrix_Matrix_bool \bool_new:N \g__nicematrix_rotate_bool \bool_new:N \l__nicematrix_X_column_bool \bool_new:N \g__nicematrix_caption_finished_bool \tl_new:N \g__nicematrix_aux_tl \tl_new:N \l__nicematrix_columns_type_tl \hook_gput_code:nnn { begindocument } { . } { \__nicematrix_set_preamble:Nn \l__nicematrix_columns_type_tl { c } } \cs_new_protected:Npn \__nicematrix_test_if_math_mode: { \if_mode_math: \else: \__nicematrix_fatal:n { Outside~math~mode } \fi: } \tl_new:N \l__nicematrix_letter_vlism_tl \seq_new:N \g__nicematrix_cols_vlism_seq \colorlet { nicematrix-last-col } { . } \colorlet { nicematrix-last-row } { . } \str_new:N \g__nicematrix_name_env_str \tl_new:N \g__nicematrix_com_or_env_str \tl_gset:Nn \g__nicematrix_com_or_env_str { environment } \cs_new:Npn \__nicematrix_full_name_env: { \str_if_eq:VnTF \g__nicematrix_com_or_env_str { command } { command \space \c_backslash_str \g__nicematrix_name_env_str } { environment \space \{ \g__nicematrix_name_env_str \} } } \tl_new:N \g_nicematrix_code_after_tl \tl_new:N \l__nicematrix_code_tl \tl_new:N \g__nicematrix_internal_code_after_tl \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 \tl_new:N \l__nicematrix_rules_color_tl \int_new:N \g__nicematrix_total_X_weight_int \bool_new:N \l__nicematrix_X_columns_aux_bool \dim_new:N \l__nicematrix_X_columns_dim \bool_new:N \g__nicematrix_after_col_zero_bool \bool_new:N \g__nicematrix_row_of_col_done_bool \bool_new:N \g__nicematrix_not_empty_cell_bool \tl_new:N \l__nicematrix_code_before_tl \bool_new:N \l__nicematrix_code_before_bool \tl_new:N \g__nicematrix_row_style_tl \dim_new:N \l__nicematrix_x_initial_dim \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 \bool_new:N \g__nicematrix_empty_cell_bool \bool_new:N \g__nicematrix_second_composition_bool \dim_new:N \g__nicematrix_width_last_col_dim \dim_new:N \g__nicematrix_width_first_col_dim \seq_new:N \g__nicematrix_blocks_seq \seq_new:N \g__nicematrix_pos_of_blocks_seq \seq_new:N \g__nicematrix_pos_of_xdots_seq \seq_new:N \g__nicematrix_pos_of_stroken_blocks_seq \seq_new:N \l__nicematrix_corners_cells_seq \seq_new:N \g__nicematrix_submatrix_names_seq \bool_new:N \l__nicematrix_width_used_bool \seq_new:N \g__nicematrix_multicolumn_cells_seq \seq_new:N \g__nicematrix_multicolumn_sizes_seq \int_new:N \l__nicematrix_row_min_int \int_new:N \l__nicematrix_row_max_int \int_new:N \l__nicematrix_col_min_int \int_new:N \l__nicematrix_col_max_int \seq_new:N \g__nicematrix_submatrix_seq \int_new:N \g__nicematrix_static_num_of_col_int \tl_new:N \l__nicematrix_fill_tl \tl_new:N \l__nicematrix_draw_tl \seq_new:N \l__nicematrix_tikz_seq \clist_new:N \l__nicematrix_borders_clist \dim_new:N \l__nicematrix_rounded_corners_dim \tl_new:N \l__nicematrix_color_tl \dim_new:N \l__nicematrix_line_width_dim \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 \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 \bool_new:N \l__nicematrix_vlines_block_bool \bool_new:N \l__nicematrix_hlines_block_bool \int_new:N \g__nicematrix_block_box_int \dim_new:N \l__nicematrix_submatrix_extra_height_dim \dim_new:N \l__nicematrix_submatrix_left_xshift_dim \dim_new:N \l__nicematrix_submatrix_right_xshift_dim \clist_new:N \l__nicematrix_hlines_clist \clist_new:N \l__nicematrix_vlines_clist \clist_new:N \l__nicematrix_submatrix_hlines_clist \clist_new:N \l__nicematrix_submatrix_vlines_clist \bool_new:N \l__nicematrix_dotted_bool \bool_new:N \l__nicematrix_in_caption_bool \int_new:N \l__nicematrix_first_row_int \int_set:Nn \l__nicematrix_first_row_int 1 \int_new:N \l__nicematrix_first_col_int \int_set:Nn \l__nicematrix_first_col_int 1 \int_new:N \l__nicematrix_last_row_int \int_set:Nn \l__nicematrix_last_row_int { -2 } \bool_new:N \l__nicematrix_last_row_without_value_bool \bool_new:N \l__nicematrix_last_col_without_value_bool \int_new:N \l__nicematrix_last_col_int \int_set:Nn \l__nicematrix_last_col_int { -2 } \bool_new:N \g__nicematrix_last_col_found_bool \cs_set_protected:Npn \__nicematrix_cut_on_hyphen:w #1-#2\q_stop { \tl_set:Nn \l_tmpa_tl { #1 } \tl_set:Nn \l_tmpb_tl { #2 } } \cs_new_protected:Npn \__nicematrix_expand_clist:N #1 { \clist_if_in:NnF #1 { all } { \clist_clear:N \l_tmpa_clist \clist_map_inline:Nn #1 { \tl_if_in:nnTF { ##1 } { - } { \__nicematrix_cut_on_hyphen:w ##1 \q_stop } { \tl_set:Nn \l_tmpa_tl { ##1 } \tl_set:Nn \l_tmpb_tl { ##1 } } \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 } } \newcounter { tabularnote } \seq_new:N \g__nicematrix_notes_seq \seq_new:N \g__nicematrix_notes_in_caption_seq \tl_new:N \l__nicematrix_tabularnote_tl \seq_new:N \l__nicematrix_notes_labels_seq \newcounter{nicematrix_draft} \cs_new_protected:Npn \__nicematrix_notes_format:n #1 { \setcounter { nicematrix_draft } { #1 } \__nicematrix_notes_style:n { nicematrix_draft } } \cs_new:Npn \__nicematrix_notes_style:n #1 { \textit { \alph { #1 } } } \cs_new:Npn \__nicematrix_notes_label_in_tabular:n #1 { \textsuperscript { #1 } } \cs_new:Npn \__nicematrix_notes_label_in_list:n #1 { \textsuperscript { #1 } } \cs_set:Npn \thetabularnote { { \__nicematrix_notes_style:n { tabularnote } } } \hook_gput_code:nnn { begindocument } { . } { \bool_if:nTF { ! \c__nicematrix_enumitem_loaded_bool } { \NewDocumentCommand \tabularnote { m } { \__nicematrix_error_or_warning:n { enumitem~not~loaded } \__nicematrix_gredirect_none:n { enumitem~not~loaded } } } { \newlist { tabularnotes } { enumerate } { 1 } \setlist [ tabularnotes ] { topsep = 0pt , noitemsep , leftmargin = * , align = left , labelsep = 0pt , label = \__nicematrix_notes_label_in_list:n { \__nicematrix_notes_style:n { tabularnotesi } } , } \newlist { tabularnotes* } { enumerate* } { 1 } \setlist [ tabularnotes* ] { afterlabel = \nobreak , itemjoin = \quad , label = \__nicematrix_notes_label_in_list:n { \__nicematrix_notes_style:n { tabularnotes*i } } } \NewDocumentCommand \tabularnote { m } { \bool_if:nT { \cs_if_exist_p:N \@captype || \l__nicematrix_in_env_bool } { \bool_if:nTF { ! \g__nicematrix_NiceArray_bool && \l__nicematrix_in_env_bool } { \__nicematrix_error:n { tabularnote~forbidden } } { \bool_if:NTF \l__nicematrix_in_caption_bool { \__nicematrix_tabularnote_ii:n { #1 } } { \__nicematrix_tabularnote_i:n { #1 } } } } } \cs_new_protected:Npn \__nicematrix_tabularnote_i:n #1 { \int_zero:N \l_tmpa_int \bool_if:NT \l__nicematrix_notes_detect_duplicates_bool { \seq_map_indexed_inline:Nn \g__nicematrix_notes_seq { \tl_if_eq:nnT { #1 } { ##2 } { \int_set:Nn \l_tmpa_int { ##1 } \seq_map_break: } } \int_compare:nNnF \l_tmpa_int = 0 { \int_add:Nn \l_tmpa_int \l__nicematrix_note_in_caption_int } } \int_compare:nNnTF \l_tmpa_int = 0 { \int_gincr:N \c@tabularnote \seq_put_right:Nx \l__nicematrix_notes_labels_seq { \__nicematrix_notes_format:n { \int_use:c { c @ tabularnote } } } \seq_gput_right:Nn \g__nicematrix_notes_seq { #1 } } { \seq_put_right:Nx \l__nicematrix_notes_labels_seq { \__nicematrix_notes_format:n { \int_use:N \l_tmpa_int } } } \peek_meaning:NF \tabularnote { \hbox_set:Nn \l_tmpa_box { \__nicematrix_notes_label_in_tabular:n { \seq_use:Nnnn \l__nicematrix_notes_labels_seq { , } { , } { , } } } \int_gsub:Nn \c@tabularnote { 1 } \int_set_eq:NN \l_tmpa_int \c@tabularnote \refstepcounter { tabularnote } \int_compare:nNnT \l_tmpa_int = \c@tabularnote { \int_gincr:N \c@tabularnote } \seq_clear:N \l__nicematrix_notes_labels_seq \hbox_overlap_right:n { \box_use:N \l_tmpa_box } \skip_horizontal:n { \box_wd:N \l_tmpa_box } } } \cs_new_protected:Npn \__nicematrix_tabularnote_ii:n #1 { \int_gincr:N \c@tabularnote \bool_if:NTF \g__nicematrix_caption_finished_bool { \int_compare:nNnTF \c@tabularnote > { \tl_count:N \g__nicematrix_notes_in_caption_seq } { \int_gset:Nn \c@tabularnote { 1 } } \seq_if_in:NnF \g__nicematrix_notes_in_caption_seq { #1 } { \__nicematrix_fatal:n { Identical~notes~in~caption } } } { \seq_if_in:NnTF \g__nicematrix_notes_in_caption_seq { #1 } { \bool_gset_true:N \g__nicematrix_caption_finished_bool \int_gset:Nn \c@tabularnote { 1 } } { \seq_gput_right:Nn \g__nicematrix_notes_in_caption_seq { #1 } } } \seq_put_right:Nx \l__nicematrix_notes_labels_seq { \__nicematrix_notes_format:n { \int_use:N \c@tabularnote } } \peek_meaning:NF \tabularnote { \hbox_set:Nn \l_tmpa_box { \__nicematrix_notes_label_in_tabular:n { \seq_use:Nnnn \l__nicematrix_notes_labels_seq { , } { , } { , } } } \seq_clear:N \l__nicematrix_notes_labels_seq \hbox_overlap_right:n { \box_use:N \l_tmpa_box } \skip_horizontal:n { \box_wd:N \l_tmpa_box } } } } } \cs_new_protected:Npn \__nicematrix_pgf_rect_node:nnnnn #1 #2 #3 #4 #5 { \begin { pgfscope } \pgfset { outer~sep = \c_zero_dim , inner~sep = \c_zero_dim , minimum~size = \c_zero_dim } \pgftransformshift { \pgfpoint { 0.5 * ( #2 + #4 ) } { 0.5 * ( #3 + #5 ) } } \pgfnode { rectangle } { center } { \vbox_to_ht:nn { \dim_abs:n { #5 - #3 } } { \vfill \hbox_to_wd:nn { \dim_abs:n { #4 - #2 } } { } } } { #1 } { } \end { pgfscope } } \cs_new_protected:Npn \__nicematrix_pgf_rect_node:nnn #1 #2 #3 { \begin { pgfscope } \pgfset { outer~sep = \c_zero_dim , inner~sep = \c_zero_dim , minimum~size = \c_zero_dim } \pgftransformshift { \pgfpointscale { 0.5 } { \pgfpointadd { #2 } { #3 } } } \pgfpointdiff { #3 } { #2 } \pgfgetlastxy \l_tmpa_dim \l_tmpb_dim \pgfnode { rectangle } { center } { \vbox_to_ht:nn { \dim_abs:n \l_tmpb_dim } { \vfill \hbox_to_wd:nn { \dim_abs:n \l_tmpa_dim } { } } } { #1 } { } \end { pgfscope } } \tl_new:N \l__nicematrix_caption_tl \tl_new:N \l__nicematrix_short_caption_tl \tl_new:N \l__nicematrix_label_tl \bool_new:N \l__nicematrix_caption_above_bool \bool_new:N \l__nicematrix_colortbl_like_bool \bool_new:N \l__nicematrix_standard_cline_bool \dim_new:N \l__nicematrix_cell_space_top_limit_dim \dim_new:N \l__nicematrix_cell_space_bottom_limit_dim \dim_new:N \l__nicematrix_xdots_inter_dim \hook_gput_code:nnn { begindocument } { . } { \dim_set:Nn \l__nicematrix_xdots_inter_dim { 0.45 em } } \dim_new:N \l__nicematrix_xdots_shorten_start_dim \dim_new:N \l__nicematrix_xdots_shorten_end_dim \hook_gput_code:nnn { begindocument } { . } { \dim_set:Nn \l__nicematrix_xdots_shorten_start_dim { 0.3 em } \dim_set:Nn \l__nicematrix_xdots_shorten_end_dim { 0.3 em } } \dim_new:N \l__nicematrix_xdots_radius_dim \hook_gput_code:nnn { begindocument } { . } { \dim_set:Nn \l__nicematrix_xdots_radius_dim { 0.53 pt } } \tl_new:N \l__nicematrix_xdots_line_style_tl \tl_const:Nn \c__nicematrix_standard_tl { standard } \tl_set_eq:NN \l__nicematrix_xdots_line_style_tl \c__nicematrix_standard_tl \bool_new:N \l__nicematrix_light_syntax_bool \tl_new:N \l__nicematrix_baseline_tl \tl_set:Nn \l__nicematrix_baseline_tl c \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_corners_clist \dim_new:N \l__nicematrix_notes_above_space_dim \hook_gput_code:nnn { begindocument } { . } { \dim_set:Nn \l__nicematrix_notes_above_space_dim { 1 mm } } \bool_new:N \l__nicematrix_nullify_dots_bool \bool_new:N \l__nicematrix_respect_arraystretch_bool \bool_new:N \l__nicematrix_auto_columns_width_bool \bool_new:N \g__nicematrix_recreate_cell_nodes_bool \str_new:N \l__nicematrix_name_str \bool_new:N \l__nicematrix_medium_nodes_bool \bool_new:N \l__nicematrix_large_nodes_bool \bool_new:N \l__nicematrix_except_borders_bool \dim_new:N \l__nicematrix_left_margin_dim \dim_new:N \l__nicematrix_right_margin_dim \dim_new:N \l__nicematrix_extra_left_margin_dim \dim_new:N \l__nicematrix_extra_right_margin_dim \tl_new:N \l__nicematrix_end_of_row_tl \tl_set:Nn \l__nicematrix_end_of_row_tl { ; } \tl_new:N \l__nicematrix_xdots_color_tl \tl_new:N \l__nicematrix_delimiters_color_tl \bool_new:N \l__nicematrix_delimiters_max_width_bool \keys_define:nn { NiceMatrix / xdots } { line-style .code:n = { \bool_lazy_or:nnTF { \cs_if_exist_p:N \tikzpicture } { \str_if_eq_p:nn { #1 } { standard } } { \tl_set:Nn \l__nicematrix_xdots_line_style_tl { #1 } } { \__nicematrix_error:n { bad~option~for~line-style } } } , line-style .value_required:n = true , color .tl_set:N = \l__nicematrix_xdots_color_tl , color .value_required:n = true , shorten .code:n = \hook_gput_code:nnn { begindocument } { . } { \dim_set:Nn \l__nicematrix_xdots_shorten_start_dim { #1 } \dim_set:Nn \l__nicematrix_xdots_shorten_end_dim { #1 } } , shorten-start .code:n = \hook_gput_code:nnn { begindocument } { . } { \dim_set:Nn \l__nicematrix_xdots_shorten_start_dim { #1 } } , shorten-end .code:n = \hook_gput_code:nnn { begindocument } { . } { \dim_set:Nn \l__nicematrix_xdots_shorten_end_dim { #1 } } , shorten .value_required:n = true , shorten-start .value_required:n = true , shorten-end .value_required:n = true , radius .code:n = \hook_gput_code:nnn { begindocument } { . } { \dim_set:Nn \l__nicematrix_xdots_radius_dim { #1 } } , radius .value_required:n = true , inter .code:n = \hook_gput_code:nnn { begindocument } { . } { \dim_set:Nn \l__nicematrix_xdots_inter_dim { #1 } } , radius .value_required:n = true , down .tl_set:N = \l__nicematrix_xdots_down_tl , up .tl_set:N = \l__nicematrix_xdots_up_tl , draw-first .code:n = \prg_do_nothing: , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~xdots } } \keys_define:nn { NiceMatrix / rules } { color .tl_set:N = \l__nicematrix_rules_color_tl , color .value_required:n = true , width .dim_set:N = \arrayrulewidth , width .value_required:n = true , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~rules } } \keys_define:nn { NiceMatrix / Global } { custom-line .code:n = \__nicematrix_custom_line:n { #1 } , delimiters .code:n = \keys_set:nn { NiceMatrix / delimiters } { #1 } , delimiters .value_required:n = true , rules .code:n = \keys_set:nn { NiceMatrix / rules } { #1 } , rules .value_required:n = true , standard-cline .bool_set:N = \l__nicematrix_standard_cline_bool , standard-cline .default:n = true , cell-space-top-limit .dim_set:N = \l__nicematrix_cell_space_top_limit_dim , cell-space-top-limit .value_required:n = true , cell-space-bottom-limit .dim_set:N = \l__nicematrix_cell_space_bottom_limit_dim , cell-space-bottom-limit .value_required:n = true , cell-space-limits .meta:n = { cell-space-top-limit = #1 , cell-space-bottom-limit = #1 , } , cell-space-limits .value_required:n = true , xdots .code:n = \keys_set:nn { NiceMatrix / xdots } { #1 } , light-syntax .bool_set:N = \l__nicematrix_light_syntax_bool , light-syntax .default:n = true , end-of-row .tl_set:N = \l__nicematrix_end_of_row_tl , end-of-row .value_required:n = true , first-col .code:n = \int_zero:N \l__nicematrix_first_col_int , first-row .code:n = \int_zero:N \l__nicematrix_first_row_int , last-row .int_set:N = \l__nicematrix_last_row_int , last-row .default:n = -1 , code-for-first-col .tl_set:N = \l__nicematrix_code_for_first_col_tl , code-for-first-col .value_required:n = true , code-for-last-col .tl_set:N = \l__nicematrix_code_for_last_col_tl , code-for-last-col .value_required:n = true , code-for-first-row .tl_set:N = \l__nicematrix_code_for_first_row_tl , code-for-first-row .value_required:n = true , code-for-last-row .tl_set:N = \l__nicematrix_code_for_last_row_tl , code-for-last-row .value_required:n = true , hlines .clist_set:N = \l__nicematrix_hlines_clist , vlines .clist_set:N = \l__nicematrix_vlines_clist , hlines .default:n = all , vlines .default:n = all , vlines-in-sub-matrix .code:n = { \tl_if_single_token:nTF { #1 } { \tl_set:Nn \l__nicematrix_letter_vlism_tl { #1 } } { \__nicematrix_error:n { One~letter~allowed } } } , vlines-in-sub-matrix .value_required:n = true , hvlines .code:n = { \clist_set:Nn \l__nicematrix_vlines_clist { all } \clist_set:Nn \l__nicematrix_hlines_clist { all } } , hvlines-except-borders .code:n = { \clist_set:Nn \l__nicematrix_vlines_clist { all } \clist_set:Nn \l__nicematrix_hlines_clist { all } \bool_set_true:N \l__nicematrix_except_borders_bool } , parallelize-diags .bool_set:N = \l__nicematrix_parallelize_diags_bool , renew-dots .bool_set:N = \l__nicematrix_renew_dots_bool , renew-dots .value_forbidden:n = true , nullify-dots .bool_set:N = \l__nicematrix_nullify_dots_bool , create-medium-nodes .bool_set:N = \l__nicematrix_medium_nodes_bool , create-large-nodes .bool_set:N = \l__nicematrix_large_nodes_bool , create-extra-nodes .meta:n = { create-medium-nodes , create-large-nodes } , left-margin .dim_set:N = \l__nicematrix_left_margin_dim , left-margin .default:n = \arraycolsep , right-margin .dim_set:N = \l__nicematrix_right_margin_dim , right-margin .default:n = \arraycolsep , margin .meta:n = { left-margin = #1 , right-margin = #1 } , margin .default:n = \arraycolsep , extra-left-margin .dim_set:N = \l__nicematrix_extra_left_margin_dim , extra-right-margin .dim_set:N = \l__nicematrix_extra_right_margin_dim , extra-margin .meta:n = { extra-left-margin = #1 , extra-right-margin = #1 } , extra-margin .value_required:n = true , respect-arraystretch .bool_set:N = \l__nicematrix_respect_arraystretch_bool , respect-arraystretch .default:n = true } \keys_define:nn { NiceMatrix / Env } { corners .clist_set:N = \l__nicematrix_corners_clist , corners .default:n = { NW , SW , NE , SE } , code-before .code:n = { \tl_if_empty:nF { #1 } { \tl_put_right:Nn \l__nicematrix_code_before_tl { #1 } \bool_set_true:N \l__nicematrix_code_before_bool } } , c .code:n = \tl_set:Nn \l__nicematrix_baseline_tl c , t .code:n = \tl_set:Nn \l__nicematrix_baseline_tl t , b .code:n = \tl_set:Nn \l__nicematrix_baseline_tl b , baseline .tl_set:N = \l__nicematrix_baseline_tl , baseline .value_required:n = true , columns-width .code:n = \tl_if_eq:nnTF { #1 } { auto } { \bool_set_true:N \l__nicematrix_auto_columns_width_bool } { \dim_set:Nn \l__nicematrix_columns_width_dim { #1 } } , columns-width .value_required:n = true , name .code:n = \legacy_if:nF { measuring@ } { \str_set:Nn \l_tmpa_str { #1 } \seq_if_in:NVTF \g__nicematrix_names_seq \l_tmpa_str { \__nicematrix_error:nn { Duplicate~name } { #1 } } { \seq_gput_left:NV \g__nicematrix_names_seq \l_tmpa_str } \str_set_eq:NN \l__nicematrix_name_str \l_tmpa_str } , name .value_required:n = true , code-after .tl_gset:N = \g_nicematrix_code_after_tl , code-after .value_required:n = true , colortbl-like .code:n = \bool_set_true:N \l__nicematrix_colortbl_like_bool \bool_set_true:N \l__nicematrix_code_before_bool , colortbl-like .value_forbidden:n = true } \keys_define:nn { NiceMatrix / notes } { para .bool_set:N = \l__nicematrix_notes_para_bool , para .default:n = true , code-before .tl_set:N = \l__nicematrix_notes_code_before_tl , code-before .value_required:n = true , code-after .tl_set:N = \l__nicematrix_notes_code_after_tl , code-after .value_required:n = true , bottomrule .bool_set:N = \l__nicematrix_notes_bottomrule_bool , bottomrule .default:n = true , style .code:n = \cs_set:Nn \__nicematrix_notes_style:n { #1 } , style .value_required:n = true , label-in-tabular .code:n = \cs_set:Nn \__nicematrix_notes_label_in_tabular:n { #1 } , label-in-tabular .value_required:n = true , label-in-list .code:n = \cs_set:Nn \__nicematrix_notes_label_in_list:n { #1 } , label-in-list .value_required:n = true , enumitem-keys .code:n = { \hook_gput_code:nnn { begindocument } { . } { \bool_if:NT \c__nicematrix_enumitem_loaded_bool { \setlist* [ tabularnotes ] { #1 } } } } , enumitem-keys .value_required:n = true , enumitem-keys-para .code:n = { \hook_gput_code:nnn { begindocument } { . } { \bool_if:NT \c__nicematrix_enumitem_loaded_bool { \setlist* [ tabularnotes* ] { #1 } } } } , enumitem-keys-para .value_required:n = true , detect-duplicates .bool_set:N = \l__nicematrix_notes_detect_duplicates_bool , detect-duplicates .default:n = true , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~notes } } \keys_define:nn { NiceMatrix / delimiters } { max-width .bool_set:N = \l__nicematrix_delimiters_max_width_bool , max-width .default:n = true , color .tl_set:N = \l__nicematrix_delimiters_color_tl , color .value_required:n = true , } \keys_define:nn { NiceMatrix } { NiceMatrixOptions .inherit:n = { NiceMatrix / Global } , NiceMatrixOptions / xdots .inherit:n = NiceMatrix / xdots , NiceMatrixOptions / rules .inherit:n = NiceMatrix / rules , NiceMatrixOptions / notes .inherit:n = NiceMatrix / notes , NiceMatrixOptions / delimiters .inherit:n = NiceMatrix / delimiters , NiceMatrixOptions / sub-matrix .inherit:n = NiceMatrix / sub-matrix , SubMatrix / rules .inherit:n = NiceMatrix / rules , CodeAfter / xdots .inherit:n = NiceMatrix / xdots , NiceMatrix .inherit:n = { NiceMatrix / Global , NiceMatrix / Env , } , NiceMatrix / xdots .inherit:n = NiceMatrix / xdots , NiceMatrix / rules .inherit:n = NiceMatrix / rules , NiceMatrix / delimiters .inherit:n = NiceMatrix / delimiters , NiceTabular .inherit:n = { NiceMatrix / Global , NiceMatrix / Env } , NiceTabular / xdots .inherit:n = NiceMatrix / xdots , NiceTabular / rules .inherit:n = NiceMatrix / rules , NiceTabular / delimiters .inherit:n = NiceMatrix / delimiters , NiceArray .inherit:n = { NiceMatrix / Global , NiceMatrix / Env , } , NiceArray / xdots .inherit:n = NiceMatrix / xdots , NiceArray / rules .inherit:n = NiceMatrix / rules , NiceArray / delimiters .inherit:n = NiceMatrix / delimiters , pNiceArray .inherit:n = { NiceMatrix / Global , NiceMatrix / Env , } , pNiceArray / xdots .inherit:n = NiceMatrix / xdots , pNiceArray / rules .inherit:n = NiceMatrix / rules , pNiceArray / delimiters .inherit:n = NiceMatrix / delimiters , } \keys_define:nn { NiceMatrix / NiceMatrixOptions } { width .code:n = \dim_set:Nn \l__nicematrix_width_dim { #1 } , width .value_required:n = true , last-col .code:n = \tl_if_empty:nF { #1 } { \__nicematrix_error:n { last-col~non~empty~for~NiceMatrixOptions } } \int_zero:N \l__nicematrix_last_col_int , small .bool_set:N = \l__nicematrix_small_bool , small .value_forbidden:n = true , renew-matrix .code:n = \__nicematrix_renew_matrix: , renew-matrix .value_forbidden:n = true , exterior-arraycolsep .bool_set:N = \l__nicematrix_exterior_arraycolsep_bool , columns-width .code:n = \tl_if_eq:nnTF { #1 } { auto } { \__nicematrix_error:n { Option~auto~for~columns-width } } { \dim_set:Nn \l__nicematrix_columns_width_dim { #1 } } , allow-duplicate-names .code:n = \__nicematrix_msg_redirect_name:nn { Duplicate~name } { none } , allow-duplicate-names .value_forbidden:n = true , notes .code:n = \keys_set:nn { NiceMatrix / notes } { #1 } , notes .value_required:n = true , sub-matrix .code:n = \keys_set:nn { NiceMatrix / sub-matrix } { #1 } , sub-matrix .value_required:n = true , matrix / columns-type .code:n = \__nicematrix_set_preamble:Nn \l__nicematrix_columns_type_tl { #1 }, matrix / columns-type .value_required:n = true , caption-above .bool_set:N = \l__nicematrix_caption_above_bool , caption-above .default:n = true , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~NiceMatrixOptions } } \NewDocumentCommand \NiceMatrixOptions { m } { \keys_set:nn { NiceMatrix / NiceMatrixOptions } { #1 } } \keys_define:nn { NiceMatrix / NiceMatrix } { last-col .code:n = \tl_if_empty:nTF {#1} { \bool_set_true:N \l__nicematrix_last_col_without_value_bool \int_set:Nn \l__nicematrix_last_col_int { -1 } } { \int_set:Nn \l__nicematrix_last_col_int { #1 } } , columns-type .code:n = \__nicematrix_set_preamble:Nn \l__nicematrix_columns_type_tl { #1 } , columns-type .value_required:n = true , l .meta:n = { columns-type = l } , r .meta:n = { columns-type = r } , small .bool_set:N = \l__nicematrix_small_bool , small .value_forbidden:n = true , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~NiceMatrix } } \keys_define:nn { NiceMatrix / NiceArray } { small .bool_set:N = \l__nicematrix_small_bool , small .value_forbidden:n = true , last-col .code:n = \tl_if_empty:nF { #1 } { \__nicematrix_error:n { last-col~non~empty~for~NiceArray } } \int_zero:N \l__nicematrix_last_col_int , notes / para .bool_set:N = \l__nicematrix_notes_para_bool , notes / para .default:n = true , notes / bottomrule .bool_set:N = \l__nicematrix_notes_bottomrule_bool , notes / bottomrule .default:n = true , tabularnote .tl_set:N = \l__nicematrix_tabularnote_tl , tabularnote .value_required:n = true , r .code:n = \__nicematrix_error:n { r~or~l~with~preamble } , l .code:n = \__nicematrix_error:n { r~or~l~with~preamble } , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~NiceArray } } \keys_define:nn { NiceMatrix / pNiceArray } { first-col .code:n = \int_zero:N \l__nicematrix_first_col_int , last-col .code:n = \tl_if_empty:nF {#1} { \__nicematrix_error:n { last-col~non~empty~for~NiceArray } } \int_zero:N \l__nicematrix_last_col_int , first-row .code:n = \int_zero:N \l__nicematrix_first_row_int , small .bool_set:N = \l__nicematrix_small_bool , small .value_forbidden:n = true , r .code:n = \__nicematrix_error:n { r~or~l~with~preamble } , l .code:n = \__nicematrix_error:n { r~or~l~with~preamble } , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~NiceMatrix } } \keys_define:nn { NiceMatrix / NiceTabular } { width .code:n = \dim_set:Nn \l__nicematrix_width_dim { #1 } \bool_set_true:N \l__nicematrix_width_used_bool , width .value_required:n = true , notes / para .bool_set:N = \l__nicematrix_notes_para_bool , notes / para .default:n = true , notes / bottomrule .bool_set:N = \l__nicematrix_notes_bottomrule_bool , notes / bottomrule .default:n = true , tabularnote .tl_set:N = \l__nicematrix_tabularnote_tl , tabularnote .value_required:n = true , caption .tl_set:N = \l__nicematrix_caption_tl , caption .value_required:n = true , short-caption .tl_set:N = \l__nicematrix_short_caption_tl , short-caption .value_required:n = true , label .tl_set:N = \l__nicematrix_label_tl , label .value_required:n = true , last-col .code:n = \tl_if_empty:nF {#1} { \__nicematrix_error:n { last-col~non~empty~for~NiceArray } } \int_zero:N \l__nicematrix_last_col_int , r .code:n = \__nicematrix_error:n { r~or~l~with~preamble } , l .code:n = \__nicematrix_error:n { r~or~l~with~preamble } , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~NiceTabular } } \cs_new_protected:Npn \__nicematrix_cell_begin:w { \tl_gclear:N \g__nicematrix_cell_after_hook_tl \cs_set_eq:NN \CodeAfter \__nicematrix_CodeAfter_i: \int_gincr:N \c@jCol \int_compare:nNnT \c@jCol = 1 { \int_compare:nNnT \l__nicematrix_first_col_int = 1 \__nicematrix_begin_of_row: } \hbox_set:Nw \l__nicematrix_cell_box \bool_if:NF \l__nicematrix_NiceTabular_bool { \c_math_toggle_token \bool_if:NT \l__nicematrix_small_bool \scriptstyle } \color { nicematrix } \g__nicematrix_row_style_tl \int_compare:nNnTF \c@iRow = 0 { \int_compare:nNnT \c@jCol > 0 { \l__nicematrix_code_for_first_row_tl \xglobal \colorlet { nicematrix-first-row } { . } } } { \int_compare:nNnT \c@iRow = \l__nicematrix_last_row_int { \l__nicematrix_code_for_last_row_tl \xglobal \colorlet { nicematrix-last-row } { . } } } } \cs_new_protected:Npn \__nicematrix_begin_of_row: { \int_gincr:N \c@iRow \dim_gset_eq:NN \g__nicematrix_dp_ante_last_row_dim \g__nicematrix_dp_last_row_dim \dim_gset:Nn \g__nicematrix_dp_last_row_dim { \box_dp:N \@arstrutbox } \dim_gset:Nn \g__nicematrix_ht_last_row_dim { \box_ht:N \@arstrutbox } \pgfpicture \pgfrememberpicturepositiononpagetrue \pgfcoordinate { \__nicematrix_env: - row - \int_use:N \c@iRow - base } { \pgfpoint \c_zero_dim { 0.5 \arrayrulewidth } } \str_if_empty:NF \l__nicematrix_name_str { \pgfnodealias { \l__nicematrix_name_str - row - \int_use:N \c@iRow - base } { \__nicematrix_env: - row - \int_use:N \c@iRow - base } } \endpgfpicture } \cs_new_protected:Npn \__nicematrix_update_for_first_and_last_row: { \int_compare:nNnTF \c@iRow = 0 { \dim_gset:Nn \g__nicematrix_dp_row_zero_dim { \dim_max:nn \g__nicematrix_dp_row_zero_dim { \box_dp:N \l__nicematrix_cell_box } } \dim_gset:Nn \g__nicematrix_ht_row_zero_dim { \dim_max:nn \g__nicematrix_ht_row_zero_dim { \box_ht:N \l__nicematrix_cell_box } } } { \int_compare:nNnT \c@iRow = 1 { \dim_gset:Nn \g__nicematrix_ht_row_one_dim { \dim_max:nn \g__nicematrix_ht_row_one_dim { \box_ht:N \l__nicematrix_cell_box } } } } } \cs_new_protected:Npn \__nicematrix_rotate_cell_box: { \box_rotate:Nn \l__nicematrix_cell_box { 90 } \int_compare:nNnT \c@iRow = \l__nicematrix_last_row_int { \vbox_set_top:Nn \l__nicematrix_cell_box { \vbox_to_zero:n { } \skip_vertical:n { - \box_ht:N \@arstrutbox + 0.8 ex } \box_use:N \l__nicematrix_cell_box } } \bool_gset_false:N \g__nicematrix_rotate_bool } \cs_new_protected:Npn \__nicematrix_adjust_size_box: { \dim_compare:nNnT \g__nicematrix_blocks_wd_dim > \c_zero_dim { \box_set_wd:Nn \l__nicematrix_cell_box { \dim_max:nn { \box_wd:N \l__nicematrix_cell_box } \g__nicematrix_blocks_wd_dim } \dim_gzero:N \g__nicematrix_blocks_wd_dim } \dim_compare:nNnT \g__nicematrix_blocks_dp_dim > \c_zero_dim { \box_set_dp:Nn \l__nicematrix_cell_box { \dim_max:nn { \box_dp:N \l__nicematrix_cell_box } \g__nicematrix_blocks_dp_dim } \dim_gzero:N \g__nicematrix_blocks_dp_dim } \dim_compare:nNnT \g__nicematrix_blocks_ht_dim > \c_zero_dim { \box_set_ht:Nn \l__nicematrix_cell_box { \dim_max:nn { \box_ht:N \l__nicematrix_cell_box } \g__nicematrix_blocks_ht_dim } \dim_gzero:N \g__nicematrix_blocks_ht_dim } } \cs_new_protected:Npn \__nicematrix_cell_end: { \__nicematrix_math_toggle_token: \hbox_set_end: \g__nicematrix_cell_after_hook_tl \bool_if:NT \g__nicematrix_rotate_bool \__nicematrix_rotate_cell_box: \__nicematrix_adjust_size_box: \box_set_ht:Nn \l__nicematrix_cell_box { \box_ht:N \l__nicematrix_cell_box + \l__nicematrix_cell_space_top_limit_dim } \box_set_dp:Nn \l__nicematrix_cell_box { \box_dp:N \l__nicematrix_cell_box + \l__nicematrix_cell_space_bottom_limit_dim } \dim_gset:Nn \g__nicematrix_max_cell_width_dim { \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:N \l__nicematrix_cell_box } { \bool_lazy_or:nnTF \g__nicematrix_not_empty_cell_bool { \dim_compare_p:nNn { \box_wd:N \l__nicematrix_cell_box } > \c_zero_dim } \__nicematrix_node_for_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 } \cs_new_protected:Npn \__nicematrix_node_for_cell: { \pgfpicture \pgfsetbaseline \c_zero_dim \pgfrememberpicturepositiononpagetrue \pgfset { inner~sep = \c_zero_dim , minimum~width = \c_zero_dim } \pgfnode { rectangle } { base } { \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 { \pgfnodealias { \l__nicematrix_name_str - \int_use:N \c@iRow - \int_use:N \c@jCol } { \__nicematrix_env: - \int_use:N \c@iRow - \int_use:N \c@jCol } } \endpgfpicture } \cs_new_protected:Npn \__nicematrix_patch_node_for_cell:n #1 { \cs_new_protected:Npn \__nicematrix_patch_node_for_cell: { \hbox_set:Nn \l__nicematrix_cell_box { \box_move_up:nn { \box_ht:N \l__nicematrix_cell_box} \hbox_overlap_left:n { \pgfsys@markposition { \__nicematrix_env: - \int_use:N \c@iRow - \int_use:N \c@jCol - NW } #1 } \box_use:N \l__nicematrix_cell_box \box_move_down:nn { \box_dp:N \l__nicematrix_cell_box } \hbox_overlap_left:n { \pgfsys@markposition { \__nicematrix_env: - \int_use:N \c@iRow - \int_use:N \c@jCol - SE } #1 } } } } \bool_lazy_or:nnTF \sys_if_engine_xetex_p: \sys_if_output_dvi_p: { \__nicematrix_patch_node_for_cell:n { \skip_horizontal:n { 0.5 \box_wd:N \l__nicematrix_cell_box } } } { \__nicematrix_patch_node_for_cell:n { } } \cs_new_protected:Npn \__nicematrix_instruction_of_type:nnn #1 #2 #3 { \bool_if:nTF { #1 } \tl_gput_left:cx \tl_gput_right:cx { g__nicematrix_ #2 _ lines _ tl } { \use:c { __nicematrix _ draw _ #2 : nnn } { \int_use:N \c@iRow } { \int_use:N \c@jCol } { \exp_not:n { #3 } } } } \cs_new_protected:Npn \__nicematrix_array:n { \bool_if:NTF \l__nicematrix_NiceTabular_bool { \dim_set_eq:NN \col@sep \tabcolsep } { \dim_set_eq:NN \col@sep \arraycolsep } \dim_compare:nNnTF \l__nicematrix_tabular_width_dim = \c_zero_dim { \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 ] } \cs_generate_variant:Nn \__nicematrix_array:n { V } \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 { \int_gset_eq:NN \g__nicematrix_last_row_node_int \c@iRow \__nicematrix_create_row_node_i: } } \cs_new_protected:Npn \__nicematrix_create_row_node_i: { \hbox { \bool_if:NT \l__nicematrix_code_before_bool { \vtop { \skip_vertical:N 0.5\arrayrulewidth \pgfsys@markposition { \__nicematrix_env: - row - \int_eval:n { \c@iRow + 1 } } \skip_vertical:N -0.5\arrayrulewidth } } \pgfpicture \pgfrememberpicturepositiononpagetrue \pgfcoordinate { \__nicematrix_env: - row - \int_eval:n { \c@iRow + 1 } } { \pgfpoint \c_zero_dim { - 0.5 \arrayrulewidth } } \str_if_empty:NF \l__nicematrix_name_str { \pgfnodealias { \l__nicematrix_name_str - row - \int_eval:n { \c@iRow + 1 } } { \__nicematrix_env: - row - \int_eval:n { \c@iRow + 1 } } } \endpgfpicture } } \cs_new:Npn \__nicematrix_everycr: { \noalign { \__nicematrix_everycr_i: } } \cs_new_protected:Npn \__nicematrix_everycr_i: { \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 { \__nicematrix_create_row_node: \tl_if_empty:NF \l__nicematrix_hlines_clist { \tl_if_eq:NnF \l__nicematrix_hlines_clist { all } { \exp_args:NNx \clist_if_in:NnT \l__nicematrix_hlines_clist { \int_eval:n { \c@iRow + 1 } } } { \int_compare:nNnT \c@iRow > { -1 } { \int_compare:nNnF \c@iRow = \l__nicematrix_last_row_int { \hrule height \arrayrulewidth width \c_zero_dim } } } } } } \cs_set_protected:Npn \__nicematrix_newcolumntype #1 { \cs_set:cpn { NC @ find @ #1 } ##1 #1 { \NC@ { ##1 } } \peek_meaning:NTF [ { \newcol@ #1 } { \newcol@ #1 [ 0 ] } } \cs_set_protected:Npn \__nicematrix_renew_dots: { \cs_set_eq:NN \ldots \__nicematrix_Ldots \cs_set_eq:NN \cdots \__nicematrix_Cdots \cs_set_eq:NN \vdots \__nicematrix_Vdots \cs_set_eq:NN \ddots \__nicematrix_Ddots \cs_set_eq:NN \iddots \__nicematrix_Iddots \cs_set_eq:NN \dots \__nicematrix_Ldots \cs_set_eq:NN \hdotsfor \__nicematrix_Hdotsfor: } \cs_new_protected:Npn \__nicematrix_colortbl_like: { \cs_set_eq:NN \cellcolor \__nicematrix_cellcolor_tabular \cs_set_eq:NN \rowcolor \__nicematrix_rowcolor_tabular \cs_set_eq:NN \columncolor \__nicematrix_columncolor_preamble } \cs_new_protected:Npn \__nicematrix_pre_array_ii: { \xglobal \colorlet { nicematrix } { . } \int_gzero:N \g__nicematrix_total_X_weight_int \__nicematrix_expand_clist:N \l__nicematrix_hlines_clist \__nicematrix_expand_clist:N \l__nicematrix_vlines_clist \bool_if:NT \c__nicematrix_booktabs_loaded_bool { \tl_put_left:Nn \@BTnormal \__nicematrix_create_row_node_i: } % modified in 6.10a \box_clear_new:N \l__nicematrix_cell_box \normalbaselines \bool_if:NT \l__nicematrix_small_bool { \cs_set_nopar:Npn \arraystretch { 0.47 } \dim_set:Nn \arraycolsep { 1.45 pt } } \bool_if:NT \g__nicematrix_recreate_cell_nodes_bool { \tl_put_right:Nn \__nicematrix_begin_of_row: { \pgfsys@markposition { \__nicematrix_env: - row - \int_use:N \c@iRow - base } } } \cs_set_nopar:Npn \ialign { \bool_if:NTF \l__nicematrix_colortbl_loaded_bool { \CT@everycr { \noalign { \cs_gset_eq:NN \CT@row@color \prg_do_nothing: } \__nicematrix_everycr: } } { \everycr { \__nicematrix_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 } \cs_set_eq:NN \__nicematrix_old_ldots \ldots \cs_set_eq:NN \__nicematrix_old_cdots \cdots \cs_set_eq:NN \__nicematrix_old_vdots \vdots \cs_set_eq:NN \__nicematrix_old_ddots \ddots \cs_set_eq:NN \__nicematrix_old_iddots \iddots \bool_if:NTF \l__nicematrix_standard_cline_bool { \cs_set_eq:NN \cline \__nicematrix_standard_cline } { \cs_set_eq:NN \cline \__nicematrix_cline } \cs_set_eq:NN \Ldots \__nicematrix_Ldots \cs_set_eq:NN \Cdots \__nicematrix_Cdots \cs_set_eq:NN \Vdots \__nicematrix_Vdots \cs_set_eq:NN \Ddots \__nicematrix_Ddots \cs_set_eq:NN \Iddots \__nicematrix_Iddots \cs_set_eq:NN \Hline \__nicematrix_Hline: \cs_set_eq:NN \Hspace \__nicematrix_Hspace: \cs_set_eq:NN \Hdotsfor \__nicematrix_Hdotsfor: \cs_set_eq:NN \Vdotsfor \__nicematrix_Vdotsfor: \cs_set_eq:NN \Block \__nicematrix_Block: \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: \cs_set_eq:NN \diagbox \__nicematrix_diagbox:nn \cs_set_eq:NN \NotEmpty \__nicematrix_NotEmpty: \cs_set_eq:NN \RowStyle \__nicematrix_RowStyle:n \seq_map_inline:Nn \l__nicematrix_custom_line_commands_seq { \cs_set_eq:cc { ##1 } { nicematrix - ##1 } } \bool_if:NT \l__nicematrix_colortbl_like_bool \__nicematrix_colortbl_like: \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 } { . } { \cs_set_eq:NN \multicolumn \__nicematrix_old_multicolumn } \tl_if_exist:NT \l__nicematrix_note_in_caption_tl { \tl_if_empty:NF \l__nicematrix_note_in_caption_tl { \int_set_eq:NN \l__nicematrix_note_in_caption_int { \l__nicematrix_note_in_caption_tl } \int_gset:Nn \c@tabularnote { \l__nicematrix_note_in_caption_tl } } } \seq_gclear:N \g__nicematrix_multicolumn_cells_seq \seq_gclear:N \g__nicematrix_multicolumn_sizes_seq \int_gset:Nn \c@iRow { \l__nicematrix_first_row_int - 1 } \int_gzero_new:N \g__nicematrix_row_total_int \int_gzero_new:N \g__nicematrix_col_total_int \cs_set_eq:NN \@ifnextchar \new@ifnextchar \__nicematrix_renew_NC@rewrite@S: \bool_gset_false:N \g__nicematrix_last_col_found_bool \tl_gclear_new:N \g__nicematrix_Cdots_lines_tl \tl_gclear_new:N \g__nicematrix_Ldots_lines_tl \tl_gclear_new:N \g__nicematrix_Vdots_lines_tl \tl_gclear_new:N \g__nicematrix_Ddots_lines_tl \tl_gclear_new:N \g__nicematrix_Iddots_lines_tl \tl_gclear_new:N \g__nicematrix_HVdotsfor_lines_tl \tl_gclear_new:N \g_nicematrix_code_before_tl } \cs_new_protected:Npn \__nicematrix_pre_array: { \cs_if_exist:NT \theiRow { \int_set_eq:NN \l__nicematrix_old_iRow_int \c@iRow } \int_gzero_new:N \c@iRow \cs_if_exist:NT \thejCol { \int_set_eq:NN \l__nicematrix_old_jCol_int \c@jCol } \int_gzero_new:N \c@jCol \int_compare:nNnT \l__nicematrix_last_row_int = { -1 } { \bool_set_true:N \l__nicematrix_last_row_without_value_bool \bool_if:NT \g__nicematrix_aux_found_bool { \int_set:Nn \l__nicematrix_last_row_int { \seq_item:Nn \g__nicematrix_size_seq 3 } } } \int_compare:nNnT \l__nicematrix_last_col_int = { -1 } { \bool_if:NT \g__nicematrix_aux_found_bool { \int_set:Nn \l__nicematrix_last_col_int { \seq_item:Nn \g__nicematrix_size_seq 6 } } } \int_compare:nNnT \l__nicematrix_last_row_int > { -2 } { \tl_put_right:Nn \__nicematrix_update_for_first_and_last_row: { \dim_gset:Nn \g__nicematrix_ht_last_row_dim { \dim_max:nn \g__nicematrix_ht_last_row_dim { \box_ht:N \l__nicematrix_cell_box } } \dim_gset:Nn \g__nicematrix_dp_last_row_dim { \dim_max:nn \g__nicematrix_dp_last_row_dim { \box_dp:N \l__nicematrix_cell_box } } } } \seq_gclear:N \g__nicematrix_cols_vlism_seq \seq_gclear:N \g__nicematrix_submatrix_seq \bool_if:NT \l__nicematrix_code_before_bool \__nicematrix_exec_code_before: \seq_gclear:N \g__nicematrix_pos_of_blocks_seq \seq_gclear_new:N \g__nicematrix_multicolumn_cells_seq \seq_gclear_new:N \g__nicematrix_multicolumn_sizes_seq \int_gset:Nn \g__nicematrix_last_row_node_int { -1 } \__nicematrix_pre_array_ii: \box_clear_new:N \l__nicematrix_the_array_box \dim_zero_new:N \l__nicematrix_left_delim_dim \dim_zero_new:N \l__nicematrix_right_delim_dim \bool_if:NTF \g__nicematrix_NiceArray_bool { \dim_gset:Nn \l__nicematrix_left_delim_dim { 2 \arraycolsep } \dim_gset:Nn \l__nicematrix_right_delim_dim { 2 \arraycolsep } } { \hbox_set:Nn \l_tmpa_box { $ \bBigg@ 5 \g__nicematrix_left_delim_tl $ } \dim_set:Nn \l__nicematrix_left_delim_dim { \box_wd:N \l_tmpa_box } \hbox_set:Nn \l_tmpa_box { $ \bBigg@ 5 \g__nicematrix_right_delim_tl $ } \dim_set:Nn \l__nicematrix_right_delim_dim { \box_wd:N \l_tmpa_box } } \hbox_set:Nw \l__nicematrix_the_array_box \skip_horizontal:N \l__nicematrix_left_margin_dim \skip_horizontal:N \l__nicematrix_extra_left_margin_dim \c_math_toggle_token \bool_if:NTF \l__nicematrix_light_syntax_bool { \use:c { __nicematrix-light-syntax } } { \use:c { __nicematrix-normal-syntax } } } \cs_new_protected_nopar:Npn \__nicematrix_CodeBefore_Body:w #1 \Body { \tl_put_right:Nn \l__nicematrix_code_before_tl { #1 } \bool_set_true:N \l__nicematrix_code_before_bool \__nicematrix_pre_array: } \cs_new_protected:Npn \__nicematrix_pre_code_before: { \int_set:Nn \c@iRow { \seq_item:Nn \g__nicematrix_size_seq 2 } \int_set:Nn \c@jCol { \seq_item:Nn \g__nicematrix_size_seq 5 } \int_set_eq:NN \g__nicematrix_row_total_int { \seq_item:Nn \g__nicematrix_size_seq 3 } \int_set_eq:NN \g__nicematrix_col_total_int { \seq_item:Nn \g__nicematrix_size_seq 6 } \pgfsys@markposition { \__nicematrix_env: - position } \pgfsys@getposition { \__nicematrix_env: - position } \__nicematrix_picture_position: \pgfpicture \pgf@relevantforpicturesizefalse \int_step_inline:nnn \l__nicematrix_first_row_int { \g__nicematrix_row_total_int + 1 } { \pgfsys@getposition { \__nicematrix_env: - row - ##1 } \__nicematrix_node_position: \pgfcoordinate { \__nicematrix_env: - row - ##1 } { \pgfpointdiff \__nicematrix_picture_position: \__nicematrix_node_position: } } \int_step_inline:nnn \l__nicematrix_first_col_int { \g__nicematrix_col_total_int + 1 } { \pgfsys@getposition { \__nicematrix_env: - col - ##1 } \__nicematrix_node_position: \pgfcoordinate { \__nicematrix_env: - col - ##1 } { \pgfpointdiff \__nicematrix_picture_position: \__nicematrix_node_position: } } \__nicematrix_create_diag_nodes: \bool_if:NT \g__nicematrix_recreate_cell_nodes_bool \__nicematrix_recreate_cell_nodes: \endpgfpicture \__nicematrix_create_blocks_nodes: \bool_if:NT \c__nicematrix_tikz_loaded_bool { \tikzset { every~picture / .style = { overlay , name~prefix = \__nicematrix_env: - } } } \cs_set_eq:NN \cellcolor \__nicematrix_cellcolor \cs_set_eq:NN \rectanglecolor \__nicematrix_rectanglecolor \cs_set_eq:NN \roundedrectanglecolor \__nicematrix_roundedrectanglecolor \cs_set_eq:NN \rowcolor \__nicematrix_rowcolor \cs_set_eq:NN \rowcolors \__nicematrix_rowcolors \cs_set_eq:NN \rowlistcolors \__nicematrix_rowlistcolors \cs_set_eq:NN \arraycolor \__nicematrix_arraycolor \cs_set_eq:NN \columncolor \__nicematrix_columncolor \cs_set_eq:NN \chessboardcolors \__nicematrix_chessboardcolors \cs_set_eq:NN \SubMatrix \__nicematrix_SubMatrix_in_code_before \cs_set_eq:NN \ShowCellNames \__nicematrix_ShowCellNames } \cs_new_protected:Npn \__nicematrix_exec_code_before: { \seq_gclear_new:N \g__nicematrix_colors_seq \bool_gset_false:N \g__nicematrix_recreate_cell_nodes_bool \group_begin: \bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token \exp_last_unbraced:NV \__nicematrix_CodeBefore_keys: \l__nicematrix_code_before_tl \q_stop \__nicematrix_actually_color: \bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token \group_end: \bool_if:NT \g__nicematrix_recreate_cell_nodes_bool { \tl_put_left:Nn \__nicematrix_node_for_cell: \__nicematrix_patch_node_for_cell: } } \keys_define:nn { NiceMatrix / CodeBefore } { create-cell-nodes .bool_gset:N = \g__nicematrix_recreate_cell_nodes_bool , create-cell-nodes .default:n = true , sub-matrix .code:n = \keys_set:nn { NiceMatrix / sub-matrix } { #1 } , sub-matrix .value_required:n = true , delimiters / color .tl_set:N = \l__nicematrix_delimiters_color_tl , delimiters / color .value_required:n = true , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~CodeAfter } } \NewDocumentCommand \__nicematrix_CodeBefore_keys: { O { } } { \keys_set:nn { NiceMatrix / CodeBefore } { #1 } \__nicematrix_CodeBefore:w } \cs_new_protected:Npn \__nicematrix_CodeBefore:w #1 \q_stop { \bool_if:NT \g__nicematrix_aux_found_bool { \__nicematrix_pre_code_before: #1 } } \cs_new_protected:Npn \__nicematrix_recreate_cell_nodes: { \int_step_inline:nnn \l__nicematrix_first_row_int \g__nicematrix_row_total_int { \pgfsys@getposition { \__nicematrix_env: - ##1 - base } \__nicematrix_node_position: \pgfcoordinate { \__nicematrix_env: - row - ##1 - base } { \pgfpointdiff \__nicematrix_picture_position: \__nicematrix_node_position: } \int_step_inline:nnn \l__nicematrix_first_col_int \g__nicematrix_col_total_int { \cs_if_exist:cT { pgf @ sys @ pdf @ mark @ pos @ \__nicematrix_env: - ##1 - ####1 - NW } { \pgfsys@getposition { \__nicematrix_env: - ##1 - ####1 - NW } \__nicematrix_node_position: \pgfsys@getposition { \__nicematrix_env: - ##1 - ####1 - SE } \__nicematrix_node_position_i: \__nicematrix_pgf_rect_node:nnn { \__nicematrix_env: - ##1 - ####1 } { \pgfpointdiff \__nicematrix_picture_position: \__nicematrix_node_position: } { \pgfpointdiff \__nicematrix_picture_position: \__nicematrix_node_position_i: } } } } \int_step_inline:nn \c@iRow { \pgfnodealias { \__nicematrix_env: - ##1 - last } { \__nicematrix_env: - ##1 - \int_use:N \c@jCol } } \int_step_inline:nn \c@jCol { \pgfnodealias { \__nicematrix_env: - last - ##1 } { \__nicematrix_env: - \int_use:N \c@iRow - ##1 } } \__nicematrix_create_extra_nodes: } \cs_new_protected:Npn \__nicematrix_create_blocks_nodes: { \pgfpicture \pgf@relevantforpicturesizefalse \pgfrememberpicturepositiononpagetrue \seq_map_inline:Nn \g__nicematrix_pos_of_blocks_seq { \__nicematrix_create_one_block_node:nnnnn ##1 } \endpgfpicture } \cs_new_protected:Npn \__nicematrix_create_one_block_node:nnnnn #1 #2 #3 #4 #5 { \tl_if_empty:nF { #5 } { \__nicematrix_qpoint:n { col - #2 } \dim_set_eq:NN \l_tmpa_dim \pgf@x \__nicematrix_qpoint:n { #1 } \dim_set_eq:NN \l_tmpb_dim \pgf@y \__nicematrix_qpoint:n { col - \int_eval:n { #4 + 1 } } \dim_set_eq:NN \l__nicematrix_tmpc_dim \pgf@x \__nicematrix_qpoint:n { \int_eval:n { #3 + 1 } } \dim_set_eq:NN \l__nicematrix_tmpd_dim \pgf@y \__nicematrix_pgf_rect_node:nnnnn { \__nicematrix_env: - #5 } { \dim_use:N \l_tmpa_dim } { \dim_use:N \l_tmpb_dim } { \dim_use:N \l__nicematrix_tmpc_dim } { \dim_use:N \l__nicematrix_tmpd_dim } } } \cs_new_protected:Npn \__nicematrix_patch_for_revtex: { \cs_set_eq:NN \@addamp \@addamp@LaTeX \cs_set_eq:NN \insert@column \insert@column@array \cs_set_eq:NN \@classx \@classx@array \cs_set_eq:NN \@xarraycr \@xarraycr@array \cs_set_eq:NN \@arraycr \@arraycr@array \cs_set_eq:NN \@xargarraycr \@xargarraycr@array \cs_set_eq:NN \array \array@array \cs_set_eq:NN \@array \@array@array \cs_set_eq:NN \@tabular \@tabular@array \cs_set_eq:NN \@mkpream \@mkpream@array \cs_set_eq:NN \endarray \endarray@array \cs_set:Npn \@tabarray { \@ifnextchar [ { \@array } { \@array [ c ] } } \cs_set:Npn \endtabular { \endarray $\egroup} % $ } \NewDocumentEnvironment { NiceArrayWithDelims } { m m O { } m ! O { } t \CodeBefore } { \bool_if:NT \c__nicematrix_revtex_bool \__nicematrix_patch_for_revtex: \__nicematrix_provide_pgfsyspdfmark: \bool_if:NT \c__nicematrix_footnote_bool \savenotes \bgroup \tl_gset:Nn \g__nicematrix_left_delim_tl { #1 } \tl_gset:Nn \g__nicematrix_right_delim_tl { #2 } \tl_gset:Nn \g__nicematrix_preamble_tl { #4 } \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 \bool_gset_false:N \g__nicematrix_row_of_col_done_bool \str_if_empty:NT \g__nicematrix_name_env_str { \str_gset:Nn \g__nicematrix_name_env_str { NiceArrayWithDelims } } \bool_if:NTF \l__nicematrix_NiceTabular_bool \mode_leave_vertical: \__nicematrix_test_if_math_mode: \bool_if:NT \l__nicematrix_in_env_bool { \__nicematrix_fatal:n { Yet~in~env } } \bool_set_true:N \l__nicematrix_in_env_bool \cs_gset_eq:NN \__nicematrix_old_CT@arc@ \CT@arc@ \cs_if_exist:NT \tikz@library@external@loaded { \tikzexternaldisable \cs_if_exist:NT \ifstandalone { \tikzset { external / optimize = false } } } \int_gincr:N \g__nicematrix_env_int \bool_if:NF \l__nicematrix_block_auto_columns_width_bool { \dim_gzero_new:N \g__nicematrix_max_cell_width_dim } \seq_gclear:N \g__nicematrix_blocks_seq \seq_gclear:N \g__nicematrix_pos_of_blocks_seq \seq_gclear:N \g__nicematrix_pos_of_stroken_blocks_seq \seq_gclear:N \g__nicematrix_pos_of_xdots_seq \tl_gclear_new:N \g__nicematrix_code_before_tl \tl_gclear:N \g__nicematrix_row_style_tl \bool_gset_false:N \g__nicematrix_aux_found_bool \tl_if_exist:cT { c__nicematrix _ \int_use:N \g__nicematrix_env_int _ tl } { \bool_gset_true:N \g__nicematrix_aux_found_bool \use:c { c__nicematrix _ \int_use:N \g__nicematrix_env_int _ tl } } \tl_gclear:N \g__nicematrix_aux_tl \tl_if_empty:NF \g__nicematrix_code_before_tl { \bool_set_true:N \l__nicematrix_code_before_bool \tl_put_right:NV \l__nicematrix_code_before_tl \g__nicematrix_code_before_tl } \bool_if:NTF \g__nicematrix_NiceArray_bool { \keys_set:nn { NiceMatrix / NiceArray } } { \keys_set:nn { NiceMatrix / pNiceArray } } { #3 , #5 } \__nicematrix_set_CT@arc@:V \l__nicematrix_rules_color_tl \IfBooleanTF { #6 } \__nicematrix_CodeBefore_Body:w \__nicematrix_pre_array: } { \bool_if:NTF \l__nicematrix_light_syntax_bool { \use:c { end __nicematrix-light-syntax } } { \use:c { end __nicematrix-normal-syntax } } \c_math_toggle_token \skip_horizontal:N \l__nicematrix_right_margin_dim \skip_horizontal:N \l__nicematrix_extra_right_margin_dim \hbox_set_end: \bool_if:NT \l__nicematrix_width_used_bool { \int_compare:nNnT \g__nicematrix_total_X_weight_int = 0 { \__nicematrix_error_or_warning:n { width~without~X~columns } } } \int_compare:nNnT \g__nicematrix_total_X_weight_int > 0 { \tl_gput_right:Nx \g__nicematrix_aux_tl { \bool_set_true:N \l__nicematrix_X_columns_aux_bool \dim_set:Nn \l__nicematrix_X_columns_dim { \dim_compare:nNnTF { \dim_abs:n { \l__nicematrix_width_dim - \box_wd:N \l__nicematrix_the_array_box } } < { 0.001 pt } { \dim_use:N \l__nicematrix_X_columns_dim } { \dim_eval:n { ( \l__nicematrix_width_dim - \box_wd:N \l__nicematrix_the_array_box ) / \int_use:N \g__nicematrix_total_X_weight_int + \l__nicematrix_X_columns_dim } } } } } \int_compare:nNnT \l__nicematrix_last_row_int > { -2 } { \bool_if:NF \l__nicematrix_last_row_without_value_bool { \int_compare:nNnF \l__nicematrix_last_row_int = \c@iRow { \__nicematrix_error:n { Wrong~last~row } \int_gset_eq:NN \l__nicematrix_last_row_int \c@iRow } } } \int_gset_eq:NN \c@jCol \g__nicematrix_col_total_int \bool_if:nTF \g__nicematrix_last_col_found_bool { \int_gdecr:N \c@jCol } { \int_compare:nNnT \l__nicematrix_last_col_int > { -1 } { \__nicematrix_error:n { last~col~not~used } } } \int_gset_eq:NN \g__nicematrix_row_total_int \c@iRow \int_compare:nNnT \l__nicematrix_last_row_int > { -1 } { \int_gdecr:N \c@iRow } \int_compare:nNnT \l__nicematrix_first_col_int = 0 { \skip_horizontal:N \col@sep \skip_horizontal:N \g__nicematrix_width_first_col_dim } \bool_if:NTF \g__nicematrix_NiceArray_bool { \str_case:VnF \l__nicematrix_baseline_tl { b \__nicematrix_use_arraybox_with_notes_b: c \__nicematrix_use_arraybox_with_notes_c: } \__nicematrix_use_arraybox_with_notes: } { \int_compare:nNnTF \l__nicematrix_first_row_int = 0 { \dim_set_eq:NN \l_tmpa_dim \g__nicematrix_dp_row_zero_dim \dim_add:Nn \l_tmpa_dim \g__nicematrix_ht_row_zero_dim } { \dim_zero:N \l_tmpa_dim } \int_compare:nNnTF \l__nicematrix_last_row_int > { -2 } { \dim_set_eq:NN \l_tmpb_dim \g__nicematrix_ht_last_row_dim \dim_add:Nn \l_tmpb_dim \g__nicematrix_dp_last_row_dim } { \dim_zero:N \l_tmpb_dim } \hbox_set:Nn \l_tmpa_box { \c_math_toggle_token \__nicematrix_color:V \l__nicematrix_delimiters_color_tl \exp_after:wN \left \g__nicematrix_left_delim_tl \vcenter { \skip_vertical:n { -\l_tmpa_dim - \arrayrulewidth } \hbox { \bool_if:NTF \l__nicematrix_NiceTabular_bool { \skip_horizontal:N -\tabcolsep } { \skip_horizontal:N -\arraycolsep } \__nicematrix_use_arraybox_with_notes_c: \bool_if:NTF \l__nicematrix_NiceTabular_bool { \skip_horizontal:N -\tabcolsep } { \skip_horizontal:N -\arraycolsep } } \skip_vertical:n { -\l_tmpb_dim + \arrayrulewidth } } \__nicematrix_color:V \l__nicematrix_delimiters_color_tl \exp_after:wN \right \g__nicematrix_right_delim_tl \c_math_toggle_token } \bool_if:NTF \l__nicematrix_delimiters_max_width_bool { \__nicematrix_put_box_in_flow_bis:nn \g__nicematrix_left_delim_tl \g__nicematrix_right_delim_tl } \__nicematrix_put_box_in_flow: } \bool_if:NT \g__nicematrix_last_col_found_bool { \skip_horizontal:N \g__nicematrix_width_last_col_dim \skip_horizontal:N \col@sep } \bool_if:NF \l__nicematrix_Matrix_bool { \int_compare:nNnT \c@jCol < \g__nicematrix_static_num_of_col_int { \__nicematrix_warning_gredirect_none:n { columns~not~used } } } \__nicematrix_after_array: \egroup \iow_now:Nn \@mainaux { \ExplSyntaxOn } \iow_now:Nn \@mainaux { \char_set_catcode_space:n { 32 } } \iow_now:Nx \@mainaux { \tl_gset:cn { c__nicematrix_ \int_use:N \g__nicematrix_env_int _ tl } { \exp_not:V \g__nicematrix_aux_tl } } \iow_now:Nn \@mainaux { \ExplSyntaxOff } \bool_if:NT \c__nicematrix_footnote_bool \endsavenotes } \cs_new_protected:Npn \__nicematrix_transform_preamble: { \group_begin: \bool_if:NF \l__nicematrix_Matrix_bool { \__nicematrix_newcolumntype w [ 2 ] { \__nicematrix_w: { ##1 } { ##2 } } \__nicematrix_newcolumntype W [ 2 ] { \__nicematrix_W: { ##1 } { ##2 } } \cs_if_exist:NT \NC@find@V { \__nicematrix_newcolumntype V { \__nicematrix_V: } } \exp_args:NV \@temptokena \g__nicematrix_preamble_tl \@tempswatrue \@whilesw \if@tempswa \fi { \@tempswafalse \the \NC@list } \int_gzero:N \c@jCol \tl_gclear:N \g__nicematrix_preamble_tl \bool_gset_false:N \g_tmpb_bool \tl_if_eq:NnTF \l__nicematrix_vlines_clist { all } { \tl_gset:Nn \g__nicematrix_preamble_tl { ! { \skip_horizontal:N \arrayrulewidth } } } { \clist_if_in:NnT \l__nicematrix_vlines_clist 1 { \tl_gset:Nn \g__nicematrix_preamble_tl { ! { \skip_horizontal:N \arrayrulewidth } } } } \seq_clear:N \g__nicematrix_cols_vlism_seq \int_zero:N \l_tmpa_int \exp_after:wN \__nicematrix_patch_preamble:n \the \@temptokena \q_stop \int_gset_eq:NN \g__nicematrix_static_num_of_col_int \c@jCol } \bool_if:NT \l__nicematrix_colortbl_like_bool { \regex_replace_all:NnN \c__nicematrix_columncolor_regex { \c { __nicematrix_columncolor_preamble } } \g__nicematrix_preamble_tl } \group_end: \bool_lazy_or:nnT { ! \str_if_eq_p:Vn \g__nicematrix_left_delim_tl { . } } { ! \str_if_eq_p:Vn \g__nicematrix_right_delim_tl { . } } { \bool_gset_false:N \g__nicematrix_NiceArray_bool } \bool_if:NT \g_tmpb_bool { \bool_set_true:N \l__nicematrix_bar_at_end_of_pream_bool } \int_compare:nNnTF \l__nicematrix_first_col_int = 0 { \tl_gput_left:NV \g__nicematrix_preamble_tl \c__nicematrix_preamble_first_col_tl } { \bool_lazy_all:nT { \g__nicematrix_NiceArray_bool { \bool_not_p:n \l__nicematrix_NiceTabular_bool } { \tl_if_empty_p:N \l__nicematrix_vlines_clist } { \bool_not_p:n \l__nicematrix_exterior_arraycolsep_bool } } { \tl_gput_left:Nn \g__nicematrix_preamble_tl { @ { } } } } \int_compare:nNnTF \l__nicematrix_last_col_int > { -1 } { \tl_gput_right:NV \g__nicematrix_preamble_tl \c__nicematrix_preamble_last_col_tl } { \bool_lazy_all:nT { \g__nicematrix_NiceArray_bool { \bool_not_p:n \l__nicematrix_NiceTabular_bool } { \tl_if_empty_p:N \l__nicematrix_vlines_clist } { \bool_not_p:n \l__nicematrix_exterior_arraycolsep_bool } } { \tl_gput_right:Nn \g__nicematrix_preamble_tl { @ { } } } } \dim_compare:nNnT \l__nicematrix_tabular_width_dim = \c_zero_dim { \tl_gput_right:Nn \g__nicematrix_preamble_tl { > { \__nicematrix_error_too_much_cols: } l } } } \cs_new_protected:Npn \__nicematrix_patch_preamble:n #1 { \str_case:nnF { #1 } { c { \__nicematrix_patch_preamble_i:n #1 } l { \__nicematrix_patch_preamble_i:n #1 } r { \__nicematrix_patch_preamble_i:n #1 } > { \__nicematrix_patch_preamble_ii:nn #1 } ! { \__nicematrix_patch_preamble_ii:nn #1 } @ { \__nicematrix_patch_preamble_ii:nn #1 } | { \__nicematrix_patch_preamble_iii:n #1 } p { \__nicematrix_patch_preamble_iv:n #1 } b { \__nicematrix_patch_preamble_iv:n #1 } m { \__nicematrix_patch_preamble_iv:n #1 } \__nicematrix_V: { \__nicematrix_patch_preamble_v:n } V { \__nicematrix_patch_preamble_v:n } \__nicematrix_w: { \__nicematrix_patch_preamble_vi:nnnn { } #1 } \__nicematrix_W: { \__nicematrix_patch_preamble_vi:nnnn { \cs_set_eq:NN \hss \hfil } #1 } \__nicematrix_S: { \__nicematrix_patch_preamble_vii:n } ( { \__nicematrix_patch_preamble_viii:nn #1 } [ { \__nicematrix_patch_preamble_viii:nn #1 } \{ { \__nicematrix_patch_preamble_viii:nn #1 } ) { \__nicematrix_patch_preamble_ix:nn #1 } ] { \__nicematrix_patch_preamble_ix:nn #1 } \} { \__nicematrix_patch_preamble_ix:nn #1 } X { \__nicematrix_patch_preamble_x:n } \__nicematrix_X { \__nicematrix_patch_preamble_x:n } \q_stop { } } { \str_if_eq:nVTF { #1 } \l__nicematrix_letter_vlism_tl { \seq_gput_right:Nx \g__nicematrix_cols_vlism_seq { \int_eval:n { \c@jCol + 1 } } \tl_gput_right:Nx \g__nicematrix_preamble_tl { \exp_not:N ! { \skip_horizontal:N \arrayrulewidth } } \__nicematrix_patch_preamble:n } { \keys_if_exist:nnTF { NiceMatrix / ColumnTypes } { #1 } { \keys_set:nn { NiceMatrix / ColumnTypes } { #1 } \__nicematrix_patch_preamble:n } { \__nicematrix_fatal:nn { unknown~column~type } { #1 } } } } } \cs_new_protected:Npn \__nicematrix_patch_preamble_i:n #1 { \tl_gput_right:Nn \g__nicematrix_preamble_tl { > { \__nicematrix_cell_begin:w \str_set:Nn \l__nicematrix_hpos_cell_str { #1 } } #1 < \__nicematrix_cell_end: } \int_gincr:N \c@jCol \__nicematrix_patch_preamble_xi:n } \cs_new_protected:Npn \__nicematrix_patch_preamble_ii:nn #1 #2 { \tl_gput_right:Nn \g__nicematrix_preamble_tl { #1 { #2 } } \__nicematrix_patch_preamble:n } \cs_new_protected:Npn \__nicematrix_patch_preamble_iii:n #1 { \int_incr:N \l_tmpa_int \__nicematrix_patch_preamble_iii_i:n } \cs_new_protected:Npn \__nicematrix_patch_preamble_iii_i:n #1 { \str_if_eq:nnTF { #1 } | { \__nicematrix_patch_preamble_iii:n | } { \tl_gput_right:Nx \g__nicematrix_preamble_tl { \exp_not:N ! { \skip_horizontal:n { \dim_eval:n { \arrayrulewidth * \l_tmpa_int + \doublerulesep * ( \l_tmpa_int - 1) } } } } \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl { \__nicematrix_vline:n { position = \int_eval:n { \c@jCol + 1 } , multiplicity = \int_use:N \l_tmpa_int , } } \int_zero:N \l_tmpa_int \str_if_eq:nnT { #1 } { \q_stop } { \bool_gset_true:N \g_tmpb_bool } \__nicematrix_patch_preamble:n #1 } } \bool_new:N \l__nicematrix_bar_at_end_of_pream_bool \keys_define:nn { WithArrows / p-column } { r .code:n = \str_set:Nn \l__nicematrix_hpos_col_str { r } , r .value_forbidden:n = true , c .code:n = \str_set:Nn \l__nicematrix_hpos_col_str { c } , c .value_forbidden:n = true , l .code:n = \str_set:Nn \l__nicematrix_hpos_col_str { l } , l .value_forbidden:n = true , si .code:n = \str_set:Nn \l__nicematrix_hpos_col_str { si } , si .value_forbidden:n = true , p .code:n = \str_set:Nn \l__nicematrix_vpos_col_str { p } , p .value_forbidden:n = true , t .meta:n = p , m .code:n = \str_set:Nn \l__nicematrix_vpos_col_str { m } , m .value_forbidden:n = true , b .code:n = \str_set:Nn \l__nicematrix_vpos_col_str { b } , b .value_forbidden:n = true , } \cs_new_protected:Npn \__nicematrix_patch_preamble_iv:n #1 { \str_set:Nn \l__nicematrix_vpos_col_str { #1 } \__nicematrix_patch_preamble_iv_i:n } \cs_new_protected:Npn \__nicematrix_patch_preamble_iv_i:n #1 { \str_if_eq:nnTF { #1 } { [ } { \__nicematrix_patch_preamble_iv_ii:w [ } { \__nicematrix_patch_preamble_iv_ii:w [ ] { #1 } } } \cs_new_protected:Npn \__nicematrix_patch_preamble_iv_ii:w [ #1 ] { \__nicematrix_patch_preamble_iv_iii:nn { #1 } } \cs_new_protected:Npn \__nicematrix_patch_preamble_iv_iii:nn #1 #2 { \str_set:Nn \l__nicematrix_hpos_col_str { j } \keys_set:nn { WithArrows / p-column } { #1 } \__nicematrix_patch_preamble_iv_iv:nn { #2 } { minipage } } \cs_new_protected:Npn \__nicematrix_patch_preamble_iv_iv:nn #1 #2 { \use:x { \__nicematrix_patch_preamble_iv_v:nnnnnnnn { \str_if_eq:VnTF \l__nicematrix_vpos_col_str { p } { t } { b } } { \dim_eval:n { #1 } } { \str_if_eq:VnTF \l__nicematrix_hpos_col_str j { \str_set:Nn \exp_not:N \l__nicematrix_hpos_cell_str { c } } { \str_set:Nn \exp_not:N \l__nicematrix_hpos_cell_str { \l__nicematrix_hpos_col_str } } \str_case:Vn \l__nicematrix_hpos_col_str { c { \exp_not:N \centering } l { \exp_not:N \raggedright } r { \exp_not:N \raggedleft } } } { \str_if_eq:VnT \l__nicematrix_vpos_col_str { m } \__nicematrix_center_cell_box: } { \str_if_eq:VnT \l__nicematrix_hpos_col_str { si } \siunitx_cell_begin:w } { \str_if_eq:VnT \l__nicematrix_hpos_col_str { si } \siunitx_cell_end: } { #2 } { \str_case:VnF \l__nicematrix_hpos_col_str { { j } { c } { si } { c } } { \l__nicematrix_hpos_col_str } } } \int_gincr:N \c@jCol \__nicematrix_patch_preamble_xi:n } \cs_new_protected:Npn \__nicematrix_patch_preamble_iv_v:nnnnnnnn #1 #2 #3 #4 #5 #6 #7 #8 { \tl_gput_right:Nn \g__nicematrix_preamble_tl { > { \dim_set:Nn \l__nicematrix_col_width_dim { #2 } \__nicematrix_cell_begin:w \begin { #7 } [ #1 ] { #2 } \everypar { \vrule height \box_ht:N \@arstrutbox width \c_zero_dim \everypar { } } #3 \g__nicematrix_row_style_tl \arraybackslash #5 } #8 < { #6 \@finalstrut \@arstrutbox % \bool_if:NT \g__nicematrix_rotate_bool { \raggedright \hsize = 3 cm } \end { #7 } #4 \__nicematrix_cell_end: } } } \cs_new_protected:Npn \__nicematrix_center_cell_box: { \tl_gput_right:Nn \g__nicematrix_cell_after_hook_tl { \int_compare:nNnT { \box_ht:N \l__nicematrix_cell_box } > { \box_ht:N \@arstrutbox } { \hbox_set:Nn \l__nicematrix_cell_box { \box_move_down:nn { ( \box_ht:N \l__nicematrix_cell_box - \box_ht:N \@arstrutbox + \baselineskip ) / 2 } { \box_use:N \l__nicematrix_cell_box } } } } } \cs_new_protected:Npn \__nicematrix_patch_preamble_v:n #1 { \str_if_eq:nnTF { #1 } { [ } { \__nicematrix_patch_preamble_v_i:w [ } { \__nicematrix_patch_preamble_v_i:w [ ] { #1 } } } \cs_new_protected:Npn \__nicematrix_patch_preamble_v_i:w [ #1 ] { \__nicematrix_patch_preamble_v_ii:nn { #1 } } \cs_new_protected:Npn \__nicematrix_patch_preamble_v_ii:nn #1 #2 { \str_set:Nn \l__nicematrix_vpos_col_str { p } \str_set:Nn \l__nicematrix_hpos_col_str { j } \keys_set:nn { WithArrows / p-column } { #1 } \bool_if:NTF \c__nicematrix_varwidth_loaded_bool { \__nicematrix_patch_preamble_iv_iv:nn { #2 } { varwidth } } { \__nicematrix_error_or_warning:n { varwidth~not~loaded } \__nicematrix_patch_preamble_iv_iv:nn { #2 } { minipage } } } \cs_new_protected:Npn \__nicematrix_patch_preamble_vi:nnnn #1 #2 #3 #4 { \tl_gput_right:Nn \g__nicematrix_preamble_tl { > { \dim_set:Nn \l__nicematrix_col_width_dim { #4 } \hbox_set:Nw \l__nicematrix_cell_box \__nicematrix_cell_begin:w \str_set:Nn \l__nicematrix_hpos_cell_str { #3 } } c < { \__nicematrix_cell_end: #1 \hbox_set_end: \bool_if:NT \g__nicematrix_rotate_bool \__nicematrix_rotate_cell_box: \__nicematrix_adjust_size_box: \makebox [ #4 ] [ #3 ] { \box_use_drop:N \l__nicematrix_cell_box } } } \int_gincr:N \c@jCol \__nicematrix_patch_preamble_xi:n } \cs_new_protected:Npn \__nicematrix_patch_preamble_vii:n #1 { \str_if_eq:nnTF { #1 } { [ } { \__nicematrix_patch_preamble_vii_i:w [ } { \__nicematrix_patch_preamble_vii_i:w [ ] { #1 } } } \cs_new_protected:Npn \__nicematrix_patch_preamble_vii_i:w [ #1 ] { \__nicematrix_patch_preamble_vii_ii:n { #1 } } \cs_new_protected:Npn \__nicematrix_patch_preamble_vii_ii:n #1 { \cs_if_exist:NTF \siunitx_cell_begin:w { \tl_gput_right:Nn \g__nicematrix_preamble_tl { > { \__nicematrix_cell_begin:w \keys_set:nn { siunitx } { #1 } \siunitx_cell_begin:w } c < { \siunitx_cell_end: \__nicematrix_cell_end: } } \int_gincr:N \c@jCol \__nicematrix_patch_preamble_xi:n } { \__nicematrix_fatal:n { Version~of~siunitx~too~old } } } \cs_new_protected:Npn \__nicematrix_patch_preamble_viii:nn #1 #2 { \bool_if:NT \l__nicematrix_small_bool { \__nicematrix_fatal:n { Delimiter~with~small } } \int_compare:nNnTF \c@jCol = \c_zero_int { \str_if_eq:VnTF \g__nicematrix_left_delim_tl { . } { \tl_gset:Nn \g__nicematrix_left_delim_tl { #1 } \tl_gset:Nn \g__nicematrix_right_delim_tl { . } \__nicematrix_patch_preamble:n #2 } { \tl_gput_right:Nn \g__nicematrix_preamble_tl { ! { \enskip } } \__nicematrix_patch_preamble_viii_i:nn { #1 } { #2 } } } { \__nicematrix_patch_preamble_viii_i:nn { #1 } { #2 } } } \cs_new_protected:Npn \__nicematrix_patch_preamble_viii_i:nn #1 #2 { \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl { \__nicematrix_delimiter:nnn #1 { \int_eval:n { \c@jCol + 1 } } \c_true_bool } \tl_if_in:nnTF { ( [ \{ ) ] \} } { #2 } { \__nicematrix_error:nn { delimiter~after~opening } { #2 } \__nicematrix_patch_preamble:n } { \__nicematrix_patch_preamble:n #2 } } \cs_new_protected:Npn \__nicematrix_patch_preamble_ix:nn #1 #2 { \bool_if:NT \l__nicematrix_small_bool { \__nicematrix_fatal:n { Delimiter~with~small } } \tl_if_in:nnTF { ) ] \} } { #2 } { \__nicematrix_patch_preamble_ix_i:nnn #1 #2 } { \tl_if_eq:nnTF { \q_stop } { #2 } { \str_if_eq:VnTF \g__nicematrix_right_delim_tl { . } { \tl_gset:Nn \g__nicematrix_right_delim_tl { #1 } } { \tl_gput_right:Nn \g__nicematrix_preamble_tl { ! { \enskip } } \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl { \__nicematrix_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool } \__nicematrix_patch_preamble:n #2 } } { \tl_if_in:nnT { ( [ \{ } { #2 } { \tl_gput_right:Nn \g__nicematrix_preamble_tl { ! { \enskip } } } \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl { \__nicematrix_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool } \__nicematrix_patch_preamble:n #2 } } } \cs_new_protected:Npn \__nicematrix_patch_preamble_ix_i:nnn #1 #2 #3 { \tl_if_eq:nnTF { \q_stop } { #3 } { \str_if_eq:VnTF \g__nicematrix_right_delim_tl { . } { \tl_gput_right:Nn \g__nicematrix_preamble_tl { ! { \enskip } } \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl { \__nicematrix_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool } \tl_gset:Nn \g__nicematrix_right_delim_tl { #2 } } { \tl_gput_right:Nn \g__nicematrix_preamble_tl { ! { \enskip } } \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl { \__nicematrix_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool } \__nicematrix_error:nn { double~closing~delimiter } { #2 } } } { \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl { \__nicematrix_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool } \__nicematrix_error:nn { double~closing~delimiter } { #2 } \__nicematrix_patch_preamble:n #3 } } \cs_new_protected:Npn \__nicematrix_patch_preamble_x:n #1 { \str_if_eq:nnTF { #1 } { [ } { \__nicematrix_patch_preamble_x_i:w [ } { \__nicematrix_patch_preamble_x_i:w [ ] #1 } } \cs_new_protected:Npn \__nicematrix_patch_preamble_x_i:w [ #1 ] { \__nicematrix_patch_preamble_x_ii:n { #1 } } \keys_define:nn { WithArrows / X-column } { unknown .code:n = \int_set:Nn \l__nicematrix_weight_int { \l_keys_key_str } } \cs_new_protected:Npn \__nicematrix_patch_preamble_x_ii:n #1 { \str_set:Nn \l__nicematrix_hpos_col_str { j } \tl_set:Nn \l__nicematrix_vpos_col_str { p } \int_zero_new:N \l__nicematrix_weight_int \int_set:Nn \l__nicematrix_weight_int { 1 } \keys_set_known:nnN { WithArrows / p-column } { #1 } \l_tmpa_tl \keys_set:nV { WithArrows / X-column } \l_tmpa_tl \int_compare:nNnT \l__nicematrix_weight_int < 0 { \__nicematrix_error_or_warning:n { negative~weight } \int_set:Nn \l__nicematrix_weight_int { - \l__nicematrix_weight_int } } \int_gadd:Nn \g__nicematrix_total_X_weight_int \l__nicematrix_weight_int \bool_if:NTF \l__nicematrix_X_columns_aux_bool { \__nicematrix_patch_preamble_iv_iv:nn { \l__nicematrix_weight_int \l__nicematrix_X_columns_dim } { minipage } } { \tl_gput_right:Nn \g__nicematrix_preamble_tl { > { \__nicematrix_cell_begin:w \bool_set_true:N \l__nicematrix_X_column_bool \tl_gput_right:Nn \g__nicematrix_cell_after_hook_tl { \hbox_set:Nn \l__nicematrix_cell_box { } } \begin { minipage } { 5 cm } \arraybackslash } c < { \end { minipage } \__nicematrix_cell_end: } } \int_gincr:N \c@jCol \__nicematrix_patch_preamble_xi:n } } \cs_new_protected:Npn \__nicematrix_patch_preamble_xi:n #1 { \str_if_eq:nnTF { #1 } { < } \__nicematrix_patch_preamble_xiii:n { \tl_if_eq:NnTF \l__nicematrix_vlines_clist { all } { \tl_gput_right:Nn \g__nicematrix_preamble_tl { ! { \skip_horizontal:N \arrayrulewidth } } } { \exp_args:NNx \clist_if_in:NnT \l__nicematrix_vlines_clist { \int_eval:n { \c@jCol + 1 } } { \tl_gput_right:Nn \g__nicematrix_preamble_tl { ! { \skip_horizontal:N \arrayrulewidth } } } } \__nicematrix_patch_preamble:n { #1 } } } \cs_new_protected:Npn \__nicematrix_patch_preamble_xiii:n #1 { \tl_gput_right:Nn \g__nicematrix_preamble_tl { < { #1 } } \__nicematrix_patch_preamble_xi:n } \cs_new_protected:Npn \__nicematrix_set_preamble:Nn #1 #2 { \@temptokena { #2 } \@tempswatrue \@whilesw \if@tempswa \fi { \@tempswafalse \the \NC@list } \tl_gclear:N \g__nicematrix_preamble_tl \exp_after:wN \__nicematrix_patch_m_preamble:n \the \@temptokena \q_stop \tl_set_eq:NN #1 \g__nicematrix_preamble_tl } \cs_new:Npn \__nicematrix_multicolumn:nnn #1 #2 #3 { \multispan { #1 } \begingroup \cs_set:Npn \@addamp { \if@firstamp \@firstampfalse \else \@preamerr 5 \fi } \@temptokena = { #2 } \@tempswatrue \@whilesw \if@tempswa \fi { \@tempswafalse \the \NC@list } \tl_gclear:N \g__nicematrix_preamble_tl \exp_after:wN \__nicematrix_patch_m_preamble:n \the \@temptokena \q_stop \exp_args:NV \@mkpream \g__nicematrix_preamble_tl \@addtopreamble \@empty \endgroup \int_compare:nNnT { #1 } > 1 { \seq_gput_left:Nx \g__nicematrix_multicolumn_cells_seq { \int_use:N \c@iRow - \int_eval:n { \c@jCol + 1 } } \seq_gput_left:Nn \g__nicematrix_multicolumn_sizes_seq { #1 } \seq_gput_right:Nx \g__nicematrix_pos_of_blocks_seq { { \int_compare:nNnTF \c@jCol = 0 { \int_eval:n { \c@iRow + 1 } } { \int_use:N \c@iRow } } { \int_eval:n { \c@jCol + 1 } } { \int_compare:nNnTF \c@jCol = 0 { \int_eval:n { \c@iRow + 1 } } { \int_use:N \c@iRow } } { \int_eval:n { \c@jCol + #1 } } { } % for the name of the block } } \cs_set:Npn \@sharp { #3 } \@arstrut \@preamble \null \int_gadd:Nn \c@jCol { #1 - 1 } \int_compare:nNnT \c@jCol > \g__nicematrix_col_total_int { \int_gset_eq:NN \g__nicematrix_col_total_int \c@jCol } \ignorespaces } \cs_new_protected:Npn \__nicematrix_patch_m_preamble:n #1 { \str_case:nnF { #1 } { c { \__nicematrix_patch_m_preamble_i:n #1 } l { \__nicematrix_patch_m_preamble_i:n #1 } r { \__nicematrix_patch_m_preamble_i:n #1 } > { \__nicematrix_patch_m_preamble_ii:nn #1 } ! { \__nicematrix_patch_m_preamble_ii:nn #1 } @ { \__nicematrix_patch_m_preamble_ii:nn #1 } | { \__nicematrix_patch_m_preamble_iii:n #1 } p { \__nicematrix_patch_m_preamble_iv:nnn t #1 } m { \__nicematrix_patch_m_preamble_iv:nnn c #1 } b { \__nicematrix_patch_m_preamble_iv:nnn b #1 } \__nicematrix_w: { \__nicematrix_patch_m_preamble_v:nnnn { } #1 } \__nicematrix_W: { \__nicematrix_patch_m_preamble_v:nnnn { \cs_set_eq:NN \hss \hfil } #1 } \q_stop { } } { \__nicematrix_fatal:nn { unknown~column~type } { #1 } } } \cs_new_protected:Npn \__nicematrix_patch_m_preamble_i:n #1 { \tl_gput_right:Nn \g__nicematrix_preamble_tl { > { \__nicematrix_cell_begin:w \str_set:Nn \l__nicematrix_hpos_cell_str { #1 } } #1 < \__nicematrix_cell_end: } \__nicematrix_patch_m_preamble_x:n } \cs_new_protected:Npn \__nicematrix_patch_m_preamble_ii:nn #1 #2 { \tl_gput_right:Nn \g__nicematrix_preamble_tl { #1 { #2 } } \__nicematrix_patch_m_preamble:n } \cs_new_protected:Npn \__nicematrix_patch_m_preamble_iii:n #1 { \tl_gput_right:Nn \g__nicematrix_preamble_tl { #1 } \__nicematrix_patch_m_preamble:n } \cs_new_protected:Npn \__nicematrix_patch_m_preamble_iv:nnn #1 #2 #3 { \tl_gput_right:Nn \g__nicematrix_preamble_tl { > { \__nicematrix_cell_begin:w \begin { minipage } [ #1 ] { \dim_eval:n { #3 } } \mode_leave_vertical: \arraybackslash \vrule height \box_ht:N \@arstrutbox depth 0 pt width 0 pt } c < { \vrule height 0 pt depth \box_dp:N \@arstrutbox width 0 pt \end { minipage } \__nicematrix_cell_end: } } \__nicematrix_patch_m_preamble_x:n } \cs_new_protected:Npn \__nicematrix_patch_m_preamble_v:nnnn #1 #2 #3 #4 { \tl_gput_right:Nn \g__nicematrix_preamble_tl { > { \hbox_set:Nw \l__nicematrix_cell_box \__nicematrix_cell_begin:w \str_set:Nn \l__nicematrix_hpos_cell_str { #3 } } c < { \__nicematrix_cell_end: #1 \hbox_set_end: \bool_if:NT \g__nicematrix_rotate_bool \__nicematrix_rotate_cell_box: \__nicematrix_adjust_size_box: \makebox [ #4 ] [ #3 ] { \box_use_drop:N \l__nicematrix_cell_box } } } \__nicematrix_patch_m_preamble_x:n } \cs_new_protected:Npn \__nicematrix_patch_m_preamble_x:n #1 { \str_if_eq:nnTF { #1 } { < } \__nicematrix_patch_m_preamble_ix:n { \__nicematrix_patch_m_preamble:n { #1 } } } \cs_new_protected:Npn \__nicematrix_patch_m_preamble_ix:n #1 { \tl_gput_right:Nn \g__nicematrix_preamble_tl { < { #1 } } \__nicematrix_patch_m_preamble_x:n } \cs_new_protected:Npn \__nicematrix_put_box_in_flow: { \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 } \tl_if_eq:NnTF \l__nicematrix_baseline_tl { c } { \box_use_drop:N \l_tmpa_box } \__nicematrix_put_box_in_flow_i: } \cs_new_protected:Npn \__nicematrix_put_box_in_flow_i: { \pgfpicture \__nicematrix_qpoint:n { row - 1 } \dim_gset_eq:NN \g_tmpa_dim \pgf@y \__nicematrix_qpoint:n { row - \int_eval:n { \c@iRow + 1 } } \dim_gadd:Nn \g_tmpa_dim \pgf@y \dim_gset:Nn \g_tmpa_dim { 0.5 \g_tmpa_dim } \str_if_in:NnTF \l__nicematrix_baseline_tl { line- } { \int_set:Nn \l_tmpa_int { \str_range:Nnn \l__nicematrix_baseline_tl 6 { \tl_count:V \l__nicematrix_baseline_tl } } \__nicematrix_qpoint:n { row - \int_use:N \l_tmpa_int } } { \str_case:VnF \l__nicematrix_baseline_tl { { t } { \int_set:Nn \l_tmpa_int 1 } { b } { \int_set_eq:NN \l_tmpa_int \c@iRow } } { \int_set:Nn \l_tmpa_int \l__nicematrix_baseline_tl } \bool_lazy_or:nnT { \int_compare_p:nNn \l_tmpa_int < \l__nicematrix_first_row_int } { \int_compare_p:nNn \l_tmpa_int > \g__nicematrix_row_total_int } { \__nicematrix_error:n { bad~value~for~baseline } \int_set:Nn \l_tmpa_int 1 } \__nicematrix_qpoint:n { row - \int_use:N \l_tmpa_int - base } \dim_gsub:Nn \g_tmpa_dim { \fontdimen22 \textfont2 } } \dim_gsub:Nn \g_tmpa_dim \pgf@y \endpgfpicture \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:nnT \l__nicematrix_Matrix_bool \g__nicematrix_NiceArray_bool { \box_set_wd:Nn \l__nicematrix_the_array_box { \box_wd:N \l__nicematrix_the_array_box - \arraycolsep } } \begin { minipage } [ t ] { \box_wd:N \l__nicematrix_the_array_box } \bool_if:NT \l__nicematrix_caption_above_bool { \tl_if_empty:NF \l__nicematrix_caption_tl { \bool_set_false:N \g__nicematrix_caption_finished_bool \int_gzero:N \c@tabularnote \__nicematrix_insert_caption: \int_gset:Nn \c@tabularnote { \seq_count:N \g__nicematrix_notes_in_caption_seq } \int_compare:nNnF \c@tabularnote = 0 { \tl_gput_right:Nx \g__nicematrix_aux_tl { \tl_set:Nn \exp_not:N \l__nicematrix_note_in_caption_tl { \int_eval:n { \c@tabularnote } } } } } } \hbox { \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_any:nT { { ! \seq_if_empty_p:N \g__nicematrix_notes_seq } { ! \seq_if_empty_p:N \g__nicematrix_notes_in_caption_seq } { ! \tl_if_empty_p:V \l__nicematrix_tabularnote_tl } } \__nicematrix_insert_tabularnotes: \cs_set_eq:NN \tabularnote \__nicematrix_tabularnote_error:n \bool_if:NF \l__nicematrix_caption_above_bool \__nicematrix_insert_caption: \end { minipage } } \cs_new_protected:Npn \__nicematrix_insert_caption: { \tl_if_empty:NF \l__nicematrix_caption_tl { \cs_if_exist:NTF \@captype { \__nicematrix_insert_caption_i: } { \__nicematrix_error:n { caption~outside~float } } } } \cs_new_protected:Npn \__nicematrix_insert_caption_i: { \group_begin: \bool_set_true:N \l__nicematrix_in_caption_bool \bool_if:NT \c__nicematrix_floatrow_loaded_bool { \cs_set_eq:NN \@makecaption \FR@makecaption } \tl_if_empty:NTF \l__nicematrix_short_caption_tl { \caption { \l__nicematrix_caption_tl } } { \caption [ \l__nicematrix_short_caption_tl ] { \l__nicematrix_caption_tl } } \tl_if_empty:NF \l__nicematrix_label_tl { \label { \l__nicematrix_label_tl } } \group_end: } \cs_new_protected:Npn \__nicematrix_tabularnote_error:n #1 { \__nicematrix_error_or_warning:n { tabularnote~below~the~tabular } \__nicematrix_gredirect_none:n { tabularnote~below~the~tabular } } \cs_new_protected:Npn \__nicematrix_insert_tabularnotes: { \seq_gconcat:NNN \g__nicematrix_notes_seq \g__nicematrix_notes_in_caption_seq \g__nicematrix_notes_seq \int_set:Nn \c@tabularnote { \seq_count:N \g__nicematrix_notes_seq } \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 { \bool_if:NTF \l__nicematrix_notes_para_bool { \begin { tabularnotes* } \seq_map_inline:Nn \g__nicematrix_notes_seq { \item ##1 } \strut \end { tabularnotes* } \par } { \tabularnotes \seq_map_inline:Nn \g__nicematrix_notes_seq { \item ##1 } \strut \endtabularnotes } } \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_or_warning:n { bottomrule~without~booktabs } } } \l__nicematrix_notes_code_after_tl \seq_gclear:N \g__nicematrix_notes_seq \seq_gclear:N \g__nicematrix_notes_in_caption_seq \int_gzero:N \c@tabularnote } \cs_new_protected:Npn \__nicematrix_use_arraybox_with_notes_b: { \pgfpicture \__nicematrix_qpoint:n { row - 1 } \dim_gset_eq:NN \g_tmpa_dim \pgf@y \__nicematrix_qpoint:n { row - \int_use:N \c@iRow - base } \dim_gsub:Nn \g_tmpa_dim \pgf@y \endpgfpicture \dim_gadd:Nn \g_tmpa_dim \arrayrulewidth \int_compare:nNnT \l__nicematrix_first_row_int = 0 { \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 { \hbox { \__nicematrix_use_arraybox_with_notes_c: } } } \cs_new_protected:Npn \__nicematrix_use_arraybox_with_notes: { \tl_if_eq:NnT \l__nicematrix_baseline_tl { t } { \tl_set:Nn \l__nicematrix_baseline_tl { 1 } } \pgfpicture \__nicematrix_qpoint:n { row - 1 } \dim_gset_eq:NN \g_tmpa_dim \pgf@y \str_if_in:NnTF \l__nicematrix_baseline_tl { line- } { \int_set:Nn \l_tmpa_int { \str_range:Nnn \l__nicematrix_baseline_tl 6 { \tl_count:V \l__nicematrix_baseline_tl } } \__nicematrix_qpoint:n { row - \int_use:N \l_tmpa_int } } { \int_set:Nn \l_tmpa_int \l__nicematrix_baseline_tl \bool_lazy_or:nnT { \int_compare_p:nNn \l_tmpa_int < \l__nicematrix_first_row_int } { \int_compare_p:nNn \l_tmpa_int > \g__nicematrix_row_total_int } { \__nicematrix_error:n { bad~value~for~baseline } \int_set:Nn \l_tmpa_int 1 } \__nicematrix_qpoint:n { row - \int_use:N \l_tmpa_int - base } } \dim_gsub:Nn \g_tmpa_dim \pgf@y \endpgfpicture \dim_gadd:Nn \g_tmpa_dim \arrayrulewidth \int_compare:nNnT \l__nicematrix_first_row_int = 0 { \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 { \hbox { \__nicematrix_use_arraybox_with_notes_c: } } } \cs_new_protected:Npn \__nicematrix_put_box_in_flow_bis:nn #1 #2 { \dim_zero_new:N \l__nicematrix_real_left_delim_dim \dim_zero_new:N \l__nicematrix_real_right_delim_dim \hbox_set:Nn \l_tmpb_box { \c_math_toggle_token \left #1 \vcenter { \vbox_to_ht:nn { \box_ht_plus_dp:N \l_tmpa_box } { } } \right . \c_math_toggle_token } \dim_set:Nn \l__nicematrix_real_left_delim_dim { \box_wd:N \l_tmpb_box - \nulldelimiterspace } \hbox_set:Nn \l_tmpb_box { \c_math_toggle_token \left . \vbox_to_ht:nn { \box_ht_plus_dp:N \l_tmpa_box } { } \right #2 \c_math_toggle_token } \dim_set:Nn \l__nicematrix_real_right_delim_dim { \box_wd:N \l_tmpb_box - \nulldelimiterspace } \skip_horizontal:N \l__nicematrix_left_delim_dim \skip_horizontal:N -\l__nicematrix_real_left_delim_dim \__nicematrix_put_box_in_flow: \skip_horizontal:N \l__nicematrix_right_delim_dim \skip_horizontal:N -\l__nicematrix_real_right_delim_dim } \NewDocumentEnvironment { __nicematrix-normal-syntax } { } { \peek_remove_spaces:n { \peek_meaning:NTF \end \__nicematrix_analyze_end:Nn { \__nicematrix_transform_preamble: \__nicematrix_array:V \g__nicematrix_preamble_tl } } } { \__nicematrix_create_col_nodes: \endarray } \NewDocumentEnvironment { __nicematrix-light-syntax } { b } { \tl_if_empty:nT { #1 } { \__nicematrix_fatal:n { empty~environment } } \tl_map_inline:nn { #1 } { \str_if_eq:nnT { ##1 } { & } { \__nicematrix_fatal:n { ampersand~in~light-syntax } } \str_if_eq:nnT { ##1 } { \\ } { \__nicematrix_fatal:n { double-backslash~in~light-syntax } } } \__nicematrix_light_syntax_i:w #1 \CodeAfter \q_stop } { \__nicematrix_create_col_nodes: \endarray } \cs_new_protected:Npn \__nicematrix_light_syntax_i:w #1\CodeAfter #2\q_stop { \tl_gput_right:Nn \g_nicematrix_code_after_tl { #2 } \seq_clear_new:N \l__nicematrix_rows_seq \tl_set_rescan:Nno \l__nicematrix_end_of_row_tl { } \l__nicematrix_end_of_row_tl \seq_set_split:NVn \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 { \seq_put_right:NV \l__nicematrix_rows_seq \l_tmpa_tl } \int_compare:nNnT \l__nicematrix_last_row_int = { -1 } { \int_set:Nn \l__nicematrix_last_row_int { \seq_count:N \l__nicematrix_rows_seq } } \tl_clear_new:N \l__nicematrix_new_body_tl \int_zero_new:N \l__nicematrix_nb_cols_int \seq_pop_left:NN \l__nicematrix_rows_seq \l_tmpa_tl \__nicematrix_line_with_light_syntax:V \l_tmpa_tl \seq_map_inline:Nn \l__nicematrix_rows_seq { \tl_put_right:Nn \l__nicematrix_new_body_tl { \\ } \__nicematrix_line_with_light_syntax:n { ##1 } } \int_compare:nNnT \l__nicematrix_last_col_int = { -1 } { \int_set:Nn \l__nicematrix_last_col_int { \l__nicematrix_nb_cols_int - 1 + \l__nicematrix_first_col_int } } \__nicematrix_transform_preamble: \__nicematrix_array:V \g__nicematrix_preamble_tl \l__nicematrix_new_body_tl } \cs_new_protected:Npn \__nicematrix_line_with_light_syntax:n #1 { \seq_clear_new:N \l__nicematrix_cells_seq \seq_set_split:Nnn \l__nicematrix_cells_seq { ~ } { #1 } \int_set:Nn \l__nicematrix_nb_cols_int { \int_max:nn \l__nicematrix_nb_cols_int { \seq_count:N \l__nicematrix_cells_seq } } \seq_pop_left:NN \l__nicematrix_cells_seq \l_tmpa_tl \tl_put_right:NV \l__nicematrix_new_body_tl \l_tmpa_tl \seq_map_inline:Nn \l__nicematrix_cells_seq { \tl_put_right:Nn \l__nicematrix_new_body_tl { & ##1 } } } \cs_generate_variant:Nn \__nicematrix_line_with_light_syntax:n { V } \cs_new_protected:Npn \__nicematrix_analyze_end:Nn #1 #2 { \str_if_eq:VnT \g__nicematrix_name_env_str { #2 } { \__nicematrix_fatal:n { empty~environment } } \end { #2 } } \cs_new:Npn \__nicematrix_create_col_nodes: { \crcr \int_compare:nNnT \l__nicematrix_first_col_int = 0 { \omit \hbox_overlap_left:n { \bool_if:NT \l__nicematrix_code_before_bool { \pgfsys@markposition { \__nicematrix_env: - col - 0 } } \pgfpicture \pgfrememberpicturepositiononpagetrue \pgfcoordinate { \__nicematrix_env: - col - 0 } \pgfpointorigin \str_if_empty:NF \l__nicematrix_name_str { \pgfnodealias { \l__nicematrix_name_str - col - 0 } { \__nicematrix_env: - col - 0 } } \endpgfpicture \skip_horizontal:N 2\col@sep \skip_horizontal:N \g__nicematrix_width_first_col_dim } & } \omit \bool_gset_true:N \g__nicematrix_row_of_col_done_bool \int_compare:nNnTF \l__nicematrix_first_col_int = 0 { \bool_if:NT \l__nicematrix_code_before_bool { \hbox { \skip_horizontal:N -0.5\arrayrulewidth \pgfsys@markposition { \__nicematrix_env: - col - 1 } \skip_horizontal:N 0.5\arrayrulewidth } } \pgfpicture \pgfrememberpicturepositiononpagetrue \pgfcoordinate { \__nicematrix_env: - col - 1 } { \pgfpoint { - 0.5 \arrayrulewidth } \c_zero_dim } \str_if_empty:NF \l__nicematrix_name_str { \pgfnodealias { \l__nicematrix_name_str - col - 1 } { \__nicematrix_env: - col - 1 } } \endpgfpicture } { \bool_if:NT \l__nicematrix_code_before_bool { \hbox { \skip_horizontal:N 0.5\arrayrulewidth \pgfsys@markposition { \__nicematrix_env: - col - 1 } \skip_horizontal:N -0.5\arrayrulewidth } } \pgfpicture \pgfrememberpicturepositiononpagetrue \pgfcoordinate { \__nicematrix_env: - col - 1 } { \pgfpoint { 0.5 \arrayrulewidth } \c_zero_dim } \str_if_empty:NF \l__nicematrix_name_str { \pgfnodealias { \l__nicematrix_name_str - col - 1 } { \__nicematrix_env: - col - 1 } } \endpgfpicture } \skip_gset:Nn \g_tmpa_skip { 0 pt~plus 1 fill } \bool_if:NF \l__nicematrix_auto_columns_width_bool { \dim_compare:nNnT \l__nicematrix_columns_width_dim > \c_zero_dim } { \bool_lazy_and:nnTF \l__nicematrix_auto_columns_width_bool { \bool_not_p:n \l__nicematrix_block_auto_columns_width_bool } { \skip_gset_eq:NN \g_tmpa_skip \g__nicematrix_max_cell_width_dim } { \skip_gset_eq:NN \g_tmpa_skip \l__nicematrix_columns_width_dim } \skip_gadd:Nn \g_tmpa_skip { 2 \col@sep } } \skip_horizontal:N \g_tmpa_skip \hbox { \bool_if:NT \l__nicematrix_code_before_bool { \hbox { \skip_horizontal:N -0.5\arrayrulewidth \pgfsys@markposition { \__nicematrix_env: - col - 2 } \skip_horizontal:N 0.5\arrayrulewidth } } \pgfpicture \pgfrememberpicturepositiononpagetrue \pgfcoordinate { \__nicematrix_env: - col - 2 } { \pgfpoint { - 0.5 \arrayrulewidth } \c_zero_dim } \str_if_empty:NF \l__nicematrix_name_str { \pgfnodealias { \l__nicematrix_name_str - col - 2 } { \__nicematrix_env: - col - 2 } } \endpgfpicture } \int_gset:Nn \g_tmpa_int 1 \bool_if:NTF \g__nicematrix_last_col_found_bool { \prg_replicate:nn { \int_max:nn { \g__nicematrix_col_total_int - 3 } 0 } } { \prg_replicate:nn { \int_max:nn { \g__nicematrix_col_total_int - 2 } 0 } } { & \omit \int_gincr:N \g_tmpa_int \skip_horizontal:N \g_tmpa_skip \bool_if:NT \l__nicematrix_code_before_bool { \hbox { \skip_horizontal:N -0.5\arrayrulewidth \pgfsys@markposition { \__nicematrix_env: - col - \int_eval:n { \g_tmpa_int + 1 } } \skip_horizontal:N 0.5\arrayrulewidth } } \pgfpicture \pgfrememberpicturepositiononpagetrue \pgfcoordinate { \__nicematrix_env: - col - \int_eval:n { \g_tmpa_int + 1 } } { \pgfpoint { - 0.5 \arrayrulewidth } \c_zero_dim } \str_if_empty:NF \l__nicematrix_name_str { \pgfnodealias { \l__nicematrix_name_str - col - \int_eval:n { \g_tmpa_int + 1 } } { \__nicematrix_env: - col - \int_eval:n { \g_tmpa_int + 1 } } } \endpgfpicture } & \omit \int_compare:nNnT \g__nicematrix_col_total_int = 1 { \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_all:nT { \g__nicematrix_NiceArray_bool { \bool_not_p:n \l__nicematrix_NiceTabular_bool } { \clist_if_empty_p:N \l__nicematrix_vlines_clist } { \bool_not_p:n \l__nicematrix_exterior_arraycolsep_bool } { ! \l__nicematrix_bar_at_end_of_pream_bool } } { \skip_horizontal:N -\col@sep } \bool_if:NT \l__nicematrix_code_before_bool { \hbox { \skip_horizontal:N -0.5\arrayrulewidth \bool_lazy_and:nnT \l__nicematrix_Matrix_bool \g__nicematrix_NiceArray_bool { \skip_horizontal:N -\arraycolsep } \pgfsys@markposition { \__nicematrix_env: - col - \int_eval:n { \g_tmpa_int + 1 } } \skip_horizontal:N 0.5\arrayrulewidth \bool_lazy_and:nnT \l__nicematrix_Matrix_bool \g__nicematrix_NiceArray_bool { \skip_horizontal:N \arraycolsep } } } \pgfpicture \pgfrememberpicturepositiononpagetrue \pgfcoordinate { \__nicematrix_env: - col - \int_eval:n { \g_tmpa_int + 1 } } { \bool_lazy_and:nnTF \l__nicematrix_Matrix_bool \g__nicematrix_NiceArray_bool { \pgfpoint { - 0.5 \arrayrulewidth - \arraycolsep } \c_zero_dim } { \pgfpoint { - 0.5 \arrayrulewidth } \c_zero_dim } } \str_if_empty:NF \l__nicematrix_name_str { \pgfnodealias { \l__nicematrix_name_str - col - \int_eval:n { \g_tmpa_int + 1 } } { \__nicematrix_env: - col - \int_eval:n { \g_tmpa_int + 1 } } } \endpgfpicture \bool_if:NT \g__nicematrix_last_col_found_bool { \hbox_overlap_right:n { \skip_horizontal:N \g__nicematrix_width_last_col_dim \bool_if:NT \l__nicematrix_code_before_bool { \pgfsys@markposition { \__nicematrix_env: - col - \int_eval:n { \g__nicematrix_col_total_int + 1 } } } \pgfpicture \pgfrememberpicturepositiononpagetrue \pgfcoordinate { \__nicematrix_env: - col - \int_eval:n { \g__nicematrix_col_total_int + 1 } } \pgfpointorigin \str_if_empty:NF \l__nicematrix_name_str { \pgfnodealias { \l__nicematrix_name_str - col - \int_eval:n { \g__nicematrix_col_total_int + 1 } } { \__nicematrix_env: - col - \int_eval:n { \g__nicematrix_col_total_int + 1 } } } \endpgfpicture } } \cr } \tl_const:Nn \c__nicematrix_preamble_first_col_tl { > { \cs_set_eq:NN \CodeAfter \__nicematrix_CodeAfter_i: \bool_gset_true:N \g__nicematrix_after_col_zero_bool \__nicematrix_begin_of_row: \hbox_set:Nw \l__nicematrix_cell_box \__nicematrix_math_toggle_token: \bool_if:NT \l__nicematrix_small_bool \scriptstyle \bool_lazy_and:nnT { \int_compare_p:nNn \c@iRow > 0 } { \bool_lazy_or_p:nn { \int_compare_p:nNn \l__nicematrix_last_row_int < 0 } { \int_compare_p:nNn \c@iRow < \l__nicematrix_last_row_int } } { \l__nicematrix_code_for_first_col_tl \xglobal \colorlet { nicematrix-first-col } { . } } } l < { \__nicematrix_math_toggle_token: \hbox_set_end: \bool_if:NT \g__nicematrix_rotate_bool \__nicematrix_rotate_cell_box: \__nicematrix_adjust_size_box: \__nicematrix_update_for_first_and_last_row: \dim_gset:Nn \g__nicematrix_width_first_col_dim { \dim_max:nn \g__nicematrix_width_first_col_dim { \box_wd:N \l__nicematrix_cell_box } } \hbox_overlap_left:n { \dim_compare:nNnTF { \box_wd:N \l__nicematrix_cell_box } > \c_zero_dim \__nicematrix_node_for_cell: { \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 } \bool_gset_false:N \g__nicematrix_empty_cell_bool \skip_horizontal:N -2\col@sep } } \tl_const:Nn \c__nicematrix_preamble_last_col_tl { > { \cs_set_eq:NN \CodeAfter \__nicematrix_CodeAfter_i: \bool_gset_true:N \g__nicematrix_last_col_found_bool \int_gincr:N \c@jCol \int_gset_eq:NN \g__nicematrix_col_total_int \c@jCol \hbox_set:Nw \l__nicematrix_cell_box \__nicematrix_math_toggle_token: \bool_if:NT \l__nicematrix_small_bool \scriptstyle \int_compare:nNnT \c@iRow > 0 { \bool_lazy_or:nnT { \int_compare_p:nNn \l__nicematrix_last_row_int < 0 } { \int_compare_p:nNn \c@iRow < \l__nicematrix_last_row_int } { \l__nicematrix_code_for_last_col_tl \xglobal \colorlet { nicematrix-last-col } { . } } } } l < { \__nicematrix_math_toggle_token: \hbox_set_end: \bool_if:NT \g__nicematrix_rotate_bool \__nicematrix_rotate_cell_box: \__nicematrix_adjust_size_box: \__nicematrix_update_for_first_and_last_row: \dim_gset:Nn \g__nicematrix_width_last_col_dim { \dim_max:nn \g__nicematrix_width_last_col_dim { \box_wd:N \l__nicematrix_cell_box } } \skip_horizontal:N -2\col@sep \hbox_overlap_right:n { \dim_compare:nNnT { \box_wd:N \l__nicematrix_cell_box } > \c_zero_dim { \skip_horizontal:N \l__nicematrix_right_delim_dim \skip_horizontal:N \l__nicematrix_right_margin_dim \skip_horizontal:N \l__nicematrix_extra_right_margin_dim \__nicematrix_node_for_cell: } } \bool_gset_false:N \g__nicematrix_empty_cell_bool } } \NewDocumentEnvironment { NiceArray } { } { \bool_gset_true:N \g__nicematrix_NiceArray_bool \str_if_empty:NT \g__nicematrix_name_env_str { \str_gset:Nn \g__nicematrix_name_env_str { NiceArray } } \NiceArrayWithDelims . . } { \endNiceArrayWithDelims } \cs_new_protected:Npn \__nicematrix_def_env:nnn #1 #2 #3 { \NewDocumentEnvironment { #1 NiceArray } { } { \bool_gset_false:N \g__nicematrix_NiceArray_bool \str_if_empty:NT \g__nicematrix_name_env_str { \str_gset:Nn \g__nicematrix_name_env_str { #1 NiceArray } } \__nicematrix_test_if_math_mode: \NiceArrayWithDelims #2 #3 } { \endNiceArrayWithDelims } } \__nicematrix_def_env:nnn p ( ) \__nicematrix_def_env:nnn b [ ] \__nicematrix_def_env:nnn B \{ \} \__nicematrix_def_env:nnn v | | \__nicematrix_def_env:nnn V \| \| \cs_new_protected:Npn \__nicematrix_begin_of_NiceMatrix:nn #1 #2 { \bool_set_true:N \l__nicematrix_Matrix_bool \use:c { #1 NiceArray } { * { \int_compare:nNnTF \l__nicematrix_last_col_int < 0 \c@MaxMatrixCols { \int_eval:n { \l__nicematrix_last_col_int - 1 } } } { #2 } } } \cs_generate_variant:Nn \__nicematrix_begin_of_NiceMatrix:nn { n V } \clist_map_inline:nn { p , b , B , v , V } { \NewDocumentEnvironment { #1 NiceMatrix } { ! O { } } { \bool_gset_false:N \g__nicematrix_NiceArray_bool \str_gset:Nn \g__nicematrix_name_env_str { #1 NiceMatrix } \keys_set:nn { NiceMatrix / NiceMatrix } { ##1 } \__nicematrix_begin_of_NiceMatrix:nV { #1 } \l__nicematrix_columns_type_tl } { \use:c { end #1 NiceArray } } } \NewDocumentEnvironment { NiceMatrix } { ! O { } } { \bool_gset_false:N \g__nicematrix_NiceArray_bool \str_gset:Nn \g__nicematrix_name_env_str { NiceMatrix } \keys_set:nn { NiceMatrix / NiceMatrix } { #1 } \__nicematrix_begin_of_NiceMatrix:nV { } \l__nicematrix_columns_type_tl } { \endNiceArray } \cs_new_protected:Npn \__nicematrix_NotEmpty: { \bool_gset_true:N \g__nicematrix_not_empty_cell_bool } \NewDocumentEnvironment { NiceTabular } { O { } m ! O { } } { \dim_compare:nNnT \l__nicematrix_width_dim = \c_zero_dim { \dim_set_eq:NN \l__nicematrix_width_dim \linewidth } \str_gset:Nn \g__nicematrix_name_env_str { NiceTabular } \keys_set:nn { NiceMatrix / NiceTabular } { #1 , #3 } \tl_if_empty:NF \l__nicematrix_short_caption_tl { \tl_if_empty:NT \l__nicematrix_caption_tl { \__nicematrix_error_or_warning:n { short-caption~without~caption } \tl_set_eq:NN \l__nicematrix_caption_tl \l__nicematrix_short_caption_tl } } \tl_if_empty:NF \l__nicematrix_label_tl { \tl_if_empty:NT \l__nicematrix_caption_tl { \__nicematrix_error_or_warning:n { label~without~caption } } } \bool_set_true:N \l__nicematrix_NiceTabular_bool \NiceArray { #2 } } { \endNiceArray } \cs_set_protected:Npn \__nicematrix_newcolumntype #1 { \cs_if_free:cT { NC @ find @ #1 } { \NC@list \expandafter { \the \NC@list \NC@do #1 } } \cs_set:cpn {NC @ find @ #1 } ##1 #1 { \NC@ { ##1 } } \peek_meaning:NTF [ { \newcol@ #1 } { \newcol@ #1 [ 0 ] } } \NewDocumentEnvironment { NiceTabularX } { m O { } m ! O { } } { \bool_if:NT \c__nicematrix_tabularx_loaded_bool { \newcolumntype { X } { \__nicematrix_X } } \str_gset:Nn \g__nicematrix_name_env_str { NiceTabularX } \dim_zero_new:N \l__nicematrix_width_dim \dim_set:Nn \l__nicematrix_width_dim { #1 } \keys_set:nn { NiceMatrix / NiceTabular } { #2 , #4 } \bool_set_true:N \l__nicematrix_NiceTabular_bool \NiceArray { #3 } } { \endNiceArray } \NewDocumentEnvironment { NiceTabular* } { m O { } m ! O { } } { \str_gset:Nn \g__nicematrix_name_env_str { NiceTabular* } \dim_set:Nn \l__nicematrix_tabular_width_dim { #1 } \keys_set:nn { NiceMatrix / NiceTabular } { #2 , #4 } \bool_set_true:N \l__nicematrix_NiceTabular_bool \NiceArray { #3 } } { \endNiceArray } \cs_new_protected:Npn \__nicematrix_after_array: { \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 } \bool_if:NT \l__nicematrix_last_col_without_value_bool { \int_set_eq:NN \l__nicematrix_last_col_int \g__nicematrix_col_total_int } \bool_if:NT \l__nicematrix_last_row_without_value_bool { \int_set_eq:NN \l__nicematrix_last_row_int \g__nicematrix_row_total_int } \tl_gput_right:Nx \g__nicematrix_aux_tl { \seq_gset_from_clist:Nn \exp_not:N \g__nicematrix_size_seq { \int_use:N \l__nicematrix_first_row_int , \int_use:N \c@iRow , \int_use:N \g__nicematrix_row_total_int , \int_use:N \l__nicematrix_first_col_int , \int_use:N \c@jCol , \int_use:N \g__nicematrix_col_total_int } } \seq_if_empty:NF \g__nicematrix_pos_of_blocks_seq { \tl_gput_right:Nx \g__nicematrix_aux_tl { \seq_gset_from_clist:Nn \exp_not:N \g__nicematrix_pos_of_blocks_seq { \seq_use:Nnnn \g__nicematrix_pos_of_blocks_seq , , , } } } \seq_if_empty:NF \g__nicematrix_multicolumn_cells_seq { \tl_gput_right:Nx \g__nicematrix_aux_tl { \seq_gset_from_clist:Nn \exp_not:N \g__nicematrix_multicolumn_cells_seq { \seq_use:Nnnn \g__nicematrix_multicolumn_cells_seq , , , } \seq_gset_from_clist:Nn \exp_not:N \g__nicematrix_multicolumn_sizes_seq { \seq_use:Nnnn \g__nicematrix_multicolumn_sizes_seq , , , } } } \__nicematrix_create_diag_nodes: \pgfpicture \int_step_inline:nn \c@iRow { \pgfnodealias { \__nicematrix_env: - ##1 - last } { \__nicematrix_env: - ##1 - \int_use:N \c@jCol } } \int_step_inline:nn \c@jCol { \pgfnodealias { \__nicematrix_env: - last - ##1 } { \__nicematrix_env: - \int_use:N \c@iRow - ##1 } } \str_if_empty:NF \l__nicematrix_name_str { \int_step_inline:nn \c@iRow { \pgfnodealias { \l__nicematrix_name_str - ##1 - last } { \__nicematrix_env: - ##1 - \int_use:N \c@jCol } } \int_step_inline:nn \c@jCol { \pgfnodealias { \l__nicematrix_name_str - last - ##1 } { \__nicematrix_env: - \int_use:N \c@iRow - ##1 } } } \endpgfpicture \bool_if:NT \l__nicematrix_parallelize_diags_bool { \int_gzero_new:N \g__nicematrix_ddots_int \int_gzero_new:N \g__nicematrix_iddots_int \dim_gzero_new:N \g__nicematrix_delta_x_one_dim \dim_gzero_new:N \g__nicematrix_delta_y_one_dim \dim_gzero_new:N \g__nicematrix_delta_x_two_dim \dim_gzero_new:N \g__nicematrix_delta_y_two_dim } \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 \int_zero_new:N \l__nicematrix_final_j_int \bool_set_false:N \l__nicematrix_initial_open_bool \bool_set_false:N \l__nicematrix_final_open_bool \bool_if:NT \l__nicematrix_small_bool { \dim_set:Nn \l__nicematrix_xdots_radius_dim { 0.7 \l__nicematrix_xdots_radius_dim } \dim_set:Nn \l__nicematrix_xdots_inter_dim { 0.55 \l__nicematrix_xdots_inter_dim } \dim_set:Nn \l__nicematrix_xdots_shorten_start_dim { 0.6 \l__nicematrix_xdots_shorten_start_dim } \dim_set:Nn \l__nicematrix_xdots_shorten_end_dim { 0.6 \l__nicematrix_xdots_shorten_end_dim } } \__nicematrix_draw_dotted_lines: \__nicematrix_compute_corners: \__nicematrix_adjust_pos_of_blocks_seq: \tl_if_empty:NF \l__nicematrix_hlines_clist \__nicematrix_draw_hlines: \tl_if_empty:NF \l__nicematrix_vlines_clist \__nicematrix_draw_vlines: \bool_if:NT \c__nicematrix_tikz_loaded_bool { \tikzset { every~picture / .style = { overlay , remember~picture , name~prefix = \__nicematrix_env: - } } } \cs_set_eq:NN \ialign \__nicematrix_old_ialign: \cs_set_eq:NN \SubMatrix \__nicematrix_SubMatrix \cs_set_eq:NN \UnderBrace \__nicematrix_UnderBrace \cs_set_eq:NN \OverBrace \__nicematrix_OverBrace \cs_set_eq:NN \ShowCellNames \__nicematrix_ShowCellNames \cs_set_eq:NN \line \__nicematrix_line \g__nicematrix_internal_code_after_tl \tl_gclear:N \g__nicematrix_internal_code_after_tl \cs_set_eq:NN \CodeAfter \prg_do_nothing: \seq_gclear:N \g__nicematrix_submatrix_names_seq \exp_last_unbraced:NV \__nicematrix_CodeAfter_keys: \g_nicematrix_code_after_tl \scan_stop: \tl_gclear:N \g_nicematrix_code_after_tl \group_end: \tl_if_empty:NF \g_nicematrix_code_before_tl { \cs_set_protected:Npn \rectanglecolor { } \cs_set_protected:Npn \columncolor { } \tl_gput_right:Nx \g__nicematrix_aux_tl { \tl_gset:Nn \exp_not:N \g__nicematrix_code_before_tl { \exp_not:V \g_nicematrix_code_before_tl } } \bool_set_true:N \l__nicematrix_code_before_bool } \str_gclear:N \g__nicematrix_name_env_str \__nicematrix_restore_iRow_jCol: \cs_gset_eq:NN \CT@arc@ \__nicematrix_old_CT@arc@ } \NewDocumentCommand \__nicematrix_CodeAfter_keys: { O { } } { \keys_set:nn { NiceMatrix / CodeAfter } { #1 } } \cs_new_protected:Npn \__nicematrix_adjust_pos_of_blocks_seq: { \seq_gset_map_x:NNn \g__nicematrix_pos_of_blocks_seq \g__nicematrix_pos_of_blocks_seq { \__nicematrix_adjust_pos_of_blocks_seq_i:nnnnn ##1 } } \cs_new:Npn \__nicematrix_adjust_pos_of_blocks_seq_i:nnnnn #1 #2 #3 #4 #5 { { #1 } { #2 } { \int_compare:nNnTF { #3 } > { 99 } { \int_use:N \c@iRow } { #3 } } { \int_compare:nNnTF { #4 } > { 99 } { \int_use:N \c@jCol } { #4 } } { #5 } } \hook_gput_code:nnn { begindocument } { . } { \cs_new_protected:Npx \__nicematrix_draw_dotted_lines: { \c__nicematrix_pgfortikzpicture_tl \__nicematrix_draw_dotted_lines_i: \c__nicematrix_endpgfortikzpicture_tl } } \cs_new_protected:Npn \__nicematrix_draw_dotted_lines_i: { \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse \g__nicematrix_HVdotsfor_lines_tl \g__nicematrix_Vdots_lines_tl \g__nicematrix_Ddots_lines_tl \g__nicematrix_Iddots_lines_tl \g__nicematrix_Cdots_lines_tl \g__nicematrix_Ldots_lines_tl } \cs_new_protected:Npn \__nicematrix_restore_iRow_jCol: { \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 } { \__nicematrix_qpoint:n { col - \int_min:nn { ##1 } { \c@jCol + 1 } } \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__nicematrix_tmpc_dim \pgf@x \__nicematrix_qpoint:n { row - \int_min:nn { ##1 + 1 } { \c@iRow + 1 } } \dim_set_eq:NN \l__nicematrix_tmpd_dim \pgf@y \pgftransformshift { \pgfpoint \l_tmpa_dim \l_tmpb_dim } \dim_set:Nn \l_tmpa_dim { ( \l__nicematrix_tmpc_dim - \l_tmpa_dim ) / 2 } \dim_set:Nn \l_tmpb_dim { ( \l__nicematrix_tmpd_dim - \l_tmpb_dim ) / 2 } \pgfnode { __nicematrix_diag_node } { center } { } { \__nicematrix_env: - ##1 } { } \str_if_empty:NF \l__nicematrix_name_str { \pgfnodealias { \l__nicematrix_name_str - ##1 } { \__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 } } \str_if_empty:NF \l__nicematrix_name_str { \pgfnodealias { \l__nicematrix_name_str - \int_use:N \l_tmpa_int } { \__nicematrix_env: - \int_use:N \l_tmpa_int } \pgfnodealias { \l__nicematrix_name_str - last } { \__nicematrix_env: - last } } \endpgfpicture } \cs_new_protected:Npn \__nicematrix_find_extremities_of_line:nnnn #1 #2 #3 #4 { \cs_set:cpn { __nicematrix _ dotted _ #1 - #2 } { } \int_set:Nn \l__nicematrix_initial_i_int { #1 } \int_set:Nn \l__nicematrix_initial_j_int { #2 } \int_set:Nn \l__nicematrix_final_i_int { #1 } \int_set:Nn \l__nicematrix_final_j_int { #2 } \bool_set_false:N \l__nicematrix_stop_loop_bool \bool_do_until:Nn \l__nicematrix_stop_loop_bool { \int_add:Nn \l__nicematrix_final_i_int { #3 } \int_add:Nn \l__nicematrix_final_j_int { #4 } \bool_set_false:N \l__nicematrix_final_open_bool \int_compare:nNnTF \l__nicematrix_final_i_int > \l__nicematrix_row_max_int { \int_compare:nNnTF { #3 } = 1 { \bool_set_true:N \l__nicematrix_final_open_bool } { \int_compare:nNnT \l__nicematrix_final_j_int > \l__nicematrix_col_max_int { \bool_set_true:N \l__nicematrix_final_open_bool } } } { \int_compare:nNnTF \l__nicematrix_final_j_int < \l__nicematrix_col_min_int { \int_compare:nNnT { #4 } = { -1 } { \bool_set_true:N \l__nicematrix_final_open_bool } } { \int_compare:nNnT \l__nicematrix_final_j_int > \l__nicematrix_col_max_int { \int_compare:nNnT { #4 } = 1 { \bool_set_true:N \l__nicematrix_final_open_bool } } } } \bool_if:NTF \l__nicematrix_final_open_bool { \int_sub:Nn \l__nicematrix_final_i_int { #3 } \int_sub:Nn \l__nicematrix_final_j_int { #4 } \bool_set_true:N \l__nicematrix_stop_loop_bool } { \cs_if_exist:cTF { __nicematrix _ dotted _ \int_use:N \l__nicematrix_final_i_int - \int_use:N \l__nicematrix_final_j_int } { \int_sub:Nn \l__nicematrix_final_i_int { #3 } \int_sub:Nn \l__nicematrix_final_j_int { #4 } \bool_set_true:N \l__nicematrix_final_open_bool \bool_set_true:N \l__nicematrix_stop_loop_bool } { \cs_if_exist:cTF { pgf @ sh @ ns @ \__nicematrix_env: - \int_use:N \l__nicematrix_final_i_int - \int_use:N \l__nicematrix_final_j_int } { \bool_set_true:N \l__nicematrix_stop_loop_bool } { \cs_set:cpn { __nicematrix _ dotted _ \int_use:N \l__nicematrix_final_i_int - \int_use:N \l__nicematrix_final_j_int } { } } } } } \bool_set_false:N \l__nicematrix_stop_loop_bool \bool_do_until:Nn \l__nicematrix_stop_loop_bool { \int_sub:Nn \l__nicematrix_initial_i_int { #3 } \int_sub:Nn \l__nicematrix_initial_j_int { #4 } \bool_set_false:N \l__nicematrix_initial_open_bool \int_compare:nNnTF \l__nicematrix_initial_i_int < \l__nicematrix_row_min_int { \int_compare:nNnTF { #3 } = 1 { \bool_set_true:N \l__nicematrix_initial_open_bool } { \int_compare:nNnT \l__nicematrix_initial_j_int = { \l__nicematrix_col_min_int -1 } { \bool_set_true:N \l__nicematrix_initial_open_bool } } } { \int_compare:nNnTF \l__nicematrix_initial_j_int < \l__nicematrix_col_min_int { \int_compare:nNnT { #4 } = 1 { \bool_set_true:N \l__nicematrix_initial_open_bool } } { \int_compare:nNnT \l__nicematrix_initial_j_int > \l__nicematrix_col_max_int { \int_compare:nNnT { #4 } = { -1 } { \bool_set_true:N \l__nicematrix_initial_open_bool } } } } \bool_if:NTF \l__nicematrix_initial_open_bool { \int_add:Nn \l__nicematrix_initial_i_int { #3 } \int_add:Nn \l__nicematrix_initial_j_int { #4 } \bool_set_true:N \l__nicematrix_stop_loop_bool } { \cs_if_exist:cTF { __nicematrix _ dotted _ \int_use:N \l__nicematrix_initial_i_int - \int_use:N \l__nicematrix_initial_j_int } { \int_add:Nn \l__nicematrix_initial_i_int { #3 } \int_add:Nn \l__nicematrix_initial_j_int { #4 } \bool_set_true:N \l__nicematrix_initial_open_bool \bool_set_true:N \l__nicematrix_stop_loop_bool } { \cs_if_exist:cTF { pgf @ sh @ ns @ \__nicematrix_env: - \int_use:N \l__nicematrix_initial_i_int - \int_use:N \l__nicematrix_initial_j_int } { \bool_set_true:N \l__nicematrix_stop_loop_bool } { \cs_set:cpn { __nicematrix _ dotted _ \int_use:N \l__nicematrix_initial_i_int - \int_use:N \l__nicematrix_initial_j_int } { } } } } } \seq_gput_right:Nx \g__nicematrix_pos_of_xdots_seq { { \int_use:N \l__nicematrix_initial_i_int } { \int_min:nn \l__nicematrix_initial_j_int \l__nicematrix_final_j_int } { \int_use:N \l__nicematrix_final_i_int } { \int_max:nn \l__nicematrix_initial_j_int \l__nicematrix_final_j_int } { } % for the name of the block } } \cs_new_protected:Npn \__nicematrix_adjust_to_submatrix:nn #1 #2 { \int_set:Nn \l__nicematrix_row_min_int 1 \int_set:Nn \l__nicematrix_col_min_int 1 \int_set_eq:NN \l__nicematrix_row_max_int \c@iRow \int_set_eq:NN \l__nicematrix_col_max_int \c@jCol \seq_map_inline:Nn \g__nicematrix_submatrix_seq { \__nicematrix_adjust_to_submatrix:nnnnnn { #1 } { #2 } ##1 } } \cs_set_protected:Npn \__nicematrix_adjust_to_submatrix:nnnnnn #1 #2 #3 #4 #5 #6 { \bool_if:nT { \int_compare_p:n { #3 <= #1 } && \int_compare_p:n { #1 <= #5 } && \int_compare_p:n { #4 <= #2 } && \int_compare_p:n { #2 <= #6 } } { \int_set:Nn \l__nicematrix_row_min_int { \int_max:nn \l__nicematrix_row_min_int { #3 } } \int_set:Nn \l__nicematrix_col_min_int { \int_max:nn \l__nicematrix_col_min_int { #4 } } \int_set:Nn \l__nicematrix_row_max_int { \int_min:nn \l__nicematrix_row_max_int { #5 } } \int_set:Nn \l__nicematrix_col_max_int { \int_min:nn \l__nicematrix_col_max_int { #6 } } } } \cs_new_protected:Npn \__nicematrix_set_initial_coords: { \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x \dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y } \cs_new_protected:Npn \__nicematrix_set_final_coords: { \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y } \cs_new_protected:Npn \__nicematrix_set_initial_coords_from_anchor:n #1 { \pgfpointanchor { \__nicematrix_env: - \int_use:N \l__nicematrix_initial_i_int - \int_use:N \l__nicematrix_initial_j_int } { #1 } \__nicematrix_set_initial_coords: } \cs_new_protected:Npn \__nicematrix_set_final_coords_from_anchor:n #1 { \pgfpointanchor { \__nicematrix_env: - \int_use:N \l__nicematrix_final_i_int - \int_use:N \l__nicematrix_final_j_int } { #1 } \__nicematrix_set_final_coords: } \cs_new_protected:Npn \__nicematrix_open_x_initial_dim: { \dim_set_eq:NN \l__nicematrix_x_initial_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_initial_j_int } { \pgfpointanchor { \__nicematrix_env: - ##1 - \int_use:N \l__nicematrix_initial_j_int } { west } \dim_set:Nn \l__nicematrix_x_initial_dim { \dim_min:nn \l__nicematrix_x_initial_dim \pgf@x } } } \dim_compare:nNnT \l__nicematrix_x_initial_dim = \c_max_dim { \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_initial_j_int } \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x \dim_add:Nn \l__nicematrix_x_initial_dim \col@sep } } \cs_new_protected:Npn \__nicematrix_open_x_final_dim: { \dim_set:Nn \l__nicematrix_x_final_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_final_j_int } { \pgfpointanchor { \__nicematrix_env: - ##1 - \int_use:N \l__nicematrix_final_j_int } { east } \dim_set:Nn \l__nicematrix_x_final_dim { \dim_max:nn \l__nicematrix_x_final_dim \pgf@x } } } \dim_compare:nNnT \l__nicematrix_x_final_dim = { - \c_max_dim } { \__nicematrix_qpoint:n { col - \int_eval:n { \l__nicematrix_final_j_int + 1 } } \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x \dim_sub:Nn \l__nicematrix_x_final_dim \col@sep } } \cs_new_protected:Npn \__nicematrix_draw_Ldots:nnn #1 #2 #3 { \__nicematrix_adjust_to_submatrix:nn { #1 } { #2 } \cs_if_free:cT { __nicematrix _ dotted _ #1 - #2 } { \__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } 0 1 \group_begin: \int_compare:nNnTF { #1 } = 0 { \color { nicematrix-first-row } } { \int_compare:nNnT { #1 } = \l__nicematrix_last_row_int { \color { nicematrix-last-row } } } \keys_set:nn { NiceMatrix / xdots } { #3 } \tl_if_empty:VF \l__nicematrix_xdots_color_tl { \color { \l__nicematrix_xdots_color_tl } } \__nicematrix_actually_draw_Ldots: \group_end: } } \cs_new_protected:Npn \__nicematrix_actually_draw_Ldots: { \bool_if:NTF \l__nicematrix_initial_open_bool { \__nicematrix_open_x_initial_dim: \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_initial_i_int - base } \dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y } { \__nicematrix_set_initial_coords_from_anchor:n { base~east } } \bool_if:NTF \l__nicematrix_final_open_bool { \__nicematrix_open_x_final_dim: \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_final_i_int - base } \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y } { \__nicematrix_set_final_coords_from_anchor:n { base~west } } \dim_add:Nn \l__nicematrix_y_initial_dim \l__nicematrix_xdots_radius_dim \dim_add:Nn \l__nicematrix_y_final_dim \l__nicematrix_xdots_radius_dim \__nicematrix_draw_line: } \cs_new_protected:Npn \__nicematrix_draw_Cdots:nnn #1 #2 #3 { \__nicematrix_adjust_to_submatrix:nn { #1 } { #2 } \cs_if_free:cT { __nicematrix _ dotted _ #1 - #2 } { \__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } 0 1 \group_begin: \int_compare:nNnTF { #1 } = 0 { \color { nicematrix-first-row } } { \int_compare:nNnT { #1 } = \l__nicematrix_last_row_int { \color { nicematrix-last-row } } } \keys_set:nn { NiceMatrix / xdots } { #3 } \tl_if_empty:VF \l__nicematrix_xdots_color_tl { \color { \l__nicematrix_xdots_color_tl } } \__nicematrix_actually_draw_Cdots: \group_end: } } \cs_new_protected:Npn \__nicematrix_actually_draw_Cdots: { \bool_if:NTF \l__nicematrix_initial_open_bool { \__nicematrix_open_x_initial_dim: } { \__nicematrix_set_initial_coords_from_anchor:n { mid~east } } \bool_if:NTF \l__nicematrix_final_open_bool { \__nicematrix_open_x_final_dim: } { \__nicematrix_set_final_coords_from_anchor:n { mid~west } } \bool_lazy_and:nnTF \l__nicematrix_initial_open_bool \l__nicematrix_final_open_bool { \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_initial_i_int } \dim_set_eq:NN \l_tmpa_dim \pgf@y \__nicematrix_qpoint:n { row - \int_eval:n { \l__nicematrix_initial_i_int + 1 } } \dim_set:Nn \l__nicematrix_y_initial_dim { ( \l_tmpa_dim + \pgf@y ) / 2 } \dim_set_eq:NN \l__nicematrix_y_final_dim \l__nicematrix_y_initial_dim } { \bool_if:NT \l__nicematrix_initial_open_bool { \dim_set_eq:NN \l__nicematrix_y_initial_dim \l__nicematrix_y_final_dim } \bool_if:NT \l__nicematrix_final_open_bool { \dim_set_eq:NN \l__nicematrix_y_final_dim \l__nicematrix_y_initial_dim } } \__nicematrix_draw_line: } \cs_new_protected:Npn \__nicematrix_open_y_initial_dim: { \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_initial_i_int - base } \dim_set:Nn \l__nicematrix_y_initial_dim { \pgf@y + ( \box_ht:N \strutbox + \extrarowheight ) * \arraystretch } \int_step_inline:nnn \l__nicematrix_first_col_int \g__nicematrix_col_total_int { \cs_if_exist:cT { pgf @ sh @ ns @ \__nicematrix_env: - \int_use:N \l__nicematrix_initial_i_int - ##1 } { \pgfpointanchor { \__nicematrix_env: - \int_use:N \l__nicematrix_initial_i_int - ##1 } { north } \dim_set:Nn \l__nicematrix_y_initial_dim { \dim_max:nn \l__nicematrix_y_initial_dim \pgf@y } } } } \cs_new_protected:Npn \__nicematrix_open_y_final_dim: { \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_final_i_int - base } \dim_set:Nn \l__nicematrix_y_final_dim { \pgf@y - ( \box_dp:N \strutbox ) * \arraystretch } \int_step_inline:nnn \l__nicematrix_first_col_int \g__nicematrix_col_total_int { \cs_if_exist:cT { pgf @ sh @ ns @ \__nicematrix_env: - \int_use:N \l__nicematrix_final_i_int - ##1 } { \pgfpointanchor { \__nicematrix_env: - \int_use:N \l__nicematrix_final_i_int - ##1 } { south } \dim_set:Nn \l__nicematrix_y_final_dim { \dim_min:nn \l__nicematrix_y_final_dim \pgf@y } } } } \cs_new_protected:Npn \__nicematrix_draw_Vdots:nnn #1 #2 #3 { \__nicematrix_adjust_to_submatrix:nn { #1 } { #2 } \cs_if_free:cT { __nicematrix _ dotted _ #1 - #2 } { \__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } 1 0 \group_begin: \int_compare:nNnTF { #2 } = 0 { \color { nicematrix-first-col } } { \int_compare:nNnT { #2 } = \l__nicematrix_last_col_int { \color { nicematrix-last-col } } } \keys_set:nn { NiceMatrix / xdots } { #3 } \tl_if_empty:VF \l__nicematrix_xdots_color_tl { \color { \l__nicematrix_xdots_color_tl } } \__nicematrix_actually_draw_Vdots: \group_end: } } \cs_new_protected:Npn \__nicematrix_actually_draw_Vdots: { \bool_set_false:N \l_tmpa_bool \bool_lazy_or:nnF \l__nicematrix_initial_open_bool \l__nicematrix_final_open_bool { \__nicematrix_set_initial_coords_from_anchor:n { south~west } \__nicematrix_set_final_coords_from_anchor:n { north~west } \bool_set:Nn \l_tmpa_bool { \dim_compare_p:nNn \l__nicematrix_x_initial_dim = \l__nicematrix_x_final_dim } } \bool_if:NTF \l__nicematrix_initial_open_bool \__nicematrix_open_y_initial_dim: { \__nicematrix_set_initial_coords_from_anchor:n { south } } \bool_if:NTF \l__nicematrix_final_open_bool \__nicematrix_open_y_final_dim: { \__nicematrix_set_final_coords_from_anchor:n { north } } \bool_if:NTF \l__nicematrix_initial_open_bool { \bool_if:NTF \l__nicematrix_final_open_bool { \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_initial_j_int } \dim_set_eq:NN \l_tmpa_dim \pgf@x \__nicematrix_qpoint:n { col - \int_eval:n { \l__nicematrix_initial_j_int + 1 } } \dim_set:Nn \l__nicematrix_x_initial_dim { ( \pgf@x + \l_tmpa_dim ) / 2 } \dim_set_eq:NN \l__nicematrix_x_final_dim \l__nicematrix_x_initial_dim \int_compare:nNnT \l__nicematrix_last_col_int > { -2 } { \int_compare:nNnT \l__nicematrix_initial_j_int = \g__nicematrix_col_total_int { \dim_set_eq:NN \l_tmpa_dim \l__nicematrix_right_margin_dim \dim_add:Nn \l_tmpa_dim \l__nicematrix_extra_right_margin_dim \dim_add:Nn \l__nicematrix_x_initial_dim \l_tmpa_dim \dim_add:Nn \l__nicematrix_x_final_dim \l_tmpa_dim } } } { \dim_set_eq:NN \l__nicematrix_x_initial_dim \l__nicematrix_x_final_dim } } { \bool_if:NTF \l__nicematrix_final_open_bool { \dim_set_eq:NN \l__nicematrix_x_final_dim \l__nicematrix_x_initial_dim } { \dim_compare:nNnF \l__nicematrix_x_initial_dim = \l__nicematrix_x_final_dim { \dim_set:Nn \l__nicematrix_x_initial_dim { \bool_if:NTF \l_tmpa_bool \dim_min:nn \dim_max:nn \l__nicematrix_x_initial_dim \l__nicematrix_x_final_dim } \dim_set_eq:NN \l__nicematrix_x_final_dim \l__nicematrix_x_initial_dim } } } \__nicematrix_draw_line: } \cs_new_protected:Npn \__nicematrix_draw_Ddots:nnn #1 #2 #3 { \__nicematrix_adjust_to_submatrix:nn { #1 } { #2 } \cs_if_free:cT { __nicematrix _ dotted _ #1 - #2 } { \__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } 1 1 \group_begin: \keys_set:nn { NiceMatrix / xdots } { #3 } \tl_if_empty:VF \l__nicematrix_xdots_color_tl { \color { \l__nicematrix_xdots_color_tl } } \__nicematrix_actually_draw_Ddots: \group_end: } } \cs_new_protected:Npn \__nicematrix_actually_draw_Ddots: { \bool_if:NTF \l__nicematrix_initial_open_bool { \__nicematrix_open_y_initial_dim: \__nicematrix_open_x_initial_dim: } { \__nicematrix_set_initial_coords_from_anchor:n { south~east } } \bool_if:NTF \l__nicematrix_final_open_bool { \__nicematrix_open_x_final_dim: \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x } { \__nicematrix_set_final_coords_from_anchor:n { north~west } } \bool_if:NT \l__nicematrix_parallelize_diags_bool { \int_gincr:N \g__nicematrix_ddots_int \int_compare:nNnTF \g__nicematrix_ddots_int = 1 { \dim_gset:Nn \g__nicematrix_delta_x_one_dim { \l__nicematrix_x_final_dim - \l__nicematrix_x_initial_dim } \dim_gset:Nn \g__nicematrix_delta_y_one_dim { \l__nicematrix_y_final_dim - \l__nicematrix_y_initial_dim } } { \dim_set:Nn \l__nicematrix_y_final_dim { \l__nicematrix_y_initial_dim + ( \l__nicematrix_x_final_dim - \l__nicematrix_x_initial_dim ) * \dim_ratio:nn \g__nicematrix_delta_y_one_dim \g__nicematrix_delta_x_one_dim } } } \__nicematrix_draw_line: } \cs_new_protected:Npn \__nicematrix_draw_Iddots:nnn #1 #2 #3 { \__nicematrix_adjust_to_submatrix:nn { #1 } { #2 } \cs_if_free:cT { __nicematrix _ dotted _ #1 - #2 } { \__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } 1 { -1 } \group_begin: \keys_set:nn { NiceMatrix / xdots } { #3 } \tl_if_empty:VF \l__nicematrix_xdots_color_tl { \color { \l__nicematrix_xdots_color_tl } } \__nicematrix_actually_draw_Iddots: \group_end: } } \cs_new_protected:Npn \__nicematrix_actually_draw_Iddots: { \bool_if:NTF \l__nicematrix_initial_open_bool { \__nicematrix_open_y_initial_dim: \__nicematrix_open_x_initial_dim: } { \__nicematrix_set_initial_coords_from_anchor:n { south~west } } \bool_if:NTF \l__nicematrix_final_open_bool { \__nicematrix_open_y_final_dim: \__nicematrix_open_x_final_dim: } { \__nicematrix_set_final_coords_from_anchor:n { north~east } } \bool_if:NT \l__nicematrix_parallelize_diags_bool { \int_gincr:N \g__nicematrix_iddots_int \int_compare:nNnTF \g__nicematrix_iddots_int = 1 { \dim_gset:Nn \g__nicematrix_delta_x_two_dim { \l__nicematrix_x_final_dim - \l__nicematrix_x_initial_dim } \dim_gset:Nn \g__nicematrix_delta_y_two_dim { \l__nicematrix_y_final_dim - \l__nicematrix_y_initial_dim } } { \dim_set:Nn \l__nicematrix_y_final_dim { \l__nicematrix_y_initial_dim + ( \l__nicematrix_x_final_dim - \l__nicematrix_x_initial_dim ) * \dim_ratio:nn \g__nicematrix_delta_y_two_dim \g__nicematrix_delta_x_two_dim } } } \__nicematrix_draw_line: } \cs_new_protected:Npn \__nicematrix_draw_line: { \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse \bool_lazy_or:nnTF { \tl_if_eq_p:NN \l__nicematrix_xdots_line_style_tl \c__nicematrix_standard_tl } \l__nicematrix_dotted_bool \__nicematrix_draw_standard_dotted_line: \__nicematrix_draw_unstandard_dotted_line: } \cs_new_protected:Npn \__nicematrix_draw_unstandard_dotted_line: { \begin { scope } \__nicematrix_draw_unstandard_dotted_line:o { \l__nicematrix_xdots_line_style_tl , \l__nicematrix_xdots_color_tl } } \cs_new_protected:Npn \__nicematrix_draw_unstandard_dotted_line:n #1 { \__nicematrix_draw_unstandard_dotted_line:nVV { #1 } \l__nicematrix_xdots_up_tl \l__nicematrix_xdots_down_tl } \cs_generate_variant:Nn \__nicematrix_draw_unstandard_dotted_line:n { o } \cs_new_protected:Npn \__nicematrix_draw_unstandard_dotted_line:nnn #1 #2 #3 { \draw [ #1 , shorten~> = \l__nicematrix_xdots_shorten_end_dim , shorten~< = \l__nicematrix_xdots_shorten_start_dim , ] ( \l__nicematrix_x_initial_dim , \l__nicematrix_y_initial_dim ) -- node [ sloped , above ] { $ \scriptstyle #2 $ } node [ sloped , below ] { $ \scriptstyle #3 $ } ( \l__nicematrix_x_final_dim , \l__nicematrix_y_final_dim ) ; \end { scope } } \cs_generate_variant:Nn \__nicematrix_draw_unstandard_dotted_line:nnn { n V V } \cs_new_protected:Npn \__nicematrix_draw_standard_dotted_line: { \bool_lazy_and:nnF { \tl_if_empty_p:N \l__nicematrix_xdots_up_tl } { \tl_if_empty_p:N \l__nicematrix_xdots_down_tl } { \pgfscope \pgftransformshift { \pgfpointlineattime { 0.5 } { \pgfpoint \l__nicematrix_x_initial_dim \l__nicematrix_y_initial_dim } { \pgfpoint \l__nicematrix_x_final_dim \l__nicematrix_y_final_dim } } \pgftransformrotate { \fp_eval:n { atand ( \l__nicematrix_y_final_dim - \l__nicematrix_y_initial_dim , \l__nicematrix_x_final_dim - \l__nicematrix_x_initial_dim ) } } \pgfnode { rectangle } { south } { \c_math_toggle_token \scriptstyle \l__nicematrix_xdots_up_tl \c_math_toggle_token } { } { \pgfusepath { } } \pgfnode { rectangle } { north } { \c_math_toggle_token \scriptstyle \l__nicematrix_xdots_down_tl \c_math_toggle_token } { } { \pgfusepath { } } \endpgfscope } \group_begin: \dim_zero_new:N \l__nicematrix_l_dim \dim_set:Nn \l__nicematrix_l_dim { \fp_to_dim:n { sqrt ( ( \l__nicematrix_x_final_dim - \l__nicematrix_x_initial_dim ) ^ 2 + ( \l__nicematrix_y_final_dim - \l__nicematrix_y_initial_dim ) ^ 2 ) } } \bool_lazy_or:nnF { \dim_compare_p:nNn { \dim_abs:n \l__nicematrix_l_dim } > \c__nicematrix_max_l_dim } { \dim_compare_p:nNn \l__nicematrix_l_dim = \c_zero_dim } \__nicematrix_draw_standard_dotted_line_i: \group_end: } \dim_const:Nn \c__nicematrix_max_l_dim { 50 cm } \cs_new_protected:Npn \__nicematrix_draw_standard_dotted_line_i: { \bool_if:NTF \l__nicematrix_initial_open_bool { \bool_if:NTF \l__nicematrix_final_open_bool { \int_set:Nn \l_tmpa_int { \dim_ratio:nn \l__nicematrix_l_dim \l__nicematrix_xdots_inter_dim } } { \int_set:Nn \l_tmpa_int { \dim_ratio:nn { \l__nicematrix_l_dim - \l__nicematrix_xdots_shorten_start_dim } \l__nicematrix_xdots_inter_dim } } } { \bool_if:NTF \l__nicematrix_final_open_bool { \int_set:Nn \l_tmpa_int { \dim_ratio:nn { \l__nicematrix_l_dim - \l__nicematrix_xdots_shorten_end_dim } \l__nicematrix_xdots_inter_dim } } { \int_set:Nn \l_tmpa_int { \dim_ratio:nn { \l__nicematrix_l_dim - \l__nicematrix_xdots_shorten_start_dim - \l__nicematrix_xdots_shorten_end_dim } \l__nicematrix_xdots_inter_dim } } } \dim_set:Nn \l_tmpa_dim { ( \l__nicematrix_x_final_dim - \l__nicematrix_x_initial_dim ) * \dim_ratio:nn \l__nicematrix_xdots_inter_dim \l__nicematrix_l_dim } \dim_set:Nn \l_tmpb_dim { ( \l__nicematrix_y_final_dim - \l__nicematrix_y_initial_dim ) * \dim_ratio:nn \l__nicematrix_xdots_inter_dim \l__nicematrix_l_dim } \dim_gadd:Nn \l__nicematrix_x_initial_dim { ( \l__nicematrix_x_final_dim - \l__nicematrix_x_initial_dim ) * \dim_ratio:nn { \l__nicematrix_l_dim - \l__nicematrix_xdots_inter_dim * \l_tmpa_int + \l__nicematrix_xdots_shorten_start_dim - \l__nicematrix_xdots_shorten_end_dim } { 2 \l__nicematrix_l_dim } } \dim_gadd:Nn \l__nicematrix_y_initial_dim { ( \l__nicematrix_y_final_dim - \l__nicematrix_y_initial_dim ) * \dim_ratio:nn { \l__nicematrix_l_dim - \l__nicematrix_xdots_inter_dim * \l_tmpa_int + \l__nicematrix_xdots_shorten_start_dim - \l__nicematrix_xdots_shorten_end_dim } { 2 \l__nicematrix_l_dim } } \pgf@relevantforpicturesizefalse \int_step_inline:nnn 0 \l_tmpa_int { \pgfpathcircle { \pgfpoint \l__nicematrix_x_initial_dim \l__nicematrix_y_initial_dim } { \l__nicematrix_xdots_radius_dim } \dim_add:Nn \l__nicematrix_x_initial_dim \l_tmpa_dim \dim_add:Nn \l__nicematrix_y_initial_dim \l_tmpb_dim } \pgfusepathqfill } \hook_gput_code:nnn { begindocument } { . } { \tl_set:Nn \l__nicematrix_argspec_tl { O { } E { _ ^ } { { } { } } } \tl_set_rescan:Nno \l__nicematrix_argspec_tl { } \l__nicematrix_argspec_tl \exp_args:NNV \NewDocumentCommand \__nicematrix_Ldots \l__nicematrix_argspec_tl { \int_compare:nNnTF \c@jCol = 0 { \__nicematrix_error:nn { in~first~col } \Ldots } { \int_compare:nNnTF \c@jCol = \l__nicematrix_last_col_int { \__nicematrix_error:nn { in~last~col } \Ldots } { \__nicematrix_instruction_of_type:nnn \c_false_bool { Ldots } { #1 , down = #2 , up = #3 } } } \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom { \ensuremath { \__nicematrix_old_ldots } } } \bool_gset_true:N \g__nicematrix_empty_cell_bool } \exp_args:NNV \NewDocumentCommand \__nicematrix_Cdots \l__nicematrix_argspec_tl { \int_compare:nNnTF \c@jCol = 0 { \__nicematrix_error:nn { in~first~col } \Cdots } { \int_compare:nNnTF \c@jCol = \l__nicematrix_last_col_int { \__nicematrix_error:nn { in~last~col } \Cdots } { \__nicematrix_instruction_of_type:nnn \c_false_bool { Cdots } { #1 , down = #2 , up = #3 } } } \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom { \ensuremath { \__nicematrix_old_cdots } } } \bool_gset_true:N \g__nicematrix_empty_cell_bool } \exp_args:NNV \NewDocumentCommand \__nicematrix_Vdots \l__nicematrix_argspec_tl { \int_compare:nNnTF \c@iRow = 0 { \__nicematrix_error:nn { in~first~row } \Vdots } { \int_compare:nNnTF \c@iRow = \l__nicematrix_last_row_int { \__nicematrix_error:nn { in~last~row } \Vdots } { \__nicematrix_instruction_of_type:nnn \c_false_bool { Vdots } { #1 , down = #2 , up = #3 } } } \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom { \ensuremath { \__nicematrix_old_vdots } } } \bool_gset_true:N \g__nicematrix_empty_cell_bool } \exp_args:NNV \NewDocumentCommand \__nicematrix_Ddots \l__nicematrix_argspec_tl { \int_case:nnF \c@iRow { 0 { \__nicematrix_error:nn { in~first~row } \Ddots } \l__nicematrix_last_row_int { \__nicematrix_error:nn { in~last~row } \Ddots } } { \int_case:nnF \c@jCol { 0 { \__nicematrix_error:nn { in~first~col } \Ddots } \l__nicematrix_last_col_int { \__nicematrix_error:nn { in~last~col } \Ddots } } { \keys_set_known:nn { NiceMatrix / Ddots } { #1 } \__nicematrix_instruction_of_type:nnn \l__nicematrix_draw_first_bool { Ddots } { #1 , down = #2 , up = #3 } } } \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom { \ensuremath { \__nicematrix_old_ddots } } } \bool_gset_true:N \g__nicematrix_empty_cell_bool } \exp_args:NNV \NewDocumentCommand \__nicematrix_Iddots \l__nicematrix_argspec_tl { \int_case:nnF \c@iRow { 0 { \__nicematrix_error:nn { in~first~row } \Iddots } \l__nicematrix_last_row_int { \__nicematrix_error:nn { in~last~row } \Iddots } } { \int_case:nnF \c@jCol { 0 { \__nicematrix_error:nn { in~first~col } \Iddots } \l__nicematrix_last_col_int { \__nicematrix_error:nn { in~last~col } \Iddots } } { \keys_set_known:nn { NiceMatrix / Ddots } { #1 } \__nicematrix_instruction_of_type:nnn \l__nicematrix_draw_first_bool { Iddots } { #1 , down = #2 , up = #3 } } } \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom { \ensuremath { \__nicematrix_old_iddots } } } \bool_gset_true:N \g__nicematrix_empty_cell_bool } } \keys_define:nn { NiceMatrix / Ddots } { draw-first .bool_set:N = \l__nicematrix_draw_first_bool , draw-first .default:n = true , draw-first .value_forbidden:n = true } \cs_new_protected:Npn \__nicematrix_Hspace: { \bool_gset_true:N \g__nicematrix_empty_cell_bool \hspace } \cs_set_eq:NN \__nicematrix_old_multicolumn \multicolumn \cs_new:Npn \__nicematrix_Hdotsfor: { \bool_lazy_and:nnTF { \int_compare_p:nNn \c@jCol = 0 } { \int_compare_p:nNn \l__nicematrix_first_col_int = 0 } { \bool_if:NTF \g__nicematrix_after_col_zero_bool { \multicolumn { 1 } { c } { } \__nicematrix_Hdotsfor_i } { \__nicematrix_fatal:n { Hdotsfor~in~col~0 } } } { \multicolumn { 1 } { c } { } \__nicematrix_Hdotsfor_i } } \hook_gput_code:nnn { begindocument } { . } { \tl_set:Nn \l__nicematrix_argspec_tl { O { } m O { } E { _ ^ } { { } { } } } \tl_set_rescan:Nno \l__nicematrix_argspec_tl { } \l__nicematrix_argspec_tl \exp_args:NNV \NewDocumentCommand \__nicematrix_Hdotsfor_i \l__nicematrix_argspec_tl { \tl_gput_right:Nx \g__nicematrix_HVdotsfor_lines_tl { \__nicematrix_Hdotsfor:nnnn { \int_use:N \c@iRow } { \int_use:N \c@jCol } { #2 } { #1 , #3 , down = \exp_not:n { #4 } , up = \exp_not:n { #5 } } } \prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { c } { } } } } \cs_new_protected:Npn \__nicematrix_Hdotsfor:nnnn #1 #2 #3 #4 { \bool_set_false:N \l__nicematrix_initial_open_bool \bool_set_false:N \l__nicematrix_final_open_bool \int_set:Nn \l__nicematrix_initial_i_int { #1 } \int_set_eq:NN \l__nicematrix_final_i_int \l__nicematrix_initial_i_int \int_compare:nNnTF { #2 } = 1 { \int_set:Nn \l__nicematrix_initial_j_int 1 \bool_set_true:N \l__nicematrix_initial_open_bool } { \cs_if_exist:cTF { pgf @ sh @ ns @ \__nicematrix_env: - \int_use:N \l__nicematrix_initial_i_int - \int_eval:n { #2 - 1 } } { \int_set:Nn \l__nicematrix_initial_j_int { #2 - 1 } } { \int_set:Nn \l__nicematrix_initial_j_int { #2 } \bool_set_true:N \l__nicematrix_initial_open_bool } } \int_compare:nNnTF { #2 + #3 -1 } = \c@jCol { \int_set:Nn \l__nicematrix_final_j_int { #2 + #3 - 1 } \bool_set_true:N \l__nicematrix_final_open_bool } { \cs_if_exist:cTF { pgf @ sh @ ns @ \__nicematrix_env: - \int_use:N \l__nicematrix_final_i_int - \int_eval:n { #2 + #3 } } { \int_set:Nn \l__nicematrix_final_j_int { #2 + #3 } } { \int_set:Nn \l__nicematrix_final_j_int { #2 + #3 - 1 } \bool_set_true:N \l__nicematrix_final_open_bool } } \group_begin: \int_compare:nNnTF { #1 } = 0 { \color { nicematrix-first-row } } { \int_compare:nNnT { #1 } = \g__nicematrix_row_total_int { \color { nicematrix-last-row } } } \keys_set:nn { NiceMatrix / xdots } { #4 } \tl_if_empty:VF \l__nicematrix_xdots_color_tl { \color { \l__nicematrix_xdots_color_tl } } \__nicematrix_actually_draw_Ldots: \group_end: \int_step_inline:nnn { #2 } { #2 + #3 - 1 } { \cs_set:cpn { __nicematrix _ dotted _ #1 - ##1 } { } } } \hook_gput_code:nnn { begindocument } { . } { \tl_set:Nn \l__nicematrix_argspec_tl { O { } m O { } E { _ ^ } { { } { } } } \tl_set_rescan:Nno \l__nicematrix_argspec_tl { } \l__nicematrix_argspec_tl \exp_args:NNV \NewDocumentCommand \__nicematrix_Vdotsfor: \l__nicematrix_argspec_tl { \tl_gput_right:Nx \g__nicematrix_HVdotsfor_lines_tl { \__nicematrix_Vdotsfor:nnnn { \int_use:N \c@iRow } { \int_use:N \c@jCol } { #2 } { #1 , #3 , down = \exp_not:n { #4 } , up = \exp_not:n { #5 } } } } } \cs_new_protected:Npn \__nicematrix_Vdotsfor:nnnn #1 #2 #3 #4 { \bool_set_false:N \l__nicematrix_initial_open_bool \bool_set_false:N \l__nicematrix_final_open_bool \int_set:Nn \l__nicematrix_initial_j_int { #2 } \int_set_eq:NN \l__nicematrix_final_j_int \l__nicematrix_initial_j_int \int_compare:nNnTF #1 = 1 { \int_set:Nn \l__nicematrix_initial_i_int 1 \bool_set_true:N \l__nicematrix_initial_open_bool } { \cs_if_exist:cTF { pgf @ sh @ ns @ \__nicematrix_env: - \int_eval:n { #1 - 1 } - \int_use:N \l__nicematrix_initial_j_int } { \int_set:Nn \l__nicematrix_initial_i_int { #1 - 1 } } { \int_set:Nn \l__nicematrix_initial_i_int { #1 } \bool_set_true:N \l__nicematrix_initial_open_bool } } \int_compare:nNnTF { #1 + #3 -1 } = \c@iRow { \int_set:Nn \l__nicematrix_final_i_int { #1 + #3 - 1 } \bool_set_true:N \l__nicematrix_final_open_bool } { \cs_if_exist:cTF { pgf @ sh @ ns @ \__nicematrix_env: - \int_eval:n { #1 + #3 } - \int_use:N \l__nicematrix_final_j_int } { \int_set:Nn \l__nicematrix_final_i_int { #1 + #3 } } { \int_set:Nn \l__nicematrix_final_i_int { #1 + #3 - 1 } \bool_set_true:N \l__nicematrix_final_open_bool } } \group_begin: \int_compare:nNnTF { #2 } = 0 { \color { nicematrix-first-col } } { \int_compare:nNnT { #2 } = \g__nicematrix_col_total_int { \color { nicematrix-last-col } } } \keys_set:nn { NiceMatrix / xdots } { #4 } \tl_if_empty:VF \l__nicematrix_xdots_color_tl { \color { \l__nicematrix_xdots_color_tl } } \__nicematrix_actually_draw_Vdots: \group_end: \int_step_inline:nnn { #1 } { #1 + #3 - 1 } { \cs_set:cpn { __nicematrix _ dotted _ ##1 - #2 } { } } } \cs_new_protected:Npn \__nicematrix_rotate: { \bool_gset_true:N \g__nicematrix_rotate_bool } \cs_new:Npn \__nicematrix_double_int_eval:n #1-#2 \q_stop { \tl_if_empty:nTF { #2 } { #1 } { \__nicematrix_double_int_eval_i:n #1-#2 \q_stop } } \cs_new:Npn \__nicematrix_double_int_eval_i:n #1-#2- \q_stop { \int_eval:n { #1 } - \int_eval:n { #2 } } \hook_gput_code:nnn { begindocument } { . } { \tl_set:Nn \l__nicematrix_argspec_tl { O { } m m ! O { } E { _ ^ } { { } { } } } \tl_set_rescan:Nno \l__nicematrix_argspec_tl { } \l__nicematrix_argspec_tl \exp_args:NNV \NewDocumentCommand \__nicematrix_line \l__nicematrix_argspec_tl { \group_begin: \keys_set:nn { NiceMatrix / xdots } { #1 , #4 , down = #5 , up = #6 } \tl_if_empty:VF \l__nicematrix_xdots_color_tl { \color { \l__nicematrix_xdots_color_tl } } \use:e { \__nicematrix_line_i:nn { \__nicematrix_double_int_eval:n #2 - \q_stop } { \__nicematrix_double_int_eval:n #3 - \q_stop } } \group_end: } } \cs_new_protected:Npn \__nicematrix_line_i:nn #1 #2 { \bool_set_false:N \l__nicematrix_initial_open_bool \bool_set_false:N \l__nicematrix_final_open_bool \bool_if:nTF { \cs_if_free_p:c { pgf @ sh @ ns @ \__nicematrix_env: - #1 } || \cs_if_free_p:c { pgf @ sh @ ns @ \__nicematrix_env: - #2 } } { \__nicematrix_error:nnn { unknown~cell~for~line~in~CodeAfter } { #1 } { #2 } } { \__nicematrix_draw_line_ii:nn { #1 } { #2 } } } \hook_gput_code:nnn { begindocument } { . } { \cs_new_protected:Npx \__nicematrix_draw_line_ii:nn #1 #2 { \c__nicematrix_pgfortikzpicture_tl \__nicematrix_draw_line_iii:nn { #1 } { #2 } \c__nicematrix_endpgfortikzpicture_tl } } \cs_new_protected:Npn \__nicematrix_draw_line_iii:nn #1 #2 { \pgfrememberpicturepositiononpagetrue \pgfpointshapeborder { \__nicematrix_env: - #1 } { \__nicematrix_qpoint:n { #2 } } \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x \dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y \pgfpointshapeborder { \__nicematrix_env: - #2 } { \__nicematrix_qpoint:n { #1 } } \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y \__nicematrix_draw_line: } \keys_define:nn { NiceMatrix / RowStyle } { cell-space-top-limit .dim_set:N = \l_tmpa_dim , cell-space-top-limit .initial:n = \c_zero_dim , cell-space-top-limit .value_required:n = true , cell-space-bottom-limit .dim_set:N = \l_tmpb_dim , cell-space-bottom-limit .initial:n = \c_zero_dim , cell-space-bottom-limit .value_required:n = true , cell-space-limits .meta:n = { cell-space-top-limit = #1 , cell-space-bottom-limit = #1 , } , color .tl_set:N = \l__nicematrix_color_tl , color .value_required:n = true , bold .bool_set:N = \l_tmpa_bool , bold .default:n = true , bold .initial:n = false , nb-rows .code:n = \str_if_eq:nnTF { #1 } { * } { \int_set:Nn \l__nicematrix_key_nb_rows_int { 500 } } { \int_set:Nn \l__nicematrix_key_nb_rows_int { #1 } } , nb-rows .value_required:n = true , rowcolor .tl_set:N = \l_tmpa_tl , rowcolor .value_required:n = true , rowcolor .initial:n = , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~RowStyle } } \NewDocumentCommand \__nicematrix_RowStyle:n { O { } m } { \group_begin: \tl_clear:N \l__nicematrix_color_tl \int_set:Nn \l__nicematrix_key_nb_rows_int 1 \keys_set:nn { NiceMatrix / RowStyle } { #1 } \tl_if_empty:NF \l_tmpa_tl { \tl_gput_right:Nx \g_nicematrix_code_before_tl { \__nicematrix_exp_color_arg:NV \__nicematrix_rectanglecolor \l_tmpa_tl { \int_use:N \c@iRow - \int_use:N \c@jCol } { \int_use:N \c@iRow - * } } \int_compare:nNnT \l__nicematrix_key_nb_rows_int > 1 { \tl_gput_right:Nx \g_nicematrix_code_before_tl { \__nicematrix_exp_color_arg:NV \__nicematrix_rowcolor \l_tmpa_tl { \int_eval:n { \c@iRow + 1 } - \int_eval:n { \c@iRow + \l__nicematrix_key_nb_rows_int - 1 } } } } } \tl_gput_right:Nn \g__nicematrix_row_style_tl { \ifnum \c@iRow < } \tl_gput_right:Nx \g__nicematrix_row_style_tl { \int_eval:n { \c@iRow + \l__nicematrix_key_nb_rows_int } } \tl_gput_right:Nn \g__nicematrix_row_style_tl { #2 } \dim_compare:nNnT \l_tmpa_dim > \c_zero_dim { \tl_gput_right:Nx \g__nicematrix_row_style_tl { \tl_gput_right:Nn \exp_not:N \g__nicematrix_cell_after_hook_tl { \dim_set:Nn \l__nicematrix_cell_space_top_limit_dim { \dim_use:N \l_tmpa_dim } } } } \dim_compare:nNnT \l_tmpb_dim > \c_zero_dim { \tl_gput_right:Nx \g__nicematrix_row_style_tl { \tl_gput_right:Nn \exp_not:N \g__nicematrix_cell_after_hook_tl { \dim_set:Nn \l__nicematrix_cell_space_bottom_limit_dim { \dim_use:N \l_tmpb_dim } } } } \tl_if_empty:NF \l__nicematrix_color_tl { \tl_gput_right:Nx \g__nicematrix_row_style_tl { \mode_leave_vertical: \__nicematrix_color:n { \l__nicematrix_color_tl } } } \bool_if:NT \l_tmpa_bool { \tl_gput_right:Nn \g__nicematrix_row_style_tl { \if_mode_math: \c_math_toggle_token \bfseries \boldmath \c_math_toggle_token \else: \bfseries \boldmath \fi: } } \tl_gput_right:Nn \g__nicematrix_row_style_tl { \fi } \group_end: \g__nicematrix_row_style_tl \ignorespaces } \cs_new_protected:Npn \__nicematrix_add_to_colors_seq:nn #1 #2 { \int_zero:N \l_tmpa_int \seq_map_indexed_inline:Nn \g__nicematrix_colors_seq { \tl_if_eq:nnT { #1 } { ##2 } { \int_set:Nn \l_tmpa_int { ##1 } } } \int_compare:nNnTF \l_tmpa_int = \c_zero_int { \seq_gput_right:Nn \g__nicematrix_colors_seq { #1 } \tl_gset:cx { g__nicematrix_color _ \seq_count:N \g__nicematrix_colors_seq _ tl } { #2 } } { \tl_gput_right:cx { g__nicematrix_color _ \int_use:N \l_tmpa_int _tl } { #2 } } } \cs_generate_variant:Nn \__nicematrix_add_to_colors_seq:nn { x n } \cs_generate_variant:Nn \__nicematrix_add_to_colors_seq:nn { x x } \cs_new_protected:Npn \__nicematrix_actually_color: { \pgfpicture \pgf@relevantforpicturesizefalse \seq_map_indexed_inline:Nn \g__nicematrix_colors_seq { \color ##2 \use:c { g__nicematrix_color _ ##1 _tl } \tl_gclear:c { g__nicematrix_color _ ##1 _tl } \pgfusepath { fill } } \endpgfpicture } \cs_new_protected:Npn \__nicematrix_cartesian_color:nn #1 #2 { \tl_set:Nn \l__nicematrix_rows_tl { #1 } \tl_set:Nn \l__nicematrix_cols_tl { #2 } \__nicematrix_cartesian_path: } \NewDocumentCommand \__nicematrix_rowcolor { O { } m m } { \tl_if_blank:nF { #2 } { \__nicematrix_add_to_colors_seq:xn { \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } } { \__nicematrix_cartesian_color:nn { #3 } { - } } } } \NewDocumentCommand \__nicematrix_columncolor { O { } m m } { \tl_if_blank:nF { #2 } { \__nicematrix_add_to_colors_seq:xn { \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } } { \__nicematrix_cartesian_color:nn { - } { #3 } } } } \NewDocumentCommand \__nicematrix_rectanglecolor { O { } m m m } { \tl_if_blank:nF { #2 } { \__nicematrix_add_to_colors_seq:xn { \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } } { \__nicematrix_rectanglecolor:nnn { #3 } { #4 } { 0 pt } } } } \NewDocumentCommand \__nicematrix_roundedrectanglecolor { O { } m m m m } { \tl_if_blank:nF { #2 } { \__nicematrix_add_to_colors_seq:xn { \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } } { \__nicematrix_rectanglecolor:nnn { #3 } { #4 } { #5 } } } } \cs_new_protected:Npn \__nicematrix_rectanglecolor:nnn #1 #2 #3 { \__nicematrix_cut_on_hyphen:w #1 \q_stop \tl_clear_new:N \l__nicematrix_tmpc_tl \tl_clear_new:N \l__nicematrix_tmpd_tl \tl_set_eq:NN \l__nicematrix_tmpc_tl \l_tmpa_tl \tl_set_eq:NN \l__nicematrix_tmpd_tl \l_tmpb_tl \__nicematrix_cut_on_hyphen:w #2 \q_stop \tl_set:Nx \l__nicematrix_rows_tl { \l__nicematrix_tmpc_tl - \l_tmpa_tl } \tl_set:Nx \l__nicematrix_cols_tl { \l__nicematrix_tmpd_tl - \l_tmpb_tl } \__nicematrix_cartesian_path:n { #3 } } \NewDocumentCommand \__nicematrix_cellcolor { O { } m m } { \clist_map_inline:nn { #3 } { \__nicematrix_rectanglecolor [ #1 ] { #2 } { ##1 } { ##1 } } } \NewDocumentCommand \__nicematrix_chessboardcolors { O { } m m } { \int_step_inline:nn { \int_use:N \c@iRow } { \int_step_inline:nn { \int_use:N \c@jCol } { \int_if_even:nTF { ####1 + ##1 } { \__nicematrix_cellcolor [ #1 ] { #2 } } { \__nicematrix_cellcolor [ #1 ] { #3 } } { ##1 - ####1 } } } } \NewDocumentCommand \__nicematrix_arraycolor { O { } m } { \__nicematrix_rectanglecolor [ #1 ] { #2 } { 1 - 1 } { \int_use:N \c@iRow - \int_use:N \c@jCol } } \keys_define:nn { NiceMatrix / rowcolors } { respect-blocks .bool_set:N = \l__nicematrix_respect_blocks_bool , respect-blocks .default:n = true , cols .tl_set:N = \l__nicematrix_cols_tl , restart .bool_set:N = \l__nicematrix_rowcolors_restart_bool , restart .default:n = true , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~rowcolors } } \NewDocumentCommand \__nicematrix_rowlistcolors { O { } m m O { } } { \group_begin: \seq_clear_new:N \l__nicematrix_colors_seq \seq_set_split:Nnn \l__nicematrix_colors_seq { , } { #3 } \tl_clear_new:N \l__nicematrix_cols_tl \tl_set:Nn \l__nicematrix_cols_tl { - } \keys_set:nn { NiceMatrix / rowcolors } { #4 } \int_zero_new:N \l__nicematrix_color_int \int_set:Nn \l__nicematrix_color_int 1 \bool_if:NT \l__nicematrix_respect_blocks_bool { \seq_set_eq:NN \l_tmpb_seq \g__nicematrix_pos_of_blocks_seq \seq_set_filter:NNn \l_tmpa_seq \l_tmpb_seq { \__nicematrix_not_in_exterior_p:nnnnn ##1 } } \pgfpicture \pgf@relevantforpicturesizefalse \clist_map_inline:nn { #2 } { \tl_set:Nn \l_tmpa_tl { ##1 } \tl_if_in:NnTF \l_tmpa_tl { - } { \__nicematrix_cut_on_hyphen:w ##1 \q_stop } { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } } \int_set:Nn \l_tmpa_int \l_tmpa_tl \bool_if:NTF \l__nicematrix_rowcolors_restart_bool { \int_set:Nn \l__nicematrix_color_int 1 } { \int_set:Nn \l__nicematrix_color_int \l_tmpa_tl } \int_zero_new:N \l__nicematrix_tmpc_int \int_set:Nn \l__nicematrix_tmpc_int \l_tmpb_tl \int_do_until:nNnn \l_tmpa_int > \l__nicematrix_tmpc_int { \int_set_eq:NN \l_tmpb_int \l_tmpa_int \bool_if:NT \l__nicematrix_respect_blocks_bool { \seq_set_filter:NNn \l_tmpb_seq \l_tmpa_seq { \__nicematrix_intersect_our_row_p:nnnnn ####1 } \seq_map_inline:Nn \l_tmpb_seq { \__nicematrix_rowcolors_i:nnnnn ####1 } } \tl_set:Nx \l__nicematrix_rows_tl { \int_use:N \l_tmpa_int - \int_use:N \l_tmpb_int } \tl_clear_new:N \l__nicematrix_color_tl \tl_set:Nx \l__nicematrix_color_tl { \__nicematrix_color_index:n { \int_mod:nn { \l__nicematrix_color_int - 1 } { \seq_count:N \l__nicematrix_colors_seq } + 1 } } \tl_if_empty:NF \l__nicematrix_color_tl { \__nicematrix_add_to_colors_seq:xx { \tl_if_blank:nF { #1 } { [ #1 ] } { \l__nicematrix_color_tl } } { \__nicematrix_cartesian_color:nn { \l__nicematrix_rows_tl } { \l__nicematrix_cols_tl } } } \int_incr:N \l__nicematrix_color_int \int_set:Nn \l_tmpa_int { \l_tmpb_int + 1 } } } \endpgfpicture \group_end: } \cs_new:Npn \__nicematrix_color_index:n #1 { \str_if_eq:eeTF { \seq_item:Nn \l__nicematrix_colors_seq { #1 } } { = } { \__nicematrix_color_index:n { #1 - 1 } } { \seq_item:Nn \l__nicematrix_colors_seq { #1 } } } \NewDocumentCommand \__nicematrix_rowcolors { O { } m m m O { } } { \__nicematrix_rowlistcolors [ #1 ] { #2 } { { #3 } , { #4 } } [ #5 ] } \cs_new_protected:Npn \__nicematrix_rowcolors_i:nnnnn #1 #2 #3 #4 #5 { \int_compare:nNnT { #3 } > \l_tmpb_int { \int_set:Nn \l_tmpb_int { #3 } } } \prg_new_conditional:Nnn \__nicematrix_not_in_exterior:nnnnn p { \bool_lazy_or:nnTF { \int_compare_p:nNn { #4 } = \c_zero_int } { \int_compare_p:nNn { #2 } = { \int_eval:n { \c@jCol + 1 } } } \prg_return_false: \prg_return_true: } \prg_new_conditional:Nnn \__nicematrix_intersect_our_row:nnnnn p { \bool_if:nTF { \int_compare_p:n { #1 <= \l_tmpa_int } && \int_compare_p:n { \l_tmpa_int <= #3 } } \prg_return_true: \prg_return_false: } \cs_new_protected:Npn \__nicematrix_cartesian_path:n #1 { \bool_lazy_and:nnT { ! \seq_if_empty_p:N \l__nicematrix_corners_cells_seq } { \dim_compare_p:nNn { #1 } = \c_zero_dim } { \__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_cols_tl { \tl_set:Nn \l_tmpa_tl { ##1 } \tl_if_in:NnTF \l_tmpa_tl { - } { \__nicematrix_cut_on_hyphen:w ##1 \q_stop } { \__nicematrix_cut_on_hyphen:w ##1 - ##1 \q_stop } \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 } } \tl_set_eq:NN \l__nicematrix_tmpc_tl \l_tmpa_tl \__nicematrix_qpoint:n { col - \l_tmpa_tl } \int_compare:nNnTF \l__nicematrix_first_col_int = \l_tmpa_tl { \dim_set:Nn \l__nicematrix_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } } { \dim_set:Nn \l__nicematrix_tmpc_dim { \pgf@x + 0.5 \arrayrulewidth } } \__nicematrix_qpoint:n { col - \int_eval:n { \l_tmpb_tl + 1 } } \dim_set:Nn \l_tmpa_dim { \pgf@x + 0.5 \arrayrulewidth } \clist_map_inline:Nn \l__nicematrix_rows_tl { \tl_set:Nn \l_tmpa_tl { ####1 } \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 { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } } \int_compare:nNnT \l_tmpb_tl > \c@iRow { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } } \seq_if_in:NxF \l__nicematrix_corners_cells_seq { \l_tmpa_tl - \l__nicematrix_tmpc_tl } { \__nicematrix_qpoint:n { row - \int_eval:n { \l_tmpb_tl + 1 } } \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth } \__nicematrix_qpoint:n { row - \l_tmpa_tl } \dim_set:Nn \l__nicematrix_tmpd_dim { \pgf@y + 0.5 \arrayrulewidth } \pgfsetcornersarced { \pgfpoint { #1 } { #1 } } \pgfpathrectanglecorners { \pgfpoint \l__nicematrix_tmpc_dim \l__nicematrix_tmpd_dim } { \pgfpoint \l_tmpa_dim \l_tmpb_dim } } } } } \cs_new_protected:Npn \__nicematrix_cartesian_path: { \__nicematrix_cartesian_path:n { 0 pt } } \cs_new_protected:Npn \__nicematrix_expand_clist:NN #1 #2 { \clist_set_eq:NN \l_tmpa_clist #1 \clist_clear:N #1 \clist_map_inline:Nn \l_tmpa_clist { \tl_set:Nn \l_tmpa_tl { ##1 } \tl_if_in:NnTF \l_tmpa_tl { - } { \__nicematrix_cut_on_hyphen:w ##1 \q_stop } { \__nicematrix_cut_on_hyphen:w ##1 - ##1 \q_stop } \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 #2 } } \int_compare:nNnT \l_tmpb_tl > #2 { \tl_set:Nx \l_tmpb_tl { \int_use:N #2 } } \int_step_inline:nnn \l_tmpa_tl \l_tmpb_tl { \clist_put_right:Nn #1 { ####1 } } } } \NewDocumentCommand \__nicematrix_cellcolor_tabular { O { } m } { \peek_remove_spaces:n { \tl_gput_right:Nx \g_nicematrix_code_before_tl { \__nicematrix_cellcolor [ #1 ] { \exp_not:n { #2 } } { \int_use:N \c@iRow - \int_use:N \c@jCol } } } } \NewDocumentCommand \__nicematrix_rowcolor_tabular { O { } m } { \peek_remove_spaces:n { \tl_gput_right:Nx \g_nicematrix_code_before_tl { \__nicematrix_rectanglecolor [ #1 ] { \exp_not:n { #2 } } { \int_use:N \c@iRow - \int_use:N \c@jCol } { \int_use:N \c@iRow - \exp_not:n { \int_use:N \c@jCol } } } } } \NewDocumentCommand \__nicematrix_columncolor_preamble { O { } m } { \int_compare:nNnT \c@jCol > \g__nicematrix_col_total_int { \tl_gput_left:Nx \g_nicematrix_code_before_tl { \exp_not:N \columncolor [ #1 ] { \exp_not:n { #2 } } { \int_use:N \c@jCol } } } } \cs_set_eq:NN \OnlyMainNiceMatrix \use:n \cs_new_protected:Npn \__nicematrix_OnlyMainNiceMatrix:n #1 { \int_compare:nNnTF \l__nicematrix_first_col_int = 0 { \__nicematrix_OnlyMainNiceMatrix_i:n { #1 } } { \int_compare:nNnTF \c@jCol = 0 { \int_compare:nNnF \c@iRow = { -1 } { \int_compare:nNnF \c@iRow = { \l__nicematrix_last_row_int - 1 } { #1 } } } { \__nicematrix_OnlyMainNiceMatrix_i:n { #1 } } } } \cs_new_protected:Npn \__nicematrix_OnlyMainNiceMatrix_i:n #1 { \int_compare:nNnF \c@iRow = 0 { \int_compare:nNnF \c@iRow = \l__nicematrix_last_row_int { #1 } } } \keys_define:nn { NiceMatrix / Rules } { position .int_set:N = \l__nicematrix_position_int , position .value_required:n = true , start .int_set:N = \l__nicematrix_start_int , start .initial:n = 1 , end .code:n = \bool_lazy_or:nnTF { \tl_if_empty_p:n { #1 } } { \str_if_eq_p:nn { #1 } { last } } { \int_set_eq:NN \l__nicematrix_end_int \c@jCol } { \int_set:Nn \l__nicematrix_end_int { #1 } } } \keys_define:nn { NiceMatrix / RulesBis } { multiplicity .int_set:N = \l__nicematrix_multiplicity_int , multiplicity .initial:n = 1 , dotted .bool_set:N = \l__nicematrix_dotted_bool , dotted .initial:n = false , dotted .default:n = true , color .code:n = \__nicematrix_set_CT@arc@:n { #1 } , color .value_required:n = true , sep-color .code:n = \__nicematrix_set_CT@drsc@:n { #1 } , sep-color .value_required:n = true , tikz .tl_set:N = \l__nicematrix_tikz_rule_tl , tikz .value_required:n = true , tikz .initial:n = , total-width .dim_set:N = \l__nicematrix_rule_width_dim , total-width .value_required:n = true , width .meta:n = { total-width = #1 } , unknown .code:n = \__nicematrix_error:n { Unknow~key~for~RulesBis } } \cs_new_protected:Npn \__nicematrix_vline:n #1 { \group_begin: \int_zero_new:N \l__nicematrix_end_int \int_set_eq:NN \l__nicematrix_end_int \c@iRow \keys_set_known:nnN { NiceMatrix / Rules } { #1 } \l__nicematrix_other_keys_tl \int_compare:nNnT \l__nicematrix_position_int < { \c@jCol + 2 } \__nicematrix_vline_i: \group_end: } \cs_new_protected:Npn \__nicematrix_vline_i: { \int_zero_new:N \l__nicematrix_local_start_int \int_zero_new:N \l__nicematrix_local_end_int \tl_set:Nx \l_tmpb_tl { \int_eval:n \l__nicematrix_position_int } \int_step_variable:nnNn \l__nicematrix_start_int \l__nicematrix_end_int \l_tmpa_tl { \bool_gset_true:N \g_tmpa_bool \seq_map_inline:Nn \g__nicematrix_pos_of_blocks_seq { \__nicematrix_test_vline_in_block:nnnnn ##1 } \seq_map_inline:Nn \g__nicematrix_pos_of_xdots_seq { \__nicematrix_test_vline_in_block:nnnnn ##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_corners_clist \__nicematrix_test_in_corner_v: \bool_if:NTF \g_tmpa_bool { \int_compare:nNnT \l__nicematrix_local_start_int = 0 { \int_set:Nn \l__nicematrix_local_start_int \l_tmpa_tl } } { \int_compare:nNnT \l__nicematrix_local_start_int > 0 { \int_set:Nn \l__nicematrix_local_end_int { \l_tmpa_tl - 1 } \__nicematrix_vline_ii: \int_zero:N \l__nicematrix_local_start_int } } } \int_compare:nNnT \l__nicematrix_local_start_int > 0 { \int_set_eq:NN \l__nicematrix_local_end_int \l__nicematrix_end_int \__nicematrix_vline_ii: } } \cs_new_protected:Npn \__nicematrix_test_in_corner_v: { \int_compare:nNnTF \l_tmpb_tl = { \int_eval:n { \c@jCol + 1 } } { \seq_if_in:NxT \l__nicematrix_corners_cells_seq { \l_tmpa_tl - \int_eval:n { \l_tmpb_tl - 1 } } { \bool_set_false:N \g_tmpa_bool } } { \seq_if_in:NxT \l__nicematrix_corners_cells_seq { \l_tmpa_tl - \l_tmpb_tl } { \int_compare:nNnTF \l_tmpb_tl = 1 { \bool_set_false:N \g_tmpa_bool } { \seq_if_in:NxT \l__nicematrix_corners_cells_seq { \l_tmpa_tl - \int_eval:n { \l_tmpb_tl - 1 } } { \bool_set_false:N \g_tmpa_bool } } } } } \cs_new_protected:Npn \__nicematrix_vline_ii: { \keys_set:nV { NiceMatrix / RulesBis } \l__nicematrix_other_keys_tl \bool_if:NTF \l__nicematrix_dotted_bool \__nicematrix_vline_iv: { \tl_if_empty:NTF \l__nicematrix_tikz_rule_tl \__nicematrix_vline_iii: \__nicematrix_vline_v: } } \cs_new_protected:Npn \__nicematrix_vline_iii: { \pgfpicture \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_local_start_int } \dim_set_eq:NN \l_tmpa_dim \pgf@y \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_position_int } \dim_set:Nn \l_tmpb_dim { \pgf@x - 0.5 \l__nicematrix_rule_width_dim + ( \arrayrulewidth * \l__nicematrix_multiplicity_int + \doublerulesep * ( \l__nicematrix_multiplicity_int - 1 ) ) / 2 } \__nicematrix_qpoint:n { row - \int_eval:n { \l__nicematrix_local_end_int + 1 } } \dim_set_eq:NN \l__nicematrix_tmpc_dim \pgf@y \bool_lazy_all:nT { { \int_compare_p:nNn \l__nicematrix_multiplicity_int > 1 } { \cs_if_exist_p:N \CT@drsc@ } { ! \tl_if_blank_p:V \CT@drsc@ } } { \group_begin: \CT@drsc@ \dim_add:Nn \l_tmpa_dim { 0.5 \arrayrulewidth } \dim_sub:Nn \l__nicematrix_tmpc_dim { 0.5 \arrayrulewidth } \dim_set:Nn \l__nicematrix_tmpd_dim { \l_tmpb_dim - ( \doublerulesep + \arrayrulewidth ) * ( \l__nicematrix_multiplicity_int - 1 ) } \pgfpathrectanglecorners { \pgfpoint \l_tmpb_dim \l_tmpa_dim } { \pgfpoint \l__nicematrix_tmpd_dim \l__nicematrix_tmpc_dim } \pgfusepath { fill } \group_end: } \pgfpathmoveto { \pgfpoint \l_tmpb_dim \l_tmpa_dim } \pgfpathlineto { \pgfpoint \l_tmpb_dim \l__nicematrix_tmpc_dim } \prg_replicate:nn { \l__nicematrix_multiplicity_int - 1 } { \dim_sub:Nn \l_tmpb_dim \arrayrulewidth \dim_sub:Nn \l_tmpb_dim \doublerulesep \pgfpathmoveto { \pgfpoint \l_tmpb_dim \l_tmpa_dim } \pgfpathlineto { \pgfpoint \l_tmpb_dim \l__nicematrix_tmpc_dim } } \CT@arc@ \pgfsetlinewidth { 1.1 \arrayrulewidth } \pgfsetrectcap \pgfusepathqstroke \endpgfpicture } \cs_new_protected:Npn \__nicematrix_vline_iv: { \pgfpicture \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_position_int } \dim_set:Nn \l__nicematrix_x_initial_dim { \pgf@x - 0.5 \l__nicematrix_rule_width_dim } \dim_set_eq:NN \l__nicematrix_x_final_dim \l__nicematrix_x_initial_dim \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_local_start_int } \dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y \__nicematrix_qpoint:n { row - \int_eval:n { \l__nicematrix_local_end_int + 1 } } \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y \CT@arc@ \__nicematrix_draw_line: \endpgfpicture } \cs_new_protected:Npn \__nicematrix_vline_v: { \begin {tikzpicture } \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_local_start_int } \dim_set_eq:NN \l_tmpa_dim \pgf@y \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_position_int } \dim_set:Nn \l_tmpb_dim { \pgf@x - 0.5 \l__nicematrix_rule_width_dim } \__nicematrix_qpoint:n { row - \int_eval:n { \l__nicematrix_local_end_int + 1 } } \dim_set_eq:NN \l__nicematrix_tmpc_dim \pgf@y \exp_args:NV \tikzset \l__nicematrix_tikz_rule_tl \use:x { \exp_not:N \draw [ \l__nicematrix_tikz_rule_tl ] } ( \l_tmpb_dim , \l_tmpa_dim ) -- ( \l_tmpb_dim , \l__nicematrix_tmpc_dim ) ; \end { tikzpicture } } \cs_new_protected:Npn \__nicematrix_draw_vlines: { \int_step_inline:nnn { \bool_if:nTF { \g__nicematrix_NiceArray_bool && ! \l__nicematrix_except_borders_bool } 1 2 } { \bool_if:nTF { \g__nicematrix_NiceArray_bool && ! \l__nicematrix_except_borders_bool } { \int_eval:n { \c@jCol + 1 } } \c@jCol } { \tl_if_eq:NnF \l__nicematrix_vlines_clist { all } { \clist_if_in:NnT \l__nicematrix_vlines_clist { ##1 } } { \__nicematrix_vline:n { position = ##1 , total-width = \arrayrulewidth } } } } \cs_new_protected:Npn \__nicematrix_hline:n #1 { \group_begin: \int_zero_new:N \l__nicematrix_end_int \int_set_eq:NN \l__nicematrix_end_int \c@jCol \keys_set_known:nnN { NiceMatrix / Rules } { #1 } \l__nicematrix_other_keys_tl \__nicematrix_hline_i: \group_end: } \cs_new_protected:Npn \__nicematrix_hline_i: { \int_zero_new:N \l__nicematrix_local_start_int \int_zero_new:N \l__nicematrix_local_end_int \tl_set:Nx \l_tmpa_tl { \int_use:N \l__nicematrix_position_int } \int_step_variable:nnNn \l__nicematrix_start_int \l__nicematrix_end_int \l_tmpb_tl { \bool_gset_true:N \g_tmpa_bool \seq_map_inline:Nn \g__nicematrix_pos_of_blocks_seq { \__nicematrix_test_hline_in_block:nnnnn ##1 } \seq_map_inline:Nn \g__nicematrix_pos_of_xdots_seq { \__nicematrix_test_hline_in_block:nnnnn ##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_corners_clist \__nicematrix_test_in_corner_h: \bool_if:NTF \g_tmpa_bool { \int_compare:nNnT \l__nicematrix_local_start_int = 0 { \int_set:Nn \l__nicematrix_local_start_int \l_tmpb_tl } } { \int_compare:nNnT \l__nicematrix_local_start_int > 0 { \int_set:Nn \l__nicematrix_local_end_int { \l_tmpb_tl - 1 } \__nicematrix_hline_ii: \int_zero:N \l__nicematrix_local_start_int } } } \int_compare:nNnT \l__nicematrix_local_start_int > 0 { \int_set_eq:NN \l__nicematrix_local_end_int \l__nicematrix_end_int \__nicematrix_hline_ii: } } \cs_new_protected:Npn \__nicematrix_test_in_corner_h: { \int_compare:nNnTF \l_tmpa_tl = { \int_eval:n { \c@iRow + 1 } } { \seq_if_in:NxT \l__nicematrix_corners_cells_seq { \int_eval:n { \l_tmpa_tl - 1 } - \l_tmpb_tl } { \bool_set_false:N \g_tmpa_bool } } { \seq_if_in:NxT \l__nicematrix_corners_cells_seq { \l_tmpa_tl - \l_tmpb_tl } { \int_compare:nNnTF \l_tmpa_tl = 1 { \bool_set_false:N \g_tmpa_bool } { \seq_if_in:NxT \l__nicematrix_corners_cells_seq { \int_eval:n { \l_tmpa_tl - 1 } - \l_tmpb_tl } { \bool_set_false:N \g_tmpa_bool } } } } } \cs_new_protected:Npn \__nicematrix_hline_ii: { % \bool_set_false:N \l__nicematrix_dotted_bool \keys_set:nV { NiceMatrix / RulesBis } \l__nicematrix_other_keys_tl \bool_if:NTF \l__nicematrix_dotted_bool \__nicematrix_hline_iv: { \tl_if_empty:NTF \l__nicematrix_tikz_rule_tl \__nicematrix_hline_iii: \__nicematrix_hline_v: } } \cs_new_protected:Npn \__nicematrix_hline_iii: { \pgfpicture \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_local_start_int } \dim_set_eq:NN \l_tmpa_dim \pgf@x \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_position_int } \dim_set:Nn \l_tmpb_dim { \pgf@y - 0.5 \l__nicematrix_rule_width_dim + ( \arrayrulewidth * \l__nicematrix_multiplicity_int + \doublerulesep * ( \l__nicematrix_multiplicity_int - 1 ) ) / 2 } \__nicematrix_qpoint:n { col - \int_eval:n { \l__nicematrix_local_end_int + 1 } } \dim_set_eq:NN \l__nicematrix_tmpc_dim \pgf@x \bool_lazy_all:nT { { \int_compare_p:nNn \l__nicematrix_multiplicity_int > 1 } { \cs_if_exist_p:N \CT@drsc@ } { ! \tl_if_blank_p:V \CT@drsc@ } } { \group_begin: \CT@drsc@ \dim_set:Nn \l__nicematrix_tmpd_dim { \l_tmpb_dim - ( \doublerulesep + \arrayrulewidth ) * ( \l__nicematrix_multiplicity_int - 1 ) } \pgfpathrectanglecorners { \pgfpoint \l_tmpa_dim \l_tmpb_dim } { \pgfpoint \l__nicematrix_tmpc_dim \l__nicematrix_tmpd_dim } \pgfusepathqfill \group_end: } \pgfpathmoveto { \pgfpoint \l_tmpa_dim \l_tmpb_dim } \pgfpathlineto { \pgfpoint \l__nicematrix_tmpc_dim \l_tmpb_dim } \prg_replicate:nn { \l__nicematrix_multiplicity_int - 1 } { \dim_sub:Nn \l_tmpb_dim \arrayrulewidth \dim_sub:Nn \l_tmpb_dim \doublerulesep \pgfpathmoveto { \pgfpoint \l_tmpa_dim \l_tmpb_dim } \pgfpathlineto { \pgfpoint \l__nicematrix_tmpc_dim \l_tmpb_dim } } \CT@arc@ \pgfsetlinewidth { 1.1 \arrayrulewidth } \pgfsetrectcap \pgfusepathqstroke \endpgfpicture } \cs_new_protected:Npn \__nicematrix_hline_iv: { \pgfpicture \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_position_int } \dim_set:Nn \l__nicematrix_y_initial_dim { \pgf@y - 0.5 \l__nicematrix_rule_width_dim } \dim_set_eq:NN \l__nicematrix_y_final_dim \l__nicematrix_y_initial_dim \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_local_start_int } \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x \int_compare:nNnT \l__nicematrix_local_start_int = 1 { \dim_sub:Nn \l__nicematrix_x_initial_dim \l__nicematrix_left_margin_dim \bool_if:NT \g__nicematrix_NiceArray_bool { \dim_sub:Nn \l__nicematrix_x_initial_dim \arraycolsep } \tl_if_eq:NnF \g__nicematrix_left_delim_tl ( { \dim_add:Nn \l__nicematrix_x_initial_dim { 0.5 \l__nicematrix_xdots_inter_dim } } } \__nicematrix_qpoint:n { col - \int_eval:n { \l__nicematrix_local_end_int + 1 } } \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x \int_compare:nNnT \l__nicematrix_local_end_int = \c@jCol { \dim_add:Nn \l__nicematrix_x_final_dim \l__nicematrix_right_margin_dim \bool_if:NT \g__nicematrix_NiceArray_bool { \dim_add:Nn \l__nicematrix_x_final_dim \arraycolsep } \tl_if_eq:NnF \g__nicematrix_right_delim_tl ) { \dim_gsub:Nn \l__nicematrix_x_final_dim { 0.5 \l__nicematrix_xdots_inter_dim } } } \CT@arc@ \__nicematrix_draw_line: \endpgfpicture } \cs_new_protected:Npn \__nicematrix_hline_v: { \begin { tikzpicture } \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_local_start_int } \dim_set_eq:NN \l_tmpa_dim \pgf@x \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_position_int } \dim_set:Nn \l_tmpb_dim { \pgf@y - 0.5 \l__nicematrix_rule_width_dim } \__nicematrix_qpoint:n { col - \int_eval:n { \l__nicematrix_local_end_int + 1 } } \dim_set_eq:NN \l__nicematrix_tmpc_dim \pgf@x \exp_args:NV \tikzset \l__nicematrix_tikz_rule_tl \use:x { \exp_not:N \draw [ \l__nicematrix_tikz_rule_tl ] } ( \l_tmpa_dim , \l_tmpb_dim ) -- ( \l__nicematrix_tmpc_dim , \l_tmpb_dim ) ; \end { tikzpicture } } \cs_new_protected:Npn \__nicematrix_draw_hlines: { \int_step_inline:nnn { \bool_if:nTF { \g__nicematrix_NiceArray_bool && ! \l__nicematrix_except_borders_bool } 1 2 } { \bool_if:nTF { \g__nicematrix_NiceArray_bool && ! \l__nicematrix_except_borders_bool } { \int_eval:n { \c@iRow + 1 } } \c@iRow } { \tl_if_eq:NnF \l__nicematrix_hlines_clist { all } { \clist_if_in:NnT \l__nicematrix_hlines_clist { ##1 } } { \__nicematrix_hline:n { position = ##1 , total-width = \arrayrulewidth } } } } \cs_set:Npn \__nicematrix_Hline: { \noalign \bgroup \__nicematrix_Hline_i:n { 1 } } \cs_set:Npn \__nicematrix_Hline_i:n #1 { \peek_remove_spaces:n { \peek_meaning:NTF \Hline { \__nicematrix_Hline_ii:nn { #1 + 1 } } { \__nicematrix_Hline_iii:n { #1 } } } } \cs_set:Npn \__nicematrix_Hline_ii:nn #1 #2 { \__nicematrix_Hline_i:n { #1 } } \cs_set:Npn \__nicematrix_Hline_iii:n #1 { \peek_meaning:NTF [ { \__nicematrix_Hline_iv:nw { #1 } } { \__nicematrix_Hline_iv:nw { #1 } [ ] } } \cs_set:Npn \__nicematrix_Hline_iv:nw #1 [ #2 ] { \__nicematrix_compute_rule_width:n { multiplicity = #1 , #2 } \skip_vertical:n { \l__nicematrix_rule_width_dim } \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl { \__nicematrix_hline:n { multiplicity = #1 , position = \int_eval:n { \c@iRow + 1 } , total-width = \dim_use:N \l__nicematrix_rule_width_dim , #2 } } \egroup } \keys_define:nn { NiceMatrix / ColumnTypes } { } \cs_new_protected:Npn \__nicematrix_custom_line:n #1 { \str_clear_new:N \l__nicematrix_command_str \str_clear_new:N \l__nicematrix_ccommand_str \str_clear_new:N \l__nicematrix_letter_str \keys_set_known:nnN { NiceMatrix / custom-line } { #1 } \l__nicematrix_other_keys_tl \bool_lazy_all:nTF { { \str_if_empty_p:N \l__nicematrix_letter_str } { \str_if_empty_p:N \l__nicematrix_command_str } { \str_if_empty_p:N \l__nicematrix_ccommand_str } } { \__nicematrix_error:n { No~letter~and~no~command } } { \exp_args:NV \__nicematrix_custom_line_i:n \l__nicematrix_other_keys_tl } } \keys_define:nn { NiceMatrix / custom-line } { % here, we will use change in the future to use .str_set:N letter .code:n = \str_set:Nn \l__nicematrix_letter_str { #1 } , letter .value_required:n = true , command .code:n = \str_set:Nn \l__nicematrix_command_str { #1 } , command .value_required:n = true , ccommand .code:n = \str_set:Nn \l__nicematrix_ccommand_str { #1 } , ccommand .value_required:n = true , } \cs_new_protected:Npn \__nicematrix_custom_line_i:n #1 { \bool_set_false:N \l__nicematrix_tikz_rule_bool \bool_set_false:N \l__nicematrix_dotted_rule_bool \bool_set_false:N \l__nicematrix_color_bool \keys_set:nn { NiceMatrix / custom-line-bis } { #1 } \bool_if:NT \l__nicematrix_tikz_rule_bool { \cs_if_exist:NF \tikzpicture { \__nicematrix_error:n { tikz~in~custom-line~without~tikz } } \bool_if:NT \l__nicematrix_color_bool { \__nicematrix_error:n { color~in~custom-line~with~tikz } } } \bool_if:nT { \int_compare_p:nNn \l__nicematrix_multiplicity_int > 1 && \l__nicematrix_dotted_rule_bool } { \__nicematrix_error:n { key~multiplicity~with~dotted } } \str_if_empty:NF \l__nicematrix_letter_str { \int_compare:nTF { \str_count:N \l__nicematrix_letter_str != 1 } { \__nicematrix_error:n { Several~letters } } { \exp_args:NnV \tl_if_in:NnTF \c__nicematrix_forbidden_letters_str \l__nicematrix_letter_str { \__nicematrix_error:n { Forbidden~letter } } { \keys_define:nx { NiceMatrix / ColumnTypes } { \l__nicematrix_letter_str .code:n = { \__nicematrix_v_custom_line:n { \exp_not:n { #1 } } } } } } } \str_if_empty:NF \l__nicematrix_command_str { \__nicematrix_h_custom_line:n { #1 } } \str_if_empty:NF \l__nicematrix_ccommand_str { \__nicematrix_c_custom_line:n { #1 } } } \str_const:Nn \c__nicematrix_forbidden_letters_str { lcrpmbVX|()[]!@<> } \keys_define:nn { NiceMatrix / custom-line-bis } { multiplicity .int_set:N = \l__nicematrix_multiplicity_int , multiplicity .initial:n = 1 , multiplicity .value_required:n = true , color .code:n = \bool_set_true:N \l__nicematrix_color_bool , color .value_required:n = true , tikz .code:n = \bool_set_true:N \l__nicematrix_tikz_rule_bool , tikz .value_required:n = true , dotted .code:n = \bool_set_true:N \l__nicematrix_dotted_rule_bool , dotted .value_forbidden:n = true , total-width .code:n = { } , total-width .value_required:n = true , width .code:n = { } , width .value_required:n = true , sep-color .code:n = { } , sep-color .value_required:n = true , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~custom-line } } \bool_new:N \l__nicematrix_dotted_rule_bool \bool_new:N \l__nicematrix_tikz_rule_bool \bool_new:N \l__nicematrix_color_bool \keys_define:nn { NiceMatrix / custom-line-width } { multiplicity .int_set:N = \l__nicematrix_multiplicity_int , multiplicity .initial:n = 1 , multiplicity .value_required:n = true , tikz .code:n = \bool_set_true:N \l__nicematrix_tikz_rule_bool , total-width .code:n = \dim_set:Nn \l__nicematrix_rule_width_dim { #1 } \bool_set_true:N \l__nicematrix_total_width_bool , total-width .value_required:n = true , width .meta:n = { total-width = #1 } , dotted .code:n = \bool_set_true:N \l__nicematrix_dotted_rule_bool , } \cs_new_protected:Npn \__nicematrix_h_custom_line:n #1 { \cs_set:cpn { nicematrix - \l__nicematrix_command_str } { \noalign { \__nicematrix_compute_rule_width:n { #1 } \skip_vertical:n { \l__nicematrix_rule_width_dim } \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl { \__nicematrix_hline:n { #1 , position = \int_eval:n { \c@iRow + 1 } , total-width = \dim_use:N \l__nicematrix_rule_width_dim } } } } \seq_put_left:NV \l__nicematrix_custom_line_commands_seq \l__nicematrix_command_str } \cs_generate_variant:Nn \__nicematrix_h_custom_line:nn { n V } \cs_new_protected:Npn \__nicematrix_c_custom_line:n #1 { \exp_args:Nc \NewExpandableDocumentCommand { nicematrix - \l__nicematrix_ccommand_str } { O { } m } { \noalign { \__nicematrix_compute_rule_width:n { #1 , ##1 } \skip_vertical:n { \l__nicematrix_rule_width_dim } \clist_map_inline:nn { ##2 } { \__nicematrix_c_custom_line_i:nn { #1 , ##1 } { ####1 } } } } \seq_put_left:NV \l__nicematrix_custom_line_commands_seq \l__nicematrix_ccommand_str } \cs_new_protected:Npn \__nicematrix_c_custom_line_i:nn #1 #2 { \str_if_in:nnTF { #2 } { - } { \__nicematrix_cut_on_hyphen:w #2 \q_stop } { \__nicematrix_cut_on_hyphen:w #2 - #2 \q_stop } \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl { \__nicematrix_hline:n { #1 , start = \l_tmpa_tl , end = \l_tmpb_tl , position = \int_eval:n { \c@iRow + 1 } , total-width = \dim_use:N \l__nicematrix_rule_width_dim } } } \cs_generate_variant:Nn \__nicematrix_c_custom_line:nn { n V } \cs_new_protected:Npn \__nicematrix_compute_rule_width:n #1 { \bool_set_false:N \l__nicematrix_tikz_rule_bool \bool_set_false:N \l__nicematrix_total_width_bool \bool_set_false:N \l__nicematrix_dotted_rule_bool \keys_set_known:nn { NiceMatrix / custom-line-width } { #1 } \bool_if:NF \l__nicematrix_total_width_bool { \bool_if:NTF \l__nicematrix_dotted_rule_bool { \dim_set:Nn \l__nicematrix_rule_width_dim { 2 \l__nicematrix_xdots_radius_dim } } { \bool_if:NF \l__nicematrix_tikz_rule_bool { \dim_set:Nn \l__nicematrix_rule_width_dim { \arrayrulewidth * \l__nicematrix_multiplicity_int + \doublerulesep * ( \l__nicematrix_multiplicity_int - 1 ) } } } } } \cs_new_protected:Npn \__nicematrix_v_custom_line:n #1 { \__nicematrix_compute_rule_width:n { #1 } \tl_gput_right:Nx \g__nicematrix_preamble_tl { \exp_not:N ! { \skip_horizontal:n { \dim_use:N \l__nicematrix_rule_width_dim } } } \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl { \__nicematrix_vline:n { #1 , position = \int_eval:n { \c@jCol + 1 } , total-width = \dim_use:N \l__nicematrix_rule_width_dim } } } \__nicematrix_custom_line:n { letter = : , command = hdottedline , ccommand = cdottedline, dotted } \cs_new_protected:Npn \__nicematrix_test_hline_in_block:nnnnn #1 #2 #3 #4 #5 { \bool_lazy_all:nT { { \int_compare_p:nNn \l_tmpa_tl > { #1 } } { \int_compare_p:nNn \l_tmpa_tl < { #3 + 1 } } { \int_compare_p:nNn \l_tmpb_tl > { #2 - 1 } } { \int_compare_p:nNn \l_tmpb_tl < { #4 + 1 } } } { \bool_gset_false:N \g_tmpa_bool } } \cs_new_protected:Npn \__nicematrix_test_vline_in_block:nnnnn #1 #2 #3 #4 #5 { \bool_lazy_all:nT { { \int_compare_p:nNn \l_tmpa_tl > { #1 - 1 } } { \int_compare_p:nNn \l_tmpa_tl < { #3 + 1 } } { \int_compare_p:nNn \l_tmpb_tl > { #2 } } { \int_compare_p:nNn \l_tmpb_tl < { #4 + 1 } } } { \bool_gset_false:N \g_tmpa_bool } } \cs_new_protected:Npn \__nicematrix_test_hline_in_stroken_block:nnnn #1 #2 #3 #4 { \bool_lazy_all:nT { { \int_compare_p:nNn \l_tmpa_tl > { #1 - 1 } } { \int_compare_p:nNn \l_tmpa_tl < { #3 + 2 } } { \int_compare_p:nNn \l_tmpb_tl > { #2 - 1 } } { \int_compare_p:nNn \l_tmpb_tl < { #4 + 1 } } } { \bool_gset_false:N \g_tmpa_bool } } \cs_new_protected:Npn \__nicematrix_test_vline_in_stroken_block:nnnn #1 #2 #3 #4 { \bool_lazy_all:nT { { \int_compare_p:nNn \l_tmpa_tl > { #1 - 1 } } { \int_compare_p:nNn \l_tmpa_tl < { #3 + 1 } } { \int_compare_p:nNn \l_tmpb_tl > { #2 - 1 } } { \int_compare_p:nNn \l_tmpb_tl < { #4 + 2 } } } { \bool_gset_false:N \g_tmpa_bool } } \cs_new_protected:Npn \__nicematrix_compute_corners: { \seq_clear_new:N \l__nicematrix_corners_cells_seq \clist_map_inline:Nn \l__nicematrix_corners_clist { \str_case:nnF { ##1 } { { NW } { \__nicematrix_compute_a_corner:nnnnnn 1 1 1 1 \c@iRow \c@jCol } { NE } { \__nicematrix_compute_a_corner:nnnnnn 1 \c@jCol 1 { -1 } \c@iRow 1 } { SW } { \__nicematrix_compute_a_corner:nnnnnn \c@iRow 1 { -1 } 1 1 \c@jCol } { SE } { \__nicematrix_compute_a_corner:nnnnnn \c@iRow \c@jCol { -1 } { -1 } 1 1 } } { \__nicematrix_error:nn { bad~corner } { ##1 } } } \seq_if_empty:NF \l__nicematrix_corners_cells_seq { \tl_gput_right:Nx \g__nicematrix_aux_tl { \seq_set_from_clist:Nn \exp_not:N \l__nicematrix_corners_cells_seq { \seq_use:Nnnn \l__nicematrix_corners_cells_seq , , , } } } } \cs_new_protected:Npn \__nicematrix_compute_a_corner:nnnnnn #1 #2 #3 #4 #5 #6 { \bool_set_false:N \l_tmpa_bool \int_zero_new:N \l__nicematrix_last_empty_row_int \int_set:Nn \l__nicematrix_last_empty_row_int { #1 } \int_step_inline:nnnn { #1 } { #3 } { #5 } { \__nicematrix_test_if_cell_in_a_block:nn { ##1 } { \int_eval:n { #2 } } \bool_lazy_or:nnTF { \cs_if_exist_p:c { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - \int_eval:n { #2 } } } \l_tmpb_bool { \bool_set_true:N \l_tmpa_bool } { \bool_if:NF \l_tmpa_bool { \int_set:Nn \l__nicematrix_last_empty_row_int { ##1 } } } } \bool_set_false:N \l_tmpa_bool \int_zero_new:N \l__nicematrix_last_empty_column_int \int_set:Nn \l__nicematrix_last_empty_column_int { #2 } \int_step_inline:nnnn { #2 } { #4 } { #6 } { \__nicematrix_test_if_cell_in_a_block:nn { \int_eval:n { #1 } } { ##1 } \bool_lazy_or:nnTF \l_tmpb_bool { \cs_if_exist_p:c { pgf @ sh @ ns @ \__nicematrix_env: - \int_eval:n { #1 } - ##1 } } { \bool_set_true:N \l_tmpa_bool } { \bool_if:NF \l_tmpa_bool { \int_set:Nn \l__nicematrix_last_empty_column_int { ##1 } } } } \int_step_inline:nnnn { #1 } { #3 } \l__nicematrix_last_empty_row_int { \bool_set_false:N \l_tmpa_bool \int_step_inline:nnnn { #2 } { #4 } \l__nicematrix_last_empty_column_int { \__nicematrix_test_if_cell_in_a_block:nn { ##1 } { ####1 } \bool_lazy_or:nnTF \l_tmpb_bool { \cs_if_exist_p:c { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - ####1 } } { \bool_set_true:N \l_tmpa_bool } { \bool_if:NF \l_tmpa_bool { \int_set:Nn \l__nicematrix_last_empty_column_int { ####1 } \seq_put_right:Nn \l__nicematrix_corners_cells_seq { ##1 - ####1 } } } } } } \cs_new_protected:Npn \__nicematrix_test_if_cell_in_a_block:nn #1 #2 { \int_set:Nn \l_tmpa_int { #1 } \int_set:Nn \l_tmpb_int { #2 } \bool_set_false:N \l_tmpb_bool \seq_map_inline:Nn \g__nicematrix_pos_of_blocks_seq { \__nicematrix_test_if_cell_in_block:nnnnnnn \l_tmpa_int \l_tmpb_int ##1 } } \cs_new_protected:Npn \__nicematrix_test_if_cell_in_block:nnnnnnn #1 #2 #3 #4 #5 #6 #7 { \int_compare:nNnT { #3 } < { \int_eval:n { #1 + 1 } } { \int_compare:nNnT { #1 } < { \int_eval:n { #5 + 1 } } { \int_compare:nNnT { #4 } < { \int_eval:n { #2 + 1 } } { \int_compare:nNnT { #2 } < { \int_eval:n { #6 + 1 } } { \bool_set_true:N \l_tmpb_bool } } } } } \bool_new:N \l__nicematrix_block_auto_columns_width_bool \keys_define:nn { NiceMatrix / NiceMatrixBlock } { auto-columns-width .code:n = { \bool_set_true:N \l__nicematrix_block_auto_columns_width_bool \dim_gzero_new:N \g__nicematrix_max_cell_width_dim \bool_set_true:N \l__nicematrix_auto_columns_width_bool } } \NewDocumentEnvironment { NiceMatrixBlock } { ! O { } } { \int_gincr:N \g__nicematrix_NiceMatrixBlock_int \dim_zero:N \l__nicematrix_columns_width_dim \keys_set:nn { NiceMatrix / NiceMatrixBlock } { #1 } \bool_if:NT \l__nicematrix_block_auto_columns_width_bool { \cs_if_exist:cT { __nicematrix_max_cell_width_ \int_use:N \g__nicematrix_NiceMatrixBlock_int } { \exp_args:NNc \dim_set:Nn \l__nicematrix_columns_width_dim { __nicematrix_max_cell_width _ \int_use:N \g__nicematrix_NiceMatrixBlock_int } } } } { \bool_if:NT \l__nicematrix_block_auto_columns_width_bool { \iow_shipout:Nn \@mainaux \ExplSyntaxOn \iow_shipout:Nx \@mainaux { \cs_gset:cpn { __nicematrix _ max _ cell _ width _ \int_use:N \g__nicematrix_NiceMatrixBlock_int } { \dim_eval:n { \g__nicematrix_max_cell_width_dim + \arrayrulewidth } } } \iow_shipout:Nn \@mainaux \ExplSyntaxOff } } \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: { \dim_zero_new:c { l__nicematrix_row_\__nicematrix_i: _min_dim } \dim_set_eq:cN { l__nicematrix_row_\__nicematrix_i: _min_dim } \c_max_dim \dim_zero_new:c { l__nicematrix_row_\__nicematrix_i: _max_dim } \dim_set:cn { l__nicematrix_row_\__nicematrix_i: _max_dim } { - \c_max_dim } } \int_step_variable:nnNn \l__nicematrix_first_col_int \g__nicematrix_col_total_int \__nicematrix_j: { \dim_zero_new:c { l__nicematrix_column_\__nicematrix_j: _min_dim } \dim_set_eq:cN { l__nicematrix_column_\__nicematrix_j: _min_dim } \c_max_dim \dim_zero_new:c { l__nicematrix_column_\__nicematrix_j: _max_dim } \dim_set:cn { l__nicematrix_column_\__nicematrix_j: _max_dim } { - \c_max_dim } } \int_step_variable:nnNn \l__nicematrix_first_row_int \g__nicematrix_row_total_int \__nicematrix_i: { \int_step_variable:nnNn \l__nicematrix_first_col_int \g__nicematrix_col_total_int \__nicematrix_j: { \cs_if_exist:cT { pgf @ sh @ ns @ \__nicematrix_env: - \__nicematrix_i: - \__nicematrix_j: } { \pgfpointanchor { \__nicematrix_env: - \__nicematrix_i: - \__nicematrix_j: } { south~west } \dim_set:cn { l__nicematrix_row_\__nicematrix_i: _min_dim} { \dim_min:vn { l__nicematrix_row _ \__nicematrix_i: _min_dim } \pgf@y } \seq_if_in:NxF \g__nicematrix_multicolumn_cells_seq { \__nicematrix_i: - \__nicematrix_j: } { \dim_set:cn { l__nicematrix_column _ \__nicematrix_j: _min_dim} { \dim_min:vn { l__nicematrix_column _ \__nicematrix_j: _min_dim } \pgf@x } } \pgfpointanchor { \__nicematrix_env: - \__nicematrix_i: - \__nicematrix_j: } { north~east } \dim_set:cn { l__nicematrix_row _ \__nicematrix_i: _ max_dim } { \dim_max:vn { l__nicematrix_row _ \__nicematrix_i: _ max_dim } \pgf@y } \seq_if_in:NxF \g__nicematrix_multicolumn_cells_seq { \__nicematrix_i: - \__nicematrix_j: } { \dim_set:cn { l__nicematrix_column _ \__nicematrix_j: _ max_dim } { \dim_max:vn { l__nicematrix_column _ \__nicematrix_j: _max_dim } \pgf@x } } } } } \int_step_variable:nnNn \l__nicematrix_first_row_int \g__nicematrix_row_total_int \__nicematrix_i: { \dim_compare:nNnT { \dim_use:c { l__nicematrix_row _ \__nicematrix_i: _ min _ dim } } = \c_max_dim { \__nicematrix_qpoint:n { row - \__nicematrix_i: - base } \dim_set:cn { l__nicematrix_row _ \__nicematrix_i: _ max _ dim } \pgf@y \dim_set:cn { l__nicematrix_row _ \__nicematrix_i: _ min _ dim } \pgf@y } } \int_step_variable:nnNn \l__nicematrix_first_col_int \g__nicematrix_col_total_int \__nicematrix_j: { \dim_compare:nNnT { \dim_use:c { l__nicematrix_column _ \__nicematrix_j: _ min _ dim } } = \c_max_dim { \__nicematrix_qpoint:n { col - \__nicematrix_j: } \dim_set:cn { l__nicematrix_column _ \__nicematrix_j: _ max _ dim } \pgf@y \dim_set:cn { l__nicematrix_column _ \__nicematrix_j: _ min _ dim } \pgf@y } } } \cs_new_protected:Npn \__nicematrix_create_medium_nodes: { \pgfpicture \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse \__nicematrix_computations_for_medium_nodes: \tl_set:Nn \l__nicematrix_suffix_tl { -medium } \__nicematrix_create_nodes: \endpgfpicture } \cs_new_protected:Npn \__nicematrix_create_large_nodes: { \pgfpicture \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse \__nicematrix_computations_for_medium_nodes: \__nicematrix_computations_for_large_nodes: \tl_set:Nn \l__nicematrix_suffix_tl { - large } \__nicematrix_create_nodes: \endpgfpicture } \cs_new_protected:Npn \__nicematrix_create_medium_and_large_nodes: { \pgfpicture \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse \__nicematrix_computations_for_medium_nodes: \tl_set:Nn \l__nicematrix_suffix_tl { - medium } \__nicematrix_create_nodes: \__nicematrix_computations_for_large_nodes: \tl_set:Nn \l__nicematrix_suffix_tl { - large } \__nicematrix_create_nodes: \endpgfpicture } \cs_new_protected:Npn \__nicematrix_computations_for_large_nodes: { \int_set:Nn \l__nicematrix_first_row_int 1 \int_set:Nn \l__nicematrix_first_col_int 1 \int_step_variable:nNn { \c@iRow - 1 } \__nicematrix_i: { \dim_set:cn { l__nicematrix_row _ \__nicematrix_i: _ min _ dim } { ( \dim_use:c { l__nicematrix_row _ \__nicematrix_i: _ min _ dim } + \dim_use:c { l__nicematrix_row _ \int_eval:n { \__nicematrix_i: + 1 } _ max _ dim } ) / 2 } \dim_set_eq:cc { l__nicematrix_row _ \int_eval:n { \__nicematrix_i: + 1 } _ max _ dim } { l__nicematrix_row_\__nicematrix_i: _min_dim } } \int_step_variable:nNn { \c@jCol - 1 } \__nicematrix_j: { \dim_set:cn { l__nicematrix_column _ \__nicematrix_j: _ max _ dim } { ( \dim_use:c { l__nicematrix_column _ \__nicematrix_j: _ max _ dim } + \dim_use:c { l__nicematrix_column _ \int_eval:n { \__nicematrix_j: + 1 } _ min _ dim } ) / 2 } \dim_set_eq:cc { l__nicematrix_column _ \int_eval:n { \__nicematrix_j: + 1 } _ min _ dim } { l__nicematrix_column _ \__nicematrix_j: _ max _ dim } } \dim_sub:cn { l__nicematrix_column _ 1 _ min _ dim } \l__nicematrix_left_margin_dim \dim_add:cn { l__nicematrix_column _ \int_use:N \c@jCol _ max _ dim } \l__nicematrix_right_margin_dim } \cs_new_protected:Npn \__nicematrix_create_nodes: { \int_step_variable:nnNn \l__nicematrix_first_row_int \g__nicematrix_row_total_int \__nicematrix_i: { \int_step_variable:nnNn \l__nicematrix_first_col_int \g__nicematrix_col_total_int \__nicematrix_j: { \__nicematrix_pgf_rect_node:nnnnn { \__nicematrix_env: - \__nicematrix_i: - \__nicematrix_j: \l__nicematrix_suffix_tl } { \dim_use:c { l__nicematrix_column_ \__nicematrix_j: _min_dim } } { \dim_use:c { l__nicematrix_row_ \__nicematrix_i: _min_dim } } { \dim_use:c { l__nicematrix_column_ \__nicematrix_j: _max_dim } } { \dim_use:c { l__nicematrix_row_ \__nicematrix_i: _max_dim } } \str_if_empty:NF \l__nicematrix_name_str { \pgfnodealias { \l__nicematrix_name_str - \__nicematrix_i: - \__nicematrix_j: \l__nicematrix_suffix_tl } { \__nicematrix_env: - \__nicematrix_i: - \__nicematrix_j: \l__nicematrix_suffix_tl } } } } \seq_mapthread_function:NNN \g__nicematrix_multicolumn_cells_seq \g__nicematrix_multicolumn_sizes_seq \__nicematrix_node_for_multicolumn:nn } \cs_new_protected:Npn \__nicematrix_extract_coords_values: #1 - #2 \q_stop { \cs_set_nopar:Npn \__nicematrix_i: { #1 } \cs_set_nopar:Npn \__nicematrix_j: { #2 } } \cs_new_protected:Npn \__nicematrix_node_for_multicolumn:nn #1 #2 { \__nicematrix_extract_coords_values: #1 \q_stop \__nicematrix_pgf_rect_node:nnnnn { \__nicematrix_env: - \__nicematrix_i: - \__nicematrix_j: \l__nicematrix_suffix_tl } { \dim_use:c { l__nicematrix_column _ \__nicematrix_j: _ min _ dim } } { \dim_use:c { l__nicematrix_row _ \__nicematrix_i: _ min _ dim } } { \dim_use:c { l__nicematrix_column _ \int_eval:n { \__nicematrix_j: +#2-1 } _ max _ dim } } { \dim_use:c { l__nicematrix_row _ \__nicematrix_i: _ max _ dim } } \str_if_empty:NF \l__nicematrix_name_str { \pgfnodealias { \l__nicematrix_name_str - \__nicematrix_i: - \__nicematrix_j: \l__nicematrix_suffix_tl } { \int_use:N \g__nicematrix_env_int - \__nicematrix_i: - \__nicematrix_j: \l__nicematrix_suffix_tl} } } \keys_define:nn { NiceMatrix / Block / FirstPass } { 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 , r .value_forbidden:n = true , c .code:n = \str_set:Nn \l__nicematrix_hpos_block_str c , c .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 , R .value_forbidden:n = true , C .code:n = \str_set:Nn \l__nicematrix_hpos_block_str c , C .value_forbidden:n = true , t .code:n = \str_set:Nn \l__nicematrix_vpos_of_block_tl t , t .value_forbidden:n = true , b .code:n = \str_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 , respect-arraystretch .bool_set:N = \l__nicematrix_respect_arraystretch_bool , respect-arraystretch .default:n = true , } \NewExpandableDocumentCommand \__nicematrix_Block: { O { } m D < > { } +m } { \peek_remove_spaces:n { \tl_if_blank:nTF { #2 } { \__nicematrix_Block_i 1-1 \q_stop } { \__nicematrix_Block_i #2 \q_stop } { #1 } { #3 } { #4 } } } \cs_new:Npn \__nicematrix_Block_i #1-#2 \q_stop { \__nicematrix_Block_ii:nnnnn { #1 } { #2 } } \cs_new_protected:Npn \__nicematrix_Block_ii:nnnnn #1 #2 #3 #4 #5 { \bool_lazy_or:nnTF { \tl_if_blank_p:n { #1 } } { \str_if_eq_p:nn { #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 } { * } } { \int_set:Nn \l_tmpb_int { 100 } } { \int_set:Nn \l_tmpb_int { #2 } } \int_compare:nNnTF \l_tmpb_int = 1 { \str_if_empty:NTF \l__nicematrix_hpos_cell_str { \str_set:Nn \l__nicematrix_hpos_block_str c } { \str_set_eq:NN \l__nicematrix_hpos_block_str \l__nicematrix_hpos_cell_str } } { \str_set:Nn \l__nicematrix_hpos_block_str c } \keys_set_known:nn { NiceMatrix / Block / FirstPass } { #3 } \tl_set:Nx \l_tmpa_tl { { \int_use:N \c@iRow } { \int_use:N \c@jCol } { \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 } = 1 || \int_compare_p:nNn { \l_tmpb_int } = 1 ) && ! \tl_if_empty_p:n { #5 } && ! \l__nicematrix_X_column_bool } { \exp_args:Nxx \__nicematrix_Block_iv:nnnnn } { \exp_args:Nxx \__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 { \int_gincr:N \g__nicematrix_block_box_int \cs_set_protected_nopar:Npn \diagbox ##1 ##2 { \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl { \__nicematrix_actually_diagbox:nnnnnn { \int_use:N \c@iRow } { \int_use:N \c@jCol } { \int_eval:n { \c@iRow + #1 - 1 } } { \int_eval:n { \c@jCol + #2 - 1 } } { \exp_not:n { ##1 } } { \exp_not:n { ##2 } } } } \box_gclear_new:c { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box } \hbox_gset:cn { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box } { \tl_if_empty:NTF \l__nicematrix_color_tl { \int_compare:nNnT { #2 } = 1 \set@color } { \__nicematrix_color:V \l__nicematrix_color_tl } \int_compare:nNnT { #1 } = 1 \g__nicematrix_row_style_tl \group_begin: \bool_if:NF \l__nicematrix_respect_arraystretch_bool { \cs_set:Npn \arraystretch { 1 } } \dim_zero:N \extrarowheight #4 \bool_if:NT \g__nicematrix_rotate_bool { \str_set:Nn \l__nicematrix_hpos_block_str c } \bool_if:NTF \l__nicematrix_NiceTabular_bool { \bool_lazy_all:nTF { { \int_compare_p:nNn { #2 } = 1 } { \dim_compare_p:n { \l__nicematrix_col_width_dim >= \c_zero_dim } } { ! \l__nicematrix_respect_arraystretch_bool } } { \begin { minipage } [ \l__nicematrix_vpos_of_block_tl ] { \l__nicematrix_col_width_dim } \str_case:Vn \l__nicematrix_hpos_block_str { c \centering r \raggedleft l \raggedright } #5 \end { minipage } } { \use:x { \exp_not:N \begin { tabular } [ \l__nicematrix_vpos_of_block_tl ] { @ { } \l__nicematrix_hpos_block_str @ { } } } #5 \end { tabular } } } { \c_math_toggle_token \use:x { \exp_not:N \begin { array } [ \l__nicematrix_vpos_of_block_tl ] { @ { } \l__nicematrix_hpos_block_str @ { } } } #5 \end { array } \c_math_toggle_token } \group_end: } \bool_if:NT \g__nicematrix_rotate_bool { \box_grotate:cn { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box } { 90 } \bool_gset_false:N \g__nicematrix_rotate_bool } \int_compare:nNnT { #2 } = 1 { \dim_gset:Nn \g__nicematrix_blocks_wd_dim { \dim_max:nn \g__nicematrix_blocks_wd_dim { \box_wd:c { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box } } } } \int_compare:nNnT { #1 } = 1 { \dim_gset: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 } } } \dim_gset: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 } } } } \seq_gput_right:Nx \g__nicematrix_blocks_seq { \l_tmpa_tl { \exp_not:n { #3 } , \l__nicematrix_hpos_block_str } { \box_use_drop:c { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box } } } } \cs_new_protected:Npn \__nicematrix_Block_v:nnnnn #1 #2 #3 #4 #5 { \seq_gput_right:Nx \g__nicematrix_blocks_seq { \l_tmpa_tl { \exp_not:n { #3 } } \exp_not:n { { \bool_if:NTF \l__nicematrix_NiceTabular_bool { \group_begin: \bool_if:NF \l__nicematrix_respect_arraystretch_bool { \cs_set:Npn \arraystretch { 1 } } \dim_zero:N \extrarowheight #4 \bool_if:NT \g__nicematrix_rotate_bool { \str_set:Nn \l__nicematrix_hpos_block_str c } \use:x { \exp_not:N \begin { tabular } [ \l__nicematrix_vpos_of_block_tl ] { @ { } \l__nicematrix_hpos_block_str @ { } } } #5 \end { tabular } \group_end: } { \group_begin: \bool_if:NF \l__nicematrix_respect_arraystretch_bool { \cs_set:Npn \arraystretch { 1 } } \dim_zero:N \extrarowheight #4 \bool_if:NT \g__nicematrix_rotate_bool { \str_set:Nn \l__nicematrix_hpos_block_str c } \c_math_toggle_token \use:x { \exp_not:N \begin { array } [ \l__nicematrix_vpos_of_block_tl ] { @ { } \l__nicematrix_hpos_block_str @ { } } } #5 \end { array } \c_math_toggle_token \group_end: } } } } } \keys_define:nn { NiceMatrix / Block / SecondPass } { tikz .code:n = \bool_if:NTF \c__nicematrix_tikz_loaded_bool { \seq_put_right:Nn \l__nicematrix_tikz_seq { { #1 } } } { \__nicematrix_error:n { tikz~key~without~tikz } } , tikz .value_required:n = true , fill .tl_set:N = \l__nicematrix_fill_tl , fill .value_required:n = true , draw .tl_set:N = \l__nicematrix_draw_tl , draw .default:n = default , rounded-corners .dim_set:N = \l__nicematrix_rounded_corners_dim , rounded-corners .default:n = 4 pt , color .code:n = \__nicematrix_color:n { #1 } \tl_set:Nn \l__nicematrix_draw_tl { #1 } , color .value_required:n = true , borders .clist_set:N = \l__nicematrix_borders_clist , borders .value_required:n = true , hvlines .meta:n = { vlines , hlines } , vlines .bool_set:N = \l__nicematrix_vlines_block_bool, vlines .default:n = true , hlines .bool_set:N = \l__nicematrix_hlines_block_bool, hlines .default:n = true , line-width .dim_set:N = \l__nicematrix_line_width_dim , line-width .value_required: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 , r .value_forbidden:n = true , c .code:n = \str_set:Nn \l__nicematrix_hpos_block_str c , c .value_forbidden:n = true , L .code:n = \str_set:Nn \l__nicematrix_hpos_block_str l \bool_set_true:N \l__nicematrix_hpos_of_block_cap_bool , L .value_forbidden:n = true , R .code:n = \str_set:Nn \l__nicematrix_hpos_block_str r \bool_set_true:N \l__nicematrix_hpos_of_block_cap_bool , R .value_forbidden:n = true , C .code:n = \str_set:Nn \l__nicematrix_hpos_block_str c \bool_set_true:N \l__nicematrix_hpos_of_block_cap_bool , C .value_forbidden:n = true , t .code:n = \str_set:Nn \l__nicematrix_vpos_of_block_tl t , t .value_forbidden:n = true , b .code:n = \str_set:Nn \l__nicematrix_vpos_of_block_tl b , b .value_forbidden:n = true , name .tl_set:N = \l__nicematrix_block_name_str , name .value_required:n = true , name .initial:n = , respect-arraystretch .bool_set:N = \l__nicematrix_respect_arraystretch_bool , respect-arraystretch .default:n = true , v-center .bool_set:N = \l__nicematrix_v_center_bool , v-center .default:n = true , v-center .initial:n = false , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~Block } } \cs_new_protected:Npn \__nicematrix_draw_blocks: { \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 { \int_zero_new:N \l__nicematrix_last_row_int \int_zero_new:N \l__nicematrix_last_col_int \int_compare:nNnTF { #3 } > { 99 } { \int_set_eq:NN \l__nicematrix_last_row_int \c@iRow } { \int_set:Nn \l__nicematrix_last_row_int { #3 } } \int_compare:nNnTF { #4 } > { 99 } { \int_set_eq:NN \l__nicematrix_last_col_int \c@jCol } { \int_set:Nn \l__nicematrix_last_col_int { #4 } } \int_compare:nNnTF \l__nicematrix_last_col_int > \g__nicematrix_col_total_int { \int_compare:nTF { \l__nicematrix_last_col_int <= \g__nicematrix_static_num_of_col_int } { \msg_error:nnnn { nicematrix } { Block~too~large~2 } { #1 } { #2 } \__nicematrix_msg_redirect_name:nn { Block~too~large~2 } { none } \__nicematrix_msg_redirect_name:nn { columns~not~used } { none } } { \msg_error:nnnn { nicematrix } { Block~too~large~1 } { #1 } { #2 } } } { \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 } } } } \cs_new_protected:Npn \__nicematrix_Block_v:nnnnnn #1 #2 #3 #4 #5 #6 { \group_begin: \keys_set:nn { NiceMatrix / Block / SecondPass } { #5 } \bool_if:NT \l__nicematrix_v_center_bool { \int_compare:nNnF { #1 } = { #3 } { \__nicematrix_error:n { Wrong~use~of~v-center } \bool_set_false:N \l__nicematrix_v_center_bool } } \bool_if:NT \l__nicematrix_vlines_block_bool { \tl_gput_right:Nx \g_nicematrix_code_after_tl { \__nicematrix_vlines_block:nnn { \exp_not:n { #5 } } { #1 - #2 } { \int_use:N \l__nicematrix_last_row_int - \int_use:N \l__nicematrix_last_col_int } } } \bool_if:NT \l__nicematrix_hlines_block_bool { \tl_gput_right:Nx \g_nicematrix_code_after_tl { \__nicematrix_hlines_block:nnn { \exp_not:n { #5 } } { #1 - #2 } { \int_use:N \l__nicematrix_last_row_int - \int_use:N \l__nicematrix_last_col_int } } } \bool_if:nT { ! \l__nicematrix_vlines_block_bool && ! \l__nicematrix_hlines_block_bool } { \seq_gput_left:Nx \g__nicematrix_pos_of_blocks_seq { { #1 } { #2 } { #3 } { #4 } { \l__nicematrix_block_name_str } } } \bool_lazy_and:nnT { ! (\tl_if_empty_p:N \l__nicematrix_draw_tl) } { \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 } } { #1 - #2 } { \int_use:N \l__nicematrix_last_row_int - \int_use:N \l__nicematrix_last_col_int } } \seq_gput_right:Nn \g__nicematrix_pos_of_stroken_blocks_seq { { #1 } { #2 } { #3 } { #4 } } } \clist_if_empty:NF \l__nicematrix_borders_clist { \tl_gput_right:Nx \g_nicematrix_code_after_tl { \__nicematrix_stroke_borders_block:nnn { \exp_not:n { #5 } } { #1 - #2 } { \int_use:N \l__nicematrix_last_row_int - \int_use:N \l__nicematrix_last_col_int } } } \tl_if_empty:NF \l__nicematrix_fill_tl { \tl_gput_right:Nx \g_nicematrix_code_before_tl { \exp_not:N \roundedrectanglecolor \exp_args:NV \tl_if_head_eq_meaning:nNTF \l__nicematrix_fill_tl [ { \l__nicematrix_fill_tl } { { \l__nicematrix_fill_tl } } { #1 - #2 } { \int_use:N \l__nicematrix_last_row_int - \int_use:N \l__nicematrix_last_col_int } { \dim_use:N \l__nicematrix_rounded_corners_dim } } } \seq_if_empty:NF \l__nicematrix_tikz_seq { \tl_gput_right:Nx \g_nicematrix_code_before_tl { \__nicematrix_block_tikz:nnnnn { #1 } { #2 } { \int_use:N \l__nicematrix_last_row_int } { \int_use:N \l__nicematrix_last_col_int } { \seq_use:Nn \l__nicematrix_tikz_seq { , } } } } \cs_set_protected_nopar:Npn \diagbox ##1 ##2 { \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl { \__nicematrix_actually_diagbox:nnnnnn { #1 } { #2 } { \int_use:N \l__nicematrix_last_row_int } { \int_use:N \l__nicematrix_last_col_int } { \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 } } } \bool_if:nTF { \int_compare_p:nNn { #1 } = { #3 } && ! \l__nicematrix_v_center_bool } { \int_compare:nNnTF { #1 } = 0 { \l__nicematrix_code_for_first_row_tl } { \int_compare:nNnT { #1 } = \l__nicematrix_last_row_int \l__nicematrix_code_for_last_row_tl } \pgfextracty \l_tmpa_dim { \__nicematrix_qpoint:n { row - #1 - base } } \pgfpointanchor { \__nicematrix_env: - #1 - #2 - block \bool_if:NF \l__nicematrix_hpos_of_block_cap_bool { - short } } { \str_case:Vn \l__nicematrix_hpos_block_str { c { center } l { west } r { east } } } \pgftransformshift { \pgfpoint \pgf@x \l_tmpa_dim } \pgfset { inner~sep = \c_zero_dim } \pgfnode { rectangle } { \str_case:Vn \l__nicematrix_hpos_block_str { c { base } l { base~west } r { base~east } } } { \box_use_drop:N \l__nicematrix_cell_box } { } { } } { \int_compare:nNnT { #2 } = 0 { \str_set:Nn \l__nicematrix_hpos_block_str r } \bool_if:nT \g__nicematrix_last_col_found_bool { \int_compare:nNnT { #2 } = \g__nicematrix_col_total_int { \str_set:Nn \l__nicematrix_hpos_block_str l } } \pgftransformshift { \pgfpointanchor { \__nicematrix_env: - #1 - #2 - block \bool_if:NF \l__nicematrix_hpos_of_block_cap_bool { - short } } { \str_case:Vn \l__nicematrix_hpos_block_str { c { center } l { west } r { east } } } } \pgfset { inner~sep = \c_zero_dim } \pgfnode { rectangle } { \str_case:Vn \l__nicematrix_hpos_block_str { c { center } l { west } r { east } } } { \box_use_drop:N \l__nicematrix_cell_box } { } { } } \endpgfpicture \group_end: } \cs_new_protected:Npn \__nicematrix_stroke_block:nnn #1 #2 #3 { \group_begin: \tl_clear:N \l__nicematrix_draw_tl \dim_set_eq:NN \l__nicematrix_line_width_dim \arrayrulewidth \keys_set_known:nn { NiceMatrix / BlockStroke } { #1 } \pgfpicture \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse \tl_if_empty:NF \l__nicematrix_draw_tl { \str_if_eq:VnTF \l__nicematrix_draw_tl { default } { \CT@arc@ } { \__nicematrix_color:V \l__nicematrix_draw_tl } } \pgfsetcornersarced { \pgfpoint { \dim_use:N \l__nicematrix_rounded_corners_dim } { \dim_use:N \l__nicematrix_rounded_corners_dim } } \__nicematrix_cut_on_hyphen:w #2 \q_stop \bool_lazy_and:nnT { \int_compare_p:n { \l_tmpa_tl <= \c@iRow } } { \int_compare_p:n { \l_tmpb_tl <= \c@jCol } } { \__nicematrix_qpoint:n { row - \l_tmpa_tl } \dim_set:Nn \l_tmpb_dim { \pgf@y } \__nicematrix_qpoint:n { col - \l_tmpb_tl } \dim_set:Nn \l__nicematrix_tmpc_dim { \pgf@x } \__nicematrix_cut_on_hyphen:w #3 \q_stop \int_compare:nNnT \l_tmpa_tl > \c@iRow { \tl_set:Nx \l_tmpa_tl { \int_use:N \c@iRow } } \int_compare:nNnT \l_tmpb_tl > \c@jCol { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } } \__nicematrix_qpoint:n { row - \int_eval:n { \l_tmpa_tl + 1 } } \dim_set:Nn \l_tmpa_dim { \pgf@y } \__nicematrix_qpoint:n { col - \int_eval:n { \l_tmpb_tl + 1 } } \dim_set:Nn \l__nicematrix_tmpd_dim { \pgf@x } \pgfpathrectanglecorners { \pgfpoint \l__nicematrix_tmpc_dim \l_tmpb_dim } { \pgfpoint \l__nicematrix_tmpd_dim \l_tmpa_dim } \pgfsetlinewidth { 1.1 \l__nicematrix_line_width_dim } \pgfusepath { stroke } } \endpgfpicture \group_end: } \keys_define:nn { NiceMatrix / BlockStroke } { color .tl_set:N = \l__nicematrix_draw_tl , draw .tl_set:N = \l__nicematrix_draw_tl , draw .default:n = default , line-width .dim_set:N = \l__nicematrix_line_width_dim , rounded-corners .dim_set:N = \l__nicematrix_rounded_corners_dim , rounded-corners .default:n = 4 pt } \cs_new_protected:Npn \__nicematrix_vlines_block:nnn #1 #2 #3 { \dim_set_eq:NN \l__nicematrix_line_width_dim \arrayrulewidth \keys_set_known:nn { NiceMatrix / BlockBorders } { #1 } \__nicematrix_cut_on_hyphen:w #2 \q_stop \tl_set_eq:NN \l__nicematrix_tmpc_tl \l_tmpa_tl \tl_set_eq:NN \l__nicematrix_tmpd_tl \l_tmpb_tl \__nicematrix_cut_on_hyphen:w #3 \q_stop \tl_set:Nx \l_tmpa_tl { \int_eval:n { \l_tmpa_tl + 1 } } \tl_set:Nx \l_tmpb_tl { \int_eval:n { \l_tmpb_tl + 1 } } \int_step_inline:nnn \l__nicematrix_tmpd_tl \l_tmpb_tl { \use:x { \__nicematrix_vline:n { position = ##1 , start = \l__nicematrix_tmpc_tl , end = \int_eval:n { \l_tmpa_tl - 1 } } } } } \cs_new_protected:Npn \__nicematrix_hlines_block:nnn #1 #2 #3 { \dim_set_eq:NN \l__nicematrix_line_width_dim \arrayrulewidth \keys_set_known:nn { NiceMatrix / BlockBorders } { #1 } \__nicematrix_cut_on_hyphen:w #2 \q_stop \tl_set_eq:NN \l__nicematrix_tmpc_tl \l_tmpa_tl \tl_set_eq:NN \l__nicematrix_tmpd_tl \l_tmpb_tl \__nicematrix_cut_on_hyphen:w #3 \q_stop \tl_set:Nx \l_tmpa_tl { \int_eval:n { \l_tmpa_tl + 1 } } \tl_set:Nx \l_tmpb_tl { \int_eval:n { \l_tmpb_tl + 1 } } \int_step_inline:nnn \l__nicematrix_tmpc_tl \l_tmpa_tl { \use:x { \__nicematrix_hline:n { position = ##1 , start = \l__nicematrix_tmpd_tl , end = \int_eval:n { \l_tmpb_tl - 1 } , total-width = \arrayrulewidth } } } } \cs_new_protected:Npn \__nicematrix_stroke_borders_block:nnn #1 #2 #3 { \dim_set_eq:NN \l__nicematrix_line_width_dim \arrayrulewidth \keys_set_known:nn { NiceMatrix / BlockBorders } { #1 } \dim_compare:nNnTF \l__nicematrix_rounded_corners_dim > \c_zero_dim { \__nicematrix_error:n { borders~forbidden } } { \tl_clear_new:N \l__nicematrix_borders_tikz_tl \keys_set:nV { NiceMatrix / OnlyForTikzInBorders } \l__nicematrix_borders_clist \__nicematrix_cut_on_hyphen:w #2 \q_stop \tl_set_eq:NN \l__nicematrix_tmpc_tl \l_tmpa_tl \tl_set_eq:NN \l__nicematrix_tmpd_tl \l_tmpb_tl \__nicematrix_cut_on_hyphen:w #3 \q_stop \tl_set:Nx \l_tmpa_tl { \int_eval:n { \l_tmpa_tl + 1 } } \tl_set:Nx \l_tmpb_tl { \int_eval:n { \l_tmpb_tl + 1 } } \__nicematrix_stroke_borders_block_i: } } \hook_gput_code:nnn { begindocument } { . } { \cs_new_protected:Npx \__nicematrix_stroke_borders_block_i: { \c__nicematrix_pgfortikzpicture_tl \__nicematrix_stroke_borders_block_ii: \c__nicematrix_endpgfortikzpicture_tl } } \cs_new_protected:Npn \__nicematrix_stroke_borders_block_ii: { \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse \CT@arc@ \pgfsetlinewidth { 1.1 \l__nicematrix_line_width_dim } \clist_if_in:NnT \l__nicematrix_borders_clist { right } { \__nicematrix_stroke_vertical:n \l_tmpb_tl } \clist_if_in:NnT \l__nicematrix_borders_clist { left } { \__nicematrix_stroke_vertical:n \l__nicematrix_tmpd_tl } \clist_if_in:NnT \l__nicematrix_borders_clist { bottom } { \__nicematrix_stroke_horizontal:n \l_tmpa_tl } \clist_if_in:NnT \l__nicematrix_borders_clist { top } { \__nicematrix_stroke_horizontal:n \l__nicematrix_tmpc_tl } } \keys_define:nn { NiceMatrix / OnlyForTikzInBorders } { tikz .code:n = \cs_if_exist:NTF \tikzpicture { \tl_set:Nn \l__nicematrix_borders_tikz_tl { #1 } } { \__nicematrix_error:n { tikz~in~borders~without~tikz } } , tikz .value_required:n = true , top .code:n = , bottom .code:n = , left .code:n = , right .code:n = , unknown .code:n = \__nicematrix_error:n { bad~border } } \cs_new_protected:Npn \__nicematrix_stroke_vertical:n #1 { \__nicematrix_qpoint:n \l__nicematrix_tmpc_tl \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \l__nicematrix_line_width_dim } \__nicematrix_qpoint:n \l_tmpa_tl \dim_set:Nn \l__nicematrix_tmpc_dim { \pgf@y + 0.5 \l__nicematrix_line_width_dim } \__nicematrix_qpoint:n { #1 } \tl_if_empty:NTF \l__nicematrix_borders_tikz_tl { \pgfpathmoveto { \pgfpoint \pgf@x \l_tmpb_dim } \pgfpathlineto { \pgfpoint \pgf@x \l__nicematrix_tmpc_dim } \pgfusepathqstroke } { \use:x { \exp_not:N \draw [ \l__nicematrix_borders_tikz_tl ] } ( \pgf@x , \l_tmpb_dim ) -- ( \pgf@x , \l__nicematrix_tmpc_dim ) ; } } \cs_new_protected:Npn \__nicematrix_stroke_horizontal:n #1 { \__nicematrix_qpoint:n \l__nicematrix_tmpd_tl \clist_if_in:NnTF \l__nicematrix_borders_clist { left } { \dim_set:Nn \l_tmpa_dim { \pgf@x - 0.5 \l__nicematrix_line_width_dim } } { \dim_set:Nn \l_tmpa_dim { \pgf@x + 0.5 \l__nicematrix_line_width_dim } } \__nicematrix_qpoint:n \l_tmpb_tl \dim_set:Nn \l_tmpb_dim { \pgf@x + 0.5 \l__nicematrix_line_width_dim } \__nicematrix_qpoint:n { #1 } \tl_if_empty:NTF \l__nicematrix_borders_tikz_tl { \pgfpathmoveto { \pgfpoint \l_tmpa_dim \pgf@y } \pgfpathlineto { \pgfpoint \l_tmpb_dim \pgf@y } \pgfusepathqstroke } { \use:x { \exp_not:N \draw [ \l__nicematrix_borders_tikz_tl ] } ( \l_tmpa_dim , \pgf@y ) -- ( \l_tmpb_dim , \pgf@y ) ; } } \keys_define:nn { NiceMatrix / BlockBorders } { borders .clist_set:N = \l__nicematrix_borders_clist , rounded-corners .dim_set:N = \l__nicematrix_rounded_corners_dim , rounded-corners .default:n = 4 pt , line-width .dim_set:N = \l__nicematrix_line_width_dim , } \cs_new_protected:Npn \__nicematrix_block_tikz:nnnnn #1 #2 #3 #4 #5 { \begin { tikzpicture } \clist_map_inline:nn { #5 } { \path [ ##1 ] ( #1 -| #2 ) rectangle ( \int_eval:n { #3 + 1 } -| \int_eval:n { #4 + 1 } ) ; } \end { tikzpicture } } \cs_set_protected:Npn \__nicematrix_renew_matrix: { \RenewDocumentEnvironment { pmatrix } { } { \pNiceMatrix } { \endpNiceMatrix } \RenewDocumentEnvironment { vmatrix } { } { \vNiceMatrix } { \endvNiceMatrix } \RenewDocumentEnvironment { Vmatrix } { } { \VNiceMatrix } { \endVNiceMatrix } \RenewDocumentEnvironment { bmatrix } { } { \bNiceMatrix } { \endbNiceMatrix } \RenewDocumentEnvironment { Bmatrix } { } { \BNiceMatrix } { \endBNiceMatrix } } \keys_define:nn { NiceMatrix / Auto } { columns-type .code:n = \__nicematrix_set_preamble:Nn \l__nicematrix_columns_type_tl { #1 } , columns-type .value_required:n = true , l .meta:n = { columns-type = l } , r .meta:n = { columns-type = r } , c .meta:n = { columns-type = c } } \NewDocumentCommand \AutoNiceMatrixWithDelims { m m O { } > { \SplitArgument { 1 } { - } } m O { } m ! O { } } { \__nicematrix_auto_nice_matrix:nnnnnn { #1 } { #2 } #4 { #6 } { #3 , #5 , #7 } } \cs_new_protected:Npn \__nicematrix_auto_nice_matrix:nnnnnn #1 #2 #3 #4 #5 #6 { \group_begin: \bool_set_true:N \l__nicematrix_Matrix_bool \keys_set_known:nnN { NiceMatrix / Auto } { #6 } \l_tmpa_tl \cs_set_eq:NN \__nicematrix_transform_preamble: \prg_do_nothing: \use:x { \exp_not:N \begin { NiceArrayWithDelims } { #1 } { #2 } { * { #4 } { \exp_not:V \l__nicematrix_columns_type_tl } } [ \exp_not:V \l_tmpa_tl ] } \int_compare:nNnT \l__nicematrix_first_row_int = 0 { \int_compare:nNnT \l__nicematrix_first_col_int = 0 { & } \prg_replicate:nn { #4 - 1 } { & } \int_compare:nNnT \l__nicematrix_last_col_int > { -1 } { & } \\ } \prg_replicate:nn { #3 } { \int_compare:nNnT \l__nicematrix_first_col_int = 0 { & } \prg_replicate:nn { #4 - 1 } { { } #5 & } #5 \int_compare:nNnT \l__nicematrix_last_col_int > { -1 } { & } \\ } \int_compare:nNnT \l__nicematrix_last_row_int > { -2 } { \int_compare:nNnT \l__nicematrix_first_col_int = 0 { & } \prg_replicate:nn { #4 - 1 } { & } \int_compare:nNnT \l__nicematrix_last_col_int > { -1 } { & } \\ } \end { NiceArrayWithDelims } \group_end: } \cs_set_protected:Npn \__nicematrix_define_com:nnn #1 #2 #3 { \cs_set_protected:cpn { #1 AutoNiceMatrix } { \bool_gset_false:N \g__nicematrix_NiceArray_bool \str_gset:Nx \g__nicematrix_name_env_str { #1 AutoNiceMatrix } \AutoNiceMatrixWithDelims { #2 } { #3 } } } \__nicematrix_define_com:nnn p ( ) \__nicematrix_define_com:nnn b [ ] \__nicematrix_define_com:nnn v | | \__nicematrix_define_com:nnn V \| \| \__nicematrix_define_com:nnn B \{ \} \NewDocumentCommand \AutoNiceMatrix { O { } m O { } m ! O { } } { \group_begin: \bool_gset_true:N \g__nicematrix_NiceArray_bool \AutoNiceMatrixWithDelims . . { #2 } { #4 } [ #1 , #3 , #5 ] \group_end: } \cs_set_eq:NN \__nicematrix_old_dotfill \dotfill \cs_new_protected:Npn \__nicematrix_dotfill: { \__nicematrix_old_dotfill \bool_if:NT \l__nicematrix_NiceTabular_bool { \group_insert_after:N \__nicematrix_dotfill_ii: } { \group_insert_after:N \__nicematrix_dotfill_i: } } \cs_new_protected:Npn \__nicematrix_dotfill_i: { \group_insert_after:N \__nicematrix_dotfill_ii: } \cs_new_protected:Npn \__nicematrix_dotfill_ii: { \group_insert_after:N \__nicematrix_dotfill_iii: } \cs_new_protected:Npn \__nicematrix_dotfill_iii: { \dim_compare:nNnT { \box_wd:N \l__nicematrix_cell_box } = \c_zero_dim \__nicematrix_old_dotfill } \cs_new_protected:Npn \__nicematrix_diagbox:nn #1 #2 { \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl { \__nicematrix_actually_diagbox:nnnnnn { \int_use:N \c@iRow } { \int_use:N \c@jCol } { \int_use:N \c@iRow } { \int_use:N \c@jCol } { \exp_not:n { #1 } } { \exp_not:n { #2 } } } \seq_gput_right:Nx \g__nicematrix_pos_of_blocks_seq { { \int_use:N \c@iRow } { \int_use:N \c@jCol } { \int_use:N \c@iRow } { \int_use:N \c@jCol } { } } } \cs_new_protected:Npn \__nicematrix_actually_diagbox:nnnnnn #1 #2 #3 #4 #5 #6 { \pgfpicture \pgf@relevantforpicturesizefalse \pgfrememberpicturepositiononpagetrue \__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 \pgfpathmoveto { \pgfpoint \l_tmpb_dim \l_tmpa_dim } \__nicematrix_qpoint:n { row - \int_eval:n { #3 + 1 } } \dim_set_eq:NN \l__nicematrix_tmpc_dim \pgf@y \__nicematrix_qpoint:n { col - \int_eval:n { #4 + 1 } } \dim_set_eq:NN \l__nicematrix_tmpd_dim \pgf@x \pgfpathlineto { \pgfpoint \l__nicematrix_tmpd_dim \l__nicematrix_tmpc_dim } { \CT@arc@ \pgfsetroundcap \pgfusepathqstroke } \pgfset { inner~sep = 1 pt } \pgfscope \pgftransformshift { \pgfpoint \l_tmpb_dim \l__nicematrix_tmpc_dim } \pgfnode { rectangle } { south~west } { \begin { minipage } { 20 cm } \__nicematrix_math_toggle_token: #5 \__nicematrix_math_toggle_token: \end { minipage } } { } { } \endpgfscope \pgftransformshift { \pgfpoint \l__nicematrix_tmpd_dim \l_tmpa_dim } \pgfnode { rectangle } { north~east } { \begin { minipage } { 20 cm } \raggedleft \__nicematrix_math_toggle_token: #6 \__nicematrix_math_toggle_token: \end { minipage } } { } { } \endpgfpicture } \keys_define:nn { NiceMatrix } { CodeAfter / rules .inherit:n = NiceMatrix / rules , CodeAfter / sub-matrix .inherit:n = NiceMatrix / sub-matrix } \keys_define:nn { NiceMatrix / CodeAfter } { sub-matrix .code:n = \keys_set:nn { NiceMatrix / sub-matrix } { #1 } , sub-matrix .value_required:n = true , delimiters / color .tl_set:N = \l__nicematrix_delimiters_color_tl , delimiters / color .value_required:n = true , rules .code:n = \keys_set:nn { NiceMatrix / rules } { #1 } , rules .value_required:n = true , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~CodeAfter } } \cs_new:Npn \__nicematrix_CodeAfter: { \omit \__nicematrix_CodeAfter_ii:n } \cs_new_protected:Npn \__nicematrix_CodeAfter_i: { \\ \omit \__nicematrix_CodeAfter_ii:n } \cs_new_protected:Npn \__nicematrix_CodeAfter_ii:n #1 \end { \tl_gput_right:Nn \g_nicematrix_code_after_tl { #1 } \__nicematrix_CodeAfter_iv:n } \cs_new_protected:Npn \__nicematrix_CodeAfter_iv:n #1 { \str_if_eq:eeTF \@currenvir { #1 } { \end { #1 } } { \tl_gput_right:Nn \g_nicematrix_code_after_tl { \end { #1 } } \__nicematrix_CodeAfter_ii:n } } \cs_new_protected:Npn \__nicematrix_delimiter:nnn #1 #2 #3 { \pgfpicture \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse \__nicematrix_qpoint:n { row - 1 } \dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y \__nicematrix_qpoint:n { row - \int_eval:n { \c@iRow + 1 } } \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y \bool_if:nTF { #3 } { \dim_set_eq:NN \l_tmpa_dim \c_max_dim } { \dim_set:Nn \l_tmpa_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 } { \pgfpointanchor { \__nicematrix_env: - ##1 - #2 } { \bool_if:nTF { #3 } { west } { east } } \dim_set:Nn \l_tmpa_dim { \bool_if:nTF { #3 } \dim_min:nn \dim_max:nn \l_tmpa_dim \pgf@x } } } \pgfset { inner~sep = \c_zero_dim } \dim_zero:N \nulldelimiterspace \pgftransformshift { \pgfpoint { \l_tmpa_dim } { ( \l__nicematrix_y_initial_dim + \l__nicematrix_y_final_dim + \arrayrulewidth ) / 2 } } \pgfnode { rectangle } { \bool_if:nTF { #3 } { east } { west } } { \nullfont \c_math_toggle_token \__nicematrix_color:V \l__nicematrix_delimiters_color_tl \bool_if:nTF { #3 } { \left #1 } { \left . } \vcenter { \nullfont \hrule \@height \dim_eval:n { \l__nicematrix_y_initial_dim - \l__nicematrix_y_final_dim } \@depth \c_zero_dim \@width \c_zero_dim } \bool_if:nTF { #3 } { \right . } { \right #1 } \c_math_toggle_token } { } { } \endpgfpicture } \keys_define:nn { NiceMatrix / sub-matrix } { extra-height .dim_set:N = \l__nicematrix_submatrix_extra_height_dim , extra-height .value_required:n = true , left-xshift .dim_set:N = \l__nicematrix_submatrix_left_xshift_dim , left-xshift .value_required:n = true , right-xshift .dim_set:N = \l__nicematrix_submatrix_right_xshift_dim , right-xshift .value_required:n = true , xshift .meta:n = { left-xshift = #1, right-xshift = #1 } , xshift .value_required:n = true , delimiters / color .tl_set:N = \l__nicematrix_delimiters_color_tl , delimiters / color .value_required:n = true , slim .bool_set:N = \l__nicematrix_submatrix_slim_bool , slim .default:n = true , hlines .clist_set:N = \l__nicematrix_submatrix_hlines_clist , hlines .default:n = all , vlines .clist_set:N = \l__nicematrix_submatrix_vlines_clist , vlines .default:n = all , hvlines .meta:n = { hlines, vlines } , hvlines .value_forbidden:n = true , } \keys_define:nn { NiceMatrix } { SubMatrix .inherit:n = NiceMatrix / sub-matrix , CodeAfter / sub-matrix .inherit:n = NiceMatrix / sub-matrix , NiceMatrix / sub-matrix .inherit:n = NiceMatrix / sub-matrix , NiceArray / sub-matrix .inherit:n = NiceMatrix / sub-matrix , pNiceArray / sub-matrix .inherit:n = NiceMatrix / sub-matrix , NiceMatrixOptions / sub-matrix .inherit:n = NiceMatrix / sub-matrix , } \keys_define:nn { NiceMatrix / SubMatrix } { delimiters / color .tl_set:N = \l__nicematrix_delimiters_color_tl , delimiters / color .value_required:n = true , hlines .clist_set:N = \l__nicematrix_submatrix_hlines_clist , hlines .default:n = all , vlines .clist_set:N = \l__nicematrix_submatrix_vlines_clist , vlines .default:n = all , hvlines .meta:n = { hlines, vlines } , hvlines .value_forbidden:n = true , name .code:n = \tl_if_empty:nTF { #1 } { \__nicematrix_error:n { Invalid~name } } { \regex_match:nnTF { \A[A-Za-z][A-Za-z0-9]*\Z } { #1 } { \seq_if_in:NnTF \g__nicematrix_submatrix_names_seq { #1 } { \__nicematrix_error:nn { Duplicate~name~for~SubMatrix } { #1 } } { \str_set:Nn \l__nicematrix_submatrix_name_str { #1 } \seq_gput_right:Nn \g__nicematrix_submatrix_names_seq { #1 } } } { \__nicematrix_error:n { Invalid~name } } } , rules .code:n = \keys_set:nn { NiceMatrix / rules } { #1 } , rules .value_required:n = true , code .tl_set:N = \l__nicematrix_code_tl , code .value_required:n = true , name .value_required:n = true , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~SubMatrix } } \NewDocumentCommand \__nicematrix_SubMatrix_in_code_before { m m m m ! O { } } { \peek_remove_spaces:n { \tl_gput_right:Nn \g__nicematrix_internal_code_after_tl { \SubMatrix { #1 } { #2 } { #3 } { #4 } [ #5 ] } \__nicematrix_SubMatrix_in_code_before_i { #2 } { #3 } } } \NewDocumentCommand \__nicematrix_SubMatrix_in_code_before_i { > { \SplitArgument { 1 } { - } } m > { \SplitArgument { 1 } { - } } m } { \__nicematrix_SubMatrix_in_code_before_i:nnnn #1 #2 } \cs_new_protected:Npn \__nicematrix_SubMatrix_in_code_before_i:nnnn #1 #2 #3 #4 { \seq_gput_right:Nx \g__nicematrix_submatrix_seq { { \str_if_eq:nnTF { #1 } { last } { \int_use:N \c@iRow } { #1 } } { \str_if_eq:nnTF { #2 } { last } { \int_use:N \c@jCol } { #2 } } { \str_if_eq:nnTF { #3 } { last } { \int_use:N \c@iRow } { #3 } } { \str_if_eq:nnTF { #4 } { last } { \int_use:N \c@jCol } { #4 } } } } \hook_gput_code:nnn { begindocument } { . } { \tl_set:Nn \l__nicematrix_argspec_tl { m m m m O { } E { _ ^ } { { } { } } } \tl_set_rescan:Nno \l__nicematrix_argspec_tl { } \l__nicematrix_argspec_tl \exp_args:NNV \NewDocumentCommand \__nicematrix_SubMatrix \l__nicematrix_argspec_tl { \peek_remove_spaces:n { \__nicematrix_sub_matrix:nnnnnnn { #1 } { #2 } { #3 } { #4 } { #5 } { #6 } { #7 } } } } \NewDocumentCommand \__nicematrix_compute_i_j:nn { > { \SplitArgument { 1 } { - } } m > { \SplitArgument { 1 } { - } } m } { \__nicematrix_compute_i_j:nnnn #1 #2 } \cs_new_protected:Npn \__nicematrix_compute_i_j:nnnn #1 #2 #3 #4 { \tl_set:Nn \l__nicematrix_first_i_tl { #1 } \tl_set:Nn \l__nicematrix_first_j_tl { #2 } \tl_set:Nn \l__nicematrix_last_i_tl { #3 } \tl_set:Nn \l__nicematrix_last_j_tl { #4 } \tl_if_eq:NnT \l__nicematrix_first_i_tl { last } { \tl_set:NV \l__nicematrix_first_i_tl \c@iRow } \tl_if_eq:NnT \l__nicematrix_first_j_tl { last } { \tl_set:NV \l__nicematrix_first_j_tl \c@jCol } \tl_if_eq:NnT \l__nicematrix_last_i_tl { last } { \tl_set:NV \l__nicematrix_last_i_tl \c@iRow } \tl_if_eq:NnT \l__nicematrix_last_j_tl { last } { \tl_set:NV \l__nicematrix_last_j_tl \c@jCol } } \cs_new_protected:Npn \__nicematrix_sub_matrix:nnnnnnn #1 #2 #3 #4 #5 #6 #7 { \group_begin: \__nicematrix_compute_i_j:nn { #2 } { #3 } \bool_lazy_or:nnTF { \int_compare_p:nNn \l__nicematrix_last_i_tl > \g__nicematrix_row_total_int } { \int_compare_p:nNn \l__nicematrix_last_j_tl > \g__nicematrix_col_total_int } { \__nicematrix_error:nn { Construct~too~large } { \SubMatrix } } { \str_clear_new:N \l__nicematrix_submatrix_name_str \keys_set:nn { NiceMatrix / SubMatrix } { #5 } \pgfpicture \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse \pgfset { inner~sep = \c_zero_dim } \dim_set_eq:NN \l__nicematrix_x_initial_dim \c_max_dim \dim_set:Nn \l__nicematrix_x_final_dim { - \c_max_dim } \bool_if:NTF \l__nicematrix_submatrix_slim_bool { \int_step_inline:nnn \l__nicematrix_first_i_tl \l__nicematrix_last_i_tl } { \int_step_inline:nnn \l__nicematrix_first_row_int \g__nicematrix_row_total_int } { \cs_if_exist:cT { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - \l__nicematrix_first_j_tl } { \pgfpointanchor { \__nicematrix_env: - ##1 - \l__nicematrix_first_j_tl } { west } \dim_set:Nn \l__nicematrix_x_initial_dim { \dim_min:nn \l__nicematrix_x_initial_dim \pgf@x } } \cs_if_exist:cT { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - \l__nicematrix_last_j_tl } { \pgfpointanchor { \__nicematrix_env: - ##1 - \l__nicematrix_last_j_tl } { east } \dim_set:Nn \l__nicematrix_x_final_dim { \dim_max:nn \l__nicematrix_x_final_dim \pgf@x } } } \dim_compare:nNnTF \l__nicematrix_x_initial_dim = \c_max_dim { \__nicematrix_error:nn { Impossible~delimiter } { left } } { \dim_compare:nNnTF \l__nicematrix_x_final_dim = { - \c_max_dim } { \__nicematrix_error:nn { Impossible~delimiter } { right } } { \__nicematrix_sub_matrix_i:nnnn { #1 } { #4 } { #6 } { #7 } } } \endpgfpicture } \group_end: } \cs_new_protected:Npn \__nicematrix_sub_matrix_i:nnnn #1 #2 #3 #4 { \__nicematrix_qpoint:n { row - \l__nicematrix_first_i_tl - base } \dim_set:Nn \l__nicematrix_y_initial_dim { \pgf@y + ( \box_ht:N \strutbox + \extrarowheight ) * \arraystretch } \__nicematrix_qpoint:n { row - \l__nicematrix_last_i_tl - base } \dim_set:Nn \l__nicematrix_y_final_dim { \pgf@y - ( \box_dp:N \strutbox ) * \arraystretch } \int_step_inline:nnn \l__nicematrix_first_col_int \g__nicematrix_col_total_int { \cs_if_exist:cT { pgf @ sh @ ns @ \__nicematrix_env: - \l__nicematrix_first_i_tl - ##1 } { \pgfpointanchor { \__nicematrix_env: - \l__nicematrix_first_i_tl - ##1 } { north } \dim_set:Nn \l__nicematrix_y_initial_dim { \dim_max:nn \l__nicematrix_y_initial_dim \pgf@y } } \cs_if_exist:cT { pgf @ sh @ ns @ \__nicematrix_env: - \l__nicematrix_last_i_tl - ##1 } { \pgfpointanchor { \__nicematrix_env: - \l__nicematrix_last_i_tl - ##1 } { south } \dim_set:Nn \l__nicematrix_y_final_dim { \dim_min:nn \l__nicematrix_y_final_dim \pgf@y } } } \dim_set:Nn \l_tmpa_dim { \l__nicematrix_y_initial_dim - \l__nicematrix_y_final_dim + \l__nicematrix_submatrix_extra_height_dim - \arrayrulewidth } \dim_zero:N \nulldelimiterspace \group_begin: \pgfsetlinewidth { 1.1 \arrayrulewidth } \__nicematrix_set_CT@arc@:V \l__nicematrix_rules_color_tl \CT@arc@ \seq_map_inline:Nn \g__nicematrix_cols_vlism_seq { \int_compare:nNnT \l__nicematrix_first_j_tl < { ##1 } { \int_compare:nNnT { ##1 } < { \int_eval:n { \l__nicematrix_last_j_tl + 1 } } { \__nicematrix_qpoint:n { col - ##1 } \pgfpathmoveto { \pgfpoint \pgf@x \l__nicematrix_y_initial_dim } \pgfpathlineto { \pgfpoint \pgf@x \l__nicematrix_y_final_dim } \pgfusepathqstroke } } } \tl_if_eq:NnTF \l__nicematrix_submatrix_vlines_clist { all } { \int_step_inline:nn { \l__nicematrix_last_j_tl - \l__nicematrix_first_j_tl } } { \clist_map_inline:Nn \l__nicematrix_submatrix_vlines_clist } { \bool_lazy_and:nnTF { \int_compare_p:nNn { ##1 } > 0 } { \int_compare_p:nNn { ##1 } < { \l__nicematrix_last_j_tl - \l__nicematrix_first_j_tl + 1 } } { \__nicematrix_qpoint:n { col - \int_eval:n { ##1 + \l__nicematrix_first_j_tl } } \pgfpathmoveto { \pgfpoint \pgf@x \l__nicematrix_y_initial_dim } \pgfpathlineto { \pgfpoint \pgf@x \l__nicematrix_y_final_dim } \pgfusepathqstroke } { \__nicematrix_error:nnn { Wrong~line~in~SubMatrix } { vertical } { ##1 } } } \tl_if_eq:NnTF \l__nicematrix_submatrix_hlines_clist { all } { \int_step_inline:nn { \l__nicematrix_last_i_tl - \l__nicematrix_first_i_tl } } { \clist_map_inline:Nn \l__nicematrix_submatrix_hlines_clist } { \bool_lazy_and:nnTF { \int_compare_p:nNn { ##1 } > 0 } { \int_compare_p:nNn { ##1 } < { \l__nicematrix_last_i_tl - \l__nicematrix_first_i_tl + 1 } } { \__nicematrix_qpoint:n { row - \int_eval:n { ##1 + \l__nicematrix_first_i_tl } } \group_begin: \dim_set:Nn \l_tmpa_dim { \l__nicematrix_x_initial_dim - \l__nicematrix_submatrix_left_xshift_dim } \str_case:nn { #1 } { ( { \dim_sub:Nn \l_tmpa_dim { 0.9 mm } } [ { \dim_sub:Nn \l_tmpa_dim { 0.2 mm } } \{ { \dim_sub:Nn \l_tmpa_dim { 0.9 mm } } } \pgfpathmoveto { \pgfpoint \l_tmpa_dim \pgf@y } \dim_set:Nn \l_tmpb_dim { \l__nicematrix_x_final_dim + \l__nicematrix_submatrix_right_xshift_dim } \str_case:nn { #2 } { ) { \dim_add:Nn \l_tmpb_dim { 0.9 mm } } ] { \dim_add:Nn \l_tmpb_dim { 0.2 mm } } \} { \dim_add:Nn \l_tmpb_dim { 0.9 mm } } } \pgfpathlineto { \pgfpoint \l_tmpb_dim \pgf@y } \pgfusepathqstroke \group_end: } { \__nicematrix_error:nnn { Wrong~line~in~SubMatrix } { horizontal } { ##1 } } } \str_if_empty:NF \l__nicematrix_submatrix_name_str { \__nicematrix_pgf_rect_node:nnnnn \l__nicematrix_submatrix_name_str \l__nicematrix_x_initial_dim \l__nicematrix_y_initial_dim \l__nicematrix_x_final_dim \l__nicematrix_y_final_dim } \group_end: \begin { pgfscope } \pgftransformshift { \pgfpoint { \l__nicematrix_x_initial_dim - \l__nicematrix_submatrix_left_xshift_dim } { ( \l__nicematrix_y_initial_dim + \l__nicematrix_y_final_dim ) / 2 } } \str_if_empty:NTF \l__nicematrix_submatrix_name_str { \__nicematrix_node_left:nn #1 { } } { \__nicematrix_node_left:nn #1 { \__nicematrix_env: - \l__nicematrix_submatrix_name_str - left } } \end { pgfscope } \pgftransformshift { \pgfpoint { \l__nicematrix_x_final_dim + \l__nicematrix_submatrix_right_xshift_dim } { ( \l__nicematrix_y_initial_dim + \l__nicematrix_y_final_dim ) / 2 } } \str_if_empty:NTF \l__nicematrix_submatrix_name_str { \__nicematrix_node_right:nnnn #2 { } { #3 } { #4 } } { \__nicematrix_node_right:nnnn #2 { \__nicematrix_env: - \l__nicematrix_submatrix_name_str - right } { #3 } { #4 } } \cs_set_eq:NN \pgfpointanchor \__nicematrix_pgfpointanchor:n \flag_clear_new:n { nicematrix } \l__nicematrix_code_tl } \cs_set_eq:NN \__nicematrix_old_pgfpointanchor \pgfpointanchor \cs_new_protected:Npn \__nicematrix_pgfpointanchor:n #1 { \use:e { \exp_not:N \__nicematrix_old_pgfpointanchor { \__nicematrix_pgfpointanchor_i:nn #1 } } } \cs_new:Npn \__nicematrix_pgfpointanchor_i:nn #1 #2 { #1 { \__nicematrix_pgfpointanchor_ii:w #2 - \q_stop } } \tl_const:Nn \c__nicematrix_integers_alist_tl { { 1 } { } { 2 } { } { 3 } { } { 4 } { } { 5 } { } { 6 } { } { 7 } { } { 8 } { } { 9 } { } { 10 } { } { 11 } { } { 12 } { } { 13 } { } { 14 } { } { 15 } { } { 16 } { } { 17 } { } { 18 } { } { 19 } { } { 20 } { } } \cs_new:Npn \__nicematrix_pgfpointanchor_ii:w #1-#2\q_stop { \tl_if_empty:nTF { #2 } { \str_case:nVTF { #1 } \c__nicematrix_integers_alist_tl { \flag_raise:n { nicematrix } \int_if_even:nTF { \flag_height:n { nicematrix } } { \int_eval:n { #1 + \l__nicematrix_first_i_tl - 1 } } { \int_eval:n { #1 + \l__nicematrix_first_j_tl - 1 } } } { #1 } } { \__nicematrix_pgfpointanchor_iii:w { #1 } #2 } } \cs_new:Npn \__nicematrix_pgfpointanchor_iii:w #1 #2 - { \str_case:nnF { #1 } { { row } { row - \int_eval:n { #2 + \l__nicematrix_first_i_tl - 1 } } { col } { col - \int_eval:n { #2 + \l__nicematrix_first_j_tl - 1 } } } { \int_eval:n { #1 + \l__nicematrix_first_i_tl - 1 } - \int_eval:n { #2 + \l__nicematrix_first_j_tl - 1 } } } \cs_new_protected:Npn \__nicematrix_node_left:nn #1 #2 { \pgfnode { rectangle } { east } { \nullfont \c_math_toggle_token \__nicematrix_color:V \l__nicematrix_delimiters_color_tl \left #1 \vcenter { \nullfont \hrule \@height \l_tmpa_dim \@depth \c_zero_dim \@width \c_zero_dim } \right . \c_math_toggle_token } { #2 } { } } \cs_new_protected:Npn \__nicematrix_node_right:nnnn #1 #2 #3 #4 { \pgfnode { rectangle } { west } { \nullfont \c_math_toggle_token \__nicematrix_color:V \l__nicematrix_delimiters_color_tl \left . \vcenter { \nullfont \hrule \@height \l_tmpa_dim \@depth \c_zero_dim \@width \c_zero_dim } \right #1 \tl_if_empty:nF { #3 } { _ { \smash { #3 } } } ^ { \smash { #4 } } \c_math_toggle_token } { #2 } { } } \NewDocumentCommand \__nicematrix_UnderBrace { O { } m m m O { } } { \peek_remove_spaces:n { \__nicematrix_brace:nnnnn { #2 } { #3 } { #4 } { #1 , #5 } { under } } } \NewDocumentCommand \__nicematrix_OverBrace { O { } m m m O { } } { \peek_remove_spaces:n { \__nicematrix_brace:nnnnn { #2 } { #3 } { #4 } { #1 , #5 } { over } } } \keys_define:nn { NiceMatrix / Brace } { left-shorten .bool_set:N = \l__nicematrix_brace_left_shorten_bool , left-shorten .default: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 , yshift .dim_set:N = \l__nicematrix_brace_yshift_dim , yshift .value_required:n = true , yshift .initial:n = \c_zero_dim , color .tl_set:N = \l_tmpa_tl , color .value_required:n = true , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~Brace } } \cs_new_protected:Npn \__nicematrix_brace:nnnnn #1 #2 #3 #4 #5 { \group_begin: \__nicematrix_compute_i_j:nn { #1 } { #2 } \bool_lazy_or:nnTF { \int_compare_p:nNn \l__nicematrix_last_i_tl > \g__nicematrix_row_total_int } { \int_compare_p:nNn \l__nicematrix_last_j_tl > \g__nicematrix_col_total_int } { \str_if_eq:nnTF { #5 } { under } { \__nicematrix_error:nn { Construct~too~large } { \UnderBrace } } { \__nicematrix_error:nn { Construct~too~large } { \OverBrace } } } { \tl_clear:N \l_tmpa_tl % added the 2022-02-25 \keys_set:nn { NiceMatrix / Brace } { #4 } \tl_if_empty:NF \l_tmpa_tl { \color { \l_tmpa_tl } } % added the 2022-02-25 \pgfpicture \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse \bool_if:NT \l__nicematrix_brace_left_shorten_bool { \dim_set_eq:NN \l__nicematrix_x_initial_dim \c_max_dim \int_step_inline:nnn \l__nicematrix_first_i_tl \l__nicematrix_last_i_tl { \cs_if_exist:cT { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - \l__nicematrix_first_j_tl } { \pgfpointanchor { \__nicematrix_env: - ##1 - \l__nicematrix_first_j_tl } { west } \dim_set:Nn \l__nicematrix_x_initial_dim { \dim_min:nn \l__nicematrix_x_initial_dim \pgf@x } } } } \bool_lazy_or:nnT { \bool_not_p:n \l__nicematrix_brace_left_shorten_bool } { \dim_compare_p:nNn \l__nicematrix_x_initial_dim = \c_max_dim } { \__nicematrix_qpoint:n { col - \l__nicematrix_first_j_tl } \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x } \bool_if:NT \l__nicematrix_brace_right_shorten_bool { \dim_set:Nn \l__nicematrix_x_final_dim { - \c_max_dim } \int_step_inline:nnn \l__nicematrix_first_i_tl \l__nicematrix_last_i_tl { \cs_if_exist:cT { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - \l__nicematrix_last_j_tl } { \pgfpointanchor { \__nicematrix_env: - ##1 - \l__nicematrix_last_j_tl } { east } \dim_set:Nn \l__nicematrix_x_final_dim { \dim_max:nn \l__nicematrix_x_final_dim \pgf@x } } } } \bool_lazy_or:nnT { \bool_not_p:n \l__nicematrix_brace_right_shorten_bool } { \dim_compare_p:nNn \l__nicematrix_x_final_dim = { - \c_max_dim } } { \__nicematrix_qpoint:n { col - \int_eval:n { \l__nicematrix_last_j_tl + 1 } } \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x } \pgfset { inner~sep = \c_zero_dim } \str_if_eq:nnTF { #5 } { under } { \__nicematrix_underbrace_i:n { #3 } } { \__nicematrix_overbrace_i:n { #3 } } \endpgfpicture } \group_end: } \cs_new_protected:Npn \__nicematrix_overbrace_i:n #1 { \__nicematrix_qpoint:n { row - \l__nicematrix_first_i_tl } \pgftransformshift { \pgfpoint { ( \l__nicematrix_x_initial_dim + \l__nicematrix_x_final_dim) / 2 } { \pgf@y + \l__nicematrix_brace_yshift_dim - 3 pt} } \pgfnode { rectangle } { south } { \vbox_top:n { \group_begin: \everycr { } \halign { \hfil ## \hfil \crcr \__nicematrix_math_toggle_token: #1 \__nicematrix_math_toggle_token: \cr \noalign { \skip_vertical:n { 3 pt } \nointerlineskip } \c_math_toggle_token \overbrace { \hbox_to_wd:nn { \l__nicematrix_x_final_dim - \l__nicematrix_x_initial_dim } { } } \c_math_toggle_token \cr } \group_end: } } { } { } } \cs_new_protected:Npn \__nicematrix_underbrace_i:n #1 { \__nicematrix_qpoint:n { row - \int_eval:n { \l__nicematrix_last_i_tl + 1 } } \pgftransformshift { \pgfpoint { ( \l__nicematrix_x_initial_dim + \l__nicematrix_x_final_dim) / 2 } { \pgf@y - \l__nicematrix_brace_yshift_dim + 3 pt } } \pgfnode { rectangle } { north } { \group_begin: \everycr { } \vbox:n { \halign { \hfil ## \hfil \crcr \c_math_toggle_token \underbrace { \hbox_to_wd:nn { \l__nicematrix_x_final_dim - \l__nicematrix_x_initial_dim } { } } \c_math_toggle_token \cr \noalign { \skip_vertical:n { 3 pt } \nointerlineskip } \__nicematrix_math_toggle_token: #1 \__nicematrix_math_toggle_token: \cr } } \group_end: } { } { } } \NewDocumentCommand \__nicematrix_ShowCellNames { } { \dim_zero_new:N \g__nicematrix_tmpc_dim \dim_zero_new:N \g__nicematrix_tmpd_dim \dim_zero_new:N \g__nicematrix_tmpe_dim \int_step_inline:nn \c@iRow { \begin { pgfpicture } \__nicematrix_qpoint:n { row - ##1 } \dim_set_eq:NN \l_tmpa_dim \pgf@y \__nicematrix_qpoint:n { row - \int_eval:n { ##1 + 1 } } \dim_gset:Nn \g_tmpa_dim { ( \l_tmpa_dim + \pgf@y ) / 2 } \dim_gset:Nn \g_tmpb_dim { \l_tmpa_dim - \pgf@y } \end { pgfpicture } \int_step_inline:nn \c@jCol { \hbox_set:Nn \l_tmpa_box { \normalfont \Large \color { red ! 50 } ##1 - ####1 } \begin { pgfpicture } \__nicematrix_qpoint:n { col - ####1 } \dim_gset_eq:NN \g__nicematrix_tmpc_dim \pgf@x \__nicematrix_qpoint:n { col - \int_eval:n { ####1 + 1 } } \dim_gset:Nn \g__nicematrix_tmpd_dim { \pgf@x - \g__nicematrix_tmpc_dim } \dim_gset_eq:NN \g__nicematrix_tmpe_dim \pgf@x \end { pgfpicture } \fp_set:Nn \l_tmpa_fp { \fp_min:nn { \fp_min:nn { \dim_ratio:nn { \g__nicematrix_tmpd_dim } { \box_wd:N \l_tmpa_box } } { \dim_ratio:nn { \g_tmpb_dim } { \box_ht_plus_dp:N \l_tmpa_box } } } { 1.0 } } \box_scale:Nnn \l_tmpa_box { \fp_use:N \l_tmpa_fp } { \fp_use:N \l_tmpa_fp } \pgfpicture \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse \pgftransformshift { \pgfpoint { 0.5 * ( \g__nicematrix_tmpc_dim + \g__nicematrix_tmpe_dim ) } { \dim_use:N \g_tmpa_dim } } \pgfnode { rectangle } { center } { \box_use:N \l_tmpa_box } { } { } \endpgfpicture } } } \bool_new:N \c__nicematrix_footnotehyper_bool \bool_new:N \c__nicematrix_footnote_bool \msg_new:nnnn { nicematrix } { Unknown~key~for~package } { The~key~'\l_keys_key_str'~is~unknown. \\ That~key~will~be~ignored. \\ For~a~list~of~the~available~keys,~type~H~. } { The~available~keys~are~(in~alphabetic~order):~ footnote,~ footnotehyper,~ messages-for-Overleaf,~ renew-dots,~and renew-matrix. } \keys_define:nn { NiceMatrix / Package } { renew-dots .bool_set:N = \l__nicematrix_renew_dots_bool , renew-dots .value_forbidden:n = true , renew-matrix .code:n = \__nicematrix_renew_matrix: , renew-matrix .value_forbidden:n = true , messages-for-Overleaf .bool_set:N = \c__nicematrix_messages_for_Overleaf_bool , footnote .bool_set:N = \c__nicematrix_footnote_bool , footnotehyper .bool_set:N = \c__nicematrix_footnotehyper_bool , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~package } } \ProcessKeysOptions { NiceMatrix / Package } \__nicematrix_msg_new:nn { footnote~with~footnotehyper~package } { You~can't~use~the~option~'footnote'~because~the~package~ footnotehyper~has~already~been~loaded.~ If~you~want,~you~can~use~the~option~'footnotehyper'~and~the~footnotes~ within~the~environments~of~nicematrix~will~be~extracted~with~the~tools~ of~the~package~footnotehyper.\\ The~package~footnote~won't~be~loaded. } \__nicematrix_msg_new:nn { footnotehyper~with~footnote~package } { You~can't~use~the~option~'footnotehyper'~because~the~package~ footnote~has~already~been~loaded.~ If~you~want,~you~can~use~the~option~'footnote'~and~the~footnotes~ within~the~environments~of~nicematrix~will~be~extracted~with~the~tools~ of~the~package~footnote.\\ The~package~footnotehyper~won't~be~loaded. } \bool_if:NT \c__nicematrix_footnote_bool { \@ifclassloaded { beamer } { \bool_set_false:N \c__nicematrix_footnote_bool } { \@ifpackageloaded { footnotehyper } { \__nicematrix_error:n { footnote~with~footnotehyper~package } } { \usepackage { footnote } } } } \bool_if:NT \c__nicematrix_footnotehyper_bool { \@ifclassloaded { beamer } { \bool_set_false:N \c__nicematrix_footnote_bool } { \@ifpackageloaded { footnote } { \__nicematrix_error:n { footnotehyper~with~footnote~package } } { \usepackage { footnotehyper } } } \bool_set_true:N \c__nicematrix_footnote_bool } \bool_new:N \l__nicematrix_underscore_loaded_bool \@ifpackageloaded { underscore } { \bool_set_true:N \l__nicematrix_underscore_loaded_bool } { } \hook_gput_code:nnn { begindocument } { . } { \bool_if:NF \l__nicematrix_underscore_loaded_bool { \@ifpackageloaded { underscore } { \__nicematrix_error:n { underscore~after~nicematrix } } } } \bool_if:NTF \c__nicematrix_messages_for_Overleaf_bool { \str_const:Nn \c__nicematrix_available_keys_str { } } { \str_const:Nn \c__nicematrix_available_keys_str { For~a~list~of~the~available~keys,~type~H~. } } \seq_new:N \g__nicematrix_types_of_matrix_seq \seq_gset_from_clist:Nn \g__nicematrix_types_of_matrix_seq { NiceMatrix , pNiceMatrix , bNiceMatrix , vNiceMatrix, BNiceMatrix, VNiceMatrix } \seq_gset_map_x:NNn \g__nicematrix_types_of_matrix_seq \g__nicematrix_types_of_matrix_seq { \tl_to_str:n { #1 } } \cs_new_protected:Npn \__nicematrix_error_too_much_cols: { \seq_if_in:NVTF \g__nicematrix_types_of_matrix_seq \g__nicematrix_name_env_str { \int_compare:nNnTF \l__nicematrix_last_col_int = { -2 } { \__nicematrix_fatal:n { too~much~cols~for~matrix } } { \bool_if:NF \l__nicematrix_last_col_without_value_bool { \__nicematrix_fatal:n { too~much~cols~for~matrix~with~last~col } } } } { \__nicematrix_fatal:n { too~much~cols~for~array } } } \cs_new:Npn \__nicematrix_message_hdotsfor: { \tl_if_empty:VF \g__nicematrix_HVdotsfor_lines_tl { ~Maybe~your~use~of~\token_to_str:N \Hdotsfor\ is~incorrect.} } \__nicematrix_msg_new:nn { negative~weight } { Negative~weight.\\ The~weight~of~the~'X'~columns~must~be~positive~and~you~have~used~ the~value~'\int_use:N \l__nicematrix_weight_int'.\\ The~absolute~value~will~be~used. } \__nicematrix_msg_new:nn { last~col~not~used } { Column~not~used.\\ The~key~'last-col'~is~in~force~but~you~have~not~used~that~last~column~ in~your~\__nicematrix_full_name_env:.~However,~you~can~go~on. } \__nicematrix_msg_new:nn { too~much~cols~for~matrix~with~last~col } { Too~much~columns.\\ In~the~row~\int_eval:n { \c@jCol - 1 },~ you~try~to~use~more~columns~ than~allowed~by~your~\__nicematrix_full_name_env:.\__nicematrix_message_hdotsfor:\ The~maximal~number~of~columns~is~\int_eval:n { \l__nicematrix_last_col_int - 1 }~ (plus~the~exterior~columns).~This~error~is~fatal. } \__nicematrix_msg_new:nn { too~much~cols~for~matrix } { Too~much~columns.\\ In~the~row~\int_eval:n { \c@jCol - 1 },~ you~try~to~use~more~columns~than~allowed~by~your~ \__nicematrix_full_name_env:.\__nicematrix_message_hdotsfor:\ Recall~that~the~maximal~ number~of~columns~for~a~matrix~is~fixed~by~the~LaTeX~counter~ 'MaxMatrixCols'.~Its~current~value~is~\int_use:N \c@MaxMatrixCols.~ This~error~is~fatal. } \__nicematrix_msg_new:nn { too~much~cols~for~array } { Too~much~columns.\\ In~the~row~\int_eval:n { \c@jCol - 1 },~ ~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).~ This~error~is~fatal. } \__nicematrix_msg_new:nn { columns~not~used } { Columns~not~used.\\ 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.\\ We~won't~have~similar~error~till~the~end~of~the~document. } \__nicematrix_msg_new:nn { in~first~col } { Erroneous~use.\\ You~can't~use~the~command~#1 in~the~first~column~(number~0)~of~the~array.\\ That~command~will~be~ignored. } \__nicematrix_msg_new:nn { in~last~col } { Erroneous~use.\\ You~can't~use~the~command~#1 in~the~last~column~(exterior)~of~the~array.\\ That~command~will~be~ignored. } \__nicematrix_msg_new:nn { in~first~row } { Erroneous~use.\\ You~can't~use~the~command~#1 in~the~first~row~(number~0)~of~the~array.\\ That~command~will~be~ignored. } \__nicematrix_msg_new:nn { in~last~row } { You~can't~use~the~command~#1 in~the~last~row~(exterior)~of~the~array.\\ That~command~will~be~ignored. } \__nicematrix_msg_new:nn { caption~outside~float } { Key~caption~forbidden.\\ You~can't~use~the~key~'caption'~because~you~are~not~in~a~floating~ environment.~This~key~will~be~ignored. } \__nicematrix_msg_new:nn { short-caption~without~caption } { You~should~not~use~the~key~'short-caption'~without~'caption'.~ However,~your~'short-caption'~will~be~used~as~'caption'. } \__nicematrix_msg_new:nn { double~closing~delimiter } { Double~delimiter.\\ You~can't~put~a~second~closing~delimiter~"#1"~just~after~a~first~closing~ delimiter.~This~delimiter~will~be~ignored. } \__nicematrix_msg_new:nn { delimiter~after~opening } { Double~delimiter.\\ You~can't~put~a~second~delimiter~"#1"~just~after~a~first~opening~ delimiter.~That~delimiter~will~be~ignored. } \__nicematrix_msg_new:nn { bad~option~for~line-style } { Bad~line~style.\\ Since~you~haven't~loaded~Tikz,~the~only~value~you~can~give~to~'line-style'~ is~'standard'.~That~key~will~be~ignored. } \__nicematrix_msg_new:nn { Identical~notes~in~caption } { Identical~tabular~notes.\\ You~can't~put~several~notes~with~the~same~content~in~ \token_to_str:N \caption\ (but~you~can~in~the~main~tabular).\\ If~you~go~on,~the~output~will~probably~be~erroneous. } \__nicematrix_msg_new:nn { tabularnote~below~the~tabular } { \token_to_str:N \tabularnote\ forbidden\\ You~can't~use~\token_to_str:N \tabularnote\ in~the~caption~ of~your~tabular~because~the~caption~will~be~composed~below~ the~tabular.~If~you~want~the~caption~above~the~tabular~use~the~ key~'caption-above'~in~\token_to_str:N \NiceMatrixOptions.\\ Your~\token_to_str:N \tabularnote\ will~be~discarded~and~ no~similar~error~will~raised~in~this~document. } \__nicematrix_msg_new:nn { Unknown~key~for~rules } { Unknown~key.\\ There~is~only~two~keys~available~here:~width~and~color.\\ You~key~'\l_keys_key_str'~will~be~ignored. } \__nicematrix_msg_new:nnn { Unknown~key~for~custom-line } { Unknown~key.\\ The~key~'\l_keys_key_str'~is~unknown~in~a~'custom-line'.~ It~you~go~on,~you~will~probably~have~other~errors. \\ \c__nicematrix_available_keys_str } { The~available~keys~are~(in~alphabetic~order):~ ccommand,~ color,~ command,~ dotted,~ letter,~ multiplicity,~ sep-color,~ tikz,~and~total-width. } \__nicematrix_msg_new:nnn { Unknown~key~for~xdots } { Unknown~key.\\ The~key~'\l_keys_key_str'~is~unknown~for~a~command~for~drawing~dotted~rules.\\ \c__nicematrix_available_keys_str } { The~available~keys~are~(in~alphabetic~order):~ 'color',~ 'inter',~ 'line-style',~ 'radius',~ 'shorten',~ 'shorten-end'~and~'shorten-start'. } \__nicematrix_msg_new:nn { Unknown~key~for~rowcolors } { Unknown~key.\\ As~for~now,~there~is~only~two~keys~available~here:~'cols'~and~'respect-blocks'~ (and~you~try~to~use~'\l_keys_key_str')\\ That~key~will~be~ignored. } \__nicematrix_msg_new:nn { label~without~caption } { You~can't~use~the~key~'label'~in~your~'{NiceTabular}'~because~ you~have~not~used~the~key~'caption'.~The~key~'label'~will~be~ignored. } \__nicematrix_msg_new:nn { Construct~too~large } { Construct~too~large.\\ Your~command~\token_to_str:N #1 can't~be~drawn~because~your~matrix~is~too~small.\\ That~command~will~be~ignored. } \__nicematrix_msg_new:nn { underscore~after~nicematrix } { Problem~with~'underscore'.\\ The~package~'underscore'~should~be~loaded~before~'nicematrix'.~ You~can~go~on~but~you~won't~be~able~to~write~something~such~as:\\ '\token_to_str:N \Cdots\token_to_str:N _{n~\token_to_str:N \text{~times}}'. } \__nicematrix_msg_new:nn { ampersand~in~light-syntax } { Ampersand~forbidden.\\ You~can't~use~an~ampersand~(\token_to_str:N &)~to~separate~columns~because~ ~the~key~'light-syntax'~is~in~force.~This~error~is~fatal. } \__nicematrix_msg_new:nn { double-backslash~in~light-syntax } { Double~backslash~forbidden.\\ You~can't~use~\token_to_str:N \\~to~separate~rows~because~the~key~'light-syntax'~ is~in~force.~You~must~use~the~character~'\l__nicematrix_end_of_row_tl'~ (set~by~the~key~'end-of-row').~This~error~is~fatal. } \__nicematrix_msg_new:nn { hlines~with~color } { 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.\\ Your~key~will~be~discarded. } \__nicematrix_msg_new:nn { bad~value~for~baseline } { Bad~value~for~baseline.\\ The~value~given~to~'baseline'~(\int_use:N \l_tmpa_int)~is~not~ valid.~The~value~must~be~between~\int_use:N \l__nicematrix_first_row_int\ and~ \int_use:N \g__nicematrix_row_total_int\ or~equal~to~'t',~'c'~or~'b'~or~of~ the~form~'line-i'.\\ A~value~of~1~will~be~used. } \__nicematrix_msg_new:nn { Invalid~name } { Invalid~name.\\ You~can't~give~the~name~'\l_keys_value_tl'~to~a~\token_to_str:N \SubMatrix\ of~your~\__nicematrix_full_name_env:.\\ A~name~must~be~accepted~by~the~regular~expression~[A-Za-z][A-Za-z0-9]*.\\ This~key~will~be~ignored. } \__nicematrix_msg_new:nn { Wrong~line~in~SubMatrix } { Wrong~line.\\ You~try~to~draw~a~#1~line~of~number~'#2'~in~a~ \token_to_str:N \SubMatrix\ of~your~\__nicematrix_full_name_env:\ but~that~ number~is~not~valid.~It~will~be~ignored. } \__nicematrix_msg_new:nn { Impossible~delimiter } { Impossible~delimiter.\\ It's~impossible~to~draw~the~#1~delimiter~of~your~ \token_to_str:N \SubMatrix\ because~all~the~cells~are~empty~ in~that~column. \bool_if:NT \l__nicematrix_submatrix_slim_bool { ~Maybe~you~should~try~without~the~key~'slim'. } \\ This~\token_to_str:N \SubMatrix\ will~be~ignored. } \__nicematrix_msg_new:nn { width~without~X~columns } { You~have~used~the~key~'width'~but~you~have~put~no~'X'~column.~ That~key~will~be~ignored. } \__nicematrix_msg_new:nn { key~multiplicity~with~dotted } { Incompatible~keys. \\ You~have~used~the~key~'multiplicity'~with~the~key~'dotted'~ in~a~'custom-line'.~They~are~incompatible. \\ The~key~'multiplicity'~will~be~discarded. } \__nicematrix_msg_new:nn { empty~environment } { Empty~environment.\\ Your~\__nicematrix_full_name_env:\ is~empty.~This~error~is~fatal. } \__nicematrix_msg_new:nn { Wrong~use~of~v-center } { Wrong~use~of~v-center.\\ You~should~not~use~the~key~'v-center'~here~because~your~block~is~not~ mono-row.~However,~you~can~go~on. } \__nicematrix_msg_new:nn { No~letter~and~no~command } { Erroneous~use.\\ Your~use~of~'custom-line'~is~no-op~since~you~don't~have~used~the~ key~'letter'~(for~a~letter~for~vertical~rules)~nor~the~keys~'command'~or~ ~'ccommand'~(to~draw~horizontal~rules).\\ However,~you~can~go~on. } \__nicematrix_msg_new:nn { Forbidden~letter } { Forbidden~letter.\\ You~can't~use~the~letter~'\l__nicematrix_letter_str'~for~a~customized~line.\\ It~will~be~ignored. } \__nicematrix_msg_new:nn { Several~letters } { Wrong~name.\\ You~must~use~only~one~letter~as~value~for~the~key~'letter'~(and~you~ have~used~'\l__nicematrix_letter_str').\\ It~will~be~ignored. } \__nicematrix_msg_new:nn { Delimiter~with~small } { Delimiter~forbidden.\\ You~can't~put~a~delimiter~in~the~preamble~of~your~\__nicematrix_full_name_env:\ because~the~key~'small'~is~in~force.\\ This~error~is~fatal. } \__nicematrix_msg_new:nn { unknown~cell~for~line~in~CodeAfter } { Unknown~cell.\\ Your~command~\token_to_str:N\line\{#1\}\{#2\}~in~ the~\token_to_str:N \CodeAfter\ of~your~\__nicematrix_full_name_env:\ can't~be~executed~because~a~cell~doesn't~exist.\\ This~command~\token_to_str:N \line\ will~be~ignored. } \__nicematrix_msg_new:nnn { Duplicate~name~for~SubMatrix } { Duplicate~name.\\ The~name~'#1'~is~already~used~for~a~\token_to_str:N \SubMatrix\ in~this~\__nicematrix_full_name_env:.\\ This~key~will~be~ignored.\\ \bool_if:NF \c__nicematrix_messages_for_Overleaf_bool { For~a~list~of~the~names~already~used,~type~H~. } } { The~names~already~defined~in~this~\__nicematrix_full_name_env:\ are:~ \seq_use:Nnnn \g__nicematrix_submatrix_names_seq { ~and~ } { ,~ } { ~and~ }. } \__nicematrix_msg_new:nn { r~or~l~with~preamble } { Erroneous~use.\\ You~can't~use~the~key~'\l_keys_key_str'~in~your~\__nicematrix_full_name_env:.~ You~must~specify~the~alignment~of~your~columns~with~the~preamble~of~ your~\__nicematrix_full_name_env:.\\ This~key~will~be~ignored. } \__nicematrix_msg_new:nn { Hdotsfor~in~col~0 } { Erroneous~use.\\ You~can't~use~\token_to_str:N \Hdotsfor\ in~an~exterior~column~of~ the~array.~This~error~is~fatal. } \__nicematrix_msg_new:nn { bad~corner } { Bad~corner.\\ #1~is~an~incorrect~specification~for~a~corner~(in~the~key~ 'corners').~The~available~values~are:~NW,~SW,~NE~and~SE.\\ This~specification~of~corner~will~be~ignored. } \__nicematrix_msg_new:nn { bad~border } { Bad~border.\\ \l_keys_key_str\space~is~an~incorrect~specification~for~a~border~ (in~the~key~'borders'~of~the~command~\token_to_str:N \Block).~ The~available~values~are:~left,~right,~top~and~bottom~(and~you~can~ also~use~the~key~'tikz' \bool_if:nF \c__nicematrix_tikz_loaded_bool {~if~you~load~the~LaTeX~package~'tikz'}).\\ This~specification~of~border~will~be~ignored. } \__nicematrix_msg_new:nn { tikz~key~without~tikz } { Tikz~not~loaded.\\ You~can't~use~the~key~'tikz'~for~the~command~'\token_to_str:N \Block'~because~you~have~not~loaded~Tikz.~ This~key~will~be~ignored. } \__nicematrix_msg_new:nn { last-col~non~empty~for~NiceArray } { Erroneous~use.\\ In~the~\__nicematrix_full_name_env:,~you~must~use~the~key~ 'last-col'~without~value.\\ However,~you~can~go~on~for~this~time~ (the~value~'\l_keys_value_tl'~will~be~ignored). } \__nicematrix_msg_new:nn { last-col~non~empty~for~NiceMatrixOptions } { Erroneous~use.\\ In~\NiceMatrixoptions,~you~must~use~the~key~ 'last-col'~without~value.\\ However,~you~can~go~on~for~this~time~ (the~value~'\l_keys_value_tl'~will~be~ignored). } \__nicematrix_msg_new:nn { Block~too~large~1 } { Block~too~large.\\ You~try~to~draw~a~block~in~the~cell~#1-#2~of~your~matrix~but~the~matrix~is~ too~small~for~that~block. \\ } \__nicematrix_msg_new:nn { Block~too~large~2 } { Block~too~large.\\ 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\ and~that's~why~a~block~ specified~in~the~cell~#1-#2~can't~be~drawn.~You~should~add~some~ampersands~ (&)~at~the~end~of~the~first~row~of~your~ \__nicematrix_full_name_env:.\\ This~block~and~maybe~others~will~be~ignored. } \__nicematrix_msg_new:nn { unknown~column~type } { Bad~column~type.\\ The~column~type~'#1'~in~your~\__nicematrix_full_name_env:\ is~unknown. \\ This~error~is~fatal. } \__nicematrix_msg_new:nn { tabularnote~forbidden } { Forbidden~command.\\ You~can't~use~the~command~\token_to_str:N\tabularnote\ ~in~a~\__nicematrix_full_name_env:.~This~command~is~available~only~in~ \{NiceTabular\},~\{NiceArray\}~and~\{NiceMatrix\}. \\ This~command~will~be~ignored. } \__nicematrix_msg_new:nn { borders~forbidden } { Forbidden~key.\\ You~can't~use~the~key~'borders'~of~the~command~\token_to_str:N \Block\ because~the~option~'rounded-corners'~ is~in~force~with~a~non-zero~value.\\ This~key~will~be~ignored. } \__nicematrix_msg_new:nn { bottomrule~without~booktabs } { booktabs~not~loaded.\\ You~can't~use~the~key~'tabular/bottomrule'~because~you~haven't~ loaded~'booktabs'.\\ This~key~will~be~ignored. } \__nicematrix_msg_new:nn { enumitem~not~loaded } { enumitem~not~loaded.\\ You~can't~use~the~command~\token_to_str:N\tabularnote\ ~because~you~haven't~loaded~'enumitem'.\\ All~the~commands~\token_to_str:N\tabularnote\ will~be~ ignored~in~the~document. } \__nicematrix_msg_new:nn { tikz~in~custom-line~without~tikz } { Tikz~not~loaded.\\ You~have~used~the~key~'tikz'~in~the~definition~of~a~ customized~line~(with~'custom-line')~but~Tikz~is~not~loaded.~ You~can~go~on~but~you~will~have~another~error~if~you~actually~ use~that~custom~line. } \__nicematrix_msg_new:nn { tikz~in~borders~without~tikz } { Tikz~not~loaded.\\ You~have~used~the~key~'tikz'~in~a~key~'borders'~(of~a~ command~'\token_to_str:N\Block')~but~Tikz~is~not~loaded.~ That~key~will~be~ignored. } \__nicematrix_msg_new:nn { color~in~custom-line~with~tikz } { Erroneous~use.\\ In~a~'custom-line',~you~have~used~both~'tikz'~and~'color',~ which~is~forbidden~(you~should~use~'color'~inside~the~key~'tikz').~ The~key~'color'~will~be~discarded. } \__nicematrix_msg_new:nn { Wrong~last~row } { Wrong~number.\\ You~have~used~'last-row=\int_use:N \l__nicematrix_last_row_int'~but~your~ \__nicematrix_full_name_env:\ seems~to~have~\int_use:N \c@iRow \ rows.~ If~you~go~on,~the~value~of~\int_use:N \c@iRow \ will~be~used~for~ last~row.~You~can~avoid~this~problem~by~using~'last-row'~ without~value~(more~compilations~might~be~necessary). } \__nicematrix_msg_new:nn { Yet~in~env } { Nested~environments.\\ Environments~of~nicematrix~can't~be~nested.\\ This~error~is~fatal. } \__nicematrix_msg_new:nn { Outside~math~mode } { Outside~math~mode.\\ The~\__nicematrix_full_name_env:\ can~be~used~only~in~math~mode~ (and~not~in~\token_to_str:N \vcenter).\\ This~error~is~fatal. } \__nicematrix_msg_new:nn { One~letter~allowed } { Bad~name.\\ The~value~of~key~'\l_keys_key_str'~must~be~of~length~1.\\ It~will~be~ignored. } \__nicematrix_msg_new:nn { varwidth~not~loaded } { varwidth~not~loaded.\\ You~can't~use~the~column~type~'V'~because~'varwidth'~is~not~ loaded.\\ Your~column~will~behave~like~'p'. } \__nicematrix_msg_new:nnn { Unknow~key~for~RulesBis } { Unkown~key.\\ Your~key~'\l_keys_key_str'~is~unknown~for~a~rule.\\ \c__nicematrix_available_keys_str } { The~available~keys~are~(in~alphabetic~order):~ color,~ dotted,~ multiplicity,~ sep-color,~ tikz,~and~total-width. } \__nicematrix_msg_new:nnn { Unknown~key~for~Block } { Unknown~key.\\ The~key~'\l_keys_key_str'~is~unknown~for~the~command~\token_to_str:N \Block.\\ It~will~be~ignored. \\ \c__nicematrix_available_keys_str } { The~available~keys~are~(in~alphabetic~order):~b,~borders,~c,~draw,~fill,~ hlines,~hvlines,~l,~line-width,~name,~rounded-corners,~r,~respect-arraystretch, ~t,~tikz~and~vlines. } \__nicematrix_msg_new:nn { Version~of~siunitx~too~old } { siunitx~too~old.\\ You~can't~use~'S'~columns~because~your~version~of~'siunitx'~ is~too~old.~You~need~at~least~v~3.0~and~your~log~file~says:~"siunitx,~ \use:c { ver @ siunitx.sty }". \\ This~error~is~fatal. } \__nicematrix_msg_new:nnn { Unknown~key~for~Brace } { Unknown~key.\\ The~key~'\l_keys_key_str'~is~unknown~for~the~commands~\token_to_str:N \UnderBrace\ and~\token_to_str:N \OverBrace.\\ It~will~be~ignored. \\ \c__nicematrix_available_keys_str } { The~available~keys~are~(in~alphabetic~order):~color,~left-shorten,~ right-shorten,~shorten~(which~fixes~both~left-shorten~and~ right-shorten)~and~yshift. } \__nicematrix_msg_new:nnn { Unknown~key~for~CodeAfter } { Unknown~key.\\ The~key~'\l_keys_key_str'~is~unknown.\\ It~will~be~ignored. \\ \c__nicematrix_available_keys_str } { The~available~keys~are~(in~alphabetic~order):~ delimiters/color,~ rules~(with~the~subkeys~'color'~and~'width'),~ sub-matrix~(several~subkeys)~ and~xdots~(several~subkeys).~ The~latter~is~for~the~command~\token_to_str:N \line. } \__nicematrix_msg_new:nnn { Unknown~key~for~SubMatrix } { Unknown~key.\\ The~key~'\l_keys_key_str'~is~unknown.\\ That~key~will~be~ignored. \\ \c__nicematrix_available_keys_str } { The~available~keys~are~(in~alphabetic~order):~ 'delimiters/color',~ 'extra-height',~ 'hlines',~ 'hvlines',~ 'left-xshift',~ 'name',~ 'right-xshift',~ 'rules'~(with~the~subkeys~'color'~and~'width'),~ 'slim',~ 'vlines'~and~'xshift'~(which~sets~both~'left-xshift'~ and~'right-xshift').\\ } \__nicematrix_msg_new:nnn { Unknown~key~for~notes } { Unknown~key.\\ The~key~'\l_keys_key_str'~is~unknown.\\ That~key~will~be~ignored. \\ \c__nicematrix_available_keys_str } { The~available~keys~are~(in~alphabetic~order):~ bottomrule,~ code-after,~ code-before,~ detect-duplicates,~ enumitem-keys,~ enumitem-keys-para,~ para,~ label-in-list,~ label-in-tabular~and~ style. } \__nicematrix_msg_new:nnn { Unknown~key~for~RowStyle } { Unknown~key.\\ The~key~'\l_keys_key_str'~is~unknown~for~the~command~ \token_to_str:N \RowStyle. \\ That~key~will~be~ignored. \\ \c__nicematrix_available_keys_str } { The~available~keys~are~(in~alphabetic~order):~ 'bold',~ 'cell-space-top-limit',~ 'cell-space-bottom-limit',~ 'cell-space-limits',~ 'color',~ 'nb-rows'~and~ 'rowcolor'. } \__nicematrix_msg_new:nnn { Unknown~key~for~NiceMatrixOptions } { Unknown~key.\\ The~key~'\l_keys_key_str'~is~unknown~for~the~command~ \token_to_str:N \NiceMatrixOptions. \\ That~key~will~be~ignored. \\ \c__nicematrix_available_keys_str } { The~available~keys~are~(in~alphabetic~order):~ allow-duplicate-names,~ caption-above,~ cell-space-bottom-limit,~ cell-space-limits,~ cell-space-top-limit,~ code-for-first-col,~ code-for-first-row,~ code-for-last-col,~ code-for-last-row,~ corners,~ custom-key,~ create-extra-nodes,~ create-medium-nodes,~ create-large-nodes,~ delimiters~(several~subkeys),~ end-of-row,~ first-col,~ first-row,~ hlines,~ hvlines,~ last-col,~ last-row,~ left-margin,~ light-syntax,~ matrix/columns-type,~ notes~(several~subkeys),~ nullify-dots,~ renew-dots,~ renew-matrix,~ respect-arraystretch,~ right-margin,~ rules~(with~the~subkeys~'color'~and~'width'),~ small,~ sub-matrix~(several~subkeys), vlines,~ xdots~(several~subkeys). } \__nicematrix_msg_new:nnn { Unknown~key~for~NiceArray } { Unknown~key.\\ The~key~'\l_keys_key_str'~is~unknown~for~the~environment~ \{NiceArray\}. \\ That~key~will~be~ignored. \\ \c__nicematrix_available_keys_str } { The~available~keys~are~(in~alphabetic~order):~ b,~ baseline,~ c,~ cell-space-bottom-limit,~ cell-space-limits,~ cell-space-top-limit,~ code-after,~ code-for-first-col,~ code-for-first-row,~ code-for-last-col,~ code-for-last-row,~ colortbl-like,~ columns-width,~ corners,~ create-extra-nodes,~ create-medium-nodes,~ create-large-nodes,~ delimiters/color,~ extra-left-margin,~ extra-right-margin,~ first-col,~ first-row,~ hlines,~ hvlines,~ last-col,~ last-row,~ left-margin,~ light-syntax,~ name,~ notes/bottomrule,~ notes/para,~ nullify-dots,~ renew-dots,~ respect-arraystretch,~ right-margin,~ rules~(with~the~subkeys~'color'~and~'width'),~ small,~ t,~ tabularnote,~ vlines,~ xdots/color,~ xdots/shorten-start,~ xdots/shorten-end,~ xdots/shorten~and~ xdots/line-style. } \__nicematrix_msg_new:nnn { Unknown~key~for~NiceMatrix } { Unknown~key.\\ The~key~'\l_keys_key_str'~is~unknown~for~the~ \__nicematrix_full_name_env:. \\ That~key~will~be~ignored. \\ \c__nicematrix_available_keys_str } { The~available~keys~are~(in~alphabetic~order):~ b,~ baseline,~ c,~ cell-space-bottom-limit,~ cell-space-limits,~ cell-space-top-limit,~ code-after,~ code-for-first-col,~ code-for-first-row,~ code-for-last-col,~ code-for-last-row,~ colortbl-like,~ columns-type,~ columns-width,~ corners,~ create-extra-nodes,~ create-medium-nodes,~ create-large-nodes,~ delimiters~(several~subkeys),~ extra-left-margin,~ extra-right-margin,~ first-col,~ first-row,~ hlines,~ hvlines,~ l,~ last-col,~ last-row,~ left-margin,~ light-syntax,~ name,~ nullify-dots,~ r,~ renew-dots,~ respect-arraystretch,~ right-margin,~ rules~(with~the~subkeys~'color'~and~'width'),~ small,~ t,~ vlines,~ xdots/color,~ xdots/shorten-start,~ xdots/shorten-end,~ xdots/shorten~and~ xdots/line-style. } \__nicematrix_msg_new:nnn { Unknown~key~for~NiceTabular } { Unknown~key.\\ The~key~'\l_keys_key_str'~is~unknown~for~the~environment~ \{NiceTabular\}. \\ That~key~will~be~ignored. \\ \c__nicematrix_available_keys_str } { The~available~keys~are~(in~alphabetic~order):~ b,~ baseline,~ c,~ caption,~ cell-space-bottom-limit,~ cell-space-limits,~ cell-space-top-limit,~ code-after,~ code-for-first-col,~ code-for-first-row,~ code-for-last-col,~ code-for-last-row,~ colortbl-like,~ columns-width,~ corners,~ custom-line,~ create-extra-nodes,~ create-medium-nodes,~ create-large-nodes,~ extra-left-margin,~ extra-right-margin,~ first-col,~ first-row,~ hlines,~ hvlines,~ label,~ last-col,~ last-row,~ left-margin,~ light-syntax,~ name,~ notes/bottomrule,~ notes/para,~ nullify-dots,~ renew-dots,~ respect-arraystretch,~ right-margin,~ rules~(with~the~subkeys~'color'~and~'width'),~ short-caption,~ t,~ tabularnote,~ vlines,~ xdots/color,~ xdots/shorten-start,~ xdots/shorten-end,~ xdots/shorten~and~ xdots/line-style. } \__nicematrix_msg_new:nnn { Duplicate~name } { Duplicate~name.\\ The~name~'\l_keys_value_tl'~is~already~used~and~you~shouldn't~use~ the~same~environment~name~twice.~You~can~go~on,~but,~ maybe,~you~will~have~incorrect~results~especially~ if~you~use~'columns-width=auto'.~If~you~don't~want~to~see~this~ message~again,~use~the~key~'allow-duplicate-names'~in~ '\token_to_str:N \NiceMatrixOptions'.\\ \c__nicematrix_available_keys_str } { The~names~already~defined~in~this~document~are:~ \seq_use:Nnnn \g__nicematrix_names_seq { ~and~ } { ,~ } { ~and~ }. } \__nicematrix_msg_new:nn { Option~auto~for~columns-width } { Erroneous~use.\\ You~can't~give~the~value~'auto'~to~the~key~'columns-width'~here.~ That~key~will~be~ignored. } \endinput %% %% End of file `nicematrix.sty'.