summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-01-23 17:53:50 +0000
committerKarl Berry <karl@freefriends.org>2020-01-23 17:53:50 +0000
commit1611b583581d3f0327a05cd9c5633bcf4a9df9ed (patch)
tree687231459b386ee4b6ad90eb4575c52e1f4326ed /Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
parent300a47794120fb8337724ab100edb9ce9f793088 (diff)
nicematrix (22jan20)
git-svn-id: svn://tug.org/texlive/trunk@53502 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty')
-rw-r--r--Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty268
1 files changed, 160 insertions, 108 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
index ce81093ceaa..9072571cef0 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.9}
-\def\myfiledate{2020/01/10}
+\def\myfileversion{3.10}
+\def\myfiledate{2020/01/22}
\RequirePackage{tikz}
\usetikzlibrary{fit}
\RequirePackage{expl3}[2019/07/01]
@@ -94,6 +94,8 @@
}
\dim_new:N \l__nicematrix_inter_dots_dim
\dim_set:Nn \l__nicematrix_inter_dots_dim { 0.45 em }
+\dim_new:N \l__nicematrix_dotted_lines_margin_dim
+\dim_set:Nn \l__nicematrix_dotted_lines_margin_dim { 0.3 em }
\dim_new:N \l__nicematrix_radius_dim
\dim_set:Nn \l__nicematrix_radius_dim { 0.53 pt }
\str_new:N \g__nicematrix_type_env_str
@@ -149,6 +151,7 @@
\NC@find
}
}
+\bool_new:N \l__nicematrix_light_syntax_bool
\str_new:N \l__nicematrix_pos_env_str
\str_set:Nn \l__nicematrix_pos_env_str c
\bool_new:N \l__nicematrix_exterior_arraycolsep_bool
@@ -168,16 +171,29 @@
\dim_new:N \g__nicematrix_width_first_col_dim
\dim_new:N \l__nicematrix_extra_left_margin_dim
\dim_new:N \l__nicematrix_extra_right_margin_dim
+\tl_new:N \l__nicematrix_end_of_row_tl
+\tl_set:Nn \l__nicematrix_end_of_row_tl { ; }
\keys_define:nn { NiceMatrix / Global }
{
+ dotted-lines-margin .dim_set:N = \l__nicematrix_dotted_lines_margin_dim ,
+ dotted-lines-margin .value_required:n = true ,
+ light-syntax .bool_set:N = \l__nicematrix_light_syntax_bool ,
+ light-syntax .default:n = true ,
+ end-of-row .tl_set:N = \l__nicematrix_end_of_row_tl ,
+ end-of-row .value_required:n = true ,
code-for-first-col .tl_set:N = \l__nicematrix_code_for_first_col_tl ,
+ code-for-first-col .value_required:n = true ,
code-for-last-col .tl_set:N = \l__nicematrix_code_for_last_col_tl ,
+ code-for-last-col .value_required:n = true ,
code-for-first-row .tl_set:N = \l__nicematrix_code_for_first_row_tl ,
+ code-for-first-row .value_required:n = true ,
code-for-last-row .tl_set:N = \l__nicematrix_code_for_last_row_tl ,
+ code-for-last-row .value_required:n = true ,
small .bool_set:N = \l__nicematrix_small_bool ,
hlines .bool_set:N = \l__nicematrix_hlines_bool ,
parallelize-diags .bool_set:N = \l__nicematrix_parallelize_diags_bool ,
renew-dots .bool_set:N = \l__nicematrix_renew_dots_bool ,
+ renew-dots .value_forbidden:n = true ,
nullify-dots .bool_set:N = \l__nicematrix_nullify_dots_bool ,
create-medium-nodes .bool_set:N = \l__nicematrix_medium_nodes_bool ,
create-large-nodes .bool_set:N = \l__nicematrix_large_nodes_bool ,
@@ -192,7 +208,7 @@
extra-left-margin .dim_set:N = \l__nicematrix_extra_left_margin_dim ,
extra-right-margin .dim_set:N = \l__nicematrix_extra_right_margin_dim ,
extra-margin .meta:n =
- { extra-left-margin = #1 , extra-right-margin = #1 } ,
+ { extra-left-margin = #1 , extra-right-margin = #1 }
}
\keys_define:nn { NiceMatrix / Env }
{
@@ -200,6 +216,7 @@
\str_if_eq:nnTF { #1 } { auto }
{ \bool_set_true:N \l__nicematrix_auto_columns_width_bool }
{ \dim_set:Nn \l__nicematrix_columns_width_dim { #1 } } ,
+ columns-width .value_required:n = true ,
name .code:n =
\unless \ifmeasuring@
\str_set:Nn \l_tmpa_str { #1 }
@@ -208,7 +225,9 @@
{ \seq_gput_left:NV \g__nicematrix_names_seq \l_tmpa_str }
\str_set_eq:NN \l__nicematrix_name_str \l_tmpa_str
\fi ,
+ name .value_required:n = true ,
code-after .tl_gset:N = \g__nicematrix_code_after_tl ,
+ code-after .value_required:n = true ,
first-col .code:n = \int_zero:N \l__nicematrix_first_col_int ,
first-row .code:n = \int_zero:N \l__nicematrix_first_row_int ,
last-row .int_set:N = \l__nicematrix_last_row_int ,
@@ -240,13 +259,10 @@
{
renew-matrix .code:n = \__nicematrix_renew_matrix: ,
renew-matrix .value_forbidden:n = true ,
- RenewMatrix .code:n = \__nicematrix_error:n { Option~RenewMatrix~suppressed }
- \__nicematrix_renew_matrix: ,
+ RenewMatrix .code:n = \__nicematrix_error:n { Option~RenewMatrix~suppressed } ,
transparent .meta:n = { renew-dots , renew-matrix } ,
transparent .value_forbidden:n = true,
- Transparent .code:n = \__nicematrix_error:n { Option~Transparent~suppressed }
- \__nicematrix_renew_matrix:
- \bool_set_true:N \l__nicematrix_renew_dots_bool ,
+ Transparent .code:n = \__nicematrix_error:n { Option~Transparent~suppressed } ,
exterior-arraycolsep .bool_set:N = \l__nicematrix_exterior_arraycolsep_bool ,
columns-width .code:n =
\str_if_eq:nnTF { #1 } { auto }
@@ -280,7 +296,7 @@
c .code:n = \str_set:Nn \l__nicematrix_pos_env_str c ,
t .code:n = \str_set:Nn \l__nicematrix_pos_env_str t ,
b .code:n = \str_set:Nn \l__nicematrix_pos_env_str b ,
- last-col .code:n = \tl_if_empty:nF {#1}
+ last-col .code:n = \tl_if_empty:nF { #1 }
{ \__nicematrix_error:n { last-col~non~empty~for~NiceArray } }
\int_zero:N \l__nicematrix_last_col_int ,
unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceArray }
@@ -388,31 +404,9 @@
\__nicematrix_end_Cell:
\hbox_set_end:
#2
- \hbox_set:Nn \l_tmpb_box
- { \makebox [ ##2 ] [ ##1 ] { \box_use:N \l_tmpa_box } }
- \dim_set:Nn \l_tmpa_dim { \box_dp:N \l_tmpb_box }
- \box_move_down:nn \l_tmpa_dim
- {
- \vbox:n
- {
- \hbox_to_wd:nn { \box_wd:N \l_tmpb_box }
- {
- \hfil
- \tikz [ remember~picture , overlay ]
- \coordinate (__nicematrix~north~east) ;
- }
- \hbox:n
- {
- \tikz [ remember~picture , overlay ]
- \coordinate (__nicematrix~south~west) ;
- \box_move_up:nn \l_tmpa_dim { \box_use:N \l_tmpb_box }
- }
- }
- }
- \tikz [ remember~picture , overlay ]
+ \tikz [ remember~picture ]
\node
[
- node~contents = { } ,
name = nm - \int_use:N \g__nicematrix_env_int -
\int_use:N \c@iRow -
\int_use:N \c@jCol - w,
@@ -424,8 +418,8 @@
\int_use:N \c@jCol - w
} ,
inner~sep = \c_zero_dim ,
- fit = (__nicematrix~south~west) (__nicematrix~north~east)
]
+ { \makebox [ ##2 ] [ ##1 ] { \box_use:N \l_tmpa_box } }
;
}
}
@@ -648,7 +642,6 @@
\c_math_toggle_token
\left #1 \vcenter to 3 cm { } \right.
\c_math_toggle_token
-
}
\dim_gset:Nn \g__nicematrix_left_delim_dim { \box_wd:N \l_tmpa_box }
\hbox_set:Nn \l_tmpa_box
@@ -685,68 +678,14 @@
\skip_horizontal:n \l__nicematrix_left_margin_dim
\skip_horizontal:n \l__nicematrix_extra_left_margin_dim
\c_math_toggle_token
- \exp_args:NV \__nicematrix_array: \l_tmpa_tl
+ \bool_if:NTF \l__nicematrix_light_syntax_bool
+ { \begin { __nicematrix-light-syntax } }
+ { \begin { __nicematrix-normal-syntax } }
}
{
- \bool_if:nT
- {
- \l__nicematrix_auto_columns_width_bool
- || \dim_compare_p:nNn \l__nicematrix_columns_width_dim > \c_zero_dim
- }
- {
- \crcr
- \int_compare:nNnT \l__nicematrix_first_col_int = 0 { \omit & }
- \omit
- \skip_horizontal:N \arraycolsep
- \tikz [ remember~picture , overlay ]
- \coordinate [ name = nm - \int_use:N \g__nicematrix_env_int - col - 0 ] ;
- \skip_horizontal:n { - \arraycolsep }
- \bool_if:nTF
- {
- \l__nicematrix_auto_columns_width_bool
- && ! \l__nicematrix_block_auto_columns_width_bool
- }
- {
- \dim_gset:Nn \g_tmpa_dim
- { \g__nicematrix_max_cell_width_dim + 2 \arraycolsep }
- }
- {
- \dim_gset:Nn \g_tmpa_dim
- { \l__nicematrix_columns_width_dim + 2 \arraycolsep }
- }
- \skip_horizontal:N \g_tmpa_dim
- \tikz [ remember~picture , overlay ]
- \coordinate [ name = nm - \int_use:N \g__nicematrix_env_int - col - 1 ] ;
- \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 } }
- {
- &
- \omit
- \int_gincr:N \g_tmpa_int
- \skip_horizontal:N \g_tmpa_dim
- \tikz [ remember~picture , overlay ]
- \coordinate
- [
- name = nm - \int_use:N \g__nicematrix_env_int -
- col - \int_use:N \g_tmpa_int
- ] ;
- }
- &
- \omit
- \int_gincr:N \g_tmpa_int
- \skip_horizontal:N \g_tmpa_dim
- \skip_horizontal:n { - \arraycolsep }
- \tikz [ remember~picture , overlay ]
- \coordinate
- [
- name = nm - \int_use:N \g__nicematrix_env_int -
- col - \int_use:N \g_tmpa_int
- ] ;
- \skip_horizontal:N \arraycolsep
- }
- \endarray
+ \bool_if:NTF \l__nicematrix_light_syntax_bool
+ { \end { __nicematrix-light-syntax } }
+ { \end { __nicematrix-normal-syntax } }
\c_math_toggle_token
\skip_horizontal:n \l__nicematrix_right_margin_dim
\skip_horizontal:n \l__nicematrix_extra_right_margin_dim
@@ -834,6 +773,99 @@
}
\__nicematrix_after_array:
}
+\NewDocumentEnvironment { __nicematrix-normal-syntax } { }
+ { \exp_args:NV \__nicematrix_array: \l_tmpa_tl }
+ {
+ \__nicematrix_create_row_of_col_nodes:
+ \endarray
+ }
+\NewDocumentEnvironment { __nicematrix-light-syntax } { b }
+ {
+ \exp_args:NV \__nicematrix_array: \l_tmpa_tl
+ \seq_gclear_new:N \g__nicematrix_rows_seq
+ \tl_set_rescan:Nno \l__nicematrix_end_of_row_tl { } \l__nicematrix_end_of_row_tl
+ \exp_args:NNV \seq_gset_split:Nnn \g__nicematrix_rows_seq \l__nicematrix_end_of_row_tl { #1 }
+ \seq_gpop_left:NN \g__nicematrix_rows_seq \l_tmpa_tl
+ \exp_args:NV \__nicematrix_line_with_light_syntax_i:n \l_tmpa_tl
+ \seq_map_function:NN \g__nicematrix_rows_seq \__nicematrix_line_with_light_syntax:n
+ \__nicematrix_create_row_of_col_nodes:
+ \endarray
+ }
+ { }
+\cs_new_protected:Npn \__nicematrix_line_with_light_syntax_i:n #1
+ {
+ \seq_gclear_new:N \g__nicematrix_cells_seq
+ \seq_gset_split:Nnn \g__nicematrix_cells_seq { ~ } { #1 }
+ \seq_gpop_left:NN \g__nicematrix_cells_seq \l_tmpa_tl
+ \l_tmpa_tl
+ \seq_map_function:NN \g__nicematrix_cells_seq \__nicematrix_cell_with_light_syntax:n
+ }
+\cs_new_protected:Npn \__nicematrix_line_with_light_syntax:n #1
+ {
+ \tl_if_empty:nF { #1 }
+ { \\ \__nicematrix_line_with_light_syntax_i:n { #1 } }
+ }
+\cs_new_protected:Npn \__nicematrix_cell_with_light_syntax:n #1 { & #1 }
+\cs_new:Npn \__nicematrix_create_row_of_col_nodes:
+ {
+ \bool_if:nT
+ {
+ \l__nicematrix_auto_columns_width_bool
+ || \dim_compare_p:nNn \l__nicematrix_columns_width_dim > \c_zero_dim
+ }
+ {
+ \crcr
+ \int_compare:nNnT \l__nicematrix_first_col_int = 0 { \omit & }
+ \omit
+ \skip_horizontal:N \arraycolsep
+ \tikz [ remember~picture , overlay ]
+ \coordinate [ name = nm - \int_use:N \g__nicematrix_env_int - col - 0 ] ;
+ \skip_horizontal:n { - \arraycolsep }
+ \bool_if:nTF
+ {
+ \l__nicematrix_auto_columns_width_bool
+ && ! \l__nicematrix_block_auto_columns_width_bool
+ }
+ {
+ \dim_gset:Nn \g_tmpa_dim
+ { \g__nicematrix_max_cell_width_dim + 2 \arraycolsep }
+ }
+ {
+ \dim_gset:Nn \g_tmpa_dim
+ { \l__nicematrix_columns_width_dim + 2 \arraycolsep }
+ }
+ \skip_horizontal:N \g_tmpa_dim
+ \tikz [ remember~picture , overlay ]
+ \coordinate [ name = nm - \int_use:N \g__nicematrix_env_int - col - 1 ] ;
+ \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 } }
+ {
+ &
+ \omit
+ \int_gincr:N \g_tmpa_int
+ \skip_horizontal:N \g_tmpa_dim
+ \__nicematrix_create_col_node:
+ }
+ &
+ \omit
+ \int_gincr:N \g_tmpa_int
+ \skip_horizontal:N \g_tmpa_dim
+ \skip_horizontal:n { - \arraycolsep }
+ \__nicematrix_create_col_node:
+ \skip_horizontal:N \arraycolsep
+ }
+ }
+\cs_new_protected:Npn \__nicematrix_create_col_node:
+ {
+ \tikz [ remember~picture , overlay ]
+ \coordinate
+ [
+ name = nm - \int_use:N \g__nicematrix_env_int -
+ col - \int_use:N \g_tmpa_int
+ ] ;
+ }
\tl_const:Nn \c__nicematrix_preamble_first_col_tl
{
>
@@ -1145,8 +1177,8 @@
\bool_if:nTF \g__nicematrix_medium_nodes_bool
{
\bool_if:NTF \g__nicematrix_large_nodes_bool
- \__nicematrix_create_medium_and_large_nodes:
- \__nicematrix_create_medium_nodes:
+ \__nicematrix_create_medium_and_large_nodes:
+ \__nicematrix_create_medium_nodes:
}
{ \bool_if:NT \g__nicematrix_large_nodes_bool \__nicematrix_create_large_nodes: }
\int_zero_new:N \l__nicematrix_initial_i_int
@@ -1632,18 +1664,30 @@
}
{
\int_set:Nn \l_tmpa_int
- { \dim_ratio:nn { \l__nicematrix_l_dim - 0.3 em } \l__nicematrix_inter_dots_dim }
+ {
+ \dim_ratio:nn
+ { \l__nicematrix_l_dim - \l__nicematrix_dotted_lines_margin_dim }
+ \l__nicematrix_inter_dots_dim
+ }
}
}
{
\bool_if:NTF \l__nicematrix_final_open_bool
{
\int_set:Nn \l_tmpa_int
- { \dim_ratio:nn { \l__nicematrix_l_dim - 0.3 em } \l__nicematrix_inter_dots_dim }
+ {
+ \dim_ratio:nn
+ { \l__nicematrix_l_dim - \l__nicematrix_dotted_lines_margin_dim }
+ \l__nicematrix_inter_dots_dim
+ }
}
{
\int_set:Nn \l_tmpa_int
- { \dim_ratio:nn { \l__nicematrix_l_dim - 0.6 em } \l__nicematrix_inter_dots_dim}
+ {
+ \dim_ratio:nn
+ { \l__nicematrix_l_dim - ( \l__nicematrix_dotted_lines_margin_dim * 2 ) }
+ \l__nicematrix_inter_dots_dim
+ }
}
}
\dim_set:Nn \l_tmpa_dim
@@ -2011,7 +2055,7 @@
\int_compare:nNnF \c@iRow = \c_zero_int
{
\int_compare:nNnF \c@iRow = \l__nicematrix_last_row_int
- \__nicematrix_vline_i:
+ \__nicematrix_vline_i:
}
}
}
@@ -2460,12 +2504,12 @@
\__nicematrix_msg_new:nn { Option~Transparent~suppressed }
{
The~option~'Transparent'~has~been~renamed~'transparent'.\\
- However,~you~can~go~on~for~this~time.
+ If~you~go~on~this~command~will~be~ignored.
}
\__nicematrix_msg_new:nn { Option~RenewMatrix~suppressed }
{
The~option~'RenewMatrix'~has~been~renamed~'renew-matrix'.\\
- However,~you~can~go~on~for~this~time.
+ If~you~go~on~this~command~will~be~ignored.
}
\__nicematrix_msg_new:nn { Bad~value~for~letter~for~dotted~lines }
{
@@ -2489,16 +2533,19 @@
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
+ dotted-lines-margin,~
+ end-of-row,~
exterior-arraycolsep,~
hlines,~
left-margin,~
letter-for-dotted-lines,~
+ light-syntax,~
nullify-dots,~
parallelize-diags,~
renew-dots,~
renew-matrix,~
right-margin,~
- small~
+ small,~
and~transparent
}
\__nicematrix_msg_new:nnn { Unknown~option~for~NiceArray }
@@ -2521,6 +2568,8 @@
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
+ dotted-lines-margin,~
+ end-of-row,~
extra-left-margin,~
extra-right-margin,~
first-col,~
@@ -2529,12 +2578,13 @@
last-col,~
last-row,~
left-margin,~
+ light-syntax,~
name,~
nullify-dots,~
parallelize-diags,~
renew-dots,~
right-margin,~
- small~
+ small,~
and~t.
}
\__nicematrix_msg_new:nnn { Unknown~option~for~NiceMatrix }
@@ -2555,6 +2605,8 @@
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
+ dotted-lines-margin,~
+ end-of-row,~
extra-left-margin,~
extra-right-margin,~
first-col,~
@@ -2563,11 +2615,12 @@
last-col,~
last-row,~
left-margin,~
+ light-syntax,~
name,~
nullify-dots,~
parallelize-diags,~
renew-dots,~
- right-margin~
+ right-margin,~
and~small.
}
\__nicematrix_msg_new:nnn { Duplicate~name }
@@ -2575,9 +2628,8 @@
The~name~'\l_keys_value_tl'~is~already~used~and~you~shouldn't~use~
the~same~environment~name~twice.~You~can~go~on,~but,~
maybe,~you~will~have~incorrect~results~especially~
- if~you~use~'columns-width=auto'.~If~you~use~nicematrix~inside~some~
- environments~of~amsmath,~this~error~may~be~an~artefact.~In~this~case,~
- use~the~option~'allow-duplicate-names'.\\
+ if~you~use~'columns-width=auto'.~If~you~don't~want~to~see~this~
+ message~again,~use~the~option~'allow-duplicate-names'.\\
For~a~list~of~the~names~already~used,~type~H~<return>. \\
}
{