texlive[68639] Master/texmf-dist: nicematrix (24oct23)
commits+karl at tug.org
commits+karl at tug.org
Tue Oct 24 22:22:49 CEST 2023
Revision: 68639
https://tug.org/svn/texlive?view=revision&revision=68639
Author: karl
Date: 2023-10-24 22:22:48 +0200 (Tue, 24 Oct 2023)
Log Message:
-----------
nicematrix (24oct23)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix-code.pdf
trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf
trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex
trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf
trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix.tex
trunk/Master/texmf-dist/source/latex/nicematrix/nicematrix-code.dtx
trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
Modified: trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix-code.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex 2023-10-24 20:22:36 UTC (rev 68638)
+++ trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex 2023-10-24 20:22:48 UTC (rev 68639)
@@ -57,6 +57,11 @@
\NewDocumentCommand{\Definition}{m}
{{\setlength{\fboxsep}{1pt}\colorbox{gray!20}{\ttfamily \vphantom{gl}#1}}}
+\NewDocumentCommand{\DefinitionCommande}{m}
+ {{\setlength{\fboxsep}{1pt}\colorbox{gray!20}{\ttfamily
+ \vphantom{gl}\textbackslash #1}}}
+
+
\usepackage{makeidx}
\makeindex
@@ -620,8 +625,8 @@
Par défaut, les filets ne sont pas tracés dans les blocs (voir à ce sujet
la partie sur les filets, section~\ref{rules} p.~\pageref{rules}). Néanmoins, si
la clé \Definition{transparent} est utilisée, les filets seront tracés.\footnote{Par
-ailleurs, la commande |\TikzEveryCell| disponible dans le |\CodeAfter|, ne
-s'applique aux blocs avec la clé |transparent|).}
+ailleurs, la commande |\TikzEveryCell| disponible dans le |\CodeAfter| et le
+|\CodeBefore|, ne s'applique aux blocs avec la clé |transparent|.}
Pour un exemple, voir la section~\ref{tikz-key-examples},
page~\pageref{tikz-key-examples}.
@@ -678,7 +683,7 @@
largeur de la colonne courante.
Dans les colonnes à largeur fixée (|p{...}|, |b{...}|, |m{...}|, |w{...}{...}|,
-|W{...}{...}|, |V| et~|X|), le contenu du bloc est mis en forme comme un
+|W{...}{...}|, |V{...}| et~|X|), le contenu du bloc est mis en forme comme un
paragraphe de cette largeur.
\item La spécification d'alignement horizontal donnée par le type de
@@ -1060,7 +1065,7 @@
En revanche, les filets verticaux ne sont pas tracés à l'intérieur des blocs
(créés par |\Block|: cf.~p.~\pageref{Block}) ni dans les coins (dont la création
est demandée par la clé |corners|: cf.~p.~\pageref{corners}), ni dans les
-éventuelles rangées extérieures (créées par les clés |row-first| et |last-row|:
+éventuelles rangées extérieures (créées par les clés |first-row| et |last-row|:
cf.~p.~\pageref{exterior}).
@@ -1266,7 +1271,6 @@
|\NewExpandableDocumentCommand| de LaTeX3, |\newcommand| de LaTeX ou même
|\def| de TeX). Exemple : |\newcommand{\RedLine}{\Hline[color=red]}|}
-\bigskip
De même que la commande |\Hline|, le specificateur «\verb+|+» admet entre crochets
des options qui caractérisent le filet à tracer.
@@ -1363,7 +1367,7 @@
La clé |hvlines-except-borders| est similaire à la clé |hvlines| mais ne trace
pas les filets sur les bords horizontaux et verticaux du tableau. Pour un
exemple d'utilisation de cette clé, voir la partie «Exemple d'utilisation avec
-tcolorbox» p.~\pageref{tcolorbox}.
+\pkg{tcolorbox}» p.~\pageref{tcolorbox}.
\medskip
\subsubsection{Les coins (vides)}
@@ -1391,7 +1395,7 @@
\medskip
\begin{minipage}{9cm}
-Dans l'exemple ci-contre (où B est au centre d'un bloc de taille $2\times 2$),
+Dans l'exemple ci-contre (où B est au centre d'un |\Block| de taille $2\times 2$),
on a colorié en bleu clair les quatre coins (vides) du tableau.
\end{minipage}\hspace{2cm}%
\begin{NiceTabular}{*{6}{c}}[cell-space-top-limit=3pt]
@@ -1480,7 +1484,9 @@
\bigskip
$\triangleright$ Les coins sont également pris en compte par les outils de
coloriage dans le |\CodeBefore|. Ces outils ne colorient pas les cases qui sont
-dans les coins (cf.~p.~\pageref{color-in-code-before}).
+dans les coins (cf.~p.~\pageref{color-in-code-before}). La commande
+|\TikzEveryCell| disponible dans le |\CodeAfter| et le |\CodeBefore| (cf.
+p.~\pageref{TikzEveryCell}). tient également compte des coins.
\subsection{La commande \textbackslash diagbox}
@@ -2355,24 +2361,28 @@
On a alors accès aux commandes suivantes (les trois premières sont inspirées par
\pkg{colortbl} mais sont indépendantes de \pkg{colortbl}) :
\begin{itemize}
-\item |\cellcolor| qui colorie la case courante\footnote{Néanmoins, cette
+\item \DefinitionCommande{cellcolor} qui colorie la case courante\footnote{Néanmoins, cette
commande |\cellcolor| supprimera les espaces qui la suivent, ce que ne fait
pas la commande |\cellcolor| de \pkg{colortbl}.} ;
-\item |\rowcolor| à utiliser dans une case et qui colorie le reste de la rangée
-;
-\item |\columncolor| à utiliser dans le préambule du tableau de la même manière
-que la commande éponyme de \pkg{colortbl} (néanmoins, contrairement à la
-commande |\columncolor| de \pkg{colortbl}, celle de \pkg{nicematrix} peut
-apparaître à l'intérieur d'une autre commande, elle-même utilisée dans le
-préambule) ;
-\item |\rowcolors| qui prend pour arguments deux couleurs et colorie la suite du
-tableau avec ces deux couleurs ;
-\item |\rowlistcolors| qui prend pour argument une liste de couleurs et colorie
-la suite du tableau avec ces couleurs.\footnote{Quand la commande
- |\rowlistcolors| (ou la commande |\rowcolors|) est utilisée dans une case de
- la colonne~$j$, le coloriage ne s'applique que les colonnes au-delà de~$j$ (à
- dessein).}
+\item \DefinitionCommande{rowcolor} à utiliser dans une case et qui colorie le
+reste de la rangée;\footnote{Si vous souhaitez une commande pour colorier les
+ $n$~rangées suivantes, considérez la commande |\RowStyle| et sa clé
+ |rowcolor|, p.~\pageref{RowStyle}}
+\item \DefinitionCommande{columncolor} à utiliser dans le préambule du tableau
+de la même manière que la commande éponyme de \pkg{colortbl} (néanmoins,
+contrairement à la commande |\columncolor| de \pkg{colortbl}, celle de
+\pkg{nicematrix} peut apparaître à l'intérieur d'une autre commande, elle-même
+utilisée dans le préambule) ;
+\item \DefinitionCommande{rowcolors} qui prend pour arguments deux couleurs et
+colorie la suite du tableau avec ces deux couleurs ;
+\item \DefinitionCommande{rowlistcolors} qui prend pour argument une liste de
+couleurs et colorie la suite du tableau avec ces couleurs.\footnote{Quand la
+ commande |\rowlistcolors| (ou la commande |\rowcolors|) est utilisée dans une
+ case de la colonne~$j$, le coloriage ne s'applique que sur les colonnes
+ au-delà de~$j$ (à dessein).}
\end{itemize}
+Ces commandes sont compatibles avec les commandes pour les \emph{overlays} de
+Beamer (comme |\only|, etc.)
\medskip
\begin{Verbatim}
@@ -2406,6 +2416,45 @@
\end{NiceTabular}
\end{center}
+\bigskip
+\colorbox{yellow!50}{\textbf{Nouveau 6.25}}\enskip Chaque utilisation de
+|\rowlistcolors| (et de |\rowcolors| qui en est un cas particulier) met un
+terme aux éventuels schémas\footnote{On a écrit \emph{schémas} au pluriel car on
+ peut avoir plusieurs schémas en cours s'ils portent sur des colonnes
+ différentes.} de coloriage en cours qui auraient été spécifiés par une
+commande |\rowlistcolors| précédente.
+
+En particulier, on peut engager un coloriage des rangées avec
+|\rowlistcolors{...}| et l'arrêter par un |\rowlistcolors{}| avec argument vide.
+
+\bigskip
+\begin{BVerbatim}[boxwidth=10cm,baseline=c]
+\begin{NiceTabular}{c}[hvlines,color-inside]
+un \\
+deux \\
+~emphase#\rowlistcolors{red!15}@
+trois \\
+quatre \\
+cinq \\
+~emphase#\rowlistcolors{}@
+six \\
+sept \\
+\end{NiceTabular}
+\end{BVerbatim}
+\begin{NiceTabular}{c}[hvlines,color-inside]
+un \\
+deux \\
+\rowlistcolors{red!15}
+trois \\
+quatre \\
+cinq \\
+\rowlistcolors{}
+six \\
+sept \\
+\end{NiceTabular}
+
+
+
\section{La commande \textbackslash RowStyle}
\label{RowStyle}
@@ -2813,8 +2862,8 @@
colonne : ce sera automatiquement (et nécessairement) une colonne |r| pour la
première colonne et une colonne |l| pour la dernière.\footnote{Si on souhaite
une colonne extérieure avec un autre type d'alignement, on aura intérêt à
- considérer la commande |\SubMatrix| disponible dans le |\CodeAfter|
- (cf. p.~\pageref{sub-matrix}).}
+ considérer la commande |\SubMatrix| disponible dans le |\CodeAfter| et le
+ |\CodeBefore| (cf. p.~\pageref{sub-matrix}).}
\item On peut se demander comment \pkg{nicematrix} détermine le nombre de rangées et de colonnes nécessaires à la
composition de la «dernière rangée» et de la «dernière colonne».
@@ -3583,7 +3632,7 @@
\bigskip
Pour des constructions plus complexes, avec en particulier des délimiteurs ne
couvrant pas toutes les rangées, on aura intérêt à considérer la commande
-|\SubMatrix| disponible dans le |\CodeAfter|: voir la partie~\ref{sub-matrix},
+|\SubMatrix| disponible dans le |\CodeAfter| et le |\CodeBefore|: voir la partie~\ref{sub-matrix},
p.~\pageref{sub-matrix}.
@@ -4093,8 +4142,10 @@
\index{SubMatrix@\texttt{\textbackslash TikzEveryCell} (commande du
\texttt{\textbackslash CodeAfter}\newline et du
\texttt{\textbackslash CodeBefore})|textbf}
+\label{TikzEveryCell}
+\index{empty (clé de \texttt{\textbackslash TikzEveryCell})}
+\index{non empty (clé de \texttt{\textbackslash TikzEveryCell})}
-
\colorbox{yellow!50}{\textbf{Nouveau 6.24}}\enskip La commande |\TikzEveryCell|
exécute avec TikZ le chemin rectangulaire qui correspond à chaque case du tableau,
avec comme paramètres TikZ l'argument de |\TikzEveryCell|. Cet argument doit
@@ -4141,7 +4192,7 @@
\endgroup
-\medskip
+\bigskip
La commande |\TikzEveryCell| possède deux clés :
\begin{itemize}
\item avec la clé \Definition{empty}, la commande ne s'applique qu'aux cellules
@@ -6546,38 +6597,39 @@
\NiceMatrixOptions
{
light-syntax,
- last-col, code-for-last-col = \color{blue} \scriptstyle,
+ last-col, code-for-last-col = \color{blue}\scriptstyle,
+ vlines = 5 ,
+ matrix/columns-type = r
}
\setlength{\extrarowheight}{1mm}
-$\begin{pNiceArray}{rrrr|r}
+\quad $\begin{pNiceMatrix}
12 -8 7 5 3 {} ;
3 -18 12 1 4 ;
-3 -46 29 -2 -15 ;
9 10 -5 4 7
-\end{pNiceArray}$
+\end{pNiceMatrix}$
\smallskip
-$\begin{pNiceArray}{rrrr|r}
-12 -8 7 5 3 ;
+\quad $\begin{pNiceMatrix}
+12 -8 7 5 3 ;
0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ;
0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ;
0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ;
-\end{pNiceArray}$
+\end{pNiceMatrix}$
\smallskip
-$\begin{pNiceArray}{rrrr|r}
+\quad $\begin{pNiceMatrix}
12 -8 7 5 3 ;
0 64 -41 1 19 ;
0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 }
-\end{pNiceArray}$
+\end{pNiceMatrix}$
\smallskip
-$\begin{pNiceArray}{rrrr|r}
+\quad $\begin{pNiceMatrix}
12 -8 7 5 3 {} ;
0 64 -41 1 19 ;
-\end{pNiceArray}$
-
+\end{pNiceMatrix}$
~emphase#\end{NiceMatrixBlock}@
\end{Verbatim}
@@ -6587,37 +6639,39 @@
\NiceMatrixOptions
{
light-syntax,
- last-col, code-for-last-col = \color{blue} \scriptstyle ,
+ last-col, code-for-last-col = \color{blue}\scriptstyle,
+ vlines = 5 ,
+ matrix/columns-type = r
}
\setlength{\extrarowheight}{1mm}
-\quad $\begin{pNiceArray}{rrrr|r}
+\quad $\begin{pNiceMatrix}
12 -8 7 5 3 {} ;
3 -18 12 1 4 ;
-3 -46 29 -2 -15 ;
9 10 -5 4 7
-\end{pNiceArray}$
+\end{pNiceMatrix}$
\smallskip
-\quad $\begin{pNiceArray}{rrrr|r}
-12 -8 7 5 3 ;
+\quad $\begin{pNiceMatrix}
+12 -8 7 5 3 ;
0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ;
0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ;
0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ;
-\end{pNiceArray}$
+\end{pNiceMatrix}$
\smallskip
-\quad $\begin{pNiceArray}{rrrr|r}
+\quad $\begin{pNiceMatrix}
12 -8 7 5 3 ;
0 64 -41 1 19 ;
0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 }
-\end{pNiceArray}$\par\nobreak
+\end{pNiceMatrix}$
\smallskip
-\quad $\begin{pNiceArray}{rrrr|r}
+\quad $\begin{pNiceMatrix}
12 -8 7 5 3 {} ;
0 64 -41 1 19 ;
-\end{pNiceArray}$
+\end{pNiceMatrix}$
\end{NiceMatrixBlock}
\medskip
@@ -6631,6 +6685,7 @@
Pour résoudre ce problème, on peut demander que les délimiteurs soient composés
avec leur largeur maximale grâce à la clé booléenne |delimiters/max-width|.
+
\begin{Verbatim}[formatcom=\small\color{gray}]
~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@
\NiceMatrixOptions
@@ -6638,16 +6693,17 @@
~emphase#delimiters/max-width@,
light-syntax,
last-col, code-for-last-col = \color{blue}\scriptstyle,
+ vlines = 5 ,
+ matrix/columns-type = r
}
\setlength{\extrarowheight}{1mm}
-$\begin{pNiceArray}{rrrr|r}
+\quad $\begin{pNiceMatrix}
12 -8 7 5 3 {} ;
3 -18 12 1 4 ;
-3 -46 29 -2 -15 ;
9 10 -5 4 7
-\end{pNiceArray}$
-
+\end{pNiceMatrix}$
...
~emphase#\end{NiceMatrixBlock}@
\end{Verbatim}
@@ -6659,37 +6715,38 @@
delimiters/max-width,
light-syntax,
last-col, code-for-last-col = \color{blue}\scriptstyle,
+ vlines = 5 ,
+ matrix/columns-type = r
}
\setlength{\extrarowheight}{1mm}
-\quad $\begin{pNiceArray}{rrrr|r}
+\quad $\begin{pNiceMatrix}
12 -8 7 5 3 {} ;
3 -18 12 1 4 ;
-3 -46 29 -2 -15 ;
9 10 -5 4 7
-\end{pNiceArray}$
+\end{pNiceMatrix}$
\smallskip
-\quad $\begin{pNiceArray}{rrrr|r}
+\quad $\begin{pNiceMatrix}
12 -8 7 5 3 ;
0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ;
0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ;
0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ;
-\end{pNiceArray}$
+\end{pNiceMatrix}$
\smallskip
-\quad $\begin{pNiceArray}{rrrr|r}
+\quad $\begin{pNiceMatrix}
12 -8 7 5 3 ;
0 64 -41 1 19 ;
0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 }
-\end{pNiceArray}$
+\end{pNiceMatrix}$
\smallskip
-\quad $\begin{pNiceArray}{rrrr|r}
+\quad $\begin{pNiceMatrix}
12 -8 7 5 3 {} ;
0 64 -41 1 19 ;
-\end{pNiceArray}$
-
+\end{pNiceMatrix}$
\end{NiceMatrixBlock}
Modified: trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix.tex 2023-10-24 20:22:36 UTC (rev 68638)
+++ trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix.tex 2023-10-24 20:22:48 UTC (rev 68639)
@@ -53,6 +53,11 @@
\NewDocumentCommand{\Definition}{m}
{{\setlength{\fboxsep}{1pt}\colorbox{gray!20}{\ttfamily \vphantom{gl}#1}}}
+\NewDocumentCommand{\DefinitionCommand}{m}
+ {{\setlength{\fboxsep}{1pt}\colorbox{gray!20}{\ttfamily
+ \vphantom{gl}\textbackslash #1}}}
+
+
\usepackage{makeidx}
\makeindex
@@ -1434,7 +1439,9 @@
\medskip
$\triangleright$ The corners are also taken into account by the tools provided
by \pkg{nicematrix} to color cells, rows and columns. These tools don't color
-the cells which are in the corners (cf.~p.~\pageref{color-in-code-before}).
+the cells which are in the corners (cf.~p.~\pageref{color-in-code-before}). The
+command |\TikzEveryCell| available in the |\CodeBefore| and the |\CodeAfter|
+(cf. p.~\pageref{TikzEveryCell}) takes also into account the empty corners.
\subsection{The command \textbackslash diagbox}
@@ -2291,24 +2298,28 @@
There are several commands available (the first three ones are inspired by
\pkg{colortbl} but are \emph{independent} of \pkg{colortbl}):
\begin{itemize}
-\item |\cellcolor| which colorizes a cell;\footnote{However, this command
-|\cellcolor| will delete the following spaces, which does not the command
-|\cellcolor| of \pkg{colortbl}.}
-\item |\rowcolor| which must be used in a cell and which colorizes the end of
-the row;
-\item |\columncolor| which must be used in the preamble of the environment
-with the same syntax as the corresponding command of
-\pkg{colortbl} (however, unlike the command |\columncolor| of \pkg{colortbl},
-this command |\columncolor| can appear within another command, itself used in the
-preamble of the array);
-\item |\rowcolors| which takes in as arguments two colors and color the rest of
-the tabular with those colors;
-\item |\rowlistcolors| which takes in as argument a color and color the rest of
-the tabular with the colors of that list of colors.\footnote{When the command
- |\rowlistcolors| (or the command |\rowcolors| is used in a cell of the
- column~$j$ of the array, the command applies only on the columns above~$j$ (by
-design).}
+\item \DefinitionCommand{cellcolor} which colorizes a cell;\footnote{However,
+ this command cellcolor will delete the following spaces, which does not the
+ command cellcolor of \pkg{colortbl}.}
+\item \DefinitionCommand{rowcolor} which must be used in a cell and which
+colorizes the end of the row;\footnote{If you want a commande to color the
+ following $n$~rows, consider the command |\RowStyle| and its key |rowcolor|,
+ p.~\pageref{RowStyle}}
+\item \DefinitionCommand{columncolor} which must be used in the preamble of the
+environment with the same syntax as the corresponding command of \pkg{colortbl}
+(however, unlike the command columncolor of \pkg{colortbl}, this command
+|\columncolor| can appear within another command, itself used in the preamble of
+the array);
+\item \DefinitionCommand{rowcolors} which takes in as arguments two colors and
+color the rest of the tabular with those colors;
+\item \DefinitionCommand{rowlistcolors} which takes in as argument a color and
+color the rest of the tabular with the colors of that list of
+colors.\footnote{When the command |\rowlistcolors| (or the command |\rowcolors|
+ is used in a cell of the column~$j$ of the array, the command applies only on
+ the columns above~$j$ (by design).}
\end{itemize}
+These commands are compatible with the commands for the overlays of Beamer
+(|\only|, etc.)
\smallskip
\begin{Verbatim}
@@ -2342,6 +2353,43 @@
\end{NiceTabular}
\end{center}
+\bigskip
+\colorbox{yellow!50}{\textbf{New 6.25}}\enskip Each use of the command
+|\rowlistcolors| (or |\rowcolors|, which is, in fact, a special case of
+|\rowlistcolors|) stops the potential coloring schemes\footnote{We say
+ \emph{schemes} in plural form because it's possible to start simultaneously
+ several coloring schemes if they apply on different columns.} specified by a
+previous command |\rowlistcolors|. In particular, it's possible to start
+coloring the rows with |\rowlistcolors{...}| and stop coloring by a command
+|\rowlistcolors| with an empty argument.
+
+\bigskip
+\begin{BVerbatim}[boxwidth=10cm,baseline=c]
+\begin{NiceTabular}{c}[hvlines,color-inside]
+one \\
+two \\
+~emphase#\rowlistcolors{red!15}@
+three \\
+four \\
+five \\
+~emphase#\rowlistcolors{}@
+six \\
+seven \\
+\end{NiceTabular}
+\end{BVerbatim}
+\begin{NiceTabular}{c}[hvlines,color-inside]
+one \\
+two \\
+\rowlistcolors{red!15}
+three \\
+four \\
+five \\
+\rowlistcolors{}
+six \\
+seven \\
+\end{NiceTabular}
+
+
\section{The command \textbackslash RowStyle}
\label{RowStyle}
@@ -2742,7 +2790,7 @@
automatically (and necessarily) be of type |r| for the first column and |l|
for the last one.\footnote{The users wishing exterior columns with another
type of alignment should consider the command |\SubMatrix| available in the
-|\CodeAfter| (cf.~p.~\pageref{sub-matrix}).}
+|\CodeAfter| and in the |\CodeBefore| (cf.~p.~\pageref{sub-matrix}).}
\item One may wonder how \pkg{nicematrix} determines the number of rows and
columns which are needed for the composition of the ``last row'' and ``last
column''.
@@ -2831,8 +2879,8 @@
\item For technical reasons, it's not possible to use the option of the
command |\\| after the ``first row'' or before the ``last row''. The placement
of the delimiters would be wrong. If you are looking for a workaround,
-consider the command |\SubMatrix| in the |\CodeAfter| described
-p.~\pageref{sub-matrix}.
+consider the command |\SubMatrix| in the |\CodeAfter| (and the |\CodeBefore|)
+described p.~\pageref{sub-matrix}.
\end{itemize}
@@ -3501,8 +3549,8 @@
\bigskip
For more complex constructions, in particular with delimiters spanning only a
\emph{subset} of the rows of the array, one should consider the command
-|\SubMatrix| available in the |\CodeAfter|. See the section~\ref{sub-matrix},
-p.~\pageref{sub-matrix}.
+|\SubMatrix| available in the |\CodeAfter| (and the |\CodeBefore|). See the
+section~\ref{sub-matrix}, p.~\pageref{sub-matrix}.
\section{The \textbackslash CodeAfter}
@@ -4008,9 +4056,11 @@
\index{SubMatrix@\texttt{\textbackslash TikzEveryCell} (command of
\texttt{\textbackslash CodeAfter}\newline and
\texttt{\textbackslash CodeBefore})|textbf}
+\label{TikzEveryCell}
+\index{empty (key of \texttt{\textbackslash TikzEveryCell})}
+\index{non empty (key of \texttt{\textbackslash TikzEveryCell})}
-
\colorbox{yellow!50}{\textbf{New 6.24}}\enskip The command |\TikzEveryCell|
execute with TikZ the rectangular path corresponding to each cell of the tabular
with parameters of TikZ the argument of |\TikzEveryCell|. That argument must be
@@ -6407,82 +6457,86 @@
with the environment |{NiceMatrixBlock}| and its option |auto-columns-width|.
\begin{Verbatim}[formatcom=\small\color{gray}]
+\begin{Verbatim}[formatcom=\small\color{gray}]
~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@
\NiceMatrixOptions
- {
+ {
light-syntax,
- last-col, code-for-last-col = \color{blue} \scriptstyle,
+ last-col, code-for-last-col = \color{blue}\scriptstyle,
+ vlines = 5 ,
+ matrix/columns-type = r
}
\setlength{\extrarowheight}{1mm}
-$\begin{pNiceArray}{rrrr|r}
+\quad $\begin{pNiceMatrix}
12 -8 7 5 3 {} ;
3 -18 12 1 4 ;
-3 -46 29 -2 -15 ;
- 9 10 -5 4 7
-\end{pNiceArray}$
+ 9 10 -5 4 7
+\end{pNiceMatrix}$
\smallskip
-$\begin{pNiceArray}{rrrr|r}
-12 -8 7 5 3 ;
+\quad $\begin{pNiceMatrix}
+12 -8 7 5 3 ;
0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ;
0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ;
0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ;
-\end{pNiceArray}$
+\end{pNiceMatrix}$
\smallskip
-$\begin{pNiceArray}{rrrr|r}
+\quad $\begin{pNiceMatrix}
12 -8 7 5 3 ;
0 64 -41 1 19 ;
-0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 }
-\end{pNiceArray}$
+0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 }
+\end{pNiceMatrix}$
\smallskip
-$\begin{pNiceArray}{rrrr|r}
+\quad $\begin{pNiceMatrix}
12 -8 7 5 3 {} ;
0 64 -41 1 19 ;
-\end{pNiceArray}$
-
+\end{pNiceMatrix}$
~emphase#\end{NiceMatrixBlock}@
\end{Verbatim}
-\bigskip
-\index{auto-columns-width!(key of \texttt{\{NiceMatrixBlock\}})|textit}
+\medskip
+\index{auto-columns-width!(clé de \texttt{\{NiceMatrixBlock\}})|textit}
\begin{NiceMatrixBlock}[auto-columns-width]
\NiceMatrixOptions
- {
+ {
light-syntax,
- last-col, code-for-last-col = \color{blue} \scriptstyle ,
+ last-col, code-for-last-col = \color{blue}\scriptstyle,
+ vlines = 5 ,
+ matrix/columns-type = r
}
\setlength{\extrarowheight}{1mm}
-\quad $\begin{pNiceArray}{rrrr|r}
+\quad $\begin{pNiceMatrix}
12 -8 7 5 3 {} ;
3 -18 12 1 4 ;
-3 -46 29 -2 -15 ;
- 9 10 -5 4 7
-\end{pNiceArray}$
+ 9 10 -5 4 7
+\end{pNiceMatrix}$
\smallskip
-\quad $\begin{pNiceArray}{rrrr|r}
-12 -8 7 5 3 ;
+\quad $\begin{pNiceMatrix}
+12 -8 7 5 3 ;
0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ;
0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ;
0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ;
-\end{pNiceArray}$
+\end{pNiceMatrix}$
\smallskip
-\quad $\begin{pNiceArray}{rrrr|r}
+\quad $\begin{pNiceMatrix}
12 -8 7 5 3 ;
0 64 -41 1 19 ;
-0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 }
-\end{pNiceArray}$\par\nobreak
+0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 }
+\end{pNiceMatrix}$
\smallskip
-\quad $\begin{pNiceArray}{rrrr|r}
+\quad $\begin{pNiceMatrix}
12 -8 7 5 3 {} ;
0 64 -41 1 19 ;
-\end{pNiceArray}$
+\end{pNiceMatrix}$
\end{NiceMatrixBlock}
\bigskip
@@ -6500,62 +6554,64 @@
\begin{Verbatim}[formatcom=\small\color{gray}]
~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@
\NiceMatrixOptions
- {
+ {
~emphase#delimiters/max-width@,
light-syntax,
last-col, code-for-last-col = \color{blue}\scriptstyle,
+ vlines = 5 ,
+ matrix/columns-type = r
}
\setlength{\extrarowheight}{1mm}
-$\begin{pNiceArray}{rrrr|r}
+\quad $\begin{pNiceMatrix}
12 -8 7 5 3 {} ;
3 -18 12 1 4 ;
-3 -46 29 -2 -15 ;
- 9 10 -5 4 7
-\end{pNiceArray}$
-
+ 9 10 -5 4 7
+\end{pNiceMatrix}$
...
~emphase#\end{NiceMatrixBlock}@
\end{Verbatim}
-\bigskip
+\medskip
\begin{NiceMatrixBlock}[auto-columns-width]
\NiceMatrixOptions
- {
+ {
delimiters/max-width,
light-syntax,
last-col, code-for-last-col = \color{blue}\scriptstyle,
+ vlines = 5 ,
+ matrix/columns-type = r
}
\setlength{\extrarowheight}{1mm}
-\quad $\begin{pNiceArray}{rrrr|r}
+\quad $\begin{pNiceMatrix}
12 -8 7 5 3 {} ;
3 -18 12 1 4 ;
-3 -46 29 -2 -15 ;
- 9 10 -5 4 7
-\end{pNiceArray}$
+ 9 10 -5 4 7
+\end{pNiceMatrix}$
\smallskip
-\quad $\begin{pNiceArray}{rrrr|r}
+\quad $\begin{pNiceMatrix}
12 -8 7 5 3 ;
0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ;
0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ;
0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ;
-\end{pNiceArray}$
+\end{pNiceMatrix}$
\smallskip
-\quad $\begin{pNiceArray}{rrrr|r}
+\quad $\begin{pNiceMatrix}
12 -8 7 5 3 ;
0 64 -41 1 19 ;
-0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 }
-\end{pNiceArray}$\par\nobreak
+0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 }
+\end{pNiceMatrix}$
\smallskip
-\quad $\begin{pNiceArray}{rrrr|r}
+\quad $\begin{pNiceMatrix}
12 -8 7 5 3 {} ;
0 64 -41 1 19 ;
-\end{pNiceArray}$
-
+\end{pNiceMatrix}$
\end{NiceMatrixBlock}
@@ -7062,7 +7118,14 @@
\nolinkurl{https:www.tug.org/svn/texlive/trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty}
}
+\subsection*{Changes between version 6.24 and 6.25}
+Correction of several bugs.
+
+An instruction |\rowlistcolors| in the tabular stops the effect of a previous
+|\rowlistcolors|.
+
+
\subsection*{Changes between version 6.23 and 6.24}
New command |\TikzEveryCell| available in the |\CodeAfter| and the |\CodeBefore|
Modified: trunk/Master/texmf-dist/source/latex/nicematrix/nicematrix-code.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/nicematrix/nicematrix-code.dtx 2023-10-24 20:22:36 UTC (rev 68638)
+++ trunk/Master/texmf-dist/source/latex/nicematrix/nicematrix-code.dtx 2023-10-24 20:22:48 UTC (rev 68639)
@@ -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 @@
\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 @@
\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 @@
%
% \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 @@
%
% 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 @@
\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 @@
\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 @@
% \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 at row@strut\relax
+ \let\ar at align@mcell\relax
+ \@temptokena{#1} % \@tempswatrue
+ % \@whilesw\if at tempswa\fi{\@tempswafalse\the\NC at list}%
+ \count@\m at ne
+ \let\the at toks\relax
+ \prepnext at 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 at 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 at 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 at setup \relax
+ \cs_set_eq:NN \CT at color \relax
+ \cs_set_eq:NN \CT at do@color \relax
+ \cs_set_eq:NN \color \relax
+ \cs_set_eq:NN \CT at column@color \relax
+ \cs_set_eq:NN \CT at row@color \relax
+ \cs_set_eq:NN \CT at cell@color \relax
+ }
+ }
+ { }
+ }
+% \end{macrocode}
+%
+% \bigskip
% \section{Parameters}
%
% \bigskip
@@ -779,7 +867,7 @@
%
% \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 @@
% \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,7 +1117,14 @@
% \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:
{
\if_mode_math: \else:
@@ -1038,12 +1133,6 @@
}
% \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 @@
% 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 @@
\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 at tabularnote }
@@ -1898,7 +1988,7 @@
{
\int_eval:n
{
- \int_compare:nNnTF \l_tmpa_int = \c_zero_int
+ \int_if_zero:nTF \l_tmpa_int
\c at tabularnote
\l_tmpa_int
}
@@ -2478,7 +2568,15 @@
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 @@
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 @@
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 @@
% \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 @@
% 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 at iRow = 0
+ \int_if_zero:nTF \c at iRow
{
\int_compare:nNnT \c at jCol > 0
{
@@ -3023,7 +3119,7 @@
% \begin{macrocode}
\cs_new_protected:Npn \@@_update_for_first_and_last_row:
{
- \int_compare:nNnTF \c at iRow = 0
+ \int_if_zero:nTF \c at 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 @@
% 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 @@
% \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 @@
}
% \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 at sep
{ \bool_if:NTF \l_@@_tabular_bool \tabcolsep \arraycolsep }
\dim_compare:nNnTF \l_@@_tabular_width_dim = \c_zero_dim
@@ -3366,7 +3477,6 @@
% \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 @@
{
\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 at iRow + 1 } }
@@ -3493,19 +3603,63 @@
}
% \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 at everycr
+ {
+ \noalign { \cs_gset_eq:NN \CT at 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 at redefine@check at 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 @@
% \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 at redefine@check at 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 @@
% \begin{macrocode}
\cs_set_nopar:Npn \ialign
{
- \IfPackageLoadedTF { colortbl }
- {
- \CT at everycr
- {
- \noalign { \cs_gset_eq:NN \CT at row@color \prg_do_nothing: }
- \@@_everycr:
- }
- }
- { \everycr { \@@_everycr: } }
+ \@@_redefine_everycr:
\tabskip = \c_zero_skip
% \end{macrocode}
%
@@ -3651,7 +3782,10 @@
\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 @@
\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 @@
% 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 @@
% \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 @@
% \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 @@
% 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 at sep % 05-08-23
\skip_horizontal:N \g_@@_width_first_col_dim
@@ -4488,7 +4621,7 @@
% |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 @@
% 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 @@
\cs_new_protected:Npn \@@_transform_preamble_i:
{
\int_gzero:N \c at 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 @@
}
}
% \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 at 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 @@
% \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 @@
% \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 @@
% \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 at 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 at find } { \@@_make_preamble_xx:n }
-% \end{macrocode}
-% The token |\NC at 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,18 +4957,21 @@
% We increment the counter of columns and then we test for the presence of a |<|.
% \begin{macrocode}
\int_gincr:N \c at 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}
%
%
@@ -4881,38 +4978,38 @@
% \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 @@
% \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,9 +5104,9 @@
%
%
% \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}
@@ -5015,22 +5113,24 @@
% 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 @@
%
% |#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 @@
\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 @@
% 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 @@
% We increment the counter of columns, and then we test for the presence of a |<|.
% \begin{macrocode}
\int_gincr:N \c at jCol
- \@@_make_preamble_xi:n
+ \@@_rec_preamble_after_col:n
}
% \end{macrocode}
%
@@ -5143,7 +5243,7 @@
% |#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,15 +5378,15 @@
% \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 }
@@ -5293,10 +5393,10 @@
\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}
@@ -5303,6 +5403,10 @@
%
% \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 @@
% |#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 @@
%
% |#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 @@
}
}
\int_gincr:N \c at jCol
- \@@_make_preamble_xi:n
+ \@@_rec_preamble_after_col:n
}
% \end{macrocode}
%
@@ -5357,7 +5461,7 @@
% 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 @@
% We increment the counter of columns and then we test for the presence of a |<|.
% \begin{macrocode}
\int_gincr:N \c at jCol
- \@@_make_preamble_xi:n
+ \@@_rec_preamble_after_col:n
}
% \end{macrocode}
%
@@ -5403,43 +5507,39 @@
% \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 at jCol
- \@@_make_preamble_xi:n
- }
- { \@@_fatal:n { Version~of~siunitx~too~old } }
+ \int_gincr:N \c at jCol
+ \@@_rec_preamble_after_col:n
}
% \end{macrocode}
%
@@ -5447,7 +5547,7 @@
% \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}
@@ -5454,7 +5554,7 @@
% If we are before the column 1 and not in |{NiceArray}|, we reserve space for
% the left delimiter.
% \begin{macrocode}
- \int_compare:nNnTF \c at jCol = \c_zero_int
+ \int_if_zero:nTF \c at jCol
{
\str_if_eq:VnTF \g_@@_left_delim_tl { . }
{
@@ -5464,19 +5564,21 @@
% \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 at jCol + 1 } } \c_true_bool }
@@ -5483,15 +5585,15 @@
\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 @@
% 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 @@
\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 at jCol } \c_false_bool }
- \@@_make_preamble:n #2
+ \@@_rec_preamble:n #2
}
}
{
@@ -5524,16 +5626,18 @@
{ \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 at 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,32 +5657,116 @@
\tl_gput_right:Nx \g_@@_pre_code_after_tl
{ \@@_delimiter:nnn #1 { \int_use:N \c at 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_protected:Npn \@@_make_preamble_ix_ii:n #1
- { \@@_make_preamble_ix:nn }
+\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 at 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 at 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 at 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:cpn { @@ _ \token_to_str:N \NC at find } #1 { \@@_rec_preamble:n }
+% \end{macrocode}
+%
+% \bigskip
% For the case of a letter |X|. This specifier may take in an optional argument
% (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 @@
% \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 @@
% \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 @@
}
}
\int_gincr:N \c at 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 |@{...}|.
+% \medskip
+% For the letter set by the user with |vlines-in-sub-matrix| (vlism).
% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_xi:n #1
+\cs_new_protected:Npn \@@_make_preamble_vlism: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 at jCol + 1 } }
- {
- \tl_gput_right:Nn \g_@@_array_preamble_tl
- { ! { \skip_horizontal:N \arrayrulewidth } }
- }
- }
- \@@_make_preamble:n { #1 }
- }
- }
+ \seq_gput_right:Nx \g_@@_cols_vlism_seq
+ { \int_eval:n { \c at jCol + 1 } }
+ \tl_gput_right:Nx \g_@@_array_preamble_tl
+ { \exp_not:N ! { \skip_horizontal:N \arrayrulewidth } }
+ \@@_rec_preamble:n
}
% \end{macrocode}
-%
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_make_preamble_xiii:n #1
- {
- \tl_gput_right:Nn \g_@@_array_preamble_tl { < { #1 } }
- \@@_make_preamble_xi: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 at 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 @@
% |\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 at firstamp \@firstampfalse \else \@preamerr 5 \fi }
% \end{macrocode}
@@ -5799,7 +5938,7 @@
% \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 @@
\seq_gput_right:Nx \g_@@_pos_of_blocks_seq
{
{
- \int_compare:nNnTF \c at jCol = 0
+ \int_if_zero:nTF \c at jCol
{ \int_eval:n { \c at iRow + 1 } }
{ \int_use:N \c at iRow }
}
{ \int_eval:n { \c at jCol + 1 } }
{
- \int_compare:nNnTF \c at jCol = 0
+ \int_if_zero:nTF \c at jCol
{ \int_eval:n { \c at iRow + 1 } }
{ \int_use:N \c at iRow }
}
@@ -5867,11 +6006,6 @@
w { \@@_make_m_preamble_v:nnnn { } #1 }
W { \@@_make_m_preamble_v:nnnn { \@@_special_W: } #1 }
\q_stop { }
-% \end{macrocode}
-% The token |\NC at 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 at find { \@@_make_preamble:n }
}
{
\cs_if_exist:cTF { NC @ find @ #1 }
@@ -6127,7 +6261,7 @@
% \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 @@
\dim_gsub:Nn \g_tmpa_dim \pgf at 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 @@
\dim_gsub:Nn \g_tmpa_dim \pgf at 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 @@
{
\@@_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 @@
% \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 @@
% \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 @@
% \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 @@
{ \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 @@
\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 @@
% 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 @@
{
\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 @@
\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 @@
}
{
\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 @@
%
% \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 @@
% \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 @@
}
\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 @@
% 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 @@
}
\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 @@
\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 @@
\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 @@
% \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 @@
% \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 @@
% \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 @@
{
\@@_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 @@
{ \@@_collect_options:n { \@@_Ldots_i } }
\exp_args:NNV \NewDocumentCommand \@@_Ldots_i \l_@@_argspec_tl
{
- \int_compare:nNnTF \c at jCol = 0
+ \int_if_zero:nTF \c at jCol
{ \@@_error:nn { in~first~col } \Ldots }
{
\int_compare:nNnTF \c at jCol = \l_@@_last_col_int
@@ -9164,7 +9310,7 @@
{ \@@_collect_options:n { \@@_Cdots_i } }
\exp_args:NNV \NewDocumentCommand \@@_Cdots_i \l_@@_argspec_tl
{
- \int_compare:nNnTF \c at jCol = 0
+ \int_if_zero:nTF \c at jCol
{ \@@_error:nn { in~first~col } \Cdots }
{
\int_compare:nNnTF \c at jCol = \l_@@_last_col_int
@@ -9186,7 +9332,7 @@
{ \@@_collect_options:n { \@@_Vdots_i } }
\exp_args:NNV \NewDocumentCommand \@@_Vdots_i \l_@@_argspec_tl
{
- \int_compare:nNnTF \c at iRow = 0
+ \int_if_zero:nTF \c at iRow
{ \@@_error:nn { in~first~row } \Vdots }
{
\int_compare:nNnTF \c at iRow = \l_@@_last_row_int
@@ -9308,8 +9454,8 @@
\cs_new:Npn \@@_Hdotsfor:
{
\bool_lazy_and:nnTF
- { \int_compare_p:nNn \c at jCol = 0 }
- { \int_compare_p:nNn \l_@@_first_col_int = 0 }
+ { \int_if_zero_p:n \c at jCol }
+ { \int_if_zero_p:n \l_@@_first_col_int }
{
\bool_if:NTF \g_@@_after_col_zero_bool
{
@@ -9420,11 +9566,8 @@
%
% \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 @@
% \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 @@
\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 @@
% \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 @@
\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 @@
{
\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 @@
{
\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 @@
{
\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 @@
{
\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 @@
%
% 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 @@
}
\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 @@
%
% \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 @@
\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 at jCol + 1 } } }
\prg_return_false:
\prg_return_true:
@@ -10503,6 +10643,7 @@
% \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 @@
% \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 @@
% 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,13 +10691,80 @@
% \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 at iRow }
+ { \exp_not:n { #1 } }
+ { \exp_not:n { #2 } }
+ { restart , cols = \int_use:N \c at 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 at 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 at iRow } { #2 }
- [ restart, cols = \int_use:N \c at jCol - , #3 ]
+ [ \exp_not:n { #2 } ]
+ { #1 - \int_eval:n { \c at iRow - 1 } }
+ { \exp_not:n { #3 } }
+ [ \exp_not:n { #4 } ]
}
}
}
@@ -10561,7 +10771,34 @@
% \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 }
{
% \end{macrocode}
@@ -10618,10 +10855,10 @@
% \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 at jCol = 0
+ \int_if_zero:nTF \c at jCol
{
\int_compare:nNnF \c at iRow = { -1 }
{ \int_compare:nNnF \c at iRow = { \l_@@_last_row_int - 1 } { #1 } }
@@ -10640,7 +10877,7 @@
% \begin{macrocode}
\cs_new_protected:Npn \@@_OnlyMainNiceMatrix_i:n #1
{
- \int_compare:nNnF \c at iRow = 0
+ \int_if_zero:nF \c at iRow
{
\int_compare:nNnF \c at iRow = \l_@@_last_row_int
{
@@ -10784,7 +11021,7 @@
\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 @@
\@@_qpoint:n { row - \int_eval:n { \l_@@_local_end_int + 1 } }
\dim_set_eq:NN \l_@@_tmpc_dim \pgf at 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 @@
\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 @@
\@@_qpoint:n { col - \int_eval:n { \l_@@_local_end_int + 1 } }
\dim_set_eq:NN \l_@@_tmpc_dim \pgf at 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,22 +11615,8 @@
% 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
% The following command will create the customized rule (it is executed when the
@@ -11473,21 +11696,18 @@
{
\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 @@
%
%
% \begin{macrocode}
+\tl_const:Nn \c_@@_forbidden_letters_tl { lcrpmbVX|()[]!@<> }
\str_const:Nn \c_@@_forbidden_letters_str { lcrpmbVX|()[]!@<> }
% \end{macrocode}
%
@@ -11668,6 +11889,7 @@
total-width = \dim_use:N \l_@@_rule_width_dim
}
}
+ \@@_rec_preamble:n
}
% \end{macrocode}
%
@@ -11786,7 +12008,7 @@
% 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 @@
\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 @@
% \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 @@
% \begin{macrocode}
\int_compare:nNnT { #1 } = 1
{
- \int_compare:nNnTF \c at iRow = 0
+ \int_if_zero:nTF \c at iRow
\l_@@_code_for_first_row_tl
{
\int_compare:nNnT \c at iRow = \l_@@_last_row_int
@@ -12664,7 +12887,7 @@
% 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 @@
% 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 @@
% \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 @@
% 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 @@
#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,9 +13260,13 @@
{ \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 }
\@@_msg_redirect_name:nn { columns~not~used } { none }
@@ -13239,9 +13466,10 @@
% 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,8 +13488,8 @@
% \tikz \node [highlight = (1-1-block-short)] { } ;
% \end{NiceTabular}
% \end{tabular}
+%
%
-%
% \bigskip
% The construction of the node corresponding to the merged cells.
% \begin{macrocode}
@@ -13406,7 +13634,7 @@
% \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 @@
{
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,7 +13854,7 @@
\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
{
@@ -13633,7 +13861,7 @@
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 @@
\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 @@
\pgfusepathqstroke
}
{
- \use:x { \exp_not:N \draw [ \l_@@_borders_tikz_tl ] }
+ \use:e { \exp_not:N \draw [ \l_@@_borders_tikz_tl ] }
( \pgf at x , \l_tmpb_dim ) -- ( \pgf at x , \l_@@_tmpc_dim ) ;
}
}
@@ -13783,7 +14011,7 @@
\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 at y ) -- ( \l_tmpb_dim , \pgf at y ) ;
}
}
@@ -13817,7 +14045,7 @@
\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 @@
% 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 @@
}
\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 @@
% \section{The command TikzEveryCell}
%
% \begin{macrocode}
-
-
\bool_new:N \l_@@_not_empty_bool
\bool_new:N \l_@@_empty_bool
@@ -15129,7 +15355,11 @@
{
\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 @@
{
\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 @@
{ \cs_set:cpn { cell - ##1 - ####1 } { } }
}
}
-
-
% \end{macrocode}
%
%
@@ -15922,7 +16150,7 @@
{
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 @@
\@@_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 @@
% \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 @@
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 @@
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
Modified: trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty 2023-10-24 20:22:36 UTC (rev 68638)
+++ trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty 2023-10-24 20:22:48 UTC (rev 68639)
@@ -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{6.24}
-\def\myfiledate{2023/09/28}
+\def\myfileversion{6.25}
+\def\myfiledate{2023/10/24}
\RequirePackage{pgfcore}
\usepgfmodule{shapes}
\RequirePackage{l3keys2e}
@@ -33,7 +33,7 @@
\cs_new_protected:Npn \__nicematrix_error:n { \msg_error:nn { nicematrix } }
\cs_new_protected:Npn \__nicematrix_warning:n { \msg_warning:nn { nicematrix } }
\cs_new_protected:Npn \__nicematrix_error:nn { \msg_error:nnn { nicematrix } }
-\cs_generate_variant:Nn \__nicematrix_error:nn { n x }
+\cs_generate_variant:Nn \__nicematrix_error:nn { n e }
\cs_new_protected:Npn \__nicematrix_error:nnn { \msg_error:nnnn { nicematrix } }
\cs_new_protected:Npn \__nicematrix_fatal:n { \msg_fatal:nn { nicematrix } }
\cs_new_protected:Npn \__nicematrix_fatal:nn { \msg_fatal:nnn { nicematrix } }
@@ -135,7 +135,6 @@
{ \__nicematrix_collect_options:nn { #1 } { #2 , #3 } }
\tl_new:N \l__nicematrix_argspec_tl
\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 }
\hook_gput_code:nnn { begindocument } { . }
{
@@ -149,10 +148,10 @@
\tl_const:Nn \c__nicematrix_endpgfortikzpicture_tl { \exp_not:N \endpgfpicture }
}
}
-\@ifclassloaded { revtex4-1 }
+\IfClassLoadedTF { revtex4-1 }
{ \bool_const:Nn \c__nicematrix_revtex_bool \c_true_bool }
{
- \@ifclassloaded { revtex4-2 }
+ \IfClassLoadedTF { revtex4-2 }
{ \bool_const:Nn \c__nicematrix_revtex_bool \c_true_bool }
{
\cs_if_exist:NT \rvtx at ifformat@geq
@@ -161,7 +160,6 @@
}
}
\cs_generate_variant:Nn \tl_if_single_token_p:n { V }
-\regex_const:Nn \c__nicematrix_columncolor_regex { \c { columncolor } }
\cs_new_protected:Npn \__nicematrix_provide_pgfsyspdfmark:
{
\iow_now:Nn \@mainaux
@@ -235,7 +233,7 @@
\cs_set:Npn \__nicematrix_standard_cline #1 { \__nicematrix_standard_cline:w #1 \q_stop }
\cs_set:Npn \__nicematrix_standard_cline:w #1-#2 \q_stop
{
- \int_compare:nNnT \l__nicematrix_first_col_int = 0 { \omit & }
+ \int_if_zero:nT \l__nicematrix_first_col_int { \omit & }
\int_compare:nNnT { #1 } > 1 { \multispan { \int_eval:n { #1 - 1 } } & }
\multispan { \int_eval:n { #2 - #1 + 1 } }
{
@@ -313,6 +311,64 @@
}
#1
}
+\cs_set_eq:NN \__nicematrix_old_mkpream: \@mkpream
+\cs_set_protected:Npn \__nicematrix_mkpream: #1
+ {
+ \__nicematrix_mkpream_colortbl:
+ \gdef\@preamble{} \@lastchclass 4 \@firstamptrue
+ \let\@sharp\relax
+ \def\@startpbox##1{\unexpanded\expandafter{\expandafter
+ \@startpbox\expandafter{##1}}}\let\@endpbox\relax
+ \let\do at row@strut\relax
+ \let\ar at align@mcell\relax
+ \@temptokena{#1} % \@tempswatrue
+ % \@whilesw\if at tempswa\fi{\@tempswafalse\the\NC at list}%
+ \count@\m at ne
+ \let\the at toks\relax
+ \prepnext at tok
+ \exp_args:NV \tl_map_variable:NNn \@temptokena \@nextchar
+ {\@testpach
+ \ifcase \@chclass \@classz \or \@classi \or \@classii
+ \or \save at 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__nicematrix \or
+ \@preamerr \tw@ \@addtopreamble\@sharp \or
+ \or
+ \else \@preamerr \@ne \fi
+ \def\the at toks{\the\toks}
+ \cs_gset_eq:NN \@mkpream \__nicematrix_old_mkpream:
+ }
+\bool_if:NTF \c__nicematrix_revtex_bool
+ { \cs_new_protected:Npn \__nicematrix_redefine_mkpream: { } }
+ {
+ \cs_new_protected:Npn \__nicematrix_redefine_mkpream:
+ { \cs_set_eq:NN \@mkpream \__nicematrix_mkpream: }
+ }
+\cs_new_protected:Npn \__nicematrix_mkpream_colortbl: { }
+\hook_gput_code:nnn { begindocument } { . }
+ {
+ \IfPackageLoadedTF { colortbl }
+ {
+ \cs_set_protected:Npn \__nicematrix_mkpream_colortbl:
+ {
+ \cs_set_eq:NN \CT at setup \relax
+ \cs_set_eq:NN \CT at color \relax
+ \cs_set_eq:NN \CT at do@color \relax
+ \cs_set_eq:NN \color \relax
+ \cs_set_eq:NN \CT at column@color \relax
+ \cs_set_eq:NN \CT at row@color \relax
+ \cs_set_eq:NN \CT at cell@color \relax
+ }
+ }
+ { }
+ }
\int_new:N \g__nicematrix_env_int
\cs_new:Npn \__nicematrix_env: { nm - \int_use:N \g__nicematrix_env_int }
\NewExpandableDocumentCommand \NiceMatrixLastEnv { }
@@ -365,6 +421,7 @@
\tl_new:N \l__nicematrix_xdots_down_tl
\tl_new:N \l__nicematrix_xdots_up_tl
\tl_new:N \l__nicematrix_xdots_middle_tl
+\seq_new:N \g__nicematrix_rowlistcolors_seq
\cs_new_protected:Npn \__nicematrix_test_if_math_mode:
{
\if_mode_math: \else:
@@ -371,7 +428,6 @@
\__nicematrix_fatal:n { Outside~math~mode }
\fi:
}
-\tl_new:N \l__nicematrix_letter_vlism_tl
\seq_new:N \g__nicematrix_cols_vlism_seq
\colorlet { nicematrix-last-col } { . }
\colorlet { nicematrix-last-row } { . }
@@ -573,10 +629,10 @@
\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__nicematrix_notes_caption_int }
}
- \int_compare:nNnT \l_tmpa_int = \c_zero_int
+ \int_if_zero:nT \l_tmpa_int
{
\seq_gput_right:Nn \g__nicematrix_notes_seq { { #1 } { #2 } }
\tl_if_novalue:nT { #1 } { \int_gincr:N \c at tabularnote }
@@ -589,7 +645,7 @@
{
\int_eval:n
{
- \int_compare:nNnTF \l_tmpa_int = \c_zero_int
+ \int_if_zero:nTF \l_tmpa_int
\c at tabularnote
\l_tmpa_int
}
@@ -852,7 +908,11 @@
vlines-in-sub-matrix .code:n =
{
\tl_if_single_token:nTF { #1 }
- { \tl_set:Nn \l__nicematrix_letter_vlism_tl { #1 } }
+ {
+ \tl_if_in:NnTF \c__nicematrix_forbidden_letters_tl { #1 }
+ { \__nicematrix_error:nn { Forbidden~letter } { #1 } }
+ { \cs_set_eq:cN { __nicematrix _ #1 } \__nicematrix_make_preamble_vlism:n }
+ }
{ \__nicematrix_error:n { One~letter~allowed } }
} ,
vlines-in-sub-matrix .value_required:n = true ,
@@ -944,13 +1004,11 @@
code-after .value_required:n = true ,
bottomrule .bool_set:N = \l__nicematrix_notes_bottomrule_bool ,
bottomrule .default:n = true ,
- style .code:n = \cs_set:Nn \__nicematrix_notes_style:n { #1 } ,
+ style .cs_set:Np = \__nicematrix_notes_style:n #1 ,
style .value_required:n = true ,
- label-in-tabular .code:n =
- \cs_set:Nn \__nicematrix_notes_label_in_tabular:n { #1 } ,
+ label-in-tabular .cs_set:Np = \__nicematrix_notes_label_in_tabular:n #1 ,
label-in-tabular .value_required:n = true ,
- label-in-list .code:n =
- \cs_set:Nn \__nicematrix_notes_label_in_list:n { #1 } ,
+ label-in-list .cs_set:Np = \__nicematrix_notes_label_in_list:n #1 ,
label-in-list .value_required:n = true ,
enumitem-keys .code:n =
{
@@ -1033,7 +1091,7 @@
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__nicematrix_width_dim { #1 } ,
+ width .dim_set:N = \l__nicematrix_width_dim ,
width .value_required:n = true ,
last-col .code:n =
\tl_if_empty:nF { #1 }
@@ -1065,7 +1123,7 @@
{ \keys_set:nn { NiceMatrix / NiceMatrixOptions } { #1 } }
\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__nicematrix_last_col_without_value_bool
\int_set:Nn \l__nicematrix_last_col_int { -1 }
@@ -1161,7 +1219,7 @@
\bool_if:NT \l__nicematrix_small_bool \scriptstyle
}
\g__nicematrix_row_style_tl
- \int_compare:nNnTF \c at iRow = 0
+ \int_if_zero:nTF \c at iRow
{
\int_compare:nNnT \c at jCol > 0
{
@@ -1198,7 +1256,7 @@
}
\cs_new_protected:Npn \__nicematrix_update_for_first_and_last_row:
{
- \int_compare:nNnTF \c at iRow = 0
+ \int_if_zero:nTF \c at iRow
{
\dim_gset:Nn \g__nicematrix_dp_row_zero_dim
{ \dim_max:nn \g__nicematrix_dp_row_zero_dim { \box_dp:N \l__nicematrix_cell_box } }
@@ -1275,8 +1333,7 @@
{ \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_max_cell_width:
\__nicematrix_update_for_first_and_last_row:
\bool_if:NTF \g__nicematrix_empty_cell_bool
{ \box_use_drop:N \l__nicematrix_cell_box }
@@ -1291,6 +1348,11 @@
\bool_gset_false:N \g__nicematrix_empty_cell_bool
\bool_gset_false:N \g__nicematrix_not_empty_cell_bool
}
+\cs_new_protected:Npn \__nicematrix_update_max_cell_width:
+ {
+ \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 } }
+ }
\cs_new_protected:Npn \__nicematrix_cell_end_for_w_s:
{
\__nicematrix_math_toggle_token:
@@ -1377,9 +1439,9 @@
{ \exp_not:n { #3 } }
}
}
-\cs_new_protected:Npn \__nicematrix_array:n
+\cs_new_protected:Npn \__nicematrix_array:
{
- % modified 05-08-23
+ \__nicematrix_redefine_mkpream:
\dim_set:Nn \col at sep
{ \bool_if:NTF \l__nicematrix_tabular_bool \tabcolsep \arraycolsep }
\dim_compare:nNnTF \l__nicematrix_tabular_width_dim = \c_zero_dim
@@ -1388,7 +1450,6 @@
\@tabarray
[ \str_if_eq:VnTF \l__nicematrix_baseline_tl c c t ]
}
-\cs_generate_variant:Nn \__nicematrix_array:n { V }
\cs_set_eq:NN \__nicematrix_old_ialign: \ialign
\cs_new_protected:Npn \__nicematrix_create_row_node:
{
@@ -1437,7 +1498,7 @@
{
\tl_if_eq:NnF \l__nicematrix_hlines_clist { all }
{
- \exp_args:NNx
+ \exp_args:NNe
\clist_if_in:NnT
\l__nicematrix_hlines_clist
{ \int_eval:n { \c at iRow + 1 } }
@@ -1462,22 +1523,45 @@
\cs_set_eq:NN \dots \__nicematrix_Ldots
\cs_set_eq:NN \hdotsfor \__nicematrix_Hdotsfor:
}
-\cs_new_protected:Npn \__nicematrix_colortbl_like:
+\cs_new_protected:Npn \__nicematrix_test_color_inside:
{
- \cs_set_eq:NN \cellcolor \__nicematrix_cellcolor_tabular
- \cs_set_eq:NN \rowcolor \__nicematrix_rowcolor_tabular
- \cs_set_eq:NN \columncolor \__nicematrix_columncolor_preamble
- \cs_set_eq:NN \rowcolors \__nicematrix_rowcolors_tabular
- \cs_set_eq:NN \rowlistcolors \__nicematrix_rowlistcolors_tabular
+ \bool_if:NF \l__nicematrix_color_inside_bool
+ {
+ \bool_if:NF \g__nicematrix_aux_found_bool
+ { \__nicematrix_error:n { without~color-inside } }
+ }
}
+\cs_new_protected:Npn \__nicematrix_redefine_everycr: { \everycr { \__nicematrix_everycr: } }
+\hook_gput_code:nnn { begindocument } { . }
+ {
+ \IfPackageLoadedTF { colortbl }
+ {
+ \cs_set_protected:Npn \__nicematrix_redefine_everycr:
+ {
+ \CT at everycr
+ {
+ \noalign { \cs_gset_eq:NN \CT at row@color \prg_do_nothing: }
+ \__nicematrix_everycr:
+ }
+ }
+ }
+ { }
+ }
+\hook_gput_code:nnn { begindocument } { . }
+ {
+ \IfPackageLoadedTF { booktabs }
+ {
+ \cs_new_protected:Npn \__nicematrix_patch_booktabs:
+ { \tl_put_left:Nn \@BTnormal \__nicematrix_create_row_node_i: }
+ }
+ { \cs_new_protected:Npn \__nicematrix_patch_booktabs: { } }
+ }
\cs_new_protected:Npn \__nicematrix_pre_array_ii:
{
\int_gzero:N \g__nicematrix_total_X_weight_int
\__nicematrix_expand_clist:N \l__nicematrix_hlines_clist
\__nicematrix_expand_clist:N \l__nicematrix_vlines_clist
- \IfPackageLoadedTF { booktabs }
- { \tl_put_left:Nn \@BTnormal \__nicematrix_create_row_node_i: }
- { }
+ \__nicematrix_patch_booktabs:
\box_clear_new:N \l__nicematrix_cell_box
\normalbaselines
\bool_if:NT \l__nicematrix_small_bool
@@ -1495,15 +1579,7 @@
}
\cs_set_nopar:Npn \ialign
{
- \IfPackageLoadedTF { colortbl }
- {
- \CT at everycr
- {
- \noalign { \cs_gset_eq:NN \CT at row@color \prg_do_nothing: }
- \__nicematrix_everycr:
- }
- }
- { \everycr { \__nicematrix_everycr: } }
+ \__nicematrix_redefine_everycr:
\tabskip = \c_zero_skip
\dim_gzero_new:N \g__nicematrix_dp_row_zero_dim
\dim_gset:Nn \g__nicematrix_dp_row_zero_dim { \box_dp:N \@arstrutbox }
@@ -1546,7 +1622,10 @@
\cs_set_eq:NN \RowStyle \__nicematrix_RowStyle:n
\seq_map_inline:Nn \l__nicematrix_custom_line_commands_seq
{ \cs_set_eq:cc { ##1 } { nicematrix - ##1 } }
- \bool_if:NT \l__nicematrix_color_inside_bool \__nicematrix_colortbl_like:
+ \cs_set_eq:NN \cellcolor \__nicematrix_cellcolor_tabular
+ \cs_set_eq:NN \rowcolor \__nicematrix_rowcolor_tabular
+ \cs_set_eq:NN \rowcolors \__nicematrix_rowcolors_tabular
+ \cs_set_eq:NN \rowlistcolors \__nicematrix_rowlistcolors_tabular
\bool_if:NT \l__nicematrix_renew_dots_bool \__nicematrix_renew_dots:
\cs_set_eq:NN \multicolumn \__nicematrix_multicolumn:nnn
\hook_gput_code:nnn { env / tabular / begin } { . }
@@ -1621,7 +1700,6 @@
\dim_set:Nn \l__nicematrix_right_delim_dim { \box_wd:N \l_tmpa_box }
}
{
- % modified 05-08-23
\dim_gset:Nn \l__nicematrix_left_delim_dim
{ 2 \bool_if:NTF \l__nicematrix_tabular_bool \tabcolsep \arraycolsep }
\dim_gset_eq:NN \l__nicematrix_right_delim_dim \l__nicematrix_left_delim_dim
@@ -1859,7 +1937,7 @@
\use:c { c__nicematrix _ \int_use:N \g__nicematrix_env_int _ tl }
}
{ \bool_gset_false:N \g__nicematrix_aux_found_bool }
- \tl_gclear:N \g__nicematrix_aux_tl
+ \tl_build_gbegin:N \g__nicematrix_aux_tl
\tl_if_empty:NF \g__nicematrix_code_before_tl
{
\bool_set_true:N \l__nicematrix_code_before_bool
@@ -1884,12 +1962,12 @@
\hbox_set_end:
\bool_if:NT \l__nicematrix_width_used_bool
{
- \int_compare:nNnT \g__nicematrix_total_X_weight_int = 0
+ \int_if_zero:nT \g__nicematrix_total_X_weight_int
{ \__nicematrix_error_or_warning:n { width~without~X~columns } }
}
\int_compare:nNnT \g__nicematrix_total_X_weight_int > 0
{
- \tl_gput_right:Nx \g__nicematrix_aux_tl
+ \tl_build_gput_right:Nx \g__nicematrix_aux_tl
{
\bool_set_true:N \l__nicematrix_X_columns_aux_bool
\dim_set:Nn \l__nicematrix_X_columns_dim
@@ -1933,7 +2011,7 @@
}
\int_gset_eq:NN \g__nicematrix_row_total_int \c at iRow
\int_compare:nNnT \l__nicematrix_last_row_int > { -1 } { \int_gdecr:N \c at iRow }
- \int_compare:nNnT \l__nicematrix_first_col_int = 0
+ \int_if_zero:nT \l__nicematrix_first_col_int
{
% \skip_horizontal:N \col at sep % 05-08-23
\skip_horizontal:N \g__nicematrix_width_first_col_dim
@@ -1948,7 +2026,7 @@
\__nicematrix_use_arraybox_with_notes:
}
{
- \int_compare:nNnTF \l__nicematrix_first_row_int = 0
+ \int_if_zero:nTF \l__nicematrix_first_row_int
{
\dim_set_eq:NN \l_tmpa_dim \g__nicematrix_dp_row_zero_dim
\dim_add:Nn \l_tmpa_dim \g__nicematrix_ht_row_zero_dim
@@ -2003,6 +2081,7 @@
}
\__nicematrix_after_array:
\egroup
+ \tl_build_gend:N \g__nicematrix_aux_tl
\iow_now:Nn \@mainaux { \ExplSyntaxOn }
\iow_now:Nn \@mainaux { \char_set_catcode_space:n { 32 } }
\iow_now:Nx \@mainaux
@@ -2021,7 +2100,6 @@
\cs_new_protected:Npn \__nicematrix_transform_preamble_i:
{
\int_gzero:N \c at jCol
- \group_begin:
\seq_gclear:N \g__nicematrix_cols_vlism_seq
\bool_gset_false:N \g_tmpb_bool
\tl_gclear_new:N \g__nicematrix_pre_cell_tl
@@ -2039,16 +2117,27 @@
{ ! { \skip_horizontal:N \arrayrulewidth } }
}
}
- \exp_last_unbraced:NV \__nicematrix_make_preamble:n \g__nicematrix_user_preamble_tl \q_stop
+ \exp_last_unbraced:NV \__nicematrix_rec_preamble:n \g__nicematrix_user_preamble_tl \stop
\int_gset_eq:NN \g__nicematrix_static_num_of_col_int \c at jCol
- \bool_if:NT \l__nicematrix_color_inside_bool
+ \__nicematrix_replace_columncolor:
+ }
+\hook_gput_code:nnn { begindocument } { . }
+ {
+ \IfPackageLoadedTF { colortbl }
{
- \regex_replace_all:NnN
- \c__nicematrix_columncolor_regex
- { \c { __nicematrix_columncolor_preamble } }
- \g__nicematrix_array_preamble_tl
+ \regex_const:Nn \c__nicematrix_columncolor_regex { \c { columncolor } }
+ \cs_new_protected:Npn \__nicematrix_replace_columncolor:
+ {
+ \regex_replace_all:NnN
+ \c__nicematrix_columncolor_regex
+ { \c { __nicematrix_columncolor_preamble } }
+ \g__nicematrix_array_preamble_tl
+ }
}
- \group_end:
+ {
+ \cs_new_protected:Npn \__nicematrix_replace_columncolor:
+ { \cs_set_eq:NN \columncolor \__nicematrix_columncolor_preamble }
+ }
}
\cs_new_protected:Npn \__nicematrix_transform_preamble_ii:
{
@@ -2057,7 +2146,7 @@
{ ! \str_if_eq_p:Vn \g__nicematrix_right_delim_tl { . } }
{ \bool_gset_true:N \g__nicematrix_delims_bool }
\bool_if:NT \g_tmpb_bool { \bool_set_true:N \l__nicematrix_bar_at_end_of_pream_bool }
- \int_compare:nNnTF \l__nicematrix_first_col_int = 0
+ \int_if_zero:nTF \l__nicematrix_first_col_int
{ \tl_gput_left:NV \g__nicematrix_array_preamble_tl \c__nicematrix_preamble_first_col_tl }
{
\bool_lazy_all:nT
@@ -2087,69 +2176,24 @@
{ > { \__nicematrix_error_too_much_cols: } l }
}
}
-\cs_new_protected:Npn \__nicematrix_make_preamble:n #1
+\cs_new_protected:Npn \__nicematrix_rec_preamble:n #1
{
- \str_if_eq:nnF { #1 } { \q_stop }
+ \cs_if_exist:cTF { __nicematrix _ \token_to_str:N #1 }
+ { \use:c { __nicematrix _ \token_to_str:N #1 } { #1 } }
{
- \cs_if_exist:cTF { __nicematrix \token_to_str:N #1 }
- { \use:c { __nicematrix \token_to_str:N #1 } { #1 } }
+ \cs_if_exist:cTF { NC @ find @ #1 }
{
- \str_if_eq:nVTF { #1 } \l__nicematrix_letter_vlism_tl
- {
- \seq_gput_right:Nx \g__nicematrix_cols_vlism_seq
- { \int_eval:n { \c at jCol + 1 } }
- \tl_gput_right:Nx \g__nicematrix_array_preamble_tl
- { \exp_not:N ! { \skip_horizontal:N \arrayrulewidth } }
- \__nicematrix_make_preamble:n
- }
- {
- \keys_if_exist:nnTF { NiceMatrix / ColumnTypes } { #1 }
- {
- \keys_set:nn { NiceMatrix / ColumnTypes } { #1 }
- \__nicematrix_make_preamble:n
- }
- {
- \cs_if_exist:cTF { NC @ find @ #1 }
- {
- \tl_set_eq:Nc \l_tmpb_tl { NC @ rewrite @ #1 }
- \exp_last_unbraced:NV \__nicematrix_make_preamble:n \l_tmpb_tl
- }
- {
- \tl_if_eq:nnT { #1 } { S }
- { \__nicematrix_fatal:n { unknown~column~type~S } }
- { \__nicematrix_fatal:nn { unknown~column~type } { #1 } }
- }
- }
- }
+ \tl_set_eq:Nc \l_tmpb_tl { NC @ rewrite @ #1 }
+ \exp_last_unbraced:NV \__nicematrix_rec_preamble:n \l_tmpb_tl
}
+ {
+ \tl_if_eq:nnT { #1 } { S }
+ { \__nicematrix_fatal:n { unknown~column~type~S } }
+ { \__nicematrix_fatal:nn { unknown~column~type } { #1 } }
+ }
}
}
-\cs_new:cpn { __nicematrix \string c } { \__nicematrix_make_preamble_i:n }
-\cs_new:cpn { __nicematrix \string l } { \__nicematrix_make_preamble_i:n }
-\cs_new:cpn { __nicematrix \string r } { \__nicematrix_make_preamble_i:n }
-\cs_new:cpn { __nicematrix \string > } { \__nicematrix_make_preamble_xiv:nn }
-\cs_new:cpn { __nicematrix \string ! } { \__nicematrix_make_preamble_ii:nn }
-\cs_new:cpn { __nicematrix \string @ } { \__nicematrix_make_preamble_ii:nn }
-\cs_new:cpn { __nicematrix \string | } { \__nicematrix_make_preamble_iii:n }
-\cs_new:cpn { __nicematrix \string p } { \__nicematrix_make_preamble_iv:n }
-\cs_new:cpn { __nicematrix \string b } { \__nicematrix_make_preamble_iv:n }
-\cs_new:cpn { __nicematrix \string m } { \__nicematrix_make_preamble_iv:n }
-\cs_new:cpn { __nicematrix \string V } { \__nicematrix_make_preamble_v:nn }
-\cs_new:cpn { __nicematrix \string w } { \__nicematrix_make_preamble_vi:nnnn { } }
-\cs_new:cpn { __nicematrix \string W } { \__nicematrix_make_preamble_vi:nnnn { \__nicematrix_special_W: } }
-\cs_new:cpn { __nicematrix \string S } { \__nicematrix_make_preamble_vii:nn }
-\cs_new:cpn { __nicematrix \string ( } { \__nicematrix_make_preamble_viii:nn }
-\cs_new:cpn { __nicematrix \string [ } { \__nicematrix_make_preamble_viii:nn }
-\cs_new:cpn { __nicematrix \string \{ } { \__nicematrix_make_preamble_viii:nn }
-\cs_new:cpn { __nicematrix \string \left } { \__nicematrix_make_preamble_viii_ii:n }
-\cs_new:cpn { __nicematrix \string ) } { \__nicematrix_make_preamble_ix:nn }
-\cs_new:cpn { __nicematrix \string ] } { \__nicematrix_make_preamble_ix:nn }
-\cs_new:cpn { __nicematrix \string \} } { \__nicematrix_make_preamble_ix:nn }
-\cs_new:cpn { __nicematrix \string \right } { \__nicematrix_make_preamble_ix_ii:n }
-\cs_new:cpn { __nicematrix \string X } { \__nicematrix_make_preamble_x:nn }
-\cs_new:cpn { __nicematrix \string * } { \__nicematrix_make_preamble_xvi:nnn }
-\cs_new:cpn { __nicematrix \string \NC at find } { \__nicematrix_make_preamble_xx:n }
-\cs_new_protected:Npn \__nicematrix_make_preamble_i:n #1
+\cs_new:Npn \__nicematrix_c #1
{
\tl_gput_right:NV \g__nicematrix_array_preamble_tl \g__nicematrix_pre_cell_tl
\tl_gclear:N \g__nicematrix_pre_cell_tl
@@ -2160,33 +2204,36 @@
< \__nicematrix_cell_end:
}
\int_gincr:N \c at jCol
- \__nicematrix_make_preamble_xi:n
+ \__nicematrix_rec_preamble_after_col:n
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_ii:nn #1 #2
+\cs_set_eq:NN \__nicematrix_l \__nicematrix_c
+\cs_set_eq:NN \__nicematrix_r \__nicematrix_c
+\cs_new:cpn { __nicematrix _ \token_to_str:N ! } #1 #2
{
\tl_gput_right:Nn \g__nicematrix_array_preamble_tl { #1 { #2 } }
- \__nicematrix_make_preamble:n
+ \__nicematrix_rec_preamble:n
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_iii:n #1
+\cs_set_eq:cc { __nicematrix _ \token_to_str:N @ } { __nicematrix _ \token_to_str:N ! }
+\cs_new:cpn { __nicematrix _ | } #1
{
\int_incr:N \l_tmpa_int
- \__nicematrix_make_preamble_iii_i:n
+ \__nicematrix_make_preamble_i_i:n
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_iii_i:n #1
+\cs_new_protected:Npn \__nicematrix_make_preamble_i_i:n #1
{
\str_if_eq:nnTF { #1 } |
{ \__nicematrix_make_preamble_iii:n | }
- { \__nicematrix_make_preamble_iii_ii:nn { } #1 }
+ { \__nicematrix_make_preamble_i_ii:nn { } #1 }
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_iii_ii:nn #1 #2
+\cs_new_protected:Npn \__nicematrix_make_preamble_i_ii:nn #1 #2
{
\str_if_eq:nnTF { #2 } [
- { \__nicematrix_make_preamble_iii_ii:nw { #1 } [ }
- { \__nicematrix_make_preamble_iii_iii:nn { #2 } { #1 } }
+ { \__nicematrix_make_preamble_i_ii:nw { #1 } [ }
+ { \__nicematrix_make_preamble_i_iii:nn { #2 } { #1 } }
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_iii_ii:nw #1 [ #2 ]
- { \__nicematrix_make_preamble_iii_ii:nn { #1 , #2 } }
-\cs_new_protected:Npn \__nicematrix_make_preamble_iii_iii:nn #1 #2
+\cs_new_protected:Npn \__nicematrix_make_preamble_i_ii:nw #1 [ #2 ]
+ { \__nicematrix_make_preamble_i_ii:nn { #1 , #2 } }
+\cs_new_protected:Npn \__nicematrix_make_preamble_i_iii:nn #1 #2
{
\__nicematrix_compute_rule_width:n { multiplicity = \l_tmpa_int , #2 }
\tl_gput_right:Nx \g__nicematrix_array_preamble_tl
@@ -2204,13 +2251,13 @@
}
}
\int_zero:N \l_tmpa_int
- \str_if_eq:nnT { #1 } { \q_stop } { \bool_gset_true:N \g_tmpb_bool }
- \__nicematrix_make_preamble:n #1
+ \str_if_eq:nnT { #1 } { \stop } { \bool_gset_true:N \g_tmpb_bool }
+ \__nicematrix_rec_preamble:n #1
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_xiv:nn #1 #2
+\cs_new:cpn { __nicematrix _ > } #1 #2
{
\tl_gput_right:Nn \g__nicematrix_pre_cell_tl { > { #2 } }
- \__nicematrix_make_preamble:n
+ \__nicematrix_rec_preamble:n
}
\bool_new:N \l__nicematrix_bar_at_end_of_pream_bool
\keys_define:nn { WithArrows / p-column }
@@ -2255,34 +2302,36 @@
b .code:n = \str_set:Nn \l__nicematrix_vpos_col_str { b } ,
b .value_forbidden:n = true ,
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_iv:n #1
+\cs_new:Npn \__nicematrix_p #1
{
\str_set:Nn \l__nicematrix_vpos_col_str { #1 }
- \__nicematrix_make_preamble_iv_i:n
+ \__nicematrix_make_preamble_ii_i:n
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_iv_i:n #1
+\cs_set_eq:NN \__nicematrix_b \__nicematrix_p
+\cs_set_eq:NN \__nicematrix_m \__nicematrix_p
+\cs_new_protected:Npn \__nicematrix_make_preamble_ii_i:n #1
{
\str_if_eq:nnTF { #1 } { [ }
- { \__nicematrix_make_preamble_iv_ii:w [ }
- { \__nicematrix_make_preamble_iv_ii:w [ ] { #1 } }
+ { \__nicematrix_make_preamble_ii_ii:w [ }
+ { \__nicematrix_make_preamble_ii_ii:w [ ] { #1 } }
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_iv_ii:w [ #1 ]
- { \__nicematrix_make_preamble_iv_iii:nn { #1 } }
-\cs_new_protected:Npn \__nicematrix_make_preamble_iv_iii:nn #1 #2
+\cs_new_protected:Npn \__nicematrix_make_preamble_ii_ii:w [ #1 ]
+ { \__nicematrix_make_preamble_ii_iii:nn { #1 } }
+\cs_new_protected:Npn \__nicematrix_make_preamble_ii_iii:nn #1 #2
{
\str_set:Nn \l__nicematrix_hpos_col_str { j }
\tl_set:Nn \l_tmpa_tl { #1 }
\__nicematrix_keys_p_column:V \l_tmpa_tl
- \__nicematrix_make_preamble_iv_iv:nn { #2 } { minipage }
+ \__nicematrix_make_preamble_ii_iv:nn { #2 } { minipage }
}
\cs_new_protected:Npn \__nicematrix_keys_p_column:n #1
{ \keys_set_known:nnN { WithArrows / p-column } { #1 } \l_tmpa_tl }
\cs_generate_variant:Nn \__nicematrix_keys_p_column:n { V }
-\cs_new_protected:Npn \__nicematrix_make_preamble_iv_iv:nn #1 #2
+\cs_new_protected:Npn \__nicematrix_make_preamble_ii_iv:nn #1 #2
{
- \use:x
+ \use:e
{
- \__nicematrix_make_preamble_iv_v:nnnnnnnn
+ \__nicematrix_make_preamble_ii_v:nnnnnnnn
{ \str_if_eq:VnTF \l__nicematrix_vpos_col_str { p } { t } { b } }
{ \dim_eval:n { #1 } }
{
@@ -2316,9 +2365,9 @@
}
}
\int_gincr:N \c at jCol
- \__nicematrix_make_preamble_xi:n
+ \__nicematrix_rec_preamble_after_col:n
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_iv_v:nnnnnnnn #1 #2 #3 #4 #5 #6 #7 #8
+\cs_new_protected:Npn \__nicematrix_make_preamble_ii_v:nnnnnnnn #1 #2 #3 #4 #5 #6 #7 #8
{
\str_if_eq:VnTF \l__nicematrix_hpos_col_str { si }
{ \tl_gput_right:Nn \g__nicematrix_array_preamble_tl { > { \__nicematrix_test_if_empty_for_S: } } }
@@ -2394,15 +2443,15 @@
}
}
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_v:nn #1 #2
+\cs_new:Npn \__nicematrix_V #1 #2
{
\str_if_eq:nnTF { #2 } { [ }
- { \__nicematrix_make_preamble_v_i:w [ }
- { \__nicematrix_make_preamble_v_i:w [ ] { #2 } }
+ { \__nicematrix_make_preamble_V_i:w [ }
+ { \__nicematrix_make_preamble_V_i:w [ ] { #2 } }
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_v_i:w [ #1 ]
- { \__nicematrix_make_preamble_v_ii:nn { #1 } }
-\cs_new_protected:Npn \__nicematrix_make_preamble_v_ii:nn #1 #2
+\cs_new_protected:Npn \__nicematrix_make_preamble_V_i:w [ #1 ]
+ { \__nicematrix_make_preamble_V_ii:nn { #1 } }
+\cs_new_protected:Npn \__nicematrix_make_preamble_V_ii:nn #1 #2
{
\str_set:Nn \l__nicematrix_vpos_col_str { p }
\str_set:Nn \l__nicematrix_hpos_col_str { j }
@@ -2409,19 +2458,21 @@
\tl_set:Nn \l_tmpa_tl { #1 }
\__nicematrix_keys_p_column:V \l_tmpa_tl
\IfPackageLoadedTF { varwidth }
- { \__nicematrix_make_preamble_iv_iv:nn { #2 } { varwidth } }
+ { \__nicematrix_make_preamble_ii_iv:nn { #2 } { varwidth } }
{
\__nicematrix_error_or_warning:n { varwidth~not~loaded }
- \__nicematrix_make_preamble_iv_iv:nn { #2 } { minipage }
+ \__nicematrix_make_preamble_ii_iv:nn { #2 } { minipage }
}
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_vi:nnnn #1 #2 #3 #4
+\cs_new:Npn \__nicematrix_w { \__nicematrix_make_preamble_w:nnnn { } }
+\cs_new:Npn \__nicematrix_W { \__nicematrix_make_preamble_w:nnnn { \__nicematrix_special_W: } }
+\cs_new_protected:Npn \__nicematrix_make_preamble_w:nnnn #1 #2 #3 #4
{
\str_if_eq:nnTF { #3 } { s }
- { \__nicematrix_make_preamble_vi_i:nnnn { #1 } { #4 } }
- { \__nicematrix_make_preamble_vi_ii:nnnn { #1 } { #2 } { #3 } { #4 } }
+ { \__nicematrix_make_preamble_w_i:nnnn { #1 } { #4 } }
+ { \__nicematrix_make_preamble_w_ii:nnnn { #1 } { #2 } { #3 } { #4 } }
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_vi_i:nnnn #1 #2
+\cs_new_protected:Npn \__nicematrix_make_preamble_w_i:nnnn #1 #2
{
\tl_gput_right:NV \g__nicematrix_array_preamble_tl \g__nicematrix_pre_cell_tl
\tl_gclear:N \g__nicematrix_pre_cell_tl
@@ -2441,9 +2492,9 @@
}
}
\int_gincr:N \c at jCol
- \__nicematrix_make_preamble_xi:n
+ \__nicematrix_rec_preamble_after_col:n
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_vi_ii:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \__nicematrix_make_preamble_w_ii:nnnn #1 #2 #3 #4
{
\tl_gput_right:NV \g__nicematrix_array_preamble_tl \g__nicematrix_pre_cell_tl
\tl_gclear:N \g__nicematrix_pre_cell_tl
@@ -2465,7 +2516,7 @@
}
}
\int_gincr:N \c at jCol
- \__nicematrix_make_preamble_xi:n
+ \__nicematrix_rec_preamble_after_col:n
}
\cs_new_protected:Npn \__nicematrix_special_W:
{
@@ -2472,54 +2523,52 @@
\dim_compare:nNnT { \box_wd:N \l__nicematrix_cell_box } > \l__nicematrix_col_width_dim
{ \__nicematrix_warning:n { W~warning } }
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_vii:nn #1 #2
+\cs_new:Npn \__nicematrix_S #1 #2
{
\str_if_eq:nnTF { #2 } { [ }
- { \__nicematrix_make_preamble_vii_i:w [ }
- { \__nicematrix_make_preamble_vii_i:w [ ] { #2 } }
+ { \__nicematrix_make_preamble_S:w [ }
+ { \__nicematrix_make_preamble_S:w [ ] { #2 } }
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_vii_i:w [ #1 ]
- { \__nicematrix_make_preamble_vii_ii:n { #1 } }
-\cs_new_protected:Npn \__nicematrix_make_preamble_vii_ii:n #1
+\cs_new_protected:Npn \__nicematrix_make_preamble_S:w [ #1 ]
+ { \__nicematrix_make_preamble_S_i:n { #1 } }
+\cs_new_protected:Npn \__nicematrix_make_preamble_S_i:n #1
{
- \IfPackageAtLeastTF { siunitx } { 2022/01/01 }
+ \tl_gput_right:NV \g__nicematrix_array_preamble_tl \g__nicematrix_pre_cell_tl
+ \tl_gclear:N \g__nicematrix_pre_cell_tl
+ \tl_gput_right:Nn \g__nicematrix_array_preamble_tl
{
- \tl_gput_right:NV \g__nicematrix_array_preamble_tl \g__nicematrix_pre_cell_tl
- \tl_gclear:N \g__nicematrix_pre_cell_tl
- \tl_gput_right:Nn \g__nicematrix_array_preamble_tl
- {
- > {
- \__nicematrix_cell_begin:w
- \keys_set:nn { siunitx } { #1 }
- \siunitx_cell_begin:w
- }
- c
- < { \siunitx_cell_end: \__nicematrix_cell_end: }
+ > {
+ \__nicematrix_cell_begin:w
+ \keys_set:nn { siunitx } { #1 }
+ \siunitx_cell_begin:w
}
- \int_gincr:N \c at jCol
- \__nicematrix_make_preamble_xi:n
+ c
+ < { \siunitx_cell_end: \__nicematrix_cell_end: }
}
- { \__nicematrix_fatal:n { Version~of~siunitx~too~old } }
+ \int_gincr:N \c at jCol
+ \__nicematrix_rec_preamble_after_col:n
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_viii:nn #1 #2
+\cs_new:cpn { __nicematrix _ \token_to_str:N ( } #1 #2
{
\bool_if:NT \l__nicematrix_small_bool { \__nicematrix_fatal:n { Delimiter~with~small } }
- \int_compare:nNnTF \c at jCol = \c_zero_int
+ \int_if_zero:nTF \c at jCol
{
\str_if_eq:VnTF \g__nicematrix_left_delim_tl { . }
{
\tl_gset:Nn \g__nicematrix_left_delim_tl { #1 }
\tl_gset:Nn \g__nicematrix_right_delim_tl { . }
- \__nicematrix_make_preamble:n #2
+ \__nicematrix_rec_preamble:n #2
}
{
\tl_gput_right:Nn \g__nicematrix_array_preamble_tl { ! { \enskip } }
- \__nicematrix_make_preamble_viii_i:nn { #1 } { #2 }
+ \__nicematrix_make_preamble_iv:nn { #1 } { #2 }
}
}
- { \__nicematrix_make_preamble_viii_i:nn { #1 } { #2 } }
+ { \__nicematrix_make_preamble_iv:nn { #1 } { #2 } }
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_viii_i:nn #1 #2
+\cs_set_eq:cc { __nicematrix _ \token_to_str:N [ } { __nicematrix _ \token_to_str:N ( }
+\cs_set_eq:cc { __nicematrix _ \token_to_str:N \{ } { __nicematrix _ \token_to_str:N ( }
+\cs_new_protected:Npn \__nicematrix_make_preamble_iv:nn #1 #2
{
\tl_gput_right:Nx \g__nicematrix_pre_code_after_tl
{ \__nicematrix_delimiter:nnn #1 { \int_eval:n { \c at jCol + 1 } } \c_true_bool }
@@ -2526,19 +2575,18 @@
\tl_if_in:nnTF { ( [ \{ ) ] \} \left \right } { #2 }
{
\__nicematrix_error:nn { delimiter~after~opening } { #2 }
- \__nicematrix_make_preamble:n
+ \__nicematrix_rec_preamble:n
}
- { \__nicematrix_make_preamble:n #2 }
+ { \__nicematrix_rec_preamble:n #2 }
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_viii_ii:n #1
- { \__nicematrix_make_preamble_viii:nn }
-\cs_new_protected:Npn \__nicematrix_make_preamble_ix:nn #1 #2
+\cs_new:cpn { __nicematrix _ \token_to_str:N \left } #1 { \use:c { __nicematrix _ \token_to_str:N ( } }
+\cs_new:cpn { __nicematrix _ \token_to_str:N ) } #1 #2
{
\bool_if:NT \l__nicematrix_small_bool { \__nicematrix_fatal:n { Delimiter~with~small } }
\tl_if_in:nnTF { ) ] \} } { #2 }
- { \__nicematrix_make_preamble_ix_i:nnn #1 #2 }
+ { \__nicematrix_make_preamble_v:nnn #1 #2 }
{
- \tl_if_eq:nnTF { \q_stop } { #2 }
+ \tl_if_eq:nnTF { \stop } { #2 }
{
\str_if_eq:VnTF \g__nicematrix_right_delim_tl { . }
{ \tl_gset:Nn \g__nicematrix_right_delim_tl { #1 } }
@@ -2546,7 +2594,7 @@
\tl_gput_right:Nn \g__nicematrix_array_preamble_tl { ! { \enskip } }
\tl_gput_right:Nx \g__nicematrix_pre_code_after_tl
{ \__nicematrix_delimiter:nnn #1 { \int_use:N \c at jCol } \c_false_bool }
- \__nicematrix_make_preamble:n #2
+ \__nicematrix_rec_preamble:n #2
}
}
{
@@ -2554,13 +2602,15 @@
{ \tl_gput_right:Nn \g__nicematrix_array_preamble_tl { ! { \enskip } } }
\tl_gput_right:Nx \g__nicematrix_pre_code_after_tl
{ \__nicematrix_delimiter:nnn #1 { \int_use:N \c at jCol } \c_false_bool }
- \__nicematrix_make_preamble:n #2
+ \__nicematrix_rec_preamble:n #2
}
}
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_ix_i:nnn #1 #2 #3
+\cs_set_eq:cc { __nicematrix _ \token_to_str:N ] } { __nicematrix _ \token_to_str:N ] }
+\cs_set_eq:cc { __nicematrix _ \token_to_str:N \} } { __nicematrix _ \token_to_str:N \} }
+\cs_new_protected:Npn \__nicematrix_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__nicematrix_right_delim_tl { . }
{
@@ -2580,22 +2630,77 @@
\tl_gput_right:Nx \g__nicematrix_pre_code_after_tl
{ \__nicematrix_delimiter:nnn #1 { \int_use:N \c at jCol } \c_false_bool }
\__nicematrix_error:nn { double~closing~delimiter } { #2 }
- \__nicematrix_make_preamble:n #3
+ \__nicematrix_rec_preamble:n #3
}
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_ix_ii:n #1
- { \__nicematrix_make_preamble_ix:nn }
-\cs_new_protected:Npn \__nicematrix_make_preamble_x:nn #1 #2
+\cs_new:cpn { __nicematrix _ \token_to_str:N \right } #1
+ { \use:c { __nicematrix _ \token_to_str:N ) } }
+\cs_new_protected:Npn \__nicematrix_rec_preamble_after_col:n #1
{
+ \str_if_eq:nnTF { #1 } { < }
+ \__nicematrix_rec_preamble_after_col_i:n
+ {
+ \str_if_eq:nnTF { #1 } { @ }
+ \__nicematrix_rec_preamble_after_col_ii:n
+ {
+ \tl_if_eq:NnTF \l__nicematrix_vlines_clist { all }
+ {
+ \tl_gput_right:Nn \g__nicematrix_array_preamble_tl
+ { ! { \skip_horizontal:N \arrayrulewidth } }
+ }
+ {
+ \exp_args:NNe
+ \clist_if_in:NnT \l__nicematrix_vlines_clist { \int_eval:n { \c at jCol + 1 } }
+ {
+ \tl_gput_right:Nn \g__nicematrix_array_preamble_tl
+ { ! { \skip_horizontal:N \arrayrulewidth } }
+ }
+ }
+ \__nicematrix_rec_preamble:n { #1 }
+ }
+ }
+ }
+\cs_new_protected:Npn \__nicematrix_rec_preamble_after_col_i:n #1
+ {
+ \tl_gput_right:Nn \g__nicematrix_array_preamble_tl { < { #1 } }
+ \__nicematrix_rec_preamble_after_col:n
+ }
+\cs_new_protected:Npn \__nicematrix_rec_preamble_after_col_ii:n #1
+ {
+ \tl_if_eq:NnTF \l__nicematrix_vlines_clist { all }
+ {
+ \tl_gput_right:Nn \g__nicematrix_array_preamble_tl
+ { @ { #1 \skip_horizontal:N \arrayrulewidth } }
+ }
+ {
+ \exp_args:NNe
+ \clist_if_in:NnTF \l__nicematrix_vlines_clist { \int_eval:n { \c at jCol + 1 } }
+ {
+ \tl_gput_right:Nn \g__nicematrix_array_preamble_tl
+ { @ { #1 \skip_horizontal:N \arrayrulewidth } }
+ }
+ { \tl_gput_right:Nn \g__nicematrix_array_preamble_tl { @ { #1 } } }
+ }
+ \__nicematrix_rec_preamble:n
+ }
+\cs_new:cpn { __nicematrix _ * } #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 \__nicematrix_rec_preamble:n \l_tmpa_tl
+ }
+\cs_new:cpn { __nicematrix _ \token_to_str:N \NC at find } #1 { \__nicematrix_rec_preamble:n }
+\cs_new:Npn \__nicematrix_X #1 #2
+ {
\str_if_eq:nnTF { #2 } { [ }
- { \__nicematrix_make_preamble_x_i:w [ }
- { \__nicematrix_make_preamble_x_i:w [ ] #2 }
+ { \__nicematrix_make_preamble_X:w [ }
+ { \__nicematrix_make_preamble_X:w [ ] #2 }
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_x_i:w [ #1 ]
- { \__nicematrix_make_preamble_x_ii:n { #1 } }
+\cs_new_protected:Npn \__nicematrix_make_preamble_X:w [ #1 ]
+ { \__nicematrix_make_preamble_X_i:n { #1 } }
\keys_define:nn { WithArrows / X-column }
{ unknown .code:n = \int_set:Nn \l__nicematrix_weight_int { \l_keys_key_str } }
-\cs_new_protected:Npn \__nicematrix_make_preamble_x_ii:n #1
+\cs_new_protected:Npn \__nicematrix_make_preamble_X_i:n #1
{
\str_set:Nn \l__nicematrix_hpos_col_str { j }
\tl_set:Nn \l__nicematrix_vpos_col_str { p }
@@ -2612,8 +2717,8 @@
\int_gadd:Nn \g__nicematrix_total_X_weight_int \l__nicematrix_weight_int
\bool_if:NTF \l__nicematrix_X_columns_aux_bool
{
- \exp_args:Nnx
- \__nicematrix_make_preamble_iv_iv:nn
+ \exp_args:Nne
+ \__nicematrix_make_preamble_ii_iv:nn
{ \l__nicematrix_weight_int \l__nicematrix_X_columns_dim }
{ minipage }
}
@@ -2635,67 +2740,27 @@
}
}
\int_gincr:N \c at jCol
- \__nicematrix_make_preamble_xi:n
+ \__nicematrix_rec_preamble_after_col:n
}
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_xi:n #1
+\cs_new_protected:Npn \__nicematrix_make_preamble_vlism:n #1
{
- \str_if_eq:nnTF { #1 } { < }
- \__nicematrix_make_preamble_xiii:n
- {
- \str_if_eq:nnTF { #1 } { @ }
- \__nicematrix_make_preamble_xv:n
- {
- \tl_if_eq:NnTF \l__nicematrix_vlines_clist { all }
- {
- \tl_gput_right:Nn \g__nicematrix_array_preamble_tl
- { ! { \skip_horizontal:N \arrayrulewidth } }
- }
- {
- \exp_args:NNx
- \clist_if_in:NnT \l__nicematrix_vlines_clist { \int_eval:n { \c at jCol + 1 } }
- {
- \tl_gput_right:Nn \g__nicematrix_array_preamble_tl
- { ! { \skip_horizontal:N \arrayrulewidth } }
- }
- }
- \__nicematrix_make_preamble:n { #1 }
- }
- }
+ \seq_gput_right:Nx \g__nicematrix_cols_vlism_seq
+ { \int_eval:n { \c at jCol + 1 } }
+ \tl_gput_right:Nx \g__nicematrix_array_preamble_tl
+ { \exp_not:N ! { \skip_horizontal:N \arrayrulewidth } }
+ \__nicematrix_rec_preamble:n
}
-\cs_new_protected:Npn \__nicematrix_make_preamble_xiii:n #1
- {
- \tl_gput_right:Nn \g__nicematrix_array_preamble_tl { < { #1 } }
- \__nicematrix_make_preamble_xi:n
- }
-\cs_new_protected:Npn \__nicematrix_make_preamble_xv:n #1
- {
- \tl_if_eq:NnTF \l__nicematrix_vlines_clist { all }
- {
- \tl_gput_right:Nn \g__nicematrix_array_preamble_tl
- { @ { #1 \skip_horizontal:N \arrayrulewidth } }
- }
- {
- \exp_args:NNx
- \clist_if_in:NnTF \l__nicematrix_vlines_clist { \int_eval:n { \c at jCol + 1 } }
- {
- \tl_gput_right:Nn \g__nicematrix_array_preamble_tl
- { @ { #1 \skip_horizontal:N \arrayrulewidth } }
- }
- { \tl_gput_right:Nn \g__nicematrix_array_preamble_tl { @ { #1 } } }
- }
- \__nicematrix_make_preamble:n
- }
-\cs_new_protected:Npn \__nicematrix_make_preamble_xx:n #1 { \__nicematrix_make_preamble:n }
-\cs_new_protected:Npn \__nicematrix_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 \__nicematrix_make_preamble:n \l_tmpa_tl
- }
+\cs_set_eq:cN { __nicematrix _ \token_to_str:N \stop } \use_none:n
+\cs_new_protected:cpn { __nicematrix _ \token_to_str:N \hline }
+ { \__nicematrix_fatal:n { Preamble~forgotten } }
+\cs_set_eq:cc { __nicematrix _ \token_to_str:N \Hline } { __nicematrix _ \token_to_str:N \hline }
+\cs_set_eq:cc { __nicematrix _ \token_to_str:N \toprule } { __nicematrix _ \token_to_str:N \hline }
+\cs_set_eq:cc { __nicematrix _ \token_to_str:N \CodeBefore } { __nicematrix _ \token_to_str:N \hline }
\cs_new:Npn \__nicematrix_multicolumn:nnn #1 #2 #3
{
\multispan { #1 }
+ \cs_set_eq:NN \__nicematrix_update_max_cell_width: \prg_do_nothing: % added 2023-10-04
\begingroup
\cs_set:Npn \@addamp { \if at firstamp \@firstampfalse \else \@preamerr 5 \fi }
\tl_gclear:N \g__nicematrix_preamble_tl
@@ -2711,13 +2776,13 @@
\seq_gput_right:Nx \g__nicematrix_pos_of_blocks_seq
{
{
- \int_compare:nNnTF \c at jCol = 0
+ \int_if_zero:nTF \c at jCol
{ \int_eval:n { \c at iRow + 1 } }
{ \int_use:N \c at iRow }
}
{ \int_eval:n { \c at jCol + 1 } }
{
- \int_compare:nNnTF \c at jCol = 0
+ \int_if_zero:nTF \c at jCol
{ \int_eval:n { \c at iRow + 1 } }
{ \int_use:N \c at iRow }
}
@@ -2751,7 +2816,6 @@
w { \__nicematrix_make_m_preamble_v:nnnn { } #1 }
W { \__nicematrix_make_m_preamble_v:nnnn { \__nicematrix_special_W: } #1 }
\q_stop { }
- \NC at find { \__nicematrix_make_preamble:n }
}
{
\cs_if_exist:cTF { NC @ find @ #1 }
@@ -2908,7 +2972,7 @@
\__nicematrix_insert_caption:
\int_compare:nNnT \g__nicematrix_notes_caption_int > 0
{
- \tl_gput_right:Nx \g__nicematrix_aux_tl
+ \tl_build_gput_right:Nx \g__nicematrix_aux_tl
{
\tl_set:Nn \exp_not:N \l__nicematrix_note_in_caption_tl
{ \int_use:N \g__nicematrix_notes_caption_int }
@@ -3030,7 +3094,7 @@
\dim_gsub:Nn \g_tmpa_dim \pgf at y
\endpgfpicture
\dim_gadd:Nn \g_tmpa_dim \arrayrulewidth
- \int_compare:nNnT \l__nicematrix_first_row_int = 0
+ \int_if_zero:nT \l__nicematrix_first_row_int
{
\dim_gadd:Nn \g_tmpa_dim \g__nicematrix_ht_row_zero_dim
\dim_gadd:Nn \g_tmpa_dim \g__nicematrix_dp_row_zero_dim
@@ -3069,7 +3133,7 @@
\dim_gsub:Nn \g_tmpa_dim \pgf at y
\endpgfpicture
\dim_gadd:Nn \g_tmpa_dim \arrayrulewidth
- \int_compare:nNnT \l__nicematrix_first_row_int = 0
+ \int_if_zero:nT \l__nicematrix_first_row_int
{
\dim_gadd:Nn \g_tmpa_dim \g__nicematrix_ht_row_zero_dim
\dim_gadd:Nn \g_tmpa_dim \g__nicematrix_dp_row_zero_dim
@@ -3121,7 +3185,7 @@
\__nicematrix_analyze_end:Nn
{
\__nicematrix_transform_preamble:
- \__nicematrix_array:V \g__nicematrix_array_preamble_tl
+ \exp_args:NV \__nicematrix_array: \g__nicematrix_array_preamble_tl
}
}
}
@@ -3156,15 +3220,16 @@
{ \seq_put_right:NV \l__nicematrix_rows_seq \l_tmpa_tl }
\int_compare:nNnT \l__nicematrix_last_row_int = { -1 }
{ \int_set:Nn \l__nicematrix_last_row_int { \seq_count:N \l__nicematrix_rows_seq } }
- \tl_clear_new:N \l__nicematrix_new_body_tl
+ \tl_build_begin:N \l__nicematrix_new_body_tl
\int_zero_new:N \l__nicematrix_nb_cols_int
\seq_pop_left:NN \l__nicematrix_rows_seq \l_tmpa_tl
\__nicematrix_line_with_light_syntax:V \l_tmpa_tl
\seq_map_inline:Nn \l__nicematrix_rows_seq
{
- \tl_put_right:Nn \l__nicematrix_new_body_tl { \\ }
+ \tl_build_put_right:Nn \l__nicematrix_new_body_tl { \\ }
\__nicematrix_line_with_light_syntax:n { ##1 }
}
+ \tl_build_end:N \l__nicematrix_new_body_tl
\int_compare:nNnT \l__nicematrix_last_col_int = { -1 }
{
\int_set:Nn \l__nicematrix_last_col_int
@@ -3171,7 +3236,7 @@
{ \l__nicematrix_nb_cols_int - 1 + \l__nicematrix_first_col_int }
}
\__nicematrix_transform_preamble:
- \__nicematrix_array:V \g__nicematrix_array_preamble_tl \l__nicematrix_new_body_tl
+ \exp_args:NV \__nicematrix_array: \g__nicematrix_array_preamble_tl \l__nicematrix_new_body_tl
}
\cs_new_protected:Npn \__nicematrix_line_with_light_syntax:n #1
{
@@ -3184,9 +3249,9 @@
{ \seq_count:N \l__nicematrix_cells_seq }
}
\seq_pop_left:NN \l__nicematrix_cells_seq \l_tmpa_tl
- \tl_put_right:NV \l__nicematrix_new_body_tl \l_tmpa_tl
+ \exp_args:NNV \tl_build_put_right:Nn \l__nicematrix_new_body_tl \l_tmpa_tl
\seq_map_inline:Nn \l__nicematrix_cells_seq
- { \tl_put_right:Nn \l__nicematrix_new_body_tl { & ##1 } }
+ { \tl_build_put_right:Nn \l__nicematrix_new_body_tl { & ##1 } }
}
\cs_generate_variant:Nn \__nicematrix_line_with_light_syntax:n { V }
\cs_new_protected:Npn \__nicematrix_analyze_end:Nn #1 #2
@@ -3198,7 +3263,7 @@
\cs_new:Npn \__nicematrix_create_col_nodes:
{
\crcr
- \int_compare:nNnT \l__nicematrix_first_col_int = 0
+ \int_if_zero:nT \l__nicematrix_first_col_int
{
\omit
\hbox_overlap_left:n
@@ -3218,7 +3283,7 @@
}
\omit
\bool_gset_true:N \g__nicematrix_row_of_col_done_bool
- \int_compare:nNnTF \l__nicematrix_first_col_int = 0
+ \int_if_zero:nTF \l__nicematrix_first_col_int
{
\bool_if:NT \l__nicematrix_code_before_bool
{
@@ -3540,6 +3605,12 @@
{
\bool_gset_true:N \g__nicematrix_delims_bool
\str_gset:Nn \g__nicematrix_name_env_str { #1 NiceMatrix }
+ % added 2023/10/01
+ \int_if_zero:nT \l__nicematrix_last_col_int
+ {
+ \bool_set_true:N \l__nicematrix_last_col_without_value_bool
+ \int_set:Nn \l__nicematrix_last_col_int { -1 }
+ }
\keys_set:nn { NiceMatrix / NiceMatrix } { ##1 }
\__nicematrix_begin_of_NiceMatrix:nV { #1 } \l__nicematrix_columns_type_tl
}
@@ -3548,6 +3619,12 @@
\NewDocumentEnvironment { NiceMatrix } { ! O { } }
{
\str_gset:Nn \g__nicematrix_name_env_str { NiceMatrix }
+ % added 2023/10/01
+ \int_if_zero:nT \l__nicematrix_last_col_int
+ {
+ \bool_set_true:N \l__nicematrix_last_col_without_value_bool
+ \int_set:Nn \l__nicematrix_last_col_int { -1 }
+ }
\keys_set:nn { NiceMatrix / NiceMatrix } { #1 }
\bool_lazy_or:nnT
{ \clist_if_empty_p:N \l__nicematrix_vlines_clist }
@@ -3603,7 +3680,7 @@
}
{
\endNiceArray
- \int_compare:nNnT \g__nicematrix_total_X_weight_int = \c_zero_int
+ \int_if_zero:nT \g__nicematrix_total_X_weight_int
{ \__nicematrix_error:n { NiceTabularX~without~X } }
}
\NewDocumentEnvironment { NiceTabular* } { m O { } m ! O { } }
@@ -3649,7 +3726,7 @@
{ \int_set_eq:NN \l__nicematrix_last_col_int \g__nicematrix_col_total_int }
\bool_if:NT \l__nicematrix_last_row_without_value_bool
{ \int_set_eq:NN \l__nicematrix_last_row_int \g__nicematrix_row_total_int }
- \tl_gput_right:Nx \g__nicematrix_aux_tl
+ \tl_build_gput_right:Nx \g__nicematrix_aux_tl
{
\seq_gset_from_clist:Nn \exp_not:N \g__nicematrix_size_seq
{
@@ -3663,7 +3740,7 @@
}
\seq_if_empty:NF \g__nicematrix_pos_of_blocks_seq
{
- \tl_gput_right:Nx \g__nicematrix_aux_tl
+ \tl_build_gput_right:Nx \g__nicematrix_aux_tl
{
\seq_gset_from_clist:Nn \exp_not:N \g__nicematrix_pos_of_blocks_seq
{ \seq_use:Nnnn \g__nicematrix_pos_of_blocks_seq , , , }
@@ -3671,7 +3748,7 @@
}
\seq_if_empty:NF \g__nicematrix_multicolumn_cells_seq
{
- \tl_gput_right:Nx \g__nicematrix_aux_tl
+ \tl_build_gput_right:Nx \g__nicematrix_aux_tl
{
\seq_gset_from_clist:Nn \exp_not:N \g__nicematrix_multicolumn_cells_seq
{ \seq_use:Nnnn \g__nicematrix_multicolumn_cells_seq , , , }
@@ -3770,9 +3847,10 @@
\scan_stop:
\tl_gclear:N \g_nicematrix_code_after_tl
\group_end:
+ \seq_if_empty:NF \g__nicematrix_rowlistcolors_seq { \__nicematrix_clear_rowlistcolors_seq: }
\tl_if_empty:NF \g__nicematrix_pre_code_before_tl
{
- \tl_gput_right:Nx \g__nicematrix_aux_tl
+ \tl_build_gput_right:Nx \g__nicematrix_aux_tl
{
\tl_gset:Nn \exp_not:N \g__nicematrix_pre_code_before_tl
{ \exp_not:V \g__nicematrix_pre_code_before_tl }
@@ -3781,7 +3859,7 @@
}
\tl_if_empty:NF \g_nicematrix_code_before_tl
{
- \tl_gput_right:Nx \g__nicematrix_aux_tl
+ \tl_build_gput_right:Nx \g__nicematrix_aux_tl
{
\tl_gset:Nn \exp_not:N \g__nicematrix_code_before_tl
{ \exp_not:V \g_nicematrix_code_before_tl }
@@ -3977,7 +4055,7 @@
\int_compare:nNnTF { #3 } = 1
{ \bool_set_true:N \l__nicematrix_initial_open_bool }
{
- \int_compare:nNnT \l__nicematrix_initial_j_int = { \l__nicematrix_col_min_int -1 }
+ \int_compare:nNnT \l__nicematrix_initial_j_int = { \l__nicematrix_col_min_int - 1 }
{ \bool_set_true:N \l__nicematrix_initial_open_bool }
}
}
@@ -4159,7 +4237,7 @@
\__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } 0 1
\group_begin:
\__nicematrix_open_shorten:
- \int_compare:nNnTF { #1 } = 0
+ \int_if_zero:nTF { #1 }
{ \color { nicematrix-first-row } }
{
\int_compare:nNnT { #1 } = \l__nicematrix_last_row_int
@@ -4211,7 +4289,7 @@
\__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } 0 1
\group_begin:
\__nicematrix_open_shorten:
- \int_compare:nNnTF { #1 } = 0
+ \int_if_zero:nTF { #1 }
{ \color { nicematrix-first-row } }
{
\int_compare:nNnT { #1 } = \l__nicematrix_last_row_int
@@ -4309,7 +4387,7 @@
\__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } 1 0
\group_begin:
\__nicematrix_open_shorten:
- \int_compare:nNnTF { #2 } = 0
+ \int_if_zero:nTF { #2 }
{ \color { nicematrix-first-col } }
{
\int_compare:nNnT { #2 } = \l__nicematrix_last_col_int
@@ -4328,7 +4406,7 @@
{
\__nicematrix_open_y_initial_dim:
\__nicematrix_open_y_final_dim:
- \int_compare:nNnTF \l__nicematrix_initial_j_int = \c_zero_int
+ \int_if_zero:nTF \l__nicematrix_initial_j_int
{
\__nicematrix_qpoint:n { col - 1 }
\dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf at x
@@ -4775,7 +4853,7 @@
{ \__nicematrix_collect_options:n { \__nicematrix_Ldots_i } }
\exp_args:NNV \NewDocumentCommand \__nicematrix_Ldots_i \l__nicematrix_argspec_tl
{
- \int_compare:nNnTF \c at jCol = 0
+ \int_if_zero:nTF \c at jCol
{ \__nicematrix_error:nn { in~first~col } \Ldots }
{
\int_compare:nNnTF \c at jCol = \l__nicematrix_last_col_int
@@ -4793,7 +4871,7 @@
{ \__nicematrix_collect_options:n { \__nicematrix_Cdots_i } }
\exp_args:NNV \NewDocumentCommand \__nicematrix_Cdots_i \l__nicematrix_argspec_tl
{
- \int_compare:nNnTF \c at jCol = 0
+ \int_if_zero:nTF \c at jCol
{ \__nicematrix_error:nn { in~first~col } \Cdots }
{
\int_compare:nNnTF \c at jCol = \l__nicematrix_last_col_int
@@ -4811,7 +4889,7 @@
{ \__nicematrix_collect_options:n { \__nicematrix_Vdots_i } }
\exp_args:NNV \NewDocumentCommand \__nicematrix_Vdots_i \l__nicematrix_argspec_tl
{
- \int_compare:nNnTF \c at iRow = 0
+ \int_if_zero:nTF \c at iRow
{ \__nicematrix_error:nn { in~first~row } \Vdots }
{
\int_compare:nNnTF \c at iRow = \l__nicematrix_last_row_int
@@ -4892,8 +4970,8 @@
\cs_new:Npn \__nicematrix_Hdotsfor:
{
\bool_lazy_and:nnTF
- { \int_compare_p:nNn \c at jCol = 0 }
- { \int_compare_p:nNn \l__nicematrix_first_col_int = 0 }
+ { \int_if_zero_p:n \c at jCol }
+ { \int_if_zero_p:n \l__nicematrix_first_col_int }
{
\bool_if:NTF \g__nicematrix_after_col_zero_bool
{
@@ -4979,10 +5057,8 @@
}
}
\group_begin:
-
\__nicematrix_open_shorten:
-
- \int_compare:nNnTF { #1 } = 0
+ \int_if_zero:nTF { #1 }
{ \color { nicematrix-first-row } }
{
\int_compare:nNnT { #1 } = \g__nicematrix_row_total_int
@@ -5064,8 +5140,7 @@
}
\group_begin:
\__nicematrix_open_shorten:
-
- \int_compare:nNnTF { #2 } = 0
+ \int_if_zero:nTF { #2 }
{ \color { nicematrix-first-col } }
{
\int_compare:nNnT { #2 } = \g__nicematrix_col_total_int
@@ -5268,7 +5343,7 @@
\seq_map_indexed_inline:Nn \g__nicematrix_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
{
\seq_gput_right:Nn \g__nicematrix_colors_seq { #1 }
\tl_gset:cx { g__nicematrix_color _ \seq_count:N \g__nicematrix_colors_seq _ tl } { #2 }
@@ -5275,8 +5350,8 @@
}
{ \tl_gput_right:cx { g__nicematrix_color _ \int_use:N \l_tmpa_int _tl } { #2 } }
}
-\cs_generate_variant:Nn \__nicematrix_add_to_colors_seq:nn { x n }
-\cs_generate_variant:Nn \__nicematrix_add_to_colors_seq:nn { x x }
+\cs_generate_variant:Nn \__nicematrix_add_to_colors_seq:nn { e n }
+\cs_generate_variant:Nn \__nicematrix_add_to_colors_seq:nn { e e }
\cs_new_protected:Npn \__nicematrix_clip_with_rounded_corners:
{
\dim_compare:nNnT \l__nicematrix_tab_rounded_corners_dim > \c_zero_dim
@@ -5350,7 +5425,7 @@
\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 ] } }
}
\keys_define:nn { nicematrix / color-opacity }
{
@@ -5367,7 +5442,7 @@
{
\tl_if_blank:nF { #2 }
{
- \__nicematrix_add_to_colors_seq:xn
+ \__nicematrix_add_to_colors_seq:en
{ \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } }
{ \__nicematrix_cartesian_color:nn { #3 } { - } }
}
@@ -5376,7 +5451,7 @@
{
\tl_if_blank:nF { #2 }
{
- \__nicematrix_add_to_colors_seq:xn
+ \__nicematrix_add_to_colors_seq:en
{ \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } }
{ \__nicematrix_cartesian_color:nn { - } { #3 } }
}
@@ -5385,7 +5460,7 @@
{
\tl_if_blank:nF { #2 }
{
- \__nicematrix_add_to_colors_seq:xn
+ \__nicematrix_add_to_colors_seq:en
{ \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } }
{ \__nicematrix_rectanglecolor:nnn { #3 } { #4 } { 0 pt } }
}
@@ -5394,7 +5469,7 @@
{
\tl_if_blank:nF { #2 }
{
- \__nicematrix_add_to_colors_seq:xn
+ \__nicematrix_add_to_colors_seq:en
{ \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } }
{ \__nicematrix_rectanglecolor:nnn { #3 } { #4 } { #5 } }
}
@@ -5497,7 +5572,7 @@
}
\tl_if_empty:NF \l__nicematrix_color_tl
{
- \__nicematrix_add_to_colors_seq:xx
+ \__nicematrix_add_to_colors_seq:ee
{ \tl_if_blank:nF { #1 } { [ #1 ] } { \l__nicematrix_color_tl } }
{ \__nicematrix_cartesian_color:nn { \l__nicematrix_rows_tl } { \l__nicematrix_cols_tl } }
}
@@ -5524,7 +5599,7 @@
\prg_new_conditional:Nnn \__nicematrix_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 at jCol + 1 } } }
\prg_return_false:
\prg_return_true:
@@ -5625,6 +5700,7 @@
}
\NewDocumentCommand \__nicematrix_cellcolor_tabular { O { } m }
{
+ \__nicematrix_test_color_inside:
\tl_gput_right:Nx \g__nicematrix_pre_code_before_tl
{
\__nicematrix_cellcolor [ #1 ] { \exp_not:n { #2 } }
@@ -5634,6 +5710,7 @@
}
\NewDocumentCommand \__nicematrix_rowcolor_tabular { O { } m }
{
+ \__nicematrix_test_color_inside:
\tl_gput_right:Nx \g__nicematrix_pre_code_before_tl
{
\__nicematrix_rectanglecolor [ #1 ] { \exp_not:n { #2 } }
@@ -5643,19 +5720,53 @@
\ignorespaces
}
\NewDocumentCommand { \__nicematrix_rowcolors_tabular } { O { } m m }
- { \__nicematrix_rowlistcolors_tabular [ #1 ] { #2 , #3 } }
+ { \__nicematrix_rowlistcolors_tabular [ #1 ] { { #2 } , { #3 } } }
\NewDocumentCommand { \__nicematrix_rowlistcolors_tabular } { O { } m O { } }
{
+ \__nicematrix_test_color_inside:
\peek_remove_spaces:n
+ { \__nicematrix_rowlistcolors_tabular:nnn { #1 } { #2 } { #3 } }
+ }
+\cs_new_protected:Npn \__nicematrix_rowlistcolors_tabular:nnn #1 #2 #3
+ {
+ \seq_gclear:N \g_tmpa_seq
+ \seq_map_inline:Nn \g__nicematrix_rowlistcolors_seq
+ { \__nicematrix_rowlistcolors_tabular_i:nnnn ##1 }
+ \seq_gset_eq:NN \g__nicematrix_rowlistcolors_seq \g_tmpa_seq
+ \seq_gput_right:Nx \g__nicematrix_rowlistcolors_seq
{
+ { \int_use:N \c at iRow }
+ { \exp_not:n { #1 } }
+ { \exp_not:n { #2 } }
+ { restart , cols = \int_use:N \c at jCol - , \exp_not:n { #3 } }
+ }
+ }
+\cs_new_protected:Npn \__nicematrix_rowlistcolors_tabular_i:nnnn #1 #2 #3 #4
+ {
+ \int_compare:nNnTF { #1 } = \c at iRow
+ { \seq_gput_right:Nn \g_tmpa_seq { { #1 } { #2 } { #3 } { #4 } } }
+ {
\tl_gput_right:Nx \g__nicematrix_pre_code_before_tl
{
\__nicematrix_rowlistcolors
- [ #1 ] { \int_use:N \c at iRow } { #2 }
- [ restart, cols = \int_use:N \c at jCol - , #3 ]
+ [ \exp_not:n { #2 } ]
+ { #1 - \int_eval:n { \c at iRow - 1 } }
+ { \exp_not:n { #3 } }
+ [ \exp_not:n { #4 } ]
}
}
}
+\cs_new_protected:Npn \__nicematrix_clear_rowlistcolors_seq:
+ {
+ \seq_map_inline:Nn \g__nicematrix_rowlistcolors_seq
+ { \__nicematrix_rowlistcolors_tabular_ii:nnnn ##1 }
+ \seq_gclear:N \g__nicematrix_rowlistcolors_seq
+ }
+\cs_new_protected:Npn \__nicematrix_rowlistcolors_tabular_ii:nnnn #1 #2 #3 #4
+ {
+ \tl_gput_right:Nn \g__nicematrix_pre_code_before_tl
+ { \__nicematrix_rowlistcolors [ #2 ] { #1 } { #3 } [ #4 ] }
+ }
\NewDocumentCommand \__nicematrix_columncolor_preamble { O { } m }
{
\int_compare:nNnT \c at jCol > \g__nicematrix_col_total_int
@@ -5670,10 +5781,10 @@
\cs_set_eq:NN \OnlyMainNiceMatrix \use:n
\cs_new_protected:Npn \__nicematrix_OnlyMainNiceMatrix:n #1
{
- \int_compare:nNnTF \l__nicematrix_first_col_int = 0
+ \int_if_zero:nTF \l__nicematrix_first_col_int
{ \__nicematrix_OnlyMainNiceMatrix_i:n { #1 } }
{
- \int_compare:nNnTF \c at jCol = 0
+ \int_if_zero:nTF \c at jCol
{
\int_compare:nNnF \c at iRow = { -1 }
{ \int_compare:nNnF \c at iRow = { \l__nicematrix_last_row_int - 1 } { #1 } }
@@ -5683,7 +5794,7 @@
}
\cs_new_protected:Npn \__nicematrix_OnlyMainNiceMatrix_i:n #1
{
- \int_compare:nNnF \c at iRow = 0
+ \int_if_zero:nF \c at iRow
{
\int_compare:nNnF \c at iRow = \l__nicematrix_last_row_int
{
@@ -5756,7 +5867,7 @@
\clist_if_empty:NF \l__nicematrix_corners_clist \__nicematrix_test_in_corner_v:
\bool_if:NTF \g_tmpa_bool
{
- \int_compare:nNnT \l__nicematrix_local_start_int = 0
+ \int_if_zero:nT \l__nicematrix_local_start_int
{ \int_set:Nn \l__nicematrix_local_start_int \l_tmpa_tl }
}
{
@@ -5898,7 +6009,7 @@
\__nicematrix_qpoint:n { row - \int_eval:n { \l__nicematrix_local_end_int + 1 } }
\dim_set_eq:NN \l__nicematrix_tmpc_dim \pgf at y
\exp_args:NV \tikzset \l__nicematrix_tikz_rule_tl
- \use:x { \exp_not:N \draw [ \l__nicematrix_tikz_rule_tl ] }
+ \use:e { \exp_not:N \draw [ \l__nicematrix_tikz_rule_tl ] }
( \l_tmpb_dim , \l_tmpa_dim ) --
( \l_tmpb_dim , \l__nicematrix_tmpc_dim ) ;
\end { tikzpicture }
@@ -5948,7 +6059,7 @@
\clist_if_empty:NF \l__nicematrix_corners_clist \__nicematrix_test_in_corner_h:
\bool_if:NTF \g_tmpa_bool
{
- \int_compare:nNnT \l__nicematrix_local_start_int = 0
+ \int_if_zero:nT \l__nicematrix_local_start_int
{ \int_set:Nn \l__nicematrix_local_start_int \l_tmpb_tl }
}
{
@@ -6104,7 +6215,7 @@
\__nicematrix_qpoint:n { col - \int_eval:n { \l__nicematrix_local_end_int + 1 } }
\dim_set_eq:NN \l__nicematrix_tmpc_dim \pgf at x
\exp_args:NV \tikzset \l__nicematrix_tikz_rule_tl
- \use:x { \exp_not:N \draw [ \l__nicematrix_tikz_rule_tl ] }
+ \use:e { \exp_not:N \draw [ \l__nicematrix_tikz_rule_tl ] }
( \l_tmpa_dim , \l_tmpb_dim ) --
( \l__nicematrix_tmpc_dim , \l_tmpb_dim ) ;
\end { tikzpicture }
@@ -6156,7 +6267,6 @@
}
\egroup
}
-\keys_define:nn { NiceMatrix / ColumnTypes } { }
\cs_new_protected:Npn \__nicematrix_custom_line:n #1
{
\str_clear_new:N \l__nicematrix_command_str
@@ -6209,19 +6319,17 @@
{
\exp_args:NnV \tl_if_in:NnTF
\c__nicematrix_forbidden_letters_str \l__nicematrix_letter_str
- { \__nicematrix_error:n { Forbidden~letter } }
+ { \__nicematrix_error:ne { Forbidden~letter } \l__nicematrix_letter_str }
{
- \keys_define:nx { NiceMatrix / ColumnTypes }
- {
- \l__nicematrix_letter_str .code:n =
- { \__nicematrix_v_custom_line:n { \exp_not:n { #1 } } }
- }
- }
- }
- }
+ \cs_set:cpn { __nicematrix _ \l__nicematrix_letter_str } ##1
+ { \__nicematrix_v_custom_line:n { #1 } }
+ }
+ }
+ }
\str_if_empty:NF \l__nicematrix_command_str { \__nicematrix_h_custom_line:n { #1 } }
\str_if_empty:NF \l__nicematrix_ccommand_str { \__nicematrix_c_custom_line:n { #1 } }
}
+\tl_const:Nn \c__nicematrix_forbidden_letters_tl { lcrpmbVX|()[]!@<> }
\str_const:Nn \c__nicematrix_forbidden_letters_str { lcrpmbVX|()[]!@<> }
\keys_define:nn { NiceMatrix / custom-line-bis }
{
@@ -6332,6 +6440,7 @@
total-width = \dim_use:N \l__nicematrix_rule_width_dim
}
}
+ \__nicematrix_rec_preamble:n
}
\__nicematrix_custom_line:n
{ letter = : , command = hdottedline , ccommand = cdottedline, dotted }
@@ -6403,7 +6512,7 @@
}
\seq_if_empty:NF \l__nicematrix_corners_cells_seq
{
- \tl_gput_right:Nx \g__nicematrix_aux_tl
+ \tl_build_gput_right:Nx \g__nicematrix_aux_tl
{
\seq_set_from_clist:Nn \exp_not:N \l__nicematrix_corners_cells_seq
{ \seq_use:Nnnn \l__nicematrix_corners_cells_seq , , , }
@@ -6515,7 +6624,8 @@
\cs_if_exist:cT
{ __nicematrix_max_cell_width_ \int_use:N \g__nicematrix_NiceMatrixBlock_int }
{
- \exp_args:NNx \dim_set:Nn \l__nicematrix_columns_width_dim
+ % is \exp_args:NNe mandatory?
+ \exp_args:NNe \dim_set:Nn \l__nicematrix_columns_width_dim
{
\use:c
{ __nicematrix_max_cell_width _ \int_use:N \g__nicematrix_NiceMatrixBlock_int }
@@ -6824,8 +6934,8 @@
&& ! \tl_if_empty_p:n { #5 }
&& ! \l__nicematrix_X_column_bool
}
- { \exp_args:Nxx \__nicematrix_Block_iv:nnnnn }
- { \exp_args:Nxx \__nicematrix_Block_v:nnnnn }
+ { \exp_args:Nee \__nicematrix_Block_iv:nnnnn }
+ { \exp_args:Nee \__nicematrix_Block_v:nnnnn }
{ \l_tmpa_int } { \l_tmpb_int } { #3 } { #4 } { #5 }
}
\cs_new_protected:Npn \__nicematrix_Block_iv:nnnnn #1 #2 #3 #4 #5
@@ -6853,7 +6963,7 @@
{ \__nicematrix_color:V \l__nicematrix_color_tl }
\int_compare:nNnT { #1 } = 1
{
- \int_compare:nNnTF \c at iRow = 0
+ \int_if_zero:nTF \c at iRow
\l__nicematrix_code_for_first_row_tl
{
\int_compare:nNnT \c at iRow = \l__nicematrix_last_row_int
@@ -6875,7 +6985,7 @@
{ ! \g__nicematrix_rotate_bool }
}
{
- \use:x
+ \use:e
{
\exp_not:N \begin { minipage }%
[ \str_lowercase:V { \l__nicematrix_vpos_of_block_str } ]
@@ -6887,7 +6997,7 @@
\end { minipage }
}
{
- \use:x
+ \use:e
{
\exp_not:N \begin { tabular }%
[ \str_lowercase:V { \l__nicematrix_vpos_of_block_str } ]
@@ -6899,7 +7009,7 @@
}
{
\c_math_toggle_token
- \use:x
+ \use:e
{
\exp_not:N \begin { array }%
[ \str_lowercase:V { \l__nicematrix_vpos_of_block_str } ]
@@ -7028,7 +7138,7 @@
\dim_zero:N \extrarowheight
#4
% \__nicematrix_adjust_hpos_rotate:
- \use:x
+ \use:e
{
\exp_not:N \begin { tabular } [ \l__nicematrix_vpos_of_block_str ]
{ @ { } \l__nicematrix_hpos_block_str @ { } }
@@ -7048,7 +7158,7 @@
#4
% \__nicematrix_adjust_hpos_rotate:
\c_math_toggle_token % :n c
- \use:x
+ \use:e
{
\exp_not:N \begin { array } [ \l__nicematrix_vpos_of_block_str ]
{ @ { } \l__nicematrix_hpos_block_str @ { } }
@@ -7141,9 +7251,13 @@
{ \int_set:Nn \l__nicematrix_last_col_int { #4 } }
\int_compare:nNnTF \l__nicematrix_last_col_int > \g__nicematrix_col_total_int
{
- \int_compare:nTF
- { \l__nicematrix_last_col_int <= \g__nicematrix_static_num_of_col_int }
+ \bool_lazy_and:nnTF
+ \l__nicematrix_preamble_bool
{
+ \int_compare_p:n
+ { \l__nicematrix_last_col_int <= \g__nicematrix_static_num_of_col_int }
+ }
+ {
\msg_error:nnnn { nicematrix } { Block~too~large~2 } { #1 } { #2 }
\__nicematrix_msg_redirect_name:nn { Block~too~large~2 } { none }
\__nicematrix_msg_redirect_name:nn { columns~not~used } { none }
@@ -7362,7 +7476,7 @@
{ \str_if_eq_p:Vn \l__nicematrix_vpos_of_block_str { B } }
}
{
- \int_compare:nNnT { #2 } = 0 { \str_set:Nn \l__nicematrix_hpos_block_str r }
+ \int_if_zero:nT { #2 } { \str_set:Nn \l__nicematrix_hpos_block_str r }
\bool_if:nT \g__nicematrix_last_col_found_bool
{
\int_compare:nNnT { #2 } = \g__nicematrix_col_total_int
@@ -7514,7 +7628,7 @@
{
color .tl_set:N = \l__nicematrix_draw_tl ,
draw .code:n =
- \exp_args:Nx \tl_if_empty:nF { #1 } { \tl_set:Nn \l__nicematrix_draw_tl { #1 } } ,
+ \exp_args:Ne \tl_if_empty:nF { #1 } { \tl_set:Nn \l__nicematrix_draw_tl { #1 } } ,
draw .default:n = default ,
line-width .dim_set:N = \l__nicematrix_line_width_dim ,
rounded-corners .dim_set:N = \l__nicematrix_rounded_corners_dim ,
@@ -7532,7 +7646,7 @@
\tl_set:Nx \l_tmpb_tl { \int_eval:n { \l_tmpb_tl + 1 } }
\int_step_inline:nnn \l__nicematrix_tmpd_tl \l_tmpb_tl
{
- \use:x
+ \use:e
{
\__nicematrix_vline:n
{
@@ -7539,7 +7653,7 @@
position = ##1 ,
start = \l__nicematrix_tmpc_tl ,
end = \int_eval:n { \l_tmpa_tl - 1 } ,
- total-width = \dim_use:N \l__nicematrix_line_width_dim % added 2022-08-06
+ total-width = \dim_use:N \l__nicematrix_line_width_dim
}
}
}
@@ -7556,7 +7670,7 @@
\tl_set:Nx \l_tmpb_tl { \int_eval:n { \l_tmpb_tl + 1 } }
\int_step_inline:nnn \l__nicematrix_tmpc_tl \l_tmpa_tl
{
- \use:x
+ \use:e
{
\__nicematrix_hline:n
{
@@ -7639,7 +7753,7 @@
\pgfusepathqstroke
}
{
- \use:x { \exp_not:N \draw [ \l__nicematrix_borders_tikz_tl ] }
+ \use:e { \exp_not:N \draw [ \l__nicematrix_borders_tikz_tl ] }
( \pgf at x , \l_tmpb_dim ) -- ( \pgf at x , \l__nicematrix_tmpc_dim ) ;
}
}
@@ -7659,7 +7773,7 @@
\pgfusepathqstroke
}
{
- \use:x { \exp_not:N \draw [ \l__nicematrix_borders_tikz_tl ] }
+ \use:e { \exp_not:N \draw [ \l__nicematrix_borders_tikz_tl ] }
( \l_tmpa_dim , \pgf at y ) -- ( \l_tmpb_dim , \pgf at y ) ;
}
}
@@ -7677,7 +7791,7 @@
\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__nicematrix_offset_dim ,
@@ -7741,27 +7855,27 @@
\group_begin:
\keys_set_known:nnN { NiceMatrix / Auto } { #6 } \l_tmpa_tl
% \bool_set_false:N \l__nicematrix_preamble_bool
- \use:x
+ \use:e
{
\exp_not:N \begin { NiceArrayWithDelims } { #1 } { #2 }
{ * { #4 } { \exp_not:V \l__nicematrix_columns_type_tl } }
[ \exp_not:V \l_tmpa_tl ]
}
- \int_compare:nNnT \l__nicematrix_first_row_int = 0
+ \int_if_zero:nT \l__nicematrix_first_row_int
{
- \int_compare:nNnT \l__nicematrix_first_col_int = 0 { & }
+ \int_if_zero:nT \l__nicematrix_first_col_int { & }
\prg_replicate:nn { #4 - 1 } { & }
\int_compare:nNnT \l__nicematrix_last_col_int > { -1 } { & } \\
}
\prg_replicate:nn { #3 }
{
- \int_compare:nNnT \l__nicematrix_first_col_int = 0 { & }
+ \int_if_zero:nT \l__nicematrix_first_col_int { & }
\prg_replicate:nn { #4 - 1 } { { } #5 & } #5
\int_compare:nNnT \l__nicematrix_last_col_int > { -1 } { & } \\
}
\int_compare:nNnT \l__nicematrix_last_row_int > { -2 }
{
- \int_compare:nNnT \l__nicematrix_first_col_int = 0 { & }
+ \int_if_zero:nT \l__nicematrix_first_col_int { & }
\prg_replicate:nn { #4 - 1 } { & }
\int_compare:nNnT \l__nicematrix_last_col_int > { -1 } { & } \\
}
@@ -8509,7 +8623,6 @@
{ }
{ }
}
-
\bool_new:N \l__nicematrix_not_empty_bool
\bool_new:N \l__nicematrix_empty_bool
@@ -8538,7 +8651,7 @@
{
\group_begin:
\keys_set:nn { NiceMatrix / TikzEveryCell } { #1 }
- \tl_set:Nn \l_tmpa_tl { #2 }
+ \tl_set:Nn \l_tmpa_tl { { #2 } }
\seq_map_inline:Nn \g__nicematrix_pos_of_blocks_seq
{ \__nicematrix_for_a_block:nnnnn ##1 }
\__nicematrix_all_the_cells:
@@ -8558,7 +8671,7 @@
{
\cs_if_exist:cF { cell - \__nicematrix_i_tl - \__nicematrix_j_tl }
{
- \exp_args:NNx \seq_if_in:NnF \l__nicematrix_corners_cells_seq
+ \exp_args:NNe \seq_if_in:NnF \l__nicematrix_corners_cells_seq
{ \__nicematrix_i_tl - \__nicematrix_j_tl }
{
\bool_set_false:N \l_tmpa_bool
@@ -8601,7 +8714,6 @@
{ \cs_set:cpn { cell - ##1 - ####1 } { } }
}
}
-
\NewDocumentCommand \__nicematrix_ShowCellNames_CodeBefore { }
{
\dim_zero_new:N \g__nicematrix_tmpc_dim
@@ -9117,7 +9229,7 @@
{
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.
}
@@ -9187,7 +9299,7 @@
\__nicematrix_msg_new:nn { Forbidden~letter }
{
Forbidden~letter.\\
- You~can't~use~the~letter~'\l__nicematrix_letter_str'~for~a~customized~line.\\
+ You~can't~use~the~letter~'#1'~for~a~customized~line.\\
It~will~be~ignored.
}
\__nicematrix_msg_new:nn { Several~letters }
@@ -9374,6 +9486,14 @@
command~'\token_to_str:N\Block')~but~tikz~is~not~loaded.~
That~key~will~be~ignored.
}
+\__nicematrix_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~\__nicematrix_full_name_env:.\\
+ You~can~go~on~but~you~may~need~more~compilations.
+ }
\__nicematrix_msg_new:nn { color~in~custom-line~with~tikz }
{
Erroneous~use.\\
@@ -9450,14 +9570,6 @@
hlines,~hvlines,~l,~line-width,~name,~opacity,~rounded-corners,~r,~
respect-arraystretch,~t,~T,~tikz,~transparent~and~vlines.
}
-\__nicematrix_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.
- }
\__nicematrix_msg_new:nnn { Unknown~key~for~Brace }
{
Unknown~key.\\
@@ -9809,6 +9921,13 @@
You~should~not~use~{NiceTabularX}~without~X~columns.\\
However,~you~can~go~on.
}
+\__nicematrix_msg_new:nn { Preamble~forgotten }
+ {
+ Preamble~forgotten.\\
+ You~have~probably~forgotten~the~preamble~of~your~
+ \__nicematrix_full_name_env:. \\
+ This~error~is~fatal.
+ }
\endinput
%%
More information about the tex-live-commits
mailing list.