summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-07-31 21:45:27 +0000
committerKarl Berry <karl@freefriends.org>2020-07-31 21:45:27 +0000
commitc41ed8c91eb4f80f74ce582bdd6c8d7bb73ec447 (patch)
treecf2e002568114c0dc7a7a7f7c4ec4069b42b0a45 /Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
parent12289572e235d473831378c99e780bb99667512f (diff)
nicematrix (31jul20)
git-svn-id: svn://tug.org/texlive/trunk@56008 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.sty765
1 files changed, 489 insertions, 276 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
index 54c7dd90b56..a4b6441abf1 100644
--- a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
+++ b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
@@ -18,8 +18,9 @@
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%%
-\def\myfileversion{5.0}
-\def\myfiledate{2020/07/15}
+\def\myfileversion{5.1}
+\def\myfiledate{2020/07/31}
+
\RequirePackage{pgfcore}
\usepgfmodule{shapes}
\RequirePackage{l3keys2e}
@@ -35,6 +36,7 @@
\cs_new_protected:Npn \__nicematrix_error:nn { \msg_error:nnn { nicematrix } }
\cs_new_protected:Npn \__nicematrix_error:nnn { \msg_error:nnnn { nicematrix } }
\cs_new_protected:Npn \__nicematrix_fatal:n { \msg_fatal:nn { nicematrix } }
+\cs_new_protected:Npn \__nicematrix_fatal:nn { \msg_fatal:nnn { nicematrix } }
\cs_new_protected:Npn \__nicematrix_msg_new:nn { \msg_new:nnn { nicematrix } }
\cs_new_protected:Npn \__nicematrix_msg_new:nnn { \msg_new:nnnn { nicematrix } }
\cs_new_protected:Npn \__nicematrix_msg_redirect_name:nn
@@ -208,6 +210,18 @@
}
}
}
+\regex_const:Nn \c__nicematrix_columncolor_regex { \c { columncolor } }
+\cs_new_protected:Npn \__nicematrix_provide_pgfsyspdfmark:
+ {
+ \iow_now:Nn \@mainaux
+ {
+ \ExplSyntaxOn
+ \cs_if_free:NT \pgfsyspdfmark
+ { \cs_set_eq:NN \pgfsyspdfmark \use:nnn }
+ \ExplSyntaxOff
+ }
+ \cs_gset_eq:NN \__nicematrix_provide_pgfsyspdfmark: \prg_do_nothing:
+ }
\bool_new:N \c__nicematrix_define_L_C_R_bool
\cs_new_protected:Npn \__nicematrix_define_L_C_R:
{
@@ -227,6 +241,8 @@
\bool_new:N \l__nicematrix_in_env_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
\cs_new_protected:Npn \__nicematrix_test_if_math_mode:
{
\if_mode_math: \else:
@@ -243,12 +259,13 @@
{ command \space \c_backslash_str \g__nicematrix_name_env_str }
{ environment \space \{ \g__nicematrix_name_env_str \} }
}
-\tl_new:N \g__nicematrix_code_after_tl
+\tl_new:N \g_nicematrix_code_after_tl
\tl_new:N \g__nicematrix_internal_code_after_tl
\int_new:N \l__nicematrix_old_iRow_int
\int_new:N \l__nicematrix_old_jCol_int
\tl_new:N \l__nicematrix_rules_color_tl
\bool_new:N \g__nicematrix_row_of_col_done_bool
+\tl_new:N \l__nicematrix_code_before_tl
\bool_new:N \l__nicematrix_code_before_bool
\dim_new:N \l__nicematrix_x_initial_dim
\dim_new:N \l__nicematrix_y_initial_dim
@@ -263,6 +280,8 @@
\seq_new:N \g__nicematrix_blocks_seq
\seq_new:N \g__nicematrix_pos_of_blocks_seq
\seq_new:N \g__nicematrix_pos_of_xdots_seq
+\int_new:N \g__nicematrix_static_num_of_col_int
+\tl_new:N \l__nicematrix_color_tl
\int_new:N \l__nicematrix_first_row_int
\int_set:Nn \l__nicematrix_first_row_int 1
\int_new:N \l__nicematrix_first_col_int
@@ -386,6 +405,7 @@
{ }
\end { pgfscope }
}
+\bool_new:N \l__nicematrix_colortbl_like_bool
\bool_new:N \l__nicematrix_standard_cline_bool
\dim_new:N \l__nicematrix_cell_space_top_limit_dim
\dim_new:N \l__nicematrix_cell_space_bottom_limit_dim
@@ -501,7 +521,7 @@
extra-right-margin .dim_set:N = \l__nicematrix_extra_right_margin_dim ,
extra-margin .meta:n =
{ extra-left-margin = #1 , extra-right-margin = #1 } ,
- extra-margin .value_required:n = true
+ extra-margin .value_required:n = true ,
}
\keys_define:nn { NiceMatrix / Env }
{
@@ -511,7 +531,7 @@
{
\tl_if_empty:nF { #1 }
{
- \tl_set:Nn \l__nicematrix_code_before_tl { #1 }
+ \tl_put_right:Nn \l__nicematrix_code_before_tl { #1 }
\bool_set_true:N \l__nicematrix_code_before_bool
}
} ,
@@ -535,8 +555,12 @@
\str_set_eq:NN \l__nicematrix_name_str \l_tmpa_str
} ,
name .value_required:n = true ,
- code-after .tl_gset:N = \g__nicematrix_code_after_tl ,
+ code-after .tl_gset:N = \g_nicematrix_code_after_tl ,
code-after .value_required:n = true ,
+ colortbl-like .code:n =
+ \bool_set_true:N \l__nicematrix_colortbl_like_bool
+ \bool_set_true:N \l__nicematrix_code_before_bool ,
+ colortbl-like .value_forbidden:n = true
}
\keys_define:nn { NiceMatrix / notes }
{
@@ -593,9 +617,7 @@
\keys_define:nn { NiceMatrix }
{
NiceMatrixOptions .inherit:n =
- {
- NiceMatrix / Global ,
- } ,
+ { NiceMatrix / Global } ,
NiceMatrixOptions / xdots .inherit:n = NiceMatrix / xdots ,
NiceMatrixOptions / rules .inherit:n = NiceMatrix / rules ,
NiceMatrixOptions / notes .inherit:n = NiceMatrix / notes ,
@@ -672,8 +694,6 @@
{ \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 ,
- 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 ,
S .code:n = \bool_if:NTF \c__nicematrix_siunitx_loaded_bool
{ \tl_set:Nn \l__nicematrix_type_of_col_tl S }
{ \__nicematrix_error:n { option~S~without~siunitx } } ,
@@ -835,17 +855,27 @@
{ \exp_not:n { #2 } }
}
}
+\cs_new_protected:Npn \__nicematrix_revtex_array:
+ {
+ \cs_set_eq:NN \@acoll \@arrayacol
+ \cs_set_eq:NN \@acolr \@arrayacol
+ \cs_set_eq:NN \@acol \@arrayacol
+ \cs_set:Npn \@halignto { }
+ \@array@array
+ }
\cs_new_protected:Npn \__nicematrix_array:
{
\bool_if:NTF \c__nicematrix_revtex_bool
+ \__nicematrix_revtex_array:
{
- \cs_set_eq:NN \@acoll \@arrayacol
- \cs_set_eq:NN \@acolr \@arrayacol
- \cs_set_eq:NN \@acol \@arrayacol
- \cs_set:Npn \@halignto { }
- \@array@array
+ \bool_if:NTF \l__nicematrix_NiceTabular_bool
+ { \dim_set_eq:NN \col@sep \tabcolsep }
+ { \dim_set_eq:NN \col@sep \arraycolsep }
+ \dim_compare:nNnTF \l__nicematrix_tabular_width_dim = \c_zero_dim
+ { \cs_set:Npn \@halignto { } }
+ { \cs_set:Npx \@halignto { to \dim_use:N \l__nicematrix_tabular_width_dim } }
+ \@tabarray
}
- \array
[ \str_if_eq:VnTF \l__nicematrix_baseline_str c c t ]
}
\cs_set_eq:NN \__nicematrix_old_ialign: \ialign
@@ -894,26 +924,27 @@
}
\cs_set_protected:Npn \__nicematrix_newcolumntype #1
{
- % \cs_if_free:cT { NC @ find @ #1 }
- % { \NC@list \exp_after:wN { \the \NC@list \NC@do #1 } }
\cs_set:cpn { NC @ find @ #1 } ##1 #1 { \NC@ { ##1 } }
\peek_meaning:NTF [
{ \newcol@ #1 }
{ \newcol@ #1 [ 0 ] }
}
-\cs_new_protected:Npn \__nicematrix_define_columntype:nn #1 #2
+\cs_set_protected:Npn \__nicematrix_renew_dots:
{
- \__nicematrix_newcolumntype #1 [ 1 ]
+ \cs_set_eq:NN \ldots \__nicematrix_Ldots
+ \cs_set_eq:NN \cdots \__nicematrix_Cdots
+ \cs_set_eq:NN \vdots \__nicematrix_Vdots
+ \cs_set_eq:NN \ddots \__nicematrix_Ddots
+ \cs_set_eq:NN \iddots \__nicematrix_Iddots
+ \cs_set_eq:NN \dots \__nicematrix_Ldots
+ \cs_set_eq:NN \hdotsfor \__nicematrix_Hdotsfor:
+ }
+\cs_new_protected:Npn \__nicematrix_colortbl_like:
{
- > {
- \__nicematrix_Cell:
- \begin { minipage } [ #2 ] { ##1 }
- \mode_leave_vertical: \box_use:N \@arstrutbox
- }
- c
- < { \box_use:N \@arstrutbox \end { minipage } \__nicematrix_end_Cell: }
+ \cs_set_eq:NN \cellcolor \__nicematrix_cellcolor_tabular
+ \cs_set_eq:NN \rowcolor \__nicematrix_rowcolor_tabular
+ \cs_set_eq:NN \columncolor \__nicematrix_columncolor_preamble
}
- }
\cs_new_protected:Npn \__nicematrix_pre_array:
{
\bool_if:NT \c__nicematrix_booktabs_loaded_bool
@@ -933,8 +964,6 @@
}
\cs_set:Npn \ialign
{
- \bool_if:NT \l__nicematrix_NiceTabular_bool
- { \dim_set_eq:NN \arraycolsep \__nicematrix_old_arraycolsep_dim }
\bool_if:NTF \c__nicematrix_colortbl_loaded_bool
{
\CT@everycr
@@ -964,8 +993,6 @@
\cs_set_eq:NN \__nicematrix_old_vdots \vdots
\cs_set_eq:NN \__nicematrix_old_ddots \ddots
\cs_set_eq:NN \__nicematrix_old_iddots \iddots
- \cs_set_eq:NN \firsthline \hline
- \cs_set_eq:NN \lasthline \hline
\bool_if:NTF \l__nicematrix_standard_cline_bool
{ \cs_set_eq:NN \cline \__nicematrix_standard_cline }
{ \cs_set_eq:NN \cline \__nicematrix_cline }
@@ -985,78 +1012,15 @@
\cs_set_eq:NN \dotfill \__nicematrix_dotfill:
\cs_set_eq:NN \CodeAfter \__nicematrix_CodeAfter:n
\cs_set_eq:NN \diagbox \__nicematrix_diagbox:nn
- \bool_if:NT \l__nicematrix_renew_dots_bool
- {
- \cs_set_eq:NN \ldots \__nicematrix_Ldots
- \cs_set_eq:NN \cdots \__nicematrix_Cdots
- \cs_set_eq:NN \vdots \__nicematrix_Vdots
- \cs_set_eq:NN \ddots \__nicematrix_Ddots
- \cs_set_eq:NN \iddots \__nicematrix_Iddots
- \cs_set_eq:NN \dots \__nicematrix_Ldots
- \cs_set_eq:NN \hdotsfor \__nicematrix_Hdotsfor:
- }
+ \bool_if:NT \l__nicematrix_colortbl_like_bool \__nicematrix_colortbl_like:
+ \bool_if:NT \l__nicematrix_renew_dots_bool \__nicematrix_renew_dots:
\seq_gclear_new:N \g__nicematrix_multicolumn_cells_seq
\seq_gclear_new:N \g__nicematrix_multicolumn_sizes_seq
\int_gset:Nn \c@iRow { \l__nicematrix_first_row_int - 1 }
\int_gzero_new:N \g__nicematrix_row_total_int
\int_gzero_new:N \g__nicematrix_col_total_int
\cs_set_eq:NN \@ifnextchar \new@ifnextchar
- \__nicematrix_define_columntype:nn p t
- \__nicematrix_define_columntype:nn m c
- \__nicematrix_define_columntype:nn b b
- \__nicematrix_newcolumntype w [ 2 ]
- {
- > {
- \hbox_set:Nw \l__nicematrix_cell_box
- \__nicematrix_Cell:
- }
- \__nicematrix_true_c:
- < {
- \__nicematrix_end_Cell:
- \hbox_set_end:
- \tl_set:Nn \l_tmpa_tl { ##1 }
- \makebox [ ##2 ] [ \__nicematrix_foldcase: ]
- { \box_use_drop:N \l__nicematrix_cell_box }
- }
- }
- \__nicematrix_newcolumntype W [ 2 ]
- {
- > {
- \hbox_set:Nw \l__nicematrix_cell_box
- \__nicematrix_Cell:
- }
- \__nicematrix_true_c:
- < {
- \__nicematrix_end_Cell:
- \hbox_set_end:
- \cs_set_eq:NN \hss \hfil
- \tl_set:Nn \l_tmpa_tl { ##1 }
- \makebox [ ##2 ] [ \__nicematrix_foldcase: ]
- { \box_use_drop:N \l__nicematrix_cell_box }
- }
- }
- \tl_set_rescan:Nno
- \l__nicematrix_letter_for_dotted_lines_str { } \l__nicematrix_letter_for_dotted_lines_str
- \exp_args:NV \newcolumntype \l__nicematrix_letter_for_dotted_lines_str
- {
- !
- {
- \int_compare:nNnF \c@iRow = 0
- {
- \int_compare:nNnF \c@iRow = \l__nicematrix_last_row_int
- { \skip_horizontal:N 2\l__nicematrix_radius_dim }
- }
- \int_compare:nNnT \c@jCol > \g__nicematrix_last_vdotted_col_int
- {
- \int_gset_eq:NN \g__nicematrix_last_vdotted_col_int \c@jCol
- \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
- { \__nicematrix_vdottedline:n { \int_use:N \c@jCol } }
- }
- }
- }
- \int_gzero_new:N \g__nicematrix_last_vdotted_col_int
\__nicematrix_renew_NC@rewrite@S:
- \int_gset:Nn \g__nicematrix_last_vdotted_col_int { -1 }
\bool_gset_false:N \g__nicematrix_last_col_found_bool
\tl_gclear_new:N \g__nicematrix_Cdots_lines_tl
\tl_gclear_new:N \g__nicematrix_Ldots_lines_tl
@@ -1064,20 +1028,12 @@
\tl_gclear_new:N \g__nicematrix_Ddots_lines_tl
\tl_gclear_new:N \g__nicematrix_Iddots_lines_tl
\tl_gclear_new:N \g__nicematrix_HVdotsfor_lines_tl
- }
-\cs_set:Npn \__nicematrix_foldcase:
- {
- \tl_case:NnF \l_tmpa_tl
- {
- C { c }
- L { l }
- R { r }
- }
- { \l_tmpa_tl }
+ \tl_gclear_new:N \g__nicematrix_code_before_tl
}
\NewDocumentEnvironment { NiceArrayWithDelims } { m m O { } m ! O { } }
{
- \bool_if:NT \c__nicematrix_footnote_bool { \begin { savenotes } }
+ \__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 }
@@ -1103,6 +1059,12 @@
\cs_set_protected:Npn \@arrayrule { \@addtopreamble \__nicematrix_vline: }
\seq_clear:N \g__nicematrix_blocks_seq
\seq_clear:N \g__nicematrix_pos_of_blocks_seq
+ \tl_if_exist:cT { g__nicematrix_code_before_ \int_use:N \g__nicematrix_env_int _ tl }
+ {
+ \bool_set_true:N \l__nicematrix_code_before_bool
+ \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
{ \keys_set:nn { NiceMatrix / NiceArray } }
{ \keys_set:nn { NiceMatrix / pNiceArray } }
@@ -1226,52 +1188,9 @@
\dim_set:Nn \l__nicematrix_right_delim_dim { \box_wd:N \l_tmpa_box }
}
\box_clear_new:N \l__nicematrix_the_array_box
- \tl_set:Nn \l_tmpa_tl { #4 }
\bool_if:NT \c__nicematrix_define_L_C_R_bool \__nicematrix_define_L_C_R:
- \@temptokena \exp_after:wN { \l_tmpa_tl }
- \@tempswatrue
- \@whilesw \if@tempswa \fi { \@tempswafalse \the \NC@list }
- \tl_gset:NV \l_tmpa_tl \@temptokena
- \tl_replace_all:Nnn \l_tmpa_tl c { > \__nicematrix_Cell: c < \__nicematrix_end_Cell: }
- \tl_replace_all:Nnn \l_tmpa_tl l { > \__nicematrix_Cell: l < \__nicematrix_end_Cell: }
- \tl_replace_all:Nnn \l_tmpa_tl r { > \__nicematrix_Cell: r < \__nicematrix_end_Cell: }
- \tl_replace_all:Nnn \l_tmpa_tl \__nicematrix_true_c: c
- \int_compare:nNnTF \l__nicematrix_first_col_int = 0
- { \tl_put_left:NV \l_tmpa_tl \c__nicematrix_preamble_first_col_tl }
- {
- \bool_lazy_all:nT
- {
- \l__nicematrix_NiceArray_bool
- { \bool_not_p:n \l__nicematrix_NiceTabular_bool }
- { \bool_not_p:n \l__nicematrix_vlines_bool }
- { \bool_not_p:n \l__nicematrix_exterior_arraycolsep_bool }
- }
- { \tl_put_left:Nn \l_tmpa_tl { @ { } } }
- }
- \int_compare:nNnTF \l__nicematrix_last_col_int > { -1 }
- { \tl_put_right:NV \l_tmpa_tl \c__nicematrix_preamble_last_col_tl }
- {
- \bool_lazy_all:nT
- {
- \l__nicematrix_NiceArray_bool
- { \bool_not_p:n \l__nicematrix_NiceTabular_bool }
- { \bool_not_p:n \l__nicematrix_vlines_bool }
- { \bool_not_p:n \l__nicematrix_exterior_arraycolsep_bool }
- }
- { \tl_put_right:Nn \l_tmpa_tl { @ { } } }
- }
- \tl_put_right:Nn \l_tmpa_tl { > { \__nicematrix_error_too_much_cols: } l }
+ \__nicematrix_construct_preamble:n { #4 }
\hbox_set:Nw \l__nicematrix_the_array_box
- \bool_if:NT \l__nicematrix_NiceTabular_bool
- {
- \dim_set_eq:NN \__nicematrix_old_arraycolsep_dim \arraycolsep
- \dim_set_eq:NN \arraycolsep \tabcolsep
- }
- \bool_if:NT \l__nicematrix_vlines_bool
- {
- \dim_add:Nn \arraycolsep { 0.5 \arrayrulewidth }
- \skip_horizontal:N 0.5\arrayrulewidth
- }
\skip_horizontal:N \l__nicematrix_left_margin_dim
\skip_horizontal:N \l__nicematrix_extra_left_margin_dim
\c_math_toggle_token
@@ -1286,7 +1205,6 @@
\c_math_toggle_token
\skip_horizontal:N \l__nicematrix_right_margin_dim
\skip_horizontal:N \l__nicematrix_extra_right_margin_dim
- \bool_if:NT \l__nicematrix_vlines_bool { \skip_horizontal:N 0.5\arrayrulewidth }
\hbox_set_end:
\int_compare:nNnT \l__nicematrix_last_row_int > { -2 }
{
@@ -1300,7 +1218,17 @@
}
}
\int_gset_eq:NN \c@jCol \g__nicematrix_col_total_int
- \bool_if:nT \g__nicematrix_last_col_found_bool { \int_gdecr:N \c@jCol }
+ \bool_if:nTF \g__nicematrix_last_col_found_bool
+ { \int_gdecr:N \c@jCol }
+ {
+ \int_compare:nNnT \l__nicematrix_last_col_int > { -1 }
+ { \__nicematrix_error:n { last~col~not~used } }
+ }
+ \bool_if:NF \l__nicematrix_Matrix_bool
+ {
+ \int_compare:nNnT \c@jCol < \g__nicematrix_static_num_of_col_int
+ { \__nicematrix_error:n { columns~not~used } }
+ }
\int_gset_eq:NN \g__nicematrix_row_total_int \c@iRow
\int_compare:nNnT \l__nicematrix_last_row_int > { -1 } { \int_gdecr:N \c@iRow }
\int_compare:nNnT \l__nicematrix_first_col_int = 0
@@ -1310,51 +1238,12 @@
}
\bool_if:NTF \l__nicematrix_NiceArray_bool
{
- \str_if_eq:VnTF \l__nicematrix_baseline_str { b }
- {
- \pgfpicture
- \__nicematrix_qpoint:n { row - 1 }
- \dim_gset_eq:NN \g_tmpa_dim \pgf@y
- \__nicematrix_qpoint:n { row - \int_use:N \c@iRow - base }
- \dim_gsub:Nn \g_tmpa_dim \pgf@y
- \endpgfpicture
- \dim_gadd:Nn \g_tmpa_dim \arrayrulewidth
- \int_compare:nNnT \l__nicematrix_first_row_int = 0
- {
- \dim_gadd:Nn \g_tmpa_dim \g__nicematrix_ht_row_zero_dim
- \dim_gadd:Nn \g_tmpa_dim \g__nicematrix_dp_row_zero_dim
- }
- \box_move_up:nn \g_tmpa_dim { \__nicematrix_use_array_box_with_notes: }
- }
+ \str_case:VnF \l__nicematrix_baseline_str
{
- \str_if_eq:VnTF \l__nicematrix_baseline_str { c }
- { \__nicematrix_use_array_box_with_notes: }
- {
- \str_if_eq:VnT \l__nicematrix_baseline_str { t }
- { \str_set:Nn \l__nicematrix_baseline_str { 1 } }
- \int_set:Nn \l_tmpa_int \l__nicematrix_baseline_str
- \bool_lazy_or:nnT
- { \int_compare_p:nNn \l_tmpa_int < \l__nicematrix_first_row_int }
- { \int_compare_p:nNn \l_tmpa_int > \g__nicematrix_row_total_int }
- {
- \__nicematrix_error:n { bad~value~for~baseline }
- \int_set:Nn \l_tmpa_int 1
- }
- \pgfpicture
- \__nicematrix_qpoint:n { row - 1 }
- \dim_gset_eq:NN \g_tmpa_dim \pgf@y
- \__nicematrix_qpoint:n { row - \int_use:N \l_tmpa_int - base }
- \dim_gsub:Nn \g_tmpa_dim \pgf@y
- \endpgfpicture
- \dim_gadd:Nn \g_tmpa_dim \arrayrulewidth
- \int_compare:nNnT \l__nicematrix_first_row_int = 0
- {
- \dim_gadd:Nn \g_tmpa_dim \g__nicematrix_ht_row_zero_dim
- \dim_gadd:Nn \g_tmpa_dim \g__nicematrix_dp_row_zero_dim
- }
- \box_move_up:nn \g_tmpa_dim { \__nicematrix_use_array_box_with_notes: }
- }
+ b \__nicematrix_use_arraybox_with_notes_b:
+ c \__nicematrix_use_arraybox_with_notes_c:
}
+ \__nicematrix_use_arraybox_with_notes:
}
{
\int_compare:nNnTF \l__nicematrix_first_row_int = 0
@@ -1382,7 +1271,7 @@
\bool_if:NTF \l__nicematrix_NiceTabular_bool
{ \skip_horizontal:N -\tabcolsep }
{ \skip_horizontal:N -\arraycolsep }
- \__nicematrix_use_array_box_with_notes:
+ \__nicematrix_use_arraybox_with_notes_c:
\bool_if:NTF \l__nicematrix_NiceTabular_bool
{ \skip_horizontal:N -\tabcolsep }
{ \skip_horizontal:N -\arraycolsep }
@@ -1404,7 +1293,194 @@
}
\__nicematrix_after_array:
\egroup
- \bool_if:NT \c__nicematrix_footnote_bool { \end { savenotes } }
+ \bool_if:NT \c__nicematrix_footnote_bool \endsavenotes
+ }
+\cs_new_protected:Npn \__nicematrix_construct_preamble:n #1
+ {
+ \group_begin:
+ \bool_if:NTF \l__nicematrix_Matrix_bool
+ { \tl_gset:Nn \g__nicematrix_preamble_tl { #1 } }
+ {
+ \__nicematrix_newcolumntype w [ 2 ] { \__nicematrix_w: { ##1 } { ##2 } }
+ \__nicematrix_newcolumntype W [ 2 ] { \__nicematrix_W: { ##1 } { ##2 } }
+ \@temptokena { #1 }
+ \@tempswatrue
+ \@whilesw \if@tempswa \fi { \@tempswafalse \the \NC@list }
+ \int_gzero_new:N \c@jCol
+ \bool_if:NTF \l__nicematrix_vlines_bool
+ {
+ \tl_gset:Nn \g__nicematrix_preamble_tl
+ { ! { \skip_horizontal:N \arrayrulewidth } }
+ }
+ { \tl_gclear:N \g__nicematrix_preamble_tl }
+ \int_zero:N \l_tmpa_int
+ \exp_after:wN \__nicematrix_patch_preamble:n \the \@temptokena \q_stop
+ \int_gset_eq:NN \g__nicematrix_static_num_of_col_int \c@jCol
+ }
+ \bool_if:NT \l__nicematrix_colortbl_like_bool
+ {
+ \regex_replace_all:NnN
+ \c__nicematrix_columncolor_regex
+ { \c { __nicematrix_columncolor_preamble } }
+ \g__nicematrix_preamble_tl
+ }
+ \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
+ {
+ \l__nicematrix_NiceArray_bool
+ { \bool_not_p:n \l__nicematrix_NiceTabular_bool }
+ { \bool_not_p:n \l__nicematrix_vlines_bool }
+ { \bool_not_p:n \l__nicematrix_exterior_arraycolsep_bool }
+ }
+ { \tl_gput_left:Nn \g__nicematrix_preamble_tl { @ { } } }
+ }
+ \int_compare:nNnTF \l__nicematrix_last_col_int > { -1 }
+ { \tl_gput_right:NV \g__nicematrix_preamble_tl \c__nicematrix_preamble_last_col_tl }
+ {
+ \bool_lazy_all:nT
+ {
+ \l__nicematrix_NiceArray_bool
+ { \bool_not_p:n \l__nicematrix_NiceTabular_bool }
+ { \bool_not_p:n \l__nicematrix_vlines_bool }
+ { \bool_not_p:n \l__nicematrix_exterior_arraycolsep_bool }
+ }
+ { \tl_gput_right:Nn \g__nicematrix_preamble_tl { @ { } } }
+ }
+ \dim_compare:nNnT \l__nicematrix_tabular_width_dim = \c_zero_dim
+ {
+ \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
+ {
+ \str_case:nnF { #1 }
+ {
+ c { \__nicematrix_patch_preamble_i:n #1 }
+ l { \__nicematrix_patch_preamble_i:n #1 }
+ r { \__nicematrix_patch_preamble_i:n #1 }
+ > { \__nicematrix_patch_preamble_ii:nn #1 }
+ < { \__nicematrix_patch_preamble_ii:nn #1 }
+ ! { \__nicematrix_patch_preamble_ii:nn #1 }
+ @ { \__nicematrix_patch_preamble_ii:nn #1 }
+ | { \__nicematrix_patch_preamble_iii:n #1 }
+ p { \__nicematrix_patch_preamble_iv:nnn t #1 }
+ m { \__nicematrix_patch_preamble_iv:nnn c #1 }
+ b { \__nicematrix_patch_preamble_iv:nnn b #1 }
+ \__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 }
+ \q_stop { }
+ }
+ {
+ \str_if_eq:VnTF \l__nicematrix_letter_for_dotted_lines_str { #1 }
+ { \__nicematrix_patch_preamble_vii:n #1 }
+ { \__nicematrix_fatal:nn { unknown~column~type } { #1 } }
+ }
+ }
+\cs_new_protected:Npn \__nicematrix_patch_preamble_i:n #1
+ {
+ \tl_gput_right:Nn \g__nicematrix_preamble_tl { > \__nicematrix_Cell: #1 < \__nicematrix_end_Cell: }
+ \int_gincr:N \c@jCol
+ \bool_if:NT \l__nicematrix_vlines_bool
+ {
+ \tl_gput_right:Nn \g__nicematrix_preamble_tl
+ { ! { \skip_horizontal:N \arrayrulewidth } }
+ }
+ \__nicematrix_patch_preamble:n
+ }
+\cs_new_protected:Npn \__nicematrix_patch_preamble_ii:nn #1 #2
+ {
+ \tl_gput_right:Nn \g__nicematrix_preamble_tl { #1 { #2 } }
+ \__nicematrix_patch_preamble:n
+ }
+\cs_new_protected:Npn \__nicematrix_patch_preamble_iii:n #1
+ {
+ \int_incr:N \l_tmpa_int
+ \__nicematrix_patch_preamble_iii_i:n
+ }
+\cs_new_protected:Npn \__nicematrix_patch_preamble_iii_i:n #1
+ {
+ \str_if_eq:nnTF { #1 } |
+ { \__nicematrix_patch_preamble_iii:n | }
+ {
+ \tl_gput_right:Nx \g__nicematrix_preamble_tl
+ {
+ \exp_not:N !
+ {
+ \skip_horizontal:n
+ {
+ \dim_eval:n
+ {
+ \arrayrulewidth * \l_tmpa_int
+ + \doublerulesep * ( \l_tmpa_int - 1)
+ }
+ }
+ }
+ }
+ \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
+ { \__nicematrix_vline:nn { \int_use:N \c@jCol } { \int_use:N \l_tmpa_int } }
+ \int_zero:N \l_tmpa_int
+ \__nicematrix_patch_preamble:n #1
+ }
+ }
+\cs_new_protected:Npn \__nicematrix_patch_preamble_iv:nnn #1 #2 #3
+ {
+ \tl_gput_right:Nn \g__nicematrix_preamble_tl
+ {
+ > {
+ \__nicematrix_Cell:
+ \begin { minipage } [ #1 ] { #3 }
+ \mode_leave_vertical:
+ \box_use:N \@arstrutbox
+ }
+ c
+ < { \box_use:N \@arstrutbox \end { minipage } \__nicematrix_end_Cell: }
+ }
+ \int_gincr:N \c@jCol
+ \__nicematrix_patch_preamble:n
+ }
+\cs_new_protected:Npn \__nicematrix_patch_preamble_v:nnnn #1 #2 #3 #4
+ {
+ \tl_gput_right:Nn \g__nicematrix_preamble_tl
+ {
+ > {
+ \hbox_set:Nw \l__nicematrix_cell_box
+ \__nicematrix_Cell:
+ }
+ c
+ < {
+ \__nicematrix_end_Cell:
+ #1
+ \hbox_set_end:
+ \makebox [ #4 ] [ #3 ] { \box_use_drop:N \l__nicematrix_cell_box }
+ }
+ }
+ \int_gincr:N \c@jCol
+ \__nicematrix_patch_preamble:n
+ }
+\cs_new_protected:Npn \__nicematrix_patch_preamble_vi:n #1
+ {
+ \tl_gput_right:Nn \g__nicematrix_preamble_tl { c }
+ \int_gincr:N \c@jCol
+ \bool_if:NT \l__nicematrix_vlines_bool
+ {
+ \tl_gput_right:Nn \g__nicematrix_preamble_tl
+ { ! { \skip_horizontal:N \arrayrulewidth } }
+ }
+ \__nicematrix_patch_preamble:n
+ }
+\cs_new_protected:Npn \__nicematrix_patch_preamble_vii:n #1
+ {
+ \tl_gput_right:Nn \g__nicematrix_preamble_tl
+ { ! { \skip_horizontal:N 2\l__nicematrix_radius_dim } }
+ \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
+ { \__nicematrix_vdottedline:n { \int_use:N \c@jCol } }
+ \__nicematrix_patch_preamble:n
}
\cs_new_protected:Npn \__nicematrix_put_box_in_flow:
{
@@ -1444,7 +1520,7 @@
\box_move_up:nn \g_tmpa_dim { \box_use_drop:N \l_tmpa_box }
\box_use_drop:N \l_tmpa_box
}
-\cs_new_protected:Npn \__nicematrix_use_array_box_with_notes:
+\cs_new_protected:Npn \__nicematrix_use_arraybox_with_notes_c:
{
\int_compare:nNnTF \c@tabularnote = 0
{ \box_use_drop:N \l__nicematrix_the_array_box }
@@ -1483,6 +1559,48 @@
\int_gzero:N \c@tabularnote
}
}
+\cs_new_protected:Npn \__nicematrix_use_arraybox_with_notes_b:
+ {
+ \pgfpicture
+ \__nicematrix_qpoint:n { row - 1 }
+ \dim_gset_eq:NN \g_tmpa_dim \pgf@y
+ \__nicematrix_qpoint:n { row - \int_use:N \c@iRow - base }
+ \dim_gsub:Nn \g_tmpa_dim \pgf@y
+ \endpgfpicture
+ \dim_gadd:Nn \g_tmpa_dim \arrayrulewidth
+ \int_compare:nNnT \l__nicematrix_first_row_int = 0
+ {
+ \dim_gadd:Nn \g_tmpa_dim \g__nicematrix_ht_row_zero_dim
+ \dim_gadd:Nn \g_tmpa_dim \g__nicematrix_dp_row_zero_dim
+ }
+ \box_move_up:nn \g_tmpa_dim { \__nicematrix_use_arraybox_with_notes_c: }
+ }
+\cs_new_protected:Npn \__nicematrix_use_arraybox_with_notes:
+ {
+ \str_if_eq:VnT \l__nicematrix_baseline_str { t }
+ { \str_set:Nn \l__nicematrix_baseline_str { 1 } }
+ \int_set:Nn \l_tmpa_int \l__nicematrix_baseline_str
+ \bool_lazy_or:nnT
+ { \int_compare_p:nNn \l_tmpa_int < \l__nicematrix_first_row_int }
+ { \int_compare_p:nNn \l_tmpa_int > \g__nicematrix_row_total_int }
+ {
+ \__nicematrix_error:n { bad~value~for~baseline }
+ \int_set:Nn \l_tmpa_int 1
+ }
+ \pgfpicture
+ \__nicematrix_qpoint:n { row - 1 }
+ \dim_gset_eq:NN \g_tmpa_dim \pgf@y
+ \__nicematrix_qpoint:n { row - \int_use:N \l_tmpa_int - base }
+ \dim_gsub:Nn \g_tmpa_dim \pgf@y
+ \endpgfpicture
+ \dim_gadd:Nn \g_tmpa_dim \arrayrulewidth
+ \int_compare:nNnT \l__nicematrix_first_row_int = 0
+ {
+ \dim_gadd:Nn \g_tmpa_dim \g__nicematrix_ht_row_zero_dim
+ \dim_gadd:Nn \g_tmpa_dim \g__nicematrix_dp_row_zero_dim
+ }
+ \box_move_up:nn \g_tmpa_dim { \__nicematrix_use_arraybox_with_notes_c: }
+ }
\cs_new_protected:Npn \__nicematrix_put_box_in_flow_bis:nn #1 #2
{
\dim_zero_new:N \l__nicematrix_real_left_delim_dim
@@ -1522,9 +1640,8 @@
}
\NewDocumentEnvironment { __nicematrix-normal-syntax } { }
{
- \peek_meaning_ignore_spaces:NTF \end
- { \__nicematrix_analyze_end:Nn }
- { \exp_args:NV \__nicematrix_array: \l_tmpa_tl }
+ \peek_meaning_ignore_spaces:NTF \end \__nicematrix_analyze_end:Nn
+ { \exp_args:NV \__nicematrix_array: \g__nicematrix_preamble_tl }
}
{
\__nicematrix_create_col_nodes:
@@ -1545,13 +1662,13 @@
{ }
\cs_new_protected:Npn \__nicematrix_light_syntax_i #1\CodeAfter #2\q_stop
{
- \tl_gput_right:Nn \g__nicematrix_code_after_tl { #2 }
+ \tl_gput_right:Nn \g_nicematrix_code_after_tl { #2 }
\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 }
\int_compare:nNnT \l__nicematrix_last_row_int = { -1 }
{ \int_set:Nn \l__nicematrix_last_row_int { \seq_count:N \g__nicematrix_rows_seq } }
- \exp_args:NV \__nicematrix_array: \l_tmpa_tl
+ \exp_args:NV \__nicematrix_array: \g__nicematrix_preamble_tl
\seq_gpop_left:NN \g__nicematrix_rows_seq \l_tmpa_tl
\exp_args:NV \__nicematrix_line_with_light_syntax_i:n \l_tmpa_tl
\seq_map_function:NN \g__nicematrix_rows_seq \__nicematrix_line_with_light_syntax:n
@@ -1803,59 +1920,25 @@
\NiceArrayWithDelims . .
}
{ \endNiceArrayWithDelims }
-\NewDocumentEnvironment { pNiceArray } { }
- {
- \str_if_empty:NT \g__nicematrix_name_env_str
- { \str_gset:Nn \g__nicematrix_name_env_str { pNiceArray } }
- \__nicematrix_test_if_math_mode:
- \NiceArrayWithDelims ( )
- }
- { \endNiceArrayWithDelims }
-\NewDocumentEnvironment { bNiceArray } { }
+\cs_new_protected:Npn \__nicematrix_def_env:nnn #1 #2 #3
{
- \str_if_empty:NT \g__nicematrix_name_env_str
- { \str_gset:Nn \g__nicematrix_name_env_str { bNiceArray } }
- \__nicematrix_test_if_math_mode:
- \NiceArrayWithDelims [ ]
- }
- { \endNiceArrayWithDelims }
-\NewDocumentEnvironment { BNiceArray } { }
- {
- \str_if_empty:NT \g__nicematrix_name_env_str
- { \str_gset:Nn \g__nicematrix_name_env_str { BNiceArray } }
- \__nicematrix_test_if_math_mode:
- \NiceArrayWithDelims \{ \}
- }
- { \endNiceArrayWithDelims }
-\NewDocumentEnvironment { vNiceArray } { }
- {
- \str_if_empty:NT \g__nicematrix_name_env_str
- { \str_gset:Nn \g__nicematrix_name_env_str { vNiceArray } }
- \__nicematrix_test_if_math_mode:
- \NiceArrayWithDelims | |
- }
- { \endNiceArrayWithDelims }
-\NewDocumentEnvironment { VNiceArray } { }
- {
- \str_if_empty:NT \g__nicematrix_name_env_str
- { \str_gset:Nn \g__nicematrix_name_env_str { VNiceArray } }
- \__nicematrix_test_if_math_mode:
- \NiceArrayWithDelims \| \|
- }
- { \endNiceArrayWithDelims }
-\cs_new_protected:Npn \__nicematrix_define_env:n #1
- {
- \NewDocumentEnvironment { #1 NiceMatrix } { ! O { } }
+ \NewDocumentEnvironment { #1 NiceArray } { }
{
- \str_gset:Nn \g__nicematrix_name_env_str { #1 NiceMatrix }
- \tl_set:Nn \l__nicematrix_type_of_col_tl c
- \keys_set:nn { NiceMatrix / NiceMatrix } { ##1 }
- \exp_args:Nnx \__nicematrix_begin_of_NiceMatrix:nn { #1 } \l__nicematrix_type_of_col_tl
+ \str_if_empty:NT \g__nicematrix_name_env_str
+ { \str_gset:Nn \g__nicematrix_name_env_str { #1 NiceArray } }
+ \__nicematrix_test_if_math_mode:
+ \NiceArrayWithDelims #2 #3
}
- { \use:c { end #1 NiceArray } }
+ { \endNiceArrayWithDelims }
}
+\__nicematrix_def_env:nnn p ( )
+\__nicematrix_def_env:nnn b [ ]
+\__nicematrix_def_env:nnn B \{ \}
+\__nicematrix_def_env:nnn v | |
+\__nicematrix_def_env:nnn V \| \|
\cs_new_protected:Npn \__nicematrix_begin_of_NiceMatrix:nn #1 #2
{
+ \bool_set_true:N \l__nicematrix_Matrix_bool
\use:c { #1 NiceArray }
{
*
@@ -1864,15 +1947,20 @@
\c@MaxMatrixCols
{ \__nicematrix_pred:n \l__nicematrix_last_col_int }
}
- #2
+ { > \__nicematrix_Cell: #2 < \__nicematrix_end_Cell: }
+ }
+ }
+\clist_map_inline:nn { { } , p , b , B , v , V }
+ {
+ \NewDocumentEnvironment { #1 NiceMatrix } { ! O { } }
+ {
+ \str_gset:Nn \g__nicematrix_name_env_str { #1 NiceMatrix }
+ \tl_set:Nn \l__nicematrix_type_of_col_tl c
+ \keys_set:nn { NiceMatrix / NiceMatrix } { ##1 }
+ \exp_args:Nnx \__nicematrix_begin_of_NiceMatrix:nn { #1 } \l__nicematrix_type_of_col_tl
}
+ { \use:c { end #1 NiceArray } }
}
-\__nicematrix_define_env:n { }
-\__nicematrix_define_env:n p
-\__nicematrix_define_env:n b
-\__nicematrix_define_env:n B
-\__nicematrix_define_env:n v
-\__nicematrix_define_env:n V
\NewDocumentEnvironment { NiceTabular } { O { } m ! O { } }
{
\str_gset:Nn \g__nicematrix_name_env_str { NiceTabular }
@@ -1881,6 +1969,15 @@
\NiceArray { #2 }
}
{ \endNiceArray }
+\NewDocumentEnvironment { NiceTabular* } { m O { } m ! O { } }
+ {
+ \str_gset:Nn \g__nicematrix_name_env_str { NiceTabular* }
+ \dim_set:Nn \l__nicematrix_tabular_width_dim { #1 }
+ \keys_set:nn { NiceMatrix / NiceTabular } { #2 , #4 }
+ \bool_set_true:N \l__nicematrix_NiceTabular_bool
+ \NiceArray { #3 }
+ }
+ { \endNiceArray }
\cs_new_protected:Npn \__nicematrix_after_array:
{
\group_begin:
@@ -2004,9 +2101,23 @@
}
\cs_set_eq:NN \line \__nicematrix_line
\cs_set_eq:NN \CodeAfter \prg_do_nothing:
- \g__nicematrix_code_after_tl
- \tl_gclear:N \g__nicematrix_code_after_tl
+ \g_nicematrix_code_after_tl
+ \tl_gclear:N \g_nicematrix_code_after_tl
\group_end:
+ \tl_if_empty:NF \g__nicematrix_code_before_tl
+ {
+ \cs_set_protected:Npn \rectanglecolor { }
+ \cs_set_protected:Npn \columncolor { }
+ \iow_now:Nn \@mainaux \ExplSyntaxOn
+ \iow_now:Nx \@mainaux
+ {
+ \tl_gset:cn
+ { g__nicematrix_code_before_ \int_use:N \g__nicematrix_env_int _ tl }
+ { \g__nicematrix_code_before_tl }
+ }
+ \iow_now:Nn \@mainaux \ExplSyntaxOff
+ \bool_set_true:N \l__nicematrix_code_before_bool
+ }
\str_gclear:N \g__nicematrix_name_env_str
\__nicematrix_restore_iRow_jCol:
\cs_gset_eq:NN \CT@arc@ \__nicematrix_old_CT@arc@
@@ -3212,6 +3323,28 @@
}
}
}
+\NewDocumentCommand \__nicematrix_cellcolor_tabular { O { } m }
+ {
+ \tl_gput_right:Nx \g__nicematrix_code_before_tl
+ { \cellcolor [ #1 ] { #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
+ {
+ \exp_not:N \rectanglecolor [ #1 ] { #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 }
+ {
+ \int_compare:nNnT \c@iRow = 1
+ {
+ \tl_gput_left:Nx \g__nicematrix_code_before_tl
+ { \exp_not:N \columncolor [ #1 ] { #2 } { \int_use:N \c@jCol } }
+ }
+ }
\cs_set_eq:NN \OnlyMainNiceMatrix \use:n
\cs_new_protected:Npn \__nicematrix_OnlyMainNiceMatrix:n #1
{
@@ -3231,8 +3364,44 @@
\int_compare:nNnF \c@iRow = 0
{ \int_compare:nNnF \c@iRow = \l__nicematrix_last_row_int { #1 } }
}
-\cs_new_protected:Npn \__nicematrix_vline:
- { \__nicematrix_OnlyMainNiceMatrix:n { { \CT@arc@ \vline } } }
+\cs_new_protected:Npn \__nicematrix_vline:nn #1 #2
+ {
+ \bool_if:NTF \c__nicematrix_tikz_loaded_bool
+ {
+ \tikzpicture
+ \__nicematrix_vline_i:nn { #1 } { #2 }
+ \endtikzpicture
+ }
+ {
+ \pgfpicture
+ \__nicematrix_vline_i:nn { #1 } { #2 }
+ \endpgfpicture
+ }
+ }
+\cs_new_protected:Npn \__nicematrix_vline_i:nn #1 #2
+ {
+ \CT@arc@
+ \pgfrememberpicturepositiononpagetrue
+ \pgf@relevantforpicturesizefalse
+ \pgfsetlinewidth { 1.1 \arrayrulewidth }
+ \pgfsetrectcap
+ \__nicematrix_qpoint:n { row - 1 }
+ \dim_set_eq:NN \l_tmpa_dim \pgf@y
+ \__nicematrix_qpoint:n { col - \int_eval:n { #1 + 1 } }
+ \dim_set_eq:NN \l_tmpb_dim \pgf@x
+ \pgfpathmoveto { \pgfpoint \l_tmpb_dim \l_tmpa_dim }
+ \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \c@iRow }
+ \dim_set_eq:NN \l_tmpc_dim \pgf@y
+ \pgfpathlineto { \pgfpoint \l_tmpb_dim \l_tmpc_dim }
+ \prg_replicate:nn { #2 - 1 }
+ {
+ \dim_sub:Nn \l_tmpb_dim \arrayrulewidth
+ \dim_sub:Nn \l_tmpb_dim \doublerulesep
+ \pgfpathmoveto { \pgfpoint \l_tmpb_dim \l_tmpa_dim }
+ \pgfpathlineto { \pgfpoint \l_tmpb_dim \l_tmpc_dim }
+ }
+ \pgfusepathqstroke
+ }
\cs_new_protected:Npn \__nicematrix_draw_vlines:
{
\group_begin:
@@ -3854,6 +4023,8 @@
{
tikz .tl_set:N = \l__nicematrix_tikz_tl ,
tikz .value_required:n = true ,
+ color .tl_set:N = \l__nicematrix_color_tl ,
+ color .value_required:n = true ,
}
\cs_new_protected:Npn \__nicematrix_draw_blocks:
{ \seq_map_inline:Nn \g__nicematrix_blocks_seq { \__nicematrix_Block_iii:nnnnnn ##1 } }
@@ -3861,12 +4032,23 @@
{
\group_begin:
\keys_set:nn { NiceMatrix / Block } { #5 }
+ \tl_if_empty:NF \l__nicematrix_color_tl
+ {
+ \tl_gput_right:Nx \g__nicematrix_code_before_tl
+ {
+ \exp_not:N \rectanglecolor
+ { \l__nicematrix_color_tl }
+ { #1 - #2 }
+ { #3 - #4 }
+ }
+ }
\cs_set_protected:Npn \diagbox ##1 ##2
{
\tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
{
\__nicematrix_actually_diagbox:nnnnnn
- { #1 } { #2 } { #3 } { #4 } { ##1 } { ##2 }
+ { #1 } { #2 } { #3 } { #4 }
+ { \exp_not:n { ##1 } } { \exp_not:n { ##2 } }
}
}
\bool_lazy_or:nnTF
@@ -4046,8 +4228,8 @@
{ \int_use:N \c@jCol }
{ \int_use:N \c@iRow }
{ \int_use:N \c@jCol }
- { #1 }
- { #2 }
+ { \exp_not:n { #1 } }
+ { \exp_not:n { #2 } }
}
\seq_gput_right:Nx \g__nicematrix_pos_of_blocks_seq
{
@@ -4090,7 +4272,7 @@
}
\cs_new_protected:Npn \__nicematrix_CodeAfter:n #1 \end
{
- \tl_gput_right:Nn \g__nicematrix_code_after_tl { #1 }
+ \tl_gput_right:Nn \g_nicematrix_code_after_tl { #1 }
\__nicematrix_CodeAfter_i:n
}
\cs_new_protected:Npn \__nicematrix_CodeAfter_i:n #1
@@ -4098,7 +4280,7 @@
\str_if_eq:eeTF \@currenvir { #1 }
{ \end { #1 } }
{
- \tl_gput_right:Nn \g__nicematrix_code_after_tl { \end { #1 } }
+ \tl_gput_right:Nn \g_nicematrix_code_after_tl { \end { #1 } }
\__nicematrix_CodeAfter:n
}
}
@@ -4174,10 +4356,19 @@
}
\bool_set_true:N \c__nicematrix_footnote_bool
}
+\cs_new_protected:Npn \__nicematrix_convert_to_str_seq:N #1
+ {
+ \seq_clear:N \l_tmpa_seq
+ \seq_map_inline:Nn #1
+ {
+ \seq_put_left:Nx \l_tmpa_seq { \tl_to_str:n { ##1 } }
+ }
+ \seq_set_eq:NN #1 \l_tmpa_seq
+ }
\cs_new_protected:Npn \__nicematrix_set_seq_of_str_from_clist:Nn #1 #2
{
\seq_set_from_clist:Nn #1 { #2 }
- \seq_set_map:NNn #1 #1 { \tl_to_str:n { ##1 } }
+ \__nicematrix_convert_to_str_seq:N #1
}
\__nicematrix_set_seq_of_str_from_clist:Nn \c__nicematrix_types_of_matrix_seq
{
@@ -4206,8 +4397,8 @@
{
You~try~to~use~more~columns~than~allowed~by~your~
\__nicematrix_full_name_env:.\__nicematrix_message_hdotsfor:\ The~maximal~number~of~
- columns~is~\int_eval:n { \l__nicematrix_last_col_int - 1 }~(plus~the~potential~
- exterior~ones).~This~error~is~fatal.
+ columns~is~\int_eval:n { \l__nicematrix_last_col_int - 1 }~(plus~the~
+ exterior~columns).~This~error~is~fatal.
}
\__nicematrix_msg_new:nn { too~much~cols~for~matrix }
{
@@ -4221,9 +4412,22 @@
{
You~try~to~use~more~columns~than~allowed~by~your~
\__nicematrix_full_name_env:.\__nicematrix_message_hdotsfor:\ The~maximal~number~of~columns~is~
- \int_eval:n { \c@jCol - 1 }~(plus~the~potential~exterior~ones).~
+ \int_use:N \g__nicematrix_static_num_of_col_int\
+ ~(plus~the~potential~exterior~ones).~
This~error~is~fatal.
}
+\__nicematrix_msg_new:nn { last~col~not~used }
+ {
+ The~key~'last-col'~is~in~force~but~you~have~not~used~that~last~column~
+ in~your~\__nicematrix_full_name_env:.~However,~you~can~go~on.
+ }
+\__nicematrix_msg_new:nn { columns~not~used }
+ {
+ The~preamble~of~your~\__nicematrix_full_name_env:\ announces~\int_use:N
+ \g__nicematrix_static_num_of_col_int\
+ columns~but~you~use~only~\int_use:N \c@jCol.\\
+ However,~you~can~go~on.
+ }
\__nicematrix_msg_new:nn { in~first~col }
{
You~can't~use~the~command~#1 in~the~first~column~(number~0)~of~the~array.\\
@@ -4311,6 +4515,12 @@
You~try~to~draw~a~block~in~the~cell~#1-#2~of~your~matrix~but~the~matrix~is~
too~small~for~that~block. \\
}
+\__nicematrix_msg_new:nn { unknown~column~type }
+ {
+ The~column~type~'#1'~in~your~\__nicematrix_full_name_env:\
+ is~unknown. \\
+ This~error~is~fatal.
+ }
\__nicematrix_msg_new:nn { angle~option~in~NiceTabular }
{
You~should~not~the~option~between~angle~brackets~(<~and~>)~for~a~command~
@@ -4384,9 +4594,9 @@
{
The~available~options~are~(in~alphabetic~order):~
allow-duplicate-names,~
- code-for-first-col,~
cell-space-bottom-limit,~
cell-space-top-limit,~
+ code-for-first-col,~
code-for-first-row,~
code-for-last-col,~
code-for-last-row,~
@@ -4435,6 +4645,7 @@
code-for-first-row,~
code-for-last-col,~
code-for-last-row,~
+ colortbl-like,~
columns-width,~
create-extra-nodes,~
create-medium-nodes,~
@@ -4483,6 +4694,7 @@
code-for-first-row,~
code-for-last-col,~
code-for-last-row,~
+ colortbl-like,~
columns-width,~
create-extra-nodes,~
create-medium-nodes,~
@@ -4493,14 +4705,14 @@
first-row,~
hlines,~
hvlines,~
- l~(=L),~
+ l,~
last-col,~
last-row,~
left-margin,~
light-syntax,~
name,~
nullify-dots,~
- r~(=R),~
+ r,~
renew-dots,~
right-margin,~
rules/color,~
@@ -4532,6 +4744,7 @@
code-for-first-row,~
code-for-last-col,~
code-for-last-row,~
+ colortbl-like,~
columns-width,~
create-extra-nodes,~
create-medium-nodes,~