summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty507
1 files changed, 234 insertions, 273 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
index 60dba930365..58aae5cd837 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.2a}
-\def\myfiledate{2019/09/21}
+\def\myfileversion{3.3}
+\def\myfiledate{2019/10/01}
\RequirePackage{tikz}
\usetikzlibrary{fit}
\RequirePackage{expl3}[2019/02/15]
@@ -67,12 +67,12 @@
}
}
\int_new:N \g__nm_env_int
+\int_new:N \g__nm_NiceMatrixBlock_int
\dim_new:N \l__nm_columns_width_dim
\seq_new:N \g__nm_names_seq
\bool_new:N \l__nm_in_env_bool
\bool_new:N \l__nm_NiceArray_bool
-\bool_new:N \g__nm_NiceArray_bool
\cs_new_protected:Npn \__nm_test_if_math_mode:
{
\if_mode_math: \else:
@@ -95,18 +95,16 @@
\dim_new:N \l__nm_radius_dim
\dim_set:Nn \l__nm_radius_dim { 0.53 pt }
\str_new:N \g__nm_type_env_str
+\tl_new:N \g__nm_code_after_tl
\int_new:N \l__nm_first_row_int
\int_set:Nn \l__nm_first_row_int 1
-\int_new:N \g__nm_first_row_int
\int_new:N \l__nm_first_col_int
\int_set:Nn \l__nm_first_col_int 1
-\int_new:N \g__nm_first_col_int
\int_new:N \l__nm_last_row_int
\int_set:Nn \l__nm_last_row_int { -2 }
-\int_new:N \g__nm_last_row_int
\bool_new:N \l__nm_last_row_without_value_bool
-\bool_new:N \g__nm_last_row_without_value_bool
-\bool_new:N \l__nm_last_col_bool
+\int_new:N \l__nm_last_col_int
+\int_set:Nn \l__nm_last_col_int { -1 }
\bool_new:N \g__nm_last_col_found_bool
\bool_new:N \c__nm_siunitx_loaded_bool
\AtBeginDocument
@@ -156,24 +154,29 @@
\bool_new:N \l__nm_nullify_dots_bool
\bool_new:N \l__nm_auto_columns_width_bool
\str_new:N \l__nm_name_str
-\str_new:N \g__nm_name_str
\bool_new:N \l__nm_extra_nodes_bool
\bool_new:N \g__nm_extra_nodes_bool
\dim_new:N \l__nm_left_margin_dim
\dim_new:N \l__nm_right_margin_dim
-\dim_new:N \g__nm_left_margin_dim
-\dim_new:N \g__nm_right_margin_dim
\dim_new:N \g__nm_width_last_col_dim
\dim_new:N \g__nm_width_first_col_dim
\dim_new:N \l__nm_extra_left_margin_dim
\dim_new:N \l__nm_extra_right_margin_dim
-\dim_new:N \g__nm_extra_right_margin_dim
\keys_define:nn { NiceMatrix / Global }
{
+ code-for-first-col .tl_set:N = \l__nm_code_for_first_col_tl ,
+ code-for-first-col .value_required:n = true ,
+ code-for-last-col .tl_set:N = \l__nm_code_for_last_col_tl ,
+ code-for-last-col .value_required:n = true ,
+ code-for-first-row .tl_set:N = \l__nm_code_for_first_row_tl ,
+ code-for-first-row .value_required:n = true ,
+ code-for-last-row .tl_set:N = \l__nm_code_for_last_row_tl ,
+ code-for-last-row .value_required:n = true ,
small .bool_set:N = \l__nm_small_bool ,
hlines .bool_set:N = \l__nm_hlines_bool ,
parallelize-diags .bool_set:N = \l__nm_parallelize_diags_bool ,
renew-dots .bool_set:N = \l__nm_renew_dots_bool ,
+ renew-dots .value_forbidden:n = true ,
nullify-dots .bool_set:N = \l__nm_nullify_dots_bool ,
create-extra-nodes .bool_set:N = \l__nm_extra_nodes_bool ,
left-margin .dim_set:N = \l__nm_left_margin_dim ,
@@ -187,17 +190,6 @@
extra-margin .meta:n =
{ extra-left-margin = #1 , extra-right-margin = #1 } ,
}
-\keys_define:nn { NiceMatrix / Code }
- {
- code-for-first-col .tl_set:N = \l__nm_code_for_first_col_tl ,
- code-for-first-col .value_required:n = true ,
- code-for-last-col .tl_set:N = \l__nm_code_for_last_col_tl ,
- code-for-last-col .value_required:n = true ,
- code-for-first-row .tl_set:N = \l__nm_code_for_first_row_tl ,
- code-for-first-row .value_required:n = true ,
- code-for-last-row .tl_set:N = \l__nm_code_for_last_row_tl ,
- code-for-last-row .value_required:n = true ,
- }
\keys_define:nn { NiceMatrix / Env }
{
columns-width .code:n =
@@ -213,15 +205,17 @@
\str_set_eq:NN \l__nm_name_str \l_tmpa_str ,
name .value_required:n = true ,
code-after .tl_gset:N = \g__nm_code_after_tl ,
- code-after .initial:n = \c_empty_tl ,
code-after .value_required:n = true ,
+ first-col .code:n = \int_zero:N \l__nm_first_col_int ,
+ first-row .code:n = \int_zero:N \l__nm_first_row_int ,
+ last-row .int_set:N = \l__nm_last_row_int ,
+ last-row .default:n = -1 ,
}
\keys_define:nn { NiceMatrix }
{
NiceMatrixOptions .inherit:n =
{
NiceMatrix / Global ,
- NiceMatrix / Code
} ,
NiceMatrix .inherit:n =
{
@@ -232,13 +226,11 @@
{
NiceMatrix / Global ,
NiceMatrix / Env ,
- NiceMatrix / Code
} ,
pNiceArray .inherit:n =
{
NiceMatrix / Global ,
NiceMatrix / Env ,
- NiceMatrix / Code
}
}
\keys_define:nn { NiceMatrix / NiceMatrixOptions }
@@ -267,33 +259,39 @@
{ \__nm_error:n { Bad~value~for~letter~for~dotted~lines } }
} ,
letter-for-dotted-lines .value_required:n = true ,
- letter-for-dotted-lines .initial:n = \c_colon_str ,
unknown .code:n = \__nm_error:n { Unknown~key~for~NiceMatrixOptions }
}
+\str_new:N \l__nm_letter_for_dotted_lines_str
+\str_set_eq:NN \l__nm_letter_for_dotted_lines_str \c_colon_str
\NewDocumentCommand \NiceMatrixOptions { m }
{ \keys_set:nn { NiceMatrix / NiceMatrixOptions } { #1 } }
\keys_define:nn { NiceMatrix / NiceMatrix }
- { unknown .code:n = \__nm_error:n { Unknown~option~for~NiceMatrix } }
+ {
+ last-col .code:n = \tl_if_empty:nTF {#1}
+ { \__nm_error:n { last-col~empty~for~NiceMatrix } }
+ { \int_set:Nn \l__nm_last_col_int { #1 } } ,
+ unknown .code:n = \__nm_error:n { Unknown~option~for~NiceMatrix }
+ }
\keys_define:nn { NiceMatrix / NiceArray }
{
c .code:n = \str_set:Nn \l__nm_pos_env_str c ,
t .code:n = \str_set:Nn \l__nm_pos_env_str t ,
b .code:n = \str_set:Nn \l__nm_pos_env_str b ,
- first-col .code:n = \int_zero:N \l__nm_first_col_int ,
- last-col .bool_set:N = \l__nm_last_col_bool ,
- first-row .code:n = \int_zero:N \l__nm_first_row_int ,
- last-row .int_set:N = \l__nm_last_row_int ,
- last-row .default:n = -1 ,
+ last-col .code:n = \tl_if_empty:nF {#1}
+ { \__nm_error:n { last-col~non~empty~for~NiceArray } }
+ \int_zero:N \l__nm_last_col_int ,
unknown .code:n = \__nm_error:n { Unknown~option~for~NiceArray }
}
\keys_define:nn { NiceMatrix / pNiceArray }
{
first-col .code:n = \int_zero:N \l__nm_first_col_int ,
- last-col .bool_set:N = \l__nm_last_col_bool ,
+ last-col .code:n = \tl_if_empty:nF {#1}
+ { \__nm_error:n { last-col~non~empty~for~NiceArray } }
+ \int_zero:N \l__nm_last_col_int ,
first-row .code:n = \int_zero:N \l__nm_first_row_int ,
last-row .int_set:N = \l__nm_last_row_int ,
last-row .default:n = -1 ,
- unknown .code:n = \__nm_error:n { Unknown~option~for~pNiceArray }
+ unknown .code:n = \__nm_error:n { Unknown~option~for~NiceMatrix }
}
\cs_new_protected:Nn \__nm_Cell:
{
@@ -465,7 +463,7 @@
{
\int_compare:nNnT \g__nm_row_int > { -1 }
{
- \int_compare:nNnF \g__nm_row_int = \g__nm_last_row_int
+ \int_compare:nNnF \g__nm_row_int = \l__nm_last_row_int
{
\hrule \@height \arrayrulewidth
\skip_vertical:n { - \arrayrulewidth }
@@ -475,41 +473,13 @@
}
\cs_new_protected:Npn \__nm_pre_array:
{
+ \tl_clear:N \g__nm_code_after_tl
\bool_if:NT \l__nm_small_bool
{
\cs_set:Npn \arraystretch { 0.47 }
\dim_set:Nn \arraycolsep { 1.45 pt }
}
- \bool_if:NT \l__nm_auto_columns_width_bool
- {
- \group_insert_after:N \__nm_write_max_cell_width:
- \cs_if_free:cTF { __nm_max_cell_width_ \int_use:N \g__nm_env_int }
- { \dim_zero:N \l__nm_columns_width_dim }
- {
- \dim_set:Nx \l__nm_columns_width_dim
- { \use:c { __nm_max_cell_width _ \int_use:N \g__nm_env_int } }
- }
- \str_if_empty:NF \l__nm_name_str
- {
- \cs_if_free:cF { __nm_max_cell_width_ \l__nm_name_str }
- {
- \dim_set:Nx \l__nm_columns_width_dim
- { \use:c { __nm_max_cell_width_ \l__nm_name_str } }
- }
- }
- }
\bool_gset_eq:NN \g__nm_extra_nodes_bool \l__nm_extra_nodes_bool
- \dim_gset_eq:NN \g__nm_left_margin_dim \l__nm_left_margin_dim
- \dim_gset_eq:NN \g__nm_right_margin_dim \l__nm_right_margin_dim
- \dim_gset_eq:NN \g__nm_extra_right_margin_dim \l__nm_extra_right_margin_dim
- \int_gset_eq:NN \g__nm_last_row_int \l__nm_last_row_int
- \tl_gset_eq:NN \g__nm_name_str \l__nm_name_str
- \int_gset_eq:NN \g__nm_first_row_int \l__nm_first_row_int
- \int_gset_eq:NN \g__nm_first_col_int \l__nm_first_col_int
- \bool_gset_eq:NN \g__nm_NiceArray_bool \l__nm_NiceArray_bool
- \bool_gset_eq:NN \g__nm_last_row_without_value_bool
- \l__nm_last_row_without_value_bool
- \bool_gset_eq:NN \g__nm_small_bool \l__nm_small_bool
\cs_set:Npn \ialign
{
\bool_if:NTF \c__nm_colortbl_loaded_bool
@@ -542,17 +512,9 @@
}
\halign
}
- \dim_compare:nNnTF \l__nm_columns_width_dim = \c_zero_dim
- {
- \newcolumntype L { > \__nm_Cell: l < \__nm_end_Cell: }
- \newcolumntype C { > \__nm_Cell: c < \__nm_end_Cell: }
- \newcolumntype R { > \__nm_Cell: r < \__nm_end_Cell: }
- }
- {
- \newcolumntype L { w l { \dim_use:N \l__nm_columns_width_dim } }
- \newcolumntype C { w c { \dim_use:N \l__nm_columns_width_dim } }
- \newcolumntype R { w r { \dim_use:N \l__nm_columns_width_dim } }
- }
+ \newcolumntype L { > \__nm_Cell: l < \__nm_end_Cell: }
+ \newcolumntype C { > \__nm_Cell: c < \__nm_end_Cell: }
+ \newcolumntype R { > \__nm_Cell: r < \__nm_end_Cell: }
\cs_set_eq:NN \Ldots \__nm_Ldots
\cs_set_eq:NN \Cdots \__nm_Cdots
\cs_set_eq:NN \Vdots \__nm_Vdots
@@ -622,7 +584,6 @@
\bool_set_true:N \l__nm_in_env_bool
\cs_if_exist:NT \tikz@library@external@loaded
{ \tikzset { external / export = false } }
- \group_insert_after:N \__nm_after_array:
\int_gincr:N \g__nm_env_int
\bool_if:NF \l__nm_block_auto_columns_width_bool
{ \dim_gzero_new:N \g__nm_max_cell_width_dim }
@@ -634,7 +595,7 @@
\int_compare:nNnT \l__nm_last_row_int = { -1 }
{
\bool_set_true:N \l__nm_last_row_without_value_bool
- \str_if_empty:NTF \g__nm_name_str
+ \str_if_empty:NTF \l__nm_name_str
{
\cs_if_exist:cT { __nm_last_row_ \int_use:N \g__nm_env_int }
{
@@ -643,16 +604,16 @@
}
}
{
- \cs_if_exist:cT { __nm_last_row_ \g__nm_name_str }
+ \cs_if_exist:cT { __nm_last_row_ \l__nm_name_str }
{
\int_set:Nn \l__nm_last_row_int
- { \use:c { __nm_last_row_ \g__nm_name_str } }
+ { \use:c { __nm_last_row_ \l__nm_name_str } }
}
}
}
\__nm_pre_array:
- \dim_zero_new:N \g__nm_left_delim_dim
- \dim_zero_new:N \g__nm_right_delim_dim
+ \dim_gzero_new:N \g__nm_left_delim_dim
+ \dim_gzero_new:N \g__nm_right_delim_dim
\bool_if:NTF \l__nm_NiceArray_bool
{
\dim_gset:Nn \g__nm_left_delim_dim { 2 \arraycolsep }
@@ -690,7 +651,7 @@
{ \tl_put_left:Nn \l_tmpa_tl { @ { } } }
}
}
- \bool_if:NTF \l__nm_last_col_bool
+ \int_compare:nNnTF \l__nm_last_col_int > { -1 }
{ \tl_put_right:NV \l_tmpa_tl \c__nm_preamble_last_col_tl }
{
\bool_if:NT \l__nm_NiceArray_bool
@@ -706,19 +667,61 @@
\exp_args:NV \__nm_array: \l_tmpa_tl
}
{
+ \bool_if:nT
+ {
+ ( \l__nm_auto_columns_width_bool && ! \l__nm_block_auto_columns_width_bool)
+ || \dim_compare_p:nNn \l__nm_columns_width_dim > \c_zero_dim
+ }
+ {
+ \crcr
+ \int_compare:nNnT \l__nm_first_col_int = 0 { \omit & }
+ \omit
+ \tikz [ remember~picture , overlay ]
+ \coordinate [ name = nm - \int_use:N \g__nm_env_int - col - 0 ] ;
+ \bool_if:nTF
+ {
+ \l__nm_auto_columns_width_bool
+ && ! \l__nm_block_auto_columns_width_bool
+ }
+ {
+ \dim_gset:Nn \g_tmpa_dim
+ { \g__nm_max_cell_width_dim + 2 \arraycolsep }
+ }
+ {
+ \dim_gset:Nn \g_tmpa_dim
+ { \l__nm_columns_width_dim + 2 \arraycolsep }
+ }
+ \skip_horizontal:N \g_tmpa_dim
+ \int_gset:Nn \g_tmpa_int 1
+ \bool_if:nTF \g__nm_last_col_found_bool
+ { \prg_replicate:nn { \g__nm_col_total_int - 2 } }
+ { \prg_replicate:nn { \g__nm_col_total_int - 1 } }
+ {
+ &
+ \omit
+ \int_gincr:N \g_tmpa_int
+ \skip_horizontal:N \g_tmpa_dim
+ \tikz [ remember~picture , overlay ]
+ \coordinate
+ [
+ name = nm - \int_use:N \g__nm_env_int -
+ col - \int_use:N \g_tmpa_int
+ ] ;
+ }
+ }
\endarray
\c_math_toggle_token
- \skip_horizontal:n \g__nm_right_margin_dim
- \skip_horizontal:n \g__nm_extra_right_margin_dim
+ \skip_horizontal:n \l__nm_right_margin_dim
+ \skip_horizontal:n \l__nm_extra_right_margin_dim
\hbox_set_end:
- \int_compare:nNnT \g__nm_last_row_int > { -2 }
+ \int_compare:nNnT \l__nm_last_row_int > { -2 }
{
- \bool_if:NF \g__nm_last_row_without_value_bool
+ \bool_if:NF \l__nm_last_row_without_value_bool
{
- \int_compare:nNnF \g__nm_last_row_int = \g__nm_row_int
+ \int_compare:nNnF \l__nm_last_row_int = \g__nm_row_int
{
\__nm_error:n { Wrong~last~row }
- \int_gset_eq:NN \g__nm_last_row_int \g__nm_row_int
+ \int_gset_eq:NN \l__nm_last_row_int \g__nm_row_int
}
}
}
@@ -742,14 +745,14 @@
}
}
{ \dim_zero:N \l_tmpb_dim }
- \int_compare:nNnT \g__nm_first_col_int = \c_zero_int
+ \int_compare:nNnT \l__nm_first_col_int = \c_zero_int
{
\skip_horizontal:n \arraycolsep
\skip_horizontal:n \g__nm_width_first_col_dim
}
- \bool_if:NTF \g__nm_NiceArray_bool
+ \bool_if:NTF \l__nm_NiceArray_bool
{
- \int_compare:nNnT \g__nm_first_row_int = \c_zero_int
+ \int_compare:nNnT \l__nm_first_row_int = \c_zero_int
{
\str_if_eq:VnTF \l__nm_pos_env_str { t }
{
@@ -758,7 +761,7 @@
}
}
{
- \bool_if:NT \g__nm_last_row_int
+ \int_compare:nNnT \l__nm_last_row_int > 0
{
\str_if_eq:VnT \l__nm_pos_env_str { b }
{
@@ -800,6 +803,7 @@
\skip_horizontal:n \g__nm_width_last_col_dim
\skip_horizontal:n \arraycolsep
}
+ \__nm_after_array:
}
\tl_const:Nn \c__nm_preamble_first_col_tl
{
@@ -930,123 +934,69 @@
{ \endNiceArrayWithDelims }
\NewDocumentEnvironment { pNiceArray } { }
{
- \str_gset:Nn \g__nm_type_env_str { pNiceArray }
+ \str_if_empty:NT \g__nm_type_env_str
+ { \str_gset:Nn \g__nm_type_env_str { pNiceArray } }
\__nm_test_if_math_mode:
\NiceArrayWithDelims ( )
}
{ \endNiceArrayWithDelims }
\NewDocumentEnvironment { bNiceArray } { }
{
- \str_gset:Nn \g__nm_type_env_str { bNiceArray }
+ \str_if_empty:NT \g__nm_type_env_str
+ { \str_gset:Nn \g__nm_type_env_str { NiceArray } }
\__nm_test_if_math_mode:
\NiceArrayWithDelims [ ]
}
{ \endNiceArrayWithDelims }
\NewDocumentEnvironment { BNiceArray } { }
{
- \str_gset:Nn \g__nm_type_env_str { BNiceArray }
+ \str_if_empty:NT \g__nm_type_env_str
+ { \str_gset:Nn \g__nm_type_env_str { BNiceArray } }
\__nm_test_if_math_mode:
\NiceArrayWithDelims \{ \}
}
{ \endNiceArrayWithDelims }
\NewDocumentEnvironment { vNiceArray } { }
{
- \str_gset:Nn \g__nm_type_env_str { vNiceArray }
+ \str_if_empty:NT \g__nm_type_env_str
+ { \str_gset:Nn \g__nm_type_env_str { vNiceArray } }
\__nm_test_if_math_mode:
\NiceArrayWithDelims | |
}
{ \endNiceArrayWithDelims }
\NewDocumentEnvironment { VNiceArray } { }
{
- \str_gset:Nn \g__nm_type_env_str { VNiceArray }
+ \str_if_empty:NT \g__nm_type_env_str
+ { \str_gset:Nn \g__nm_type_env_str { VNiceArray } }
\__nm_test_if_math_mode:
\NiceArrayWithDelims \| \|
}
{ \endNiceArrayWithDelims }
-\NewDocumentEnvironment { NiceMatrix } { ! O { } }
+\cs_new_protected:Npn \__nm_define_env:n #1
{
- \str_if_empty:NT \g__nm_type_env_str
- { \str_gset:Nn \g__nm_type_env_str { NiceMatrix } }
- \__nm_test_if_math_mode:
- \bool_if:NT \l__nm_in_env_bool { \__nm_fatal:n { Yet~in~env } }
- \bool_set_true:N \l__nm_in_env_bool
- \cs_if_exist:NT \tikz@library@external@loaded
- { \tikzset { external / export = false } }
- \group_insert_after:N \__nm_after_array:
- \int_gincr:N \g__nm_env_int
- \bool_if:NF \l__nm_block_auto_columns_width_bool
- { \dim_gzero_new:N \g__nm_max_cell_width_dim }
- \keys_set:nn { NiceMatrix / NiceMatrix } { #1 }
- \__nm_pre_array:
- \skip_horizontal:n { - \arraycolsep }
- \skip_horizontal:n \l__nm_left_margin_dim
- \skip_horizontal:n \l__nm_extra_left_margin_dim
- \str_set:Nn \l__nm_pos_env_str c
- \bool_set_false:N \l__nm_exterior_arraycolsep_bool
- \__nm_array: { * \c@MaxMatrixCols C }
- }
- {
- \endarray
- \skip_horizontal:n { - \arraycolsep }
- \skip_horizontal:n \g__nm_right_margin_dim
- \skip_horizontal:n \g__nm_extra_right_margin_dim
- }
-\NewDocumentEnvironment { pNiceMatrix } { }
- {
- \str_gset:Nn \g__nm_type_env_str { pNiceMatrix }
- \__nm_test_if_math_mode:
- \left( \begin{NiceMatrix}
- }
- { \end{NiceMatrix} \right) }
-\NewDocumentEnvironment { bNiceMatrix } { }
- {
- \str_gset:Nn \g__nm_type_env_str { bNiceMatrix }
- \__nm_test_if_math_mode:
- \left[ \begin{NiceMatrix}
- }
- { \end{NiceMatrix} \right] }
-\NewDocumentEnvironment { BNiceMatrix } { }
- {
- \str_gset:Nn \g__nm_type_env_str { BNiceMatrix }
- \__nm_test_if_math_mode:
- \left\{ \begin{NiceMatrix}
- }
- { \end{NiceMatrix} \right\} }
-\NewDocumentEnvironment { vNiceMatrix } { }
- {
- \str_gset:Nn \g__nm_type_env_str { vNiceMatrix }
- \__nm_test_if_math_mode:
- \left\lvert \begin{NiceMatrix}
- }
- { \end{NiceMatrix} \right\rvert }
-\NewDocumentEnvironment { VNiceMatrix } { }
- {
- \str_gset:Nn \g__nm_type_env_str { VNiceMatrix }
- \__nm_test_if_math_mode:
- \left\lVert \begin{NiceMatrix}
- }
- { \end{NiceMatrix} \right\rVert }
-\cs_new_protected:Nn \__nm_write_max_cell_width:
- {
- \bool_if:NF \l__nm_block_auto_columns_width_bool
+ \NewDocumentEnvironment { #1 NiceMatrix } { ! O { } }
{
- \iow_now:Nn \@mainaux \ExplSyntaxOn
- \iow_now:Nx \@mainaux
+ \str_gset:Nn \g__nm_type_env_str { #1 NiceMatrix }
+ \keys_set:nn { NiceMatrix / NiceMatrix } { ##1 }
+ \begin { #1 NiceArray }
{
- \cs_gset:cpn { __nm_max_cell_width_ \int_use:N \g__nm_env_int }
- { \dim_use:N \g__nm_max_cell_width_dim }
- }
- \str_if_empty:NF \g__nm_name_str
- {
- \iow_now:Nx \@mainaux
+ *
{
- \cs_gset:cpn { __nm_max_cell_width_ \g__nm_name_str }
- { \dim_use:N \g__nm_max_cell_width_dim }
+ \int_compare:nNnTF \l__nm_last_col_int = { -1 }
+ \c@MaxMatrixCols
+ { \int_eval:n { \l__nm_last_col_int - 1 } }
}
+ C
}
- \iow_now:Nn \@mainaux \ExplSyntaxOff
}
+ { \end { #1 NiceArray } }
}
+\__nm_define_env:n { }
+\__nm_define_env:n p
+\__nm_define_env:n b
+\__nm_define_env:n B
+\__nm_define_env:n v
+\__nm_define_env:n V
\prg_set_conditional:Npnn \__nm_if_not_empty_cell:nn #1 #2 { T , TF }
{
\bool_set_false:N \l_tmpa_bool
@@ -1111,9 +1061,9 @@
\int_gset_eq:NN \g__nm_col_int \g__nm_col_total_int
\bool_if:nT \g__nm_last_col_found_bool { \int_gdecr:N \g__nm_col_int }
\int_gset_eq:NN \g__nm_row_total_int \g__nm_row_int
- \int_compare:nNnT \g__nm_last_row_int > { -1 }
+ \int_compare:nNnT \l__nm_last_row_int > { -1 }
{ \int_gsub:Nn \g__nm_row_int \c_one_int }
- \bool_if:NT \g__nm_last_row_without_value_bool
+ \bool_if:NT \l__nm_last_row_without_value_bool
{
\iow_now:Nn \@mainaux \ExplSyntaxOn
\iow_now:Nx \@mainaux
@@ -1121,11 +1071,11 @@
\cs_gset:cpn { __nm_last_row_ \int_use:N \g__nm_env_int }
{ \int_use:N \g__nm_row_total_int }
}
- \str_if_empty:NF \g__nm_name_str
+ \str_if_empty:NF \l__nm_name_str
{
\iow_now:Nx \@mainaux
{
- \cs_gset:cpn { __nm_last_row_ \g__nm_name_str }
+ \cs_gset:cpn { __nm_last_row_ \l__nm_name_str }
{ \int_use:N \g__nm_row_total_int }
}
}
@@ -1147,7 +1097,7 @@
\int_zero_new:N \l__nm_final_j_int
\bool_set_false:N \l__nm_initial_open_bool
\bool_set_false:N \l__nm_final_open_bool
- \bool_if:NT \g__nm_small_bool
+ \bool_if:NT \l__nm_small_bool
{
\dim_set:Nn \l__nm_radius_dim { 0.37 pt }
\dim_set:Nn \l__nm_inter_dots_dim { 0.25 em }
@@ -1618,8 +1568,9 @@
{
( \g__nm_x_final_dim - \g__nm_x_initial_dim ) *
\dim_ratio:nn
- { \l__nm_l_dim - \l__nm_inter_dots_dim * \l_tmpa_int } { \l__nm_l_dim * 2 } *
- \l_tmpb_int
+ { \l__nm_l_dim - \l__nm_inter_dots_dim * \l_tmpa_int }
+ { \l__nm_l_dim * 2 }
+ * \l_tmpb_int
}
\dim_gadd:Nn \g__nm_y_initial_dim
{
@@ -1816,7 +1767,7 @@
\hbox_to_wd:nn
{
\l_tmpa_dim + 2 \arraycolsep
- - \l__nm_left_margin_dim - \g__nm_right_margin_dim
+ - \l__nm_left_margin_dim - \l__nm_right_margin_dim
}
\__nm_dotfill:
}
@@ -1860,6 +1811,16 @@
\dim_gadd:Nn \g__nm_x_initial_dim \arraycolsep
\dim_gadd:Nn \g__nm_x_final_dim \arraycolsep
}
+ \cs_if_exist:cT
+ { pgf@sh@ns@nm -\int_use:N \g__nm_env_int - col - #1 }
+ {
+ \begin { tikzpicture } [ remember~picture ]
+ \tikz@parse@node\pgfutil@firstofone
+ ( col - #1 )
+ \dim_gset:Nn \g__nm_x_initial_dim \pgf@x
+ \dim_gset:Nn \g__nm_x_final_dim \pgf@x
+ \end { tikzpicture }
+ }
\__nm_draw_tikz_line:
}
}
@@ -1925,21 +1886,27 @@
}
\NewDocumentEnvironment { NiceMatrixBlock } { ! O { } }
{
+ \int_gincr:N \g__nm_NiceMatrixBlock_int
+ \dim_zero:N \l__nm_columns_width_dim
\keys_set:nn { NiceMatrix / NiceMatrixBlock } { #1 }
- \int_zero_new:N \l__nm_first_env_block_int
- \int_set:Nn \l__nm_first_env_block_int { \g__nm_env_int + 1 }
+ \bool_if:NT \l__nm_block_auto_columns_width_bool
+ {
+ \cs_if_exist:cT { __nm_max_cell_width_ \int_use:N \g__nm_NiceMatrixBlock_int }
+ {
+ \dim_set:Nx \l__nm_columns_width_dim
+ { \use:c { __nm_max_cell_width _ \int_use:N \g__nm_NiceMatrixBlock_int } }
+ }
+ }
}
{
\bool_if:NT \l__nm_block_auto_columns_width_bool
{
\iow_now:Nn \@mainaux \ExplSyntaxOn
- \int_step_inline:nnnn \l__nm_first_env_block_int 1 \g__nm_env_int
+ \iow_now:Nx \@mainaux
{
- \iow_now:Nx \@mainaux
- {
- \cs_gset:cpn { __nm _ max _ cell _ width _ ##1 }
- { \dim_use:N \g__nm_max_cell_width_dim }
- }
+ \cs_gset:cpn
+ { __nm _ max _ cell _ width _ \int_use:N \g__nm_NiceMatrixBlock_int }
+ { \dim_use:N \g__nm_max_cell_width_dim }
}
\iow_now:Nn \@mainaux \ExplSyntaxOff
}
@@ -1949,24 +1916,24 @@
\cs_new_protected:Nn \__nm_create_extra_nodes:
{
\begin { tikzpicture } [ remember~picture , overlay ]
- \int_step_variable:nnNn \g__nm_first_row_int \g__nm_row_total_int \__nm_i:
+ \int_step_variable:nnNn \l__nm_first_row_int \g__nm_row_total_int \__nm_i:
{
\dim_zero_new:c { l__nm_row_\__nm_i: _min_dim }
\dim_set_eq:cN { l__nm_row_\__nm_i: _min_dim } \c_max_dim
\dim_zero_new:c { l__nm_row_\__nm_i: _max_dim }
\dim_set:cn { l__nm_row_\__nm_i: _max_dim } { - \c_max_dim }
}
- \int_step_variable:nnNn \g__nm_first_col_int \g__nm_col_total_int \__nm_j:
+ \int_step_variable:nnNn \l__nm_first_col_int \g__nm_col_total_int \__nm_j:
{
\dim_zero_new:c { l__nm_column_\__nm_j: _min_dim }
\dim_set_eq:cN { l__nm_column_\__nm_j: _min_dim } \c_max_dim
\dim_zero_new:c { l__nm_column_\__nm_j: _max_dim }
\dim_set:cn { l__nm_column_\__nm_j: _max_dim } { - \c_max_dim }
}
- \int_step_variable:nnNn \g__nm_first_row_int \g__nm_row_total_int \__nm_i:
+ \int_step_variable:nnNn \l__nm_first_row_int \g__nm_row_total_int \__nm_i:
{
\int_step_variable:nnNn
- \g__nm_first_col_int \g__nm_col_total_int \__nm_j:
+ \l__nm_first_col_int \g__nm_col_total_int \__nm_j:
{ \cs_if_exist:cT
{ pgf@sh@ns@nm - \int_use:N \g__nm_env_int - \__nm_i: - \__nm_j: }
{
@@ -1994,8 +1961,8 @@
}
\tikzset { name~suffix = -medium }
\__nm_create_nodes:
- \int_set:Nn \g__nm_first_row_int 1
- \int_set:Nn \g__nm_first_col_int 1
+ \int_set:Nn \l__nm_first_row_int 1
+ \int_set:Nn \l__nm_first_col_int 1
\int_step_variable:nNn { \g__nm_row_int - 1 } \__nm_i:
{
\dim_set:cn { l__nm_row _ \__nm_i: _ min _ dim }
@@ -2026,10 +1993,10 @@
}
\dim_sub:cn
{ l__nm_column _ 1 _ min _ dim }
- \g__nm_left_margin_dim
+ \l__nm_left_margin_dim
\dim_add:cn
{ l__nm_column _ \int_use:N \g__nm_col_int _ max _ dim }
- \g__nm_right_margin_dim
+ \l__nm_right_margin_dim
\tikzset { name~suffix = -large }
\__nm_create_nodes:
\end{tikzpicture}
@@ -2053,9 +2020,9 @@
}
\cs_new_protected:Nn \__nm_create_nodes:
{
- \int_step_variable:nnNn \g__nm_first_row_int \g__nm_row_total_int \__nm_i:
+ \int_step_variable:nnNn \l__nm_first_row_int \g__nm_row_total_int \__nm_i:
{
- \int_step_variable:nnNn \g__nm_first_col_int \g__nm_col_total_int \__nm_j:
+ \int_step_variable:nnNn \l__nm_first_col_int \g__nm_col_total_int \__nm_j:
{
\coordinate ( __nm~south~west )
at ( \dim_use:c { l__nm_column_ \__nm_j: _min_dim } ,
@@ -2070,13 +2037,13 @@
inner~sep = \c_zero_dim ,
name = nm - \int_use:N \g__nm_env_int - \__nm_i: - \__nm_j: ,
alias =
- \str_if_empty:NF \g__nm_name_str
- { \g__nm_name_str - \__nm_i: - \__nm_j: }
+ \str_if_empty:NF \l__nm_name_str
+ { \l__nm_name_str - \__nm_i: - \__nm_j: }
]
;
}
}
- \__nm_seq_mapthread_function:NNN
+ \seq_mapthread_function:NNN
\g__nm_multicolumn_cells_seq
\g__nm_multicolumn_sizes_seq
\__nm_node_for_multicolumn:nn
@@ -2106,7 +2073,7 @@
inner~sep = \c_zero_dim ,
name = nm - \int_use:N \g__nm_env_int - \__nm_i: - \__nm_j: ,
alias =
- \str_if_empty:NF \g__nm_name_str { \g__nm_name_str - \__nm_i: - \__nm_j: }
+ \str_if_empty:NF \l__nm_name_str { \l__nm_name_str - \__nm_i: - \__nm_j: }
]
;
}
@@ -2172,7 +2139,48 @@
\end{tikzpicture}
}
}
-\ProcessKeysOptions { NiceMatrix }
+\cs_set_protected:Npn \__nm_renew_matrix:
+ {
+ \RenewDocumentEnvironment { pmatrix } { }
+ { \pNiceMatrix }
+ { \endpNiceMatrix }
+ \RenewDocumentEnvironment { vmatrix } { }
+ { \vNiceMatrix }
+ { \endvNiceMatrix }
+ \RenewDocumentEnvironment { Vmatrix } { }
+ { \VNiceMatrix }
+ { \endVNiceMatrix }
+ \RenewDocumentEnvironment { bmatrix } { }
+ { \bNiceMatrix }
+ { \endbNiceMatrix }
+ \RenewDocumentEnvironment { Bmatrix } { }
+ { \BNiceMatrix }
+ { \endBNiceMatrix }
+ }
+\keys_define:nn { NiceMatrix / Package }
+ {
+ renew-dots .bool_set:N = \l__nm_renew_dots_bool ,
+ renew-dots .value_forbidden:n = true ,
+ renew-matrix .code:n = \__nm_renew_matrix: ,
+ renew-matrix .value_forbidden:n = true ,
+ transparent .meta:n = { renew-dots , renew-matrix } ,
+ transparent .value_forbidden:n = true,
+ }
+\ProcessKeysOptions { NiceMatrix / Package }
+\__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).\\
+ 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~
+ 'last-col'~without~value.~You~must~give~the~number~of~that~last~column.\\
+ If~you~go~on~this~option~will~be~ignored.
+ }
\__nm_msg_new:nn { Block~too~large }
{
You~try~to~draw~a~block~in~the~cell~#1-#2~of~your~matrix~but~the~matrix~is~
@@ -2187,7 +2195,7 @@
}
\__nm_msg_new:nn { Wrong~last~row }
{
- You~have~used~'last-row=\int_use:N \g__nm_last_row_int'~but~your~environment~
+ 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 \g__nm_row_int\
rows.~If~you~go~on,~the~value~of~\int_use:N \g__nm_row_int\
will~be~used~for~last~row.~You~can~avoid~this~problem~by~using~'last-row'~
@@ -2245,7 +2253,7 @@
renew-dots,~
renew-matrix,~
right-margin,~
- small,~
+ small~
and~transparent
}
\__nm_msg_new:nnn { Unknown~option~for~NiceArray }
@@ -2268,42 +2276,23 @@
create-extra-nodes,~
extra-left-margin,~
extra-right-margin,~
+ first-col,~
+ first-row,~
hlines,~
+ last-col,~
+ last-row,~
left-margin,~
name,~
nullify-dots,~
parallelize-diags,~
renew-dots,~
right-margin,~
- small,~
+ small~
and~t.
}
\__nm_msg_new:nnn { Unknown~option~for~NiceMatrix }
{
The~option~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~environment~
- \{NiceMatrix\}~and~its~variants. \\
- If~you~go~on,~it~will~be~ignored. \\
- For~a~list~of~the~available~options,~type~H~<return>.
- }
- {
- The~available~options~are~(in~alphabetic~order):~
- code-after,~
- columns-width,~
- create-extra-nodes,~
- extra-left-margin,~
- extra-right-margin,~
- hlines,~
- left-margin,~
- name,~
- nullify-dots,~
- parallelize-diags,~
- renew-dots,~
- right-margin~
- and~small.
- }
-\__nm_msg_new:nnn { Unknown~option~for~pNiceArray }
- {
- The~option~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~environment~
\{\g__nm_type_env_str\}. \\
If~you~go~on,~it~will~be~ignored. \\
For~a~list~of~the~available~options,~type~H~<return>.
@@ -2321,9 +2310,9 @@
extra-right-margin,~
first-col,~
first-row,~
+ hlines,~
last-col,~
last-row,~
- hlines,~
left-margin,~
name,~
nullify-dots,~
@@ -2364,82 +2353,53 @@
first~position~of~the~preamble~of~the~environment~\{\g__nm_type_env_str\}. \\
If~you~go~on,~this~dotted~line~will~be~ignored.
}
-\cs_new:Npn \__nm_seq_mapthread_function:NNN #1 #2 #3
- {
- \group_begin:
- \int_step_inline:nn { \seq_count:N #1 }
- {
- \seq_pop:NN #1 \l_tmpa_tl
- \seq_pop:NN #2 \l_tmpb_tl
- \exp_args:NVV #3 \l_tmpa_tl \l_tmpb_tl
- }
- \group_end:
- }
-\cs_set_protected:Npn \__nm_renew_matrix:
- {
- \RenewDocumentEnvironment { pmatrix } { }
- { \pNiceMatrix }
- { \endpNiceMatrix }
- \RenewDocumentEnvironment { vmatrix } { }
- { \vNiceMatrix }
- { \endvNiceMatrix }
- \RenewDocumentEnvironment { Vmatrix } { }
- { \VNiceMatrix }
- { \endVNiceMatrix }
- \RenewDocumentEnvironment { bmatrix } { }
- { \bNiceMatrix }
- { \endbNiceMatrix }
- \RenewDocumentEnvironment { Bmatrix } { }
- { \BNiceMatrix }
- { \endBNiceMatrix }
- }
\NewDocumentEnvironment { pNiceArrayC } { }
{
- \bool_set_true:N \l__nm_last_col_bool
+ \int_set:Nn \l__nm_last_col_int \c_zero_dim
\pNiceArray
}
{ \endpNiceArray }
\NewDocumentEnvironment { bNiceArrayC } { }
{
- \bool_set_true:N \l__nm_last_col_bool
+ \int_set:Nn \l__nm_last_col_int \c_zero_dim
\bNiceArray
}
{ \endbNiceArray }
\NewDocumentEnvironment { BNiceArrayC } { }
{
- \bool_set_true:N \l__nm_last_col_bool
+ \int_set:Nn \l__nm_last_col_int \c_zero_dim
\BNiceArray
}
{ \endBNiceArray }
\NewDocumentEnvironment { vNiceArrayC } { }
{
- \bool_set_true:N \l__nm_last_col_bool
+ \int_set:Nn \l__nm_last_col_int \c_zero_dim
\vNiceArray
}
{ \endvNiceArray }
\NewDocumentEnvironment { VNiceArrayC } { }
{
- \bool_set_true:N \l__nm_last_col_bool
+ \int_set:Nn \l__nm_last_col_int \c_zero_dim
\VNiceArray
}
{ \endVNiceArray }
\NewDocumentEnvironment { pNiceArrayRC } { }
{
- \bool_set_true:N \l__nm_last_col_bool
+ \int_set:Nn \l__nm_last_col_int \c_zero_dim
\int_set:Nn \l__nm_first_row_int \c_zero_int
\pNiceArray
}
{ \endpNiceArray }
\NewDocumentEnvironment { bNiceArrayRC } { }
{
- \bool_set_true:N \l__nm_last_col_bool
+ \int_set:Nn \l__nm_last_col_int \c_zero_dim
\int_set:Nn \l__nm_first_row_int \c_zero_int
\bNiceArray
}
{ \endbNiceArray }
\NewDocumentEnvironment { BNiceArrayRC } { }
{
- \bool_set_true:N \l__nm_last_col_bool
+ \int_set:Nn \l__nm_last_col_int \c_zero_dim
\int_set:Nn \l__nm_first_row_int \c_zero_int
\BNiceArray
}
@@ -2453,24 +2413,25 @@
{ \endvNiceArray }
\NewDocumentEnvironment { VNiceArrayRC } { }
{
- \bool_set_true:N \l__nm_last_col_bool
+ \int_set:Nn \l__nm_last_col_int \c_zero_dim
\int_set:Nn \l__nm_first_row_int \c_zero_int
\VNiceArray
}
{ \endVNiceArray }
\NewDocumentEnvironment { NiceArrayCwithDelims } { }
{
- \bool_set_true:N \l__nm_last_col_bool
+ \int_set:Nn \l__nm_last_col_int \c_zero_dim
\NiceArrayWithDelims
}
{ \endNiceArrayWithDelims }
\NewDocumentEnvironment { NiceArrayRCwithDelims } { }
{
- \bool_set_true:N \l__nm_last_col_bool
+ \int_set:Nn \l__nm_last_col_int \c_zero_dim
\int_set:Nn \l__nm_first_row_int \c_zero_int
\NiceArrayWithDelims
}
{ \endNiceArrayWithDelims }
+
\endinput
%%
%% End of file `nicematrix.sty'.