summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/nicematrix
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-07-24 20:47:43 +0000
committerKarl Berry <karl@freefriends.org>2021-07-24 20:47:43 +0000
commitc972b4686ccff3f2f39b4ca033b74f6b3168106c (patch)
tree0d5e1b4c7b11955dcba45665611428c73fc6bae8 /Master/texmf-dist/tex/latex/nicematrix
parent5fb448a59007c3ae2a8d6b1746951c62ed808df1 (diff)
nicematrix (24jul21)
git-svn-id: svn://tug.org/texlive/trunk@60042 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/nicematrix')
-rw-r--r--Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty169
1 files changed, 139 insertions, 30 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
index bbd810f13e4..c9122db838d 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.18}
-\def\myfiledate{2021/07/15}
+\def\myfileversion{5.19}
+\def\myfiledate{2021/07/23}
\RequirePackage{pgfcore}
\usepgfmodule{shapes}
\RequirePackage{l3keys2e}
@@ -152,7 +152,6 @@
}
}
}
-\cs_set_protected:Npn \CT@drsc@ { }
\cs_set:Npn \__nicematrix_standard_cline #1 { \__nicematrix_standard_cline:w #1 \q_stop }
\cs_set:Npn \__nicematrix_standard_cline:w #1-#2 \q_stop
{
@@ -326,6 +325,9 @@
\int_new:N \l__nicematrix_old_iRow_int
\int_new:N \l__nicematrix_old_jCol_int
\tl_new:N \l__nicematrix_rules_color_tl
+\int_new:N \g__nicematrix_nb_of_X_int
+\bool_new:N \l__nicematrix_X_columns_aux_bool
+\dim_new:N \l__nicematrix_X_columns_dim
\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
@@ -357,6 +359,7 @@
\int_new:N \g__nicematrix_static_num_of_col_int
\tl_new:N \l__nicematrix_fill_tl
\tl_new:N \l__nicematrix_draw_tl
+\seq_new:N \l__nicematrix_tikz_seq
\clist_new:N \l__nicematrix_borders_clist
\dim_new:N \l__nicematrix_rounded_corners_dim
\tl_new:N \l__nicematrix_color_tl
@@ -900,7 +903,7 @@
}
\cs_new_protected:Npn \__nicematrix_Cell:
{
- \tl_gclear:N \g__nicematrix_exit_cell_tl
+ \tl_gclear:N \g__nicematrix_post_treatment_cell_tl
\cs_set_eq:NN \CodeAfter \__nicematrix_CodeAfter_i:n
\int_gincr:N \c@jCol
\int_compare:nNnT \c@jCol = 1
@@ -1004,7 +1007,7 @@
{
\__nicematrix_math_toggle_token:
\hbox_set_end:
- \g__nicematrix_exit_cell_tl
+ \g__nicematrix_post_treatment_cell_tl
\bool_if:NT \g__nicematrix_rotate_bool \__nicematrix_rotate_cell_box:
\__nicematrix_adjust_size_box:
\box_set_ht:Nn \l__nicematrix_cell_box
@@ -1351,7 +1354,7 @@
{
\tl_gput_right:Nn \g__nicematrix_row_style_tl
{
- \tl_gput_right:Nn \g__nicematrix_exit_cell_tl
+ \tl_gput_right:Nn \g__nicematrix_post_treatment_cell_tl
{ \dim_set:Nn \l__nicematrix_cell_space_top_limit_dim { #1 } }
}
} ,
@@ -1360,7 +1363,7 @@
{
\tl_gput_right:Nn \g__nicematrix_row_style_tl
{
- \tl_gput_right:Nn \g__nicematrix_exit_cell_tl
+ \tl_gput_right:Nn \g__nicematrix_post_treatment_cell_tl
{ \dim_set:Nn \l__nicematrix_cell_space_bottom_limit_dim { #1 } }
}
} ,
@@ -1550,6 +1553,23 @@
\skip_horizontal:N \l__nicematrix_right_margin_dim
\skip_horizontal:N \l__nicematrix_extra_right_margin_dim
\hbox_set_end:
+ \int_compare:nNnT \g__nicematrix_nb_of_X_int > 0
+ {
+ \bool_if:NTF \l__nicematrix_X_columns_aux_bool
+ { \dim_set_eq:NN \l_tmpa_dim \l__nicematrix_X_columns_dim }
+ {
+ \dim_set:Nn \l_tmpa_dim
+ {
+ ( \textwidth - \box_wd:N \l__nicematrix_the_array_box )
+ / \int_use:N \g__nicematrix_nb_of_X_int
+ }
+ }
+ \tl_gput_right:Nx \g__nicematrix_aux_tl
+ {
+ \bool_set_true:N \l__nicematrix_X_columns_aux_bool
+ \dim_set:Nn \l__nicematrix_X_columns_dim { \dim_use:N \l_tmpa_dim }
+ }
+ }
\int_compare:nNnT \l__nicematrix_last_row_int > { -2 }
{
\bool_if:NF \l__nicematrix_last_row_without_value_bool
@@ -1647,10 +1667,11 @@
\__nicematrix_after_array:
\egroup
\iow_now:Nn \@mainaux { \ExplSyntaxOn }
+ \iow_now:Nn \@mainaux { \char_set_catcode_space:n { 32 } }
\iow_now:Nx \@mainaux
{
\tl_gset:cn { c__nicematrix_ \int_use:N \g__nicematrix_env_int _ tl }
- \iow_newline: { \iow_newline: \exp_not:V \g__nicematrix_aux_tl }
+ { \exp_not:V \g__nicematrix_aux_tl }
}
\iow_now:Nn \@mainaux { \ExplSyntaxOff }
\bool_if:NT \c__nicematrix_footnote_bool \endsavenotes
@@ -1680,6 +1701,7 @@
{ ! { \skip_horizontal:N \arrayrulewidth } }
}
}
+ \int_gzero:N \g__nicematrix_nb_of_X_int
\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
@@ -1740,8 +1762,8 @@
@ { \__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 }
+ m { \__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 }
@@ -1751,6 +1773,7 @@
) { \__nicematrix_patch_preamble_viii:nn #1 }
] { \__nicematrix_patch_preamble_viii:nn #1 }
\} { \__nicematrix_patch_preamble_viii:nn #1 }
+ X { \__nicematrix_patch_preamble_xii: }
C { \__nicematrix_error:nn { old~column~type } #1 }
L { \__nicematrix_error:nn { old~column~type } #1 }
R { \__nicematrix_error:nn { old~column~type } #1 }
@@ -1837,20 +1860,46 @@
> {
\__nicematrix_Cell:
\begin { minipage } [ #1 ] { \dim_eval:n { #3 } }
- \mode_leave_vertical:
+ \everypar
+ {
+ \vrule height \box_ht:N \@arstrutbox width \c_zero_dim
+ \everypar { }
+ }
+ \g__nicematrix_row_style_tl % added the 2021-07-17
\arraybackslash
- \vrule height \box_ht:N \@arstrutbox depth 0 pt width 0 pt
}
c
< {
- \vrule height 0 pt depth \box_dp:N \@arstrutbox width 0 pt
+ \@finalstrut \@arstrutbox
\end { minipage }
+ \str_if_eq:nnT { #2 } m \__nicematrix_center_cell_box:
\__nicematrix_end_Cell:
}
}
\int_gincr:N \c@jCol
\__nicematrix_patch_preamble_x:n
}
+\cs_new_protected:Npn \__nicematrix_center_cell_box:
+ {
+ \tl_gput_right:Nn \g__nicematrix_post_treatment_cell_tl
+ {
+ \int_compare:nNnT
+ { \box_ht:N \l__nicematrix_cell_box }
+ >
+ { \box_ht:N \@arstrutbox }
+ {
+ \hbox_set:Nn \l__nicematrix_cell_box
+ {
+ \box_move_down:nn
+ {
+ ( \box_ht:N \l__nicematrix_cell_box - \box_ht:N \@arstrutbox
+ + \baselineskip ) / 2
+ }
+ { \box_use:N \l__nicematrix_cell_box }
+ }
+ }
+ }
+ }
\cs_new_protected:Npn \__nicematrix_patch_preamble_v:nnnn #1 #2 #3 #4
{
\tl_gput_right:Nn \g__nicematrix_preamble_tl
@@ -1993,6 +2042,27 @@
\tl_gput_right:Nn \g__nicematrix_preamble_tl { < { #1 } }
\__nicematrix_patch_preamble_x:n
}
+\cs_new_protected:Npn \__nicematrix_patch_preamble_xii:
+ {
+ \int_gincr:N \g__nicematrix_nb_of_X_int
+ \bool_if:NTF \l__nicematrix_X_columns_aux_bool
+ { \exp_args:NNNV \__nicematrix_patch_preamble_iv:nnn t p \l__nicematrix_X_columns_dim }
+ {
+ \tl_gput_right:Nn \g__nicematrix_preamble_tl
+ {
+ > {
+ \__nicematrix_Cell:
+ \tl_set:Nn \l__nicematrix_cell_type_tl { c }
+ \tl_gput_right:Nn \g__nicematrix_post_treatment_cell_tl
+ { \hbox_set:Nn \l__nicematrix_cell_box { } }
+ }
+ c
+ < { \__nicematrix_end_Cell: }
+ }
+ \int_gincr:N \c@jCol
+ \__nicematrix_patch_preamble_x:n
+ }
+ }
\cs_new:Npn \__nicematrix_multicolumn:nnn #1 #2 #3
{
\multispan { #1 }
@@ -2201,9 +2271,12 @@
{ \box_wd:N \l__nicematrix_the_array_box - \arraycolsep }
}
\begin { minipage } [ t ] { \box_wd:N \l__nicematrix_the_array_box }
- \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: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:
+ }
\bool_lazy_or:nnT
{ \int_compare_p:nNn \c@tabularnote > 0 }
{ ! \tl_if_empty_p:V \l__nicematrix_tabularnote_tl }
@@ -2484,8 +2557,8 @@
}
\int_gset:Nn \g_tmpa_int 1
\bool_if:NTF \g__nicematrix_last_col_found_bool
- { \prg_replicate:nn { \g__nicematrix_col_total_int - 3 } }
- { \prg_replicate:nn { \g__nicematrix_col_total_int - 2 } }
+ { \prg_replicate:nn { \int_max:nn { \g__nicematrix_col_total_int - 3 } 0 } }
+ { \prg_replicate:nn { \int_max:nn { \g__nicematrix_col_total_int - 2 } 0 } }
{
&
\omit
@@ -2761,7 +2834,6 @@
\int_use:N \c@jCol ,
\int_use:N \g__nicematrix_col_total_int
}
- \iow_newline:
}
\seq_if_empty:NF \g__nicematrix_pos_of_blocks_seq
{
@@ -2769,7 +2841,6 @@
{
\seq_gset_from_clist:Nn \exp_not:N \g__nicematrix_pos_of_blocks_seq
{ \seq_use:Nnnn \g__nicematrix_pos_of_blocks_seq , , , }
- \iow_newline:
}
}
\seq_if_empty:NF \g__nicematrix_multicolumn_cells_seq
@@ -2778,10 +2849,8 @@
{
\seq_gset_from_clist:Nn \exp_not:N \g__nicematrix_multicolumn_cells_seq
{ \seq_use:Nnnn \g__nicematrix_multicolumn_cells_seq , , , }
- \iow_newline:
\seq_gset_from_clist:Nn \exp_not:N \g__nicematrix_multicolumn_sizes_seq
{ \seq_use:Nnnn \g__nicematrix_multicolumn_sizes_seq , , , }
- \iow_newline:
}
}
\__nicematrix_create_diag_nodes:
@@ -2853,7 +2922,6 @@
{
\tl_gset:Nn \exp_not:N \g__nicematrix_code_before_tl
{ \exp_not:V \g_nicematrix_code_before_tl }
- \iow_newline:
}
\bool_set_true:N \l__nicematrix_code_before_bool
}
@@ -4513,9 +4581,12 @@
\dim_set_eq:NN \l_tmpb_dim \pgf@x
\__nicematrix_qpoint:n { row - \__nicematrix_succ:n { #4 } }
\dim_set_eq:NN \l_tmpc_dim \pgf@y
- \bool_lazy_and:nnT
- { \int_compare_p:nNn { #2 } > 1 }
- { ! \tl_if_blank_p:V \CT@drsc@ }
+ \bool_lazy_all:nT
+ {
+ { \int_compare_p:nNn { #2 } > 1 }
+ { \cs_if_exist_p:N \CT@drsc@ } % condition added in version 5.18a
+ { ! \tl_if_blank_p:V \CT@drsc@ }
+ }
{
\group_begin:
\CT@drsc@
@@ -4780,7 +4851,6 @@
{
\seq_set_from_clist:Nn \exp_not:N \l__nicematrix_corners_cells_seq
{ \seq_use:Nnnn \l__nicematrix_corners_cells_seq , , , }
- \iow_newline:
}
}
}
@@ -5238,9 +5308,15 @@
{ \int_eval:n { \c@iRow + \l_tmpa_int - 1 } }
{ \int_eval:n { \c@jCol + \l_tmpb_int - 1 } }
}
- \bool_lazy_or:nnTF
- { \int_compare_p:nNn { \l_tmpa_int } = 1 }
- { \int_compare_p:nNn { \l_tmpb_int } = 1 }
+ \bool_if:nTF
+ {
+ (
+ \int_compare_p:nNn { \l_tmpa_int } = 1
+ ||
+ \int_compare_p:nNn { \l_tmpb_int } = 1
+ )
+ && ! \tl_if_empty_p:n { #5 }
+ }
{ \exp_args:Nxx \__nicematrix_Block_iv:nnnnn }
{ \exp_args:Nxx \__nicematrix_Block_v:nnnnn }
{ \l_tmpa_int } { \l_tmpb_int } { #3 } { #4 } { #5 }
@@ -5397,6 +5473,11 @@
}
\keys_define:nn { NiceMatrix / Block / SecondPass }
{
+ tikz .code:n =
+ \bool_if:NTF \c__nicematrix_tikz_loaded_bool
+ { \seq_put_right:Nn \l__nicematrix_tikz_seq { { #1 } } }
+ { \__nicematrix_error:n { tikz~key~without~tikz } } ,
+ tikz .value_required:n = true ,
fill .tl_set:N = \l__nicematrix_fill_tl ,
fill .value_required:n = true ,
draw .tl_set:N = \l__nicematrix_draw_tl ,
@@ -5517,6 +5598,18 @@
{ \dim_use:N \l__nicematrix_rounded_corners_dim }
}
}
+ \seq_if_empty:NF \l__nicematrix_tikz_seq
+ {
+ \tl_gput_right:Nx \g_nicematrix_code_before_tl
+ {
+ \__nicematrix_block_tikz:nnnnn
+ { #1 }
+ { #2 }
+ { \int_use:N \l__nicematrix_last_row_int }
+ { \int_use:N \l__nicematrix_last_col_int }
+ { \seq_use:Nn \l__nicematrix_tikz_seq { , } }
+ }
+ }
\cs_set_protected_nopar:Npn \diagbox ##1 ##2
{
\tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
@@ -5850,6 +5943,16 @@
rounded-corners .default:n = 4 pt ,
line-width .dim_set:N = \l__nicematrix_line_width_dim
}
+\cs_new_protected:Npn \__nicematrix_block_tikz:nnnnn #1 #2 #3 #4 #5
+ {
+ \begin { tikzpicture }
+ \clist_map_inline:nn { #5 }
+ {
+ \path [ ##1 ]
+ ( #1 -| #2 ) rectangle ( \__nicematrix_succ:n { #3 } -| \__nicematrix_succ:n { #4 } ) ;
+ }
+ \end { tikzpicture }
+ }
\cs_set_protected:Npn \__nicematrix_renew_matrix:
{
\RenewDocumentEnvironment { pmatrix } { }
@@ -6770,6 +6873,12 @@
values~are:~left,~right,~top~and~bottom.\\
If~you~go~on,~this~specification~of~border~will~be~ignored.
}
+\__nicematrix_msg_new:nn { tikz~key~without~tikz }
+ {
+ You~can't~use~the~key~'tikz'~for~the~command~'\token_to_str:N
+ \Block'~because~you~have~not~loaded~Tikz.~
+ If~you~go~on,~this~key~will~be~ignored.
+ }
\__nicematrix_msg_new:nn { last-col~non~empty~for~NiceArray }
{
In~the~\__nicematrix_full_name_env:,~you~must~use~the~key~
@@ -6860,7 +6969,7 @@
}
{
The~available~keys~are~(in~alphabetic~order):~b,~borders,~c,~draw,~fill,~
- hvlines,~l,~line-width,~rounded-corners,~r~and~t.
+ hvlines,~l,~line-width,~rounded-corners,~r,~t~and~tikz.
}
\__nicematrix_msg_new:nnn { Unknown~key~for~CodeAfter }
{