summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/nicematrix
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-05-06 20:23:54 +0000
committerKarl Berry <karl@freefriends.org>2021-05-06 20:23:54 +0000
commitd23ce5cb0bb42ef0380b13d2d43d48afcc51b897 (patch)
tree65c2a60d8228f1f424836829ff29361773376a71 /Master/texmf-dist/tex/latex/nicematrix
parent4a3742b13d2d84ad2530328f8f4d6e51cba2182c (diff)
nicematrix (6may21)
git-svn-id: svn://tug.org/texlive/trunk@59105 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/nicematrix')
-rw-r--r--Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty453
1 files changed, 298 insertions, 155 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
index 1f21908183f..f8439a04692 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{5.15}
-\def\myfiledate{2021/04/25}
+\def\myfileversion{5.15a}
+\def\myfiledate{2021/05/06}
\RequirePackage{pgfcore}
\usepgfmodule{shapes}
\RequirePackage{l3keys2e}
@@ -256,6 +256,8 @@
{ \pgfpointanchor { \__nicematrix_env: - #1 } { center } }
\int_new:N \g__nicematrix_NiceMatrixBlock_int
\dim_new:N \l__nicematrix_columns_width_dim
+\int_new:N \g__nicematrix_row_total_int
+\int_new:N \g__nicematrix_col_total_int
\tl_new:N \l__nicematrix_cell_type_tl
\tl_set:Nn \l__nicematrix_cell_type_tl { c }
\dim_new:N \g__nicematrix_blocks_wd_dim
@@ -263,7 +265,7 @@
\dim_new:N \g__nicematrix_blocks_dp_dim
\seq_new:N \g__nicematrix_names_seq
\bool_new:N \l__nicematrix_in_env_bool
-\bool_new:N \g__nicematrix_NiceArray_bool
+\bool_new:N \l__nicematrix_NiceArray_bool
\bool_new:N \l__nicematrix_NiceTabular_bool
\dim_new:N \l__nicematrix_tabular_width_dim
\bool_new:N \l__nicematrix_Matrix_bool
@@ -386,7 +388,7 @@
}
\NewDocumentCommand \tabularnote { m }
{
- \bool_if:nTF { ! \g__nicematrix_NiceArray_bool && \l__nicematrix_in_env_bool }
+ \bool_if:nTF { ! \l__nicematrix_NiceArray_bool && \l__nicematrix_in_env_bool }
{ \__nicematrix_error:n { tabularnote~forbidden } }
{
\int_incr:N \l__nicematrix_number_of_notes_int
@@ -490,6 +492,7 @@
\AtBeginDocument { \dim_set:Nn \l__nicematrix_notes_above_space_dim { 1 mm } }
\bool_new:N \l__nicematrix_nullify_dots_bool
\bool_new:N \l__nicematrix_auto_columns_width_bool
+\bool_new:N \g__nicematrix_recreate_cell_nodes_bool
\str_new:N \l__nicematrix_name_str
\bool_new:N \l__nicematrix_medium_nodes_bool
\bool_new:N \l__nicematrix_large_nodes_bool
@@ -531,6 +534,9 @@
}
\keys_define:nn { NiceMatrix / Global }
{
+ delimiters .code:n =
+ \keys_set:nn { NiceMatrix / delimiters } { #1 } ,
+ delimiters .value_required:n = true ,
rules .code:n = \keys_set:nn { NiceMatrix / rules } { #1 } ,
rules .value_required:n = true ,
standard-cline .bool_set:N = \l__nicematrix_standard_cline_bool ,
@@ -600,7 +606,7 @@
}
\keys_define:nn { NiceMatrix / Env }
{
- delimiters/max-width .bool_set:N = \l__nicematrix_delimiters_max_width_bool ,
+
hvlines-except-corners .code:n =
{
\clist_set:Nn \l__nicematrix_corners_clist { #1 }
@@ -697,6 +703,13 @@
enumitem-keys-para .value_required:n = true ,
unknown .code:n = \__nicematrix_error:n { Unknown~key~for~notes }
}
+\keys_define:nn { NiceMatrix / delimiters }
+ {
+ max-width .bool_set:N = \l__nicematrix_delimiters_max_width_bool ,
+ max-width .default:n = true ,
+ color .tl_set:N = \l__nicematrix_delimiters_color_tl ,
+ color .value_required:n = true ,
+ }
\keys_define:nn { NiceMatrix }
{
NiceMatrixOptions .inherit:n =
@@ -704,6 +717,7 @@
NiceMatrixOptions / xdots .inherit:n = NiceMatrix / xdots ,
NiceMatrixOptions / rules .inherit:n = NiceMatrix / rules ,
NiceMatrixOptions / notes .inherit:n = NiceMatrix / notes ,
+ NiceMatrixOptions / delimiters .inherit:n = NiceMatrix / delimiters ,
NiceMatrixOptions / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,
SubMatrix / rules .inherit:n = NiceMatrix / rules ,
CodeAfter / xdots .inherit:n = NiceMatrix / xdots ,
@@ -714,6 +728,7 @@
} ,
NiceMatrix / xdots .inherit:n = NiceMatrix / xdots ,
NiceMatrix / rules .inherit:n = NiceMatrix / rules ,
+ NiceMatrix / delimiters .inherit:n = NiceMatrix / delimiters ,
NiceTabular .inherit:n =
{
NiceMatrix / Global ,
@@ -721,6 +736,7 @@
} ,
NiceTabular / xdots .inherit:n = NiceMatrix / xdots ,
NiceTabular / rules .inherit:n = NiceMatrix / rules ,
+ NiceTabular / delimiters .inherit:n = NiceMatrix / delimiters ,
NiceArray .inherit:n =
{
NiceMatrix / Global ,
@@ -728,6 +744,7 @@
} ,
NiceArray / xdots .inherit:n = NiceMatrix / xdots ,
NiceArray / rules .inherit:n = NiceMatrix / rules ,
+ NiceArray / delimiters .inherit:n = NiceMatrix / delimiters ,
pNiceArray .inherit:n =
{
NiceMatrix / Global ,
@@ -735,16 +752,10 @@
} ,
pNiceArray / xdots .inherit:n = NiceMatrix / xdots ,
pNiceArray / rules .inherit:n = NiceMatrix / rules ,
+ pNiceArray / delimiters .inherit:n = NiceMatrix / delimiters ,
}
\keys_define:nn { NiceMatrix / NiceMatrixOptions }
{
- delimiters / max-width .bool_set:N = \l__nicematrix_delimiters_max_width_bool ,
- delimiters / color .tl_set:N = \l__nicematrix_delimiters_color_tl ,
- delimiters / color .value_required:n = true ,
- delimiters-color .code:n =
- \tl_set:Nn \l__nicematrix_delimiters_color_tl { #1 }
- \__nicematrix_error:n { delimiters-color deleted } ,
- delimiters-color .value_required:n = true ,
last-col .code:n = \tl_if_empty:nF { #1 }
{ \__nicematrix_error:n { last-col~non~empty~for~NiceMatrixOptions } }
\int_zero:N \l__nicematrix_last_col_int ,
@@ -797,12 +808,6 @@
r .code:n = \tl_set:Nn \l__nicematrix_type_of_col_tl r ,
small .bool_set:N = \l__nicematrix_small_bool ,
small .value_forbidden:n = true ,
- delimiters / color .tl_set:N = \l__nicematrix_delimiters_color_tl ,
- delimiters / color .value_required:n = true ,
- delimiters-color .code:n =
- \tl_set:Nn \l__nicematrix_delimiters_color_tl { #1 }
- \__nicematrix_error:n { delimiters-color deleted } ,
- delimiters-color .value_required:n = true ,
unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceMatrix }
}
\keys_define:nn { NiceMatrix / NiceArray }
@@ -818,11 +823,6 @@
notes / bottomrule .default:n = true ,
tabularnote .tl_set:N = \l__nicematrix_tabularnote_tl ,
tabularnote .value_required:n = true ,
- delimiters-color .code:n =
- \tl_set:Nn \l__nicematrix_delimiters_color_tl { #1 }
- \__nicematrix_error:n { delimiters-color deleted } ,
- delimiters / color .tl_set:N = \l__nicematrix_delimiters_color_tl ,
- delimiters / color .value_required:n = true ,
r .code:n = \__nicematrix_error:n { r~or~l~with~preamble } ,
l .code:n = \__nicematrix_error:n { r~or~l~with~preamble } ,
unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceArray }
@@ -973,14 +973,14 @@
\bool_lazy_or:nnTF
\g__nicematrix_not_empty_cell_bool
{ \dim_compare_p:nNn { \box_wd:N \l__nicematrix_cell_box } > \c_zero_dim }
- \__nicematrix_node_for_the_cell:
+ \__nicematrix_node_for_cell:
{ \box_use_drop:N \l__nicematrix_cell_box }
}
\int_gset:Nn \g__nicematrix_col_total_int { \int_max:nn \g__nicematrix_col_total_int \c@jCol }
\bool_gset_false:N \g__nicematrix_empty_cell_bool
\bool_gset_false:N \g__nicematrix_not_empty_cell_bool
}
-\cs_new_protected:Npn \__nicematrix_node_for_the_cell:
+\cs_new_protected:Npn \__nicematrix_node_for_cell:
{
\pgfpicture
\pgfsetbaseline \c_zero_dim
@@ -1004,6 +1004,36 @@
}
\endpgfpicture
}
+\cs_new_protected:Npn \__nicematrix_patch_node_for_cell:n #1
+ {
+ \cs_new_protected:Npn \__nicematrix_patch_node_for_cell:
+ {
+ \hbox_set:Nn \l__nicematrix_cell_box
+ {
+ \box_move_up:nn { \box_ht:N \l__nicematrix_cell_box}
+ \hbox_overlap_left:n
+ {
+ \pgfsys@markposition
+ { \__nicematrix_env: - \int_use:N \c@iRow - \int_use:N \c@jCol - NW }
+ #1
+ }
+ \box_use:N \l__nicematrix_cell_box
+ \box_move_down:nn { \box_dp:N \l__nicematrix_cell_box }
+ \hbox_overlap_left:n
+ {
+ \pgfsys@markposition
+ { \__nicematrix_env: - \int_use:N \c@iRow - \int_use:N \c@jCol - SE }
+ #1
+ }
+ }
+ }
+ }
+\bool_lazy_or:nnTF \sys_if_engine_xetex_p: \sys_if_output_dvi_p:
+ {
+ \__nicematrix_patch_node_for_cell:n
+ { \skip_horizontal:n { 0.5 \box_wd:N \l__nicematrix_cell_box } }
+ }
+ { \__nicematrix_patch_node_for_cell:n { } }
\cs_new_protected:Npn \__nicematrix_instruction_of_type:nnn #1 #2 #3
{
\bool_if:nTF { #1 } \tl_gput_left:cx \tl_gput_right:cx
@@ -1205,73 +1235,7 @@
\cs_new_protected:Npn \__nicematrix_pre_array:
{
\seq_gclear:N \g__nicematrix_submatrix_seq
- \bool_if:NT \l__nicematrix_code_before_bool
- {
- \seq_if_exist:cT
- { c__nicematrix_corners_cells_ \int_use:N \g__nicematrix_env_int _ seq }
- {
- \seq_set_eq:Nc \l__nicematrix_corners_cells_seq
- { c__nicematrix_corners_cells_ \int_use:N \g__nicematrix_env_int _ seq }
- }
- \seq_if_exist:cT { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq }
- {
- \int_zero_new:N \c@iRow
- \int_set:Nn \c@iRow
- { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 2 }
- \int_zero_new:N \c@jCol
- \int_set:Nn \c@jCol
- { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 4 }
- \int_compare:nNnF \l__nicematrix_last_row_int = { -2 }
- { \int_decr:N \c@iRow }
- \int_compare:nNnF \l__nicematrix_last_col_int = { -2 }
- { \int_decr:N \c@jCol }
- \pgfsys@markposition { \__nicematrix_env: - position }
- \pgfsys@getposition { \__nicematrix_env: - position } \__nicematrix_picture_position:
- \pgfpicture
- \int_step_inline:nnn
- { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 1 }
- { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 2 + 1 }
- {
- \pgfsys@getposition { \__nicematrix_env: - row - ##1 } \__nicematrix_node_position:
- \pgfcoordinate { \__nicematrix_env: - row - ##1 }
- { \pgfpointdiff \__nicematrix_picture_position: \__nicematrix_node_position: }
- }
- \int_step_inline:nnn
- { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 3 }
- { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 4 + 1 }
- {
- \pgfsys@getposition { \__nicematrix_env: - col - ##1 } \__nicematrix_node_position:
- \pgfcoordinate { \__nicematrix_env: - col - ##1 }
- { \pgfpointdiff \__nicematrix_picture_position: \__nicematrix_node_position: }
- }
- \endpgfpicture
- \__nicematrix_create_diag_nodes:
- \group_begin:
- \bool_if:NT \c__nicematrix_tikz_loaded_bool
- {
- \tikzset
- {
- every~picture / .style =
- { overlay , name~prefix = \__nicematrix_env: - }
- }
- }
- \cs_set_eq:NN \cellcolor \__nicematrix_cellcolor
- \cs_set_eq:NN \rectanglecolor \__nicematrix_rectanglecolor
- \cs_set_eq:NN \roundedrectanglecolor \__nicematrix_roundedrectanglecolor
- \cs_set_eq:NN \rowcolor \__nicematrix_rowcolor
- \cs_set_eq:NN \rowcolors \__nicematrix_rowcolors
- \cs_set_eq:NN \arraycolor \__nicematrix_arraycolor
- \cs_set_eq:NN \columncolor \__nicematrix_columncolor
- \cs_set_eq:NN \chessboardcolors \__nicematrix_chessboardcolors
- \cs_set_eq:NN \SubMatrix \__nicematrix_SubMatrix_in_code_before
- \bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token
- \seq_gclear_new:N \g__nicematrix_colors_seq
- \exp_last_unbraced:NV \__nicematrix_CodeAfter_keys: \l__nicematrix_code_before_tl
- \__nicematrix_actually_color:
- \bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token
- \group_end:
- }
- }
+ \bool_if:NT \l__nicematrix_code_before_bool \__nicematrix_exec_code_before:
\int_compare:nNnT \l__nicematrix_last_row_int > { -2 }
{
\tl_put_right:Nn \__nicematrix_update_for_first_and_last_row:
@@ -1325,7 +1289,7 @@
\__nicematrix_construct_preamble:
\dim_zero_new:N \l__nicematrix_left_delim_dim
\dim_zero_new:N \l__nicematrix_right_delim_dim
- \bool_if:NTF \g__nicematrix_NiceArray_bool
+ \bool_if:NTF \l__nicematrix_NiceArray_bool
{
\dim_gset:Nn \l__nicematrix_left_delim_dim { 2 \arraycolsep }
\dim_gset:Nn \l__nicematrix_right_delim_dim { 2 \arraycolsep }
@@ -1350,6 +1314,128 @@
\bool_set_true:N \l__nicematrix_code_before_bool
\__nicematrix_pre_array:
}
+\cs_new_protected:Npn \__nicematrix_pre_code_before:
+ {
+ \int_zero_new:N \c@iRow
+ \int_set:Nn \c@iRow
+ { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 2 }
+ \int_zero_new:N \c@jCol
+ \int_set:Nn \c@jCol
+ { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 4 }
+ \int_compare:nNnF \l__nicematrix_last_row_int = { -2 }
+ { \int_decr:N \c@iRow }
+ \int_compare:nNnF \l__nicematrix_last_col_int = { -2 }
+ { \int_decr:N \c@jCol }
+ \pgfsys@markposition { \__nicematrix_env: - position }
+ \pgfsys@getposition { \__nicematrix_env: - position } \__nicematrix_picture_position:
+ \pgfpicture
+ \pgf@relevantforpicturesizefalse
+ \int_step_inline:nnn
+ { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 1 }
+ { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 2 + 1 }
+ {
+ \pgfsys@getposition { \__nicematrix_env: - row - ##1 } \__nicematrix_node_position:
+ \pgfcoordinate { \__nicematrix_env: - row - ##1 }
+ { \pgfpointdiff \__nicematrix_picture_position: \__nicematrix_node_position: }
+ }
+ \int_step_inline:nnn
+ { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 3 }
+ { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 4 + 1 }
+ {
+ \pgfsys@getposition { \__nicematrix_env: - col - ##1 } \__nicematrix_node_position:
+ \pgfcoordinate { \__nicematrix_env: - col - ##1 }
+ { \pgfpointdiff \__nicematrix_picture_position: \__nicematrix_node_position: }
+ }
+ \__nicematrix_create_diag_nodes:
+ \bool_if:NT \g__nicematrix_recreate_cell_nodes_bool \__nicematrix_recreate_cell_nodes:
+ \endpgfpicture
+ \bool_if:NT \c__nicematrix_tikz_loaded_bool
+ {
+ \tikzset
+ {
+ every~picture / .style =
+ { overlay , name~prefix = \__nicematrix_env: - }
+ }
+ }
+ \cs_set_eq:NN \cellcolor \__nicematrix_cellcolor
+ \cs_set_eq:NN \rectanglecolor \__nicematrix_rectanglecolor
+ \cs_set_eq:NN \roundedrectanglecolor \__nicematrix_roundedrectanglecolor
+ \cs_set_eq:NN \rowcolor \__nicematrix_rowcolor
+ \cs_set_eq:NN \rowcolors \__nicematrix_rowcolors
+ \cs_set_eq:NN \arraycolor \__nicematrix_arraycolor
+ \cs_set_eq:NN \columncolor \__nicematrix_columncolor
+ \cs_set_eq:NN \chessboardcolors \__nicematrix_chessboardcolors
+ \cs_set_eq:NN \SubMatrix \__nicematrix_SubMatrix_in_code_before
+ \seq_if_exist:cT
+ { c__nicematrix_corners_cells_ \int_use:N \g__nicematrix_env_int _ seq }
+ {
+ \seq_set_eq:Nc \l__nicematrix_corners_cells_seq
+ { c__nicematrix_corners_cells_ \int_use:N \g__nicematrix_env_int _ seq }
+ }
+ }
+\cs_new_protected:Npn \__nicematrix_exec_code_before:
+ {
+ \seq_gclear_new:N \g__nicematrix_colors_seq
+ \bool_gset_false:N \g__nicematrix_recreate_cell_nodes_bool
+ \group_begin:
+ \bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token
+ \exp_last_unbraced:NV \__nicematrix_CodeBefore_keys: \l__nicematrix_code_before_tl \q_stop
+ \__nicematrix_actually_color:
+ \bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token
+ \group_end:
+ \bool_if:NT \g__nicematrix_recreate_cell_nodes_bool
+ { \tl_put_left:Nn \__nicematrix_node_for_cell: \__nicematrix_patch_node_for_cell: }
+ }
+\keys_define:nn { NiceMatrix / CodeBefore }
+ {
+ create-cell-nodes .bool_gset:N = \g__nicematrix_recreate_cell_nodes_bool ,
+ create-cell-nodes .default:n = true ,
+ sub-matrix .code:n = \keys_set:nn { NiceMatrix / sub-matrix } { #1 } ,
+ sub-matrix .value_required:n = true ,
+ delimiters / color .tl_set:N = \l__nicematrix_delimiters_color_tl ,
+ delimiters / color .value_required:n = true ,
+ unknown .code:n = \__nicematrix_error:n { Unknown~key~for~CodeAfter }
+ }
+\NewDocumentCommand \__nicematrix_CodeBefore_keys: { O { } }
+ {
+ \keys_set:nn { NiceMatrix / CodeBefore } { #1 }
+ \__nicematrix_CodeBefore:w
+ }
+\cs_new_protected:Npn \__nicematrix_CodeBefore:w #1 \q_stop
+ {
+ \seq_if_exist:cT { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq }
+ {
+ \__nicematrix_pre_code_before:
+ #1
+ }
+ }
+\cs_new_protected:Npn \__nicematrix_recreate_cell_nodes:
+ {
+ \int_step_inline:nnn
+ { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 1 }
+ { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 2 }
+ {
+ \int_step_inline:nnn
+ { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 3 }
+ { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 4 }
+ {
+ \cs_if_exist:cT
+ { pgf @ sys @ pdf @ mark @ pos @ \__nicematrix_env: - ##1 - ####1 - NW }
+ {
+ \pgfsys@getposition
+ { \__nicematrix_env: - ##1 - ####1 - NW }
+ \__nicematrix_node_position:
+ \pgfsys@getposition
+ { \__nicematrix_env: - ##1 - ####1 - SE }
+ \__nicematrix_node_position_i:
+ \__nicematrix_pgf_rect_node:nnn
+ { \__nicematrix_env: - ##1 - ####1 }
+ { \pgfpointdiff \__nicematrix_picture_position: \__nicematrix_node_position: }
+ { \pgfpointdiff \__nicematrix_picture_position: \__nicematrix_node_position_i: }
+ }
+ }
+ }
+ }
\NewDocumentEnvironment { NiceArrayWithDelims }
{ m m O { } m ! O { } t \CodeBefore }
{
@@ -1391,7 +1477,7 @@
\exp_args:NNv \tl_put_right:Nn \l__nicematrix_code_before_tl
{ g__nicematrix_code_before_ \int_use:N \g__nicematrix_env_int _ tl }
}
- \bool_if:NTF \g__nicematrix_NiceArray_bool
+ \bool_if:NTF \l__nicematrix_NiceArray_bool
{ \keys_set:nn { NiceMatrix / NiceArray } }
{ \keys_set:nn { NiceMatrix / pNiceArray } }
{ #3 , #5 }
@@ -1432,7 +1518,7 @@
\skip_horizontal:N \col@sep
\skip_horizontal:N \g__nicematrix_width_first_col_dim
}
- \bool_if:NTF \g__nicematrix_NiceArray_bool
+ \bool_if:NTF \l__nicematrix_NiceArray_bool
{
\str_case:VnF \l__nicematrix_baseline_tl
{
@@ -1509,9 +1595,9 @@
{
\group_begin:
\bool_if:NF \l__nicematrix_Matrix_bool
- {
- \__nicematrix_newcolumntype w [ 2 ] { \__nicematrix_w: { ##1 } { ##2 } }
- \__nicematrix_newcolumntype W [ 2 ] { \__nicematrix_W: { ##1 } { ##2 } }
+ {
+ \__nicematrix_newcolumntype w [ 2 ] { \__nicematrix_w: { ##1 } { ##2 } }
+ \__nicematrix_newcolumntype W [ 2 ] { \__nicematrix_W: { ##1 } { ##2 } }
\exp_args:NV \@temptokena \g__nicematrix_preamble_tl
\@tempswatrue
\@whilesw \if@tempswa \fi { \@tempswafalse \the \NC@list }
@@ -1531,9 +1617,7 @@
}
\seq_clear:N \g__nicematrix_cols_vlism_seq
\int_zero:N \l_tmpa_int
- \bool_set_false:N \l_tmpa_bool
\exp_after:wN \__nicematrix_patch_preamble:n \the \@temptokena \q_stop
- \bool_if:NT \l_tmpa_bool { \bool_gset_false:N \g__nicematrix_NiceArray_bool }
\int_gset_eq:NN \g__nicematrix_static_num_of_col_int \c@jCol
}
\bool_if:NT \l__nicematrix_colortbl_like_bool
@@ -1543,12 +1627,17 @@
{ \c { __nicematrix_columncolor_preamble } }
\g__nicematrix_preamble_tl
}
+ \group_end:
+ \bool_lazy_or:nnT
+ { ! \str_if_eq_p:Vn \g__nicematrix_left_delim_tl { . } }
+ { ! \str_if_eq_p:Vn \g__nicematrix_right_delim_tl { . } }
+ { \bool_set_false:N \l__nicematrix_NiceArray_bool }
\int_compare:nNnTF \l__nicematrix_first_col_int = 0
{ \tl_gput_left:NV \g__nicematrix_preamble_tl \c__nicematrix_preamble_first_col_tl }
{
\bool_lazy_all:nT
{
- \g__nicematrix_NiceArray_bool
+ \l__nicematrix_NiceArray_bool
{ \bool_not_p:n \l__nicematrix_NiceTabular_bool }
{ \tl_if_empty_p:N \l__nicematrix_vlines_clist }
{ \bool_not_p:n \l__nicematrix_exterior_arraycolsep_bool }
@@ -1560,7 +1649,7 @@
{
\bool_lazy_all:nT
{
- \g__nicematrix_NiceArray_bool
+ \l__nicematrix_NiceArray_bool
{ \bool_not_p:n \l__nicematrix_NiceTabular_bool }
{ \tl_if_empty_p:N \l__nicematrix_vlines_clist }
{ \bool_not_p:n \l__nicematrix_exterior_arraycolsep_bool }
@@ -1572,7 +1661,6 @@
\tl_gput_right:Nn \g__nicematrix_preamble_tl
{ > { \__nicematrix_error_too_much_cols: } l }
}
- \group_end:
}
\cs_new_protected:Npn \__nicematrix_patch_preamble:n #1
{
@@ -1591,9 +1679,9 @@
\__nicematrix_w: { \__nicematrix_patch_preamble_v:nnnn { } #1 }
\__nicematrix_W: { \__nicematrix_patch_preamble_v:nnnn { \cs_set_eq:NN \hss \hfil } #1 }
\__nicematrix_true_c: { \__nicematrix_patch_preamble_vi:n #1 }
- ( { \__nicematrix_patch_preamble_vii:n #1 }
- [ { \__nicematrix_patch_preamble_vii:n #1 }
- \{ { \__nicematrix_patch_preamble_vii:n #1 }
+ ( { \__nicematrix_patch_preamble_vii:nn #1 }
+ [ { \__nicematrix_patch_preamble_vii:nn #1 }
+ \{ { \__nicematrix_patch_preamble_vii:nn #1 }
) { \__nicematrix_patch_preamble_viii:nn #1 }
] { \__nicematrix_patch_preamble_viii:nn #1 }
\} { \__nicematrix_patch_preamble_viii:nn #1 }
@@ -1722,60 +1810,50 @@
\int_gincr:N \c@jCol
\__nicematrix_patch_preamble_x:n
}
-\cs_new_protected:Npn \__nicematrix_patch_preamble_vii:n #1
+\cs_new_protected:Npn \__nicematrix_patch_preamble_vii:nn #1 #2
{
- \bool_if:NT \l__nicematrix_small_bool
- { \__nicematrix_fatal:n { Delimiter~with~small } }
+ \bool_if:NT \l__nicematrix_small_bool { \__nicematrix_fatal:n { Delimiter~with~small } }
\int_compare:nNnTF \c@jCol = \c_zero_int
{
- \bool_if:NTF \g__nicematrix_NiceArray_bool
+ \str_if_eq:VnTF \g__nicematrix_left_delim_tl { . }
{
\tl_gset:Nn \g__nicematrix_left_delim_tl { #1 }
\tl_gset:Nn \g__nicematrix_right_delim_tl { . }
- \bool_set_true:N \l_tmpa_bool
- \__nicematrix_patch_preamble:n
+ \__nicematrix_patch_preamble:n #2
}
{
\tl_gput_right:Nn \g__nicematrix_preamble_tl { ! { \enskip } }
\tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
{ \__nicematrix_delimiter:nnn #1 { \__nicematrix_succ:n \c@jCol } \c_true_bool }
- \__nicematrix_patch_preamble_vii_i:n
+ \tl_if_in:nnTF { ( [ \{ ) ] \} } { #2 }
+ {
+ \__nicematrix_error:nn { delimiter~after~opening } { #2 }
+ \__nicematrix_patch_preamble:n
+ }
+ { \__nicematrix_patch_preamble:n #2 }
}
}
{
\tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
{ \__nicematrix_delimiter:nnn #1 { \__nicematrix_succ:n \c@jCol } \c_true_bool }
- \__nicematrix_patch_preamble_vii_i:n
- }
- }
-\cs_new_protected:Npn \__nicematrix_patch_preamble_vii_i:n #1
- {
- \tl_if_in:nnTF { ( [ \{ ) ] \} } { #1 }
- {
- \__nicematrix_error:nn { delimiter~after~opening } { #1 }
- \__nicematrix_patch_preamble:n
+ \tl_if_in:nnTF { ( [ \{ ) ] \} } { #2 }
+ {
+ \__nicematrix_error:nn { delimiter~after~opening } { #2 }
+ \__nicematrix_patch_preamble:n
+ }
+ { \__nicematrix_patch_preamble:n #2 }
}
- { \__nicematrix_patch_preamble:n #1 }
}
\cs_new_protected:Npn \__nicematrix_patch_preamble_viii:nn #1 #2
{
- \bool_if:NT \l__nicematrix_small_bool
- { \__nicematrix_fatal:n { Delimiter~with~small } }
+ \bool_if:NT \l__nicematrix_small_bool { \__nicematrix_fatal:n { Delimiter~with~small } }
\tl_if_in:nnTF { ) ] \} } { #2 }
- {
- \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
- { \__nicematrix_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool }
- \__nicematrix_error:nn { double~closing~delimiter } { #2 }
- \__nicematrix_patch_preamble:n
- }
+ { \__nicematrix_patch_preamble_viii_i:nnn #1 #2 }
{
\tl_if_eq:nnTF { \q_stop } { #2 }
{
- \bool_if:NTF \g__nicematrix_NiceArray_bool
- {
- \tl_gset:Nn \g__nicematrix_right_delim_tl { #1 }
- \bool_set_true:N \l_tmpa_bool
- }
+ \str_if_eq:VnTF \g__nicematrix_right_delim_tl { . }
+ { \tl_gset:Nn \g__nicematrix_right_delim_tl { #1 } }
{
\tl_gput_right:Nn \g__nicematrix_preamble_tl { ! { \enskip } }
\tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
@@ -1792,6 +1870,31 @@
}
}
}
+\cs_new_protected:Npn \__nicematrix_patch_preamble_viii_i:nnn #1 #2 #3
+ {
+ \tl_if_eq:nnTF { \q_stop } { #3 }
+ {
+ \str_if_eq:VnTF \g__nicematrix_right_delim_tl { . }
+ {
+ \tl_gput_right:Nn \g__nicematrix_preamble_tl { ! { \enskip } }
+ \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
+ { \__nicematrix_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool }
+ \tl_gset:Nn \g__nicematrix_right_delim_tl { #2 }
+ }
+ {
+ \tl_gput_right:Nn \g__nicematrix_preamble_tl { ! { \enskip } }
+ \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
+ { \__nicematrix_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool }
+ \__nicematrix_error:nn { double~closing~delimiter } { #2 }
+ }
+ }
+ {
+ \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
+ { \__nicematrix_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool }
+ \__nicematrix_error:nn { double~closing~delimiter } { #2 }
+ \__nicematrix_patch_preamble:n #3
+ }
+ }
\cs_new_protected:Npn \__nicematrix_patch_preamble_xi:n #1
{
\tl_gput_right:Nn \g__nicematrix_preamble_tl
@@ -2250,7 +2353,7 @@
\hbox_overlap_left:n
{
\dim_compare:nNnTF { \box_wd:N \l__nicematrix_cell_box } > \c_zero_dim
- \__nicematrix_node_for_the_cell:
+ \__nicematrix_node_for_cell:
{ \box_use_drop:N \l__nicematrix_cell_box }
\skip_horizontal:N \l__nicematrix_left_delim_dim
\skip_horizontal:N \l__nicematrix_left_margin_dim
@@ -2300,7 +2403,7 @@
\skip_horizontal:N \l__nicematrix_right_delim_dim
\skip_horizontal:N \l__nicematrix_right_margin_dim
\skip_horizontal:N \l__nicematrix_extra_right_margin_dim
- \__nicematrix_node_for_the_cell:
+ \__nicematrix_node_for_cell:
}
}
\bool_gset_false:N \g__nicematrix_empty_cell_bool
@@ -2308,7 +2411,7 @@
}
\NewDocumentEnvironment { NiceArray } { }
{
- \bool_gset_true:N \g__nicematrix_NiceArray_bool
+ \bool_set_true:N \l__nicematrix_NiceArray_bool
\str_if_empty:NT \g__nicematrix_name_env_str
{ \str_gset:Nn \g__nicematrix_name_env_str { NiceArray } }
\NiceArrayWithDelims . .
@@ -2443,6 +2546,7 @@
{ c__nicematrix_pos_of_blocks_ \int_use:N \g__nicematrix_env_int _ seq }
{ \seq_use:Nnnn \g__nicematrix_pos_of_blocks_seq , , , }
}
+ \iow_now:Nn \@mainaux \ExplSyntaxOff
}
\__nicematrix_create_diag_nodes:
\bool_if:NT \l__nicematrix_parallelize_diags_bool
@@ -2517,7 +2621,7 @@
\iow_now:Nn \@mainaux \ExplSyntaxOff
\bool_set_true:N \l__nicematrix_code_before_bool
}
- \bool_gset_false:N \g__nicematrix_NiceArray_bool
+ % \bool_if:NT \l__nicematrix_code_before_bool \__nicematrix_write_aux_for_cell_nodes:
\str_gclear:N \g__nicematrix_name_env_str
\__nicematrix_restore_iRow_jCol:
\cs_gset_eq:NN \CT@arc@ \__nicematrix_old_CT@arc@
@@ -2579,6 +2683,49 @@
\anchor { 5 } { \five }
\anchor { center } { \pgfpointorigin }
}
+\cs_new_protected:Npn \__nicematrix_write_aux_for_cell_nodes:
+ {
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgf@relevantforpicturesizefalse
+ \int_step_inline:nnn \l__nicematrix_first_row_int \g__nicematrix_row_total_int
+ {
+ \int_step_inline:nnn \l__nicematrix_first_col_int \g__nicematrix_col_total_int
+ {
+ \cs_if_exist:cT { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - ####1 }
+ {
+ \pgfscope
+ \pgftransformshift
+ { \pgfpointanchor { \__nicematrix_env: - ##1 - ####1 } { north~west } }
+ \pgfnode
+ { rectangle }
+ { center }
+ {
+ \hbox
+ { \pgfsys@markposition { \__nicematrix_env: - ##1 - ####1 - NW } }
+ }
+ { }
+ { }
+ \endpgfscope
+ \pgfscope
+ \pgftransformshift
+ { \pgfpointanchor { \__nicematrix_env: - ##1 - ####1 } { south~east } }
+ \pgfnode
+ { rectangle }
+ { center }
+ {
+ \hbox
+ { \pgfsys@markposition { \__nicematrix_env: - ##1 - ####1 - SE } }
+ }
+ { }
+ { }
+ \endpgfscope
+ }
+ }
+ }
+ \endpgfpicture
+ \__nicematrix_create_extra_nodes:
+ }
\cs_new_protected:Npn \__nicematrix_create_diag_nodes:
{
\pgfpicture
@@ -4206,8 +4353,8 @@
\cs_new_protected:Npn \__nicematrix_draw_vlines:
{
\int_step_inline:nnn
- { \bool_if:NTF \g__nicematrix_NiceArray_bool 1 2 }
- { \bool_if:NTF \g__nicematrix_NiceArray_bool { \__nicematrix_succ:n \c@jCol } \c@jCol }
+ { \bool_if:NTF \l__nicematrix_NiceArray_bool 1 2 }
+ { \bool_if:NTF \l__nicematrix_NiceArray_bool { \__nicematrix_succ:n \c@jCol } \c@jCol }
{
\tl_if_eq:NnF \l__nicematrix_vlines_clist { all }
{ \clist_if_in:NnT \l__nicematrix_vlines_clist { ##1 } }
@@ -4329,8 +4476,8 @@
\cs_new_protected:Npn \__nicematrix_draw_hlines:
{
\int_step_inline:nnn
- { \bool_if:NTF \g__nicematrix_NiceArray_bool 1 2 }
- { \bool_if:NTF \g__nicematrix_NiceArray_bool { \__nicematrix_succ:n \c@iRow } \c@iRow }
+ { \bool_if:NTF \l__nicematrix_NiceArray_bool 1 2 }
+ { \bool_if:NTF \l__nicematrix_NiceArray_bool { \__nicematrix_succ:n \c@iRow } \c@iRow }
{
\tl_if_eq:NnF \l__nicematrix_hlines_clist { all }
{ \clist_if_in:NnT \l__nicematrix_hlines_clist { ##1 } }
@@ -4547,14 +4694,14 @@
\dim_set:Nn \l__nicematrix_x_initial_dim
{
\pgf@x +
- \bool_if:NTF \g__nicematrix_NiceArray_bool \c_zero_dim \arraycolsep
+ \bool_if:NTF \l__nicematrix_NiceArray_bool \c_zero_dim \arraycolsep
- \l__nicematrix_left_margin_dim
}
\__nicematrix_qpoint:n { col - \__nicematrix_succ:n \c@jCol }
\dim_set:Nn \l__nicematrix_x_final_dim
{
\pgf@x -
- \bool_if:NTF \g__nicematrix_NiceArray_bool \c_zero_dim \arraycolsep
+ \bool_if:NTF \l__nicematrix_NiceArray_bool \c_zero_dim \arraycolsep
+ \l__nicematrix_right_margin_dim
}
\tl_if_eq:NnF \g__nicematrix_left_delim_tl (
@@ -5536,9 +5683,10 @@
\__nicematrix_define_com:nnn B \{ \}
\NewDocumentCommand \AutoNiceMatrix { O { } m O { } m ! O { } }
{
- \bool_gset_true:N \g__nicematrix_NiceArray_bool
+ \group_begin:
+ \bool_set_true:N \l__nicematrix_NiceArray_bool
\AutoNiceMatrixWithDelims . . { #2 } { #4 } [ #1 , #3 , #5 ]
- \bool_gset_false: \g__nicematrix_NiceArray_bool
+ \group_end:
}
\cs_set_eq:NN \__nicematrix_old_dotfill \dotfill
\cs_new_protected:Npn \__nicematrix_dotfill:
@@ -6130,11 +6278,6 @@
the~key~'corners'~in~your~\__nicematrix_full_name_env:.\\
If~you~go~on,~this~key~will~be~ignored.
}
-\__nicematrix_msg_new:nn { delimiters-color deleted }
- {
- The~key~'delimiters-color'~has~been~renamed~'delimiters/color'.\\
- ~However,~you~can~go~on~for~this~time.
- }
\seq_new:N \c__nicematrix_types_of_matrix_seq
\seq_set_from_clist:Nn \c__nicematrix_types_of_matrix_seq
{
@@ -6518,7 +6661,7 @@
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
- delimiters/color,~
+ delimiters~(several~subkeys),~
end-of-row,~
first-col,~
first-row,~
@@ -6618,7 +6761,7 @@
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
- delimiters/color,~
+ delimiters~(several~subkeys),~
extra-left-margin,~
extra-right-margin,~
first-col,~