summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/nicematrix
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-04-25 20:00:35 +0000
committerKarl Berry <karl@freefriends.org>2021-04-25 20:00:35 +0000
commit9a7fbd3067b48f35e170f7ce637050f224b30453 (patch)
tree6e959ba419d8068785e588249f544d8c798c97ce /Master/texmf-dist/tex/latex/nicematrix
parent59feb2e8c60220eb9ac745fe9ed9b827a63eda6a (diff)
nicematrix (25apr21)
git-svn-id: svn://tug.org/texlive/trunk@58987 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/nicematrix')
-rw-r--r--Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty677
1 files changed, 431 insertions, 246 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
index 1c9828f225f..1f21908183f 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.14}
-\def\myfiledate{2021/04/08}
+\def\myfileversion{5.15}
+\def\myfiledate{2021/04/25}
\RequirePackage{pgfcore}
\usepgfmodule{shapes}
\RequirePackage{l3keys2e}
@@ -263,7 +263,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 \l__nicematrix_NiceArray_bool
+\bool_new:N \g__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
@@ -310,6 +310,7 @@
\seq_new:N \g__nicematrix_pos_of_blocks_seq
\seq_new:N \g__nicematrix_pos_of_xdots_seq
\seq_new:N \g__nicematrix_pos_of_stroken_blocks_seq
+\seq_new:N \l__nicematrix_corners_cells_seq
\seq_new:N \g__nicematrix_submatrix_names_seq
\int_new:N \l__nicematrix_row_min_int
\int_new:N \l__nicematrix_row_max_int
@@ -328,6 +329,7 @@
\tl_new:N \l__nicematrix_vpos_of_block_tl
\tl_set:Nn \l__nicematrix_vpos_of_block_tl { c }
\bool_new:N \l__nicematrix_draw_first_bool
+\bool_new:N \l__nicematrix_hvlines_block_bool
\int_new:N \g__nicematrix_block_box_int
\dim_new:N \l__nicematrix_submatrix_extra_height_dim
\dim_new:N \l__nicematrix_submatrix_left_xshift_dim
@@ -384,7 +386,7 @@
}
\NewDocumentCommand \tabularnote { m }
{
- \bool_if:nTF { ! \l__nicematrix_NiceArray_bool && \l__nicematrix_in_env_bool }
+ \bool_if:nTF { ! \g__nicematrix_NiceArray_bool && \l__nicematrix_in_env_bool }
{ \__nicematrix_error:n { tabularnote~forbidden } }
{
\int_incr:N \l__nicematrix_number_of_notes_int
@@ -739,7 +741,9 @@
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 .tl_set:N = \l__nicematrix_delimiters_color_tl ,
+ 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 } }
@@ -795,7 +799,9 @@
small .value_forbidden:n = true ,
delimiters / color .tl_set:N = \l__nicematrix_delimiters_color_tl ,
delimiters / color .value_required:n = true ,
- delimiters-color .tl_set:N = \l__nicematrix_delimiters_color_tl ,
+ 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 }
}
@@ -812,8 +818,9 @@
notes / bottomrule .default:n = true ,
tabularnote .tl_set:N = \l__nicematrix_tabularnote_tl ,
tabularnote .value_required: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 .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 } ,
@@ -1200,6 +1207,12 @@
\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
@@ -1307,22 +1320,22 @@
}
}
\__nicematrix_pre_array_ii:
+ \box_clear_new:N \l__nicematrix_the_array_box
+ \bool_if:NT \c__nicematrix_define_L_C_R_bool \__nicematrix_define_L_C_R:
+ \__nicematrix_construct_preamble:
\dim_zero_new:N \l__nicematrix_left_delim_dim
\dim_zero_new:N \l__nicematrix_right_delim_dim
- \bool_if:NTF \l__nicematrix_NiceArray_bool
+ \bool_if:NTF \g__nicematrix_NiceArray_bool
{
\dim_gset:Nn \l__nicematrix_left_delim_dim { 2 \arraycolsep }
\dim_gset:Nn \l__nicematrix_right_delim_dim { 2 \arraycolsep }
}
{
- \hbox_set:Nn \l_tmpa_box { $ \bBigg@ 5 \l__nicematrix_left_delim_tl $ }
+ \hbox_set:Nn \l_tmpa_box { $ \bBigg@ 5 \g__nicematrix_left_delim_tl $ }
\dim_set:Nn \l__nicematrix_left_delim_dim { \box_wd:N \l_tmpa_box }
- \hbox_set:Nn \l_tmpa_box { $ \bBigg@ 5 \l__nicematrix_right_delim_tl $ }
+ \hbox_set:Nn \l_tmpa_box { $ \bBigg@ 5 \g__nicematrix_right_delim_tl $ }
\dim_set:Nn \l__nicematrix_right_delim_dim { \box_wd:N \l_tmpa_box }
}
- \box_clear_new:N \l__nicematrix_the_array_box
- \bool_if:NT \c__nicematrix_define_L_C_R_bool \__nicematrix_define_L_C_R:
- \__nicematrix_construct_preamble:
\hbox_set:Nw \l__nicematrix_the_array_box
\skip_horizontal:N \l__nicematrix_left_margin_dim
\skip_horizontal:N \l__nicematrix_extra_left_margin_dim
@@ -1343,8 +1356,8 @@
\__nicematrix_provide_pgfsyspdfmark:
\bool_if:NT \c__nicematrix_footnote_bool \savenotes
\bgroup
- \tl_set:Nn \l__nicematrix_left_delim_tl { #1 }
- \tl_set:Nn \l__nicematrix_right_delim_tl { #2 }
+ \tl_gset:Nn \g__nicematrix_left_delim_tl { #1 }
+ \tl_gset:Nn \g__nicematrix_right_delim_tl { #2 }
\tl_gset:Nn \g__nicematrix_preamble_tl { #4 }
\int_gzero:N \g__nicematrix_block_box_int
\dim_zero:N \g__nicematrix_width_last_col_dim
@@ -1378,7 +1391,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 \l__nicematrix_NiceArray_bool
+ \bool_if:NTF \g__nicematrix_NiceArray_bool
{ \keys_set:nn { NiceMatrix / NiceArray } }
{ \keys_set:nn { NiceMatrix / pNiceArray } }
{ #3 , #5 }
@@ -1419,7 +1432,7 @@
\skip_horizontal:N \col@sep
\skip_horizontal:N \g__nicematrix_width_first_col_dim
}
- \bool_if:NTF \l__nicematrix_NiceArray_bool
+ \bool_if:NTF \g__nicematrix_NiceArray_bool
{
\str_case:VnF \l__nicematrix_baseline_tl
{
@@ -1446,7 +1459,7 @@
\c_math_toggle_token
\tl_if_empty:NF \l__nicematrix_delimiters_color_tl
{ \color { \l__nicematrix_delimiters_color_tl } }
- \exp_after:wN \left \l__nicematrix_left_delim_tl
+ \exp_after:wN \left \g__nicematrix_left_delim_tl
\vcenter
{
\skip_vertical:N -\l_tmpa_dim
@@ -1464,11 +1477,14 @@
}
\tl_if_empty:NF \l__nicematrix_delimiters_color_tl
{ \color { \l__nicematrix_delimiters_color_tl } }
- \exp_after:wN \right \l__nicematrix_right_delim_tl
+ \exp_after:wN \right \g__nicematrix_right_delim_tl
\c_math_toggle_token
}
\bool_if:NTF \l__nicematrix_delimiters_max_width_bool
- { \__nicematrix_put_box_in_flow_bis:nn { #1 } { #2 } }
+ {
+ \__nicematrix_put_box_in_flow_bis:nn
+ \g__nicematrix_left_delim_tl \g__nicematrix_right_delim_tl
+ }
\__nicematrix_put_box_in_flow:
}
\bool_if:NT \g__nicematrix_last_col_found_bool
@@ -1515,7 +1531,9 @@
}
\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
@@ -1530,7 +1548,7 @@
{
\bool_lazy_all:nT
{
- \l__nicematrix_NiceArray_bool
+ \g__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 }
@@ -1542,7 +1560,7 @@
{
\bool_lazy_all:nT
{
- \l__nicematrix_NiceArray_bool
+ \g__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 }
@@ -1576,9 +1594,9 @@
( { \__nicematrix_patch_preamble_vii:n #1 }
[ { \__nicematrix_patch_preamble_vii:n #1 }
\{ { \__nicematrix_patch_preamble_vii:n #1 }
- ) { \__nicematrix_patch_preamble_viii:n #1 }
- ] { \__nicematrix_patch_preamble_viii:n #1 }
- \} { \__nicematrix_patch_preamble_viii:n #1 }
+ ) { \__nicematrix_patch_preamble_viii:nn #1 }
+ ] { \__nicematrix_patch_preamble_viii:nn #1 }
+ \} { \__nicematrix_patch_preamble_viii:nn #1 }
C { \__nicematrix_error:nn { old~column~type } #1 }
L { \__nicematrix_error:nn { old~column~type } #1 }
R { \__nicematrix_error:nn { old~column~type } #1 }
@@ -1661,14 +1679,14 @@
{
> {
\__nicematrix_Cell:
- \begin { minipage } [ #1 ] { #3 }
+ \begin { minipage } [ #1 ] { \dim_eval:n { #3 } }
\mode_leave_vertical:
\arraybackslash
- \vrule height \box_ht:N \@arstrutbox depth 0 pt width 0 pt % v. 5.11
+ \vrule height \box_ht:N \@arstrutbox depth 0 pt width 0 pt
}
c
< {
- \vrule height 0 pt depth \box_dp:N \@arstrutbox width 0 pt % v. 5.11
+ \vrule height 0 pt depth \box_dp:N \@arstrutbox width 0 pt
\end { minipage }
\__nicematrix_end_Cell:
}
@@ -1706,33 +1724,73 @@
}
\cs_new_protected:Npn \__nicematrix_patch_preamble_vii:n #1
{
- \bool_if:NT \l__nicematrix_small_bool
- { \__nicematrix_fatal:n { Delimiter~with~small } }
- \int_compare:nNnT \c@jCol = \c_zero_int
- { \tl_gput_right:Nx \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:n
+ \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
+ {
+ \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
+ }
+ {
+ \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_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_viii:n #1
+\cs_new_protected:Npn \__nicematrix_patch_preamble_vii_i:n #1
{
- \bool_if:NT \l__nicematrix_small_bool
- { \__nicematrix_fatal:n { Delimiter~with~small } }
- \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
- { \__nicematrix_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool }
- \__nicematrix_patch_preamble_viii_i:n
+ \tl_if_in:nnTF { ( [ \{ ) ] \} } { #1 }
+ {
+ \__nicematrix_error:nn { delimiter~after~opening } { #1 }
+ \__nicematrix_patch_preamble:n
+ }
+ { \__nicematrix_patch_preamble:n #1 }
}
-\cs_new_protected:Npn \__nicematrix_patch_preamble_viii_i:n #1
+\cs_new_protected:Npn \__nicematrix_patch_preamble_viii:nn #1 #2
{
- \bool_lazy_any:nT
+ \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
+ }
{
- { \str_if_eq_p:nn { #1 } ( }
- { \str_if_eq_p:nn { #1 } [ }
- { \str_if_eq_p:nn { #1 } \{ }
- { \str_if_eq_p:nn { #1 } \q_stop }
+ \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
+ }
+ {
+ \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_patch_preamble:n #2
+ }
+ }
+ {
+ \tl_if_in:nnT { ( [ \{ } { #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_patch_preamble:n #2
+ }
}
- { \tl_gput_right:Nn \g__nicematrix_preamble_tl { ! { \enskip } } }
- \__nicematrix_patch_preamble:n #1
}
\cs_new_protected:Npn \__nicematrix_patch_preamble_xi:n #1
{
@@ -2250,7 +2308,7 @@
}
\NewDocumentEnvironment { NiceArray } { }
{
- \bool_set_true:N \l__nicematrix_NiceArray_bool
+ \bool_gset_true:N \g__nicematrix_NiceArray_bool
\str_if_empty:NT \g__nicematrix_name_env_str
{ \str_gset:Nn \g__nicematrix_name_env_str { NiceArray } }
\NiceArrayWithDelims . .
@@ -2385,7 +2443,6 @@
{ 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
@@ -2416,7 +2473,7 @@
{
{ \seq_if_empty_p:N \g__nicematrix_pos_of_blocks_seq }
{ \seq_if_empty_p:N \g__nicematrix_pos_of_xdots_seq }
- { \seq_if_empty_p:N \l__nicematrix_empty_corner_cells_seq }
+ { \seq_if_empty_p:N \l__nicematrix_corners_cells_seq }
}
{
\cs_set_eq:NN \__nicematrix_vline_i:nn \__nicematrix_vline_i_complete:nn
@@ -2460,6 +2517,7 @@
\iow_now:Nn \@mainaux \ExplSyntaxOff
\bool_set_true:N \l__nicematrix_code_before_bool
}
+ \bool_gset_false:N \g__nicematrix_NiceArray_bool
\str_gclear:N \g__nicematrix_name_env_str
\__nicematrix_restore_iRow_jCol:
\cs_gset_eq:NN \CT@arc@ \__nicematrix_old_CT@arc@
@@ -3480,7 +3538,7 @@
\bool_set_false:N \l__nicematrix_final_open_bool
\int_set:Nn \l__nicematrix_initial_i_int { #1 }
\int_set_eq:NN \l__nicematrix_final_i_int \l__nicematrix_initial_i_int
- \int_compare:nNnTF #2 = 1
+ \int_compare:nNnTF { #2 } = 1
{
\int_set:Nn \l__nicematrix_initial_j_int 1
\bool_set_true:N \l__nicematrix_initial_open_bool
@@ -3728,7 +3786,7 @@
{
\__nicematrix_add_to_colors_seq:xn
{ \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } }
- { \__nicematrix_rectanglecolor:nnn { #3 } { #4 } { 0 pt }}
+ { \__nicematrix_rectanglecolor:nnn { #3 } { #4 } { 0 pt } }
}
}
\NewDocumentCommand \__nicematrix_roundedrectanglecolor { O { } m m m m }
@@ -3771,45 +3829,13 @@
}
}
\keys_define:nn { NiceMatrix / arraycolor }
- {
- except-corners .clist_set:N = \l_tmpa_clist ,
- except-corners .default:n = { NW , SW , NE , SE }
- }
+ { except-corners .code:n = \__nicematrix_error:n { key except-corners } }
\NewDocumentCommand \__nicematrix_arraycolor { O { } m O { } }
{
\keys_set:nn { NiceMatrix / arraycolor } { #3 }
- \clist_if_empty:NTF \l_tmpa_clist
- {
- \__nicematrix_rectanglecolor [ #1 ] { #2 }
- { 1 - 1 } { \int_use:N \c@iRow - \int_use:N \c@jCol }
- }
- {
- \tl_gput_left:Nx \g__nicematrix_internal_code_after_tl
- {
- \__nicematrix_arraycolor_code_after:nnn
- { #1 }
- { \exp_not:n { #2 } }
- { \l_tmpa_clist }
- }
- }
- }
-\cs_new_protected:Npn \__nicematrix_arraycolor_code_after:nnn #1 #2 #3
- {
- \group_begin:
- \clist_set:Nn \l__nicematrix_corners_clist { #3 }
- \__nicematrix_compute_corners:
- \int_step_inline:nn \c@iRow
- {
- \int_step_inline:nn \c@jCol
- {
- \seq_if_in:NnF \l__nicematrix_empty_corner_cells_seq { ##1 - ####1 }
- {
- \tl_gput_left:Nx \g_nicematrix_code_before_tl
- { \__nicematrix_cellcolor [ #1 ] { \exp_not:n { #2 } } { ##1 - ####1 } }
- }
- }
- }
- \group_end:
+ \__nicematrix_rectanglecolor [ #1 ] { #2 }
+ { 1 - 1 }
+ { \int_use:N \c@iRow - \int_use:N \c@jCol }
}
\keys_define:nn { NiceMatrix / rowcolors }
{
@@ -3923,9 +3949,15 @@
\prg_return_true:
\prg_return_false:
}
-\cs_new:Npn \__nicematrix_cartesian_path: { \__nicematrix_cartesian_path:n { 0 pt } }
\cs_new_protected:Npn \__nicematrix_cartesian_path:n #1
{
+ \bool_lazy_and:nnT
+ { ! \seq_if_empty_p:N \l__nicematrix_corners_cells_seq }
+ { \dim_compare_p:nNn { #1 } = \c_zero_dim }
+ {
+ \__nicematrix_expand_clist:NN \l__nicematrix_cols_tl \c@jCol
+ \__nicematrix_expand_clist:NN \l__nicematrix_rows_tl \c@iRow
+ }
\clist_map_inline:Nn \l__nicematrix_cols_tl
{
\tl_set:Nn \l_tmpa_tl { ##1 }
@@ -3942,6 +3974,7 @@
{ \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } }
\int_compare:nNnT \l_tmpb_tl > \c@jCol
{ \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } }
+ \tl_set_eq:NN \l_tmpc_tl \l_tmpa_tl
\__nicematrix_qpoint:n { col - \l_tmpa_tl }
\int_compare:nNnTF \l__nicematrix_first_col_int = \l_tmpa_tl
{ \dim_set:Nn \l_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } }
@@ -3959,32 +3992,67 @@
{ \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } }
\int_compare:nNnT \l_tmpb_tl > \c@iRow
{ \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } }
- \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l_tmpb_tl }
- \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth }
- \__nicematrix_qpoint:n { row - \l_tmpa_tl }
- \dim_set:Nn \l_tmpd_dim { \pgf@y + 0.5 \arrayrulewidth }
- \pgfsetcornersarced { \pgfpoint { #1 } { #1 } }
- \pgfpathrectanglecorners
- { \pgfpoint \l_tmpc_dim \l_tmpd_dim }
- { \pgfpoint \l_tmpa_dim \l_tmpb_dim }
+ \seq_if_in:NxF \l__nicematrix_corners_cells_seq
+ { \l_tmpa_tl - \l_tmpc_tl }
+ {
+ \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l_tmpb_tl }
+ \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth }
+ \__nicematrix_qpoint:n { row - \l_tmpa_tl }
+ \dim_set:Nn \l_tmpd_dim { \pgf@y + 0.5 \arrayrulewidth }
+ \pgfsetcornersarced { \pgfpoint { #1 } { #1 } }
+ \pgfpathrectanglecorners
+ { \pgfpoint \l_tmpc_dim \l_tmpd_dim }
+ { \pgfpoint \l_tmpa_dim \l_tmpb_dim }
+ }
}
}
}
+\cs_new_protected:Npn \__nicematrix_cartesian_path: { \__nicematrix_cartesian_path:n { 0 pt } }
+\cs_new_protected:Npn \__nicematrix_expand_clist:NN #1 #2
+ {
+ \clist_set_eq:NN \l_tmpa_clist #1
+ \clist_clear:N #1
+ \clist_map_inline:Nn \l_tmpa_clist
+ {
+ \tl_set:Nn \l_tmpa_tl { ##1 }
+ \tl_if_in:NnTF \l_tmpa_tl { - }
+ { \__nicematrix_cut_on_hyphen:w ##1 \q_stop }
+ { \__nicematrix_cut_on_hyphen:w ##1 - ##1 \q_stop }
+ \bool_lazy_or:nnT
+ { \tl_if_blank_p:V \l_tmpa_tl }
+ { \str_if_eq_p:Vn \l_tmpa_tl { * } }
+ { \tl_set:Nn \l_tmpa_tl { 1 } }
+ \bool_lazy_or:nnT
+ { \tl_if_blank_p:V \l_tmpb_tl }
+ { \str_if_eq_p:Vn \l_tmpb_tl { * } }
+ { \tl_set:Nx \l_tmpb_tl { \int_use:N #2 } }
+ \int_compare:nNnT \l_tmpb_tl > #2
+ { \tl_set:Nx \l_tmpb_tl { \int_use:N #2 } }
+ \int_step_inline:nnn \l_tmpa_tl \l_tmpb_tl
+ { \clist_put_right:Nn #1 { ####1 } }
+ }
+ }
\NewDocumentCommand \__nicematrix_cellcolor_tabular { O { } m }
{
- \tl_gput_right:Nx \g_nicematrix_code_before_tl
+ \peek_remove_spaces:n
{
- \cellcolor [ #1 ] { \exp_not:n { #2 } }
- { \int_use:N \c@iRow - \int_use:N \c@jCol }
+ \tl_gput_right:Nx \g_nicematrix_code_before_tl
+ {
+ \cellcolor [ #1 ] { \exp_not:n { #2 } }
+ { \int_use:N \c@iRow - \int_use:N \c@jCol }
+ }
}
}
\NewDocumentCommand \__nicematrix_rowcolor_tabular { O { } m }
{
- \tl_gput_right:Nx \g_nicematrix_code_before_tl
+ \peek_remove_spaces:n
{
- \exp_not:N \rectanglecolor [ #1 ] { \exp_not:n { #2 } }
- { \int_use:N \c@iRow - \int_use:N \c@jCol }
- { \int_use:N \c@iRow - \exp_not:n { \int_use:N \c@jCol } }
+ \tl_gput_right:Nx \g_nicematrix_code_before_tl
+ {
+ \exp_not:N \rectanglecolor [ #1 ] { \exp_not:n { #2 } }
+ { \int_use:N \c@iRow - \int_use:N \c@jCol }
+ { \int_use:N \c@iRow - \exp_not:n { \int_use:N \c@jCol } }
+ }
}
}
\NewDocumentCommand \__nicematrix_columncolor_preamble { O { } m }
@@ -4073,20 +4141,20 @@
\int_compare:nNnTF \l_tmpb_tl = { \__nicematrix_succ:n \c@jCol }
{
\seq_if_in:NxT
- \l__nicematrix_empty_corner_cells_seq
+ \l__nicematrix_corners_cells_seq
{ \l_tmpa_tl - \__nicematrix_pred:n \l_tmpb_tl }
{ \bool_set_false:N \g_tmpa_bool }
}
{
\seq_if_in:NxT
- \l__nicematrix_empty_corner_cells_seq
+ \l__nicematrix_corners_cells_seq
{ \l_tmpa_tl - \l_tmpb_tl }
{
\int_compare:nNnTF \l_tmpb_tl = 1
{ \bool_set_false:N \g_tmpa_bool }
{
\seq_if_in:NxT
- \l__nicematrix_empty_corner_cells_seq
+ \l__nicematrix_corners_cells_seq
{ \l_tmpa_tl - \__nicematrix_pred:n \l_tmpb_tl }
{ \bool_set_false:N \g_tmpa_bool }
}
@@ -4138,8 +4206,8 @@
\cs_new_protected:Npn \__nicematrix_draw_vlines:
{
\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 \g__nicematrix_NiceArray_bool 1 2 }
+ { \bool_if:NTF \g__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 } }
@@ -4198,20 +4266,20 @@
\int_compare:nNnTF \l_tmpa_tl = { \__nicematrix_succ:n \c@iRow }
{
\seq_if_in:NxT
- \l__nicematrix_empty_corner_cells_seq
+ \l__nicematrix_corners_cells_seq
{ \__nicematrix_pred:n \l_tmpa_tl - \l_tmpb_tl }
{ \bool_set_false:N \g_tmpa_bool }
}
{
\seq_if_in:NxT
- \l__nicematrix_empty_corner_cells_seq
+ \l__nicematrix_corners_cells_seq
{ \l_tmpa_tl - \l_tmpb_tl }
{
\int_compare:nNnTF \l_tmpa_tl = 1
{ \bool_set_false:N \g_tmpa_bool }
{
\seq_if_in:NxT
- \l__nicematrix_empty_corner_cells_seq
+ \l__nicematrix_corners_cells_seq
{ \__nicematrix_pred:n \l_tmpa_tl - \l_tmpb_tl }
{ \bool_set_false:N \g_tmpa_bool }
}
@@ -4261,8 +4329,8 @@
\cs_new_protected:Npn \__nicematrix_draw_hlines:
{
\int_step_inline:nnn
- { \bool_if:NTF \l__nicematrix_NiceArray_bool 1 2 }
- { \bool_if:NTF \l__nicematrix_NiceArray_bool { \__nicematrix_succ:n \c@iRow } \c@iRow }
+ { \bool_if:NTF \g__nicematrix_NiceArray_bool 1 2 }
+ { \bool_if:NTF \g__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 } }
@@ -4334,7 +4402,7 @@
}
\cs_new_protected:Npn \__nicematrix_compute_corners:
{
- \seq_clear_new:N \l__nicematrix_empty_corner_cells_seq
+ \seq_clear_new:N \l__nicematrix_corners_cells_seq
\clist_map_inline:Nn \l__nicematrix_corners_clist
{
\str_case:nnF { ##1 }
@@ -4350,6 +4418,17 @@
}
{ \__nicematrix_error:nn { bad~corner } { ##1 } }
}
+ \seq_if_empty:NF \l__nicematrix_corners_cells_seq
+ {
+ \iow_now:Nn \@mainaux \ExplSyntaxOn
+ \iow_now:Nx \@mainaux
+ {
+ \seq_gset_from_clist:cn
+ { c__nicematrix_corners_cells_ \int_use:N \g__nicematrix_env_int _ seq }
+ { \seq_use:Nnnn \l__nicematrix_corners_cells_seq , , , }
+ }
+ \iow_now:Nn \@mainaux \ExplSyntaxOff
+ }
}
\cs_new_protected:Npn \__nicematrix_compute_a_corner:nnnnnn #1 #2 #3 #4 #5 #6
{
@@ -4407,7 +4486,7 @@
{
\int_set:Nn \l__nicematrix_last_empty_column_int { ####1 }
\seq_put_right:Nn
- \l__nicematrix_empty_corner_cells_seq
+ \l__nicematrix_corners_cells_seq
{ ##1 - ####1 }
}
}
@@ -4468,19 +4547,19 @@
\dim_set:Nn \l__nicematrix_x_initial_dim
{
\pgf@x +
- \bool_if:NTF \l__nicematrix_NiceArray_bool \c_zero_dim \arraycolsep
+ \bool_if:NTF \g__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 \l__nicematrix_NiceArray_bool \c_zero_dim \arraycolsep
+ \bool_if:NTF \g__nicematrix_NiceArray_bool \c_zero_dim \arraycolsep
+ \l__nicematrix_right_margin_dim
}
- \tl_if_eq:NnF \l__nicematrix_left_delim_tl (
+ \tl_if_eq:NnF \g__nicematrix_left_delim_tl (
{ \dim_gadd:Nn \l__nicematrix_x_initial_dim { 0.5 \l__nicematrix_inter_dots_dim } }
- \tl_if_eq:NnF \l__nicematrix_right_delim_tl )
+ \tl_if_eq:NnF \g__nicematrix_right_delim_tl )
{ \dim_gsub:Nn \l__nicematrix_x_final_dim { 0.5 \l__nicematrix_inter_dots_dim } }
\tl_set_eq:NN \l__nicematrix_xdots_line_style_tl \c__nicematrix_standard_tl
\__nicematrix_draw_line:
@@ -4763,8 +4842,13 @@
}
\NewExpandableDocumentCommand \__nicematrix_Block: { O { } m D < > { } m }
{
- \tl_if_blank:nTF { #2 } { \__nicematrix_Block_i 1-1 \q_stop } { \__nicematrix_Block_i #2 \q_stop }
- { #1 } { #3 } { #4 }
+ \peek_remove_spaces:n
+ {
+ \tl_if_blank:nTF { #2 }
+ { \__nicematrix_Block_i 1-1 \q_stop }
+ { \__nicematrix_Block_i #2 \q_stop }
+ { #1 } { #3 } { #4 }
+ }
}
\cs_new:Npn \__nicematrix_Block_i #1-#2 \q_stop { \__nicematrix_Block_ii:nnnnn { #1 } { #2 } }
\cs_new_protected:Npn \__nicematrix_Block_ii:nnnnn #1 #2 #3 #4 #5
@@ -4962,6 +5046,8 @@
color .value_required:n = true ,
borders .clist_set:N = \l__nicematrix_borders_clist ,
borders .value_required:n = true ,
+ hvlines .bool_set:N = \l__nicematrix_hvlines_block_bool ,
+ hvlines .default:n = true ,
line-width .dim_set:N = \l__nicematrix_line_width_dim ,
line-width .value_required:n = true ,
l .code:n = \tl_set:Nn \l__nicematrix_hpos_of_block_tl l ,
@@ -5028,6 +5114,16 @@
\seq_gput_right:Nn \g__nicematrix_pos_of_stroken_blocks_seq
{ { #1 } { #2 } { #3 } { #4 } }
}
+ \bool_if:NT \l__nicematrix_hvlines_block_bool
+ {
+ \tl_gput_right:Nx \g_nicematrix_code_after_tl
+ {
+ \__nicematrix_hvlines_block:nnn
+ { \exp_not:n { #5 } }
+ { #1 - #2 }
+ { \int_use:N \l__nicematrix_last_row_int - \int_use:N \l__nicematrix_last_col_int }
+ }
+ }
\clist_if_empty:NF \l__nicematrix_borders_clist
{
\tl_gput_right:Nx \g_nicematrix_code_after_tl
@@ -5040,10 +5136,12 @@
}
\tl_if_empty:NF \l__nicematrix_fill_tl
{
+ \exp_last_unbraced:NV \__nicematrix_extract_brackets \l__nicematrix_fill_tl \q_stop
\tl_gput_right:Nx \g_nicematrix_code_before_tl
{
\exp_not:N \roundedrectanglecolor
- { \exp_not:V \l__nicematrix_fill_tl }
+ [ \l_tmpa_tl ]
+ { \exp_not:V \l_tmpb_tl }
{ #1 - #2 }
{ \int_use:N \l__nicematrix_last_row_int - \int_use:N \l__nicematrix_last_col_int }
{ \dim_use:N \l__nicematrix_rounded_corners_dim }
@@ -5204,6 +5302,13 @@
\endpgfpicture
\group_end:
}
+\NewDocumentCommand \__nicematrix_extract_brackets { O { } }
+ {
+ \tl_set:Nn \l_tmpa_tl { #1 }
+ \__nicematrix_store_in_tmpb_tl
+ }
+\cs_new_protected:Npn \__nicematrix_store_in_tmpb_tl #1 \q_stop
+ { \tl_set:Nn \l_tmpb_tl { #1 } }
\cs_new_protected:Npn \__nicematrix_stroke_block:nnn #1 #2 #3
{
\group_begin:
@@ -5261,6 +5366,46 @@
rounded-corners .dim_set:N = \l__nicematrix_rounded_corners_dim ,
rounded-corners .default:n = 4 pt
}
+
+\cs_new_protected:Npn \__nicematrix_hvlines_block:nnn #1 #2 #3
+ {
+ \dim_set_eq:NN \l__nicematrix_line_width_dim \arrayrulewidth
+ \keys_set_known:nn { NiceMatrix / BlockBorders } { #1 }
+ \__nicematrix_cut_on_hyphen:w #2 \q_stop
+ \tl_set_eq:NN \l_tmpc_tl \l_tmpa_tl
+ \tl_set_eq:NN \l_tmpd_tl \l_tmpb_tl
+ \__nicematrix_cut_on_hyphen:w #3 \q_stop
+ \tl_set:Nx \l_tmpa_tl { \int_eval:n { \l_tmpa_tl + 1 } }
+ \tl_set:Nx \l_tmpb_tl { \int_eval:n { \l_tmpb_tl + 1 } }
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgf@relevantforpicturesizefalse
+ \CT@arc@
+ \pgfsetlinewidth { 1.1 \l__nicematrix_line_width_dim }
+ \__nicematrix_qpoint:n { row - \l_tmpa_tl }
+ \dim_set_eq:NN \l_tmpa_dim \pgf@y
+ \__nicematrix_qpoint:n { row - \l_tmpc_tl }
+ \dim_set_eq:NN \l_tmpb_dim \pgf@y
+ \int_step_inline:nnn \l_tmpd_tl \l_tmpb_tl
+ {
+ \__nicematrix_qpoint:n { col - ##1 }
+ \pgfpathmoveto { \pgfpoint \pgf@x \l_tmpa_dim }
+ \pgfpathlineto { \pgfpoint \pgf@x \l_tmpb_dim }
+ \pgfusepathqstroke
+ }
+ \__nicematrix_qpoint:n { col - \l_tmpb_tl }
+ \dim_set:Nn \l_tmpa_dim { \pgf@x + 0.5 \arrayrulewidth }
+ \__nicematrix_qpoint:n { col - \l_tmpd_tl }
+ \dim_set:Nn \l_tmpb_dim { \pgf@x - 0.5 \arrayrulewidth }
+ \int_step_inline:nnn \l_tmpc_tl \l_tmpa_tl
+ {
+ \__nicematrix_qpoint:n { row - ##1 }
+ \pgfpathmoveto { \pgfpoint \l_tmpa_dim \pgf@y }
+ \pgfpathlineto { \pgfpoint \l_tmpb_dim \pgf@y }
+ \pgfusepathqstroke
+ }
+ \endpgfpicture
+ }
\cs_new_protected:Npn \__nicematrix_stroke_borders_block:nnn #1 #2 #3
{
\dim_set_eq:NN \l__nicematrix_line_width_dim \arrayrulewidth
@@ -5391,10 +5536,9 @@
\__nicematrix_define_com:nnn B \{ \}
\NewDocumentCommand \AutoNiceMatrix { O { } m O { } m ! O { } }
{
- \group_begin:
- \bool_set_true:N \l__nicematrix_NiceArray_bool
- \AutoNiceMatrixWithDelims . . { #2 } { #4 } [ #1 , #3 , #5 ]
- \group_end:
+ \bool_gset_true:N \g__nicematrix_NiceArray_bool
+ \AutoNiceMatrixWithDelims . . { #2 } { #4 } [ #1 , #3 , #5 ]
+ \bool_gset_false: \g__nicematrix_NiceArray_bool
}
\cs_set_eq:NN \__nicematrix_old_dotfill \dotfill
\cs_new_protected:Npn \__nicematrix_dotfill:
@@ -5644,7 +5788,7 @@
\dim_set_eq:NN \l__nicematrix_x_initial_dim \c_max_dim
\dim_set:Nn \l__nicematrix_x_final_dim { - \c_max_dim }
\bool_if:NTF \l__nicematrix_submatrix_slim_bool
- { \int_step_inline:nnn \l__nicematrix_first_i_tl \l__nicematrix_last_i_tl }
+ { \int_step_inline:nnn \l__nicematrix_first_i_tl \l__nicematrix_last_i_tl }
{ \int_step_inline:nnn \l__nicematrix_first_row_int \g__nicematrix_row_total_int }
{
\cs_if_exist:cT
@@ -5662,141 +5806,151 @@
{ \dim_max:nn \l__nicematrix_x_final_dim \pgf@x }
}
}
- \__nicematrix_qpoint:n { row - \l__nicematrix_first_i_tl - base }
- \dim_set:Nn \l__nicematrix_y_initial_dim
- { \pgf@y + ( \box_ht:N \strutbox + \extrarowheight ) * \arraystretch }
- \__nicematrix_qpoint:n { row - \l__nicematrix_last_i_tl - base }
- \dim_set:Nn \l__nicematrix_y_final_dim
- { \pgf@y - ( \box_dp:N \strutbox ) * \arraystretch }
- \int_step_inline:nnn \l__nicematrix_first_col_int \g__nicematrix_col_total_int
+ \dim_compare:nNnTF \l__nicematrix_x_initial_dim = \c_max_dim
+ { \__nicematrix_error:nn { impossible~delimiter } { left } }
{
- \cs_if_exist:cT
- { pgf @ sh @ ns @ \__nicematrix_env: - \l__nicematrix_first_i_tl - ##1 }
- {
- \pgfpointanchor { \__nicematrix_env: - \l__nicematrix_first_i_tl - ##1 } { north }
- \dim_set:Nn \l__nicematrix_y_initial_dim
- { \dim_max:nn \l__nicematrix_y_initial_dim \pgf@y }
- }
- \cs_if_exist:cT
- { pgf @ sh @ ns @ \__nicematrix_env: - \l__nicematrix_last_i_tl - ##1 }
- {
- \pgfpointanchor { \__nicematrix_env: - \l__nicematrix_last_i_tl - ##1 } { south }
- \dim_set:Nn \l__nicematrix_y_final_dim
- { \dim_min:nn \l__nicematrix_y_final_dim \pgf@y }
- }
+ \dim_compare:nNnTF \l__nicematrix_x_final_dim = { - \c_max_dim }
+ { \__nicematrix_error:nn { impossible~delimiter } { right } }
+ { \__nicematrix_sub_matrix_i:nn { #1 } { #4 } }
}
- \dim_set:Nn \l_tmpa_dim
+ \endpgfpicture
+ }
+ \group_end:
+ }
+\cs_new_protected:Npn \__nicematrix_sub_matrix_i:nn #1 #2
+ {
+ \__nicematrix_qpoint:n { row - \l__nicematrix_first_i_tl - base }
+ \dim_set:Nn \l__nicematrix_y_initial_dim
+ { \pgf@y + ( \box_ht:N \strutbox + \extrarowheight ) * \arraystretch }
+ \__nicematrix_qpoint:n { row - \l__nicematrix_last_i_tl - base }
+ \dim_set:Nn \l__nicematrix_y_final_dim
+ { \pgf@y - ( \box_dp:N \strutbox ) * \arraystretch }
+ \int_step_inline:nnn \l__nicematrix_first_col_int \g__nicematrix_col_total_int
+ {
+ \cs_if_exist:cT
+ { pgf @ sh @ ns @ \__nicematrix_env: - \l__nicematrix_first_i_tl - ##1 }
{
- \l__nicematrix_y_initial_dim - \l__nicematrix_y_final_dim +
- \l__nicematrix_submatrix_extra_height_dim - \arrayrulewidth
+ \pgfpointanchor { \__nicematrix_env: - \l__nicematrix_first_i_tl - ##1 } { north }
+ \dim_set:Nn \l__nicematrix_y_initial_dim
+ { \dim_max:nn \l__nicematrix_y_initial_dim \pgf@y }
}
- \dim_set_eq:NN \nulldelimiterspace \c_zero_dim
- \group_begin:
- \pgfsetlinewidth { 1.1 \arrayrulewidth }
- \tl_if_empty:NF \l__nicematrix_rules_color_tl
- { \exp_after:wN \__nicematrix_set_CT@arc@: \l__nicematrix_rules_color_tl \q_stop }
- \CT@arc@
- \seq_map_inline:Nn \g__nicematrix_cols_vlism_seq
+ \cs_if_exist:cT
+ { pgf @ sh @ ns @ \__nicematrix_env: - \l__nicematrix_last_i_tl - ##1 }
{
- \int_compare:nNnT \l__nicematrix_first_j_tl < { ##1 }
- {
- \int_compare:nNnT
- { ##1 } < { \int_eval:n { \l__nicematrix_last_j_tl + 1 } }
- {
- \__nicematrix_qpoint:n { col - ##1 }
- \pgfpathmoveto { \pgfpoint \pgf@x \l__nicematrix_y_initial_dim }
- \pgfpathlineto { \pgfpoint \pgf@x \l__nicematrix_y_final_dim }
- \pgfusepathqstroke
- }
- }
+ \pgfpointanchor { \__nicematrix_env: - \l__nicematrix_last_i_tl - ##1 } { south }
+ \dim_set:Nn \l__nicematrix_y_final_dim
+ { \dim_min:nn \l__nicematrix_y_final_dim \pgf@y }
}
- \tl_if_eq:NnTF \l__nicematrix_submatrix_vlines_clist { all }
- { \int_step_inline:nn { \l__nicematrix_last_j_tl - \l__nicematrix_first_j_tl } }
- { \clist_map_inline:Nn \l__nicematrix_submatrix_vlines_clist }
+ }
+ \dim_set:Nn \l_tmpa_dim
+ {
+ \l__nicematrix_y_initial_dim - \l__nicematrix_y_final_dim +
+ \l__nicematrix_submatrix_extra_height_dim - \arrayrulewidth
+ }
+ \dim_set_eq:NN \nulldelimiterspace \c_zero_dim
+ \group_begin:
+ \pgfsetlinewidth { 1.1 \arrayrulewidth }
+ \tl_if_empty:NF \l__nicematrix_rules_color_tl
+ { \exp_after:wN \__nicematrix_set_CT@arc@: \l__nicematrix_rules_color_tl \q_stop }
+ \CT@arc@
+ \seq_map_inline:Nn \g__nicematrix_cols_vlism_seq
+ {
+ \int_compare:nNnT \l__nicematrix_first_j_tl < { ##1 }
{
- \bool_lazy_and:nnTF
- { \int_compare_p:nNn { ##1 } > 0 }
- {
- \int_compare_p:nNn
- { ##1 } < { \l__nicematrix_last_j_tl - \l__nicematrix_first_j_tl + 1 } }
+ \int_compare:nNnT
+ { ##1 } < { \int_eval:n { \l__nicematrix_last_j_tl + 1 } }
{
- \__nicematrix_qpoint:n { col - \int_eval:n { ##1 + \l__nicematrix_first_j_tl } }
+ \__nicematrix_qpoint:n { col - ##1 }
\pgfpathmoveto { \pgfpoint \pgf@x \l__nicematrix_y_initial_dim }
\pgfpathlineto { \pgfpoint \pgf@x \l__nicematrix_y_final_dim }
\pgfusepathqstroke
}
- { \__nicematrix_error:nnn { Wrong~line~in~SubMatrix } { vertical } { ##1 } }
}
- \tl_if_eq:NnTF \l__nicematrix_submatrix_hlines_clist { all }
- { \int_step_inline:nn { \l__nicematrix_last_i_tl - \l__nicematrix_first_i_tl } }
- { \clist_map_inline:Nn \l__nicematrix_submatrix_hlines_clist }
+ }
+ \tl_if_eq:NnTF \l__nicematrix_submatrix_vlines_clist { all }
+ { \int_step_inline:nn { \l__nicematrix_last_j_tl - \l__nicematrix_first_j_tl } }
+ { \clist_map_inline:Nn \l__nicematrix_submatrix_vlines_clist }
+ {
+ \bool_lazy_and:nnTF
+ { \int_compare_p:nNn { ##1 } > 0 }
{
- \bool_lazy_and:nnTF
- { \int_compare_p:nNn { ##1 } > 0 }
- {
- \int_compare_p:nNn
- { ##1 } < { \l__nicematrix_last_i_tl - \l__nicematrix_first_i_tl + 1 } }
- {
- \__nicematrix_qpoint:n { row - \int_eval:n { ##1 + \l__nicematrix_first_i_tl } }
- \group_begin:
- \dim_set:Nn \l_tmpa_dim
- { \l__nicematrix_x_initial_dim - \l__nicematrix_submatrix_left_xshift_dim }
- \str_case:nn { #1 }
- {
- ( { \dim_sub:Nn \l_tmpa_dim { 0.9 mm } }
- [ { \dim_sub:Nn \l_tmpa_dim { 0.2 mm } }
- \{ { \dim_sub:Nn \l_tmpa_dim { 0.9 mm } }
- }
- \pgfpathmoveto { \pgfpoint \l_tmpa_dim \pgf@y }
- \dim_set:Nn \l_tmpb_dim
- { \l__nicematrix_x_final_dim + \l__nicematrix_submatrix_right_xshift_dim }
- \str_case:nn { #4 }
- {
- ) { \dim_add:Nn \l_tmpb_dim { 0.9 mm } }
- ] { \dim_add:Nn \l_tmpb_dim { 0.2 mm } }
- \} { \dim_add:Nn \l_tmpb_dim { 0.9 mm } }
- }
- \pgfpathlineto { \pgfpoint \l_tmpb_dim \pgf@y }
- \pgfusepathqstroke
- \group_end:
- }
- { \__nicematrix_error:nnn { Wrong~line~in~SubMatrix } { horizontal } { ##1 } }
- }
- \str_if_empty:NF \l__nicematrix_submatrix_name_str
+ \int_compare_p:nNn
+ { ##1 } < { \l__nicematrix_last_j_tl - \l__nicematrix_first_j_tl + 1 } }
{
- \__nicematrix_pgf_rect_node:nnnnn \l__nicematrix_submatrix_name_str
- \l__nicematrix_x_initial_dim \l__nicematrix_y_initial_dim
- \l__nicematrix_x_final_dim \l__nicematrix_y_final_dim
+ \__nicematrix_qpoint:n { col - \int_eval:n { ##1 + \l__nicematrix_first_j_tl } }
+ \pgfpathmoveto { \pgfpoint \pgf@x \l__nicematrix_y_initial_dim }
+ \pgfpathlineto { \pgfpoint \pgf@x \l__nicematrix_y_final_dim }
+ \pgfusepathqstroke
}
- \group_end:
- \begin { pgfscope }
- \pgftransformshift
+ { \__nicematrix_error:nnn { Wrong~line~in~SubMatrix } { vertical } { ##1 } }
+ }
+ \tl_if_eq:NnTF \l__nicematrix_submatrix_hlines_clist { all }
+ { \int_step_inline:nn { \l__nicematrix_last_i_tl - \l__nicematrix_first_i_tl } }
+ { \clist_map_inline:Nn \l__nicematrix_submatrix_hlines_clist }
+ {
+ \bool_lazy_and:nnTF
+ { \int_compare_p:nNn { ##1 } > 0 }
{
- \pgfpoint
- { \l__nicematrix_x_initial_dim - \l__nicematrix_submatrix_left_xshift_dim }
- { ( \l__nicematrix_y_initial_dim + \l__nicematrix_y_final_dim ) / 2 }
- }
- \str_if_empty:NTF \l__nicematrix_submatrix_name_str
- { \__nicematrix_node_left:nn #1 { } }
- { \__nicematrix_node_left:nn #1 { \__nicematrix_env: - \l__nicematrix_submatrix_name_str - left } }
- \end { pgfscope }
- \pgftransformshift
+ \int_compare_p:nNn
+ { ##1 } < { \l__nicematrix_last_i_tl - \l__nicematrix_first_i_tl + 1 } }
{
- \pgfpoint
+ \__nicematrix_qpoint:n { row - \int_eval:n { ##1 + \l__nicematrix_first_i_tl } }
+ \group_begin:
+ \dim_set:Nn \l_tmpa_dim
+ { \l__nicematrix_x_initial_dim - \l__nicematrix_submatrix_left_xshift_dim }
+ \str_case:nn { #1 }
+ {
+ ( { \dim_sub:Nn \l_tmpa_dim { 0.9 mm } }
+ [ { \dim_sub:Nn \l_tmpa_dim { 0.2 mm } }
+ \{ { \dim_sub:Nn \l_tmpa_dim { 0.9 mm } }
+ }
+ \pgfpathmoveto { \pgfpoint \l_tmpa_dim \pgf@y }
+ \dim_set:Nn \l_tmpb_dim
{ \l__nicematrix_x_final_dim + \l__nicematrix_submatrix_right_xshift_dim }
- { ( \l__nicematrix_y_initial_dim + \l__nicematrix_y_final_dim ) / 2 }
- }
- \str_if_empty:NTF \l__nicematrix_submatrix_name_str
- { \__nicematrix_node_right:nn #4 { } }
- {
- \__nicematrix_node_right:nn #4 { \__nicematrix_env: - \l__nicematrix_submatrix_name_str - right }
+ \str_case:nn { #2 }
+ {
+ ) { \dim_add:Nn \l_tmpb_dim { 0.9 mm } }
+ ] { \dim_add:Nn \l_tmpb_dim { 0.2 mm } }
+ \} { \dim_add:Nn \l_tmpb_dim { 0.9 mm } }
+ }
+ \pgfpathlineto { \pgfpoint \l_tmpb_dim \pgf@y }
+ \pgfusepathqstroke
+ \group_end:
}
- \endpgfpicture
- \cs_set_eq:NN \pgfpointanchor \__nicematrix_pgfpointanchor:n
- \flag_clear_new:n { nicematrix }
- \l__nicematrix_code_tl
+ { \__nicematrix_error:nnn { Wrong~line~in~SubMatrix } { horizontal } { ##1 } }
+ }
+ \str_if_empty:NF \l__nicematrix_submatrix_name_str
+ {
+ \__nicematrix_pgf_rect_node:nnnnn \l__nicematrix_submatrix_name_str
+ \l__nicematrix_x_initial_dim \l__nicematrix_y_initial_dim
+ \l__nicematrix_x_final_dim \l__nicematrix_y_final_dim
}
\group_end:
+ \begin { pgfscope }
+ \pgftransformshift
+ {
+ \pgfpoint
+ { \l__nicematrix_x_initial_dim - \l__nicematrix_submatrix_left_xshift_dim }
+ { ( \l__nicematrix_y_initial_dim + \l__nicematrix_y_final_dim ) / 2 }
+ }
+ \str_if_empty:NTF \l__nicematrix_submatrix_name_str
+ { \__nicematrix_node_left:nn #1 { } }
+ { \__nicematrix_node_left:nn #1 { \__nicematrix_env: - \l__nicematrix_submatrix_name_str - left } }
+ \end { pgfscope }
+ \pgftransformshift
+ {
+ \pgfpoint
+ { \l__nicematrix_x_final_dim + \l__nicematrix_submatrix_right_xshift_dim }
+ { ( \l__nicematrix_y_initial_dim + \l__nicematrix_y_final_dim ) / 2 }
+ }
+ \str_if_empty:NTF \l__nicematrix_submatrix_name_str
+ { \__nicematrix_node_right:nn #2 { } }
+ {
+ \__nicematrix_node_right:nn #2 { \__nicematrix_env: - \l__nicematrix_submatrix_name_str - right }
+ }
+ \cs_set_eq:NN \pgfpointanchor \__nicematrix_pgfpointanchor:n
+ \flag_clear_new:n { nicematrix }
+ \l__nicematrix_code_tl
}
\cs_set_eq:NN \__nicematrix_old_pgfpointanchor \pgfpointanchor
\cs_new_protected:Npn \__nicematrix_pgfpointanchor:n #1
@@ -5969,6 +6123,18 @@
}
\bool_set_true:N \c__nicematrix_footnote_bool
}
+\__nicematrix_msg_new:nn { key except-corners }
+ {
+ The~key~'except-corners'~has~been~deleted~for~the~command~\token_to_str:N
+ \arraycolor\ in~the~\token_to_str:N \CodeBefore.~You~should~instead~use~
+ 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
{
@@ -6049,6 +6215,16 @@
You~can't~use~the~command~#1 in~the~last~row~(exterior)~of~the~array.\\
If~you~go~on,~this~command~will~be~ignored.
}
+\__nicematrix_msg_new:nn { double~closing~delimiter }
+ {
+ You~can't~put~a~second~closing~delimiter~"#1"~just~after~a~first~closing~
+ delimiter.~This~delimiter~will~be~ignored.
+ }
+\__nicematrix_msg_new:nn { delimiter~after~opening }
+ {
+ You~can't~put~a~second~delimiter~"#1"~just~after~a~first~opening~
+ delimiter.~This~delimiter~will~be~ignored.
+ }
\__nicematrix_msg_new:nn { bad~option~for~line-style }
{
Since~you~haven't~loaded~Tikz,~the~only~value~you~can~give~to~'line-style'~
@@ -6115,6 +6291,15 @@
\token_to_str:N \SubMatrix\ of~your~\__nicematrix_full_name_env:\ but~that~
number~is~not~valid.~If~you~go~on,~it~will~be~ignored.
}
+\__nicematrix_msg_new:nn { impossible~delimiter }
+ {
+ It's~impossible~to~draw~the~#1~delimiter~of~your~
+ \token_to_str:N \SubMatrix\ because~all~the~cells~are~empty~
+ in~that~column.
+ \bool_if:NT \l__nicematrix_submatrix_slim_bool
+ { ~Maybe~you~should~try~without~the~key~'slim'. } \\
+ If~you~go~on,~this~\token_to_str:N \SubMatrix\ will~be~ignored.
+ }
\__nicematrix_msg_new:nn { empty~environment }
{ Your~\__nicematrix_full_name_env:\ is~empty.~This~error~is~fatal. }
\__nicematrix_msg_new:nn { Delimiter~with~small }
@@ -6255,8 +6440,8 @@
For~a~list~of~the~available~keys,~type~H~<return>.
}
{
- The~available~keys~are~(in~alphabetic~order):~borders,~c,~draw,~fill,~l,~
- line-width,~rounded-corners~and~r.
+ The~available~keys~are~(in~alphabetic~order):~b,~borders,~c,~draw,~fill,~
+ hvlines,~l,~line-width,~rounded-corners,~r~and~t.
}
\__nicematrix_msg_new:nnn { Unknown~key~for~CodeAfter }
{