summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/nicematrix
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-09-03 21:11:59 +0000
committerKarl Berry <karl@freefriends.org>2020-09-03 21:11:59 +0000
commit253ee34e8aebfb8731d657b1fa4ef2c22f9e7f52 (patch)
tree9cf89df92efa7cf9f4ec184bbe44c120d65a2b9c /Master/texmf-dist/tex/latex/nicematrix
parent1ebdcbffb0e852f50e0dc8f4dfcadee48c11e105 (diff)
nicematrix (3sep20)
git-svn-id: svn://tug.org/texlive/trunk@56256 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/nicematrix')
-rw-r--r--Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty248
1 files changed, 194 insertions, 54 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
index c4ffc2e87fa..ca4ab2c60d7 100644
--- a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
+++ b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
@@ -18,8 +18,8 @@
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%%
-\def\myfileversion{5.2}
-\def\myfiledate{2020/08/19}
+\def\myfileversion{5.3}
+\def\myfiledate{2020/09/03}
\RequirePackage{pgfcore}
\usepgfmodule{shapes}
@@ -297,6 +297,9 @@
\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
+\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
\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
@@ -474,6 +477,7 @@
shorten .value_required:n = true ,
down .tl_set:N = \l__nicematrix_xdots_down_tl ,
up .tl_set:N = \l__nicematrix_xdots_up_tl ,
+ draw-first .code:n = \prg_do_nothing: ,
unknown .code:n = \__nicematrix_error:n { Unknown~option~for~xdots }
}
\keys_define:nn { NiceMatrix / rules }
@@ -861,15 +865,15 @@
}
\endpgfpicture
}
-\cs_new_protected:Npn \__nicematrix_instruction_of_type:nn #1 #2
+\cs_new_protected:Npn \__nicematrix_instruction_of_type:nnn #1 #2 #3
{
- \tl_gput_right:cx
- { g__nicematrix_ #1 _ lines _ tl }
+ \bool_if:nTF { #1 } \tl_gput_left:cx \tl_gput_right:cx
+ { g__nicematrix_ #2 _ lines _ tl }
{
- \use:c { __nicematrix _ draw _ #1 : nnn }
+ \use:c { __nicematrix _ draw _ #2 : nnn }
{ \int_use:N \c@iRow }
{ \int_use:N \c@jCol }
- { \exp_not:n { #2 } }
+ { \exp_not:n { #3 } }
}
}
\cs_new_protected:Npn \__nicematrix_revtex_array:
@@ -877,7 +881,7 @@
\cs_set_eq:NN \@acoll \@arrayacol
\cs_set_eq:NN \@acolr \@arrayacol
\cs_set_eq:NN \@acol \@arrayacol
- \cs_set:Npn \@halignto { }
+ \cs_set_nopar:Npn \@halignto { }
\@array@array
}
\cs_new_protected:Npn \__nicematrix_array:
@@ -889,8 +893,8 @@
{ \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 } }
+ { \cs_set_nopar:Npn \@halignto { } }
+ { \cs_set_nopar:Npx \@halignto { to \dim_use:N \l__nicematrix_tabular_width_dim } }
\@tabarray
}
[ \str_if_eq:VnTF \l__nicematrix_baseline_str c c t ]
@@ -976,10 +980,10 @@
\normalbaselines
\bool_if:NT \l__nicematrix_small_bool
{
- \cs_set:Npn \arraystretch { 0.47 }
+ \cs_set_nopar:Npn \arraystretch { 0.47 }
\dim_set:Nn \arraycolsep { 1.45 pt }
}
- \cs_set:Npn \ialign
+ \cs_set_nopar:Npn \ialign
{
\bool_if:NTF \c__nicematrix_colortbl_loaded_bool
{
@@ -1055,6 +1059,8 @@
\bgroup
\tl_set:Nn \l__nicematrix_left_delim_tl { #1 }
\tl_set:Nn \l__nicematrix_right_delim_tl { #2 }
+ \dim_zero:N \g__nicematrix_width_last_col_dim
+ \dim_zero:N \g__nicematrix_width_first_col_dim
\bool_gset_false:N \g__nicematrix_row_of_col_done_bool
\str_if_empty:NT \g__nicematrix_name_env_str
{ \str_gset:Nn \g__nicematrix_name_env_str { NiceArrayWithDelims } }
@@ -1903,6 +1909,7 @@
\skip_horizontal:N \l__nicematrix_left_margin_dim
\skip_horizontal:N \l__nicematrix_extra_left_margin_dim
}
+ \bool_gset_false:N \g__nicematrix_empty_cell_bool
\skip_horizontal:N -2\col@sep
}
}
@@ -1946,6 +1953,7 @@
\__nicematrix_node_for_the_cell:
}
}
+ \bool_gset_false:N \g__nicematrix_empty_cell_bool
}
}
\NewDocumentEnvironment { NiceArray } { }
@@ -2115,16 +2123,16 @@
}
\__nicematrix_draw_dotted_lines:
\__nicematrix_compute_corners:
- % \bool_lazy_all:nT
- % {
- % { \seq_if_empty_p:N \g__nicematrix_pos_of_blocks_seq }
- % { \seq_if_empty_p:N \g__nicematrix_pos_of_xdots_seq }
- % { \seq_if_empty_p:N \l__nicematrix_empty_corner_cells_seq }
- % }
- % {
- % \cs_set_eq:NN \__nicematrix_vline_i:nn \__nicematrix_vline_i_complete:nn
- % \cs_set_eq:NN \__nicematrix_hline_i:nn \__nicematrix_hline_i_complete:nn
- % }
+ \bool_lazy_all:nT
+ {
+ { \seq_if_empty_p:N \g__nicematrix_pos_of_blocks_seq }
+ { \seq_if_empty_p:N \g__nicematrix_pos_of_xdots_seq }
+ { \seq_if_empty_p:N \l__nicematrix_empty_corner_cells_seq }
+ }
+ {
+ \cs_set_eq:NN \__nicematrix_vline_i:nn \__nicematrix_vline_i_complete:nn
+ \cs_set_eq:NN \__nicematrix_hline_i:nn \__nicematrix_hline_i_complete:nn
+ }
\bool_if:NT \l__nicematrix_hlines_bool \__nicematrix_draw_hlines:
\bool_if:NT \l__nicematrix_vlines_bool \__nicematrix_draw_vlines:
\g__nicematrix_internal_code_after_tl
@@ -2472,7 +2480,6 @@
}
\cs_new_protected:Npn \__nicematrix_draw_Vdots:nnn #1 #2 #3
{
- \tl_if_empty:VF \l__nicematrix_xdots_color_tl { \color { \l__nicematrix_xdots_color_tl } }
\cs_if_free:cT { __nicematrix _ dotted _ #1 - #2 }
{
\__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } 1 0
@@ -2484,6 +2491,8 @@
{ \color { nicematrix-last-col } }
}
\keys_set:nn { NiceMatrix / xdots } { #3 }
+ \tl_if_empty:VF \l__nicematrix_xdots_color_tl
+ { \color { \l__nicematrix_xdots_color_tl } }
\__nicematrix_actually_draw_Vdots:
\group_end:
}
@@ -2846,7 +2855,7 @@
\int_compare:nNnTF \c@jCol = \l__nicematrix_last_col_int
{ \__nicematrix_error:nn { in~last~col } \Ldots }
{
- \__nicematrix_instruction_of_type:nn { Ldots }
+ \__nicematrix_instruction_of_type:nnn \c_false_bool { Ldots }
{ #1 , down = #2 , up = #3 }
}
}
@@ -2861,7 +2870,7 @@
\int_compare:nNnTF \c@jCol = \l__nicematrix_last_col_int
{ \__nicematrix_error:nn { in~last~col } \Cdots }
{
- \__nicematrix_instruction_of_type:nn { Cdots }
+ \__nicematrix_instruction_of_type:nnn \c_false_bool { Cdots }
{ #1 , down = #2 , up = #3 }
}
}
@@ -2876,7 +2885,7 @@
\int_compare:nNnTF \c@iRow = \l__nicematrix_last_row_int
{ \__nicematrix_error:nn { in~last~row } \Vdots }
{
- \__nicematrix_instruction_of_type:nn { Vdots }
+ \__nicematrix_instruction_of_type:nnn \c_false_bool { Vdots }
{ #1 , down = #2 , up = #3 }
}
}
@@ -2897,7 +2906,8 @@
\l__nicematrix_last_col_int { \__nicematrix_error:nn { in~last~col } \Ddots }
}
{
- \__nicematrix_instruction_of_type:nn { Ddots }
+ \keys_set_known:nn { NiceMatrix / Ddots } { #1 }
+ \__nicematrix_instruction_of_type:nnn \l__nicematrix_draw_first_bool { Ddots }
{ #1 , down = #2 , up = #3 }
}
@@ -2919,7 +2929,8 @@
\l__nicematrix_last_col_int { \__nicematrix_error:nn { in~last~col } \Iddots }
}
{
- \__nicematrix_instruction_of_type:nn { Iddots }
+ \keys_set_known:nn { NiceMatrix / Ddots } { #1 }
+ \__nicematrix_instruction_of_type:nnn \l__nicematrix_draw_first_bool { Iddots }
{ #1 , down = #2 , up = #3 }
}
@@ -2928,6 +2939,12 @@
\bool_gset_true:N \g__nicematrix_empty_cell_bool
}
}
+\keys_define:nn { NiceMatrix / Ddots }
+ {
+ draw-first .bool_set:N = \l__nicematrix_draw_first_bool ,
+ draw-first .default:n = true ,
+ draw-first .value_forbidden:n = true
+ }
\cs_new_protected:Npn \__nicematrix_Hspace:
{
\bool_gset_true:N \g__nicematrix_empty_cell_bool
@@ -2973,12 +2990,18 @@
}
}
\int_gadd:Nn \c@jCol { #1 - 1 }
+ \int_compare:nNnT \c@jCol > \g__nicematrix_col_total_int
+ { \int_gset_eq:NN \g__nicematrix_col_total_int \c@jCol }
}
}
\cs_new:Npn \__nicematrix_Hdotsfor:
{
- \multicolumn { 1 } { c } { }
- \__nicematrix_Hdotsfor_i
+ \int_compare:nNnTF \c@jCol = 0
+ { \__nicematrix_error:n { Hdotsfor~in~col~0 } }
+ {
+ \multicolumn { 1 } { c } { }
+ \__nicematrix_Hdotsfor_i
+ }
}
\AtBeginDocument
{
@@ -3493,6 +3516,7 @@
\cs_new_protected:Npn \__nicematrix_vline_i:nn #1 #2
{
\tl_set:Nx \l_tmpb_tl { #1 }
+ \tl_clear_new:N \l_tmpc_tl
\int_step_variable:nNn \c@iRow \l_tmpa_tl
{
\bool_gset_true:N \g_tmpa_bool
@@ -3502,8 +3526,31 @@
{ \__nicematrix_test_if_vline_in_block:nnnn ##1 }
\clist_if_empty:NF \l__nicematrix_except_corners_clist
\__nicematrix_test_in_corner_v:
- \bool_if:NT \g_tmpa_bool
- { \__nicematrix_vline_ii:nnnn { #1 } { #2 } \l_tmpa_tl \l_tmpa_tl }
+ \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
+ {
+ \__nicematrix_vline_ii:nnnn
+ { #1 }
+ { #2 }
+ \l_tmpc_tl
+ { \int_use:N \c@iRow }
+ \tl_clear:N \l_tmpc_tl
}
}
\cs_new_protected:Npn \__nicematrix_test_in_corner_v:
@@ -3589,6 +3636,7 @@
\cs_new_protected:Npn \__nicematrix_hline_i:nn #1 #2
{
\tl_set:Nn \l_tmpa_tl { #1 }
+ \tl_clear_new:N \l_tmpc_tl
\int_step_variable:nNn \c@jCol \l_tmpb_tl
{
\bool_gset_true:N \g_tmpa_bool
@@ -3597,8 +3645,31 @@
\seq_map_inline:Nn \g__nicematrix_pos_of_xdots_seq
{ \__nicematrix_test_if_hline_in_block:nnnn ##1 }
\clist_if_empty:NF \l__nicematrix_except_corners_clist \__nicematrix_test_in_corner_h:
- \bool_if:NT \g_tmpa_bool
- { \__nicematrix_hline_ii:nnnn { #1 } { #2 } \l_tmpb_tl \l_tmpb_tl }
+ \bool_if:NTF \g_tmpa_bool
+ {
+ \tl_if_empty:NT \l_tmpc_tl
+ { \tl_set_eq:NN \l_tmpc_tl \l_tmpb_tl }
+ }
+ {
+ \tl_if_empty:NF \l_tmpc_tl
+ {
+ \__nicematrix_hline_ii:nnnn
+ { #1 }
+ { #2 }
+ \l_tmpc_tl
+ { \int_eval:n { \l_tmpb_tl - 1 } }
+ \tl_clear:N \l_tmpc_tl
+ }
+ }
+ }
+ \tl_if_empty:NF \l_tmpc_tl
+ {
+ \__nicematrix_hline_ii:nnnn
+ { #1 }
+ { #2 }
+ \l_tmpc_tl
+ { \int_use:N \c@jCol }
+ \tl_clear:N \l_tmpc_tl
}
}
\cs_new_protected:Npn \__nicematrix_test_in_corner_h:
@@ -3665,7 +3736,7 @@
\pgfusepathqstroke
}
\cs_new_protected:Npn \__nicematrix_hline_i_complete:nn #1 #2
- { \__nicematrix_hline_ii:nnnn #1 #2 1 { \int_use:N \c@jCol } }
+ { \__nicematrix_hline_ii:nnnn { #1 } { #2 } 1 { \int_use:N \c@jCol } }
\cs_new_protected:Npn \__nicematrix_draw_hlines:
{
\int_step_inline:nnn
@@ -4101,8 +4172,8 @@
}
\cs_new_protected:Npn \__nicematrix_extract_coords_values: #1 - #2 \q_stop
{
- \cs_set:Npn \__nicematrix_i: { #1 }
- \cs_set:Npn \__nicematrix_j: { #2 }
+ \cs_set_nopar:Npn \__nicematrix_i: { #1 }
+ \cs_set_nopar:Npn \__nicematrix_j: { #2 }
}
\cs_new_protected:Npn \__nicematrix_node_for_multicolumn:nn #1 #2
{
@@ -4148,6 +4219,13 @@
tikz .value_required:n = true ,
color .tl_set:N = \l__nicematrix_color_tl ,
color .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 ,
+ r .value_forbidden:n = true ,
+ c .code:n = \tl_set:Nn \l__nicematrix_pos_of_block_tl c ,
+ c .value_forbidden:n = true ,
+ unknown .code:n = \__nicematrix_error:n { Unknown~key~for~Block }
}
\cs_new_protected:Npn \__nicematrix_draw_blocks:
{ \seq_map_inline:Nn \g__nicematrix_blocks_seq { \__nicematrix_Block_iii:nnnnnn ##1 } }
@@ -4165,15 +4243,15 @@
{ #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 }
- { \exp_not:n { ##1 } } { \exp_not:n { ##2 } }
- }
- }
+ \cs_set_protected_nopar:Npn \diagbox ##1 ##2
+ {
+ \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
+ {
+ \__nicematrix_actually_diagbox:nnnnnn
+ { #1 } { #2 } { #3 } { #4 }
+ { \exp_not:n { ##1 } } { \exp_not:n { ##2 } }
+ }
+ }
\bool_lazy_or:nnTF
{ \int_compare_p:nNn { #3 } > \g__nicematrix_row_total_int }
{ \int_compare_p:nNn { #4 } > \g__nicematrix_col_total_int }
@@ -4203,8 +4281,11 @@
\cs_if_exist:cT
{ pgf @ sh @ ns @ \__nicematrix_env: - ##1 - #2 }
{
- \pgfpointanchor { \__nicematrix_env: - ##1 - #2 } { west }
- \dim_set:Nn \l_tmpb_dim { \dim_min:nn \l_tmpb_dim \pgf@x }
+ \seq_if_in:NnF \g__nicematrix_multicolumn_cells_seq { ##1 - #2 }
+ {
+ \pgfpointanchor { \__nicematrix_env: - ##1 - #2 } { west }
+ \dim_set:Nn \l_tmpb_dim { \dim_min:nn \l_tmpb_dim \pgf@x }
+ }
}
}
\dim_compare:nNnT \l_tmpb_dim = \c_max_dim
@@ -4218,8 +4299,11 @@
\cs_if_exist:cT
{ pgf @ sh @ ns @ \__nicematrix_env: - ##1 - #4 }
{
- \pgfpointanchor { \__nicematrix_env: - ##1 - #4 } { east }
- \dim_set:Nn \l_tmpd_dim { \dim_max:nn \l_tmpd_dim \pgf@x }
+ \seq_if_in:NnF \g__nicematrix_multicolumn_cells_seq { ##1 - #2 }
+ {
+ \pgfpointanchor { \__nicematrix_env: - ##1 - #4 } { east }
+ \dim_set:Nn \l_tmpd_dim { \dim_max:nn \l_tmpd_dim \pgf@x }
+ }
}
}
\dim_compare:nNnT \l_tmpd_dim = { - \c_max_dim }
@@ -4246,14 +4330,55 @@
\l__nicematrix_code_for_last_row_tl
}
\pgfextracty \l_tmpa_dim { \__nicematrix_qpoint:n { row - #1 - base } }
- \__nicematrix_qpoint:n { #1 - #2 - block - short }
+ \pgfpointanchor
+ { \__nicematrix_env: - #1 - #2 - block - short }
+ {
+ \str_case:Vn \l__nicematrix_pos_of_block_tl
+ {
+ c { center }
+ l { west }
+ r { east }
+ }
+ }
\pgftransformshift { \pgfpoint \pgf@x \l_tmpa_dim }
- \pgfnode { rectangle } { base }
+ \pgfset { inner~sep = \c_zero_dim }
+ \pgfnode
+ { rectangle }
+ {
+ \str_case:Vn \l__nicematrix_pos_of_block_tl
+ {
+ c { base }
+ l { base~west }
+ r { base~east }
+ }
+ }
{ \box_use_drop:N \l__nicematrix_cell_box } { } { }
}
{
- \pgftransformshift { \__nicematrix_qpoint:n { #1 - #2 - block - short } }
- \pgfnode { rectangle } { center }
+ \pgftransformshift
+ {
+ \pgfpointanchor
+ { \__nicematrix_env: - #1 - #2 - block - short }
+ {
+ \str_case:Vn \l__nicematrix_pos_of_block_tl
+ {
+ c { center }
+ l { west }
+ r { east }
+ }
+ }
+ }
+ \pgfset { inner~sep = \c_zero_dim }
+ \pgfnode
+ { rectangle }
+ {
+ \str_case:Vn \l__nicematrix_pos_of_block_tl
+ {
+ c { center }
+ l { west }
+ r { east }
+ }
+ }
{ \box_use_drop:N \l__nicematrix_cell_box } { } { }
}
\endpgfpicture
@@ -4619,6 +4744,11 @@
can't~be~executed~because~a~cell~doesn't~exist.\\
If~you~go~on~this~command~will~be~ignored.
}
+\__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.
+ }
\__nicematrix_msg_new:nn { bad~corner }
{
#1~is~an~incorrect~specification~for~a~corner~(in~the~keys~
@@ -4696,6 +4826,16 @@
The~value~of~key~'\l_keys_key_tl'~must~be~of~length~1.\\
If~you~go~on,~it~will~be~ignored.
}
+\__nicematrix_msg_new:nnn { Unknown~key~for~Block }
+ {
+ The~key~'\l_keys_key_tl'~is~unknown~for~the~command~\token_to_str:N
+ \Block.\\ If~you~go~on,~it~will~be~ignored. \\
+ For~a~list~of~the~available~keys,~type~H~<return>.
+ }
+ {
+ The~available~options~are~(in~alphabetic~order):~c,~
+ color,~l,~and~r.
+ }
\__nicematrix_msg_new:nnn { Unknown~key~for~notes }
{
The~key~'\l_keys_key_tl'~is~unknown.\\