summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/nicematrix
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-11-23 22:01:33 +0000
committerKarl Berry <karl@freefriends.org>2020-11-23 22:01:33 +0000
commit586739881a834da18ee485728bdf9182e02025f8 (patch)
tree66ed5516b8812957e64d20353933abdb4f2c19e2 /Master/texmf-dist/tex/latex/nicematrix
parentc23682f2c0c9d6928d1a2d9f362b8b7ed708fb72 (diff)
nicematrix (23nov20)
git-svn-id: svn://tug.org/texlive/trunk@56990 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/nicematrix')
-rw-r--r--Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty207
1 files changed, 174 insertions, 33 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
index 595260e2658..a43579d0b61 100644
--- a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
+++ b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
@@ -18,9 +18,8 @@
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%%
-\def\myfileversion{5.6}
-\def\myfiledate{2020/11/08}
-
+\def\myfileversion{5.7}
+\def\myfiledate{2020/11/23}
\RequirePackage{pgfcore}
\usepgfmodule{shapes}
\RequirePackage{l3keys2e}
@@ -283,6 +282,7 @@
\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_after_col_zero_bool
\bool_new:N \g__nicematrix_row_of_col_done_bool
\bool_new:N \g__nicematrix_not_empty_cell_bool
\tl_new:N \l__nicematrix_code_before_tl
@@ -300,8 +300,12 @@
\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
+\seq_new:N \g__nicematrix_pos_of_stroken_blocks_seq
\int_new:N \g__nicematrix_static_num_of_col_int
+\tl_new:N \l__nicematrix_fill_tl
+\tl_new:N \l__nicematrix_draw_tl
\tl_new:N \l__nicematrix_color_tl
+\dim_new:N \l__nicematrix_line_width_dim
\tl_new:N \l__nicematrix_pos_of_block_tl
\tl_set:Nn \l__nicematrix_pos_of_block_tl { c }
\bool_new:N \l__nicematrix_draw_first_bool
@@ -470,6 +474,7 @@
\tl_new:N \l__nicematrix_end_of_row_tl
\tl_set:Nn \l__nicematrix_end_of_row_tl { ; }
\tl_new:N \l__nicematrix_xdots_color_tl
+\tl_new:N \l__nicematrix_delimiters_color_tl
\bool_new:N \l__nicematrix_max_delimiter_width_bool
\keys_define:nn { NiceMatrix / xdots }
{
@@ -687,6 +692,8 @@
}
\keys_define:nn { NiceMatrix / NiceMatrixOptions }
{
+ delimiters-color .tl_set:N = \l__nicematrix_delimiters_color_tl ,
+ delimiters-color .value_required:n = true ,
last-col .code:n = \tl_if_empty:nF { #1 }
{ \__nicematrix_error:n { last-col~non~empty~for~NiceMatrixOptions } }
\int_zero:N \l__nicematrix_last_col_int ,
@@ -731,6 +738,8 @@
r .code:n = \tl_set:Nn \l__nicematrix_type_of_col_tl r ,
small .bool_set:N = \l__nicematrix_small_bool ,
small .value_forbidden:n = true ,
+ delimiters-color .tl_set:N = \l__nicematrix_delimiters_color_tl ,
+ delimiters-color .value_required:n = true ,
unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceMatrix }
}
\keys_define:nn { NiceMatrix / NiceArray }
@@ -746,6 +755,8 @@
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 ,
unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceArray }
}
\keys_define:nn { NiceMatrix / pNiceArray }
@@ -803,7 +814,7 @@
}
\cs_new_protected:Npn \__nicematrix_begin_of_row:
{
- \int_gincr:N \c@iRow
+ \refstepcounter { 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 }
\dim_gset:Nn \g__nicematrix_ht_last_row_dim { \box_ht:N \@arstrutbox }
@@ -986,6 +997,7 @@
\cs_new_protected:Npn \__nicematrix_everycr_i:
{
\int_gzero:N \c@jCol
+ \bool_gset_false:N \g__nicematrix_after_col_zero_bool
\bool_if:NF \g__nicematrix_row_of_col_done_bool
{
\__nicematrix_create_row_node:
@@ -1140,6 +1152,7 @@
{ \dim_gzero_new:N \g__nicematrix_max_cell_width_dim }
\seq_gclear:N \g__nicematrix_blocks_seq
\seq_gclear:N \g__nicematrix_pos_of_blocks_seq
+ \seq_gclear:N \g__nicematrix_pos_of_stroken_blocks_seq
\seq_gclear:N \g__nicematrix_pos_of_xdots_seq
\tl_if_exist:cT { g__nicematrix_code_before_ \int_use:N \g__nicematrix_env_int _ tl }
{
@@ -1343,6 +1356,8 @@
\hbox_set:Nn \l_tmpa_box
{
\c_math_toggle_token
+ \tl_if_empty:NF \l__nicematrix_delimiters_color_tl
+ { \color { \l__nicematrix_delimiters_color_tl } }
\left #1
\vcenter
{
@@ -1455,6 +1470,9 @@
\__nicematrix_w: { \__nicematrix_patch_preamble_v:nnnn { } #1 }
\__nicematrix_W: { \__nicematrix_patch_preamble_v:nnnn { \cs_set_eq:NN \hss \hfil } #1 }
\__nicematrix_true_c: { \__nicematrix_patch_preamble_vi:n #1 }
+ C { \__nicematrix_error:nn { old~column~type } C }
+ L { \__nicematrix_error:nn { old~column~type } L }
+ R { \__nicematrix_error:nn { old~column~type } R }
\q_stop { }
}
{
@@ -1972,6 +1990,7 @@
{
>
{
+ \bool_gset_true:N \g__nicematrix_after_col_zero_bool
\__nicematrix_begin_of_row:
\hbox_set:Nw \l__nicematrix_cell_box
\__nicematrix_math_toggle_token:
@@ -3107,7 +3126,14 @@
\cs_new:Npn \__nicematrix_Hdotsfor:
{
\int_compare:nNnTF \c@jCol = 0
- { \__nicematrix_error:n { Hdotsfor~in~col~0 } }
+ {
+ \bool_if:NTF \g__nicematrix_after_col_zero_bool
+ {
+ \multicolumn { 1 } { c } { }
+ \__nicematrix_Hdotsfor_i
+ }
+ { \__nicematrix_fatal:n { Hdotsfor~in~col~0 } }
+ }
{
\multicolumn { 1 } { c } { }
\__nicematrix_Hdotsfor_i
@@ -3614,6 +3640,8 @@
{ \__nicematrix_test_if_vline_in_block:nnnn ##1 }
\seq_map_inline:Nn \g__nicematrix_pos_of_xdots_seq
{ \__nicematrix_test_if_vline_in_block:nnnn ##1 }
+ \seq_map_inline:Nn \g__nicematrix_pos_of_stroken_blocks_seq
+ { \__nicematrix_test_if_vline_in_stroken_block:nnnn ##1 }
\clist_if_empty:NF \l__nicematrix_except_corners_clist
\__nicematrix_test_in_corner_v:
\bool_if:NTF \g_tmpa_bool
@@ -3734,6 +3762,8 @@
{ \__nicematrix_test_if_hline_in_block:nnnn ##1 }
\seq_map_inline:Nn \g__nicematrix_pos_of_xdots_seq
{ \__nicematrix_test_if_hline_in_block:nnnn ##1 }
+ \seq_map_inline:Nn \g__nicematrix_pos_of_stroken_blocks_seq
+ { \__nicematrix_test_if_hline_in_stroken_block:nnnn ##1 }
\clist_if_empty:NF \l__nicematrix_except_corners_clist \__nicematrix_test_in_corner_h:
\bool_if:NTF \g_tmpa_bool
{
@@ -3875,6 +3905,28 @@
}
{ \bool_gset_false:N \g_tmpa_bool }
}
+\cs_new_protected:Npn \__nicematrix_test_if_hline_in_stroken_block:nnnn #1 #2 #3 #4
+ {
+ \bool_lazy_all:nT
+ {
+ { \int_compare_p:nNn \l_tmpa_tl > { #1 - 1 } }
+ { \int_compare_p:nNn \l_tmpa_tl < { #3 + 2 } }
+ { \int_compare_p:nNn \l_tmpb_tl > { #2 - 1 } }
+ { \int_compare_p:nNn \l_tmpb_tl < { #4 + 1 } }
+ }
+ { \bool_gset_false:N \g_tmpa_bool }
+ }
+\cs_new_protected:Npn \__nicematrix_test_if_vline_in_stroken_block:nnnn #1 #2 #3 #4
+ {
+ \bool_lazy_all:nT
+ {
+ { \int_compare_p:nNn \l_tmpa_tl > { #1 - 1 } }
+ { \int_compare_p:nNn \l_tmpa_tl < { #3 + 1 } }
+ { \int_compare_p:nNn \l_tmpb_tl > { #2 - 1 } }
+ { \int_compare_p:nNn \l_tmpb_tl < { #4 + 2 } }
+ }
+ { \bool_gset_false:N \g_tmpa_bool }
+ }
\cs_new_protected:Npn \__nicematrix_compute_corners:
{
\seq_clear_new:N \l__nicematrix_empty_corner_cells_seq
@@ -4299,6 +4351,8 @@
r .value_forbidden:n = true ,
c .code:n = \tl_set:Nn \l__nicematrix_pos_of_block_tl c ,
c .value_forbidden:n = true ,
+ % color .tl_set:N = \l__nicematrix_color_tl ,
+ % color .value_required:n = true ,
}
\NewExpandableDocumentCommand \__nicematrix_Block: { O { } m D < > { } m }
{
@@ -4308,9 +4362,13 @@
\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
{
- \tl_if_empty:NTF \l__nicematrix_cell_type_tl
+ \int_compare:nNnTF { #2 } = 1
+ {
+ \tl_if_empty:NTF \l__nicematrix_cell_type_tl
+ { \tl_set:Nn \l__nicematrix_pos_of_block_tl c }
+ { \tl_set_eq:NN \l__nicematrix_pos_of_block_tl \l__nicematrix_cell_type_tl }
+ }
{ \tl_set:Nn \l__nicematrix_pos_of_block_tl c }
- { \tl_set_eq:NN \l__nicematrix_pos_of_block_tl \l__nicematrix_cell_type_tl }
\keys_set_known:nn { NiceMatrix / Block / FirstPass } { #3 }
\tl_if_empty:nTF { #1 }
{ \int_set:Nn \l_tmpa_int { 100 } }
@@ -4353,36 +4411,30 @@
\hbox_gset:cn
{ g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box }
{
- \int_compare:nNnT { #2 } = 1 \set@color
+ \tl_if_empty:NTF \l__nicematrix_color_tl
+ { \int_compare:nNnT { #2 } = 1 \set@color }
+ { \color { \l__nicematrix_color_tl } }
+ \group_begin:
+ \cs_set:Npn \arraystretch { 1 }
+ \dim_set_eq:NN \extrarowheight \c_zero_dim
+ #4
+ \bool_if:NT \g__nicematrix_rotate_bool { \tl_set:Nn \l__nicematrix_pos_of_block_tl c }
\bool_if:NTF \l__nicematrix_NiceTabular_bool
{
- \group_begin:
- \cs_set:Npn \arraystretch { 1 }
- \dim_set_eq:NN \extrarowheight \c_zero_dim
- #4
- \bool_if:NT \g__nicematrix_rotate_bool
- { \tl_set:Nn \l__nicematrix_pos_of_block_tl c }
\exp_args:Nnx \begin { tabular }
{ @ { } \l__nicematrix_pos_of_block_tl @ { } }
#5
\end { tabular }
- \group_end:
}
{
- \group_begin:
- \cs_set:Npn \arraystretch { 1 }
- \dim_set_eq:NN \extrarowheight \c_zero_dim
- #4
- \bool_if:NT \g__nicematrix_rotate_bool
- { \tl_set:Nn \l__nicematrix_pos_of_block_tl c }
\c_math_toggle_token
\exp_args:Nnx \begin { array }
{ @ { } \l__nicematrix_pos_of_block_tl @ { } }
#5
\end { array }
\c_math_toggle_token
- \group_end:
}
+ \group_end:
}
\bool_if:NT \g__nicematrix_rotate_bool
{
@@ -4476,10 +4528,17 @@
}
\keys_define:nn { NiceMatrix / Block / SecondPass }
{
- tikz .tl_set:N = \l__nicematrix_tikz_tl ,
- tikz .value_required:n = true ,
- color .tl_set:N = \l__nicematrix_color_tl ,
+ fill .tl_set:N = \l__nicematrix_fill_tl ,
+ fill .value_required:n = true ,
+ draw .tl_set:N = \l__nicematrix_draw_tl ,
+ draw .default:n = default ,
+ color .code:n =
+ \__nicematrix_error:n { Key~color~for~Block }
+ \tl_set:Nn \l__nicematrix_fill_tl { #1 } ,
+ % color .code:n = \color { #1 } \tl_set:Nn \l__nicematrix_draw_tl { #1 } ,
color .value_required: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_pos_of_block_tl l ,
l .value_forbidden:n = true ,
r .code:n = \tl_set:Nn \l__nicematrix_pos_of_block_tl r ,
@@ -4496,7 +4555,7 @@
\cs_new_protected:Npn \__nicematrix_Block_iii:nnnnnn #1 #2 #3 #4 #5 #6
{
\group_begin:
- \keys_set:nn { NiceMatrix / Block / SecondPass} { #5 }
+ \keys_set:nn { NiceMatrix / Block / SecondPass } { #5 }
\int_zero_new:N \l__nicematrix_last_row_int
\int_zero_new:N \l__nicematrix_last_col_int
\int_compare:nNnTF { #3 } > { 99 }
@@ -4505,12 +4564,26 @@
\int_compare:nNnTF { #4 } > { 99 }
{ \int_set_eq:NN \l__nicematrix_last_col_int \c@jCol }
{ \int_set:Nn \l__nicematrix_last_col_int { #4 } }
- \tl_if_empty:NF \l__nicematrix_color_tl
+ \bool_lazy_or:nnT
+ { ! \tl_if_empty_p:N \l__nicematrix_draw_tl }
+ { \dim_compare_p:nNn \l__nicematrix_line_width_dim > \c_zero_dim }
+ {
+ \tl_gput_right:Nx \g_nicematrix_code_after_tl
+ {
+ \__nicematrix_stroke_block:nnn
+ { #5 }
+ { #1 - #2 }
+ { \int_use:N \l__nicematrix_last_row_int - \int_use:N \l__nicematrix_last_col_int }
+ }
+ \seq_gput_right:Nn \g__nicematrix_pos_of_stroken_blocks_seq
+ { { #1 } { #2 } { #3 } { #4 } }
+ }
+ \tl_if_empty:NF \l__nicematrix_fill_tl
{
\tl_gput_right:Nx \g_nicematrix_code_before_tl
{
\exp_not:N \rectanglecolor
- { \l__nicematrix_color_tl }
+ { \l__nicematrix_fill_tl }
{ #1 - #2 }
{ \int_use:N \l__nicematrix_last_row_int - \int_use:N \l__nicematrix_last_col_int }
}
@@ -4546,7 +4619,6 @@
\__nicematrix_qpoint:n { col - \__nicematrix_succ:n { \l__nicematrix_last_col_int } }
\dim_set_eq:NN \l_tmpd_dim \pgf@x
\begin { pgfscope }
- \exp_args:Nx \pgfset { \l__nicematrix_tikz_tl }
\__nicematrix_pgf_rect_node:nnnnn
{ \__nicematrix_env: - #1 - #2 - block }
\l_tmpb_dim \l_tmpa_dim \l_tmpd_dim \l_tmpc_dim
@@ -4640,10 +4712,13 @@
{ \box_use_drop:N \l__nicematrix_cell_box } { } { }
}
{
- \int_compare:nNnT \c@jCol = 0
+ \int_compare:nNnT { #2 } = 0
{ \tl_set:Nn \l__nicematrix_pos_of_block_tl r }
- \int_compare:nNnT \c@jCol = \l__nicematrix_last_col_int
- { \tl_set:Nn \l__nicematrix_pos_of_block_tl l }
+ \bool_if:nT \g__nicematrix_last_col_found_bool
+ {
+ \int_compare:nNnT { #2 } = \g__nicematrix_col_total_int
+ { \tl_set:Nn \l__nicematrix_pos_of_block_tl l }
+ }
\pgftransformshift
{
\pgfpointanchor
@@ -4674,6 +4749,55 @@
}
\group_end:
}
+\cs_new_protected:Npn \__nicematrix_stroke_block:nnn #1 #2 #3
+ {
+ \group_begin:
+ \tl_clear:N \l__nicematrix_draw_tl
+ \dim_set_eq:NN \l__nicematrix_line_width_dim \arrayrulewidth
+ \keys_set_known:nn { NiceMatrix / BlockStroke } { #1 }
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgf@relevantforpicturesizefalse
+ \tl_if_empty:NF \l__nicematrix_draw_tl
+ {
+ \str_if_eq:VnTF \l__nicematrix_draw_tl { default }
+ { \CT@arc@ }
+ { \pgfsetstrokecolor { \l__nicematrix_draw_tl } }
+ }
+ \__nicematrix_cut_on_hyphen:w #2 \q_stop
+ \bool_lazy_and:nnT
+ { \int_compare_p:n { \l_tmpa_tl <= \c@iRow } }
+ { \int_compare_p:n { \l_tmpb_tl <= \c@jCol } }
+ {
+ \__nicematrix_qpoint:n { row - \l_tmpa_tl }
+ \dim_set:Nn \l_tmpb_dim { \pgf@y }
+ \__nicematrix_qpoint:n { col - \l_tmpb_tl }
+ \dim_set:Nn \l_tmpc_dim { \pgf@x }
+ \__nicematrix_cut_on_hyphen:w #3 \q_stop
+ \int_compare:nNnT \l_tmpa_tl > \c@iRow
+ { \tl_set:Nx \l_tmpa_tl { \int_use:N \c@iRow } }
+ \int_compare:nNnT \l_tmpb_tl > \c@jCol
+ { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } }
+ \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l_tmpa_tl }
+ \dim_set:Nn \l_tmpa_dim { \pgf@y }
+ \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l_tmpb_tl }
+ \dim_set:Nn \l_tmpd_dim { \pgf@x }
+ \pgfpathrectanglecorners
+ { \pgfpoint \l_tmpc_dim \l_tmpb_dim }
+ { \pgfpoint \l_tmpd_dim \l_tmpa_dim }
+ \pgfsetlinewidth { 1.1 \l__nicematrix_line_width_dim }
+ \pgfusepathqstroke
+ }
+ \endpgfpicture
+ \group_end:
+ }
+\keys_define:nn { NiceMatrix / BlockStroke }
+ {
+ % color .tl_set:N = \l__nicematrix_draw_tl ,
+ draw .tl_set:N = \l__nicematrix_draw_tl ,
+ draw .default:n = default ,
+ line-width .dim_set:N = \l__nicematrix_line_width_dim ,
+ }
\cs_set_protected:Npn \__nicematrix_renew_matrix:
{
\RenewDocumentEnvironment { pmatrix } { }
@@ -5003,6 +5127,13 @@
(and~you~try~to~use~'\l_keys_key_tl').~If~you~go~on,~
this~option~will~be~ignored.
}
+\__nicematrix_msg_new:nn { Key~color~for~Block }
+ {
+ The~key~'color'~for~the~command~\token_to_str:N \Block\
+ is~deprecated:~you~should~use~'fill'~instead.\\
+ You~can~go~on~for~this~time~but~remember~that~that~key~
+ will~be~deleted~in~a~future~version.
+ }
\__nicematrix_msg_new:nn { ampersand~in~light-syntax }
{
You~can't~use~an~ampersand~(\token_to_str &)~to~separate~columns~because
@@ -5019,6 +5150,13 @@
The~key~'standard-cline'~is~available~only~in~the~preamble.\\
If~you~go~on~this~command~will~be~ignored.
}
+\__nicematrix_msg_new:nn { old~column~type }
+ {
+ The~column~type~'#1'~is~no~longer~defined~in~'nicematrix'.~
+ Since~version~5.0,~you~have~to~use~'l',~'c'~and~'r'~instead~of~'L',~
+ 'C'~and~'R'.~You~can~also~use~the~key~'define-L-C-R'.\\
+ This~error~is~fatal.
+ }
\__nicematrix_msg_new:nn { bad~value~for~baseline }
{
The~value~given~to~'baseline'~(\int_use:N \l_tmpa_int)~is~not~
@@ -5037,7 +5175,7 @@
\__nicematrix_msg_new:nn { Hdotsfor~in~col~0 }
{
You~can't~use~\token_to_str:N \Hdotsfor\ in~an~exterior~column~of~
- the~array.~If~you~go~on,~the~corresponding~dotted~line~won't~be~drawn.
+ the~array.~This~error~is~fatal.
}
\__nicematrix_msg_new:nn { bad~corner }
{
@@ -5158,6 +5296,7 @@
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
+ delimiters-color,~
end-of-row,~
first-col,~
first-row,~
@@ -5205,6 +5344,7 @@
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
+ delimiters-color,~
extra-left-margin,~
extra-right-margin,~
first-col,~
@@ -5255,6 +5395,7 @@
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
+ delimiters-color,~
extra-left-margin,~
extra-right-margin,~
first-col,~