summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/nicematrix
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-11-24 21:29:45 +0000
committerKarl Berry <karl@freefriends.org>2021-11-24 21:29:45 +0000
commit97463c3d441d47bb67305116787a8dd100a38cfe (patch)
tree12c6bbe68889dcfa8feef86e0c9a867c5fc9c29a /Master/texmf-dist/tex/latex/nicematrix
parent8832179161b2bf27735f1276934f097904ffc1ce (diff)
nicematrix (24nov21)
git-svn-id: svn://tug.org/texlive/trunk@61142 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/nicematrix')
-rw-r--r--Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty303
1 files changed, 228 insertions, 75 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
index 3434c440780..6f86a4640a4 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.3}
-\def\myfiledate{2021/10/18}
+\def\myfileversion{6.4}
+\def\myfiledate{2021/11/23}
\RequirePackage{pgfcore}
\usepgfmodule{shapes}
\RequirePackage{l3keys2e}
@@ -158,7 +158,6 @@
}
}
}
-\cs_if_exist:NF \AtBeginEnvironment { \RequirePackage { etoolbox } }
\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
{
@@ -234,30 +233,6 @@
}
}
}
-\AtBeginDocument
- {
- \cs_set_eq:NN \__nicematrix_adapt_S_column: \prg_do_nothing:
- \bool_lazy_and:nnT
- { \c__nicematrix_siunitx_loaded_bool }
- { ! \cs_if_exist_p:N \siunitx_cell_begin:w }
- {
- \cs_set_protected:Npn \__nicematrix_adapt_S_column:
- {
- \group_begin:
- \@temptokena = { }
- \cs_set_eq:NN \NC@find \prg_do_nothing:
- \NC@rewrite@S { }
- \tl_gset:NV \g_tmpa_tl \@temptokena
- \group_end:
- \tl_new:N \c__nicematrix_table_collect_begin_tl
- \tl_set:Nx \l_tmpa_tl { \tl_item:Nn \g_tmpa_tl 2 }
- \tl_gset:Nx \c__nicematrix_table_collect_begin_tl { \tl_item:Nn \l_tmpa_tl 1 }
- \tl_new:N \c__nicematrix_table_print_tl
- \tl_gset:Nx \c__nicematrix_table_print_tl { \tl_item:Nn \g_tmpa_tl { -1 } }
- \cs_gset_eq:NN \__nicematrix_adapt_S_column: \prg_do_nothing:
- }
- }
- }
\int_new:N \g__nicematrix_env_int
\cs_new:Npn \__nicematrix_env: { nm - \int_use:N \g__nicematrix_env_int }
\NewExpandableDocumentCommand \NiceMatrixLastEnv { }
@@ -1538,7 +1513,6 @@
\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 } }
- \__nicematrix_adapt_S_column:
\bool_if:NTF \l__nicematrix_NiceTabular_bool
\mode_leave_vertical:
\__nicematrix_test_if_math_mode:
@@ -1674,7 +1648,7 @@
\exp_after:wN \left \g__nicematrix_left_delim_tl
\vcenter
{
- \skip_vertical:N -\l_tmpa_dim
+ \skip_vertical:n { -\l_tmpa_dim - \arrayrulewidth }
\hbox
{
\bool_if:NTF \l__nicematrix_NiceTabular_bool
@@ -1685,7 +1659,7 @@
{ \skip_horizontal:N -\tabcolsep }
{ \skip_horizontal:N -\arraycolsep }
}
- \skip_vertical:N -\l_tmpb_dim
+ \skip_vertical:n { -\l_tmpb_dim + \arrayrulewidth }
}
\tl_if_empty:NF \l__nicematrix_delimiters_color_tl
{ \color { \l__nicematrix_delimiters_color_tl } }
@@ -1945,7 +1919,7 @@
{
\use:x
{
- \__nicematrix_patch_preamble_iv_v:nnnnnnn
+ \__nicematrix_patch_preamble_iv_v:nnnnnnnn
{ \str_if_eq:VnTF \l__nicematrix_vpos_col_str { p } { t } { b } }
{ \dim_eval:n { #1 } }
{
@@ -1966,11 +1940,19 @@
{ \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 }
+ {
+ \str_case:VnF \l__nicematrix_hpos_col_str
+ {
+ { j } { c }
+ { si } { c }
+ }
+ { \l__nicematrix_hpos_col_str }
+ }
}
\int_gincr:N \c@jCol
\__nicematrix_patch_preamble_xi:n
}
-\cs_new_protected:Npn \__nicematrix_patch_preamble_iv_v:nnnnnnn #1 #2 #3 #4 #5 #6 #7
+\cs_new_protected:Npn \__nicematrix_patch_preamble_iv_v:nnnnnnnn #1 #2 #3 #4 #5 #6 #7 #8
{
\tl_gput_right:Nn \g__nicematrix_preamble_tl
{
@@ -1988,7 +1970,7 @@
\arraybackslash
#5
}
- c
+ #8
< {
#6
\@finalstrut \@arstrutbox
@@ -2071,39 +2053,24 @@
}
\cs_new_protected:Npn \__nicematrix_patch_preamble_vii_i:w [ #1 ]
{ \__nicematrix_patch_preamble_vii_ii:n { #1 } }
-\AtBeginDocument
+\cs_new_protected:Npn \__nicematrix_patch_preamble_vii_ii:n #1
{
\cs_if_exist:NTF \siunitx_cell_begin:w
{
- \cs_new_protected:Npn \__nicematrix_patch_preamble_vii_ii:n #1
+ \tl_gput_right:Nn \g__nicematrix_preamble_tl
{
- \tl_gput_right:Nn \g__nicematrix_preamble_tl
- {
- > {
- \__nicematrix_cell_begin:w
- \keys_set:nn { siunitx } { #1 }
- \siunitx_cell_begin:w
- }
- c
- < { \siunitx_cell_end: \__nicematrix_cell_end: }
+ > {
+ \__nicematrix_cell_begin:w
+ \keys_set:nn { siunitx } { #1 }
+ \siunitx_cell_begin:w
}
- \int_gincr:N \c@jCol
- \__nicematrix_patch_preamble_xi:n
+ c
+ < { \siunitx_cell_end: \__nicematrix_cell_end: }
}
+ \int_gincr:N \c@jCol
+ \__nicematrix_patch_preamble_xi:n
}
- {
- \cs_new_protected:Npn \__nicematrix_patch_preamble_vii_ii:n #1
- {
- \tl_gput_right:Nn \g__nicematrix_preamble_tl
- {
- > { \__nicematrix_cell_begin:w \c__nicematrix_table_collect_begin_tl S { #1 } }
- c
- < { \c__nicematrix_table_print_tl \__nicematrix_cell_end: }
- }
- \int_gincr:N \c@jCol
- \__nicematrix_patch_preamble_xi:n
- }
- }
+ { \__nicematrix_fatal:n { Version~of~siunitx~too~old } }
}
\cs_new_protected:Npn \__nicematrix_patch_preamble_viii:nn #1 #2
{
@@ -2584,7 +2551,7 @@
\vcenter
{
\vbox_to_ht:nn
- { \box_ht:N \l_tmpa_box + \box_dp:N \l_tmpa_box }
+ { \box_ht_plus_dp:N \l_tmpa_box }
{ }
}
\right .
@@ -2597,7 +2564,7 @@
\c_math_toggle_token
\left .
\vbox_to_ht:nn
- { \box_ht:N \l_tmpa_box + \box_dp:N \l_tmpa_box }
+ { \box_ht_plus_dp:N \l_tmpa_box }
{ }
\right #2
\c_math_toggle_token
@@ -3131,7 +3098,6 @@
\__nicematrix_adjust_pos_of_blocks_seq:
\tl_if_empty:NF \l__nicematrix_hlines_clist \__nicematrix_draw_hlines:
\tl_if_empty:NF \l__nicematrix_vlines_clist \__nicematrix_draw_vlines:
- \cs_set_eq:NN \SubMatrix \__nicematrix_SubMatrix
\bool_if:NT \c__nicematrix_tikz_loaded_bool
{
\tikzset
@@ -3144,15 +3110,17 @@
}
}
}
+ \cs_set_eq:NN \ialign \__nicematrix_old_ialign:
+ \cs_set_eq:NN \SubMatrix \__nicematrix_SubMatrix
+ \cs_set_eq:NN \UnderBrace \__nicematrix_UnderBrace
+ \cs_set_eq:NN \OverBrace \__nicematrix_OverBrace
\cs_set_eq:NN \line \__nicematrix_line
\g__nicematrix_internal_code_after_tl
\tl_gclear:N \g__nicematrix_internal_code_after_tl
\cs_set_eq:NN \CodeAfter \prg_do_nothing:
\seq_gclear:N \g__nicematrix_submatrix_names_seq
- % \bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token
\exp_last_unbraced:NV \__nicematrix_CodeAfter_keys: \g_nicematrix_code_after_tl
\scan_stop:
- % \bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token
\tl_gclear:N \g_nicematrix_code_after_tl
\group_end:
\tl_if_empty:NF \g_nicematrix_code_before_tl
@@ -3817,7 +3785,9 @@
{
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
- \tl_if_eq:NNTF \l__nicematrix_xdots_line_style_tl \c__nicematrix_standard_tl
+ \bool_lazy_or:nnTF
+ { \tl_if_eq_p:NN \l__nicematrix_xdots_line_style_tl \c__nicematrix_standard_tl }
+ \l__nicematrix_dotted_bool
\__nicematrix_draw_standard_dotted_line:
\__nicematrix_draw_unstandard_dotted_line:
}
@@ -6595,23 +6565,35 @@
}
}
}
-\cs_new_protected:Npn \__nicematrix_sub_matrix:nnnnnnn #1 #2 #3 #4 #5 #6 #7
+\cs_new_protected:Npn \__nicematrix_compute_i_j:nn #1 #2
{
- \group_begin:
\tl_clear_new:N \l__nicematrix_first_i_tl
\tl_clear_new:N \l__nicematrix_first_j_tl
\tl_clear_new:N \l__nicematrix_last_i_tl
\tl_clear_new:N \l__nicematrix_last_j_tl
+ \__nicematrix_cut_on_hyphen:w #1 \q_stop
+ \tl_if_eq:NnTF \l_tmpa_tl { last }
+ { \tl_set:NV \l__nicematrix_first_i_tl \c@iRow }
+ { \tl_set_eq:NN \l__nicematrix_first_i_tl \l_tmpa_tl }
+ \tl_if_eq:NnTF \l_tmpb_tl { last }
+ { \tl_set:NV \l__nicematrix_first_j_tl \c@jCol }
+ { \tl_set_eq:NN \l__nicematrix_first_j_tl \l_tmpb_tl }
\__nicematrix_cut_on_hyphen:w #2 \q_stop
- \tl_set_eq:NN \l__nicematrix_first_i_tl \l_tmpa_tl
- \tl_set_eq:NN \l__nicematrix_first_j_tl \l_tmpb_tl
- \__nicematrix_cut_on_hyphen:w #3 \q_stop
- \tl_set_eq:NN \l__nicematrix_last_i_tl \l_tmpa_tl
- \tl_set_eq:NN \l__nicematrix_last_j_tl \l_tmpb_tl
+ \tl_if_eq:NnTF \l_tmpa_tl { last }
+ { \tl_set:NV \l__nicematrix_last_i_tl \c@iRow }
+ { \tl_set_eq:NN \l__nicematrix_last_i_tl \l_tmpa_tl }
+ \tl_if_eq:NnTF \l_tmpb_tl { last }
+ { \tl_set:NV \l__nicematrix_last_j_tl \c@jCol }
+ { \tl_set_eq:NN \l__nicematrix_last_j_tl \l_tmpb_tl }
+ }
+\cs_new_protected:Npn \__nicematrix_sub_matrix:nnnnnnn #1 #2 #3 #4 #5 #6 #7
+ {
+ \group_begin:
+ \__nicematrix_compute_i_j:nn { #2 } { #3 }
\bool_lazy_or:nnTF
{ \int_compare_p:nNn \l__nicematrix_last_i_tl > \g__nicematrix_row_total_int }
{ \int_compare_p:nNn \l__nicematrix_last_j_tl > \g__nicematrix_col_total_int }
- { \__nicematrix_error:n { SubMatrix~too~large } }
+ { \__nicematrix_error:nn { Construct~too~large } { \SubMatrix } }
{
\str_clear_new:N \l__nicematrix_submatrix_name_str
\keys_set:nn { NiceMatrix / SubMatrix } { #5 }
@@ -6879,6 +6861,159 @@
{ #2 }
{ }
}
+\NewDocumentCommand \__nicematrix_UnderBrace { O { } m m m O { } }
+ {
+ \peek_remove_spaces:n
+ { \__nicematrix_brace:nnnnn { #2 } { #3 } { #4 } { #1 , #5 } { under } }
+ }
+\NewDocumentCommand \__nicematrix_OverBrace { O { } m m m O { } }
+ {
+ \peek_remove_spaces:n
+ { \__nicematrix_brace:nnnnn { #2 } { #3 } { #4 } { #1 , #5 } { over } }
+ }
+\keys_define:nn { NiceMatrix / Brace }
+ {
+ left-shorten .bool_set:N = \l__nicematrix_brace_left_shorten_bool ,
+ left-shorten .default:n = true ,
+ right-shorten .bool_set:N = \l__nicematrix_brace_right_shorten_bool ,
+ shorten .meta:n = { left-shorten , right-shorten } ,
+ right-shorten .default:n = true ,
+ yshift .dim_set:N = \l__nicematrix_brace_yshift_dim ,
+ yshift .value_required:n = true ,
+ yshift .initial:n = \c_zero_dim ,
+ unknown .code:n = \__nicematrix_error:n { Unknown~key~for~Brace }
+ }
+\cs_new_protected:Npn \__nicematrix_brace:nnnnn #1 #2 #3 #4 #5
+ {
+ \group_begin:
+ \__nicematrix_compute_i_j:nn { #1 } { #2 }
+ \bool_lazy_or:nnTF
+ { \int_compare_p:nNn \l__nicematrix_last_i_tl > \g__nicematrix_row_total_int }
+ { \int_compare_p:nNn \l__nicematrix_last_j_tl > \g__nicematrix_col_total_int }
+ {
+ \str_if_eq:nnTF { #5 } { under }
+ { \__nicematrix_error:nn { Construct~too~large } { \UnderBrace } }
+ { \__nicematrix_error:nn { Construct~too~large } { \OverBrace } }
+ }
+ {
+ \keys_set:nn { NiceMatrix / Brace } { #4 }
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgf@relevantforpicturesizefalse
+ \bool_if:NT \l__nicematrix_brace_left_shorten_bool
+ {
+ \dim_set_eq:NN \l__nicematrix_x_initial_dim \c_max_dim
+ \int_step_inline:nnn \l__nicematrix_first_i_tl \l__nicematrix_last_i_tl
+ {
+ \cs_if_exist:cT
+ { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - \l__nicematrix_first_j_tl }
+ {
+ \pgfpointanchor { \__nicematrix_env: - ##1 - \l__nicematrix_first_j_tl } { west }
+ \dim_set:Nn \l__nicematrix_x_initial_dim
+ { \dim_min:nn \l__nicematrix_x_initial_dim \pgf@x }
+ }
+ }
+ }
+ \bool_lazy_or:nnT
+ { \bool_not_p:n \l__nicematrix_brace_left_shorten_bool }
+ { \dim_compare_p:nNn \l__nicematrix_x_initial_dim = \c_max_dim }
+ {
+ \__nicematrix_qpoint:n { col - \l__nicematrix_first_j_tl }
+ \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x
+ }
+ \bool_if:NT \l__nicematrix_brace_right_shorten_bool
+ {
+ \dim_set:Nn \l__nicematrix_x_final_dim { - \c_max_dim }
+ \int_step_inline:nnn \l__nicematrix_first_i_tl \l__nicematrix_last_i_tl
+ {
+ \cs_if_exist:cT
+ { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - \l__nicematrix_last_j_tl }
+ {
+ \pgfpointanchor { \__nicematrix_env: - ##1 - \l__nicematrix_last_j_tl } { east }
+ \dim_set:Nn \l__nicematrix_x_final_dim
+ { \dim_max:nn \l__nicematrix_x_final_dim \pgf@x }
+ }
+ }
+ }
+ \bool_lazy_or:nnT
+ { \bool_not_p:n \l__nicematrix_brace_right_shorten_bool }
+ { \dim_compare_p:nNn \l__nicematrix_x_final_dim = { - \c_max_dim } }
+ {
+ \__nicematrix_qpoint:n { col - \int_eval:n { \l__nicematrix_last_j_tl + 1 } }
+ \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x
+ }
+ \pgfset { inner~sep = \c_zero_dim }
+ \str_if_eq:nnTF { #5 } { under }
+ { \__nicematrix_underbrace_i:n { #3 } }
+ { \__nicematrix_overbrace_i:n { #3 } }
+ \endpgfpicture
+ }
+ \group_end:
+ }
+\cs_new_protected:Npn \__nicematrix_overbrace_i:n #1
+ {
+ \__nicematrix_qpoint:n { row - \l__nicematrix_first_i_tl }
+ \pgftransformshift
+ {
+ \pgfpoint
+ { ( \l__nicematrix_x_initial_dim + \l__nicematrix_x_final_dim) / 2 }
+ { \pgf@y + \l__nicematrix_brace_yshift_dim }
+ }
+ \pgfnode
+ { rectangle }
+ { south }
+ {
+ \vbox_top:n
+ {
+ \group_begin:
+ \everycr { }
+ \halign
+ {
+ \hfil ## \hfil \crcr
+ \__nicematrix_math_toggle_token: #1 \__nicematrix_math_toggle_token: \cr
+ \noalign { \skip_vertical:n { 4.5 pt } \nointerlineskip }
+ \hbox_to_wd:nn
+ { \l__nicematrix_x_final_dim - \l__nicematrix_x_initial_dim }
+ { \downbracefill } \cr
+ }
+ \group_end:
+ }
+ }
+ { }
+ { }
+ }
+\cs_new_protected:Npn \__nicematrix_underbrace_i:n #1
+ {
+ \__nicematrix_qpoint:n { row - \int_eval:n { \l__nicematrix_last_i_tl + 1 } }
+ \pgftransformshift
+ {
+ \pgfpoint
+ { ( \l__nicematrix_x_initial_dim + \l__nicematrix_x_final_dim) / 2 }
+ { \pgf@y - \l__nicematrix_brace_yshift_dim }
+ }
+ \pgfnode
+ { rectangle }
+ { north }
+ {
+ \group_begin:
+ \everycr { }
+ \vbox:n
+ {
+ \halign
+ {
+ \hfil ## \hfil \crcr
+ \hbox_to_wd:nn
+ { \l__nicematrix_x_final_dim - \l__nicematrix_x_initial_dim }
+ { \upbracefill } \cr
+ \noalign { \skip_vertical:n { 4.5 pt } \nointerlineskip }
+ \__nicematrix_math_toggle_token: #1 \__nicematrix_math_toggle_token: \cr
+ }
+ }
+ \group_end:
+ }
+ { }
+ { }
+ }
\bool_new:N \c__nicematrix_footnotehyper_bool
\bool_new:N \c__nicematrix_footnote_bool
\__nicematrix_msg_new:nnn { Unknown~key~for~package }
@@ -7081,9 +7216,9 @@
You~can't~use~an~ampersand~(\token_to_str:N &)~to~separate~columns~because~
~you~have~used~the~key~'light-syntax'.~This~error~is~fatal.
}
-\__nicematrix_msg_new:nn { SubMatrix~too~large }
+\__nicematrix_msg_new:nn { Construct~too~large }
{
- Your~command~\token_to_str:N \SubMatrix\
+ Your~command~\token_to_str:N #1
can't~be~drawn~because~your~matrix~is~too~small.\\
If~you~go~on,~this~command~will~be~ignored.
}
@@ -7287,6 +7422,24 @@
The~available~keys~are~(in~alphabetic~order):~b,~borders,~c,~draw,~fill,~
hvlines,~l,~line-width,~name,~rounded-corners,~r,~t~and~tikz.
}
+\__nicematrix_msg_new:nn { Version~of~siunitx~too~old }
+ {
+ You~can't~use~'S'~columns~because~your~version~of~'siunitx'~
+ is~too~old.~You~need~at~least~v~3.0.\\
+ This~error~is~fatal.
+ }
+\__nicematrix_msg_new:nnn { Unknown~key~for~Brace }
+ {
+ The~key~'\l_keys_key_str'~is~unknown~for~the~commands~\token_to_str:N
+ \UnderBrace\ and~\token_to_str:N \OverBrace.\\
+ 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):~left-shorten,~
+ right-shorten,~shorten~(which~fixes~both~left-shorten~and~
+ right-shorten)~and~yshift.
+ }
\__nicematrix_msg_new:nnn { Unknown~key~for~CodeAfter }
{
The~key~'\l_keys_key_str'~is~unknown.\\