summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-10-24 21:05:28 +0000
committerKarl Berry <karl@freefriends.org>2021-10-24 21:05:28 +0000
commit533a763eb9e2f764d3d6814d47c48ba12fe341a9 (patch)
treef2b78228552ad03befe5aeecd79f4e4c54734ba7 /Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
parentf6bbe90c82a89c41229b1aa9707b0bcecc767206 (diff)
nicematrix
git-svn-id: svn://tug.org/texlive/trunk@60864 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.sty730
1 files changed, 461 insertions, 269 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
index 2a006ddef02..3434c440780 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{6.2}
-\def\myfiledate{2021/09/09}
+\def\myfileversion{6.3}
+\def\myfiledate{2021/10/18}
\RequirePackage{pgfcore}
\usepgfmodule{shapes}
\RequirePackage{l3keys2e}
@@ -48,8 +48,12 @@
\bool_new:N \c__nicematrix_enumitem_loaded_bool
\bool_new:N \c__nicematrix_tabularx_loaded_bool
\bool_new:N \c__nicematrix_tikz_loaded_bool
+\bool_new:N \c__nicematrix_varwidth_loaded_bool
\AtBeginDocument
{
+ \@ifpackageloaded { varwidth }
+ { \bool_set_true:N \c__nicematrix_varwidth_loaded_bool }
+ { }
\@ifpackageloaded { arydshln }
{ \bool_set_true:N \c__nicematrix_arydshln_loaded_bool }
{ }
@@ -266,11 +270,13 @@
\dim_set:Nn \l__nicematrix_col_width_dim { -1 cm }
\int_new:N \g__nicematrix_row_total_int
\int_new:N \g__nicematrix_col_total_int
+\int_new:N \l__nicematrix_key_nb_rows_int
\str_new:N \l__nicematrix_hpos_cell_str
\str_set:Nn \l__nicematrix_hpos_cell_str { c }
\dim_new:N \g__nicematrix_blocks_wd_dim
\dim_new:N \g__nicematrix_blocks_ht_dim
\dim_new:N \g__nicematrix_blocks_dp_dim
+\dim_new:N \l__nicematrix_width_dim
\seq_new:N \g__nicematrix_names_seq
\bool_new:N \l__nicematrix_in_env_bool
\bool_new:N \l__nicematrix_NiceArray_bool
@@ -360,7 +366,6 @@
\clist_new:N \l__nicematrix_submatrix_hlines_clist
\clist_new:N \l__nicematrix_submatrix_vlines_clist
\bool_new:N \l__nicematrix_dotted_bool
-\dim_new:N \l__nicematrix_trim_dim
\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
@@ -372,6 +377,30 @@
\int_new:N \l__nicematrix_last_col_int
\int_set:Nn \l__nicematrix_last_col_int { -2 }
\bool_new:N \g__nicematrix_last_col_found_bool
+\cs_set_protected:Npn \__nicematrix_cut_on_hyphen:w #1-#2\q_stop
+ {
+ \tl_set:Nn \l_tmpa_tl { #1 }
+ \tl_set:Nn \l_tmpb_tl { #2 }
+ }
+\cs_new_protected:Npn \__nicematrix_expand_clist:N #1
+ {
+ \clist_if_in:NnF #1 { all }
+ {
+ \clist_clear:N \l_tmpa_clist
+ \clist_map_inline:Nn #1
+ {
+ \tl_if_in:nnTF { ##1 } { - }
+ { \__nicematrix_cut_on_hyphen:w ##1 \q_stop }
+ {
+ \tl_set:Nn \l_tmpa_tl { ##1 }
+ \tl_set:Nn \l_tmpb_tl { ##1 }
+ }
+ \int_step_inline:nnn { \l_tmpa_tl } { \l_tmpb_tl }
+ { \clist_put_right:Nn \l_tmpa_clist { ####1 } }
+ }
+ \tl_set_eq:NN #1 \l_tmpa_clist
+ }
+ }
\newcounter { tabularnote }
\seq_new:N \g__nicematrix_tabularnotes_seq
\tl_new:N \l__nicematrix_tabularnote_tl
@@ -783,6 +812,8 @@
}
\keys_define:nn { NiceMatrix / NiceMatrixOptions }
{
+ width .code:n = \dim_set:Nn \l__nicematrix_width_dim { #1 } ,
+ width .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 ,
@@ -888,7 +919,7 @@
\cs_new_protected:Npn \__nicematrix_cell_begin:w
{
\tl_gclear:N \g__nicematrix_post_action_cell_tl
- \cs_set_eq:NN \CodeAfter \__nicematrix_CodeAfter_i:n
+ \cs_set_eq:NN \CodeAfter \__nicematrix_CodeAfter_i:
\int_gincr:N \c@jCol
\int_compare:nNnT \c@jCol = 1
{ \int_compare:nNnT \l__nicematrix_first_col_int = 1 \__nicematrix_begin_of_row: }
@@ -918,7 +949,6 @@
}
\cs_new_protected:Npn \__nicematrix_begin_of_row:
{
- \tl_gclear:N \g__nicematrix_row_style_tl
\int_gincr:N \c@iRow
\dim_gset_eq:NN \g__nicematrix_dp_ante_last_row_dim \g__nicematrix_dp_last_row_dim
\dim_gset:Nn \g__nicematrix_dp_last_row_dim { \box_dp:N \@arstrutbox }
@@ -1046,12 +1076,12 @@
\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
- }
+ \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
@@ -1170,8 +1200,10 @@
}
\cs_new_protected:Npn \__nicematrix_pre_array_ii:
{
- \xglobal \colorlet { nicematrix } { . }
- \int_gzero:N \g__nicematrix_total_X_weight_int
+ \xglobal \colorlet { nicematrix } { . }
+ \int_gzero:N \g__nicematrix_total_X_weight_int
+ \__nicematrix_expand_clist:N \l__nicematrix_hlines_clist
+ \__nicematrix_expand_clist:N \l__nicematrix_vlines_clist
\bool_if:NT \c__nicematrix_booktabs_loaded_bool
{ \tl_put_left:Nn \@BTnormal \__nicematrix_create_row_node: }
\box_clear_new:N \l__nicematrix_cell_box
@@ -1325,47 +1357,6 @@
\bool_set_true:N \l__nicematrix_code_before_bool
\__nicematrix_pre_array:
}
-\keys_define:nn { NiceMatrix / RowStyle }
- {
- cell-space-top-limit .code:n =
- {
- \tl_gput_right:Nn \g__nicematrix_row_style_tl
- {
- \tl_gput_right:Nn \g__nicematrix_post_action_cell_tl
- { \dim_set:Nn \l__nicematrix_cell_space_top_limit_dim { #1 } }
- }
- } ,
- cell-space-top-limit .value_required:n = true ,
- cell-space-bottom-limit .code:n =
- {
- \tl_gput_right:Nn \g__nicematrix_row_style_tl
- {
- \tl_gput_right:Nn \g__nicematrix_post_action_cell_tl
- { \dim_set:Nn \l__nicematrix_cell_space_bottom_limit_dim { #1 } }
- }
- } ,
- cell-space-bottom-limit .value_required:n = true ,
- cell-space-limits .meta:n =
- {
- cell-space-top-limit = #1 ,
- cell-space-bottom-limit = #1 ,
- } ,
- color .code:n =
- {
- \leavevmode \color { #1 }
- \tl_gput_right:Nn \g__nicematrix_row_style_tl
- { \leavevmode \color { #1 } }
- } ,
- color .value_required:n = true ,
- unknown .code:n = \__nicematrix_error:n { Unknown~key~for~RowStyle }
- }
-\NewDocumentCommand \__nicematrix_RowStyle:n { O { } m }
- {
- \tl_gset:Nn \g__nicematrix_row_style_tl { #2 }
- \keys_set:nn { NiceMatrix / RowStyle } { #1 }
- #2
- \ignorespaces
- }
\cs_new_protected:Npn \__nicematrix_pre_code_before:
{
\int_set:Nn \c@iRow { \seq_item:Nn \c__nicematrix_size_seq 2 }
@@ -1391,6 +1382,7 @@
\__nicematrix_create_diag_nodes:
\bool_if:NT \g__nicematrix_recreate_cell_nodes_bool \__nicematrix_recreate_cell_nodes:
\endpgfpicture
+ \__nicematrix_create_blocks_nodes:
\bool_if:NT \c__nicematrix_tikz_loaded_bool
{
\tikzset
@@ -1471,8 +1463,49 @@
}
}
}
+ \int_step_inline:nn \c@iRow
+ {
+ \pgfnodealias
+ { \__nicematrix_env: - ##1 - last }
+ { \__nicematrix_env: - ##1 - \int_use:N \c@jCol }
+ }
+ \int_step_inline:nn \c@jCol
+ {
+ \pgfnodealias
+ { \__nicematrix_env: - last - ##1 }
+ { \__nicematrix_env: - \int_use:N \c@iRow - ##1 }
+ }
\__nicematrix_create_extra_nodes:
}
+\cs_new_protected:Npn \__nicematrix_create_blocks_nodes:
+ {
+ \pgfpicture
+ \pgf@relevantforpicturesizefalse
+ \pgfrememberpicturepositiononpagetrue
+ \seq_map_inline:Nn \g__nicematrix_pos_of_blocks_seq
+ { \__nicematrix_create_one_block_node:nnnnn ##1 }
+ \endpgfpicture
+ }
+\cs_new_protected:Npn \__nicematrix_create_one_block_node:nnnnn #1 #2 #3 #4 #5
+ {
+ \tl_if_empty:nF { #5 }
+ {
+ \__nicematrix_qpoint:n { col - #2 }
+ \dim_set_eq:NN \l_tmpa_dim \pgf@x
+ \__nicematrix_qpoint:n { #1 }
+ \dim_set_eq:NN \l_tmpb_dim \pgf@y
+ \__nicematrix_qpoint:n { col - \__nicematrix_succ:n { #4 } }
+ \dim_set_eq:NN \l_tmpc_dim \pgf@x
+ \__nicematrix_qpoint:n { \__nicematrix_succ:n { #3 } }
+ \dim_set_eq:NN \l_tmpd_dim \pgf@y
+ \__nicematrix_pgf_rect_node:nnnnn
+ { \__nicematrix_env: - #5 }
+ { \dim_use:N \l_tmpa_dim }
+ { \dim_use:N \l_tmpb_dim }
+ { \dim_use:N \l_tmpc_dim }
+ { \dim_use:N \l_tmpd_dim }
+ }
+ }
\cs_new_protected:Npn \__nicematrix_patch_for_revtex:
{
\cs_set_eq:NN \@addamp \@addamp@LaTeX
@@ -1492,7 +1525,7 @@
\NewDocumentEnvironment { NiceArrayWithDelims }
{ m m O { } m ! O { } t \CodeBefore }
{
- \bool_if:NT \c__nicematrix_revtex_bool \__nicematrix_patch_for_revtex:
+ \bool_if:NT \c__nicematrix_revtex_bool \__nicematrix_patch_for_revtex:
\__nicematrix_provide_pgfsyspdfmark:
\bool_if:NT \c__nicematrix_footnote_bool \savenotes
\bgroup
@@ -1699,24 +1732,25 @@
{
\__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 }
- \int_gzero:N \c@jCol
- \tl_gclear:N \g__nicematrix_preamble_tl
- \bool_gset_false:N \g_tmpb_bool
- \tl_if_eq:NnTF \l__nicematrix_vlines_clist { all }
- {
- \tl_gset:Nn \g__nicematrix_preamble_tl
- { ! { \skip_horizontal:N \arrayrulewidth } }
- }
- {
- \clist_if_in:NnT \l__nicematrix_vlines_clist 1
- {
- \tl_gset:Nn \g__nicematrix_preamble_tl
- { ! { \skip_horizontal:N \arrayrulewidth } }
- }
- }
+ \cs_if_exist:NT \NC@find@V { \__nicematrix_newcolumntype V { \__nicematrix_V: } }
+ \exp_args:NV \@temptokena \g__nicematrix_preamble_tl
+ \@tempswatrue
+ \@whilesw \if@tempswa \fi { \@tempswafalse \the \NC@list }
+ \int_gzero:N \c@jCol
+ \tl_gclear:N \g__nicematrix_preamble_tl
+ \bool_gset_false:N \g_tmpb_bool
+ \tl_if_eq:NnTF \l__nicematrix_vlines_clist { all }
+ {
+ \tl_gset:Nn \g__nicematrix_preamble_tl
+ { ! { \skip_horizontal:N \arrayrulewidth } }
+ }
+ {
+ \clist_if_in:NnT \l__nicematrix_vlines_clist 1
+ {
+ \tl_gset:Nn \g__nicematrix_preamble_tl
+ { ! { \skip_horizontal:N \arrayrulewidth } }
+ }
+ }
\seq_clear:N \g__nicematrix_cols_vlism_seq
\int_zero:N \l_tmpa_int
\exp_after:wN \__nicematrix_patch_preamble:n \the \@temptokena \q_stop
@@ -1779,22 +1813,24 @@
p { \__nicematrix_patch_preamble_iv:n #1 }
b { \__nicematrix_patch_preamble_iv:n #1 }
m { \__nicematrix_patch_preamble_iv:n #1 }
- \__nicematrix_w: { \__nicematrix_patch_preamble_v:nnnn { } #1 }
- \__nicematrix_W: { \__nicematrix_patch_preamble_v:nnnn { \cs_set_eq:NN \hss \hfil } #1 }
- \__nicematrix_S: { \__nicematrix_patch_preamble_vi:n }
- ( { \__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 }
- X { \__nicematrix_patch_preamble_ix:n }
- \__nicematrix_X { \__nicematrix_patch_preamble_ix:n }
+ \__nicematrix_V: { \__nicematrix_patch_preamble_v:n }
+ V { \__nicematrix_patch_preamble_v:n }
+ \__nicematrix_w: { \__nicematrix_patch_preamble_vi:nnnn { } #1 }
+ \__nicematrix_W: { \__nicematrix_patch_preamble_vi:nnnn { \cs_set_eq:NN \hss \hfil } #1 }
+ \__nicematrix_S: { \__nicematrix_patch_preamble_vii:n }
+ ( { \__nicematrix_patch_preamble_viii:nn #1 }
+ [ { \__nicematrix_patch_preamble_viii:nn #1 }
+ \{ { \__nicematrix_patch_preamble_viii:nn #1 }
+ ) { \__nicematrix_patch_preamble_ix:nn #1 }
+ ] { \__nicematrix_patch_preamble_ix:nn #1 }
+ \} { \__nicematrix_patch_preamble_ix:nn #1 }
+ X { \__nicematrix_patch_preamble_x:n }
+ \__nicematrix_X { \__nicematrix_patch_preamble_x:n }
\q_stop { }
}
{
\str_if_eq:VnTF \l__nicematrix_letter_for_dotted_lines_str { #1 }
- { \__nicematrix_patch_preamble_xi:n #1 }
+ { \__nicematrix_patch_preamble_xii:n #1 }
{
\str_if_eq:VnTF \l__nicematrix_letter_vlism_tl { #1 }
{
@@ -1826,7 +1862,7 @@
< \__nicematrix_cell_end:
}
\int_gincr:N \c@jCol
- \__nicematrix_patch_preamble_x:n
+ \__nicematrix_patch_preamble_xi:n
}
\cs_new_protected:Npn \__nicematrix_patch_preamble_ii:nn #1 #2
{
@@ -1903,13 +1939,13 @@
{
\str_set:Nn \l__nicematrix_hpos_col_str { j }
\keys_set:nn { WithArrows / p-column } { #1 }
- \__nicematrix_patch_preamble_iv_iv:n { #2 }
+ \__nicematrix_patch_preamble_iv_iv:nn { #2 } { minipage }
}
-\cs_new_protected:Npn \__nicematrix_patch_preamble_iv_iv:n #1
+\cs_new_protected:Npn \__nicematrix_patch_preamble_iv_iv:nn #1 #2
{
\use:x
{
- \__nicematrix_patch_preamble_iv_v:nnnnnn
+ \__nicematrix_patch_preamble_iv_v:nnnnnnn
{ \str_if_eq:VnTF \l__nicematrix_vpos_col_str { p } { t } { b } }
{ \dim_eval:n { #1 } }
{
@@ -1929,18 +1965,19 @@
{ \str_if_eq:VnT \l__nicematrix_vpos_col_str { m } \__nicematrix_center_cell_box: }
{ \str_if_eq:VnT \l__nicematrix_hpos_col_str { si } \siunitx_cell_begin:w }
{ \str_if_eq:VnT \l__nicematrix_hpos_col_str { si } \siunitx_cell_end: }
+ { #2 }
}
\int_gincr:N \c@jCol
- \__nicematrix_patch_preamble_x:n
+ \__nicematrix_patch_preamble_xi:n
}
-\cs_new_protected:Npn \__nicematrix_patch_preamble_iv_v:nnnnnn #1 #2 #3 #4 #5 #6
+\cs_new_protected:Npn \__nicematrix_patch_preamble_iv_v:nnnnnnn #1 #2 #3 #4 #5 #6 #7
{
\tl_gput_right:Nn \g__nicematrix_preamble_tl
{
> {
\dim_set:Nn \l__nicematrix_col_width_dim { #2 }
\__nicematrix_cell_begin:w
- \begin { minipage } [ #1 ] { #2 }
+ \begin { #7 } [ #1 ] { #2 }
\everypar
{
\vrule height \box_ht:N \@arstrutbox width \c_zero_dim
@@ -1955,7 +1992,8 @@
< {
#6
\@finalstrut \@arstrutbox
- \end { minipage }
+ % \bool_if:NT \g__nicematrix_rotate_bool { \raggedright \hsize = 3 cm }
+ \end { #7 }
#4
\__nicematrix_cell_end:
}
@@ -1977,12 +2015,32 @@
( \box_ht:N \l__nicematrix_cell_box - \box_ht:N \@arstrutbox
+ \baselineskip ) / 2
}
- { \box_use:N \l__nicematrix_cell_box }
+ { \box_use:N \l__nicematrix_cell_box }
}
}
}
}
-\cs_new_protected:Npn \__nicematrix_patch_preamble_v:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \__nicematrix_patch_preamble_v:n #1
+ {
+ \str_if_eq:nnTF { #1 } { [ }
+ { \__nicematrix_patch_preamble_v_i:w [ }
+ { \__nicematrix_patch_preamble_v_i:w [ ] { #1 } }
+ }
+\cs_new_protected:Npn \__nicematrix_patch_preamble_v_i:w [ #1 ]
+ { \__nicematrix_patch_preamble_v_ii:nn { #1 } }
+\cs_new_protected:Npn \__nicematrix_patch_preamble_v_ii:nn #1 #2
+ {
+ \str_set:Nn \l__nicematrix_vpos_col_str { p }
+ \str_set:Nn \l__nicematrix_hpos_col_str { j }
+ \keys_set:nn { WithArrows / p-column } { #1 }
+ \bool_if:NTF \c__nicematrix_varwidth_loaded_bool
+ { \__nicematrix_patch_preamble_iv_iv:nn { #2 } { varwidth } }
+ {
+ \__nicematrix_error:n { varwidth~not~loaded }
+ \__nicematrix_patch_preamble_iv_iv:nn { #2 } { minipage }
+ }
+ }
+\cs_new_protected:Npn \__nicematrix_patch_preamble_vi:nnnn #1 #2 #3 #4
{
\tl_gput_right:Nn \g__nicematrix_preamble_tl
{
@@ -2003,21 +2061,21 @@
}
}
\int_gincr:N \c@jCol
- \__nicematrix_patch_preamble_x:n
+ \__nicematrix_patch_preamble_xi:n
}
-\cs_new_protected:Npn \__nicematrix_patch_preamble_vi:n #1
+\cs_new_protected:Npn \__nicematrix_patch_preamble_vii:n #1
{
\str_if_eq:nnTF { #1 } { [ }
- { \__nicematrix_patch_preamble_vi_i:w [ }
- { \__nicematrix_patch_preamble_vi_i:w [ ] { #1 } }
+ { \__nicematrix_patch_preamble_vii_i:w [ }
+ { \__nicematrix_patch_preamble_vii_i:w [ ] { #1 } }
}
-\cs_new_protected:Npn \__nicematrix_patch_preamble_vi_i:w [ #1 ]
- { \__nicematrix_patch_preamble_vi_ii:n { #1 } }
+\cs_new_protected:Npn \__nicematrix_patch_preamble_vii_i:w [ #1 ]
+ { \__nicematrix_patch_preamble_vii_ii:n { #1 } }
\AtBeginDocument
{
\cs_if_exist:NTF \siunitx_cell_begin:w
{
- \cs_new_protected:Npn \__nicematrix_patch_preamble_vi_ii:n #1
+ \cs_new_protected:Npn \__nicematrix_patch_preamble_vii_ii:n #1
{
\tl_gput_right:Nn \g__nicematrix_preamble_tl
{
@@ -2030,11 +2088,11 @@
< { \siunitx_cell_end: \__nicematrix_cell_end: }
}
\int_gincr:N \c@jCol
- \__nicematrix_patch_preamble_x:n
+ \__nicematrix_patch_preamble_xi:n
}
}
{
- \cs_new_protected:Npn \__nicematrix_patch_preamble_vi_ii:n #1
+ \cs_new_protected:Npn \__nicematrix_patch_preamble_vii_ii:n #1
{
\tl_gput_right:Nn \g__nicematrix_preamble_tl
{
@@ -2043,11 +2101,11 @@
< { \c__nicematrix_table_print_tl \__nicematrix_cell_end: }
}
\int_gincr:N \c@jCol
- \__nicematrix_patch_preamble_x:n
+ \__nicematrix_patch_preamble_xi:n
}
}
}
-\cs_new_protected:Npn \__nicematrix_patch_preamble_vii:nn #1 #2
+\cs_new_protected:Npn \__nicematrix_patch_preamble_viii:nn #1 #2
{
\bool_if:NT \l__nicematrix_small_bool { \__nicematrix_fatal:n { Delimiter~with~small } }
\int_compare:nNnTF \c@jCol = \c_zero_int
@@ -2060,12 +2118,12 @@
}
{
\tl_gput_right:Nn \g__nicematrix_preamble_tl { ! { \enskip } }
- \__nicematrix_patch_preamble_vii_i:nn { #1 } { #2 }
+ \__nicematrix_patch_preamble_viii_i:nn { #1 } { #2 }
}
}
- { \__nicematrix_patch_preamble_vii_i:nn { #1 } { #2 } }
+ { \__nicematrix_patch_preamble_viii_i:nn { #1 } { #2 } }
}
-\cs_new_protected:Npn \__nicematrix_patch_preamble_vii_i:nn #1 #2
+\cs_new_protected:Npn \__nicematrix_patch_preamble_viii_i:nn #1 #2
{
\tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
{ \__nicematrix_delimiter:nnn #1 { \__nicematrix_succ:n \c@jCol } \c_true_bool }
@@ -2076,11 +2134,11 @@
}
{ \__nicematrix_patch_preamble:n #2 }
}
-\cs_new_protected:Npn \__nicematrix_patch_preamble_viii:nn #1 #2
+\cs_new_protected:Npn \__nicematrix_patch_preamble_ix:nn #1 #2
{
\bool_if:NT \l__nicematrix_small_bool { \__nicematrix_fatal:n { Delimiter~with~small } }
\tl_if_in:nnTF { ) ] \} } { #2 }
- { \__nicematrix_patch_preamble_viii_i:nnn #1 #2 }
+ { \__nicematrix_patch_preamble_ix_i:nnn #1 #2 }
{
\tl_if_eq:nnTF { \q_stop } { #2 }
{
@@ -2102,7 +2160,7 @@
}
}
}
-\cs_new_protected:Npn \__nicematrix_patch_preamble_viii_i:nnn #1 #2 #3
+\cs_new_protected:Npn \__nicematrix_patch_preamble_ix_i:nnn #1 #2 #3
{
\tl_if_eq:nnTF { \q_stop } { #3 }
{
@@ -2127,17 +2185,17 @@
\__nicematrix_patch_preamble:n #3
}
}
-\cs_new_protected:Npn \__nicematrix_patch_preamble_ix:n #1
+\cs_new_protected:Npn \__nicematrix_patch_preamble_x:n #1
{
\str_if_eq:nnTF { #1 } { [ }
- { \__nicematrix_patch_preamble_ix_i:w [ }
- { \__nicematrix_patch_preamble_ix_i:w [ ] #1 }
+ { \__nicematrix_patch_preamble_x_i:w [ }
+ { \__nicematrix_patch_preamble_x_i:w [ ] #1 }
}
-\cs_new_protected:Npn \__nicematrix_patch_preamble_ix_i:w [ #1 ]
- { \__nicematrix_patch_preamble_ix_ii:n { #1 } }
+\cs_new_protected:Npn \__nicematrix_patch_preamble_x_i:w [ #1 ]
+ { \__nicematrix_patch_preamble_x_ii:n { #1 } }
\keys_define:nn { WithArrows / X-column }
{ unknown .code:n = \int_set:Nn \l__nicematrix_weight_int { \l_keys_key_str } }
-\cs_new_protected:Npn \__nicematrix_patch_preamble_ix_ii:n #1
+\cs_new_protected:Npn \__nicematrix_patch_preamble_x_ii:n #1
{
\str_set:Nn \l__nicematrix_hpos_col_str { j }
\tl_set:Nn \l__nicematrix_vpos_col_str { p }
@@ -2145,9 +2203,19 @@
\int_set:Nn \l__nicematrix_weight_int { 1 }
\keys_set_known:nnN { WithArrows / p-column } { #1 } \l_tmpa_tl
\keys_set:nV { WithArrows / X-column } \l_tmpa_tl
+ \int_compare:nNnT \l__nicematrix_weight_int < 0
+ {
+ \exp_args:Nnx \__nicematrix_error:nn { negative~weight }
+ { \int_use:N \l__nicematrix_weight_int }
+ \int_set:Nn \l__nicematrix_weight_int { - \l__nicematrix_weight_int }
+ }
\int_gadd:Nn \g__nicematrix_total_X_weight_int \l__nicematrix_weight_int
\bool_if:NTF \l__nicematrix_X_columns_aux_bool
- { \__nicematrix_patch_preamble_iv_iv:n { \l__nicematrix_weight_int \l__nicematrix_X_columns_dim } }
+ {
+ \__nicematrix_patch_preamble_iv_iv:nn
+ { \l__nicematrix_weight_int \l__nicematrix_X_columns_dim }
+ { minipage }
+ }
{
\tl_gput_right:Nn \g__nicematrix_preamble_tl
{
@@ -2165,10 +2233,10 @@
}
}
\int_gincr:N \c@jCol
- \__nicematrix_patch_preamble_x:n
+ \__nicematrix_patch_preamble_xi:n
}
}
-\cs_new_protected:Npn \__nicematrix_patch_preamble_xi:n #1
+\cs_new_protected:Npn \__nicematrix_patch_preamble_xii:n #1
{
\tl_gput_right:Nn \g__nicematrix_preamble_tl
{ ! { \skip_horizontal:N 2\l__nicematrix_radius_dim } }
@@ -2176,10 +2244,10 @@
{ \__nicematrix_vdottedline:n { \int_use:N \c@jCol } }
\__nicematrix_patch_preamble:n
}
-\cs_new_protected:Npn \__nicematrix_patch_preamble_x:n #1
+\cs_new_protected:Npn \__nicematrix_patch_preamble_xi:n #1
{
\str_if_eq:nnTF { #1 } { < }
- \__nicematrix_patch_preamble_xii:n
+ \__nicematrix_patch_preamble_xiii:n
{
\tl_if_eq:NnTF \l__nicematrix_vlines_clist { all }
{
@@ -2197,10 +2265,10 @@
\__nicematrix_patch_preamble:n { #1 }
}
}
-\cs_new_protected:Npn \__nicematrix_patch_preamble_xii:n #1
+\cs_new_protected:Npn \__nicematrix_patch_preamble_xiii:n #1
{
\tl_gput_right:Nn \g__nicematrix_preamble_tl { < { #1 } }
- \__nicematrix_patch_preamble_x:n
+ \__nicematrix_patch_preamble_xi:n
}
\cs_new:Npn \__nicematrix_multicolumn:nnn #1 #2 #3
{
@@ -2226,6 +2294,7 @@
{ \int_eval:n { \c@jCol + 1 } }
{ \int_use:N \c@iRow }
{ \int_eval:n { \c@jCol + #1 } }
+ { } % for the name of the block
}
}
\cs_set:Npn \@sharp { #3 }
@@ -2253,7 +2322,6 @@
b { \__nicematrix_patch_m_preamble_iv:nnn b #1 }
\__nicematrix_w: { \__nicematrix_patch_m_preamble_v:nnnn { } #1 }
\__nicematrix_W: { \__nicematrix_patch_m_preamble_v:nnnn { \cs_set_eq:NN \hss \hfil } #1 }
- \__nicematrix_true_c: { \__nicematrix_patch_m_preamble_vi:n #1 }
\q_stop { }
}
{ \__nicematrix_fatal:nn { unknown~column~type } { #1 } }
@@ -2319,11 +2387,6 @@
}
\__nicematrix_patch_m_preamble_x:n
}
-\cs_new_protected:Npn \__nicematrix_patch_m_preamble_vi:n #1
- {
- \tl_gput_right:Nn \g__nicematrix_preamble_tl { c }
- \__nicematrix_patch_m_preamble_x:n
- }
\cs_new_protected:Npn \__nicematrix_patch_m_preamble_x:n #1
{
\str_if_eq:nnTF { #1 } { < }
@@ -2407,12 +2470,12 @@
{ \box_wd:N \l__nicematrix_the_array_box - \arraycolsep }
}
\begin { minipage } [ t ] { \box_wd:N \l__nicematrix_the_array_box }
- \hbox:n
- {
- \box_use_drop:N \l__nicematrix_the_array_box
- \__nicematrix_create_extra_nodes:
- \seq_if_empty:NF \g__nicematrix_blocks_seq \__nicematrix_draw_blocks:
- }
+ \hbox
+ {
+ \box_use_drop:N \l__nicematrix_the_array_box
+ \__nicematrix_create_extra_nodes:
+ \seq_if_empty:NF \g__nicematrix_blocks_seq \__nicematrix_draw_blocks:
+ }
\bool_lazy_or:nnT
{ \int_compare_p:nNn \c@tabularnote > 0 }
{ ! \tl_if_empty_p:V \l__nicematrix_tabularnote_tl }
@@ -2752,12 +2815,12 @@
\pgfcoordinate { \__nicematrix_env: - col - \__nicematrix_succ:n \g_tmpa_int }
{
\bool_lazy_and:nnTF \l__nicematrix_Matrix_bool \l__nicematrix_NiceArray_bool
- {
- \pgfpoint
- { - 0.5 \arrayrulewidth - \arraycolsep }
- \c_zero_dim
- }
- { \pgfpoint { - 0.5 \arrayrulewidth } \c_zero_dim }
+ {
+ \pgfpoint
+ { - 0.5 \arrayrulewidth - \arraycolsep }
+ \c_zero_dim
+ }
+ { \pgfpoint { - 0.5 \arrayrulewidth } \c_zero_dim }
}
\str_if_empty:NF \l__nicematrix_name_str
{
@@ -2795,7 +2858,7 @@
{
>
{
- \cs_set_eq:NN \CodeAfter \__nicematrix_CodeAfter_i:n
+ \cs_set_eq:NN \CodeAfter \__nicematrix_CodeAfter_i:
\bool_gset_true:N \g__nicematrix_after_col_zero_bool
\__nicematrix_begin_of_row:
\hbox_set:Nw \l__nicematrix_cell_box
@@ -2840,7 +2903,7 @@
{
>
{
- \cs_set_eq:NN \CodeAfter \__nicematrix_CodeAfter_i:n
+ \cs_set_eq:NN \CodeAfter \__nicematrix_CodeAfter_i:
\bool_gset_true:N \g__nicematrix_last_col_found_bool
\int_gincr:N \c@jCol
\int_gset_eq:NN \g__nicematrix_col_total_int \c@jCol
@@ -2935,8 +2998,8 @@
{ \bool_gset_true:N \g__nicematrix_not_empty_cell_bool }
\NewDocumentEnvironment { NiceTabular } { O { } m ! O { } }
{
- \dim_zero_new:N \l__nicematrix_width_dim
- \dim_set_eq:NN \l__nicematrix_width_dim \linewidth
+ \dim_compare:nNnT \l__nicematrix_width_dim = \c_zero_dim
+ { \dim_set_eq:NN \l__nicematrix_width_dim \linewidth }
\str_gset:Nn \g__nicematrix_name_env_str { NiceTabular }
\keys_set:nn { NiceMatrix / NiceTabular } { #1 , #3 }
\bool_set_true:N \l__nicematrix_NiceTabular_bool
@@ -3013,6 +3076,35 @@
}
}
\__nicematrix_create_diag_nodes:
+ \pgfpicture
+ \int_step_inline:nn \c@iRow
+ {
+ \pgfnodealias
+ { \__nicematrix_env: - ##1 - last }
+ { \__nicematrix_env: - ##1 - \int_use:N \c@jCol }
+ }
+ \int_step_inline:nn \c@jCol
+ {
+ \pgfnodealias
+ { \__nicematrix_env: - last - ##1 }
+ { \__nicematrix_env: - \int_use:N \c@iRow - ##1 }
+ }
+ \str_if_empty:NF \l__nicematrix_name_str
+ {
+ \int_step_inline:nn \c@iRow
+ {
+ \pgfnodealias
+ { \l__nicematrix_name_str - ##1 - last }
+ { \__nicematrix_env: - ##1 - \int_use:N \c@jCol }
+ }
+ \int_step_inline:nn \c@jCol
+ {
+ \pgfnodealias
+ { \l__nicematrix_name_str - last - ##1 }
+ { \__nicematrix_env: - \int_use:N \c@iRow - ##1 }
+ }
+ }
+ \endpgfpicture
\bool_if:NT \l__nicematrix_parallelize_diags_bool
{
\int_gzero_new:N \g__nicematrix_ddots_int
@@ -3074,7 +3166,6 @@
}
\bool_set_true:N \l__nicematrix_code_before_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@
@@ -3084,9 +3175,9 @@
\cs_new_protected:Npn \__nicematrix_adjust_pos_of_blocks_seq:
{
\seq_gset_map_x:NNn \g__nicematrix_pos_of_blocks_seq \g__nicematrix_pos_of_blocks_seq
- { \__nicematrix_adjust_pos_of_blocks_seq_i:nnnn ##1 }
+ { \__nicematrix_adjust_pos_of_blocks_seq_i:nnnnn ##1 }
}
-\cs_new:Npn \__nicematrix_adjust_pos_of_blocks_seq_i:nnnn #1 #2 #3 #4
+\cs_new:Npn \__nicematrix_adjust_pos_of_blocks_seq_i:nnnnn #1 #2 #3 #4 #5
{
{ #1 }
{ #2 }
@@ -3100,6 +3191,7 @@
{ \int_use:N \c@jCol }
{ #4 }
}
+ { #5 }
}
\AtBeginDocument
{
@@ -3136,49 +3228,6 @@
\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
@@ -3369,6 +3418,7 @@
{ \int_min:nn \l__nicematrix_initial_j_int \l__nicematrix_final_j_int }
{ \int_use:N \l__nicematrix_final_i_int }
{ \int_max:nn \l__nicematrix_initial_j_int \l__nicematrix_final_j_int }
+ { } % for the name of the block
}
}
\cs_new_protected:Npn \__nicematrix_adjust_to_submatrix:nn #1 #2
@@ -3685,15 +3735,11 @@
\bool_if:NTF \l__nicematrix_initial_open_bool
{
\__nicematrix_open_y_initial_dim:
- % \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_initial_j_int }
- % \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x
\__nicematrix_open_x_initial_dim:
}
{ \__nicematrix_set_initial_coords_from_anchor:n { south~east } }
\bool_if:NTF \l__nicematrix_final_open_bool
{
- % \__nicematrix_open_y_final_dim:
- % \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l__nicematrix_final_j_int }
\__nicematrix_open_x_final_dim:
\dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x
}
@@ -3962,8 +4008,8 @@
\int_compare:nNnTF \c@jCol = \l__nicematrix_last_col_int
{ \__nicematrix_error:nn { in~last~col } \Ldots }
{
- \__nicematrix_instruction_of_type:nnn \c_false_bool { Ldots }
- { #1 , down = #2 , up = #3 }
+ \__nicematrix_instruction_of_type:nnn \c_false_bool { Ldots }
+ { #1 , down = #2 , up = #3 }
}
}
\bool_if:NF \l__nicematrix_nullify_dots_bool
@@ -3978,8 +4024,8 @@
\int_compare:nNnTF \c@jCol = \l__nicematrix_last_col_int
{ \__nicematrix_error:nn { in~last~col } \Cdots }
{
- \__nicematrix_instruction_of_type:nnn \c_false_bool { Cdots }
- { #1 , down = #2 , up = #3 }
+ \__nicematrix_instruction_of_type:nnn \c_false_bool { Cdots }
+ { #1 , down = #2 , up = #3 }
}
}
\bool_if:NF \l__nicematrix_nullify_dots_bool
@@ -3994,8 +4040,8 @@
\int_compare:nNnTF \c@iRow = \l__nicematrix_last_row_int
{ \__nicematrix_error:nn { in~last~row } \Vdots }
{
- \__nicematrix_instruction_of_type:nnn \c_false_bool { Vdots }
- { #1 , down = #2 , up = #3 }
+ \__nicematrix_instruction_of_type:nnn \c_false_bool { Vdots }
+ { #1 , down = #2 , up = #3 }
}
}
\bool_if:NF \l__nicematrix_nullify_dots_bool
@@ -4288,6 +4334,105 @@
\dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y
\__nicematrix_draw_line:
}
+\keys_define:nn { NiceMatrix / RowStyle }
+ {
+ cell-space-top-limit .dim_set:N = \l_tmpa_dim ,
+ cell-space-top-limit .initial:n = \c_zero_dim ,
+ cell-space-top-limit .value_required:n = true ,
+ cell-space-bottom-limit .dim_set:N = \l_tmpb_dim ,
+ cell-space-bottom-limit .initial:n = \c_zero_dim ,
+ cell-space-bottom-limit .value_required:n = true ,
+ cell-space-limits .meta:n =
+ {
+ cell-space-top-limit = #1 ,
+ cell-space-bottom-limit = #1 ,
+ } ,
+ color .tl_set:N = \l_tmpa_tl ,
+ color .value_required:n = true ,
+ bold .bool_set:N = \l_tmpa_bool ,
+ bold .default:n = true ,
+ bold .initial:n = false ,
+ nb-rows .int_set:N = \l__nicematrix_key_nb_rows_int ,
+ nb-rows .value_required:n = true ,
+ nb-rows .initial:n = 1 ,
+ rowcolor .tl_set:N = \l_tmpc_tl ,
+ rowcolor .value_required:n = true ,
+ rowcolor .initial:n = \c_empty_tl ,
+ unknown .code:n = \__nicematrix_error:n { Unknown~key~for~RowStyle }
+ }
+\NewDocumentCommand \__nicematrix_RowStyle:n { O { } m }
+ {
+ \keys_set:nn { NiceMatrix / RowStyle } { #1 }
+ \tl_if_empty:NF \l_tmpc_tl
+ {
+ \tl_gput_right:Nx \g_nicematrix_code_before_tl
+ {
+ \__nicematrix_rectanglecolor
+ { \l_tmpc_tl }
+ { \int_use:N \c@iRow - \int_use:N \c@jCol }
+ { \int_use:N \c@iRow - * }
+ }
+ \int_compare:nNnT \l__nicematrix_key_nb_rows_int > 1
+ {
+ \tl_gput_right:Nx \g_nicematrix_code_before_tl
+ {
+ \__nicematrix_rowcolor
+ { \l_tmpc_tl }
+ {
+ \int_eval:n { \c@iRow + 1 }
+ - \int_eval:n { \c@iRow + \l__nicematrix_key_nb_rows_int - 1 }
+ }
+ }
+ }
+ }
+ \tl_gput_right:Nn \g__nicematrix_row_style_tl { \ifnum \c@iRow < }
+ \tl_gput_right:Nx \g__nicematrix_row_style_tl
+ { \int_eval:n { \c@iRow + \l__nicematrix_key_nb_rows_int } }
+ \tl_gput_right:Nn \g__nicematrix_row_style_tl { #2 }
+ \dim_compare:nNnT \l_tmpa_dim > \c_zero_dim
+ {
+ \tl_gput_right:Nx \g__nicematrix_row_style_tl
+ {
+ \tl_gput_right:Nn \exp_not:N \g__nicematrix_post_action_cell_tl
+ {
+ \dim_set:Nn \l__nicematrix_cell_space_top_limit_dim
+ { \dim_use:N \l_tmpa_dim }
+ }
+ }
+ }
+ \dim_compare:nNnT \l_tmpb_dim > \c_zero_dim
+ {
+ \tl_gput_right:Nx \g__nicematrix_row_style_tl
+ {
+ \tl_gput_right:Nn \exp_not:N \g__nicematrix_post_action_cell_tl
+ {
+ \dim_set:Nn \l__nicematrix_cell_space_bottom_limit_dim
+ { \dim_use:N \l_tmpb_dim }
+ }
+ }
+ }
+ \tl_if_empty:NF \l_tmpa_tl
+ {
+ \tl_gput_right:Nx \g__nicematrix_row_style_tl
+ { \mode_leave_vertical: \exp_not:N \color { \l_tmpa_tl } }
+ }
+ \bool_if:NT \l_tmpa_bool
+ {
+ \tl_gput_right:Nn \g__nicematrix_row_style_tl
+ {
+ \if_mode_math:
+ \c_math_toggle_token
+ \bfseries \boldmath
+ \c_math_toggle_token
+ \else:
+ \bfseries \boldmath
+ \fi:
+ }
+ }
+ \tl_gput_right:Nn \g__nicematrix_row_style_tl { \fi }
+ \g__nicematrix_row_style_tl
+ \ignorespaces
+ }
\cs_new_protected:Npn \__nicematrix_add_to_colors_seq:nn #1 #2
{
\int_zero:N \l_tmpa_int
@@ -4315,11 +4460,6 @@
}
\endpgfpicture
}
-\cs_set_protected:Npn \__nicematrix_cut_on_hyphen:w #1-#2\q_stop
- {
- \tl_set:Nn \l_tmpa_tl { #1 }
- \tl_set:Nn \l_tmpb_tl { #2 }
- }
\cs_new_protected:Npn \__nicematrix_cartesian_color:nn #1 #2
{
\tl_set:Nn \l__nicematrix_rows_tl { #1 }
@@ -4393,7 +4533,7 @@
}
}
\keys_define:nn { NiceMatrix / arraycolor }
- { except-corners .code:n = \__nicematrix_error:n { key except-corners } }
+ { except-corners .code:n = \__nicematrix_error:n { key~except-corners } }
\NewDocumentCommand \__nicematrix_arraycolor { O { } m O { } }
{
\keys_set:nn { NiceMatrix / arraycolor } { #3 }
@@ -4424,7 +4564,7 @@
{
\seq_set_eq:NN \l_tmpb_seq \g__nicematrix_pos_of_blocks_seq
\seq_set_filter:NNn \l_tmpa_seq \l_tmpb_seq
- { \__nicematrix_not_in_exterior_p:nnnn ##1 }
+ { \__nicematrix_not_in_exterior_p:nnnnn ##1 }
}
\pgfpicture
\pgf@relevantforpicturesizefalse
@@ -4446,8 +4586,8 @@
\bool_if:NT \l__nicematrix_respect_blocks_bool
{
\seq_set_filter:NNn \l_tmpb_seq \l_tmpa_seq
- { \__nicematrix_intersect_our_row_p:nnnn ####1 }
- \seq_map_inline:Nn \l_tmpb_seq { \__nicematrix_rowcolors_i:nnnn ####1 }
+ { \__nicematrix_intersect_our_row_p:nnnnn ####1 }
+ \seq_map_inline:Nn \l_tmpb_seq { \__nicematrix_rowcolors_i:nnnnn ####1 }
}
\tl_set:Nx \l__nicematrix_rows_tl
{ \int_use:N \l_tmpa_int - \int_use:N \l_tmpb_int }
@@ -4483,12 +4623,12 @@
}
\NewDocumentCommand \__nicematrix_rowcolors { O { } m m m O { } }
{ \__nicematrix_rowlistcolors [ #1 ] { #2 } { { #3 } , { #4 } } [ #5 ] }
-\cs_new_protected:Npn \__nicematrix_rowcolors_i:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \__nicematrix_rowcolors_i:nnnnn #1 #2 #3 #4 #5
{
\int_compare:nNnT { #3 } > \l_tmpb_int
{ \int_set:Nn \l_tmpb_int { #3 } }
}
-\prg_new_conditional:Nnn \__nicematrix_not_in_exterior:nnnn p
+\prg_new_conditional:Nnn \__nicematrix_not_in_exterior:nnnnn p
{
\bool_lazy_or:nnTF
{ \int_compare_p:nNn { #4 } = \c_zero_int }
@@ -4496,7 +4636,7 @@
\prg_return_false:
\prg_return_true:
}
-\prg_new_conditional:Nnn \__nicematrix_intersect_our_row:nnnn p
+\prg_new_conditional:Nnn \__nicematrix_intersect_our_row:nnnnn p
{
\bool_if:nTF
{
@@ -4596,7 +4736,7 @@
{
\tl_gput_right:Nx \g_nicematrix_code_before_tl
{
- \cellcolor [ #1 ] { \exp_not:n { #2 } }
+ \__nicematrix_cellcolor [ #1 ] { \exp_not:n { #2 } }
{ \int_use:N \c@iRow - \int_use:N \c@jCol }
}
}
@@ -4607,7 +4747,7 @@
{
\tl_gput_right:Nx \g_nicematrix_code_before_tl
{
- \exp_not:N \rectanglecolor [ #1 ] { \exp_not:n { #2 } }
+ \__nicematrix_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 } }
}
@@ -4661,30 +4801,30 @@
{ \tl_if_blank:nTF { #4 } { \int_use:N \c@iRow } { #4 } }
\l_tmpa_tl
{
- \bool_gset_true:N \g_tmpa_bool
- \seq_map_inline:Nn \g__nicematrix_pos_of_blocks_seq
- { \__nicematrix_test_vline_in_block:nnnn ##1 }
- \seq_map_inline:Nn \g__nicematrix_pos_of_xdots_seq
- { \__nicematrix_test_vline_in_block:nnnn ##1 }
- \seq_map_inline:Nn \g__nicematrix_pos_of_stroken_blocks_seq
- { \__nicematrix_test_vline_in_stroken_block:nnnn ##1 }
- \clist_if_empty:NF \l__nicematrix_corners_clist \__nicematrix_test_in_corner_v:
- \bool_if:NTF \g_tmpa_bool
- {
- \tl_if_empty:NT \l_tmpc_tl
- { \tl_set_eq:NN \l_tmpc_tl \l_tmpa_tl }
- }
- {
- \tl_if_empty:NF \l_tmpc_tl
- {
- \__nicematrix_vline_ii:nnnn
- { #1 }
- { #2 }
- \l_tmpc_tl
- { \int_eval:n { \l_tmpa_tl - 1 } }
- \tl_clear:N \l_tmpc_tl
- }
- }
+ \bool_gset_true:N \g_tmpa_bool
+ \seq_map_inline:Nn \g__nicematrix_pos_of_blocks_seq
+ { \__nicematrix_test_vline_in_block:nnnnn ##1 }
+ \seq_map_inline:Nn \g__nicematrix_pos_of_xdots_seq
+ { \__nicematrix_test_vline_in_block:nnnnn ##1 }
+ \seq_map_inline:Nn \g__nicematrix_pos_of_stroken_blocks_seq
+ { \__nicematrix_test_vline_in_stroken_block:nnnn ##1 }
+ \clist_if_empty:NF \l__nicematrix_corners_clist \__nicematrix_test_in_corner_v:
+ \bool_if:NTF \g_tmpa_bool
+ {
+ \tl_if_empty:NT \l_tmpc_tl
+ { \tl_set_eq:NN \l_tmpc_tl \l_tmpa_tl }
+ }
+ {
+ \tl_if_empty:NF \l_tmpc_tl
+ {
+ \__nicematrix_vline_ii:nnnn
+ { #1 }
+ { #2 }
+ \l_tmpc_tl
+ { \int_eval:n { \l_tmpa_tl - 1 } }
+ \tl_clear:N \l_tmpc_tl
+ }
+ }
}
\tl_if_empty:NF \l_tmpc_tl
{
@@ -4818,9 +4958,9 @@
{
\bool_gset_true:N \g_tmpa_bool
\seq_map_inline:Nn \g__nicematrix_pos_of_blocks_seq
- { \__nicematrix_test_hline_in_block:nnnn ##1 }
+ { \__nicematrix_test_hline_in_block:nnnnn ##1 }
\seq_map_inline:Nn \g__nicematrix_pos_of_xdots_seq
- { \__nicematrix_test_hline_in_block:nnnn ##1 }
+ { \__nicematrix_test_hline_in_block:nnnnn ##1 }
\seq_map_inline:Nn \g__nicematrix_pos_of_stroken_blocks_seq
{ \__nicematrix_test_hline_in_stroken_block:nnnn ##1 }
\clist_if_empty:NF \l__nicematrix_corners_clist \__nicematrix_test_in_corner_h:
@@ -4989,7 +5129,7 @@
{ \__nicematrix_hline:nnnn { \__nicematrix_succ:n { \c@iRow } } { #1 } 1 { } }
\ifnum 0 = `{ \fi }
}
-\cs_new_protected:Npn \__nicematrix_test_hline_in_block:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \__nicematrix_test_hline_in_block:nnnnn #1 #2 #3 #4
{
\bool_lazy_all:nT
{
@@ -5000,7 +5140,7 @@
}
{ \bool_gset_false:N \g_tmpa_bool }
}
-\cs_new_protected:Npn \__nicematrix_test_vline_in_block:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \__nicematrix_test_vline_in_block:nnnnn #1 #2 #3 #4
{
\bool_lazy_all:nT
{
@@ -5070,8 +5210,8 @@
\__nicematrix_test_if_cell_in_a_block:nn { ##1 } { \int_eval:n { #2 } }
\bool_lazy_or:nnTF
{
- \cs_if_exist_p:c
- { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - \int_eval:n { #2 } }
+ \cs_if_exist_p:c
+ { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - \int_eval:n { #2 } }
}
\l_tmpb_bool
{ \bool_set_true:N \l_tmpa_bool }
@@ -5131,7 +5271,7 @@
\seq_map_inline:Nn \g__nicematrix_pos_of_blocks_seq
{ \__nicematrix_test_if_cell_in_block:nnnnnnn \l_tmpa_int \l_tmpb_int ##1 }
}
-\cs_new_protected:Npn \__nicematrix_test_if_cell_in_block:nnnnnnn #1 #2 #3 #4 #5 #6
+\cs_new_protected:Npn \__nicematrix_test_if_cell_in_block:nnnnnnn #1 #2 #3 #4 #5 #6 #7
{
\int_compare:nNnT { #3 } < { \__nicematrix_succ:n { #1 } }
{
@@ -5680,6 +5820,9 @@
t .value_forbidden:n = true ,
b .code:n = \str_set:Nn \l__nicematrix_vpos_of_block_tl b ,
b .value_forbidden:n = true ,
+ name .tl_set:N = \l__nicematrix_block_name_str ,
+ name .value_required:n = true ,
+ name .initial:n = \c_empty_tl ,
unknown .code:n = \__nicematrix_error:n { Unknown~key~for~Block }
}
\cs_new_protected:Npn \__nicematrix_draw_blocks:
@@ -5732,8 +5875,8 @@
}
}
{
- \seq_gput_left:Nn \g__nicematrix_pos_of_blocks_seq
- { { #1 } { #2 } { #3 } { #4 } }
+ \seq_gput_left:Nx \g__nicematrix_pos_of_blocks_seq
+ { { #1 } { #2 } { #3 } { #4 } { \l__nicematrix_block_name_str } }
}
\tl_if_empty:NF \l__nicematrix_draw_tl
{
@@ -5807,11 +5950,21 @@
\dim_set_eq:NN \l_tmpc_dim \pgf@y
\__nicematrix_qpoint:n { col - \__nicematrix_succ:n { \l__nicematrix_last_col_int } }
\dim_set_eq:NN \l_tmpd_dim \pgf@x
- \begin { pgfscope }
\__nicematrix_pgf_rect_node:nnnnn
{ \__nicematrix_env: - #1 - #2 - block }
\l_tmpb_dim \l_tmpa_dim \l_tmpd_dim \l_tmpc_dim
- \end { pgfscope }
+ \str_if_empty:NF \l__nicematrix_block_name_str
+ {
+ \pgfnodealias
+ { \__nicematrix_env: - \l__nicematrix_block_name_str }
+ { \__nicematrix_env: - #1 - #2 - block }
+ \str_if_empty:NF \l__nicematrix_name_str
+ {
+ \pgfnodealias
+ { \l__nicematrix_name_str - \l__nicematrix_block_name_str }
+ { \__nicematrix_env: - #1 - #2 - block }
+ }
+ }
\bool_if:NF \l__nicematrix_hpos_of_block_cap_bool
{
\dim_set_eq:NN \l_tmpb_dim \c_max_dim
@@ -6220,6 +6373,7 @@
{ \int_use:N \c@jCol }
{ \int_use:N \c@iRow }
{ \int_use:N \c@jCol }
+ { }
}
}
\cs_new_protected:Npn \__nicematrix_actually_diagbox:nnnnnn #1 #2 #3 #4 #5 #6
@@ -6246,11 +6400,24 @@
\pgfscope
\pgftransformshift { \pgfpoint \l_tmpb_dim \l_tmpc_dim }
\pgfnode { rectangle } { south~west }
- { \__nicematrix_math_toggle_token: #5 \__nicematrix_math_toggle_token: } { } { }
+ {
+ \begin { minipage } { 20 cm }
+ \__nicematrix_math_toggle_token: #5 \__nicematrix_math_toggle_token:
+ \end { minipage }
+ }
+ { }
+ { }
\endpgfscope
\pgftransformshift { \pgfpoint \l_tmpd_dim \l_tmpa_dim }
\pgfnode { rectangle } { north~east }
- { \__nicematrix_math_toggle_token: #6 \__nicematrix_math_toggle_token: } { } { }
+ {
+ \begin { minipage } { 20 cm }
+ \raggedleft
+ \__nicematrix_math_toggle_token: #6 \__nicematrix_math_toggle_token:
+ \end { minipage }
+ }
+ { }
+ { }
\endpgfpicture
}
\keys_define:nn { NiceMatrix }
@@ -6268,18 +6435,19 @@
rules .value_required:n = true ,
unknown .code:n = \__nicematrix_error:n { Unknown~key~for~CodeAfter }
}
-\cs_new:Npn \__nicematrix_CodeAfter: { \omit \__nicematrix_CodeAfter_i:n }
-\cs_new_protected:Npn \__nicematrix_CodeAfter_i:n #1 \end
+\cs_new:Npn \__nicematrix_CodeAfter: { \omit \__nicematrix_CodeAfter_ii:n }
+\cs_new_protected:Npn \__nicematrix_CodeAfter_i: { \\ \omit \__nicematrix_CodeAfter_ii:n }
+\cs_new_protected:Npn \__nicematrix_CodeAfter_ii:n #1 \end
{
\tl_gput_right:Nn \g_nicematrix_code_after_tl { #1 }
- \__nicematrix_CodeAfter_ii:n
+ \__nicematrix_CodeAfter_iv:n
}
-\cs_new_protected:Npn \__nicematrix_CodeAfter_ii:n #1
+\cs_new_protected:Npn \__nicematrix_CodeAfter_iv:n #1
{
\str_if_eq:eeTF \@currenvir { #1 } { \end { #1 } }
{
\tl_gput_right:Nn \g_nicematrix_code_after_tl { \end { #1 } }
- \__nicematrix_CodeAfter_i:n
+ \__nicematrix_CodeAfter_ii:n
}
}
\cs_new_protected:Npn \__nicematrix_delimiter:nnn #1 #2 #3
@@ -6421,8 +6589,10 @@
\exp_args:NNV \NewDocumentCommand \__nicematrix_SubMatrix \l__nicematrix_argspec_tl
{
\peek_remove_spaces:n
- { \__nicematrix_sub_matrix:nnnnnnn
- { #1 } { #2 } { #3 } { #4 } { #5 } { #6 } { #7 } }
+ {
+ \__nicematrix_sub_matrix:nnnnnnn
+ { #1 } { #2 } { #3 } { #4 } { #5 } { #6 } { #7 }
+ }
}
}
\cs_new_protected:Npn \__nicematrix_sub_matrix:nnnnnnn #1 #2 #3 #4 #5 #6 #7
@@ -6787,7 +6957,7 @@
}
\bool_set_true:N \c__nicematrix_footnote_bool
}
-\__nicematrix_msg_new:nn { key except-corners }
+\__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~
@@ -6820,6 +6990,11 @@
\tl_if_empty:VF \g__nicematrix_HVdotsfor_lines_tl
{ ~Maybe~your~use~of~\token_to_str:N \Hdotsfor\ is~incorrect.}
}
+\__nicematrix_msg_new:nn { negative~weight }
+ {
+ The~weight~of~the~'X'~columns~must~be~positive~and~you~have~used~
+ the~value~'#1'.~If~you~go~on,~the~absolute~value~will~be~used.
+ }
\__nicematrix_msg_new:nn { too~much~cols~for~matrix~with~last~col }
{
You~try~to~use~more~columns~than~allowed~by~your~
@@ -6895,12 +7070,6 @@
and~'shorten'~(and~you~try~to~use~'\l_keys_key_str').~If~you~go~on,~
this~key~will~be~ignored.
}
-\__nicematrix_msg_new:nn { Unknown~key~for~RowStyle }
- {
- As~for~now,~there~is~only~four~keys~available~here:~'cell-space-top-limit',~
- 'cell-space-bottom-limit~'cell-space-limits'~and~color~(and~you~try~to~use~
- '\l_keys_key_str').~If~you~go~on,~this~key~will~be~ignored.
- }
\__nicematrix_msg_new:nn { Unknown~key~for~rowcolors }
{
As~for~now,~there~is~only~two~keys~available~here:~'cols'~and~'respect-blocks'~
@@ -7102,6 +7271,12 @@
The~value~of~key~'\l_keys_key_str'~must~be~of~length~1.\\
If~you~go~on,~it~will~be~ignored.
}
+\__nicematrix_msg_new:nn { varwidth~not~loaded }
+ {
+ You~can't~use~the~column~type~'V'~because~'varwidth'~is~not~
+ loaded.\\
+ If~you~go~on,~your~column~will~behave~like~'p'.
+ }
\__nicematrix_msg_new:nnn { Unknown~key~for~Block }
{
The~key~'\l_keys_key_str'~is~unknown~for~the~command~\token_to_str:N
@@ -7110,7 +7285,7 @@
}
{
The~available~keys~are~(in~alphabetic~order):~b,~borders,~c,~draw,~fill,~
- hvlines,~l,~line-width,~rounded-corners,~r,~t~and~tikz.
+ hvlines,~l,~line-width,~name,~rounded-corners,~r,~t~and~tikz.
}
\__nicematrix_msg_new:nnn { Unknown~key~for~CodeAfter }
{
@@ -7166,6 +7341,23 @@
label-in-tabular~and~
style.
}
+\__nicematrix_msg_new:nnn { Unknown~key~for~RowStyle }
+ {
+ The~key~'\l_keys_key_str'~is~unknown~for~the~command~
+ \token_to_str:N \RowStyle. \\
+ If~you~go~on,~it~will~be~ignored. \\
+ For~a~list~of~the~available~keys,~type~H~<return>.
+ }
+ {
+ The~available~keys~are~(in~alphabetic~order):~
+ 'bold',~
+ 'cell-space-top-limit',~
+ 'cell-space-bottom-limit',~
+ 'cell-space-limits',~
+ 'color',~
+ 'nb-rows'~and~
+ 'rowcolor'.
+ }
\__nicematrix_msg_new:nnn { Unknown~key~for~NiceMatrixOptions }
{
The~key~'\l_keys_key_str'~is~unknown~for~the~command~