summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty')
-rw-r--r--Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty1565
1 files changed, 1120 insertions, 445 deletions
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
index 4b5e8ce16bf..06c3fa98690 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.15}
-\def\myfiledate{2020/04/06}
+\def\myfileversion{4.0}
+\def\myfiledate{2020/05/08}
\RequirePackage{pgfcore}
\usepgfmodule{shapes}
\RequirePackage{l3keys2e}
@@ -36,10 +36,6 @@
}
\cs_if_exist:NF \l_keys_key_str
{ \msg_error:nn { nicematrix } { expl3~too~old } }
-\bool_new:N \c__nicematrix_draft_bool
-\DeclareOption { draft } { \bool_set_true:N \c__nicematrix_draft_bool }
-\DeclareOption* { }
-\ProcessOptions \relax
\RequirePackage { array }
\RequirePackage { amsmath }
\RequirePackage { xparse }
@@ -52,9 +48,13 @@
\cs_new_protected:Npn \__nicematrix_msg_new:nnn { \msg_new:nnnn { nicematrix } }
\cs_new_protected:Npn \__nicematrix_msg_redirect_name:nn
{ \msg_redirect_name:nnn { nicematrix } }
+\bool_new:N \c__nicematrix_booktabs_loaded_bool
\bool_new:N \c__nicematrix_tikz_loaded_bool
\AtBeginDocument
{
+ \@ifpackageloaded { booktabs }
+ { \bool_set_true:N \c__nicematrix_booktabs_loaded_bool }
+ { }
\@ifpackageloaded { tikz }
{
\bool_set_true:N \c__nicematrix_tikz_loaded_bool
@@ -73,9 +73,6 @@
\@ifclassloaded { revtex4-2 }
{ \bool_set_true:N \c__nicematrix_revtex_bool }
{ }
-\__nicematrix_msg_new:nn { Draft~mode }
- { The~compilation~is~in~draft~mode:~the~dotted~lines~won't~be~drawn. }
-\bool_if:NT \c__nicematrix_draft_bool { \msg_warning:nn { nicematrix } { Draft~mode } }
\ProvideDocumentCommand \iddots { }
{
\mathinner
@@ -90,79 +87,45 @@
\tex_mkern:D 1 mu
}
}
-\int_new:N \g__nicematrix_env_int
-\cs_new:Npn \__nicematrix_env: { nm - \int_use:N \g__nicematrix_env_int }
-\cs_new_protected:Npn \__nicematrix_qpoint: #1
- { \pgfpointanchor { \__nicematrix_env: - #1 } { center } }
-\int_new:N \g__nicematrix_NiceMatrixBlock_int
-\dim_new:N \l__nicematrix_columns_width_dim
-\seq_new:N \g__nicematrix_names_seq
-
-\bool_new:N \l__nicematrix_in_env_bool
-\bool_new:N \l__nicematrix_NiceArray_bool
-\cs_new_protected:Npn \__nicematrix_test_if_math_mode:
+\AtBeginDocument
{
- \if_mode_math: \else:
- \__nicematrix_fatal:n { Outside~math~mode }
- \fi:
+ \@ifpackageloaded { booktabs }
+ { \iow_now:Nn \@mainaux \nicematrix@redefine@check@rerun }
+ { }
+ }
+\cs_set_protected:Npn \nicematrix@redefine@check@rerun
+ {
+ \cs_set_eq:NN \__nicematrix_old_pgfutil@check@rerun \pgfutil@check@rerun
+ \cs_set_protected:Npn \pgfutil@check@rerun ##1 ##2
+ {
+ \str_set:Nx \l_tmpa_str { \tl_range:nnn { ##1 } 1 3 }
+ \str_if_eq:VnF \l_tmpa_str { nm- }
+ { \__nicematrix_old_pgfutil@check@rerun { ##1 } { ##2 } }
+ }
}
\bool_new:N \c__nicematrix_colortbl_loaded_bool
\AtBeginDocument
{
\@ifpackageloaded { colortbl }
+ { \bool_set_true:N \c__nicematrix_colortbl_loaded_bool }
{
- \bool_set_true:N \c__nicematrix_colortbl_loaded_bool
- \cs_set_protected:Npn \__nicematrix_vline_i: { { \CT@arc@ \vline } }
+ \cs_set_protected:Npn \CT@arc@ { }
+ \NewDocumentCommand { \arrayrulecolor } { m }
+ { \tl_gset:Nn \CT@arc@ { \color { #1 } } }
+ \cs_set:Npn \hline
+ {
+ \noalign { \ifnum 0 = `} \fi
+ \let \hskip \vskip
+ \let \vrule \hrule
+ \let \@width \@height
+ { \CT@arc@ \vline }
+ \futurelet \reserved@a
+ \@xhline
+ }
}
- { }
}
-\colorlet { nicematrix-last-col } { . }
-\colorlet { nicematrix-last-row } { . }
-\dim_new:N \l__nicematrix_inter_dots_dim
-\dim_set:Nn \l__nicematrix_inter_dots_dim { 0.45 em }
-\dim_new:N \l__nicematrix_xdots_shorten_dim
-\dim_set:Nn \l__nicematrix_xdots_shorten_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_name_env_str
-\str_new:N \g__nicematrix_com_or_env_str
-\str_set:Nn \g__nicematrix_com_or_env_str { environment }
-\cs_new:Npn \__nicematrix_full_name_env:
- {
- \str_if_eq:VnTF \g__nicematrix_com_or_env_str { command }
- { command \space \c_backslash_str \g__nicematrix_name_env_str }
- { environment \space \{ \g__nicematrix_name_env_str \} }
- }
-\tl_new:N \g__nicematrix_internal_code_after_tl
-\tl_new:N \g__nicematrix_code_after_tl
-\int_new:N \l__nicematrix_save_iRow_int
-\int_new:N \l__nicematrix_save_jCol_int
-\bool_new:N \g__nicematrix_row_of_col_done_bool
-\tl_new:N \l__nicematrix_initial_suffix_tl
-\tl_new:N \l__nicematrix_initial_anchor_tl
-\tl_new:N \l__nicematrix_final_suffix_tl
-\tl_new:N \l__nicematrix_final_anchor_tl
-\dim_new:N \l__nicematrix_x_initial_dim
-\dim_new:N \l__nicematrix_y_initial_dim
-\dim_new:N \l__nicematrix_x_final_dim
-\dim_new:N \l__nicematrix_y_final_dim
-\dim_new:N \l_tmpc_dim
-\dim_new:N \l_tmpd_dim
-\bool_new:N \g__nicematrix_empty_cell_bool
-\tl_new:N \l__nicematrix_xdots_line_style_tl
-\tl_const:Nn \c__nicematrix_standard_tl { standard }
-\tl_set_eq:NN \l__nicematrix_xdots_line_style_tl \c__nicematrix_standard_tl
-\int_new:N \l__nicematrix_first_row_int
-\int_set:Nn \l__nicematrix_first_row_int 1
-\int_new:N \l__nicematrix_first_col_int
-\int_set:Nn \l__nicematrix_first_col_int 1
-\int_new:N \l__nicematrix_last_row_int
-\int_set:Nn \l__nicematrix_last_row_int { -2 }
-\bool_new:N \l__nicematrix_last_row_without_value_bool
-\bool_new:N \l__nicematrix_last_col_without_value_bool
-\int_new:N \l__nicematrix_last_col_int
-\int_set:Nn \l__nicematrix_last_col_int { -2 }
-\bool_new:N \g__nicematrix_last_col_found_bool
+\cs_new:Npn \__nicematrix_succ:n #1 { \the \numexpr #1 + 1 \relax }
+\cs_new:Npn \__nicematrix_pred:n #1 { \the \numexpr #1 - 1 \relax }
\bool_new:N \c__nicematrix_siunitx_loaded_bool
\AtBeginDocument
{
@@ -202,8 +165,60 @@
\NC@find
}
}
-\cs_new:Npn \__nicematrix_succ:n #1 { \the \numexpr #1 + 1 \relax }
-\cs_new:Npn \__nicematrix_pred:n #1 { \the \numexpr #1 - 1 \relax }
+\int_new:N \g__nicematrix_env_int
+\cs_new:Npn \__nicematrix_env: { nm - \int_use:N \g__nicematrix_env_int }
+\cs_new_protected:Npn \__nicematrix_qpoint:n #1
+ { \pgfpointanchor { \__nicematrix_env: - #1 } { center } }
+\int_new:N \g__nicematrix_NiceMatrixBlock_int
+\dim_new:N \l__nicematrix_columns_width_dim
+\seq_new:N \g__nicematrix_names_seq
+\bool_new:N \l__nicematrix_in_env_bool
+\bool_new:N \l__nicematrix_NiceArray_bool
+\bool_new:N \l__nicematrix_NiceTabular_bool
+\cs_new_protected:Npn \__nicematrix_test_if_math_mode:
+ {
+ \if_mode_math: \else:
+ \__nicematrix_fatal:n { Outside~math~mode }
+ \fi:
+ }
+\colorlet { nicematrix-last-col } { . }
+\colorlet { nicematrix-last-row } { . }
+\str_new:N \g__nicematrix_name_env_str
+\str_new:N \g__nicematrix_com_or_env_str
+\str_set:Nn \g__nicematrix_com_or_env_str { environment }
+\cs_new:Npn \__nicematrix_full_name_env:
+ {
+ \str_if_eq:VnTF \g__nicematrix_com_or_env_str { command }
+ { command \space \c_backslash_str \g__nicematrix_name_env_str }
+ { environment \space \{ \g__nicematrix_name_env_str \} }
+ }
+\tl_new:N \g__nicematrix_code_after_tl
+\tl_new:N \g__nicematrix_internal_code_after_tl
+\int_new:N \l__nicematrix_old_iRow_int
+\int_new:N \l__nicematrix_old_jCol_int
+\bool_new:N \g__nicematrix_row_of_col_done_bool
+\bool_new:N \l__nicematrix_code_before_bool
+\dim_new:N \l__nicematrix_x_initial_dim
+\dim_new:N \l__nicematrix_y_initial_dim
+\dim_new:N \l__nicematrix_x_final_dim
+\dim_new:N \l__nicematrix_y_final_dim
+\dim_zero_new:N \l_tmpc_dim
+\dim_zero_new:N \l_tmpd_dim
+\bool_new:N \g__nicematrix_empty_cell_bool
+\dim_new:N \__nicematrix_old_arraycolsep_dim
+\dim_new:N \g__nicematrix_width_last_col_dim
+\dim_new:N \g__nicematrix_width_first_col_dim
+\int_new:N \l__nicematrix_first_row_int
+\int_set:Nn \l__nicematrix_first_row_int 1
+\int_new:N \l__nicematrix_first_col_int
+\int_set:Nn \l__nicematrix_first_col_int 1
+\int_new:N \l__nicematrix_last_row_int
+\int_set:Nn \l__nicematrix_last_row_int { -2 }
+\bool_new:N \l__nicematrix_last_row_without_value_bool
+\bool_new:N \l__nicematrix_last_col_without_value_bool
+\int_new:N \l__nicematrix_last_col_int
+\int_set:Nn \l__nicematrix_last_col_int { -2 }
+\bool_new:N \g__nicematrix_last_col_found_bool
\cs_new_protected:Npn \__nicematrix_pgf_rect_node:nnnnn #1 #2 #3 #4 #5
{
\begin { pgfscope }
@@ -253,6 +268,17 @@
{ }
\end { pgfscope }
}
+\dim_new:N \l__nicematrix_cell_space_top_limit_dim
+\dim_new:N \l__nicematrix_cell_space_bottom_limit_dim
+\dim_new:N \l__nicematrix_inter_dots_dim
+\dim_set:Nn \l__nicematrix_inter_dots_dim { 0.45 em }
+\dim_new:N \l__nicematrix_xdots_shorten_dim
+\dim_set:Nn \l__nicematrix_xdots_shorten_dim { 0.3 em }
+\dim_new:N \l__nicematrix_radius_dim
+\dim_set:Nn \l__nicematrix_radius_dim { 0.53 pt }
+\tl_new:N \l__nicematrix_xdots_line_style_tl
+\tl_const:Nn \c__nicematrix_standard_tl { standard }
+\tl_set_eq:NN \l__nicematrix_xdots_line_style_tl \c__nicematrix_standard_tl
\bool_new:N \l__nicematrix_light_syntax_bool
\str_new:N \l__nicematrix_baseline_str
\str_set:Nn \l__nicematrix_baseline_str c
@@ -268,8 +294,6 @@
\bool_new:N \l__nicematrix_large_nodes_bool
\dim_new:N \l__nicematrix_left_margin_dim
\dim_new:N \l__nicematrix_right_margin_dim
-\dim_new:N \g__nicematrix_width_last_col_dim
-\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
@@ -297,12 +321,20 @@
}
\keys_define:nn { NiceMatrix / Global }
{
+ cell-space-top-limit .dim_set:N = \l__nicematrix_cell_space_top_limit_dim ,
+ cell-space-top-limit .value_required:n = true ,
+ cell-space-bottom-limit .dim_set:N = \l__nicematrix_cell_space_bottom_limit_dim ,
+ cell-space-bottom-limit .value_required:n = true ,
xdots .code:n = \keys_set:nn { NiceMatrix / xdots } { #1 } ,
max-delimiter-width .bool_set:N = \l__nicematrix_max_delimiter_width_bool ,
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 ,
+ 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 ,
+ last-row .default:n = -1 ,
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 ,
@@ -311,7 +343,6 @@
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 ,
vlines .bool_set:N = \l__nicematrix_vlines_bool ,
hvlines .meta:n = { hlines , vlines } ,
@@ -337,6 +368,14 @@
}
\keys_define:nn { NiceMatrix / Env }
{
+ code-before .code:n =
+ {
+ \tl_if_empty:nF { #1 }
+ {
+ \tl_set:Nn \l__nicematrix_code_before_tl { #1 }
+ \bool_set_true:N \l__nicematrix_code_before_bool
+ }
+ } ,
c .code:n = \str_set:Nn \l__nicematrix_baseline_str c ,
t .code:n = \str_set:Nn \l__nicematrix_baseline_str t ,
b .code:n = \str_set:Nn \l__nicematrix_baseline_str b ,
@@ -359,10 +398,6 @@
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 ,
- last-row .default:n = -1 ,
}
\keys_define:nn { NiceMatrix }
{
@@ -377,6 +412,12 @@
NiceMatrix / Env ,
} ,
NiceMatrix / xdots .inherit:n = NiceMatrix / xdots ,
+ NiceTabular .inherit:n =
+ {
+ NiceMatrix / Global ,
+ NiceMatrix / Env
+ } ,
+ NiceTabular / xdots .inherit:n = NiceMatrix / xdots ,
NiceArray .inherit:n =
{
NiceMatrix / Global ,
@@ -392,6 +433,11 @@
}
\keys_define:nn { NiceMatrix / NiceMatrixOptions }
{
+ last-col .code:n = \tl_if_empty:nF { #1 }
+ { \__nicematrix_error:n { last-col~non~empty~for~NiceMatrixOptions } }
+ \int_zero:N \l__nicematrix_last_col_int ,
+ small .bool_set:N = \l__nicematrix_small_bool ,
+ small .value_forbidden:n = true ,
renew-matrix .code:n = \__nicematrix_renew_matrix: ,
renew-matrix .value_forbidden:n = true ,
transparent .meta:n = { renew-dots , renew-matrix } ,
@@ -429,10 +475,17 @@
r .code:n = \tl_set:Nn \l__nicematrix_type_of_col_tl R ,
L .code:n = \tl_set:Nn \l__nicematrix_type_of_col_tl L ,
R .code:n = \tl_set:Nn \l__nicematrix_type_of_col_tl R ,
+ S .code:n = \bool_if:NTF \c__nicematrix_siunitx_loaded_bool
+ { \tl_set:Nn \l__nicematrix_type_of_col_tl S }
+ { \__nicematrix_error:n { option~S~without~siunitx } } ,
+ small .bool_set:N = \l__nicematrix_small_bool ,
+ small .value_forbidden:n = true ,
unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceMatrix }
}
\keys_define:nn { NiceMatrix / NiceArray }
{
+ small .bool_set:N = \l__nicematrix_small_bool ,
+ small .value_forbidden:n = true ,
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 ,
@@ -445,10 +498,14 @@
{ \__nicematrix_error:n { last-col~non~empty~for~NiceArray } }
\int_zero:N \l__nicematrix_last_col_int ,
first-row .code:n = \int_zero:N \l__nicematrix_first_row_int ,
- last-row .int_set:N = \l__nicematrix_last_row_int ,
- last-row .default:n = -1 ,
+ small .bool_set:N = \l__nicematrix_small_bool ,
+ small .value_forbidden:n = true ,
unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceMatrix }
}
+\keys_define:nn { NiceMatrix / NiceTabular }
+ {
+ unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceTabular }
+ }
\cs_new_protected:Npn \__nicematrix_Cell:
{
\int_gincr:N \c@jCol
@@ -456,8 +513,11 @@
{ \int_compare:nNnT \l__nicematrix_first_col_int = 1 \__nicematrix_begin_of_row: }
\int_gset:Nn \g__nicematrix_col_total_int { \int_max:nn \g__nicematrix_col_total_int \c@jCol }
\hbox_set:Nw \l__nicematrix_cell_box
- \c_math_toggle_token
- \bool_if:NT \l__nicematrix_small_bool \scriptstyle
+ \bool_if:NF \l__nicematrix_NiceTabular_bool
+ {
+ \c_math_toggle_token
+ \bool_if:NT \l__nicematrix_small_bool \scriptstyle
+ }
\int_compare:nNnTF \c@iRow = 0
{
\int_compare:nNnT \c@jCol > 0
@@ -484,12 +544,12 @@
\pgfrememberpicturepositiononpagetrue
\pgfcoordinate
{ \__nicematrix_env: - row - \int_use:N \c@iRow - base }
- \pgfpointorigin
+ { \pgfpoint \c_zero_dim { 0.5 \arrayrulewidth } }
\str_if_empty:NF \l__nicematrix_name_str
{
\pgfnodealias
- { \__nicematrix_env: - row - \int_use:N \c@iRow - base }
{ \l__nicematrix_name_str - row - \int_use:N \c@iRow - base }
+ { \__nicematrix_env: - row - \int_use:N \c@iRow - base }
}
\endpgfpicture
}
@@ -512,16 +572,17 @@
}
\cs_new_protected:Npn \__nicematrix_end_Cell:
{
- \c_math_toggle_token
+ \bool_if:NF \l__nicematrix_NiceTabular_bool \c_math_toggle_token
\hbox_set_end:
+ \box_set_ht:Nn \l__nicematrix_cell_box
+ { \box_ht:N \l__nicematrix_cell_box + \l__nicematrix_cell_space_top_limit_dim }
+ \box_set_dp:Nn \l__nicematrix_cell_box
+ { \box_dp:N \l__nicematrix_cell_box + \l__nicematrix_cell_space_bottom_limit_dim }
\dim_gset:Nn \g__nicematrix_max_cell_width_dim
{ \dim_max:nn \g__nicematrix_max_cell_width_dim { \box_wd:N \l__nicematrix_cell_box } }
\__nicematrix_update_for_first_and_last_row:
\bool_if:NTF \g__nicematrix_empty_cell_bool
- {
- \box_use_drop:N \l__nicematrix_cell_box
- \bool_gset_false:N \g__nicematrix_empty_cell_bool
- }
+ { \box_use_drop:N \l__nicematrix_cell_box }
{
\dim_compare:nNnTF { \box_wd:N \l__nicematrix_cell_box } > \c_zero_dim
\__nicematrix_node_for_the_cell:
@@ -553,19 +614,15 @@
}
\endpgfpicture
}
-\bool_if:NTF \c__nicematrix_draft_bool
- { \cs_set_protected:Npn \__nicematrix_instruction_of_type:nn #1 #2 { } }
+\cs_new_protected:Npn \__nicematrix_instruction_of_type:nn #1 #2
{
- \cs_new_protected:Npn \__nicematrix_instruction_of_type:nn #1 #2
+ \tl_gput_right:cx
+ { g__nicematrix_ #1 _ lines _ tl }
{
- \tl_gput_right:cx
- { g__nicematrix_ #1 _ lines _ tl }
- {
- \use:c { __nicematrix _ draw _ #1 : nnn }
- { \int_use:N \c@iRow }
- { \int_use:N \c@jCol }
- { \exp_not:n { #2 } }
- }
+ \use:c { __nicematrix _ draw _ #1 : nnn }
+ { \int_use:N \c@iRow }
+ { \int_use:N \c@jCol }
+ { \exp_not:n { #2 } }
}
}
\cs_new_protected:Npn \__nicematrix_array:
@@ -581,49 +638,82 @@
\array
[ \str_if_eq:VnTF \l__nicematrix_baseline_str c c t ]
}
-\cs_set_eq:NN \__nicematrix_standard_ialign: \ialign
-\cs_new:Npn \__nicematrix_everycr: { \noalign { \__nicematrix_everycr_i: } }
-\cs_new_protected:Npn \__nicematrix_everycr_i:
+\cs_set_eq:NN \__nicematrix_old_ialign: \ialign
+\cs_new_protected:Npn \__nicematrix_create_row_node:
{
- \int_gzero:N \c@jCol
\hbox
{
+ \bool_if:NT \l__nicematrix_code_before_bool
+ {
+ \vtop
+ {
+ \skip_vertical:N 0.5\arrayrulewidth
+ \pgfsys@markposition { \__nicematrix_env: - row - \__nicematrix_succ:n \c@iRow }
+ \skip_vertical:N -0.5\arrayrulewidth
+ }
+ }
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgfcoordinate { \__nicematrix_env: - row - \__nicematrix_succ:n \c@iRow }
- \pgfpointorigin
+ { \pgfpoint \c_zero_dim { - 0.5 \arrayrulewidth } }
\str_if_empty:NF \l__nicematrix_name_str
{
\pgfnodealias
- { \__nicematrix_env: - row - \int_use:N \c@iRow - row }
- { \l__nicematrix_name_str - row - \int_use:N \c@iRow - row }
+ { \l__nicematrix_name_str - row - \int_use:N \c@iRow }
+ { \__nicematrix_env: - row - \int_use:N \c@iRow }
}
\endpgfpicture
}
- \bool_if:NT \l__nicematrix_hlines_bool
+ }
+\cs_new:Npn \__nicematrix_everycr: { \noalign { \__nicematrix_everycr_i: } }
+\cs_new_protected:Npn \__nicematrix_everycr_i:
+ {
+ \int_gzero:N \c@jCol
+ \bool_if:NF \g__nicematrix_row_of_col_done_bool
{
- \int_compare:nNnT \c@iRow > { -1 }
+ \__nicematrix_create_row_node:
+ \bool_if:NT \l__nicematrix_hlines_bool
{
- \bool_if:NF \g__nicematrix_row_of_col_done_bool
+ \int_compare:nNnT \c@iRow > { -1 }
{
\int_compare:nNnF \c@iRow = \l__nicematrix_last_row_int
- {
- \bool_if:NTF \c__nicematrix_colortbl_loaded_bool
- { { \CT@arc@ \hrule height \arrayrulewidth } }
- { \hrule height \arrayrulewidth }
- }
+ { { \CT@arc@ \hrule height \arrayrulewidth } }
}
}
}
}
+\cs_set_protected:Npn \__nicematrix_newcolumntype #1
+ {
+ \cs_if_free:cT { NC @ find @ #1 }
+ { \NC@list \expandafter { \the \NC@list \NC@do #1 } }
+ \cs_set:cpn {NC @ find @ #1 } ##1 #1 { \NC@ { ##1 } }
+ \peek_meaning:NTF [
+ { \newcol@ #1 }
+ { \newcol@ #1 [ 0 ] }
+ }
+\cs_new_protected:Npn \__nicematrix_define_columntype:nn #1 #2
+ {
+ \__nicematrix_newcolumntype #1 [ 1 ]
+ {
+ > {
+ \__nicematrix_Cell:
+ \begin { minipage } [ #2 ] { ##1 }
+ \mode_leave_vertical: \box_use:N \@arstrutbox
+ }
+ c
+ < { \box_use:N \@arstrutbox \end { minipage } \__nicematrix_end_Cell: }
+ }
+ }
\cs_new_protected:Npn \__nicematrix_pre_array:
{
+ \bool_if:NT \c__nicematrix_booktabs_loaded_bool
+ { \tl_put_left:Nn \@BTnormal \__nicematrix_create_row_node: }
\box_clear_new:N \l__nicematrix_cell_box
\cs_if_exist:NT \theiRow
- { \int_set_eq:NN \l__nicematrix_save_iRow_int \c@iRow }
+ { \int_set_eq:NN \l__nicematrix_old_iRow_int \c@iRow }
\int_gzero_new:N \c@iRow
\cs_if_exist:NT \thejCol
- { \int_set_eq:NN \l__nicematrix_save_jCol_int \c@jCol }
+ { \int_set_eq:NN \l__nicematrix_old_jCol_int \c@jCol }
\int_gzero_new:N \c@jCol
\normalbaselines
\bool_if:NT \l__nicematrix_small_bool
@@ -633,6 +723,8 @@
}
\cs_set:Npn \ialign
{
+ \bool_if:NT \l__nicematrix_NiceTabular_bool
+ { \dim_set_eq:NN \arraycolsep \__nicematrix_old_arraycolsep_dim }
\bool_if:NTF \c__nicematrix_colortbl_loaded_bool
{
\CT@everycr
@@ -654,17 +746,14 @@
\dim_gset:Nn \g__nicematrix_ht_last_row_dim { \box_ht:N \@arstrutbox }
\dim_gzero_new:N \g__nicematrix_dp_last_row_dim
\dim_gset:Nn \g__nicematrix_dp_last_row_dim { \box_dp:N \@arstrutbox }
- \cs_set_eq:NN \ialign \__nicematrix_standard_ialign:
+ \cs_set_eq:NN \ialign \__nicematrix_old_ialign:
\halign
}
- \newcolumntype L { > \__nicematrix_Cell: l < \__nicematrix_end_Cell: }
- \newcolumntype C { > \__nicematrix_Cell: c < \__nicematrix_end_Cell: }
- \newcolumntype R { > \__nicematrix_Cell: r < \__nicematrix_end_Cell: }
- \cs_set_eq:NN \__nicematrix_ldots \ldots
- \cs_set_eq:NN \__nicematrix_cdots \cdots
- \cs_set_eq:NN \__nicematrix_vdots \vdots
- \cs_set_eq:NN \__nicematrix_ddots \ddots
- \cs_set_eq:NN \__nicematrix_iddots \iddots
+ \cs_set_eq:NN \__nicematrix_old_ldots \ldots
+ \cs_set_eq:NN \__nicematrix_old_cdots \cdots
+ \cs_set_eq:NN \__nicematrix_old_vdots \vdots
+ \cs_set_eq:NN \__nicematrix_old_ddots \ddots
+ \cs_set_eq:NN \__nicematrix_old_iddots \iddots
\cs_set_eq:NN \firsthline \hline
\cs_set_eq:NN \lasthline \hline
\cs_set_eq:NN \Ldots \__nicematrix_Ldots
@@ -675,11 +764,14 @@
\cs_set_eq:NN \hdottedline \__nicematrix_hdottedline:
\cs_set_eq:NN \Hspace \__nicematrix_Hspace:
\cs_set_eq:NN \Hdotsfor \__nicematrix_Hdotsfor:
+ \cs_set_eq:NN \Vdotsfor \__nicematrix_Vdotsfor:
\cs_set_eq:NN \multicolumn \__nicematrix_multicolumn:nnn
\cs_set_eq:NN \Block \__nicematrix_Block:
\cs_set_eq:NN \rotate \__nicematrix_rotate:
\cs_set_eq:NN \OnlyMainNiceMatrix \__nicematrix_OnlyMainNiceMatrix:n
+ \cs_set_eq:NN \dotfill \__nicematrix_dotfill:
\cs_set_eq:NN \CodeAfter \__nicematrix_CodeAfter:n
+ \cs_set_eq:NN \slashbox \__nicematrix_slashbox:nn
\bool_if:NT \l__nicematrix_renew_dots_bool
{
\cs_set_eq:NN \ldots \__nicematrix_Ldots
@@ -696,9 +788,13 @@
\int_gzero_new:N \g__nicematrix_row_total_int
\int_gzero_new:N \g__nicematrix_col_total_int
\cs_set_eq:NN \@ifnextchar \new@ifnextchar
- \cs_set_eq:NN \NC@find@w \relax
- \cs_set_eq:NN \NC@find@W \relax
- \newcolumntype w [ 2 ]
+ \__nicematrix_newcolumntype L { > \__nicematrix_Cell: l < \__nicematrix_end_Cell: }
+ \__nicematrix_newcolumntype C { > \__nicematrix_Cell: c < \__nicematrix_end_Cell: }
+ \__nicematrix_newcolumntype R { > \__nicematrix_Cell: r < \__nicematrix_end_Cell: }
+ \__nicematrix_define_columntype:nn p t
+ \__nicematrix_define_columntype:nn m c
+ \__nicematrix_define_columntype:nn b b
+ \__nicematrix_newcolumntype w [ 2 ]
{
> {
\hbox_set:Nw \l__nicematrix_cell_box
@@ -712,7 +808,7 @@
{ \box_use_drop:N \l__nicematrix_cell_box }
}
}
- \newcolumntype W [ 2 ]
+ \__nicematrix_newcolumntype W [ 2 ]
{
> {
\hbox_set:Nw \l__nicematrix_cell_box
@@ -755,7 +851,7 @@
\tl_gclear_new:N \g__nicematrix_Vdots_lines_tl
\tl_gclear_new:N \g__nicematrix_Ddots_lines_tl
\tl_gclear_new:N \g__nicematrix_Iddots_lines_tl
- \tl_gclear_new:N \g__nicematrix_Hdotsfor_lines_tl
+ \tl_gclear_new:N \g__nicematrix_HVdotsfor_lines_tl
}
\NewDocumentEnvironment { NiceArrayWithDelims } { m m O { } m ! O { } }
{
@@ -765,7 +861,9 @@
\str_if_empty:NT \g__nicematrix_name_env_str
{ \str_gset:Nn \g__nicematrix_name_env_str { NiceArrayWithDelims } }
\__nicematrix_adapt_S_column:
- \__nicematrix_test_if_math_mode:
+ \bool_if:NTF \l__nicematrix_NiceTabular_bool
+ \mode_leave_vertical:
+ \__nicematrix_test_if_math_mode:
\bool_if:NT \l__nicematrix_in_env_bool { \__nicematrix_fatal:n { Yet~in~env } }
\bool_set_true:N \l__nicematrix_in_env_bool
\cs_if_exist:NT \tikz@library@external@loaded
@@ -782,6 +880,61 @@
{ \keys_set:nn { NiceMatrix / NiceArray } }
{ \keys_set:nn { NiceMatrix / pNiceArray } }
{ #3 , #5 }
+ \bool_if:NT \l__nicematrix_code_before_bool
+ {
+ \seq_if_exist:cT { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq }
+ {
+ \int_zero_new:N \c@iRow
+ \int_set:Nn \c@iRow
+ { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 2 }
+ \int_zero_new:N \c@jCol
+ \int_set:Nn \c@jCol
+ { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 4 }
+ \int_compare:nNnF \l__nicematrix_last_row_int = { -2 }
+ { \int_decr:N \c@iRow }
+ \int_compare:nNnF \l__nicematrix_last_col_int = { -2 }
+ { \int_decr:N \c@jCol }
+ \pgfsys@markposition { \__nicematrix_env: - position }
+ \pgfsys@getposition { \__nicematrix_env: - position } \__nicematrix_picture_position:
+ \pgfpicture
+ \int_step_inline:nnn
+ { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 1 }
+ { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 2 + 1 }
+ {
+ \pgfsys@getposition { \__nicematrix_env: - row - ##1 } \__nicematrix_node_position:
+ \pgfcoordinate { \__nicematrix_env: - row - ##1 }
+ { \pgfpointdiff \__nicematrix_picture_position: \__nicematrix_node_position: }
+ }
+ \int_step_inline:nnn
+ { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 3 }
+ { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 4 + 1 }
+ {
+ \pgfsys@getposition { \__nicematrix_env: - col - ##1 } \__nicematrix_node_position:
+ \pgfcoordinate { \__nicematrix_env: - col - ##1 }
+ { \pgfpointdiff \__nicematrix_picture_position: \__nicematrix_node_position: }
+ }
+ \endpgfpicture
+ \group_begin:
+ \bool_if:NT \c__nicematrix_tikz_loaded_bool
+ {
+ \pgfset
+ {
+ every~picture / .style =
+ { overlay , name~prefix = \__nicematrix_env: - }
+ }
+ }
+ \cs_set_eq:NN \cellcolor \__nicematrix_cellcolor:nn
+ \cs_set_eq:NN \rectanglecolor \__nicematrix_rectanglecolor:nnn
+ \cs_set_eq:NN \rowcolor \__nicematrix_rowcolor:nn
+ \cs_set_eq:NN \rowcolors \__nicematrix_rowcolors:nnn
+ \cs_set_eq:NN \columncolor \__nicematrix_columncolor:nn
+ \cs_set_eq:NN \chessboardcolors \__nicematrix_chessboardcolors:nn
+ \bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token
+ \l__nicematrix_code_before_tl
+ \bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token
+ \group_end:
+ }
+ }
\int_compare:nNnT \l__nicematrix_last_row_int > { -2 }
{
\tl_put_right:Nn \__nicematrix_update_for_first_and_last_row:
@@ -851,6 +1004,7 @@
\bool_lazy_all:nT
{
\l__nicematrix_NiceArray_bool
+ { \bool_not_p:n \l__nicematrix_NiceTabular_bool }
{ \bool_not_p:n \l__nicematrix_vlines_bool }
{ \bool_not_p:n \l__nicematrix_exterior_arraycolsep_bool }
}
@@ -862,6 +1016,7 @@
\bool_lazy_all:nT
{
\l__nicematrix_NiceArray_bool
+ { \bool_not_p:n \l__nicematrix_NiceTabular_bool }
{ \bool_not_p:n \l__nicematrix_vlines_bool }
{ \bool_not_p:n \l__nicematrix_exterior_arraycolsep_bool }
}
@@ -869,6 +1024,11 @@
}
\tl_put_right:Nn \l_tmpa_tl { > { \__nicematrix_error_too_much_cols: } L }
\hbox_set:Nw \l__nicematrix_the_array_box
+ \bool_if:NT \l__nicematrix_NiceTabular_bool
+ {
+ \dim_set_eq:NN \__nicematrix_old_arraycolsep_dim \arraycolsep
+ \dim_set_eq:NN \arraycolsep \tabcolsep
+ }
\bool_if:NT \l__nicematrix_vlines_bool
{
\dim_add:Nn \arraycolsep { 0.5 \arrayrulewidth }
@@ -878,13 +1038,13 @@
\skip_horizontal:N \l__nicematrix_extra_left_margin_dim
\c_math_toggle_token
\bool_if:NTF \l__nicematrix_light_syntax_bool
- { \begin { __nicematrix-light-syntax } }
- { \begin { __nicematrix-normal-syntax } }
+ { \use:c { __nicematrix-light-syntax } }
+ { \use:c { __nicematrix-normal-syntax } }
}
{
\bool_if:NTF \l__nicematrix_light_syntax_bool
- { \end { __nicematrix-light-syntax } }
- { \end { __nicematrix-normal-syntax } }
+ { \use:c { end __nicematrix-light-syntax } }
+ { \use:c { 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
@@ -915,9 +1075,9 @@
\str_if_eq:VnTF \l__nicematrix_baseline_str { b }
{
\pgfpicture
- \__nicematrix_qpoint: { row - 1 }
+ \__nicematrix_qpoint:n { row - 1 }
\dim_gset_eq:NN \g_tmpa_dim \pgf@y
- \__nicematrix_qpoint: { row - \int_use:N \c@iRow - base }
+ \__nicematrix_qpoint:n { row - \int_use:N \c@iRow - base }
\dim_gsub:Nn \g_tmpa_dim \pgf@y
\endpgfpicture
\int_compare:nNnT \l__nicematrix_first_row_int = 0
@@ -944,9 +1104,9 @@
\int_set:Nn \l_tmpa_int 1
}
\pgfpicture
- \__nicematrix_qpoint: { row - 1 }
+ \__nicematrix_qpoint:n { row - 1 }
\dim_gset_eq:NN \g_tmpa_dim \pgf@y
- \__nicematrix_qpoint: { row - \int_use:N \l_tmpa_int - base }
+ \__nicematrix_qpoint:n { row - \int_use:N \l_tmpa_int - base }
\dim_gsub:Nn \g_tmpa_dim \pgf@y
\endpgfpicture
\int_compare:nNnT \l__nicematrix_first_row_int = 0
@@ -981,9 +1141,13 @@
\skip_vertical:N -\l_tmpa_dim
\hbox
{
- \skip_horizontal:N -\arraycolsep
+ \bool_if:NTF \l__nicematrix_NiceTabular_bool
+ { \skip_horizontal:N -\tabcolsep }
+ { \skip_horizontal:N -\arraycolsep }
\box_use_drop:N \l__nicematrix_the_array_box
- \skip_horizontal:N -\arraycolsep
+ \bool_if:NTF \l__nicematrix_NiceTabular_bool
+ { \skip_horizontal:N -\tabcolsep }
+ { \skip_horizontal:N -\arraycolsep }
}
\skip_vertical:N -\l_tmpb_dim
}
@@ -1027,12 +1191,12 @@
\int_set:Nn \l_tmpa_int 1
}
\pgfpicture
- \__nicematrix_qpoint: { row - 1 }
+ \__nicematrix_qpoint:n { row - 1 }
\dim_gset_eq:NN \g_tmpa_dim \pgf@y
- \__nicematrix_qpoint: { row - \__nicematrix_succ:n \c@iRow }
+ \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \c@iRow }
\dim_gadd:Nn \g_tmpa_dim \pgf@y
\dim_gset:Nn \g_tmpa_dim { 0.5 \g_tmpa_dim }
- \__nicematrix_qpoint: { row - \int_use:N \l_tmpa_int - base }
+ \__nicematrix_qpoint:n { row - \int_use:N \l_tmpa_int - base }
\dim_gsub:Nn \g_tmpa_dim \pgf@y
\dim_gsub:Nn \g_tmpa_dim { \fontdimen22 \textfont2 }
\endpgfpicture
@@ -1096,6 +1260,12 @@
\tl_if_eq:nnT { ##1 } { \\ }
{ \__nicematrix_fatal:n { double-backslash~in~light-syntax } }
}
+ \__nicematrix_light_syntax_i #1 \CodeAfter \q_stop
+ }
+ { }
+\cs_new_protected:Npn \__nicematrix_light_syntax_i #1\CodeAfter #2\q_stop
+ {
+ \tl_gput_right:Nn \g__nicematrix_code_after_tl { #2 }
\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 }
@@ -1108,21 +1278,16 @@
\__nicematrix_create_col_nodes:
\endarray
}
- { }
+\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_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 } }
+ \seq_map_inline:Nn \g__nicematrix_cells_seq { & ##1 }
}
-\cs_new_protected:Npn \__nicematrix_cell_with_light_syntax:n #1 { & #1 }
\cs_new_protected:Npn \__nicematrix_analyze_end:Nn #1 #2
{
\str_if_eq:VnT \g__nicematrix_name_env_str { #2 }
@@ -1136,23 +1301,56 @@
\int_compare:nNnT \l__nicematrix_first_col_int = 0
{
\omit
- \skip_horizontal:N -2\arraycolsep
+ \skip_horizontal:N -2\col@sep
+ \bool_if:NT \l__nicematrix_code_before_bool
+ { \pgfsys@markposition { \__nicematrix_env: - col - 0 } }
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgfcoordinate { \__nicematrix_env: - col - 0 } \pgfpointorigin
\str_if_empty:NF \l__nicematrix_name_str
- { \pgfnodealias { \__nicematrix_env: - col - 0 } { \l__nicematrix_name_str - col - 0 } }
+ { \pgfnodealias { \l__nicematrix_name_str - col - 0 } { \__nicematrix_env: - col - 0 } }
\endpgfpicture
&
}
\omit
\bool_gset_true:N \g__nicematrix_row_of_col_done_bool
- \pgfpicture
- \pgfrememberpicturepositiononpagetrue
- \pgfcoordinate { \__nicematrix_env: - col - 1 } \pgfpointorigin
- \str_if_empty:NF \l__nicematrix_name_str
- { \pgfnodealias { \__nicematrix_env: - col - 1 } { \l__nicematrix_name_str - col - 1 } }
- \endpgfpicture
+ \int_compare:nNnTF \l__nicematrix_first_col_int = 0
+ {
+ \bool_if:NT \l__nicematrix_code_before_bool
+ {
+ \hbox
+ {
+ \skip_horizontal:N -0.5\arrayrulewidth
+ \pgfsys@markposition { \__nicematrix_env: - col - 1 }
+ \skip_horizontal:N 0.5\arrayrulewidth
+ }
+ }
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgfcoordinate { \__nicematrix_env: - col - 1 }
+ { \pgfpoint { - 0.5 \arrayrulewidth } \c_zero_dim }
+ \str_if_empty:NF \l__nicematrix_name_str
+ { \pgfnodealias { \l__nicematrix_name_str - col - 1 } { \__nicematrix_env: - col - 1 } }
+ \endpgfpicture
+ }
+ {
+ \bool_if:NT \l__nicematrix_code_before_bool
+ {
+ \hbox
+ {
+ \skip_horizontal:N 0.5 \arrayrulewidth
+ \pgfsys@markposition { \__nicematrix_env: - col - 1 }
+ \skip_horizontal:N -0.5\arrayrulewidth
+ }
+ }
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgfcoordinate { \__nicematrix_env: - col - 1 }
+ { \pgfpoint { 0.5 \arrayrulewidth } \c_zero_dim }
+ \str_if_empty:NF \l__nicematrix_name_str
+ { \pgfnodealias { \l__nicematrix_name_str - col - 1 } { \__nicematrix_env: - col - 1 } }
+ \endpgfpicture
+ }
\skip_gset:Nn \g_tmpa_skip { 0 pt~plus 1 fill }
\bool_if:NF \l__nicematrix_auto_columns_width_bool
{ \dim_compare:nNnT \l__nicematrix_columns_width_dim > \c_zero_dim }
@@ -1162,16 +1360,26 @@
{ \bool_not_p:n \l__nicematrix_block_auto_columns_width_bool }
{ \skip_gset_eq:NN \g_tmpa_skip \g__nicematrix_max_cell_width_dim }
{ \skip_gset_eq:NN \g_tmpa_skip \l__nicematrix_columns_width_dim }
- \skip_gadd:Nn \g_tmpa_skip { 2 \arraycolsep }
+ \skip_gadd:Nn \g_tmpa_skip { 2 \col@sep }
}
\skip_horizontal:N \g_tmpa_skip
\hbox
{
+ \bool_if:NT \l__nicematrix_code_before_bool
+ {
+ \hbox
+ {
+ \skip_horizontal:N -0.5\arrayrulewidth
+ \pgfsys@markposition { \__nicematrix_env: - col - 2 }
+ \skip_horizontal:N 0.5\arrayrulewidth
+ }
+ }
\pgfpicture
\pgfrememberpicturepositiononpagetrue
- \pgfcoordinate { \__nicematrix_env: - col - 2 } \pgfpointorigin
+ \pgfcoordinate { \__nicematrix_env: - col - 2 }
+ { \pgfpoint { - 0.5 \arrayrulewidth } \c_zero_dim }
\str_if_empty:NF \l__nicematrix_name_str
- { \pgfnodealias { \__nicematrix_env: - col - 2 } { \l__nicematrix_name_str - col - 2 } }
+ { \pgfnodealias { \l__nicematrix_name_str - col - 2 } { \__nicematrix_env: - col - 2 } }
\endpgfpicture
}
\int_gset:Nn \g_tmpa_int 1
@@ -1179,25 +1387,38 @@
{ \prg_replicate:nn { \g__nicematrix_col_total_int - 2 } }
{ \prg_replicate:nn { \g__nicematrix_col_total_int - 1 } }
{
- &
- \omit
- \int_gincr:N \g_tmpa_int
- \skip_horizontal:N \g_tmpa_skip
- \pgfpicture
- \pgfrememberpicturepositiononpagetrue
- \pgfcoordinate { \__nicematrix_env: - col - \__nicematrix_succ:n \g_tmpa_int }
- \pgfpointorigin
- \str_if_empty:NF \l__nicematrix_name_str
- {
- \pgfnodealias
- { \__nicematrix_env: - col - \__nicematrix_succ:n \g_tmpa_int }
- { \l__nicematrix_name_str - col - \__nicematrix_succ:n \g_tmpa_int }
- }
- \endpgfpicture
+ &
+ \omit
+ \int_gincr:N \g_tmpa_int
+ \skip_horizontal:N \g_tmpa_skip
+ \bool_if:NT \l__nicematrix_code_before_bool
+ {
+ \hbox
+ {
+ \skip_horizontal:N -0.5\arrayrulewidth
+ \pgfsys@markposition { \__nicematrix_env: - col - \__nicematrix_succ:n \g_tmpa_int }
+ \skip_horizontal:N 0.5\arrayrulewidth
+ }
+ }
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgfcoordinate { \__nicematrix_env: - col - \__nicematrix_succ:n \g_tmpa_int }
+ { \pgfpoint { - 0.5 \arrayrulewidth } \c_zero_dim }
+ \str_if_empty:NF \l__nicematrix_name_str
+ {
+ \pgfnodealias
+ { \l__nicematrix_name_str - col - \__nicematrix_succ:n \g_tmpa_int }
+ { \__nicematrix_env: - col - \__nicematrix_succ:n \g_tmpa_int }
+ }
+ \endpgfpicture
}
\bool_if:NT \g__nicematrix_last_col_found_bool
{
- \skip_horizontal:N 2\arraycolsep
+ \bool_if:NT \l__nicematrix_code_before_bool
+ {
+ \pgfsys@markposition { \__nicematrix_env: - col - \__nicematrix_succ:n \g__nicematrix_col_total_int }
+ }
+ \skip_horizontal:N 2\col@sep
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgfcoordinate { \__nicematrix_env: - col - \__nicematrix_succ:n \g__nicematrix_col_total_int }
@@ -1205,11 +1426,11 @@
\str_if_empty:NF \l__nicematrix_name_str
{
\pgfnodealias
- { \__nicematrix_env: - col - \__nicematrix_succ:n \g__nicematrix_col_total_int }
{ \l__nicematrix_name_str - col - \__nicematrix_succ:n \g__nicematrix_col_total_int }
+ { \__nicematrix_env: - col - \__nicematrix_succ:n \g__nicematrix_col_total_int }
}
\endpgfpicture
- \skip_horizontal:N -2\arraycolsep
+ \skip_horizontal:N -2\col@sep
}
\cr
}
@@ -1219,7 +1440,7 @@
{
\__nicematrix_begin_of_row:
\hbox_set:Nw \l__nicematrix_cell_box
- \c_math_toggle_token
+ \bool_if:NF \l__nicematrix_NiceTabular_bool \c_math_toggle_token
\bool_if:NT \l__nicematrix_small_bool \scriptstyle
\bool_lazy_and:nnT
{ \int_compare_p:nNn \c@iRow > 0 }
@@ -1236,7 +1457,7 @@
l
<
{
- \c_math_toggle_token
+ \bool_if:NF \l__nicematrix_NiceTabular_bool \c_math_toggle_token
\hbox_set_end:
\__nicematrix_update_for_first_and_last_row:
\dim_gset:Nn \g__nicematrix_width_first_col_dim
@@ -1250,7 +1471,7 @@
\skip_horizontal:N \l__nicematrix_left_margin_dim
\skip_horizontal:N \l__nicematrix_extra_left_margin_dim
}
- \skip_horizontal:N -2\arraycolsep
+ \skip_horizontal:N -2\col@sep
}
}
\tl_const:Nn \c__nicematrix_preamble_last_col_tl
@@ -1261,7 +1482,7 @@
\int_gincr:N \c@jCol
\int_gset_eq:NN \g__nicematrix_col_total_int \c@jCol
\hbox_set:Nw \l__nicematrix_cell_box
- \c_math_toggle_token
+ \bool_if:NF \l__nicematrix_NiceTabular_bool \c_math_toggle_token
\bool_if:NT \l__nicematrix_small_bool \scriptstyle
\int_compare:nNnT \c@iRow > 0
{
@@ -1277,12 +1498,12 @@
l
<
{
- \c_math_toggle_token
+ \bool_if:NF \l__nicematrix_NiceTabular_bool \c_math_toggle_token
\hbox_set_end:
\__nicematrix_update_for_first_and_last_row:
\dim_gset:Nn \g__nicematrix_width_last_col_dim
{ \dim_max:nn \g__nicematrix_width_last_col_dim { \box_wd:N \l__nicematrix_cell_box } }
- \skip_horizontal:N -2\arraycolsep
+ \skip_horizontal:N -2\col@sep
\hbox_overlap_right:n
{
\dim_compare:nNnT { \box_wd:N \l__nicematrix_cell_box } > \c_zero_dim
@@ -1352,11 +1573,11 @@
\keys_set:nn { NiceMatrix / NiceMatrix } { ##1 }
\exp_args:Nnx \__nicematrix_begin_of_NiceMatrix:nn { #1 } \l__nicematrix_type_of_col_tl
}
- { \end { #1 NiceArray } }
+ { \use:c { end #1 NiceArray } }
}
\cs_new_protected:Npn \__nicematrix_begin_of_NiceMatrix:nn #1 #2
{
- \begin { #1 NiceArray }
+ \use:c { #1 NiceArray }
{
*
{
@@ -1373,6 +1594,13 @@
\__nicematrix_define_env:n B
\__nicematrix_define_env:n v
\__nicematrix_define_env:n V
+\NewDocumentEnvironment { NiceTabular } { O { } m ! O { } }
+ {
+ \keys_set:nn { NiceMatrix / NiceTabular } { #1 , #3 }
+ \bool_set_true:N \l__nicematrix_NiceTabular_bool
+ \NiceArray { #2 }
+ }
+ { \endNiceArray }
\cs_new_protected:Npn \__nicematrix_after_array:
{
\group_begin:
@@ -1419,6 +1647,28 @@
\iow_shipout:Nn \@mainaux \ExplSyntaxOff
}
}
+ \bool_if:NT \l__nicematrix_code_before_bool
+ {
+ \iow_now:Nn \@mainaux \ExplSyntaxOn
+ \iow_now:Nx \@mainaux
+ { \seq_clear_new:c { __nicematrix_size _ \int_use:N \g__nicematrix_env_int _ seq } }
+ \iow_now:Nx \@mainaux
+ {
+ \seq_gset_from_clist:cn { __nicematrix_size _ \int_use:N \g__nicematrix_env_int _ seq }
+ {
+ \int_use:N \l__nicematrix_first_row_int ,
+ \int_use:N \g__nicematrix_row_total_int ,
+ \int_use:N \l__nicematrix_first_col_int ,
+ \bool_lazy_and:nnTF
+ { \int_compare_p:nNn \l__nicematrix_last_col_int > { -2 } }
+ { \bool_not_p:n \g__nicematrix_last_col_found_bool }
+ \__nicematrix_succ:n
+ \int_use:N
+ \g__nicematrix_col_total_int
+ }
+ }
+ \iow_now:Nn \@mainaux \ExplSyntaxOff
+ }
\bool_if:NT \l__nicematrix_parallelize_diags_bool
{
\int_gzero_new:N \g__nicematrix_ddots_int
@@ -1464,6 +1714,7 @@
}
}
\cs_set_eq:NN \line \__nicematrix_line
+ \cs_set_eq:NN \CodeAfter \prg_do_nothing:
\g__nicematrix_code_after_tl
\tl_gclear:N \g__nicematrix_code_after_tl
\group_end:
@@ -1483,7 +1734,7 @@
{
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
- \g__nicematrix_Hdotsfor_lines_tl
+ \g__nicematrix_HVdotsfor_lines_tl
\g__nicematrix_Vdots_lines_tl
\g__nicematrix_Ddots_lines_tl
\g__nicematrix_Iddots_lines_tl
@@ -1492,8 +1743,8 @@
}
\cs_new_protected:Npn \__nicematrix_restore_iRow_jCol:
{
- \cs_if_exist:NT \theiRow { \int_gset_eq:NN \c@iRow \l__nicematrix_save_iRow_int }
- \cs_if_exist:NT \thejCol { \int_gset_eq:NN \c@jCol \l__nicematrix_save_jCol_int }
+ \cs_if_exist:NT \theiRow { \int_gset_eq:NN \c@iRow \l__nicematrix_old_iRow_int }
+ \cs_if_exist:NT \thejCol { \int_gset_eq:NN \c@jCol \l__nicematrix_old_jCol_int }
}
\cs_new_protected:Npn \__nicematrix_find_extremities_of_line:nnnn #1 #2 #3 #4
{
@@ -1639,10 +1890,6 @@
}
}
}
-\cs_new:Nn \__nicematrix_initial_cell:
- { \__nicematrix_env: - \int_use:N \l__nicematrix_initial_i_int - \int_use:N \l__nicematrix_initial_j_int }
-\cs_new:Nn \__nicematrix_final_cell:
- { \__nicematrix_env: - \int_use:N \l__nicematrix_final_i_int - \int_use:N \l__nicematrix_final_j_int }
\cs_new_protected:Npn \__nicematrix_set_initial_coords:
{
\dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x
@@ -1655,12 +1902,24 @@
}
\cs_new_protected:Npn \__nicematrix_set_initial_coords_from_anchor:n #1
{
- \pgfpointanchor \__nicematrix_initial_cell: { #1 }
+ \pgfpointanchor
+ {
+ \__nicematrix_env:
+ - \int_use:N \l__nicematrix_initial_i_int
+ - \int_use:N \l__nicematrix_initial_j_int
+ }
+ { #1 }
\__nicematrix_set_initial_coords:
}
\cs_new_protected:Npn \__nicematrix_set_final_coords_from_anchor:n #1
{
- \pgfpointanchor \__nicematrix_final_cell: { #1 }
+ \pgfpointanchor
+ {
+ \__nicematrix_env:
+ - \int_use:N \l__nicematrix_final_i_int
+ - \int_use:N \l__nicematrix_final_j_int
+ }
+ { #1 }
\__nicematrix_set_final_coords:
}
\cs_new_protected:Npn \__nicematrix_draw_Ldots:nnn #1 #2 #3
@@ -1685,19 +1944,21 @@
{
\bool_if:NTF \l__nicematrix_initial_open_bool
{
- \__nicematrix_qpoint: { col - \int_use:N \l__nicematrix_initial_j_int }
+ \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_initial_j_int }
\dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x
- \dim_add:Nn \l__nicematrix_x_initial_dim \arraycolsep
- \__nicematrix_qpoint: { row - \int_use:N \l__nicematrix_initial_i_int - base }
+ \dim_add:Nn \l__nicematrix_x_initial_dim
+ { \bool_if:NTF \l__nicematrix_NiceTabular_bool \tabcolsep \arraycolsep }
+ \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_initial_i_int - base }
\dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y
}
{ \__nicematrix_set_initial_coords_from_anchor:n { base~east } }
\bool_if:NTF \l__nicematrix_final_open_bool
{
- \__nicematrix_qpoint: { col - \__nicematrix_succ:n \l__nicematrix_final_j_int }
+ \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l__nicematrix_final_j_int }
\dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x
- \dim_sub:Nn \l__nicematrix_x_final_dim \arraycolsep
- \__nicematrix_qpoint: { row - \int_use:N \l__nicematrix_final_i_int - base }
+ \dim_sub:Nn \l__nicematrix_x_final_dim
+ { \bool_if:NTF \l__nicematrix_NiceTabular_bool \tabcolsep \arraycolsep }
+ \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_final_i_int - base }
\dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y
}
{ \__nicematrix_set_final_coords_from_anchor:n { base~west } }
@@ -1727,25 +1988,27 @@
{
\bool_if:NTF \l__nicematrix_initial_open_bool
{
- \__nicematrix_qpoint: { col - \int_use:N \l__nicematrix_initial_j_int }
+ \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_initial_j_int }
\dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x
- \dim_add:Nn \l__nicematrix_x_initial_dim \arraycolsep
+ \dim_add:Nn \l__nicematrix_x_initial_dim
+ { \bool_if:NTF \l__nicematrix_NiceTabular_bool \tabcolsep \arraycolsep }
}
{ \__nicematrix_set_initial_coords_from_anchor:n { mid~east } }
\bool_if:NTF \l__nicematrix_final_open_bool
{
- \__nicematrix_qpoint: { col - \__nicematrix_succ:n \l__nicematrix_final_j_int }
+ \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l__nicematrix_final_j_int }
\dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x
- \dim_sub:Nn \l__nicematrix_x_final_dim \arraycolsep
+ \dim_sub:Nn \l__nicematrix_x_final_dim
+ { \bool_if:NTF \l__nicematrix_NiceTabular_bool \tabcolsep \arraycolsep }
}
{ \__nicematrix_set_final_coords_from_anchor:n { mid~west } }
\bool_lazy_and:nnTF
\l__nicematrix_initial_open_bool
\l__nicematrix_final_open_bool
{
- \__nicematrix_qpoint: { row - \int_use:N \l__nicematrix_initial_i_int }
+ \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_initial_i_int }
\dim_set_eq:NN \l_tmpa_dim \pgf@y
- \__nicematrix_qpoint: { row - \__nicematrix_succ:n \l__nicematrix_initial_i_int }
+ \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l__nicematrix_initial_i_int }
\dim_set:Nn \l__nicematrix_y_initial_dim { ( \l_tmpa_dim + \pgf@y ) / 2 }
\dim_set_eq:NN \l__nicematrix_y_final_dim \l__nicematrix_y_initial_dim
}
@@ -1787,13 +2050,13 @@
}
\bool_if:NTF \l__nicematrix_initial_open_bool
{
- \__nicematrix_qpoint: { row - 1 }
+ \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_initial_i_int }
\dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y
}
{ \__nicematrix_set_initial_coords_from_anchor:n { south } }
\bool_if:NTF \l__nicematrix_final_open_bool
{
- \__nicematrix_qpoint: { row - \__nicematrix_succ:n \c@iRow }
+ \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l__nicematrix_final_i_int }
\dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y
}
{ \__nicematrix_set_final_coords_from_anchor:n { north } }
@@ -1801,11 +2064,21 @@
{
\bool_if:NTF \l__nicematrix_final_open_bool
{
- \__nicematrix_qpoint: { col - \int_use:N \l__nicematrix_initial_j_int }
+ \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_initial_j_int }
\dim_set_eq:NN \l_tmpa_dim \pgf@x
- \__nicematrix_qpoint: { col - \__nicematrix_succ:n \l__nicematrix_initial_j_int }
+ \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l__nicematrix_initial_j_int }
\dim_set:Nn \l__nicematrix_x_initial_dim { ( \pgf@x + \l_tmpa_dim ) / 2 }
\dim_set_eq:NN \l__nicematrix_x_final_dim \l__nicematrix_x_initial_dim
+ \int_compare:nNnT \l__nicematrix_last_col_int > { -2 }
+ {
+ \int_compare:nNnT \l__nicematrix_initial_j_int = \g__nicematrix_col_total_int
+ {
+ \dim_set_eq:NN \l_tmpa_dim \l__nicematrix_right_margin_dim
+ \dim_add:Nn \l_tmpa_dim \l__nicematrix_extra_right_margin_dim
+ \dim_add:Nn \l__nicematrix_x_initial_dim \l_tmpa_dim
+ \dim_add:Nn \l__nicematrix_x_final_dim \l_tmpa_dim
+ }
+ }
}
{ \dim_set_eq:NN \l__nicematrix_x_initial_dim \l__nicematrix_x_final_dim }
}
@@ -1842,17 +2115,17 @@
{
\bool_if:NTF \l__nicematrix_initial_open_bool
{
- \__nicematrix_qpoint: { row - \int_use:N \l__nicematrix_initial_i_int }
+ \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_initial_i_int }
\dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y
- \__nicematrix_qpoint: { col - \int_use:N \l__nicematrix_initial_j_int }
+ \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_initial_j_int }
\dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x
}
{ \__nicematrix_set_initial_coords_from_anchor:n { south~east } }
\bool_if:NTF \l__nicematrix_final_open_bool
{
- \__nicematrix_qpoint: { row - \__nicematrix_succ:n \l__nicematrix_final_i_int }
+ \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l__nicematrix_final_i_int }
\dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y
- \__nicematrix_qpoint: { col - \__nicematrix_succ:n \l__nicematrix_final_j_int }
+ \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l__nicematrix_final_j_int }
\dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x
}
{ \__nicematrix_set_final_coords_from_anchor:n { north~west } }
@@ -1893,17 +2166,17 @@
{
\bool_if:NTF \l__nicematrix_initial_open_bool
{
- \__nicematrix_qpoint: { row - \int_use:N \l__nicematrix_initial_i_int }
+ \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_initial_i_int }
\dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y
- \__nicematrix_qpoint: { col - \__nicematrix_succ:n \l__nicematrix_initial_j_int }
+ \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l__nicematrix_initial_j_int }
\dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x
}
{ \__nicematrix_set_initial_coords_from_anchor:n { south~west } }
\bool_if:NTF \l__nicematrix_final_open_bool
{
- \__nicematrix_qpoint: { row - \__nicematrix_succ:n \l__nicematrix_final_i_int }
+ \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l__nicematrix_final_i_int }
\dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y
- \__nicematrix_qpoint: { col - \int_use:N \l__nicematrix_final_j_int }
+ \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_final_j_int }
\dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x
}
{ \__nicematrix_set_final_coords_from_anchor:n { north~east } }
@@ -2121,40 +2394,107 @@
{
\bool_if:nTF { #1 }
{ \__nicematrix_error:n { starred~commands } }
- { \__nicematrix_instruction_of_type:nn { Ldots } { #2 , down = #3 , up = #4 } }
- \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_ldots }
+ {
+ \int_compare:nNnTF \c@jCol = 0
+ { \__nicematrix_error:nn { in~first~col } \Ldots }
+ {
+ \int_compare:nNnTF \c@jCol = \l__nicematrix_last_col_int
+ { \__nicematrix_error:nn { in~last~col } \Ldots }
+ {
+ \__nicematrix_instruction_of_type:nn { Ldots }
+ { #2 , down = #3 , up = #4 }
+ }
+ }
+ }
+ \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_ldots }
\bool_gset_true:N \g__nicematrix_empty_cell_bool
}
\exp_args:NNV \NewDocumentCommand \__nicematrix_Cdots \l__nicematrix_argspec_tl
{
\bool_if:nTF { #1 }
{ \__nicematrix_error:n { starred~commands } }
- { \__nicematrix_instruction_of_type:nn { Cdots } { #2 , down = #3 , up = #4 } }
- \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_cdots }
+ {
+ \int_compare:nNnTF \c@jCol = 0
+ { \__nicematrix_error:nn { in~first~col } \Cdots }
+ {
+ \int_compare:nNnTF \c@jCol = \l__nicematrix_last_col_int
+ { \__nicematrix_error:nn { in~last~col } \Cdots }
+ {
+ \__nicematrix_instruction_of_type:nn { Cdots }
+ { #2 , down = #3 , up = #4 }
+ }
+ }
+ }
+ \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_cdots }
\bool_gset_true:N \g__nicematrix_empty_cell_bool
}
\exp_args:NNV \NewDocumentCommand \__nicematrix_Vdots \l__nicematrix_argspec_tl
{
\bool_if:nTF { #1 }
{ \__nicematrix_error:n { starred~commands } }
- { \__nicematrix_instruction_of_type:nn { Vdots } { #2 , down = #3 , up = #4 } }
- \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_vdots }
+ \int_compare:nNnTF \c@iRow = 0
+ { \__nicematrix_error:nn { in~first~row } \Vdots }
+ {
+ \int_compare:nNnTF \c@iRow = \l__nicematrix_last_row_int
+ { \__nicematrix_error:nn { in~last~row } \Vdots }
+ {
+ \__nicematrix_instruction_of_type:nn { Vdots }
+ { #2 , down = #3 , up = #4 }
+ }
+ }
+ \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_vdots }
\bool_gset_true:N \g__nicematrix_empty_cell_bool
}
\exp_args:NNV \NewDocumentCommand \__nicematrix_Ddots \l__nicematrix_argspec_tl
{
\bool_if:nTF { #1 }
{ \__nicematrix_error:n { starred~commands } }
- { \__nicematrix_instruction_of_type:nn { Ddots } { #2 , down = #3 , up = #4 } }
- \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_ddots }
+ {
+ \int_case:nnF \c@iRow
+ {
+ 0 { \__nicematrix_error:nn { in~first~row } \Ddots }
+ \l__nicematrix_last_row_int { \__nicematrix_error:nn { in~last~row } \Ddots }
+ }
+ {
+ \int_case:nnF \c@jCol
+ {
+ 0 { \__nicematrix_error:nn { in~first~col } \Ddots }
+ \l__nicematrix_last_col_int { \__nicematrix_error:nn { in~last~col } \Ddots }
+ }
+ {
+ \__nicematrix_instruction_of_type:nn { Ddots }
+ { #2 , down = #3 , up = #4 }
+ }
+
+ }
+ }
+ \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_ddots }
\bool_gset_true:N \g__nicematrix_empty_cell_bool
}
\exp_args:NNV \NewDocumentCommand \__nicematrix_Iddots \l__nicematrix_argspec_tl
{
\bool_if:nTF { #1 }
{ \__nicematrix_error:n { starred~commands } }
- { \__nicematrix_instruction_of_type:nn { Iddots } { #2 , down = #3 , up = #4 } }
- \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_iddots }
+ {
+ \int_case:nnF \c@iRow
+ {
+ 0 { \__nicematrix_error:nn { in~first~row } \Iddots }
+ \l__nicematrix_last_row_int { \__nicematrix_error:nn { in~last~row } \Iddots }
+ }
+ {
+ \int_case:nnF \c@jCol
+ {
+ 0 { \__nicematrix_error:nn { in~first~col } \Iddots }
+ \l__nicematrix_last_col_int { \__nicematrix_error:nn { in~last~col } \Iddots }
+ }
+ {
+ \__nicematrix_instruction_of_type:nn { Iddots }
+ { #2 , down = #3 , up = #4 }
+ }
+
+ }
+ }
+ \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_iddots }
\bool_gset_true:N \g__nicematrix_empty_cell_bool
}
}
@@ -2170,7 +2510,7 @@
\int_compare:nNnT #1 > 1
{
\seq_gput_left:Nx \g__nicematrix_multicolumn_cells_seq
- { \int_eval:n \c@iRow - \int_use:N \c@jCol }
+ { \int_use:N \c@iRow - \int_use:N \c@jCol }
\seq_gput_left:Nn \g__nicematrix_multicolumn_sizes_seq { #1 }
}
\int_gadd:Nn \c@jCol { #1 - 1 }
@@ -2180,32 +2520,24 @@
\multicolumn { 1 } { C } { }
\__nicematrix_Hdotsfor_i
}
-\ExplSyntaxOff
-\def \@tempa { O { } m O { } E { _ ^ } { { } { } } }
-\ExplSyntaxOn
-\tl_set_eq:NN \l__nicematrix_a_signature_tl \@tempa
\AtBeginDocument
{
\tl_set:Nn \l__nicematrix_argspec_tl { O { } m O { } E { _ ^ } { { } { } } }
\tl_set_rescan:Nno \l__nicematrix_argspec_tl { } \l__nicematrix_argspec_tl
- \bool_if:NTF \c__nicematrix_draft_bool
+ \exp_args:NNV \NewDocumentCommand \__nicematrix_Hdotsfor_i \l__nicematrix_argspec_tl
{
- \exp_args:NNV \NewDocumentCommand \__nicematrix_Hdotsfor_i \l__nicematrix_argspec_tl
- { \prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { C } { } } }
- }
- {
- \exp_args:NNV \NewDocumentCommand \__nicematrix_Hdotsfor_i \l__nicematrix_argspec_tl
+ \tl_gput_right:Nx \g__nicematrix_HVdotsfor_lines_tl
{
- \tl_gput_right:Nx \g__nicematrix_Hdotsfor_lines_tl
+ \__nicematrix_Hdotsfor:nnnn
+ { \int_use:N \c@iRow }
+ { \int_use:N \c@jCol }
+ { #2 }
{
- \__nicematrix_Hdotsfor:nnnn
- { \int_use:N \c@iRow }
- { \int_use:N \c@jCol }
- { #2 }
- { #1 , #3 , down = #4 , up = #5 }
+ #1 , #3 ,
+ down = \exp_not:n { #4 } , up = \exp_not:n { #5 }
}
- \prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { C } { } }
}
+ \prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { C } { } }
}
}
\cs_new_protected:Npn \__nicematrix_Hdotsfor:nnnn #1 #2 #3 #4
@@ -2264,6 +2596,81 @@
\int_step_inline:nnn { #2 } { #2 + #3 - 1 }
{ \cs_set:cpn { __nicematrix _ dotted _ #1 - ##1 } { } }
}
+\AtBeginDocument
+ {
+ \tl_set:Nn \l__nicematrix_argspec_tl { O { } m O { } E { _ ^ } { { } { } } }
+ \tl_set_rescan:Nno \l__nicematrix_argspec_tl { } \l__nicematrix_argspec_tl
+ \exp_args:NNV \NewDocumentCommand \__nicematrix_Vdotsfor: \l__nicematrix_argspec_tl
+ {
+ \tl_gput_right:Nx \g__nicematrix_HVdotsfor_lines_tl
+ {
+ \__nicematrix_Vdotsfor:nnnn
+ { \int_use:N \c@iRow }
+ { \int_use:N \c@jCol }
+ { #2 }
+ {
+ #1 , #3 ,
+ down = \exp_not:n { #4 } , up = \exp_not:n { #5 }
+ }
+ }
+ }
+ }
+\cs_new_protected:Npn \__nicematrix_Vdotsfor:nnnn #1 #2 #3 #4
+ {
+ \bool_set_false:N \l__nicematrix_initial_open_bool
+ \bool_set_false:N \l__nicematrix_final_open_bool
+ \int_set:Nn \l__nicematrix_initial_j_int { #2 }
+ \int_set_eq:NN \l__nicematrix_final_j_int \l__nicematrix_initial_j_int
+ \int_compare:nNnTF #1 = 1
+ {
+ \int_set:Nn \l__nicematrix_initial_i_int 1
+ \bool_set_true:N \l__nicematrix_initial_open_bool
+ }
+ {
+ \cs_if_exist:cTF
+ {
+ pgf @ sh @ ns @ \__nicematrix_env:
+ - \int_eval:n { #1 - 1 }
+ - \int_use:N \l__nicematrix_initial_j_int
+ }
+ { \int_set:Nn \l__nicematrix_initial_i_int { #1 - 1 } }
+ {
+ \int_set:Nn \l__nicematrix_initial_i_int { #1 }
+ \bool_set_true:N \l__nicematrix_initial_open_bool
+ }
+ }
+ \int_compare:nNnTF { #1 + #3 -1 } = \c@iRow
+ {
+ \int_set:Nn \l__nicematrix_final_i_int { #1 + #3 - 1 }
+ \bool_set_true:N \l__nicematrix_final_open_bool
+ }
+ {
+ \cs_if_exist:cTF
+ {
+ pgf @ sh @ ns @ \__nicematrix_env:
+ - \int_eval:n { #1 + #3 }
+ - \int_use:N \l__nicematrix_final_j_int
+ }
+ { \int_set:Nn \l__nicematrix_final_i_int { #1 + #3 } }
+ {
+ \int_set:Nn \l__nicematrix_final_i_int { #1 + #3 - 1 }
+ \bool_set_true:N \l__nicematrix_final_open_bool
+ }
+ }
+ \group_begin:
+ \int_compare:nNnTF { #2 } = 0
+ { \color { nicematrix-first-col } }
+ {
+ \int_compare:nNnT { #2 } = \g__nicematrix_col_total_int
+ { \color { nicematrix-last-col } }
+ }
+ \keys_set:nn { NiceMatrix / xdots } { #4 }
+ \tl_if_empty:VF \l__nicematrix_xdots_color_tl { \color { \l__nicematrix_xdots_color_tl } }
+ \__nicematrix_actually_draw_Vdots:
+ \group_end:
+ \int_step_inline:nnn { #1 } { #1 + #3 - 1 }
+ { \cs_set:cpn { __nicematrix _ dotted _ ##1 - #2 } { } }
+ }
\cs_new_protected:Npn \__nicematrix_rotate: { \group_insert_after:N \__nicematrix_rotate_i: }
\cs_new_protected:Npn \__nicematrix_rotate_i: { \group_insert_after:N \__nicematrix_rotate_ii: }
\cs_new_protected:Npn \__nicematrix_rotate_ii: { \group_insert_after:N \__nicematrix_rotate_iii: }
@@ -2282,10 +2689,6 @@
}
\cs_new:Npn \__nicematrix_double_int_eval:n #1-#2 \q_stop
{ \int_eval:n { #1 } - \int_eval:n { #2 } }
-\ExplSyntaxOff
-\def \@tempa { O { } m m ! O { } E { _ ^ } { { } { } } }
-\ExplSyntaxOn
-\tl_set_eq:NN \l__nicematrix_a_signature_tl \@tempa
\AtBeginDocument
{
\tl_set:Nn \l__nicematrix_argspec_tl { O { } m m ! O { } E { _ ^ } { { } { } } }
@@ -2304,24 +2707,20 @@
\group_end:
}
}
-\bool_if:NTF \c__nicematrix_draft_bool
- { \cs_new_protected:Npn \__nicematrix_line_i:nn #1 #2 { } }
+\cs_new_protected:Npn \__nicematrix_line_i:nn #1 #2
{
- \cs_new_protected:Npn \__nicematrix_line_i:nn #1 #2
+ \bool_set_false:N \l__nicematrix_initial_open_bool
+ \bool_set_false:N \l__nicematrix_final_open_bool
+ \bool_if:nTF
{
- \bool_set_false:N \l__nicematrix_initial_open_bool
- \bool_set_false:N \l__nicematrix_final_open_bool
- \bool_if:nTF
- {
- \cs_if_free_p:c { pgf @ sh @ ns @ \__nicematrix_env: - #1 }
- ||
- \cs_if_free_p:c { pgf @ sh @ ns @ \__nicematrix_env: - #2 }
- }
- {
- \__nicematrix_error:nnn { unknown~cell~for~line~in~code-after } { #1 } { #2 }
- }
- { \__nicematrix_draw_line_ii:nn { #1 } { #2 } }
+ \cs_if_free_p:c { pgf @ sh @ ns @ \__nicematrix_env: - #1 }
+ ||
+ \cs_if_free_p:c { pgf @ sh @ ns @ \__nicematrix_env: - #2 }
+ }
+ {
+ \__nicematrix_error:nnn { unknown~cell~for~line~in~code-after } { #1 } { #2 }
}
+ { \__nicematrix_draw_line_ii:nn { #1 } { #2 } }
}
\AtBeginDocument
{
@@ -2335,14 +2734,166 @@
\cs_new_protected:Npn \__nicematrix_draw_line_iii:nn #1 #2
{
\pgfrememberpicturepositiononpagetrue
- \pgfpointshapeborder { \__nicematrix_env: - #1 } { \__nicematrix_qpoint: { #2 } }
+ \pgfpointshapeborder { \__nicematrix_env: - #1 } { \__nicematrix_qpoint:n { #2 } }
\dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x
\dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y
- \pgfpointshapeborder { \__nicematrix_env: - #2 } { \__nicematrix_qpoint: { #1 } }
+ \pgfpointshapeborder { \__nicematrix_env: - #2 } { \__nicematrix_qpoint:n { #1 } }
\dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x
\dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y
\__nicematrix_draw_line:
}
+\cs_set_protected:Npn \__nicematrix_cut_on_hyphen:w #1-#2\q_stop
+ {
+ \tl_set:Nn \l_tmpa_tl { #1 }
+ \tl_set:Nn \l_tmpb_tl { #2 }
+ }
+\cs_new_protected:Npn \__nicematrix_rowcolor:nn #1 #2
+ {
+ \tl_if_blank:nF { #1 }
+ {
+ \pgfpicture
+ \pgf@relevantforpicturesizefalse
+ \pgfsetfillcolor { #1 }
+ \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \c@jCol }
+ \dim_set_eq:NN \l_tmpa_dim \pgf@x
+ \clist_map_inline:nn { #2 }
+ {
+ \tl_set:Nn \l_tmpa_tl { ##1 }
+ \tl_if_in:NnTF \l_tmpa_tl { - }
+ { \__nicematrix_cut_on_hyphen:w ##1 \q_stop }
+ { \__nicematrix_cut_on_hyphen:w ##1 - ##1 \q_stop }
+ \tl_if_empty:NT \l_tmpa_tl { \tl_set:Nn \l_tmpa_tl { 1 } }
+ \tl_if_empty:NT \l_tmpb_tl
+ { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } }
+ \int_compare:nNnT \l_tmpb_tl > \c@iRow
+ { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } }
+ \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l_tmpb_tl }
+ \pgfpathrectanglecorners
+ { \__nicematrix_qpoint:n { row - \l_tmpa_tl } }
+ { \pgfpoint \l_tmpa_dim \pgf@y }
+ }
+ \pgfusepathqfill
+ \endpgfpicture
+ }
+ }
+\cs_new_protected:Npn \__nicematrix_columncolor:nn #1 #2
+ {
+ \tl_if_blank:nF { #1 }
+ {
+ \pgfpicture
+ \pgf@relevantforpicturesizefalse
+ \pgfsetfillcolor { #1 }
+ \__nicematrix_qpoint:n { row - 1 }
+ \dim_set_eq:NN \l_tmpa_dim \pgf@y
+ \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \c@iRow }
+ \dim_set_eq:NN \l_tmpb_dim \pgf@y
+ \clist_map_inline:nn { #2 }
+ {
+ \tl_set:Nn \l_tmpa_tl { ##1 }
+ \tl_if_in:NnTF \l_tmpa_tl { - }
+ { \__nicematrix_cut_on_hyphen:w ##1 \q_stop }
+ { \__nicematrix_cut_on_hyphen:w ##1 - ##1 \q_stop }
+ \tl_if_empty:NT \l_tmpa_tl { \tl_set:Nn \l_tmpa_tl { 1 } }
+ \tl_if_empty:NT \l_tmpb_tl
+ { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } }
+ \int_compare:nNnT \l_tmpb_tl > \c@jCol
+ { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } }
+ \__nicematrix_qpoint:n { col - \l_tmpa_tl }
+ \dim_set_eq:NN \l_tmpc_dim \pgf@x
+ \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l_tmpb_tl }
+ \pgfpathrectanglecorners
+ { \pgfpoint \l_tmpc_dim \l_tmpa_dim }
+ { \pgfpoint \pgf@x \l_tmpb_dim }
+ }
+ \pgfusepathqfill
+ \endpgfpicture
+ }
+ }
+\cs_new_protected:Npn \__nicematrix_cellcolor:nn #1 #2
+ {
+ \tl_if_blank:nF { #1 }
+ {
+ \pgfpicture
+ \pgf@relevantforpicturesizefalse
+ \pgfsetfillcolor { #1 }
+ \clist_map_inline:nn { #2 }
+ {
+ \__nicematrix_cut_on_hyphen:w ##1 \q_stop
+ \__nicematrix_qpoint:n { row - \l_tmpa_tl }
+ \bool_lazy_and:nnT
+ { \int_compare_p:n { \l_tmpa_tl <= \c@iRow } }
+ { \int_compare_p:n { \l_tmpb_tl <= \c@jCol } }
+ {
+ \dim_set_eq:NN \l_tmpb_dim \pgf@y
+ \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l_tmpa_tl }
+ \dim_set_eq:NN \l_tmpa_dim \pgf@y
+ \__nicematrix_qpoint:n { col - \l_tmpb_tl }
+ \dim_set_eq:NN \l_tmpc_dim \pgf@x
+ \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l_tmpb_tl }
+ \dim_set_eq:NN \l_tmpd_dim \pgf@x
+ \pgfpathrectanglecorners
+ { \pgfpoint \l_tmpc_dim \l_tmpb_dim }
+ { \pgfpoint \l_tmpd_dim \l_tmpa_dim }
+ }
+ }
+ \pgfusepathqfill
+ \endpgfpicture
+ }
+ }
+\cs_new_protected:Npn \__nicematrix_rectanglecolor:nnn #1 #2 #3
+ {
+ \tl_if_blank:nF { #1 }
+ {
+ \pgfpicture
+ \pgf@relevantforpicturesizefalse
+ \pgfsetfillcolor { #1 }
+ \__nicematrix_cut_on_hyphen:w #2 \q_stop
+ \bool_lazy_and:nnT
+ { \int_compare_p:n { \l_tmpa_tl <= \c@iRow } }
+ { \int_compare_p:n { \l_tmpb_tl <= \c@jCol } }
+ {
+ \__nicematrix_qpoint:n { row - \l_tmpa_tl }
+ \dim_set_eq:NN \l_tmpb_dim \pgf@y
+ \__nicematrix_qpoint:n { col - \l_tmpb_tl }
+ \__nicematrix_cut_on_hyphen:w #3 \q_stop
+ \int_compare:nNnT \l_tmpa_tl > \c@iRow
+ { \tl_set:Nx \l_tmpa_tl { \int_use:N \c@iRow } }
+ \int_compare:nNnT \l_tmpb_tl > \c@jCol
+ { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } }
+ \dim_set_eq:NN \l_tmpc_dim \pgf@x
+ \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l_tmpa_tl }
+ \dim_set_eq:NN \l_tmpa_dim \pgf@y
+ \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l_tmpb_tl }
+ \dim_set_eq:NN \l_tmpd_dim \pgf@x
+ \pgfpathrectanglecorners
+ { \pgfpoint \l_tmpc_dim \l_tmpb_dim }
+ { \pgfpoint \l_tmpd_dim \l_tmpa_dim }
+ \pgfusepathqfill
+ }
+ \endpgfpicture
+ }
+ }
+\cs_new_protected:Npn \__nicematrix_rowcolors:nnn #1 #2 #3
+ {
+ \int_step_inline:nnn { #1 } { \int_use:N \c@iRow }
+ {
+ \int_if_odd:nTF { ##1 }
+ { \__nicematrix_rowcolor:nn { #2 } { ##1 } }
+ { \__nicematrix_rowcolor:nn { #3 } { ##1 } }
+ }
+ }
+\cs_new_protected:Npn \__nicematrix_chessboardcolors:nn #1 #2
+ {
+ \int_step_inline:nn { \int_use:N \c@iRow }
+ {
+ \int_step_inline:nn { \int_use:N \c@jCol }
+ {
+ \int_if_even:nTF { ####1 + ##1 }
+ { \__nicematrix_cellcolor:nn { #1 } { ####1 - ##1 } }
+ { \__nicematrix_cellcolor:nn { #2 } { ####1 - ##1 } }
+ }
+ }
+ }
\cs_set_eq:NN \OnlyMainNiceMatrix \use:n
\cs_new_protected:Npn \__nicematrix_OnlyMainNiceMatrix:n #1
{
@@ -2362,20 +2913,20 @@
\int_compare:nNnF \c@iRow = 0
{ \int_compare:nNnF \c@iRow = \l__nicematrix_last_row_int { #1 } }
}
-\cs_new_protected:Npn \__nicematrix_vline: { \__nicematrix_OnlyMainNiceMatrix:n { \__nicematrix_vline_i: } }
-\cs_set_eq:NN \__nicematrix_vline_i: \vline
+\cs_new_protected:Npn \__nicematrix_vline:
+ { \__nicematrix_OnlyMainNiceMatrix:n { { \CT@arc@ \vline } } }
\cs_new_protected:Npn \__nicematrix_draw_vlines:
{
\group_begin:
- \bool_if:NT \c__nicematrix_colortbl_loaded_bool \CT@arc@
+ \CT@arc@
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
\pgfsetlinewidth \arrayrulewidth
- \__nicematrix_qpoint: {row - 1 }
+ \__nicematrix_qpoint:n { row - 1 }
\dim_set_eq:NN \l_tmpa_dim \pgf@y
\pgfusepathqfill
- \__nicematrix_qpoint: { row - \__nicematrix_succ:n \c@iRow }
+ \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \c@iRow }
\dim_sub:Nn \l_tmpa_dim \pgf@y
\pgfusepathqfill
\dim_zero:N \l_tmpb_dim
@@ -2383,63 +2934,33 @@
{
\dim_set_eq:NN \l_tmpb_dim \g__nicematrix_dp_last_row_dim
\dim_add:Nn \l_tmpb_dim \g__nicematrix_ht_last_row_dim
- \__nicematrix_qpoint: { row - \__nicematrix_succ:n\c@iRow }
+ \__nicematrix_qpoint:n { row - \__nicematrix_succ:n\c@iRow }
\dim_add:Nn \l_tmpa_dim \pgf@y
- \__nicematrix_qpoint: { row - \__nicematrix_succ:n \g__nicematrix_row_total_int }
+ \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \g__nicematrix_row_total_int }
\dim_sub:Nn \l_tmpa_dim \pgf@y
\dim_sub:Nn \l_tmpa_dim \l_tmpb_dim
}
+ \dim_add:Nn \l_tmpa_dim \arrayrulewidth
\int_step_inline:nnn
{ \bool_if:NTF \l__nicematrix_NiceArray_bool 1 2 }
{ \bool_if:NTF \l__nicematrix_NiceArray_bool { \__nicematrix_succ:n \c@jCol } \c@jCol }
{
- \pgfpathmoveto
- {
- \pgfpointadd
- { \__nicematrix_qpoint: { col - ##1 } }
- {
- \pgfpoint
- {
- -0.5 \arrayrulewidth
- \int_compare:nNnT { ##1 } = 1
- {
- \int_compare:nNnT \l__nicematrix_first_col_int = 1
- { + \arrayrulewidth }
- }
- }
- { \l_tmpb_dim }
- }
- }
+ \pgfpathmoveto { \__nicematrix_qpoint:n { col - ##1 } }
\pgfpathlineto
{
\pgfpointadd
- { \__nicematrix_qpoint: { col - ##1 } }
- {
- \pgfpoint
- {
- -0.5 \arrayrulewidth
- \int_compare:nNnT { ##1 } = 1
- {
- \int_compare:nNnT \l__nicematrix_first_col_int = 1
- { + \arrayrulewidth }
- }
- }
- { \l_tmpb_dim + \l_tmpa_dim }
- }
+ { \__nicematrix_qpoint:n { col - ##1 } }
+ { \pgfpoint \c_zero_dim { \l_tmpb_dim + \l_tmpa_dim } }
}
}
\pgfusepathqstroke
\endpgfpicture
\group_end:
}
-\bool_if:NTF \c__nicematrix_draft_bool
- { \cs_new:Npn \__nicematrix_hdottedline: { } }
+\cs_new:Npn \__nicematrix_hdottedline:
{
- \cs_new:Npn \__nicematrix_hdottedline:
- {
- \noalign { \skip_vertical:N 2\l__nicematrix_radius_dim }
- \__nicematrix_hdottedline_i:
- }
+ \noalign { \skip_vertical:N 2\l__nicematrix_radius_dim }
+ \__nicematrix_hdottedline_i:
}
\cs_new_protected:Npn \__nicematrix_hdottedline_i:
{
@@ -2460,16 +2981,24 @@
\cs_new_protected:Npn \__nicematrix_hdottedline_i:n #1
{
\pgfrememberpicturepositiononpagetrue
- \__nicematrix_qpoint: { row - #1 }
+ \__nicematrix_qpoint:n { row - #1 }
\dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y
\dim_sub:Nn \l__nicematrix_y_initial_dim \l__nicematrix_radius_dim
\dim_set_eq:NN \l__nicematrix_y_final_dim \l__nicematrix_y_initial_dim
- \__nicematrix_qpoint: { col - 1 }
+ \__nicematrix_qpoint:n { col - 1 }
\dim_set:Nn \l__nicematrix_x_initial_dim
- { \pgf@x + \arraycolsep - \l__nicematrix_left_margin_dim }
- \__nicematrix_qpoint: { col - \__nicematrix_succ:n \c@jCol }
+ {
+ \pgf@x +
+ \bool_if:NTF \l__nicematrix_NiceTabular_bool \tabcolsep \arraycolsep
+ - \l__nicematrix_left_margin_dim
+ }
+ \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \c@jCol }
\dim_set:Nn \l__nicematrix_x_final_dim
- { \pgf@x - \arraycolsep + \l__nicematrix_right_margin_dim }
+ {
+ \pgf@x -
+ \bool_if:NTF \l__nicematrix_NiceTabular_bool \tabcolsep \arraycolsep
+ + \l__nicematrix_right_margin_dim
+ }
\tl_set:Nn \l_tmpa_tl { ( }
\tl_if_eq:NNF \l__nicematrix_left_delim_tl \l_tmpa_tl
{ \dim_gadd:Nn \l__nicematrix_x_initial_dim { 0.5 \l__nicematrix_inter_dots_dim } }
@@ -2479,36 +3008,32 @@
\tl_set_eq:NN \l__nicematrix_xdots_line_style_tl \c__nicematrix_standard_tl
\__nicematrix_draw_line:
}
-\bool_if:nTF \c__nicematrix_draft_bool
- { \cs_new_protected:Npn \__nicematrix_vdottedline:n #1 { } }
+\cs_new_protected:Npn \__nicematrix_vdottedline:n #1
{
- \cs_new_protected:Npn \__nicematrix_vdottedline:n #1
+ \bool_set_true:N \l__nicematrix_initial_open_bool
+ \bool_set_true:N \l__nicematrix_final_open_bool
+ \bool_if:NTF \c__nicematrix_tikz_loaded_bool
{
- \bool_set_true:N \l__nicematrix_initial_open_bool
- \bool_set_true:N \l__nicematrix_final_open_bool
- \bool_if:NTF \c__nicematrix_tikz_loaded_bool
- {
- \tikzpicture
- \__nicematrix_vdottedline_i:n { #1 }
- \endtikzpicture
- }
- {
- \pgfpicture
- \__nicematrix_vdottedline_i:n { #1 }
- \endpgfpicture
- }
+ \tikzpicture
+ \__nicematrix_vdottedline_i:n { #1 }
+ \endtikzpicture
+ }
+ {
+ \pgfpicture
+ \__nicematrix_vdottedline_i:n { #1 }
+ \endpgfpicture
}
}
\cs_new_protected:Npn \__nicematrix_vdottedline_i:n #1
{
- \bool_if:NT \c__nicematrix_colortbl_loaded_bool \CT@arc@
+ \CT@arc@
\pgfrememberpicturepositiononpagetrue
- \__nicematrix_qpoint: { col - \int_eval:n { #1 + 1 } }
+ \__nicematrix_qpoint:n { col - \int_eval:n { #1 + 1 } }
\dim_set:Nn \l__nicematrix_x_initial_dim { \pgf@x - \l__nicematrix_radius_dim }
\dim_set:Nn \l__nicematrix_x_final_dim { \pgf@x - \l__nicematrix_radius_dim }
- \__nicematrix_qpoint: { row - 1 }
+ \__nicematrix_qpoint:n { row - 1 }
\dim_set:Nn \l__nicematrix_y_initial_dim { \pgf@y - 0.5 \l__nicematrix_inter_dots_dim }
- \__nicematrix_qpoint: { row - \__nicematrix_succ:n \c@iRow }
+ \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \c@iRow }
\dim_set:Nn \l__nicematrix_y_final_dim { \pgf@y + 0.5 \l__nicematrix_inter_dots_dim }
\tl_set_eq:NN \l__nicematrix_xdots_line_style_tl \c__nicematrix_standard_tl
\__nicematrix_draw_line:
@@ -2600,7 +3125,7 @@
\dim_compare:nNnT
{ \dim_use:c { l__nicematrix_row _ \__nicematrix_i: _ min _ dim } } = \c_max_dim
{
- \__nicematrix_qpoint: { row - \__nicematrix_i: - base }
+ \__nicematrix_qpoint:n { row - \__nicematrix_i: - base }
\dim_set:cn { l__nicematrix_row _ \__nicematrix_i: _ max _ dim } \pgf@y
\dim_set:cn { l__nicematrix_row _ \__nicematrix_i: _ min _ dim } \pgf@y
}
@@ -2610,7 +3135,7 @@
\dim_compare:nNnT
{ \dim_use:c { l__nicematrix_column _ \__nicematrix_j: _ min _ dim } } = \c_max_dim
{
- \__nicematrix_qpoint: { col - \__nicematrix_j: }
+ \__nicematrix_qpoint:n { col - \__nicematrix_j: }
\dim_set:cn { l__nicematrix_column _ \__nicematrix_j: _ max _ dim } \pgf@y
\dim_set:cn { l__nicematrix_column _ \__nicematrix_j: _ min _ dim } \pgf@y
}
@@ -2779,26 +3304,29 @@
\pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgf@relevantforpicturesizefalse
- \__nicematrix_qpoint: { row - #1 }
+ \__nicematrix_qpoint:n { row - #1 }
\dim_set_eq:NN \l_tmpa_dim \pgf@y
- \__nicematrix_qpoint: { col - #2 }
+ \__nicematrix_qpoint:n { col - #2 }
\dim_set_eq:NN \l_tmpb_dim \pgf@x
- \__nicematrix_qpoint: { row - \__nicematrix_succ:n { #3 } }
+ \__nicematrix_qpoint:n { row - \__nicematrix_succ:n { #3 } }
\dim_set_eq:NN \l_tmpc_dim \pgf@y
- \__nicematrix_qpoint: { col - \__nicematrix_succ:n { #4 } }
+ \__nicematrix_qpoint:n { col - \__nicematrix_succ:n { #4 } }
\dim_set_eq:NN \l_tmpd_dim \pgf@x
\bool_if:NT \l__nicematrix_white_bool
{
\begin { pgfscope }
\pgfsetfillcolor { white }
- \int_compare:nNnT { #2 } = 1
+ \pgfpathrectanglecorners
{
- \int_compare:nNnT \l__nicematrix_first_col_int = 1
- { \dim_add:Nn \l_tmpb_dim \arrayrulewidth }
+ \pgfpoint
+ { \l_tmpb_dim + 0.5 \arrayrulewidth }
+ { \l_tmpa_dim - 0.5 \arrayrulewidth }
+ }
+ {
+ \pgfpoint
+ { \l_tmpd_dim - 0.5 \arrayrulewidth }
+ { \l_tmpc_dim + 0.5 \arrayrulewidth }
}
- \pgfpathrectanglecorners
- { \pgfpoint \l_tmpb_dim { \l_tmpa_dim - \arrayrulewidth } }
- { \pgfpoint { \l_tmpd_dim - \arrayrulewidth } \l_tmpc_dim }
\pgfusepathqfill
\end { pgfscope }
}
@@ -2817,14 +3345,14 @@
}
\int_compare:nNnTF { #1 } = { #3 }
{
- \pgfextracty \l_tmpa_dim { \__nicematrix_qpoint: { row - #1 - base } }
- \__nicematrix_qpoint: { #1 - #2 - block }
+ \pgfextracty \l_tmpa_dim { \__nicematrix_qpoint:n { row - #1 - base } }
+ \__nicematrix_qpoint:n { #1 - #2 - block }
\pgftransformshift { \pgfpoint \pgf@x \l_tmpa_dim }
\pgfnode { rectangle } { base }
{ \box_use_drop:N \l__nicematrix_cell_box } { } { }
}
{
- \pgftransformshift { \__nicematrix_qpoint: { #1 - #2 - block } }
+ \pgftransformshift { \__nicematrix_qpoint:n { #1 - #2 - block } }
\pgfnode { rectangle } { center }
{ \box_use_drop:N \l__nicematrix_cell_box } { } { }
}
@@ -2895,6 +3423,60 @@
\__nicematrix_define_com:nnn v | |
\__nicematrix_define_com:nnn V \| \|
\__nicematrix_define_com:nnn B \{ \}
+\NewDocumentCommand \AutoNiceMatrix { O { } m O { } m ! O { } }
+ {
+ \group_begin:
+ \bool_set_true:N \l__nicematrix_NiceArray_bool
+ \AutoNiceMatrixWithDelims . . { #2 } { #4 } [ #1 , #3 , #5 ]
+ \group_end:
+ }
+\cs_set_eq:NN \__nicematrix_dotfill \dotfill
+\cs_new_protected:Npn \__nicematrix_dotfill:
+ {
+ \__nicematrix_dotfill
+ \group_insert_after:N \__nicematrix_dotfill_i:
+ }
+\cs_new_protected:Npn \__nicematrix_dotfill_i: { \group_insert_after:N \__nicematrix_dotfill_ii: }
+\cs_new_protected:Npn \__nicematrix_dotfill_ii: { \group_insert_after:N \__nicematrix_dotfill_iii: }
+\cs_new_protected:Npn \__nicematrix_dotfill_iii:
+ { \dim_compare:nNnT { \box_wd:N \l__nicematrix_cell_box } = \c_zero_dim \__nicematrix_dotfill }
+\cs_new_protected:Npn \__nicematrix_slashbox:nn #1 #2
+ {
+ \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
+ {
+ \__nicematrix_actually_slashbox:nnnn
+ { \int_use:N \c@iRow } { \int_use:N \c@jCol } { #1 } { #2 }
+ }
+ }
+\cs_new_protected:Npn \__nicematrix_actually_slashbox:nnnn #1 #2 #3 #4
+ {
+ \pgfpicture
+ \pgf@relevantforpicturesizefalse
+ \pgfrememberpicturepositiononpagetrue
+ \__nicematrix_qpoint:n { row - #1 }
+ \dim_set_eq:NN \l_tmpa_dim \pgf@y
+ \__nicematrix_qpoint:n { col - #2 }
+ \dim_set_eq:NN \l_tmpb_dim \pgf@x
+ \pgfpathmoveto { \pgfpoint \l_tmpb_dim \l_tmpa_dim }
+ \__nicematrix_qpoint:n { row - \__nicematrix_succ:n { #1 } }
+ \dim_set_eq:NN \l_tmpc_dim \pgf@y
+ \__nicematrix_qpoint:n { col - \__nicematrix_succ:n { #2 } }
+ \dim_set_eq:NN \l_tmpd_dim \pgf@x
+ \pgfpathlineto { \pgfpoint \l_tmpd_dim \l_tmpc_dim }
+ {
+ \CT@arc@
+ \pgfsetroundcap
+ \pgfusepathqstroke
+ }
+ \pgfset { inner~sep = 1 pt }
+ \pgfscope
+ \pgftransformshift { \pgfpoint \l_tmpb_dim \l_tmpc_dim }
+ \pgfnode { rectangle } { south~west } { $ #3 $ } { } { }
+ \endpgfscope
+ \pgftransformshift { \pgfpoint \l_tmpd_dim \l_tmpa_dim }
+ \pgfnode { rectangle } { north~east } { $ #4 $ } { } { }
+ \endpgfpicture
+ }
\cs_new_protected:Npn \__nicematrix_CodeAfter:n #1 \end
{
\tl_gput_right:Nn \g__nicematrix_code_after_tl { #1 }
@@ -2902,14 +3484,22 @@
}
\cs_new_protected:Npn \__nicematrix_CodeAfter_i:n #1
{
- \bool_if:NTF { \str_if_eq_p:Vn \g__nicematrix_name_env_str { #1 } }
+ \str_set:NV \l_tmpa_str \@currenvir
+ \bool_if:NTF { \str_if_eq_p:Vn \l_tmpa_str { #1 } }
{ \end { #1 } }
{
\tl_gput_right:Nn \g__nicematrix_code_after_tl { \end { #1 } }
\__nicematrix_CodeAfter:n
}
}
-\bool_new:N \c__nicematrix_obsolete_environments_bool
+\__nicematrix_msg_new:nn { obsolete~environments }
+ {
+ The~obsolete~environments~(eg.~{pNiceArrayC})~have~been~deleted~
+ from~the~package~nicematrix.\\
+ However,~if~you~still~want~to~use~them,~you~will~find~the~code~for~
+ those~environments~at~the~end~of~the~file~'nicematrix.sty',~after~
+ a~command~'\token_to_str:N\file_input_stop:'.
+ }
\keys_define:nn { NiceMatrix / Package }
{
renew-dots .bool_set:N = \l__nicematrix_renew_dots_bool ,
@@ -2918,9 +3508,7 @@
renew-matrix .value_forbidden:n = true ,
transparent .meta:n = { renew-dots , renew-matrix } ,
transparent .value_forbidden:n = true,
- obsolete-environments .bool_set:N = \c__nicematrix_obsolete_environments_bool ,
- obsolete-environments .value_forbidden:n = true ,
- obsolete-environments .default:n = true ,
+ obsolete-environments .code:n = \__nicematrix_fatal:n { obsolete~environments },
starred-commands .code:n =
\__nicematrix_msg_redirect_name:nn { starred~commands } { none } ,
starred-commands .value_forbidden:n = true ,
@@ -2961,7 +3549,7 @@
}
\cs_new:Npn \__nicematrix_message_hdotsfor:
{
- \tl_if_empty:VF \g__nicematrix_Hdotsfor_lines_tl
+ \tl_if_empty:VF \g__nicematrix_HVdotsfor_lines_tl
{ ~Maybe~your~use~of~\token_to_str:N \Hdotsfor\ is~incorrect.}
}
\__nicematrix_msg_new:nn { too~much~cols~for~matrix~with~last~col }
@@ -2986,6 +3574,32 @@
\int_eval:n { \c@jCol - 1 }~(plus~the~potential~exterior~ones).~
This~error~is~fatal.
}
+\__nicematrix_msg_new:nn { in~first~col }
+ {
+ You~can't~use~the~command~#1 in~the~first~column~(number~0)~of~the~array.\\
+ If~you~go~on,~this~command~will~be~ignored.
+ }
+\__nicematrix_msg_new:nn { in~last~col }
+ {
+ You~can't~use~the~command~#1 in~the~last~column~(exterior)~of~the~array.\\
+ If~you~go~on,~this~command~will~be~ignored.
+ }
+\__nicematrix_msg_new:nn { in~first~row }
+ {
+ You~can't~use~the~command~#1 in~the~first~row~(number~0)~of~the~array.\\
+ If~you~go~on,~this~command~will~be~ignored.
+ }
+\__nicematrix_msg_new:nn { in~last~row }
+ {
+ You~can't~use~the~command~#1 in~the~last~row~(exterior)~of~the~array.\\
+ If~you~go~on,~this~command~will~be~ignored.
+ }
+\__nicematrix_msg_new:nn { option~S~without~siunitx }
+ {
+ You~can't~use~the~option~'S'~in~your~environment~\__nicematrix_full_name_env:
+ because~you~have~not~loaded~siunitx.\\
+ If~you~go~on,~this~option~will~be~ignored.
+ }
\__nicematrix_msg_new:nn { bad~option~for~line-style }
{
Since~you~haven't~loaded~Tikz,~the~only~value~you~can~give~to~'line-style'~
@@ -3043,6 +3657,13 @@
However,~you~can~go~on~for~this~time~
(the~value~'\l_keys_value_tl'~will~be~ignored).
}
+\__nicematrix_msg_new:nn { last-col~non~empty~for~NiceMatrixOptions }
+ {
+ In~\NiceMatrixoptions,~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).
+ }
\__nicematrix_msg_new:nn { Block~too~large }
{
You~try~to~draw~a~block~in~the~cell~#1-#2~of~your~matrix~but~the~matrix~is~
@@ -3084,6 +3705,8 @@
The~available~options~are~(in~alphabetic~order):~
allow-duplicate-names,~
code-for-first-col,~
+ cell-space-bottom-limit,~
+ cell-space-top-limit,~
code-for-first-row,~
code-for-last-col,~
code-for-last-row,~
@@ -3092,8 +3715,12 @@
create-large-nodes,~
end-of-row,~
exterior-arraycolsep,~
+ first-col,~
+ first-row,~
hlines,~
hvlines,~
+ last-col,~
+ last-row,~
left-margin,~
letter-for-dotted-lines,~
light-syntax,~
@@ -3121,6 +3748,8 @@
b,~
baseline,~
c,~
+ cell-space-bottom-limit,~
+ cell-space-top-limit,~
code-after,~
code-for-first-col,~
code-for-first-row,~
@@ -3165,6 +3794,8 @@
b,~
baseline,~
c,~
+ cell-space-bottom-limit,~
+ cell-space-top-limit,~
code-after,~
code-for-first-col,~
code-for-first-row,~
@@ -3192,6 +3823,7 @@
r~(=R),~
renew-dots,~
right-margin,~
+ S,~
small,~
t,~
vlines,~
@@ -3199,6 +3831,51 @@
xdots/shorten~and~
xdots/line-style.
}
+\__nicematrix_msg_new:nnn { Unknown~option~for~NiceTabular }
+ {
+ The~option~'\tl_use:N\l_keys_key_str'~is~unknown~for~the~environment~
+ \{NiceTabular\}. \\
+ 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):~
+ b,~
+ baseline,~
+ c,~
+ cell-space-bottom-limit,~
+ cell-space-top-limit,~
+ code-after,~
+ code-for-first-col,~
+ code-for-first-row,~
+ code-for-last-col,~
+ code-for-last-row,~
+ columns-width,~
+ create-extra-nodes,~
+ create-medium-nodes,~
+ create-large-nodes,~
+ end-of-row,~
+ extra-left-margin,~
+ extra-right-margin,~
+ first-col,~
+ first-row,~
+ hlines,~
+ hvlines,~
+ last-col,~
+ last-row,~
+ left-margin,~
+ light-syntax,~
+ name,~
+ nullify-dots,~
+ parallelize-diags,~
+ renew-dots,~
+ right-margin,~
+ t,~
+ vlines,~
+ xdots/color,~
+ xdots/shorten~and~
+ xdots/line-style.
+ }
\__nicematrix_msg_new:nnn { Duplicate~name }
{
The~name~'\l_keys_value_tl'~is~already~used~and~you~shouldn't~use~
@@ -3223,87 +3900,85 @@
and~R~in~the~preamble~of~your~environment. \\
This~error~is~fatal.
}
-\bool_if:NT \c__nicematrix_obsolete_environments_bool
+\file_input_stop:
+\NewDocumentEnvironment { pNiceArrayC } { }
{
- \NewDocumentEnvironment { pNiceArrayC } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \pNiceArray
- }
- { \endpNiceArray }
- \NewDocumentEnvironment { bNiceArrayC } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \bNiceArray
- }
- { \endbNiceArray }
- \NewDocumentEnvironment { BNiceArrayC } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \BNiceArray
- }
- { \endBNiceArray }
- \NewDocumentEnvironment { vNiceArrayC } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \vNiceArray
- }
- { \endvNiceArray }
- \NewDocumentEnvironment { VNiceArrayC } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \VNiceArray
- }
- { \endVNiceArray }
- \NewDocumentEnvironment { pNiceArrayRC } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \int_zero:N \l__nicematrix_first_row_int
- \pNiceArray
- }
- { \endpNiceArray }
- \NewDocumentEnvironment { bNiceArrayRC } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \int_zero:N \l__nicematrix_first_row_int
- \bNiceArray
- }
- { \endbNiceArray }
- \NewDocumentEnvironment { BNiceArrayRC } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \int_zero:N \l__nicematrix_first_row_int
- \BNiceArray
- }
- { \endBNiceArray }
- \NewDocumentEnvironment { vNiceArrayRC } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \int_zero:N \l__nicematrix_first_row_int
- \vNiceArray
- }
- { \endvNiceArray }
- \NewDocumentEnvironment { VNiceArrayRC } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \int_zero:N \l__nicematrix_first_row_int
- \VNiceArray
- }
- { \endVNiceArray }
- \NewDocumentEnvironment { NiceArrayCwithDelims } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \NiceArrayWithDelims
- }
- { \endNiceArrayWithDelims }
- \NewDocumentEnvironment { NiceArrayRCwithDelims } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \int_zero:N \l__nicematrix_first_row_int
- \NiceArrayWithDelims
- }
- { \endNiceArrayWithDelims }
+ \int_zero:N \l__nicematrix_last_col_int
+ \pNiceArray
+ }
+ { \endpNiceArray }
+ \NewDocumentEnvironment { bNiceArrayC } { }
+ {
+ \int_zero:N \l__nicematrix_last_col_int
+ \bNiceArray
+ }
+ { \endbNiceArray }
+\NewDocumentEnvironment { BNiceArrayC } { }
+ {
+ \int_zero:N \l__nicematrix_last_col_int
+ \BNiceArray
+ }
+ { \endBNiceArray }
+\NewDocumentEnvironment { vNiceArrayC } { }
+ {
+ \int_zero:N \l__nicematrix_last_col_int
+ \vNiceArray
}
+ { \endvNiceArray }
+\NewDocumentEnvironment { VNiceArrayC } { }
+ {
+ \int_zero:N \l__nicematrix_last_col_int
+ \VNiceArray
+ }
+ { \endVNiceArray }
+\NewDocumentEnvironment { pNiceArrayRC } { }
+ {
+ \int_zero:N \l__nicematrix_last_col_int
+ \int_zero:N \l__nicematrix_first_row_int
+ \pNiceArray
+ }
+ { \endpNiceArray }
+\NewDocumentEnvironment { bNiceArrayRC } { }
+ {
+ \int_zero:N \l__nicematrix_last_col_int
+ \int_zero:N \l__nicematrix_first_row_int
+ \bNiceArray
+ }
+ { \endbNiceArray }
+\NewDocumentEnvironment { BNiceArrayRC } { }
+ {
+ \int_zero:N \l__nicematrix_last_col_int
+ \int_zero:N \l__nicematrix_first_row_int
+ \BNiceArray
+ }
+ { \endBNiceArray }
+\NewDocumentEnvironment { vNiceArrayRC } { }
+ {
+ \int_zero:N \l__nicematrix_last_col_int
+ \int_zero:N \l__nicematrix_first_row_int
+ \vNiceArray
+ }
+ { \endvNiceArray }
+\NewDocumentEnvironment { VNiceArrayRC } { }
+ {
+ \int_zero:N \l__nicematrix_last_col_int
+ \int_zero:N \l__nicematrix_first_row_int
+ \VNiceArray
+ }
+ { \endVNiceArray }
+\NewDocumentEnvironment { NiceArrayCwithDelims } { }
+ {
+ \int_zero:N \l__nicematrix_last_col_int
+ \NiceArrayWithDelims
+ }
+ { \endNiceArrayWithDelims }
+\NewDocumentEnvironment { NiceArrayRCwithDelims } { }
+ {
+ \int_zero:N \l__nicematrix_last_col_int
+ \int_zero:N \l__nicematrix_first_row_int
+ \NiceArrayWithDelims
+ }
+ { \endNiceArrayWithDelims }
\endinput
%%