summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/nicematrix
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-11-12 21:43:08 +0000
committerKarl Berry <karl@freefriends.org>2019-11-12 21:43:08 +0000
commit9d6c49cae17469027c229eb48c1c0c1a6719c805 (patch)
tree7ace81295ef1027e04787b1835b7d010d6e231d6 /Master/texmf-dist/tex/latex/nicematrix
parenta272b01e61e4f437870ae86420b1d13c07d7acf9 (diff)
nicematrix (12nov19)
git-svn-id: svn://tug.org/texlive/trunk@52757 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/nicematrix')
-rw-r--r--Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty168
1 files changed, 121 insertions, 47 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
index 7c650dca5aa..d2940a8e405 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{3.6}
-\def\myfiledate{2019/10/29}
+\def\myfileversion{3.7}
+\def\myfiledate{2019/11/11}
\RequirePackage{tikz}
\usetikzlibrary{fit}
\RequirePackage{expl3}[2019/07/01]
@@ -203,11 +203,11 @@
columns-width .value_required:n = true ,
name .code:n =
\unless \ifmeasuring@
- \str_set:Nn \l_tmpa_str { #1 }
- \seq_if_in:NVTF \g__nm_names_seq \l_tmpa_str
- { \__nm_error:nn { Duplicate~name } { #1 } }
- { \seq_gput_left:NV \g__nm_names_seq \l_tmpa_str }
- \str_set_eq:NN \l__nm_name_str \l_tmpa_str
+ \str_set:Nn \l_tmpa_str { #1 }
+ \seq_if_in:NVTF \g__nm_names_seq \l_tmpa_str
+ { \__nm_error:nn { Duplicate~name } { #1 } }
+ { \seq_gput_left:NV \g__nm_names_seq \l_tmpa_str }
+ \str_set_eq:NN \l__nm_name_str \l_tmpa_str
\fi ,
name .value_required:n = true ,
code-after .tl_gset:N = \g__nm_code_after_tl ,
@@ -592,7 +592,10 @@
\NewDocumentEnvironment { NiceArrayWithDelims } { m m O { } m ! O { } }
{
\str_if_empty:NT \g__nm_type_env_str
- { \str_gset:Nn \g__nm_type_env_str { NiceArrayWithDelims } }
+ {
+ \str_gset:Nn \g__nm_type_env_str
+ { environment ~ { NiceArrayWithDelims } }
+ }
\__nm_adapt_S_column:
\__nm_test_if_math_mode:
\bool_if:NT \l__nm_in_env_bool { \__nm_fatal:n { Yet~in~env } }
@@ -840,7 +843,17 @@
\hbox_set:Nw \l_tmpa_box
\c_math_toggle_token
\bool_if:NT \l__nm_small_bool \scriptstyle
- \int_compare:nNnT \c@iRow > \c_zero_int \l__nm_code_for_first_col_tl
+ \bool_if:nT
+ {
+ \int_compare_p:nNn \c@iRow > \c_zero_int
+ &&
+ (
+ \int_compare_p:nNn \l__nm_last_row_int < 0
+ ||
+ \int_compare_p:nNn \c@iRow < \l__nm_last_row_int
+ )
+ }
+ { \l__nm_code_for_first_col_tl }
}
l
<
@@ -901,7 +914,17 @@
\hbox_set:Nw \l_tmpa_box
\c_math_toggle_token
\bool_if:NT \l__nm_small_bool \scriptstyle
- \l__nm_code_for_last_col_tl
+ \bool_if:nT
+ {
+ \int_compare_p:nNn \c@iRow > \c_zero_int
+ &&
+ (
+ \int_compare_p:nNn \l__nm_last_row_int < 0
+ ||
+ \int_compare_p:nNn \c@iRow < \l__nm_last_row_int
+ )
+ }
+ { \l__nm_code_for_last_col_tl }
}
l
<
@@ -955,14 +978,14 @@
{
\bool_set_true:N \l__nm_NiceArray_bool
\str_if_empty:NT \g__nm_type_env_str
- { \str_gset:Nn \g__nm_type_env_str { NiceArray } }
+ { \str_gset:Nn \g__nm_type_env_str { environment ~ { NiceArray } } }
\NiceArrayWithDelims . .
}
{ \endNiceArrayWithDelims }
\NewDocumentEnvironment { pNiceArray } { }
{
\str_if_empty:NT \g__nm_type_env_str
- { \str_gset:Nn \g__nm_type_env_str { pNiceArray } }
+ { \str_gset:Nn \g__nm_type_env_str { environment ~ { pNiceArray } } }
\__nm_test_if_math_mode:
\NiceArrayWithDelims ( )
}
@@ -970,7 +993,7 @@
\NewDocumentEnvironment { bNiceArray } { }
{
\str_if_empty:NT \g__nm_type_env_str
- { \str_gset:Nn \g__nm_type_env_str { NiceArray } }
+ { \str_gset:Nn \g__nm_type_env_str { environment ~ { bNiceArray } } }
\__nm_test_if_math_mode:
\NiceArrayWithDelims [ ]
}
@@ -978,7 +1001,7 @@
\NewDocumentEnvironment { BNiceArray } { }
{
\str_if_empty:NT \g__nm_type_env_str
- { \str_gset:Nn \g__nm_type_env_str { BNiceArray } }
+ { \str_gset:Nn \g__nm_type_env_str { environment ~ { BNiceArray } } }
\__nm_test_if_math_mode:
\NiceArrayWithDelims \{ \}
}
@@ -986,7 +1009,7 @@
\NewDocumentEnvironment { vNiceArray } { }
{
\str_if_empty:NT \g__nm_type_env_str
- { \str_gset:Nn \g__nm_type_env_str { vNiceArray } }
+ { \str_gset:Nn \g__nm_type_env_str { environment ~ { vNiceArray } } }
\__nm_test_if_math_mode:
\NiceArrayWithDelims | |
}
@@ -994,7 +1017,7 @@
\NewDocumentEnvironment { VNiceArray } { }
{
\str_if_empty:NT \g__nm_type_env_str
- { \str_gset:Nn \g__nm_type_env_str { VNiceArray } }
+ { \str_gset:Nn \g__nm_type_env_str { environment ~ { VNiceArray } } }
\__nm_test_if_math_mode:
\NiceArrayWithDelims \| \|
}
@@ -1003,7 +1026,7 @@
{
\NewDocumentEnvironment { #1 NiceMatrix } { ! O { } }
{
- \str_gset:Nn \g__nm_type_env_str { #1 NiceMatrix }
+ \str_gset:Nn \g__nm_type_env_str { environment ~ { #1 NiceMatrix } }
\keys_set:nn { NiceMatrix / NiceMatrix } { ##1 }
\begin { #1 NiceArray }
{
@@ -1785,7 +1808,18 @@
\int_step_inline:nnn { #2 } { #2 + #3 - 1 }
{ \cs_set:cpn { __nm _ dotted _ #1 - ##1 } { } }
}
-\cs_new_protected:Nn \__nm_line:nn
+\cs_new:Npn \__nm_double_int_eval:n #1-#2 \q_stop
+ { \int_eval:n { #1 } - \int_eval:n { #2 } }
+\cs_new_protected:Npn \__nm_line:nn #1 #2
+ {
+ \use:x
+ {
+ \__nm_line_i:nn
+ { \__nm_double_int_eval:n #1 \q_stop }
+ { \__nm_double_int_eval:n #2 \q_stop }
+ }
+ }
+\cs_new_protected:Nn \__nm_line_i:nn
{
\bool_if:NF \c__nm_draft_bool
{
@@ -1803,13 +1837,13 @@
}
{
\begin { tikzpicture }
- \path~(#1)~--~(#2)~node[at~start]~(i)~{}~node[at~end]~(f)~{} ;
- \tikz@parse@node \pgfutil@firstofone ( i )
- \dim_gset:Nn \g__nm_x_initial_dim \pgf@x
- \dim_gset:Nn \g__nm_y_initial_dim \pgf@y
- \tikz@parse@node \pgfutil@firstofone ( f )
- \dim_gset:Nn \g__nm_x_final_dim \pgf@x
- \dim_gset:Nn \g__nm_y_final_dim \pgf@y
+ \path~(#1)~--~(#2)~node[at~start]~(i)~{}~node[at~end]~(f)~{} ;
+ \tikz@parse@node \pgfutil@firstofone ( i )
+ \dim_gset:Nn \g__nm_x_initial_dim \pgf@x
+ \dim_gset:Nn \g__nm_y_initial_dim \pgf@y
+ \tikz@parse@node \pgfutil@firstofone ( f )
+ \dim_gset:Nn \g__nm_x_final_dim \pgf@x
+ \dim_gset:Nn \g__nm_y_final_dim \pgf@y
\end { tikzpicture }
\__nm_draw_tikz_line:
}
@@ -2184,13 +2218,8 @@
;
}
\NewExpandableDocumentCommand \__nm_Block: { m D < > { } m }
- {
- \__nm_Block_i #1 \q_stop { #2 } { #3 }
- }
-\cs_new:Npn \__nm_Block_i #1-#2 \q_stop
- {
- \__nm_Block_ii:nnnn { #1 } { #2 }
- }
+ { \__nm_Block_i #1 \q_stop { #2 } { #3 } }
+\cs_new:Npn \__nm_Block_i #1-#2 \q_stop { \__nm_Block_ii:nnnn { #1 } { #2 } }
\cs_new:Npn \__nm_Block_ii:nnnn #1 #2 #3 #4
{
\int_compare:nNnTF { #1 } = 1
@@ -2263,6 +2292,52 @@
{ \BNiceMatrix }
{ \endBNiceMatrix }
}
+\cs_new_protected:Npn \__nm_set_size:n #1-#2 \q_stop
+ {
+ \int_set:Nn \l__nm_nb_rows_int { #1 }
+ \int_set:Nn \l__nm_nb_cols_int { #2 }
+ }
+\NewDocumentCommand \AutoNiceMatrixWithDelims { m m O { } m O { } m ! O { } }
+ {
+ \int_zero_new:N \l__nm_nb_rows_int
+ \int_zero_new:N \l__nm_nb_cols_int
+ \__nm_set_size:n #4 \q_stop
+ \begin { NiceArrayWithDelims } { #1 } { #2 }
+ { * { \l__nm_nb_cols_int } { C } } [ #3 , #5 , #7 ]
+ \int_compare:nNnT \l__nm_first_row_int = \c_zero_int
+ {
+ \int_compare:nNnT \l__nm_first_col_int = \c_zero_int { & }
+ \prg_replicate:nn { \l__nm_nb_cols_int - 1 } { & }
+ \int_compare:nNnT \l__nm_last_col_int > { -1 } { & } \\
+ }
+ \prg_replicate:nn \l__nm_nb_rows_int
+ {
+ \int_compare:nNnT \l__nm_first_col_int = \c_zero_int { & }
+ \prg_replicate:nn { \l__nm_nb_cols_int - 1 } { { } #6 & } #6
+ \int_compare:nNnT \l__nm_last_col_int > { -1 } { & } \\
+ }
+ \int_compare:nNnT \l__nm_last_row_int > { -2 }
+ {
+ \int_compare:nNnT \l__nm_first_col_int = \c_zero_int { & }
+ \prg_replicate:nn { \l__nm_nb_cols_int - 1 } { & }
+ \int_compare:nNnT \l__nm_last_col_int > { -1 } { & } \\
+ }
+ \end { NiceArrayWithDelims }
+ }
+\cs_set_protected:Npn \__nm_define_com:nnn #1 #2 #3
+ {
+ \cs_set_protected:cpn { #1 AutoNiceMatrix }
+ {
+ \str_gset:Nx \g__nm_type_env_str
+ { command ~ \c_backslash_str #1 AutoNiceMatrix }
+ \AutoNiceMatrixWithDelims { #2 } { #3 }
+ }
+ }
+\__nm_define_com:nnn p ( )
+\__nm_define_com:nnn b [ ]
+\__nm_define_com:nnn v | |
+\__nm_define_com:nnn V \| \|
+\__nm_define_com:nnn B \{ \}
\keys_define:nn { NiceMatrix / Package }
{
renew-dots .bool_set:N = \l__nm_renew_dots_bool ,
@@ -2281,15 +2356,14 @@
}
\__nm_msg_new:nn { last-col~non~empty~for~NiceArray }
{
- In~the~environment~\{\g__nm_type_env_str\},~you~must~use~the~option~
- 'last-col'~without~value~(the~number~of~columns~is~known~by~the~
- preamble~of~the~environment).\\
+ In~the~\g__nm_type_env_str,~you~must~use~the~option~
+ 'last-col'~without~value.\\
However,~you~can~go~on~for~this~time~
(the~value~'\l_keys_value_tl'~will~be~ignored).
}
\__nm_msg_new:nn { last-col~empty~for~NiceMatrix }
{
- In~the~environment~\{\g__nm_type_env_str\}~you~can't~use~the~option~
+ In~the~\g__nm_type_env_str, you~can't~use~the~option~
'last-col'~without~value.~You~must~give~the~number~of~that~last~column.\\
If~you~go~on~this~option~will~be~ignored.
}
@@ -2297,7 +2371,7 @@
{
You~try~to~draw~a~block~in~the~cell~#1-#2~of~your~matrix~but~the~matrix~is~
too~small~for~that~block.\\
- If~you~go~on,~this~command~line~will~be~ignored.
+ If~you~go~on,~this~command~will~be~ignored.
}
\__nm_msg_new:nn { Impossible~line }
{
@@ -2307,10 +2381,10 @@
}
\__nm_msg_new:nn { Wrong~last~row }
{
- You~have~used~'last-row=\int_use:N \l__nm_last_row_int'~but~your~environment~
- \{\g__nm_type_env_str\}~seems~to~have~\int_use:N \c@iRow
- rows.~If~you~go~on,~the~value~of~\int_use:N \c@iRow
- will~be~used~for~last~row.~You~can~avoid~this~problem~by~using~'last-row'~
+ You~have~used~'last-row=\int_use:N \l__nm_last_row_int'~but~your~
+ \g__nm_type_env_str\ seems~to~have~\int_use:N \c@iRow \ rows.~
+ If~you~go~on,~the~value~of~\int_use:N \c@iRow \ will~be~used~for~
+ last~row.~You~can~avoid~this~problem~by~using~'last-row'~
without~value~(more~compilations~might~be~necessary).
}
\__nm_msg_new:nn { Yet~in~env }
@@ -2320,7 +2394,7 @@
}
\__nm_msg_new:nn { Outside~math~mode }
{
- The~environment~\{\g__nm_type_env_str\}~can~be~used~only~in~math~mode~
+ The~\g__nm_type_env_str\ can~be~used~only~in~math~mode~
(and~not~in~\token_to_str:N \vcenter).\\
This~error~is~fatal.
}
@@ -2401,8 +2475,8 @@
}
\__nm_msg_new:nnn { Unknown~option~for~NiceMatrix }
{
- The~option~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~environment~
- \{\g__nm_type_env_str\}. \\
+ The~option~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~
+ \g__nm_type_env_str. \\
If~you~go~on,~it~will~be~ignored. \\
For~a~list~of~the~available~options,~type~H~<return>.
}
@@ -2451,7 +2525,7 @@
}
\__nm_msg_new:nn { Zero~row }
{
- There~is~a~problem.~Maybe~your~environment~\{\g__nm_type_env_str\}~is~empty.~
+ There~is~a~problem.~Maybe~your~\g__nm_type_env_str\ is~empty.~
Maybe~you~have~used~l,~c~and~r~instead~of~L,~C~and~R~in~the~preamble~
of~your~environment. \\
If~you~go~on,~the~result~may~be~incorrect.
@@ -2459,12 +2533,12 @@
\__nm_msg_new:nn { Use~of~:~in~first~position }
{
You~can't~use~the~column~specifier~'\l__nm_letter_for_dotted_lines_str'~in~the~
- first~position~of~the~preamble~of~the~environment~\{\g__nm_type_env_str\}. \\
+ first~position~of~the~preamble~of~the~\g__nm_type_env_str. \\
If~you~go~on,~this~dotted~line~will~be~ignored.
}
\__nm_msg_new:nn { Obsolete~environment }
{
- The~environment~\{\@currenvir\}~is~obsolete.~
+ The~environment~\{\@currenvir\}~is~obsolete~and~will~be~deleted~in~future~version.~
We~should~use~#1~instead.
}
\NewDocumentEnvironment { pNiceArrayC } { }