From 3b3b42b1273d6ac4e7182964334a2487c05fee64 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 29 Oct 2019 21:24:28 +0000 Subject: nicematrix (29oct19) git-svn-id: svn://tug.org/texlive/trunk@52573 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/latex/nicematrix/nicematrix.sty | 424 +++++++++++++-------- 1 file changed, 269 insertions(+), 155 deletions(-) (limited to 'Master/texmf-dist/tex') diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index 8365b0e24c7..7c650dca5aa 100644 --- a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty +++ b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty @@ -18,11 +18,11 @@ %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% -\def\myfileversion{3.5} -\def\myfiledate{2019/10/13} +\def\myfileversion{3.6} +\def\myfiledate{2019/10/29} \RequirePackage{tikz} \usetikzlibrary{fit} -\RequirePackage{expl3}[2019/02/15] +\RequirePackage{expl3}[2019/07/01] \RequirePackage{l3keys2e} \ProvidesExplPackage {nicematrix} @@ -35,7 +35,7 @@ \ProcessOptions \relax \RequirePackage { array } \RequirePackage { amsmath } -\RequirePackage { xparse } [ 2018-10-17 ] +\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 } } @@ -52,6 +52,8 @@ \@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 { } @@ -96,6 +98,8 @@ \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 @@ -198,11 +202,13 @@ { \dim_set:Nn \l__nm_columns_width_dim { #1 } } , columns-width .value_required:n = true , name .code:n = - \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 , + \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 , @@ -295,41 +301,41 @@ } \cs_new_protected:Nn \__nm_Cell: { - \int_gincr:N \g__nm_col_int - \int_compare:nNnT \g__nm_col_int = \c_one_int + \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 \g__nm_col_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 \g__nm_row_int = \c_zero_int - \l__nm_code_for_first_row_tl + \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 \g__nm_row_int = \l__nm_last_row_int + \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 \g__nm_row_int + \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 \g__nm_row_int = \c_zero_int + \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 \g__nm_row_int = \c_one_int + \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 } } @@ -357,14 +363,14 @@ [ anchor = base , name = nm - \int_use:N \g__nm_env_int - - \int_use:N \g__nm_row_int - - \int_use:N \g__nm_col_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 \g__nm_row_int - - \int_use:N \g__nm_col_int + \int_use:N \c@iRow - + \int_use:N \c@jCol } ] \bgroup @@ -411,14 +417,14 @@ [ node~contents = { } , name = nm - \int_use:N \g__nm_env_int - - \int_use:N \g__nm_row_int - - \int_use:N \g__nm_col_int - w, + \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 \g__nm_row_int - - \int_use:N \g__nm_col_int - w + \int_use:N \c@iRow - + \int_use:N \c@jCol - w } , inner~sep = \c_zero_dim , fit = (__nm~south~west) (__nm~north~east) @@ -436,8 +442,8 @@ { g__nm_ #1 _ lines _ tl } { \use:c { __nm _ draw _ #1 : nn } - { \int_use:N \g__nm_row_int } - { \int_use:N \g__nm_col_int } + { \int_use:N \c@iRow } + { \int_use:N \c@jCol } } } } @@ -458,12 +464,12 @@ { \noalign { \__nm_everycr_i: } } \cs_new_protected:Npn \__nm_everycr_i: { - \int_gzero:N \g__nm_col_int + \int_gzero:N \c@jCol \bool_if:NT \l__nm_hlines_bool { - \int_compare:nNnT \g__nm_row_int > { -1 } + \int_compare:nNnT \c@iRow > { -1 } { - \int_compare:nNnF \g__nm_row_int = \l__nm_last_row_int + \int_compare:nNnF \c@iRow = \l__nm_last_row_int { \hrule \@height \arrayrulewidth \skip_vertical:n { - \arrayrulewidth } @@ -473,6 +479,13 @@ } \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 } @@ -536,10 +549,8 @@ } \seq_gclear_new:N \g__nm_multicolumn_cells_seq \seq_gclear_new:N \g__nm_multicolumn_sizes_seq - \int_gzero_new:N \g__nm_row_int - \int_gset:Nn \g__nm_row_int { \l__nm_first_row_int - 1 } + \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_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 @@ -553,12 +564,17 @@ ! { \skip_horizontal:n { 0.53 pt } - \bool_gset_true:N \g__nm_extra_nodes_bool - \int_compare:nNnT \g__nm_col_int > \g__nm_last_vdotted_col_int + \bool_if:nF { - \int_gset_eq:NN \g__nm_last_vdotted_col_int \g__nm_col_int + \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 \g__nm_col_int } } + { \__nm_vdottedline:n { \int_use:N \c@jCol } } } } } @@ -672,15 +688,17 @@ { \bool_if:nT { - ( \l__nm_auto_columns_width_bool && ! \l__nm_block_auto_columns_width_bool) + \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 @@ -693,12 +711,14 @@ { \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 } } - { \prg_replicate:nn { \g__nm_col_total_int - 1 } } { & \omit @@ -711,6 +731,18 @@ 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 @@ -721,31 +753,23 @@ { \bool_if:NF \l__nm_last_row_without_value_bool { - \int_compare:nNnF \l__nm_last_row_int = \g__nm_row_int + \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 \g__nm_row_int + \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_ht_row_one_dim + \g__nm_dp_row_zero_dim - + \lineskip - + \g__nm_ht_row_zero_dim - \g__nm_ht_row_one_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 + \g__nm_dp_ante_last_row_dim - + \lineskip - + \g__nm_dp_last_row_dim - \g__nm_dp_ante_last_row_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 @@ -816,7 +840,7 @@ \hbox_set:Nw \l_tmpa_box \c_math_toggle_token \bool_if:NT \l__nm_small_bool \scriptstyle - \l__nm_code_for_first_col_tl + \int_compare:nNnT \c@iRow > \c_zero_int \l__nm_code_for_first_col_tl } l < @@ -845,13 +869,13 @@ name = nm - \int_use:N \g__nm_env_int - - \int_use:N \g__nm_row_int - + \int_use:N \c@iRow - 0 , alias = \str_if_empty:NF \l__nm_name_str { \l__nm_name_str - - \int_use:N \g__nm_row_int - + \int_use:N \c@iRow - 0 } ] @@ -871,9 +895,9 @@ > { \bool_gset_true:N \g__nm_last_col_found_bool - \int_gincr:N \g__nm_col_int + \int_gincr:N \c@jCol \int_gset:Nn \g__nm_col_total_int - { \int_max:nn \g__nm_col_total_int \g__nm_col_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 @@ -913,14 +937,14 @@ name = nm - \int_use:N \g__nm_env_int - - \int_use:N \g__nm_row_int - - \int_use:N \g__nm_col_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 \g__nm_row_int - - \int_use:N \g__nm_col_int + \int_use:N \c@iRow - + \int_use:N \c@jCol } ] { \box_use:N \l_tmpa_box } ; @@ -1052,20 +1076,23 @@ } \cs_new_protected:Nn \__nm_after_array: { - \int_compare:nNnTF \g__nm_row_int > \c_zero_int + \int_compare:nNnTF \c@iRow > \c_zero_int \__nm_after_array_i: - { \__nm_error:n { Zero~row } } + { + \__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 \g__nm_col_int \g__nm_col_total_int - \bool_if:nT \g__nm_last_col_found_bool { \int_gdecr:N \g__nm_col_int } - \int_gset_eq:NN \g__nm_row_total_int \g__nm_row_int + \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 \g__nm_row_int \c_one_int } + { \int_gsub:Nn \c@iRow \c_one_int } \bool_if:NT \l__nm_last_row_without_value_bool { \iow_now:Nn \@mainaux \ExplSyntaxOn @@ -1114,17 +1141,23 @@ \tikzset { every~picture / .style = - { - overlay , - remember~picture , - name~prefix = nm - \int_use:N \g__nm_env_int - - } + { + 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 { @@ -1139,7 +1172,7 @@ \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 > \g__nm_row_int + \int_compare:nNnTF \l__nm_final_i_int > \c@iRow { \int_compare:nNnT { #3 } = 1 { \bool_set_true:N \l__nm_final_open_bool } @@ -1151,7 +1184,7 @@ { \bool_set_true:N \l__nm_final_open_bool } } { - \int_compare:nNnT \l__nm_final_j_int > \g__nm_col_int + \int_compare:nNnT \l__nm_final_j_int > \c@jCol { \int_compare:nNnT { #4 } = 1 { \bool_set_true:N \l__nm_final_open_bool } @@ -1211,7 +1244,7 @@ { \bool_set_true:N \l__nm_initial_open_bool } } { - \int_compare:nNnT \l__nm_initial_j_int > \g__nm_col_int + \int_compare:nNnT \l__nm_initial_j_int > \c@jCol { \int_compare:nNnT { #4 } = { -1 } { \bool_set_true:N \l__nm_initial_open_bool } @@ -1279,6 +1312,39 @@ \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 } @@ -1321,6 +1387,7 @@ } { .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 @@ -1368,6 +1435,7 @@ } { .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 @@ -1584,7 +1652,7 @@ \l_tmpb_int } \begin { tikzpicture } [ overlay ] - \int_step_inline:nnnn 0 1 \l_tmpa_int + \int_step_inline:nnn 0 \l_tmpa_int { \pgfpathcircle { \pgfpoint { \g__nm_x_initial_dim } { \g__nm_y_initial_dim } } @@ -1604,7 +1672,7 @@ \cs_new_protected:Nn \__nm_add_to_empty_cells: { \cs_gset:cpx - { __nm _ empty _ \int_use:N \g__nm_row_int - \int_use:N \g__nm_col_int } + { __nm _ empty _ \int_use:N \c@iRow - \int_use:N \c@jCol } { \int_use:N \g__nm_env_int } } \NewDocumentCommand \__nm_Ldots { s } @@ -1649,10 +1717,10 @@ \int_compare:nNnT #1 > 1 { \seq_gput_left:Nx \g__nm_multicolumn_cells_seq - { \int_eval:n \g__nm_row_int - \int_use:N \g__nm_col_int } + { \int_eval:n \c@iRow - \int_use:N \c@jCol } \seq_gput_left:Nn \g__nm_multicolumn_sizes_seq { #1 } } - \int_gadd:Nn \g__nm_col_int { #1 - 1 } + \int_gadd:Nn \c@jCol { #1 - 1 } } \cs_new:Npn \__nm_Hdotsfor: { @@ -1670,8 +1738,8 @@ \tl_gput_right:Nx \g__nm_Hdotsfor_lines_tl { \__nm_draw_Hdotsfor:nnn - { \int_use:N \g__nm_row_int } - { \int_use:N \g__nm_col_int } + { \int_use:N \c@iRow } + { \int_use:N \c@jCol } { #2 } } \prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { C } { } } @@ -1697,7 +1765,7 @@ \bool_set_true:N \l__nm_initial_open_bool } } - \int_compare:nNnTF { #2 + #3 -1 } = \g__nm_col_int + \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 @@ -1719,31 +1787,37 @@ } \cs_new_protected:Nn \__nm_line:nn { - \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 + \bool_if:NF \c__nm_draft_bool { - \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: + \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 } + } } - { \__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: } @@ -1797,7 +1871,6 @@ \int_compare:nNnTF #1 = \c_zero_int { \__nm_error:n { Use~of~:~in~first~position } } { - \__nm_create_extra_nodes: \bool_if:NF \c__nm_draft_bool { \dim_zero_new:N \g__nm_x_initial_dim @@ -1806,39 +1879,52 @@ \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 - \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 \g__nm_row_int - #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 } + \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 - ( 1 - #1 - w .north~east ) + ( col - #1 ) \dim_gset:Nn \g__nm_x_initial_dim \pgf@x - \tikz@parse@node\pgfutil@firstofone - ( \int_use:N \g__nm_row_int - #1 - w .south~east ) \dim_gset:Nn \g__nm_x_final_dim \pgf@x + \dim_gset:Nn \g__nm_y_final_dim \pgf@y \end { tikzpicture } - \dim_gadd:Nn \g__nm_x_initial_dim \arraycolsep - \dim_gadd:Nn \g__nm_x_final_dim \arraycolsep + \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 } + } } - \cs_if_exist:cT - { pgf@sh@ns@nm -\int_use:N \g__nm_env_int - col - #1 } { \begin { tikzpicture } [ remember~picture ] \tikz@parse@node\pgfutil@firstofone - ( col - #1 ) + ( 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: } @@ -1848,45 +1934,45 @@ { \int_compare:nNnTF \l__nm_first_col_int = \c_zero_int { - \int_compare:nNnTF \g__nm_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 \g__nm_row_int = \c_zero_int + \int_compare:nNnF \c@iRow = \c_zero_int { - \int_compare:nNnF \g__nm_row_int = \l__nm_last_row_int + \int_compare:nNnF \c@iRow = \l__nm_last_row_int \__nm_vline_i: } } { - \int_compare:nNnF \g__nm_row_int = \c_zero_int + \int_compare:nNnF \c@iRow = \c_zero_int { - \int_compare:nNnF \g__nm_row_int = \l__nm_last_row_int + \int_compare:nNnF \c@iRow = \l__nm_last_row_int \__nm_vline_i: } } } { - \int_compare:nNnF \g__nm_row_int = \c_zero_int + \int_compare:nNnF \c@iRow = \c_zero_int { - \int_compare:nNnF \g__nm_row_int = \l__nm_last_row_int + \int_compare:nNnF \c@iRow = \l__nm_last_row_int \__nm_vline_i: } } } { - \int_compare:nNnTF \g__nm_col_int = \c_zero_int + \int_compare:nNnTF \c@jCol = \c_zero_int { - \int_compare:nNnF \g__nm_row_int = { -1 } + \int_compare:nNnF \c@iRow = { -1 } { - \int_compare:nNnF \g__nm_row_int = { \l__nm_last_row_int - 1 } + \int_compare:nNnF \c@iRow = { \l__nm_last_row_int - 1 } \__nm_vline_i: } } { - \int_compare:nNnF \g__nm_row_int = \c_zero_int + \int_compare:nNnF \c@iRow = \c_zero_int { - \int_compare:nNnF \g__nm_row_int = \l__nm_last_row_int + \int_compare:nNnF \c@iRow = \l__nm_last_row_int \__nm_vline_i: } } @@ -1982,7 +2068,7 @@ \__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 { \g__nm_row_int - 1 } \__nm_i: + \int_step_variable:nNn { \c@iRow - 1 } \__nm_i: { \dim_set:cn { l__nm_row _ \__nm_i: _ min _ dim } { @@ -1995,7 +2081,7 @@ \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 { \g__nm_col_int - 1 } \__nm_j: + \int_step_variable:nNn { \c@jCol - 1 } \__nm_j: { \dim_set:cn { l__nm_column _ \__nm_j: _ max _ dim } { @@ -2014,7 +2100,7 @@ { l__nm_column _ 1 _ min _ dim } \l__nm_left_margin_dim \dim_add:cn - { l__nm_column _ \int_use:N \g__nm_col_int _ max _ dim } + { l__nm_column _ \int_use:N \c@jCol _ max _ dim } \l__nm_right_margin_dim \tikzset { name~suffix = -large } \__nm_create_nodes: @@ -2026,7 +2112,7 @@ \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 \g__nm_col_int - large .north~east ) + \int_use:N \c@jCol - large .north~east ) \dim_gset:Nn \g_tmpb_dim \pgf@x \end { tikzpicture } \iow_now:Nn \@mainaux \ExplSyntaxOn @@ -2092,7 +2178,8 @@ 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: } + \str_if_empty:NF \l__nm_name_str + { \l__nm_name_str - \__nm_i: - \__nm_j: } ] ; } @@ -2119,10 +2206,10 @@ \tl_gput_left:Nx \g__nm_code_after_tl { \__nm_Block_iv:nnnnn - { \int_use:N \g__nm_row_int } - { \int_use:N \g__nm_col_int } - { \int_eval:n { \g__nm_row_int + #1 - 1 } } - { \int_eval:n { \g__nm_col_int + #2 - 1 } } + { \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 $ } } } } @@ -2141,8 +2228,8 @@ { \bool_if:nTF { - \int_compare_p:nNn { #3 } > \g__nm_row_int - || \int_compare_p:nNn { #4 } > \g__nm_col_int + \int_compare_p:nNn { #3 } > \c@iRow + || \int_compare_p:nNn { #4 } > \c@jCol } { \msg_error:nnnn { nicematrix } { Block~too~large } { #1 } { #2 } } { @@ -2221,13 +2308,11 @@ \__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 \g__nm_row_int\ - rows.~If~you~go~on,~the~value~of~\int_use:N \g__nm_row_int\ + \{\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 { Draft~mode } - { The~compilation~is~in~draft~mode:~the~dotted~lines~won't~be~drawn. } \__nm_msg_new:nn { Yet~in~env } { Environments~\{NiceArray\}~(or~\{NiceMatrix\},~etc.)~can't~be~nested.\\ @@ -2351,7 +2436,7 @@ 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, + 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~. \\ } @@ -2377,38 +2462,55 @@ 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 @@ -2416,6 +2518,8 @@ { \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 @@ -2423,6 +2527,8 @@ { \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 @@ -2430,6 +2536,8 @@ { \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 @@ -2437,6 +2545,8 @@ { \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 @@ -2444,12 +2554,16 @@ { \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 -- cgit v1.2.3