diff options
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | 2086 |
1 files changed, 1044 insertions, 1042 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index d2940a8e405..fd41a0cf057 100644 --- a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty +++ b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty @@ -18,8 +18,8 @@ %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% -\def\myfileversion{3.7} -\def\myfiledate{2019/11/11} +\def\myfileversion{3.8} +\def\myfiledate{2020/01/02} \RequirePackage{tikz} \usetikzlibrary{fit} \RequirePackage{expl3}[2019/07/01] @@ -29,32 +29,32 @@ {\myfiledate} {\myfileversion} {Several features to improve the typesetting of mathematical matrices with TikZ} -\bool_new:N \c__nm_draft_bool -\DeclareOption { draft } { \bool_set_true:N \c__nm_draft_bool } +\bool_new:N \c__nicematrix_draft_bool +\DeclareOption { draft } { \bool_set_true:N \c__nicematrix_draft_bool } \DeclareOption* { } \ProcessOptions \relax \RequirePackage { array } \RequirePackage { amsmath } \RequirePackage { xparse } [ 2018-07-01 ] -\cs_new_protected:Npn \__nm_error:n { \msg_error:nn { nicematrix } } -\cs_new_protected:Npn \__nm_error:nn { \msg_error:nnn { nicematrix } } -\cs_new_protected:Npn \__nm_error:nnn { \msg_error:nnnn { nicematrix } } -\cs_new_protected:Npn \__nm_fatal:n { \msg_fatal:nn { nicematrix } } -\cs_new_protected:Npn \__nm_fatal:nn { \msg_fatal:nn { nicematrix } } -\cs_new_protected:Npn \__nm_msg_new:nn { \msg_new:nnn { nicematrix } } -\cs_new_protected:Npn \__nm_msg_new:nnn { \msg_new:nnnn { nicematrix } } -\cs_new_protected:Npn \__nm_msg_redirect_name:nn +\cs_new_protected:Npn \__nicematrix_error:n { \msg_error:nn { nicematrix } } +\cs_new_protected:Npn \__nicematrix_error:nn { \msg_error:nnn { nicematrix } } +\cs_new_protected:Npn \__nicematrix_error:nnn { \msg_error:nnnn { nicematrix } } +\cs_new_protected:Npn \__nicematrix_fatal:n { \msg_fatal:nn { nicematrix } } +\cs_new_protected:Npn \__nicematrix_fatal:nn { \msg_fatal:nn { nicematrix } } +\cs_new_protected:Npn \__nicematrix_msg_new:nn { \msg_new:nnn { nicematrix } } +\cs_new_protected:Npn \__nicematrix_msg_new:nnn { \msg_new:nnnn { nicematrix } } +\cs_new_protected:Npn \__nicematrix_msg_redirect_name:nn { \msg_redirect_name:nnn { nicematrix } } -\bool_new:N \c__nm_revtex_bool +\bool_new:N \c__nicematrix_revtex_bool \@ifclassloaded { revtex4-1 } - { \bool_set_true:N \c__nm_revtex_bool } + { \bool_set_true:N \c__nicematrix_revtex_bool } { } \@ifclassloaded { revtex4-2 } - { \bool_set_true:N \c__nm_revtex_bool } + { \bool_set_true:N \c__nicematrix_revtex_bool } { } -\__nm_msg_new:nn { Draft~mode } +\__nicematrix_msg_new:nn { Draft~mode } { The~compilation~is~in~draft~mode:~the~dotted~lines~won't~be~drawn. } -\bool_if:NT \c__nm_draft_bool +\bool_if:NT \c__nicematrix_draft_bool { \msg_warning:nn { nicematrix } { Draft~mode } } \ProvideDocumentCommand \iddots { } { @@ -68,58 +68,58 @@ \raise 7 \p@ \vbox { \kern 7 pt \hbox:n { . } } \mkern 1 mu } } -\int_new:N \g__nm_env_int -\int_new:N \g__nm_NiceMatrixBlock_int -\dim_new:N \l__nm_columns_width_dim -\seq_new:N \g__nm_names_seq +\int_new:N \g__nicematrix_env_int +\int_new:N \g__nicematrix_NiceMatrixBlock_int +\dim_new:N \l__nicematrix_columns_width_dim +\seq_new:N \g__nicematrix_names_seq -\bool_new:N \l__nm_in_env_bool -\bool_new:N \l__nm_NiceArray_bool -\cs_new_protected:Npn \__nm_test_if_math_mode: +\bool_new:N \l__nicematrix_in_env_bool +\bool_new:N \l__nicematrix_NiceArray_bool +\cs_new_protected:Npn \__nicematrix_test_if_math_mode: { \if_mode_math: \else: - \__nm_fatal:n { Outside~math~mode } + \__nicematrix_fatal:n { Outside~math~mode } \fi: } -\bool_new:N \l__nm_impossible_line_bool -\bool_new:N \c__nm_colortbl_loaded_bool +\bool_new:N \l__nicematrix_impossible_line_bool +\bool_new:N \c__nicematrix_colortbl_loaded_bool \AtBeginDocument { \@ifpackageloaded { colortbl } { - \bool_set_true:N \c__nm_colortbl_loaded_bool - \cs_set_protected:Npn \__nm_vline_i: { { \CT@arc@ \vline } } + \bool_set_true:N \c__nicematrix_colortbl_loaded_bool + \cs_set_protected:Npn \__nicematrix_vline_i: { { \CT@arc@ \vline } } } { } } -\dim_new:N \l__nm_inter_dots_dim -\dim_set:Nn \l__nm_inter_dots_dim { 0.45 em } -\dim_new:N \l__nm_radius_dim -\dim_set:Nn \l__nm_radius_dim { 0.53 pt } -\str_new:N \g__nm_type_env_str -\tl_new:N \g__nm_code_after_tl -\int_new:N \l__nm_save_iRow_int -\int_new:N \l__nm_save_jCol_int -\int_new:N \l__nm_first_row_int -\int_set:Nn \l__nm_first_row_int 1 -\int_new:N \l__nm_first_col_int -\int_set:Nn \l__nm_first_col_int 1 -\int_new:N \l__nm_last_row_int -\int_set:Nn \l__nm_last_row_int { -2 } -\bool_new:N \l__nm_last_row_without_value_bool -\int_new:N \l__nm_last_col_int -\int_set:Nn \l__nm_last_col_int { -1 } -\bool_new:N \g__nm_last_col_found_bool -\bool_new:N \c__nm_siunitx_loaded_bool +\dim_new:N \l__nicematrix_inter_dots_dim +\dim_set:Nn \l__nicematrix_inter_dots_dim { 0.45 em } +\dim_new:N \l__nicematrix_radius_dim +\dim_set:Nn \l__nicematrix_radius_dim { 0.53 pt } +\str_new:N \g__nicematrix_type_env_str +\tl_new:N \g__nicematrix_code_after_tl +\int_new:N \l__nicematrix_save_iRow_int +\int_new:N \l__nicematrix_save_jCol_int +\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 +\int_new:N \l__nicematrix_last_col_int +\int_set:Nn \l__nicematrix_last_col_int { -1 } +\bool_new:N \g__nicematrix_last_col_found_bool +\bool_new:N \c__nicematrix_siunitx_loaded_bool \AtBeginDocument { \@ifpackageloaded { siunitx } - { \bool_set_true:N \c__nm_siunitx_loaded_bool } + { \bool_set_true:N \c__nicematrix_siunitx_loaded_bool } { } } -\cs_set_protected:Npn \__nm_adapt_S_column: +\cs_set_protected:Npn \__nicematrix_adapt_S_column: { - \bool_if:NT \c__nm_siunitx_loaded_bool + \bool_if:NT \c__nicematrix_siunitx_loaded_bool { \group_begin: \@temptokena = { } @@ -127,70 +127,66 @@ \NC@rewrite@S { } \tl_gset:NV \g_tmpa_tl \@temptokena \group_end: - \tl_new:N \c__nm_table_collect_begin_tl + \tl_new:N \c__nicematrix_table_collect_begin_tl \tl_set:Nx \l_tmpa_tl { \tl_item:Nn \g_tmpa_tl 2 } - \tl_gset:Nx \c__nm_table_collect_begin_tl { \tl_item:Nn \l_tmpa_tl 1 } - \tl_new:N \c__nm_table_print_tl - \tl_gset:Nx \c__nm_table_print_tl { \tl_item:Nn \g_tmpa_tl { -1 } } - \cs_gset_eq:NN \__nm_adapt_S_column: \prg_do_nothing: + \tl_gset:Nx \c__nicematrix_table_collect_begin_tl { \tl_item:Nn \l_tmpa_tl 1 } + \tl_new:N \c__nicematrix_table_print_tl + \tl_gset:Nx \c__nicematrix_table_print_tl { \tl_item:Nn \g_tmpa_tl { -1 } } + \cs_gset_eq:NN \__nicematrix_adapt_S_column: \prg_do_nothing: } } -\cs_new_protected:Npn \__nm_renew_NC@rewrite@S: +\cs_new_protected:Npn \__nicematrix_renew_NC@rewrite@S: { \renewcommand*{\NC@rewrite@S}[1][] { \@temptokena \exp_after:wN { \tex_the:D \@temptokena - > { \__nm_Cell: \c__nm_table_collect_begin_tl S {##1} } + > { \__nicematrix_Cell: \c__nicematrix_table_collect_begin_tl S {##1} } c - < { \c__nm_table_print_tl \__nm_end_Cell: } + < { \c__nicematrix_table_print_tl \__nicematrix_end_Cell: } } \NC@find } } -\str_new:N \l__nm_pos_env_str -\str_set:Nn \l__nm_pos_env_str c -\bool_new:N \l__nm_exterior_arraycolsep_bool -\bool_new:N \l__nm_parallelize_diags_bool -\bool_set_true:N \l__nm_parallelize_diags_bool -\bool_new:N \l__nm_hlines_bool -\bool_new:N \l__nm_nullify_dots_bool -\bool_new:N \l__nm_auto_columns_width_bool -\str_new:N \l__nm_name_str -\bool_new:N \l__nm_extra_nodes_bool -\bool_new:N \g__nm_extra_nodes_bool -\dim_new:N \l__nm_left_margin_dim -\dim_new:N \l__nm_right_margin_dim -\dim_new:N \g__nm_width_last_col_dim -\dim_new:N \g__nm_width_first_col_dim -\dim_new:N \l__nm_extra_left_margin_dim -\dim_new:N \l__nm_extra_right_margin_dim +\str_new:N \l__nicematrix_pos_env_str +\str_set:Nn \l__nicematrix_pos_env_str 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 +\bool_new:N \l__nicematrix_hlines_bool +\bool_new:N \l__nicematrix_nullify_dots_bool +\bool_new:N \l__nicematrix_auto_columns_width_bool +\str_new:N \l__nicematrix_name_str +\bool_new:N \l__nicematrix_extra_nodes_bool +\bool_new:N \g__nicematrix_extra_nodes_bool +\dim_new:N \l__nicematrix_left_margin_dim +\dim_new:N \l__nicematrix_right_margin_dim +\dim_new:N \g__nicematrix_width_last_col_dim +\dim_new:N \g__nicematrix_width_first_col_dim +\dim_new:N \l__nicematrix_extra_left_margin_dim +\dim_new:N \l__nicematrix_extra_right_margin_dim \keys_define:nn { NiceMatrix / Global } { - code-for-first-col .tl_set:N = \l__nm_code_for_first_col_tl , - code-for-first-col .value_required:n = true , - code-for-last-col .tl_set:N = \l__nm_code_for_last_col_tl , - code-for-last-col .value_required:n = true , - code-for-first-row .tl_set:N = \l__nm_code_for_first_row_tl , - code-for-first-row .value_required:n = true , - code-for-last-row .tl_set:N = \l__nm_code_for_last_row_tl , - code-for-last-row .value_required:n = true , - small .bool_set:N = \l__nm_small_bool , - hlines .bool_set:N = \l__nm_hlines_bool , - parallelize-diags .bool_set:N = \l__nm_parallelize_diags_bool , - renew-dots .bool_set:N = \l__nm_renew_dots_bool , - renew-dots .value_forbidden:n = true , - nullify-dots .bool_set:N = \l__nm_nullify_dots_bool , - create-extra-nodes .bool_set:N = \l__nm_extra_nodes_bool , - left-margin .dim_set:N = \l__nm_left_margin_dim , + code-for-first-col .tl_set:N = \l__nicematrix_code_for_first_col_tl , + code-for-last-col .tl_set:N = \l__nicematrix_code_for_last_col_tl , + code-for-first-row .tl_set:N = \l__nicematrix_code_for_first_row_tl , + code-for-last-row .tl_set:N = \l__nicematrix_code_for_last_row_tl , + small .bool_set:N = \l__nicematrix_small_bool , + hlines .bool_set:N = \l__nicematrix_hlines_bool , + parallelize-diags .bool_set:N = \l__nicematrix_parallelize_diags_bool , + renew-dots .bool_set:N = \l__nicematrix_renew_dots_bool , + + nullify-dots .bool_set:N = \l__nicematrix_nullify_dots_bool , + create-extra-nodes .bool_set:N = \l__nicematrix_extra_nodes_bool , + left-margin .dim_set:N = \l__nicematrix_left_margin_dim , left-margin .default:n = \arraycolsep , - right-margin .dim_set:N = \l__nm_right_margin_dim , + 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__nm_extra_left_margin_dim , - extra-right-margin .dim_set:N = \l__nm_extra_right_margin_dim , + 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 } , } @@ -198,23 +194,20 @@ { columns-width .code:n = \str_if_eq:nnTF { #1 } { auto } - { \bool_set_true:N \l__nm_auto_columns_width_bool } - { \dim_set:Nn \l__nm_columns_width_dim { #1 } } , - columns-width .value_required:n = true , + { \bool_set_true:N \l__nicematrix_auto_columns_width_bool } + { \dim_set:Nn \l__nicematrix_columns_width_dim { #1 } } , name .code:n = \unless \ifmeasuring@ \str_set:Nn \l_tmpa_str { #1 } - \seq_if_in:NVTF \g__nm_names_seq \l_tmpa_str - { \__nm_error:nn { Duplicate~name } { #1 } } - { \seq_gput_left:NV \g__nm_names_seq \l_tmpa_str } - \str_set_eq:NN \l__nm_name_str \l_tmpa_str + \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 \fi , - name .value_required:n = true , - code-after .tl_gset:N = \g__nm_code_after_tl , - code-after .value_required:n = true , - first-col .code:n = \int_zero:N \l__nm_first_col_int , - first-row .code:n = \int_zero:N \l__nm_first_row_int , - last-row .int_set:N = \l__nm_last_row_int , + code-after .tl_gset:N = \g__nicematrix_code_after_tl , + 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 , } \keys_define:nn { NiceMatrix } @@ -241,117 +234,117 @@ } \keys_define:nn { NiceMatrix / NiceMatrixOptions } { - renew-matrix .code:n = \__nm_renew_matrix: , + renew-matrix .code:n = \__nicematrix_renew_matrix: , renew-matrix .value_forbidden:n = true , - RenewMatrix .code:n = \__nm_error:n { Option~RenewMatrix~suppressed } - \__nm_renew_matrix: , + RenewMatrix .code:n = \__nicematrix_error:n { Option~RenewMatrix~suppressed } + \__nicematrix_renew_matrix: , transparent .meta:n = { renew-dots , renew-matrix } , transparent .value_forbidden:n = true, - Transparent .code:n = \__nm_error:n { Option~Transparent~suppressed } - \__nm_renew_matrix: - \bool_set_true:N \l__nm_renew_dots_bool , - exterior-arraycolsep .bool_set:N = \l__nm_exterior_arraycolsep_bool , + Transparent .code:n = \__nicematrix_error:n { Option~Transparent~suppressed } + \__nicematrix_renew_matrix: + \bool_set_true:N \l__nicematrix_renew_dots_bool , + exterior-arraycolsep .bool_set:N = \l__nicematrix_exterior_arraycolsep_bool , columns-width .code:n = \str_if_eq:nnTF { #1 } { auto } - { \__nm_error:n { Option~auto~for~columns-width } } - { \dim_set:Nn \l__nm_columns_width_dim { #1 } } , + { \__nicematrix_error:n { Option~auto~for~columns-width } } + { \dim_set:Nn \l__nicematrix_columns_width_dim { #1 } } , allow-duplicate-names .code:n = - \__nm_msg_redirect_name:nn { Duplicate~name } { none } , + \__nicematrix_msg_redirect_name:nn { Duplicate~name } { none } , allow-duplicate-names .value_forbidden:n = true , letter-for-dotted-lines .code:n = { \int_compare:nTF { \tl_count:n { #1 } = \c_one_int } - { \str_set:Nx \l__nm_letter_for_dotted_lines_str { #1 } } - { \__nm_error:n { Bad~value~for~letter~for~dotted~lines } } + { \str_set:Nx \l__nicematrix_letter_for_dotted_lines_str { #1 } } + { \__nicematrix_error:n { Bad~value~for~letter~for~dotted~lines } } } , letter-for-dotted-lines .value_required:n = true , - unknown .code:n = \__nm_error:n { Unknown~key~for~NiceMatrixOptions } + unknown .code:n = \__nicematrix_error:n { Unknown~key~for~NiceMatrixOptions } } -\str_new:N \l__nm_letter_for_dotted_lines_str -\str_set_eq:NN \l__nm_letter_for_dotted_lines_str \c_colon_str +\str_new:N \l__nicematrix_letter_for_dotted_lines_str +\str_set_eq:NN \l__nicematrix_letter_for_dotted_lines_str \c_colon_str \NewDocumentCommand \NiceMatrixOptions { m } { \keys_set:nn { NiceMatrix / NiceMatrixOptions } { #1 } } \keys_define:nn { NiceMatrix / NiceMatrix } { last-col .code:n = \tl_if_empty:nTF {#1} - { \__nm_error:n { last-col~empty~for~NiceMatrix } } - { \int_set:Nn \l__nm_last_col_int { #1 } } , - unknown .code:n = \__nm_error:n { Unknown~option~for~NiceMatrix } + { \__nicematrix_error:n { last-col~empty~for~NiceMatrix } } + { \int_set:Nn \l__nicematrix_last_col_int { #1 } } , + unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceMatrix } } \keys_define:nn { NiceMatrix / NiceArray } { - c .code:n = \str_set:Nn \l__nm_pos_env_str c , - t .code:n = \str_set:Nn \l__nm_pos_env_str t , - b .code:n = \str_set:Nn \l__nm_pos_env_str b , + c .code:n = \str_set:Nn \l__nicematrix_pos_env_str c , + t .code:n = \str_set:Nn \l__nicematrix_pos_env_str t , + b .code:n = \str_set:Nn \l__nicematrix_pos_env_str b , last-col .code:n = \tl_if_empty:nF {#1} - { \__nm_error:n { last-col~non~empty~for~NiceArray } } - \int_zero:N \l__nm_last_col_int , - unknown .code:n = \__nm_error:n { Unknown~option~for~NiceArray } + { \__nicematrix_error:n { last-col~non~empty~for~NiceArray } } + \int_zero:N \l__nicematrix_last_col_int , + unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceArray } } \keys_define:nn { NiceMatrix / pNiceArray } { - first-col .code:n = \int_zero:N \l__nm_first_col_int , + first-col .code:n = \int_zero:N \l__nicematrix_first_col_int , last-col .code:n = \tl_if_empty:nF {#1} - { \__nm_error:n { last-col~non~empty~for~NiceArray } } - \int_zero:N \l__nm_last_col_int , - first-row .code:n = \int_zero:N \l__nm_first_row_int , - last-row .int_set:N = \l__nm_last_row_int , + { \__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 , + last-row .int_set:N = \l__nicematrix_last_row_int , last-row .default:n = -1 , - unknown .code:n = \__nm_error:n { Unknown~option~for~NiceMatrix } + unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceMatrix } } -\cs_new_protected:Nn \__nm_Cell: +\cs_new_protected:Nn \__nicematrix_Cell: { \int_gincr:N \c@jCol \int_compare:nNnT \c@jCol = \c_one_int { - \int_compare:nNnT \l__nm_first_col_int = \c_one_int - \__nm_begin_of_row: + \int_compare:nNnT \l__nicematrix_first_col_int = \c_one_int + \__nicematrix_begin_of_row: } - \int_gset:Nn \g__nm_col_total_int - { \int_max:nn \g__nm_col_total_int \c@jCol } + \int_gset:Nn \g__nicematrix_col_total_int + { \int_max:nn \g__nicematrix_col_total_int \c@jCol } \hbox_set:Nw \l_tmpa_box \c_math_toggle_token - \bool_if:NT \l__nm_small_bool \scriptstyle + \bool_if:NT \l__nicematrix_small_bool \scriptstyle \int_compare:nNnTF \c@iRow = \c_zero_int - { \int_compare:nNnT \c@jCol > \c_zero_int \l__nm_code_for_first_row_tl } + { \int_compare:nNnT \c@jCol > \c_zero_int \l__nicematrix_code_for_first_row_tl } { - \int_compare:nNnT \c@iRow = \l__nm_last_row_int - \l__nm_code_for_last_row_tl + \int_compare:nNnT \c@iRow = \l__nicematrix_last_row_int + \l__nicematrix_code_for_last_row_tl } } -\cs_new_protected:Nn \__nm_begin_of_row: +\cs_new_protected:Nn \__nicematrix_begin_of_row: { \int_gincr:N \c@iRow - \dim_gset_eq:NN \g__nm_dp_ante_last_row_dim \g__nm_dp_last_row_dim - \dim_gzero:N \g__nm_dp_last_row_dim - \dim_gzero:N \g__nm_ht_last_row_dim + \dim_gset_eq:NN \g__nicematrix_dp_ante_last_row_dim \g__nicematrix_dp_last_row_dim + \dim_gzero:N \g__nicematrix_dp_last_row_dim + \dim_gzero:N \g__nicematrix_ht_last_row_dim } -\cs_new_protected:Npn \__nm_actualization_for_first_and_last_row: +\cs_new_protected:Npn \__nicematrix_actualization_for_first_and_last_row: { \int_compare:nNnT \c@iRow = \c_zero_int { - \dim_gset:Nn \g__nm_dp_row_zero_dim - { \dim_max:nn \g__nm_dp_row_zero_dim { \box_dp:N \l_tmpa_box } } - \dim_gset:Nn \g__nm_ht_row_zero_dim - { \dim_max:nn \g__nm_ht_row_zero_dim { \box_ht:N \l_tmpa_box } } + \dim_gset:Nn \g__nicematrix_dp_row_zero_dim + { \dim_max:nn \g__nicematrix_dp_row_zero_dim { \box_dp:N \l_tmpa_box } } + \dim_gset:Nn \g__nicematrix_ht_row_zero_dim + { \dim_max:nn \g__nicematrix_ht_row_zero_dim { \box_ht:N \l_tmpa_box } } } \int_compare:nNnT \c@iRow = \c_one_int { - \dim_gset:Nn \g__nm_ht_row_one_dim - { \dim_max:nn \g__nm_ht_row_one_dim { \box_ht:N \l_tmpa_box } } + \dim_gset:Nn \g__nicematrix_ht_row_one_dim + { \dim_max:nn \g__nicematrix_ht_row_one_dim { \box_ht:N \l_tmpa_box } } } - \dim_gset:Nn \g__nm_ht_last_row_dim - { \dim_max:nn \g__nm_ht_last_row_dim { \box_ht:N \l_tmpa_box } } - \dim_gset:Nn \g__nm_dp_last_row_dim - { \dim_max:nn \g__nm_dp_last_row_dim { \box_dp:N \l_tmpa_box } } + \dim_gset:Nn \g__nicematrix_ht_last_row_dim + { \dim_max:nn \g__nicematrix_ht_last_row_dim { \box_ht:N \l_tmpa_box } } + \dim_gset:Nn \g__nicematrix_dp_last_row_dim + { \dim_max:nn \g__nicematrix_dp_last_row_dim { \box_dp:N \l_tmpa_box } } } -\cs_new_protected:Nn \__nm_end_Cell: +\cs_new_protected:Nn \__nicematrix_end_Cell: { \c_math_toggle_token \hbox_set_end: - \dim_gset:Nn \g__nm_max_cell_width_dim - { \dim_max:nn \g__nm_max_cell_width_dim { \box_wd:N \l_tmpa_box } } - \__nm_actualization_for_first_and_last_row: + \dim_gset:Nn \g__nicematrix_max_cell_width_dim + { \dim_max:nn \g__nicematrix_max_cell_width_dim { \box_wd:N \l_tmpa_box } } + \__nicematrix_actualization_for_first_and_last_row: \tikz [ remember~picture , @@ -362,13 +355,13 @@ \node [ anchor = base , - name = nm - \int_use:N \g__nm_env_int - + name = nm - \int_use:N \g__nicematrix_env_int - \int_use:N \c@iRow - \int_use:N \c@jCol , alias = - \str_if_empty:NF \l__nm_name_str + \str_if_empty:NF \l__nicematrix_name_str { - \l__nm_name_str - + \l__nicematrix_name_str - \int_use:N \c@iRow - \int_use:N \c@jCol } @@ -378,17 +371,17 @@ \egroup ; } \cs_generate_variant:Nn \dim_set:Nn { N x } -\cs_new_protected:Nn \__nm_renewcolumntype:nn +\cs_new_protected:Nn \__nicematrix_renewcolumntype:nn { \newcolumntype #1 [ 2 ] { > { \hbox_set:Nw \l_tmpa_box - \__nm_Cell: + \__nicematrix_Cell: } c < { - \__nm_end_Cell: + \__nicematrix_end_Cell: \hbox_set_end: #2 \hbox_set:Nn \l_tmpb_box @@ -402,12 +395,12 @@ { \hfil \tikz [ remember~picture , overlay ] - \coordinate (__nm~north~east) ; + \coordinate (__nicematrix~north~east) ; } \hbox:n { \tikz [ remember~picture , overlay ] - \coordinate (__nm~south~west) ; + \coordinate (__nicematrix~south~west) ; \box_move_up:nn \l_tmpa_dim { \box_use:N \l_tmpb_box } } } @@ -416,40 +409,40 @@ \node [ node~contents = { } , - name = nm - \int_use:N \g__nm_env_int - + name = nm - \int_use:N \g__nicematrix_env_int - \int_use:N \c@iRow - \int_use:N \c@jCol - w, alias = - \str_if_empty:NF \l__nm_name_str + \str_if_empty:NF \l__nicematrix_name_str { - \l__nm_name_str - + \l__nicematrix_name_str - \int_use:N \c@iRow - \int_use:N \c@jCol - w } , inner~sep = \c_zero_dim , - fit = (__nm~south~west) (__nm~north~east) + fit = (__nicematrix~south~west) (__nicematrix~north~east) ] ; } } } -\bool_if:NTF \c__nm_draft_bool - { \cs_set_protected:Npn \__nm_instruction_of_type:n #1 { } } +\bool_if:NTF \c__nicematrix_draft_bool + { \cs_set_protected:Npn \__nicematrix_instruction_of_type:n #1 { } } { - \cs_new_protected:Npn \__nm_instruction_of_type:n #1 + \cs_new_protected:Npn \__nicematrix_instruction_of_type:n #1 { \tl_gput_right:cx - { g__nm_ #1 _ lines _ tl } + { g__nicematrix_ #1 _ lines _ tl } { - \use:c { __nm _ draw _ #1 : nn } + \use:c { __nicematrix _ draw _ #1 : nn } { \int_use:N \c@iRow } { \int_use:N \c@jCol } } } } -\cs_new_protected:Npn \__nm_array: +\cs_new_protected:Npn \__nicematrix_array: { - \bool_if:NTF \c__nm_revtex_bool + \bool_if:NTF \c__nicematrix_revtex_bool { \cs_set_eq:NN \@acoll \@arrayacol \cs_set_eq:NN \@acolr \@arrayacol @@ -458,18 +451,18 @@ \@array@array } \array - [ \l__nm_pos_env_str ] + [ \l__nicematrix_pos_env_str ] } -\cs_new:Npn \__nm_everycr: - { \noalign { \__nm_everycr_i: } } -\cs_new_protected:Npn \__nm_everycr_i: +\cs_new:Npn \__nicematrix_everycr: + { \noalign { \__nicematrix_everycr_i: } } +\cs_new_protected:Npn \__nicematrix_everycr_i: { \int_gzero:N \c@jCol - \bool_if:NT \l__nm_hlines_bool + \bool_if:NT \l__nicematrix_hlines_bool { \int_compare:nNnT \c@iRow > { -1 } { - \int_compare:nNnF \c@iRow = \l__nm_last_row_int + \int_compare:nNnF \c@iRow = \l__nicematrix_last_row_int { \hrule \@height \arrayrulewidth \skip_vertical:n { - \arrayrulewidth } @@ -477,45 +470,45 @@ } } } -\cs_new_protected:Npn \__nm_pre_array: +\cs_new_protected:Npn \__nicematrix_pre_array: { \cs_if_exist:NT \theiRow - { \int_set_eq:NN \l__nm_save_iRow_int \c@iRow } + { \int_set_eq:NN \l__nicematrix_save_iRow_int \c@iRow } \int_gzero_new:N \c@iRow \cs_if_exist:NT \thejCol - { \int_set_eq:NN \l__nm_save_jCol_int \c@jCol } + { \int_set_eq:NN \l__nicematrix_save_jCol_int \c@jCol } \int_gzero_new:N \c@jCol \normalbaselines - \bool_if:NT \l__nm_small_bool + \bool_if:NT \l__nicematrix_small_bool { \cs_set:Npn \arraystretch { 0.47 } \dim_set:Nn \arraycolsep { 1.45 pt } } - \bool_gset_eq:NN \g__nm_extra_nodes_bool \l__nm_extra_nodes_bool + \bool_gset_eq:NN \g__nicematrix_extra_nodes_bool \l__nicematrix_extra_nodes_bool \cs_set:Npn \ialign { - \bool_if:NTF \c__nm_colortbl_loaded_bool + \bool_if:NTF \c__nicematrix_colortbl_loaded_bool { \CT@everycr { \noalign { \cs_gset_eq:NN \CT@row@color \prg_do_nothing: } - \__nm_everycr: + \__nicematrix_everycr: } } - { \everycr { \__nm_everycr: } } + { \everycr { \__nicematrix_everycr: } } \tabskip = \c_zero_skip - \dim_gzero_new:N \g__nm_dp_row_zero_dim - \dim_gset:Nn \g__nm_dp_row_zero_dim { \box_dp:N \@arstrutbox } - \dim_gzero_new:N \g__nm_ht_row_zero_dim - \dim_gset:Nn \g__nm_ht_row_zero_dim { \box_ht:N \@arstrutbox } - \dim_gzero_new:N \g__nm_ht_row_one_dim - \dim_gset:Nn \g__nm_ht_row_one_dim { \box_ht:N \@arstrutbox } - \dim_gzero_new:N \g__nm_dp_ante_last_row_dim - \dim_gset:Nn \g__nm_dp_ante_last_row_dim { \box_dp:N \@arstrutbox } - \dim_gzero_new:N \g__nm_ht_last_row_dim - \dim_gset:Nn \g__nm_ht_last_row_dim { \box_ht:N \@arstrutbox } - \dim_gzero_new:N \g__nm_dp_last_row_dim - \dim_gset:Nn \g__nm_dp_last_row_dim { \box_dp:N \@arstrutbox } + \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_gset:Nn \g__nicematrix_dp_ante_last_row_dim { \box_dp:N \@arstrutbox } + \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:Npn \ialign { \everycr { } @@ -524,122 +517,122 @@ } \halign } - \newcolumntype L { > \__nm_Cell: l < \__nm_end_Cell: } - \newcolumntype C { > \__nm_Cell: c < \__nm_end_Cell: } - \newcolumntype R { > \__nm_Cell: r < \__nm_end_Cell: } - \cs_set_eq:NN \Ldots \__nm_Ldots - \cs_set_eq:NN \Cdots \__nm_Cdots - \cs_set_eq:NN \Vdots \__nm_Vdots - \cs_set_eq:NN \Ddots \__nm_Ddots - \cs_set_eq:NN \Iddots \__nm_Iddots - \cs_set_eq:NN \hdottedline \__nm_hdottedline: - \cs_set_eq:NN \Hspace \__nm_Hspace: - \cs_set_eq:NN \Hdotsfor \__nm_Hdotsfor: - \cs_set_eq:NN \multicolumn \__nm_multicolumn:nnn - \cs_set_eq:NN \Block \__nm_Block: - \bool_if:NT \l__nm_renew_dots_bool - { - \cs_set_eq:NN \ldots \__nm_Ldots - \cs_set_eq:NN \cdots \__nm_Cdots - \cs_set_eq:NN \vdots \__nm_Vdots - \cs_set_eq:NN \ddots \__nm_Ddots - \cs_set_eq:NN \iddots \__nm_Iddots - \cs_set_eq:NN \dots \__nm_Ldots - \cs_set_eq:NN \hdotsfor \__nm_Hdotsfor: - } - \seq_gclear_new:N \g__nm_multicolumn_cells_seq - \seq_gclear_new:N \g__nm_multicolumn_sizes_seq - \int_gset:Nn \c@iRow { \l__nm_first_row_int - 1 } - \int_gzero_new:N \g__nm_row_total_int - \int_gzero_new:N \g__nm_col_total_int + \newcolumntype L { > \__nicematrix_Cell: l < \__nicematrix_end_Cell: } + \newcolumntype C { > \__nicematrix_Cell: c < \__nicematrix_end_Cell: } + \newcolumntype R { > \__nicematrix_Cell: r < \__nicematrix_end_Cell: } + \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 \hdottedline \__nicematrix_hdottedline: + \cs_set_eq:NN \Hspace \__nicematrix_Hspace: + \cs_set_eq:NN \Hdotsfor \__nicematrix_Hdotsfor: + \cs_set_eq:NN \multicolumn \__nicematrix_multicolumn:nnn + \cs_set_eq:NN \Block \__nicematrix_Block: + \bool_if:NT \l__nicematrix_renew_dots_bool + { + \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: + } + \seq_gclear_new:N \g__nicematrix_multicolumn_cells_seq + \seq_gclear_new: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 \cs_set_eq:NN \NC@find@w \relax \cs_set_eq:NN \NC@find@W \relax - \__nm_renewcolumntype:nn w { } - \__nm_renewcolumntype:nn W { \cs_set_eq:NN \hss \hfil } + \__nicematrix_renewcolumntype:nn w { } + \__nicematrix_renewcolumntype:nn W { \cs_set_eq:NN \hss \hfil } \tl_set_rescan:Nno - \l__nm_letter_for_dotted_lines_str { } \l__nm_letter_for_dotted_lines_str - \exp_args:NV \newcolumntype \l__nm_letter_for_dotted_lines_str + \l__nicematrix_letter_for_dotted_lines_str { } \l__nicematrix_letter_for_dotted_lines_str + \exp_args:NV \newcolumntype \l__nicematrix_letter_for_dotted_lines_str { ! { \skip_horizontal:n { 0.53 pt } \bool_if:nF { - \l__nm_auto_columns_width_bool - || \dim_compare_p:nNn \l__nm_columns_width_dim > \c_zero_dim + \l__nicematrix_auto_columns_width_bool + || \dim_compare_p:nNn \l__nicematrix_columns_width_dim > \c_zero_dim } - { \bool_gset_true:N \g__nm_extra_nodes_bool } - \int_compare:nNnT \c@jCol > \g__nm_last_vdotted_col_int + { \bool_gset_true:N \g__nicematrix_extra_nodes_bool } + \int_compare:nNnT \c@jCol > \g__nicematrix_last_vdotted_col_int { - \int_gset_eq:NN \g__nm_last_vdotted_col_int \c@jCol - \tl_gput_right:Nx \g__nm_code_after_tl - { \__nm_vdottedline:n { \int_use:N \c@jCol } } + \int_gset_eq:NN \g__nicematrix_last_vdotted_col_int \c@jCol + \tl_gput_right:Nx \g__nicematrix_code_after_tl + { \__nicematrix_vdottedline:n { \int_use:N \c@jCol } } } } } - \int_gzero_new:N \g__nm_last_vdotted_col_int - \bool_if:NT \c__nm_siunitx_loaded_bool \__nm_renew_NC@rewrite@S: - \int_gset:Nn \g__nm_last_vdotted_col_int { -1 } - \bool_gset_false:N \g__nm_last_col_found_bool - \tl_gclear_new:N \g__nm_Cdots_lines_tl - \tl_gclear_new:N \g__nm_Ldots_lines_tl - \tl_gclear_new:N \g__nm_Vdots_lines_tl - \tl_gclear_new:N \g__nm_Ddots_lines_tl - \tl_gclear_new:N \g__nm_Iddots_lines_tl - \tl_gclear_new:N \g__nm_Hdotsfor_lines_tl + \int_gzero_new:N \g__nicematrix_last_vdotted_col_int + \bool_if:NT \c__nicematrix_siunitx_loaded_bool \__nicematrix_renew_NC@rewrite@S: + \int_gset:Nn \g__nicematrix_last_vdotted_col_int { -1 } + \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_Hdotsfor_lines_tl } \NewDocumentEnvironment { NiceArrayWithDelims } { m m O { } m ! O { } } { - \str_if_empty:NT \g__nm_type_env_str + \str_if_empty:NT \g__nicematrix_type_env_str { - \str_gset:Nn \g__nm_type_env_str + \str_gset:Nn \g__nicematrix_type_env_str { environment ~ { NiceArrayWithDelims } } } - \__nm_adapt_S_column: - \__nm_test_if_math_mode: - \bool_if:NT \l__nm_in_env_bool { \__nm_fatal:n { Yet~in~env } } - \bool_set_true:N \l__nm_in_env_bool + \__nicematrix_adapt_S_column: + \__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_if_exist:NT \tikz@library@external@loaded { \tikzset { external / export = false } \cs_if_exist:NT \ifstandalone { \tikzset { external / optimize = false } } } - \int_gincr:N \g__nm_env_int - \bool_if:NF \l__nm_block_auto_columns_width_bool - { \dim_gzero_new:N \g__nm_max_cell_width_dim } - \cs_set_protected:Npn \@arrayrule { \@addtopreamble \__nm_vline: } - \bool_if:NTF \l__nm_NiceArray_bool + \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 } + \cs_set_protected:Npn \@arrayrule { \@addtopreamble \__nicematrix_vline: } + \bool_if:NTF \l__nicematrix_NiceArray_bool { \keys_set:nn { NiceMatrix / NiceArray } } { \keys_set:nn { NiceMatrix / pNiceArray } } { #3 , #5 } - \int_compare:nNnT \l__nm_last_row_int = { -1 } + \int_compare:nNnT \l__nicematrix_last_row_int = { -1 } { - \bool_set_true:N \l__nm_last_row_without_value_bool - \str_if_empty:NTF \l__nm_name_str + \bool_set_true:N \l__nicematrix_last_row_without_value_bool + \str_if_empty:NTF \l__nicematrix_name_str { - \cs_if_exist:cT { __nm_last_row_ \int_use:N \g__nm_env_int } + \cs_if_exist:cT { __nicematrix_last_row_ \int_use:N \g__nicematrix_env_int } { - \int_set:Nn \l__nm_last_row_int - { \use:c { __nm_last_row_ \int_use:N \g__nm_env_int } } + \int_set:Nn \l__nicematrix_last_row_int + { \use:c { __nicematrix_last_row_ \int_use:N \g__nicematrix_env_int } } } } { - \cs_if_exist:cT { __nm_last_row_ \l__nm_name_str } + \cs_if_exist:cT { __nicematrix_last_row_ \l__nicematrix_name_str } { - \int_set:Nn \l__nm_last_row_int - { \use:c { __nm_last_row_ \l__nm_name_str } } + \int_set:Nn \l__nicematrix_last_row_int + { \use:c { __nicematrix_last_row_ \l__nicematrix_name_str } } } } } - \__nm_pre_array: - \dim_gzero_new:N \g__nm_left_delim_dim - \dim_gzero_new:N \g__nm_right_delim_dim - \bool_if:NTF \l__nm_NiceArray_bool + \__nicematrix_pre_array: + \dim_gzero_new:N \g__nicematrix_left_delim_dim + \dim_gzero_new:N \g__nicematrix_right_delim_dim + \bool_if:NTF \l__nicematrix_NiceArray_bool { - \dim_gset:Nn \g__nm_left_delim_dim { 2 \arraycolsep } - \dim_gset:Nn \g__nm_right_delim_dim { 2 \arraycolsep } + \dim_gset:Nn \g__nicematrix_left_delim_dim { 2 \arraycolsep } + \dim_gset:Nn \g__nicematrix_right_delim_dim { 2 \arraycolsep } } { \group_begin: @@ -651,7 +644,7 @@ \c_math_toggle_token } - \dim_gset:Nn \g__nm_left_delim_dim { \box_wd:N \l_tmpa_box } + \dim_gset:Nn \g__nicematrix_left_delim_dim { \box_wd:N \l_tmpa_box } \hbox_set:Nn \l_tmpa_box { \dim_set_eq:NN \nulldelimiterspace \c_zero_dim @@ -659,69 +652,69 @@ \left. \vcenter to 3 cm { } \right #2 \c_math_toggle_token } - \dim_gset:Nn \g__nm_right_delim_dim { \box_wd:N \l_tmpa_box } + \dim_gset:Nn \g__nicematrix_right_delim_dim { \box_wd:N \l_tmpa_box } \group_end: } - \box_clear_new:N \l__nm_the_array_box + \box_clear_new:N \l__nicematrix_the_array_box \tl_set:Nn \l_tmpa_tl { #4 } - \int_compare:nNnTF \l__nm_first_col_int = \c_zero_int - { \tl_put_left:NV \l_tmpa_tl \c__nm_preamble_first_col_tl } + \int_compare:nNnTF \l__nicematrix_first_col_int = \c_zero_int + { \tl_put_left:NV \l_tmpa_tl \c__nicematrix_preamble_first_col_tl } { - \bool_if:NT \l__nm_NiceArray_bool + \bool_if:NT \l__nicematrix_NiceArray_bool { - \bool_if:NF \l__nm_exterior_arraycolsep_bool + \bool_if:NF \l__nicematrix_exterior_arraycolsep_bool { \tl_put_left:Nn \l_tmpa_tl { @ { } } } } } - \int_compare:nNnTF \l__nm_last_col_int > { -1 } - { \tl_put_right:NV \l_tmpa_tl \c__nm_preamble_last_col_tl } + \int_compare:nNnTF \l__nicematrix_last_col_int > { -1 } + { \tl_put_right:NV \l_tmpa_tl \c__nicematrix_preamble_last_col_tl } { - \bool_if:NT \l__nm_NiceArray_bool + \bool_if:NT \l__nicematrix_NiceArray_bool { - \bool_if:NF \l__nm_exterior_arraycolsep_bool + \bool_if:NF \l__nicematrix_exterior_arraycolsep_bool { \tl_put_right:Nn \l_tmpa_tl { @ { } } } } } - \hbox_set:Nw \l__nm_the_array_box - \skip_horizontal:n \l__nm_left_margin_dim - \skip_horizontal:n \l__nm_extra_left_margin_dim + \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 - \exp_args:NV \__nm_array: \l_tmpa_tl + \exp_args:NV \__nicematrix_array: \l_tmpa_tl } { \bool_if:nT { - \l__nm_auto_columns_width_bool - || \dim_compare_p:nNn \l__nm_columns_width_dim > \c_zero_dim + \l__nicematrix_auto_columns_width_bool + || \dim_compare_p:nNn \l__nicematrix_columns_width_dim > \c_zero_dim } { \crcr - \int_compare:nNnT \l__nm_first_col_int = 0 { \omit & } + \int_compare:nNnT \l__nicematrix_first_col_int = 0 { \omit & } \omit \skip_horizontal:N \arraycolsep \tikz [ remember~picture , overlay ] - \coordinate [ name = nm - \int_use:N \g__nm_env_int - col - 0 ] ; + \coordinate [ name = nm - \int_use:N \g__nicematrix_env_int - col - 0 ] ; \skip_horizontal:n { - \arraycolsep } \bool_if:nTF { - \l__nm_auto_columns_width_bool - && ! \l__nm_block_auto_columns_width_bool + \l__nicematrix_auto_columns_width_bool + && ! \l__nicematrix_block_auto_columns_width_bool } { \dim_gset:Nn \g_tmpa_dim - { \g__nm_max_cell_width_dim + 2 \arraycolsep } + { \g__nicematrix_max_cell_width_dim + 2 \arraycolsep } } { \dim_gset:Nn \g_tmpa_dim - { \l__nm_columns_width_dim + 2 \arraycolsep } + { \l__nicematrix_columns_width_dim + 2 \arraycolsep } } \skip_horizontal:N \g_tmpa_dim \tikz [ remember~picture , overlay ] - \coordinate [ name = nm - \int_use:N \g__nm_env_int - col - 1 ] ; + \coordinate [ name = nm - \int_use:N \g__nicematrix_env_int - col - 1 ] ; \int_gset:Nn \g_tmpa_int 1 - \bool_if:nTF \g__nm_last_col_found_bool - { \prg_replicate:nn { \g__nm_col_total_int - 3 } } - { \prg_replicate:nn { \g__nm_col_total_int - 2 } } + \bool_if:nTF \g__nicematrix_last_col_found_bool + { \prg_replicate:nn { \g__nicematrix_col_total_int - 3 } } + { \prg_replicate:nn { \g__nicematrix_col_total_int - 2 } } { & \omit @@ -730,7 +723,7 @@ \tikz [ remember~picture , overlay ] \coordinate [ - name = nm - \int_use:N \g__nm_env_int - + name = nm - \int_use:N \g__nicematrix_env_int - col - \int_use:N \g_tmpa_int ] ; } @@ -742,68 +735,68 @@ \tikz [ remember~picture , overlay ] \coordinate [ - name = nm - \int_use:N \g__nm_env_int - + name = nm - \int_use:N \g__nicematrix_env_int - col - \int_use:N \g_tmpa_int ] ; \skip_horizontal:N \arraycolsep } \endarray \c_math_toggle_token - \skip_horizontal:n \l__nm_right_margin_dim - \skip_horizontal:n \l__nm_extra_right_margin_dim + \skip_horizontal:n \l__nicematrix_right_margin_dim + \skip_horizontal:n \l__nicematrix_extra_right_margin_dim \hbox_set_end: - \int_compare:nNnT \l__nm_last_row_int > { -2 } + \int_compare:nNnT \l__nicematrix_last_row_int > { -2 } { - \bool_if:NF \l__nm_last_row_without_value_bool + \bool_if:NF \l__nicematrix_last_row_without_value_bool { - \int_compare:nNnF \l__nm_last_row_int = \c@iRow + \int_compare:nNnF \l__nicematrix_last_row_int = \c@iRow { - \__nm_error:n { Wrong~last~row } - \int_gset_eq:NN \l__nm_last_row_int \c@iRow + \__nicematrix_error:n { Wrong~last~row } + \int_gset_eq:NN \l__nicematrix_last_row_int \c@iRow } } } - \int_compare:nNnTF \l__nm_first_row_int = \c_zero_int + \int_compare:nNnTF \l__nicematrix_first_row_int = \c_zero_int { \dim_set:Nn \l_tmpa_dim - { \g__nm_dp_row_zero_dim + \lineskip + \g__nm_ht_row_zero_dim } + { \g__nicematrix_dp_row_zero_dim + \lineskip + \g__nicematrix_ht_row_zero_dim } } { \dim_zero:N \l_tmpa_dim } - \int_compare:nNnTF \l__nm_last_row_int > { -2 } + \int_compare:nNnTF \l__nicematrix_last_row_int > { -2 } { \dim_set:Nn \l_tmpb_dim - { \g__nm_ht_last_row_dim + \lineskip + \g__nm_dp_last_row_dim } + { \g__nicematrix_ht_last_row_dim + \lineskip + \g__nicematrix_dp_last_row_dim } } { \dim_zero:N \l_tmpb_dim } - \int_compare:nNnT \l__nm_first_col_int = \c_zero_int + \int_compare:nNnT \l__nicematrix_first_col_int = \c_zero_int { \skip_horizontal:n \arraycolsep - \skip_horizontal:n \g__nm_width_first_col_dim + \skip_horizontal:n \g__nicematrix_width_first_col_dim } - \bool_if:NTF \l__nm_NiceArray_bool + \bool_if:NTF \l__nicematrix_NiceArray_bool { - \int_compare:nNnT \l__nm_first_row_int = \c_zero_int + \int_compare:nNnT \l__nicematrix_first_row_int = \c_zero_int { - \str_if_eq:VnTF \l__nm_pos_env_str { t } + \str_if_eq:VnTF \l__nicematrix_pos_env_str { t } { \box_move_up:nn - { \l_tmpa_dim - \g__nm_ht_row_zero_dim + \g__nm_ht_row_one_dim } + { \l_tmpa_dim - \g__nicematrix_ht_row_zero_dim + \g__nicematrix_ht_row_one_dim } } } { - \int_compare:nNnT \l__nm_last_row_int > 0 + \int_compare:nNnT \l__nicematrix_last_row_int > 0 { - \str_if_eq:VnT \l__nm_pos_env_str { b } + \str_if_eq:VnT \l__nicematrix_pos_env_str { b } { \box_move_down:nn { \l_tmpb_dim - - \g__nm_dp_last_row_dim + \g__nm_dp_ante_last_row_dim + - \g__nicematrix_dp_last_row_dim + \g__nicematrix_dp_ante_last_row_dim } } } } - { \box_use_drop:N \l__nm_the_array_box } + { \box_use_drop:N \l__nicematrix_the_array_box } } { \hbox_set:Nn \l_tmpa_box @@ -816,7 +809,7 @@ \hbox:n { \skip_horizontal:n { - \arraycolsep } - \box_use_drop:N \l__nm_the_array_box + \box_use_drop:N \l__nicematrix_the_array_box \skip_horizontal:n { - \arraycolsep } } \skip_vertical:n { - \l_tmpb_dim } @@ -828,43 +821,43 @@ \box_set_dp:Nn \l_tmpa_box { \box_dp:N \l_tmpa_box + \l_tmpb_dim } \box_use_drop:N \l_tmpa_box } - \bool_if:NT \g__nm_last_col_found_bool + \bool_if:NT \g__nicematrix_last_col_found_bool { - \skip_horizontal:n \g__nm_width_last_col_dim + \skip_horizontal:n \g__nicematrix_width_last_col_dim \skip_horizontal:n \arraycolsep } - \__nm_after_array: + \__nicematrix_after_array: } -\tl_const:Nn \c__nm_preamble_first_col_tl +\tl_const:Nn \c__nicematrix_preamble_first_col_tl { > { - \__nm_begin_of_row: + \__nicematrix_begin_of_row: \hbox_set:Nw \l_tmpa_box \c_math_toggle_token - \bool_if:NT \l__nm_small_bool \scriptstyle + \bool_if:NT \l__nicematrix_small_bool \scriptstyle \bool_if:nT { \int_compare_p:nNn \c@iRow > \c_zero_int && ( - \int_compare_p:nNn \l__nm_last_row_int < 0 + \int_compare_p:nNn \l__nicematrix_last_row_int < 0 || - \int_compare_p:nNn \c@iRow < \l__nm_last_row_int + \int_compare_p:nNn \c@iRow < \l__nicematrix_last_row_int ) } - { \l__nm_code_for_first_col_tl } + { \l__nicematrix_code_for_first_col_tl } } l < { \c_math_toggle_token \hbox_set_end: - \__nm_actualization_for_first_and_last_row: - \dim_gset:Nn \g__nm_width_first_col_dim + \__nicematrix_actualization_for_first_and_last_row: + \dim_gset:Nn \g__nicematrix_width_first_col_dim { \dim_max:nn - \g__nm_width_first_col_dim + \g__nicematrix_width_first_col_dim { \box_wd:N \l_tmpa_box } } \hbox_overlap_left:n @@ -881,13 +874,13 @@ anchor = base , name = nm - - \int_use:N \g__nm_env_int - + \int_use:N \g__nicematrix_env_int - \int_use:N \c@iRow - 0 , alias = - \str_if_empty:NF \l__nm_name_str + \str_if_empty:NF \l__nicematrix_name_str { - \l__nm_name_str - + \l__nicematrix_name_str - \int_use:N \c@iRow - 0 } @@ -895,47 +888,47 @@ { \box_use:N \l_tmpa_box } ; \skip_horizontal:n { - \g__nm_left_delim_dim + - \l__nm_left_margin_dim + - \l__nm_extra_left_margin_dim + \g__nicematrix_left_delim_dim + + \l__nicematrix_left_margin_dim + + \l__nicematrix_extra_left_margin_dim } } \skip_horizontal:n { - 2 \arraycolsep } } } -\tl_const:Nn \c__nm_preamble_last_col_tl +\tl_const:Nn \c__nicematrix_preamble_last_col_tl { > { - \bool_gset_true:N \g__nm_last_col_found_bool + \bool_gset_true:N \g__nicematrix_last_col_found_bool \int_gincr:N \c@jCol - \int_gset:Nn \g__nm_col_total_int - { \int_max:nn \g__nm_col_total_int \c@jCol } + \int_gset:Nn \g__nicematrix_col_total_int + { \int_max:nn \g__nicematrix_col_total_int \c@jCol } \hbox_set:Nw \l_tmpa_box \c_math_toggle_token - \bool_if:NT \l__nm_small_bool \scriptstyle + \bool_if:NT \l__nicematrix_small_bool \scriptstyle \bool_if:nT { \int_compare_p:nNn \c@iRow > \c_zero_int && ( - \int_compare_p:nNn \l__nm_last_row_int < 0 + \int_compare_p:nNn \l__nicematrix_last_row_int < 0 || - \int_compare_p:nNn \c@iRow < \l__nm_last_row_int + \int_compare_p:nNn \c@iRow < \l__nicematrix_last_row_int ) } - { \l__nm_code_for_last_col_tl } + { \l__nicematrix_code_for_last_col_tl } } l < { \c_math_toggle_token \hbox_set_end: - \__nm_actualization_for_first_and_last_row: - \dim_gset:Nn \g__nm_width_last_col_dim + \__nicematrix_actualization_for_first_and_last_row: + \dim_gset:Nn \g__nicematrix_width_last_col_dim { \dim_max:nn - \g__nm_width_last_col_dim + \g__nicematrix_width_last_col_dim { \box_wd:N \l_tmpa_box } } \skip_horizontal:n { - 2 \arraycolsep } @@ -943,9 +936,9 @@ { \skip_horizontal:n { - \g__nm_right_delim_dim + - \l__nm_right_margin_dim + - \l__nm_extra_right_margin_dim + \g__nicematrix_right_delim_dim + + \l__nicematrix_right_margin_dim + + \l__nicematrix_extra_right_margin_dim } \tikz [ @@ -959,13 +952,13 @@ anchor = base , name = nm - - \int_use:N \g__nm_env_int - + \int_use:N \g__nicematrix_env_int - \int_use:N \c@iRow - \int_use:N \c@jCol , alias = - \str_if_empty:NF \l__nm_name_str + \str_if_empty:NF \l__nicematrix_name_str { - \l__nm_name_str - + \l__nicematrix_name_str - \int_use:N \c@iRow - \int_use:N \c@jCol } @@ -976,88 +969,88 @@ } \NewDocumentEnvironment { NiceArray } { } { - \bool_set_true:N \l__nm_NiceArray_bool - \str_if_empty:NT \g__nm_type_env_str - { \str_gset:Nn \g__nm_type_env_str { environment ~ { NiceArray } } } + \bool_set_true:N \l__nicematrix_NiceArray_bool + \str_if_empty:NT \g__nicematrix_type_env_str + { \str_gset:Nn \g__nicematrix_type_env_str { environment ~ { NiceArray } } } \NiceArrayWithDelims . . } { \endNiceArrayWithDelims } \NewDocumentEnvironment { pNiceArray } { } { - \str_if_empty:NT \g__nm_type_env_str - { \str_gset:Nn \g__nm_type_env_str { environment ~ { pNiceArray } } } - \__nm_test_if_math_mode: + \str_if_empty:NT \g__nicematrix_type_env_str + { \str_gset:Nn \g__nicematrix_type_env_str { environment ~ { pNiceArray } } } + \__nicematrix_test_if_math_mode: \NiceArrayWithDelims ( ) } { \endNiceArrayWithDelims } \NewDocumentEnvironment { bNiceArray } { } { - \str_if_empty:NT \g__nm_type_env_str - { \str_gset:Nn \g__nm_type_env_str { environment ~ { bNiceArray } } } - \__nm_test_if_math_mode: + \str_if_empty:NT \g__nicematrix_type_env_str + { \str_gset:Nn \g__nicematrix_type_env_str { environment ~ { bNiceArray } } } + \__nicematrix_test_if_math_mode: \NiceArrayWithDelims [ ] } { \endNiceArrayWithDelims } \NewDocumentEnvironment { BNiceArray } { } { - \str_if_empty:NT \g__nm_type_env_str - { \str_gset:Nn \g__nm_type_env_str { environment ~ { BNiceArray } } } - \__nm_test_if_math_mode: + \str_if_empty:NT \g__nicematrix_type_env_str + { \str_gset:Nn \g__nicematrix_type_env_str { environment ~ { BNiceArray } } } + \__nicematrix_test_if_math_mode: \NiceArrayWithDelims \{ \} } { \endNiceArrayWithDelims } \NewDocumentEnvironment { vNiceArray } { } { - \str_if_empty:NT \g__nm_type_env_str - { \str_gset:Nn \g__nm_type_env_str { environment ~ { vNiceArray } } } - \__nm_test_if_math_mode: + \str_if_empty:NT \g__nicematrix_type_env_str + { \str_gset:Nn \g__nicematrix_type_env_str { environment ~ { vNiceArray } } } + \__nicematrix_test_if_math_mode: \NiceArrayWithDelims | | } { \endNiceArrayWithDelims } \NewDocumentEnvironment { VNiceArray } { } { - \str_if_empty:NT \g__nm_type_env_str - { \str_gset:Nn \g__nm_type_env_str { environment ~ { VNiceArray } } } - \__nm_test_if_math_mode: + \str_if_empty:NT \g__nicematrix_type_env_str + { \str_gset:Nn \g__nicematrix_type_env_str { environment ~ { VNiceArray } } } + \__nicematrix_test_if_math_mode: \NiceArrayWithDelims \| \| } { \endNiceArrayWithDelims } -\cs_new_protected:Npn \__nm_define_env:n #1 +\cs_new_protected:Npn \__nicematrix_define_env:n #1 { \NewDocumentEnvironment { #1 NiceMatrix } { ! O { } } { - \str_gset:Nn \g__nm_type_env_str { environment ~ { #1 NiceMatrix } } + \str_gset:Nn \g__nicematrix_type_env_str { environment ~ { #1 NiceMatrix } } \keys_set:nn { NiceMatrix / NiceMatrix } { ##1 } \begin { #1 NiceArray } { * { - \int_compare:nNnTF \l__nm_last_col_int = { -1 } + \int_compare:nNnTF \l__nicematrix_last_col_int = { -1 } \c@MaxMatrixCols - { \int_eval:n { \l__nm_last_col_int - 1 } } + { \int_eval:n { \l__nicematrix_last_col_int - 1 } } } C } } { \end { #1 NiceArray } } } -\__nm_define_env:n { } -\__nm_define_env:n p -\__nm_define_env:n b -\__nm_define_env:n B -\__nm_define_env:n v -\__nm_define_env:n V -\prg_set_conditional:Npnn \__nm_if_not_empty_cell:nn #1 #2 { T , TF } +\__nicematrix_define_env:n { } +\__nicematrix_define_env:n p +\__nicematrix_define_env:n b +\__nicematrix_define_env:n B +\__nicematrix_define_env:n v +\__nicematrix_define_env:n V +\prg_set_conditional:Npnn \__nicematrix_if_not_empty_cell:nn #1 #2 { T , TF } { \bool_set_false:N \l_tmpa_bool \cs_if_exist:cTF - { __nm _ dotted _ \int_use:N #1 - \int_use:N #2 } + { __nicematrix _ dotted _ \int_use:N #1 - \int_use:N #2 } \prg_return_true: { \cs_if_free:cTF { pgf@sh@ns@nm - - \int_use:N \g__nm_env_int - + \int_use:N \g__nicematrix_env_int - \int_use:N #1 - \int_use:N #2 } @@ -1065,12 +1058,12 @@ { \bool_set_false:N \l_tmpa_bool \cs_if_exist:cT - { __nm _ empty _ \int_use:N #1 - \int_use:N #2 } + { __nicematrix _ empty _ \int_use:N #1 - \int_use:N #2 } { \int_compare:nNnT - { \use:c { __nm _ empty _ \int_use:N #1 - \int_use:N #2 } } + { \use:c { __nicematrix _ empty _ \int_use:N #1 - \int_use:N #2 } } = - \g__nm_env_int + \g__nicematrix_env_int { \bool_set_true:N \l_tmpa_bool } } \bool_if:NTF \l_tmpa_bool @@ -1080,7 +1073,7 @@ \tl_set:Nx \l_tmpa_tl { nm - - \int_use:N \g__nm_env_int - + \int_use:N \g__nicematrix_env_int - \int_use:N #1 - \int_use:N #2 } @@ -1097,138 +1090,138 @@ } } } -\cs_new_protected:Nn \__nm_after_array: +\cs_new_protected:Nn \__nicematrix_after_array: { \int_compare:nNnTF \c@iRow > \c_zero_int - \__nm_after_array_i: + \__nicematrix_after_array_i: { - \__nm_error:n { Zero~row } - \__nm_restore_iRow_jCol: + \__nicematrix_error:n { Zero~row } + \__nicematrix_restore_iRow_jCol: } } -\cs_new_protected:Nn \__nm_after_array_i: +\cs_new_protected:Nn \__nicematrix_after_array_i: { \group_begin: \cs_if_exist:NT \tikz@library@external@loaded { \tikzset { external / export = false } } - \int_gset_eq:NN \c@jCol \g__nm_col_total_int - \bool_if:nT \g__nm_last_col_found_bool { \int_gdecr:N \c@jCol } - \int_gset_eq:NN \g__nm_row_total_int \c@iRow - \int_compare:nNnT \l__nm_last_row_int > { -1 } + \int_gset_eq:NN \c@jCol \g__nicematrix_col_total_int + \bool_if:nT \g__nicematrix_last_col_found_bool { \int_gdecr:N \c@jCol } + \int_gset_eq:NN \g__nicematrix_row_total_int \c@iRow + \int_compare:nNnT \l__nicematrix_last_row_int > { -1 } { \int_gsub:Nn \c@iRow \c_one_int } - \bool_if:NT \l__nm_last_row_without_value_bool + \bool_if:NT \l__nicematrix_last_row_without_value_bool { \iow_now:Nn \@mainaux \ExplSyntaxOn \iow_now:Nx \@mainaux { - \cs_gset:cpn { __nm_last_row_ \int_use:N \g__nm_env_int } - { \int_use:N \g__nm_row_total_int } + \cs_gset:cpn { __nicematrix_last_row_ \int_use:N \g__nicematrix_env_int } + { \int_use:N \g__nicematrix_row_total_int } } - \str_if_empty:NF \l__nm_name_str + \str_if_empty:NF \l__nicematrix_name_str { \iow_now:Nx \@mainaux { - \cs_gset:cpn { __nm_last_row_ \l__nm_name_str } - { \int_use:N \g__nm_row_total_int } + \cs_gset:cpn { __nicematrix_last_row_ \l__nicematrix_name_str } + { \int_use:N \g__nicematrix_row_total_int } } } \iow_now:Nn \@mainaux \ExplSyntaxOff } - \bool_if:NT \l__nm_parallelize_diags_bool - { - \int_zero_new:N \l__nm_ddots_int - \int_zero_new:N \l__nm_iddots_int - \dim_zero_new:N \l__nm_delta_x_one_dim - \dim_zero_new:N \l__nm_delta_y_one_dim - \dim_zero_new:N \l__nm_delta_x_two_dim - \dim_zero_new:N \l__nm_delta_y_two_dim - } - \bool_if:NT \g__nm_extra_nodes_bool \__nm_create_extra_nodes: - \int_zero_new:N \l__nm_initial_i_int - \int_zero_new:N \l__nm_initial_j_int - \int_zero_new:N \l__nm_final_i_int - \int_zero_new:N \l__nm_final_j_int - \bool_set_false:N \l__nm_initial_open_bool - \bool_set_false:N \l__nm_final_open_bool - \bool_if:NT \l__nm_small_bool - { - \dim_set:Nn \l__nm_radius_dim { 0.37 pt } - \dim_set:Nn \l__nm_inter_dots_dim { 0.25 em } - } - \g__nm_Hdotsfor_lines_tl - \g__nm_Vdots_lines_tl - \g__nm_Ddots_lines_tl - \g__nm_Iddots_lines_tl - \g__nm_Cdots_lines_tl - \g__nm_Ldots_lines_tl + \bool_if:NT \l__nicematrix_parallelize_diags_bool + { + \int_zero_new:N \l__nicematrix_ddots_int + \int_zero_new:N \l__nicematrix_iddots_int + \dim_zero_new:N \l__nicematrix_delta_x_one_dim + \dim_zero_new:N \l__nicematrix_delta_y_one_dim + \dim_zero_new:N \l__nicematrix_delta_x_two_dim + \dim_zero_new:N \l__nicematrix_delta_y_two_dim + } + \bool_if:NT \g__nicematrix_extra_nodes_bool \__nicematrix_create_extra_nodes: + \int_zero_new:N \l__nicematrix_initial_i_int + \int_zero_new:N \l__nicematrix_initial_j_int + \int_zero_new:N \l__nicematrix_final_i_int + \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_radius_dim { 0.37 pt } + \dim_set:Nn \l__nicematrix_inter_dots_dim { 0.25 em } + } + \g__nicematrix_Hdotsfor_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 \tikzset { every~picture / .style = { overlay , remember~picture , - name~prefix = nm - \int_use:N \g__nm_env_int - + name~prefix = nm - \int_use:N \g__nicematrix_env_int - } } - \cs_set_eq:NN \line \__nm_line:nn - \g__nm_code_after_tl - \tl_gclear:N \g__nm_code_after_tl + \cs_set_eq:NN \line \__nicematrix_line:nn + \g__nicematrix_code_after_tl + \tl_gclear:N \g__nicematrix_code_after_tl \group_end: - \str_gclear:N \g__nm_type_env_str - \__nm_restore_iRow_jCol: + \str_gclear:N \g__nicematrix_type_env_str + \__nicematrix_restore_iRow_jCol: } -\cs_new_protected:Nn \__nm_restore_iRow_jCol: +\cs_new_protected:Nn \__nicematrix_restore_iRow_jCol: { - \cs_if_exist:NT \theiRow { \int_gset_eq:NN \c@iRow \l__nm_save_iRow_int } - \cs_if_exist:NT \thejCol { \int_gset_eq:NN \c@jCol \l__nm_save_jCol_int } + \cs_if_exist:NT \theiRow { \int_gset_eq:NN \c@iRow \l__nicematrix_save_iRow_int } + \cs_if_exist:NT \thejCol { \int_gset_eq:NN \c@jCol \l__nicematrix_save_jCol_int } } -\cs_new_protected:Nn \__nm_find_extremities_of_line:nnnn +\cs_new_protected:Nn \__nicematrix_find_extremities_of_line:nnnn { - \cs_set:cpn { __nm _ dotted _ #1 - #2 } { } - \int_set:Nn \l__nm_initial_i_int { #1 } - \int_set:Nn \l__nm_initial_j_int { #2 } - \int_set:Nn \l__nm_final_i_int { #1 } - \int_set:Nn \l__nm_final_j_int { #2 } - \bool_set_false:N \l__nm_stop_loop_bool - \bool_do_until:Nn \l__nm_stop_loop_bool + \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__nm_final_i_int { #3 } - \int_add:Nn \l__nm_final_j_int { #4 } - \bool_set_false:N \l__nm_final_open_bool - \int_compare:nNnTF \l__nm_final_i_int > \c@iRow + \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 > \c@iRow { \int_compare:nNnT { #3 } = 1 - { \bool_set_true:N \l__nm_final_open_bool } + { \bool_set_true:N \l__nicematrix_final_open_bool } } { - \int_compare:nNnTF \l__nm_final_j_int < 1 + \int_compare:nNnTF \l__nicematrix_final_j_int < 1 { \int_compare:nNnT { #4 } = { -1 } - { \bool_set_true:N \l__nm_final_open_bool } + { \bool_set_true:N \l__nicematrix_final_open_bool } } { - \int_compare:nNnT \l__nm_final_j_int > \c@jCol + \int_compare:nNnT \l__nicematrix_final_j_int > \c@jCol { \int_compare:nNnT { #4 } = 1 - { \bool_set_true:N \l__nm_final_open_bool } + { \bool_set_true:N \l__nicematrix_final_open_bool } } } } - \bool_if:NTF \l__nm_final_open_bool + \bool_if:NTF \l__nicematrix_final_open_bool { - \int_sub:Nn \l__nm_final_i_int { #3 } - \int_sub:Nn \l__nm_final_j_int { #4 } - \bool_set_true:N \l__nm_stop_loop_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 } { - \__nm_if_not_empty_cell:nnTF \l__nm_final_i_int \l__nm_final_j_int - { \bool_set_true:N \l__nm_stop_loop_bool } + \__nicematrix_if_not_empty_cell:nnTF \l__nicematrix_final_i_int \l__nicematrix_final_j_int + { \bool_set_true:N \l__nicematrix_stop_loop_bool } { \cs_set:cpn { - __nm _ dotted _ - \int_use:N \l__nm_final_i_int - - \int_use:N \l__nm_final_j_int + __nicematrix _ dotted _ + \int_use:N \l__nicematrix_final_i_int - + \int_use:N \l__nicematrix_final_j_int } { } } @@ -1237,59 +1230,59 @@ \cs_if_free:cT { pgf@sh@ns@nm - - \int_use:N \g__nm_env_int - - \int_use:N \l__nm_final_i_int - - \int_use:N \l__nm_final_j_int + \int_use:N \g__nicematrix_env_int - + \int_use:N \l__nicematrix_final_i_int - + \int_use:N \l__nicematrix_final_j_int } { - \bool_if:NF \l__nm_final_open_bool + \bool_if:NF \l__nicematrix_final_open_bool { \msg_error:nnx { nicematrix } { Impossible~line } - { \int_use:N \l__nm_final_i_int } - \bool_set_true:N \l__nm_impossible_line_bool + { \int_use:N \l__nicematrix_final_i_int } + \bool_set_true:N \l__nicematrix_impossible_line_bool } } - \bool_set_false:N \l__nm_stop_loop_bool - \bool_do_until:Nn \l__nm_stop_loop_bool + \bool_set_false:N \l__nicematrix_stop_loop_bool + \bool_do_until:Nn \l__nicematrix_stop_loop_bool { - \int_sub:Nn \l__nm_initial_i_int { #3 } - \int_sub:Nn \l__nm_initial_j_int { #4 } - \bool_set_false:N \l__nm_initial_open_bool - \int_compare:nNnTF \l__nm_initial_i_int < 1 + \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 < 1 { \int_compare:nNnT { #3 } = 1 - { \bool_set_true:N \l__nm_initial_open_bool } + { \bool_set_true:N \l__nicematrix_initial_open_bool } } { - \int_compare:nNnTF \l__nm_initial_j_int < 1 + \int_compare:nNnTF \l__nicematrix_initial_j_int < 1 { \int_compare:nNnT { #4 } = 1 - { \bool_set_true:N \l__nm_initial_open_bool } + { \bool_set_true:N \l__nicematrix_initial_open_bool } } { - \int_compare:nNnT \l__nm_initial_j_int > \c@jCol + \int_compare:nNnT \l__nicematrix_initial_j_int > \c@jCol { \int_compare:nNnT { #4 } = { -1 } - { \bool_set_true:N \l__nm_initial_open_bool } + { \bool_set_true:N \l__nicematrix_initial_open_bool } } } } - \bool_if:NTF \l__nm_initial_open_bool + \bool_if:NTF \l__nicematrix_initial_open_bool { - \int_add:Nn \l__nm_initial_i_int { #3 } - \int_add:Nn \l__nm_initial_j_int { #4 } - \bool_set_true:N \l__nm_stop_loop_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 } { - \__nm_if_not_empty_cell:nnTF - \l__nm_initial_i_int \l__nm_initial_j_int - { \bool_set_true:N \l__nm_stop_loop_bool } + \__nicematrix_if_not_empty_cell:nnTF + \l__nicematrix_initial_i_int \l__nicematrix_initial_j_int + { \bool_set_true:N \l__nicematrix_stop_loop_bool } { \cs_set:cpn { - __nm _ dotted _ - \int_use:N \l__nm_initial_i_int - - \int_use:N \l__nm_initial_j_int + __nicematrix _ dotted _ + \int_use:N \l__nicematrix_initial_i_int - + \int_use:N \l__nicematrix_initial_j_int } { } } @@ -1298,97 +1291,94 @@ \cs_if_free:cT { pgf@sh@ns@nm - - \int_use:N \g__nm_env_int - - \int_use:N \l__nm_initial_i_int - - \int_use:N \l__nm_initial_j_int + \int_use:N \g__nicematrix_env_int - + \int_use:N \l__nicematrix_initial_i_int - + \int_use:N \l__nicematrix_initial_j_int } { - \bool_if:NF \l__nm_initial_open_bool + \bool_if:NF \l__nicematrix_initial_open_bool { \msg_error:nnx { nicematrix } { Impossible~line } - { \int_use:N \l__nm_initial_i_int } - \bool_set_true:N \l__nm_impossible_line_bool + { \int_use:N \l__nicematrix_initial_i_int } + \bool_set_true:N \l__nicematrix_impossible_line_bool } } - \bool_if:nT \l__nm_initial_open_bool \__nm_create_extra_nodes: - \bool_if:NT \l__nm_final_open_bool \__nm_create_extra_nodes: + \bool_if:nT \l__nicematrix_initial_open_bool \__nicematrix_create_extra_nodes: + \bool_if:NT \l__nicematrix_final_open_bool \__nicematrix_create_extra_nodes: } -\cs_new_protected:Nn \__nm_retrieve_coords:nn +\cs_new_protected:Nn \__nicematrix_retrieve_coords:nn { - \dim_gzero_new:N \g__nm_x_initial_dim - \dim_gzero_new:N \g__nm_y_initial_dim - \dim_gzero_new:N \g__nm_x_final_dim - \dim_gzero_new:N \g__nm_y_final_dim + \dim_gzero_new:N \g__nicematrix_x_initial_dim + \dim_gzero_new:N \g__nicematrix_y_initial_dim + \dim_gzero_new:N \g__nicematrix_x_final_dim + \dim_gzero_new:N \g__nicematrix_y_final_dim \begin { tikzpicture } [ remember~picture ] \tikz@parse@node \pgfutil@firstofone - ( nm - \int_use:N \g__nm_env_int - - \int_use:N \l__nm_initial_i_int - - \int_use:N \l__nm_initial_j_int #1 ) - \dim_gset:Nn \g__nm_x_initial_dim \pgf@x - \dim_gset:Nn \g__nm_y_initial_dim \pgf@y + ( nm - \int_use:N \g__nicematrix_env_int - + \int_use:N \l__nicematrix_initial_i_int - + \int_use:N \l__nicematrix_initial_j_int #1 ) + \dim_gset:Nn \g__nicematrix_x_initial_dim \pgf@x + \dim_gset:Nn \g__nicematrix_y_initial_dim \pgf@y \tikz@parse@node \pgfutil@firstofone - ( nm - \int_use:N \g__nm_env_int - - \int_use:N \l__nm_final_i_int - - \int_use:N \l__nm_final_j_int #2 ) - \dim_gset:Nn \g__nm_x_final_dim \pgf@x - \dim_gset:Nn \g__nm_y_final_dim \pgf@y + ( nm - \int_use:N \g__nicematrix_env_int - + \int_use:N \l__nicematrix_final_i_int - + \int_use:N \l__nicematrix_final_j_int #2 ) + \dim_gset:Nn \g__nicematrix_x_final_dim \pgf@x + \dim_gset:Nn \g__nicematrix_y_final_dim \pgf@y \end { tikzpicture } } -\cs_generate_variant:Nn \__nm_retrieve_coords:nn { x x } -\cs_new_protected:Nn \__nm_adjust_with_col_nodes: +\cs_generate_variant:Nn \__nicematrix_retrieve_coords:nn { x x } +\cs_new_protected:Nn \__nicematrix_adjust_with_col_nodes: { - \bool_if:NT \l__nm_initial_open_bool + \bool_if:NT \l__nicematrix_initial_open_bool { \cs_if_exist:cT - { pgf@sh@ns@nm - \int_use:N \g__nm_env_int - col - 0 } + { pgf@sh@ns@nm - \int_use:N \g__nicematrix_env_int - col - 0 } { \begin { tikzpicture } [ remember~picture ] \tikz@parse@node \pgfutil@firstofone - ( nm - \int_use:N \g__nm_env_int - col - 0 ) - \dim_gset:Nn \g__nm_x_initial_dim \pgf@x + ( nm - \int_use:N \g__nicematrix_env_int - col - 0 ) + \dim_gset:Nn \g__nicematrix_x_initial_dim \pgf@x \end { tikzpicture } } } - \bool_if:NT \l__nm_final_open_bool + \bool_if:NT \l__nicematrix_final_open_bool { \cs_if_exist:cT { - pgf@sh@ns@nm - \int_use:N \g__nm_env_int - col - + pgf@sh@ns@nm - \int_use:N \g__nicematrix_env_int - col - \int_use:N \c@jCol } { \begin { tikzpicture } [ remember~picture ] \tikz@parse@node \pgfutil@firstofone - ( - nm - \int_use:N \g__nm_env_int - col - - \int_use:N \c@jCol - ) - \dim_gset:Nn \g__nm_x_final_dim \pgf@x + ( nm - \int_use:N \g__nicematrix_env_int - col - \int_use:N \c@jCol ) + \dim_gset:Nn \g__nicematrix_x_final_dim \pgf@x \end { tikzpicture } } } } -\cs_new_protected:Nn \__nm_draw_Ldots:nn +\cs_new_protected:Nn \__nicematrix_draw_Ldots:nn { - \cs_if_free:cT { __nm _ dotted _ #1 - #2 } + \cs_if_free:cT { __nicematrix _ dotted _ #1 - #2 } { - \bool_set_false:N \l__nm_impossible_line_bool - \__nm_find_extremities_of_line:nnnn { #1 } { #2 } \c_zero_int \c_one_int - \bool_if:NF \l__nm_impossible_line_bool \__nm_actually_draw_Ldots: + \bool_set_false:N \l__nicematrix_impossible_line_bool + \__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } \c_zero_int \c_one_int + \bool_if:NF \l__nicematrix_impossible_line_bool \__nicematrix_actually_draw_Ldots: } } -\cs_new_protected:Nn \__nm_actually_draw_Ldots: +\cs_new_protected:Nn \__nicematrix_actually_draw_Ldots: { - \__nm_retrieve_coords:xx + \__nicematrix_retrieve_coords:xx { - \bool_if:NTF \l__nm_initial_open_bool + \bool_if:NTF \l__nicematrix_initial_open_bool { \cs_if_exist:cTF { pgf@sh@ns@nm - - \int_use:N \g__nm_env_int - - \int_use:N \l__nm_initial_i_int - - \int_use:N \l__nm_initial_j_int - w + - \int_use:N \g__nicematrix_env_int + - \int_use:N \l__nicematrix_initial_i_int + - \int_use:N \l__nicematrix_initial_j_int - w } { - w.base~west } { - medium.base~west } @@ -1396,47 +1386,47 @@ { .base~east } } { - \bool_if:NTF \l__nm_final_open_bool + \bool_if:NTF \l__nicematrix_final_open_bool { \cs_if_exist:cTF { pgf@sh@ns@nm - - \int_use:N \g__nm_env_int - - \int_use:N \l__nm_final_i_int - - \int_use:N \l__nm_final_j_int - w + - \int_use:N \g__nicematrix_env_int + - \int_use:N \l__nicematrix_final_i_int + - \int_use:N \l__nicematrix_final_j_int - w } { - w.base~east } { - medium.base~east } } { .base~west } } - \__nm_adjust_with_col_nodes: - \bool_if:NT \l__nm_initial_open_bool - { \dim_gset_eq:NN \g__nm_y_initial_dim \g__nm_y_final_dim } - \bool_if:NT \l__nm_final_open_bool - { \dim_gset_eq:NN \g__nm_y_final_dim \g__nm_y_initial_dim } - \dim_gadd:Nn \g__nm_y_initial_dim { 0.53 pt } - \dim_gadd:Nn \g__nm_y_final_dim { 0.53 pt } - \__nm_draw_tikz_line: + \__nicematrix_adjust_with_col_nodes: + \bool_if:NT \l__nicematrix_initial_open_bool + { \dim_gset_eq:NN \g__nicematrix_y_initial_dim \g__nicematrix_y_final_dim } + \bool_if:NT \l__nicematrix_final_open_bool + { \dim_gset_eq:NN \g__nicematrix_y_final_dim \g__nicematrix_y_initial_dim } + \dim_gadd:Nn \g__nicematrix_y_initial_dim { 0.53 pt } + \dim_gadd:Nn \g__nicematrix_y_final_dim { 0.53 pt } + \__nicematrix_draw_tikz_line: } -\cs_new_protected:Nn \__nm_draw_Cdots:nn +\cs_new_protected:Nn \__nicematrix_draw_Cdots:nn { - \cs_if_free:cT { __nm _ dotted _ #1 - #2 } + \cs_if_free:cT { __nicematrix _ dotted _ #1 - #2 } { - \bool_set_false:N \l__nm_impossible_line_bool - \__nm_find_extremities_of_line:nnnn { #1 } { #2 } \c_zero_int \c_one_int - \bool_if:NF \l__nm_impossible_line_bool + \bool_set_false:N \l__nicematrix_impossible_line_bool + \__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } \c_zero_int \c_one_int + \bool_if:NF \l__nicematrix_impossible_line_bool { - \__nm_retrieve_coords:xx + \__nicematrix_retrieve_coords:xx { - \bool_if:NTF \l__nm_initial_open_bool + \bool_if:NTF \l__nicematrix_initial_open_bool { \cs_if_exist:cTF { pgf@sh@ns@nm - - \int_use:N \g__nm_env_int - - \int_use:N \l__nm_initial_i_int - - \int_use:N \l__nm_initial_j_int - w + - \int_use:N \g__nicematrix_env_int + - \int_use:N \l__nicematrix_initial_i_int + - \int_use:N \l__nicematrix_initial_j_int - w } { - w.mid~west } { - medium.mid~west } @@ -1444,323 +1434,323 @@ { .mid~east } } { - \bool_if:NTF \l__nm_final_open_bool + \bool_if:NTF \l__nicematrix_final_open_bool { \cs_if_exist:cTF { pgf@sh@ns@nm - - \int_use:N \g__nm_env_int - - \int_use:N \l__nm_final_i_int - - \int_use:N \l__nm_final_j_int - w + - \int_use:N \g__nicematrix_env_int + - \int_use:N \l__nicematrix_final_i_int + - \int_use:N \l__nicematrix_final_j_int - w } { - w.mid~east } { - medium.mid~east } } { .mid~west } } - \__nm_adjust_with_col_nodes: - \bool_if:NT \l__nm_initial_open_bool - { \dim_gset_eq:NN \g__nm_y_initial_dim \g__nm_y_final_dim } - \bool_if:NT \l__nm_final_open_bool - { \dim_gset_eq:NN \g__nm_y_final_dim \g__nm_y_initial_dim } - \__nm_draw_tikz_line: + \__nicematrix_adjust_with_col_nodes: + \bool_if:NT \l__nicematrix_initial_open_bool + { \dim_gset_eq:NN \g__nicematrix_y_initial_dim \g__nicematrix_y_final_dim } + \bool_if:NT \l__nicematrix_final_open_bool + { \dim_gset_eq:NN \g__nicematrix_y_final_dim \g__nicematrix_y_initial_dim } + \__nicematrix_draw_tikz_line: } } } -\cs_new_protected:Nn \__nm_draw_Vdots:nn +\cs_new_protected:Nn \__nicematrix_draw_Vdots:nn { - \cs_if_free:cT { __nm _ dotted _ #1 - #2 } + \cs_if_free:cT { __nicematrix _ dotted _ #1 - #2 } { - \bool_set_false:N \l__nm_impossible_line_bool - \__nm_find_extremities_of_line:nnnn { #1 } { #2 } \c_one_int \c_zero_int - \bool_if:NF \l__nm_impossible_line_bool + \bool_set_false:N \l__nicematrix_impossible_line_bool + \__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } \c_one_int \c_zero_int + \bool_if:NF \l__nicematrix_impossible_line_bool { - \__nm_retrieve_coords:xx + \__nicematrix_retrieve_coords:xx { - \bool_if:NTF \l__nm_initial_open_bool + \bool_if:NTF \l__nicematrix_initial_open_bool { - medium.north~west } { .south~west } } { - \bool_if:NTF \l__nm_final_open_bool + \bool_if:NTF \l__nicematrix_final_open_bool { - medium.south~west } { .north~west } } \bool_set:Nn \l_tmpa_bool - { \dim_compare_p:nNn \g__nm_x_initial_dim = \g__nm_x_final_dim } - \__nm_retrieve_coords:xx + { \dim_compare_p:nNn \g__nicematrix_x_initial_dim = \g__nicematrix_x_final_dim } + \__nicematrix_retrieve_coords:xx { - \bool_if:NTF \l__nm_initial_open_bool + \bool_if:NTF \l__nicematrix_initial_open_bool { - medium.north } { .south } } { - \bool_if:NTF \l__nm_final_open_bool + \bool_if:NTF \l__nicematrix_final_open_bool { - medium.south } { .north } } \bool_set:Nn \l_tmpb_bool - { \dim_compare_p:nNn \g__nm_x_initial_dim = \g__nm_x_final_dim } + { \dim_compare_p:nNn \g__nicematrix_x_initial_dim = \g__nicematrix_x_final_dim } \bool_if:NF \l_tmpb_bool { - \dim_gset:Nn \g__nm_x_initial_dim + \dim_gset:Nn \g__nicematrix_x_initial_dim { \bool_if:NTF \l_tmpa_bool \dim_min:nn \dim_max:nn - \g__nm_x_initial_dim \g__nm_x_final_dim + \g__nicematrix_x_initial_dim \g__nicematrix_x_final_dim } - \dim_gset_eq:NN \g__nm_x_final_dim \g__nm_x_initial_dim + \dim_gset_eq:NN \g__nicematrix_x_final_dim \g__nicematrix_x_initial_dim } - \__nm_draw_tikz_line: + \__nicematrix_draw_tikz_line: } } } -\cs_new_protected:Nn \__nm_draw_Ddots:nn +\cs_new_protected:Nn \__nicematrix_draw_Ddots:nn { - \cs_if_free:cT { __nm _ dotted _ #1 - #2 } + \cs_if_free:cT { __nicematrix _ dotted _ #1 - #2 } { - \bool_set_false:N \l__nm_impossible_line_bool - \__nm_find_extremities_of_line:nnnn { #1 } { #2 } \c_one_int \c_one_int - \bool_if:NF \l__nm_impossible_line_bool + \bool_set_false:N \l__nicematrix_impossible_line_bool + \__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } \c_one_int \c_one_int + \bool_if:NF \l__nicematrix_impossible_line_bool { - \__nm_retrieve_coords:xx + \__nicematrix_retrieve_coords:xx { - \bool_if:NTF \l__nm_initial_open_bool + \bool_if:NTF \l__nicematrix_initial_open_bool { - medium.north~west } { .south~east } } { - \bool_if:NTF \l__nm_final_open_bool + \bool_if:NTF \l__nicematrix_final_open_bool { - medium.south~east } { .north~west } } - \bool_if:NT \l__nm_parallelize_diags_bool + \bool_if:NT \l__nicematrix_parallelize_diags_bool { - \int_incr:N \l__nm_ddots_int - \int_compare:nNnTF \l__nm_ddots_int = \c_one_int + \int_incr:N \l__nicematrix_ddots_int + \int_compare:nNnTF \l__nicematrix_ddots_int = \c_one_int { - \dim_set:Nn \l__nm_delta_x_one_dim - { \g__nm_x_final_dim - \g__nm_x_initial_dim } - \dim_set:Nn \l__nm_delta_y_one_dim - { \g__nm_y_final_dim - \g__nm_y_initial_dim } + \dim_set:Nn \l__nicematrix_delta_x_one_dim + { \g__nicematrix_x_final_dim - \g__nicematrix_x_initial_dim } + \dim_set:Nn \l__nicematrix_delta_y_one_dim + { \g__nicematrix_y_final_dim - \g__nicematrix_y_initial_dim } } { - \dim_gset:Nn \g__nm_y_final_dim + \dim_gset:Nn \g__nicematrix_y_final_dim { - \g__nm_y_initial_dim + - ( \g__nm_x_final_dim - \g__nm_x_initial_dim ) * - \dim_ratio:nn \l__nm_delta_y_one_dim \l__nm_delta_x_one_dim + \g__nicematrix_y_initial_dim + + ( \g__nicematrix_x_final_dim - \g__nicematrix_x_initial_dim ) * + \dim_ratio:nn \l__nicematrix_delta_y_one_dim \l__nicematrix_delta_x_one_dim } } } - \__nm_draw_tikz_line: + \__nicematrix_draw_tikz_line: } } } -\cs_new_protected:Nn \__nm_draw_Iddots:nn +\cs_new_protected:Nn \__nicematrix_draw_Iddots:nn { - \cs_if_free:cT { __nm _ dotted _ #1 - #2 } + \cs_if_free:cT { __nicematrix _ dotted _ #1 - #2 } { - \bool_set_false:N \l__nm_impossible_line_bool - \__nm_find_extremities_of_line:nnnn { #1 } { #2 } 1 { -1 } - \bool_if:NF \l__nm_impossible_line_bool + \bool_set_false:N \l__nicematrix_impossible_line_bool + \__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } 1 { -1 } + \bool_if:NF \l__nicematrix_impossible_line_bool { - \__nm_retrieve_coords:xx + \__nicematrix_retrieve_coords:xx { - \bool_if:NTF \l__nm_initial_open_bool + \bool_if:NTF \l__nicematrix_initial_open_bool { - medium.north~east } { .south~west } } { - \bool_if:NTF \l__nm_final_open_bool + \bool_if:NTF \l__nicematrix_final_open_bool { - medium.south~west } { .north~east } } - \bool_if:NT \l__nm_parallelize_diags_bool + \bool_if:NT \l__nicematrix_parallelize_diags_bool { - \int_incr:N \l__nm_iddots_int - \int_compare:nNnTF \l__nm_iddots_int = \c_one_int + \int_incr:N \l__nicematrix_iddots_int + \int_compare:nNnTF \l__nicematrix_iddots_int = \c_one_int { - \dim_set:Nn \l__nm_delta_x_two_dim - { \g__nm_x_final_dim - \g__nm_x_initial_dim } - \dim_set:Nn \l__nm_delta_y_two_dim - { \g__nm_y_final_dim - \g__nm_y_initial_dim } + \dim_set:Nn \l__nicematrix_delta_x_two_dim + { \g__nicematrix_x_final_dim - \g__nicematrix_x_initial_dim } + \dim_set:Nn \l__nicematrix_delta_y_two_dim + { \g__nicematrix_y_final_dim - \g__nicematrix_y_initial_dim } } { - \dim_gset:Nn \g__nm_y_final_dim + \dim_gset:Nn \g__nicematrix_y_final_dim { - \g__nm_y_initial_dim + - ( \g__nm_x_final_dim - \g__nm_x_initial_dim ) * - \dim_ratio:nn \l__nm_delta_y_two_dim \l__nm_delta_x_two_dim + \g__nicematrix_y_initial_dim + + ( \g__nicematrix_x_final_dim - \g__nicematrix_x_initial_dim ) * + \dim_ratio:nn \l__nicematrix_delta_y_two_dim \l__nicematrix_delta_x_two_dim } } } - \__nm_draw_tikz_line: + \__nicematrix_draw_tikz_line: } } } -\cs_new_protected:Nn \__nm_draw_tikz_line: +\cs_new_protected:Nn \__nicematrix_draw_tikz_line: { - \dim_zero_new:N \l__nm_l_dim - \dim_set:Nn \l__nm_l_dim + \dim_zero_new:N \l__nicematrix_l_dim + \dim_set:Nn \l__nicematrix_l_dim { \fp_to_dim:n { sqrt ( - ( \dim_use:N \g__nm_x_final_dim - - \dim_use:N \g__nm_x_initial_dim + ( \dim_use:N \g__nicematrix_x_final_dim + - \dim_use:N \g__nicematrix_x_initial_dim ) ^ 2 + - ( \dim_use:N \g__nm_y_final_dim - - \dim_use:N \g__nm_y_initial_dim + ( \dim_use:N \g__nicematrix_y_final_dim + - \dim_use:N \g__nicematrix_y_initial_dim ) ^ 2 ) } } - \dim_compare:nNnF \l__nm_l_dim = \c_zero_dim + \dim_compare:nNnF \l__nicematrix_l_dim = \c_zero_dim { - \bool_if:NTF \l__nm_initial_open_bool + \bool_if:NTF \l__nicematrix_initial_open_bool { - \bool_if:NTF \l__nm_final_open_bool + \bool_if:NTF \l__nicematrix_final_open_bool { \int_set:Nn \l_tmpa_int - { \dim_ratio:nn \l__nm_l_dim \l__nm_inter_dots_dim } + { \dim_ratio:nn \l__nicematrix_l_dim \l__nicematrix_inter_dots_dim } } { \int_set:Nn \l_tmpa_int - { \dim_ratio:nn { \l__nm_l_dim - 0.3 em } \l__nm_inter_dots_dim } + { \dim_ratio:nn { \l__nicematrix_l_dim - 0.3 em } \l__nicematrix_inter_dots_dim } } } { - \bool_if:NTF \l__nm_final_open_bool + \bool_if:NTF \l__nicematrix_final_open_bool { \int_set:Nn \l_tmpa_int - { \dim_ratio:nn { \l__nm_l_dim - 0.3 em } \l__nm_inter_dots_dim } + { \dim_ratio:nn { \l__nicematrix_l_dim - 0.3 em } \l__nicematrix_inter_dots_dim } } { \int_set:Nn \l_tmpa_int - { \dim_ratio:nn { \l__nm_l_dim - 0.6 em } \l__nm_inter_dots_dim} + { \dim_ratio:nn { \l__nicematrix_l_dim - 0.6 em } \l__nicematrix_inter_dots_dim} } } \dim_set:Nn \l_tmpa_dim { - ( \g__nm_x_final_dim - \g__nm_x_initial_dim ) * - \dim_ratio:nn \l__nm_inter_dots_dim \l__nm_l_dim + ( \g__nicematrix_x_final_dim - \g__nicematrix_x_initial_dim ) * + \dim_ratio:nn \l__nicematrix_inter_dots_dim \l__nicematrix_l_dim } \dim_set:Nn \l_tmpb_dim { - ( \g__nm_y_final_dim - \g__nm_y_initial_dim ) * - \dim_ratio:nn \l__nm_inter_dots_dim \l__nm_l_dim + ( \g__nicematrix_y_final_dim - \g__nicematrix_y_initial_dim ) * + \dim_ratio:nn \l__nicematrix_inter_dots_dim \l__nicematrix_l_dim } \int_set:Nn \l_tmpb_int { - \bool_if:NTF \l__nm_initial_open_bool - { \bool_if:NTF \l__nm_final_open_bool 1 0 } - { \bool_if:NTF \l__nm_final_open_bool 2 1 } + \bool_if:NTF \l__nicematrix_initial_open_bool + { \bool_if:NTF \l__nicematrix_final_open_bool 1 0 } + { \bool_if:NTF \l__nicematrix_final_open_bool 2 1 } } - \dim_gadd:Nn \g__nm_x_initial_dim + \dim_gadd:Nn \g__nicematrix_x_initial_dim { - ( \g__nm_x_final_dim - \g__nm_x_initial_dim ) * + ( \g__nicematrix_x_final_dim - \g__nicematrix_x_initial_dim ) * \dim_ratio:nn - { \l__nm_l_dim - \l__nm_inter_dots_dim * \l_tmpa_int } - { \l__nm_l_dim * 2 } + { \l__nicematrix_l_dim - \l__nicematrix_inter_dots_dim * \l_tmpa_int } + { \l__nicematrix_l_dim * 2 } * \l_tmpb_int } - \dim_gadd:Nn \g__nm_y_initial_dim + \dim_gadd:Nn \g__nicematrix_y_initial_dim { - ( \g__nm_y_final_dim - \g__nm_y_initial_dim ) * + ( \g__nicematrix_y_final_dim - \g__nicematrix_y_initial_dim ) * \dim_ratio:nn - { \l__nm_l_dim - \l__nm_inter_dots_dim * \l_tmpa_int } - { \l__nm_l_dim * 2 } * + { \l__nicematrix_l_dim - \l__nicematrix_inter_dots_dim * \l_tmpa_int } + { \l__nicematrix_l_dim * 2 } * \l_tmpb_int } \begin { tikzpicture } [ overlay ] \int_step_inline:nnn 0 \l_tmpa_int { \pgfpathcircle - { \pgfpoint { \g__nm_x_initial_dim } { \g__nm_y_initial_dim } } - { \l__nm_radius_dim } + { \pgfpoint { \g__nicematrix_x_initial_dim } { \g__nicematrix_y_initial_dim } } + { \l__nicematrix_radius_dim } \pgfusepath { fill } - \dim_gadd:Nn \g__nm_x_initial_dim \l_tmpa_dim - \dim_gadd:Nn \g__nm_y_initial_dim \l_tmpb_dim + \dim_gadd:Nn \g__nicematrix_x_initial_dim \l_tmpa_dim + \dim_gadd:Nn \g__nicematrix_y_initial_dim \l_tmpb_dim } \end { tikzpicture } } } -\cs_set_eq:NN \__nm_ldots \ldots -\cs_set_eq:NN \__nm_cdots \cdots -\cs_set_eq:NN \__nm_vdots \vdots -\cs_set_eq:NN \__nm_ddots \ddots -\cs_set_eq:NN \__nm_iddots \iddots -\cs_new_protected:Nn \__nm_add_to_empty_cells: +\cs_set_eq:NN \__nicematrix_ldots \ldots +\cs_set_eq:NN \__nicematrix_cdots \cdots +\cs_set_eq:NN \__nicematrix_vdots \vdots +\cs_set_eq:NN \__nicematrix_ddots \ddots +\cs_set_eq:NN \__nicematrix_iddots \iddots +\cs_new_protected:Nn \__nicematrix_add_to_empty_cells: { \cs_gset:cpx - { __nm _ empty _ \int_use:N \c@iRow - \int_use:N \c@jCol } - { \int_use:N \g__nm_env_int } + { __nicematrix _ empty _ \int_use:N \c@iRow - \int_use:N \c@jCol } + { \int_use:N \g__nicematrix_env_int } } -\NewDocumentCommand \__nm_Ldots { s } +\NewDocumentCommand \__nicematrix_Ldots { s } { - \bool_if:nF { #1 } { \__nm_instruction_of_type:n { Ldots } } - \bool_if:NF \l__nm_nullify_dots_bool { \phantom \__nm_ldots } - \__nm_add_to_empty_cells: + \bool_if:nF { #1 } { \__nicematrix_instruction_of_type:n { Ldots } } + \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_ldots } + \__nicematrix_add_to_empty_cells: } -\NewDocumentCommand \__nm_Cdots { s } +\NewDocumentCommand \__nicematrix_Cdots { s } { - \bool_if:nF { #1 } { \__nm_instruction_of_type:n { Cdots } } - \bool_if:NF \l__nm_nullify_dots_bool { \phantom \__nm_cdots } - \__nm_add_to_empty_cells: + \bool_if:nF { #1 } { \__nicematrix_instruction_of_type:n { Cdots } } + \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_cdots } + \__nicematrix_add_to_empty_cells: } -\NewDocumentCommand \__nm_Vdots { s } +\NewDocumentCommand \__nicematrix_Vdots { s } { - \bool_if:nF { #1 } { \__nm_instruction_of_type:n { Vdots } } - \bool_if:NF \l__nm_nullify_dots_bool { \phantom \__nm_vdots } - \__nm_add_to_empty_cells: + \bool_if:nF { #1 } { \__nicematrix_instruction_of_type:n { Vdots } } + \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_vdots } + \__nicematrix_add_to_empty_cells: } -\NewDocumentCommand \__nm_Ddots { s } +\NewDocumentCommand \__nicematrix_Ddots { s } { - \bool_if:nF { #1 } { \__nm_instruction_of_type:n { Ddots } } - \bool_if:NF \l__nm_nullify_dots_bool { \phantom \__nm_ddots } - \__nm_add_to_empty_cells: + \bool_if:nF { #1 } { \__nicematrix_instruction_of_type:n { Ddots } } + \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_ddots } + \__nicematrix_add_to_empty_cells: } -\NewDocumentCommand \__nm_Iddots { s } +\NewDocumentCommand \__nicematrix_Iddots { s } { - \bool_if:nF { #1 } { \__nm_instruction_of_type:n { Iddots } } - \bool_if:NF \l__nm_nullify_dots_bool { \phantom \__nm_iddots } - \__nm_add_to_empty_cells: + \bool_if:nF { #1 } { \__nicematrix_instruction_of_type:n { Iddots } } + \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_iddots } + \__nicematrix_add_to_empty_cells: } -\cs_new_protected:Nn \__nm_Hspace: +\cs_new_protected:Nn \__nicematrix_Hspace: { - \__nm_add_to_empty_cells: + \__nicematrix_add_to_empty_cells: \hspace } -\cs_set_eq:NN \__nm_old_multicolumn \multicolumn -\cs_new:Npn \__nm_multicolumn:nnn #1 #2 #3 +\cs_set_eq:NN \__nicematrix_old_multicolumn \multicolumn +\cs_new:Npn \__nicematrix_multicolumn:nnn #1 #2 #3 { - \__nm_old_multicolumn { #1 } { #2 } { #3 } + \__nicematrix_old_multicolumn { #1 } { #2 } { #3 } \int_compare:nNnT #1 > 1 { - \seq_gput_left:Nx \g__nm_multicolumn_cells_seq + \seq_gput_left:Nx \g__nicematrix_multicolumn_cells_seq { \int_eval:n \c@iRow - \int_use:N \c@jCol } - \seq_gput_left:Nn \g__nm_multicolumn_sizes_seq { #1 } + \seq_gput_left:Nn \g__nicematrix_multicolumn_sizes_seq { #1 } } \int_gadd:Nn \c@jCol { #1 - 1 } } -\cs_new:Npn \__nm_Hdotsfor: +\cs_new:Npn \__nicematrix_Hdotsfor: { \multicolumn { 1 } { C } { } - \__nm_Hdotsfor_i + \__nicematrix_Hdotsfor_i } -\bool_if:NTF \c__nm_draft_bool +\bool_if:NTF \c__nicematrix_draft_bool { - \NewDocumentCommand \__nm_Hdotsfor_i { O { } m } + \NewDocumentCommand \__nicematrix_Hdotsfor_i { O { } m } { \prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { C } { } } } } { - \NewDocumentCommand \__nm_Hdotsfor_i { O { } m } + \NewDocumentCommand \__nicematrix_Hdotsfor_i { O { } m } { - \tl_gput_right:Nx \g__nm_Hdotsfor_lines_tl + \tl_gput_right:Nx \g__nicematrix_Hdotsfor_lines_tl { - \__nm_draw_Hdotsfor:nnn + \__nicematrix_draw_Hdotsfor:nnn { \int_use:N \c@iRow } { \int_use:N \c@jCol } { #2 } @@ -1768,169 +1758,169 @@ \prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { C } { } } } } -\cs_new_protected:Nn \__nm_draw_Hdotsfor:nnn +\cs_new_protected:Nn \__nicematrix_draw_Hdotsfor:nnn { - \bool_set_false:N \l__nm_initial_open_bool - \bool_set_false:N \l__nm_final_open_bool - \int_set:Nn \l__nm_initial_i_int { #1 } - \int_set:Nn \l__nm_final_i_int { #1 } + \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:Nn \l__nicematrix_final_i_int { #1 } \int_compare:nNnTF #2 = 1 { - \int_set:Nn \l__nm_initial_j_int 1 - \bool_set_true:N \l__nm_initial_open_bool + \int_set:Nn \l__nicematrix_initial_j_int 1 + \bool_set_true:N \l__nicematrix_initial_open_bool } { \int_set:Nn \l_tmpa_int { #2 - 1 } - \__nm_if_not_empty_cell:nnTF \l__nm_initial_i_int \l_tmpa_int - { \int_set:Nn \l__nm_initial_j_int { #2 - 1 } } + \__nicematrix_if_not_empty_cell:nnTF \l__nicematrix_initial_i_int \l_tmpa_int + { \int_set:Nn \l__nicematrix_initial_j_int { #2 - 1 } } { - \int_set:Nn \l__nm_initial_j_int {#2} - \bool_set_true:N \l__nm_initial_open_bool + \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__nm_final_j_int { #2 + #3 - 1 } - \bool_set_true:N \l__nm_final_open_bool + \int_set:Nn \l__nicematrix_final_j_int { #2 + #3 - 1 } + \bool_set_true:N \l__nicematrix_final_open_bool } { \int_set:Nn \l_tmpa_int { #2 + #3 } - \__nm_if_not_empty_cell:nnTF \l__nm_final_i_int \l_tmpa_int - { \int_set:Nn \l__nm_final_j_int { #2 + #3 } } + \__nicematrix_if_not_empty_cell:nnTF \l__nicematrix_final_i_int \l_tmpa_int + { \int_set:Nn \l__nicematrix_final_j_int { #2 + #3 } } { - \int_set:Nn \l__nm_final_j_int { #2 + #3 - 1 } - \bool_set_true:N \l__nm_final_open_bool + \int_set:Nn \l__nicematrix_final_j_int { #2 + #3 - 1 } + \bool_set_true:N \l__nicematrix_final_open_bool } } - \bool_if:nT { \l__nm_initial_open_bool || \l__nm_final_open_bool } - \__nm_create_extra_nodes: - \__nm_actually_draw_Ldots: + \bool_if:nT { \l__nicematrix_initial_open_bool || \l__nicematrix_final_open_bool } + \__nicematrix_create_extra_nodes: + \__nicematrix_actually_draw_Ldots: \int_step_inline:nnn { #2 } { #2 + #3 - 1 } - { \cs_set:cpn { __nm _ dotted _ #1 - ##1 } { } } + { \cs_set:cpn { __nicematrix _ dotted _ #1 - ##1 } { } } } -\cs_new:Npn \__nm_double_int_eval:n #1-#2 \q_stop +\cs_new:Npn \__nicematrix_double_int_eval:n #1-#2 \q_stop { \int_eval:n { #1 } - \int_eval:n { #2 } } -\cs_new_protected:Npn \__nm_line:nn #1 #2 +\cs_new_protected:Npn \__nicematrix_line:nn #1 #2 { \use:x { - \__nm_line_i:nn - { \__nm_double_int_eval:n #1 \q_stop } - { \__nm_double_int_eval:n #2 \q_stop } + \__nicematrix_line_i:nn + { \__nicematrix_double_int_eval:n #1 \q_stop } + { \__nicematrix_double_int_eval:n #2 \q_stop } } } -\cs_new_protected:Nn \__nm_line_i:nn +\cs_new_protected:Nn \__nicematrix_line_i:nn { - \bool_if:NF \c__nm_draft_bool + \bool_if:NF \c__nicematrix_draft_bool { - \dim_zero_new:N \g__nm_x_initial_dim - \dim_zero_new:N \g__nm_y_initial_dim - \dim_zero_new:N \g__nm_x_final_dim - \dim_zero_new:N \g__nm_y_final_dim - \bool_set_false:N \l__nm_initial_open_bool - \bool_set_false:N \l__nm_final_open_bool + \dim_zero_new:N \g__nicematrix_x_initial_dim + \dim_zero_new:N \g__nicematrix_y_initial_dim + \dim_zero_new:N \g__nicematrix_x_final_dim + \dim_zero_new:N \g__nicematrix_y_final_dim + \bool_set_false:N \l__nicematrix_initial_open_bool + \bool_set_false:N \l__nicematrix_final_open_bool \bool_if:nTF { - \cs_if_exist_p:c { pgf@sh@ns@nm - \int_use:N \g__nm_env_int - #1 } + \cs_if_exist_p:c { pgf@sh@ns@nm - \int_use:N \g__nicematrix_env_int - #1 } && - \cs_if_exist_p:c { pgf@sh@ns@nm - \int_use:N \g__nm_env_int - #2 } + \cs_if_exist_p:c { pgf@sh@ns@nm - \int_use:N \g__nicematrix_env_int - #2 } } { \begin { tikzpicture } \path~(#1)~--~(#2)~node[at~start]~(i)~{}~node[at~end]~(f)~{} ; \tikz@parse@node \pgfutil@firstofone ( i ) - \dim_gset:Nn \g__nm_x_initial_dim \pgf@x - \dim_gset:Nn \g__nm_y_initial_dim \pgf@y + \dim_gset:Nn \g__nicematrix_x_initial_dim \pgf@x + \dim_gset:Nn \g__nicematrix_y_initial_dim \pgf@y \tikz@parse@node \pgfutil@firstofone ( f ) - \dim_gset:Nn \g__nm_x_final_dim \pgf@x - \dim_gset:Nn \g__nm_y_final_dim \pgf@y + \dim_gset:Nn \g__nicematrix_x_final_dim \pgf@x + \dim_gset:Nn \g__nicematrix_y_final_dim \pgf@y \end { tikzpicture } - \__nm_draw_tikz_line: + \__nicematrix_draw_tikz_line: } { - \__nm_error:nnn { unknown~cell~for~line~in~code-after } + \__nicematrix_error:nnn { unknown~cell~for~line~in~code-after } { #1 } { #2 } } } } -\bool_if:NTF \c__nm_draft_bool - { \cs_set_eq:NN \__nm_dotfill: \prg_do_nothing: } +\bool_if:NTF \c__nicematrix_draft_bool + { \cs_set_eq:NN \__nicematrix_dotfill: \prg_do_nothing: } { - \cs_set:Npn \__nm_dotfill: + \cs_set:Npn \__nicematrix_dotfill: { - \bool_if:NT \l__nm_small_bool - { \dim_set:Nn \l__nm_inter_dots_dim { 0.25 em } } + \bool_if:NT \l__nicematrix_small_bool + { \dim_set:Nn \l__nicematrix_inter_dots_dim { 0.25 em } } \cleaders \hbox_to_wd:nn - { \l__nm_inter_dots_dim } + { \l__nicematrix_inter_dots_dim } { \c_math_toggle_token - \bool_if:NT \l__nm_small_bool \scriptstyle + \bool_if:NT \l__nicematrix_small_bool \scriptstyle \hss . \hss \c_math_toggle_token } \hfill } } -\cs_new:Npn \__nm_hdottedline: +\cs_new:Npn \__nicematrix_hdottedline: { \noalign { - \bool_gset_true:N \g__nm_extra_nodes_bool - \cs_if_exist:cTF { __nm_width_ \int_use:N \g__nm_env_int } - { \dim_set_eq:Nc \l_tmpa_dim { __nm_width_ \int_use:N \g__nm_env_int } } + \bool_gset_true:N \g__nicematrix_extra_nodes_bool + \cs_if_exist:cTF { __nicematrix_width_ \int_use:N \g__nicematrix_env_int } + { \dim_set_eq:Nc \l_tmpa_dim { __nicematrix_width_ \int_use:N \g__nicematrix_env_int } } { \dim_set:Nn \l_tmpa_dim { 5 mm } } \hbox_overlap_right:n { \bool_if:nT { - \l__nm_NiceArray_bool + \l__nicematrix_NiceArray_bool && - ! \l__nm_exterior_arraycolsep_bool + ! \l__nicematrix_exterior_arraycolsep_bool && - \int_compare_p:nNn \l__nm_first_col_int > \c_zero_int + \int_compare_p:nNn \l__nicematrix_first_col_int > \c_zero_int } { \skip_horizontal:n { - \arraycolsep } } \hbox_to_wd:nn { \l_tmpa_dim + 2 \arraycolsep - - \l__nm_left_margin_dim - \l__nm_right_margin_dim + - \l__nicematrix_left_margin_dim - \l__nicematrix_right_margin_dim } - \__nm_dotfill: + \__nicematrix_dotfill: } } } -\cs_new_protected:Nn \__nm_vdottedline:n +\cs_new_protected:Nn \__nicematrix_vdottedline:n { \int_compare:nNnTF #1 = \c_zero_int - { \__nm_error:n { Use~of~:~in~first~position } } + { \__nicematrix_error:n { Use~of~:~in~first~position } } { - \bool_if:NF \c__nm_draft_bool + \bool_if:NF \c__nicematrix_draft_bool { - \dim_zero_new:N \g__nm_x_initial_dim - \dim_zero_new:N \g__nm_y_initial_dim - \dim_zero_new:N \g__nm_x_final_dim - \dim_zero_new:N \g__nm_y_final_dim - \bool_set_true:N \l__nm_initial_open_bool - \bool_set_true:N \l__nm_final_open_bool + \dim_zero_new:N \g__nicematrix_x_initial_dim + \dim_zero_new:N \g__nicematrix_y_initial_dim + \dim_zero_new:N \g__nicematrix_x_final_dim + \dim_zero_new:N \g__nicematrix_y_final_dim + \bool_set_true:N \l__nicematrix_initial_open_bool + \bool_set_true:N \l__nicematrix_final_open_bool \cs_if_exist:cTF - { pgf@sh@ns@nm -\int_use:N \g__nm_env_int - col - #1 } + { pgf@sh@ns@nm -\int_use:N \g__nicematrix_env_int - col - #1 } { \begin { tikzpicture } [ remember~picture ] \tikz@parse@node\pgfutil@firstofone ( col - #1 ) - \dim_gset:Nn \g__nm_x_initial_dim \pgf@x - \dim_gset:Nn \g__nm_x_final_dim \pgf@x - \dim_gset:Nn \g__nm_y_final_dim \pgf@y + \dim_gset:Nn \g__nicematrix_x_initial_dim \pgf@x + \dim_gset:Nn \g__nicematrix_x_final_dim \pgf@x + \dim_gset:Nn \g__nicematrix_y_final_dim \pgf@y \end { tikzpicture } - \dim_gset:Nn \g__nm_y_initial_dim { - \c_max_dim } + \dim_gset:Nn \g__nicematrix_y_initial_dim { - \c_max_dim } \int_step_inline:nn \c@jCol { \begin { tikzpicture } [ remember~picture ] \tikz@parse@node\pgfutil@firstofone ( 1 - ##1 . north~east ) - \dim_gset:Nn \g__nm_y_initial_dim - { \dim_max:nn \g__nm_y_initial_dim \pgf@y } + \dim_gset:Nn \g__nicematrix_y_initial_dim + { \dim_max:nn \g__nicematrix_y_initial_dim \pgf@y } \end { tikzpicture } } } @@ -1938,59 +1928,59 @@ \begin { tikzpicture } [ remember~picture ] \tikz@parse@node\pgfutil@firstofone ( 1 - #1 - large .north~east ) - \dim_gset:Nn \g__nm_x_initial_dim \pgf@x - \dim_gset:Nn \g__nm_y_initial_dim \pgf@y + \dim_gset:Nn \g__nicematrix_x_initial_dim \pgf@x + \dim_gset:Nn \g__nicematrix_y_initial_dim \pgf@y \tikz@parse@node\pgfutil@firstofone ( \int_use:N \c@iRow - #1 - large .south~east ) - \dim_gset:Nn \g__nm_x_final_dim \pgf@x - \dim_gset:Nn \g__nm_y_final_dim \pgf@y + \dim_gset:Nn \g__nicematrix_x_final_dim \pgf@x + \dim_gset:Nn \g__nicematrix_y_final_dim \pgf@y \end { tikzpicture } \cs_if_exist:cT - { pgf@sh@ns@nm -\int_use:N \g__nm_env_int - 1 - #1 - w } + { pgf@sh@ns@nm -\int_use:N \g__nicematrix_env_int - 1 - #1 - w } { \begin { tikzpicture } [ remember~picture ] \tikz@parse@node\pgfutil@firstofone ( 1 - #1 - w .north~east ) - \dim_gset:Nn \g__nm_x_initial_dim \pgf@x + \dim_gset:Nn \g__nicematrix_x_initial_dim \pgf@x \tikz@parse@node\pgfutil@firstofone ( \int_use:N \c@iRow - #1 - w .south~east ) - \dim_gset:Nn \g__nm_x_final_dim \pgf@x + \dim_gset:Nn \g__nicematrix_x_final_dim \pgf@x \end { tikzpicture } - \dim_gadd:Nn \g__nm_x_initial_dim \arraycolsep - \dim_gadd:Nn \g__nm_x_final_dim \arraycolsep + \dim_gadd:Nn \g__nicematrix_x_initial_dim \arraycolsep + \dim_gadd:Nn \g__nicematrix_x_final_dim \arraycolsep } } - \__nm_draw_tikz_line: + \__nicematrix_draw_tikz_line: } } } -\cs_new_protected:Npn \__nm_vline: +\cs_new_protected:Npn \__nicematrix_vline: { - \int_compare:nNnTF \l__nm_first_col_int = \c_zero_int + \int_compare:nNnTF \l__nicematrix_first_col_int = \c_zero_int { \int_compare:nNnTF \c@jCol = \c_zero_int { - \int_compare:nNnTF \l__nm_first_row_int = \c_zero_int + \int_compare:nNnTF \l__nicematrix_first_row_int = \c_zero_int { \int_compare:nNnF \c@iRow = \c_zero_int { - \int_compare:nNnF \c@iRow = \l__nm_last_row_int - \__nm_vline_i: + \int_compare:nNnF \c@iRow = \l__nicematrix_last_row_int + \__nicematrix_vline_i: } } { \int_compare:nNnF \c@iRow = \c_zero_int { - \int_compare:nNnF \c@iRow = \l__nm_last_row_int - \__nm_vline_i: + \int_compare:nNnF \c@iRow = \l__nicematrix_last_row_int + \__nicematrix_vline_i: } } } { \int_compare:nNnF \c@iRow = \c_zero_int { - \int_compare:nNnF \c@iRow = \l__nm_last_row_int - \__nm_vline_i: + \int_compare:nNnF \c@iRow = \l__nicematrix_last_row_int + \__nicematrix_vline_i: } } } @@ -1999,242 +1989,243 @@ { \int_compare:nNnF \c@iRow = { -1 } { - \int_compare:nNnF \c@iRow = { \l__nm_last_row_int - 1 } - \__nm_vline_i: + \int_compare:nNnF \c@iRow = { \l__nicematrix_last_row_int - 1 } + \__nicematrix_vline_i: } } { \int_compare:nNnF \c@iRow = \c_zero_int { - \int_compare:nNnF \c@iRow = \l__nm_last_row_int - \__nm_vline_i: + \int_compare:nNnF \c@iRow = \l__nicematrix_last_row_int + \__nicematrix_vline_i: } } } } -\cs_set_eq:NN \__nm_vline_i: \vline -\bool_new:N \l__nm_block_auto_columns_width_bool +\cs_set_eq:NN \__nicematrix_vline_i: \vline +\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__nm_block_auto_columns_width_bool - \dim_gzero_new:N \g__nm_max_cell_width_dim - \bool_set_true:N \l__nm_auto_columns_width_bool + \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__nm_NiceMatrixBlock_int - \dim_zero:N \l__nm_columns_width_dim + \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__nm_block_auto_columns_width_bool + \bool_if:NT \l__nicematrix_block_auto_columns_width_bool { - \cs_if_exist:cT { __nm_max_cell_width_ \int_use:N \g__nm_NiceMatrixBlock_int } + \cs_if_exist:cT { __nicematrix_max_cell_width_ \int_use:N \g__nicematrix_NiceMatrixBlock_int } { - \dim_set:Nx \l__nm_columns_width_dim - { \use:c { __nm_max_cell_width _ \int_use:N \g__nm_NiceMatrixBlock_int } } + \dim_set:Nx \l__nicematrix_columns_width_dim + { \use:c { __nicematrix_max_cell_width _ \int_use:N \g__nicematrix_NiceMatrixBlock_int } } } } } { - \bool_if:NT \l__nm_block_auto_columns_width_bool + \bool_if:NT \l__nicematrix_block_auto_columns_width_bool { \iow_now:Nn \@mainaux \ExplSyntaxOn \iow_now:Nx \@mainaux { \cs_gset:cpn - { __nm _ max _ cell _ width _ \int_use:N \g__nm_NiceMatrixBlock_int } - { \dim_use:N \g__nm_max_cell_width_dim } + { __nicematrix _ max _ cell _ width _ \int_use:N \g__nicematrix_NiceMatrixBlock_int } + { \dim_use:N \g__nicematrix_max_cell_width_dim } } \iow_now:Nn \@mainaux \ExplSyntaxOff } } \cs_generate_variant:Nn \dim_min:nn { v n } \cs_generate_variant:Nn \dim_max:nn { v n } -\cs_new_protected:Nn \__nm_create_extra_nodes: +\cs_new_protected:Nn \__nicematrix_create_extra_nodes: { \begin { tikzpicture } [ remember~picture , overlay ] - \int_step_variable:nnNn \l__nm_first_row_int \g__nm_row_total_int \__nm_i: + \int_step_variable:nnNn \l__nicematrix_first_row_int \g__nicematrix_row_total_int \__nicematrix_i: { - \dim_zero_new:c { l__nm_row_\__nm_i: _min_dim } - \dim_set_eq:cN { l__nm_row_\__nm_i: _min_dim } \c_max_dim - \dim_zero_new:c { l__nm_row_\__nm_i: _max_dim } - \dim_set:cn { l__nm_row_\__nm_i: _max_dim } { - \c_max_dim } + \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__nm_first_col_int \g__nm_col_total_int \__nm_j: + \int_step_variable:nnNn \l__nicematrix_first_col_int \g__nicematrix_col_total_int \__nicematrix_j: { - \dim_zero_new:c { l__nm_column_\__nm_j: _min_dim } - \dim_set_eq:cN { l__nm_column_\__nm_j: _min_dim } \c_max_dim - \dim_zero_new:c { l__nm_column_\__nm_j: _max_dim } - \dim_set:cn { l__nm_column_\__nm_j: _max_dim } { - \c_max_dim } + \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__nm_first_row_int \g__nm_row_total_int \__nm_i: + \int_step_variable:nnNn \l__nicematrix_first_row_int \g__nicematrix_row_total_int \__nicematrix_i: { \int_step_variable:nnNn - \l__nm_first_col_int \g__nm_col_total_int \__nm_j: + \l__nicematrix_first_col_int \g__nicematrix_col_total_int \__nicematrix_j: { \cs_if_exist:cT - { pgf@sh@ns@nm - \int_use:N \g__nm_env_int - \__nm_i: - \__nm_j: } + { pgf@sh@ns@nm - \int_use:N \g__nicematrix_env_int - \__nicematrix_i: - \__nicematrix_j: } { \tikz@parse@node \pgfutil@firstofone - ( nm - \int_use:N \g__nm_env_int - - \__nm_i: - \__nm_j: .south~west ) - \dim_set:cn { l__nm_row_\__nm_i: _min_dim} - { \dim_min:vn { l__nm_row _ \__nm_i: _min_dim } \pgf@y } - \seq_if_in:NxF \g__nm_multicolumn_cells_seq { \__nm_i: - \__nm_j: } + ( nm - \int_use:N \g__nicematrix_env_int + - \__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__nm_column _ \__nm_j: _min_dim} - { \dim_min:vn { l__nm_column _ \__nm_j: _min_dim } \pgf@x } + \dim_set:cn { l__nicematrix_column _ \__nicematrix_j: _min_dim} + { \dim_min:vn { l__nicematrix_column _ \__nicematrix_j: _min_dim } \pgf@x } } \tikz@parse@node \pgfutil@firstofone - ( nm - \int_use:N \g__nm_env_int - \__nm_i: - \__nm_j: .north~east ) - \dim_set:cn { l__nm_row _ \__nm_i: _ max_dim } - { \dim_max:vn { l__nm_row _ \__nm_i: _ max_dim } \pgf@y } - \seq_if_in:NxF \g__nm_multicolumn_cells_seq { \__nm_i: - \__nm_j: } + ( nm - \int_use:N \g__nicematrix_env_int - \__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__nm_column _ \__nm_j: _ max_dim } - { \dim_max:vn { l__nm_column _ \__nm_j: _max_dim } \pgf@x } + \dim_set:cn { l__nicematrix_column _ \__nicematrix_j: _ max_dim } + { \dim_max:vn { l__nicematrix_column _ \__nicematrix_j: _max_dim } \pgf@x } } } } } \tikzset { name~suffix = -medium } - \__nm_create_nodes: - \int_set:Nn \l__nm_first_row_int 1 - \int_set:Nn \l__nm_first_col_int 1 - \int_step_variable:nNn { \c@iRow - 1 } \__nm_i: + \__nicematrix_create_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__nm_row _ \__nm_i: _ min _ dim } + \dim_set:cn { l__nicematrix_row _ \__nicematrix_i: _ min _ dim } { ( - \dim_use:c { l__nm_row _ \__nm_i: _ min _ dim } + - \dim_use:c { l__nm_row _ \int_eval:n { \__nm_i: + 1 } _ max _ 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__nm_row _ \int_eval:n { \__nm_i: + 1 } _ max _ dim } - { l__nm_row_\__nm_i: _min_dim } + \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 } \__nm_j: + \int_step_variable:nNn { \c@jCol - 1 } \__nicematrix_j: { - \dim_set:cn { l__nm_column _ \__nm_j: _ max _ dim } + \dim_set:cn { l__nicematrix_column _ \__nicematrix_j: _ max _ dim } { ( \dim_use:c - { l__nm_column _ \__nm_j: _ max _ dim } + + { l__nicematrix_column _ \__nicematrix_j: _ max _ dim } + \dim_use:c - { l__nm_column _ \int_eval:n { \__nm_j: + 1 } _ min _ dim } + { l__nicematrix_column _ \int_eval:n { \__nicematrix_j: + 1 } _ min _ dim } ) / 2 } - \dim_set_eq:cc { l__nm_column _ \int_eval:n { \__nm_j: + 1 } _ min _ dim } - { l__nm_column _ \__nm_j: _ max _ dim } + \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__nm_column _ 1 _ min _ dim } - \l__nm_left_margin_dim + { l__nicematrix_column _ 1 _ min _ dim } + \l__nicematrix_left_margin_dim \dim_add:cn - { l__nm_column _ \int_use:N \c@jCol _ max _ dim } - \l__nm_right_margin_dim + { l__nicematrix_column _ \int_use:N \c@jCol _ max _ dim } + \l__nicematrix_right_margin_dim \tikzset { name~suffix = -large } - \__nm_create_nodes: + \__nicematrix_create_nodes: \end{tikzpicture} - \cs_set:Npn \__nm_create_extra_nodes: { } + \cs_set:Npn \__nicematrix_create_extra_nodes: { } \begin { tikzpicture } [ remember~picture , overlay ] \tikz@parse@node \pgfutil@firstofone - ( nm - \int_use:N \g__nm_env_int - 1 - 1 - large .north~west ) + ( nm - \int_use:N \g__nicematrix_env_int - 1 - 1 - large .north~west ) \dim_gset:Nn \g_tmpa_dim \pgf@x \tikz@parse@node \pgfutil@firstofone - ( nm - \int_use:N \g__nm_env_int - 1 - + ( nm - \int_use:N \g__nicematrix_env_int - 1 - \int_use:N \c@jCol - large .north~east ) \dim_gset:Nn \g_tmpb_dim \pgf@x \end { tikzpicture } \iow_now:Nn \@mainaux \ExplSyntaxOn \iow_now:Nx \@mainaux { - \cs_gset:cpn { __nm_width_ \int_use:N \g__nm_env_int } + \cs_gset:cpn { __nicematrix_width_ \int_use:N \g__nicematrix_env_int } { \dim_eval:n { \g_tmpb_dim - \g_tmpa_dim } } } \iow_now:Nn \@mainaux \ExplSyntaxOff } -\cs_new_protected:Nn \__nm_create_nodes: +\cs_new_protected:Nn \__nicematrix_create_nodes: { - \int_step_variable:nnNn \l__nm_first_row_int \g__nm_row_total_int \__nm_i: + \int_step_variable:nnNn \l__nicematrix_first_row_int \g__nicematrix_row_total_int \__nicematrix_i: { - \int_step_variable:nnNn \l__nm_first_col_int \g__nm_col_total_int \__nm_j: + \int_step_variable:nnNn \l__nicematrix_first_col_int \g__nicematrix_col_total_int \__nicematrix_j: { - \coordinate ( __nm~south~west ) - at ( \dim_use:c { l__nm_column_ \__nm_j: _min_dim } , - \dim_use:c { l__nm_row_ \__nm_i: _min_dim } ) ; - \coordinate ( __nm~north~east ) - at ( \dim_use:c { l__nm_column_ \__nm_j: _max_dim } , - \dim_use:c { l__nm_row_ \__nm_i: _max_dim } ) ; + \coordinate ( __nicematrix~south~west ) + at ( \dim_use:c { l__nicematrix_column_ \__nicematrix_j: _min_dim } , + \dim_use:c { l__nicematrix_row_ \__nicematrix_i: _min_dim } ) ; + \coordinate ( __nicematrix~north~east ) + at ( \dim_use:c { l__nicematrix_column_ \__nicematrix_j: _max_dim } , + \dim_use:c { l__nicematrix_row_ \__nicematrix_i: _max_dim } ) ; \node [ node~contents = { } , - fit = ( __nm~south~west ) ( __nm~north~east ) , + fit = ( __nicematrix~south~west ) ( __nicematrix~north~east ) , inner~sep = \c_zero_dim , - name = nm - \int_use:N \g__nm_env_int - \__nm_i: - \__nm_j: , + name = nm - \int_use:N \g__nicematrix_env_int - \__nicematrix_i: - \__nicematrix_j: , alias = - \str_if_empty:NF \l__nm_name_str - { \l__nm_name_str - \__nm_i: - \__nm_j: } + \str_if_empty:NF \l__nicematrix_name_str + { \l__nicematrix_name_str - \__nicematrix_i: - \__nicematrix_j: } ] ; } } \seq_mapthread_function:NNN - \g__nm_multicolumn_cells_seq - \g__nm_multicolumn_sizes_seq - \__nm_node_for_multicolumn:nn + \g__nicematrix_multicolumn_cells_seq + \g__nicematrix_multicolumn_sizes_seq + \__nicematrix_node_for_multicolumn:nn } -\cs_new_protected:Npn \__nm_extract_coords: #1 - #2 \q_stop +\cs_new_protected:Npn \__nicematrix_extract_coords: #1 - #2 \q_stop { - \cs_set:Npn \__nm_i: { #1 } - \cs_set:Npn \__nm_j: { #2 } + \cs_set:Npn \__nicematrix_i: { #1 } + \cs_set:Npn \__nicematrix_j: { #2 } } -\cs_new_protected:Nn \__nm_node_for_multicolumn:nn +\cs_new_protected:Nn \__nicematrix_node_for_multicolumn:nn { - \__nm_extract_coords: #1 \q_stop - \coordinate ( __nm~south~west ) at + \__nicematrix_extract_coords: #1 \q_stop + \coordinate ( __nicematrix~south~west ) at ( - \dim_use:c { l__nm_column _ \__nm_j: _ min _ dim } , - \dim_use:c { l__nm_row _ \__nm_i: _ min _ dim } + \dim_use:c { l__nicematrix_column _ \__nicematrix_j: _ min _ dim } , + \dim_use:c { l__nicematrix_row _ \__nicematrix_i: _ min _ dim } ) ; - \coordinate ( __nm~north~east ) at + \coordinate ( __nicematrix~north~east ) at ( - \dim_use:c { l__nm_column _ \int_eval:n { \__nm_j: + #2 - 1 } _ max _ dim} , - \dim_use:c { l__nm_row _ \__nm_i: _ max _ 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 } ) ; \node [ node~contents = { } , - fit = ( __nm~south~west ) ( __nm~north~east ) , + fit = ( __nicematrix~south~west ) ( __nicematrix~north~east ) , inner~sep = \c_zero_dim , - name = nm - \int_use:N \g__nm_env_int - \__nm_i: - \__nm_j: , + name = nm - \int_use:N \g__nicematrix_env_int - \__nicematrix_i: - \__nicematrix_j: , alias = - \str_if_empty:NF \l__nm_name_str - { \l__nm_name_str - \__nm_i: - \__nm_j: } + \str_if_empty:NF \l__nicematrix_name_str + { \l__nicematrix_name_str - \__nicematrix_i: - \__nicematrix_j: } ] ; } -\NewExpandableDocumentCommand \__nm_Block: { m D < > { } m } - { \__nm_Block_i #1 \q_stop { #2 } { #3 } } -\cs_new:Npn \__nm_Block_i #1-#2 \q_stop { \__nm_Block_ii:nnnn { #1 } { #2 } } -\cs_new:Npn \__nm_Block_ii:nnnn #1 #2 #3 #4 +\NewDocumentCommand \__nicematrix_Block: { m D < > { } m } + { \__nicematrix_Block_i #1 \q_stop { #2 } { #3 } } +\cs_new:Npn \__nicematrix_Block_i #1-#2 \q_stop { \__nicematrix_Block_ii:nnnn { #1 } { #2 } } +\cs_new:Npn \__nicematrix_Block_ii:nnnn #1 #2 #3 #4 { - \int_compare:nNnTF { #1 } = 1 + \int_compare:nNnT { #1 } = 1 { - \multicolumn { #2 } { C } { \hbox:n { #3 $#4$ } } - \__nm_gobble_ampersands:n { #2 - 1 } + \begin { tikzpicture } [ remember~picture , baseline ] + \coordinate + ( nm - \int_use:N \g__nicematrix_env_int + - Block + - \int_use:N \c@iRow + - \int_use:N \c@jCol ) ; + \end { tikzpicture } } - { \__nm_Block_iii:nnnn { #1 } { #2 } { #3 } { #4 } } - } -\cs_new_protected:Npn \__nm_Block_iii:nnnn #1 #2 #3 #4 - { - \bool_gset_true:N \g__nm_extra_nodes_bool - \tl_gput_left:Nx \g__nm_code_after_tl + \bool_gset_true:N \g__nicematrix_extra_nodes_bool + \tl_gput_left:Nx \g__nicematrix_code_after_tl { - \__nm_Block_iv:nnnnn + \__nicematrix_Block_iii:nnnnn { \int_use:N \c@iRow } { \int_use:N \c@jCol } { \int_eval:n { \c@iRow + #1 - 1 } } @@ -2242,18 +2233,7 @@ \exp_not:n { { #3 $ #4 $ } } } } -\group_begin: - \char_set_catcode_letter:N \& - \cs_new:Npn \__nm_gobble_ampersands:n #1 - { - \int_compare:nNnT { #1 } > 0 - { - \peek_charcode_remove_ignore_spaces:NT & - { \__nm_gobble_ampersands:n { #1 - 1 } } - } - } -\group_end: -\cs_new_protected:Npn \__nm_Block_iv:nnnnn #1 #2 #3 #4 #5 +\cs_new_protected:Npn \__nicematrix_Block_iii:nnnnn #1 #2 #3 #4 #5 { \bool_if:nTF { @@ -2262,19 +2242,37 @@ } { \msg_error:nnnn { nicematrix } { Block~too~large } { #1 } { #2 } } { - \begin{tikzpicture} - \node - [ - fit = ( #1 - #2 - medium . north~west ) - ( #3 - #4 - medium . south~east ) , - inner~sep = 0 pt , - ] - (#1-#2) { } ; - \node at (#1-#2.center) { #5 } ; - \end{tikzpicture} + \int_compare:nNnTF { #1 } = { #3 } + { + \begin { tikzpicture } + \tikz@parse@node \pgfutil@firstofone (Block-#1-#2) + \dim_set:Nn \l_tmpa_dim \pgf@y + \node + [ + fit = ( #1 - #2 - medium . north~west ) + ( #3 - #4 - medium . south~east ) , + inner~sep = 0 pt , + ] + (#1-#2) { } ; + \tikz@parse@node \pgfutil@firstofone (#1-#2) + \path (\pgf@x,\l_tmpa_dim) node [ anchor = base ] { #5 } ; + \end { tikzpicture } + } + { + \begin { tikzpicture } + \node + [ + fit = ( #1 - #2 - medium . north~west ) + ( #3 - #4 - medium . south~east ) , + inner~sep = 0 pt , + ] + (#1-#2) { } ; + \node at (#1-#2.center) { #5 } ; + \end { tikzpicture } + } } } -\cs_set_protected:Npn \__nm_renew_matrix: +\cs_set_protected:Npn \__nicematrix_renew_matrix: { \RenewDocumentEnvironment { pmatrix } { } { \pNiceMatrix } @@ -2292,128 +2290,130 @@ { \BNiceMatrix } { \endBNiceMatrix } } -\cs_new_protected:Npn \__nm_set_size:n #1-#2 \q_stop +\cs_new_protected:Npn \__nicematrix_set_size:n #1-#2 \q_stop { - \int_set:Nn \l__nm_nb_rows_int { #1 } - \int_set:Nn \l__nm_nb_cols_int { #2 } + \int_set:Nn \l__nicematrix_nb_rows_int { #1 } + \int_set:Nn \l__nicematrix_nb_cols_int { #2 } } \NewDocumentCommand \AutoNiceMatrixWithDelims { m m O { } m O { } m ! O { } } { - \int_zero_new:N \l__nm_nb_rows_int - \int_zero_new:N \l__nm_nb_cols_int - \__nm_set_size:n #4 \q_stop + \int_zero_new:N \l__nicematrix_nb_rows_int + \int_zero_new:N \l__nicematrix_nb_cols_int + \__nicematrix_set_size:n #4 \q_stop \begin { NiceArrayWithDelims } { #1 } { #2 } - { * { \l__nm_nb_cols_int } { C } } [ #3 , #5 , #7 ] - \int_compare:nNnT \l__nm_first_row_int = \c_zero_int + { * { \l__nicematrix_nb_cols_int } { C } } [ #3 , #5 , #7 ] + \int_compare:nNnT \l__nicematrix_first_row_int = \c_zero_int { - \int_compare:nNnT \l__nm_first_col_int = \c_zero_int { & } - \prg_replicate:nn { \l__nm_nb_cols_int - 1 } { & } - \int_compare:nNnT \l__nm_last_col_int > { -1 } { & } \\ + \int_compare:nNnT \l__nicematrix_first_col_int = \c_zero_int { & } + \prg_replicate:nn { \l__nicematrix_nb_cols_int - 1 } { & } + \int_compare:nNnT \l__nicematrix_last_col_int > { -1 } { & } \\ } - \prg_replicate:nn \l__nm_nb_rows_int + \prg_replicate:nn \l__nicematrix_nb_rows_int { - \int_compare:nNnT \l__nm_first_col_int = \c_zero_int { & } - \prg_replicate:nn { \l__nm_nb_cols_int - 1 } { { } #6 & } #6 - \int_compare:nNnT \l__nm_last_col_int > { -1 } { & } \\ + \int_compare:nNnT \l__nicematrix_first_col_int = \c_zero_int { & } + \prg_replicate:nn { \l__nicematrix_nb_cols_int - 1 } { { } #6 & } #6 + \int_compare:nNnT \l__nicematrix_last_col_int > { -1 } { & } \\ } - \int_compare:nNnT \l__nm_last_row_int > { -2 } + \int_compare:nNnT \l__nicematrix_last_row_int > { -2 } { - \int_compare:nNnT \l__nm_first_col_int = \c_zero_int { & } - \prg_replicate:nn { \l__nm_nb_cols_int - 1 } { & } - \int_compare:nNnT \l__nm_last_col_int > { -1 } { & } \\ + \int_compare:nNnT \l__nicematrix_first_col_int = \c_zero_int { & } + \prg_replicate:nn { \l__nicematrix_nb_cols_int - 1 } { & } + \int_compare:nNnT \l__nicematrix_last_col_int > { -1 } { & } \\ } \end { NiceArrayWithDelims } } -\cs_set_protected:Npn \__nm_define_com:nnn #1 #2 #3 +\cs_set_protected:Npn \__nicematrix_define_com:nnn #1 #2 #3 { \cs_set_protected:cpn { #1 AutoNiceMatrix } { - \str_gset:Nx \g__nm_type_env_str + \str_gset:Nx \g__nicematrix_type_env_str { command ~ \c_backslash_str #1 AutoNiceMatrix } \AutoNiceMatrixWithDelims { #2 } { #3 } } } -\__nm_define_com:nnn p ( ) -\__nm_define_com:nnn b [ ] -\__nm_define_com:nnn v | | -\__nm_define_com:nnn V \| \| -\__nm_define_com:nnn B \{ \} +\__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 \{ \} \keys_define:nn { NiceMatrix / Package } { - renew-dots .bool_set:N = \l__nm_renew_dots_bool , + renew-dots .bool_set:N = \l__nicematrix_renew_dots_bool , renew-dots .value_forbidden:n = true , - renew-matrix .code:n = \__nm_renew_matrix: , + renew-matrix .code:n = \__nicematrix_renew_matrix: , renew-matrix .value_forbidden:n = true , transparent .meta:n = { renew-dots , renew-matrix } , transparent .value_forbidden:n = true, + obsolete-environments .code:n = + \__nicematrix_msg_redirect_name:nn { Obsolete~environment } { none } } \ProcessKeysOptions { NiceMatrix / Package } -\__nm_msg_new:nn { unknown~cell~for~line~in~code-after } +\__nicematrix_msg_new:nn { unknown~cell~for~line~in~code-after } { Your~command~\token_to_str:N\line\{#1\}\{#2\}~in~the~'code-after'~ can't~be~executed~because~a~Tikz~node~doesn't~exist.\\ If~you~go~on~this~command~will~be~ignored. } -\__nm_msg_new:nn { last-col~non~empty~for~NiceArray } +\__nicematrix_msg_new:nn { last-col~non~empty~for~NiceArray } { - In~the~\g__nm_type_env_str,~you~must~use~the~option~ + In~the~\g__nicematrix_type_env_str,~you~must~use~the~option~ 'last-col'~without~value.\\ However,~you~can~go~on~for~this~time~ (the~value~'\l_keys_value_tl'~will~be~ignored). } -\__nm_msg_new:nn { last-col~empty~for~NiceMatrix } +\__nicematrix_msg_new:nn { last-col~empty~for~NiceMatrix } { - In~the~\g__nm_type_env_str, you~can't~use~the~option~ + In~the~\g__nicematrix_type_env_str, you~can't~use~the~option~ 'last-col'~without~value.~You~must~give~the~number~of~that~last~column.\\ If~you~go~on~this~option~will~be~ignored. } -\__nm_msg_new:nn { Block~too~large } +\__nicematrix_msg_new:nn { 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.\\ If~you~go~on,~this~command~will~be~ignored. } -\__nm_msg_new:nn { Impossible~line } +\__nicematrix_msg_new:nn { Impossible~line } { A~dotted~line~can't~be~drawn~because~you~have~not~put~ all~the~ampersands~required~on~the~row~#1.\\ If~you~go~on,~this~dotted~line~will~be~ignored. } -\__nm_msg_new:nn { Wrong~last~row } +\__nicematrix_msg_new:nn { Wrong~last~row } { - You~have~used~'last-row=\int_use:N \l__nm_last_row_int'~but~your~ - \g__nm_type_env_str\ seems~to~have~\int_use:N \c@iRow \ rows.~ + You~have~used~'last-row=\int_use:N \l__nicematrix_last_row_int'~but~your~ + \g__nicematrix_type_env_str\ 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). } -\__nm_msg_new:nn { Yet~in~env } +\__nicematrix_msg_new:nn { Yet~in~env } { Environments~\{NiceArray\}~(or~\{NiceMatrix\},~etc.)~can't~be~nested.\\ This~error~is~fatal. } -\__nm_msg_new:nn { Outside~math~mode } +\__nicematrix_msg_new:nn { Outside~math~mode } { - The~\g__nm_type_env_str\ can~be~used~only~in~math~mode~ + The~\g__nicematrix_type_env_str\ can~be~used~only~in~math~mode~ (and~not~in~\token_to_str:N \vcenter).\\ This~error~is~fatal. } -\__nm_msg_new:nn { Option~Transparent~suppressed } +\__nicematrix_msg_new:nn { Option~Transparent~suppressed } { The~option~'Transparent'~has~been~renamed~'transparent'.\\ However,~you~can~go~on~for~this~time. } -\__nm_msg_new:nn { Option~RenewMatrix~suppressed } +\__nicematrix_msg_new:nn { Option~RenewMatrix~suppressed } { The~option~'RenewMatrix'~has~been~renamed~'renew-matrix'.\\ However,~you~can~go~on~for~this~time. } -\__nm_msg_new:nn { Bad~value~for~letter~for~dotted~lines } +\__nicematrix_msg_new:nn { Bad~value~for~letter~for~dotted~lines } { The~value~of~key~'\tl_use:N\l_keys_key_tl'~must~be~of~length~1.\\ If~you~go~on,~it~will~be~ignored. } -\__nm_msg_new:nnn { Unknown~key~for~NiceMatrixOptions } +\__nicematrix_msg_new:nnn { Unknown~key~for~NiceMatrixOptions } { The~key~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~command~ \token_to_str:N \NiceMatrixOptions. \\ @@ -2439,7 +2439,7 @@ small~ and~transparent } -\__nm_msg_new:nnn { Unknown~option~for~NiceArray } +\__nicematrix_msg_new:nnn { Unknown~option~for~NiceArray } { The~option~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~environment~ \{NiceArray\}. \\ @@ -2473,10 +2473,10 @@ small~ and~t. } -\__nm_msg_new:nnn { Unknown~option~for~NiceMatrix } +\__nicematrix_msg_new:nnn { Unknown~option~for~NiceMatrix } { The~option~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~ - \g__nm_type_env_str. \\ + \g__nicematrix_type_env_str. \\ If~you~go~on,~it~will~be~ignored. \\ For~a~list~of~the~available~options,~type~H~<return>. } @@ -2504,7 +2504,7 @@ right-margin~ and~small. } -\__nm_msg_new:nnn { Duplicate~name } +\__nicematrix_msg_new:nnn { 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,~ @@ -2516,130 +2516,132 @@ } { The~names~already~defined~in~this~document~are:~ - \seq_use:Nnnn \g__nm_names_seq { ,~ } { ,~ } { ~and~ }. + \seq_use:Nnnn \g__nicematrix_names_seq { ,~ } { ,~ } { ~and~ }. } -\__nm_msg_new:nn { Option~auto~for~columns-width } +\__nicematrix_msg_new:nn { Option~auto~for~columns-width } { You~can't~give~the~value~'auto'~to~the~option~'columns-width'~here.~ If~you~go~on,~the~option~will~be~ignored. } -\__nm_msg_new:nn { Zero~row } +\__nicematrix_msg_new:nn { Zero~row } { - There~is~a~problem.~Maybe~your~\g__nm_type_env_str\ is~empty.~ + There~is~a~problem.~Maybe~your~\g__nicematrix_type_env_str\ is~empty.~ Maybe~you~have~used~l,~c~and~r~instead~of~L,~C~and~R~in~the~preamble~ of~your~environment. \\ If~you~go~on,~the~result~may~be~incorrect. } -\__nm_msg_new:nn { Use~of~:~in~first~position } +\__nicematrix_msg_new:nn { Use~of~:~in~first~position } { - You~can't~use~the~column~specifier~'\l__nm_letter_for_dotted_lines_str'~in~the~ - first~position~of~the~preamble~of~the~\g__nm_type_env_str. \\ + You~can't~use~the~column~specifier~'\l__nicematrix_letter_for_dotted_lines_str'~in~the~ + first~position~of~the~preamble~of~the~\g__nicematrix_type_env_str. \\ If~you~go~on,~this~dotted~line~will~be~ignored. } -\__nm_msg_new:nn { Obsolete~environment } +\__nicematrix_msg_new:nn { Obsolete~environment } { - The~environment~\{\@currenvir\}~is~obsolete~and~will~be~deleted~in~future~version.~ - We~should~use~#1~instead. + The~environment~\{\@currenvir\}~is~obsolete.~We~should~use~#1~instead.~ + However,~you~can~go~on~for~this~time.~ + If~you~don't~want~to~see~this~error~again,~you~should~load~'nicematrix'~ + with~the~option~'obsolete-environments'. } \NewDocumentEnvironment { pNiceArrayC } { } { - \msg_info:nnn { nicematrix } { Obsolete~environment } + \__nicematrix_error:nn { Obsolete~environment } { the~option~'last-col' } - \int_set:Nn \l__nm_last_col_int \c_zero_dim + \int_set:Nn \l__nicematrix_last_col_int \c_zero_dim \pNiceArray } { \endpNiceArray } \NewDocumentEnvironment { bNiceArrayC } { } { - \msg_info:nnn { nicematrix } { Obsolete~environment } + \__nicematrix_error:nn { Obsolete~environment } { the~option~'last-col' } - \int_set:Nn \l__nm_last_col_int \c_zero_dim + \int_set:Nn \l__nicematrix_last_col_int \c_zero_dim \bNiceArray } { \endbNiceArray } \NewDocumentEnvironment { BNiceArrayC } { } { - \msg_info:nnn { nicematrix } { Obsolete~environment } + \__nicematrix_error:nn { Obsolete~environment } { the~option~'last-col' } - \int_set:Nn \l__nm_last_col_int \c_zero_dim + \int_set:Nn \l__nicematrix_last_col_int \c_zero_dim \BNiceArray } { \endBNiceArray } \NewDocumentEnvironment { vNiceArrayC } { } { - \msg_info:nnn { nicematrix } { Obsolete~environment } + \__nicematrix_error:nn { Obsolete~environment } { the~option~'last-col' } - \int_set:Nn \l__nm_last_col_int \c_zero_dim + \int_set:Nn \l__nicematrix_last_col_int \c_zero_dim \vNiceArray } { \endvNiceArray } \NewDocumentEnvironment { VNiceArrayC } { } { - \msg_info:nnn { nicematrix } { Obsolete~environment } + \__nicematrix_error:nn { Obsolete~environment } { the~option~'last-col' } - \int_set:Nn \l__nm_last_col_int \c_zero_dim + \int_set:Nn \l__nicematrix_last_col_int \c_zero_dim \VNiceArray } { \endVNiceArray } \NewDocumentEnvironment { pNiceArrayRC } { } { - \msg_info:nnn { nicematrix } { Obsolete~environment } + \__nicematrix_error:nn { Obsolete~environment } { the~options~'last-col'~and~'first-row' } - \int_set:Nn \l__nm_last_col_int \c_zero_dim - \int_set:Nn \l__nm_first_row_int \c_zero_int + \int_set:Nn \l__nicematrix_last_col_int \c_zero_dim + \int_set:Nn \l__nicematrix_first_row_int \c_zero_int \pNiceArray } { \endpNiceArray } \NewDocumentEnvironment { bNiceArrayRC } { } { - \msg_info:nnn { nicematrix } { Obsolete~environment } + \__nicematrix_error:nn { Obsolete~environment } { the~options~'last-col'~and~'first-row' } - \int_set:Nn \l__nm_last_col_int \c_zero_dim - \int_set:Nn \l__nm_first_row_int \c_zero_int + \int_set:Nn \l__nicematrix_last_col_int \c_zero_dim + \int_set:Nn \l__nicematrix_first_row_int \c_zero_int \bNiceArray } { \endbNiceArray } \NewDocumentEnvironment { BNiceArrayRC } { } { - \msg_info:nnn { nicematrix } { Obsolete~environment } + \__nicematrix_error:nn { Obsolete~environment } { the~options~'last-col'~and~'first-row' } - \int_set:Nn \l__nm_last_col_int \c_zero_dim - \int_set:Nn \l__nm_first_row_int \c_zero_int + \int_set:Nn \l__nicematrix_last_col_int \c_zero_dim + \int_set:Nn \l__nicematrix_first_row_int \c_zero_int \BNiceArray } { \endBNiceArray } \NewDocumentEnvironment { vNiceArrayRC } { } { - \msg_info:nnn { nicematrix } { Obsolete~environment } + \__nicematrix_error:nn { Obsolete~environment } { the~options~'last-col'~and~'first-row' } - \bool_set_true:N \l__nm_last_col_bool - \int_set:Nn \l__nm_first_row_int \c_zero_int + \bool_set_true:N \l__nicematrix_last_col_bool + \int_set:Nn \l__nicematrix_first_row_int \c_zero_int \vNiceArray } { \endvNiceArray } \NewDocumentEnvironment { VNiceArrayRC } { } { - \msg_info:nnn { nicematrix } { Obsolete~environment } + \__nicematrix_error:nn { Obsolete~environment } { the~options~'last-col'~and~'first-row' } - \int_set:Nn \l__nm_last_col_int \c_zero_dim - \int_set:Nn \l__nm_first_row_int \c_zero_int + \int_set:Nn \l__nicematrix_last_col_int \c_zero_dim + \int_set:Nn \l__nicematrix_first_row_int \c_zero_int \VNiceArray } { \endVNiceArray } \NewDocumentEnvironment { NiceArrayCwithDelims } { } { - \msg_info:nnn { nicematrix } { Obsolete~environment } + \__nicematrix_error:nn { Obsolete~environment } { the~option~'last-col' } - \int_set:Nn \l__nm_last_col_int \c_zero_dim + \int_set:Nn \l__nicematrix_last_col_int \c_zero_dim \NiceArrayWithDelims } { \endNiceArrayWithDelims } \NewDocumentEnvironment { NiceArrayRCwithDelims } { } { - \msg_info:nnn { nicematrix } { Obsolete~environment } + \__nicematrix_error:nn { Obsolete~environment } { the~options~'last-col'~and~'first-row' } - \int_set:Nn \l__nm_last_col_int \c_zero_dim - \int_set:Nn \l__nm_first_row_int \c_zero_int + \int_set:Nn \l__nicematrix_last_col_int \c_zero_dim + \int_set:Nn \l__nicematrix_first_row_int \c_zero_int \NiceArrayWithDelims } { \endNiceArrayWithDelims } |