%% %% This is file `nicematrix.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% nicematrix.dtx (with options: `package') %% %% Copyright (C) 2017-2019 by F. Pantigny %% %% This file may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either %% version 1.3 of this license or (at your option) any later %% version. The latest version of this license is in: %% %% http://www.latex-project.org/lppl.txt %% %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% \def\myfileversion{3.6} \def\myfiledate{2019/10/29} \RequirePackage{tikz} \usetikzlibrary{fit} \RequirePackage{expl3}[2019/07/01] \RequirePackage{l3keys2e} \ProvidesExplPackage {nicematrix} {\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 } \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 { \msg_redirect_name:nnn { nicematrix } } \bool_new:N \c__nm_revtex_bool \@ifclassloaded { revtex4-1 } { \bool_set_true:N \c__nm_revtex_bool } { } \@ifclassloaded { revtex4-2 } { \bool_set_true:N \c__nm_revtex_bool } { } \__nm_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 { \msg_warning:nn { nicematrix } { Draft~mode } } \ProvideDocumentCommand \iddots { } { \mathinner { \mkern 1 mu \raise \p@ \hbox:n { . } \mkern 2 mu \raise 4 \p@ \hbox:n { . } \mkern 2 mu \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 \bool_new:N \l__nm_in_env_bool \bool_new:N \l__nm_NiceArray_bool \cs_new_protected:Npn \__nm_test_if_math_mode: { \if_mode_math: \else: \__nm_fatal:n { Outside~math~mode } \fi: } \bool_new:N \l__nm_impossible_line_bool \bool_new:N \c__nm_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 } } } { } } \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 \AtBeginDocument { \@ifpackageloaded { siunitx } { \bool_set_true:N \c__nm_siunitx_loaded_bool } { } } \cs_set_protected:Npn \__nm_adapt_S_column: { \bool_if:NT \c__nm_siunitx_loaded_bool { \group_begin: \@temptokena = { } \cs_set_eq:NN \NC@find \prg_do_nothing: \NC@rewrite@S { } \tl_gset:NV \g_tmpa_tl \@temptokena \group_end: \tl_new:N \c__nm_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: } } \cs_new_protected:Npn \__nm_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} } c < { \c__nm_table_print_tl \__nm_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 \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 , left-margin .default:n = \arraycolsep , right-margin .dim_set:N = \l__nm_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-margin .meta:n = { extra-left-margin = #1 , extra-right-margin = #1 } , } \keys_define:nn { NiceMatrix / Env } { 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 , 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 \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 , last-row .default:n = -1 , } \keys_define:nn { NiceMatrix } { NiceMatrixOptions .inherit:n = { NiceMatrix / Global , } , NiceMatrix .inherit:n = { NiceMatrix / Global , NiceMatrix / Env } , NiceArray .inherit:n = { NiceMatrix / Global , NiceMatrix / Env , } , pNiceArray .inherit:n = { NiceMatrix / Global , NiceMatrix / Env , } } \keys_define:nn { NiceMatrix / NiceMatrixOptions } { renew-matrix .code:n = \__nm_renew_matrix: , renew-matrix .value_forbidden:n = true , RenewMatrix .code:n = \__nm_error:n { Option~RenewMatrix~suppressed } \__nm_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 , 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 } } , allow-duplicate-names .code:n = \__nm_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 } } } , letter-for-dotted-lines .value_required:n = true , unknown .code:n = \__nm_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 \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 } } \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 , 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 } } \keys_define:nn { NiceMatrix / pNiceArray } { first-col .code:n = \int_zero:N \l__nm_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 , last-row .default:n = -1 , unknown .code:n = \__nm_error:n { Unknown~option~for~NiceMatrix } } \cs_new_protected:Nn \__nm_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_gset:Nn \g__nm_col_total_int { \int_max:nn \g__nm_col_total_int \c@jCol } \hbox_set:Nw \l_tmpa_box \c_math_toggle_token \bool_if:NT \l__nm_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@iRow = \l__nm_last_row_int \l__nm_code_for_last_row_tl } } \cs_new_protected:Nn \__nm_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 } \cs_new_protected:Npn \__nm_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 } } } \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__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 } } } \cs_new_protected:Nn \__nm_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: \tikz [ remember~picture , inner~sep = \c_zero_dim , minimum~width = \c_zero_dim , baseline ] \node [ anchor = base , name = nm - \int_use:N \g__nm_env_int - \int_use:N \c@iRow - \int_use:N \c@jCol , alias = \str_if_empty:NF \l__nm_name_str { \l__nm_name_str - \int_use:N \c@iRow - \int_use:N \c@jCol } ] \bgroup \box_use:N \l_tmpa_box \egroup ; } \cs_generate_variant:Nn \dim_set:Nn { N x } \cs_new_protected:Nn \__nm_renewcolumntype:nn { \newcolumntype #1 [ 2 ] { > { \hbox_set:Nw \l_tmpa_box \__nm_Cell: } c < { \__nm_end_Cell: \hbox_set_end: #2 \hbox_set:Nn \l_tmpb_box { \makebox [ ##2 ] [ ##1 ] { \box_use:N \l_tmpa_box } } \dim_set:Nn \l_tmpa_dim { \box_dp:N \l_tmpb_box } \box_move_down:nn \l_tmpa_dim { \vbox:n { \hbox_to_wd:nn { \box_wd:N \l_tmpb_box } { \hfil \tikz [ remember~picture , overlay ] \coordinate (__nm~north~east) ; } \hbox:n { \tikz [ remember~picture , overlay ] \coordinate (__nm~south~west) ; \box_move_up:nn \l_tmpa_dim { \box_use:N \l_tmpb_box } } } } \tikz [ remember~picture , overlay ] \node [ node~contents = { } , name = nm - \int_use:N \g__nm_env_int - \int_use:N \c@iRow - \int_use:N \c@jCol - w, alias = \str_if_empty:NF \l__nm_name_str { \l__nm_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) ] ; } } } \bool_if:NTF \c__nm_draft_bool { \cs_set_protected:Npn \__nm_instruction_of_type:n #1 { } } { \cs_new_protected:Npn \__nm_instruction_of_type:n #1 { \tl_gput_right:cx { g__nm_ #1 _ lines _ tl } { \use:c { __nm _ draw _ #1 : nn } { \int_use:N \c@iRow } { \int_use:N \c@jCol } } } } \cs_new_protected:Npn \__nm_array: { \bool_if:NTF \c__nm_revtex_bool { \cs_set_eq:NN \@acoll \@arrayacol \cs_set_eq:NN \@acolr \@arrayacol \cs_set_eq:NN \@acol \@arrayacol \cs_set:Npn \@halignto { } \@array@array } \array [ \l__nm_pos_env_str ] } \cs_new:Npn \__nm_everycr: { \noalign { \__nm_everycr_i: } } \cs_new_protected:Npn \__nm_everycr_i: { \int_gzero:N \c@jCol \bool_if:NT \l__nm_hlines_bool { \int_compare:nNnT \c@iRow > { -1 } { \int_compare:nNnF \c@iRow = \l__nm_last_row_int { \hrule \@height \arrayrulewidth \skip_vertical:n { - \arrayrulewidth } } } } } \cs_new_protected:Npn \__nm_pre_array: { \cs_if_exist:NT \theiRow { \int_set_eq:NN \l__nm_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_gzero_new:N \c@jCol \normalbaselines \bool_if:NT \l__nm_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 \cs_set:Npn \ialign { \bool_if:NTF \c__nm_colortbl_loaded_bool { \CT@everycr { \noalign { \cs_gset_eq:NN \CT@row@color \prg_do_nothing: } \__nm_everycr: } } { \everycr { \__nm_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 } \cs_set:Npn \ialign { \everycr { } \tabskip = \c_zero_skip \halign } \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 \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 } \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 { ! { \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 } { \bool_gset_true:N \g__nm_extra_nodes_bool } \int_compare:nNnT \c@jCol > \g__nm_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_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 } \NewDocumentEnvironment { NiceArrayWithDelims } { m m O { } m ! O { } } { \str_if_empty:NT \g__nm_type_env_str { \str_gset:Nn \g__nm_type_env_str { 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 \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 { \keys_set:nn { NiceMatrix / NiceArray } } { \keys_set:nn { NiceMatrix / pNiceArray } } { #3 , #5 } \int_compare:nNnT \l__nm_last_row_int = { -1 } { \bool_set_true:N \l__nm_last_row_without_value_bool \str_if_empty:NTF \l__nm_name_str { \cs_if_exist:cT { __nm_last_row_ \int_use:N \g__nm_env_int } { \int_set:Nn \l__nm_last_row_int { \use:c { __nm_last_row_ \int_use:N \g__nm_env_int } } } } { \cs_if_exist:cT { __nm_last_row_ \l__nm_name_str } { \int_set:Nn \l__nm_last_row_int { \use:c { __nm_last_row_ \l__nm_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 { \dim_gset:Nn \g__nm_left_delim_dim { 2 \arraycolsep } \dim_gset:Nn \g__nm_right_delim_dim { 2 \arraycolsep } } { \group_begin: \dim_set_eq:NN \nulldelimiterspace \c_zero_dim \hbox_set:Nn \l_tmpa_box { \c_math_toggle_token \left #1 \vcenter to 3 cm { } \right. \c_math_toggle_token } \dim_gset:Nn \g__nm_left_delim_dim { \box_wd:N \l_tmpa_box } \hbox_set:Nn \l_tmpa_box { \dim_set_eq:NN \nulldelimiterspace \c_zero_dim \c_math_toggle_token \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 } \group_end: } \box_clear_new:N \l__nm_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 } { \bool_if:NT \l__nm_NiceArray_bool { \bool_if:NF \l__nm_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 } { \bool_if:NT \l__nm_NiceArray_bool { \bool_if:NF \l__nm_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 \c_math_toggle_token \exp_args:NV \__nm_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 } { \crcr \int_compare:nNnT \l__nm_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 ] ; \skip_horizontal:n { - \arraycolsep } \bool_if:nTF { \l__nm_auto_columns_width_bool && ! \l__nm_block_auto_columns_width_bool } { \dim_gset:Nn \g_tmpa_dim { \g__nm_max_cell_width_dim + 2 \arraycolsep } } { \dim_gset:Nn \g_tmpa_dim { \l__nm_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 ] ; \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 } } { & \omit \int_gincr:N \g_tmpa_int \skip_horizontal:N \g_tmpa_dim \tikz [ remember~picture , overlay ] \coordinate [ name = nm - \int_use:N \g__nm_env_int - col - \int_use:N \g_tmpa_int ] ; } & \omit \int_gincr:N \g_tmpa_int \skip_horizontal:N \g_tmpa_dim \skip_horizontal:n { - \arraycolsep } \tikz [ remember~picture , overlay ] \coordinate [ name = nm - \int_use:N \g__nm_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 \hbox_set_end: \int_compare:nNnT \l__nm_last_row_int > { -2 } { \bool_if:NF \l__nm_last_row_without_value_bool { \int_compare:nNnF \l__nm_last_row_int = \c@iRow { \__nm_error:n { Wrong~last~row } \int_gset_eq:NN \l__nm_last_row_int \c@iRow } } } \int_compare:nNnTF \l__nm_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 } } { \dim_zero:N \l_tmpa_dim } \int_compare:nNnTF \l__nm_last_row_int > { -2 } { \dim_set:Nn \l_tmpb_dim { \g__nm_ht_last_row_dim + \lineskip + \g__nm_dp_last_row_dim } } { \dim_zero:N \l_tmpb_dim } \int_compare:nNnT \l__nm_first_col_int = \c_zero_int { \skip_horizontal:n \arraycolsep \skip_horizontal:n \g__nm_width_first_col_dim } \bool_if:NTF \l__nm_NiceArray_bool { \int_compare:nNnT \l__nm_first_row_int = \c_zero_int { \str_if_eq:VnTF \l__nm_pos_env_str { t } { \box_move_up:nn { \l_tmpa_dim - \g__nm_ht_row_zero_dim + \g__nm_ht_row_one_dim } } } { \int_compare:nNnT \l__nm_last_row_int > 0 { \str_if_eq:VnT \l__nm_pos_env_str { b } { \box_move_down:nn { \l_tmpb_dim - \g__nm_dp_last_row_dim + \g__nm_dp_ante_last_row_dim } } } } { \box_use_drop:N \l__nm_the_array_box } } { \hbox_set:Nn \l_tmpa_box { \c_math_toggle_token \left #1 \vcenter { \skip_vertical:n { - \l_tmpa_dim } \hbox:n { \skip_horizontal:n { - \arraycolsep } \box_use_drop:N \l__nm_the_array_box \skip_horizontal:n { - \arraycolsep } } \skip_vertical:n { - \l_tmpb_dim } } \right #2 \c_math_toggle_token } \box_set_ht:Nn \l_tmpa_box { \box_ht:N \l_tmpa_box + \l_tmpa_dim } \box_set_dp:Nn \l_tmpa_box { \box_dp:N \l_tmpa_box + \l_tmpb_dim } \box_use_drop:N \l_tmpa_box } \bool_if:NT \g__nm_last_col_found_bool { \skip_horizontal:n \g__nm_width_last_col_dim \skip_horizontal:n \arraycolsep } \__nm_after_array: } \tl_const:Nn \c__nm_preamble_first_col_tl { > { \__nm_begin_of_row: \hbox_set:Nw \l_tmpa_box \c_math_toggle_token \bool_if:NT \l__nm_small_bool \scriptstyle \int_compare:nNnT \c@iRow > \c_zero_int \l__nm_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 { \dim_max:nn \g__nm_width_first_col_dim { \box_wd:N \l_tmpa_box } } \hbox_overlap_left:n { \tikz [ remember~picture , inner~sep = \c_zero_dim , minimum~width = \c_zero_dim , baseline ] \node [ anchor = base , name = nm - \int_use:N \g__nm_env_int - \int_use:N \c@iRow - 0 , alias = \str_if_empty:NF \l__nm_name_str { \l__nm_name_str - \int_use:N \c@iRow - 0 } ] { \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 } } \skip_horizontal:n { - 2 \arraycolsep } } } \tl_const:Nn \c__nm_preamble_last_col_tl { > { \bool_gset_true:N \g__nm_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 } \hbox_set:Nw \l_tmpa_box \c_math_toggle_token \bool_if:NT \l__nm_small_bool \scriptstyle \l__nm_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 { \dim_max:nn \g__nm_width_last_col_dim { \box_wd:N \l_tmpa_box } } \skip_horizontal:n { - 2 \arraycolsep } \hbox_overlap_right:n { \skip_horizontal:n { \g__nm_right_delim_dim + \l__nm_right_margin_dim + \l__nm_extra_right_margin_dim } \tikz [ remember~picture , inner~sep = \c_zero_dim , minimum~width = \c_zero_dim , baseline ] \node [ anchor = base , name = nm - \int_use:N \g__nm_env_int - \int_use:N \c@iRow - \int_use:N \c@jCol , alias = \str_if_empty:NF \l__nm_name_str { \l__nm_name_str - \int_use:N \c@iRow - \int_use:N \c@jCol } ] { \box_use:N \l_tmpa_box } ; } } } \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 { NiceArray } } \NiceArrayWithDelims . . } { \endNiceArrayWithDelims } \NewDocumentEnvironment { pNiceArray } { } { \str_if_empty:NT \g__nm_type_env_str { \str_gset:Nn \g__nm_type_env_str { pNiceArray } } \__nm_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 { NiceArray } } \__nm_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 { BNiceArray } } \__nm_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 { vNiceArray } } \__nm_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 { VNiceArray } } \__nm_test_if_math_mode: \NiceArrayWithDelims \| \| } { \endNiceArrayWithDelims } \cs_new_protected:Npn \__nm_define_env:n #1 { \NewDocumentEnvironment { #1 NiceMatrix } { ! O { } } { \str_gset:Nn \g__nm_type_env_str { #1 NiceMatrix } \keys_set:nn { NiceMatrix / NiceMatrix } { ##1 } \begin { #1 NiceArray } { * { \int_compare:nNnTF \l__nm_last_col_int = { -1 } \c@MaxMatrixCols { \int_eval:n { \l__nm_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 } { \bool_set_false:N \l_tmpa_bool \cs_if_exist:cTF { __nm _ 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 #1 - \int_use:N #2 } { \prg_return_false: } { \bool_set_false:N \l_tmpa_bool \cs_if_exist:cT { __nm _ empty _ \int_use:N #1 - \int_use:N #2 } { \int_compare:nNnT { \use:c { __nm _ empty _ \int_use:N #1 - \int_use:N #2 } } = \g__nm_env_int { \bool_set_true:N \l_tmpa_bool } } \bool_if:NTF \l_tmpa_bool \prg_return_false: { \begin { pgfpicture } \tl_set:Nx \l_tmpa_tl { nm - \int_use:N \g__nm_env_int - \int_use:N #1 - \int_use:N #2 } \pgfpointanchor \l_tmpa_tl { east } \dim_gset:Nn \g_tmpa_dim \pgf@x \pgfpointanchor \l_tmpa_tl { west } \dim_gset:Nn \g_tmpb_dim \pgf@x \end { pgfpicture } \dim_compare:nNnTF { \dim_abs:n { \g_tmpb_dim - \g_tmpa_dim } } < { 0.5 pt } \prg_return_false: \prg_return_true: } } } } \cs_new_protected:Nn \__nm_after_array: { \int_compare:nNnTF \c@iRow > \c_zero_int \__nm_after_array_i: { \__nm_error:n { Zero~row } \__nm_restore_iRow_jCol: } } \cs_new_protected:Nn \__nm_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_gsub:Nn \c@iRow \c_one_int } \bool_if:NT \l__nm_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 } } \str_if_empty:NF \l__nm_name_str { \iow_now:Nx \@mainaux { \cs_gset:cpn { __nm_last_row_ \l__nm_name_str } { \int_use:N \g__nm_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 \tikzset { every~picture / .style = { overlay , remember~picture , name~prefix = nm - \int_use:N \g__nm_env_int - } } \cs_set_eq:NN \line \__nm_line:nn \g__nm_code_after_tl \tl_gclear:N \g__nm_code_after_tl \group_end: \str_gclear:N \g__nm_type_env_str \__nm_restore_iRow_jCol: } \cs_new_protected:Nn \__nm_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_new_protected:Nn \__nm_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 { \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_compare:nNnT { #3 } = 1 { \bool_set_true:N \l__nm_final_open_bool } } { \int_compare:nNnTF \l__nm_final_j_int < 1 { \int_compare:nNnT { #4 } = { -1 } { \bool_set_true:N \l__nm_final_open_bool } } { \int_compare:nNnT \l__nm_final_j_int > \c@jCol { \int_compare:nNnT { #4 } = 1 { \bool_set_true:N \l__nm_final_open_bool } } } } \bool_if:NTF \l__nm_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 } { \__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 } { \cs_set:cpn { __nm _ dotted _ \int_use:N \l__nm_final_i_int - \int_use:N \l__nm_final_j_int } { } } } } \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 } { \bool_if:NF \l__nm_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 } } \bool_set_false:N \l__nm_stop_loop_bool \bool_do_until:Nn \l__nm_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_compare:nNnT { #3 } = 1 { \bool_set_true:N \l__nm_initial_open_bool } } { \int_compare:nNnTF \l__nm_initial_j_int < 1 { \int_compare:nNnT { #4 } = 1 { \bool_set_true:N \l__nm_initial_open_bool } } { \int_compare:nNnT \l__nm_initial_j_int > \c@jCol { \int_compare:nNnT { #4 } = { -1 } { \bool_set_true:N \l__nm_initial_open_bool } } } } \bool_if:NTF \l__nm_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 } { \__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 } { \cs_set:cpn { __nm _ dotted _ \int_use:N \l__nm_initial_i_int - \int_use:N \l__nm_initial_j_int } { } } } } \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 } { \bool_if:NF \l__nm_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 } } \bool_if:nT \l__nm_initial_open_bool \__nm_create_extra_nodes: \bool_if:NT \l__nm_final_open_bool \__nm_create_extra_nodes: } \cs_new_protected:Nn \__nm_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 \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 \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 \end { tikzpicture } } \cs_generate_variant:Nn \__nm_retrieve_coords:nn { x x } \cs_new_protected:Nn \__nm_adjust_with_col_nodes: { \bool_if:NT \l__nm_initial_open_bool { \cs_if_exist:cT { pgf@sh@ns@nm - \int_use:N \g__nm_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 \end { tikzpicture } } } \bool_if:NT \l__nm_final_open_bool { \cs_if_exist:cT { pgf@sh@ns@nm - \int_use:N \g__nm_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 \end { tikzpicture } } } } \cs_new_protected:Nn \__nm_draw_Ldots:nn { \cs_if_free:cT { __nm _ 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: } } \cs_new_protected:Nn \__nm_actually_draw_Ldots: { \__nm_retrieve_coords:xx { \bool_if:NTF \l__nm_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 } { - w.base~west } { - medium.base~west } } { .base~east } } { \bool_if:NTF \l__nm_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 } { - 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: } \cs_new_protected:Nn \__nm_draw_Cdots:nn { \cs_if_free:cT { __nm _ 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_retrieve_coords:xx { \bool_if:NTF \l__nm_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 } { - w.mid~west } { - medium.mid~west } } { .mid~east } } { \bool_if:NTF \l__nm_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 } { - 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: } } } \cs_new_protected:Nn \__nm_draw_Vdots:nn { \cs_if_free:cT { __nm _ 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 { \__nm_retrieve_coords:xx { \bool_if:NTF \l__nm_initial_open_bool { - medium.north~west } { .south~west } } { \bool_if:NTF \l__nm_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 { \bool_if:NTF \l__nm_initial_open_bool { - medium.north } { .south } } { \bool_if:NTF \l__nm_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 } \bool_if:NF \l_tmpb_bool { \dim_gset:Nn \g__nm_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 } \dim_gset_eq:NN \g__nm_x_final_dim \g__nm_x_initial_dim } \__nm_draw_tikz_line: } } } \cs_new_protected:Nn \__nm_draw_Ddots:nn { \cs_if_free:cT { __nm _ 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 { \__nm_retrieve_coords:xx { \bool_if:NTF \l__nm_initial_open_bool { - medium.north~west } { .south~east } } { \bool_if:NTF \l__nm_final_open_bool { - medium.south~east } { .north~west } } \bool_if:NT \l__nm_parallelize_diags_bool { \int_incr:N \l__nm_ddots_int \int_compare:nNnTF \l__nm_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_gset:Nn \g__nm_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 } } } \__nm_draw_tikz_line: } } } \cs_new_protected:Nn \__nm_draw_Iddots:nn { \cs_if_free:cT { __nm _ 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 { \__nm_retrieve_coords:xx { \bool_if:NTF \l__nm_initial_open_bool { - medium.north~east } { .south~west } } { \bool_if:NTF \l__nm_final_open_bool { - medium.south~west } { .north~east } } \bool_if:NT \l__nm_parallelize_diags_bool { \int_incr:N \l__nm_iddots_int \int_compare:nNnTF \l__nm_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_gset:Nn \g__nm_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 } } } \__nm_draw_tikz_line: } } } \cs_new_protected:Nn \__nm_draw_tikz_line: { \dim_zero_new:N \l__nm_l_dim \dim_set:Nn \l__nm_l_dim { \fp_to_dim:n { sqrt ( ( \dim_use:N \g__nm_x_final_dim - \dim_use:N \g__nm_x_initial_dim ) ^ 2 + ( \dim_use:N \g__nm_y_final_dim - \dim_use:N \g__nm_y_initial_dim ) ^ 2 ) } } \dim_compare:nNnF \l__nm_l_dim = \c_zero_dim { \bool_if:NTF \l__nm_initial_open_bool { \bool_if:NTF \l__nm_final_open_bool { \int_set:Nn \l_tmpa_int { \dim_ratio:nn \l__nm_l_dim \l__nm_inter_dots_dim } } { \int_set:Nn \l_tmpa_int { \dim_ratio:nn { \l__nm_l_dim - 0.3 em } \l__nm_inter_dots_dim } } } { \bool_if:NTF \l__nm_final_open_bool { \int_set:Nn \l_tmpa_int { \dim_ratio:nn { \l__nm_l_dim - 0.3 em } \l__nm_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_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 } \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 } \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 } } \dim_gadd:Nn \g__nm_x_initial_dim { ( \g__nm_x_final_dim - \g__nm_x_initial_dim ) * \dim_ratio:nn { \l__nm_l_dim - \l__nm_inter_dots_dim * \l_tmpa_int } { \l__nm_l_dim * 2 } * \l_tmpb_int } \dim_gadd:Nn \g__nm_y_initial_dim { ( \g__nm_y_final_dim - \g__nm_y_initial_dim ) * \dim_ratio:nn { \l__nm_l_dim - \l__nm_inter_dots_dim * \l_tmpa_int } { \l__nm_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 } \pgfusepath { fill } \dim_gadd:Nn \g__nm_x_initial_dim \l_tmpa_dim \dim_gadd:Nn \g__nm_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_gset:cpx { __nm _ empty _ \int_use:N \c@iRow - \int_use:N \c@jCol } { \int_use:N \g__nm_env_int } } \NewDocumentCommand \__nm_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: } \NewDocumentCommand \__nm_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: } \NewDocumentCommand \__nm_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: } \NewDocumentCommand \__nm_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: } \NewDocumentCommand \__nm_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: } \cs_new_protected:Nn \__nm_Hspace: { \__nm_add_to_empty_cells: \hspace } \cs_set_eq:NN \__nm_old_multicolumn \multicolumn \cs_new:Npn \__nm_multicolumn:nnn #1 #2 #3 { \__nm_old_multicolumn { #1 } { #2 } { #3 } \int_compare:nNnT #1 > 1 { \seq_gput_left:Nx \g__nm_multicolumn_cells_seq { \int_eval:n \c@iRow - \int_use:N \c@jCol } \seq_gput_left:Nn \g__nm_multicolumn_sizes_seq { #1 } } \int_gadd:Nn \c@jCol { #1 - 1 } } \cs_new:Npn \__nm_Hdotsfor: { \multicolumn { 1 } { C } { } \__nm_Hdotsfor_i } \bool_if:NTF \c__nm_draft_bool { \NewDocumentCommand \__nm_Hdotsfor_i { O { } m } { \prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { C } { } } } } { \NewDocumentCommand \__nm_Hdotsfor_i { O { } m } { \tl_gput_right:Nx \g__nm_Hdotsfor_lines_tl { \__nm_draw_Hdotsfor:nnn { \int_use:N \c@iRow } { \int_use:N \c@jCol } { #2 } } \prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { C } { } } } } \cs_new_protected:Nn \__nm_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 } \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_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 } } { \int_set:Nn \l__nm_initial_j_int {#2} \bool_set_true:N \l__nm_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_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 } } { \int_set:Nn \l__nm_final_j_int { #2 + #3 - 1 } \bool_set_true:N \l__nm_final_open_bool } } \bool_if:nT { \l__nm_initial_open_bool || \l__nm_final_open_bool } \__nm_create_extra_nodes: \__nm_actually_draw_Ldots: \int_step_inline:nnn { #2 } { #2 + #3 - 1 } { \cs_set:cpn { __nm _ dotted _ #1 - ##1 } { } } } \cs_new_protected:Nn \__nm_line:nn { \bool_if:NF \c__nm_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 \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__nm_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 \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 \end { tikzpicture } \__nm_draw_tikz_line: } { \__nm_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: } { \cs_set:Npn \__nm_dotfill: { \bool_if:NT \l__nm_small_bool { \dim_set:Nn \l__nm_inter_dots_dim { 0.25 em } } \cleaders \hbox_to_wd:nn { \l__nm_inter_dots_dim } { \c_math_toggle_token \bool_if:NT \l__nm_small_bool \scriptstyle \hss . \hss \c_math_toggle_token } \hfill } } \cs_new:Npn \__nm_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 } } { \dim_set:Nn \l_tmpa_dim { 5 mm } } \hbox_overlap_right:n { \bool_if:nT { \l__nm_NiceArray_bool && ! \l__nm_exterior_arraycolsep_bool && \int_compare_p:nNn \l__nm_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 } \__nm_dotfill: } } } \cs_new_protected:Nn \__nm_vdottedline:n { \int_compare:nNnTF #1 = \c_zero_int { \__nm_error:n { Use~of~:~in~first~position } } { \bool_if:NF \c__nm_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 \cs_if_exist:cTF { pgf@sh@ns@nm -\int_use:N \g__nm_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 \end { tikzpicture } \dim_gset:Nn \g__nm_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 } \end { tikzpicture } } } { \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 \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 \end { tikzpicture } \cs_if_exist:cT { pgf@sh@ns@nm -\int_use:N \g__nm_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 \tikz@parse@node\pgfutil@firstofone ( \int_use:N \c@iRow - #1 - w .south~east ) \dim_gset:Nn \g__nm_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 } } \__nm_draw_tikz_line: } } } \cs_new_protected:Npn \__nm_vline: { \int_compare:nNnTF \l__nm_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:nNnF \c@iRow = \c_zero_int { \int_compare:nNnF \c@iRow = \l__nm_last_row_int \__nm_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 = \c_zero_int { \int_compare:nNnF \c@iRow = \l__nm_last_row_int \__nm_vline_i: } } } { \int_compare:nNnTF \c@jCol = \c_zero_int { \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 = \c_zero_int { \int_compare:nNnF \c@iRow = \l__nm_last_row_int \__nm_vline_i: } } } } \cs_set_eq:NN \__nm_vline_i: \vline \bool_new:N \l__nm_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 } } \NewDocumentEnvironment { NiceMatrixBlock } { ! O { } } { \int_gincr:N \g__nm_NiceMatrixBlock_int \dim_zero:N \l__nm_columns_width_dim \keys_set:nn { NiceMatrix / NiceMatrixBlock } { #1 } \bool_if:NT \l__nm_block_auto_columns_width_bool { \cs_if_exist:cT { __nm_max_cell_width_ \int_use:N \g__nm_NiceMatrixBlock_int } { \dim_set:Nx \l__nm_columns_width_dim { \use:c { __nm_max_cell_width _ \int_use:N \g__nm_NiceMatrixBlock_int } } } } } { \bool_if:NT \l__nm_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 } } \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: { \begin { tikzpicture } [ remember~picture , overlay ] \int_step_variable:nnNn \l__nm_first_row_int \g__nm_row_total_int \__nm_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 } } \int_step_variable:nnNn \l__nm_first_col_int \g__nm_col_total_int \__nm_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 } } \int_step_variable:nnNn \l__nm_first_row_int \g__nm_row_total_int \__nm_i: { \int_step_variable:nnNn \l__nm_first_col_int \g__nm_col_total_int \__nm_j: { \cs_if_exist:cT { pgf@sh@ns@nm - \int_use:N \g__nm_env_int - \__nm_i: - \__nm_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: } { \dim_set:cn { l__nm_column _ \__nm_j: _min_dim} { \dim_min:vn { l__nm_column _ \__nm_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: } { \dim_set:cn { l__nm_column _ \__nm_j: _ max_dim } { \dim_max:vn { l__nm_column _ \__nm_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: { \dim_set:cn { l__nm_row _ \__nm_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 } ) / 2 } \dim_set_eq:cc { l__nm_row _ \int_eval:n { \__nm_i: + 1 } _ max _ dim } { l__nm_row_\__nm_i: _min_dim } } \int_step_variable:nNn { \c@jCol - 1 } \__nm_j: { \dim_set:cn { l__nm_column _ \__nm_j: _ max _ dim } { ( \dim_use:c { l__nm_column _ \__nm_j: _ max _ dim } + \dim_use:c { l__nm_column _ \int_eval:n { \__nm_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_sub:cn { l__nm_column _ 1 _ min _ dim } \l__nm_left_margin_dim \dim_add:cn { l__nm_column _ \int_use:N \c@jCol _ max _ dim } \l__nm_right_margin_dim \tikzset { name~suffix = -large } \__nm_create_nodes: \end{tikzpicture} \cs_set:Npn \__nm_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 ) \dim_gset:Nn \g_tmpa_dim \pgf@x \tikz@parse@node \pgfutil@firstofone ( nm - \int_use:N \g__nm_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 } { \dim_eval:n { \g_tmpb_dim - \g_tmpa_dim } } } \iow_now:Nn \@mainaux \ExplSyntaxOff } \cs_new_protected:Nn \__nm_create_nodes: { \int_step_variable:nnNn \l__nm_first_row_int \g__nm_row_total_int \__nm_i: { \int_step_variable:nnNn \l__nm_first_col_int \g__nm_col_total_int \__nm_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 } ) ; \node [ node~contents = { } , fit = ( __nm~south~west ) ( __nm~north~east ) , inner~sep = \c_zero_dim , name = nm - \int_use:N \g__nm_env_int - \__nm_i: - \__nm_j: , alias = \str_if_empty:NF \l__nm_name_str { \l__nm_name_str - \__nm_i: - \__nm_j: } ] ; } } \seq_mapthread_function:NNN \g__nm_multicolumn_cells_seq \g__nm_multicolumn_sizes_seq \__nm_node_for_multicolumn:nn } \cs_new_protected:Npn \__nm_extract_coords: #1 - #2 \q_stop { \cs_set:Npn \__nm_i: { #1 } \cs_set:Npn \__nm_j: { #2 } } \cs_new_protected:Nn \__nm_node_for_multicolumn:nn { \__nm_extract_coords: #1 \q_stop \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 _ \int_eval:n { \__nm_j: + #2 - 1 } _ max _ dim} , \dim_use:c { l__nm_row _ \__nm_i: _ max _ dim } ) ; \node [ node~contents = { } , fit = ( __nm~south~west ) ( __nm~north~east ) , inner~sep = \c_zero_dim , name = nm - \int_use:N \g__nm_env_int - \__nm_i: - \__nm_j: , alias = \str_if_empty:NF \l__nm_name_str { \l__nm_name_str - \__nm_i: - \__nm_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 { \int_compare:nNnTF { #1 } = 1 { \multicolumn { #2 } { C } { \hbox:n { #3 $#4$ } } \__nm_gobble_ampersands:n { #2 - 1 } } { \__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 { \__nm_Block_iv:nnnnn { \int_use:N \c@iRow } { \int_use:N \c@jCol } { \int_eval:n { \c@iRow + #1 - 1 } } { \int_eval:n { \c@jCol + #2 - 1 } } \exp_not:n { { #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 { \bool_if:nTF { \int_compare_p:nNn { #3 } > \c@iRow || \int_compare_p:nNn { #4 } > \c@jCol } { \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} } } \cs_set_protected:Npn \__nm_renew_matrix: { \RenewDocumentEnvironment { pmatrix } { } { \pNiceMatrix } { \endpNiceMatrix } \RenewDocumentEnvironment { vmatrix } { } { \vNiceMatrix } { \endvNiceMatrix } \RenewDocumentEnvironment { Vmatrix } { } { \VNiceMatrix } { \endVNiceMatrix } \RenewDocumentEnvironment { bmatrix } { } { \bNiceMatrix } { \endbNiceMatrix } \RenewDocumentEnvironment { Bmatrix } { } { \BNiceMatrix } { \endBNiceMatrix } } \keys_define:nn { NiceMatrix / Package } { renew-dots .bool_set:N = \l__nm_renew_dots_bool , renew-dots .value_forbidden:n = true , renew-matrix .code:n = \__nm_renew_matrix: , renew-matrix .value_forbidden:n = true , transparent .meta:n = { renew-dots , renew-matrix } , transparent .value_forbidden:n = true, } \ProcessKeysOptions { NiceMatrix / Package } \__nm_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 } { In~the~environment~\{\g__nm_type_env_str\},~you~must~use~the~option~ 'last-col'~without~value~(the~number~of~columns~is~known~by~the~ preamble~of~the~environment).\\ 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 } { In~the~environment~\{\g__nm_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 } { 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~line~will~be~ignored. } \__nm_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 } { You~have~used~'last-row=\int_use:N \l__nm_last_row_int'~but~your~environment~ \{\g__nm_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 } { Environments~\{NiceArray\}~(or~\{NiceMatrix\},~etc.)~can't~be~nested.\\ This~error~is~fatal. } \__nm_msg_new:nn { Outside~math~mode } { The~environment~\{\g__nm_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 } { The~option~'Transparent'~has~been~renamed~'transparent'.\\ However,~you~can~go~on~for~this~time. } \__nm_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 } { 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 } { The~key~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~command~ \token_to_str:N \NiceMatrixOptions. \\ If~you~go~on,~it~will~be~ignored. \\ For~a~list~of~the~available~keys,~type~H~. } { The~available~options~are~(in~alphabetic~order):~ allow-duplicate-names,~ code-for-first-col,~ code-for-first-row,~ code-for-last-col,~ code-for-last-row,~ exterior-arraycolsep,~ hlines,~ left-margin,~ letter-for-dotted-lines,~ nullify-dots,~ parallelize-diags,~ renew-dots,~ renew-matrix,~ right-margin,~ small~ and~transparent } \__nm_msg_new:nnn { Unknown~option~for~NiceArray } { The~option~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~environment~ \{NiceArray\}. \\ If~you~go~on,~it~will~be~ignored. \\ For~a~list~of~the~available~options,~type~H~. } { The~available~options~are~(in~alphabetic~order):~ b,~ c,~ code-after,~ code-for-first-col,~ code-for-first-row,~ code-for-last-col,~ code-for-last-row,~ columns-width,~ create-extra-nodes,~ extra-left-margin,~ extra-right-margin,~ first-col,~ first-row,~ hlines,~ last-col,~ last-row,~ left-margin,~ name,~ nullify-dots,~ parallelize-diags,~ renew-dots,~ right-margin,~ small~ and~t. } \__nm_msg_new:nnn { Unknown~option~for~NiceMatrix } { The~option~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~environment~ \{\g__nm_type_env_str\}. \\ If~you~go~on,~it~will~be~ignored. \\ For~a~list~of~the~available~options,~type~H~. } { The~available~options~are~(in~alphabetic~order):~ code-after,~ code-for-first-col,~ code-for-first-row,~ code-for-last-col,~ code-for-last-row,~ columns-width,~ create-extra-nodes,~ extra-left-margin,~ extra-right-margin,~ first-col,~ first-row,~ hlines,~ last-col,~ last-row,~ left-margin,~ name,~ nullify-dots,~ parallelize-diags,~ renew-dots,~ right-margin~ and~small. } \__nm_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,~ maybe,~you~will~have~incorrect~results~especially~ if~you~use~'columns-width=auto'.~If~you~use~nicematrix~inside~some~ environments~of~amsmath,~this~error~may~be~an~artefact.~In~this~case,~ use~the~option~'allow-duplicate-names'.\\ For~a~list~of~the~names~already~used,~type~H~. \\ } { The~names~already~defined~in~this~document~are:~ \seq_use:Nnnn \g__nm_names_seq { ,~ } { ,~ } { ~and~ }. } \__nm_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 } { There~is~a~problem.~Maybe~your~environment~\{\g__nm_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 } { You~can't~use~the~column~specifier~'\l__nm_letter_for_dotted_lines_str'~in~the~ first~position~of~the~preamble~of~the~environment~\{\g__nm_type_env_str\}. \\ If~you~go~on,~this~dotted~line~will~be~ignored. } \__nm_msg_new:nn { Obsolete~environment } { The~environment~\{\@currenvir\}~is~obsolete.~ We~should~use~#1~instead. } \NewDocumentEnvironment { pNiceArrayC } { } { \msg_info:nnn { nicematrix } { Obsolete~environment } { the~option~'last-col' } \int_set:Nn \l__nm_last_col_int \c_zero_dim \pNiceArray } { \endpNiceArray } \NewDocumentEnvironment { bNiceArrayC } { } { \msg_info:nnn { nicematrix } { Obsolete~environment } { the~option~'last-col' } \int_set:Nn \l__nm_last_col_int \c_zero_dim \bNiceArray } { \endbNiceArray } \NewDocumentEnvironment { BNiceArrayC } { } { \msg_info:nnn { nicematrix } { Obsolete~environment } { the~option~'last-col' } \int_set:Nn \l__nm_last_col_int \c_zero_dim \BNiceArray } { \endBNiceArray } \NewDocumentEnvironment { vNiceArrayC } { } { \msg_info:nnn { nicematrix } { Obsolete~environment } { the~option~'last-col' } \int_set:Nn \l__nm_last_col_int \c_zero_dim \vNiceArray } { \endvNiceArray } \NewDocumentEnvironment { VNiceArrayC } { } { \msg_info:nnn { nicematrix } { Obsolete~environment } { the~option~'last-col' } \int_set:Nn \l__nm_last_col_int \c_zero_dim \VNiceArray } { \endVNiceArray } \NewDocumentEnvironment { pNiceArrayRC } { } { \msg_info:nnn { nicematrix } { 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 \pNiceArray } { \endpNiceArray } \NewDocumentEnvironment { bNiceArrayRC } { } { \msg_info:nnn { nicematrix } { 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 \bNiceArray } { \endbNiceArray } \NewDocumentEnvironment { BNiceArrayRC } { } { \msg_info:nnn { nicematrix } { 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 \BNiceArray } { \endBNiceArray } \NewDocumentEnvironment { vNiceArrayRC } { } { \msg_info:nnn { nicematrix } { 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 \vNiceArray } { \endvNiceArray } \NewDocumentEnvironment { VNiceArrayRC } { } { \msg_info:nnn { nicematrix } { 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 \VNiceArray } { \endVNiceArray } \NewDocumentEnvironment { NiceArrayCwithDelims } { } { \msg_info:nnn { nicematrix } { Obsolete~environment } { the~option~'last-col' } \int_set:Nn \l__nm_last_col_int \c_zero_dim \NiceArrayWithDelims } { \endNiceArrayWithDelims } \NewDocumentEnvironment { NiceArrayRCwithDelims } { } { \msg_info:nnn { nicematrix } { 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 \NiceArrayWithDelims } { \endNiceArrayWithDelims } \endinput %% %% End of file `nicematrix.sty'.