summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/nicematrix/nicematrix-code.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/nicematrix/nicematrix-code.dtx')
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix-code.dtx1224
1 files changed, 731 insertions, 493 deletions
diff --git a/macros/latex/contrib/nicematrix/nicematrix-code.dtx b/macros/latex/contrib/nicematrix/nicematrix-code.dtx
index 8246cffbd8..4605970134 100644
--- a/macros/latex/contrib/nicematrix/nicematrix-code.dtx
+++ b/macros/latex/contrib/nicematrix/nicematrix-code.dtx
@@ -17,8 +17,8 @@
%
% \fi
% \iffalse
-\def\myfileversion{6.24}
-\def\myfiledate{2023/09/28}
+\def\myfileversion{6.25}
+\def\myfiledate{2023/10/24}
%
%
%<*batchfile>
@@ -62,6 +62,9 @@ version 2005/12/01 or later.
\def\interitem{\vspace{7mm plus 2 mm minus 3mm}}
\fvset{commandchars=\~\#\@,formatcom=\color{gray}}
+
+\usepackage{upquote}
+
\usepackage{titlesec}
\titlespacing*{\section}{0pt}{6.5ex plus 1ex minus .2ex}{4.3ex plus .2ex}
\titlespacing*{\subsection}{0pt}{4.5ex plus 1ex minus .2ex}{2ex plus .2ex}
@@ -166,7 +169,7 @@ version 2005/12/01 or later.
\cs_new_protected:Npn \@@_error:n { \msg_error:nn { nicematrix } }
\cs_new_protected:Npn \@@_warning:n { \msg_warning:nn { nicematrix } }
\cs_new_protected:Npn \@@_error:nn { \msg_error:nnn { nicematrix } }
-\cs_generate_variant:Nn \@@_error:nn { n x }
+\cs_generate_variant:Nn \@@_error:nn { n e }
\cs_new_protected:Npn \@@_error:nnn { \msg_error:nnnn { nicematrix } }
\cs_new_protected:Npn \@@_fatal:n { \msg_fatal:nn { nicematrix } }
\cs_new_protected:Npn \@@_fatal:nn { \msg_fatal:nnn { nicematrix } }
@@ -376,7 +379,6 @@ version 2005/12/01 or later.
%
% \begin{macrocode}
\cs_generate_variant:Nn \seq_set_split:Nnn { N V n }
-\cs_generate_variant:Nn \keys_define:nn { n x }
\cs_generate_variant:Nn \str_lowercase:n { V }
% \end{macrocode}
%
@@ -412,14 +414,14 @@ version 2005/12/01 or later.
%
% We test whether the current class is \cls{revtex4-1} (deprecated) or
% \cls{revtex4-2} because these classes redefines |\array| (of \pkg{array}) in a
-% way incompatible with our programmation. At the date March 2023, the current
-% version \cls{revtex4-2} is 4.2e (compatible with \pkg{booktabs}).
+% way incompatible with our programmation. At the date May 2023, the current
+% version \cls{revtex4-2} is 4.2f (compatible with \pkg{booktabs}).
%
% \begin{macrocode}
-\@ifclassloaded { revtex4-1 }
+\IfClassLoadedTF { revtex4-1 }
{ \bool_const:Nn \c_@@_revtex_bool \c_true_bool }
{
- \@ifclassloaded { revtex4-2 }
+ \IfClassLoadedTF { revtex4-2 }
{ \bool_const:Nn \c_@@_revtex_bool \c_true_bool }
{
% \end{macrocode}
@@ -438,12 +440,6 @@ version 2005/12/01 or later.
\cs_generate_variant:Nn \tl_if_single_token_p:n { V }
% \end{macrocode}
%
-% \bigskip
-% The following regex will be used to modify the preamble of the array when the
-% key |color-inside| is used.
-% \begin{macrocode}
-\regex_const:Nn \c_@@_columncolor_regex { \c { columncolor } }
-% \end{macrocode}
%
% \bigskip
% If the final user uses \pkg{nicematrix}, PGF/Tikz will write instruction
@@ -573,7 +569,7 @@ version 2005/12/01 or later.
\cs_set:Npn \@@_standard_cline #1 { \@@_standard_cline:w #1 \q_stop }
\cs_set:Npn \@@_standard_cline:w #1-#2 \q_stop
{
- \int_compare:nNnT \l_@@_first_col_int = 0 { \omit & }
+ \int_if_zero:nT \l_@@_first_col_int { \omit & }
\int_compare:nNnT { #1 } > 1 { \multispan { \int_eval:n { #1 - 1 } } & }
\multispan { \int_eval:n { #2 - #1 + 1 } }
{
@@ -722,6 +718,98 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
+% Since we will do ourself the expansion of the preamble of the array, we will
+% modify |\@mkpream| of \pkg{array} in order to skip the operation of expansion
+% done by |\@mkpream|.
+% \begin{macrocode}
+\cs_set_eq:NN \@@_old_mkpream: \@mkpream
+\cs_set_protected:Npn \@@_mkpream: #1
+ {
+% \end{macrocode}
+% The command |\@@_mkpream_colortbl:| will be empty when \pkg{colortbl} is not loaded.
+% \begin{macrocode}
+ \@@_mkpream_colortbl:
+ \gdef\@preamble{} \@lastchclass 4 \@firstamptrue
+ \let\@sharp\relax
+ \def\@startpbox##1{\unexpanded\expandafter{\expandafter
+ \@startpbox\expandafter{##1}}}\let\@endpbox\relax
+ \let\do@row@strut\relax
+ \let\ar@align@mcell\relax
+ \@temptokena{#1} % \@tempswatrue
+ % \@whilesw\if@tempswa\fi{\@tempswafalse\the\NC@list}%
+ \count@\m@ne
+ \let\the@toks\relax
+ \prepnext@tok
+% \end{macrocode}
+% We have slightly modified the code of the original version of |\@mkpream| in
+% order to have something compatible with |\ExplSyntaxOn|.
+% \begin{macrocode}
+ \exp_args:NV \tl_map_variable:NNn \@temptokena \@nextchar
+ {\@testpach
+ \ifcase \@chclass \@classz \or \@classi \or \@classii
+ \or \save@decl \or \or \@classv \or \@classvi
+ \or \@classvii \or \@classviii
+ \or \@classx
+ \or \@classx \fi
+ \@lastchclass\@chclass}%
+ \ifcase\@lastchclass
+ \@acol \or
+ \or
+ \@acol \or
+ \@preamerr \thr@@ \or
+ \@preamerr \tw@ \@addtopreamble\@sharp \or
+ \or
+ \else \@preamerr \@ne \fi
+ \def\the@toks{\the\toks}
+% \end{macrocode}
+% After an utilisation of the modified version of |\@mkpream|, we come back to
+% the original version because there may be occurrences of the classical
+% |{array}| in the cells of our array (of \pkg{nicematrix}).
+% \begin{macrocode}
+ \cs_gset_eq:NN \@mkpream \@@_old_mkpream:
+ }
+% \end{macrocode}
+% The classes of REVTeX do their own redefinition of |\array| and that's why the
+% previous mechanisme is not compatible with REVTeX. However, it would probably
+% be possible to do something similar for REVTeX...
+% \begin{macrocode}
+\bool_if:NTF \c_@@_revtex_bool
+ { \cs_new_protected:Npn \@@_redefine_mkpream: { } }
+ {
+ \cs_new_protected:Npn \@@_redefine_mkpream:
+ { \cs_set_eq:NN \@mkpream \@@_mkpream: }
+ }
+% \end{macrocode}
+%
+% \bigskip
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_mkpream_colortbl: { }
+\hook_gput_code:nnn { begindocument } { . }
+ {
+ \IfPackageLoadedTF { colortbl }
+ {
+ \cs_set_protected:Npn \@@_mkpream_colortbl:
+ {
+% \end{macrocode}
+% The following lines are a patch added to |\@mkpream| by \pkg{colortbl} (by
+% storing the version of |\@mkpream| provided by \pkg{array} in
+% |\@mkpreamarray|). Since you do a redefinition of |\@mkpream|, you have to add
+% the following lines in our redefinition when \pkg{colortbl} is loaded.
+% \begin{macrocode}
+ \cs_set_eq:NN \CT@setup \relax
+ \cs_set_eq:NN \CT@color \relax
+ \cs_set_eq:NN \CT@do@color \relax
+ \cs_set_eq:NN \color \relax
+ \cs_set_eq:NN \CT@column@color \relax
+ \cs_set_eq:NN \CT@row@color \relax
+ \cs_set_eq:NN \CT@cell@color \relax
+ }
+ }
+ { }
+ }
+% \end{macrocode}
+%
+% \bigskip
% \section{Parameters}
%
% \bigskip
@@ -779,7 +867,7 @@ version 2005/12/01 or later.
%
% \medskip
% The following boolean will be equal to |true| in the environments which have
-% an environment (provided by the final user): |{NiceTabular}|, |{NiceArray}|,
+% a preamble (provided by the final user): |{NiceTabular}|, |{NiceArray}|,
% |{pNiceArray}|, etc.
% \begin{macrocode}
\bool_new:N \l_@@_preamble_bool
@@ -979,7 +1067,7 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% In particuler, in that |aux| file, there will, for each environment of
+% In particuler, in that |aux| file, there will be, for each environment of
% \pkg{nicematrix}, an affectation for the the following sequence that will
% contain informations about the size of the array.
% \begin{macrocode}
@@ -1029,6 +1117,13 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
+% We will store in the following sequence informations provided by the
+% instructions |\rowlistcolors| in the main array (not in the |\CodeBefore|).
+% \begin{macrocode}
+\seq_new:N \g_@@_rowlistcolors_seq
+% \end{macrocode}
+%
+% \bigskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_test_if_math_mode:
{
@@ -1038,12 +1133,6 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
-% \bigskip
-% The letter used for the vlines which will be drawn only in the sub-matrices.
-% |vlism| stands for \emph{vertical lines in sub-matrices}.
-% \begin{macrocode}
-\tl_new:N \l_@@_letter_vlism_tl
-% \end{macrocode}
%
% The list of the columns where vertical lines in sub-matrices (vlism) must be
% drawn. Of course, the actual value of this sequence will be known after the
@@ -1579,7 +1668,8 @@ version 2005/12/01 or later.
% but we don't know its value because the user has used the option |last-col|
% without value. A value of $0$ means that the option |last-col| has been used
% in an environment with preamble (like |{pNiceArray}|): in this case, the key
-% was necessary without argument.
+% was necessary without argument. The command |\NiceMatrixOptions| also sets
+% |\l_@@_last_col_int| to~$0$.
% \begin{macrocode}
\int_new:N \l_@@_last_col_int
\int_set:Nn \l_@@_last_col_int { -2 }
@@ -1882,10 +1972,10 @@ version 2005/12/01 or later.
\seq_map_break:
}
}
- \int_compare:nNnF \l_tmpa_int = \c_zero_int
+ \int_if_zero:nF \l_tmpa_int
{ \int_add:Nn \l_tmpa_int \g_@@_notes_caption_int }
}
- \int_compare:nNnT \l_tmpa_int = \c_zero_int
+ \int_if_zero:nT \l_tmpa_int
{
\seq_gput_right:Nn \g_@@_notes_seq { { #1 } { #2 } }
\tl_if_novalue:nT { #1 } { \int_gincr:N \c@tabularnote }
@@ -1898,7 +1988,7 @@ version 2005/12/01 or later.
{
\int_eval:n
{
- \int_compare:nNnTF \l_tmpa_int = \c_zero_int
+ \int_if_zero:nTF \l_tmpa_int
\c@tabularnote
\l_tmpa_int
}
@@ -2478,7 +2568,15 @@ version 2005/12/01 or later.
vlines-in-sub-matrix .code:n =
{
\tl_if_single_token:nTF { #1 }
- { \tl_set:Nn \l_@@_letter_vlism_tl { #1 } }
+ {
+ \tl_if_in:NnTF \c_@@_forbidden_letters_tl { #1 }
+ { \@@_error:nn { Forbidden~letter } { #1 } }
+% \end{macrocode}
+% We write directly a command for the automata which reads the preamble provided
+% by the final user.
+% \begin{macrocode}
+ { \cs_set_eq:cN { @@ _ #1 } \@@_make_preamble_vlism:n }
+ }
{ \@@_error:n { One~letter~allowed } }
} ,
vlines-in-sub-matrix .value_required:n = true ,
@@ -2596,13 +2694,11 @@ version 2005/12/01 or later.
code-after .value_required:n = true ,
bottomrule .bool_set:N = \l_@@_notes_bottomrule_bool ,
bottomrule .default:n = true ,
- style .code:n = \cs_set:Nn \@@_notes_style:n { #1 } ,
+ style .cs_set:Np = \@@_notes_style:n #1 ,
style .value_required:n = true ,
- label-in-tabular .code:n =
- \cs_set:Nn \@@_notes_label_in_tabular:n { #1 } ,
+ label-in-tabular .cs_set:Np = \@@_notes_label_in_tabular:n #1 ,
label-in-tabular .value_required:n = true ,
- label-in-list .code:n =
- \cs_set:Nn \@@_notes_label_in_list:n { #1 } ,
+ label-in-list .cs_set:Np = \@@_notes_label_in_list:n #1 ,
label-in-list .value_required:n = true ,
enumitem-keys .code:n =
{
@@ -2702,7 +2798,7 @@ version 2005/12/01 or later.
delimiters / max-width .default:n = true ,
delimiters .code:n = \keys_set:nn { NiceMatrix / delimiters } { #1 } ,
delimiters .value_required:n = true ,
- width .code:n = \dim_set:Nn \l_@@_width_dim { #1 } ,
+ width .dim_set:N = \l_@@_width_dim ,
width .value_required:n = true ,
last-col .code:n =
\tl_if_empty:nF { #1 }
@@ -2780,7 +2876,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / NiceMatrix }
{
- last-col .code:n = \tl_if_empty:nTF {#1}
+ last-col .code:n = \tl_if_empty:nTF { #1 }
{
\bool_set_true:N \l_@@_last_col_without_value_bool
\int_set:Nn \l_@@_last_col_int { -1 }
@@ -2968,7 +3064,7 @@ version 2005/12/01 or later.
% The codes |\l_@@_code_for_first_row_tl| and \emph{al} don't apply in the
% corners of the matrix.
% \begin{macrocode}
- \int_compare:nNnTF \c@iRow = 0
+ \int_if_zero:nTF \c@iRow
{
\int_compare:nNnT \c@jCol > 0
{
@@ -3023,7 +3119,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_update_for_first_and_last_row:
{
- \int_compare:nNnTF \c@iRow = 0
+ \int_if_zero:nTF \c@iRow
{
\dim_gset:Nn \g_@@_dp_row_zero_dim
{ \dim_max:nn \g_@@_dp_row_zero_dim { \box_dp:N \l_@@_cell_box } }
@@ -3126,8 +3222,7 @@ version 2005/12/01 or later.
% of the array (except the cells of the ``first column'' and the ``last
% column'').
% \begin{macrocode}
- \dim_gset:Nn \g_@@_max_cell_width_dim
- { \dim_max:nn \g_@@_max_cell_width_dim { \box_wd:N \l_@@_cell_box } }
+ \@@_update_max_cell_width:
% \end{macrocode}
%
% The following computations are for the ``first row'' and the ``last row''.
@@ -3178,6 +3273,16 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
+% The following command will be nullified in our redefinition of |\multicolumn|.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_update_max_cell_width:
+ {
+ \dim_gset:Nn \g_@@_max_cell_width_dim
+ { \dim_max:nn \g_@@_max_cell_width_dim { \box_wd:N \l_@@_cell_box } }
+ }
+% \end{macrocode}
+%
+% \bigskip
% The following variant of |\@@_cell_end:| is only for the columns of type
% |w{s}{...}| or |W{s}{...}| (which use the horizontal alignement key |s| of
% |\makebox|).
@@ -3343,11 +3448,17 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
-%
+% \bigskip
% \begin{macrocode}
-\cs_new_protected:Npn \@@_array:n
+\cs_new_protected:Npn \@@_array:
{
- % modified 05-08-23
+% \end{macrocode}
+% The following line is only a speed-up: it's a redefinition of |\@mkpream|
+% of \pkg{array} in order to speed up the compilation by deleting one line of
+% code in |\@mkpream| (the expansion of the preamble). In the classes of REVTeX,
+% that command |\@@_redefine_mkpream:| will be nullified (no speed-up).
+% \begin{macrocode}
+ \@@_redefine_mkpream:
\dim_set:Nn \col@sep
{ \bool_if:NTF \l_@@_tabular_bool \tabcolsep \arraycolsep }
\dim_compare:nNnTF \l_@@_tabular_width_dim = \c_zero_dim
@@ -3366,7 +3477,6 @@ version 2005/12/01 or later.
% \begin{macrocode}
[ \str_if_eq:VnTF \l_@@_baseline_tl c c t ]
}
-\cs_generate_variant:Nn \@@_array:n { V }
% \end{macrocode}
%
% \medskip
@@ -3448,7 +3558,7 @@ version 2005/12/01 or later.
{
\tl_if_eq:NnF \l_@@_hlines_clist { all }
{
- \exp_args:NNx
+ \exp_args:NNe
\clist_if_in:NnT
\l_@@_hlines_clist
{ \int_eval:n { \c@iRow + 1 } }
@@ -3493,19 +3603,63 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_test_color_inside:
+ {
+ \bool_if:NF \l_@@_color_inside_bool
+ {
+% \end{macrocode}
+% We will issue an error only during the first run.
+% \begin{macrocode}
+ \bool_if:NF \g_@@_aux_found_bool
+ { \@@_error:n { without~color-inside } }
+ }
+ }
+% \end{macrocode}
+%
% \bigskip
-% When the key |color-inside| is used, the following code will be executed.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_colortbl_like:
+\cs_new_protected:Npn \@@_redefine_everycr: { \everycr { \@@_everycr: } }
+\hook_gput_code:nnn { begindocument } { . }
{
- \cs_set_eq:NN \cellcolor \@@_cellcolor_tabular
- \cs_set_eq:NN \rowcolor \@@_rowcolor_tabular
- \cs_set_eq:NN \columncolor \@@_columncolor_preamble
- \cs_set_eq:NN \rowcolors \@@_rowcolors_tabular
- \cs_set_eq:NN \rowlistcolors \@@_rowlistcolors_tabular
+ \IfPackageLoadedTF { colortbl }
+ {
+ \cs_set_protected:Npn \@@_redefine_everycr:
+ {
+ \CT@everycr
+ {
+ \noalign { \cs_gset_eq:NN \CT@row@color \prg_do_nothing: }
+ \@@_everycr:
+ }
+ }
+ }
+ { }
}
% \end{macrocode}
%
+% If \pkg{booktabs} is loaded, we have to patch the macro |\@BTnormal| which is
+% a macro of \pkg{booktabs}. The macro |\@BTnormal| draws an horizontal rule but
+% it occurs after a vertical skip done by a low level TeX command. When this
+% macro |\@BTnormal| occurs, the |row| node has yet been inserted by
+% \pkg{nicematrix} \emph{before} the vertical skip (and thus, at a wrong place).
+% That why we decide to create a new |row| node (for the same row). We patch the
+% macro |\@BTnormal| to create this |row| node. This new |row| node will
+% overwrite the previous definition of that |row| node and we have managed to
+% avoid the error messages of that redefinition
+% \footnote{cf. |\nicematrix@redefine@check@rerun|}.
+% \begin{macrocode}
+\hook_gput_code:nnn { begindocument } { . }
+ {
+ \IfPackageLoadedTF { booktabs }
+ {
+ \cs_new_protected:Npn \@@_patch_booktabs:
+ { \tl_put_left:Nn \@BTnormal \@@_create_row_node_i: }
+ }
+ { \cs_new_protected:Npn \@@_patch_booktabs: { } }
+ }
+% \end{macrocode}
+%
% \bigskip
% The following code |\@@_pre_array_ii:| is used in |{NiceArrayWithDelims}|. It
% exists as a standalone macro only for legibility.
@@ -3523,22 +3677,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\@@_expand_clist:N \l_@@_hlines_clist
\@@_expand_clist:N \l_@@_vlines_clist
-% \end{macrocode}
-%
-% If \pkg{booktabs} is loaded, we have to patch the macro |\@BTnormal| which is
-% a macro of \pkg{booktabs}. The macro |\@BTnormal| draws an horizontal rule but
-% it occurs after a vertical skip done by a low level TeX command. When this
-% macro |\@BTnormal| occurs, the |row| node has yet been inserted by
-% \pkg{nicematrix} \emph{before} the vertical skip (and thus, at a wrong place).
-% That why we decide to create a new |row| node (for the same row). We patch the
-% macro |\@BTnormal| to create this |row| node. This new |row| node will
-% overwrite the previous definition of that |row| node and we have managed to
-% avoid the error messages of that redefinition
-% \footnote{cf. |\nicematrix@redefine@check@rerun|}.
-% \begin{macrocode}
- \IfPackageLoadedTF { booktabs }
- { \tl_put_left:Nn \@BTnormal \@@_create_row_node_i: }
- { }
+ \@@_patch_booktabs:
\box_clear_new:N \l_@@_cell_box
\normalbaselines
% \end{macrocode}
@@ -3575,15 +3714,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_set_nopar:Npn \ialign
{
- \IfPackageLoadedTF { colortbl }
- {
- \CT@everycr
- {
- \noalign { \cs_gset_eq:NN \CT@row@color \prg_do_nothing: }
- \@@_everycr:
- }
- }
- { \everycr { \@@_everycr: } }
+ \@@_redefine_everycr:
\tabskip = \c_zero_skip
% \end{macrocode}
%
@@ -3651,7 +3782,10 @@ version 2005/12/01 or later.
\cs_set_eq:NN \RowStyle \@@_RowStyle:n
\seq_map_inline:Nn \l_@@_custom_line_commands_seq
{ \cs_set_eq:cc { ##1 } { nicematrix - ##1 } }
- \bool_if:NT \l_@@_color_inside_bool \@@_colortbl_like:
+ \cs_set_eq:NN \cellcolor \@@_cellcolor_tabular
+ \cs_set_eq:NN \rowcolor \@@_rowcolor_tabular
+ \cs_set_eq:NN \rowcolors \@@_rowcolors_tabular
+ \cs_set_eq:NN \rowlistcolors \@@_rowlistcolors_tabular
\bool_if:NT \l_@@_renew_dots_bool \@@_renew_dots:
% \end{macrocode}
% We redefine |\multicolumn| and, since we want |\multicolumn| to be available
@@ -3863,7 +3997,6 @@ version 2005/12/01 or later.
\dim_set:Nn \l_@@_right_delim_dim { \box_wd:N \l_tmpa_box }
}
{
- % modified 05-08-23
\dim_gset:Nn \l_@@_left_delim_dim
{ 2 \bool_if:NTF \l_@@_tabular_bool \tabcolsep \arraycolsep }
\dim_gset_eq:NN \l_@@_right_delim_dim \l_@@_left_delim_dim
@@ -4315,7 +4448,7 @@ version 2005/12/01 or later.
% Now, we prepare the token list for the instructions that we will have to write
% on the |aux| file at the end of the environment.
% \begin{macrocode}
- \tl_gclear:N \g_@@_aux_tl
+ \tl_build_gbegin:N \g_@@_aux_tl
% \end{macrocode}
%
% \begin{macrocode}
@@ -4374,7 +4507,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\bool_if:NT \l_@@_width_used_bool
{
- \int_compare:nNnT \g_@@_total_X_weight_int = 0
+ \int_if_zero:nT \g_@@_total_X_weight_int
{ \@@_error_or_warning:n { width~without~X~columns } }
}
% \end{macrocode}
@@ -4388,7 +4521,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\int_compare:nNnT \g_@@_total_X_weight_int > 0
{
- \tl_gput_right:Nx \g_@@_aux_tl
+ \tl_build_gput_right:Nx \g_@@_aux_tl
{
\bool_set_true:N \l_@@_X_columns_aux_bool
\dim_set:Nn \l_@@_X_columns_dim
@@ -4462,7 +4595,7 @@ version 2005/12/01 or later.
% computed its width in |\g_@@_width_first_col_dim|: see
% p.~\pageref{overlap-left}).
% \begin{macrocode}
- \int_compare:nNnT \l_@@_first_col_int = 0
+ \int_if_zero:nT \l_@@_first_col_int
{
% \skip_horizontal:N \col@sep % 05-08-23
\skip_horizontal:N \g_@@_width_first_col_dim
@@ -4488,7 +4621,7 @@ version 2005/12/01 or later.
% |first-row| is used).
% \begin{macrocode}
{
- \int_compare:nNnTF \l_@@_first_row_int = 0
+ \int_if_zero:nTF \l_@@_first_row_int
{
\dim_set_eq:NN \l_tmpa_dim \g_@@_dp_row_zero_dim
\dim_add:Nn \l_tmpa_dim \g_@@_ht_row_zero_dim
@@ -4592,6 +4725,7 @@ version 2005/12/01 or later.
% We write on the |aux| file all the informations corresponding to the
% current environment.
% \begin{macrocode}
+ \tl_build_gend:N \g_@@_aux_tl
\iow_now:Nn \@mainaux { \ExplSyntaxOn }
\iow_now:Nn \@mainaux { \char_set_catcode_space:n { 32 } }
\iow_now:Nx \@mainaux
@@ -4631,7 +4765,6 @@ version 2005/12/01 or later.
\cs_new_protected:Npn \@@_transform_preamble_i:
{
\int_gzero:N \c@jCol
- \group_begin:
% \end{macrocode}
% The sequence |\g_@@_cols_vlsim_seq| will contain the numbers of the columns
% where you will to have to draw vertical lines in the potential sub-matrices
@@ -4668,29 +4801,40 @@ version 2005/12/01 or later.
}
}
% \end{macrocode}
+%
+% \bigskip
% Now, we actually make the preamble (which will be given to |{array}|). It will
% be stored in |\g_@@_array_preamble_tl|.
% \begin{macrocode}
- \exp_last_unbraced:NV \@@_make_preamble:n \g_@@_user_preamble_tl \q_stop
+ \exp_last_unbraced:NV \@@_rec_preamble:n \g_@@_user_preamble_tl \stop
\int_gset_eq:NN \g_@@_static_num_of_col_int \c@jCol
% \end{macrocode}
%
% \medskip
-% Now, we replace |\columncolor| by |\@@_columncolor_preamble|.
% \begin{macrocode}
- \bool_if:NT \l_@@_color_inside_bool
- {
- \regex_replace_all:NnN
- \c_@@_columncolor_regex
- { \c { @@_columncolor_preamble } }
- \g_@@_array_preamble_tl
- }
+ \@@_replace_columncolor:
+ }
% \end{macrocode}
%
-% \medskip
-% We are not sure that the following TeX group is still necessary.
+% \bigskip
% \begin{macrocode}
- \group_end:
+\hook_gput_code:nnn { begindocument } { . }
+ {
+ \IfPackageLoadedTF { colortbl }
+ {
+ \regex_const:Nn \c_@@_columncolor_regex { \c { columncolor } }
+ \cs_new_protected:Npn \@@_replace_columncolor:
+ {
+ \regex_replace_all:NnN
+ \c_@@_columncolor_regex
+ { \c { @@_columncolor_preamble } }
+ \g_@@_array_preamble_tl
+ }
+ }
+ {
+ \cs_new_protected:Npn \@@_replace_columncolor:
+ { \cs_set_eq:NN \columncolor \@@_columncolor_preamble }
+ }
}
% \end{macrocode}
%
@@ -4701,7 +4845,7 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \medskip
-% If there was delimiters at the beginning or at the end of the preamble, the
+% If there were delimiters at the beginning or at the end of the preamble, the
% environment |{NiceArray}| is transformed into an environment |{xNiceMatrix}|.
% \begin{macrocode}
\bool_lazy_or:nnT
@@ -4719,7 +4863,7 @@ version 2005/12/01 or later.
% \bigskip
% We complete the preamble with the potential ``exterior columns'' (on both sides).
% \begin{macrocode}
- \int_compare:nNnTF \l_@@_first_col_int = 0
+ \int_if_zero:nTF \l_@@_first_col_int
{ \tl_gput_left:NV \g_@@_array_preamble_tl \c_@@_preamble_first_col_tl }
{
\bool_lazy_all:nT
@@ -4758,97 +4902,47 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% The command |\@@_make_preamble:n| is the main function for the creation
-% of the preamble. It is recursive.
+% The preamble provided by the final user will be read by a finite
+% automata. The following function |\@@_rec_preamble:n| will read that preamble
+% (usually letter by letter) in a recursive way (hence the name of that function).
+% in the preamble and
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble:n #1
+\cs_new_protected:Npn \@@_rec_preamble:n #1
{
- \str_if_eq:nnF { #1 } { \q_stop }
- {
- \cs_if_exist:cTF { @@ \token_to_str:N #1 }
- { \use:c { @@ \token_to_str:N #1 } { #1 } }
- {
- \str_if_eq:nVTF { #1 } \l_@@_letter_vlism_tl
- {
- \seq_gput_right:Nx \g_@@_cols_vlism_seq
- { \int_eval:n { \c@jCol + 1 } }
- \tl_gput_right:Nx \g_@@_array_preamble_tl
- { \exp_not:N ! { \skip_horizontal:N \arrayrulewidth } }
- \@@_make_preamble:n
- }
% \end{macrocode}
-% Now the case of a letter set by the final user for a customized rule. Such
-% customized rule is defined by using the key |custom-line| in
-% |\NiceMatrixOptions|. That key takes in as value a list of \textsl{key=value}
-% pairs. Among the keys avalaible in that list, there is the key |letter|. All
-% the letters defined by this way by the final user for such customized rules
-% are added in the set of keys |{NiceMatrix/ColumnTypes}|. That set of keys is
-% used to store the characteristics of those types of rules for convenience: the
-% keys of that set of keys won't never be used as keys by the final user (he
-% will use, instead, letters in the preamble of its array).
+% For the majority of the letters, we will trigger the corresponding action by
+% calling directly a function in the main hashtable of TeX (thanks to the
+% mechanism |\csname...\endcsname|. Be careful: all these functions take in as
+% first argument the letter (or token) itself.\footnote{We do that because it's
+% a easy way to insert the letter at some places in the code that we will add to
+% |\g_@@_array_preamble_tl|.}
% \begin{macrocode}
- {
- \keys_if_exist:nnTF { NiceMatrix / ColumnTypes } { #1 }
- {
- \keys_set:nn { NiceMatrix / ColumnTypes } { #1 }
- \@@_make_preamble:n
- }
- {
- \cs_if_exist:cTF { NC @ find @ #1 }
- {
- \tl_set_eq:Nc \l_tmpb_tl { NC @ rewrite @ #1 }
- \exp_last_unbraced:NV \@@_make_preamble:n \l_tmpb_tl
- }
- {
- \tl_if_eq:nnT { #1 } { S }
- { \@@_fatal:n { unknown~column~type~S } }
- { \@@_fatal:nn { unknown~column~type } { #1 } }
- }
- }
- }
+ \cs_if_exist:cTF { @@ _ \token_to_str:N #1 }
+ { \use:c { @@ _ \token_to_str:N #1 } { #1 } }
+ {
+% \end{macrocode}
+% Now, the columns defined by |\newcolumntype| of \pkg{array}.
+% \begin{macrocode}
+ \cs_if_exist:cTF { NC @ find @ #1 }
+ {
+ \tl_set_eq:Nc \l_tmpb_tl { NC @ rewrite @ #1 }
+ \exp_last_unbraced:NV \@@_rec_preamble:n \l_tmpb_tl
+ }
+ {
+ \tl_if_eq:nnT { #1 } { S }
+ { \@@_fatal:n { unknown~column~type~S } }
+ { \@@_fatal:nn { unknown~column~type } { #1 } }
}
}
}
% \end{macrocode}
%
-% \bigskip
-% Now, we will list all the auxiliary functions for the different types of
-% entries in the preamble of the array.
-% \begin{macrocode}
-\cs_new:cpn { @@ \string c } { \@@_make_preamble_i:n }
-\cs_new:cpn { @@ \string l } { \@@_make_preamble_i:n }
-\cs_new:cpn { @@ \string r } { \@@_make_preamble_i:n }
-\cs_new:cpn { @@ \string > } { \@@_make_preamble_xiv:nn }
-\cs_new:cpn { @@ \string ! } { \@@_make_preamble_ii:nn }
-\cs_new:cpn { @@ \string @ } { \@@_make_preamble_ii:nn }
-\cs_new:cpn { @@ \string | } { \@@_make_preamble_iii:n }
-\cs_new:cpn { @@ \string p } { \@@_make_preamble_iv:n }
-\cs_new:cpn { @@ \string b } { \@@_make_preamble_iv:n }
-\cs_new:cpn { @@ \string m } { \@@_make_preamble_iv:n }
-\cs_new:cpn { @@ \string V } { \@@_make_preamble_v:nn }
-\cs_new:cpn { @@ \string w } { \@@_make_preamble_vi:nnnn { } }
-\cs_new:cpn { @@ \string W } { \@@_make_preamble_vi:nnnn { \@@_special_W: } }
-\cs_new:cpn { @@ \string S } { \@@_make_preamble_vii:nn }
-\cs_new:cpn { @@ \string ( } { \@@_make_preamble_viii:nn }
-\cs_new:cpn { @@ \string [ } { \@@_make_preamble_viii:nn }
-\cs_new:cpn { @@ \string \{ } { \@@_make_preamble_viii:nn }
-\cs_new:cpn { @@ \string \left } { \@@_make_preamble_viii_ii:n }
-\cs_new:cpn { @@ \string ) } { \@@_make_preamble_ix:nn }
-\cs_new:cpn { @@ \string ] } { \@@_make_preamble_ix:nn }
-\cs_new:cpn { @@ \string \} } { \@@_make_preamble_ix:nn }
-\cs_new:cpn { @@ \string \right } { \@@_make_preamble_ix_ii:n }
-\cs_new:cpn { @@ \string X } { \@@_make_preamble_x:nn }
-\cs_new:cpn { @@ \string * } { \@@_make_preamble_xvi:nnn }
-\cs_new:cpn { @@ \string \NC@find } { \@@_make_preamble_xx:n }
-% \end{macrocode}
-% The token |\NC@find| is at the head of the definition of the columns type done
-% by |\newcolumntype|. We wan't that token to be no-op here.
%
%
% \bigskip
% For |c|, |l| and |r|
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_i:n #1
+\cs_new:Npn \@@_c #1
{
\tl_gput_right:NV \g_@@_array_preamble_tl \g_@@_pre_cell_tl
\tl_gclear:N \g_@@_pre_cell_tl
@@ -4863,56 +4957,59 @@ version 2005/12/01 or later.
% We increment the counter of columns and then we test for the presence of a |<|.
% \begin{macrocode}
\int_gincr:N \c@jCol
- \@@_make_preamble_xi:n
+ \@@_rec_preamble_after_col:n
}
+\cs_set_eq:NN \@@_l \@@_c
+\cs_set_eq:NN \@@_r \@@_c
% \end{macrocode}
%
% \medskip
-% For |>|, |!| and |@|
+% For |!| and |@|
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_ii:nn #1 #2
+\cs_new:cpn { @@ _ \token_to_str:N ! } #1 #2
{
\tl_gput_right:Nn \g_@@_array_preamble_tl { #1 { #2 } }
- \@@_make_preamble:n
+ \@@_rec_preamble:n
}
+\cs_set_eq:cc { @@ _ \token_to_str:N @ } { @@ _ \token_to_str:N ! }
% \end{macrocode}
%
%
% \medskip
% For \verb+|+
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_iii:n #1
+\cs_new:cpn { @@ _ | } #1
{
% \end{macrocode}
% |\l_tmpa_int| is the number of successive occurrences of \verb+|+
% \begin{macrocode}
\int_incr:N \l_tmpa_int
- \@@_make_preamble_iii_i:n
+ \@@_make_preamble_i_i:n
}
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_iii_i:n #1
+\cs_new_protected:Npn \@@_make_preamble_i_i:n #1
{
\str_if_eq:nnTF { #1 } |
{ \@@_make_preamble_iii:n | }
- { \@@_make_preamble_iii_ii:nn { } #1 }
+ { \@@_make_preamble_i_ii:nn { } #1 }
}
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_iii_ii:nn #1 #2
+\cs_new_protected:Npn \@@_make_preamble_i_ii:nn #1 #2
{
\str_if_eq:nnTF { #2 } [
- { \@@_make_preamble_iii_ii:nw { #1 } [ }
- { \@@_make_preamble_iii_iii:nn { #2 } { #1 } }
+ { \@@_make_preamble_i_ii:nw { #1 } [ }
+ { \@@_make_preamble_i_iii:nn { #2 } { #1 } }
}
-\cs_new_protected:Npn \@@_make_preamble_iii_ii:nw #1 [ #2 ]
- { \@@_make_preamble_iii_ii:nn { #1 , #2 } }
+\cs_new_protected:Npn \@@_make_preamble_i_ii:nw #1 [ #2 ]
+ { \@@_make_preamble_i_ii:nn { #1 , #2 } }
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_iii_iii:nn #1 #2
+\cs_new_protected:Npn \@@_make_preamble_i_iii:nn #1 #2
{
\@@_compute_rule_width:n { multiplicity = \l_tmpa_int , #2 }
\tl_gput_right:Nx \g_@@_array_preamble_tl
@@ -4938,16 +5035,17 @@ version 2005/12/01 or later.
% \begin{macrocode}
}
\int_zero:N \l_tmpa_int
- \str_if_eq:nnT { #1 } { \q_stop } { \bool_gset_true:N \g_tmpb_bool }
- \@@_make_preamble:n #1
+ \str_if_eq:nnT { #1 } { \stop } { \bool_gset_true:N \g_tmpb_bool }
+ \@@_rec_preamble:n #1
}
% \end{macrocode}
%
+% \bigskip
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_xiv:nn #1 #2
+\cs_new:cpn { @@ _ > } #1 #2
{
\tl_gput_right:Nn \g_@@_pre_cell_tl { > { #2 } }
- \@@_make_preamble:n
+ \@@_rec_preamble:n
}
% \end{macrocode}
%
@@ -5006,31 +5104,33 @@ version 2005/12/01 or later.
%
%
% \medskip
-% For |p|, |b| and |m|. The argument |#1| is that value : |p|, |b| or |m|.
+% For |p|, |b| and |m|.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_iv:n #1
+\cs_new:Npn \@@_p #1
{
\str_set:Nn \l_@@_vpos_col_str { #1 }
% \end{macrocode}
% Now, you look for a potential character |[| after the letter of the specifier
% (for the options).
% \begin{macrocode}
- \@@_make_preamble_iv_i:n
+ \@@_make_preamble_ii_i:n
}
+\cs_set_eq:NN \@@_b \@@_p
+\cs_set_eq:NN \@@_m \@@_p
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_iv_i:n #1
+\cs_new_protected:Npn \@@_make_preamble_ii_i:n #1
{
\str_if_eq:nnTF { #1 } { [ }
- { \@@_make_preamble_iv_ii:w [ }
- { \@@_make_preamble_iv_ii:w [ ] { #1 } }
+ { \@@_make_preamble_ii_ii:w [ }
+ { \@@_make_preamble_ii_ii:w [ ] { #1 } }
}
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_iv_ii:w [ #1 ]
- { \@@_make_preamble_iv_iii:nn { #1 } }
+\cs_new_protected:Npn \@@_make_preamble_ii_ii:w [ #1 ]
+ { \@@_make_preamble_ii_iii:nn { #1 } }
% \end{macrocode}
%
% \medskip
@@ -5039,7 +5139,7 @@ version 2005/12/01 or later.
%
% |#2| is the mandatory argument of the specifier: the width of the column.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_iv_iii:nn #1 #2
+\cs_new_protected:Npn \@@_make_preamble_ii_iii:nn #1 #2
{
% \end{macrocode}
% The possible values of |\l_@@_hpos_col_str| are |j| (for \emph{justified} which is
@@ -5049,7 +5149,7 @@ version 2005/12/01 or later.
\str_set:Nn \l_@@_hpos_col_str { j }
\tl_set:Nn \l_tmpa_tl { #1 }
\@@_keys_p_column:V \l_tmpa_tl
- \@@_make_preamble_iv_iv:nn { #2 } { minipage }
+ \@@_make_preamble_ii_iv:nn { #2 } { minipage }
}
% \end{macrocode}
%
@@ -5063,11 +5163,11 @@ version 2005/12/01 or later.
% The first argument is the width of the column. The second is the type of
% environment: |minipage| or |varwidth|.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_iv_iv:nn #1 #2
+\cs_new_protected:Npn \@@_make_preamble_ii_iv:nn #1 #2
{
- \use:x
+ \use:e
{
- \@@_make_preamble_iv_v:nnnnnnnn
+ \@@_make_preamble_ii_v:nnnnnnnn
{ \str_if_eq:VnTF \l_@@_vpos_col_str { p } { t } { b } }
{ \dim_eval:n { #1 } }
{
@@ -5114,7 +5214,7 @@ version 2005/12/01 or later.
% We increment the counter of columns, and then we test for the presence of a |<|.
% \begin{macrocode}
\int_gincr:N \c@jCol
- \@@_make_preamble_xi:n
+ \@@_rec_preamble_after_col:n
}
% \end{macrocode}
%
@@ -5143,7 +5243,7 @@ version 2005/12/01 or later.
% |#8| is the letter |c| or |r| or |l| which is the basic specificier of column
% which is used \emph{in fine}.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_iv_v:nnnnnnnn #1 #2 #3 #4 #5 #6 #7 #8
+\cs_new_protected:Npn \@@_make_preamble_ii_v:nnnnnnnn #1 #2 #3 #4 #5 #6 #7 #8
{
\str_if_eq:VnTF \l_@@_hpos_col_str { si }
{ \tl_gput_right:Nn \g_@@_array_preamble_tl { > { \@@_test_if_empty_for_S: } } }
@@ -5278,31 +5378,35 @@ version 2005/12/01 or later.
% \medskip
% For |V| (similar to the |V| of \pkg{varwidth}).
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_v:nn #1 #2
+\cs_new:Npn \@@_V #1 #2
{
\str_if_eq:nnTF { #2 } { [ }
- { \@@_make_preamble_v_i:w [ }
- { \@@_make_preamble_v_i:w [ ] { #2 } }
+ { \@@_make_preamble_V_i:w [ }
+ { \@@_make_preamble_V_i:w [ ] { #2 } }
}
-\cs_new_protected:Npn \@@_make_preamble_v_i:w [ #1 ]
- { \@@_make_preamble_v_ii:nn { #1 } }
-\cs_new_protected:Npn \@@_make_preamble_v_ii:nn #1 #2
+\cs_new_protected:Npn \@@_make_preamble_V_i:w [ #1 ]
+ { \@@_make_preamble_V_ii:nn { #1 } }
+\cs_new_protected:Npn \@@_make_preamble_V_ii:nn #1 #2
{
\str_set:Nn \l_@@_vpos_col_str { p }
\str_set:Nn \l_@@_hpos_col_str { j }
\tl_set:Nn \l_tmpa_tl { #1 }
\@@_keys_p_column:V \l_tmpa_tl
\IfPackageLoadedTF { varwidth }
- { \@@_make_preamble_iv_iv:nn { #2 } { varwidth } }
+ { \@@_make_preamble_ii_iv:nn { #2 } { varwidth } }
{
\@@_error_or_warning:n { varwidth~not~loaded }
- \@@_make_preamble_iv_iv:nn { #2 } { minipage }
+ \@@_make_preamble_ii_iv:nn { #2 } { minipage }
}
}
% \end{macrocode}
%
% \medskip
% For |w| and |W|
+% \begin{macrocode}
+\cs_new:Npn \@@_w { \@@_make_preamble_w:nnnn { } }
+\cs_new:Npn \@@_W { \@@_make_preamble_w:nnnn { \@@_special_W: } }
+% \end{macrocode}
%
% |#1| is a special argument: empty for |w| and equal to |\@@_special_W:| for |W|;
%
@@ -5313,11 +5417,11 @@ version 2005/12/01 or later.
% |#4| is the width of the column.
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_vi:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \@@_make_preamble_w:nnnn #1 #2 #3 #4
{
\str_if_eq:nnTF { #3 } { s }
- { \@@_make_preamble_vi_i:nnnn { #1 } { #4 } }
- { \@@_make_preamble_vi_ii:nnnn { #1 } { #2 } { #3 } { #4 } }
+ { \@@_make_preamble_w_i:nnnn { #1 } { #4 } }
+ { \@@_make_preamble_w_ii:nnnn { #1 } { #2 } { #3 } { #4 } }
}
% \end{macrocode}
%
@@ -5329,7 +5433,7 @@ version 2005/12/01 or later.
%
% |#2| is the width of the column.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_vi_i:nnnn #1 #2
+\cs_new_protected:Npn \@@_make_preamble_w_i:nnnn #1 #2
{
\tl_gput_right:NV \g_@@_array_preamble_tl \g_@@_pre_cell_tl
\tl_gclear:N \g_@@_pre_cell_tl
@@ -5349,7 +5453,7 @@ version 2005/12/01 or later.
}
}
\int_gincr:N \c@jCol
- \@@_make_preamble_xi:n
+ \@@_rec_preamble_after_col:n
}
% \end{macrocode}
%
@@ -5357,7 +5461,7 @@ version 2005/12/01 or later.
% Then, the most important version, for the horizontal alignments types of |c|,
% |l| and |r| (and not |s|).
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_vi_ii:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \@@_make_preamble_w_ii:nnnn #1 #2 #3 #4
{
\tl_gput_right:NV \g_@@_array_preamble_tl \g_@@_pre_cell_tl
\tl_gclear:N \g_@@_pre_cell_tl
@@ -5387,7 +5491,7 @@ version 2005/12/01 or later.
% We increment the counter of columns and then we test for the presence of a |<|.
% \begin{macrocode}
\int_gincr:N \c@jCol
- \@@_make_preamble_xi:n
+ \@@_rec_preamble_after_col:n
}
% \end{macrocode}
%
@@ -5403,43 +5507,39 @@ version 2005/12/01 or later.
% \medskip
% For |S| (of \pkg{siunitx}).
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_vii:nn #1 #2
+\cs_new:Npn \@@_S #1 #2
{
\str_if_eq:nnTF { #2 } { [ }
- { \@@_make_preamble_vii_i:w [ }
- { \@@_make_preamble_vii_i:w [ ] { #2 } }
+ { \@@_make_preamble_S:w [ }
+ { \@@_make_preamble_S:w [ ] { #2 } }
}
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_vii_i:w [ #1 ]
- { \@@_make_preamble_vii_ii:n { #1 } }
+\cs_new_protected:Npn \@@_make_preamble_S:w [ #1 ]
+ { \@@_make_preamble_S_i:n { #1 } }
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_vii_ii:n #1
+\cs_new_protected:Npn \@@_make_preamble_S_i:n #1
{
- \IfPackageAtLeastTF { siunitx } { 2022/01/01 }
+ \tl_gput_right:NV \g_@@_array_preamble_tl \g_@@_pre_cell_tl
+ \tl_gclear:N \g_@@_pre_cell_tl
+ \tl_gput_right:Nn \g_@@_array_preamble_tl
{
- \tl_gput_right:NV \g_@@_array_preamble_tl \g_@@_pre_cell_tl
- \tl_gclear:N \g_@@_pre_cell_tl
- \tl_gput_right:Nn \g_@@_array_preamble_tl
- {
- > {
- \@@_cell_begin:w
- \keys_set:nn { siunitx } { #1 }
- \siunitx_cell_begin:w
- }
- c
- < { \siunitx_cell_end: \@@_cell_end: }
+ > {
+ \@@_cell_begin:w
+ \keys_set:nn { siunitx } { #1 }
+ \siunitx_cell_begin:w
}
+ c
+ < { \siunitx_cell_end: \@@_cell_end: }
+ }
% \end{macrocode}
% We increment the counter of columns and then we test for the presence of a |<|.
% \begin{macrocode}
- \int_gincr:N \c@jCol
- \@@_make_preamble_xi:n
- }
- { \@@_fatal:n { Version~of~siunitx~too~old } }
+ \int_gincr:N \c@jCol
+ \@@_rec_preamble_after_col:n
}
% \end{macrocode}
%
@@ -5447,14 +5547,14 @@ version 2005/12/01 or later.
% \medskip
% For |(|, |[| and |\{|.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_viii:nn #1 #2
+\cs_new:cpn { @@ _ \token_to_str:N ( } #1 #2
{
\bool_if:NT \l_@@_small_bool { \@@_fatal:n { Delimiter~with~small } }
% \end{macrocode}
% If we are before the column 1 and not in |{NiceArray}|, we reserve space for
% the left delimiter.
% \begin{macrocode}
- \int_compare:nNnTF \c@jCol = \c_zero_int
+ \int_if_zero:nTF \c@jCol
{
\str_if_eq:VnTF \g_@@_left_delim_tl { . }
{
@@ -5464,34 +5564,36 @@ version 2005/12/01 or later.
% \begin{macrocode}
\tl_gset:Nn \g_@@_left_delim_tl { #1 }
\tl_gset:Nn \g_@@_right_delim_tl { . }
- \@@_make_preamble:n #2
+ \@@_rec_preamble:n #2
}
{
\tl_gput_right:Nn \g_@@_array_preamble_tl { ! { \enskip } }
- \@@_make_preamble_viii_i:nn { #1 } { #2 }
+ \@@_make_preamble_iv:nn { #1 } { #2 }
}
}
- { \@@_make_preamble_viii_i:nn { #1 } { #2 } }
+ { \@@_make_preamble_iv:nn { #1 } { #2 } }
}
+\cs_set_eq:cc { @@ _ \token_to_str:N [ } { @@ _ \token_to_str:N ( }
+\cs_set_eq:cc { @@ _ \token_to_str:N \{ } { @@ _ \token_to_str:N ( }
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_viii_i:nn #1 #2
+\cs_new_protected:Npn \@@_make_preamble_iv:nn #1 #2
{
\tl_gput_right:Nx \g_@@_pre_code_after_tl
{ \@@_delimiter:nnn #1 { \int_eval:n { \c@jCol + 1 } } \c_true_bool }
\tl_if_in:nnTF { ( [ \{ ) ] \} \left \right } { #2 }
{
\@@_error:nn { delimiter~after~opening } { #2 }
- \@@_make_preamble:n
+ \@@_rec_preamble:n
}
- { \@@_make_preamble:n #2 }
+ { \@@_rec_preamble:n #2 }
}
% \end{macrocode}
%
+% In fact, if would be possible to define |\left| and |\right| as no-op.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_viii_ii:n #1
- { \@@_make_preamble_viii:nn }
+\cs_new:cpn { @@ _ \token_to_str:N \left } #1 { \use:c { @@ _ \token_to_str:N ( } }
% \end{macrocode}
%
% \bigskip
@@ -5502,13 +5604,13 @@ version 2005/12/01 or later.
% considered as the right delimiter of the environment if the environment is
% |{NiceArray}|).
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_ix:nn #1 #2
+\cs_new:cpn { @@ _ \token_to_str:N ) } #1 #2
{
\bool_if:NT \l_@@_small_bool { \@@_fatal:n { Delimiter~with~small } }
\tl_if_in:nnTF { ) ] \} } { #2 }
- { \@@_make_preamble_ix_i:nnn #1 #2 }
+ { \@@_make_preamble_v:nnn #1 #2 }
{
- \tl_if_eq:nnTF { \q_stop } { #2 }
+ \tl_if_eq:nnTF { \stop } { #2 }
{
\str_if_eq:VnTF \g_@@_right_delim_tl { . }
{ \tl_gset:Nn \g_@@_right_delim_tl { #1 } }
@@ -5516,7 +5618,7 @@ version 2005/12/01 or later.
\tl_gput_right:Nn \g_@@_array_preamble_tl { ! { \enskip } }
\tl_gput_right:Nx \g_@@_pre_code_after_tl
{ \@@_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool }
- \@@_make_preamble:n #2
+ \@@_rec_preamble:n #2
}
}
{
@@ -5524,16 +5626,18 @@ version 2005/12/01 or later.
{ \tl_gput_right:Nn \g_@@_array_preamble_tl { ! { \enskip } } }
\tl_gput_right:Nx \g_@@_pre_code_after_tl
{ \@@_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool }
- \@@_make_preamble:n #2
+ \@@_rec_preamble:n #2
}
}
}
+\cs_set_eq:cc { @@ _ \token_to_str:N ] } { @@ _ \token_to_str:N ] }
+\cs_set_eq:cc { @@ _ \token_to_str:N \} } { @@ _ \token_to_str:N \} }
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_ix_i:nnn #1 #2 #3
+\cs_new_protected:Npn \@@_make_preamble_v:nnn #1 #2 #3
{
- \tl_if_eq:nnTF { \q_stop } { #3 }
+ \tl_if_eq:nnTF { \stop } { #3 }
{
\str_if_eq:VnTF \g_@@_right_delim_tl { . }
{
@@ -5553,14 +5657,98 @@ version 2005/12/01 or later.
\tl_gput_right:Nx \g_@@_pre_code_after_tl
{ \@@_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool }
\@@_error:nn { double~closing~delimiter } { #2 }
- \@@_make_preamble:n #3
+ \@@_rec_preamble:n #3
+ }
+ }
+% \end{macrocode}
+%
+% \medskip
+% \begin{macrocode}
+\cs_new:cpn { @@ _ \token_to_str:N \right } #1
+ { \use:c { @@ _ \token_to_str:N ) } }
+% \end{macrocode}
+%
+%
+% \bigskip
+% After a specifier of column, we have to test whether there is one or several
+% |<{..}| because, after those potential |<{...}|, we have to insert
+% |!{\skip_horizontal:N ...}| when the key |vlines| is used. In fact, we have
+% also to test whether there is, after the |<{...}|, a |@{...}|.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_rec_preamble_after_col:n #1
+ {
+ \str_if_eq:nnTF { #1 } { < }
+ \@@_rec_preamble_after_col_i:n
+ {
+ \str_if_eq:nnTF { #1 } { @ }
+ \@@_rec_preamble_after_col_ii:n
+ {
+ \tl_if_eq:NnTF \l_@@_vlines_clist { all }
+ {
+ \tl_gput_right:Nn \g_@@_array_preamble_tl
+ { ! { \skip_horizontal:N \arrayrulewidth } }
+ }
+ {
+ \exp_args:NNe
+ \clist_if_in:NnT \l_@@_vlines_clist { \int_eval:n { \c@jCol + 1 } }
+ {
+ \tl_gput_right:Nn \g_@@_array_preamble_tl
+ { ! { \skip_horizontal:N \arrayrulewidth } }
+ }
+ }
+ \@@_rec_preamble:n { #1 }
+ }
}
}
% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_rec_preamble_after_col_i:n #1
+ {
+ \tl_gput_right:Nn \g_@@_array_preamble_tl { < { #1 } }
+ \@@_rec_preamble_after_col:n
+ }
+% \end{macrocode}
+%
+% We have to catch a |@{...}| after a specifier of column because, if we have to
+% draw a vertical rule, we have to add in that |@{...}| a |\hskip| corresponding
+% to the width of the vertical rule.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_rec_preamble_after_col_ii:n #1
+ {
+ \tl_if_eq:NnTF \l_@@_vlines_clist { all }
+ {
+ \tl_gput_right:Nn \g_@@_array_preamble_tl
+ { @ { #1 \skip_horizontal:N \arrayrulewidth } }
+ }
+ {
+ \exp_args:NNe
+ \clist_if_in:NnTF \l_@@_vlines_clist { \int_eval:n { \c@jCol + 1 } }
+ {
+ \tl_gput_right:Nn \g_@@_array_preamble_tl
+ { @ { #1 \skip_horizontal:N \arrayrulewidth } }
+ }
+ { \tl_gput_right:Nn \g_@@_array_preamble_tl { @ { #1 } } }
+ }
+ \@@_rec_preamble:n
+ }
+% \end{macrocode}
+%
+% \bigskip
+% \begin{macrocode}
+\cs_new:cpn { @@ _ * } #1 #2 #3
+ {
+ \tl_clear:N \l_tmpa_tl
+ \int_step_inline:nn { #2 } { \tl_put_right:Nn \l_tmpa_tl { #3 } }
+ \exp_last_unbraced:NV \@@_rec_preamble:n \l_tmpa_tl
+ }
+% \end{macrocode}
%
+% \bigskip
+% The token |\NC@find| is at the head of the definition of the columns type done
+% by |\newcolumntype|. We wan't that token to be no-op here.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_ix_ii:n #1
- { \@@_make_preamble_ix:nn }
+\cs_new:cpn { @@ _ \token_to_str:N \NC@find } #1 { \@@_rec_preamble:n }
% \end{macrocode}
%
% \bigskip
@@ -5568,17 +5756,17 @@ version 2005/12/01 or later.
% (between square brackets). That's why we test whether there is a |[| after the
% letter |X|.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_x:nn #1 #2
+\cs_new:Npn \@@_X #1 #2
{
\str_if_eq:nnTF { #2 } { [ }
- { \@@_make_preamble_x_i:w [ }
- { \@@_make_preamble_x_i:w [ ] #2 }
+ { \@@_make_preamble_X:w [ }
+ { \@@_make_preamble_X:w [ ] #2 }
}
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_x_i:w [ #1 ]
- { \@@_make_preamble_x_ii:n { #1 } }
+\cs_new_protected:Npn \@@_make_preamble_X:w [ #1 ]
+ { \@@_make_preamble_X_i:n { #1 } }
% \end{macrocode}
% |#1| is the optional argument of the |X| specifier (a list of
% \emph{key}-\emph{value} pairs).
@@ -5597,7 +5785,7 @@ version 2005/12/01 or later.
% \medskip
% In the following command, |#1| is the list of the options of the specifier |X|.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_x_ii:n #1
+\cs_new_protected:Npn \@@_make_preamble_X_i:n #1
{
% \end{macrocode}
% The possible values of |\l_@@_hpos_col_str| are |j| (for \emph{justified} which is
@@ -5638,8 +5826,8 @@ version 2005/12/01 or later.
% \begin{macrocode}
\bool_if:NTF \l_@@_X_columns_aux_bool
{
- \exp_args:Nnx
- \@@_make_preamble_iv_iv:nn
+ \exp_args:Nne
+ \@@_make_preamble_ii_iv:nn
{ \l_@@_weight_int \l_@@_X_columns_dim }
{ minipage }
}
@@ -5675,93 +5863,43 @@ version 2005/12/01 or later.
}
}
\int_gincr:N \c@jCol
- \@@_make_preamble_xi:n
+ \@@_rec_preamble_after_col:n
}
}
% \end{macrocode}
%
-%
-% \bigskip
-% After a specifier of column, we have to test whether there is one or several
-% |<{..}| because, after those potential |<{...}|, we have to insert
-% |!{\skip_horizontal:N ...}| when the key |vlines| is used. In fact, we have
-% also to test whether there is, after the |<{...}|, a |@{...}|.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_xi:n #1
- {
- \str_if_eq:nnTF { #1 } { < }
- \@@_make_preamble_xiii:n
- {
- \str_if_eq:nnTF { #1 } { @ }
- \@@_make_preamble_xv:n
- {
- \tl_if_eq:NnTF \l_@@_vlines_clist { all }
- {
- \tl_gput_right:Nn \g_@@_array_preamble_tl
- { ! { \skip_horizontal:N \arrayrulewidth } }
- }
- {
- \exp_args:NNx
- \clist_if_in:NnT \l_@@_vlines_clist { \int_eval:n { \c@jCol + 1 } }
- {
- \tl_gput_right:Nn \g_@@_array_preamble_tl
- { ! { \skip_horizontal:N \arrayrulewidth } }
- }
- }
- \@@_make_preamble:n { #1 }
- }
- }
- }
-% \end{macrocode}
-%
+% \medskip
+% For the letter set by the user with |vlines-in-sub-matrix| (vlism).
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_xiii:n #1
+\cs_new_protected:Npn \@@_make_preamble_vlism:n #1
{
- \tl_gput_right:Nn \g_@@_array_preamble_tl { < { #1 } }
- \@@_make_preamble_xi:n
+ \seq_gput_right:Nx \g_@@_cols_vlism_seq
+ { \int_eval:n { \c@jCol + 1 } }
+ \tl_gput_right:Nx \g_@@_array_preamble_tl
+ { \exp_not:N ! { \skip_horizontal:N \arrayrulewidth } }
+ \@@_rec_preamble:n
}
% \end{macrocode}
%
-% We have to catch a |@{...}| after a specifier of column because, if we have to
-% draw a vertical rule, we have to add in that |@{...}| a |\hskip| corresponding
-% to the width of the vertical rule.
+% \medskip
+% The token |\stop| is a marker that we have inserted to mark the end of the
+% preamble (as provided by the final user) that we have inserted in the TeX flow.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_xv:n #1
- {
- \tl_if_eq:NnTF \l_@@_vlines_clist { all }
- {
- \tl_gput_right:Nn \g_@@_array_preamble_tl
- { @ { #1 \skip_horizontal:N \arrayrulewidth } }
- }
- {
- \exp_args:NNx
- \clist_if_in:NnTF \l_@@_vlines_clist { \int_eval:n { \c@jCol + 1 } }
- {
- \tl_gput_right:Nn \g_@@_array_preamble_tl
- { @ { #1 \skip_horizontal:N \arrayrulewidth } }
- }
- { \tl_gput_right:Nn \g_@@_array_preamble_tl { @ { #1 } } }
- }
- \@@_make_preamble:n
- }
+\cs_set_eq:cN { @@ _ \token_to_str:N \stop } \use_none:n
% \end{macrocode}
%
+% \medskip
+% The following lines try to catch some errors (when the final user has
+% forgotten the preamble of its environment).
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_xx:n #1 { \@@_make_preamble:n }
+\cs_new_protected:cpn { @@ _ \token_to_str:N \hline }
+ { \@@_fatal:n { Preamble~forgotten } }
+\cs_set_eq:cc { @@ _ \token_to_str:N \Hline } { @@ _ \token_to_str:N \hline }
+\cs_set_eq:cc { @@ _ \token_to_str:N \toprule } { @@ _ \token_to_str:N \hline }
+\cs_set_eq:cc { @@ _ \token_to_str:N \CodeBefore } { @@ _ \token_to_str:N \hline }
% \end{macrocode}
%
% \bigskip
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_xvi:nnn #1 #2 #3
- {
- \tl_clear:N \l_tmpa_tl
- \int_step_inline:nn { #2 } { \tl_put_right:Nn \l_tmpa_tl { #3 } }
- \exp_last_unbraced:NV \@@_make_preamble:n \l_tmpa_tl
- }
-% \end{macrocode}
-%
-%
-% \bigskip
% \section{The redefinition of \textbackslash multicolumn}
%
% \medskip
@@ -5777,6 +5915,7 @@ version 2005/12/01 or later.
% |\multicolumn|.
% \begin{macrocode}
\multispan { #1 }
+ \cs_set_eq:NN \@@_update_max_cell_width: \prg_do_nothing: % added 2023-10-04
\begingroup
\cs_set:Npn \@addamp { \if@firstamp \@firstampfalse \else \@preamerr 5 \fi }
% \end{macrocode}
@@ -5799,7 +5938,7 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \medskip
-% Now, you do a treatment specific to \pkg{nicematrix} which has no equivalent
+% Now, we do a treatment specific to \pkg{nicematrix} which has no equivalent
% in the original definition of |\multicolumn|.
% \begin{macrocode}
\int_compare:nNnT { #1 } > 1
@@ -5810,13 +5949,13 @@ version 2005/12/01 or later.
\seq_gput_right:Nx \g_@@_pos_of_blocks_seq
{
{
- \int_compare:nNnTF \c@jCol = 0
+ \int_if_zero:nTF \c@jCol
{ \int_eval:n { \c@iRow + 1 } }
{ \int_use:N \c@iRow }
}
{ \int_eval:n { \c@jCol + 1 } }
{
- \int_compare:nNnTF \c@jCol = 0
+ \int_if_zero:nTF \c@jCol
{ \int_eval:n { \c@iRow + 1 } }
{ \int_use:N \c@iRow }
}
@@ -5867,11 +6006,6 @@ version 2005/12/01 or later.
w { \@@_make_m_preamble_v:nnnn { } #1 }
W { \@@_make_m_preamble_v:nnnn { \@@_special_W: } #1 }
\q_stop { }
-% \end{macrocode}
-% The token |\NC@find| is at the head of the definition of the columns type done
-% by |\newcolumntype|. We wan't that token to no-op here.
-% \begin{macrocode}
- \NC@find { \@@_make_preamble:n }
}
{
\cs_if_exist:cTF { NC @ find @ #1 }
@@ -6127,7 +6261,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\int_compare:nNnT \g_@@_notes_caption_int > 0
{
- \tl_gput_right:Nx \g_@@_aux_tl
+ \tl_build_gput_right:Nx \g_@@_aux_tl
{
\tl_set:Nn \exp_not:N \l_@@_note_in_caption_tl
{ \int_use:N \g_@@_notes_caption_int }
@@ -6337,7 +6471,7 @@ version 2005/12/01 or later.
\dim_gsub:Nn \g_tmpa_dim \pgf@y
\endpgfpicture
\dim_gadd:Nn \g_tmpa_dim \arrayrulewidth
- \int_compare:nNnT \l_@@_first_row_int = 0
+ \int_if_zero:nT \l_@@_first_row_int
{
\dim_gadd:Nn \g_tmpa_dim \g_@@_ht_row_zero_dim
\dim_gadd:Nn \g_tmpa_dim \g_@@_dp_row_zero_dim
@@ -6388,7 +6522,7 @@ version 2005/12/01 or later.
\dim_gsub:Nn \g_tmpa_dim \pgf@y
\endpgfpicture
\dim_gadd:Nn \g_tmpa_dim \arrayrulewidth
- \int_compare:nNnT \l_@@_first_row_int = 0
+ \int_if_zero:nT \l_@@_first_row_int
{
\dim_gadd:Nn \g_tmpa_dim \g_@@_ht_row_zero_dim
\dim_gadd:Nn \g_tmpa_dim \g_@@_dp_row_zero_dim
@@ -6475,10 +6609,10 @@ version 2005/12/01 or later.
{
\@@_transform_preamble:
% \end{macrocode}
-% Here is the call to |\array| (we have a dedicated macro |\@@_array:n| because
+% Here is the call to |\array| (we have a dedicated macro |\@@_array:| because
% of compatibility with the classes \cls{revtex4-1} and \cls{revtex4-2}).
% \begin{macrocode}
- \@@_array:V \g_@@_array_preamble_tl
+ \exp_args:NV \@@_array: \g_@@_array_preamble_tl
}
}
}
@@ -6570,11 +6704,10 @@ version 2005/12/01 or later.
% \bigskip
% The new value of the body (that is to say after replacement of the separators
% of rows and columns by |\\| and |&|) of the environment will be stored in
-% |\l_@@_new_body_tl| (that part of the implementation has been changed in the
-% version 6.11 of \pkg{nicematrix} in order to allow the use of commands such as
+% |\l_@@_new_body_tl| in order to allow the use of commands such as
% |\hline| or |\hdottedline| with the key |light-syntax|).
% \begin{macrocode}
- \tl_clear_new:N \l_@@_new_body_tl
+ \tl_build_begin:N \l_@@_new_body_tl
\int_zero_new:N \l_@@_nb_cols_int
% \end{macrocode}
% First, we treat the first row.
@@ -6587,9 +6720,10 @@ version 2005/12/01 or later.
% \begin{macrocode}
\seq_map_inline:Nn \l_@@_rows_seq
{
- \tl_put_right:Nn \l_@@_new_body_tl { \\ }
+ \tl_build_put_right:Nn \l_@@_new_body_tl { \\ }
\@@_line_with_light_syntax:n { ##1 }
}
+ \tl_build_end:N \l_@@_new_body_tl
% \end{macrocode}
%
% \begin{macrocode}
@@ -6606,14 +6740,13 @@ version 2005/12/01 or later.
% \begin{macrocode}
\@@_transform_preamble:
% \end{macrocode}
-%
-%
+% \bigskip
%
% The call to |\array| is in the following command (we have a dedicated macro
-% |\@@_array:n| because of compatibility with the classes \cls{revtex4-1} and
+% |\@@_array:| because of compatibility with the classes \cls{revtex4-1} and
% \cls{revtex4-2}).
% \begin{macrocode}
- \@@_array:V \g_@@_array_preamble_tl \l_@@_new_body_tl
+ \exp_args:NV \@@_array: \g_@@_array_preamble_tl \l_@@_new_body_tl
}
% \end{macrocode}
%
@@ -6629,9 +6762,9 @@ version 2005/12/01 or later.
{ \seq_count:N \l_@@_cells_seq }
}
\seq_pop_left:NN \l_@@_cells_seq \l_tmpa_tl
- \tl_put_right:NV \l_@@_new_body_tl \l_tmpa_tl
+ \exp_args:NNV \tl_build_put_right:Nn \l_@@_new_body_tl \l_tmpa_tl
\seq_map_inline:Nn \l_@@_cells_seq
- { \tl_put_right:Nn \l_@@_new_body_tl { & ##1 } }
+ { \tl_build_put_right:Nn \l_@@_new_body_tl { & ##1 } }
}
\cs_generate_variant:Nn \@@_line_with_light_syntax:n { V }
% \end{macrocode}
@@ -6663,7 +6796,7 @@ version 2005/12/01 or later.
\cs_new:Npn \@@_create_col_nodes:
{
\crcr
- \int_compare:nNnT \l_@@_first_col_int = 0
+ \int_if_zero:nT \l_@@_first_col_int
{
\omit
\hbox_overlap_left:n
@@ -6690,7 +6823,7 @@ version 2005/12/01 or later.
% First, we put a |col| node on the left of the first column (of course, we
% have to do that \emph{after} the |\omit|).
% \begin{macrocode}
- \int_compare:nNnTF \l_@@_first_col_int = 0
+ \int_if_zero:nTF \l_@@_first_col_int
{
\bool_if:NT \l_@@_code_before_bool
{
@@ -7155,6 +7288,12 @@ version 2005/12/01 or later.
{
\bool_gset_true:N \g_@@_delims_bool
\str_gset:Nn \g_@@_name_env_str { #1 NiceMatrix }
+ % added 2023/10/01
+ \int_if_zero:nT \l_@@_last_col_int
+ {
+ \bool_set_true:N \l_@@_last_col_without_value_bool
+ \int_set:Nn \l_@@_last_col_int { -1 }
+ }
\keys_set:nn { NiceMatrix / NiceMatrix } { ##1 }
\@@_begin_of_NiceMatrix:nV { #1 } \l_@@_columns_type_tl
}
@@ -7168,6 +7307,12 @@ version 2005/12/01 or later.
\NewDocumentEnvironment { NiceMatrix } { ! O { } }
{
\str_gset:Nn \g_@@_name_env_str { NiceMatrix }
+ % added 2023/10/01
+ \int_if_zero:nT \l_@@_last_col_int
+ {
+ \bool_set_true:N \l_@@_last_col_without_value_bool
+ \int_set:Nn \l_@@_last_col_int { -1 }
+ }
\keys_set:nn { NiceMatrix / NiceMatrix } { #1 }
\bool_lazy_or:nnT
{ \clist_if_empty_p:N \l_@@_vlines_clist }
@@ -7244,7 +7389,7 @@ version 2005/12/01 or later.
}
{
\endNiceArray
- \int_compare:nNnT \g_@@_total_X_weight_int = \c_zero_int
+ \int_if_zero:nT \g_@@_total_X_weight_int
{ \@@_error:n { NiceTabularX~without~X } }
}
% \end{macrocode}
@@ -7334,7 +7479,7 @@ version 2005/12/01 or later.
%
% \medskip
% \begin{macrocode}
- \tl_gput_right:Nx \g_@@_aux_tl
+ \tl_build_gput_right:Nx \g_@@_aux_tl
{
\seq_gset_from_clist:Nn \exp_not:N \g_@@_size_seq
{
@@ -7353,7 +7498,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\seq_if_empty:NF \g_@@_pos_of_blocks_seq
{
- \tl_gput_right:Nx \g_@@_aux_tl
+ \tl_build_gput_right:Nx \g_@@_aux_tl
{
\seq_gset_from_clist:Nn \exp_not:N \g_@@_pos_of_blocks_seq
{ \seq_use:Nnnn \g_@@_pos_of_blocks_seq , , , }
@@ -7361,7 +7506,7 @@ version 2005/12/01 or later.
}
\seq_if_empty:NF \g_@@_multicolumn_cells_seq
{
- \tl_gput_right:Nx \g_@@_aux_tl
+ \tl_build_gput_right:Nx \g_@@_aux_tl
{
\seq_gset_from_clist:Nn \exp_not:N \g_@@_multicolumn_cells_seq
{ \seq_use:Nnnn \g_@@_multicolumn_cells_seq , , , }
@@ -7566,9 +7711,10 @@ version 2005/12/01 or later.
% force). These instructions will be written on the |aux| file to be added to
% the |code-before| in the next run.
% \begin{macrocode}
+ \seq_if_empty:NF \g_@@_rowlistcolors_seq { \@@_clear_rowlistcolors_seq: }
\tl_if_empty:NF \g_@@_pre_code_before_tl
{
- \tl_gput_right:Nx \g_@@_aux_tl
+ \tl_build_gput_right:Nx \g_@@_aux_tl
{
\tl_gset:Nn \exp_not:N \g_@@_pre_code_before_tl
{ \exp_not:V \g_@@_pre_code_before_tl }
@@ -7577,7 +7723,7 @@ version 2005/12/01 or later.
}
\tl_if_empty:NF \g_nicematrix_code_before_tl
{
- \tl_gput_right:Nx \g_@@_aux_tl
+ \tl_build_gput_right:Nx \g_@@_aux_tl
{
\tl_gset:Nn \exp_not:N \g_@@_code_before_tl
{ \exp_not:V \g_nicematrix_code_before_tl }
@@ -7735,7 +7881,7 @@ version 2005/12/01 or later.
\pgftransformshift { \pgfpoint \l_tmpa_dim \l_tmpb_dim }
% \end{macrocode}
% Now, |\l_tmpa_dim| and |\l_tmpb_dim| become the width and the height of the
-% node (of shape |@à_diag_node|) that we will construct.
+% node (of shape |@@_diag_node|) that we will construct.
% \begin{macrocode}
\dim_set:Nn \l_tmpa_dim { ( \l_@@_tmpc_dim - \l_tmpa_dim ) / 2 }
\dim_set:Nn \l_tmpb_dim { ( \l_@@_tmpd_dim - \l_tmpb_dim ) / 2 }
@@ -7937,7 +8083,7 @@ version 2005/12/01 or later.
\int_compare:nNnTF { #3 } = 1
{ \bool_set_true:N \l_@@_initial_open_bool }
{
- \int_compare:nNnT \l_@@_initial_j_int = { \l_@@_col_min_int -1 }
+ \int_compare:nNnT \l_@@_initial_j_int = { \l_@@_col_min_int - 1 }
{ \bool_set_true:N \l_@@_initial_open_bool }
}
}
@@ -8192,7 +8338,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\group_begin:
\@@_open_shorten:
- \int_compare:nNnTF { #1 } = 0
+ \int_if_zero:nTF { #1 }
{ \color { nicematrix-first-row } }
{
% \end{macrocode}
@@ -8287,7 +8433,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\group_begin:
\@@_open_shorten:
- \int_compare:nNnTF { #1 } = 0
+ \int_if_zero:nTF { #1 }
{ \color { nicematrix-first-row } }
{
% \end{macrocode}
@@ -8422,7 +8568,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\group_begin:
\@@_open_shorten:
- \int_compare:nNnTF { #2 } = 0
+ \int_if_zero:nTF { #2 }
{ \color { nicematrix-first-col } }
{
\int_compare:nNnT { #2 } = \l_@@_last_col_int
@@ -8465,7 +8611,7 @@ version 2005/12/01 or later.
{
\@@_open_y_initial_dim:
\@@_open_y_final_dim:
- \int_compare:nNnTF \l_@@_initial_j_int = \c_zero_int
+ \int_if_zero:nTF \l_@@_initial_j_int
% \end{macrocode}
% We have a dotted line open on both sides in the ``first column''.
% \begin{macrocode}
@@ -9142,7 +9288,7 @@ version 2005/12/01 or later.
{ \@@_collect_options:n { \@@_Ldots_i } }
\exp_args:NNV \NewDocumentCommand \@@_Ldots_i \l_@@_argspec_tl
{
- \int_compare:nNnTF \c@jCol = 0
+ \int_if_zero:nTF \c@jCol
{ \@@_error:nn { in~first~col } \Ldots }
{
\int_compare:nNnTF \c@jCol = \l_@@_last_col_int
@@ -9164,7 +9310,7 @@ version 2005/12/01 or later.
{ \@@_collect_options:n { \@@_Cdots_i } }
\exp_args:NNV \NewDocumentCommand \@@_Cdots_i \l_@@_argspec_tl
{
- \int_compare:nNnTF \c@jCol = 0
+ \int_if_zero:nTF \c@jCol
{ \@@_error:nn { in~first~col } \Cdots }
{
\int_compare:nNnTF \c@jCol = \l_@@_last_col_int
@@ -9186,7 +9332,7 @@ version 2005/12/01 or later.
{ \@@_collect_options:n { \@@_Vdots_i } }
\exp_args:NNV \NewDocumentCommand \@@_Vdots_i \l_@@_argspec_tl
{
- \int_compare:nNnTF \c@iRow = 0
+ \int_if_zero:nTF \c@iRow
{ \@@_error:nn { in~first~row } \Vdots }
{
\int_compare:nNnTF \c@iRow = \l_@@_last_row_int
@@ -9308,8 +9454,8 @@ version 2005/12/01 or later.
\cs_new:Npn \@@_Hdotsfor:
{
\bool_lazy_and:nnTF
- { \int_compare_p:nNn \c@jCol = 0 }
- { \int_compare_p:nNn \l_@@_first_col_int = 0 }
+ { \int_if_zero_p:n \c@jCol }
+ { \int_if_zero_p:n \l_@@_first_col_int }
{
\bool_if:NTF \g_@@_after_col_zero_bool
{
@@ -9420,11 +9566,8 @@ version 2005/12/01 or later.
%
% \begin{macrocode}
\group_begin:
-
\@@_open_shorten:
-
-
- \int_compare:nNnTF { #1 } = 0
+ \int_if_zero:nTF { #1 }
{ \color { nicematrix-first-row } }
{
\int_compare:nNnT { #1 } = \g_@@_row_total_int
@@ -9531,11 +9674,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\group_begin:
\@@_open_shorten:
-
-
-
-
- \int_compare:nNnTF { #2 } = 0
+ \int_if_zero:nTF { #2 }
{ \color { nicematrix-first-col } }
{
\int_compare:nNnT { #2 } = \g_@@_col_total_int
@@ -9896,7 +10035,7 @@ version 2005/12/01 or later.
\seq_map_indexed_inline:Nn \g_@@_colors_seq
{ \tl_if_eq:nnT { #1 } { ##2 } { \int_set:Nn \l_tmpa_int { ##1 } } }
}
- \int_compare:nNnTF \l_tmpa_int = \c_zero_int
+ \int_if_zero:nTF \l_tmpa_int
% \end{macrocode}
% First, the case where the color is a \emph{new} color (not in the sequence).
% \begin{macrocode}
@@ -9913,8 +10052,8 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \begin{macrocode}
-\cs_generate_variant:Nn \@@_add_to_colors_seq:nn { x n }
-\cs_generate_variant:Nn \@@_add_to_colors_seq:nn { x x }
+\cs_generate_variant:Nn \@@_add_to_colors_seq:nn { e n }
+\cs_generate_variant:Nn \@@_add_to_colors_seq:nn { e e }
% \end{macrocode}
%
% \bigskip
@@ -10036,7 +10175,7 @@ version 2005/12/01 or later.
\tl_if_empty:NF \l_tmpa_tl { \exp_args:NV \pgfsetfillopacity \l_tmpa_tl }
\tl_if_empty:NTF \l_tmpb_tl
{ \@declaredcolor }
- { \use:x { \exp_not:N \@undeclaredcolor [ \l_tmpb_tl ] } }
+ { \use:e { \exp_not:N \@undeclaredcolor [ \l_tmpb_tl ] } }
}
% \end{macrocode}
%
@@ -10067,7 +10206,7 @@ version 2005/12/01 or later.
{
\tl_if_blank:nF { #2 }
{
- \@@_add_to_colors_seq:xn
+ \@@_add_to_colors_seq:en
{ \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } }
{ \@@_cartesian_color:nn { #3 } { - } }
}
@@ -10081,7 +10220,7 @@ version 2005/12/01 or later.
{
\tl_if_blank:nF { #2 }
{
- \@@_add_to_colors_seq:xn
+ \@@_add_to_colors_seq:en
{ \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } }
{ \@@_cartesian_color:nn { - } { #3 } }
}
@@ -10095,7 +10234,7 @@ version 2005/12/01 or later.
{
\tl_if_blank:nF { #2 }
{
- \@@_add_to_colors_seq:xn
+ \@@_add_to_colors_seq:en
{ \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } }
{ \@@_rectanglecolor:nnn { #3 } { #4 } { 0 pt } }
}
@@ -10109,7 +10248,7 @@ version 2005/12/01 or later.
{
\tl_if_blank:nF { #2 }
{
- \@@_add_to_colors_seq:xn
+ \@@_add_to_colors_seq:en
{ \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } }
{ \@@_rectanglecolor:nnn { #3 } { #4 } { #5 } }
}
@@ -10199,12 +10338,12 @@ version 2005/12/01 or later.
%
% Here is an example: |\rowcolors{1}{blue!10}{}[respect-blocks]|.
%
-% In \pkg{nicematrix}, the commmand |\@@_rowcolors| apperas as a special case of
+% In \pkg{nicematrix}, the commmand |\@@_rowcolors| appears as a special case of
% |\@@_rowlistcolors|.
%
-% |#1| (optional) is the color space ;
-% |#2| is a list of intervals of rows ;
-% |#3| is the list of colors ;
+% |#1| (optional) is the color space;
+% |#2| is a list of intervals of rows;
+% |#3| is the list of colors;
% |#4| is for the optional list of pairs \textsl{key=value}.
% \begin{macrocode}
\NewDocumentCommand \@@_rowlistcolors { O { } m m O { } }
@@ -10293,7 +10432,7 @@ version 2005/12/01 or later.
}
\tl_if_empty:NF \l_@@_color_tl
{
- \@@_add_to_colors_seq:xx
+ \@@_add_to_colors_seq:ee
{ \tl_if_blank:nF { #1 } { [ #1 ] } { \l_@@_color_tl } }
{ \@@_cartesian_color:nn { \l_@@_rows_tl } { \l_@@_cols_tl } }
}
@@ -10321,12 +10460,13 @@ version 2005/12/01 or later.
%
% \bigskip
% The command |\rowcolors| (available in the |\CodeBefore|) is a specialisation
-% of the most general command |\rowlistcolors|. The last argument, which is a
+% of the more general command |\rowlistcolors|. The last argument, which is a
% optional argument between square brackets is provided by curryfication.
% \begin{macrocode}
\NewDocumentCommand \@@_rowcolors { O { } m m m }
{ \@@_rowlistcolors [ #1 ] { #2 } { { #3 } , { #4 } } }
% \end{macrocode}
+% The braces around |#3| and |#4| are mandatory.
%
% \bigskip
% \begin{macrocode}
@@ -10343,7 +10483,7 @@ version 2005/12/01 or later.
\prg_new_conditional:Nnn \@@_not_in_exterior:nnnnn p
{
\bool_lazy_or:nnTF
- { \int_compare_p:nNn { #4 } = \c_zero_int }
+ { \int_if_zero_p:n { #4 } }
{ \int_compare_p:nNn { #2 } = { \int_eval:n { \c@jCol + 1 } } }
\prg_return_false:
\prg_return_true:
@@ -10503,6 +10643,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\NewDocumentCommand \@@_cellcolor_tabular { O { } m }
{
+ \@@_test_color_inside:
\tl_gput_right:Nx \g_@@_pre_code_before_tl
{
% \end{macrocode}
@@ -10523,6 +10664,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\NewDocumentCommand \@@_rowcolor_tabular { O { } m }
{
+ \@@_test_color_inside:
\tl_gput_right:Nx \g_@@_pre_code_before_tl
{
\@@_rectanglecolor [ #1 ] { \exp_not:n { #2 } }
@@ -10539,8 +10681,9 @@ version 2005/12/01 or later.
% argument between square brackets is taken by curryfication).
% \begin{macrocode}
\NewDocumentCommand { \@@_rowcolors_tabular } { O { } m m }
- { \@@_rowlistcolors_tabular [ #1 ] { #2 , #3 } }
+ { \@@_rowlistcolors_tabular [ #1 ] { { #2 } , { #3 } } }
% \end{macrocode}
+% The braces around |#2| and |#3| are mandatory.
%
% \bigskip
% When the user uses the key |color-inside|, the following command will
@@ -10548,19 +10691,113 @@ version 2005/12/01 or later.
% \begin{macrocode}
\NewDocumentCommand { \@@_rowlistcolors_tabular } { O { } m O { } }
{
+ \@@_test_color_inside:
\peek_remove_spaces:n
+ { \@@_rowlistcolors_tabular:nnn { #1 } { #2 } { #3 } }
+ }
+% \end{macrocode}
+%
+% \bigskip
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_rowlistcolors_tabular:nnn #1 #2 #3
+ {
+% \end{macrocode}
+% A use of |\rowlistcolors| in the tabular erases the instructions
+% |\rowlistcolors| which are in force. However, it's possible to put \emph{several}
+% instructions |\rowlistcolors| in the same row of a tabular: it may be useful
+% when those instructions |\rowlistcolors| concerns different columns of the
+% tabular (thanks to the key |cols| of |\rowlistcolors|). That's why we store
+% the different instructions |\rowlistcolors| which are in force in a sequence
+% |\g_@@_rowlistcolors_seq|. Now, we will filter that sequence to keep only the
+% elements which have been issued on the actual row. We will store the elements
+% to keep in the |\g_tmpa_seq|.
+% \begin{macrocode}
+ \seq_gclear:N \g_tmpa_seq
+ \seq_map_inline:Nn \g_@@_rowlistcolors_seq
+ { \@@_rowlistcolors_tabular_i:nnnn ##1 }
+ \seq_gset_eq:NN \g_@@_rowlistcolors_seq \g_tmpa_seq
+% \end{macrocode}
+% Now, we add to the sequence |\g_@@_rowlistcolors_seq| (which is the list of
+% the commands |\rowlistcolors| which are in force) the current instruction
+% |\rowlistcolors|.
+% \begin{macrocode}
+ \seq_gput_right:Nx \g_@@_rowlistcolors_seq
+ {
+ { \int_use:N \c@iRow }
+ { \exp_not:n { #1 } }
+ { \exp_not:n { #2 } }
+ { restart , cols = \int_use:N \c@jCol - , \exp_not:n { #3 } }
+ }
+ }
+% \end{macrocode}
+%
+%
+% \bigskip
+% The following command will be applied to each component of
+% |\g_@@_rowlistcolors_seq|. Each component of that sequence is a kind of 4-uple
+% of the form |{#1}{#2}{#3}{#4}|.
+%
+% |#1| is the number of the row where the command |\rowlistcolors| has been
+% issued.
+%
+% |#2| is the colorimetric space (optional argument of the |\rowlistcolors|).
+%
+% |#3| is the list of colors (mandatory argument of |\rowlistcolors|).
+%
+% |#4| is the list of \textsl{key=value} pairs (last optional argument of
+% |\rowlistcolors|).
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_rowlistcolors_tabular_i:nnnn #1 #2 #3 #4
+ {
+ \int_compare:nNnTF { #1 } = \c@iRow
+% \end{macrocode}
+% We (temporary) keep in memory in |\g_tmpa_seq| the instructions which will
+% still be in force after the current instruction (because they have been issued
+% in the same row of the tabular).
+% \begin{macrocode}
+ { \seq_gput_right:Nn \g_tmpa_seq { { #1 } { #2 } { #3 } { #4 } } }
{
\tl_gput_right:Nx \g_@@_pre_code_before_tl
{
\@@_rowlistcolors
- [ #1 ] { \int_use:N \c@iRow } { #2 }
- [ restart, cols = \int_use:N \c@jCol - , #3 ]
+ [ \exp_not:n { #2 } ]
+ { #1 - \int_eval:n { \c@iRow - 1 } }
+ { \exp_not:n { #3 } }
+ [ \exp_not:n { #4 } ]
}
}
}
% \end{macrocode}
%
% \bigskip
+% The following command will be used at the end of the tabular, just before the
+% execution of the |\g_@@_pre_code_before_tl|. It clears the sequence
+% |\g_@@_rowlistcolors_seq| of all the commands |\rowlistcolors| which are
+% (still) in force.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_clear_rowlistcolors_seq:
+ {
+ \seq_map_inline:Nn \g_@@_rowlistcolors_seq
+ { \@@_rowlistcolors_tabular_ii:nnnn ##1 }
+ \seq_gclear:N \g_@@_rowlistcolors_seq
+ }
+% \end{macrocode}
+%
+% \medskip
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_rowlistcolors_tabular_ii:nnnn #1 #2 #3 #4
+ {
+ \tl_gput_right:Nn \g_@@_pre_code_before_tl
+ { \@@_rowlistcolors [ #2 ] { #1 } { #3 } [ #4 ] }
+ }
+% \end{macrocode}
+% The first mandatory argument of the command |\@@_rowlistcolors| which is
+% writtent in the pre-|\CodeBefore| is of the form |i|: it means that the
+% command must be applied to all the rows from the row~$i$ until the end of the
+% tabular.
+%
+% \bigskip
% \begin{macrocode}
\NewDocumentCommand \@@_columncolor_preamble { O { } m }
{
@@ -10618,10 +10855,10 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_OnlyMainNiceMatrix:n #1
{
- \int_compare:nNnTF \l_@@_first_col_int = 0
+ \int_if_zero:nTF \l_@@_first_col_int
{ \@@_OnlyMainNiceMatrix_i:n { #1 } }
{
- \int_compare:nNnTF \c@jCol = 0
+ \int_if_zero:nTF \c@jCol
{
\int_compare:nNnF \c@iRow = { -1 }
{ \int_compare:nNnF \c@iRow = { \l_@@_last_row_int - 1 } { #1 } }
@@ -10640,7 +10877,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_OnlyMainNiceMatrix_i:n #1
{
- \int_compare:nNnF \c@iRow = 0
+ \int_if_zero:nF \c@iRow
{
\int_compare:nNnF \c@iRow = \l_@@_last_row_int
{
@@ -10784,7 +11021,7 @@ version 2005/12/01 or later.
\clist_if_empty:NF \l_@@_corners_clist \@@_test_in_corner_v:
\bool_if:NTF \g_tmpa_bool
{
- \int_compare:nNnT \l_@@_local_start_int = 0
+ \int_if_zero:nT \l_@@_local_start_int
% \end{macrocode}
% We keep in memory that we have a rule to draw. |\l_@@_local_start_int| will be
% the starting row of the rule that we will have to draw.
@@ -10962,7 +11199,7 @@ version 2005/12/01 or later.
\@@_qpoint:n { row - \int_eval:n { \l_@@_local_end_int + 1 } }
\dim_set_eq:NN \l_@@_tmpc_dim \pgf@y
\exp_args:NV \tikzset \l_@@_tikz_rule_tl
- \use:x { \exp_not:N \draw [ \l_@@_tikz_rule_tl ] }
+ \use:e { \exp_not:N \draw [ \l_@@_tikz_rule_tl ] }
( \l_tmpb_dim , \l_tmpa_dim ) --
( \l_tmpb_dim , \l_@@_tmpc_dim ) ;
\end { tikzpicture }
@@ -11049,7 +11286,7 @@ version 2005/12/01 or later.
\clist_if_empty:NF \l_@@_corners_clist \@@_test_in_corner_h:
\bool_if:NTF \g_tmpa_bool
{
- \int_compare:nNnT \l_@@_local_start_int = 0
+ \int_if_zero:nT \l_@@_local_start_int
% \end{macrocode}
% We keep in memory that we have a rule to draw. |\l_@@_local_start_int| will be
% the starting row of the rule that we will have to draw.
@@ -11288,7 +11525,7 @@ version 2005/12/01 or later.
\@@_qpoint:n { col - \int_eval:n { \l_@@_local_end_int + 1 } }
\dim_set_eq:NN \l_@@_tmpc_dim \pgf@x
\exp_args:NV \tikzset \l_@@_tikz_rule_tl
- \use:x { \exp_not:N \draw [ \l_@@_tikz_rule_tl ] }
+ \use:e { \exp_not:N \draw [ \l_@@_tikz_rule_tl ] }
( \l_tmpa_dim , \l_tmpb_dim ) --
( \l_@@_tmpc_dim , \l_tmpb_dim ) ;
\end { tikzpicture }
@@ -11378,21 +11615,7 @@ version 2005/12/01 or later.
% The final user can define a customized rule by using the key |custom-line| in
% |\NiceMatrixOptions|. That key takes in as value a list of \textsl{key=value}
% pairs.
-%
%
-%
-% \medskip
-% Among the keys avalaible in that list, there is the key |letter| to specify a
-% letter that the final user will use in the preamble of the array. All the
-% letters defined by this way by the final user for such customized rules are
-% added in the set of keys |{NiceMatrix / ColumnTypes}|. That set of keys is
-% used to store the characteristics of those types of rules for convenience: the
-% keys of that set of keys won't never be used as keys by the final user (he
-% will use, instead, letters in the preamble of its array).
-%
-% \begin{macrocode}
-\keys_define:nn { NiceMatrix / ColumnTypes } { }
-% \end{macrocode}
%
%
% \medskip
@@ -11473,21 +11696,18 @@ version 2005/12/01 or later.
{
\exp_args:NnV \tl_if_in:NnTF
\c_@@_forbidden_letters_str \l_@@_letter_str
- { \@@_error:n { Forbidden~letter } }
+ { \@@_error:ne { Forbidden~letter } \l_@@_letter_str }
{
% \end{macrocode}
-% The final user can, locally, redefine a letter of column type. That's
-% compatible with the use of |\keys_define:nn|: the definition is local and may
-% overwrite a previous definition.
+% During the analyse of the preamble provided by the final user, our automaton,
+% for the letter corresponding at the custom line, will directly use the
+% following command that you define in the main hash table of TeX.
% \begin{macrocode}
- \keys_define:nx { NiceMatrix / ColumnTypes }
- {
- \l_@@_letter_str .code:n =
- { \@@_v_custom_line:n { \exp_not:n { #1 } } }
- }
- }
- }
- }
+ \cs_set:cpn { @@ _ \l_@@_letter_str } ##1
+ { \@@_v_custom_line:n { #1 } }
+ }
+ }
+ }
\str_if_empty:NF \l_@@_command_str { \@@_h_custom_line:n { #1 } }
\str_if_empty:NF \l_@@_ccommand_str { \@@_c_custom_line:n { #1 } }
}
@@ -11495,6 +11715,7 @@ version 2005/12/01 or later.
%
%
% \begin{macrocode}
+\tl_const:Nn \c_@@_forbidden_letters_tl { lcrpmbVX|()[]!@<> }
\str_const:Nn \c_@@_forbidden_letters_str { lcrpmbVX|()[]!@<> }
% \end{macrocode}
%
@@ -11668,6 +11889,7 @@ version 2005/12/01 or later.
total-width = \dim_use:N \l_@@_rule_width_dim
}
}
+ \@@_rec_preamble:n
}
% \end{macrocode}
%
@@ -11786,7 +12008,7 @@ version 2005/12/01 or later.
% commands which color the |rows|, |columns| and |cells| must not color the
% cells in the corners.
% \begin{macrocode}
- \tl_gput_right:Nx \g_@@_aux_tl
+ \tl_build_gput_right:Nx \g_@@_aux_tl
{
\seq_set_from_clist:Nn \exp_not:N \l_@@_corners_cells_seq
{ \seq_use:Nnnn \l_@@_corners_cells_seq , , , }
@@ -11968,7 +12190,8 @@ version 2005/12/01 or later.
\cs_if_exist:cT
{ @@_max_cell_width_ \int_use:N \g_@@_NiceMatrixBlock_int }
{
- \exp_args:NNx \dim_set:Nn \l_@@_columns_width_dim
+ % is \exp_args:NNe mandatory?
+ \exp_args:NNe \dim_set:Nn \l_@@_columns_width_dim
{
\use:c
{ @@_max_cell_width _ \int_use:N \g_@@_NiceMatrixBlock_int }
@@ -12550,8 +12773,8 @@ version 2005/12/01 or later.
% \begin{macrocode}
&& ! \l_@@_X_column_bool
}
- { \exp_args:Nxx \@@_Block_iv:nnnnn }
- { \exp_args:Nxx \@@_Block_v:nnnnn }
+ { \exp_args:Nee \@@_Block_iv:nnnnn }
+ { \exp_args:Nee \@@_Block_v:nnnnn }
{ \l_tmpa_int } { \l_tmpb_int } { #3 } { #4 } { #5 }
}
% \end{macrocode}
@@ -12616,7 +12839,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\int_compare:nNnT { #1 } = 1
{
- \int_compare:nNnTF \c@iRow = 0
+ \int_if_zero:nTF \c@iRow
\l_@@_code_for_first_row_tl
{
\int_compare:nNnT \c@iRow = \l_@@_last_row_int
@@ -12664,7 +12887,7 @@ version 2005/12/01 or later.
% use a |{minipage}|.
% \begin{macrocode}
{
- \use:x
+ \use:e
{
\exp_not:N \begin { minipage }%
[ \str_lowercase:V { \l_@@_vpos_of_block_str } ]
@@ -12679,7 +12902,7 @@ version 2005/12/01 or later.
% In the other cases, we use a |{tabular}|.
% \begin{macrocode}
{
- \use:x
+ \use:e
{
\exp_not:N \begin { tabular }%
[ \str_lowercase:V { \l_@@_vpos_of_block_str } ]
@@ -12695,7 +12918,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
{
\c_math_toggle_token
- \use:x
+ \use:e
{
\exp_not:N \begin { array }%
[ \str_lowercase:V { \l_@@_vpos_of_block_str } ]
@@ -12883,7 +13106,7 @@ version 2005/12/01 or later.
% say the position of the block in its zone of merged cells).
% \begin{macrocode}
% \@@_adjust_hpos_rotate:
- \use:x
+ \use:e
{
\exp_not:N \begin { tabular } [ \l_@@_vpos_of_block_str ]
{ @ { } \l_@@_hpos_block_str @ { } }
@@ -12906,7 +13129,7 @@ version 2005/12/01 or later.
#4
% \@@_adjust_hpos_rotate:
\c_math_toggle_token % :n c
- \use:x
+ \use:e
{
\exp_not:N \begin { array } [ \l_@@_vpos_of_block_str ]
{ @ { } \l_@@_hpos_block_str @ { } }
@@ -13037,8 +13260,12 @@ version 2005/12/01 or later.
{ \int_set:Nn \l_@@_last_col_int { #4 } }
\int_compare:nNnTF \l_@@_last_col_int > \g_@@_col_total_int
{
- \int_compare:nTF
- { \l_@@_last_col_int <= \g_@@_static_num_of_col_int }
+ \bool_lazy_and:nnTF
+ \l_@@_preamble_bool
+ {
+ \int_compare_p:n
+ { \l_@@_last_col_int <= \g_@@_static_num_of_col_int }
+ }
{
\msg_error:nnnn { nicematrix } { Block~too~large~2 } { #1 } { #2 }
\@@_msg_redirect_name:nn { Block~too~large~2 } { none }
@@ -13239,9 +13466,10 @@ version 2005/12/01 or later.
% inner sep=0pt,
% fit = #1}}
%
-% \begin{tabular}{c!{\hspace{1cm}}c}
+% \begin{tabular}{c@{\hspace{1cm}}c}
% We highlight the node |1-1-block|
-% & We highlight the node |1-1-block-short| \\[2mm]
+% &
+% We highlight the node |1-1-block-short| \\[2mm]
% \begin{NiceTabular}{cc!{\hspace{1cm}}c}
% \Block{2-2}{our block} & & one \\
% & & two \\
@@ -13260,7 +13488,7 @@ version 2005/12/01 or later.
% \tikz \node [highlight = (1-1-block-short)] { } ;
% \end{NiceTabular}
% \end{tabular}
-%
+%
%
% \bigskip
% The construction of the node corresponding to the merged cells.
@@ -13406,7 +13634,7 @@ version 2005/12/01 or later.
% \end{macrocode}
% If we are in the first column, we must put the block as if it was with the key~|r|.
% \begin{macrocode}
- \int_compare:nNnT { #2 } = 0 { \str_set:Nn \l_@@_hpos_block_str r }
+ \int_if_zero:nT { #2 } { \str_set:Nn \l_@@_hpos_block_str r }
% \end{macrocode}
% If we are in the last column, we must put the block as if it was with the key~|l|.
% \begin{macrocode}
@@ -13599,7 +13827,7 @@ version 2005/12/01 or later.
{
color .tl_set:N = \l_@@_draw_tl ,
draw .code:n =
- \exp_args:Nx \tl_if_empty:nF { #1 } { \tl_set:Nn \l_@@_draw_tl { #1 } } ,
+ \exp_args:Ne \tl_if_empty:nF { #1 } { \tl_set:Nn \l_@@_draw_tl { #1 } } ,
draw .default:n = default ,
line-width .dim_set:N = \l_@@_line_width_dim ,
rounded-corners .dim_set:N = \l_@@_rounded_corners_dim ,
@@ -13626,14 +13854,14 @@ version 2005/12/01 or later.
\tl_set:Nx \l_tmpb_tl { \int_eval:n { \l_tmpb_tl + 1 } }
\int_step_inline:nnn \l_@@_tmpd_tl \l_tmpb_tl
{
- \use:x
+ \use:e
{
\@@_vline:n
{
position = ##1 ,
start = \l_@@_tmpc_tl ,
end = \int_eval:n { \l_tmpa_tl - 1 } ,
- total-width = \dim_use:N \l_@@_line_width_dim % added 2022-08-06
+ total-width = \dim_use:N \l_@@_line_width_dim
}
}
}
@@ -13650,7 +13878,7 @@ version 2005/12/01 or later.
\tl_set:Nx \l_tmpb_tl { \int_eval:n { \l_tmpb_tl + 1 } }
\int_step_inline:nnn \l_@@_tmpc_tl \l_tmpa_tl
{
- \use:x
+ \use:e
{
\@@_hline:n
{
@@ -13757,7 +13985,7 @@ version 2005/12/01 or later.
\pgfusepathqstroke
}
{
- \use:x { \exp_not:N \draw [ \l_@@_borders_tikz_tl ] }
+ \use:e { \exp_not:N \draw [ \l_@@_borders_tikz_tl ] }
( \pgf@x , \l_tmpb_dim ) -- ( \pgf@x , \l_@@_tmpc_dim ) ;
}
}
@@ -13783,7 +14011,7 @@ version 2005/12/01 or later.
\pgfusepathqstroke
}
{
- \use:x { \exp_not:N \draw [ \l_@@_borders_tikz_tl ] }
+ \use:e { \exp_not:N \draw [ \l_@@_borders_tikz_tl ] }
( \l_tmpa_dim , \pgf@y ) -- ( \l_tmpb_dim , \pgf@y ) ;
}
}
@@ -13817,7 +14045,7 @@ version 2005/12/01 or later.
\clist_map_inline:nn { #5 }
{
\keys_set_known:nnN { NiceMatrix / SpecialOffset } { ##1 } \l_tmpa_tl
- \use:x { \exp_not:N \path [ \l_tmpa_tl ] }
+ \use:e { \exp_not:N \path [ \l_tmpa_tl ] }
(
[
xshift = \dim_use:N \l_@@_offset_dim ,
@@ -13916,21 +14144,21 @@ version 2005/12/01 or later.
% yet nicematrix-ready).
% \begin{macrocode}
% \bool_set_false:N \l_@@_preamble_bool
- \use:x
+ \use:e
{
\exp_not:N \begin { NiceArrayWithDelims } { #1 } { #2 }
{ * { #4 } { \exp_not:V \l_@@_columns_type_tl } }
[ \exp_not:V \l_tmpa_tl ]
}
- \int_compare:nNnT \l_@@_first_row_int = 0
+ \int_if_zero:nT \l_@@_first_row_int
{
- \int_compare:nNnT \l_@@_first_col_int = 0 { & }
+ \int_if_zero:nT \l_@@_first_col_int { & }
\prg_replicate:nn { #4 - 1 } { & }
\int_compare:nNnT \l_@@_last_col_int > { -1 } { & } \\
}
\prg_replicate:nn { #3 }
{
- \int_compare:nNnT \l_@@_first_col_int = 0 { & }
+ \int_if_zero:nT \l_@@_first_col_int { & }
% \end{macrocode}
% We put |{ }| before |#6| to avoid a hasty expansion of a potential
% |\arabic{iRow}| at the beginning of the row which would result in an incorrect
@@ -13942,7 +14170,7 @@ version 2005/12/01 or later.
}
\int_compare:nNnT \l_@@_last_row_int > { -2 }
{
- \int_compare:nNnT \l_@@_first_col_int = 0 { & }
+ \int_if_zero:nT \l_@@_first_col_int { & }
\prg_replicate:nn { #4 - 1 } { & }
\int_compare:nNnT \l_@@_last_col_int > { -1 } { & } \\
}
@@ -15098,8 +15326,6 @@ version 2005/12/01 or later.
% \section{The command TikzEveryCell}
%
% \begin{macrocode}
-
-
\bool_new:N \l_@@_not_empty_bool
\bool_new:N \l_@@_empty_bool
@@ -15129,7 +15355,11 @@ version 2005/12/01 or later.
{
\group_begin:
\keys_set:nn { NiceMatrix / TikzEveryCell } { #1 }
- \tl_set:Nn \l_tmpa_tl { #2 }
+% \end{macrocode}
+% The inner pair of braces in the following line is mandatory because, the last
+% argument of |\@@_tikz:nnnnn| is \emph{a list of lists} of TikZ keys.
+% \begin{macrocode}
+ \tl_set:Nn \l_tmpa_tl { { #2 } }
\seq_map_inline:Nn \g_@@_pos_of_blocks_seq
{ \@@_for_a_block:nnnnn ##1 }
\@@_all_the_cells:
@@ -15149,7 +15379,7 @@ version 2005/12/01 or later.
{
\cs_if_exist:cF { cell - \@@_i_tl - \@@_j_tl }
{
- \exp_args:NNx \seq_if_in:NnF \l_@@_corners_cells_seq
+ \exp_args:NNe \seq_if_in:NnF \l_@@_corners_cells_seq
{ \@@_i_tl - \@@_j_tl }
{
\bool_set_false:N \l_tmpa_bool
@@ -15192,8 +15422,6 @@ version 2005/12/01 or later.
{ \cs_set:cpn { cell - ##1 - ####1 } { } }
}
}
-
-
% \end{macrocode}
%
%
@@ -15922,7 +16150,7 @@ version 2005/12/01 or later.
{
Problem~with~'not-empty'\\
For~technical~reasons,~you~must~activate~
- 'recreate-cell-nodes'~in~\token_to_str:N \CodeBefore\
+ 'create-cell-nodes'~in~\token_to_str:N \CodeBefore\
in~order~to~use~the~key~'\l_keys_key_str'.\\
That~key~will~be~ignored.
}
@@ -16020,7 +16248,7 @@ version 2005/12/01 or later.
\@@_msg_new:nn { Forbidden~letter }
{
Forbidden~letter.\\
- You~can't~use~the~letter~'\l_@@_letter_str'~for~a~customized~line.\\
+ You~can't~use~the~letter~'#1'~for~a~customized~line.\\
It~will~be~ignored.
}
% \end{macrocode}
@@ -16283,6 +16511,17 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \begin{macrocode}
+\@@_msg_new:nn { without~color-inside }
+ {
+ If~order~to~use~\token_to_str:N \cellcolor,~\token_to_str:N \rowcolor,~
+ \token_to_str:N \rowcolors\ or~\token_to_str:N \rowlistcolors\
+ outside~\token_to_str:N \CodeBefore,~you~
+ should~have~used~the~key~'color-inside'~in~your~\@@_full_name_env:.\\
+ You~can~go~on~but~you~may~need~more~compilations.
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
\@@_msg_new:nn { color~in~custom-line~with~tikz }
{
Erroneous~use.\\
@@ -16385,17 +16624,6 @@ version 2005/12/01 or later.
respect-arraystretch,~t,~T,~tikz,~transparent~and~vlines.
}
% \end{macrocode}
-%
-% \begin{macrocode}
-\@@_msg_new:nn { Version~of~siunitx~too~old }
- {
- siunitx~too~old.\\
- You~can't~use~'S'~columns~because~your~version~of~'siunitx'~
- is~too~old.~You~need~at~least~v~3.0.38~and~your~log~file~says:~"siunitx,~
- \use:c { ver @ siunitx.sty }". \\
- This~error~is~fatal.
- }
-% \end{macrocode}
%
%
% \begin{macrocode}
@@ -16794,6 +17022,16 @@ version 2005/12/01 or later.
However,~you~can~go~on.
}
% \end{macrocode}
+%
+% \begin{macrocode}
+\@@_msg_new:nn { Preamble~forgotten }
+ {
+ Preamble~forgotten.\\
+ You~have~probably~forgotten~the~preamble~of~your~
+ \@@_full_name_env:. \\
+ This~error~is~fatal.
+ }
+% \end{macrocode}
%
% \newpage
% \tableofcontents