diff options
author | Karl Berry <karl@freefriends.org> | 2020-03-23 22:23:38 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-03-23 22:23:38 +0000 |
commit | 884bf8a42f14a3b61b189b3fae38645e299e4456 (patch) | |
tree | 2bf65749d52c5296d281813fb35fec5ce58d256f /Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | |
parent | 39ed40a659b0e72555fff665123a5c3c3b11cb3b (diff) |
nicematrix (23mar20)
git-svn-id: svn://tug.org/texlive/trunk@54509 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | 474 |
1 files changed, 262 insertions, 212 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index a3b169cfa85..eb8221367fb 100644 --- a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty +++ b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty @@ -18,8 +18,8 @@ %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% -\def\myfileversion{3.13} -\def\myfiledate{2020/03/15} +\def\myfileversion{3.14} +\def\myfiledate{2020/03/23} \RequirePackage{pgfcore} \usepgfmodule{shapes} \RequirePackage{expl3}[2020/02/08] @@ -160,8 +160,9 @@ \int_new:N \l__nicematrix_last_row_int \int_set:Nn \l__nicematrix_last_row_int { -2 } \bool_new:N \l__nicematrix_last_row_without_value_bool +\bool_new:N \l__nicematrix_last_col_without_value_bool \int_new:N \l__nicematrix_last_col_int -\int_set:Nn \l__nicematrix_last_col_int { -1 } +\int_set:Nn \l__nicematrix_last_col_int { -2 } \bool_new:N \g__nicematrix_last_col_found_bool \bool_new:N \c__nicematrix_siunitx_loaded_bool \AtBeginDocument @@ -202,7 +203,57 @@ \NC@find } } -\cs_new:Npn \__nicematrix_succ:N #1 { \the \numexpr #1 + 1 \relax } +\cs_new:Npn \__nicematrix_succ:n #1 { \the \numexpr #1 + 1 \relax } +\cs_new:Npn \__nicematrix_pred:n #1 { \the \numexpr #1 - 1 \relax } +\cs_new_protected:Npn \__nicematrix_pgf_rect_node:nnnnn #1 #2 #3 #4 #5 + { + \begin { pgfscope } + \pgfset + { + outer~sep = \c_zero_dim , + inner~sep = \c_zero_dim , + minimum~size = \c_zero_dim + } + \pgftransformshift { \pgfpoint { 0.5 * ( #2 + #4 ) } { 0.5 * ( #3 + #5 ) } } + \pgfnode + { rectangle } + { center } + { + \vbox_to_ht:nn + { \dim_abs:n { #5 - #3 } } + { + \vfill + \hbox_to_wd:nn { \dim_abs:n { #4 - #2 } } { } + } + } + { #1 } + { } + \end { pgfscope } + } +\cs_new_protected:Npn \__nicematrix_pgf_rect_node:nnn #1 #2 #3 + { + \begin { pgfscope } + \pgfset + { + outer~sep = \c_zero_dim , + inner~sep = \c_zero_dim , + minimum~size = \c_zero_dim + } + \pgftransformshift { \pgfpointscale { 0.5 } { \pgfpointadd { #2 } { #3 } } } + \pgfpointdiff { #3 } { #2 } + \pgfgetlastxy \l_tmpa_dim \l_tmpb_dim + \pgfnode + { rectangle } + { center } + { + \vbox_to_ht:nn + { \dim_abs:n \l_tmpb_dim } + { \vfill \hbox_to_wd:nn { \dim_abs:n \l_tmpa_dim } { } } + } + { #1 } + { } + \end { pgfscope } + } \bool_new:N \l__nicematrix_light_syntax_bool \str_new:N \l__nicematrix_baseline_str \str_set:Nn \l__nicematrix_baseline_str c @@ -363,7 +414,10 @@ \keys_define:nn { NiceMatrix / NiceMatrix } { last-col .code:n = \tl_if_empty:nTF {#1} - { \__nicematrix_error:n { last-col~empty~for~NiceMatrix } } + { + \bool_set_true:N \l__nicematrix_last_col_without_value_bool + \int_set:Nn \l__nicematrix_last_col_int { -1 } + } { \int_set:Nn \l__nicematrix_last_col_int { #1 } } , l .code:n = \tl_set:Nn \l__nicematrix_type_of_col_tl L , r .code:n = \tl_set:Nn \l__nicematrix_type_of_col_tl R , @@ -535,7 +589,7 @@ { \pgfpicture \pgfrememberpicturepositiononpagetrue - \pgfcoordinate { \__nicematrix_env: - row - \__nicematrix_succ:N \c@iRow } + \pgfcoordinate { \__nicematrix_env: - row - \__nicematrix_succ:n \c@iRow } \pgfpointorigin \str_if_empty:NF \l__nicematrix_name_str { @@ -755,6 +809,24 @@ } } } + \int_compare:nNnT \l__nicematrix_last_col_int = { -1 } + { + \str_if_empty:NTF \l__nicematrix_name_str + { + \cs_if_exist:cT { __nicematrix_last_col_ \int_use:N \g__nicematrix_env_int } + { + \int_set:Nn \l__nicematrix_last_col_int + { \use:c { __nicematrix_last_col_ \int_use:N \g__nicematrix_env_int } } + } + } + { + \cs_if_exist:cT { __nicematrix_last_col_ \l__nicematrix_name_str } + { + \int_set:Nn \l__nicematrix_last_col_int + { \use:c { __nicematrix_last_col_ \l__nicematrix_name_str } } + } + } + } \__nicematrix_pre_array: \dim_zero_new:N \l__nicematrix_left_delim_dim \dim_zero_new:N \l__nicematrix_right_delim_dim @@ -983,6 +1055,13 @@ \NewDocumentEnvironment { __nicematrix-light-syntax } { b } { \tl_if_empty:nT { #1 } { \__nicematrix_fatal:n { empty~environment } } + \tl_map_inline:nn { #1 } + { + \tl_if_eq:nnT { ##1 } { & } + { \__nicematrix_fatal:n { ampersand~in~light-syntax } } + \tl_if_eq:nnT { ##1 } { \\ } + { \__nicematrix_fatal:n { double-backslash~in~light-syntax } } + } \seq_gclear_new:N \g__nicematrix_rows_seq \tl_set_rescan:Nno \l__nicematrix_end_of_row_tl { } \l__nicematrix_end_of_row_tl \exp_args:NNV \seq_gset_split:Nnn \g__nicematrix_rows_seq \l__nicematrix_end_of_row_tl { #1 } @@ -1061,13 +1140,13 @@ \skip_horizontal:N \g_tmpa_skip \pgfpicture \pgfrememberpicturepositiononpagetrue - \pgfcoordinate { \__nicematrix_env: - col - \__nicematrix_succ:N \g_tmpa_int } + \pgfcoordinate { \__nicematrix_env: - col - \__nicematrix_succ:n \g_tmpa_int } \pgfpointorigin \str_if_empty:NF \l__nicematrix_name_str { \pgfnodealias - { \__nicematrix_env: - col - \__nicematrix_succ:N \g_tmpa_int } - { \l__nicematrix_name_str - col - \__nicematrix_succ:N \g_tmpa_int } + { \__nicematrix_env: - col - \__nicematrix_succ:n \g_tmpa_int } + { \l__nicematrix_name_str - col - \__nicematrix_succ:n \g_tmpa_int } } \endpgfpicture } @@ -1119,8 +1198,7 @@ { \bool_gset_true:N \g__nicematrix_last_col_found_bool \int_gincr:N \c@jCol - \int_gset:Nn \g__nicematrix_col_total_int - { \int_max:nn \g__nicematrix_col_total_int \c@jCol } + \int_gset_eq:NN \g__nicematrix_col_total_int \c@jCol \hbox_set:Nw \l__nicematrix_cell_box \c_math_toggle_token \bool_if:NT \l__nicematrix_small_bool \scriptstyle @@ -1221,9 +1299,9 @@ { * { - \int_compare:nNnTF \l__nicematrix_last_col_int = { -1 } + \int_compare:nNnTF \l__nicematrix_last_col_int < 0 \c@MaxMatrixCols - { \int_eval:n { \l__nicematrix_last_col_int - 1 } } + { \__nicematrix_pred:n \l__nicematrix_last_col_int } } #2 } @@ -1237,29 +1315,48 @@ \cs_new_protected:Npn \__nicematrix_after_array: { \group_begin: - \int_compare:nNnT \l__nicematrix_last_col_int = 0 + \bool_if:NT \g__nicematrix_last_col_found_bool + { \int_set_eq:NN \l__nicematrix_last_col_int \g__nicematrix_col_total_int } + \bool_if:NT \l__nicematrix_last_col_without_value_bool { - \bool_if:NT \g__nicematrix_last_col_found_bool - { \dim_set_eq:NN \l__nicematrix_last_col_int \g__nicematrix_col_total_int } + \dim_set_eq:NN \l__nicematrix_last_col_int \g__nicematrix_col_total_int + \iow_shipout:Nn \@mainaux \ExplSyntaxOn + \iow_shipout:Nx \@mainaux + { + \cs_gset:cpn { __nicematrix_last_col_ \int_use:N \g__nicematrix_env_int } + { \int_use:N \g__nicematrix_col_total_int } + } + \str_if_empty:NF \l__nicematrix_name_str + { + \iow_shipout:Nx \@mainaux + { + \cs_gset:cpn { __nicematrix_last_col_ \l__nicematrix_name_str } + { \int_use:N \g__nicematrix_col_total_int } + } + } + \iow_shipout:Nn \@mainaux \ExplSyntaxOff } \bool_if:NT \l__nicematrix_last_row_without_value_bool { \dim_set_eq:NN \l__nicematrix_last_row_int \g__nicematrix_row_total_int - \iow_now:Nn \@mainaux \ExplSyntaxOn - \iow_now:Nx \@mainaux - { - \cs_gset:cpn { __nicematrix_last_row_ \int_use:N \g__nicematrix_env_int } - { \int_use:N \g__nicematrix_row_total_int } - } - \str_if_empty:NF \l__nicematrix_name_str + \bool_if:NF \l__nicematrix_light_syntax_bool { - \iow_now:Nx \@mainaux + \iow_shipout:Nn \@mainaux \ExplSyntaxOn + \iow_shipout:Nx \@mainaux { - \cs_gset:cpn { __nicematrix_last_row_ \l__nicematrix_name_str } + \cs_gset:cpn { __nicematrix_last_row_ \int_use:N \g__nicematrix_env_int } { \int_use:N \g__nicematrix_row_total_int } } + \str_if_empty:NF \l__nicematrix_name_str + { + \iow_shipout:Nx \@mainaux + { + \cs_gset:cpn { __nicematrix_last_row_ \l__nicematrix_name_str } + { \int_use:N \g__nicematrix_row_total_int } + } + } + \iow_shipout:Nn \@mainaux \ExplSyntaxOff } - \iow_now:Nn \@mainaux \ExplSyntaxOff } \bool_if:NT \l__nicematrix_parallelize_diags_bool { @@ -1528,7 +1625,7 @@ { \__nicematrix_set_initial_coords_from_anchor:n { base~east } } \bool_if:NTF \l__nicematrix_final_open_bool { - \__nicematrix_qpoint: { col - \__nicematrix_succ:N \l__nicematrix_final_j_int } + \__nicematrix_qpoint: { col - \__nicematrix_succ:n \l__nicematrix_final_j_int } \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x \dim_sub:Nn \l__nicematrix_x_final_dim \arraycolsep \__nicematrix_qpoint: { row - \int_use:N \l__nicematrix_final_i_int - base } @@ -1568,7 +1665,7 @@ { \__nicematrix_set_initial_coords_from_anchor:n { mid~east } } \bool_if:NTF \l__nicematrix_final_open_bool { - \__nicematrix_qpoint: { col - \__nicematrix_succ:N \l__nicematrix_final_j_int } + \__nicematrix_qpoint: { col - \__nicematrix_succ:n \l__nicematrix_final_j_int } \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x \dim_sub:Nn \l__nicematrix_x_final_dim \arraycolsep } @@ -1579,7 +1676,7 @@ { \__nicematrix_qpoint: { row - \int_use:N \l__nicematrix_initial_i_int } \dim_set_eq:NN \l_tmpa_dim \pgf@y - \__nicematrix_qpoint: { row - \__nicematrix_succ:N \l__nicematrix_initial_i_int } + \__nicematrix_qpoint: { row - \__nicematrix_succ:n \l__nicematrix_initial_i_int } \dim_set:Nn \l__nicematrix_y_initial_dim { ( \l_tmpa_dim + \pgf@y ) / 2 } \dim_set_eq:NN \l__nicematrix_y_final_dim \l__nicematrix_y_initial_dim } @@ -1627,7 +1724,7 @@ { \__nicematrix_set_initial_coords_from_anchor:n { south } } \bool_if:NTF \l__nicematrix_final_open_bool { - \__nicematrix_qpoint: { row - \__nicematrix_succ:N \c@iRow } + \__nicematrix_qpoint: { row - \__nicematrix_succ:n \c@iRow } \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y } { \__nicematrix_set_final_coords_from_anchor:n { north } } @@ -1637,7 +1734,7 @@ { \__nicematrix_qpoint: { col - \int_use:N \l__nicematrix_initial_j_int } \dim_set_eq:NN \l_tmpa_dim \pgf@x - \__nicematrix_qpoint: { col - \__nicematrix_succ:N \l__nicematrix_initial_j_int } + \__nicematrix_qpoint: { col - \__nicematrix_succ:n \l__nicematrix_initial_j_int } \dim_set:Nn \l__nicematrix_x_initial_dim { ( \pgf@x + \l_tmpa_dim ) / 2 } \dim_set_eq:NN \l__nicematrix_x_final_dim \l__nicematrix_x_initial_dim } @@ -1684,9 +1781,9 @@ { \__nicematrix_set_initial_coords_from_anchor:n { south~east } } \bool_if:NTF \l__nicematrix_final_open_bool { - \__nicematrix_qpoint: { row - \__nicematrix_succ:N \l__nicematrix_final_i_int } + \__nicematrix_qpoint: { row - \__nicematrix_succ:n \l__nicematrix_final_i_int } \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y - \__nicematrix_qpoint: { col - \__nicematrix_succ:N \l__nicematrix_final_j_int } + \__nicematrix_qpoint: { col - \__nicematrix_succ:n \l__nicematrix_final_j_int } \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x } { \__nicematrix_set_final_coords_from_anchor:n { north~west } } @@ -1729,13 +1826,13 @@ { \__nicematrix_qpoint: { row - \int_use:N \l__nicematrix_initial_i_int } \dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y - \__nicematrix_qpoint: { col - \__nicematrix_succ:N \l__nicematrix_initial_j_int } + \__nicematrix_qpoint: { col - \__nicematrix_succ:n \l__nicematrix_initial_j_int } \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x } { \__nicematrix_set_initial_coords_from_anchor:n { south~west } } \bool_if:NTF \l__nicematrix_final_open_bool { - \__nicematrix_qpoint: { row - \__nicematrix_succ:N \l__nicematrix_final_i_int } + \__nicematrix_qpoint: { row - \__nicematrix_succ:n \l__nicematrix_final_i_int } \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y \__nicematrix_qpoint: { col - \int_use:N \l__nicematrix_final_j_int } \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x @@ -1808,9 +1905,13 @@ ) } } - \dim_compare:nNnF \l__nicematrix_l_dim = \c_zero_dim \__nicematrix_actually_draw_line: + \bool_lazy_or:nnF + { \dim_compare_p:nNn { \dim_abs:n \l__nicematrix_l_dim } > \c__nicematrix_max_l_dim } + { \dim_compare_p:nNn \l__nicematrix_l_dim = \c_zero_dim } + \__nicematrix_actually_draw_line: \group_end: } +\dim_const:Nn \c__nicematrix_max_l_dim { 50 cm } \cs_new_protected:Npn \__nicematrix_actually_draw_line: { \bool_if:NTF \l__nicematrix_initial_open_bool @@ -1843,7 +1944,7 @@ \int_set:Nn \l_tmpa_int { \dim_ratio:nn - { \l__nicematrix_l_dim - ( 2 \l__nicematrix_xdots_shorten_dim ) } + { \l__nicematrix_l_dim - 2 \l__nicematrix_xdots_shorten_dim } \l__nicematrix_inter_dots_dim } } @@ -2130,7 +2231,7 @@ \__nicematrix_qpoint: {row - 1 } \dim_set_eq:NN \l_tmpa_dim \pgf@y \pgfusepathqfill - \__nicematrix_qpoint: { row - \__nicematrix_succ:N \c@iRow } + \__nicematrix_qpoint: { row - \__nicematrix_succ:n \c@iRow } \dim_sub:Nn \l_tmpa_dim \pgf@y \pgfusepathqfill \dim_zero:N \l_tmpb_dim @@ -2138,15 +2239,15 @@ { \dim_set_eq:NN \l_tmpb_dim \g__nicematrix_dp_last_row_dim \dim_add:Nn \l_tmpb_dim \g__nicematrix_ht_last_row_dim - \__nicematrix_qpoint: { row - \__nicematrix_succ:N\c@iRow } + \__nicematrix_qpoint: { row - \__nicematrix_succ:n\c@iRow } \dim_add:Nn \l_tmpa_dim \pgf@y - \__nicematrix_qpoint: { row - \__nicematrix_succ:N \g__nicematrix_row_total_int } + \__nicematrix_qpoint: { row - \__nicematrix_succ:n \g__nicematrix_row_total_int } \dim_sub:Nn \l_tmpa_dim \pgf@y \dim_sub:Nn \l_tmpa_dim \l_tmpb_dim } \int_step_inline:nnn { \bool_if:NTF \l__nicematrix_NiceArray_bool 1 2 } - { \bool_if:NTF \l__nicematrix_NiceArray_bool { \__nicematrix_succ:N \c@jCol } \c@jCol } + { \bool_if:NTF \l__nicematrix_NiceArray_bool { \__nicematrix_succ:n \c@jCol } \c@jCol } { \pgfpathmoveto { @@ -2222,7 +2323,7 @@ \__nicematrix_qpoint: { col - 1 } \dim_set:Nn \l__nicematrix_x_initial_dim { \pgf@x + \arraycolsep - \l__nicematrix_left_margin_dim } - \__nicematrix_qpoint: { col - \__nicematrix_succ:N \c@jCol } + \__nicematrix_qpoint: { col - \__nicematrix_succ:n \c@jCol } \dim_set:Nn \l__nicematrix_x_final_dim { \pgf@x - \arraycolsep + \l__nicematrix_right_margin_dim } \tl_set:Nn \l_tmpa_tl { ( } @@ -2263,7 +2364,7 @@ \dim_set:Nn \l__nicematrix_x_final_dim { \pgf@x - \l__nicematrix_radius_dim } \__nicematrix_qpoint: { row - 1 } \dim_set:Nn \l__nicematrix_y_initial_dim { \pgf@y - 0.5 \l__nicematrix_inter_dots_dim } - \__nicematrix_qpoint: { row - \__nicematrix_succ:N \c@iRow } + \__nicematrix_qpoint: { row - \__nicematrix_succ:n \c@iRow } \dim_set:Nn \l__nicematrix_y_final_dim { \pgf@y + 0.5 \l__nicematrix_inter_dots_dim } \tl_set_eq:NN \l__nicematrix_xdots_line_style_tl \c__nicematrix_standard_tl \__nicematrix_draw_line: @@ -2295,14 +2396,14 @@ { \bool_if:NT \l__nicematrix_block_auto_columns_width_bool { - \iow_now:Nn \@mainaux \ExplSyntaxOn - \iow_now:Nx \@mainaux + \iow_shipout:Nn \@mainaux \ExplSyntaxOn + \iow_shipout:Nx \@mainaux { \cs_gset:cpn { __nicematrix _ max _ cell _ width _ \int_use:N \g__nicematrix_NiceMatrixBlock_int } { \dim_eval:n { \g__nicematrix_max_cell_width_dim + \arrayrulewidth } } } - \iow_now:Nn \@mainaux \ExplSyntaxOff + \iow_shipout:Nn \@mainaux \ExplSyntaxOff } } \cs_generate_variant:Nn \dim_min:nn { v n } @@ -2331,9 +2432,7 @@ \cs_if_exist:cT { pgf @ sh @ ns @ \__nicematrix_env: - \__nicematrix_i: - \__nicematrix_j: } { - \pgfpointanchor - { \__nicematrix_env: - \__nicematrix_i: - \__nicematrix_j: } - { south~west } + \pgfpointanchor { \__nicematrix_env: - \__nicematrix_i: - \__nicematrix_j: } { south~west } \dim_set:cn { l__nicematrix_row_\__nicematrix_i: _min_dim} { \dim_min:vn { l__nicematrix_row _ \__nicematrix_i: _min_dim } \pgf@y } \seq_if_in:NxF \g__nicematrix_multicolumn_cells_seq { \__nicematrix_i: - \__nicematrix_j: } @@ -2341,9 +2440,7 @@ \dim_set:cn { l__nicematrix_column _ \__nicematrix_j: _min_dim} { \dim_min:vn { l__nicematrix_column _ \__nicematrix_j: _min_dim } \pgf@x } } - \pgfpointanchor - { \__nicematrix_env: - \__nicematrix_i: - \__nicematrix_j: } - { north~east } + \pgfpointanchor { \__nicematrix_env: - \__nicematrix_i: - \__nicematrix_j: } { north~east } \dim_set:cn { l__nicematrix_row _ \__nicematrix_i: _ max_dim } { \dim_max:vn { l__nicematrix_row _ \__nicematrix_i: _ max_dim } \pgf@y } \seq_if_in:NxF \g__nicematrix_multicolumn_cells_seq { \__nicematrix_i: - \__nicematrix_j: } @@ -2354,6 +2451,26 @@ } } } + \int_step_variable:nnNn \l__nicematrix_first_row_int \g__nicematrix_row_total_int \__nicematrix_i: + { + \dim_compare:nNnT + { \dim_use:c { l__nicematrix_row _ \__nicematrix_i: _ min _ dim } } = \c_max_dim + { + \__nicematrix_qpoint: { row - \__nicematrix_i: - base } + \dim_set:cn { l__nicematrix_row _ \__nicematrix_i: _ max _ dim } \pgf@y + \dim_set:cn { l__nicematrix_row _ \__nicematrix_i: _ min _ dim } \pgf@y + } + } + \int_step_variable:nnNn \l__nicematrix_first_col_int \g__nicematrix_col_total_int \__nicematrix_j: + { + \dim_compare:nNnT + { \dim_use:c { l__nicematrix_column _ \__nicematrix_j: _ min _ dim } } = \c_max_dim + { + \__nicematrix_qpoint: { col - \__nicematrix_j: } + \dim_set:cn { l__nicematrix_column _ \__nicematrix_j: _ max _ dim } \pgf@y + \dim_set:cn { l__nicematrix_column _ \__nicematrix_j: _ min _ dim } \pgf@y + } + } } \cs_new_protected:Npn \__nicematrix_create_medium_nodes: { @@ -2399,11 +2516,11 @@ { ( \dim_use:c { l__nicematrix_row _ \__nicematrix_i: _ min _ dim } + - \dim_use:c { l__nicematrix_row _ \int_eval:n { \__nicematrix_i: + 1 } _ max _ dim } + \dim_use:c { l__nicematrix_row _ \__nicematrix_succ:n \__nicematrix_i: _ max _ dim } ) / 2 } - \dim_set_eq:cc { l__nicematrix_row _ \int_eval:n { \__nicematrix_i: + 1 } _ max _ dim } + \dim_set_eq:cc { l__nicematrix_row _ \__nicematrix_succ:n \__nicematrix_i: _ max _ dim } { l__nicematrix_row_\__nicematrix_i: _min_dim } } \int_step_variable:nNn { \c@jCol - 1 } \__nicematrix_j: @@ -2411,14 +2528,13 @@ \dim_set:cn { l__nicematrix_column _ \__nicematrix_j: _ max _ dim } { ( + \dim_use:c { l__nicematrix_column _ \__nicematrix_j: _ max _ dim } + \dim_use:c - { l__nicematrix_column _ \__nicematrix_j: _ max _ dim } + - \dim_use:c - { l__nicematrix_column _ \int_eval:n { \__nicematrix_j: + 1 } _ min _ dim } + { l__nicematrix_column _ \__nicematrix_succ:n \__nicematrix_j: _ min _ dim } ) / 2 } - \dim_set_eq:cc { l__nicematrix_column _ \int_eval:n { \__nicematrix_j: + 1 } _ min _ dim } + \dim_set_eq:cc { l__nicematrix_column _ \__nicematrix_succ:n \__nicematrix_j: _ min _ dim } { l__nicematrix_column _ \__nicematrix_j: _ max _ dim } } \dim_sub:cn @@ -2523,9 +2639,9 @@ \dim_set_eq:NN \l_tmpa_dim \pgf@y \__nicematrix_qpoint: { col - #2 } \dim_set_eq:NN \l_tmpb_dim \pgf@x - \__nicematrix_qpoint: { row - \__nicematrix_succ:N #3 } + \__nicematrix_qpoint: { row - \__nicematrix_succ:n { #3 } } \dim_set_eq:NN \l_tmpc_dim \pgf@y - \__nicematrix_qpoint: { col - \__nicematrix_succ:N #4 } + \__nicematrix_qpoint: { col - \__nicematrix_succ:n { #4 } } \dim_set_eq:NN \l_tmpd_dim \pgf@x \bool_if:NT \l__nicematrix_white_bool { @@ -2635,6 +2751,7 @@ \__nicematrix_define_com:nnn v | | \__nicematrix_define_com:nnn V \| \| \__nicematrix_define_com:nnn B \{ \} +\bool_new:N \c__nicematrix_obsolete_environments_bool \keys_define:nn { NiceMatrix / Package } { renew-dots .bool_set:N = \l__nicematrix_renew_dots_bool , @@ -2643,9 +2760,9 @@ renew-matrix .value_forbidden:n = true , transparent .meta:n = { renew-dots , renew-matrix } , transparent .value_forbidden:n = true, - obsolete-environments .code:n = - \__nicematrix_msg_redirect_name:nn { Obsolete~environment } { none } , - obsolete-environments .value_forbidden:n = true, + obsolete-environments .bool_set:N = \c__nicematrix_obsolete_environments_bool , + obsolete-environments .value_forbidden:n = true , + obsolete-environments .default:n = true , starred-commands .code:n = \__nicematrix_msg_redirect_name:nn { starred~commands } { none } , starred-commands .value_forbidden:n = true , @@ -2719,6 +2836,17 @@ and~'shorten'~(and~you~try~to~use~'\l_keys_key_str').~If~you~go~on,~ this~option~will~be~ignored. } +\__nicematrix_msg_new:nn { ampersand~in~light-syntax } + { + You~can't~use~an~ampersand~(\token_to_str &)~to~separate~columns~because + ~you~have~used~the~option~'light-syntax'.~This~error~is~fatal. + } +\__nicematrix_msg_new:nn { double-backslash~in~light-syntax } + { + You~can't~use~\token_to_str:N \\~to~separate~rows~because~you~have~used~ + the~option~'light-syntax'.~You~must~use~the~character~'\l__nicematrix_end_of_row_tl'~ + (set~by~the~option~'end-of-row').~This~error~is~fatal. + } \__nicematrix_msg_new:nn { starred~commands } { The~starred~versions~of~\token_to_str:N \Cdots,~\token_to_str:N \Ldots,~ @@ -2754,12 +2882,6 @@ However,~you~can~go~on~for~this~time~ (the~value~'\l_keys_value_tl'~will~be~ignored). } -\__nicematrix_msg_new:nn { last-col~empty~for~NiceMatrix } - { - In~the~\__nicematrix_full_name_env:, 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. - } \__nicematrix_msg_new:nn { Block~too~large } { You~try~to~draw~a~block~in~the~cell~#1-#2~of~your~matrix~but~the~matrix~is~ @@ -2936,158 +3058,86 @@ and~R~in~the~preamble~of~your~environment. \\ This~error~is~fatal. } -\__nicematrix_msg_new:nn { Obsolete~environment } - { - The~environment~\{\@currenvir\}~is~obsolete.~You~should~use~#1~instead.~ - However,~it's~still~possible~to~use~the~environment~\{\@currenvir\}~(for~ - a~few~months)~by~loading~'nicematrix'~with~the~option~ - 'obsolete-environments'. - } -\NewDocumentEnvironment { pNiceArrayC } { } - { - \__nicematrix_fatal:nn { Obsolete~environment } { the~option~'last-col' } - \int_zero:N \l__nicematrix_last_col_int - \pNiceArray - } - { \endpNiceArray } -\NewDocumentEnvironment { bNiceArrayC } { } - { - \__nicematrix_fatal:nn { Obsolete~environment } { the~option~'last-col' } - \int_zero:N \l__nicematrix_last_col_int - \bNiceArray - } - { \endbNiceArray } -\NewDocumentEnvironment { BNiceArrayC } { } - { - \__nicematrix_fatal:nn { Obsolete~environment } { the~option~'last-col' } - \int_zero:N \l__nicematrix_last_col_int - \BNiceArray - } - { \endBNiceArray } -\NewDocumentEnvironment { vNiceArrayC } { } - { - \__nicematrix_fatal:nn { Obsolete~environment } { the~option~'last-col' } - \int_zero:N \l__nicematrix_last_col_int - \vNiceArray - } - { \endvNiceArray } -\NewDocumentEnvironment { VNiceArrayC } { } - { - \__nicematrix_fatal:nn { Obsolete~environment } { the~option~'last-col' } - \int_zero:N \l__nicematrix_last_col_int - \VNiceArray - } - { \endVNiceArray } -\NewDocumentEnvironment { pNiceArrayRC } { } - { - \__nicematrix_fatal:nn { Obsolete~environment } - { the~options~'last-col'~and~'first-row' } - \int_zero:N \l__nicematrix_last_col_int - \int_zero:N \l__nicematrix_first_row_int - \pNiceArray - } - { \endpNiceArray } -\NewDocumentEnvironment { bNiceArrayRC } { } - { - \__nicematrix_fatal:nn { Obsolete~environment } - { the~options~'last-col'~and~'first-row' } - \int_zero:N \l__nicematrix_last_col_int - \int_zero:N \l__nicematrix_first_row_int - \bNiceArray - } - { \endbNiceArray } -\NewDocumentEnvironment { BNiceArrayRC } { } +\bool_if:NT \c__nicematrix_obsolete_environments_bool { - \__nicematrix_fatal:nn { Obsolete~environment } - { the~options~'last-col'~and~'first-row' } - \int_zero:N \l__nicematrix_last_col_int - \int_zero:N \l__nicematrix_first_row_int - \BNiceArray - } - { \endBNiceArray } -\NewDocumentEnvironment { vNiceArrayRC } { } - { - \__nicematrix_fatal:nn { Obsolete~environment } - { the~options~'last-col'~and~'first-row' } - \int_zero:N \l__nicematrix_last_col_int - \int_zero:N \l__nicematrix_first_row_int - \vNiceArray - } - { \endvNiceArray } -\NewDocumentEnvironment { VNiceArrayRC } { } - { - \__nicematrix_fatal:nn { Obsolete~environment } - { the~options~'last-col'~and~'first-row' } - \int_zero:N \l__nicematrix_last_col_int - \int_zero:N \l__nicematrix_first_row_int - \VNiceArray - } - { \endVNiceArray } -\NewDocumentEnvironment { NiceArrayCwithDelims } { } - { - \__nicematrix_fatal:nn { Obsolete~environment } - { the~option~'last-col' } - \int_zero:N \l__nicematrix_last_col_int - \NiceArrayWithDelims - } - { \endNiceArrayWithDelims } -\NewDocumentEnvironment { NiceArrayRCwithDelims } { } - { - \__nicematrix_fatal:nn { Obsolete~environment } - { the~options~'last-col'~and~'first-row' } - \int_zero:N \l__nicematrix_last_col_int - \int_zero:N \l__nicematrix_first_row_int - \NiceArrayWithDelims - } - { \endNiceArrayWithDelims } -\cs_new_protected:Npn \__nicematrix_pgf_rect_node:nnnnn #1 #2 #3 #4 #5 - { - \begin { pgfscope } - \pgfset + \NewDocumentEnvironment { pNiceArrayC } { } { - outer~sep = \c_zero_dim , - inner~sep = \c_zero_dim , - minimum~size = \c_zero_dim + \int_zero:N \l__nicematrix_last_col_int + \pNiceArray } - \pgftransformshift { \pgfpoint { 0.5 * ( #2 + #4 ) } { 0.5 * ( #3 + #5 ) } } - \pgfnode - { rectangle } - { center } + { \endpNiceArray } + \NewDocumentEnvironment { bNiceArrayC } { } + { + \int_zero:N \l__nicematrix_last_col_int + \bNiceArray + } + { \endbNiceArray } + \NewDocumentEnvironment { BNiceArrayC } { } { - \vbox_to_ht:nn - { \dim_abs:n { #5 - #3 } } - { - \vfill - \hbox_to_wd:nn { \dim_abs:n { #4 - #2 } } { } - } + \int_zero:N \l__nicematrix_last_col_int + \BNiceArray } - { #1 } - { } - \end { pgfscope } - } -\cs_new_protected:Npn \__nicematrix_pgf_rect_node:nnn #1 #2 #3 - { - \begin { pgfscope } - \pgfset + { \endBNiceArray } + \NewDocumentEnvironment { vNiceArrayC } { } { - outer~sep = \c_zero_dim , - inner~sep = \c_zero_dim , - minimum~size = \c_zero_dim + \int_zero:N \l__nicematrix_last_col_int + \vNiceArray } - \pgftransformshift { \pgfpointscale { 0.5 } { \pgfpointadd { #2 } { #3 } } } - \pgfpointdiff { #3 } { #2 } - \pgfgetlastxy \l_tmpa_dim \l_tmpb_dim - \pgfnode - { rectangle } - { center } + { \endvNiceArray } + \NewDocumentEnvironment { VNiceArrayC } { } { - \vbox_to_ht:nn - { \dim_abs:n { \l_tmpb_dim } } - { \vfill \hbox_to_wd:nn { \dim_abs:n { \l_tmpa_dim } } { } } + \int_zero:N \l__nicematrix_last_col_int + \VNiceArray } - { #1 } - { } - \end { pgfscope } + { \endVNiceArray } + \NewDocumentEnvironment { pNiceArrayRC } { } + { + \int_zero:N \l__nicematrix_last_col_int + \int_zero:N \l__nicematrix_first_row_int + \pNiceArray + } + { \endpNiceArray } + \NewDocumentEnvironment { bNiceArrayRC } { } + { + \int_zero:N \l__nicematrix_last_col_int + \int_zero:N \l__nicematrix_first_row_int + \bNiceArray + } + { \endbNiceArray } + \NewDocumentEnvironment { BNiceArrayRC } { } + { + \int_zero:N \l__nicematrix_last_col_int + \int_zero:N \l__nicematrix_first_row_int + \BNiceArray + } + { \endBNiceArray } + \NewDocumentEnvironment { vNiceArrayRC } { } + { + \int_zero:N \l__nicematrix_last_col_int + \int_zero:N \l__nicematrix_first_row_int + \vNiceArray + } + { \endvNiceArray } + \NewDocumentEnvironment { VNiceArrayRC } { } + { + \int_zero:N \l__nicematrix_last_col_int + \int_zero:N \l__nicematrix_first_row_int + \VNiceArray + } + { \endVNiceArray } + \NewDocumentEnvironment { NiceArrayCwithDelims } { } + { + \int_zero:N \l__nicematrix_last_col_int + \NiceArrayWithDelims + } + { \endNiceArrayWithDelims } + \NewDocumentEnvironment { NiceArrayRCwithDelims } { } + { + \int_zero:N \l__nicematrix_last_col_int + \int_zero:N \l__nicematrix_first_row_int + \NiceArrayWithDelims + } + { \endNiceArrayWithDelims } } \endinput |