diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | 192 |
1 files changed, 105 insertions, 87 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index 20432043d69..86dc6b39765 100644 --- a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty +++ b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty @@ -18,8 +18,8 @@ %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% -\def\myfileversion{2.2} -\def\myfiledate{2019/06/23} +\def\myfileversion{2.2.1} +\def\myfiledate{2019/07/02} \RequirePackage{tikz} \usetikzlibrary{fit} \RequirePackage{expl3}[2019/02/15] @@ -66,7 +66,15 @@ \int_new:N \l__nm_nb_first_row_int \int_set:Nn \l__nm_nb_first_row_int 1 \bool_new:N \l__nm_exterior_column_bool +\bool_new:N \g__nm_exterior_column_found_bool \bool_new:N \l__nm_in_NiceArray_bool +\seq_new:N \c__nm_env_with_preamble_seq +\seq_set_from_clist:Nn \c__nm_env_with_preamble_seq + { + NiceArray , NiceArrayCwithDelims , pNiceArrayC , vNiceArrayC , VNiceArrayC , + bNiceArrayC , BNiceArrayC , NiceArrayRCwithDelims , pNiceArrayRC , + vNiceArrayRC , VNiceArrayRC , bNiceArrayRC , BNiceArrayRC + } \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 @@ -163,7 +171,7 @@ { \__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} , + \__nm_msg_redirect_name:nn { Duplicate~name } { none } , allow-duplicate-names .value_forbidden:n = true , letter-for-dotted-lines .tl_set:N = \l__nm_letter_for_dotted_lines_str , letter-for-dotted-lines .value_required:n = true , @@ -268,8 +276,7 @@ \cs_new_protected:Nn \__nm_Cell: { \int_gincr:N \g__nm_column_int - \int_compare:nNnT \g__nm_column_int = \c_one_int - { \int_gincr:N \g__nm_row_int } + \int_compare:nNnT \g__nm_column_int = 1 { \int_gincr:N \g__nm_row_int } \int_gset:Nn \g__nm_column_total_int { \int_max:nn \g__nm_column_total_int \g__nm_column_int } \hbox_set:Nw \l_tmpa_box $ % $ @@ -446,20 +453,20 @@ \bool_if:NT \l__nm_auto_columns_width_bool { \group_insert_after:N \__nm_write_max_cell_width: - \cs_if_free:cTF { __nm_max_cell_width_ \int_use:N \g__nm_env_int } - { \dim_set:Nn \l__nm_columns_width_dim \c_zero_dim } - { - \dim_set:Nx \l__nm_columns_width_dim - { \use:c { __nm_max_cell_width _ \int_use:N \g__nm_env_int } } - } - \str_if_empty:NF \l__nm_name_str - { - \cs_if_free:cF { __nm_max_cell_width_ \l__nm_name_str } - { - \dim_set:Nx \l__nm_columns_width_dim - { \use:c { __nm_max_cell_width_ \l__nm_name_str } } - } - } + \cs_if_free:cTF { __nm_max_cell_width_ \int_use:N \g__nm_env_int } + { \dim_set:Nn \l__nm_columns_width_dim \c_zero_dim } + { + \dim_set:Nx \l__nm_columns_width_dim + { \use:c { __nm_max_cell_width _ \int_use:N \g__nm_env_int } } + } + \str_if_empty:NF \l__nm_name_str + { + \cs_if_free:cF { __nm_max_cell_width_ \l__nm_name_str } + { + \dim_set:Nx \l__nm_columns_width_dim + { \use:c { __nm_max_cell_width_ \l__nm_name_str } } + } + } } \bool_gset_eq:NN \g__nm_extra_nodes_bool \l__nm_extra_nodes_bool \dim_gset_eq:NN \g__nm_left_margin_dim \l__nm_left_margin_dim @@ -499,18 +506,15 @@ { \skip_horizontal:n { 0.53 pt } \bool_gset_true:N \g__nm_extra_nodes_bool - \int_compare:nNnT \g__nm_row_int = 1 + \int_compare:nNnT \g__nm_column_int > \g__nm_last_vdotted_col_int { - \int_compare:nNnTF \g__nm_column_int = \c_zero_dim - { \__nm_error:n { Use~of~:~in~first~position } } + \int_gset_eq:NN \g__nm_last_vdotted_col_int \g__nm_column_int + \tl_gput_right:Nx \g__nm_code_after_tl { - \tl_gput_right:Nx \g__nm_code_after_tl - { - \exp_not:N \__nm_vdottedline:n - \exp_not:N { - \int_use:N \g__nm_column_int - \exp_not:N } - } + \exp_not:N \__nm_vdottedline:n + \exp_not:N { + \int_use:N \g__nm_column_int + \exp_not:N } } } } @@ -529,6 +533,8 @@ \int_gset:Nn \g__nm_row_int { \l__nm_nb_first_row_int - 1 } \int_gzero_new:N \g__nm_column_int \int_gzero_new:N \g__nm_column_total_int + \int_gzero_new:N \g__nm_last_vdotted_col_int + \int_gset:Nn \g__nm_last_vdotted_col_int { -1 } \cs_set_eq:NN \@ifnextchar \new@ifnextchar \bool_if:NF \l__nm_exterior_arraycolsep_bool { \skip_horizontal:n { - \arraycolsep } } @@ -618,11 +624,24 @@ } \cs_new_protected:Nn \__nm_after_array: { + \int_compare:nNnTF \g__nm_row_int > 0 + \__nm_after_array_i: + { \__nm_error:n { Zero~row } } + } +\__nm_msg_new:nn { Zero~row } + { + There~is~a~problem.~Maybe~your~environment~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. + } +\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_column_int \g__nm_column_total_int - \bool_if:NT \l__nm_exterior_column_bool { \int_gdecr:N \g__nm_column_int } + \bool_if:nT { \l__nm_exterior_column_bool && \g__nm_exterior_column_found_bool } + { \int_gdecr:N \g__nm_column_int } \seq_gclear_new:N \g__nm_yet_drawn_seq \bool_if:NT \l__nm_parallelize_diags_bool { @@ -746,13 +765,13 @@ \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 + \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 + \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 ) @@ -1139,51 +1158,36 @@ \end { tikzpicture } \__nm_draw_tikz_line: } +\cs_generate_variant:Nn \dim_set:Nn { N v } +\cs_set:Npn \__nm_dotfill: + { \cleaders \hbox_to_wd:nn {.44em} {\hss .\hss } \hfill \kern \c_zero_dim } + \cs_new:Nn \__nm_hdottedline: { - \noalign { \skip_vertical:n { 0.53 pt } } - \__nm_hdottedline_i: - } -\cs_new_protected:Nn \__nm_hdottedline_i: - { - \int_compare:nNnTF \g__nm_row_int < 2 - { \__nm_error:n { Use~of~hdottedline~in~first~position } } + \noalign { \bool_gset_true:N \g__nm_extra_nodes_bool - \bool_if:NF \c__nm_draft_bool - { - \tl_gput_right:Nx \g__nm_code_after_tl + \cs_if_exist:cTF { __nm_width_ \int_use:N \g__nm_env_int } + { \dim_set:Nv \l_tmpa_dim { __nm_width_ \int_use:N \g__nm_env_int } } + { \dim_set:Nn \l_tmpa_dim { 5 mm } } + \hbox_overlap_right:n + { \hbox_to_wd:nn { - \exp_not:N \__nm_hdottedline:n - \exp_not:N { - \int_eval:n { \g__nm_row_int - 1 } - \exp_not:N } + \l_tmpa_dim + 2 \arraycolsep + - \l__nm_left_margin_dim - \g__nm_right_margin_dim } + \__nm_dotfill: } } } -\cs_new_protected:Nn \__nm_hdottedline:n +\__nm_msg_new:nn { Use~of~hdottedline~in~first~position } { - \__nm_create_extra_nodes: - \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 - \begin { tikzpicture } [ remember~picture ] - \tikz@parse@node\pgfutil@firstofone - ( #1 - 1 -large .south~west ) - \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 - ( #1 - \int_use:N \g__nm_column_int -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 } - \__nm_draw_tikz_line: + You~can't~use~the~command~\token_to_str:N\hdottedline\ in~the~first~row~ + of~the~environment~\{\@currenvir\}.~But~maybe~you~have~used~l,~c~and~r~ + instead~of~L,~C,~R~in~the~preamble~of~the~array.\\ + If~you~go~on,~this~dotted~line~will~be~ignored. } -\__nm_msg_new:nn { Use~of~hdottedline~in~first~position } +\__nm_msg_new:nn { Use~of~hdottedline~in~first~position~bis } { You~can't~use~the~command~\token_to_str:N\hdottedline\ in~the~first~row~ of~the~environment~\{\@currenvir\}. \\ @@ -1203,34 +1207,30 @@ \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 + \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 } { \begin { tikzpicture } [ remember~picture ] \tikz@parse@node\pgfutil@firstofone ( 1 - #1 - w .north~east ) \dim_gset:Nn \g__nm_x_initial_dim \pgf@x - \dim_gset:Nn \g__nm_y_initial_dim \pgf@y \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 } - { - \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 } - } \__nm_draw_tikz_line: } } @@ -1303,10 +1303,12 @@ \cs_new_protected:Nn \__nm_NiceArrayC:n { \bool_set_true:N \l__nm_exterior_column_bool + \bool_gset_false:N \g__nm_exterior_column_found_bool \begin { NiceArray } { #1 > { + \bool_gset_true:N \g__nm_exterior_column_found_bool \int_gincr:N \g__nm_column_int \int_gset:Nn \g__nm_column_total_int { \int_max:nn \g__nm_column_total_int \g__nm_column_int } @@ -1487,7 +1489,7 @@ \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:nnnNn 1 1 \g__nm_column_total_int \__nm_j + \int_step_variable:nNn \g__nm_column_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 @@ -1510,8 +1512,8 @@ \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 ) + \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 } @@ -1525,7 +1527,7 @@ \tikzset { name~suffix = -medium } \__nm_create_nodes: \int_set:Nn \l__nm_nb_first_row_int 1 - \int_step_variable:nnnNn 1 1 { \g__nm_row_int - 1 } \__nm_i + \int_step_variable:nNn { \g__nm_row_int - 1 } \__nm_i { \dim_set:cn { l__nm_row _ \__nm_i _ min _ dim } { @@ -1538,7 +1540,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:nnnNn 1 1 { \g__nm_column_int - 1 } \__nm_j + \int_step_variable:nNn { \g__nm_column_int - 1 } \__nm_j { \dim_set:cn { l__nm_column _ \__nm_j _ max _ dim } { @@ -1563,6 +1565,22 @@ \__nm_create_nodes: \end{tikzpicture} \cs_set:Nn \__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 \g__nm_column_int - 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: { @@ -1627,7 +1645,7 @@ \cs_new:Npn \__nm_seq_mapthread_function:NNN #1 #2 #3 { \group_begin: - \int_step_inline:nnnn 1 1 { \seq_count:N #1 } + \int_step_inline:nn { \seq_count:N #1 } { \seq_pop:NN #1 \l_tmpa_tl \seq_pop:NN #2 \l_tmpb_tl |