summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/nicematrix/README.md3
-rw-r--r--Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdfbin349092 -> 355393 bytes
-rw-r--r--Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex2840
-rw-r--r--Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdfbin845357 -> 875835 bytes
-rw-r--r--Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx4061
-rw-r--r--Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty721
6 files changed, 4315 insertions, 3310 deletions
diff --git a/Master/texmf-dist/doc/latex/nicematrix/README.md b/Master/texmf-dist/doc/latex/nicematrix/README.md
index 62c2d060890..f3183a5cfc4 100644
--- a/Master/texmf-dist/doc/latex/nicematrix/README.md
+++ b/Master/texmf-dist/doc/latex/nicematrix/README.md
@@ -26,4 +26,5 @@ For a manual installation:
The file `nicematrix.sty` will be generated.
-The file `nicematrix.sty` is the only file necessary to use the extension `nicematrix`.
+The file `nicematrix.sty` is the only file necessary to use the extension `nicematrix`.
+You have to put it in the same directory as your document or (best) in a `texmf` tree.
diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf
index 5e5910a1ed6..6acb7b9f282 100644
--- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf
+++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex
index 7adcadf7389..d79a0f3727f 100644
--- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex
+++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex
@@ -7,22 +7,14 @@
\usepackage{geometry}
\geometry{left=2.8cm,right=2.8cm,top=2.5cm,bottom=2.5cm,papersize={21cm,29.7cm}}
-\usepackage{amsmath}
-
-\usepackage{array}
\usepackage{nicematrix}
-% \usepackage{colortbl}
\usepackage{tikz}
\usetikzlibrary{fit}
\usepackage{enumitem}
-
\usepackage{siunitx}
-
-
-% \usepackage{arydshln}
\usepackage{verbatim}
% We use \MakeShortVerb of shortvrb and not \DefineShortVerb of fancyvrb
@@ -45,9 +37,7 @@
\def\emphase{\bgroup\color{RoyalPurple}\let\next=}
\usepackage{footnote}
-
\usepackage{booktabs}
-
\usepackage{varwidth}
\usepackage[hyperfootnotes = false]{hyperref}
@@ -83,38 +73,16 @@
\maketitle
+
\begin{abstract}
L'extension LaTeX \pkg{nicematrix} fournit de nouveaux environnements similaires aux environnements classiques
-|{tabular}|, |{array}| et |{matrix}| mais avec des fonctionnalités supplémentaires. Parmi ces fonctionnalités
-figurent la possibilité de fixer la largeur des colonnes et de tracer des traits en pointillés continus entre les
-cases du tableau.
+|{tabular}|, |{array}| et |{matrix}| de \pkg{array} et \pkg{amsmath} mais avec des fonctionnalités plus étendues.
\end{abstract}
-\vspace{1cm}
-\section{Présentation}
-
-Cette extension peut être utilisée avec |xelatex|, |lualatex| et |pdflatex| mais aussi avec le cheminement
-classique |latex|-|dvips|-|ps2pdf| (ou Adobe Distiller). Deux ou trois compilations successives peuvent être
-nécessaires. Cette extension nécessite et charge les extensions \pkg{expl3}, \pkg{l3keys2e}, \pkg{xparse},
-\pkg{array}, \pkg{amsmath} et \pkg{pgfcore} ainsi que le module \pkg{shapes} de \textsc{pgf} (l'extension
-\pkg{tikz} n'est \emph{pas} chargée). L'utilisateur final n'a qu'à charger l'extension \pkg{nicematrix} avec
-l'instruction habituelle : |\usepackage{nicematrix}|.
-
+\vspace{1cm}
-\medskip
-\begin{savenotes}
-\begin{minipage}{0.6\linewidth}
-Cette extension fournit quelques outils supplémentaires pour dessiner des matrices (au sens mathématique). Les
-principales caractéristiques sont les suivantes :
-\begin{itemize}\setlength{\itemsep}{0pt}
-\item des lignes en pointillés continues ;
-\item des rangées et colonnes extérieures pour les labels ;
-\item un contrôle sur la largeur des colonnes.
-\end{itemize}
-\end{minipage}
-\end{savenotes}
-\hspace{1.4cm}
+\hspace{1cm}
$\begin{bNiceArray}{CCCC}[first-row,first-col,
code-for-first-col=\color{blue}\scriptstyle,
code-for-first-row=\color{blue}\scriptstyle,
@@ -125,98 +93,1106 @@ L_2 & a_{21} & a_{22} & \Cdots & a_{2n} \\
\Vdots & \Vdots & \Vdots & \Ddots & \Vdots \\
L_n & a_{n1} & a_{n2} & \Cdots & a_{nn}
\end{bNiceArray}$
+\hspace{2cm}
+\begin{NiceTabular}[c]{LSSSS}%
+[code-before = \rowcolor{red!15}{1-2} \rowcolors{3}{blue!15}{}]
+\toprule
+\Block{2-1}{Produit} & \multicolumn{3}{C}{dimensions (cm)} & \Block{2-1}{\rotate Prix} \\
+\cmidrule(rl){2-4}
+ & L & l & h \\
+\midrule
+petit & 3 & 5.5 & 1 & 30 \\
+standard & 5.5 & 8 & 1.5 & 50.5 \\
+premium & 8.5 & 10.5 & 2 & 80 \\
+extra & 8.5 & 10 & 1.5 & 85.5 \\
+spécial & 12 & 12 & 0.5 & 70 \\
+\bottomrule
+\end{NiceTabular}
+\vspace{1cm}
-\medskip
+L'extension \pkg{nicematrix} est entièrement contenue dans le fichier |nicematrix.sty|. Ce fichier peut être placé
+dans le répertoire courant ou dans une arborescence |texmf|. Le mieux reste néanmoins d'installer \pkg{nicematrix}
+avec une distribution TeX comme MiKTeX ou TeXlive.
+
+\bigskip
+Cette extension peut être utilisée avec |xelatex|, |lualatex| et |pdflatex| mais aussi avec le cheminement
+classique |latex|-|dvips|-|ps2pdf| (ou Adobe Distiller).
+
+\bigskip
+Cette extension nécessite et charge les extensions \pkg{l3keys2e}, \pkg{xparse}, \pkg{array}, \pkg{amsmath} et
+\pkg{pgfcore} ainsi que le module \pkg{shapes} de \textsc{pgf} (l'extension \pkg{tikz}, qui est une surcouche de
+\textsc{pgf} n'est \emph{pas} chargée). L'utilisateur final n'a qu'à charger l'extension \pkg{nicematrix} avec
+l'instruction habituelle : |\usepackage{nicematrix}|.
+
+
+\bigskip
+L'idée de \pkg{nicematrix} est de créer des nœuds \textsc{pgf} derrière les cases et les positions des filets des
+tableaux créés par \pkg{array} et de les utiliser pour développer de nouvelles fonctionnalités. Comme toujours avec
+\textsc{pgf}, les coordonnées de ces nœuds sont écrites dans le fichier |.aux| pour être utilisées à la
+compilation suivante. C'est pourquoi l'utilisation de \pkg{nicematrix} nécessite \textbf{plusieurs compilations
+ successives}.
+
+\bigskip
+La plupart des fonctionnalités de \pkg{nicematrix} sont accessibles sans avoir à utiliser explicitement
+\textsc{pgf} ou Tikz (ce dernier n'est d'ailleurs pas chargé par défaut).
+
+\bigskip
Une commande|\NiceMatrixOptions| est fournie pour régler les options (la portée des options fixées par cette
-commande est le groupe TeX courant).
+commande est le groupe TeX courant : elles sont semi-globales).
+
+
+\newpage
+
+\section{Les environnements de cette extension}
+
+L'extension \pkg{nicematrix} définit les nouveaux environnements suivants :
+
+\medskip
+\begin{ttfamily}
+\setlength{\tabcolsep}{3mm}
+\begin{tabular}{llll}
+\{NiceTabular\} & \{NiceArray\} & \{NiceMatrix\} \\
+ & \{pNiceArray\} & \{pNiceMatrix\} \\
+ & \{bNiceArray\} & \{bNiceMatrix\} \\
+ & \{BNiceArray\} & \{BNiceMatrix\} \\
+ & \{vNiceArray\} & \{vNiceMatrix\} \\
+ & \{VNiceArray\} & \{VNiceMatrix\}
+\end{tabular}
+\end{ttfamily}
+
+
+\medskip
+Les environnements |{NiceArray}| et |{NiceTabular}| sont similaires aux environnements |{array}| et |{tabular}| de
+l'extension \pkg{array} (qui est chargée par \pkg{nicematrix}).
+
+\medskip
+Il y a néanmoins quelques différences :
+\begin{itemize}
+\item Pour des raisons techniques, dans le préambule de ces environnements, l'utilisateur doit utiliser les lettres
+|L|, |C| et~|R|\footnote{Les types de colonnes |L|, |C| et |R| sont définis localement à l'intérieur de
+ |{NiceTabular}| ou |{NiceArray}| avec la commande |\newcolumntype| de \pkg{array}. Cette définition masque une
+ éventuelle définition précédente.} au lieu de |l|, |c| et |r|, y compris dans les commandes |\multicolumn| et
+dans les types de colonnes définis par |\newcolumntype|.
+
+\item Dans |{NiceArray}| (et ses variantes), les colonnes de type |w| (ex. : |wc{1cm}|) sont composées en mode
+mathématique alors que dans |{array}| de \pkg{array}, elles sont composées en mode texte.
+\end{itemize}
+
+\medskip
+Les environnements |{pNiceArray}|, |{bNiceArray}|, etc. n'ont pas d'équivalents dans \pkg{array}.
+
+\medskip
+Les environnements |{NiceMatrix}|, |{pNiceMatrix}|, etc. sont similaires aux environnements correspondants de
+l'\pkg{amsmath} (qui est chargée par \pkg{nicematrix}) : |{matrix}|, |{pmatrix}|, etc.
+
+\medskip
+Tous les environnements de l'extension \pkg{nicematrix} acceptent, entre crochets, une liste optionnelle de paires
+de la forme \textsl{clé=valeur}. {\bfseries Il doit n'y avoir aucun espace devant le crochet ouvrant (|[|) de cette
+liste d'options.}
+
+
+
+\section{L'espace vertical entre les rangées}
+
+Il est bien connu que certaines rangées des tableaux créés par défault avec LaTeX sont trop proches l'une de
+l'autre. On en donne ci-dessous un exemple classique.
+
+\medskip
+\begin{BVerbatim}[baseline=c,boxwidth=9cm]
+$\begin{pmatrix}
+\frac12 & -\frac12 \\
+\frac13 & \frac14 \\
+\end{pmatrix}$
+\end{BVerbatim}
+$\begin{pmatrix}
+\frac12 & -\frac12 \\
+\frac13 & \frac14 \\
+\end{pmatrix}$
+
+\bigskip
+En s'inspirant de l'extension \pkg{cellspace} qui traite de ce problème, l'extension \pkg{nicematrix} propose deux
+clés |cell-space-top-limit| et |cell-space-bottom-limit| qui sont similaires aux deux paramètres
+|\cellspacetoplimit| et |\cellspacebottomlimit| proposés par \pkg{cellspace}. La valeur initiale de ces paramètres
+est $0$~pt pour que les environnements de \pkg{nicematrix} aient par défaut le même comportement que ceux de
+\pkg{array} et de l'\pkg{amsmth} mais une valeur de $1$~pt serait un bon choix. On conseille de régler leurs
+valeurs avec la commande |\NiceMatrixOptions|.
+
+\medskip
+\begin{Verbatim}
+\NiceMatrixOptions{~emphase#cell-space-top-limit = 1pt,cell-space-bottom-limit = 1pt@}
+\end{Verbatim}
+
+\begin{BVerbatim}[baseline=c,boxwidth=9cm]
+$\begin{pNiceMatrix}
+\frac12 & -\frac12 \\
+\frac13 & \frac14 \\
+\end{pNiceMatrix}$
+\end{BVerbatim}
+\begin{scope}
+\NiceMatrixOptions{
+ cell-space-top-limit = 1pt ,
+ cell-space-bottom-limit = 1pt ,
+}
+$\begin{pNiceMatrix}
+\frac12 & -\frac12 \\
+\frac13 & \frac14 \\
+\end{pNiceMatrix}$
+\end{scope}
+
\bigskip
-\textbf{Un exemple d'utilisation pour les lignes en pointillés continues}
+\section{La clé baseline}
+
+L'extension \pkg{nicematrix} propose une option |baseline| pour la position verticale des tableaux. Cette
+option |baseline| prend comme valeur un entier qui indique le numéro de rangée dont la ligne de base servira de
+ligne de base pour le tableau.
\medskip
-\begin{minipage}{10cm}
-Considérons par exemple le code suivant qui utilise un environnement |{pmatrix}| de l'extension \pkg{amsmath}.
+\begin{BVerbatim}[baseline=c,boxwidth=9cm]
+$A = \begin{pNiceMatrix}[~emphase#baseline=2@]
+\frac{1}{\sqrt{1+p^2}} & p & 1-p \\
+1 & 1 & 1 \\
+1 & p & 1+p
+\end{pNiceMatrix}$
+\end{BVerbatim}
+$A = \begin{pNiceMatrix}[baseline=2]
+\frac{1}{\sqrt{1+p^2}} & p & 1-p \\
+1 & 1 & 1 \\
+1 & p & 1+p
+\end{pNiceMatrix}$
+
+
+\interitem
+L'option |baseline| peut aussi prendre les trois valeurs spéciales |t|, |c| et |b|. Ces trois lettres peuvent aussi
+être utilisées de manière absolue comme pour l'option des environnements |{tabular}| et |{array}| de \pkg{array}.
+La valeur initiale de |baseline| est~|c|.
+
+
+\bigskip
+Dans l'exemple suivant, on utilise l'option |t| (synonyme de |baseline=t|) immédiatement après un |\item| de liste.
+On remarquera que la présence d'un |\hline| initial n'empêche pas l'alignement sur la ligne de base de la première
+rangée (avec |{tabular}| ou |{array}| de \pkg{array}, il faut utiliser |\firsthline|\footnote{On peut aussi utiliser |\firsthline|
+ dans les environnements de \pkg{nicematrix}.}).
\smallskip
-\begin{BVerbatim}
-$A = \begin{pmatrix}
-1 & \cdots & \cdots & 1 \\
-0 & \ddots & & \vdots \\
-\vdots & \ddots & \ddots & \vdots \\
-0 & \cdots & 0 & 1
-\end{pmatrix}$
+\begin{BVerbatim}[baseline=c,boxwidth=9cm]
+\begin{enumerate}
+\item un item
+\smallskip
+\item \renewcommand{\arraystretch}{1.2}
+$\begin{NiceArray}[t]{LCCCCCC}
+\hline
+n & 0 & 1 & 2 & 3 & 4 & 5 \\
+u_n & 1 & 2 & 4 & 8 & 16 & 32
+\hline
+\end{NiceArray}$
+\end{enumerate}
\end{BVerbatim}
+%
+\begin{minipage}{5cm}
+\begin{enumerate}
+\item un item
+\smallskip
+\item \renewcommand{\arraystretch}{1.2}
+$\begin{NiceArray}[t]{LCCCCCC}
+\hline
+n & 0 & 1 & 2 & 3 & 4 & 5 \\
+u_n & 1 & 2 & 4 & 8 & 16 & 32 \\
+\hline
+\end{NiceArray}$
+\end{enumerate}
+\end{minipage}
+
+
+\bigskip
+Il est également possible d'utiliser les outils de \pkg{booktabs}: |\toprule|,
+|\bottomrule|, |\midrule|, etc.\par\nobreak
\smallskip
-Ce code compose la matrice $A$ représentée à droite.
-\end{minipage}\hspace{1cm}
-$A = \begin{pmatrix}
-1 &\cdots &\cdots &1 \\
-0 &\ddots & &\vdots \\
-\vdots &\ddots &\ddots &\vdots \\
-0 &\cdots &0 &1
-\end{pmatrix}$
+\begin{BVerbatim}[baseline=c,boxwidth=9cm]
+\begin{enumerate}
+\item an item
+\smallskip
+\item
+$\begin{NiceArray}[t]{LCCCCCC}
+~emphase#\toprule@
+n & 0 & 1 & 2 & 3 & 4 & 5 \\
+~emphase#\midrule@
+u_n & 1 & 2 & 4 & 8 & 16 & 32
+~emphase#\bottomrule@
+\end{NiceArray}$
+\end{enumerate}
+\end{BVerbatim}
+\begin{minipage}{5cm}
+\begin{enumerate}
+\item an item
+\smallskip
+\item
+$\begin{NiceArray}[t]{LCCCCCC}
+\toprule
+n & 0 & 1 & 2 & 3 & 4 & 5 \\
+\midrule
+u_n & 1 & 2 & 4 & 8 & 16 & 32 \\
+\bottomrule
+\end{NiceArray}$
+\end{enumerate}
+\end{minipage}
+
+
+
+\section{Les blocs}
+\label{Block}
+Dans les environnements de \pkg{nicematrix}, on peut utiliser la commande |\Block| pour placer un élément au centre
+d'un rectangle de cases fusionnées. La commande |\Block| ne crée pas d'espace par elle-même.
+La commande |\Block| doit être utilisée dans la case supérieure gauche du bloc avec deux arguments. Le premier
+argument est la taille de ce bloc avec la syntaxe $i$-$j$ où $i$ est le nombre de rangées et $j$ le nombre de
+colonnes du bloc. Le deuxième argument, est, sans surprise, le contenu du bloc.
+Dans |{NiceTabular}|, le contenu est composé en mode texte. Dans les autres environnements, il est composé en mode
+mathématique.
+
+\medskip
+\begin{BVerbatim}
+\begin{NiceTabular}{CCCC}
+rose & tulipe & marguerite & dahlia \\
+violette & ~emphase#\Block{2-2}{\LARGE\color{blue} fleurs}@ & & souci \\
+pervenche & & & lys \\
+arum & iris & jacinthe & muguet
+\end{NiceTabular}
+\end{BVerbatim}
+
+
+\medskip
+\begin{center}
+\begin{NiceTabular}{CCCC}
+rose & tulipe & marguerite & dahlia \\
+violette & \Block{2-2}{\LARGE\color{blue} fleurs} & & souci \\
+pervenche & & & lys \\
+arum & iris & jacinthe & muguet
+\end{NiceTabular}
+\end{center}
+
+
+
+\bigskip
+On peut aussi utiliser la commande |\Block| dans des matrices mathématiques.
+
+\medskip
+\begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
+$\begin{bNiceArray}{CCC|C}[margin]
+~emphase#\Block{3-3}{A}@ & & & 0 \\
+& \hspace*{1cm} & & \Vdots \\
+& & & 0 \\
+\hline
+0 & \Cdots& 0 & 0
+\end{bNiceArray}$
+\end{BVerbatim}
+$\begin{bNiceArray}{CCC|C}[margin]
+\Block{3-3}{A} & & & 0 \\
+& \hspace*{1cm} & & \Vdots \\
+& & & 0 \\
+\hline
+0 & \Cdots& 0 & 0
+\end{bNiceArray}$
\bigskip
+On peut souhaiter agrandir la taille du «$A$» placé dans le bloc de l'exemple précédent. Comme il est composé en
+mode mathématique, on ne peut pas directement utiliser une commande comme |\large|, |\Large| ou |\LARGE|. C'est
+pourquoi une option à mettre entre chevrons est proposée par |\Block| pour spécifier du code LaTeX qui sera inséré
+\emph{avant} le début du mode mathématique.
+
+\medskip
+\begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
+$\begin{bNiceArray}{CCC|C}[margin]
+\Block{3-3}~emphase#<\LARGE>@{A} & & & 0 \\
+& \hspace*{1cm} & & \Vdots \\
+& & & 0 \\
+\hline
+0 & \Cdots& 0 & 0
+\end{bNiceArray}$
+\end{BVerbatim}
+$\begin{bNiceArray}{CCC|C}[margin]
+\Block{3-3}<\LARGE>{A} & & & 0 \\
+& \hspace*{1cm} & & \Vdots \\
+& & & 0 \\
+\hline
+0 & \Cdots& 0 & 0
+\end{bNiceArray}$
+
+
+\section{Les filets horizontaux et verticaux}
+
+Les techniques habituelles pour tracer des filets peuvent être utilisées dans les environnements de
+\pkg{nicematrix}, à l'exception de |\vline|.
+
+\subsection{L'épaisseur et la couleur des filets}
+
+Les environnements de \pkg{nicematrix} proposent une clé |rules/width| pour fixer la largeur (en fait l'épaisseur)
+des filets dans l'environnement. En fait, cette clé ne fait que fixer la valeur de |\arrayrulewidth|.
+
+\smallskip
+On sait que \pkg{colortbl} propose la commande |\arrayrulecolor| pour spécifier la couleur de ces filets.
+
+\smallskip
+Avec \pkg{nicematrix}, il est possible de spécifier une couleur même si \pkg{colortbl} n'est pas chargé. Par souci
+de compatibilité, la commande est nommée également |\arrayrulecolor|. Les environnements de \pkg{nicematrix}
+proposent également une clé |rules/color| qui permet de fixer cette couleur pour l'environnement en question.
+
+\medskip
\begin{scope}
-\NiceMatrixOptions{transparent}
-\begin{minipage}{10cm}
-Maintenant, si nous utilisons l'extension \pkg{nicematrix} avec l'option |transparent|, le même code va donner le
-résultat ci-contre à droite.
-\end{minipage}\hspace{1cm}
-$A = \begin{pmatrix}
-1 & \cdots & \cdots & 1 \\
-0 & \ddots & & \vdots \\
-\vdots & \ddots & \ddots & \vdots \\
-0 & \cdots & 0 & 1
-\end{pmatrix}$
+\hfuzz=10cm
+\begin{BVerbatim}[baseline=c,boxwidth=9.5cm]
+\begin{NiceTabular}{|CCC|}[~emphase#rules/color=[gray]{0.9},rules/width=1pt@]
+\hline
+rose & tulipe & lys \\
+arum & iris & violette \\
+muguet & dahlia & souci \\
+\hline
+\end{NiceTabular}
+\end{BVerbatim}
+\begin{NiceTabular}{|CCC|}[rules/color=[gray]{0.9},rules/width=1pt]
+\hline
+rose & tulipe & lys \\
+arum & iris & violette \\
+muguet & dahlia & souci \\
+\hline
+\end{NiceTabular}
\end{scope}
+\medskip
+Si on veut définir de nouveaux spécificateurs de colonnes pour des filets (par exemple plus épais ou bien d'une
+couleur spécifique), on aura peut-être intérêt à utiliser la commande |\OnlyMainNiceMatrix| décrite p.~\pageref{OnlyMainNiceMatrix}.
+
+\bigskip
+\subsection{Une remarque concernant \textbackslash cline}
-\section{Les environnements de cette extension}
+\label{remark-cline}
-L'extension \pkg{nicematrix} définit les nouveaux environnements suivants :
+Les traits verticaux et horizontaux que l'on insère avec |\hline| et le spécificateur de colonne «\verb+|+» de
+\pkg{array} rendent le tableau plus large ou plus long d'une quantité égale à la largeur du trait.
+
+\smallskip
+Pour des raisons historiques, il n'en est pas de même pour la commande |\cline|, comme on peut le voir avec
+l'exemple suivant.
\medskip
-\begin{ttfamily}
-\setlength{\tabcolsep}{3mm}
-\begin{tabular}{llll}
-\{NiceMatrix\} & \{NiceArray\} & \{NiceTabular\} \\
-\{pNiceMatrix\} & \{pNiceArray\} \\
-\{bNiceMatrix\} & \{bNiceArray\} \\
-\{BNiceMatrix\} & \{BNiceArray\} \\
-\{vNiceMatrix\} & \{vNiceArray\} \\
-\{VNiceMatrix\} & \{VNiceArray\} \\
- & \{NiceArrayWithDelims\}
+\begin{BVerbatim}[baseline=c,boxwidth=10cm]
+\setlength{\arrayrulewidth}{2pt}
+\begin{tabular}{cccc} \hline
+A&B&C&D \\ ~emphase#\cline{2-2}@
+A&B&C&D \\ \hline
\end{tabular}
-\end{ttfamily}
+\end{BVerbatim}
+%
+\begin{scope}
+\setlength{\arrayrulewidth}{2pt}
+\begin{tabular}[c]{cccc}
+\hline
+A&B&C&D \\
+\cline{2-2}
+A&B&C&D \\
+\hline
+\end{tabular}
+\end{scope}
+
+\medskip
+Dans les environnements de \pkg{nicematrix}, cette situation est corrigée (il est néanmoins possible de revenir au
+comportement par défaut de |\cline| avec la clé |standard-cline|).
+
+\medskip
+\begin{BVerbatim}[baseline=c,boxwidth=10cm]
+\setlength{\arrayrulewidth}{2pt}
+\begin{NiceTabular}{CCCC} \hline
+A&B&C&D \\ ~emphase#\cline{2-2}@
+A&B&C&D \\ \hline
+\end{NiceTabular}
+\end{BVerbatim}
+%
+\begin{scope}
+\setlength{\arrayrulewidth}{2pt}
+\begin{NiceTabular}[c]{CCCC}
+\hline
+A&B&C&D \\
+\cline{2-2}
+A&B&C&D \\
+\hline
+\end{NiceTabular}
+\end{scope}
+
+
+\bigskip
+\subsection{Les clés hlines et vlines}
+
+La clé |hlines| demande un tracé de tous les filets horizontaux et la clé |vlines| demande un tracé de tous les
+filets verticaux. En fait, dans les environnements avec délimiteurs (comme |{pNiceMatrix}| ou |{bNiceArray}|), les
+filets extérieurs ne sont pas tracés (ce qui est le comportement certainement attendu).
\medskip
-Par défaut, les environnements |{NiceMatrix}|, |{pNiceMatrix}|, |{bNiceMatrix}|, |{BNiceMatrix}|, |{vNiceMatrix}|
-et |{VNiceMatrix}| se comportent quasiment comme les environnements correspondants de \pkg{amsmath} : |{matrix}|,
-|{pmatrix}|, |{bmatrix}|, |{Bmatrix}|, |{vmatrix}| et |{Vmatrix}|.
+\begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
+$\begin{pNiceMatrix}[~emphase#vlines@,rules/width=0.2pt]
+1 & 2 & 3 & 4 & 5 & 6 \\
+1 & 2 & 3 & 4 & 5 & 6 \\
+1 & 2 & 3 & 4 & 5 & 6
+\end{pNiceMatrix}$
+\end{BVerbatim}
+$\begin{pNiceMatrix}[vlines,rules/width=0.2pt]
+1 & 2 & 3 & 4 & 5 & 6 \\
+1 & 2 & 3 & 4 & 5 & 6 \\
+1 & 2 & 3 & 4 & 5 & 6
+\end{pNiceMatrix}$
+\bigskip
+Il y a néanmoins une différence entre l'utilisation de l'option |vlines| et du spécificateur «\verb+|+» dans le
+préambule de l'environnement : les filets tracés par |vlines| traversent les double-filets horizontaux tracés par
+|\hline\hline| (il n'y a pas besoin d'utiliser \pkg{hhline}).
+
\medskip
-Les environnements |{NiceArray}| et |{NiceTabular}| sont similaires aux environnements |{array}| et |{tabular}| de
-l'extension |{array}|. Néanmoins, pour des raisons techniques, dans le préambule de ces environnements,
-l'utilisateur doit utiliser les lettres |L|, |C| et~|R| au lieu de |l|, |c| et |r|. Il est possible d'utiliser les
-constructions |p{...}|, |m{...}|, |b{...}|, |w{...}{...}|, |W{...}{...}|, \verb+|+, |>{...}|, |<{...}|, |@{...}|,
-|!{...}| et |*{n}{...}|.
+\begin{BVerbatim}[baseline=c,boxwidth=11.5cm]
+$\begin{NiceMatrix}[~emphase#vlines@] \hline
+a & b & c & d \\ \hline \hline
+1 & 2 & 3 & 4 \\
+1 & 2 & 3 & 4 \\ \hline
+\end{NiceMatrix}$
+\end{BVerbatim}
+%
+$\begin{NiceMatrix}[vlines]
+\hline
+a & b & c & d \\
+\hline \hline
+1 & 2 & 3 & 4 \\
+1 & 2 & 3 & 4 \\
+\hline
+\end{NiceMatrix}$
+
+
+\bigskip
+Si vous utilisez \pkg{booktabs} (qui fournit |\toprule|, |\midrule|, |\bottomrule|, etc.) et que vous tenez
+absolument à mettre des filets verticaux (ce qui est contraire à l'esprit à \pkg{booktabs}), sachez que la clé
+|vlines| est compatible avec \pkg{booktabs}.
+
+\medskip
+\begin{BVerbatim}[baseline=c,boxwidth=11.5cm]
+$\begin{NiceMatrix}[~emphase#vlines@] \toprule
+a & b & c & d \\ \midrule
+1 & 2 & 3 & 4 \\
+1 & 2 & 3 & 4 \\ \bottomrule
+\end{NiceMatrix}$
+\end{BVerbatim}
+%
+$\begin{NiceMatrix}[vlines]
+\toprule
+a & b & c & d \\
+\midrule
+1 & 2 & 3 & 4 \\
+1 & 2 & 3 & 4 \\
+\bottomrule
+\end{NiceMatrix}$
+
+
+\subsection{La clé hvlines}
+\label{hvlines}
+
+La clé |hvlines| demande le tracé de tous les filets horizontaux et verticaux \emph{sauf dans les
+ blocs}.\footnote{En fait, quand la clé |hvlines| est utilisée, les filets ne sont pas non plus tracés dans les blocs virtuels
+ délimités par des cases reliées par des lignes pointillées (cf. p. \pageref{dotted-and-hvlines}).}
+
+\medskip
+\begin{Verbatim}
+\begin{NiceTabular}{CCCC}[~emphase#hvlines@,rules/color=blue,rules/width=1pt]
+rose & tulipe & marguerite & dahlia \\
+violette & \Block{2-2}{\LARGE\color{blue} fleurs} & & souci \\
+pervenche & & & lys \\
+arum & iris & jacinthe & muguet
+\end{NiceTabular}
+\end{Verbatim}
+%
+\begin{center}
+\begin{NiceTabular}{CCCC}[hvlines,rules/color=blue,rules/width=1pt]
+rose & tulipe & marguerite & dahlia \\
+violette & \Block{2-2}{\LARGE\color{blue} fleurs} & & souci \\
+pervenche & & & lys \\
+arum & iris & jacinthe & muguet
+\end{NiceTabular}
+\end{center}
+
+
+
+\subsection{La commande \textbackslash diagbox}
+
+La commande |\diagbox| (inspirée par l'extension \pkg{diagbox}) permet, quand elle est utilisée dans une case, de
+couper cette case selon une diagonale descendante.\footnote{L'auteur de ce document considère que ce type de
+ construction est un piètre choix graphique.}
+
+\medskip
+\begin{BVerbatim}[baseline=c,boxwidth=10cm]
+$\begin{NiceArray}{*{5}{C}}[hvlines]
+~emphase#\diagbox{x}{y}@ & e & a & b & c \\
+e & e & a & b & c \\
+a & a & e & c & b \\
+b & b & c & e & a \\
+c & c & b & a & e
+\end{NiceArray}$
+\end{BVerbatim}
+$\begin{NiceArray}{*{5}{C}}[hvlines]
+\diagbox{x}{y} & e & a & b & c \\
+e & e & a & b & c \\
+a & a & e & c & b \\
+b & b & c & e & a \\
+c & c & b & a & e
+\end{NiceArray}$
+
+
+
+
+
+\subsection{Filets en pointillés}
+
+
+Dans les environnements de \pkg{nicematrix}, il est possible d'utiliser la commande |\hdottedline| (fournie
+par \pkg{nicematrix}) qui est l'équivalent pour les pointillés des commandes |\hline| et |\hdashline|
+(cette dernière étant une commande de \pkg{arydshln}).
+
+\medskip
+\begin{BVerbatim}[baseline=c,boxwidth=9.5cm]
+\begin{pNiceMatrix}
+1 & 2 & 3 & 4 & 5 \\
+~emphase#\hdottedline@
+6 & 7 & 8 & 9 & 10 \\
+11 & 12 & 13 & 14 & 15
+\end{pNiceMatrix}
+\end{BVerbatim}
+$\begin{pNiceMatrix}
+1 & 2 & 3 & 4 & 5 \\
+\hdottedline
+6 & 7 & 8 & 9 & 10 \\
+11 & 12 & 13 & 14 & 15
+\end{pNiceMatrix}$
+
+
+\bigskip
+Dans les environnements avec un préambule explicite (comme |{NiceTabular}|, |{NiceArray}|, etc.), il est possible
+de dessiner un trait vertical en pointillés avec le spécificateur «|:|».
+
+\medskip
+\begin{BVerbatim}[baseline=c,boxwidth=9.5cm]
+\begin{pNiceArray}{CCCC~emphase#:@C}
+1 & 2 & 3 & 4 & 5 \\
+6 & 7 & 8 & 9 & 10 \\
+11 & 12 & 13 & 14 & 15
+\end{pNiceArray}
+\end{BVerbatim}
+$\begin{pNiceArray}{CCCC:C}
+1 & 2 & 3 & 4 & 5 \\
+6 & 7 & 8 & 9 & 10 \\
+11 & 12 & 13 & 14 & 15
+\end{pNiceArray}$
+
+\bigskip
+Il est possible de changer dans \pkg{nicematrix} la lettre utilisée pour indiquer dans le préambule un trait
+vertical en pointillés avec l'option |letter-for-dotted-lines| disponible dans |\NiceMatrixOptions|.
+
+
+\bigskip
+\emph{Remarque} : Quand l'extension \pkg{array} (sur laquelle s'appuie \pkg{nicematrix}) est chargée, les traits
+verticaux et horizontaux que l'on insère rendent le tableau plus large ou plus long d'une quantité égale à la
+largeur du trait\footnote{En fait, cela est vrai pour |\hline| et «\verb+|+» mais pas pour |\cline|.}. Avec
+\pkg{nicematrix}, les lignes en pointillés tracées par |\hdottedline| et «|:|» ont le même effet.
+
+
+
+
+\section{Les couleurs des rangées et des colonnes}
+
+L'extension \pkg{colortbl} permet de colorier des cases, des rangées ou des colonnes d'un tableau. Néanmoins,
+l'affichage du \textsc{pdf} résultant n'est pas toujours parfait, en particulier quand on utilise également des
+filets. Dans certains lecteurs de \textsc{pdf}, des filets verticaux semblent disparaître. De fines lignes blanches
+peuvent également apparaître.
+
+\medskip
+L'extension \pkg{nicematrix} propose des outils similaires qui ne présentent pas ces inconvénients. Elle propose
+une clé |code-before|\footnote{Il existe aussi une clé |code-after| : cf. p.~\pageref{code-after}.} pour du code
+qui sera exécuté \emph{avant} le tracé du tableau. Dans ce |code-before|, de nouvelles commandes sont disponibles :
+|\cellcolor|, |\rectanglecolor|, |\rowcolor|, |\columncolor|, |\rowcolors| et |\chessboardcolors|.
+\label{code-before}
+
+\medskip
+Ces outils sont indépendants de \pkg{colortbl}.\footnote{On peut donc colorier les filets, les cellules, les
+ rangées, les colonnes, etc. sans charger \pkg{colortbl}. Le présent document ne charge pas \pkg{colortbl}.}
+
+\medskip
+Toutes ces commandes acceptent un argument optionnel (entre crochets et en première position) qui est le modèle
+colorimétrique pour la spécification des couleurs.
+
+\medskip
+\begin{itemize}
+\item La commande |\cellcolor| tient son nom de la commande |\cellcolor| de \pkg{colortbl}.
+
+Elle prend en arguments obligatoires une couleur et une liste de cases sous le format $i$-$j$ où $i$ est le
+numéro de ligne et $j$ le numéro de colonne.
+
+\medskip
+\begin{scope}
+\hfuzz=10cm
+\begin{BVerbatim}[boxwidth=10cm,baseline=c]
+\begin{NiceTabular}{|C|C|C|}[code-before = ~emphase#\cellcolor{red!15}{3-1,2-2,1-3}@]
+\hline
+a & b & c \\ \hline
+e & f & g \\ \hline
+h & i & j \\ \hline
+\end{NiceTabular}
+\end{BVerbatim}
+\begin{NiceTabular}{|C|C|C|}[code-before = \cellcolor{red!15}{3-1,2-2,1-3}]
+\hline
+a & b & c \\ \hline
+e & f & g \\ \hline
+h & i & j \\ \hline
+\end{NiceTabular}
+\end{scope}
+
+\bigskip
+\item La commande |\rectanglecolor| prend trois arguments obligatoires. Le premier est la couleur, les deux
+suivants fournissent la case en haut à gauche et la case en bas à droite du rectangle.
+
+\medskip
+\begin{scope}
+\hfuzz=10cm
+\begin{BVerbatim}[boxwidth=10cm,baseline=c]
+\begin{NiceTabular}{|C|C|C|}[code-before = ~emphase#\rectanglecolor{blue!15}{2-2}{3-3}@]
+\hline
+a & b & c \\ \hline
+e & f & g \\ \hline
+h & i & j \\ \hline
+\end{NiceTabular}
+\end{BVerbatim}
+\begin{NiceTabular}{|C|C|C|}[code-before = \rectanglecolor{blue!15}{2-2}{3-3}]
+\hline
+a & b & c \\ \hline
+e & f & g \\ \hline
+h & i & j \\ \hline
+\end{NiceTabular}
+\end{scope}
+
+
+
+\bigskip
+\item La commande |\rowcolor| doit son nom à la commande |\rowcolor| de \pkg{colortbl}. Son premier argument
+obligatoire est la couleur et le deuxième est une liste de numéros de rangées ou bien d'intervalles de rangées sous
+la forme $a$-$b$ (un intervalle de la forme $a$- représente toutes les rangées à partir de la rangée~$a$).
+
+\medskip
+
+\begin{scope}
+\hfuzz=10cm
+\begin{BVerbatim}[boxwidth=9cm,baseline=c]
+$\begin{NiceArray}{LLL}[hvlines, ~emphase#code-before = \rowcolor{red!15}{1,3-5,8-}@]
+a_1 & b_1 & c_1 \\
+a_2 & b_2 & c_2 \\
+a_3 & b_3 & c_3 \\
+a_4 & b_4 & c_4 \\
+a_5 & b_5 & c_5 \\
+a_6 & b_6 & c_6 \\
+a_7 & b_7 & c_7 \\
+a_8 & b_8 & c_8 \\
+a_9 & b_9 & c_9 \\
+a_{10} & b_{10} & c_{10} \\
+\end{NiceArray}$
+\end{BVerbatim}
+%
+$\begin{NiceArray}{LLL}%
+[baseline=4,hvlines, code-before = \rowcolor{red!15}{1,3-5,8-}]
+a_1 & b_1 & c_1 \\
+a_2 & b_2 & c_2 \\
+a_3 & b_3 & c_3 \\
+a_4 & b_4 & c_4 \\
+a_5 & b_5 & c_5 \\
+a_6 & b_6 & c_6 \\
+a_7 & b_7 & c_7 \\
+a_8 & b_8 & c_8 \\
+a_9 & b_9 & c_9 \\
+a_{10} & b_{10} & c_{10} \\
+\end{NiceArray}$
+\end{scope}
+
+
+\bigskip
+\item La commande |\columncolor| doit son nom à la commande |\columncolor| de \pkg{colortbl}. Sa syntaxe est
+similaire à celle de |\rowcolor|.
+
+\bigskip
+\item La commande |\rowcolors| (avec un \emph{s}) doit son nom à la commande |\rowcolors| de
+\pkg{xcolor}\footnote{La commande |\rowcolors| de \pkg{xcolor} est disponible quand \pkg{xcolor} est chargé avec
+ l'option |table|.}. Le \emph{s} rappelle qu'il y a deux couleurs. Elle colorie alternativement les rangées avec
+les deux couleurs à partir de la rangée dont le numéro est donné en premier argument (obligatoire).
+
+\medskip
+\begin{scope}
+\hfuzz=10cm
+\begin{BVerbatim}[baseline=c,boxwidth=9cm]
+\begin{NiceTabular}{LR}[hlines,code-before = ~emphase#\rowcolors{1}{blue!10}{}@]
+Pierre & 12 \\
+Jacques & 8 \\
+Stéphanie & 18 \\
+Amélie & 20 \\
+Henri & 14 \\
+Estelle & 15
+\end{NiceTabular}
+\end{BVerbatim}
+\begin{NiceTabular}{LR}[hlines,code-before = \rowcolors{1}{blue!10}{},baseline=3]
+Pierre & 12 \\
+Jacques & 8 \\
+Stéphanie & 18 \\
+Amélie & 20 \\
+Henri & 14 \\
+Estelle & 15
+\end{NiceTabular}
+\end{scope}
+
+
+
+\bigskip
+\item La commande |\chessboardcolors| prend en arguments obligatoires deux couleurs et colorie les cases en
+quinconces avec les deux couleurs.
+
+\medskip
+\begin{scope}
+\hfuzz=10cm
+\begin{BVerbatim}[baseline=c,boxwidth=9cm]
+$\begin{pNiceMatrix}[R,margin, ~emphase#code-before=\chessboardcolors{red!15}{blue!15}@]
+1 & -1 & 1 \\
+-1 & 1 & -1 \\
+1 & -1 & 1
+\end{pNiceMatrix}$
+\end{BVerbatim}
+$\begin{pNiceMatrix}%
+[baseline=1, R, margin, code-before = \chessboardcolors{red!15}{blue!15}]
+1 & -1 & 1 \\
+-1 & 1 & -1 \\
+1 & -1 & 1
+\end{pNiceMatrix}$
+\end{scope}
+
+\medskip
+On a utilisé la clé |R| qui impose que toutes les colonnes soient alignées à droite (cf. p.~\pageref{key-R}).
+\end{itemize}
+
+\bigskip
+On remarquera que ces commandes sont compatibles avec les commandes de \pkg{booktabs} (|\toprule|, |\midrule|,
+|\bottomrule|, etc).
+
+\medskip
+\begin{scope}
+\hfuzz=10cm
+\begin{BVerbatim}[baseline=c,boxwidth=8.5cm]
+\begin{NiceTabular}{LSSSS}%
+[code-before = \rowcolor{red!15}{1-2} \rowcolors{3}{blue!15}{}]
+~emphase#\toprule@
+\Block{2-1}{Produit} \\
+\Block{1-3}{dimensions (cm)} & & &
+\Block{2-1}{\rotate Prix} \\
+~emphase#\cmidrule(rl){2-4}@
+ & L & l & h \\
+~emphase#\midrule@
+petit & 3 & 5.5 & 1 & 30 \\
+moyen & 5.5 & 8 & 1.5 & 50.5 \\
+premium & 8.5 & 10.5 & 2 & 80 \\
+extra & 8.5 & 10 & 1.5 & 85.5 \\
+spécial & 12 & 12 & 0.5 & 70 \\
+~emphase#\bottomrule@
+\end{NiceTabular}
+\end{BVerbatim}
+\begin{NiceTabular}[c]{LSSSS}%
+[code-before = \rowcolor{red!15}{1-2} \rowcolors{3}{blue!15}{}]
+\toprule
+\Block{2-1}{Produit} &
+\Block{1-3}{dimensions (cm)} & & &
+\Block{2-1}{\rotate Prix} \\
+\cmidrule(rl){2-4}
+ & L & l & h \\
+\midrule
+petit & 3 & 5.5 & 1 & 30 \\
+moyen & 5.5 & 8 & 1.5 & 50.5 \\
+premium & 8.5 & 10.5 & 2 & 80 \\
+extra & 8.5 & 10 & 1.5 & 85.5 \\
+spécial & 12 & 12 & 0.5 & 70 \\
+\bottomrule
+\end{NiceTabular}
+\end{scope}
+
+\medskip
+On a utilisé le type de colonne |S| de \pkg{siunitx}.
+
+
+\section{La largeur des colonnes}
+\label{width}
+
+Dans les environnements avec un préambule explicite (comme |{NiceTabular}|, |{NiceArray}|, etc.), il est possible
+de fixer la largeur d'une colonne avec les lettres classiques |w| et |W| de l'extension \pkg{array}. Dans
+|{NiceTabular}|, les cases des colonnes de ce type sont composées en mode texte mais, dans |{NiceArray}|,
+|{pNiceArray}|, etc., elles sont composées en mode mathématique (alors que dans |{array}| de \pkg{array}, elles
+sont composées en mode texte).
+
+\medskip
+\begin{BVerbatim}[baseline=c,boxwidth=9cm]
+\begin{NiceTabular}{~emphase#Wc{2cm}@CC}[hvlines]
+Paris & New York & Madrid \\
+Berlin & London & Roma \\
+Rio & Tokyo & Oslo
+\end{NiceTabular}
+\end{BVerbatim}
+\begin{NiceTabular}{Wc{2cm}CC}[hvlines]
+Paris & New York & Madrid \\
+Berlin & London & Roma \\
+Rio & Tokyo & Oslo
+\end{NiceTabular}
+
+
+\bigskip
+Dans les environnements de \pkg{nicematrix}, il est aussi possible de fixer la largeur \emph{minimale} de toutes
+les colonnes de la matrice directement avec l'option |columns-width|.
+
+\medskip
+\begin{BVerbatim}[baseline=c,boxwidth=10cm]
+$\begin{pNiceMatrix}[~emphase#columns-width = 1cm@]
+1 & 12 & -123 \\
+12 & 0 & 0 \\
+4 & 1 & 2
+\end{pNiceMatrix}$
+\end{BVerbatim}
+$\begin{pNiceMatrix}[columns-width = 1cm]
+1 & 12 & -123 \\
+12 & 0 & 0 \\
+4 & 1 & 2
+\end{pNiceMatrix}$
+
+\medskip
+Notez que l'espace inséré entre deux colonnes (égal à 2 |\tabcolsep| dans |{NiceTabular}| et à 2 |\arraycolsep|
+dans les autres environnements) n'est pas supprimé (il est évidemment possible de le supprimer en mettant
+|\tabcolsep| ou |\arraycolsep| à~$0$ avant).
+
+\bigskip
+Il est possible de donner la valeur spéciale |auto| à l'option |columns-width|: toutes les colonnes du tableau
+auront alors une largeur égale à la largeur de la case la plus large du tableau.\footnote{Le résultat est atteint
+ dès la première compilation (mais Tikz écrivant des informations dans le fichier |.aux|, un message demandant une
+ deuxième compilation apparaîtra).}\par\nobreak
+
+\medskip
+\begin{BVerbatim}[baseline=c,boxwidth=10cm]
+$\begin{pNiceMatrix}[~emphase#columns-width = auto@]
+1 & 12 & -123 \\
+12 & 0 & 0 \\
+4 & 1 & 2
+\end{pNiceMatrix}$
+\end{BVerbatim}
+$\begin{pNiceMatrix}[columns-width = auto]
+1 & 12 & -123 \\
+12 & 0 & 0 \\
+4 & 1 & 2
+\end{pNiceMatrix}$
+
+\bigskip
+Sans surprise, il est possible de fixer la largeur minimale de toutes les colonnes de toutes les matrices dans une
+certaine portion de document avec la commande |\NiceMatrixOptions|.\par\nobreak
+
+\medskip
+\begin{BVerbatim}[baseline=c,boxwidth=8.5cm]
+~emphase#\NiceMatrixOptions{columns-width=10mm}@
+$\begin{pNiceMatrix}
+a & b \\ c & d
+\end{pNiceMatrix}
+=
+\begin{pNiceMatrix}
+1 & 1245 \\ 345 & 2
+\end{pNiceMatrix}$
+\end{BVerbatim}
+\begin{scope}
+\NiceMatrixOptions{columns-width=10mm}
+$\begin{pNiceMatrix}
+a & b \\
+c & d
+\end{pNiceMatrix}
+=
+\begin{pNiceMatrix}
+1 & 1245 \\
+345 & 2
+\end{pNiceMatrix}$
+\end{scope}
+
+
+\bigskip
+Mais il est aussi possible de fixer une zone dans laquelle toutes les matrices auront leurs colonnes de la même
+largeur, égale à la largeur de la case la plus large de toutes les matrices de la zone. Cette construction utilise
+l'environnement |{NiceMatrixBlock}| avec l'option |auto-columns-width|\footnote{Pour le moment, c'est le seul
+ usage de l'environnement |{NiceMatrixBlock}| mais il pourrait y en avoir davantage dans le futur.}.
+L'environnement |{NiceMatrixBlock}| n'a pas de rapport direct avec la commande |\Block| présentée précédemment dans
+ce document (cf.~p.~\pageref{Block}).
+
+\medskip
+\begin{BVerbatim}[baseline=c,boxwidth=8.5cm]
+~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@
+$\begin{array}{c}
+\begin{bNiceMatrix}
+ 9 & 17 \\ -2 & 5
+ \end{bNiceMatrix} \\ \\
+\begin{bNiceMatrix}
+ 1 & 1245345 \\ 345 & 2
+\end{bNiceMatrix}
+\end{array}$
+~emphase#\end{NiceMatrixBlock}@
+\end{BVerbatim}
+\begin{NiceMatrixBlock}[auto-columns-width]
+$\begin{array}{c}
+\begin{bNiceMatrix}
+ 9 & 17 \\ -2 & 5
+ \end{bNiceMatrix} \\ \\
+\begin{bNiceMatrix}
+ 1 & 1245345 \\ 345 & 2
+\end{bNiceMatrix}
+\end{array}$
+\end{NiceMatrixBlock}
+
+\medskip
+\textbf{Plusieurs compilations peuvent être nécessaires pour obtenir le résultat désiré.}
+
+
+
+\bigskip
+\section{Les rangées et colonnes extérieures}
+Les environnements de \pkg{nicematrix} permettent de composer des rangées et des colonnes «extérieures» grâce aux options
+|first-row|, |last-row|, |first-col| et |last-col|.
+\label{exterior}
+
+Si elle est présente, la «première rangée» (extérieure) est numérotée par $0$ (et non $1$). Il en est de même pour
+la «première colonne».
+
+\begin{Verbatim}
+$\begin{pNiceMatrix}[~emphase#first-row,last-row,first-col,last-col@,nullify-dots]
+ & C_1 & \Cdots & & C_4 & \\
+L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
+\Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
+ & a_{31} & a_{32} & a_{33} & a_{34} & \\
+L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
+ & C_1 & \Cdots & & C_4 &
+\end{pNiceMatrix}$
+\end{Verbatim}
+%
+\[\begin{pNiceMatrix}[first-row,last-row,first-col,last-col,nullify-dots]
+ & C_1 & \Cdots & & C_4 & \\
+L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
+\Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
+ & a_{31} & a_{32} & a_{33} & a_{34} & \\
+L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
+ & C_1 & \Cdots & & C_4 &
+\end{pNiceMatrix}\]
+
+\medskip
+Les lignes pointillées ont été tracées avec les outils présentés p.~\pageref{Cdots}.
+
+
+\bigskip
+Il y a plusieurs remarques à formuler.
+%
+\begin{itemize}[beginpenalty=10000]
+\item Si on utilise un environnement avec préambule explicite (c'est-à-dire |{NiceArray}| ou l'une de ses
+variantes), on ne doit pas mettre dans ce préambule de spécification de colonne pour les éventuelles première et
+dernière colonne : ce sera automatiquement (et nécessairement) une colonne |R| pour la première colonne et une
+colonne |L| pour la dernière.
+
+\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».
+
+\begin{itemize}
+\item Dans le cas d'un environnement avec préambule, comme |{NiceTabular}| ou |{pNiceArray}|, le nombre de colonnes
+se déduit évidemment du préambule.
+
+\item Dans le cas où l'option |light-syntax| (cf. p. \pageref{light-syntax}) est utilisée, \pkg{nicematrix} profite
+du fait que cette option nécessite de toutes manières le chargement complet du contenu de l'environnement (d'où
+l'impossibilité de mettre du verbatim dans ce cas-là) avant composition du tableau. L'analyse du contenu de
+l'environnement donne le nombre de rangées (mais pas le nombre de colonnes).
+
+\item Dans les autres cas, \pkg{nicematrix} détermine le nombre de rangées et de colonnes à la première compilation
+et l'écrit dans le fichier |.aux| pour pouvoir l'utiliser à la compilation suivante.
+
+\textsl{Néanmoins, il est possible de donner le numéro de la dernière rangée et le numéro de la dernière colonne en
+arguments des options |last-row| et |last-col|, ce qui permettra d'accélérer le processus complet de
+compilation.} C'est ce que nous ferons dans la suite.
+\end{itemize}
+
+\end{itemize}
+
+
+
+\bigskip
+On peut contrôler l'apparence de ces rangées et colonnes avec les options |code-for-first-row|,
+|code-for-last-row|, |code-for-first-col| et |code-for-last-col|. Ces options sont des listes de tokens qui seront
+insérées au début de chaque case de la rangée ou de la colonne considérée.
+
+\begin{Verbatim}
+\NiceMatrixOptions{~emphase#code-for-first-row@ = \color{red},
+ ~emphase#code-for-first-col@ = \color{blue},
+ ~emphase#code-for-last-row@ = \color{green},
+ ~emphase#code-for-last-col@ = \color{magenta}}
+$\begin{pNiceArray}{CC|CC}[first-row,last-row=6,first-col,last-col,nullify-dots]
+ & C_1 & \Cdots & & C_4 & \\
+L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
+\Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
+\hline
+ & a_{31} & a_{32} & a_{33} & a_{34} & \\
+L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
+ & C_1 & \Cdots & & C_4 &
+\end{pNiceArray}$
+\end{Verbatim}
+%
+\begin{scope}
+\NiceMatrixOptions{code-for-first-row = \color{red},
+ code-for-first-col = \color{blue},
+ code-for-last-row = \color{green},
+ code-for-last-col = \color{magenta}}
+\begin{displaymath}
+\begin{pNiceArray}{CC|CC}[first-row,last-row=5,first-col,last-col,nullify-dots]
+ & C_1 & \multicolumn1C{\Cdots} & & C_4 & \\
+L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
+\Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
+\hline
+ & a_{31} & a_{32} & a_{33} & a_{34} & \\
+L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
+ & C_1 & \multicolumn1C{\Cdots} & & C_4 &
+\end{pNiceArray}
+\end{displaymath}
+\end{scope}
+
+
+
+\emph{Remarques}
+\begin{itemize}[beginpenalty=10000]
+\item Comme on peut le voir dans l'exemple précédent, les filets horizontaux et verticaux ne s'étendent pas dans
+les rangées et colonnes extérieures.
+
+Néanmoins, si on veut définir de nouveaux spécificateurs de colonnes pour des filets (par exemple plus épais), on
+aura sans doute intérêt à utiliser la commande |\OnlyMainNiceMatrix| décrite p.~\pageref{OnlyMainNiceMatrix}.
+\item Une spécification de couleur présente dans |code-for-first-row| s'applique à une ligne pointillée tracée
+dans cette «première rangée» (sauf si une valeur a été donnée à |xdots/color|). Idem pour les autres.
+\item Sans surprise, une éventuelle option |columns-width| (décrite p.~\pageref{width}) ne s'applique pas à la
+«première colonne» ni à la «dernière colonne».
+\item Pour des raisons techniques, il n'est pas possible d'utiliser l'option de la commande |\\| après la
+«première rangée» ou avant la «dernière rangée» (le placement des délimiteurs serait erroné).
+\end{itemize}
+
+
-Voir p.~\pageref{NiceArray} la partie concernant |{NiceArray}| et |{NiceTabular}|.
\section{Les lignes en pointillés continues}
+\label{Cdots}
+
À l'intérieur des environnements de l'extension \pkg{nicematrix}, de nouvelles commandes sont définies : |\Ldots|,
|\Cdots|, |\Vdots|, |\Ddots|, et |\Iddots|. Ces commandes sont conçues pour être utilisées à la place de |\dots|,
|\cdots|, |\vdots|, |\ddots| et |\iddots|.\footnote{La commande |\iddots|, définie dans \pkg{nicematrix}, est une
@@ -416,8 +1392,6 @@ x & \Ldots & & & & x
L'option |nullify-dots| «smashe» les instructions |\Ldots| (et ses variantes) horizontalement mais aussi
verticalement.
-\medskip
-{\bfseries Il doit n'y avoir aucun espace devant le crochet ouvrant (|[|) des options de l'environnement.}
\subsection{La commande \textbackslash Hdotsfor}
@@ -636,225 +1610,51 @@ b & a & b & \Ddots & & \Vdots \\
\end{pNiceMatrix}\]
-\section{Les nœuds PGF-Tikz créés par l'extension nicematrix}
+\subsection{Les lignes pointillées et la clé hvlines}
-\label{name}
+\label{dotted-and-hvlines}
-L'extension \pkg{nicematrix} crée un nœud PGF-Tikz pour chaque case (non vide) du tableau considéré. Ces nœuds sont
-utilisés pour tracer les lignes en pointillés entre les cases du tableau. Toutefois, l'utilisateur peut aussi
-utiliser directement ces nœuds (s'il a chargé Tikz\footnote{On rappelle que depuis la version 3.13,
- \pkg{nicematrix} ne charge plus Tikz par défaut, mais seulement \textsc{pgf} (Tikz est une surcouche de
- \textsc{pgf}).}). On commence par donner un nom au tableau (avec l'option |name|). Cela étant fait, les nœuds
-sont accessibles à travers les noms «\textsl{nom}-$i$-$j$» où \textsl{nom} est le nom donné au tableau et $i$ et
-$j$ les numéros de rangée et de colonne de la case considérée.
+On a dit (cf. p. \pageref{hvlines}) que la clé |hvlines| trace tous les filets horizontaux et verticaux, exceptés
+dans les blocs. En fait, avec cette clé, les filets ne sont pas non plus tracés dans les blocs virtuels délimités
+par des cases reliées par des lignes pointillées.
\medskip
\begin{BVerbatim}[baseline=c,boxwidth=11cm]
-$\begin{pNiceMatrix}[name=~emphase#ma-matrice@]
-1 & 2 & 3 \\
-4 & 5 & 6 \\
-7 & 8 & 9
+\NiceMatrixOptions{nullify-dots}
+$\begin{pNiceMatrix}[rules/color=gray,~emphase#hvlines@,margin]
+0 & \Cdots & & & & 0 \\
+1 & \Cdots & & & 1 & 2 \\
+0 & \Ddots & & & \Vdots & \Vdots \\
+\Vdots & \Ddots & & & & \\
+ & & & & & \\
+0 & \Cdots & & 0 & 1 & 2 \\
\end{pNiceMatrix}$
-\tikz[remember picture,overlay]
- \draw ~emphase#(ma-matrice-2-2)@ circle (2mm) ;
\end{BVerbatim}
-$\begin{pNiceMatrix}[name=ma-matrice]
-1 & 2 & 3 \\
-4 & 5 & 6 \\
-7 & 8 & 9
+\begin{scope}
+\NiceMatrixOptions{nullify-dots}
+$\begin{pNiceMatrix}[rules/color=gray,hvlines,margin]
+0 & \Cdots & & & & 0 \\
+1 & \Cdots & & & 1 & 2 \\
+0 & \Ddots & & & \Vdots & \Vdots \\
+\Vdots & \Ddots & & & & \\
+ & & & & & \\
+0 & \Cdots & & 0 & 1 & 2 \\
\end{pNiceMatrix}$
-\tikz[remember picture,overlay]
- \draw (ma-matrice-2-2) circle (2mm) ;
-
-\medskip
-Ne pas oublier les options |remember picture| et |overlay|.
-
-\bigskip
-Dans l'exemple suivant, nous avons surligné toutes les cases de la matrice.
-\[\begin{pNiceMatrix}
-a & a + b & a + b + c \\
-a & a & a + b \\
-a & a & a
-\CodeAfter
-\begin{tikzpicture}[
- every node/.style =
- {
- blend mode = multiply,
- inner sep = 0 pt ,
- fill = red!15
- }
- ]
-\node [fit = (1-1)] {} ;
-\node [fit = (1-3)] {} ;
-\node [fit = (2-2)] {} ;
-\node [fit = (3-1)] {} ;
-\node [fit = (3-3)] {} ;
-\node [fit = (1-2)] {} ;
-\node [fit = (2-1)] {} ;
-\node [fit = (2-3)] {} ;
-\node [fit = (3-2)] {} ;
-\end{tikzpicture}
-\end{pNiceMatrix}\]
-
-
-\bigskip
-En fait, l'extension \pkg{nicematrix} peut créer deux séries de nœuds supplémentaires (\emph{extra nodes} en
-anglais) : les «nœuds moyens» (\emph{medium nodes} en anglais) et les «nœuds larges» (\emph{large nodes} en
-anglais). Les premiers sont créés avec l'option |create-medium-nodes| et les seconds avec l'option
-|create-large-nodes|.\footnote{Il existe aussi l'option |create-extra-nodes| qui est un alias pour la conjonction
-de |create-medium-nodes| et |create-large-nodes|.}
-
-\medskip
-Les noms des «nœuds moyens» s'obtiennent en ajoutant le suffixe «|-medium|» au nom des nœuds normaux. Dans
-l'exemple suivant, on a surligné tous les «nœuds moyens». Nous considérons que cet exemple se suffit à lui-même
-comme définition de ces nœuds.
-\[\begin{pNiceMatrix}[
- create-medium-nodes,
- code-after = {\begin{tikzpicture}
- [every node/.style = {fill = red!15,
- blend mode = multiply,
- inner sep = 0 pt},
- name suffix = -medium]
- \node [fit = (1-1)] {} ;
- \node [fit = (1-2)] {} ;
- \node [fit = (1-3)] {} ;
- \node [fit = (2-1)] {} ;
- \node [fit = (2-2)] {} ;
- \node [fit = (2-3)] {} ;
- \node [fit = (3-1)] {} ;
- \node [fit = (3-2)] {} ;
- \node [fit = (3-3)] {} ;
- \end{tikzpicture}}]
-a & a + b & a + b + c \\
-a & a & a + b \\
-a & a & a
-\end{pNiceMatrix}\]
-
-
-\medskip
-Les noms des «nœuds larges» s'obtiennent en ajoutant le suffixe «|-large|» au nom des nœuds normaux. Dans l'exemple
-suivant, on a surligné tous les «nœuds larges». Nous considérons que cet exemple se suffit à lui-même comme
-définition de ces nœuds.\footnote{Il n'y a pas de «nœuds larges» créés dans les rangées et colonnes extérieures
- (pour ces rangées et colonnes, voir p.~\pageref{exterior}).}
-
-\[\begin{pNiceMatrix}[
- create-large-nodes,
- code-after = {\begin{tikzpicture}
- [every node/.style = {blend mode = multiply,
- inner sep = 0 pt},
- name suffix = -large]
- \node [fit = (1-1),fill = red!15] {} ;
- \node [fit = (1-3),fill = red!15] {} ;
- \node [fit = (2-2),fill = red!15] {} ;
- \node [fit = (3-1),fill = red!15] {} ;
- \node [fit = (3-3),fill = red!15] {} ;
- \node [fit = (1-2),fill = blue!15] {} ;
- \node [fit = (2-1),fill = blue!15] {} ;
- \node [fit = (2-3),fill = blue!15] {} ;
- \node [fit = (3-2),fill = blue!15] {} ;
- \end{tikzpicture}}]
-a & a + b & a + b + c \\
-a & a & a + b \\
-a & a & a
-\end{pNiceMatrix}\]
-
-
-\medskip
-Les «nœuds larges» de la première colonne et de la dernière colonne peuvent apparaître trop petits pour certains
-usages. C'est pourquoi il est possible d'utiliser les options |left-margin| et |right-margin| pour ajouter de
-l'espace des deux côtés du tableau et aussi de l'espace dans les «nœuds larges» de la première colonne et de la
-dernière colonne. Dans l'exemple suivant, nous avons utilisé les options |left-margin| et
-|right-margin|.\footnote{Les options |left-margin| et |right-margin| prennent des dimensions comme valeurs mais, si
- aucune valeur n'est donnée, c'est la valeur par défaut qui est utilisée et elle est égale à |\arraycolsep| (par
- défaut, 5~pt).Il existe aussi une option |margin| pour fixer à la fois |left-margin| et |right-margin|.}
-\[\begin{pNiceMatrix}[
- create-large-nodes,left-margin,right-margin,
- code-after = {\begin{tikzpicture}
- [every node/.style = {blend mode = multiply,
- inner sep = 0 pt},
- name suffix = -large]
- \node [fit = (1-1),fill = red!15] {} ;
- \node [fit = (1-3),fill = red!15] {} ;
- \node [fit = (2-2),fill = red!15] {} ;
- \node [fit = (3-1),fill = red!15] {} ;
- \node [fit = (3-3),fill = red!15] {} ;
- \node [fit = (1-2),fill = blue!15] {} ;
- \node [fit = (2-1),fill = blue!15] {} ;
- \node [fit = (2-3),fill = blue!15] {} ;
- \node [fit = (3-2),fill = blue!15] {} ;
- \end{tikzpicture}}]
-a & a + b & a + b + c \\
-a & a & a + b \\
-a & a & a
-\end{pNiceMatrix}\]
-
-\medskip
-Il est aussi possible d'ajouter de l'espace sur les côtés du tableau avec les options |extra-left-margin| et
-|extra-right-margin|. Ces marges ne sont pas incorporées dans les «nœuds larges». Dans l'exemple suivant, nous
-avons utilisé |extra-left-margin| et |extra-right-margin| avec la valeur $3$~pt.
-\[\begin{pNiceMatrix}[
- create-large-nodes,left-margin,right-margin,extra-right-margin=3pt,extra-left-margin=3pt,
- code-after = {\begin{tikzpicture}
- [every node/.style = {blend mode = multiply,
- inner sep = 0 pt},
- name suffix = -large]
- \node [fit = (1-1),fill = red!15] {} ;
- \node [fit = (1-3),fill = red!15] {} ;
- \node [fit = (2-2),fill = red!15] {} ;
- \node [fit = (3-1),fill = red!15] {} ;
- \node [fit = (3-3),fill = red!15] {} ;
- \node [fit = (1-2),fill = blue!15] {} ;
- \node [fit = (2-1),fill = blue!15] {} ;
- \node [fit = (2-3),fill = blue!15] {} ;
- \node [fit = (3-2),fill = blue!15] {} ;
- \end{tikzpicture}}]
-a & a + b & a + b + c \\
-a & a & a + b \\
-a & a & a
-\end{pNiceMatrix}\]
+\end{scope}
-\medskip
-Dans le cas présent, si on veut un contrôle sur la hauteur des rangées, on peut ajouter un |\strut| dans chaque
-rangée du tableau.
-\[\begin{pNiceMatrix}[
- create-large-nodes,left-margin,right-margin,extra-right-margin=3pt,extra-left-margin=3pt,
- code-after = {\begin{tikzpicture}
- [every node/.style = {blend mode = multiply,
- inner sep = 0 pt},
- name suffix = -large]
- \node [fit = (1-1),fill = red!15] {} ;
- \node [fit = (1-3),fill = red!15] {} ;
- \node [fit = (2-2),fill = red!15] {} ;
- \node [fit = (3-1),fill = red!15] {} ;
- \node [fit = (3-3),fill = red!15] {} ;
- \node [fit = (1-2),fill = blue!15] {} ;
- \node [fit = (2-1),fill = blue!15] {} ;
- \node [fit = (2-3),fill = blue!15] {} ;
- \node [fit = (3-2),fill = blue!15] {} ;
- \end{tikzpicture}}]
-\strut a & a + b & a + b + c \\
-\strut a & a & a + b \\
-\strut a & a & a
-\end{pNiceMatrix}\]
-\bigskip
-On explique plus loin comment surligner les nœuds créés par Tikz (cf. p. \pageref{highlight}).
\section{Le code-after}
\label{code-after}
-L'option |code-after| peut être utilisée pour indiquer du code qui sera exécuté après la construction de la matrice,
-et donc, en particulier, après la construction de tous les nœuds.
+L'option |code-after| peut être utilisée pour indiquer du code qui sera exécuté après la construction de la
+matrice.\footnote{Il existe aussi une clé |code-before| décrite p.~\pageref{code-before}.}
-\textbf{Si on a chargé Tikz}\footnote{On rappelle que depuis la version 3.13, \pkg{nicematrix} ne charge plus Tikz
- par défaut, mais seulement \textsc{pgf} (Tikz est une surcouche de \textsc{pgf}).}, on peut accéder à ces nœuds
-avec des instructions Tikz classiques. Les nœuds devront être désignés sous la forme $i$-$j$ (sans le préfixe
-correspondant au nom de l'environnement).
-
-De plus, une commande spéciale, nommée |\line| est disponible pour tracer directement des lignes en pointillés
-entre les nœuds). Elle peut par exemple être utilisée pour tracer une ligne entre deux cases adjacentes comme dans
-l'exemple suivant.
+Une commande spéciale, nommée |\line| est disponible pour tracer directement des lignes en pointillés entre les
+cases. Elle prend deux arguments correspondant aux deux cases à relier, chacun de la forme $i$-$j$ où $i$ est le
+numéro de ligne et $j$ est le numéro de colonne. Elle peut par exemple être utilisée pour tracer une ligne entre
+deux cases adjacentes comme dans l'exemple suivant.
\label{line-in-code-after}
\medskip
@@ -882,786 +1682,47 @@ Pour améliorer la lisibilité du code, une syntaxe alternative est proposée :
|code-after| à la fin de l'environnement, après le mot-clé |\CodeAfter|. Pour un exemple, voir page
\pageref{exemple-CodeAfter}.
-\section{Les environnements \{NiceArray\} et \{NiceTabular\}}
-\label{NiceArray}
-
-Les environnements |{NiceArray}| et |{NiceTabular}| sont similaires aux environnements |{array}| et |{tabular}|.
-L'argument obligatoire est le préambule du tableau. Néanmoins, pour des raisons techniques, l'utilisateur doit
-utiliser les lettres |L|, |C| et |R|\footnote{Les types de colonnes |L|, |C| et |R| sont définis localement à
- l'intérieur de |{NiceArray}| avec la commande |\newcolumntype| de \pkg{array}. Cette définition masque une
- éventuelle définition précédente.} au lieu de |l|, |c| et |r|. Dans une commande |\multicolumn|, on doit
-également utiliser les lettres |L|, |C| et |R|.
-
-Il est possible d'utiliser les constructions |p{...}|, |m{...}|, |b{...}|, |w{...}{...}|, |W{...}{...}|, \verb+|+,
-|>{...}|, |<{...}|, |@{...}|, |!{...}| et |*{n}{...}|. Néanmoins, dans l'environnement |{NiceArray}| (et ses
-variantes), le contenu des colonnes de type |w| ou |W| est composé en mode mathématique (dans |{array}| de
-\pkg{array}, elles sont composées en mode texte).
-\bigskip
-Sans surprise, l'extension \pkg{nicematrix} fournit également les variantes |{pNiceArray}|, |{vNiceArray}|,
-|{VNiceArray}|, |{bNiceArray}| et |{BNiceArray}|.
-\interitem
-L'un des intérêts de |{pNiceArray}| par rapport à |{pNiceMatrix}| est la possibilité de tracer des filets verticaux
-:
+\section{Autres fonctionnalités}
-\bigskip
-\begin{BVerbatim}[baseline=c,boxwidth=10cm]
-$\left[\begin{NiceArray}{CCCC|C}
-a_1 & ? & \Cdots & ? & ? \\
-0 & & \Ddots & \Vdots & \Vdots\\
-\Vdots & \Ddots & \Ddots & ? \\
-0 & \Cdots & 0 & a_n & ?
-\end{NiceArray}\right]$
-\end{BVerbatim}
-$\left[\begin{NiceArray}{CCCC|C}
-a_1 & ? & \Cdots & ? & ? \\
-0 & & \Ddots & \Vdots & \Vdots\\
-\Vdots & \Ddots & \Ddots & ? \\
-0 & \Cdots & 0 & a_n & ?
-\end{NiceArray}\right]$
-\interitem
-Un autre intérêt est la possibilité d'utiliser plusieurs types d'alignement de colonnes.
-\bigskip
-\begin{BVerbatim}[baseline=c,boxwidth=10cm]
-$\begin{pNiceArray}{LCR}
-a_{11} & \Cdots & a_{1n} \\
-a_{21} & & a_{2n} \\
-\Vdots & & \Vdots \\
-a_{n-1,1} & \Cdots & a_{n-1,n}
-\end{pNiceArray}$
-\end{BVerbatim}
-$\begin{pNiceArray}{LCR}
-a_{11} & \Cdots & a_{1n} \\
-a_{21} & & a_{2n} \\
-\Vdots & & \Vdots \\
-a_{n-1,1} & \Cdots & a_{n-1,n}
-\end{pNiceArray}$
-
-
-
-\interitem
-En fait, l'environnement |{pNiceArray}| et ses variantes sont fondés sur un environnement plus général, appelé
-|{NiceArrayWithDelims}|. Les deux premiers arguments obligatoires de cet environnement sont les délimiteurs gauche
-et droit qui seront utilisés dans la construction de la matrice. Il est possible d'utiliser |{NiceArrayWithDelims}|
-si on a besoin de délimiteurs atypiques ou asymétriques.
-
-\medskip
-\begin{BVerbatim}[baseline=c,boxwidth=11cm]
-$\begin{~emphase#NiceArrayWithDelims@}
- {\downarrow}{\uparrow}{CCC}[margin]
-1 & 2 & 3 \\
-4 & 5 & 6 \\
-7 & 8 & 9
-\end{~emphase#NiceArrayWithDelims@}$
-\end{BVerbatim}
-$\begin{NiceArrayWithDelims}
- {\downarrow}{\uparrow}{CCC}[margin]
-1 & 2 & 3 \\
-4 & 5 & 6 \\
-7 & 8 & 9
-\end{NiceArrayWithDelims}$
-
-\bigskip
-\subsection{Le positionnement vertical des matrices}
-
-L'extension \pkg{nicematrix} propose aussi une option |baseline| pour la position verticale des matrices. Cette
-option |baseline| prend comme valeur un entier qui indique le numéro de rangée dont la ligne de base servira de
-ligne de base pour le tableau.
-
-\medskip
-\begin{BVerbatim}[baseline=c,boxwidth=9cm]
-$A = \begin{pNiceMatrix}[~emphase#baseline=2@]
-\frac{1}{\sqrt{1+p^2}} & p & 1-p \\
-1 & 1 & 1 \\
-1 & p & 1+p
-\end{pNiceMatrix}$
-\end{BVerbatim}
-$A = \begin{pNiceMatrix}[baseline=2]
-\frac{1}{\sqrt{1+p^2}} & p & 1-p \\
-1 & 1 & 1 \\
-1 & p & 1+p
-\end{pNiceMatrix}$
-
-
-\interitem
-L'option |baseline| peut aussi prendre les trois valeurs spéciales |t|, |c| et |b|. Ces trois lettres peuvent aussi
-être utilisées de manière absolue comme pour l'option de l'environnement |{array}| de \pkg{array}. La valeur
-initiale de |baseline| est~|c|.
-
-
-\bigskip
-Dans l'exemple suivant, on utilise l'option |t| (synonyme de |baseline=t|) immédiatement après un |\item| de liste.
-On remarquera que la présence d'un |\hline| initial n'empêche pas l'alignement sur la ligne de base de la première
-rangée (avec |{array}| de {array}, il faut utiliser |\firsthline|\footnote{On peut aussi utiliser |\firsthline|
- avec |{NiceArray}|.}).
-
-\smallskip
-\begin{BVerbatim}[baseline=c,boxwidth=9cm]
-\begin{enumerate}
-\item un item
-\smallskip
-\item \renewcommand{\arraystretch}{1.2}
-$\begin{NiceArray}[t]{LCCCCCC}
-\hline
-n & 0 & 1 & 2 & 3 & 4 & 5 \\
-u_n & 1 & 2 & 4 & 8 & 16 & 32
-\hline
-\end{NiceArray}$
-\end{enumerate}
-\end{BVerbatim}
-%
-\begin{minipage}{5cm}
-\begin{enumerate}
-\item un item
-\smallskip
-\item \renewcommand{\arraystretch}{1.2}
-$\begin{NiceArray}[t]{LCCCCCC}
-\hline
-n & 0 & 1 & 2 & 3 & 4 & 5 \\
-u_n & 1 & 2 & 4 & 8 & 16 & 32 \\
-\hline
-\end{NiceArray}$
-\end{enumerate}
-\end{minipage}
-
-
-\bigskip
-Il est également possible d'utiliser les outils de \pkg{booktabs}: |\toprule|,
-|\bottomrule| et |\midrule|.\par\nobreak
-
-\smallskip
-\begin{BVerbatim}[baseline=c,boxwidth=9cm]
-\begin{enumerate}
-\item an item
-\smallskip
-\item
-$\begin{NiceArray}[t]{LCCCCCC}
-~emphase#\toprule@
-n & 0 & 1 & 2 & 3 & 4 & 5 \\
-~emphase#\midrule@
-u_n & 1 & 2 & 4 & 8 & 16 & 32
-~emphase#\bottomrule@
-\end{NiceArray}$
-\end{enumerate}
-\end{BVerbatim}
-\begin{minipage}{5cm}
-\begin{enumerate}
-\item an item
-\smallskip
-\item
-$\begin{NiceArray}[t]{LCCCCCC}
-\toprule
-n & 0 & 1 & 2 & 3 & 4 & 5 \\
-\midrule
-u_n & 1 & 2 & 4 & 8 & 16 & 32 \\
-\bottomrule
-\end{NiceArray}$
-\end{enumerate}
-\end{minipage}
-
-
-
-
-
-\bigskip
-\section{Les rangées et colonnes extérieures}
-Les environnements de \pkg{nicematrix} permettent de composer des rangées et des colonnes «extérieures» grâce aux options
-|first-row|, |last-row|, |first-col| et |last-col|.
-\label{exterior}
-
-Si elle est présente, la «première rangée» (extérieure) est numérotée par $0$ (et non $1$). Il en est de même pour
-la «première rangée».
-
-\begin{Verbatim}
-$\begin{pNiceMatrix}[~emphase#first-row,last-row,first-col,last-col@,nullify-dots]
- & C_1 & \Cdots & & C_4 & \\
-L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
-\Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
- & a_{31} & a_{32} & a_{33} & a_{34} & \\
-L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
- & C_1 & \Cdots & & C_4 &
-\end{pNiceMatrix}$
-\end{Verbatim}
-%
-\[\begin{pNiceMatrix}[first-row,last-row,first-col,last-col,nullify-dots]
- & C_1 & \Cdots & & C_4 & \\
-L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
-\Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
- & a_{31} & a_{32} & a_{33} & a_{34} & \\
-L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
- & C_1 & \Cdots & & C_4 &
-\end{pNiceMatrix}\]
-
-\bigskip
-Il y a plusieurs remarques à formuler.
-%
-\begin{itemize}[beginpenalty=10000]
-\item Si on utilise un environnement avec préambule explicite (c'est-à-dire |{NiceArray}| ou l'une de ses
-variantes), on ne doit pas mettre dans ce préambule de spécification de colonne pour les éventuelles première et
-dernière colonne : ce sera automatiquement (et nécessairement) une colonne |R| pour la première colonne et une
-colonne |L| pour la dernière.
-
-\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».
-
-\begin{itemize}
-\item Dans le cas d'un environnement avec préambule, comme |{NiceTabular}| ou |{pNiceArray}|, le nombre de colonnes
-se déduit évidemment du préambule.
-
-\item Dans le cas où l'option |light-syntax| (cf. p. \pageref{light-syntax}) est utilisée, \pkg{nicematrix} profite
-du fait que cette option nécessite de toutes manières le chargement complet du contenu de l'environnement (d'où
-l'impossibilité de mettre du verbatim dans ce cas-là) avant composition du tableau. L'analyse du contenu de
-l'environnement donne le nombre de rangées (mais pas le nombre de colonnes).
-
-\item Dans les autres cas, \pkg{nicematrix} détermine le nombre de rangées et de colonnes à la première compilation
-et l'écrit dans le fichier |.aux| pour pouvoir l'utiliser à la compilation suivante.
-
-\textsl{Néanmoins, il est possible de donner le numéro de la dernière rangée et le numéro de la dernière colonne en
-arguments des options |last-row| et |last-col|, ce qui permettra d'accélérer le processus complet de
-compilation.} C'est ce que nous ferons dans la suite.
-\end{itemize}
-
-\end{itemize}
-
-
-
-\bigskip
-On peut contrôler l'apparence de ces rangées et colonnes avec les options |code-for-first-row|,
-|code-for-last-row|, |code-for-first-col| et |code-for-last-col|. Ces options sont des listes de tokens qui seront
-insérées au début de chaque case de la rangée ou de la colonne considérée.
-
-\begin{Verbatim}
-\NiceMatrixOptions{~emphase#code-for-first-row@ = \color{red},
- ~emphase#code-for-first-col@ = \color{blue},
- ~emphase#code-for-last-row@ = \color{green},
- ~emphase#code-for-last-col@ = \color{magenta}}
-$\begin{pNiceArray}{CC|CC}[first-row,last-row=6,first-col,last-col,nullify-dots]
- & C_1 & \Cdots & & C_4 & \\
-L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
-\Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
-\hline
- & a_{31} & a_{32} & a_{33} & a_{34} & \\
-L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
- & C_1 & \Cdots & & C_4 &
-\end{pNiceArray}$
-\end{Verbatim}
-%
-\begin{scope}
-\NiceMatrixOptions{code-for-first-row = \color{red},
- code-for-first-col = \color{blue},
- code-for-last-row = \color{green},
- code-for-last-col = \color{magenta}}
-\begin{displaymath}
-\begin{pNiceArray}{CC|CC}[first-row,last-row=5,first-col,last-col,nullify-dots]
- & C_1 & \multicolumn1C{\Cdots} & & C_4 & \\
-L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
-\Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
-\hline
- & a_{31} & a_{32} & a_{33} & a_{34} & \\
-L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
- & C_1 & \multicolumn1C{\Cdots} & & C_4 &
-\end{pNiceArray}
-\end{displaymath}
-\end{scope}
-
-
-
-\emph{Remarques}
-\begin{itemize}[beginpenalty=10000]
-\item Comme on peut le voir dans l'exemple précédent, un filet horizontal (tracé avec |\hline|) ne s'étend pas
-dans les colonnes extérieures et un filet vertical (spécifié par un caractère «\verb+|+» dans le préambule du
-tableau) ne s'étend pas dans les rangées extérieures.\footnote{Ce dernier point n'est pas valable si on a chargé,
- en plus de \pkg{nicematrix}, l'extension \pkg{arydshln}. Les extensions \pkg{nicematrix} et \pkg{arydshln} ne
- sont pas parfaitement compatibles car \pkg{arydshln} redéfinit beaucoup de structures internes à \pkg{array}. Par
-ailleurs, si on veut vraiment un filet qui s'étende dans la première et la dernière rangée, on peut utiliser
-|!{\vline}| dans le préambule à la place de \verb+|+.}
-
-Si on veut définir de nouveaux spécificateurs de colonnes pour des filets (par exemple plus épais), on aura
-peut-être intérêt à utiliser la commande |\OnlyMainNiceMatrix| décrite p.~\pageref{OnlyMainNiceMatrix}.
-\item Une spécification de couleur présente dans |code-for-first-row| s'applique à une ligne pointillée tracée
-dans cette «première rangée» (sauf si une valeur a été donnée à |xdots/color|). Idem pour les autres.
-\item Sans surprise, une éventuelle option |columns-width| (décrite p.~\pageref{width}) ne s'applique pas à la
-«première colonne» ni à la «dernière colonne».
-\item Pour des raisons techniques, il n'est pas possible d'utiliser l'option de la commande |\\| après la
-«première rangée» ou avant la «dernière rangée» (le placement des délimiteurs serait erroné).
-\end{itemize}
-
-
-
-
-
-\section[Les lignes en pointillés pour séparer les rangées et les colonnes]{Les lignes en pointillés pour séparer les rangées\\ et les colonnes}
-
-
-Dans les environnements de \pkg{nicematrix}, il est possible d'utiliser la commande |\hdottedline| (fournie
-par \pkg{nicematrix}) qui est l'équivalent pour les pointillés des commandes |\hline| et |\hdashline|
-(cette dernière étant une commande de \pkg{arydshln}).
-
-\medskip
-\begin{BVerbatim}[baseline=c,boxwidth=9.5cm]
-\begin{pNiceMatrix}
-1 & 2 & 3 & 4 & 5 \\
-~emphase#\hdottedline@
-6 & 7 & 8 & 9 & 10 \\
-11 & 12 & 13 & 14 & 15
-\end{pNiceMatrix}
-\end{BVerbatim}
-$\begin{pNiceMatrix}
-1 & 2 & 3 & 4 & 5 \\
-\hdottedline
-6 & 7 & 8 & 9 & 10 \\
-11 & 12 & 13 & 14 & 15
-\end{pNiceMatrix}$
-
-
-\bigskip
-Dans les environnements avec un préambule explicite (comme |{NiceArray}|, |{pNiceArray}|, etc.), il est possible de
-dessiner un trait vertical en pointillés avec le spécificateur «|:|».
-
-\medskip
-\begin{BVerbatim}[baseline=c,boxwidth=9.5cm]
-\begin{pNiceArray}{CCCC~emphase#:@C}
-1 & 2 & 3 & 4 & 5 \\
-6 & 7 & 8 & 9 & 10 \\
-11 & 12 & 13 & 14 & 15
-\end{pNiceArray}
-\end{BVerbatim}
-$\begin{pNiceArray}{CCCC:C}
-1 & 2 & 3 & 4 & 5 \\
-6 & 7 & 8 & 9 & 10 \\
-11 & 12 & 13 & 14 & 15
-\end{pNiceArray}$
-
-
-\bigskip
-Ces lignes en pointillés ne s'étendent pas dans les rangées et colonnes extérieures.\par\nobreak
-
-
-\medskip
-\begin{BVerbatim}[baseline=c,boxwidth=9.5cm]
-$\begin{pNiceArray}{CCC:C}%
- [first-row,last-col,
- code-for-first-row = \color{blue}\scriptstyle,
- code-for-last-col = \color{blue}\scriptstyle ]
-C_1 & C_2 & C_3 & C_4 \\
-1 & 2 & 3 & 4 & L_1 \\
-5 & 6 & 7 & 8 & L_2 \\
-9 & 10 & 11 & 12 & L_3 \\
-\hdottedline
-13 & 14 & 15 & 16 & L_4
-\end{pNiceArray}$
-\end{BVerbatim}
-$\begin{pNiceArray}{CCC:C}%
- [first-row,last-col,
- code-for-first-row = \color{blue}\scriptstyle,
- code-for-last-col = \color{blue}\scriptstyle ]
-C_1 & C_2 & C_3 & C_4 \\
-1 & 2 & 3 & 4 & L_1 \\
-5 & 6 & 7 & 8 & L_2 \\
-9 & 10 & 11 & 12 & L_3 \\
-\hdottedline
-13 & 14 & 15 & 16 & L_4
-\end{pNiceArray}$
-
-\bigskip
-Il est possible de changer dans \pkg{nicematrix} la lettre utilisée pour indiquer dans le préambule un trait
-vertical en pointillés avec l'option |letter-for-dotted-lines| disponible dans |\NiceMatrixOptions|.
-
-
-\bigskip
-\emph{Remarque} : Quand l'extension \pkg{array} (sur laquelle s'appuie \pkg{nicematrix}) est chargée, les traits
-verticaux et horizontaux que l'on insère rendent le tableau plus large ou plus long d'une quantité égale à la
-largeur du trait\footnote{En fait, cela est vrai pour |\hline| et «\verb+|+» mais pas pour |\cline|.}. Avec
-\pkg{nicematrix}, les lignes en pointillés tracées par |\hdottedline| et «|:|» ont le même effet.
-
-\section{La largeur des colonnes}
-\label{width}
+\subsection{Utilisation du type de colonne S de siunitx}
-Dans les environnements avec un préambule explicite (comme |{NiceArray}|, |{pNiceArray}|, etc.), il est possible de
-fixer la largeur d'une colonne avec les lettres classiques |w| et |W| de l'extension \pkg{array}. Dans les
-environnements de \pkg{nicematrix}, les cases des colonnes de ce type sont composées en mode mathématique (alors
-que dans |{array}| de \pkg{array}, elles sont composées en mode texte).
+Si l'extension \pkg{siunitx} est chargée (avant ou après \pkg{nicematrix}), il est possible d'utiliser les colonnes
+de type |S| de \pkg{siunitx} dans les environnements de \pkg{nicematrix}. L'implémentation n'utilise explicitement
+aucune macro privée de \pkg{siunitx}.
\medskip
-\begin{BVerbatim}[baseline=c,boxwidth=10cm]
-$\begin{pNiceArray}{~emphase#Wc{1cm}@CC}
-1 & 12 & -123 \\
-12 & 0 & 0 \\
-4 & 1 & 2
+\begin{BVerbatim}[baseline = c, boxwidth = 10.5cm]
+$\begin{pNiceArray}{~emphase#S@CWc{1cm}C}[nullify-dots,first-row]
+{C_1} & \Cdots & & C_n \\
+2.3 & 0 & \Cdots & 0 \\
+12.4 & \Vdots & & \Vdots \\
+1.45 \\
+7.2 & 0 & \Cdots & 0
\end{pNiceArray}$
\end{BVerbatim}
-$\begin{pNiceArray}{Wc{1cm}CC}
-1 & 12 & -123 \\
-12 & 0 & 0 \\
-4 & 1 & 2
+$\begin{pNiceArray}{SCWc{1cm}C}[nullify-dots,first-row]
+{C_1} & \Cdots & & C_n \\
+2.3 & 0 & \Cdots & 0 \\
+12.4 & \Vdots & & \Vdots \\
+1.45 \\
+7.2 & 0 & \Cdots & 0
\end{pNiceArray}$
-
-\bigskip
-Dans les environnements de \pkg{nicematrix}, il est aussi possible de fixer la largeur \emph{minimale} de toutes
-les colonnes de la matrice directement avec l'option |columns-width|.
-
-\medskip
-\begin{BVerbatim}[baseline=c,boxwidth=10cm]
-$\begin{pNiceMatrix}[~emphase#columns-width = 1cm@]
-1 & 12 & -123 \\
-12 & 0 & 0 \\
-4 & 1 & 2
-\end{pNiceMatrix}$
-\end{BVerbatim}
-$\begin{pNiceMatrix}[columns-width = 1cm]
-1 & 12 & -123 \\
-12 & 0 & 0 \\
-4 & 1 & 2
-\end{pNiceMatrix}$
-
-\medskip
-Noter que l'espace inséré entre deux colonnes (égal à 2 |\arraycolsep|) n'est pas supprimé (il est évidemment
-possible de le supprimer en mettant |\arraycolsep| à~$0$ avant).
-
-\bigskip
-Il est possible de donner la valeur spéciale |auto| à l'option |columns-width|: toutes les colonnes du tableau
-auront alors une largeur égale à la largeur de la case la plus large du tableau.\footnote{Le résultat est atteint
- dès la première compilation (mais Tikz écrivant des informations dans le fichier |.aux|, un message demandant une
- deuxième compilation apparaîtra).}\par\nobreak
-
-\medskip
-\begin{BVerbatim}[baseline=c,boxwidth=10cm]
-$\begin{pNiceMatrix}[~emphase#columns-width = auto@]
-1 & 12 & -123 \\
-12 & 0 & 0 \\
-4 & 1 & 2
-\end{pNiceMatrix}$
-\end{BVerbatim}
-$\begin{pNiceMatrix}[columns-width = auto]
-1 & 12 & -123 \\
-12 & 0 & 0 \\
-4 & 1 & 2
-\end{pNiceMatrix}$
-
-\bigskip
-Sans surprise, il est possible de fixer la largeur minimale de toutes les colonnes de toutes les matrices dans une
-certaine portion de document avec la commande |\NiceMatrixOptions|.\par\nobreak
-
-\medskip
-\begin{BVerbatim}[baseline=c,boxwidth=8.5cm]
-~emphase#\NiceMatrixOptions{columns-width=10mm}@
-$\begin{pNiceMatrix}
-a & b \\ c & d
-\end{pNiceMatrix}
-=
-\begin{pNiceMatrix}
-1 & 1245 \\ 345 & 2
-\end{pNiceMatrix}$
-\end{BVerbatim}
-\begin{scope}
-\NiceMatrixOptions{columns-width=10mm}
-$\begin{pNiceMatrix}
-a & b \\
-c & d
-\end{pNiceMatrix}
-=
-\begin{pNiceMatrix}
-1 & 1245 \\
-345 & 2
-\end{pNiceMatrix}$
-\end{scope}
-
-
-\bigskip
-Mais il est aussi possible de fixer une zone dans laquelle toutes les matrices auront leurs colonnes de la même
-largeur, égale à la largeur de la case la plus large de toutes les matrices de la zone. Cette construction utilise
-l'environnement |{NiceMatrixBlock}| avec l'option |auto-columns-width|\footnote{Pour le moment, c'est le seul
- usage de l'environnement |{NiceMatrixBlock}| mais il pourrait y en avoir davantage dans le futur.}.
-L'environnement |{NiceMatrixBlock}| n'a pas de rapport direct avec la commande |\Block| présentée juste ci-dessous
-(cf.~p.~\pageref{Block}).
-
-\medskip
-\begin{BVerbatim}[baseline=c,boxwidth=8.5cm]
-~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@
-$\begin{pNiceMatrix}
-a & b \\ c & d
-\end{pNiceMatrix}
-=
-\begin{pNiceMatrix}
-1 & 1245 \\ 345 & 2
-\end{pNiceMatrix}$
-~emphase#\end{NiceMatrixBlock}@
-\end{BVerbatim}
-\begin{NiceMatrixBlock}[auto-columns-width]
-$\begin{pNiceMatrix}
- a & b \\ c & d
- \end{pNiceMatrix}
-=
- \begin{pNiceMatrix}
- 1 & 1245 \\ 345 & 2
-\end{pNiceMatrix}$
-\end{NiceMatrixBlock}
-
-\medskip
-\textbf{Plusieurs compilations peuvent être nécessaires pour obtenir le résultat désiré.}
-
-\section{Les matrices par blocs}
-
-\label{Block}
-
-Cette partie, qui introduit une commande |\Block|, n'a pas de rapport direct avec l'environnement
-|{NiceMatrixBlock}| présenté dans la section précédente.
-
-\smallskip
-Dans les environnements de \pkg{nicematrix}, on peut utiliser la commande |\Block| pour placer un élément au centre
-d'un rectangle de cases fusionnées.
-
-La commande |\Block| doit être utilisée dans la case supérieure gauche du bloc avec deux arguments. Le premier
-argument est la taille de ce bloc avec la syntaxe $i$-$j$ où $i$ est le nombre de rangées et $j$ le nombre de
-colonnes du bloc. Le deuxième argument, est, sans surprise, le contenu du bloc (en mode mathématique). Un nœud Tikz
-correspondant à l'ensemble des cases fusionnées est créé sous le nom «$i$-$j$-block» où \textsl{nom} est le
-nom donné au tableau. Si on a demandé la création des nœuds |medium|, alors un nœud de ce type est aussi créé pour
-ce bloc avec un nom suffixé par |-medium|.
-
-\medskip
-Dans les exemples qui suivent, on utilise la commande |\arrayrulecolor| de \pkg{colortbl}.
-
-\medskip
-\begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
-\arrayrulecolor{blue}
-$\begin{bNiceArray}{CCC|C}[margin]
-~emphase#\Block{3-3}{A}@ & & & 0 \\
-& \hspace*{1cm} & & \Vdots \\
-& & & 0 \\
-\hline
-0 & \Cdots& 0 & 0
-\end{bNiceArray}$
-\arrayrulecolor{black}
-\end{BVerbatim}
-\begin{scope}
-\arrayrulecolor{blue}
-$\begin{bNiceArray}{CCC|C}[margin]
-\Block{3-3}{A} & & & 0 \\
-& \hspace*{1cm} & & \Vdots \\
-& & & 0 \\
-\hline
-0 & \Cdots& 0 & 0
-\end{bNiceArray}$
-\arrayrulecolor{black}
-\end{scope}
-
-\bigskip
-On peut souhaiter agrandir la taille du «$A$» placé dans le bloc de l'exemple précédent. Comme il est composé en
-mode mathématique, on ne peut pas directement utiliser une commande comme |\large|, |\Large| ou |\LARGE|. C'est
-pourquoi une option à mettre entre chevrons est proposée par |\Block| pour spécifier du code LaTeX qui sera inséré
-\emph{avant} le début du mode mathématique.
-
-\medskip
-\begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
-\arrayrulecolor{blue}
-$\begin{bNiceArray}{CCC|C}[margin]
-\Block{3-3}~emphase#<\Large>@{A} & & & 0 \\
-& \hspace*{1cm} & & \Vdots \\
-& & & 0 \\
-\hline
-0 & \Cdots& 0 & 0
-\end{bNiceArray}$
-\arrayrulecolor{black}
-\end{BVerbatim}
-\begin{scope}
-\arrayrulecolor{blue}
-$\begin{bNiceArray}{CCC|C}[margin]
-\Block{3-3}<\Large>{A} & & & 0 \\
-& \hspace*{1cm} & & \Vdots \\
-& & & 0 \\
-\hline
-0 & \Cdots& 0 & 0
-\end{bNiceArray}$
-\arrayrulecolor{black}
-\end{scope}
-
-
-\medskip
-Pour des raisons techniques, il n'est pas possible d'écrire |\Block{|$i$|-|$j$|}{<}|
-(mais on peut écrire |\Block{|$i$|-|$j$|}<>{<}| avec le résultat attendu).
-
-
-\section{Les couleurs des rangées et des colonnes}
-
-L'extension \pkg{colortbl} permet de colorier des cellules, des rangées ou des colonnes d'un tableau. Néanmoins,
-l'affichage du \textsc{pdf} résultant n'est pas toujours parfait, en particulier quand on utilise également des
-filets. Dans certains lecteurs de \textsc{pdf}, des filets verticaux semblent disparaître. De fines lignes
-blanches peuvent également apparaître.
-
-\medskip
-La version 4.0 de \pkg{nicematrix} propose des outils similaires qui ne présentent pas ces inconvénients. Elle
-propose une option |code-before| pour du code qui sera exécuté \emph{avant} le tracé du tableau. Dans ce
-|code-before|, de nouvelles commandes sont disponibles : |\cellcolor|, |\rectanglecolor|, |\rowcolor|,
-|\columncolor|, |\rowcolors| et |\chessboardcolors|.
-
-\medskip
-\begin{itemize}
-\item La commande |\cellcolor| tient son nom de la commande |\cellcolor| de \pkg{colortbl}.
-
-Elle prend en arguments une couleur et une liste de cellules sous le format $i$-$j$ où $i$ est le numéro de ligne
-et $j$ le numéro de colonne.
-
-\medskip
-\begin{scope}
-\hfuzz=10cm
-\begin{BVerbatim}[boxwidth=10cm,baseline=c]
-\begin{NiceTabular}{|C|C|C|}[code-before = ~emphase#\cellcolor{red!15}{3-1,2-2,1-3}@]
-\hline
-a & b & c \\ \hline
-e & f & g \\ \hline
-h & i & j \\ \hline
-\end{NiceTabular}
-\end{BVerbatim}
-\begin{NiceTabular}{|C|C|C|}[code-before = \cellcolor{red!15}{3-1,2-2,1-3}]
-\hline
-a & b & c \\ \hline
-e & f & g \\ \hline
-h & i & j \\ \hline
-\end{NiceTabular}
-\end{scope}
-
-\bigskip
-\item La commande |\rectanglecolor| prend trois arguments. Le premier est la couleur, les deux suivants fournissent
-la case en haut à gauche et la case en bas à droite du rectangle.
-
-\medskip
-\begin{scope}
-\hfuzz=10cm
-\begin{BVerbatim}[boxwidth=10cm,baseline=c]
-\begin{NiceTabular}{|C|C|C|}[code-before = ~emphase#\rectanglecolor{red!15}{2-2}{3-3}@]
-\hline
-a & b & c \\ \hline
-e & f & g \\ \hline
-h & i & j \\ \hline
-\end{NiceTabular}
-\end{BVerbatim}
-\begin{NiceTabular}{|C|C|C|}[code-before = \rectanglecolor{red!15}{2-2}{3-3}]
-\hline
-a & b & c \\ \hline
-e & f & g \\ \hline
-h & i & j \\ \hline
-\end{NiceTabular}
-\end{scope}
-
-
-
-\bigskip
-\item La commande |\rowcolor| doit son nom à la commande |\rowcolor| de \pkg{colortbl}. Son premier argument est la
-couleur et le deuxième est une liste de numéros de rangées ou bien d'intervalles de rangées sous la forme
-$a$-$b$ (un intervalle de la forme $a$- représente toutes les rangées à partir de la rangée~$a$).
-
-\medskip
-
-\begin{scope}
-\hfuzz=10cm
-\begin{BVerbatim}[boxwidth=9cm,baseline=c]
-$\begin{NiceArray}{LLL}[hvlines, ~emphase#code-before = \rowcolor{red!15}{1,3-5,8-}@]
-a_1 & b_1 & c_1 \\
-a_2 & b_2 & c_2 \\
-a_3 & b_3 & c_3 \\
-a_4 & b_4 & c_4 \\
-a_5 & b_5 & c_5 \\
-a_6 & b_6 & c_6 \\
-a_7 & b_7 & c_7 \\
-a_8 & b_8 & c_8 \\
-a_9 & b_9 & c_9 \\
-a_{10} & b_{10} & c_{10} \\
-\end{NiceArray}$
-\end{BVerbatim}
-%
-$\begin{NiceArray}{LLL}%
-[baseline=4,hvlines, code-before = \rowcolor{red!15}{1,3-5,8-}]
-a_1 & b_1 & c_1 \\
-a_2 & b_2 & c_2 \\
-a_3 & b_3 & c_3 \\
-a_4 & b_4 & c_4 \\
-a_5 & b_5 & c_5 \\
-a_6 & b_6 & c_6 \\
-a_7 & b_7 & c_7 \\
-a_8 & b_8 & c_8 \\
-a_9 & b_9 & c_9 \\
-a_{10} & b_{10} & c_{10} \\
-\end{NiceArray}$
-\end{scope}
-
-
-\bigskip
-\item La commande |\columncolor| doit son nom à la commande |\columncolor| de \pkg{colortbl}. Sa syntaxe est
-similaire à celle de |\rowcolor|.
-
-\bigskip
-\item La commande |\rowcolors| (avec un \emph{s}) doit son nom à la commande |\rowcolors| de \pkg{xcolor}. Le
-\emph{s} rappelle qu'il y a deux couleurs. Elle colorie alternativement les rangées avec les deux couleurs à partir
-de la rangée dont le numéro est donné en premier argument.
-
\medskip
-
-
-\begin{scope}
-\hfuzz=10cm
-\begin{BVerbatim}[baseline=c,boxwidth=9cm]
-\begin{NiceTabular}{LR}%
-[~emphase#code-before = \rowcolor{red!15}{1} \rowcolors{3}{blue!10}{}@]
-\toprule
-Ville & habitants \\
-\midrule
-Pau & 80000 \\
-Paris & 2000000 \\
-Toulouse & 700000 \\
-Reims & 40000 \\
-\bottomrule
-\end{NiceTabular}
-\end{BVerbatim}
-\begin{NiceTabular}{LR}[code-before =\rowcolor{red!15}{1} \rowcolors{3}{blue!10}{}]
-\toprule
-Ville & habitants \\
-\midrule
-Pau & 80000 \\
-Paris & 2000000 \\
-Toulouse & 700000 \\
-Reims & 40000 \\
-\bottomrule
-\end{NiceTabular}
-\end{scope}
-
-\bigskip
-\item La commande |\chessboardcolors| prend en arguments deux couleurs et colorie les cellules en quinconces avec
-les deux couleurs.
-
-\medskip
-\begin{scope}
-\hfuzz=10cm
-\begin{BVerbatim}[baseline=c,boxwidth=9cm]
-$\begin{pNiceMatrix}[R,margin, ~emphase#code-before=\chessboardcolors{red!15}{blue!15}@]
-1 & -1 & 1 \\
--1 & 1 & -1 \\
-1 & -1 & 1
-\end{pNiceMatrix}$
-\end{BVerbatim}
-$\begin{pNiceMatrix}%
-[baseline=1, R, margin, code-before = \chessboardcolors{red!15}{blue!15}]
-1 & -1 & 1 \\
--1 & 1 & -1 \\
-1 & -1 & 1
-\end{pNiceMatrix}$
-\end{scope}
-
-\end{itemize}
+En revanche, les colonnes |d| de l'extension \pkg{dcolumn} ne sont pas prises en charge par \pkg{nicematrix}.
-\section{Fonctionnalités avancées}
+\subsection{Option d'alignement dans \{NiceMatrix\}}
-\subsection{Option d'alignement dans NiceMatrix}
+\label{key-R}
Les environnements sans préambule (|{NiceMatrix}|, |{pNiceMatrix}|, |{bNiceMatrix}|, etc.) proposent les options
-|l| et |r| (possédant |L| et |R| comme alias) qui imposent des colonnes alignées à gauche ou à
-droite.\footnote{Cela reprend une partie des fonctionnalités proposées par les environnements |{pmatrix*}|,
- |{bmatrix*}|, etc. de \pkg{mathtools}.}
+|l| et |r| (possédant |L| et |R| comme alias) qui imposent des colonnes alignées à gauche ou à droite.
\medskip
\begin{BVerbatim}[baseline=c,boxwidth=10cm]
@@ -1675,7 +1736,10 @@ $\begin{bNiceMatrix}[R]
\sin x & \cos x
\end{bNiceMatrix}$
-
+\medskip
+Il existe aussi l'option |S| qui impose que toutes les colonnes soient des colonnes |S| de \pkg{siunitx} (si cette
+extension est chargée).\footnote{Cela reprend une partie des fonctionnalités proposées par les environnements |{pmatrix*}|,
+ |{bmatrix*}|, etc. de \pkg{mathtools}.}
\subsection{La commande \textbackslash rotate}
@@ -1790,8 +1854,9 @@ numéro de la rangée courante et le numéro de la colonne courante\footnote{On
Bien entendu, l'utilisateur ne doit pas modifier les valeurs de ces compteurs qui sont utilisés en interne par
\pkg{nicematrix}.
-Dans le |code-after| (cf. p. \pageref{code-after}), |iRow| représente le nombre total de rangées (hors éventuelles
-rangées extérieures) et |jCol| le nombre total de colonnes (hors potentielles colonnes extérieures).
+Dans le |code-before| (cf. p. \pageref{code-before}) et dans le |code-after| (cf. p. \pageref{code-after}), |iRow|
+représente le nombre total de rangées (hors éventuelles rangées extérieures) et |jCol| le nombre total de colonnes
+(hors potentielles colonnes extérieures).
\medskip
\begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
@@ -1818,8 +1883,8 @@ $\begin{pNiceMatrix}[first-row,
\medskip
Si des compteurs LaTeX nommés |iRow| ou |jCol| sont créés dans le document par d'autres extensions que
-\pkg{nicematrix} (ou tout simplement par l'utilisateur), ces compteurs sont masqués dans les environnements de
-\pkg{nicematrix}.
+\pkg{nicematrix} (ou tout simplement par l'utilisateur final), ces compteurs sont masqués dans les environnements
+de \pkg{nicematrix}.
\bigskip
@@ -1838,166 +1903,460 @@ $C = ~emphase#\pAutoNiceMatrix@{3-3}{C_{\arabic{iRow},\arabic{jCol}}}$
\end{Verbatim}
-$C = \pAutoNiceMatrix{3-3}{C_{\arabic{iRow},\arabic{jCol}}}$
+\[C = \pAutoNiceMatrix{3-3}{C_{\arabic{iRow},\arabic{jCol}}}\]
-\subsection{Les options hlines, vlines et hvlines}
-\label{hvlines}
-Dans les environnements de \pkg{nicematrix}, on peut bien entendu ajouter des filets horizontaux entre les rangées
-avec la commande~|\hline| et des filets verticaux avec le spécificateur ``\verb+|+'' dans le préambule de
-l'environnement. Par souci de commodité, l'extension \pkg{nicematrix} fournit aussi l'option |hlines| (resp.
-|vlines|) qui impose directement que tous les filets horizontaux (resp. verticaux) soient tracés (à l'exception,
-très naturelle, des filets extérieurs aux rangées et colonnes extérieures). L'option |hvlines| est la conjonction
-des options |hlines| et |vlines|.
+\subsection{L'option light-syntax}
+
+\label{light-syntax}
+
+L'option |light-syntax| (inspirée de l'extension \pkg{spalign}) permet d'alléger la saisie des matrices, ainsi que
+leur lisibilité dans le source TeX. Lorsque cette option est activée, on doit utiliser le point-virgule comme
+marqueur de fin de rangée et séparer les colonnes par des espaces ou des tabulations. On remarquera toutefois que,
+comme souvent dans le monde TeX, les espaces après les séquences de contrôle ne sont pas comptées et que les
+éléments entre accolades sont considérés comme un tout.
+
\medskip
-Dans l'exemple suivant, on utilise la commande |\arrayrulecolor| de \pkg{colortbl}.
+\begin{scope}
+\begin{BVerbatim}[baseline=c,boxwidth=10cm]
+$\begin{bNiceMatrix}[~emphase#light-syntax@,first-row,first-col]
+{} a b ;
+a 2\cos a {\cos a + \cos b} ;
+b \cos a+\cos b { 2 \cos b }
+\end{bNiceMatrix}$
+\end{BVerbatim}
+\end{scope}
+%
+$\begin{bNiceMatrix}[light-syntax,first-row,first-col]
+{} a b ;
+a 2\cos a {\cos a + \cos b} ;
+b \cos a+\cos b { 2 \cos b }
+\end{bNiceMatrix}$
+
+\medskip
+On peut changer le caractère utilisé pour indiquer les fins de rangées avec l'option |end-of-row|. Comme dit
+précédemment, la valeur initiale de ce paramètre est un point-virgule.
+
+\medskip
+Lorsque l'option |light-syntax| est utilisée, il n'est pas possible de mettre d'éléments en verbatim (avec par
+exemple la commande |\verb|) dans les cases du tableau.\footnote{La raison en est que lorsque l'option
+ |light-syntax| est utilisée, le contenu complet de l'environnement est chargé comme un argument de commande TeX.
+ L'environnement ne se comporte plus comme un «vrai» environnement de LaTeX qui se contente d'insérer des
+ commandes avant et après.}
+\subsection{L'environnement \{NiceArrayWithDelims\}}
+En fait, l'environnement |{pNiceArray}| et ses variantes sont fondés sur un environnement plus général, appelé
+|{NiceArrayWithDelims}|. Les deux premiers arguments obligatoires de cet environnement sont les délimiteurs gauche
+et droit qui seront utilisés dans la construction de la matrice. Il est possible d'utiliser |{NiceArrayWithDelims}|
+si on a besoin de délimiteurs atypiques ou asymétriques.
\medskip
\begin{BVerbatim}[baseline=c,boxwidth=11cm]
-\arrayrulecolor{blue}
-$\begin{NiceArray}{CCCC}[~emphase#hvlines@,first-row,first-col]
- & e & a & b & c \\
-e & e & a & b & c \\
-a & a & e & c & b \\
-b & b & c & e & a \\
-c & c & b & a & e
-\end{NiceArray}$
-\arrayrulecolor{black}
+$\begin{~emphase#NiceArrayWithDelims@}
+ {\downarrow}{\uparrow}{CCC}[margin]
+1 & 2 & 3 \\
+4 & 5 & 6 \\
+7 & 8 & 9
+\end{~emphase#NiceArrayWithDelims@}$
\end{BVerbatim}
%
-\arrayrulecolor{blue}
-$\begin{NiceArray}{CCCC}[hvlines,first-row,first-col]
- & e & a & b & c \\
-e & e & a & b & c \\
-a & a & e & c & b \\
-b & b & c & e & a \\
-c & c & b & a & e
-\end{NiceArray}$
-\arrayrulecolor{black}
+$\begin{NiceArrayWithDelims}
+ {\downarrow}{\uparrow}{CCC}[margin]
+1 & 2 & 3 \\
+4 & 5 & 6 \\
+7 & 8 & 9
+\end{NiceArrayWithDelims}$
+
+
+\section{Utilisation de Tikz avec nicematrix}
+
+\label{name}
+
+\subsection{Les nœuds correspondant aux contenus des cases}
+
+L'extension \pkg{nicematrix} crée un nœud PGF-Tikz pour chaque case (non vide) du tableau considéré. Ces nœuds sont
+utilisés, entre autres, pour tracer les lignes en pointillés entre les cases du tableau.
+
+\smallskip
+Tous les nœuds du document doivent avoir des noms deux à deux distincts et le nom de ces nœuds doit donc faire
+intervenir le numéro de l'environnement courant. Les environnements créés par \pkg{nicematrix} sont en effet
+numérotés par un compteur global interne.
+
+\smallskip
+Si l'environnement concerné a le numéro $n$, alors le nœud de la rangée~$i$ et de la colonne~$j$ a pour nom
+|nm-|$n$|-|$i$|-|$j$.
+
+\smallskip
+La commande |\NiceMatrixLastEnv| donne le numéro du dernier de ces environnements (pour LaTeX, il s'agit d'une
+commande — complètement développable — et non d'un compteur).
+
+\smallskip
+Il est néanmoins recommandé de passer plutôt par la clé |name|. Celle-ci permet de donner un nom à l'environnement.
+Une fois l'environnement nommé, les nœuds sont accessibles à travers les noms «\textsl{nom}-$i$-$j$» où
+\textsl{nom} est le nom donné au tableau et $i$ et $j$ les numéros de rangée et de colonne de la case considérée.
+On peut les utiliser avec \textsc{pgf} mais l'utilisateur final préférera sans doute utiliser Tikz (qui est une
+sur-couche de \textsc{pgf}). Il faut néanmoins se souvenir que \pkg{nicematrix} ne charge pas Tikz par défault.
\bigskip
-Il y a néanmoins une différence entre l'utilisation de l'option |vlines| et du spécificateur «\verb+|+» dans le
-préambule de l'environnement : les filets tracés par |vlines| traversent les double-filets horizontaux tracés par
-|\hline\hline|.
+\begin{BVerbatim}[baseline=c,boxwidth=11cm]
+$\begin{pNiceMatrix}[name=~emphase#ma-matrice@]
+1 & 2 & 3 \\
+4 & 5 & 6 \\
+7 & 8 & 9
+\end{pNiceMatrix}$
+\tikz[remember picture,overlay]
+ \draw ~emphase#(ma-matrice-2-2)@ circle (2mm) ;
+\end{BVerbatim}
+$\begin{pNiceMatrix}[name=ma-matrice]
+1 & 2 & 3 \\
+4 & 5 & 6 \\
+7 & 8 & 9
+\end{pNiceMatrix}$
+\tikz[remember picture,overlay]
+ \draw (ma-matrice-2-2) circle (2mm) ;
\medskip
-\begin{BVerbatim}[baseline=c,boxwidth=11.5cm]
-$\begin{NiceArray}{CCCC}[vlines] \hline
-a & b & c & d \\ \hline \hline
-1 & 2 & 3 & 4 \\
-1 & 2 & 3 & 4 \\ \hline
-\end{NiceArray}$
-\end{BVerbatim}
-%
-$\begin{NiceArray}{CCCC}[vlines]
-\hline
-a & b & c & d \\
-\hline \hline
-1 & 2 & 3 & 4 \\
-1 & 2 & 3 & 4 \\
-\hline
-\end{NiceArray}$
+Ne pas oublier les options |remember picture| et |overlay|.
+
\bigskip
-Dans le cas d'un environnement avec délimiteurs (par exemple |{pNiceArray}| ou |{pNiceMatrix}|), l'option |vlines| ne
-trace pas de filets verticaux au niveau des deux délimiteurs (bien entendu).
+Dans le |code-after|, et si Tikz est chargé, les choses sont plus simples. On peut (et on doit) désigner les nœuds
+sous la forme $i$-$j$ : il n'y a pas besoin de préciser l'environnement qui est évidemment l'environnement courant.
+
\medskip
-\begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
-\setlength{\arrayrulewidth}{0.2pt}
-$\begin{pNiceMatrix}[vlines]
-1 & 2 & 3 & 4 & 5 & 6 \\
-1 & 2 & 3 & 4 & 5 & 6 \\
-1 & 2 & 3 & 4 & 5 & 6 \\
+\begin{BVerbatim}[baseline=c,boxwidth=11cm]
+$\begin{pNiceMatrix}
+1 & 2 & 3 \\
+4 & 5 & 6 \\
+7 & 8 & 9
+\CodeAfter
+\tikz \draw ~emphase#(2-2)@ circle (2mm) ;
\end{pNiceMatrix}$
\end{BVerbatim}
-%
-\begin{scope}
-\setlength{\arrayrulewidth}{0.2pt}
-$\begin{pNiceMatrix}[vlines]
-1 & 2 & 3 & 4 & 5 & 6 \\
-1 & 2 & 3 & 4 & 5 & 6 \\
-1 & 2 & 3 & 4 & 5 & 6 \\
+$\begin{pNiceMatrix}
+1 & 2 & 3 \\
+4 & 5 & 6 \\
+7 & 8 & 9
+\CodeAfter
+\tikz \draw (2-2) circle (2mm) ;
\end{pNiceMatrix}$
-\end{scope}
+\bigskip
+Dans l'exemple suivant, nous avons surligné tous nœuds de la matrice (on explique plus loin la technique utilisée :
+cf. p. \pageref{highlight}).
-\subsection{L'option light-syntax}
+\[\begin{pNiceMatrix}
+a & a + b & a + b + c \\
+a & a & a + b \\
+a & a & a
+\CodeAfter
+\begin{tikzpicture}[
+ every node/.style =
+ {
+ blend mode = multiply,
+ inner sep = 0 pt ,
+ fill = red!15
+ }
+ ]
+\node [fit = (1-1)] {} ;
+\node [fit = (1-3)] {} ;
+\node [fit = (2-2)] {} ;
+\node [fit = (3-1)] {} ;
+\node [fit = (3-3)] {} ;
+\node [fit = (1-2)] {} ;
+\node [fit = (2-1)] {} ;
+\node [fit = (2-3)] {} ;
+\node [fit = (3-2)] {} ;
+\end{tikzpicture}
+\end{pNiceMatrix}\]
-\label{light-syntax}
-L'option |light-syntax|\footnote{Cette option est inspirée de l'extension \pkg{spalign} de Joseph Rabinoff.} permet
-d'alléger la saisie des matrices, ainsi que leur lisibilité dans le source TeX. Lorsque cette option est activée,
-on doit utiliser le point-virgule comme marqueur de fin de rangée et séparer les colonnes par des espaces ou des
-tabulations. On remarquera toutefois que, comme souvent dans le monde TeX, les espaces après les séquences de
-contrôle ne sont pas comptées et que les éléments entre accolades sont considérés comme un tout.
+\subsection{Les «nœuds moyens» et les «nœuds larges»}
+En fait, l'extension \pkg{nicematrix} peut créer deux séries de nœuds supplémentaires (\emph{extra nodes} en
+anglais) : les «nœuds moyens» (\emph{medium nodes} en anglais) et les «nœuds larges» (\emph{large nodes} en
+anglais). Les premiers sont créés avec l'option |create-medium-nodes| et les seconds avec l'option
+|create-large-nodes|.\footnote{Il existe aussi l'option |create-extra-nodes| qui est un alias pour la conjonction
+de |create-medium-nodes| et |create-large-nodes|.}
+
\medskip
-\begin{scope}
-\begin{BVerbatim}[baseline=c,boxwidth=10cm]
-$\begin{bNiceMatrix}[~emphase#light-syntax@,first-row,first-col]
-{} a b ;
-a 2\cos a {\cos a + \cos b} ;
-b \cos a+\cos b { 2 \cos b }
-\end{bNiceMatrix}$
-\end{BVerbatim}
-\end{scope}
-%
-$\begin{bNiceMatrix}[light-syntax,first-row,first-col]
-{} a b ;
-a 2\cos a {\cos a + \cos b} ;
-b \cos a+\cos b { 2 \cos b }
-\end{bNiceMatrix}$
+Ces nœuds ne sont pas utilisés par défault par \pkg{nicematrix}.
\medskip
-On peut changer le caractère utilisé pour indiquer les fins de rangées avec l'option |end-of-row|. Comme dit
-précédemment, la valeur initiale de ce paramètre est un point-virgule.
+Les noms des «nœuds moyens» s'obtiennent en ajoutant le suffixe «|-medium|» au nom des nœuds normaux. Dans
+l'exemple suivant, on a surligné tous les «nœuds moyens». Nous considérons que cet exemple se suffit à lui-même
+comme définition de ces nœuds.
+\[\begin{pNiceMatrix}[
+ create-medium-nodes,
+ code-after = {\begin{tikzpicture}
+ [every node/.style = {fill = red!15,
+ blend mode = multiply,
+ inner sep = 0 pt},
+ name suffix = -medium]
+ \node [fit = (1-1)] {} ;
+ \node [fit = (1-2)] {} ;
+ \node [fit = (1-3)] {} ;
+ \node [fit = (2-1)] {} ;
+ \node [fit = (2-2)] {} ;
+ \node [fit = (2-3)] {} ;
+ \node [fit = (3-1)] {} ;
+ \node [fit = (3-2)] {} ;
+ \node [fit = (3-3)] {} ;
+ \end{tikzpicture}}]
+a & a + b & a + b + c \\
+a & a & a + b \\
+a & a & a
+\end{pNiceMatrix}\]
+
\medskip
-Lorsque l'option |light-syntax| est utilisée, il n'est pas possible de mettre d'éléments en verbatim (avec par
-exemple la commande |\verb|) dans les cases du tableau.\footnote{La raison en est que lorsque l'option
- |light-syntax| est utilisée, le contenu complet de l'environnement est chargé comme un argument de commande TeX.
- L'environnement ne se comporte plus comme un «vrai» environnement de LaTeX qui se contente d'insérer des
- commandes avant et après.}
+Les noms des «nœuds larges» s'obtiennent en ajoutant le suffixe «|-large|» au nom des nœuds normaux. Dans l'exemple
+suivant, on a surligné tous les «nœuds larges». Nous considérons que cet exemple se suffit à lui-même comme
+définition de ces nœuds.\footnote{Il n'y a pas de «nœuds larges» créés dans les rangées et colonnes extérieures
+ (pour ces rangées et colonnes, voir p.~\pageref{exterior}).}
-\subsection{Utilisation du type de colonne S de siunitx}
+\[\begin{pNiceMatrix}[
+ create-large-nodes,
+ code-after = {\begin{tikzpicture}
+ [every node/.style = {blend mode = multiply,
+ inner sep = 0 pt},
+ name suffix = -large]
+ \node [fit = (1-1),fill = red!15] {} ;
+ \node [fit = (1-3),fill = red!15] {} ;
+ \node [fit = (2-2),fill = red!15] {} ;
+ \node [fit = (3-1),fill = red!15] {} ;
+ \node [fit = (3-3),fill = red!15] {} ;
+ \node [fit = (1-2),fill = blue!15] {} ;
+ \node [fit = (2-1),fill = blue!15] {} ;
+ \node [fit = (2-3),fill = blue!15] {} ;
+ \node [fit = (3-2),fill = blue!15] {} ;
+ \end{tikzpicture}}]
+a & a + b & a + b + c \\
+a & a & a + b \\
+a & a & a
+\end{pNiceMatrix}\]
-Si l'extension \pkg{siunitx} est chargée (avant ou après \pkg{nicematrix}), il est possible d'utiliser les colonnes
-de type |S| de \pkg{siunitx} dans les environnements de \pkg{nicematrix}. L'implémentation n'utilise explicitement
-aucune macro privée de \pkg{siunitx}.
\medskip
-\begin{BVerbatim}[baseline = c, boxwidth = 10.5cm]
-$\begin{pNiceArray}{~emphase#S@CWc{1cm}C}[nullify-dots,first-row]
-{C_1} & \Cdots & & C_n \\
-2.3 & 0 & \Cdots & 0 \\
-12.4 & \Vdots & & \Vdots \\
-1.45 \\
-7.2 & 0 & \Cdots & 0
-\end{pNiceArray}$
-\end{BVerbatim}
-$\begin{pNiceArray}{SCWc{1cm}C}[nullify-dots,first-row]
-{C_1} & \Cdots & & C_n \\
-2.3 & 0 & \Cdots & 0 \\
-12.4 & \Vdots & & \Vdots \\
-1.45 \\
-7.2 & 0 & \Cdots & 0
-\end{pNiceArray}$
+Les «nœuds larges» de la première colonne et de la dernière colonne peuvent apparaître trop petits pour certains
+usages. C'est pourquoi il est possible d'utiliser les options |left-margin| et |right-margin| pour ajouter de
+l'espace des deux côtés du tableau et aussi de l'espace dans les «nœuds larges» de la première colonne et de la
+dernière colonne. Dans l'exemple suivant, nous avons utilisé les options |left-margin| et
+|right-margin|.\footnote{Les options |left-margin| et |right-margin| prennent des dimensions comme valeurs mais, si
+ aucune valeur n'est donnée, c'est la valeur par défaut qui est utilisée et elle est égale à |\arraycolsep| (par
+ défaut, 5~pt). Il existe aussi une option |margin| pour fixer à la fois |left-margin| et |right-margin|.}
+\[\begin{pNiceMatrix}[
+ create-large-nodes,left-margin,right-margin,
+ code-after = {\begin{tikzpicture}
+ [every node/.style = {blend mode = multiply,
+ inner sep = 0 pt},
+ name suffix = -large]
+ \node [fit = (1-1),fill = red!15] {} ;
+ \node [fit = (1-3),fill = red!15] {} ;
+ \node [fit = (2-2),fill = red!15] {} ;
+ \node [fit = (3-1),fill = red!15] {} ;
+ \node [fit = (3-3),fill = red!15] {} ;
+ \node [fit = (1-2),fill = blue!15] {} ;
+ \node [fit = (2-1),fill = blue!15] {} ;
+ \node [fit = (2-3),fill = blue!15] {} ;
+ \node [fit = (3-2),fill = blue!15] {} ;
+ \end{tikzpicture}}]
+a & a + b & a + b + c \\
+a & a & a + b \\
+a & a & a
+\end{pNiceMatrix}\]
\medskip
-En revanche, les colonnes |d| de l'extension \pkg{dcolumn} ne sont pas prises en charge par \pkg{nicematrix}.
+Il est aussi possible d'ajouter de l'espace sur les côtés du tableau avec les options |extra-left-margin| et
+|extra-right-margin|. Ces marges ne sont pas incorporées dans les «nœuds larges». Dans l'exemple suivant, nous
+avons utilisé |extra-left-margin| et |extra-right-margin| avec la valeur $3$~pt.
+\[\begin{pNiceMatrix}[
+ create-large-nodes,left-margin,right-margin,extra-right-margin=3pt,extra-left-margin=3pt,
+ code-after = {\begin{tikzpicture}
+ [every node/.style = {blend mode = multiply,
+ inner sep = 0 pt},
+ name suffix = -large]
+ \node [fit = (1-1),fill = red!15] {} ;
+ \node [fit = (1-3),fill = red!15] {} ;
+ \node [fit = (2-2),fill = red!15] {} ;
+ \node [fit = (3-1),fill = red!15] {} ;
+ \node [fit = (3-3),fill = red!15] {} ;
+ \node [fit = (1-2),fill = blue!15] {} ;
+ \node [fit = (2-1),fill = blue!15] {} ;
+ \node [fit = (2-3),fill = blue!15] {} ;
+ \node [fit = (3-2),fill = blue!15] {} ;
+ \end{tikzpicture}}]
+a & a + b & a + b + c \\
+a & a & a + b \\
+a & a & a
+\end{pNiceMatrix}\]
+
+
+\bigskip
+\textbf{Attention} : Ces nœuds sont reconstruits à partir des contenus des cases et ne correspondent donc pas
+nécessairement aux cases délimitées par des filets.
+
+\bigskip
+\begin{minipage}[c]{7.5cm}
+Voici un tableau qui a été composé de la manière suivante :
+
+\medskip
+\begin{BVerbatim}
+\large
+\begin{NiceTabular}{wl{2cm}LL}[hvlines]
+fraise & amande & abricot \\
+prune & pêche & poire \\[1ex]
+noix & noisette & brugnon
+\end{NiceTabular}
+\end{BVerbatim}
+\end{minipage}
+\hspace{1cm}
+\begin{scope}
+\large
+\begin{NiceTabular}[c]{wl{2cm}LL}[hvlines]
+fraise & amande & abricot \\
+prune & pêche & poire \\[1ex]
+noix & noisette & brugnon
+\end{NiceTabular}
+\end{scope}
+
+\vspace{1cm}
+\begin{minipage}[c]{7cm}
+Ci-contre, on a colorié toutes les cases de ce tableau avec |\chessboardcolors|.
+\end{minipage}
+\hspace{1.5cm}
+\begin{scope}
+\large
+\begin{NiceTabular}[c]{wl{2cm}LL}[hvlines,code-before = \chessboardcolors{red!15}{blue!15}]
+fraise & amande & abricot \\
+prune & pêche & poire \\[1ex]
+noix & noisette & brugnon
+\end{NiceTabular}
+\end{scope}
+
+
+\vspace{1cm}
+\begin{minipage}[c]{7cm}
+Voici maintenant tous les «nœuds larges» de ce tableau (sans utilisation de |margin| ni de |extra-margin|).
+\end{minipage}
+\hspace{1.5cm}
+\begin{scope}
+\large
+\begin{NiceTabular}[c]{wl{2cm}LL}[hvlines,
+ create-large-nodes,
+ code-after = {\begin{tikzpicture}
+ [every node/.style = {blend mode = multiply,
+ inner sep = 0 pt},
+ name suffix = -large]
+ \node [fit = (1-1),fill = red!15] {} ;
+ \node [fit = (1-3),fill = red!15] {} ;
+ \node [fit = (2-2),fill = red!15] {} ;
+ \node [fit = (3-1),fill = red!15] {} ;
+ \node [fit = (3-3),fill = red!15] {} ;
+ \node [fit = (1-2),fill = blue!15] {} ;
+ \node [fit = (2-1),fill = blue!15] {} ;
+ \node [fit = (2-3),fill = blue!15] {} ;
+ \node [fit = (3-2),fill = blue!15] {} ;
+ \end{tikzpicture}}]
+fraise & amande & abricot \\
+prune & pêche & poire \\[1ex]
+noix & noisette & brugnon
+\end{NiceTabular}
+\end{scope}
+
+
+
+
+
+
+\subsection{Les nœuds «row» et «col»}
+
+L'extension \pkg{nicematrix} crée un nœud PGF-Tikz indiquant la position potentielle de chaque filet horizontal
+(avec les noms |row-|$i$) et de chaque filet vertical (avec les noms |col-|$j$), comme décrit sur la figure
+ci-dessous. Ces nœuds sont accessibles dans le |code-before| et dans le |code-after|.
+\begin{center}
+\begin{NiceTabular}{CCC}[hvlines,rules/width=1pt,rules/color=gray]
+rose & tulipe & lys \\
+arum & iris & violette \\
+muguet & dahlia & souci
+\CodeAfter
+\tiny
+\begin{tikzpicture}
+\foreach \i in {1,2,3,4}
+ {
+ \fill [red] (row-\i) circle (0.5mm) ;
+ \node [red,anchor=east] at (row-\i) {row-\i} ;
+ }
+\foreach \j in {1,2,3,4}
+ {
+ \fill [blue] (col-\j) circle (0.5mm) ;
+ \node [blue,anchor=north] at (col-\j) {col-\j} ;
+ }
+\end{tikzpicture}
+\end{NiceTabular}
+\end{center}
+
+
+\bigskip
+Si on utilise Tikz (on rappelle que \pkg{nicematrix} ne charge pas Tikz par défaut), on peut donc accéder (dans le
+|code-before| et le |code-after|) à l'intersection du filet horizontal~$i$ et du filet vertical~$j$ avec la syntaxe
+|(row-|$i$\verb+-|col-+$j$|)|.
+
+
+\medskip
+\begin{Verbatim}
+\[\begin{NiceMatrix}[
+ code-before =
+ {
+~emphase# \tikz \draw [fill = red!15] @
+~emphase# (row-7-|col-4) -- (row-8-|col-4) -- (row-8-|col-5) -- @
+~emphase# (row-9-|col-5) -- (row-9-|col-6) |- cycle ; @
+ }
+]
+1 \\
+1 & 1 \\
+1 & 2 & 1 \\
+1 & 3 & 3 & 1 \\
+1 & 4 & 6 & 4 & 1 \\
+1 & 5 & 10 & 10 & 5 & 1 \\
+1 & 6 & 15 & 20 & 15 & 6 & 1 \\
+1 & 7 & 21 & 35 & 35 & 21 & 7 & 1 \\
+1 & 8 & 28 & 56 & 70 & 56 & 28 & 8 & 1
+\end{NiceMatrix}\]
+\end{Verbatim}
+%
+\[\begin{NiceMatrix}[
+ code-before =
+ {
+ \tikz \draw [fill = red!15]
+ (row-7-|col-4) -- (row-8-|col-4) -- (row-8-|col-5) --
+ (row-9-|col-5) -- (row-9-|col-6) |- cycle ;
+ }
+]
+1 \\
+1 & 1 \\
+1 & 2 & 1 \\
+1 & 3 & 3 & 1 \\
+1 & 4 & 6 & 4 & 1 \\
+1 & 5 & 10 & 10 & 5 & 1 \\
+1 & 6 & 15 & 20 & 15 & 6 & 1 \\
+1 & 7 & 21 & 35 & 35 & 21 & 7 & 1 \\
+1 & 8 & 28 & 56 & 70 & 56 & 28 & 8 & 1
+\end{NiceMatrix}\]
+
+
\section{Remarques techniques}
Première remarque : l'extension \pkg{nicematrix} doit être chargée après l'extension \pkg{underscore}. Si ce n'est
@@ -2040,26 +2399,13 @@ C_1 & C_2 & C_3 & C_4
\end{scope}
\medskip
-Le spécificateur |?| ainsi créé est aussi utilisable dans les environnements |{array}| (de \pkg{array}) et, dans ce
-cas, |\OnlyMainNiceMatrix| est sans effet.
-
+Le spécificateur |?| ainsi créé est aussi utilisable dans les environnements |{tabular}| et |{array}| (de
+\pkg{array}) et, dans ce cas, |\OnlyMainNiceMatrix| est sans effet.
-\subsection{Le nom des nœuds PGF créés par nicematrix}
-Les nœuds PGF-Tikz créés par \pkg{nicematrix} peuvent être utilisés hors des environnements de \pkg{nicematrix}
-après avoir nommé l'environnement concerné avec l'option |name| (cf. p.~\pageref{name}). Il s'agit là de la méthode
-conseillée mais on décrit néanmoins maintenant le nom Tikz interne de ces nœuds.
-
-Les environnements créés par \pkg{nicematrix} sont numérotés par un compteur global interne. La commande
-|\NiceMatrixLastEnv| donne le numéro du dernier de ces environnements (pour LaTeX, il s'agit d'une commande —
-complètement développable — et non d'un compteur).
-
-Si l'environnement concerné a le numéro $n$, alors le nœud de la rangée~$i$ et de la colonne~$j$ a pour nom
-|nm-|$n$|-|$i$|-|$j$. Les noms des nœuds |medium| et |large| correspondants s'obtiennent en suffixant par |-medium|
-et |-large|.
\subsection{Lignes diagonales}
@@ -2185,91 +2531,14 @@ Avec cette option, des espaces extérieurs de longueur |\arraycolsep| seront ins
-\subsection{Un problème technique avec l'argument de \textbackslash\textbackslash}
-
-Pour des raisons techniques, si vous utilisez l'argument optionnel de la commande |\\|, l'espace vertical sera
-aussi ajouté au nœud («normal») correspondant à la case précédente.
+\subsection{Incompatibilités}
+L'extension \pkg{nicematrix} n'est pas compatible with \pkg{threeparttable}.
\medskip
-\begin{BVerbatim}[baseline=c,boxwidth=11cm]
- \begin{pNiceMatrix}
- a & \frac AB \\~emphase#[2mm]@
- b & c
- \end{pNiceMatrix}
-\end{BVerbatim}
-$\begin{pNiceMatrix}[
- code-after = {\tikz \node [inner sep = 0pt,
- fill = red!15,
- blend mode = multiply,
- fit = (1-2) ] {} ; } ]
-a & \frac AB \\[2mm]
-b & c
-\end{pNiceMatrix}$
-
-\bigskip
-Il y a deux solutions pour résoudre ce problème. La première solution est d'utiliser une commande TeX pour insérer
-l'espace entre les deux rangées.
-
-\medskip
-\begin{BVerbatim}[baseline=c,boxwidth=11cm]
- \begin{pNiceMatrix}
- a & \frac AB \\
- ~emphase#\noalign{\kern2mm}@
- b & c
- \end{pNiceMatrix}
-\end{BVerbatim}
-$\begin{pNiceMatrix}[
- code-after = {\tikz \node [inner sep = 0pt,
- fill = red!15,
- blend mode = multiply,
- fit = (1-2) ] {} ; } ]
-a & \frac AB \\
-\noalign{\kern2mm}
-b & c
-\end{pNiceMatrix}$
-
-
-\bigskip
-L'autre solution est d'utiliser la commande |\multicolumn| dans la case précédente :
-
-\medskip
-\begin{BVerbatim}[baseline=c,boxwidth=11cm]
- \begin{pNiceMatrix}
- a & ~emphase#\multicolumn1C{\frac AB}@ \\[2mm]
- b & c
- \end{pNiceMatrix}
-\end{BVerbatim}
-$\begin{pNiceMatrix}[
- code-after = {\tikz \node [inner sep = 0pt,
- fill = red!15,
- blend mode = multiply,
- fit = (1-2) ] {} ; } ]
-a & \multicolumn1C{\frac AB} \\[2mm]
-b & c
-\end{pNiceMatrix}$
-
-\subsection{Environnements obsolètes}
-
-La version 3.0 de \pkg{nicematrix} a introduit l'environnement |{pNiceArray}| (et ses variantes) avec les options
-|first-row|, |last-row|, |first-col| et |last-col|.
-
-Par conséquent, les environnements suivants, présents dans les versions précédentes de \pkg{nicematrix} ont été
-supprimés.
-%
-\begin{itemize}
-\item |{NiceArrayCwithDelims}| ;
-\item |{pNiceArrayC}|, |{bNiceArrayC}|, |{BNiceArrayC}|, |{vNiceArrayC}|,
-|{VNiceArrayC}| ;
-\item |{NiceArrayRCwithDelims}| ;
-\item |{pNiceArrayRC}|, |{bNiceArrayRC}|, |{BNiceArrayRC}|, |{vNiceArrayRC}|,
-|{VNiceArrayRC}|.
-\end{itemize}
-
-Le code correspondant est toutefois encore présent à la fin du fichier |nicematrix.sty|, après une
-commande |\file_input_stop:|.
-
+L'extension \pkg{nicematrix} n'est pas parfaitement compatible avec l'extension \pkg{arydshln} (parce que cette
+extension redéfinit de nombreuses commandes internes de \pkg{array}).
\section{Exemples}
@@ -2402,11 +2671,9 @@ a_p & &&a_0 & & &b_1 \\
\end{scope}
\vspace{2cm}
-Un exemple avec un système linéaire (le trait vertical a été tracé en bleu avec les outils de
-\pkg{colortbl}):\par\nobreak
+Un exemple avec un système linéaire:\par\nobreak
\begin{Verbatim}
-\arrayrulecolor{blue}
$\begin{pNiceArray}{*6C|C}[nullify-dots,last-col,code-for-last-col=\scriptstyle]
1 & 1 & 1 &\Cdots & & 1 & 0 & \\
0 & 1 & 0 &\Cdots & & 0 & & L_2 \gets L_2-L_1 \\
@@ -2415,10 +2682,9 @@ $\begin{pNiceArray}{*6C|C}[nullify-dots,last-col,code-for-last-col=\scriptstyle]
\Vdots & & &\Ddots & & 0 & \\
0 & & &\Cdots & 0 & 1 & 0 & L_n \gets L_n-L_1
\end{pNiceArray}$
-\arrayrulecolor{black}
\end{Verbatim}
-\arrayrulecolor{blue}
+
\[\begin{pNiceArray}{*6C|C}[nullify-dots,last-col,code-for-last-col=\scriptstyle]
1 & 1 & 1 &\Cdots & & 1 & 0 & \\
0 & 1 & 0 &\Cdots & & 0 & & L_2 \gets L_2-L_1 \\
@@ -2427,7 +2693,7 @@ $\begin{pNiceArray}{*6C|C}[nullify-dots,last-col,code-for-last-col=\scriptstyle]
\Vdots & & &\Ddots & & 0 & \\
0 & & &\Cdots & 0 & 1 & 0 & L_n \gets L_n-L_1
\end{pNiceArray}\]
-\arrayrulecolor{black}
+
\subsection{Des lignes pointillées qui ne sont plus pointillées}
@@ -2617,19 +2883,16 @@ a_{41} & a_{42} & a_{43} & a_{44}
On remarquera que les traits que l'on vient de tracer sont dessinés \emph{après} la matrice sans modifier la
position des composantes de celle-ci. En revanche, les traits tracés par |\hline|, le spécificateur «\verb+|+» ou
-les options |hlines| et |vlines| «écartent» les composantes de la matrice (quand l'extension \pkg{array} est
-chargée, ce qui est toujours le cas avec \pkg{nicematrix}).\footnote{En revanche les traits tracés par |\ncline|
- n'écartent pas les lignes de la matrice.}
+les options |hlines|, |vlines| et |hvlines| «écartent» les composantes de la matrice.\footnote{Pour la commande
+ |\cline|, voir la remarque p.~\pageref{remark-cline}.}
\vspace{1cm}
-
-L'extension \pkg{nicematrix} est construite au-dessus de l'environnement |{array}| et, par conséquent, il est
-possible d'utiliser l'extension \pkg{colortbl} dans les environnements de \pkg{nicematrix}. Les possibilités de
-réglage de \pkg{colortbl} sont néanmoins assez limitées. C'est pourquoi nous proposons une autre méthode pour
-surligner une rangée de la matrice. Nous créons un nœud Tikz rectangulaire qui englobe les nœuds de la deuxième
-rangée en utilisant les outils de la bibliothèque Tikz \pkg{fit}. Ce nœud est rempli après la construction de la
-matrice. Pour que l'on puisse voir le texte \emph{sous} le nœud, nous devons utiliser la transparence avec le
-|blend mode| égal à |multiply|.
+Il est possible de colorier une rangée avec |\rowcolor| dans le |code-before| (ou avec |\rowcolor| de
+\pkg{colortbl} dans la première case de la rangée ). Les possibilités de réglages sont néanmoins limitées. C'est
+pourquoi nous présentons ici une autre méthode pour surligner une rangée de la matrice. Nous créons un nœud Tikz
+rectangulaire qui englobe les nœuds de la deuxième rangée en utilisant les outils de la bibliothèque Tikz
+\pkg{fit}. Ce nœud est rempli après la construction de la matrice. Pour que l'on puisse voir le texte \emph{sous}
+le nœud, nous devons utiliser la transparence avec le |blend mode| égal à |multiply|.
\tikzset{highlight/.style={rectangle,
@@ -2941,3 +3204,8 @@ documentation ici présente, ainsi que le code source commenté et un historique
\end{document}
+
+
+
+
+
diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf
index 8f7fb6b647e..0004ec61cd3 100644
--- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf
+++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx
index a78a94ee50c..7e220667699 100644
--- a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx
+++ b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx
@@ -15,8 +15,8 @@
%
% \fi
% \iffalse
-\def\myfileversion{4.0}
-\def\myfiledate{2020/05/08}
+\def\myfileversion{4.1}
+\def\myfiledate{2020/05/27}
%
%
%<*batchfile>
@@ -123,38 +123,12 @@ version 2005/12/01 or later.
%
% \begin{abstract}
% The LaTeX package \pkg{nicematrix} provides new environments similar to the
-% classical environments |{tabular}|, |{array}| and |{matrix}| but with some
-% additional features. Among these features are the possibilities to fix the
-% width of the columns and to draw continuous ellipsis dots between the cells of
-% the array.
+% classical environments |{tabular}|, |{array}| and |{matrix}| of \pkg{array}
+% and \pkg{amsmath} but with extended features.
% \end{abstract}
%
% \vspace{1cm}
-% \section{Presentation}
-%
-%
-% This package can be used with |xelatex|, |lualatex|, |pdflatex| but also by
-% the classical workflow |latex|-|dvips|-|ps2pdf| (or Adobe Distiller). Two or
-% three compilations may be necessary. This package requires and \textbf{loads}
-% the packages \pkg{l3keys2e}, \pkg{xparse}, \pkg{array}, \pkg{amsmath},
-% \pkg{pgfcore} and the module \pkg{shapes} of \textsc{pgf} (\pkg{tikz} is
-% \emph{not} loaded). The final user only has to load the package with
-% |\usepackage{nicematrix}|.
-%
-%
-% \medskip
-% \begin{savenotes}
-% \begin{minipage}{0.6\linewidth}
-% This package provides some new tools to draw mathematical matrices. The main
-% features are the following:
-% \begin{itemize}\setlength{\itemsep}{0pt}
-% \item continuous dotted lines;
-% \item exterior rows and columns for labels;
-% \item a control of the width of the columns.
-% \end{itemize}
-% \end{minipage}
-% \end{savenotes}
-% \hspace{1.4cm}
+% \hspace{1cm}
% $\begin{bNiceArray}{CCCC}[first-row,first-col,
% code-for-first-col=\color{blue}\scriptstyle,
% code-for-first-row=\color{blue}\scriptstyle,
@@ -164,98 +138,1155 @@ version 2005/12/01 or later.
% L_2 & a_{21} & a_{22} & \Cdots & a_{2n} \\
% \Vdots & \Vdots & \Vdots & \Ddots & \Vdots\\
% L_n & a_{n1} & a_{n2} & \Cdots & a_{nn}
-% \end{bNiceArray}$
+% \end{bNiceArray}$\hspace{2cm}
+% \begin{NiceTabular}{LSSSS}[code-before = \rowcolor{red!15}{1-2} \rowcolors{3}{blue!15}{}]
+% \toprule
+% \Block{2-1}{Product} & \multicolumn{3}{C}{dimensions (cm)} & \Block{2-1}{\rotate Price} \\
+% \cmidrule(rl){2-4}
+% & L & l & h \\
+% \midrule
+% small & 3 & 5.5 & 1 & 30 \\
+% standard & 5.5 & 8 & 1.5 & 50.5 \\
+% premium & 8.5 & 10.5 & 2 & 80 \\
+% extra & 8.5 & 10 & 1.5 & 85.5 \\
+% special & 12 & 12 & 0.5 & 70 \\
+% \bottomrule
+% \end{NiceTabular}
+%
+% \vspace{1cm}
+% The package \pkg{nicematrix} is entirely contained in the file
+% |nicematrix.sty|. This file may be put in the current directory or in a
+% |texmf| tree. However, the best is to install \pkg{nicematrix} with a TeX
+% distribution as MiKTeX or TeXlive.
+%
+% \bigskip
+% This package can be used with |xelatex|, |lualatex|, |pdflatex| but also by
+% the classical workflow |latex|-|dvips|-|ps2pdf| (or Adobe Distiller).
+%
+% \bigskip
+% This package requires and \textbf{loads} the packages \pkg{l3keys2e},
+% \pkg{xparse}, \pkg{array}, \pkg{amsmath}, \pkg{pgfcore} and the module
+% \pkg{shapes} of \textsc{pgf} (\pkg{tikz}, which is a layer over \textsc{pgf}
+% is \emph{not} loaded). The final user only has to load the package with
+% |\usepackage{nicematrix}|.
+%
+%
+% \bigskip
+% The idea of \pkg{nicematrix} is to create \textsc{pgf} nodes under the cells
+% and the positions of the rules of the tabular created by \pkg{array} and to
+% use these nodes to develop new features. As usual with \textsc{pgf}, the
+% coordinates of these nodes are written in the |.aux| to be used on the next
+% compilation and that's why \pkg{nicematrix} may need \textbf{several
+% compilations}.
%
-% \medskip
+% \bigskip
+% Most features of \pkg{nicematrix} may be used without explicit use of
+% \textsc{pgf} or Tikz (which, in fact, is not loaded by default).
+%
+% \bigskip
% A command |\NiceMatrixOptions| is provided to fix the options (the
-% scope of the options fixed by this command is the current TeX group).
+% scope of the options fixed by this command is the current TeX group: they are
+% semi-global).
+%
%
+% \newpage
+%
+% \section{The environments of this package}
+%
+% The package \pkg{nicematrix} defines the following new environments.
+%
+% \medskip
+% \begin{ttfamily}
+% \setlength{\tabcolsep}{3mm}
+% \begin{tabular}{llll}
+% \{NiceTabular\} & \{NiceArray\} & \{NiceMatrix\} \\
+% & \{pNiceArray\} & \{pNiceMatrix\} \\
+% & \{bNiceArray\} & \{bNiceMatrix\} \\
+% & \{BNiceArray\} & \{BNiceMatrix\} \\
+% & \{vNiceArray\} & \{vNiceMatrix\} \\
+% & \{VNiceArray\} & \{VNiceMatrix\}
+% \end{tabular}
+% \end{ttfamily}
+%
+%
+%
+%
+% \medskip
+% The environments |{NiceArray}| and |{NiceTabular}| are similar to the
+% environments |{array}| and |{tabular}| of the package \pkg{array} (which is
+% loaded by \pkg{nicematrix} ).
+%
+% \medskip
+% However, there are some small differences:
+% \begin{itemize}
+% \item For technical reasons, in the preamble of these environments, the user
+% must use the letters |L|, |C| and~|R|\footnote{The column types |L|, |C| and
+% |R| are defined locally inside |{NiceTabular}| or |{NiceArray}| with
+% |\newcolumntype| of \pkg{array}. This definition overrides an eventual
+% previous definition.} instead of |l|, |c| and |r|, included in the commands
+% |\multicolumn| and in the types of columns defined by |\newcolumntype|.
+%
+% * In |{NiceArray}| (and its variants), the columns of type |w| (ex. :
+% |wc{1cm}|) are composed in math mode whereas, in |{array}| of \pkg{array},
+% they are composed in text mode.
+% \end{itemize}
+%
+% \medskip
+% The environments |{pNiceArray}|, |{bNiceArray}|, etc. have no equivalent in
+% \pkg{array}.
+%
+% \medskip
+% The environments |{NiceMatrix}|, |{pNiceMatrix}|, etc. are similar to the
+% corresponding environments of \pkg{amsmath} (which is loaded by
+% \pkg{nicematrix}): |{matrix}|, |{pmatrix}|, etc.
+%
+% \medskip
+% All the environments of the package \pkg{nicematrix} accept, between square
+% brackets, an optional list of \textsl{key=value} pairs. \textbf{There must be
+% no space before the opening bracket (|[|) of this list of options.}
+%
+% \section{The vertical space between the rows}
+%
+% It's well known that some rows of the arrays created by default with LaTeX
+% are, by default, too close to each other. Here is a classical example.
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
+% $\begin{pmatrix}
+% \frac12 & -\frac12 \\
+% \frac13 & \frac14 \\
+% \end{pmatrix}$
+% \end{BVerbatim}
+% $\begin{pmatrix}
+% \frac12 & -\frac12 \\
+% \frac13 & \frac14 \\
+% \end{pmatrix}$
%
% \bigskip
-% \textbf{An example for the continuous dotted lines}
+% Inspired by the package \pkg{cellspace} which deals with that problem, the
+% package \pkg{nicematrix} provides two keys |cell-space-top-limit| and
+% |cell-space-bottom-limit| similar to the parameters |\cellspacetoplimit| and
+% |\cellspacebottomlimit| of \pkg{cellspace}. The initial value of these
+% parameters is $0$~pt in order to have for the environments of \pkg{nicematrix}
+% the same behaviour as those of \pkg{array} and \pkg{amsmath}. However, a value
+% of $1$~pt would probably be a good choice and we suggest to set them with
+% |\NiceMatrixOptions|.
%
% \medskip
-% \begin{minipage}{10cm}
-% For example, consider the following code which uses an environment |{pmatrix}|
-% of \pkg{amsmath}.
+% \begin{Verbatim}
+% \NiceMatrixOptions{~emphase#cell-space-top-limit = 1pt,cell-space-bottom-limit = 1pt@}
+% \end{Verbatim}
%
+% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
+% $\begin{pNiceMatrix}
+% \frac12 & -\frac12 \\
+% \frac13 & \frac14 \\
+% \end{pNiceMatrix}$
+% \end{BVerbatim}
+% \begin{scope}
+% \NiceMatrixOptions{
+% cell-space-top-limit = 1pt ,
+% cell-space-bottom-limit = 1pt ,
+% }
+% $\begin{pNiceMatrix}
+% \frac12 & -\frac12 \\
+% \frac13 & \frac14 \\
+% \end{pNiceMatrix}$
+% \end{scope}
+%
+%
+%
+%
+%
+% \bigskip
+% \section{The vertical position of the arrays}
+%
+% The package \pkg{nicematrix} provides a option |baseline| for the vertical
+% position of the arrays. This option takes as value an integer which is the
+% number of the row on which the array will be aligned.
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
+% $A = \begin{pNiceMatrix}[~emphase#baseline=2@]
+% \frac{1}{\sqrt{1+p^2}} & p & 1-p \\
+% 1 & 1 & 1 \\
+% 1 & p & 1+p
+% \end{pNiceMatrix}$
+% \end{BVerbatim}
+% $A = \begin{pNiceMatrix}[baseline=2]
+% \frac{1}{\sqrt{1+p^2}} & p & 1-p \\
+% 1 & 1 & 1 \\
+% 1 & p & 1+p
+% \end{pNiceMatrix}$
+%
+%
+% \medskip
+% It's also possible to use the option |baseline| with one of the special values
+% |t|, |c| or |b|. These letters may also be used absolutely like the option of
+% the environments |{tabular}| and |{array}| of \pkg{array}. The initial value
+% of |baseline| is~|c|.
+%
+%
+% \medskip
+% In the following example, we use the option |t| (equivalent to |baseline=t|)
+% immediately after an |\item| of list. One should remark that the presence of a
+% |\hline| at the beginning of the array doesn't prevent the alignment of the
+% baseline with the baseline of the first row (with |{tabular}| or |{array}| of
+% \pkg{array}, one must use |\firsthline|\footnote{It's also possible to use
+% |\firsthline| in the environments of \pkg{nicematrix}.}).
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
+% \begin{enumerate}
+% \item an item
+% \smallskip
+% \item \renewcommand{\arraystretch}{1.2}
+% $\begin{NiceArray}~emphase#[t]@{LCCCCCC}
+% \hline
+% n & 0 & 1 & 2 & 3 & 4 & 5 \\
+% u_n & 1 & 2 & 4 & 8 & 16 & 32
+% \hline
+% \end{NiceArray}$
+% \end{enumerate}
+% \end{BVerbatim}
+% \begin{minipage}{5cm}
+% \begin{enumerate}
+% \item an item
+% \smallskip
+% \item \renewcommand{\arraystretch}{1.2}
+% $\begin{NiceArray}[t]{LCCCCCC}
+% \hline
+% n & 0 & 1 & 2 & 3 & 4 & 5 \\
+% u_n & 1 & 2 & 4 & 8 & 16 & 32 \\
+% \hline
+% \end{NiceArray}$
+% \end{enumerate}
+% \end{minipage}
+%
+% \medskip
+% However, it's also possible to use the tools of \pkg{booktabs}: |\toprule|,
+% |\bottomrule|, |\midrule|, etc.\par\nobreak
+%
+% \smallskip
+% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
+% \begin{enumerate}
+% \item an item
+% \smallskip
+% \item
+% $\begin{NiceArray}[t]{LCCCCCC}
+% ~emphase#\toprule@
+% n & 0 & 1 & 2 & 3 & 4 & 5 \\
+% ~emphase#\midrule@
+% u_n & 1 & 2 & 4 & 8 & 16 & 32
+% ~emphase#\bottomrule@
+% \end{NiceArray}$
+% \end{enumerate}
+% \end{BVerbatim}
+% \begin{minipage}{5cm}
+% \begin{enumerate}
+% \item an item
% \smallskip
+% \item
+% $\begin{NiceArray}[t]{LCCCCCC}
+% \toprule
+% n & 0 & 1 & 2 & 3 & 4 & 5 \\
+% \midrule
+% u_n & 1 & 2 & 4 & 8 & 16 & 32 \\
+% \bottomrule
+% \end{NiceArray}$
+% \end{enumerate}
+% \end{minipage}
+%
+%
+% \section{The blocks}
+% \label{Block}
+%
+% In the environments of \pkg{nicematrix}, it's possible to use the command
+% |\Block| in order to place an element in the center of a rectangle of merged
+% cells of the array. The command |\Block| don't create space by itself.
+%
+% The command |\Block| must be used in the upper leftmost cell of the array with
+% two arguments. The first argument is the size of the block with the syntax
+% $i$\verb|-|$j$ where $i$ is the number of rows of the block and $j$ its number
+% of columns. The second argument is the content of the block.
+%
+% In |{NiceTabular}| the content of the block is composed in text mode. In the
+% other environments, it is composed in math mode.
+%
+% \medskip
% \begin{BVerbatim}
-% $A = \begin{pmatrix}
-% 1 & \cdots & \cdots & 1 \\
-% 0 & \ddots & & \vdots \\
-% \vdots & \ddots & \ddots & \vdots \\
-% 0 & \cdots & 0 & 1
-% \end{pmatrix}$
+% \begin{NiceTabular}{CCCC}
+% rose & tulipe & marguerite & dahlia \\
+% violette & ~emphase#\Block{2-2}{\LARGE\color{blue} fleurs}@ & & souci \\
+% pervenche & & & lys \\
+% arum & iris & jacinthe & muguet
+% \end{NiceTabular}
% \end{BVerbatim}
%
+%
+% \medskip
+% \begin{center}
+% \begin{NiceTabular}{CCCC}
+% rose & tulipe & marguerite & dahlia \\
+% violette & \Block{2-2}{\LARGE\color{blue} fleurs} & & souci \\
+% pervenche & & & lys \\
+% arum & iris & jacinthe & muguet
+% \end{NiceTabular}
+% \end{center}
+%
+%
+%
+% \medskip
+% It's also possible to use the command |\Block| in mathematical matrices.
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
+% $\begin{bNiceArray}{CCC|C}[margin]
+% ~emphase#\Block{3-3}{A}@ & & & 0 \\
+% & \hspace*{1cm} & & \Vdots \\
+% & & & 0 \\
+% \hline
+% 0 & \Cdots& 0 & 0
+% \end{bNiceArray}$
+% \end{BVerbatim}
+% $\begin{bNiceArray}{CCC|C}[margin]
+% \Block{3-3}{A} & & & 0 \\
+% & \hspace*{1cm} & & \Vdots \\
+% & & & 0 \\
+% \hline
+% 0 & \Cdots& 0 & 0
+% \end{bNiceArray}$
+%
+% \bigskip
+% One may wish to raise the size of the ``$A$'' placed in the block of the
+% previous example. Since this element is composed in math mode, it's not
+% possible to use directly a command like |\large|, |\Large| and |\LARGE|.
+% That's why the command |\Block| provides an option between angle brackets to
+% specify some TeX code which will be inserted before the beginning of the
+% math mode.
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
+% $\begin{bNiceArray}{CCC|C}[margin]
+% \Block{3-3}~emphase#<\Large>@{A} & & & 0 \\
+% & \hspace*{1cm} & & \Vdots \\
+% & & & 0 \\
+% \hline
+% 0 & \Cdots& 0 & 0
+% \end{bNiceArray}$
+% \end{BVerbatim}
+% \begin{scope}
+% $\begin{bNiceArray}{CCC|C}[margin]
+% \Block{3-3}<\Large>{A} & & & 0 \\
+% & \hspace*{1cm} & & \Vdots \\
+% & & & 0 \\
+% \hline
+% 0 & \Cdots& 0 & 0
+% \end{bNiceArray}$
+% \end{scope}
+%
+% \section{The rules}
+%
+% The usual techniques for the rules may be used in the environments of
+% \pkg{nicematrix} (excepted |\vline|).
+%
+%
+% \subsection{The thickness and the color of the rules}
+%
+% The environments of \pkg{nicematrix} provide a key |rules/width| to set the
+% width (in fact the thickness) of the rules in the current environment. In
+% fact, this key merely sets the value of the length |\arrayrulewidth|.
+%
% \smallskip
-% This code composes the matrix $A$ on the right.
-% \end{minipage}\hspace{1cm}
-% $A = \begin{pmatrix}
-% 1 &\cdots &\cdots &1 \\
-% 0 &\ddots & &\vdots \\
-% \vdots &\ddots &\ddots &\vdots \\
-% 0 &\cdots &0 &1
-% \end{pmatrix}$
+% It's well known that \pkg{colortbl} provides the command |\arrayrulecolor| in
+% order to specify the color of the rules.
+%
+% \smallskip
+% With \pkg{nicematrix}, it's possible to specify the color of the rules even
+% when \pkg{colortbl} is not loaded. For sake of compatibility, the command is
+% also named |\arrayrulecolor|. The environments of \pkg{nicematrix} also
+% provide a key |rules/color| to fix the color of the rules in the current
+% environment.
+%
+% \medskip
+% \begin{scope}
+% \hfuzz=10cm
+% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm]
+% \begin{NiceTabular}{|CCC|}[~emphase#rules/color=[gray]{0.9},rules/width=1pt@]
+% \hline
+% rose & tulipe & lys \\
+% arum & iris & violette \\
+% muguet & dahlia & souci \\
+% \hline
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \begin{NiceTabular}{|CCC|}[rules/color=[gray]{0.9},rules/width=1pt]
+% \hline
+% rose & tulipe & lys \\
+% arum & iris & violette \\
+% muguet & dahlia & souci \\
+% \hline
+% \end{NiceTabular}
+% \end{scope}
+%
+% \medskip
+% If one wishes to define new specifiers for columns in order to draw vertical
+% rules (for example with a specific color or thicker than the standard rules),
+% he should consider the command |\OnlyMainNiceMatrix| described on
+% page~\pageref{OnlyMainNiceMatrix}.
%
%
% \bigskip
+% \subsection{A remark about \textbackslash cline}
+%
+%\label{remark-cline}
+%
+% The horizontal and vertical rules drawn by |\hline| and the specifier
+% ``\verb+|+'' make the array larger or wider by a quantity equal to the width of the rule.
+%
+% \smallskip
+% For historical reasons, this is not the case with the command |\cline|, as
+% shown by the following example.
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
+% \setlength{\arrayrulewidth}{2pt}
+% \begin{tabular}{cccc} \hline
+% A&B&C&D \\ ~emphase#\cline{2-2}@
+% A&B&C&D \\ \hline
+% \end{tabular}
+% \end{BVerbatim}
% \begin{scope}
-% \NiceMatrixOptions{transparent}
-% \begin{minipage}{10cm}
-% Now, if we use the package \pkg{nicematrix} with the option \\
-% |transparent|, the same code will give the result on the right.
-% \end{minipage}\hspace{1cm}
-% $A = \begin{pmatrix}
-% 1 & \cdots & \cdots & 1 \\
-% 0 & \ddots & & \vdots \\
-% \vdots & \ddots & \ddots & \vdots \\
-% 0 & \cdots & 0 & 1
-% \end{pmatrix}$
+% \setlength{\arrayrulewidth}{2pt}
+% \begin{tabular}[c]{cccc}
+% \hline
+% A&B&C&D \\
+% \cline{2-2}
+% A&B&C&D \\
+% \hline
+% \end{tabular}
% \end{scope}
%
+% \medskip
+% In the environments of \pkg{nicematrix}, this situation is corrected (it's
+% still possible to go to the standard behaviour of |\cline| with the key |standard-cline|).
%
-% \section{The environments of this package}
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
+% \setlength{\arrayrulewidth}{2pt}
+% \begin{NiceTabular}{CCCC} \hline
+% A&B&C&D \\ ~emphase#\cline{2-2}@
+% A&B&C&D \\ \hline
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \begin{scope}
+% \setlength{\arrayrulewidth}{2pt}
+% \begin{NiceTabular}[c]{CCCC}
+% \hline
+% A&B&C&D \\
+% \cline{2-2}
+% A&B&C&D \\
+% \hline
+% \end{NiceTabular}
+% \end{scope}
%
-% The package \pkg{nicematrix} defines the following new environments.
+% \subsection{The keys hlines and vlines}
+%
+% The key |hlines| draws all the horizontal rules and the key |vlines| draws all
+% the vertical rules. In fact, in the environments with delimiters (as
+% |{pNiceMatrix}| or |{bNiceArray}|) the exteriors rules are not drawn (as
+% expected).
%
% \medskip
-% \begin{ttfamily}
-% \setlength{\tabcolsep}{3mm}
-% \begin{tabular}{llll}
-% \{NiceMatrix\} & \{NiceArray\} & \{NiceTabular\} \\
-% \{pNiceMatrix\} & \{pNiceArray\} \\
-% \{bNiceMatrix\} & \{bNiceArray\} \\
-% \{BNiceMatrix\} & \{BNiceArray\} \\
-% \{vNiceMatrix\} & \{vNiceArray\} \\
-% \{VNiceMatrix\} & \{VNiceArray\} \\
-% & \{NiceArrayWithDelims\}
-% \end{tabular}
-% \end{ttfamily}
+% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
+% $\begin{pNiceMatrix}[~emphase#vlines@,rules/width=0.2pt]
+% 1 & 2 & 3 & 4 & 5 & 6 \\
+% 1 & 2 & 3 & 4 & 5 & 6 \\
+% 1 & 2 & 3 & 4 & 5 & 6
+% \end{pNiceMatrix}$
+% \end{BVerbatim}
+% $\begin{pNiceMatrix}[vlines,rules/width=0.2pt]
+% 1 & 2 & 3 & 4 & 5 & 6 \\
+% 1 & 2 & 3 & 4 & 5 & 6 \\
+% 1 & 2 & 3 & 4 & 5 & 6
+% \end{pNiceMatrix}$
%
+% \bigskip
+% However, there is a difference between the key |vlines| and the use of
+% the specifier ``"|"'' in the preamble of the environment: the rules drawn by
+% |vlines| completely cross the double-rules drawn by |\hline\hline| (you don't
+% need \pkg{hhline}).
%
% \medskip
-% By default, the environments |{NiceMatrix}|, |{pNiceMatrix}|, |{bNiceMatrix}|,
-% |{BNiceMatrix}|, |{vNiceMatrix}| and |{VNiceMatrix}| behave almost exactly as
-% the corresponding environments of \pkg{amsmath}: |{matrix}|, |{pmatrix}|,
-% |{bmatrix}|, |{Bmatrix}|, |{vmatrix}| and |{Vmatrix}|.
+% \begin{BVerbatim}[baseline=c,boxwidth=11.5cm]
+% $\begin{NiceMatrix}[~emphase#vlines@] \hline
+% a & b & c & d \\ \hline \hline
+% 1 & 2 & 3 & 4 \\
+% 1 & 2 & 3 & 4 \\ \hline
+% \end{NiceMatrix}$
+% \end{BVerbatim}
+% $\begin{NiceMatrix}[vlines]
+% \hline
+% a & b & c & d \\
+% \hline \hline
+% 1 & 2 & 3 & 4 \\
+% 1 & 2 & 3 & 4 \\
+% \hline
+% \end{NiceMatrix}$
+%
+%
+% \bigskip
+% If you use \pkg{booktabs} (which provides |\toprule|, |midrule|, |bottomrule|,
+% etc.) and you really want to draw vertical rules (something opposed to the
+% spirit of \pkg{booktabs}), you should remark that the key |vlines| in
+% compatible with \pkg{booktabs}.
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=11.5cm]
+% $\begin{NiceMatrix}[~emphase#vlines@] \toprule
+% a & b & c & d \\ \midrule
+% 1 & 2 & 3 & 4 \\
+% 1 & 2 & 3 & 4 \\ \bottomrule
+% \end{NiceMatrix}$
+% \end{BVerbatim}
+% $\begin{NiceMatrix}[vlines]
+% \toprule
+% a & b & c & d \\
+% \midrule
+% 1 & 2 & 3 & 4 \\
+% 1 & 2 & 3 & 4 \\
+% \bottomrule
+% \end{NiceMatrix}$
+%
+%
+% \subsection{The key hvlines}
+% \label{hvlines}
+%
+% The key |hvlines| draws all the vertical and horizontal rules \emph{excepted
+% in the blocks}.\footnote{In fact, when the key |hvlines| is in force, the
+% rules are also not drawn in the virtual blocks delimited by cells relied par
+% dotted lines (cf. p. \pageref{dotted-and-hvlines}).}
+%
+% \medskip
+% \begin{Verbatim}
+% \setlength{\arrayrulewidth}{1pt}
+% \begin{NiceTabular}{CCCC}[~emphase#hvlines@,rules/color=blue]
+% rose & tulipe & marguerite & dahlia \\
+% violette & \Block{2-2}{\LARGE\color{blue} fleurs} & & souci \\
+% pervenche & & & lys \\
+% arum & iris & jacinthe & muguet
+% \end{NiceTabular}
+% \end{Verbatim}
+%
+% \begin{center}
+% \setlength{\arrayrulewidth}{1pt}
+% \begin{NiceTabular}{CCCC}[hvlines,rules/color=blue]
+% rose & tulipe & marguerite & dahlia \\
+% violette & \Block{2-2}{\LARGE\color{blue} fleurs} & & souci \\
+% pervenche & & & lys \\
+% arum & iris & jacinthe & muguet
+% \end{NiceTabular}
+% \end{center}
+%
+%
%
+% \subsection{La commande \textbackslash diagbox}
+%
+% The command |\diagbox| (inspired by the package \pkg{diagbox}), allows, when
+% it is used in a cell, to slash that cell diagonally downwards.\footnote{The
+% author of this document considers that type of construction as graphically
+% poor.}.
%
% \medskip
-% The environments |{NiceArray}| and |{NiceTabular}| are similar to the
-% environments |{array}| and |{tabular}| of the
-% package |{array}|. However, for technical reasons, in the preamble of these
-% environments, the user must use the letters |L|, |C| and~|R|
-% instead of |l|, |c| and |r|. It's possible to use the constructions
-% |w{...}{...}|, |W{...}{...}|, "|", |>{...}|, |<{...}|, |@{...}|, |!{...}| and
-% |*{n}{...}| but the letters |p|, |m| and |b| should not be used.
+% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
+% $\begin{NiceArray}{*{5}{C}}[hvlines]
+% ~emphase#\diagbox{x}{y}@ & e & a & b & c \\
+% e & e & a & b & c \\
+% a & a & e & c & b \\
+% b & b & c & e & a \\
+% c & c & b & a & e
+% \end{NiceArray}$
+% \end{BVerbatim}
+% $\begin{NiceArray}{*{5}{C}}[hvlines]
+% \diagbox{x}{y} & e & a & b & c \\
+% e & e & a & b & c \\
+% a & a & e & c & b \\
+% b & b & c & e & a \\
+% c & c & b & a & e
+% \end{NiceArray}$
+%
+%
+%
+% \subsection{Dotted rules}
+%
+%
+% In the environments of the package \pkg{nicematrix}, it's possible to use
+% the command |\hdottedline| (provided by \pkg{nicematrix}) which is a
+% counterpart of the classical commands |\hline| and |\hdashline| (the latter is
+% a command of \pkg{arydshln}).
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm]
+% \begin{pNiceMatrix}
+% 1 & 2 & 3 & 4 & 5 \\
+% ~emphase#\hdottedline@
+% 6 & 7 & 8 & 9 & 10 \\
+% 11 & 12 & 13 & 14 & 15
+% \end{pNiceMatrix}
+% \end{BVerbatim}
+% $\begin{pNiceMatrix}
+% 1 & 2 & 3 & 4 & 5 \\
+% \hdottedline
+% 6 & 7 & 8 & 9 & 10 \\
+% 11 & 12 & 13 & 14 & 15
+% \end{pNiceMatrix}$
+%
+%
+% \bigskip
+% In the environments with an explicit preamble (like |{NiceTabular}|,
+% |{NiceArray}|, etc.), it's possible to draw a vertical dotted line with the
+% specifier ``|:|''.
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm]
+% \left(\begin{NiceArray}{CCCC~emphase#:@C}
+% 1 & 2 & 3 & 4 & 5 \\
+% 6 & 7 & 8 & 9 & 10 \\
+% 11 & 12 & 13 & 14 & 15
+% \end{NiceArray}\right)
+% \end{BVerbatim}
+% $\left(\begin{NiceArray}{CCCC:C}
+% 1 & 2 & 3 & 4 & 5 \\
+% 6 & 7 & 8 & 9 & 10 \\
+% 11 & 12 & 13 & 14 & 15
+% \end{NiceArray}\right)$
+%
+% \bigskip
+% It's possible to change in \pkg{nicematrix} the letter used to specify a
+% vertical dotted line with the option |letter-for-dotted-lines| available in
+% |\NiceMatrixOptions|.
+%
+% \bigskip
+% \emph{Remark} : In the package \pkg{array} (on which the package
+% \pkg{nicematrix} relies), horizontal and vertical rules make the array larger
+% or wider by a quantity equal to the width of the rule\footnote{In fact, this
+% is true only for |\hline| and ``"|"'' but not for |\cline|.}. In
+% \pkg{nicematrix}, the dotted lines drawn by |\hdottedline| and ``|:|'' do
+% likewise.
+%
+%
+%
+%\section{The color of the rows and columns}
+%
+% With the classical package \pkg{colortbl}, it's possible to color the cells,
+% rows and columns of a tabular. However, the resulting \textsc{pdf} is not
+% always perfectly displayed by the \textsc{pdf} viewers, in particular in
+% conjonction with rules. With some \textsc{pdf} viewers, some vertical rules
+% seem to vanish. On the other side, some thin horizontal white lines may appear
+% in some circonstances.
+%
+%
+% \medskip
+% The package \pkg{nicematrix} provides similar tools which do not present these
+% drawbacks. It provides a key |code-before|\footnote{There is also a key
+% |code-after| : see p.~\pageref{code-after}.} for some code which will be
+% executed \emph{before} the drawing of the tabular. In this |code-before|, new
+% commands are available: |\cellcolor|, |\rectanglecolor|, |\rowcolor|,
+% |\columncolor|, |\rowcolors| and |\chessboardcolors|.
+% \label{code-before}
+%
+% \medskip
+% These commands are independent of \pkg{colortbl}.\footnote{Thus, it's possible
+% to coloror the rules, the cells, the rows, the columns, etc. without loading \pkg{colortbl}.}
+%
+% \medskip
+% All these commands accept an optional argument (between square brackets and
+% in first position) which is the color model for the specification of the colors.
+%
+% \medskip
+% \begin{itemize}
+% \item The command |\cellcolor| takes its name from the command |\cellcolor| of
+% \pkg{colortbl}.
+%
+% This command takes in mandatory arguments a color and a list of cells, each of
+% which with the format $i$-$j$ where $i$ is the number of row and $j$ the
+% number of colummn of the cell.
+%
+%
+% \medskip
+% \begin{scope}
+% \hfuzz=10cm
+% \begin{BVerbatim}[boxwidth=10cm,baseline=c]
+% \begin{NiceTabular}{|C|C|C|}[code-before =
+% ~emphase#\cellcolor{red!15}{3-1,2-2,1-3}@]
+% \hline
+% a & b & c \\ \hline
+% e & f & g \\ \hline
+% h & i & j \\ \hline
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \begin{NiceTabular}{|C|C|C|}[hvlines, code-before =
+% \cellcolor{red!15}{3-1,2-2,1-3}]
+% \hline
+% a & b & c \\ \hline
+% e & f & g \\ \hline
+% h & i & j \\ \hline
+% \end{NiceTabular}
+% \end{scope}
+%
+% \bigskip
+% \item The command |\rectanglecolor| takes three mandatory arguments. The first
+% is the color. The second is the upper-left cell of the rectangle and the third
+% is the lower-right cell of the rectangle.
%
-% See p.~\pageref{NiceArray} the section relating to |{NiceArray}| and |{NiceTabular}|.
+% \medskip
+% \begin{scope}
+% \hfuzz=10cm
+% \begin{BVerbatim}[boxwidth=10cm,baseline=c]
+% \begin{NiceTabular}{|C|C|C|}[code-before =
+% ~emphase#\rectanglecolor{blue!15}{2-2}{3-3}@]
+% \hline
+% a & b & c \\ \hline
+% e & f & g \\ \hline
+% h & i & j \\ \hline
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \begin{NiceTabular}{|C|C|C|}[hvlines, code-before =
+% \rectanglecolor{blue!15}{2-2}{3-3}]
+% \hline
+% a & b & c \\ \hline
+% e & f & g \\ \hline
+% h & i & j \\ \hline
+% \end{NiceTabular}
+% \end{scope}
%
+%
+%
+% \bigskip
+% \item The command |\rowcolor| takes its name from the command |\rowcolor| of
+% \pkg{colortbl}. Its first mandatory argument is the color and the second is a
+% comma-separated list of rows or interval of rows with the form $a$-$b$ (an
+% interval of the form $a$- represent all the rows from the row $a$ until the end).
+%
+% \medskip
+% \begin{scope}
+% \hfuzz = 10cm
+% \begin{BVerbatim}[boxwidth=9cm,baseline=c]
+% $\begin{NiceArray}{LLL}[hvlines, ~emphase#code-before = \rowcolor{red!15}{1,3-5,8-}@]
+% a_1 & b_1 & c_1 \\
+% a_2 & b_2 & c_2 \\
+% a_3 & b_3 & c_3 \\
+% a_4 & b_4 & c_4 \\
+% a_5 & b_5 & c_5 \\
+% a_6 & b_6 & c_6 \\
+% a_7 & b_7 & c_7 \\
+% a_8 & b_8 & c_8 \\
+% a_9 & b_9 & c_9 \\
+% a_{10} & b_{10} & c_{10} \\
+% \end{NiceArray}$
+% \end{BVerbatim}
+% $\begin{NiceArray}{LLL}[baseline=4,hvlines, code-before = \rowcolor{red!15}{1,3-5,8-}]
+% a_1 & b_1 & c_1 \\
+% a_2 & b_2 & c_2 \\
+% a_3 & b_3 & c_3 \\
+% a_4 & b_4 & c_4 \\
+% a_5 & b_5 & c_5 \\
+% a_6 & b_6 & c_6 \\
+% a_7 & b_7 & c_7 \\
+% a_8 & b_8 & c_8 \\
+% a_9 & b_9 & c_9 \\
+% a_{10} & b_{10} & c_{10} \\
+% \end{NiceArray}$
+% \end{scope}
+%
+%
+% \bigskip
+% \item The command |\columncolor| takes its name from the command
+% |\columncolor| of \pkg{colortbl}. Its syntax is similar to the syntaxe of
+% |\rowcolor|.
+%
+% \bigskip
+% \item The command |\rowcolors| (with a \emph{s}) takes its name from the
+% command |\rowcolors| of \pkg{xcolor}\footnote{The command |\rowcolors| of
+% \pkg{color} is available when \pkg{xcolor} is loaded with the
+% option~|table|.}. The \emph{s} emphasizes the fact that there is \emph{two}
+% colors. This command colors alternately the rows of the tabular, beginning
+% with the row whose number is given in first (mandatory) argument. The two
+% other (mandatory) arguments are the colors.
+%
+% \medskip
+% \begin{scope}
+% \hfuzz=10cm
+% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
+% \begin{NiceTabular}{LR}[hlines,code-before = ~emphase#\rowcolors{1}{blue!10}{}@]
+% John & 12 \\
+% Stephen & 8 \\
+% Sarah & 18 \\
+% Ashley & 20 \\
+% Henry & 14 \\
+% Madison & 15
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \begin{NiceTabular}{LR}[hlines,code-before = \rowcolors{1}{blue!10}{},baseline=3]
+% John & 12 \\
+% Stephen & 8 \\
+% Sarah & 18 \\
+% Ashley & 20 \\
+% Henry & 14 \\
+% Madison & 15
+% \end{NiceTabular}
+% \end{scope}
+%
+% \bigskip
+% \item The command |\chessboardcolors| takes in mandatory arguments two colors
+% and colors the cells of the tabular in quincunx with these colors.
+%
+% \medskip
+% \begin{scope}
+% \hfuzz=10cm
+% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
+% $\begin{pNiceMatrix}[R,margin, ~emphase#code-before=\chessboardcolors{red!15}{blue!15}@]
+% 1 & -1 & 1 \\
+% -1 & 1 & -1 \\
+% 1 & -1 & 1
+% \end{pNiceMatrix}$
+% \end{BVerbatim}
+% $\begin{pNiceMatrix}[R,baseline=1, margin, code-before = \chessboardcolors{red!15}{blue!15}]
+% 1 & -1 & 1 \\
+% -1 & 1 & -1 \\
+% 1 & -1 & 1
+% \end{pNiceMatrix}$
+% \end{scope}
+%
+% \medskip
+% We have used the key |R| which aligns all the columns rightwards (cf. p.~\pageref{key-R}).
+% \end{itemize}
+%
+%
+%
+% \bigskip
+% One should remark that these commands are compatible with the commands de
+% \pkg{booktabs} (|\toprule|, |\midrule|, |\bottomrule|, etc).
+%
+% \medskip
+% \begin{scope}
+% \hfuzz=10cm
+% \begin{BVerbatim}[baseline=c,boxwidth=8.5cm]
+% \begin{NiceTabular}[c]{LSSSS}%
+% [code-before = \rowcolor{red!15}{1-2} \rowcolors{3}{blue!15}{}]
+% ~emphase#\toprule@
+% \Block{2-1}{Product} \\
+% \Block{1-3}{dimensions (cm)} & & &
+% \Block{2-1}{\rotate Price} \\
+% ~emphase#\cmidrule(rl){2-4}@
+% & L & l & h \\
+% ~emphase#\midrule@
+% small & 3 & 5.5 & 1 & 30 \\
+% standard & 5.5 & 8 & 1.5 & 50.5 \\
+% premium & 8.5 & 10.5 & 2 & 80 \\
+% extra & 8.5 & 10 & 1.5 & 85.5 \\
+% special & 12 & 12 & 0.5 & 70 \\
+% ~emphase#\bottomrule@
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \begin{NiceTabular}[c]{LSSSS}[code-before = \rowcolor{red!15}{1-2}
+% \rowcolors{3}{blue!15}{}]
+% \toprule
+% \Block{2-1}{Product} &
+% \Block{1-3}{dimensions (cm)} & & &
+% \Block{2-1}{\rotate Price} \\
+% \cmidrule(rl){2-4}
+% & L & l & h \\
+% \midrule
+% small & 3 & 5.5 & 1 & 30 \\
+% standard & 5.5 & 8 & 1.5 & 50.5 \\
+% premium & 8.5 & 10.5 & 2 & 80 \\
+% extra & 8.5 & 10 & 1.5 & 85.5 \\
+% special & 12 & 12 & 0.5 & 70 \\
+% \bottomrule
+% \end{NiceTabular}
+% \end{scope}
+%
+% \medskip
+% We have used the type of column |S| of \pkg{siunitx}.
+%
+% \section{The width of the columns}
+% \label{width}
+%
+% In the environments with an explicit preamble (like |{NiceTabular}|,
+% |{NiceArray}|, etc.), it's possible to fix the width of a given column with
+% the standard letters |w| and |W| of the package \pkg{array}. In
+% |{NiceTabular}|, the cells of such columns are composed in texte mode but, in
+% |{NiceArray}|, |{pNiceArray}|, etc., they are composed in math mode (whereas,
+% in |{array}| of \pkg{array}, they are composed in text mode).
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
+% \begin{NiceTabular}{~emphase#Wc{2cm}@CC}[hvlines]
+% Paris & New York & Madrid \\
+% Berlin & London & Roma \\
+% Rio & Tokyo & Oslo
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \begin{NiceTabular}{Wc{2cm}CC}[hvlines]
+% Paris & New York & Madrid \\
+% Berlin & London & Roma \\
+% Rio & Tokyo & Oslo
+% \end{NiceTabular}
+%
+%
+% \bigskip
+% In the environments of \pkg{nicematrix}, it's also possible to fix the \emph{minimal}
+% width of all the columns of an array directly with the key |columns-width|.
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
+% $\begin{pNiceMatrix}[~emphase#columns-width = 1cm@]
+% 1 & 12 & -123 \\
+% 12 & 0 & 0 \\
+% 4 & 1 & 2
+% \end{pNiceMatrix}$
+% \end{BVerbatim}
+% $\begin{pNiceMatrix}[columns-width = 1cm]
+% 1 & 12 & -123 \\
+% 12 & 0 & 0 \\
+% 4 & 1 & 2
+% \end{pNiceMatrix}$
+%
+% \medskip
+% Note that the space inserted between two columns (equal to 2 |\tabcolsep| in
+% |{NiceTabular}| and to 2 |\arraycolsep| in the other environments)
+% is not suppressed (of course, it's possible to suppress this space by setting
+% |\tabcolsep| or |\arraycolsep| equal to $0$~pt before the environment).
+%
+% \bigskip
+% It's possible to give the special value |auto| to the option |columns-width|:
+% all the columns of the array will have a width equal to the widest cell of
+% the array.\footnote{The result is achieved with only one compilation (but Tikz
+% will have written informations in the |.aux| file and a message requiring a
+% second compilation will appear).}\par\nobreak
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
+% $\begin{pNiceMatrix}[~emphase#columns-width = auto@]
+% 1 & 12 & -123 \\
+% 12 & 0 & 0 \\
+% 4 & 1 & 2
+% \end{pNiceMatrix}$
+% \end{BVerbatim}
+% $\begin{pNiceMatrix}[columns-width = auto]
+% 1 & 12 & -123 \\
+% 12 & 0 & 0 \\
+% 4 & 1 & 2
+% \end{pNiceMatrix}$
+%
+% \bigskip
+% Without surprise, it's possible to fix the minimal width of the columns of all
+% the matrices of a current scope with the command
+% |\NiceMatrixOptions|.\par\nobreak
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=8.5cm]
+% ~emphase#\NiceMatrixOptions{columns-width=10mm}@
+% $\begin{pNiceMatrix}
+% a & b \\ c & d
+% \end{pNiceMatrix}
+% =
+% \begin{pNiceMatrix}
+% 1 & 1245 \\ 345 & 2
+% \end{pNiceMatrix}$
+% \end{BVerbatim}
+% \begin{scope}
+% \NiceMatrixOptions{columns-width=10mm}
+% $\begin{pNiceMatrix}
+% a & b \\
+% c & d
+% \end{pNiceMatrix}
+% =
+% \begin{pNiceMatrix}
+% 1 & 1245 \\
+% 345 & 2
+% \end{pNiceMatrix}$
+% \end{scope}
+%
+%
+% \bigskip
+% But it's also possible to fix a zone where all the matrices will have their
+% columns of the same width, equal to the widest cell of all the matrices. This
+% construction uses the environment |{NiceMatrixBlock}| with the option
+% |auto-columns-width|\footnote{At this time, this is the only usage of the
+% environment |{NiceMatrixBlock}| but it may have other usages in the future.}.
+% The environment |{NiceMatrixBlock}| has no direct link with the command
+% |\Block| presented previously in this document (cf.~p.~\pageref{Block}).
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=8.5cm]
+% ~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@
+% $\begin{array}{c}
+% \begin{bNiceMatrix}
+% 9 & 17 \\ -2 & 5
+% \end{bNiceMatrix} \\ \\
+% \begin{bNiceMatrix}
+% 1 & 1245345 \\ 345 & 2
+% \end{bNiceMatrix}
+% \end{array}$
+% ~emphase#\end{NiceMatrixBlock}@
+% \end{BVerbatim}
+% \begin{NiceMatrixBlock}[auto-columns-width]
+% $\begin{array}{c}
+% \begin{bNiceMatrix}
+% 9 & 17 \\ -2 & 5
+% \end{bNiceMatrix} \\ \\
+% \begin{bNiceMatrix}
+% 1 & 1245345 \\ 345 & 2
+% \end{bNiceMatrix}
+% \end{array}$
+% \end{NiceMatrixBlock}
+%
+% \medskip
+% \textbf{Several compilations may be necessary to achieve the job.}
+%
+%
+%
+% \bigskip
+% \section{The exterior rows and columns}
+%
+% The options |first-row|, |last-row|, |first-col| and |last-col| allow the
+% composition of exterior rows and columns in the environments of
+% \pkg{nicematrix}.
+% \label{exterior}
+%
+% A potential ``first row'' (exterior) has the number $0$ (and not $1$). Idem
+% for the potential ``first column''.
+%
+% \begin{Verbatim}
+% $\begin{pNiceMatrix}[~emphase#first-row,last-row,first-col,last-col@]
+% $\begin{pNiceMatrix}[~emphase#first-row,last-row,first-col,last-col@,nullify-dots]
+% & C_1 & \Cdots & & C_4 & \\
+% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
+% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
+% & a_{31} & a_{32} & a_{33} & a_{34} & \\
+% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
+% & C_1 & \Cdots & & C_4 &
+% \end{pNiceMatrix}$
+% \end{pNiceMatrix}$
+% \end{Verbatim}
+%
+% \[\begin{pNiceMatrix}[first-row,last-row,first-col,last-col,nullify-dots]
+% & C_1 & \Cdots & & C_4 & \\
+% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
+% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
+% & a_{31} & a_{32} & a_{33} & a_{34} & \\
+% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
+% & C_1 & \Cdots & & C_4 &
+% \end{pNiceMatrix}\]
+%
+% \medskip
+% The dotted lines have been drawn with the tools presented p.~\pageref{Cdots}.
+%
+% \bigskip
+% We have several remarks to do.
+% \begin{itemize}
+% \item For the environments with an explicit preamble (i.e. |{NiceArray}| and
+% its variants), no letter must be given in that preamble for the potential
+% first column and the potential last column: they will automatically (and
+% necessarily) be of type |R| for the first column and |L| for the last one.
+% \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''.
+% \begin{itemize}
+% \item For the environments with explicit preamble, like |{NiceTabular}| and
+% |{pNiceArray}|, the number of columns can obviously be computed from the
+% preamble.
+%
+% \item When the option |light-syntax| (cf. p. \pageref{light-syntax}) is used,
+% \pkg{nicematrix} has, in any case, to load the whole body of the environment
+% (and that's why it's not possible to put verbatim material in the array with
+% the option |light-syntax|). The analysis of this whole body gives the number
+% of rows (but not the number of columns).
+%
+% \item In the other cases, \pkg{nicematrix} compute the number of rows and
+% columns during the first compilation and write the result in the |aux| file
+% for the next run.
+%
+% \textsl{However, it's possible to provide the number of the last row and the
+% number of the last column as values of the options |last-row| and |last-col|,
+% tending to an acceleration of the whole compilation of the document.} That's
+% what we will do throughout the rest of the document.
+% \end{itemize}
+% \end{itemize}
+%
+% \bigskip
+% It's possible to control the appearance of these rows and columns with options
+% |code-for-first-row|, |code-for-last-row|, |code-for-first-col| and
+% |code-for-last-col|. These options
+% specify tokens that will be inserted before each cell of the corresponding row
+% or column.
+%
+%
+% \begin{Verbatim}
+% \NiceMatrixOptions{~emphase#code-for-first-row@ = \color{red},
+% ~emphase#code-for-first-col@ = \color{blue},
+% ~emphase#code-for-last-row@ = \color{green},
+% ~emphase#code-for-last-col@ = \color{magenta}}
+% $\begin{pNiceArray}{CC|CC}[first-row,last-row=5,first-col,last-col,nullify-dots]
+% & C_1 & \Cdots & & C_4 & \\
+% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
+% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
+% \hline
+% & a_{31} & a_{32} & a_{33} & a_{34} & \\
+% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
+% & C_1 & \Cdots & & C_4 &
+% \end{pNiceArray}$
+% \end{Verbatim}
+%
+% \begin{scope}
+% \NiceMatrixOptions{code-for-first-row = \color{red},
+% code-for-first-col = \color{blue},
+% code-for-last-row = \color{green},
+% code-for-last-col = \color{magenta}}
+% \begin{displaymath}
+% \begin{pNiceArray}{CC|CC}[first-row,last-row=5,first-col,last-col,nullify-dots]
+% & C_1 & \multicolumn1C{\Cdots} & & C_4 & \\
+% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
+% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
+% \hline
+% & a_{31} & a_{32} & a_{33} & a_{34} & \\
+% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
+% & C_1 & \multicolumn1C{\Cdots} & & C_4 &
+% \end{pNiceArray}
+% \end{displaymath}
+% \end{scope}
+%
+%
+% \emph{Remarks}
+% \begin{itemize}[beginpenalty=10000]
+% \item As shown in the previous example, the horizontal and rules doesn't
+% extend in the exterior rows and columns.
+%
+% However, if one wishes to define new specifiers for columns in order to draw
+% vertical rules (for example thicker than the standard rules), he should
+% consider the command |\OnlyMainNiceMatrix| described on
+% page~\pageref{OnlyMainNiceMatrix}.
+%
+% \item A specification of color present in |code-for-first-row| also applies to
+% a dotted line draw in this exterior ``first row'' (excepted if a value has
+% been given to |xdots/color|). Idem for the other exterior rows and columns.
+%
+% \item Logically, the potential option |columns-width| (described
+% p.~\pageref{width}) doesn't apply to the ``first column'' and ``last column''.
+% \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).
+% \end{itemize}
+%
+%
+%
+%
%
% \section{The continuous dotted lines}
%
+% \label{Cdots}
% Inside the environments of the package \pkg{nicematrix}, new commands are
% defined: |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, and |\Iddots|. These commands
% are intended to be used in place of |\dots|, |\cdots|, |\vdots|, |\ddots| and
@@ -275,7 +1306,8 @@ version 2005/12/01 or later.
% |\Iddots| diagonal ones. It's possible to change the color of these lines
% with the option |color|.\footnote{It's also possible to change the color of
% all theses dotted lines with the option |xdots/color| (\textsl{xdots} to
-% remind that it works for |\Cdots|, |\Ldots|, |\Vdots|, etc.): cf. p. \pageref{customization}.}\par\nobreak
+% remind that it works for |\Cdots|, |\Ldots|, |\Vdots|, etc.): cf. p.
+% \pageref{customization}.}\par\nobreak
%
% \bigskip
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
@@ -463,9 +1495,6 @@ version 2005/12/01 or later.
% The option |nullify-dots| smashes the instructions |\Ldots| (and the variants)
% horizontally but also vertically.
%
-% \medskip
-% \textbf{There must be no space before the opening bracket (|[|) of the options
-% of the environment.}
%
%
% \subsection{The command \textbackslash Hdotsfor}
@@ -692,234 +1721,52 @@ version 2005/12/01 or later.
% \end{pNiceMatrix}\]
%
%
-%
-% \section{The PGF/Tikz nodes created by nicematrix}
-%
-% \label{name}
+% \subsection{The dotted lines and the key hvlines}
%
-% The package \pkg{nicematrix} creates a PGF/Tikz node for each (non-empty) cell
-% of the considered array. These nodes are used to draw the dotted lines between
-% the cells of the matrix. However, the user may wish to use directly these
-% nodes. It's possible (if Tikz has been loaded\footnote{We remind that, since
-% the version 3.13, \pkg{nicematrix} doesn't load Tikz by default by only
-% \textsc{pgf} (Tikz is a layer over \textsc{pfg}).}). First, the user have to
-% give a name to the array (with the key called |name|). Then, the nodes are
-% accessible through the names ``\textsl{name}-$i$-$j$'' where \textsl{name} is
-% the name given to the array and $i$ and $j$ the numbers of the row and the
-% column of the considered cell.
+% \label{dotted-and-hvlines}
%
+% We have said (cf. p. \pageref{hvlines}) that the key |hvlines| draws all the
+% horizontal and vertical rules, excepted in the blocks. In fact, when this key
+% is in force, the rules are also not drawn in the virtual blocks delimited by
+% cells relied par dotted lines.
+%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
-% $\begin{pNiceMatrix}[name=~emphase#mymatrix@]
-% 1 & 2 & 3 \\
-% 4 & 5 & 6 \\
-% 7 & 8 & 9
+% \NiceMatrixOptions{nullify-dots}
+% $\begin{pNiceMatrix}[rules/color=gray,~emphase#hvlines@,margin]
+% 0 & \Cdots & & & & 0 \\
+% 1 & \Cdots & & & 1 & 2 \\
+% 0 & \Ddots & & & \Vdots & \Vdots \\
+% \Vdots & \Ddots & & & & \\
+% & & & & & \\
+% 0 & \Cdots & & 0 & 1 & 2 \\
% \end{pNiceMatrix}$
-% \tikz[remember picture,overlay]
-% \draw ~emphase#(mymatrix-2-2)@ circle (2mm) ;
% \end{BVerbatim}
-% $\begin{pNiceMatrix}[name=mymatrix]
-% 1 & 2 & 3 \\
-% 4 & 5 & 6 \\
-% 7 & 8 & 9
+% \begin{scope}
+% \NiceMatrixOptions{nullify-dots}
+% $\begin{pNiceMatrix}[rules/color=gray,hvlines,margin]
+% 0 & \Cdots & & & & 0 \\
+% 1 & \Cdots & & & 1 & 2 \\
+% 0 & \Ddots & & & \Vdots & \Vdots \\
+% \Vdots & \Ddots & & & & \\
+% & & & & & \\
+% 0 & \Cdots & & 0 & 1 & 2 \\
% \end{pNiceMatrix}$
-% \tikz[remember picture,overlay]
-% \draw (mymatrix-2-2) circle (2mm) ;
-%
-% \medskip
-% Don't forget the options |remember picture| and |overlay|.
-%
-% \bigskip
-% In the following example, we have underlined all the nodes of the matrix.
-% \[\begin{pNiceMatrix}[
-% code-after = {\begin{tikzpicture}
-% [every node/.style = {blend mode = multiply,
-% fill = red!15,
-% inner sep = 0 pt }]
-% \node [fit = (1-1)] {} ;
-% \node [fit = (1-3)] {} ;
-% \node [fit = (2-2)] {} ;
-% \node [fit = (3-1)] {} ;
-% \node [fit = (3-3)] {} ;
-% \node [fit = (1-2)] {} ;
-% \node [fit = (2-1)] {} ;
-% \node [fit = (2-3)] {} ;
-% \node [fit = (3-2)] {} ;
-% \end{tikzpicture}}]
-% a & a + b & a + b + c \\
-% a & a & a + b \\
-% a & a & a
-% \end{pNiceMatrix}\]
-%
-%
-% \bigskip
-% In fact, the package \pkg{nicematrix} can create ``extra nodes'': the ``medium
-% nodes'' and the ``large nodes''. The first ones
-% are created with the option |create-medium-nodes| and the second ones with the
-% option |create-large-nodes|.\footnote{There is also an option
-% |create-extra-nodes| which is an alias for the conjonction of
-% |create-medium-nodes| and |create-large-nodes|.}
-%
-% \medskip
-% The names of the ``medium nodes'' are constructed by adding the suffix
-% ``|-medium|'' to the names of the ``normal nodes''. In the following example,
-% we have underlined the ``medium nodes''. We consider that this example is
-% self-explanatory.
-% \[\begin{pNiceMatrix}[
-% create-medium-nodes,
-% code-after = {\begin{tikzpicture}
-% [every node/.style = {fill = red!15,
-% blend mode = multiply,
-% inner sep = 0pt},
-% name suffix = -medium]
-% \node [fit = (1-1)] {} ;
-% \node [fit = (1-2)] {} ;
-% \node [fit = (1-3)] {} ;
-% \node [fit = (2-1)] {} ;
-% \node [fit = (2-2)] {} ;
-% \node [fit = (2-3)] {} ;
-% \node [fit = (3-1)] {} ;
-% \node [fit = (3-2)] {} ;
-% \node [fit = (3-3)] {} ;
-% \end{tikzpicture}}]
-% a & a + b & a + b + c \\
-% a & a & a + b \\
-% a & a & a
-% \end{pNiceMatrix}\]
-%
-%
-% \medskip
-% The names of the ``large nodes'' are constructed by adding the suffix
-% ``|-large|'' to the names of the ``normal nodes''. In the following example,
-% we have underlined the ``large nodes''. We consider that this example is
-% self-explanatory.\footnote{There is no ``large nodes'' created in the exterior
-% rows and columns (for these rows and columns, cf. p.~\pageref{exterior}).}
-%
-% \[\begin{pNiceMatrix}[
-% create-large-nodes,
-% code-after = {\begin{tikzpicture}
-% [every node/.style = {blend mode = multiply,
-% inner sep = 0pt},
-% name suffix = -large]
-% \node [fit = (1-1),fill = red!15] {} ;
-% \node [fit = (1-3),fill = red!15] {} ;
-% \node [fit = (2-2),fill = red!15] {} ;
-% \node [fit = (3-1),fill = red!15] {} ;
-% \node [fit = (3-3),fill = red!15] {} ;
-% \node [fit = (1-2),fill = blue!15] {} ;
-% \node [fit = (2-1),fill = blue!15] {} ;
-% \node [fit = (2-3),fill = blue!15] {} ;
-% \node [fit = (3-2),fill = blue!15] {} ;
-% \end{tikzpicture}}]
-% a & a + b & a + b + c \\
-% a & a & a + b \\
-% a & a & a
-% \end{pNiceMatrix}\]
+% \end{scope}
%
%
-% \medskip
-% The ``large nodes'' of the first column and last column may appear too small
-% for some usage. That's why it's possible to use the options |left-margin| and
-% |right-margin| to add space on both sides of the array and also space in the
-% ``large nodes'' of the first column and last column. In the following example,
-% we have used the options |left-margin| and |right-margin|.\footnote{The
-% options |left-margin| and |right-margin| take dimensions as values but, if no
-% value is given, the default value is used, which is |\arraycolsep| (by
-% default: 5~pt). There is also an option |margin| to fix both |left-margin| and
-% |right-margin| to the same value.}
-% \[\begin{pNiceMatrix}[
-% create-large-nodes,left-margin,right-margin,
-% code-after = {\begin{tikzpicture}
-% [every node/.style = {blend mode = multiply,
-% inner sep = 0pt},
-% name suffix = -large]
-% \node [fit = (1-1),fill = red!15] {} ;
-% \node [fit = (1-3),fill = red!15] {} ;
-% \node [fit = (2-2),fill = red!15] {} ;
-% \node [fit = (3-1),fill = red!15] {} ;
-% \node [fit = (3-3),fill = red!15] {} ;
-% \node [fit = (1-2),fill = blue!15] {} ;
-% \node [fit = (2-1),fill = blue!15] {} ;
-% \node [fit = (2-3),fill = blue!15] {} ;
-% \node [fit = (3-2),fill = blue!15] {} ;
-% \end{tikzpicture}}]
-% a & a + b & a + b + c \\
-% a & a & a + b \\
-% a & a & a
-% \end{pNiceMatrix}\]
-%
-% \medskip
-% It's also possible to add more space on both side of the array with the
-% options |extra-left-margin| and |extra-right-margin|. These margins are not
-% incorporated in the ``large nodes''. It's possible to fix both values with the
-% option |extra-margin| and, in the following example, we use |extra-margin|
-% with the value $3$~pt.
-% \[\begin{pNiceMatrix}[
-% create-large-nodes,margin,extra-margin=3pt,
-% code-after = {\begin{tikzpicture}
-% [every node/.style = {blend mode = multiply,
-% inner sep = 0 pt},
-% name suffix = -large]
-% \node [fit = (1-1),fill = red!15] {} ;
-% \node [fit = (1-3),fill = red!15] {} ;
-% \node [fit = (2-2),fill = red!15] {} ;
-% \node [fit = (3-1),fill = red!15] {} ;
-% \node [fit = (3-3),fill = red!15] {} ;
-% \node [fit = (1-2),fill = blue!15] {} ;
-% \node [fit = (2-1),fill = blue!15] {} ;
-% \node [fit = (2-3),fill = blue!15] {} ;
-% \node [fit = (3-2),fill = blue!15] {} ;
-% \end{tikzpicture}}]
-% a & a + b & a + b + c \\
-% a & a & a + b \\
-% a & a & a
-% \end{pNiceMatrix}\]
-%
-% \medskip
-% In this case, if we want a control over the height of the rows, we can add a
-% |\strut| in each row of the array.
-% \[\begin{pNiceMatrix}[
-% create-large-nodes,left-margin,right-margin,extra-right-margin=3pt,
-% extra-left-margin=3pt,
-% code-after = {\begin{tikzpicture}
-% [every node/.style = {blend mode = multiply,
-% inner sep = 0 pt},
-% name suffix = -large]
-% \node [fit = (1-1),fill = red!15] {} ;
-% \node [fit = (1-3),fill = red!15] {} ;
-% \node [fit = (2-2),fill = red!15] {} ;
-% \node [fit = (3-1),fill = red!15] {} ;
-% \node [fit = (3-3),fill = red!15] {} ;
-% \node [fit = (1-2),fill = blue!15] {} ;
-% \node [fit = (2-1),fill = blue!15] {} ;
-% \node [fit = (2-3),fill = blue!15] {} ;
-% \node [fit = (3-2),fill = blue!15] {} ;
-% \end{tikzpicture}}]
-% \strut a & a + b & a + b + c \\
-% \strut a & a & a + b \\
-% \strut a & a & a
-% \end{pNiceMatrix}\]
-%
-% \bigskip
-% We explain below how to fill the nodes created by \pkg{nicematrix} (cf. p.
-% \pageref{highlight}).
%
% \section{The code-after}
%
% \label{code-after}
% The option |code-after| may be used to give some code that will be excuted
-% after the construction of the matrix (and thus after the construction of
-% all the nodes).
+% after the construction of the matrix.\footnote{There is also a key
+% |code-before| described p.~\pageref{code-before}.}
%
-% \smallskip
-% \textbf{If Tikz is loaded}\footnote{We remind that, since the version 3.13,
-% \pkg{nicematrix} doesn't load Tikz by default but only \textsc{pgf} (Tikz is a
-% layer over \textsc{pfg}).}, one may access to that nodes with classical Tikz
-% instructions. The nodes should be designed as $i$-$j$ (without the prefix
-% corresponding to the name of the environment).
-%
-% Moreover, a special command, called |\line|, is available to draw directly
-% dotted lines between nodes. It may be used, for example, to draw a dotted line
+% A special command, called |\line|, is available to draw directly
+% dotted lines between nodes. It takes two arguments for the two cells to rely,
+% both of the form $i$-$j$ where is the number of row and $j$ is the number of
+% column. It may be used, for example, to draw a dotted line
% between two adjacents cells. \label{line-in-code-after}
%
% \medskip
@@ -949,823 +1796,49 @@ version 2005/12/01 or later.
% p.~\pageref{example-CodeAfter}.
%
%
-% \section{The environments \{NiceArray\} and \{NiceTabular\}}
-% \label{NiceArray}
-%
-% The environments |{NiceArray}| and |{NiceTabular}| are similar to the
-% environments |{array}| and |{tabular}|. The mandatory argument is the preamble
-% of the array. However, for technical reasons, in this preamble, the user must
-% use the letters |L|, |C| and~|R|\footnote{The column types |L|, |C| and |R|
-% are defined locally inside |{NiceArray}| with |\newcolumntype| of \pkg{array}.
-% This definition overrides an eventual previous definition.} instead of |l|,
-% |c| and |r|. In a command |\multicolumn|, one should also use the letters |L|,
-% |C|, |R|.
-%
-% It's possible to use the constructions |p{...}|, |m{...}|, |b{...}|,
-% |w{...}{...}|, |W{...}{...}|, "|", |>{...}|, |<{...}|, |@{...}|, |!{...}| and
-% |*{n}{...}|. However, in the environment |{NiceArray}| (and its variants), the
-% content of the columns of type |w| or |W| is composed in math mode (in
-% |{array}| of \pkg{array}, they are composed in text mode).
-%
-% \bigskip
-% The package \pkg{nicematrix} provides also the variants |{pNiceArray}|,
-%|{vNiceArray}|, |{VNiceArray}|, |{bNiceArray}| and |{BNiceArray}|.
-%
-% \bigskip
-% Of course, one of the benefits of |{pNiceArray}| over |{pNiceMatrix}| is the
-% possibility of drawing vertical rules:
-%
-%\bigskip
-% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
-% $\left[\begin{NiceArray}{CCCC|C}
-% a_1 & ? & \Cdots & ? & ? \\
-% 0 & & \Ddots & \Vdots & \Vdots\\
-% \Vdots & \Ddots & \Ddots & ? \\
-% 0 & \Cdots & 0 & a_n & ?
-% \end{NiceArray}\right]$
-% \end{BVerbatim}
-% $\left[\begin{NiceArray}{CCCC|C}
-% a_1 & ? & \Cdots & ? & ? \\
-% 0 & & \Ddots & \Vdots & \Vdots\\
-% \Vdots & \Ddots & \Ddots & ? \\
-% 0 & \Cdots & 0 & a_n & ?
-% \end{NiceArray}\right]$
-%
-% \bigskip
-% Another benefit is the possibility of using different alignments of columns.
-%
-% \bigskip
-% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
-% $\begin{pNiceArray}{LCR}
-% a_{11} & \Cdots & a_{1n} \\
-% a_{21} & & a_{2n} \\
-% \Vdots & & \Vdots \\
-% a_{n-1,1} & \Cdots & a_{n-1,n}
-% \end{pNiceArray}$
-% \end{BVerbatim}
-% $\begin{pNiceArray}{LCR}
-% a_{11} & \Cdots & a_{1n} \\
-% a_{21} & & a_{2n} \\
-% \Vdots & & \Vdots \\
-% a_{n-1,1} & \Cdots & a_{n-1,n}
-% \end{pNiceArray}$
-%
-%
-% \bigskip
-% In fact, the environment |{pNiceArray}| and its variants are based upon a
-% more general environment, called |{NiceArrayWithDelims}|. The first two
-% mandatory arguments of this environment are the left and right delimiters used
-% in the construction of the matrix. It's possible to use
-% |{NiceArrayWithDelims}| if we want to use atypical or asymetrical delimiters.
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
-% $\begin{~emphase#NiceArrayWithDelims@}
-% {\downarrow}{\uparrow}{CCC}[margin]
-% 1 & 2 & 3 \\
-% 4 & 5 & 6 \\
-% 7 & 8 & 9
-% \end{~emphase#NiceArrayWithDelims@}$
-% \end{BVerbatim}
-% $\begin{NiceArrayWithDelims}
-% {\downarrow}{\uparrow}{CCC}[margin]
-% 1 & 2 & 3 \\
-% 4 & 5 & 6 \\
-% 7 & 8 & 9
-% \end{NiceArrayWithDelims}$
-%
-%
-% \bigskip
-% \section{The vertical position of the arrays}
-%
-% The package \pkg{nicematrix} provides a option |baseline| for the vertical
-% position of the arrays. This option takes as value an integer which is the
-% number of the row on which the array will be aligned.
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
-% $A = \begin{pNiceMatrix}[~emphase#baseline=2@]
-% \frac{1}{\sqrt{1+p^2}} & p & 1-p \\
-% 1 & 1 & 1 \\
-% 1 & p & 1+p
-% \end{pNiceMatrix}$
-% \end{BVerbatim}
-% $A = \begin{pNiceMatrix}[baseline=2]
-% \frac{1}{\sqrt{1+p^2}} & p & 1-p \\
-% 1 & 1 & 1 \\
-% 1 & p & 1+p
-% \end{pNiceMatrix}$
-%
-%
-% \medskip
-% It's also possible to use the option |baseline| with one of the special values
-% |t|, |c| or |b|. These letters may also be used absolutely like the option of
-% the environment |{array}| of \pkg{array}. The initial value of |baseline| is~|c|.
-%
-%
-% \medskip
-% In the following example, we use the option |t| (equivalent to |baseline=t|)
-% immediately after an |\item| of list. One should remark that the presence of
-% a |\hline| at the beginning of the array doesn't prevent the alignment of the
-% baseline with the baseline of the first row (with |{array}| of \pkg{array},
-% one must use |\firsthline|\footnote{It's also possible to use |\firsthline|
-% with |{NiceArray}|.}).
-%
-% \smallskip
-% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
-% \begin{enumerate}
-% \item an item
-% \smallskip
-% \item \renewcommand{\arraystretch}{1.2}
-% $\begin{NiceArray}~emphase#[t]@{LCCCCCC}
-% \hline
-% n & 0 & 1 & 2 & 3 & 4 & 5 \\
-% u_n & 1 & 2 & 4 & 8 & 16 & 32
-% \hline
-% \end{NiceArray}$
-% \end{enumerate}
-% \end{BVerbatim}
-% \begin{minipage}{5cm}
-% \begin{enumerate}
-% \item an item
-% \smallskip
-% \item \renewcommand{\arraystretch}{1.2}
-% $\begin{NiceArray}[t]{LCCCCCC}
-% \hline
-% n & 0 & 1 & 2 & 3 & 4 & 5 \\
-% u_n & 1 & 2 & 4 & 8 & 16 & 32 \\
-% \hline
-% \end{NiceArray}$
-% \end{enumerate}
-% \end{minipage}
-%
-% \medskip
-% However, it's also possible to use the tools of \pkg{booktabs}: |\toprule|,
-% |\bottomrule| and |\midrule|.\par\nobreak
-%
-% \smallskip
-% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
-% \begin{enumerate}
-% \item an item
-% \smallskip
-% \item
-% $\begin{NiceArray}[t]{LCCCCCC}
-% ~emphase#\toprule@
-% n & 0 & 1 & 2 & 3 & 4 & 5 \\
-% ~emphase#\midrule@
-% u_n & 1 & 2 & 4 & 8 & 16 & 32
-% ~emphase#\bottomrule@
-% \end{NiceArray}$
-% \end{enumerate}
-% \end{BVerbatim}
-% \begin{minipage}{5cm}
-% \begin{enumerate}
-% \item an item
-% \smallskip
-% \item
-% $\begin{NiceArray}[t]{LCCCCCC}
-% \toprule
-% n & 0 & 1 & 2 & 3 & 4 & 5 \\
-% \midrule
-% u_n & 1 & 2 & 4 & 8 & 16 & 32 \\
-% \bottomrule
-% \end{NiceArray}$
-% \end{enumerate}
-% \end{minipage}
-%
-%
-% \bigskip
-% \section{The exterior rows and columns}
-% The options |first-row|, |last-row|, |first-col| and |last-col| allow the
-% composition of exterior rows and columns in the environments of
-% \pkg{nicematrix}.
-% \label{exterior}
-%
-% A potential ``first row'' (exterior) has the number $0$ (and not $1$). Idem
-% for the potential ``first column''.
-%
-% \begin{Verbatim}
-% $\begin{pNiceMatrix}[~emphase#first-row,last-row,first-col,last-col@]
-% $\begin{pNiceMatrix}[~emphase#first-row,last-row,first-col,last-col@,nullify-dots]
-% & C_1 & \Cdots & & C_4 & \\
-% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
-% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
-% & a_{31} & a_{32} & a_{33} & a_{34} & \\
-% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
-% & C_1 & \Cdots & & C_4 &
-% \end{pNiceMatrix}$
-% \end{pNiceMatrix}$
-% \end{Verbatim}
-%
-% \[\begin{pNiceMatrix}[first-row,last-row,first-col,last-col,nullify-dots]
-% & C_1 & \Cdots & & C_4 & \\
-% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
-% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
-% & a_{31} & a_{32} & a_{33} & a_{34} & \\
-% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
-% & C_1 & \Cdots & & C_4 &
-% \end{pNiceMatrix}\]
-%
-%
-% \bigskip
-% We have several remarks to do.
-% \begin{itemize}
-% \item For the environments with an explicit preamble (i.e. |{NiceArray}| and
-% its variants), no letter must be given in that preamble for the potential
-% first column and the potential last column: they will automatically (and
-% necessarily) be of type |R| for the first column and |L| for the last one.
-% \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''.
-% \begin{itemize}
-% \item For the environments with explicit preamble, like |{NiceTabular}| and
-% |{pNiceArray}|, the number of columns can obviously be computed from the
-% preamble.
-%
-% \item When the option |light-syntax| (cf. p. \pageref{light-syntax}) is used,
-% \pkg{nicematrix} has, in any case, to load the whole body of the environment
-% (and that's why it's not possible to put verbatim material in the array with
-% the option |light-syntax|). The analysis of this whole body gives the number
-% of rows (but not the number of columns).
-%
-% \item In the other cases, \pkg{nicematrix} compute the number of rows and
-% columns during the first compilation and write the result in the |aux| file
-% for the next run.
-%
-% \textsl{However, it's possible to provide the number of the last row and the
-% number of the last column as values of the options |last-row| and |last-col|,
-% tending to an acceleration of the whole compilation of the document.} That's
-% what we will do throughout the rest of the document.
-% \end{itemize}
-% \end{itemize}
-%
-% \bigskip
-% It's possible to control the appearance of these rows and columns with options
-% |code-for-first-row|, |code-for-last-row|, |code-for-first-col| and
-% |code-for-last-col|. These options
-% specify tokens that will be inserted before each cell of the corresponding row
-% or column.
-%
-%
-% \begin{Verbatim}
-% \NiceMatrixOptions{~emphase#code-for-first-row@ = \color{red},
-% ~emphase#code-for-first-col@ = \color{blue},
-% ~emphase#code-for-last-row@ = \color{green},
-% ~emphase#code-for-last-col@ = \color{magenta}}
-% $\begin{pNiceArray}{CC|CC}[first-row,last-row=5,first-col,last-col,nullify-dots]
-% & C_1 & \Cdots & & C_4 & \\
-% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
-% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
-% \hline
-% & a_{31} & a_{32} & a_{33} & a_{34} & \\
-% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
-% & C_1 & \Cdots & & C_4 &
-% \end{pNiceArray}$
-% \end{Verbatim}
-%
-% \begin{scope}
-% \NiceMatrixOptions{code-for-first-row = \color{red},
-% code-for-first-col = \color{blue},
-% code-for-last-row = \color{green},
-% code-for-last-col = \color{magenta}}
-% \begin{displaymath}
-% \begin{pNiceArray}{CC|CC}[first-row,last-row=5,first-col,last-col,nullify-dots]
-% & C_1 & \multicolumn1C{\Cdots} & & C_4 & \\
-% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
-% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
-% \hline
-% & a_{31} & a_{32} & a_{33} & a_{34} & \\
-% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
-% & C_1 & \multicolumn1C{\Cdots} & & C_4 &
-% \end{pNiceArray}
-% \end{displaymath}
-% \end{scope}
-%
-%
-% \emph{Remarks}
-% \begin{itemize}[beginpenalty=10000]
-% \item As shown in the previous example, an horizontal rule (drawn by |\hline|)
-% doesn't extend in the exterior columns and a vertical rule (specified by a
-% ``\verb+|+'' in the preamble of the array) doesn't extend in the exterior
-% rows.\footnote{The latter is not true when the package \pkg{arydshln} is
-% loaded besides \pkg{nicematrix}. In fact, \pkg{nicematrix} and \pkg{arydhsln}
-% are not totally compatible because \pkg{arydshln} redefines many internals of
-% \pkg{array}. On another hand, if one really wants a vertical rule running in
-% the first and in the last row, he should use |!{\vline}| instead of \verb+|+
-% in the preamble of the array.}
-%
-% If one wishes to define new specifiers for columns in order to draw vertical
-% rules (for example thicker than the standard rules), he should consider the
-% command |\OnlyMainNiceMatrix| described on page~\pageref{OnlyMainNiceMatrix}.
-%
-% \item A specification of color present in |code-for-first-row| also applies to
-% a dotted line draw in this exterior ``first row'' (excepted if a value has
-% been given to |xdots/color|). Idem for the other exterior rows and columns.
-%
-% \item Logically, the potential option |columns-width| (described
-% p.~\pageref{width}) doesn't apply to the ``first column'' and ``last column''.
-% \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).
-% \end{itemize}
-%
%
%
+% \section{Other features}
%
+% \subsection{Use of the column type S of siunitx}
%
-% \section{The dotted lines to separate rows or columns}
-%
-%
-% In the environments of the package \pkg{nicematrix}, it's possible to use
-% the command |\hdottedline| (provided by \pkg{nicematrix}) which is a
-% counterpart of the classical commands |\hline| and |\hdashline| (the latter is
-% a command of \pkg{arydshln}).
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm]
-% \begin{pNiceMatrix}
-% 1 & 2 & 3 & 4 & 5 \\
-% ~emphase#\hdottedline@
-% 6 & 7 & 8 & 9 & 10 \\
-% 11 & 12 & 13 & 14 & 15
-% \end{pNiceMatrix}
-% \end{BVerbatim}
-% $\begin{pNiceMatrix}
-% 1 & 2 & 3 & 4 & 5 \\
-% \hdottedline
-% 6 & 7 & 8 & 9 & 10 \\
-% 11 & 12 & 13 & 14 & 15
-% \end{pNiceMatrix}$
-%
-%
-% \bigskip
-% In the environments with an explicit preamble (like |{NiceArray}|, etc.), it's
-% possible to draw a vertical dotted line with the specifier ``|:|''.
+% If the package \pkg{siunitx} is loaded (before or after \pkg{nicematrix}),
+% it's possible to use the |S| column type of \pkg{siunitx} in the environments
+% of \pkg{nicematrix}. The implementation doesn't use explicitly any private
+% macro of \pkg{siunitx}.
%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm]
-% \left(\begin{NiceArray}{CCCC~emphase#:@C}
-% 1 & 2 & 3 & 4 & 5 \\
-% 6 & 7 & 8 & 9 & 10 \\
-% 11 & 12 & 13 & 14 & 15
-% \end{NiceArray}\right)
-% \end{BVerbatim}
-% $\left(\begin{NiceArray}{CCCC:C}
-% 1 & 2 & 3 & 4 & 5 \\
-% 6 & 7 & 8 & 9 & 10 \\
-% 11 & 12 & 13 & 14 & 15
-% \end{NiceArray}\right)$
-%
-%
-% \bigskip
-% These dotted lines do \emph{not} extend in the potential exterior rows and
-% columns.
-%
%
% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm]
-% $\begin{pNiceArray}{CCC:C}[
-% first-row,last-col,
-% code-for-first-row = \color{blue}\scriptstyle,
-% code-for-last-col = \color{blue}\scriptstyle ]
-% C_1 & C_2 & C_3 & C_4 \\
-% 1 & 2 & 3 & 4 & L_1 \\
-% 5 & 6 & 7 & 8 & L_2 \\
-% 9 & 10 & 11 & 12 & L_3 \\
-% \hdottedline
-% 13 & 14 & 15 & 16 & L_4
+% \begin{BVerbatim}[baseline = c, boxwidth = 10.5cm]
+% $\begin{pNiceArray}{~emphase#S@CWc{1cm}C}[nullify-dots,first-row]
+% {C_1} & \Cdots & & C_n \\
+% 2.3 & 0 & \Cdots & 0 \\
+% 12.4 & \Vdots & & \Vdots \\
+% 1.45 \\
+% 7.2 & 0 & \Cdots & 0
% \end{pNiceArray}$
% \end{BVerbatim}
-% $\begin{pNiceArray}{CCC:C}[
-% first-row,last-col,
-% code-for-first-row = \color{blue}\scriptstyle,
-% code-for-last-col = \color{blue}\scriptstyle ]
-% C_1 & C_2 & C_3 & C_4 \\
-% 1 & 2 & 3 & 4 & L_1 \\
-% 5 & 6 & 7 & 8 & L_2 \\
-% 9 & 10 & 11 & 12 & L_3 \\
-% \hdottedline
-% 13 & 14 & 15 & 16 & L_4
+% $\begin{pNiceArray}{SCWc{1cm}C}[nullify-dots,first-row]
+% {C_1} & \Cdots & & C_n \\
+% 2.3 & 0 & \Cdots & 0 \\
+% 12.4 & \Vdots & & \Vdots \\
+% 1.45 \\
+% 7.2 & 0 & \Cdots & 0
% \end{pNiceArray}$
%
-% \bigskip
-% It's possible to change in \pkg{nicematrix} the letter used to specify a
-% vertical dotted line with the option |letter-for-dotted-lines| available in
-% |\NiceMatrixOptions|.
-%
-% \bigskip
-% \emph{Remark} : In the package \pkg{array} (on which the package
-% \pkg{nicematrix} relies), horizontal and vertical rules make the array larger
-% or wider by a quantity equal to the width of the rule\footnote{In fact, this
-% is true only for |\hline| and ``"|"'' but not for |\cline|.}. In
-% \pkg{nicematrix}, the dotted lines drawn by |\hdottedline| and ``|:|'' do
-% likewise.
-%
-%
-%
-% \section{The width of the columns}
-% \label{width}
-%
-% In the environments with an explicit preamble (like |{NiceArray}|,
-% |{pNiceArray}|, etc.), it's possible to fix the width of a given column with
-% the standard letters |w| and |W| of the package \pkg{array}. In the
-% environments of \pkg{nicematrix}, the cells of such columns are composed in
-% mathematical mode, whereas, in |{array}| of \pkg{array}, they are composed in
-% text mode.
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
-% $\left(\begin{NiceArray}{~emphase#wc{1cm}@CC}
-% 1 & 12 & -123 \\
-% 12 & 0 & 0 \\
-% 4 & 1 & 2
-% \end{NiceArray}\right)$
-% \end{BVerbatim}
-% $\left(\begin{NiceArray}{wc{1cm}CC}
-% 1 & 12 & -123 \\
-% 12 & 0 & 0 \\
-% 4 & 1 & 2
-% \end{NiceArray}\right)$
-%
-%
-% \bigskip
-% In the environments of \pkg{nicematrix}, it's also possible to fix the \emph{minimal}
-% width of all the columns of a matrix directly with the option |columns-width|.
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
-% $\begin{pNiceMatrix}[~emphase#columns-width = 1cm@]
-% 1 & 12 & -123 \\
-% 12 & 0 & 0 \\
-% 4 & 1 & 2
-% \end{pNiceMatrix}$
-% \end{BVerbatim}
-% $\begin{pNiceMatrix}[columns-width = 1cm]
-% 1 & 12 & -123 \\
-% 12 & 0 & 0 \\
-% 4 & 1 & 2
-% \end{pNiceMatrix}$
-%
-% \medskip
-% Note that the space inserted between two columns (equal to 2 |\arraycolsep|)
-% is not suppressed (of course, it's possible to suppress this space by setting
-% |\arraycolsep| equal to $0$~pt).
-%
-% \bigskip
-% It's possible to give the special value |auto| to the option |columns-width|:
-% all the columns of the array will have a width equal to the widest cell of
-% the array.\footnote{The result is achieved with only one compilation (but Tikz
-% will have written informations in the |.aux| file and a message requiring a
-% second compilation will appear).}\par\nobreak
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
-% $\begin{pNiceMatrix}[~emphase#columns-width = auto@]
-% 1 & 12 & -123 \\
-% 12 & 0 & 0 \\
-% 4 & 1 & 2
-% \end{pNiceMatrix}$
-% \end{BVerbatim}
-% $\begin{pNiceMatrix}[columns-width = auto]
-% 1 & 12 & -123 \\
-% 12 & 0 & 0 \\
-% 4 & 1 & 2
-% \end{pNiceMatrix}$
-%
-% \bigskip
-% Without surprise, it's possible to fix the minimal width of the columns of all
-% the matrices of a current scope with the command
-% |\NiceMatrixOptions|.\par\nobreak
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=8.5cm]
-% ~emphase#\NiceMatrixOptions{columns-width=10mm}@
-% $\begin{pNiceMatrix}
-% a & b \\ c & d
-% \end{pNiceMatrix}
-% =
-% \begin{pNiceMatrix}
-% 1 & 1245 \\ 345 & 2
-% \end{pNiceMatrix}$
-% \end{BVerbatim}
-% \begin{scope}
-% \NiceMatrixOptions{columns-width=10mm}
-% $\begin{pNiceMatrix}
-% a & b \\
-% c & d
-% \end{pNiceMatrix}
-% =
-% \begin{pNiceMatrix}
-% 1 & 1245 \\
-% 345 & 2
-% \end{pNiceMatrix}$
-% \end{scope}
-%
-%
-% \bigskip
-% But it's also possible to fix a zone where all the matrices will have their
-% columns of the same width, equal to the widest cell of all the matrices. This
-% construction uses the environment |{NiceMatrixBlock}| with the option
-% |auto-columns-width|\footnote{At this time, this is the only usage of the
-% environment |{NiceMatrixBlock}| but it may have other usages in the future.}.
-% The environment |{NiceMatrixBlock}| has no direct link with the command
-% |\Block| presented just below (cf.~p.~\pageref{Block}).
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=8.5cm]
-% ~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@
-% $\begin{pNiceMatrix}
-% a & b \\ c & d
-% \end{pNiceMatrix}
-% =
-% \begin{pNiceMatrix}
-% 1 & 1245 \\ 345 & 2
-% \end{pNiceMatrix}$
-% ~emphase#\end{NiceMatrixBlock}@
-% \end{BVerbatim}
-% \begin{NiceMatrixBlock}[auto-columns-width]
-% $\begin{pNiceMatrix}
-% a & b \\ c & d
-% \end{pNiceMatrix}
-% =
-% \begin{pNiceMatrix}
-% 1 & 1245 \\ 345 & 2
-% \end{pNiceMatrix}$
-% \end{NiceMatrixBlock}
-%
-% \medskip
-% \textbf{Several compilations may be necessary to achieve the job.}
-%
-%
-% \section{Block matrices}
-% \label{Block}
-%
-% This section has no direct link with the previous one where an environment
-% |{NiceMatrixBlock}| was introduced.
-%
-% In the environments of \pkg{nicematrix}, it's possible to use the command
-% |\Block| in order to place an element in the center of a rectangle of merged
-% cells of the array.
-%
-% The command |\Block| must be used in the upper leftmost cell of the array with
-% two arguments. The first argument is the size of the block with the syntax
-% $i$\verb|-|$j$ where $i$ is the number of rows of the block and $j$ its number
-% of columns. The second argument is the content of the block (composed in math
-% mode). A Tikz node corresponding to the merged cells is created with the name
-% ``$i$-$j$-block''. If the user has required the creation of the ``medium
-% nodes'', a node of this type is also created with a name suffixed by
-% |-medium|.
-%
-% \medskip
-% In the following examples, we use the command |\arrayrulecolor| of
-% \pkg{colortbl}.
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
-% \arrayrulecolor{blue}
-% $\begin{bNiceArray}{CCC|C}[margin]
-% ~emphase#\Block{3-3}{A}@ & & & 0 \\
-% & \hspace*{1cm} & & \Vdots \\
-% & & & 0 \\
-% \hline
-% 0 & \Cdots& 0 & 0
-% \end{bNiceArray}$
-% \arrayrulecolor{black}
-% \end{BVerbatim}
-% \begin{scope}
-% \arrayrulecolor{blue}
-% $\begin{bNiceArray}{CCC|C}[margin]
-% \Block{3-3}{A} & & & 0 \\
-% & \hspace*{1cm} & & \Vdots \\
-% & & & 0 \\
-% \hline
-% 0 & \Cdots& 0 & 0
-% \end{bNiceArray}$
-% \arrayrulecolor{black}
-% \end{scope}
-%
-% \bigskip
-% One may wish to raise the size of the ``$A$'' placed in the block of the
-% previous example. Since this element is composed in math mode, it's not
-% possible to use directly a command like |\large|, |\Large| and |\LARGE|.
-% That's why the command |\Block| provides an option between angle brackets to
-% specify some TeX code which will be inserted before the beginning of the
-% math mode.
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
-% \arrayrulecolor{blue}
-% $\begin{bNiceArray}{CCC|C}[margin]
-% \Block{3-3}~emphase#<\Large>@{A} & & & 0 \\
-% & \hspace*{1cm} & & \Vdots \\
-% & & & 0 \\
-% \hline
-% 0 & \Cdots& 0 & 0
-% \end{bNiceArray}$
-% \arrayrulecolor{black}
-% \end{BVerbatim}
-% \begin{scope}
-% \arrayrulecolor{blue}
-% $\begin{bNiceArray}{CCC|C}[margin]
-% \Block{3-3}<\Large>{A} & & & 0 \\
-% & \hspace*{1cm} & & \Vdots \\
-% & & & 0 \\
-% \hline
-% 0 & \Cdots& 0 & 0
-% \end{bNiceArray}$
-% \arrayrulecolor{black}
-% \end{scope}
-%
-% \medskip
-% For technical reasons, you can't write |\Block{|$i$|-|$j$|}{<}|. But you can
-% write |\Block{|$i$|-|$j$|}<>{<}| with the expected result.
-%
-%
-% \section{The color of the rows and columns}
-%
-% With the classical package \pkg{colortbl}, it's possible to color the cells,
-% rows and columns of a tabular. However, the resulting \textsc{pdf} is not
-% always perfectly displayed by the \textsc{pdf} viewers, in particular in
-% conjonction with rules. With some \textsc{pdf} viewers, some vertical rules
-% seem to vanish. On the other side, some thin horizontal white lines may appear
-% in some circonstances.
-%
-%
-% \medskip
-% The version 4.0 of \pkg{nicematrix} provide similar tools which do not
-% present these drawbacks. This version provides a key |code-before| for some
-% code which will be executed \emph{before} the drawing of the tabular. In this
-% |code-before|, new commands are available: |\cellcolor|, |\rectanglecolor|,
-% |\rowcolor|, |\columncolor|, |\rowcolors| and |\chessboardcolors|.
-%
% \medskip
-% \begin{itemize}
-% \item The command |\cellcolor| takes its name from the command |\cellcolor| of
-% \pkg{colortbl}.
-%
-% This command takes in arguments a color and a list of cells, each of which
-% with the format $i$-$j$ where $i$ is the number of row and $j$ the number of
-% colummn of the cell.
-%
-%
-% \medskip
-% \begin{scope}
-% \hfuzz=10cm
-% \begin{BVerbatim}[boxwidth=10cm,baseline=c]
-% \begin{NiceTabular}{|C|C|C|}[code-before = ~emphase#\cellcolor{red!15}{3-1,2-2,1-3}@]
-% \hline
-% a & b & c \\ \hline
-% e & f & g \\ \hline
-% h & i & j \\ \hline
-% \end{NiceTabular}
-% \end{BVerbatim}
-% \begin{NiceTabular}{|C|C|C|}[code-before = \cellcolor{red!15}{3-1,2-2,1-3}]
-% \hline
-% a & b & c \\ \hline
-% e & f & g \\ \hline
-% h & i & j \\ \hline
-% \end{NiceTabular}
-% \end{scope}
-%
-% \bigskip
-% \item The command |\rectanglecolor| takes three arguments. The first is the
-% color. The second is the upper-left cell of the rectangle and the third is
-% the lower-right cell of the rectangle.
-%
-% \medskip
-% \begin{scope}
-% \hfuzz=10cm
-% \begin{BVerbatim}[boxwidth=10cm,baseline=c]
-% \begin{NiceTabular}{|C|C|C|}[code-before = ~emphase#\rectanglecolor{red!15}{2-2}{3-3}@]
-% \hline
-% a & b & c \\ \hline
-% e & f & g \\ \hline
-% h & i & j \\ \hline
-% \end{NiceTabular}
-% \end{BVerbatim}
-% \begin{NiceTabular}{|C|C|C|}[code-before = \rectanglecolor{red!15}{2-2}{3-3}]
-% \hline
-% a & b & c \\ \hline
-% e & f & g \\ \hline
-% h & i & j \\ \hline
-% \end{NiceTabular}
-% \end{scope}
-%
-%
-%
-% \bigskip
-% \item The command |\rowcolor| takes its name from the command |\rowcolor| of
-% \pkg{colortbl}. Its first argument is the color and the second is a
-% comma-separated list of rows or interval of rows with the form $a$-$b$ (an
-% interval of the form $a$- represent all the rows from the row $a$ until the end).
-%
-% \medskip
-% \begin{scope}
-% \hfuzz = 10cm
-% \begin{BVerbatim}[boxwidth=9cm,baseline=c]
-% $\begin{NiceArray}{LLL}[hvlines, ~emphase#code-before = \rowcolor{red!15}{1,3-5,8-}@]
-% a_1 & b_1 & c_1 \\
-% a_2 & b_2 & c_2 \\
-% a_3 & b_3 & c_3 \\
-% a_4 & b_4 & c_4 \\
-% a_5 & b_5 & c_5 \\
-% a_6 & b_6 & c_6 \\
-% a_7 & b_7 & c_7 \\
-% a_8 & b_8 & c_8 \\
-% a_9 & b_9 & c_9 \\
-% a_{10} & b_{10} & c_{10} \\
-% \end{NiceArray}$
-% \end{BVerbatim}
-% $\begin{NiceArray}{LLL}[baseline=4,hvlines, code-before = \rowcolor{red!15}{1,3-5,8-}]
-% a_1 & b_1 & c_1 \\
-% a_2 & b_2 & c_2 \\
-% a_3 & b_3 & c_3 \\
-% a_4 & b_4 & c_4 \\
-% a_5 & b_5 & c_5 \\
-% a_6 & b_6 & c_6 \\
-% a_7 & b_7 & c_7 \\
-% a_8 & b_8 & c_8 \\
-% a_9 & b_9 & c_9 \\
-% a_{10} & b_{10} & c_{10} \\
-% \end{NiceArray}$
-% \end{scope}
-%
-%
-% \bigskip
-% \item The command |\columncolor| takes its name from the command
-% |\columncolor| of \pkg{colortbl}. Its syntax is similar to the syntaxe of
-% |\rowcolor|.
-%
-% \bigskip
-% \item The command |\rowcolors| (with a \emph{s}) takes its name from the
-% command |\rowcolors| of \pkg{xcolor}. The \emph{s} emphasizes the fact that
-% there is \emph{two} colors. This command colors alternately the rows of the
-% tabular, beginning with the row whose number is given in first argument. The
-% two other arguments are the colors.
-%
-% \medskip
-% \begin{scope}
-% \hfuzz=10cm
-% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
-% \begin{NiceTabular}{LR}%
-% [~emphase#code-before = \rowcolor{red!15}{1} \rowcolors{3}{blue!10}{}@]
-% \toprule
-% Town & Habitants \\
-% \midrule
-% Pau & 80000 \\
-% Paris & 2000000 \\
-% Toulouse & 700000 \\
-% Reims & 40000 \\
-% \bottomrule
-% \end{NiceTabular}
-% \end{BVerbatim}
-% \begin{NiceTabular}{LR}[code-before =\rowcolor{red!15}{1} \rowcolors{3}{blue!10}{}]
-% \toprule
-% Ville & habitants \\
-% \midrule
-% Pau & 80000 \\
-% Paris & 2000000 \\
-% Toulouse & 700000 \\
-% Reims & 40000 \\
-% \bottomrule
-% \end{NiceTabular}
-% \end{scope}
-%
-% \bigskip
-% \item The command |\chessboardcolors| take in arguments two colors and colors
-% the cells of the tabular in quincunx with these colors.
-%
-% \medskip
-% \begin{scope}
-% \hfuzz=10cm
-% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
-% $\begin{pNiceMatrix}[R,margin, ~emphase#code-before=\chessboardcolors{red!15}{blue!15}@]
-% 1 & -1 & 1 \\
-% -1 & 1 & -1 \\
-% 1 & -1 & 1
-% \end{pNiceMatrix}$
-% \end{BVerbatim}
-% $\begin{pNiceMatrix}[R,baseline=1, margin, code-before = \chessboardcolors{red!15}{blue!15}]
-% 1 & -1 & 1 \\
-% -1 & 1 & -1 \\
-% 1 & -1 & 1
-% \end{pNiceMatrix}$
-% \end{scope}
-%
-% \end{itemize}
-%
+% On the other hand, the |d| columns of the package \pkg{dcolumn} are not
+% supported by \pkg{nicematrix}.
%
-%
-% \section{Advanced features}
%
+% \subsection{Alignement option in \{NiceMatrix\}}
%
-% \subsection{Alignement option in NiceMatrix}
+% \label{key-R}
%
% The environments without preamble (|{NiceMatrix}|, |{pNiceMatrix}|,
% |{bNiceMatrix}|, etc.) provide two options |l| and |r| (equivalent at |L| and
% |R|) which generate all the columns aligned leftwards (or
-% rightwards).\footnote{This is a part of the functionality provided by the
-% environments |{pmatrix*}|, |{bmatrix*}|, etc. of \pkg{mathtools}.}
+% rightwards).
%
%
% \medskip
@@ -1780,6 +1853,11 @@ version 2005/12/01 or later.
% \sin x & \cos x
% \end{bNiceMatrix}$
%
+% \medskip
+% There is also a key |S| which sets all the columns all type |S| of
+% \pkg{siunitx} (if this package is loaded).\footnote{This is a part of the
+% functionality provided by the environments |{pmatrix*}|, |{bmatrix*}|, etc. of
+% \pkg{mathtools}.}
%
% \subsection{The command \textbackslash rotate}
%
@@ -1900,9 +1978,10 @@ version 2005/12/01 or later.
% exists) has also the number~$0$.}. Of course, the user must not change the
% value of these counters which are used internally by \pkg{nicematrix}.
%
-% In the |code-after| (cf. p. \pageref{code-after}), |iRow| represents the total
-% number of rows (excepted the potential exterior rows) and |jCol| represents
-% the total number of columns (excepted the potential exterior columns).
+% In the |code-before| (cf. p. \pageref{code-before}) and in the |code-after|
+% (cf. p. \pageref{code-after}), |iRow| represents the total number of rows
+% (excepted the potential exterior rows) and |jCol| represents the total number
+% of columns (excepted the potential exterior columns).
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
@@ -1929,8 +2008,8 @@ version 2005/12/01 or later.
%
% \medskip
% If LaTeX counters called |iRow| and |jCol| are defined in the document by
-% packages other than \pkg{nicematrix} (or by the user), they are shadowed in
-% the environments of \pkg{nicematrix}.
+% packages other than \pkg{nicematrix} (or by the final user), they are shadowed
+% in the environments of \pkg{nicematrix}.
%
% \bigskip
% The package \pkg{nicematrix} also provides commands in order to compose
@@ -1950,98 +2029,15 @@ version 2005/12/01 or later.
% \end{Verbatim}
%
%
-% $C = \pAutoNiceMatrix{3-3}{C_{\arabic{iRow},\arabic{jCol}}}$
-%
-% \subsection{The options hlines, vlines and hvlines}
-%
-% \label{hvlines}
-% You can add horizontal rules between rows in the environments of
-% \pkg{nicematrix} with the usual command |\hline| and you can use the specifier
-% ``"|"'' to add vertical rules. However, by convenience, the package
-% \pkg{nicematrix} also provides the option |hlines| (resp. |vlines|) which will
-% draw all the horizontal (resp. vertical) rules (excepted, of course, the
-% exterior rules corresponding to the exterior rows and columns). The key
-% |hvlines| is an alias for the conjonction for the keys |hlines| et |vlines|.
-%
-% % \medskip
-% In the following example, we use the command |\arrayrulecolor| of
-% \pkg{colortbl}.
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
-% \arrayrulecolor{blue}
-% $\begin{NiceArray}{CCCC}%
-% [~emphase#hvlines@,first-row,first-col]
-% & e & a & b & c \\
-% e & e & a & b & c \\
-% a & a & e & c & b \\
-% b & b & c & e & a \\
-% c & c & b & a & e
-% \end{NiceArray}$
-% \arrayrulecolor{black}
-% \end{BVerbatim}
-% \arrayrulecolor{blue}
-% $\begin{NiceArray}{CCCC}[hvlines,first-row,first-col]
-% & e & a & b & c \\
-% e & e & a & b & c \\
-% a & a & e & c & b \\
-% b & b & c & e & a \\
-% c & c & b & a & e
-% \end{NiceArray}$
-% \arrayrulecolor{black}
-%
-% \bigskip
-% However, there is a difference between the key |vlines| and the use of
-% the specifier ``"|"'' in the preamble of the environment: the rules drawn by
-% |vlines| completely cross the double-rules drawn by |\hline\hline|.
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=11.5cm]
-% $\begin{NiceArray}{CCCC}[vlines] \hline
-% a & b & c & d \\ \hline \hline
-% 1 & 2 & 3 & 4 \\
-% 1 & 2 & 3 & 4 \\ \hline
-% \end{NiceArray}$
-% \end{BVerbatim}
-% $\begin{NiceArray}{CCCC}[vlines]
-% \hline
-% a & b & c & d \\
-% \hline \hline
-% 1 & 2 & 3 & 4 \\
-% 1 & 2 & 3 & 4 \\
-% \hline
-% \end{NiceArray}$
-%
-% \bigskip
-% For the environments with delimiters (for example |{pNiceArray}| or
-% |{pNiceMatrix}|), the option |vlines| don't draw vertical rules on both sides,
-% where are the delimiters (fortunately).
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
-% \setlength{\arrayrulewidth}{0.2pt}
-% $\begin{pNiceMatrix}[vlines]
-% 1 & 2 & 3 & 4 & 5 & 6 \\
-% 1 & 2 & 3 & 4 & 5 & 6 \\
-% 1 & 2 & 3 & 4 & 5 & 6
-% \end{pNiceMatrix}$
-% \end{BVerbatim}
-% \begin{scope}
-% \setlength{\arrayrulewidth}{0.2pt}
-% $\begin{pNiceMatrix}[vlines]
-% 1 & 2 & 3 & 4 & 5 & 6 \\
-% 1 & 2 & 3 & 4 & 5 & 6 \\
-% 1 & 2 & 3 & 4 & 5 & 6
-% \end{pNiceMatrix}$
-% \end{scope}
+% \[C = \pAutoNiceMatrix{3-3}{C_{\arabic{iRow},\arabic{jCol}}}\]
%
%
% \subsection{The option light-syntax}
%
% \label{light-syntax}
-% The option |light-syntax|\footnote{This option is inspired by the package
-% \pkg{spalign} of Joseph Rabinoff.} allows the user to compose the arrays with a
-% lighter syntax, which gives a more readable TeX source.
+% The option |light-syntax| (inpired by the package \pkg{spalign}) allows the
+% user to compose the arrays with a lighter syntax, which gives a better
+% legibility of the TeX source.
%
% When this option is used, one should use the semicolon for the end of a row
% and spaces or tabulations to separate the columns. However, as usual in the
@@ -2080,36 +2076,419 @@ version 2005/12/01 or later.
% analyzed. The environment doesn't behave in that case as a standard
% environment of LaTeX which only put TeX commands before and after the content.}
%
-% \subsection{Use of the column type S of siunitx}
%
-% If the package \pkg{siunitx} is loaded (before or after \pkg{nicematrix}),
-% it's possible to use the |S| column type of \pkg{siunitx} in the environments
-% of \pkg{nicematrix}. The implementation doesn't use explicitly any private
-% macro of \pkg{siunitx}.
+%
+% \subsection{The environment \{NiceArrayWithDelims\}}
+%
+% In fact, the environment |{pNiceArray}| and its variants are based upon a
+% more general environment, called |{NiceArrayWithDelims}|. The first two
+% mandatory arguments of this environment are the left and right delimiters used
+% in the construction of the matrix. It's possible to use
+% |{NiceArrayWithDelims}| if we want to use atypical or asymetrical delimiters.
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
+% $\begin{~emphase#NiceArrayWithDelims@}
+% {\downarrow}{\uparrow}{CCC}[margin]
+% 1 & 2 & 3 \\
+% 4 & 5 & 6 \\
+% 7 & 8 & 9
+% \end{~emphase#NiceArrayWithDelims@}$
+% \end{BVerbatim}
+% $\begin{NiceArrayWithDelims}
+% {\downarrow}{\uparrow}{CCC}[margin]
+% 1 & 2 & 3 \\
+% 4 & 5 & 6 \\
+% 7 & 8 & 9
+% \end{NiceArrayWithDelims}$
+%
+%
+%
+% \section{Utilisation of Tikz with nicematrix}
%
+% \label{name}
+% \subsection{The nodes corresponding to the contents of the cells}
+%
+% The package \pkg{nicematrix} creates a PGF/Tikz node for each (non-empty) cell
+% of the considered array. These nodes are used to draw the dotted lines between
+% the cells of the matrix (inter alia).
+%
+% \smallskip
+% The nodes of a document must have distinct names. That's why the names of the
+% nodes created by \pkg{nicematrix} contains the number of the current
+% environment. Indeed, the environments of \pkg{nicematrix} are numbered by a
+% internal global counter.
+%
+% \smallskip
+% In the environment with the number $n$, the node of the row $i$ and
+% column~$j$ has for name |nm-|$n$|-|$i$|-|$j$.
+%
+% \smallskip
+% The command |\NiceMatrixLastEnv| provides the number of the last environment
+% of \pkg{nicematrix} (for LaTeX, it's a ``fully expandable'' command and not a
+% counter).
+%
+% \smallskip
+% However, it's advisable to use instead the key |name|. This key gives a name
+% to the current environment. When the environment has a name, the nodes are
+% accessible with the name ``\textsl{name}-$i$-$j$'' where \textsl{name} is the
+% name given to the array and $i$ and $j$ the numbers of row and column. It's
+% possible to use these nodes with \textsc{pgf} but the final user will
+% probably prefer to use Tikz (which is a convenient layer upon \textsc{pgf}).
+% However, one should remind that \pkg{nicematrix} doesn't load Tikz by default.
%
+% \bigskip
+% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
+% $\begin{pNiceMatrix}[name=~emphase#mymatrix@]
+% 1 & 2 & 3 \\
+% 4 & 5 & 6 \\
+% 7 & 8 & 9
+% \end{pNiceMatrix}$
+% \tikz[remember picture,overlay]
+% \draw ~emphase#(mymatrix-2-2)@ circle (2mm) ;
+% \end{BVerbatim}
+% $\begin{pNiceMatrix}[name=mymatrix]
+% 1 & 2 & 3 \\
+% 4 & 5 & 6 \\
+% 7 & 8 & 9
+% \end{pNiceMatrix}$
+% \tikz[remember picture,overlay]
+% \draw (mymatrix-2-2) circle (2mm) ;
+%
% \medskip
-% \begin{BVerbatim}[baseline = c, boxwidth = 10.5cm]
-% $\begin{pNiceArray}{~emphase#S@CWc{1cm}C}[nullify-dots,first-row]
-% {C_1} & \Cdots & & C_n \\
-% 2.3 & 0 & \Cdots & 0 \\
-% 12.4 & \Vdots & & \Vdots \\
-% 1.45 \\
-% 7.2 & 0 & \Cdots & 0
-% \end{pNiceArray}$
+% Don't forget the options |remember picture| and |overlay|.
+%
+% \bigskip
+% In the |code-after|, and if Tikz is loaded, the things are easier. One may
+% design the nodes with the form $i$-$j$: there is no need to indicate the
+% environment which is of course the current environment.
+%
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
+% $\begin{pNiceMatrix}
+% 1 & 2 & 3 \\
+% 4 & 5 & 6 \\
+% 7 & 8 & 9
+% \CodeAfter
+% \tikz \draw ~emphase#(2-2)@ circle (2mm) ;
+% \end{pNiceMatrix}$
% \end{BVerbatim}
-% $\begin{pNiceArray}{SCWc{1cm}C}[nullify-dots,first-row]
-% {C_1} & \Cdots & & C_n \\
-% 2.3 & 0 & \Cdots & 0 \\
-% 12.4 & \Vdots & & \Vdots \\
-% 1.45 \\
-% 7.2 & 0 & \Cdots & 0
-% \end{pNiceArray}$
+% $\begin{pNiceMatrix}
+% 1 & 2 & 3 \\
+% 4 & 5 & 6 \\
+% 7 & 8 & 9
+% \CodeAfter
+% \tikz \draw (2-2) circle (2mm) ;
+% \end{pNiceMatrix}$
+%
+%
+% \bigskip
+% In the following example, we have underlined all the nodes of the matrix (we
+% explain below the technic used : cf. p. \pageref{highlight}).
+%
+% \[\begin{pNiceMatrix}[
+% code-after = {\begin{tikzpicture}
+% [every node/.style = {blend mode = multiply,
+% fill = red!15,
+% inner sep = 0 pt }]
+% \node [fit = (1-1)] {} ;
+% \node [fit = (1-3)] {} ;
+% \node [fit = (2-2)] {} ;
+% \node [fit = (3-1)] {} ;
+% \node [fit = (3-3)] {} ;
+% \node [fit = (1-2)] {} ;
+% \node [fit = (2-1)] {} ;
+% \node [fit = (2-3)] {} ;
+% \node [fit = (3-2)] {} ;
+% \end{tikzpicture}}]
+% a & a + b & a + b + c \\
+% a & a & a + b \\
+% a & a & a
+% \end{pNiceMatrix}\]
+%
+%
%
+% \subsection{The ``medium nodes'' and the ``large nodes''}
+%
+% In fact, the package \pkg{nicematrix} can create ``extra nodes'': the ``medium
+% nodes'' and the ``large nodes''. The first ones
+% are created with the option |create-medium-nodes| and the second ones with the
+% option |create-large-nodes|.\footnote{There is also an option
+% |create-extra-nodes| which is an alias for the conjonction of
+% |create-medium-nodes| and |create-large-nodes|.}
+%
% \medskip
-% On the other hand, the |d| columns of the package \pkg{dcolumn} are not
-% supported by \pkg{nicematrix}.
+% These nodes are not used by \pkg{nicematrix} by default, and that's why they
+% are not created by default.
+%
+% \medskip
+% The names of the ``medium nodes'' are constructed by adding the suffix
+% ``|-medium|'' to the names of the ``normal nodes''. In the following example,
+% we have underlined the ``medium nodes''. We consider that this example is
+% self-explanatory.
+% \[\begin{pNiceMatrix}[
+% create-medium-nodes,
+% code-after = {\begin{tikzpicture}
+% [every node/.style = {fill = red!15,
+% blend mode = multiply,
+% inner sep = 0pt},
+% name suffix = -medium]
+% \node [fit = (1-1)] {} ;
+% \node [fit = (1-2)] {} ;
+% \node [fit = (1-3)] {} ;
+% \node [fit = (2-1)] {} ;
+% \node [fit = (2-2)] {} ;
+% \node [fit = (2-3)] {} ;
+% \node [fit = (3-1)] {} ;
+% \node [fit = (3-2)] {} ;
+% \node [fit = (3-3)] {} ;
+% \end{tikzpicture}}]
+% a & a + b & a + b + c \\
+% a & a & a + b \\
+% a & a & a
+% \end{pNiceMatrix}\]
+%
+%
+% \medskip
+% The names of the ``large nodes'' are constructed by adding the suffix
+% ``|-large|'' to the names of the ``normal nodes''. In the following example,
+% we have underlined the ``large nodes''. We consider that this example is
+% self-explanatory.\footnote{There is no ``large nodes'' created in the exterior
+% rows and columns (for these rows and columns, cf. p.~\pageref{exterior}).}
+%
+% \[\begin{pNiceMatrix}[
+% create-large-nodes,
+% code-after = {\begin{tikzpicture}
+% [every node/.style = {blend mode = multiply,
+% inner sep = 0pt},
+% name suffix = -large]
+% \node [fit = (1-1),fill = red!15] {} ;
+% \node [fit = (1-3),fill = red!15] {} ;
+% \node [fit = (2-2),fill = red!15] {} ;
+% \node [fit = (3-1),fill = red!15] {} ;
+% \node [fit = (3-3),fill = red!15] {} ;
+% \node [fit = (1-2),fill = blue!15] {} ;
+% \node [fit = (2-1),fill = blue!15] {} ;
+% \node [fit = (2-3),fill = blue!15] {} ;
+% \node [fit = (3-2),fill = blue!15] {} ;
+% \end{tikzpicture}}]
+% a & a + b & a + b + c \\
+% a & a & a + b \\
+% a & a & a
+% \end{pNiceMatrix}\]
+%
+%
+% \medskip
+% The ``large nodes'' of the first column and last column may appear too small
+% for some usage. That's why it's possible to use the options |left-margin| and
+% |right-margin| to add space on both sides of the array and also space in the
+% ``large nodes'' of the first column and last column. In the following example,
+% we have used the options |left-margin| and |right-margin|.\footnote{The
+% options |left-margin| and |right-margin| take dimensions as values but, if no
+% value is given, the default value is used, which is |\arraycolsep| (by
+% default: 5~pt). There is also an option |margin| to fix both |left-margin| and
+% |right-margin| to the same value.}
+% \[\begin{pNiceMatrix}[
+% create-large-nodes,left-margin,right-margin,
+% code-after = {\begin{tikzpicture}
+% [every node/.style = {blend mode = multiply,
+% inner sep = 0pt},
+% name suffix = -large]
+% \node [fit = (1-1),fill = red!15] {} ;
+% \node [fit = (1-3),fill = red!15] {} ;
+% \node [fit = (2-2),fill = red!15] {} ;
+% \node [fit = (3-1),fill = red!15] {} ;
+% \node [fit = (3-3),fill = red!15] {} ;
+% \node [fit = (1-2),fill = blue!15] {} ;
+% \node [fit = (2-1),fill = blue!15] {} ;
+% \node [fit = (2-3),fill = blue!15] {} ;
+% \node [fit = (3-2),fill = blue!15] {} ;
+% \end{tikzpicture}}]
+% a & a + b & a + b + c \\
+% a & a & a + b \\
+% a & a & a
+% \end{pNiceMatrix}\]
+%
+% \medskip
+% It's also possible to add more space on both side of the array with the
+% options |extra-left-margin| and |extra-right-margin|. These margins are not
+% incorporated in the ``large nodes''. It's possible to fix both values with the
+% option |extra-margin| and, in the following example, we use |extra-margin|
+% with the value $3$~pt.
+% \[\begin{pNiceMatrix}[
+% create-large-nodes,margin,extra-margin=3pt,
+% code-after = {\begin{tikzpicture}
+% [every node/.style = {blend mode = multiply,
+% inner sep = 0 pt},
+% name suffix = -large]
+% \node [fit = (1-1),fill = red!15] {} ;
+% \node [fit = (1-3),fill = red!15] {} ;
+% \node [fit = (2-2),fill = red!15] {} ;
+% \node [fit = (3-1),fill = red!15] {} ;
+% \node [fit = (3-3),fill = red!15] {} ;
+% \node [fit = (1-2),fill = blue!15] {} ;
+% \node [fit = (2-1),fill = blue!15] {} ;
+% \node [fit = (2-3),fill = blue!15] {} ;
+% \node [fit = (3-2),fill = blue!15] {} ;
+% \end{tikzpicture}}]
+% a & a + b & a + b + c \\
+% a & a & a + b \\
+% a & a & a
+% \end{pNiceMatrix}\]
+%
+%
+%
+% \bigskip
+% \textbf{Be careful} : These nodes are reconstructed from the contents of the
+% contents cells of the array. Usually, they do not correspond to the cells
+% delimited by the rules (if we consider that these rules are drawn).
+%
+% \bigskip
+% \begin{minipage}[c]{7.6cm}
+% Here is a array composed with the following code:
+%
+% \medskip
+% \begin{BVerbatim}
+% \large
+% \begin{NiceTabular}{wl{2cm}LL}[hvlines]
+% fraise & amande & abricot \\
+% prune & pêche & poire \\[1ex]
+% noix & noisette & brugnon
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \end{minipage}
+% \hspace{0.9cm}
+% \begin{scope}
+% \large
+% \begin{NiceTabular}[c]{wl{2cm}LL}[hvlines]
+% fraise & amande & abricot \\
+% prune & pêche & poire \\[1ex]
+% noix & noisette & brugnon
+% \end{NiceTabular}
+% \end{scope}
%
+% \vspace{1cm}
+% \begin{minipage}[c]{7cm}
+% Here, we have colored all the cells of the array with |\chessboardcolors|.
+% \end{minipage}
+% \hspace{1.5cm}
+% \begin{scope}
+% \large
+% \begin{NiceTabular}[c]{wl{2cm}LL}[hvlines,code-before = \chessboardcolors{red!15}{blue!15}]
+% fraise & amande & abricot \\
+% prune & pêche & poire \\[1ex]
+% noix & noisette & brugnon
+% \end{NiceTabular}
+% \end{scope}
+%
+%
+% \vspace{1cm}
+% \begin{minipage}[c]{7cm}
+% Here are the ``large nodes'' of this array (without utilisation of |margin|
+% nor |extra-margin|).
+% \end{minipage}
+% \hspace{1.5cm}
+% \begin{scope}
+% \large
+% \begin{NiceTabular}[c]{wl{2cm}LL}[hvlines,
+% create-large-nodes,
+% code-after = {\begin{tikzpicture}
+% [every node/.style = {blend mode = multiply,
+% inner sep = 0 pt},
+% name suffix = -large]
+% \node [fit = (1-1),fill = red!15] {} ;
+% \node [fit = (1-3),fill = red!15] {} ;
+% \node [fit = (2-2),fill = red!15] {} ;
+% \node [fit = (3-1),fill = red!15] {} ;
+% \node [fit = (3-3),fill = red!15] {} ;
+% \node [fit = (1-2),fill = blue!15] {} ;
+% \node [fit = (2-1),fill = blue!15] {} ;
+% \node [fit = (2-3),fill = blue!15] {} ;
+% \node [fit = (3-2),fill = blue!15] {} ;
+% \end{tikzpicture}}]
+% fraise & amande & abricot \\
+% prune & pêche & poire \\[1ex]
+% noix & noisette & brugnon
+% \end{NiceTabular}
+% \end{scope}
+%
+%
+%
+%
+% \subsection{The ``row-nodes'' and the ``col-nodes''}
+%
+% The package \pkg{nicematrix} creates a PGF/Tikz node indicating the potential
+% position of each horizontal rule (with the names |row-|$i$) and each vertical
+% rule (with the names |col-|$j$), as described in the following figure. These
+% nodes are available in the |code-before| and the |code-after|.
+% \begin{center}
+% \begin{NiceTabular}{CCC}[hvlines,rules/width=1pt,rules/color=gray]
+% rose & tulipe & lys \\
+% arum & iris & violette \\
+% muguet & dahlia & souci
+% \CodeAfter
+% \tiny
+% \begin{tikzpicture}
+% \foreach \i in {1,2,3,4}
+% {
+% \fill [red] (row-\i) circle (0.5mm) ;
+% \node [red,anchor=east] at (row-\i) {row-\i} ;
+% }
+% \foreach \j in {1,2,3,4}
+% {
+% \fill [blue] (col-\j) circle (0.5mm) ;
+% \node [blue,anchor=north] at (col-\j) {col-\j} ;
+% }
+% \end{tikzpicture}
+% \end{NiceTabular}
+% \end{center}
+%
+% \bigskip
+% If we use Tikz (we remind that \pkg{nicematrix} does not load Tikz by
+% default), we can access (in the |code-before| and the |code-after|) to the
+% intersection of the horizontal rule~$i$ and the vertical rule~$j$ with the
+% syntax |(row-|$i$\verb+-|col-+$j$|)|.
+%
+% \medskip
+% \begin{Verbatim}
+% \[\begin{NiceMatrix}[
+% code-before =
+% {
+% ~emphase# \tikz \draw [fill = red!15] @
+% ~emphase# (row-7-|col-4) -- (row-8-|col-4) -- (row-8-|col-5) -- @
+% ~emphase# (row-9-|col-5) -- (row-9-|col-6) |- cycle ; @
+% }
+% ]
+% 1 \\
+% 1 & 1 \\
+% 1 & 2 & 1 \\
+% 1 & 3 & 3 & 1 \\
+% 1 & 4 & 6 & 4 & 1 \\
+% 1 & 5 & 10 & 10 & 5 & 1 \\
+% 1 & 6 & 15 & 20 & 15 & 6 & 1 \\
+% 1 & 7 & 21 & 35 & 35 & 21 & 7 & 1 \\
+% 1 & 8 & 28 & 56 & 70 & 56 & 28 & 8 & 1
+% \end{NiceMatrix}\]
+% \end{Verbatim}
+% \[\begin{NiceMatrix}[
+% code-before =
+% {
+% \tikz \draw [fill = red!15]
+% (row-7-|col-4) -- (row-8-|col-4) -- (row-8-|col-5) --
+% (row-9-|col-5) -- (row-9-|col-6) |- cycle ;
+% }
+% ]
+% 1 \\
+% 1 & 1 \\
+% 1 & 2 & 1 \\
+% 1 & 3 & 3 & 1 \\
+% 1 & 4 & 6 & 4 & 1 \\
+% 1 & 5 & 10 & 10 & 5 & 1 \\
+% 1 & 6 & 15 & 20 & 15 & 6 & 1 \\
+% 1 & 7 & 21 & 35 & 35 & 21 & 7 & 1 \\
+% 1 & 8 & 28 & 56 & 70 & 56 & 28 & 8 & 1
+% \end{NiceMatrix}\]
%
%
% \section{Technical remarks}
@@ -2153,28 +2532,10 @@ version 2005/12/01 or later.
% \end{scope}
%
% \medskip
-% The specifier |?| may be used in a standard environment |{array}| (of the
-% package \pkg{array}) and, in this case, the command |\OnlyMainNiceMatrix| is
-% no-op.
-%
-%
-% \subsection{The names of the PGF nodes created by nicematrix}
-%
-% We have said that, when a name is given to an environment of \pkg{nicematrix},
-% it's possible to access the PGF/Tikz nodes through this name (cf.
-% p.~\pageref{name}).
+% This specifier |?| may be used in the standard environments |{tabular}| and
+% |{array}| (of the package \pkg{array}) and, in this case, the command
+% |\OnlyMainNiceMatrix| is no-op.
%
-% That's the recommended way to access these nodes. However, we describe now the
-% internal names of these nodes.
-%
-% The environments created by \pkg{nicematrix} are numbered by an internal
-% global counter. The command |\NiceMatrixLastEnv| provides the number of the
-% last environment of \pkg{nicematrix} (for LaTeX, it's a ``fully expandable''
-% command and not a counter).
-%
-% For the environment of number~$n$, the node in row~$i$ and column~$j$ has the
-% name |nm-|$n$|-|$i$|-|$j$. The |medium| and |large| nodes have the same name,
-% suffixed by |-medium| and |-large|.
%
%
% \subsection{Diagonal lines}
@@ -2310,95 +2671,16 @@ version 2005/12/01 or later.
% environments of \pkg{nicematrix} are not affected).
%
%
-%
-% \subsection{A technical problem with the argument of
-% \textbackslash\textbackslash}
-%
-%
-% For technical, reasons, if you use the optional argument of the command |\\|,
-% the vertical space added will also be added to the ``normal'' node
-% corresponding at the previous node.
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
-% \begin{pNiceMatrix}
-% a & \frac AB \\~emphase#[2mm]@
-% b & c
-% \end{pNiceMatrix}
-% \end{BVerbatim}
-% $\begin{pNiceMatrix}[
-% code-after = {\tikz \node [inner sep = 0pt,
-% fill = red!15,
-% blend mode = multiply,
-% fit = (1-2) ] {} ; } ]
-% a & \frac AB \\[2mm]
-% b & c
-% \end{pNiceMatrix}$
%
-% \bigskip
-% There are two solutions to solve this problem. The first solution is to use a
-% TeX command to insert space between the rows.
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
-% \begin{pNiceMatrix}
-% a & \frac AB \\
-% ~emphase#\noalign{\kern2mm}@
-% b & c
-% \end{pNiceMatrix}
-% \end{BVerbatim}
-% $\begin{pNiceMatrix}[
-% code-after = {\tikz \node [inner sep = 0pt,
-% fill = red!15,
-% blend mode = multiply,
-% fit = (1-2) ] {} ; } ]
-% a & \frac AB \\
-% \noalign{\kern2mm}
-% b & c
-% \end{pNiceMatrix}$
-%
-%
-% \bigskip
-% The other solution is to use the command |\multicolumn| in the previous cell.
+% \subsection{Incompatibilities}
%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
-% \begin{pNiceMatrix}
-% a & ~emphase#\multicolumn1C{\frac AB}@ \\[2mm]
-% b & c
-% \end{pNiceMatrix}
-% \end{BVerbatim}
-% $\begin{pNiceMatrix}[
-% code-after = {\tikz \node [inner sep = 0pt,
-% fill = red!15,
-% blend mode = multiply,
-% fit = (1-2) ] {} ; } ]
-% a & \multicolumn1C{\frac AB} \\[2mm]
-% b & c
-% \end{pNiceMatrix}$
-%
-%
-% \subsection{Obsolete environments which have been deleted}
+% The package \pkg{nicematrix} is not compatible with \pkg{threeparttable}.
%
-% The version 3.0 of \pkg{nicematrix} has introduced the environment
-% |{pNiceArray}| (and its variants) with the options |first-row|, |last-row|,
-% |first-col| and |last-col|.
+% \medskip
+% The package \pkg{nicematrix} is not fully compatible with the package
+% \pkg{arydshln} (because this package redefines many internal of \pkg{array}).
%
-% Consequently the following environments present in previous versions of
-% have been deleted from \pkg{nicematrix}.
-% %
-% \begin{itemize}
-% \item |{NiceArrayCwithDelims}| ;
-% \item |{pNiceArrayC}|, |{bNiceArrayC}|, |{BNiceArrayC}|, |{vNiceArrayC}|,
-% |{VNiceArrayC}| ;
-% \item |{NiceArrayRCwithDelims}| ;
-% \item |{pNiceArrayRC}|, |{bNiceArrayRC}|, |{BNiceArrayRC}|, |{vNiceArrayRC}|,
-% |{VNiceArrayRC}|.
-% \end{itemize}
%
-% However, the definition of those environments is still available (temporarily)
-% at the end of the file |nicematrix.sty| after a command |\file_input_stop:|.
-%
% \section{Examples}
%
% \subsection{Dotted lines}
@@ -2531,11 +2813,9 @@ version 2005/12/01 or later.
% \end{scope}
%
% \vspace{2cm}
-% An example for a linear system (the vertical rule has been drawn in blue with
-% the tools of \pkg{colortbl}):\par\nobreak
+% An example for a linear system:\par\nobreak
%
% \begin{Verbatim}
-% \arrayrulecolor{blue}
% $\begin{pNiceArray}{*6C|C}[nullify-dots,last-col,code-for-last-col=\scriptstyle]
% 1 & 1 & 1 &\Cdots & & 1 & 0 & \\
% 0 & 1 & 0 &\Cdots & & 0 & & L_2 \gets L_2-L_1 \\
@@ -2544,10 +2824,9 @@ version 2005/12/01 or later.
% \Vdots & & &\Ddots & & 0 & \\
% 0 & & &\Cdots & 0 & 1 & 0 & L_n \gets L_n-L_1
% \end{pNiceArray}$
-% \arrayrulecolor{black}
% \end{Verbatim}
%
-% \arrayrulecolor{blue}
+%
% \[\begin{pNiceArray}{*6C|C}[nullify-dots,last-col,code-for-last-col=\scriptstyle]
% 1 & 1 & 1 &\Cdots & & 1 & 0 & \\
% 0 & 1 & 0 &\Cdots & & 0 & & L_2 \gets L_2-L_1 \\
@@ -2556,7 +2835,6 @@ version 2005/12/01 or later.
% \Vdots & & &\Ddots & & 0 & \\
% 0 & & &\Cdots & 0 & 1 & 0 & L_n \gets L_n-L_1
% \end{pNiceArray}\]
-% \arrayrulecolor{black}
%
%
%
@@ -2746,24 +3024,22 @@ version 2005/12/01 or later.
%
%
% We should remark that the rules we have drawn are drawn \emph{after} the
-% construction of the array and thus, they don't spread the cells of the
-% array. We recall that, on the other side, the command |\hline|, the specifier
-% ``"|"'' and the options |hlines| and |vlines| spread the cells (when the
-% package \pkg{array} is loaded but, when the package \pkg{nicematrix} is
-% loaded, \pkg{array} is always loaded).\footnote{On the other side, the command
-% |\cline| doesn't spread the rows of the array.}
+% construction of the array and thus, they don't spread the cells of the array.
+% We recall that, on the other side, the command |\hline|, the specifier ``"|"''
+% and the options |hlines|, |vlines| and |hvlines| spread the
+% cells.\footnote{For the command |\cline|, see the remark
+% p.~\pageref{remark-cline}.}
%
%
% \vspace{1cm}
-% The package \pkg{nicematrix} is constructed upon the environment |{array}|
-% and, therefore, it's possible to use the package \pkg{colortbl} in the
-% environments of \pkg{nicematrix}. However, it's not always easy to do a fine
-% tuning of \pkg{colortbl}. That's why we propose another method to highlight a
+% It's possible to color a row with |\rowcolor| in the |code-before| (or with
+% |\rowcolor| of \pkg{colortbl} in the first cell of the row). However, it's not
+% possible to do a fine tuning. That's why we describe now method to highlight a
% row of the matrix. We create a rectangular Tikz node which encompasses the
% nodes of the second row with the Tikz library \pkg{fit}. This Tikz node is
% filled after the construction of the matrix. In order to see the text
% \emph{under} this node, we have to use transparency with the |blend mode|
-% equal to |multiply|.
+% equal to |multiply|.
%
% \tikzset{highlight/.style={rectangle,
% fill=red!15,
@@ -3318,28 +3594,91 @@ version 2005/12/01 or later.
% the rules even if \pkg{colortbl} is not loaded.
% \begin{macrocode}
\cs_set_protected:Npn \CT@arc@ { }
- \NewDocumentCommand { \arrayrulecolor } { m }
- { \tl_gset:Nn \CT@arc@ { \color { #1 } } }
-% \end{macrocode}
-% The following line are from the redefinition of |\hline| of standard LaTeX by
-% \pkg{colortbl} (\pkg{array} does not redefine |\hline|).
-% \begin{macrocode}
+ \cs_set:Npn \arrayrulecolor #1 # { \CT@arc { #1 } }
+ \cs_set:Npn \CT@arc #1 #2
+ {
+ \dim_compare:nNnT \baselineskip = \c_zero_dim \noalign
+ { \cs_gset:Npn \CT@arc@ { \color #1 { #2 } } }
+ }
\cs_set:Npn \hline
{
\noalign { \ifnum 0 = `} \fi
- \let \hskip \vskip
- \let \vrule \hrule
- \let \@width \@height
+ \cs_set_eq:NN \hskip \vskip
+ \cs_set_eq:NN \vrule \hrule
+ \cs_set_eq:NN \@width \@height
{ \CT@arc@ \vline }
\futurelet \reserved@a
\@xhline
}
}
+ }
+% \end{macrocode}
+%
+% \bigskip
+% We have to redefine |\cline| for several reasons. The command |\@@_cline| will
+% be linked to |\cline| in the beginning of |{NiceArrayWithDelims}|. The
+% following commands must \emph{not} be protected.
+% \begin{macrocode}
+\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_compare:nNnT { #1 } > 1 { \multispan { \@@_pred:n { #1 } } & }
+ \multispan { \int_eval:n { #2 - #1 + 1 } }
+ { \CT@arc@ \leaders \hrule \@height \arrayrulewidth \hfill }
+% \end{macrocode}
+% Our |\everycr| has been modified. In particular, the creation of the |row|
+% node is in the |\everycr| (maybe we should put it with the incrementation of
+% |\c@iRow|). Since the following |\cr| correspond to a ``false row'', we have
+% to nullify |\everycr|.
+% \begin{macrocode}
+ \everycr { }
+ \cr
+ \noalign { \skip_vertical:N -\arrayrulewidth }
}
% \end{macrocode}
%
% \bigskip
-% The following command are only for efficiency. It must \emph{not} be protected
+% The following version of |\cline| spreads the array of a quantity equal
+% to |\arrayrulewidth| as does |\hline|. It will be loaded except if the key
+% |standard-cline| has been used.
+% \begin{macrocode}
+\cs_set:Npn \@@_cline
+% \end{macrocode}
+% We have to act in a fully expandable way since there may be |\noalign| (in the
+% |\multispan|) to detect. That's why we use |\exp_arg:Ne| and not |\exp_arg:Nx|.
+% \begin{macrocode}
+ { \exp_args:Ne \@@_cline_i:nn \l_@@_first_col_int }
+% \end{macrocode}
+% The command |\cline_i:nn| has two arguments. The first is the number of the
+% current column (it \emph{must} be used in that column). The second is a
+% standard argument of |\cline| of the form \textsl{i}-\textsl{j}.
+% \begin{macrocode}
+\cs_set:Npn \@@_cline_i:nn #1 #2 { \@@_cline_i:w #1-#2 \q_stop }
+\cs_set:Npn \@@_cline_i:w #1-#2-#3 \q_stop
+ {
+% \end{macrocode}
+% Now, |#1| is the number of the current column and we have to draw a line from
+% the column |#2| to the column |#3| (both included).
+% \begin{macrocode}
+ \int_compare:nNnT { #1 } < { #2 }
+ { \multispan { \int_eval:n { #2 - #1 } } & }
+ \multispan { \int_eval:n { #3 - #2 + 1 } }
+ { \CT@arc@ \leaders \hrule \@height \arrayrulewidth \hfill }
+% \end{macrocode}
+% You look whether there is another |\cline| to draw (the final user may put
+% several |\cline|).
+% \begin{macrocode}
+ \peek_meaning_remove_ignore_spaces:NTF \cline
+ { & \exp_args:Ne \@@_cline_i:nn { \@@_succ:n { #3 } } }
+ { \everycr { } \cr }
+ }
+
+
+% \end{macrocode}
+%
+% \bigskip
+% The following commands are only for efficiency. It must \emph{not} be protected
% because it will be used (for instance) in names of \textsc{pgf} nodes.
% \begin{macrocode}
\cs_new:Npn \@@_succ:n #1 { \the \numexpr #1 + 1 \relax }
@@ -3347,6 +3686,23 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
+% The following command is a small shortcut.
+% \begin{macrocode}
+\cs_new:Npn \@@_math_toggle_token:
+ { \bool_if:NF \l_@@_NiceTabular_bool \c_math_toggle_token }
+% \end{macrocode}
+%
+% \bigskip
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_set_CT@arc@:
+ { \peek_meaning:NTF [ \@@_set_CT@arc@_i: \@@_set_CT@arc@_ii: }
+\cs_new_protected:Npn \@@_set_CT@arc@_i: [ #1 ] #2 \q_stop
+ { \cs_set:Npn \CT@arc@ { \color [ #1 ] { #2 } } }
+\cs_new_protected:Npn \@@_set_CT@arc@_ii: #1 \q_stop
+ { \cs_set:Npn \CT@arc@ { \color { #1 } } }
+% \end{macrocode}
+%
+% \bigskip
% \textbf{The column S of siunitx}\par\nobreak
%
% \medskip
@@ -3486,6 +3842,20 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
+% The command |\NiceMatrixLastEnv| is not used by the package \pkg{nicematrix}.
+% It's only a facility given to the final user. It gives the number of the last
+% environment (in fact the number of the current environment but it's meant to
+% be used after the environment in order to refer to that environment --- and
+% its nodes --- without having to give it a name). This command \emph{must} be
+% expandable since it will be used in \pkg{pgf} nodes.
+% \begin{macrocode}
+\NewExpandableDocumentCommand \NiceMatrixLastEnv { }
+ { \int_use:N \g_@@_env_int }
+% \end{macrocode}
+%
+%
+%
+% \bigskip
% The following command is only a syntaxic shortcut. The |q| in |qpoint| means
% \emph{quick}.
% \begin{macrocode}
@@ -3525,11 +3895,8 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% If the user uses |{NiceArray}| (and not another environment relying upon
-% |{NiceArrayWithDelims}| like |{pNiceArray}|), we will raise the flag
-% |\l_@@_NiceArray_bool|. We have to know that, because, in |{NiceArray}|, we
-% won't use a structure with |\left| and |\right| and we will use the option of
-% position (|t|, |b| or |c|).
+% If the user uses |{NiceArray}| or |{NiceTabular}| the flag
+% |\l_@@_NiceArray_bool| will be raised.
% \begin{macrocode}
\bool_new:N \l_@@_NiceArray_bool
% \end{macrocode}
@@ -3615,7 +3982,14 @@ version 2005/12/01 or later.
%
% The TeX counters |\c@iRow| and |\c@jCol| will be created in the beginning of
% |{NiceArrayWithDelims}| (if they don't exist previously).
-%
+%
+% \bigskip
+% The following token list corresponds to the key |rules/color| available
+% in the environments.
+% \begin{macrocode}
+\tl_new:N \l_@@_rules_color_tl
+% \end{macrocode}
+%
% \bigskip
% A kind of false row will be inserted at the end of the array for the
% construction of the |col| nodes (and also to fix the width of the columns when
@@ -3676,6 +4050,42 @@ version 2005/12/01 or later.
\dim_new:N \g_@@_width_first_col_dim
% \end{macrocode}
%
+% \bigskip
+% The following sequence will contain the caracteristics of the blocks of the
+% array, specified by the command |\Block|. Each block is represented by 6
+% components surrounded by braces:
+%
+% |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}{|\textsl{options}|}{|\textsl{contents}|}|.
+%
+% The variable is global because it will be modified in the cells of the array.
+% \begin{macrocode}
+\seq_new:N \g_@@_blocks_seq
+% \end{macrocode}
+% We also manage a sequence of the \emph{positions} of the blocks. Of course,
+% it's redundant with the previous sequence, but it's for efficiency. In that
+% sequence, each block is represented by only the four first components:
+% |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}|.
+% \begin{macrocode}
+\seq_new:N \g_@@_pos_of_blocks_seq
+% \end{macrocode}
+% The sequence |\g_@@_pos_of_blocks_seq| will be used by the test of
+% non-overlapping of two blocks and when we will draw the rules required by the
+% key |hvlines| (these rules won't be drawn within the blocks).
+%
+% \bigskip
+% We will also manage a sequence for the positions of the dotted lines. These
+% dotted lines are created in the array by |\Cdots|, |\Vdots|, |\Ddots|, etc.
+% However, their positions, that is to say, their extremities, will be
+% determined only after the construction of the array. In this sequence, each
+% item contains four components:
+% |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}|.
+% \begin{macrocode}
+\seq_new:N \g_@@_pos_of_xdots_seq
+% \end{macrocode}
+% The sequence |\g_@@_pos_of_xdots_seq| will be used when we will draw the rules
+% required by the key |hvlines| (these rules won't be drawn within the virtual
+% blocks corresponding to the dotted lines).
+%
%
% \bigskip
% \textbf{Variables for the exterior rows and columns}\par\nobreak
@@ -3841,7 +4251,15 @@ version 2005/12/01 or later.
% \bigskip
% \subsection*{The options}
%
+% By default, the behaviour of |\cline| is changed in the environments of
+% \pkg{nicematrix}: a |\cline| spreads the array by an amount equal to
+% |\arrayrulewidht|. It's possible to disable this feature with the key
+% |\l_@@_standard_line_bool|.
+% \begin{macrocode}
+\bool_new:N \l_@@_standard_cline_bool
+% \end{macrocode}
%
+% \bigskip
% The following dimensions correspond to the options |cell-space-top-limit| and co
% (these parameters are inspired by the package \pkg{cellspace}).
% \begin{macrocode}
@@ -3922,11 +4340,15 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% The flag |\l_@@_hlines_bool| corresponds to the option |\hlines| and the flag
-% |\l_@@_vlines_bool| to the option |\vlines|.
+% The flag |\l_@@_hlines_bool| corresponds to the key |hlines|, the flag
+% |\l_@@_vlines_bool| to the key |vlines| and the flag |hvlines| to the key
+% |hvlines|. Since version 4.1, the key |hvlines| is no longer a mere alias for
+% the conjonction of |hlines| and |vlines|. Indeed, with |hvlines|, the vertical
+% and horizontal rules are \emph{not} drawn within the blocks (created by |\Block|).
% \begin{macrocode}
\bool_new:N \l_@@_hlines_bool
\bool_new:N \l_@@_vlines_bool
+\bool_new:N \l_@@_hvlines_bool
% \end{macrocode}
%
% \bigskip
@@ -4052,8 +4474,20 @@ version 2005/12/01 or later.
%
%
% \begin{macrocode}
+\keys_define:nn { NiceMatrix / rules }
+ {
+ color .tl_set:N = \l_@@_rules_color_tl ,
+ color .value_required:n = true ,
+ width .dim_set:N = \arrayrulewidth ,
+ width .value_required:n = true
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
\keys_define:nn { NiceMatrix / Global }
{
+ standard-cline .bool_set:N = \l_@@_standard_cline_bool ,
+ standard-cline .default:n = true ,
cell-space-top-limit .dim_set:N = \l_@@_cell_space_top_limit_dim ,
cell-space-top-limit .value_required:n = true ,
cell-space-bottom-limit .dim_set:N = \l_@@_cell_space_bottom_limit_dim ,
@@ -4078,7 +4512,12 @@ version 2005/12/01 or later.
code-for-last-row .value_required:n = true ,
hlines .bool_set:N = \l_@@_hlines_bool ,
vlines .bool_set:N = \l_@@_vlines_bool ,
- hvlines .meta:n = { hlines , vlines } ,
+ hvlines .code:n =
+ {
+ \bool_set_true:N \l_@@_hvlines_bool
+ \bool_set_true:N \l_@@_vlines_bool
+ \bool_set_true:N \l_@@_hlines_bool
+ } ,
parallelize-diags .bool_set:N = \l_@@_parallelize_diags_bool ,
% \end{macrocode}
%
@@ -4175,24 +4614,28 @@ version 2005/12/01 or later.
NiceMatrix / Env ,
} ,
NiceMatrix / xdots .inherit:n = NiceMatrix / xdots ,
+ NiceMatrix / rules .inherit:n = NiceMatrix / rules ,
NiceTabular .inherit:n =
{
NiceMatrix / Global ,
NiceMatrix / Env
} ,
NiceTabular / xdots .inherit:n = NiceMatrix / xdots ,
+ NiceTabular / rules .inherit:n = NiceMatrix / rules ,
NiceArray .inherit:n =
{
NiceMatrix / Global ,
NiceMatrix / Env ,
} ,
NiceArray / xdots .inherit:n = NiceMatrix / xdots ,
+ NiceArray / rules .inherit:n = NiceMatrix / rules ,
pNiceArray .inherit:n =
{
NiceMatrix / Global ,
NiceMatrix / Env ,
} ,
- pNiceArray / xdots .inherit:n = NiceMatrix / xdots
+ pNiceArray / xdots .inherit:n = NiceMatrix / xdots ,
+ pNiceArray / rules .inherit:n = NiceMatrix / rules ,
}
% \end{macrocode}
%
@@ -4358,6 +4801,9 @@ version 2005/12/01 or later.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / NiceTabular }
{
+ last-col .code:n = \tl_if_empty:nF {#1}
+ { \@@_error:n { last-col~non~empty~for~NiceArray } }
+ \int_zero:N \l_@@_last_col_int ,
unknown .code:n = \@@_error:n { Unknown~option~for~NiceTabular }
}
% \end{macrocode}
@@ -4480,7 +4926,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_end_Cell:
{
- \bool_if:NF \l_@@_NiceTabular_bool \c_math_toggle_token
+ \@@_math_toggle_token:
\hbox_set_end:
% \end{macrocode}
%
@@ -4712,7 +5158,8 @@ version 2005/12/01 or later.
{
\@@_create_row_node:
% \end{macrocode}
-% We add the potential horizontal lines specified by the option |hlines|.
+% We don't draw the rules of the key |hlines| (or |hvlines|) but we reserve the
+% vertical space for theses rules.
% \begin{macrocode}
\bool_if:NT \l_@@_hlines_bool
{
@@ -4730,7 +5177,7 @@ version 2005/12/01 or later.
% \pkg{colortbl} is not loaded. We use a TeX group in order to limit the scope
% of |\CT@arc@|.
% \begin{macrocode}
- { { \CT@arc@ \hrule height \arrayrulewidth } }
+ { \hrule height \arrayrulewidth width \c_zero_dim }
}
}
}
@@ -4895,6 +5342,9 @@ version 2005/12/01 or later.
\cs_set_eq:NN \@@_old_iddots \iddots
\cs_set_eq:NN \firsthline \hline
\cs_set_eq:NN \lasthline \hline
+ \bool_if:NTF \l_@@_standard_cline_bool
+ { \cs_set_eq:NN \cline \@@_standard_cline }
+ { \cs_set_eq:NN \cline \@@_cline }
\cs_set_eq:NN \Ldots \@@_Ldots
\cs_set_eq:NN \Cdots \@@_Cdots
\cs_set_eq:NN \Vdots \@@_Vdots
@@ -4910,7 +5360,7 @@ version 2005/12/01 or later.
\cs_set_eq:NN \OnlyMainNiceMatrix \@@_OnlyMainNiceMatrix:n
\cs_set_eq:NN \dotfill \@@_dotfill:
\cs_set_eq:NN \CodeAfter \@@_CodeAfter:n
- \cs_set_eq:NN \slashbox \@@_slashbox:nn
+ \cs_set_eq:NN \diagbox \@@_diagbox:nn
\bool_if:NT \l_@@_renew_dots_bool
{
\cs_set_eq:NN \ldots \@@_Ldots
@@ -5123,9 +5573,19 @@ version 2005/12/01 or later.
\bool_if:NT \l_@@_in_env_bool { \@@_fatal:n { Yet~in~env } }
\bool_set_true:N \l_@@_in_env_bool
% \end{macrocode}
+% The command |\CT@arc@| contains the instruction of color for the rules of the
+% array\footnote{e.g. |\color[rgb]{0.5,0.5,0}|)}. This command is used by |\CT@arc@| but
+% we use it also for compatibility with \pkg{colortbl}. But we want also to be
+% able to use color for the rules of the array when \pkg{colortbl} is \emph{not}
+% loaded. That's why we do the following instruction which is in the patch of
+% the beginning of arrays done by \pkg{colortbl}. Of course, we restore the
+% value of |\CT@arc@| at the end of our environment.
+% \begin{macrocode}
+ \cs_gset_eq:NN \@@_old_CT@arc@ \CT@arc@
+% \end{macrocode}
%
-% We deactivate Tikz externalization because we will use \textsc{pgf} pictures with the
-% options |overlay| and |remember picture| (or equivalent forms).
+% We deactivate Tikz externalization because we will use \textsc{pgf} pictures
+% with the options |overlay| and |remember picture| (or equivalent forms).
% \begin{macrocode}
\cs_if_exist:NT \tikz@library@external@loaded
{
@@ -5151,7 +5611,16 @@ version 2005/12/01 or later.
\cs_set_protected:Npn \@arrayrule { \@addtopreamble \@@_vline: }
% \end{macrocode}
%
-%
+% The sequence |\g_@@_blocks_seq| will contain the carateristics of the blocks
+% (specified by |\Block|) of the array. The sequence |\g_@@_pos_of_blocks_seq|
+% will contain only the position of the blocks. Of course, this is redundant but
+% it's for efficiency.
+% \begin{macrocode}
+ \seq_clear:N \g_@@_blocks_seq
+ \seq_clear:N \g_@@_pos_of_blocks_seq
+% \end{macrocode}
+%
+%
% The set of keys is not exactly the same for |{NiceArray}| and for the variants
% of |{NiceArray}| (|{pNiceArray}|, |{bNiceArray}|, etc.) because, for
% |{NiceArray}|, we have the options |t|, |c|, |b| and |baseline|.
@@ -5161,7 +5630,13 @@ version 2005/12/01 or later.
{ \keys_set:nn { NiceMatrix / pNiceArray } }
{ #3 , #5 }
% \end{macrocode}
-%
+%
+% \bigskip
+% \begin{macrocode}
+ \tl_if_empty:NF \l_@@_rules_color_tl
+ { \exp_after:wN \@@_set_CT@arc@: \l_@@_rules_color_tl \q_stop }
+% \end{macrocode}
+%
% \bigskip
% If the key |code-before| is used, we have to create the |col| nodes and the
% |row| nodes before the creation of the array. First, we have to test whether
@@ -5228,21 +5703,18 @@ version 2005/12/01 or later.
\group_begin:
\bool_if:NT \c_@@_tikz_loaded_bool
{
-% \end{macrocode}
-% Be careful: we must \emph{not} put ``|remember picture|'' in the |\pgfset|.
-% \begin{macrocode}
- \pgfset
+ \tikzset
{
every~picture / .style =
- { overlay , name~prefix = \@@_env: - }
+ { overlay , name~prefix = \@@_env: - }
}
- }
- \cs_set_eq:NN \cellcolor \@@_cellcolor:nn
- \cs_set_eq:NN \rectanglecolor \@@_rectanglecolor:nnn
- \cs_set_eq:NN \rowcolor \@@_rowcolor:nn
- \cs_set_eq:NN \rowcolors \@@_rowcolors:nnn
- \cs_set_eq:NN \columncolor \@@_columncolor:nn
- \cs_set_eq:NN \chessboardcolors \@@_chessboardcolors:nn
+ }
+ \cs_set_eq:NN \cellcolor \@@_cellcolor
+ \cs_set_eq:NN \rectanglecolor \@@_rectanglecolor
+ \cs_set_eq:NN \rowcolor \@@_rowcolor
+ \cs_set_eq:NN \rowcolors \@@_rowcolors
+ \cs_set_eq:NN \columncolor \@@_columncolor
+ \cs_set_eq:NN \chessboardcolors \@@_chessboardcolors
% \end{macrocode}
% We compose the |code-before| in math mode in order to nullify the spaces put
% by the user between instructions in the |code-before|.
@@ -5745,7 +6217,7 @@ version 2005/12/01 or later.
{ \box_ht:N \l_tmpa_box + \box_dp:N \l_tmpa_box }
{ }
}
- \right .
+ \right .
\c_math_toggle_token
}
\dim_set:Nn \l_@@_real_left_delim_dim
@@ -6106,7 +6578,7 @@ version 2005/12/01 or later.
% have to compute some dimensions of this box.
% \begin{macrocode}
\hbox_set:Nw \l_@@_cell_box
- \bool_if:NF \l_@@_NiceTabular_bool \c_math_toggle_token
+ \@@_math_toggle_token:
\bool_if:NT \l_@@_small_bool \scriptstyle
% \end{macrocode}
% We insert |\l_@@_code_for_first_col_tl|... but we don't insert it in the
@@ -6131,7 +6603,7 @@ version 2005/12/01 or later.
l
<
{
- \bool_if:NF \l_@@_NiceTabular_bool \c_math_toggle_token
+ \@@_math_toggle_token:
\hbox_set_end:
\@@_update_for_first_and_last_row:
% \end{macrocode}
@@ -6178,7 +6650,7 @@ version 2005/12/01 or later.
% have to compute some dimensions of this box.
% \begin{macrocode}
\hbox_set:Nw \l_@@_cell_box
- \bool_if:NF \l_@@_NiceTabular_bool \c_math_toggle_token
+ \@@_math_toggle_token:
\bool_if:NT \l_@@_small_bool \scriptstyle
% \end{macrocode}
% We insert |\l_@@_code_for_last_col_tl|... but we don't insert it in the
@@ -6198,7 +6670,7 @@ version 2005/12/01 or later.
l
<
{
- \bool_if:NF \l_@@_NiceTabular_bool \c_math_toggle_token
+ \@@_math_toggle_token:
\hbox_set_end:
\@@_update_for_first_and_last_row:
% \end{macrocode}
@@ -6354,6 +6826,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\NewDocumentEnvironment { NiceTabular } { O { } m ! O { } }
{
+ \str_gset:Nn \g_@@_name_env_str { NiceTabular }
\keys_set:nn { NiceMatrix / NiceTabular } { #1 , #3 }
\bool_set_true:N \l_@@_NiceTabular_bool
\NiceArray { #2 }
@@ -6537,18 +7010,26 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
-%
% \bigskip
-% Now, we really draw the dotted lines.
+% Now, we actually draw the dotted lines.
% \begin{macrocode}
\@@_draw_dotted_lines:
% \end{macrocode}
%
-% We draw the vertical rules of the option |vlines| before the
-% |internal-code-after| because the option |white| of a |\Block| may have to
-% erase these vertical rules.
% \begin{macrocode}
- \bool_if:NT \l_@@_vlines_bool \@@_draw_vlines:
+ \bool_if:NTF \l_@@_hvlines_bool
+ \@@_draw_hvlines:
+ {
+ \bool_if:NT \l_@@_hlines_bool \@@_draw_hlines:
+ \bool_if:NT \l_@@_vlines_bool \@@_draw_vlines:
+ }
+% \end{macrocode}
+%
+% We have to revert to a clean version of |\ialign| because there may be
+% tabulars in the |\Block| instructions that will be composed now.
+% \begin{macrocode}
+ \cs_set_eq:NN \ialign \@@_old_ialign:
+ \seq_if_empty:NF \g_@@_blocks_seq \@@_draw_blocks:
\g_@@_internal_code_after_tl
\tl_gclear:N \g_@@_internal_code_after_tl
\bool_if:NT \c_@@_tikz_loaded_bool
@@ -6579,9 +7060,19 @@ version 2005/12/01 or later.
\group_end:
\str_gclear:N \g_@@_name_env_str
\@@_restore_iRow_jCol:
+% \end{macrocode}
+% The command |\CT@arc@| contains the instruction of color for the rules of the
+% array\footnote{e.g. |\color[rgb]{0.5,0.5,0}|)}. This command is used by
+% |\CT@arc@| but we use it also for compatibility with \pkg{colortbl}. But we
+% want also to be able to use color for the rules of the array when
+% \pkg{colortbl} is \emph{not} loaded. That's why we do the following
+% instruction which is in the patch of the end of arrays done by \pkg{colortbl}.
+% \begin{macrocode}
+ \cs_gset_eq:NN \CT@arc@ \@@_old_CT@arc@
}
% \end{macrocode}
%
+%
% \bigskip
% We recall that, when externalization is used, |\tikzpicture| and
% |\endtikzpicture| (or |\pgfpicture| and |\endpgfpicture|) must be directly
@@ -6625,7 +7116,10 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+%
% \bigskip
+% \subsection*{We draw the dotted lines}
+%
% A dotted line will be said \emph{open} in one of its extremities when it stops
% on the edge of the matrix and \emph{closed} otherwise. In the following
% matrix, the dotted line is closed on its left extremity and open on its right.
@@ -6847,6 +7341,21 @@ version 2005/12/01 or later.
}
}
}
+% \end{macrocode}
+% If the key |hvlines| is used, we remind the rectangle described by all the
+% dotted lines in order to respect the corresponding virtual ``block'' when
+% drawing the horizontal and vertical rules.
+% \begin{macrocode}
+ \bool_if:NT \l_@@_hvlines_bool
+ {
+ \seq_gput_right:Nx \g_@@_pos_of_xdots_seq
+ {
+ { \int_use:N \l_@@_initial_i_int }
+ { \int_use:N \l_@@_initial_j_int }
+ { \int_use:N \l_@@_final_i_int }
+ { \int_use:N \l_@@_final_j_int }
+ }
+ }
}
% \end{macrocode}
%
@@ -7354,17 +7863,6 @@ version 2005/12/01 or later.
%
%
% \bigskip
-% The command |\NiceMatrixLastEnv| is not used by the package \pkg{nicematrix}.
-% It's only a facility given to the final user. It gives the number of the last
-% environment (in fact the number of the current environment but it's meant to
-% be used after the environment in order to refer to that environment --- and
-% its nodes --- without having to give it a name).
-% \begin{macrocode}
-\NewExpandableDocumentCommand \NiceMatrixLastEnv { }
- { \int_use:N \g_@@_env_int }
-% \end{macrocode}
-%
-% \bigskip
% \subsection*{The actual instructions for drawing the dotted line with Tikz}
%
% The command |\@@_draw_line:| should be used in a |{pgfpicture}|. It has six
@@ -7653,23 +8151,19 @@ version 2005/12/01 or later.
% \begin{macrocode}
\AtBeginDocument
{
- \tl_set:Nn \l_@@_argspec_tl { s O { } E { _ ^ } { { } { } } }
+ \tl_set:Nn \l_@@_argspec_tl { O { } E { _ ^ } { { } { } } }
\tl_set_rescan:Nno \l_@@_argspec_tl { } \l_@@_argspec_tl
\exp_args:NNV \NewDocumentCommand \@@_Ldots \l_@@_argspec_tl
{
- \bool_if:nTF { #1 }
- { \@@_error:n { starred~commands } }
+ \int_compare:nNnTF \c@jCol = 0
+ { \@@_error:nn { in~first~col } \Ldots }
{
- \int_compare:nNnTF \c@jCol = 0
- { \@@_error:nn { in~first~col } \Ldots }
+ \int_compare:nNnTF \c@jCol = \l_@@_last_col_int
+ { \@@_error:nn { in~last~col } \Ldots }
{
- \int_compare:nNnTF \c@jCol = \l_@@_last_col_int
- { \@@_error:nn { in~last~col } \Ldots }
- {
- \@@_instruction_of_type:nn { Ldots }
- { #2 , down = #3 , up = #4 }
- }
- }
+ \@@_instruction_of_type:nn { Ldots }
+ { #1 , down = #2 , up = #3 }
+ }
}
\bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_ldots }
\bool_gset_true:N \g_@@_empty_cell_bool
@@ -7680,19 +8174,15 @@ version 2005/12/01 or later.
% \begin{macrocode}
\exp_args:NNV \NewDocumentCommand \@@_Cdots \l_@@_argspec_tl
{
- \bool_if:nTF { #1 }
- { \@@_error:n { starred~commands } }
+ \int_compare:nNnTF \c@jCol = 0
+ { \@@_error:nn { in~first~col } \Cdots }
{
- \int_compare:nNnTF \c@jCol = 0
- { \@@_error:nn { in~first~col } \Cdots }
+ \int_compare:nNnTF \c@jCol = \l_@@_last_col_int
+ { \@@_error:nn { in~last~col } \Cdots }
{
- \int_compare:nNnTF \c@jCol = \l_@@_last_col_int
- { \@@_error:nn { in~last~col } \Cdots }
- {
- \@@_instruction_of_type:nn { Cdots }
- { #2 , down = #3 , up = #4 }
- }
- }
+ \@@_instruction_of_type:nn { Cdots }
+ { #1 , down = #2 , up = #3 }
+ }
}
\bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_cdots }
\bool_gset_true:N \g_@@_empty_cell_bool
@@ -7703,18 +8193,16 @@ version 2005/12/01 or later.
% \begin{macrocode}
\exp_args:NNV \NewDocumentCommand \@@_Vdots \l_@@_argspec_tl
{
- \bool_if:nTF { #1 }
- { \@@_error:n { starred~commands } }
- \int_compare:nNnTF \c@iRow = 0
- { \@@_error:nn { in~first~row } \Vdots }
+ \int_compare:nNnTF \c@iRow = 0
+ { \@@_error:nn { in~first~row } \Vdots }
+ {
+ \int_compare:nNnTF \c@iRow = \l_@@_last_row_int
+ { \@@_error:nn { in~last~row } \Vdots }
{
- \int_compare:nNnTF \c@iRow = \l_@@_last_row_int
- { \@@_error:nn { in~last~row } \Vdots }
- {
- \@@_instruction_of_type:nn { Vdots }
- { #2 , down = #3 , up = #4 }
- }
- }
+ \@@_instruction_of_type:nn { Vdots }
+ { #1 , down = #2 , up = #3 }
+ }
+ }
\bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_vdots }
\bool_gset_true:N \g_@@_empty_cell_bool
}
@@ -7724,27 +8212,23 @@ version 2005/12/01 or later.
% \begin{macrocode}
\exp_args:NNV \NewDocumentCommand \@@_Ddots \l_@@_argspec_tl
{
- \bool_if:nTF { #1 }
- { \@@_error:n { starred~commands } }
+ \int_case:nnF \c@iRow
+ {
+ 0 { \@@_error:nn { in~first~row } \Ddots }
+ \l_@@_last_row_int { \@@_error:nn { in~last~row } \Ddots }
+ }
{
- \int_case:nnF \c@iRow
+ \int_case:nnF \c@jCol
{
- 0 { \@@_error:nn { in~first~row } \Ddots }
- \l_@@_last_row_int { \@@_error:nn { in~last~row } \Ddots }
+ 0 { \@@_error:nn { in~first~col } \Ddots }
+ \l_@@_last_col_int { \@@_error:nn { in~last~col } \Ddots }
}
- {
- \int_case:nnF \c@jCol
- {
- 0 { \@@_error:nn { in~first~col } \Ddots }
- \l_@@_last_col_int { \@@_error:nn { in~last~col } \Ddots }
- }
- {
- \@@_instruction_of_type:nn { Ddots }
- { #2 , down = #3 , up = #4 }
- }
+ {
+ \@@_instruction_of_type:nn { Ddots }
+ { #1 , down = #2 , up = #3 }
+ }
- }
- }
+ }
\bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_ddots }
\bool_gset_true:N \g_@@_empty_cell_bool
}
@@ -7754,27 +8238,23 @@ version 2005/12/01 or later.
% \begin{macrocode}
\exp_args:NNV \NewDocumentCommand \@@_Iddots \l_@@_argspec_tl
{
- \bool_if:nTF { #1 }
- { \@@_error:n { starred~commands } }
+ \int_case:nnF \c@iRow
+ {
+ 0 { \@@_error:nn { in~first~row } \Iddots }
+ \l_@@_last_row_int { \@@_error:nn { in~last~row } \Iddots }
+ }
{
- \int_case:nnF \c@iRow
+ \int_case:nnF \c@jCol
{
- 0 { \@@_error:nn { in~first~row } \Iddots }
- \l_@@_last_row_int { \@@_error:nn { in~last~row } \Iddots }
+ 0 { \@@_error:nn { in~first~col } \Iddots }
+ \l_@@_last_col_int { \@@_error:nn { in~last~col } \Iddots }
}
- {
- \int_case:nnF \c@jCol
- {
- 0 { \@@_error:nn { in~first~col } \Iddots }
- \l_@@_last_col_int { \@@_error:nn { in~last~col } \Iddots }
- }
- {
- \@@_instruction_of_type:nn { Iddots }
- { #2 , down = #3 , up = #4 }
- }
+ {
+ \@@_instruction_of_type:nn { Iddots }
+ { #1 , down = #2 , up = #3 }
+ }
- }
- }
+ }
\bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_iddots }
\bool_gset_true:N \g_@@_empty_cell_bool
}
@@ -7803,13 +8283,26 @@ version 2005/12/01 or later.
\cs_new:Npn \@@_multicolumn:nnn #1 #2 #3
{
\@@_old_multicolumn { #1 } { #2 } { #3 }
- \int_compare:nNnT #1 > 1
+% \end{macrocode}
+% The |\peek_remove_spaces:n| is mandatory.
+% \begin{macrocode}
+ \peek_remove_spaces:n
{
- \seq_gput_left:Nx \g_@@_multicolumn_cells_seq
- { \int_use:N \c@iRow - \int_use:N \c@jCol }
- \seq_gput_left:Nn \g_@@_multicolumn_sizes_seq { #1 }
- }
- \int_gadd:Nn \c@jCol { #1 - 1 }
+ \int_compare:nNnT #1 > 1
+ {
+ \seq_gput_left:Nx \g_@@_multicolumn_cells_seq
+ { \int_use:N \c@iRow - \int_use:N \c@jCol }
+ \seq_gput_left:Nn \g_@@_multicolumn_sizes_seq { #1 }
+ \seq_gput_right:Nx \g_@@_pos_of_blocks_seq
+ {
+ { \int_use:N \c@iRow }
+ { \int_use:N \c@jCol }
+ { \int_use:N \c@iRow }
+ { \int_eval:n { \c@jCol + #1 - 1 } }
+ }
+ }
+ \int_gadd:Nn \c@jCol { #1 - 1 }
+ }
}
% \end{macrocode}
%
@@ -8044,14 +8537,20 @@ version 2005/12/01 or later.
% The command |\@@_rotate:| will be linked to |\rotate| in
% |{NiceArrayWithDelims}|.
%
-% The command will exit three levels of groups in order
+% The command will exit three levels of groups (only two in |{NiceTabular}|
+% because there is not the group of the math mode to exit) in order
% to execute the command
%
% \qquad ``|\box_rotate:Nn \l_@@_cell_box { 90 }|''
%
% just after the construction of the box |\l_@@_cell_box|.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_rotate: { \group_insert_after:N \@@_rotate_i: }
+\cs_new_protected:Npn \@@_rotate:
+ {
+ \bool_if:NTF \l_@@_NiceTabular_bool
+ { \group_insert_after:N \@@_rotate_ii: }
+ { \group_insert_after:N \@@_rotate_i: }
+ }
\cs_new_protected:Npn \@@_rotate_i: { \group_insert_after:N \@@_rotate_ii: }
\cs_new_protected:Npn \@@_rotate_ii: { \group_insert_after:N \@@_rotate_iii: }
\cs_new_protected:Npn \@@_rotate_iii:
@@ -8196,21 +8695,25 @@ version 2005/12/01 or later.
%
%
% \bigskip
-% Here an example : |\@@_rowcolor:nn {red!15} {1,3,5-7,10-}|
+% Here an example : |\@@_rowcolor {red!15} {1,3,5-7,10-}|
% \begin{macrocode}
-\cs_new_protected:Npn \@@_rowcolor:nn #1 #2
+\NewDocumentCommand \@@_rowcolor { O { } m m }
{
- \tl_if_blank:nF { #1 }
+ \tl_if_blank:nF { #2 }
{
\pgfpicture
\pgf@relevantforpicturesizefalse
- \pgfsetfillcolor { #1 }
+ \tl_if_empty:nTF { #1 } \color { \color [ #1 ] } { #2 }
% \end{macrocode}
-% |\l_tmpa_dim| is the $x$-value of the left side of the rows.
+% |\l_tmpa_dim| is the $x$-value of the right side of the rows.
% \begin{macrocode}
+ \@@_qpoint:n { col - 1}
+ \int_compare:nNnTF \l_@@_first_col_int = 0
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x + 0.5 \arrayrulewidth } }
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } }
\@@_qpoint:n { col - \@@_succ:n \c@jCol }
- \dim_set_eq:NN \l_tmpa_dim \pgf@x
- \clist_map_inline:nn { #2 }
+ \dim_set:Nn \l_tmpa_dim { \pgf@x + 0.5 \arrayrulewidth }
+ \clist_map_inline:nn { #3 }
{
\tl_set:Nn \l_tmpa_tl { ##1 }
\tl_if_in:NnTF \l_tmpa_tl { - }
@@ -8225,9 +8728,12 @@ version 2005/12/01 or later.
% Now, the numbers of both rows are in |\l_tmpa_tl| and |\l_tmpb_tl|.
% \begin{macrocode}
\@@_qpoint:n { row - \@@_succ:n \l_tmpb_tl }
+ \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth }
+ \@@_qpoint:n { row - \l_tmpa_tl }
+ \dim_set:Nn \l_tmpd_dim { \pgf@y + 0.5 \arrayrulewidth }
\pgfpathrectanglecorners
- { \@@_qpoint:n { row - \l_tmpa_tl } }
- { \pgfpoint \l_tmpa_dim \pgf@y }
+ { \pgfpoint \l_tmpc_dim \l_tmpd_dim }
+ { \pgfpoint \l_tmpa_dim \l_tmpb_dim }
}
\pgfusepathqfill
\endpgfpicture
@@ -8238,22 +8744,22 @@ version 2005/12/01 or later.
% \bigskip
% Here an example : |\@@_columncolor:nn {red!15} {1,3,5-7,10-}|
% \begin{macrocode}
-\cs_new_protected:Npn \@@_columncolor:nn #1 #2
+\NewDocumentCommand \@@_columncolor { O { } m m }
{
- \tl_if_blank:nF { #1 }
+ \tl_if_blank:nF { #2 }
{
\pgfpicture
\pgf@relevantforpicturesizefalse
- \pgfsetfillcolor { #1 }
+ \tl_if_empty:nTF { #1 } \color { \color [ #1 ] } { #2 }
\@@_qpoint:n { row - 1 }
% \end{macrocode}
% |\l_tmpa_dim| is the $y$-value of the top of the columns et |\l_tmpb_dim| is
% the $y$-value of the bottom.
% \begin{macrocode}
- \dim_set_eq:NN \l_tmpa_dim \pgf@y
+ \dim_set:Nn \l_tmpa_dim {\pgf@y + 0.5 \arrayrulewidth }
\@@_qpoint:n { row - \@@_succ:n \c@iRow }
- \dim_set_eq:NN \l_tmpb_dim \pgf@y
- \clist_map_inline:nn { #2 }
+ \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth }
+ \clist_map_inline:nn { #3 }
{
\tl_set:Nn \l_tmpa_tl { ##1 }
\tl_if_in:NnTF \l_tmpa_tl { - }
@@ -8268,11 +8774,14 @@ version 2005/12/01 or later.
% Now, the numbers of both columns are in |\l_tmpa_tl| and |\l_tmpb_tl|.
% \begin{macrocode}
\@@_qpoint:n { col - \l_tmpa_tl }
- \dim_set_eq:NN \l_tmpc_dim \pgf@x
+ \int_compare:nNnTF \l_@@_first_col_int = \l_tmpa_tl
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } }
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x + 0.5 \arrayrulewidth } }
\@@_qpoint:n { col - \@@_succ:n \l_tmpb_tl }
+ \dim_set:Nn \l_tmpd_dim { \pgf@x + 0.5 \arrayrulewidth }
\pgfpathrectanglecorners
{ \pgfpoint \l_tmpc_dim \l_tmpa_dim }
- { \pgfpoint \pgf@x \l_tmpb_dim }
+ { \pgfpoint \l_tmpd_dim \l_tmpb_dim }
}
\pgfusepathqfill
\endpgfpicture
@@ -8281,16 +8790,16 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% Here an example : |\@@_cellcolor:nn {red!15}{2-3,3-4,4-5,5-6}|
+% Here an example : |\@@_cellcolor[rgb]{0.5,0.5,0}{2-3,3-4,4-5,5-6}|
% \begin{macrocode}
-\cs_new_protected:Npn \@@_cellcolor:nn #1 #2
+\NewDocumentCommand \@@_cellcolor { O { } m m }
{
- \tl_if_blank:nF { #1 }
+ \tl_if_blank:nF { #2 }
{
\pgfpicture
\pgf@relevantforpicturesizefalse
- \pgfsetfillcolor { #1 }
- \clist_map_inline:nn { #2 }
+ \tl_if_empty:nTF { #1 } \color { \color [ #1 ] } { #2 }
+ \clist_map_inline:nn { #3 }
{
\@@_cut_on_hyphen:w ##1 \q_stop
\@@_qpoint:n { row - \l_tmpa_tl }
@@ -8298,13 +8807,15 @@ version 2005/12/01 or later.
{ \int_compare_p:n { \l_tmpa_tl <= \c@iRow } }
{ \int_compare_p:n { \l_tmpb_tl <= \c@jCol } }
{
- \dim_set_eq:NN \l_tmpb_dim \pgf@y
+ \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth }
\@@_qpoint:n { row - \@@_succ:n \l_tmpa_tl }
- \dim_set_eq:NN \l_tmpa_dim \pgf@y
+ \dim_set:Nn \l_tmpa_dim { \pgf@y + 0.5 \arrayrulewidth }
\@@_qpoint:n { col - \l_tmpb_tl }
- \dim_set_eq:NN \l_tmpc_dim \pgf@x
+ \int_compare:nNnTF \l_@@_first_col_int = \l_tmpb_tl
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } }
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x + 0.5 \arrayrulewidth } }
\@@_qpoint:n { col - \@@_succ:n \l_tmpb_tl }
- \dim_set_eq:NN \l_tmpd_dim \pgf@x
+ \dim_set:Nn \l_tmpd_dim { \pgf@x + 0.5 \arrayrulewidth }
\pgfpathrectanglecorners
{ \pgfpoint \l_tmpc_dim \l_tmpb_dim }
{ \pgfpoint \l_tmpd_dim \l_tmpa_dim }
@@ -8312,38 +8823,40 @@ version 2005/12/01 or later.
}
\pgfusepathqfill
\endpgfpicture
- }
+ }
}
% \end{macrocode}
%
% \bigskip
-% Here an example : |\@@_rectanglecolor:nn {red!15}{2-3}{5-6}|
+% Here an example : |\@@_rectanglecolor{red!15}{2-3}{5-6}|
% \begin{macrocode}
-\cs_new_protected:Npn \@@_rectanglecolor:nnn #1 #2 #3
+\NewDocumentCommand \@@_rectanglecolor { O { } m m m }
{
- \tl_if_blank:nF { #1 }
+ \tl_if_blank:nF { #2 }
{
\pgfpicture
\pgf@relevantforpicturesizefalse
- \pgfsetfillcolor { #1 }
- \@@_cut_on_hyphen:w #2 \q_stop
+ \tl_if_empty:nTF { #1 } \color { \color [ #1 ] } { #2 }
+ \@@_cut_on_hyphen:w #3 \q_stop
\bool_lazy_and:nnT
{ \int_compare_p:n { \l_tmpa_tl <= \c@iRow } }
{ \int_compare_p:n { \l_tmpb_tl <= \c@jCol } }
{
\@@_qpoint:n { row - \l_tmpa_tl }
- \dim_set_eq:NN \l_tmpb_dim \pgf@y
+ \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth }
\@@_qpoint:n { col - \l_tmpb_tl }
- \@@_cut_on_hyphen:w #3 \q_stop
+ \int_compare:nNnTF \l_@@_first_col_int = \l_tmpb_tl
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } }
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x + 0.5 \arrayrulewidth } }
+ \@@_cut_on_hyphen:w #4 \q_stop
\int_compare:nNnT \l_tmpa_tl > \c@iRow
{ \tl_set:Nx \l_tmpa_tl { \int_use:N \c@iRow } }
\int_compare:nNnT \l_tmpb_tl > \c@jCol
{ \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } }
- \dim_set_eq:NN \l_tmpc_dim \pgf@x
\@@_qpoint:n { row - \@@_succ:n \l_tmpa_tl }
- \dim_set_eq:NN \l_tmpa_dim \pgf@y
+ \dim_set:Nn \l_tmpa_dim { \pgf@y + 0.5 \arrayrulewidth }
\@@_qpoint:n { col - \@@_succ:n \l_tmpb_tl }
- \dim_set_eq:NN \l_tmpd_dim \pgf@x
+ \dim_set:Nn \l_tmpd_dim { \pgf@x + 0.5 \arrayrulewidth }
\pgfpathrectanglecorners
{ \pgfpoint \l_tmpc_dim \l_tmpb_dim }
{ \pgfpoint \l_tmpd_dim \l_tmpa_dim }
@@ -8361,30 +8874,32 @@ version 2005/12/01 or later.
% However, the command |\rowcolors| of \pkg{nicematrix} has \emph{not} the
% optional argument of the command |\rowcolors| of \pkg{xcolor}.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_rowcolors:nnn #1 #2 #3
+\NewDocumentCommand \@@_rowcolors { O { } m m m }
{
- \int_step_inline:nnn { #1 } { \int_use:N \c@iRow }
+ \int_step_inline:nnn { #2 } { \int_use:N \c@iRow }
{
\int_if_odd:nTF { ##1 }
- { \@@_rowcolor:nn { #2 } { ##1 } }
- { \@@_rowcolor:nn { #3 } { ##1 } }
- }
+ { \@@_rowcolor [ #1 ] { #3 } }
+ { \@@_rowcolor [ #1 ] { #4 } }
+ { ##1 }
+ }
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
-\cs_new_protected:Npn \@@_chessboardcolors:nn #1 #2
+\NewDocumentCommand \@@_chessboardcolors { O { } m m }
{
\int_step_inline:nn { \int_use:N \c@iRow }
{
\int_step_inline:nn { \int_use:N \c@jCol }
{
\int_if_even:nTF { ####1 + ##1 }
- { \@@_cellcolor:nn { #1 } { ####1 - ##1 } }
- { \@@_cellcolor:nn { #2 } { ####1 - ##1 } }
+ { \@@_cellcolor [ #1 ] { #2 } }
+ { \@@_cellcolor [ #1 ] { #3 } }
+ { ##1 - ####1 }
}
- }
+ }
}
% \end{macrocode}
%
@@ -8500,10 +9015,8 @@ version 2005/12/01 or later.
% \begin{macrocode}
\@@_qpoint:n { row - 1 }
\dim_set_eq:NN \l_tmpa_dim \pgf@y
- \pgfusepathqfill
\@@_qpoint:n { row - \@@_succ:n \c@iRow }
\dim_sub:Nn \l_tmpa_dim \pgf@y
- \pgfusepathqfill
% \end{macrocode}
% We translate vertically to take into account the potential ``last row''.
% \begin{macrocode}
@@ -8516,7 +9029,7 @@ version 2005/12/01 or later.
% We adjust the value of |\l_tmpa_dim| by the width of the horizontal rule just
% before the ``last row''.
% \begin{macrocode}
- \@@_qpoint:n { row - \@@_succ:n\c@iRow }
+ \@@_qpoint:n { row - \@@_succ:n \c@iRow }
\dim_add:Nn \l_tmpa_dim \pgf@y
\@@_qpoint:n { row - \@@_succ:n \g_@@_row_total_int }
\dim_sub:Nn \l_tmpa_dim \pgf@y
@@ -8546,6 +9059,223 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+%%
+% \subsection*{The key hvlines}
+%
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_draw_hlines:
+ {
+ \pgfpicture
+ \CT@arc@
+ \pgfrememberpicturepositiononpagetrue
+ \pgf@relevantforpicturesizefalse
+ \pgfsetlinewidth \arrayrulewidth
+ \int_step_inline:nnn
+ { \bool_if:NTF \l_@@_NiceArray_bool 1 2 }
+ { \bool_if:NTF \l_@@_NiceArray_bool { \@@_succ:n \c@iRow } \c@iRow }
+ {
+ \@@_qpoint:n { row - ##1 }
+ \dim_set_eq:NN \l_tmpa_dim \pgf@y
+ \pgfpathmoveto { \pgfpoint \pgf@x \pgf@y }
+ \@@_qpoint:n { col - \@@_succ:n { \c@jCol } }
+ \dim_set:Nn \l_tmpb_dim { \pgf@x + 0.5 \arrayrulewidth }
+ \pgfpathlineto { \pgfpoint \l_tmpb_dim \l_tmpa_dim }
+ }
+ \pgfusepathqstroke
+ \endpgfpicture
+ }
+% \end{macrocode}
+%
+% \bigskip
+% Since version 4.1, the key |hvlines| is no longer a mere alias for
+% the conjonction of |hlines| and |vlines|. Indeed, with |hvlines|, the vertical
+% and horizontal rules are \emph{not} drawn within the blocks (created by
+% |\Block|) nor within the ``virtual blocks'' (corresponding to the dotted lines
+% drawn by |\Cdots|, |\Vdots|, etc.).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_draw_hvlines:
+ {
+ \bool_lazy_and:nnTF
+ { \seq_if_empty_p:N \g_@@_pos_of_blocks_seq }
+ { \seq_if_empty_p:N \g_@@_pos_of_xdots_seq }
+ \@@_draw_hvlines_i:
+ \@@_draw_hvlines_ii:
+ }
+% \end{macrocode}
+%
+% \bigskip
+% This version is only for efficiency. The general case (in
+% |\@@_draw_hvlines_ii:|) does the job in all case (but slower).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_draw_hvlines_i:
+ {
+ \@@_draw_hlines:
+ \@@_draw_vlines:
+ }
+% \end{macrocode}
+%
+% \bigskip
+% Now, the general case, where there are blocks or dots in the array.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_draw_hvlines_ii:
+ {
+ \group_begin:
+ \CT@arc@
+% \end{macrocode}
+%
+% First, the exterior rectangle of the array (only in |{NiceArray}| and
+% |{NiceTabular}|).
+% \begin{macrocode}
+ \bool_if:NT \l_@@_NiceArray_bool
+ {
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgf@relevantforpicturesizefalse
+ \pgfsetlinewidth \arrayrulewidth
+ \pgfsetrectcap
+ \@@_qpoint:n { col - 1 }
+ \dim_set_eq:NN \l_tmpa_dim \pgf@x
+ \@@_qpoint:n { row -1 }
+ \dim_set_eq:NN \l_tmpb_dim \pgf@y
+ \@@_qpoint:n { col - \@@_succ:n \c@jCol }
+ \dim_set_eq:NN \l_tmpc_dim \pgf@x
+ \@@_qpoint:n { row - \@@_succ:n \c@iRow }
+ \pgfpathrectanglecorners
+ { \pgfpoint \l_tmpa_dim \l_tmpb_dim }
+ { \pgfpoint \l_tmpc_dim \pgf@y }
+ \pgfusepathqstroke
+ \endpgfpicture
+ }
+% \end{macrocode}
+%
+% First, the horizontal rules in the interior of the array.
+% \begin{macrocode}
+ \int_step_variable:nnNn 2 \c@iRow \l_tmpa_tl
+ {
+ \int_step_variable:nNn \c@jCol \l_tmpb_tl
+ {
+% \end{macrocode}
+% The boolean |\g_tmpa_bool| indicates whether the small horizontal rule will be
+% drawn. If we find that it is in a block (a real block, created by |\Block| or
+% a virtual block corresponding to a dotted line, created by |\Cdots|, |\Vdots|,
+% etc.), we will set |\g_tmpa_bool| to |false| and the small horizontal rule
+% won't be drawn.
+% \begin{macrocode}
+ \bool_gset_true:N \g_tmpa_bool
+ \seq_map_inline:Nn \g_@@_pos_of_blocks_seq
+ { \@@_test_if_hline_in_block:nnnn ##1 }
+ \seq_map_inline:Nn \g_@@_pos_of_xdots_seq
+ { \@@_test_if_hline_in_block:nnnn ##1 }
+ \bool_if:NT \g_tmpa_bool
+ {
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgf@relevantforpicturesizefalse
+ \pgfsetlinewidth \arrayrulewidth
+ \pgfsetrectcap
+ \@@_qpoint:n { row - \l_tmpa_tl }
+ \dim_set_eq:NN \l_tmpb_dim \pgf@y
+ \@@_qpoint:n { col - \l_tmpb_tl }
+ \dim_set_eq:NN \l_tmpa_dim \pgf@x
+ \@@_qpoint:n { col - \@@_succ:n \l_tmpb_tl }
+ \dim_set_eq:NN \l_tmpc_dim \pgf@x
+ \pgfpathmoveto { \pgfpoint \l_tmpa_dim \l_tmpb_dim }
+ \pgfpathlineto { \pgfpoint \l_tmpc_dim \l_tmpb_dim }
+ \pgfusepathqstroke
+ \endpgfpicture
+ }
+ }
+ }
+% \end{macrocode}
+% Now, the vertical rules in the interior of the array.
+% \begin{macrocode}
+ \int_step_variable:nNn \c@iRow \l_tmpa_tl
+ {
+ \int_step_variable:nnNn 2 \c@jCol \l_tmpb_tl
+ {
+% \end{macrocode}
+% The boolean |\g_tmpa_bool| indicates whether the small vertial rule will be
+% drawn. If we find that it is in a block (a real block, created by |\Block| or
+% a virtual block corresponding to a dotted line, created by |\Cdots|, |\Vdots|,
+% etc.), we will set |\g_tmpa_bool| to |false| and the small vertial rule won't
+% be drawn.
+% \begin{macrocode}
+ \bool_gset_true:N \g_tmpa_bool
+ \seq_map_inline:Nn \g_@@_pos_of_blocks_seq
+ { \@@_test_if_vline_in_block:nnnn ##1 }
+ \seq_map_inline:Nn \g_@@_pos_of_xdots_seq
+ { \@@_test_if_vline_in_block:nnnn ##1 }
+ \bool_if:NT \g_tmpa_bool
+ {
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgf@relevantforpicturesizefalse
+ \pgfsetlinewidth \arrayrulewidth
+ \pgfsetrectcap
+ \@@_qpoint:n { row - \l_tmpa_tl }
+ \dim_set_eq:NN \l_tmpb_dim \pgf@y
+ \@@_qpoint:n { col - \l_tmpb_tl }
+ \dim_set_eq:NN \l_tmpa_dim \pgf@x
+ \@@_qpoint:n { row - \@@_succ:n \l_tmpa_tl }
+ \dim_set_eq:NN \l_tmpc_dim \pgf@y
+ \pgfpathmoveto { \pgfpoint \l_tmpa_dim \l_tmpb_dim }
+ \pgfpathlineto { \pgfpoint \l_tmpa_dim \l_tmpc_dim }
+ \pgfusepathqstroke
+ \endpgfpicture
+ }
+ }
+ }
+% \end{macrocode}
+% The group was for the color of the rules.
+% \begin{macrocode}
+ \group_end:
+ \seq_gclear:N \g_@@_pos_of_xdots_seq
+ }
+% \end{macrocode}
+%
+% The following command tests wether the current position in the array (given by
+% |\l_tmpa_tl| for the row and |\l_tmpb_tl| for the col) would provide an
+% horizontal rule towards the right in the block delimited by the four arguments
+% |#1|, |#2|, |#3| and |#4|. If this rule would be in the block (it must not be
+% drawn), the boolean |\l_tmpa_bool| is set to |false|.
+% \begin{macrocode}
+\cs_set_protected:Npn \@@_test_if_hline_in_block:nnnn #1 #2 #3 #4
+ {
+ \int_compare:nNnT \l_tmpa_tl > { #1 }
+ {
+ \int_compare:nNnT \l_tmpa_tl < { #3 + 1 }
+ {
+ \int_compare:nNnT \l_tmpb_tl > { #2 - 1 }
+ {
+ \int_compare:nNnT \l_tmpb_tl < { #4 + 1 }
+ { \bool_gset_false:N \g_tmpa_bool }
+ }
+ }
+ }
+ }
+% \end{macrocode}
+%
+% The same for vertical rules.
+% \begin{macrocode}
+\cs_set_protected:Npn \@@_test_if_vline_in_block:nnnn #1 #2 #3 #4
+ {
+ \int_compare:nNnT \l_tmpa_tl > { #1 - 1 }
+ {
+ \int_compare:nNnT \l_tmpa_tl < { #3 + 1 }
+ {
+ \int_compare:nNnT \l_tmpb_tl > { #2 }
+ {
+ \int_compare:nNnT \l_tmpb_tl < { #4 + 1 }
+ { \bool_gset_false:N \g_tmpa_bool }
+ }
+ }
+ }
+ }
+% \end{macrocode}
+%
+%
+%
%
% \bigskip
% \subsection*{The commands to draw dotted lines to separate columns and rows}
@@ -9211,54 +9941,63 @@ version 2005/12/01 or later.
\cs_new_protected:Npn \@@_Block_ii:nnnnn #1 #2 #3 #4 #5
{
% \end{macrocode}
-% We write an instruction in the |code-after|. We write the instruction in the
-% beginning of the |code-after| (the |left| in |\tl_gput_left:Nx|) because we
-% want the Tikz nodes corresponding of the block created \emph{before} potential
-% instructions written by the user in the |code-after| (these instructions may
-% use the Tikz node of the created block).
+%
+% \medskip
% \begin{macrocode}
- \tl_gput_left:Nx \g_@@_internal_code_after_tl
+ \tl_set:Nx \l_tmpa_tl
{
- \@@_Block_iii:nnnnnn
{ \int_use:N \c@iRow }
{ \int_use:N \c@jCol }
{ \int_eval:n { \c@iRow + #1 - 1 } }
{ \int_eval:n { \c@jCol + #2 - 1 } }
- { #3 }
- \exp_not:n { { #4 $ #5 $ } }
- }
+ }
% \end{macrocode}
-% It's not allowed to use the command |\Block| twice in the same cell of the
-% array. That's why, at the first use, we link the command |\Block|
-% to a special version. The scope of this link is the cell of the array.
+% Now, |\l_tmpa_tl| constains a ``object'' corresponding to the position of the
+% block whith four components surrounded by brackets:
+%
+% |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}|.
+%
+% We store this information in the sequence |\g_@@_pos_of_blocks_seq|.
% \begin{macrocode}
- \cs_set_eq:NN \Block \@@_Block_error:nn
- }
+ \seq_gput_left:NV \g_@@_pos_of_blocks_seq \l_tmpa_tl
% \end{macrocode}
+% We also store a complete description of the block in the sequence
+% |\g_@@_blocks_seq|. Of course, the sequences |\g_@@_pos_of_blocks_seq| and
+% |\g_@@_blocks_seq| are redundant, but it's for efficiency. In
+% |\g_@@_blocks_seq|, each block is represented by an ``objet'' with six
+% components:
%
+% |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}{|\textsl{options}|}{|\textsl{contents}|}|.
% \begin{macrocode}
-\cs_new:Npn \@@_Block_error:nn #1 #2
- {
- \@@_error:n { Second~Block }
- \cs_set_eq:NN \Block \use:nn
+ \seq_gput_left:Nx \g_@@_blocks_seq
+ {
+ \l_tmpa_tl
+ { #3 }
+ \exp_not:n { { #4 \@@_math_toggle_token: #5 \@@_math_toggle_token: } }
+ }
}
% \end{macrocode}
+%
%
-% \medskip
+% \bigskip
+% The key |tikz| is for Tikz options used when the \textsc{pgf} node of the
+% block is created.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / Block }
{
tikz .tl_set:N = \l_@@_tikz_tl ,
tikz .value_required:n = true ,
- white .bool_set:N = \l_@@_white_bool ,
- white .default:n = true ,
- white .value_forbidden:n = true ,
}
% \end{macrocode}
%
+% \bigskip
+% The command |\@@_draw_blocks:| will draw all the blocks. This command is used
+% after the construction of the array.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_draw_blocks:
+ { \seq_map_inline:Nn \g_@@_blocks_seq { \@@_Block_iii:nnnnnn ##1 } }
+% \end{macrocode}
%
-% \medskip
-% The following command |\@@_Block_iii:nnnnnn| will be used in the |code-after|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_Block_iii:nnnnnn #1 #2 #3 #4 #5 #6
{
@@ -9270,11 +10009,9 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \begin{macrocode}
- \bool_if:nTF
- {
- \int_compare_p:nNn { #3 } > \c@iRow
- || \int_compare_p:nNn { #4 } > \c@jCol
- }
+ \bool_lazy_or:nnTF
+ { \int_compare_p:nNn { #3 } > \c@iRow }
+ { \int_compare_p:nNn { #4 } > \c@jCol }
{ \msg_error:nnnn { nicematrix } { Block~too~large } { #1 } { #2 } }
{
% \end{macrocode}
@@ -9299,33 +10036,6 @@ version 2005/12/01 or later.
\@@_qpoint:n { col - \@@_succ:n { #4 } }
\dim_set_eq:NN \l_tmpd_dim \pgf@x
% \end{macrocode}
-%
-% \medskip
-% The following code doesn't work for the first vertical rule. You should allow
-% the option |white| if and only if the option |vlines| and |hlines| has been used.
-% \begin{macrocode}
- \bool_if:NT \l_@@_white_bool
- {
- \begin { pgfscope }
- \pgfsetfillcolor { white }
-% \end{macrocode}
-%
-% \begin{macrocode}
- \pgfpathrectanglecorners
- {
- \pgfpoint
- { \l_tmpb_dim + 0.5 \arrayrulewidth }
- { \l_tmpa_dim - 0.5 \arrayrulewidth }
- }
- {
- \pgfpoint
- { \l_tmpd_dim - 0.5 \arrayrulewidth }
- { \l_tmpc_dim + 0.5 \arrayrulewidth }
- }
- \pgfusepathqfill
- \end { pgfscope }
- }
-% \end{macrocode}
%
% We construct the node for the block with the name |(#1-#2-block)|.
%
@@ -9510,7 +10220,9 @@ version 2005/12/01 or later.
% case of use of |\dotfill| ``internally'' in the cell (e.g. |\hbox to 1cm {\dotfill}|).
% \begin{macrocode}
\@@_dotfill
- \group_insert_after:N \@@_dotfill_i:
+ \bool_if:NT \l_@@_NiceTabular_bool
+ { \group_insert_after:N \@@_dotfill_ii: }
+ { \group_insert_after:N \@@_dotfill_i: }
}
\cs_new_protected:Npn \@@_dotfill_i: { \group_insert_after:N \@@_dotfill_ii: }
\cs_new_protected:Npn \@@_dotfill_ii: { \group_insert_after:N \@@_dotfill_iii: }
@@ -9518,32 +10230,32 @@ version 2005/12/01 or later.
% Now, if the box if not empty (unfornately, we can't actually test whether the
% box is empty and that's why we only consider it's width), we insert
% |\@@_dotfill| (which is the saved version of |\dotfill|) in the cell of the
-% array, and it will extends, since it's no longer in |\l_@@_cell_box|.
+% array, and it will extend, since it is no longer in |\l_@@_cell_box|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_dotfill_iii:
{ \dim_compare:nNnT { \box_wd:N \l_@@_cell_box } = \c_zero_dim \@@_dotfill }
% \end{macrocode}
%
-% \subsection*{The command \textbackslash slashbox}
+% \subsection*{The command \textbackslash diagbox}
%
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_slashbox:nn #1 #2
+\cs_new_protected:Npn \@@_diagbox:nn #1 #2
{
\tl_gput_right:Nx \g_@@_internal_code_after_tl
{
- \@@_actually_slashbox:nnnn
+ \@@_actually_diagbox:nnnn
{ \int_use:N \c@iRow } { \int_use:N \c@jCol } { #1 } { #2 }
}
}
% \end{macrocode}
%
% \medskip
-% The two arguments of |\@@_actually_slashbox:nn| are the number of row and the
+% The two arguments of |\@@_actually_diagbox:nn| are the number of row and the
% number of column of the cell to slash. The two other are the elements to draw
% below and above the diagonal line.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_actually_slashbox:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \@@_actually_diagbox:nnnn #1 #2 #3 #4
{
\pgfpicture
\pgf@relevantforpicturesizefalse
@@ -9571,10 +10283,12 @@ version 2005/12/01 or later.
\pgfset { inner~sep = 1 pt }
\pgfscope
\pgftransformshift { \pgfpoint \l_tmpb_dim \l_tmpc_dim }
- \pgfnode { rectangle } { south~west } { $ #3 $ } { } { }
+ \pgfnode { rectangle } { south~west }
+ { \@@_math_toggle_token: #3 \@@_math_toggle_token: } { } { }
\endpgfscope
\pgftransformshift { \pgfpoint \l_tmpd_dim \l_tmpa_dim }
- \pgfnode { rectangle } { north~east } { $ #4 $ } { } { }
+ \pgfnode { rectangle } { north~east }
+ { \@@_math_toggle_token: #4 \@@_math_toggle_token: } { } { }
\endpgfpicture
}
% \end{macrocode}
@@ -9621,21 +10335,12 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+%
%
% \bigskip
-% \subsection*{We process the options}
+% \subsection*{We process the options at package loading}
%
%
-% \begin{macrocode}
-\@@_msg_new:nn { obsolete~environments }
- {
- The~obsolete~environments~(eg.~{pNiceArrayC})~have~been~deleted~
- from~the~package~nicematrix.\\
- However,~if~you~still~want~to~use~them,~you~will~find~the~code~for~
- those~environments~at~the~end~of~the~file~'nicematrix.sty',~after~
- a~command~'\token_to_str:N\file_input_stop:'.
- }
-% \end{macrocode}
%
% We process the options when the package is loaded (with |\usepackage|) but we
% recommend to use |\NiceMatrixOptions| instead.
@@ -9655,11 +10360,6 @@ version 2005/12/01 or later.
renew-matrix .value_forbidden:n = true ,
transparent .meta:n = { renew-dots , renew-matrix } ,
transparent .value_forbidden:n = true,
- obsolete-environments .code:n = \@@_fatal:n { obsolete~environments },
- starred-commands .code:n =
- \@@_msg_redirect_name:nn { starred~commands } { none } ,
- starred-commands .value_forbidden:n = true ,
-
}
\ProcessKeysOptions { NiceMatrix / Package }
% \end{macrocode}
@@ -9798,6 +10498,7 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+%
% \begin{macrocode}
\@@_msg_new:nn { option~S~without~siunitx }
{
@@ -9841,16 +10542,14 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
-% \begin{macrocode}
-\@@_msg_new:nn { starred~commands }
+% \begin{macrocode}
+\@@_msg_new:nn { standard-cline~in~document }
{
- The~starred~versions~of~\token_to_str:N \Cdots,~\token_to_str:N \Ldots,~
- \token_to_str:N \Vdots,~\token_to_str:N\Ddots\ and~\token_to_str:N\Iddots\
- are~deprecated.~However,~you~can~go~on~for~this~time.~If~you~don't~want~to~
- see~this~error~we~should~load~'nicematrix'~with~the~option~
- 'starred-commands'.
+ The~key~'standard-cline'~is~available~only~in~the~preamble.\\
+ If~you~go~on~this~command~will~be~ignored.
}
% \end{macrocode}
+%
%
% \begin{macrocode}
\@@_msg_new:nn { bad~value~for~baseline }
@@ -9862,14 +10561,6 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
-%
-% \begin{macrocode}
-\@@_msg_new:nn { Second~Block }
- {
- You~can't~use~\token_to_str:N \Block\ twice~in~the~same~cell~of~the~array.\\
- If~you~go~on,~this~command~(and~the~other)~will~be~ignored.
- }
-% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { empty~environment }
@@ -9896,6 +10587,7 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+%
% \begin{macrocode}
\@@_msg_new:nn { last-col~non~empty~for~NiceMatrixOptions }
{
@@ -9961,7 +10653,7 @@ version 2005/12/01 or later.
The~key~'\tl_use:N\l_keys_key_str'~is~unknown~for~the~command~
\token_to_str:N \NiceMatrixOptions. \\
If~you~go~on,~it~will~be~ignored. \\
- For~a~list~of~the~available~keys,~type~H~<return>.
+ For~a~list~of~the~*principal*~available~keys,~type~H~<return>.
}
{
The~available~options~are~(in~alphabetic~order):~
@@ -9976,7 +10668,6 @@ version 2005/12/01 or later.
create-medium-nodes,~
create-large-nodes,~
end-of-row,~
- exterior-arraycolsep,~
first-col,~
first-row,~
hlines,~
@@ -9987,7 +10678,6 @@ version 2005/12/01 or later.
letter-for-dotted-lines,~
light-syntax,~
nullify-dots,~
- parallelize-diags,~
renew-dots,~
renew-matrix,~
right-margin,~
@@ -10006,7 +10696,7 @@ version 2005/12/01 or later.
The~option~'\tl_use:N\l_keys_key_str'~is~unknown~for~the~environment~
\{NiceArray\}. \\
If~you~go~on,~it~will~be~ignored. \\
- For~a~list~of~the~available~options,~type~H~<return>.
+ For~a~list~of~the~*principal*~available~options,~type~H~<return>.
}
{
The~available~options~are~(in~alphabetic~order):~
@@ -10024,7 +10714,6 @@ version 2005/12/01 or later.
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
- end-of-row,~
extra-left-margin,~
extra-right-margin,~
first-col,~
@@ -10037,9 +10726,10 @@ version 2005/12/01 or later.
light-syntax,~
name,~
nullify-dots,~
- parallelize-diags,~
renew-dots,~
right-margin,~
+ rules/color,~
+ rules/width,~
small,~
t,~
vlines,~
@@ -10059,7 +10749,7 @@ version 2005/12/01 or later.
The~option~'\tl_use:N\l_keys_key_str'~is~unknown~for~the~
\@@_full_name_env:. \\
If~you~go~on,~it~will~be~ignored. \\
- For~a~list~of~the~available~options,~type~H~<return>.
+ For~a~list~of~the~*principal*~available~options,~type~H~<return>.
}
{
The~available~options~are~(in~alphabetic~order):~
@@ -10077,7 +10767,6 @@ version 2005/12/01 or later.
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
- end-of-row,~
extra-left-margin,~
extra-right-margin,~
first-col,~
@@ -10091,10 +10780,11 @@ version 2005/12/01 or later.
light-syntax,~
name,~
nullify-dots,~
- parallelize-diags,~
r~(=R),~
renew-dots,~
right-margin,~
+ rules/color,~
+ rules/width,~
S,~
small,~
t,~
@@ -10111,7 +10801,7 @@ version 2005/12/01 or later.
The~option~'\tl_use:N\l_keys_key_str'~is~unknown~for~the~environment~
\{NiceTabular\}. \\
If~you~go~on,~it~will~be~ignored. \\
- For~a~list~of~the~available~options,~type~H~<return>.
+ For~a~list~of~the~*principal*~available~options,~type~H~<return>.
}
{
The~available~options~are~(in~alphabetic~order):~
@@ -10129,7 +10819,6 @@ version 2005/12/01 or later.
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
- end-of-row,~
extra-left-margin,~
extra-right-margin,~
first-col,~
@@ -10142,9 +10831,10 @@ version 2005/12/01 or later.
light-syntax,~
name,~
nullify-dots,~
- parallelize-diags,~
renew-dots,~
right-margin,~
+ rules/color,~
+ rules/width,~
t,~
vlines,~
xdots/color,~
@@ -10187,97 +10877,6 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
-%
-% \bigskip
-% \subsection*{Obsolete environments}
-%
-% The following environments are loaded only when the package \pkg{nicematrix}
-% has been loaded with the option |obsolete-environments|. However, they will be
-% completly deleted in a future version.
-%
-% \begin{macrocode}
-\file_input_stop:
-\NewDocumentEnvironment { pNiceArrayC } { }
- {
- \int_zero:N \l_@@_last_col_int
- \pNiceArray
- }
- { \endpNiceArray }
- \NewDocumentEnvironment { bNiceArrayC } { }
- {
- \int_zero:N \l_@@_last_col_int
- \bNiceArray
- }
- { \endbNiceArray }
-\NewDocumentEnvironment { BNiceArrayC } { }
- {
- \int_zero:N \l_@@_last_col_int
- \BNiceArray
- }
- { \endBNiceArray }
-\NewDocumentEnvironment { vNiceArrayC } { }
- {
- \int_zero:N \l_@@_last_col_int
- \vNiceArray
- }
- { \endvNiceArray }
-\NewDocumentEnvironment { VNiceArrayC } { }
- {
- \int_zero:N \l_@@_last_col_int
- \VNiceArray
- }
- { \endVNiceArray }
-\NewDocumentEnvironment { pNiceArrayRC } { }
- {
- \int_zero:N \l_@@_last_col_int
- \int_zero:N \l_@@_first_row_int
- \pNiceArray
- }
- { \endpNiceArray }
-\NewDocumentEnvironment { bNiceArrayRC } { }
- {
- \int_zero:N \l_@@_last_col_int
- \int_zero:N \l_@@_first_row_int
- \bNiceArray
- }
- { \endbNiceArray }
-\NewDocumentEnvironment { BNiceArrayRC } { }
- {
- \int_zero:N \l_@@_last_col_int
- \int_zero:N \l_@@_first_row_int
- \BNiceArray
- }
- { \endBNiceArray }
-\NewDocumentEnvironment { vNiceArrayRC } { }
- {
- \int_zero:N \l_@@_last_col_int
- \int_zero:N \l_@@_first_row_int
- \vNiceArray
- }
- { \endvNiceArray }
-\NewDocumentEnvironment { VNiceArrayRC } { }
- {
- \int_zero:N \l_@@_last_col_int
- \int_zero:N \l_@@_first_row_int
- \VNiceArray
- }
- { \endVNiceArray }
-\NewDocumentEnvironment { NiceArrayCwithDelims } { }
- {
- \int_zero:N \l_@@_last_col_int
- \NiceArrayWithDelims
- }
- { \endNiceArrayWithDelims }
-\NewDocumentEnvironment { NiceArrayRCwithDelims } { }
- {
- \int_zero:N \l_@@_last_col_int
- \int_zero:N \l_@@_first_row_int
- \NiceArrayWithDelims
- }
- { \endNiceArrayWithDelims }
-% \end{macrocode}
-%
-%
%
% \vspace{1cm}
% \section{History}
@@ -10576,6 +11175,14 @@ version 2005/12/01 or later.
%
% Commands to color cells, row and columns with a perfect result in the \textsc{pdf}.
%
+% \subsection*{Changes between versions 4.0 and 4.1}
+%
+% New keys |cell-space-top-limit| and |cell-space-bottom-limit|
+%
+% New command |\diagbox|
+%
+% The key |hvline| don't draw rules in the blocks (commands |\Block|) and in the
+% virtual blocks corresponding to the dotted lines.
%
% \PrintIndex
%
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
index 06c3fa98690..dde56d6fc32 100644
--- a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
+++ b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
@@ -18,8 +18,8 @@
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%%
-\def\myfileversion{4.0}
-\def\myfiledate{2020/05/08}
+\def\myfileversion{4.1}
+\def\myfiledate{2020/05/27}
\RequirePackage{pgfcore}
\usepgfmodule{shapes}
\RequirePackage{l3keys2e}
@@ -110,22 +110,59 @@
{ \bool_set_true:N \c__nicematrix_colortbl_loaded_bool }
{
\cs_set_protected:Npn \CT@arc@ { }
- \NewDocumentCommand { \arrayrulecolor } { m }
- { \tl_gset:Nn \CT@arc@ { \color { #1 } } }
+ \cs_set:Npn \arrayrulecolor #1 # { \CT@arc { #1 } }
+ \cs_set:Npn \CT@arc #1 #2
+ {
+ \dim_compare:nNnT \baselineskip = \c_zero_dim \noalign
+ { \cs_gset:Npn \CT@arc@ { \color #1 { #2 } } }
+ }
\cs_set:Npn \hline
{
\noalign { \ifnum 0 = `} \fi
- \let \hskip \vskip
- \let \vrule \hrule
- \let \@width \@height
+ \cs_set_eq:NN \hskip \vskip
+ \cs_set_eq:NN \vrule \hrule
+ \cs_set_eq:NN \@width \@height
{ \CT@arc@ \vline }
\futurelet \reserved@a
\@xhline
}
}
}
+\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_compare:nNnT { #1 } > 1 { \multispan { \__nicematrix_pred:n { #1 } } & }
+ \multispan { \int_eval:n { #2 - #1 + 1 } }
+ { \CT@arc@ \leaders \hrule \@height \arrayrulewidth \hfill }
+ \everycr { }
+ \cr
+ \noalign { \skip_vertical:N -\arrayrulewidth }
+ }
+\cs_set:Npn \__nicematrix_cline
+ { \exp_args:Ne \__nicematrix_cline_i:nn \l__nicematrix_first_col_int }
+\cs_set:Npn \__nicematrix_cline_i:nn #1 #2 { \__nicematrix_cline_i:w #1-#2 \q_stop }
+\cs_set:Npn \__nicematrix_cline_i:w #1-#2-#3 \q_stop
+ {
+ \int_compare:nNnT { #1 } < { #2 }
+ { \multispan { \int_eval:n { #2 - #1 } } & }
+ \multispan { \int_eval:n { #3 - #2 + 1 } }
+ { \CT@arc@ \leaders \hrule \@height \arrayrulewidth \hfill }
+ \peek_meaning_remove_ignore_spaces:NTF \cline
+ { & \exp_args:Ne \__nicematrix_cline_i:nn { \__nicematrix_succ:n { #3 } } }
+ { \everycr { } \cr }
+ }
+
\cs_new:Npn \__nicematrix_succ:n #1 { \the \numexpr #1 + 1 \relax }
\cs_new:Npn \__nicematrix_pred:n #1 { \the \numexpr #1 - 1 \relax }
+\cs_new:Npn \__nicematrix_math_toggle_token:
+ { \bool_if:NF \l__nicematrix_NiceTabular_bool \c_math_toggle_token }
+\cs_new_protected:Npn \__nicematrix_set_CT@arc@:
+ { \peek_meaning:NTF [ \__nicematrix_set_CT@arc@_i: \__nicematrix_set_CT@arc@_ii: }
+\cs_new_protected:Npn \__nicematrix_set_CT@arc@_i: [ #1 ] #2 \q_stop
+ { \cs_set:Npn \CT@arc@ { \color [ #1 ] { #2 } } }
+\cs_new_protected:Npn \__nicematrix_set_CT@arc@_ii: #1 \q_stop
+ { \cs_set:Npn \CT@arc@ { \color { #1 } } }
\bool_new:N \c__nicematrix_siunitx_loaded_bool
\AtBeginDocument
{
@@ -167,6 +204,8 @@
}
\int_new:N \g__nicematrix_env_int
\cs_new:Npn \__nicematrix_env: { nm - \int_use:N \g__nicematrix_env_int }
+\NewExpandableDocumentCommand \NiceMatrixLastEnv { }
+ { \int_use:N \g__nicematrix_env_int }
\cs_new_protected:Npn \__nicematrix_qpoint:n #1
{ \pgfpointanchor { \__nicematrix_env: - #1 } { center } }
\int_new:N \g__nicematrix_NiceMatrixBlock_int
@@ -196,6 +235,7 @@
\tl_new:N \g__nicematrix_internal_code_after_tl
\int_new:N \l__nicematrix_old_iRow_int
\int_new:N \l__nicematrix_old_jCol_int
+\tl_new:N \l__nicematrix_rules_color_tl
\bool_new:N \g__nicematrix_row_of_col_done_bool
\bool_new:N \l__nicematrix_code_before_bool
\dim_new:N \l__nicematrix_x_initial_dim
@@ -208,6 +248,9 @@
\dim_new:N \__nicematrix_old_arraycolsep_dim
\dim_new:N \g__nicematrix_width_last_col_dim
\dim_new:N \g__nicematrix_width_first_col_dim
+\seq_new:N \g__nicematrix_blocks_seq
+\seq_new:N \g__nicematrix_pos_of_blocks_seq
+\seq_new:N \g__nicematrix_pos_of_xdots_seq
\int_new:N \l__nicematrix_first_row_int
\int_set:Nn \l__nicematrix_first_row_int 1
\int_new:N \l__nicematrix_first_col_int
@@ -268,6 +311,7 @@
{ }
\end { pgfscope }
}
+\bool_new:N \l__nicematrix_standard_cline_bool
\dim_new:N \l__nicematrix_cell_space_top_limit_dim
\dim_new:N \l__nicematrix_cell_space_bottom_limit_dim
\dim_new:N \l__nicematrix_inter_dots_dim
@@ -287,6 +331,7 @@
\bool_set_true:N \l__nicematrix_parallelize_diags_bool
\bool_new:N \l__nicematrix_hlines_bool
\bool_new:N \l__nicematrix_vlines_bool
+\bool_new:N \l__nicematrix_hvlines_bool
\bool_new:N \l__nicematrix_nullify_dots_bool
\bool_new:N \l__nicematrix_auto_columns_width_bool
\str_new:N \l__nicematrix_name_str
@@ -319,8 +364,17 @@
up .tl_set:N = \l__nicematrix_xdots_up_tl ,
unknown .code:n = \__nicematrix_error:n { Unknown~option~for~xdots }
}
+\keys_define:nn { NiceMatrix / rules }
+ {
+ color .tl_set:N = \l__nicematrix_rules_color_tl ,
+ color .value_required:n = true ,
+ width .dim_set:N = \arrayrulewidth ,
+ width .value_required:n = true
+ }
\keys_define:nn { NiceMatrix / Global }
{
+ standard-cline .bool_set:N = \l__nicematrix_standard_cline_bool ,
+ standard-cline .default:n = true ,
cell-space-top-limit .dim_set:N = \l__nicematrix_cell_space_top_limit_dim ,
cell-space-top-limit .value_required:n = true ,
cell-space-bottom-limit .dim_set:N = \l__nicematrix_cell_space_bottom_limit_dim ,
@@ -345,7 +399,12 @@
code-for-last-row .value_required:n = true ,
hlines .bool_set:N = \l__nicematrix_hlines_bool ,
vlines .bool_set:N = \l__nicematrix_vlines_bool ,
- hvlines .meta:n = { hlines , vlines } ,
+ hvlines .code:n =
+ {
+ \bool_set_true:N \l__nicematrix_hvlines_bool
+ \bool_set_true:N \l__nicematrix_vlines_bool
+ \bool_set_true:N \l__nicematrix_hlines_bool
+ } ,
parallelize-diags .bool_set:N = \l__nicematrix_parallelize_diags_bool ,
renew-dots .bool_set:N = \l__nicematrix_renew_dots_bool ,
renew-dots .value_forbidden:n = true ,
@@ -412,24 +471,28 @@
NiceMatrix / Env ,
} ,
NiceMatrix / xdots .inherit:n = NiceMatrix / xdots ,
+ NiceMatrix / rules .inherit:n = NiceMatrix / rules ,
NiceTabular .inherit:n =
{
NiceMatrix / Global ,
NiceMatrix / Env
} ,
NiceTabular / xdots .inherit:n = NiceMatrix / xdots ,
+ NiceTabular / rules .inherit:n = NiceMatrix / rules ,
NiceArray .inherit:n =
{
NiceMatrix / Global ,
NiceMatrix / Env ,
} ,
NiceArray / xdots .inherit:n = NiceMatrix / xdots ,
+ NiceArray / rules .inherit:n = NiceMatrix / rules ,
pNiceArray .inherit:n =
{
NiceMatrix / Global ,
NiceMatrix / Env ,
} ,
- pNiceArray / xdots .inherit:n = NiceMatrix / xdots
+ pNiceArray / xdots .inherit:n = NiceMatrix / xdots ,
+ pNiceArray / rules .inherit:n = NiceMatrix / rules ,
}
\keys_define:nn { NiceMatrix / NiceMatrixOptions }
{
@@ -504,6 +567,9 @@
}
\keys_define:nn { NiceMatrix / NiceTabular }
{
+ last-col .code:n = \tl_if_empty:nF {#1}
+ { \__nicematrix_error:n { last-col~non~empty~for~NiceArray } }
+ \int_zero:N \l__nicematrix_last_col_int ,
unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceTabular }
}
\cs_new_protected:Npn \__nicematrix_Cell:
@@ -572,7 +638,7 @@
}
\cs_new_protected:Npn \__nicematrix_end_Cell:
{
- \bool_if:NF \l__nicematrix_NiceTabular_bool \c_math_toggle_token
+ \__nicematrix_math_toggle_token:
\hbox_set_end:
\box_set_ht:Nn \l__nicematrix_cell_box
{ \box_ht:N \l__nicematrix_cell_box + \l__nicematrix_cell_space_top_limit_dim }
@@ -677,7 +743,7 @@
\int_compare:nNnT \c@iRow > { -1 }
{
\int_compare:nNnF \c@iRow = \l__nicematrix_last_row_int
- { { \CT@arc@ \hrule height \arrayrulewidth } }
+ { \hrule height \arrayrulewidth width \c_zero_dim }
}
}
}
@@ -756,6 +822,9 @@
\cs_set_eq:NN \__nicematrix_old_iddots \iddots
\cs_set_eq:NN \firsthline \hline
\cs_set_eq:NN \lasthline \hline
+ \bool_if:NTF \l__nicematrix_standard_cline_bool
+ { \cs_set_eq:NN \cline \__nicematrix_standard_cline }
+ { \cs_set_eq:NN \cline \__nicematrix_cline }
\cs_set_eq:NN \Ldots \__nicematrix_Ldots
\cs_set_eq:NN \Cdots \__nicematrix_Cdots
\cs_set_eq:NN \Vdots \__nicematrix_Vdots
@@ -771,7 +840,7 @@
\cs_set_eq:NN \OnlyMainNiceMatrix \__nicematrix_OnlyMainNiceMatrix:n
\cs_set_eq:NN \dotfill \__nicematrix_dotfill:
\cs_set_eq:NN \CodeAfter \__nicematrix_CodeAfter:n
- \cs_set_eq:NN \slashbox \__nicematrix_slashbox:nn
+ \cs_set_eq:NN \diagbox \__nicematrix_diagbox:nn
\bool_if:NT \l__nicematrix_renew_dots_bool
{
\cs_set_eq:NN \ldots \__nicematrix_Ldots
@@ -866,6 +935,7 @@
\__nicematrix_test_if_math_mode:
\bool_if:NT \l__nicematrix_in_env_bool { \__nicematrix_fatal:n { Yet~in~env } }
\bool_set_true:N \l__nicematrix_in_env_bool
+ \cs_gset_eq:NN \__nicematrix_old_CT@arc@ \CT@arc@
\cs_if_exist:NT \tikz@library@external@loaded
{
\tikzset { external / export = false }
@@ -876,10 +946,14 @@
\bool_if:NF \l__nicematrix_block_auto_columns_width_bool
{ \dim_gzero_new:N \g__nicematrix_max_cell_width_dim }
\cs_set_protected:Npn \@arrayrule { \@addtopreamble \__nicematrix_vline: }
+ \seq_clear:N \g__nicematrix_blocks_seq
+ \seq_clear:N \g__nicematrix_pos_of_blocks_seq
\bool_if:NTF \l__nicematrix_NiceArray_bool
{ \keys_set:nn { NiceMatrix / NiceArray } }
{ \keys_set:nn { NiceMatrix / pNiceArray } }
{ #3 , #5 }
+ \tl_if_empty:NF \l__nicematrix_rules_color_tl
+ { \exp_after:wN \__nicematrix_set_CT@arc@: \l__nicematrix_rules_color_tl \q_stop }
\bool_if:NT \l__nicematrix_code_before_bool
{
\seq_if_exist:cT { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq }
@@ -917,18 +991,18 @@
\group_begin:
\bool_if:NT \c__nicematrix_tikz_loaded_bool
{
- \pgfset
+ \tikzset
{
every~picture / .style =
- { overlay , name~prefix = \__nicematrix_env: - }
+ { overlay , name~prefix = \__nicematrix_env: - }
}
}
- \cs_set_eq:NN \cellcolor \__nicematrix_cellcolor:nn
- \cs_set_eq:NN \rectanglecolor \__nicematrix_rectanglecolor:nnn
- \cs_set_eq:NN \rowcolor \__nicematrix_rowcolor:nn
- \cs_set_eq:NN \rowcolors \__nicematrix_rowcolors:nnn
- \cs_set_eq:NN \columncolor \__nicematrix_columncolor:nn
- \cs_set_eq:NN \chessboardcolors \__nicematrix_chessboardcolors:nn
+ \cs_set_eq:NN \cellcolor \__nicematrix_cellcolor
+ \cs_set_eq:NN \rectanglecolor \__nicematrix_rectanglecolor
+ \cs_set_eq:NN \rowcolor \__nicematrix_rowcolor
+ \cs_set_eq:NN \rowcolors \__nicematrix_rowcolors
+ \cs_set_eq:NN \columncolor \__nicematrix_columncolor
+ \cs_set_eq:NN \chessboardcolors \__nicematrix_chessboardcolors
\bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token
\l__nicematrix_code_before_tl
\bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token
@@ -1217,7 +1291,7 @@
{ \box_ht:N \l_tmpa_box + \box_dp:N \l_tmpa_box }
{ }
}
- \right .
+ \right .
\c_math_toggle_token
}
\dim_set:Nn \l__nicematrix_real_left_delim_dim
@@ -1440,7 +1514,7 @@
{
\__nicematrix_begin_of_row:
\hbox_set:Nw \l__nicematrix_cell_box
- \bool_if:NF \l__nicematrix_NiceTabular_bool \c_math_toggle_token
+ \__nicematrix_math_toggle_token:
\bool_if:NT \l__nicematrix_small_bool \scriptstyle
\bool_lazy_and:nnT
{ \int_compare_p:nNn \c@iRow > 0 }
@@ -1457,7 +1531,7 @@
l
<
{
- \bool_if:NF \l__nicematrix_NiceTabular_bool \c_math_toggle_token
+ \__nicematrix_math_toggle_token:
\hbox_set_end:
\__nicematrix_update_for_first_and_last_row:
\dim_gset:Nn \g__nicematrix_width_first_col_dim
@@ -1482,7 +1556,7 @@
\int_gincr:N \c@jCol
\int_gset_eq:NN \g__nicematrix_col_total_int \c@jCol
\hbox_set:Nw \l__nicematrix_cell_box
- \bool_if:NF \l__nicematrix_NiceTabular_bool \c_math_toggle_token
+ \__nicematrix_math_toggle_token:
\bool_if:NT \l__nicematrix_small_bool \scriptstyle
\int_compare:nNnT \c@iRow > 0
{
@@ -1498,7 +1572,7 @@
l
<
{
- \bool_if:NF \l__nicematrix_NiceTabular_bool \c_math_toggle_token
+ \__nicematrix_math_toggle_token:
\hbox_set_end:
\__nicematrix_update_for_first_and_last_row:
\dim_gset:Nn \g__nicematrix_width_last_col_dim
@@ -1596,6 +1670,7 @@
\__nicematrix_define_env:n V
\NewDocumentEnvironment { NiceTabular } { O { } m ! O { } }
{
+ \str_gset:Nn \g__nicematrix_name_env_str { NiceTabular }
\keys_set:nn { NiceMatrix / NiceTabular } { #1 , #3 }
\bool_set_true:N \l__nicematrix_NiceTabular_bool
\NiceArray { #2 }
@@ -1698,7 +1773,14 @@
\dim_set:Nn \l__nicematrix_xdots_shorten_dim { 0.6 \l__nicematrix_xdots_shorten_dim }
}
\__nicematrix_draw_dotted_lines:
- \bool_if:NT \l__nicematrix_vlines_bool \__nicematrix_draw_vlines:
+ \bool_if:NTF \l__nicematrix_hvlines_bool
+ \__nicematrix_draw_hvlines:
+ {
+ \bool_if:NT \l__nicematrix_hlines_bool \__nicematrix_draw_hlines:
+ \bool_if:NT \l__nicematrix_vlines_bool \__nicematrix_draw_vlines:
+ }
+ \cs_set_eq:NN \ialign \__nicematrix_old_ialign:
+ \seq_if_empty:NF \g__nicematrix_blocks_seq \__nicematrix_draw_blocks:
\g__nicematrix_internal_code_after_tl
\tl_gclear:N \g__nicematrix_internal_code_after_tl
\bool_if:NT \c__nicematrix_tikz_loaded_bool
@@ -1720,6 +1802,7 @@
\group_end:
\str_gclear:N \g__nicematrix_name_env_str
\__nicematrix_restore_iRow_jCol:
+ \cs_gset_eq:NN \CT@arc@ \__nicematrix_old_CT@arc@
}
\AtBeginDocument
{
@@ -1889,6 +1972,16 @@
}
}
}
+ \bool_if:NT \l__nicematrix_hvlines_bool
+ {
+ \seq_gput_right:Nx \g__nicematrix_pos_of_xdots_seq
+ {
+ { \int_use:N \l__nicematrix_initial_i_int }
+ { \int_use:N \l__nicematrix_initial_j_int }
+ { \int_use:N \l__nicematrix_final_i_int }
+ { \int_use:N \l__nicematrix_final_j_int }
+ }
+ }
}
\cs_new_protected:Npn \__nicematrix_set_initial_coords:
{
@@ -2201,8 +2294,6 @@
}
\__nicematrix_draw_line:
}
-\NewExpandableDocumentCommand \NiceMatrixLastEnv { }
- { \int_use:N \g__nicematrix_env_int }
\cs_new_protected:Npn \__nicematrix_draw_line:
{
\pgfrememberpicturepositiononpagetrue
@@ -2388,22 +2479,18 @@
}
\AtBeginDocument
{
- \tl_set:Nn \l__nicematrix_argspec_tl { s O { } E { _ ^ } { { } { } } }
+ \tl_set:Nn \l__nicematrix_argspec_tl { O { } E { _ ^ } { { } { } } }
\tl_set_rescan:Nno \l__nicematrix_argspec_tl { } \l__nicematrix_argspec_tl
\exp_args:NNV \NewDocumentCommand \__nicematrix_Ldots \l__nicematrix_argspec_tl
{
- \bool_if:nTF { #1 }
- { \__nicematrix_error:n { starred~commands } }
+ \int_compare:nNnTF \c@jCol = 0
+ { \__nicematrix_error:nn { in~first~col } \Ldots }
{
- \int_compare:nNnTF \c@jCol = 0
- { \__nicematrix_error:nn { in~first~col } \Ldots }
+ \int_compare:nNnTF \c@jCol = \l__nicematrix_last_col_int
+ { \__nicematrix_error:nn { in~last~col } \Ldots }
{
- \int_compare:nNnTF \c@jCol = \l__nicematrix_last_col_int
- { \__nicematrix_error:nn { in~last~col } \Ldots }
- {
- \__nicematrix_instruction_of_type:nn { Ldots }
- { #2 , down = #3 , up = #4 }
- }
+ \__nicematrix_instruction_of_type:nn { Ldots }
+ { #1 , down = #2 , up = #3 }
}
}
\bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_ldots }
@@ -2411,18 +2498,14 @@
}
\exp_args:NNV \NewDocumentCommand \__nicematrix_Cdots \l__nicematrix_argspec_tl
{
- \bool_if:nTF { #1 }
- { \__nicematrix_error:n { starred~commands } }
+ \int_compare:nNnTF \c@jCol = 0
+ { \__nicematrix_error:nn { in~first~col } \Cdots }
{
- \int_compare:nNnTF \c@jCol = 0
- { \__nicematrix_error:nn { in~first~col } \Cdots }
+ \int_compare:nNnTF \c@jCol = \l__nicematrix_last_col_int
+ { \__nicematrix_error:nn { in~last~col } \Cdots }
{
- \int_compare:nNnTF \c@jCol = \l__nicematrix_last_col_int
- { \__nicematrix_error:nn { in~last~col } \Cdots }
- {
- \__nicematrix_instruction_of_type:nn { Cdots }
- { #2 , down = #3 , up = #4 }
- }
+ \__nicematrix_instruction_of_type:nn { Cdots }
+ { #1 , down = #2 , up = #3 }
}
}
\bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_cdots }
@@ -2430,69 +2513,59 @@
}
\exp_args:NNV \NewDocumentCommand \__nicematrix_Vdots \l__nicematrix_argspec_tl
{
- \bool_if:nTF { #1 }
- { \__nicematrix_error:n { starred~commands } }
- \int_compare:nNnTF \c@iRow = 0
- { \__nicematrix_error:nn { in~first~row } \Vdots }
+ \int_compare:nNnTF \c@iRow = 0
+ { \__nicematrix_error:nn { in~first~row } \Vdots }
+ {
+ \int_compare:nNnTF \c@iRow = \l__nicematrix_last_row_int
+ { \__nicematrix_error:nn { in~last~row } \Vdots }
{
- \int_compare:nNnTF \c@iRow = \l__nicematrix_last_row_int
- { \__nicematrix_error:nn { in~last~row } \Vdots }
- {
- \__nicematrix_instruction_of_type:nn { Vdots }
- { #2 , down = #3 , up = #4 }
- }
+ \__nicematrix_instruction_of_type:nn { Vdots }
+ { #1 , down = #2 , up = #3 }
}
+ }
\bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_vdots }
\bool_gset_true:N \g__nicematrix_empty_cell_bool
}
\exp_args:NNV \NewDocumentCommand \__nicematrix_Ddots \l__nicematrix_argspec_tl
{
- \bool_if:nTF { #1 }
- { \__nicematrix_error:n { starred~commands } }
+ \int_case:nnF \c@iRow
+ {
+ 0 { \__nicematrix_error:nn { in~first~row } \Ddots }
+ \l__nicematrix_last_row_int { \__nicematrix_error:nn { in~last~row } \Ddots }
+ }
{
- \int_case:nnF \c@iRow
+ \int_case:nnF \c@jCol
{
- 0 { \__nicematrix_error:nn { in~first~row } \Ddots }
- \l__nicematrix_last_row_int { \__nicematrix_error:nn { in~last~row } \Ddots }
+ 0 { \__nicematrix_error:nn { in~first~col } \Ddots }
+ \l__nicematrix_last_col_int { \__nicematrix_error:nn { in~last~col } \Ddots }
}
{
- \int_case:nnF \c@jCol
- {
- 0 { \__nicematrix_error:nn { in~first~col } \Ddots }
- \l__nicematrix_last_col_int { \__nicematrix_error:nn { in~last~col } \Ddots }
- }
- {
- \__nicematrix_instruction_of_type:nn { Ddots }
- { #2 , down = #3 , up = #4 }
- }
-
+ \__nicematrix_instruction_of_type:nn { Ddots }
+ { #1 , down = #2 , up = #3 }
}
+
}
\bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_ddots }
\bool_gset_true:N \g__nicematrix_empty_cell_bool
}
\exp_args:NNV \NewDocumentCommand \__nicematrix_Iddots \l__nicematrix_argspec_tl
{
- \bool_if:nTF { #1 }
- { \__nicematrix_error:n { starred~commands } }
+ \int_case:nnF \c@iRow
+ {
+ 0 { \__nicematrix_error:nn { in~first~row } \Iddots }
+ \l__nicematrix_last_row_int { \__nicematrix_error:nn { in~last~row } \Iddots }
+ }
{
- \int_case:nnF \c@iRow
+ \int_case:nnF \c@jCol
{
- 0 { \__nicematrix_error:nn { in~first~row } \Iddots }
- \l__nicematrix_last_row_int { \__nicematrix_error:nn { in~last~row } \Iddots }
+ 0 { \__nicematrix_error:nn { in~first~col } \Iddots }
+ \l__nicematrix_last_col_int { \__nicematrix_error:nn { in~last~col } \Iddots }
}
{
- \int_case:nnF \c@jCol
- {
- 0 { \__nicematrix_error:nn { in~first~col } \Iddots }
- \l__nicematrix_last_col_int { \__nicematrix_error:nn { in~last~col } \Iddots }
- }
- {
- \__nicematrix_instruction_of_type:nn { Iddots }
- { #2 , down = #3 , up = #4 }
- }
-
+ \__nicematrix_instruction_of_type:nn { Iddots }
+ { #1 , down = #2 , up = #3 }
}
+
}
\bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_iddots }
\bool_gset_true:N \g__nicematrix_empty_cell_bool
@@ -2507,13 +2580,23 @@
\cs_new:Npn \__nicematrix_multicolumn:nnn #1 #2 #3
{
\__nicematrix_old_multicolumn { #1 } { #2 } { #3 }
- \int_compare:nNnT #1 > 1
+ \peek_remove_spaces:n
{
- \seq_gput_left:Nx \g__nicematrix_multicolumn_cells_seq
- { \int_use:N \c@iRow - \int_use:N \c@jCol }
- \seq_gput_left:Nn \g__nicematrix_multicolumn_sizes_seq { #1 }
- }
- \int_gadd:Nn \c@jCol { #1 - 1 }
+ \int_compare:nNnT #1 > 1
+ {
+ \seq_gput_left:Nx \g__nicematrix_multicolumn_cells_seq
+ { \int_use:N \c@iRow - \int_use:N \c@jCol }
+ \seq_gput_left:Nn \g__nicematrix_multicolumn_sizes_seq { #1 }
+ \seq_gput_right:Nx \g__nicematrix_pos_of_blocks_seq
+ {
+ { \int_use:N \c@iRow }
+ { \int_use:N \c@jCol }
+ { \int_use:N \c@iRow }
+ { \int_eval:n { \c@jCol + #1 - 1 } }
+ }
+ }
+ \int_gadd:Nn \c@jCol { #1 - 1 }
+ }
}
\cs_new:Npn \__nicematrix_Hdotsfor:
{
@@ -2671,7 +2754,12 @@
\int_step_inline:nnn { #1 } { #1 + #3 - 1 }
{ \cs_set:cpn { __nicematrix _ dotted _ ##1 - #2 } { } }
}
-\cs_new_protected:Npn \__nicematrix_rotate: { \group_insert_after:N \__nicematrix_rotate_i: }
+\cs_new_protected:Npn \__nicematrix_rotate:
+ {
+ \bool_if:NTF \l__nicematrix_NiceTabular_bool
+ { \group_insert_after:N \__nicematrix_rotate_ii: }
+ { \group_insert_after:N \__nicematrix_rotate_i: }
+ }
\cs_new_protected:Npn \__nicematrix_rotate_i: { \group_insert_after:N \__nicematrix_rotate_ii: }
\cs_new_protected:Npn \__nicematrix_rotate_ii: { \group_insert_after:N \__nicematrix_rotate_iii: }
\cs_new_protected:Npn \__nicematrix_rotate_iii:
@@ -2747,16 +2835,20 @@
\tl_set:Nn \l_tmpa_tl { #1 }
\tl_set:Nn \l_tmpb_tl { #2 }
}
-\cs_new_protected:Npn \__nicematrix_rowcolor:nn #1 #2
+\NewDocumentCommand \__nicematrix_rowcolor { O { } m m }
{
- \tl_if_blank:nF { #1 }
+ \tl_if_blank:nF { #2 }
{
\pgfpicture
\pgf@relevantforpicturesizefalse
- \pgfsetfillcolor { #1 }
+ \tl_if_empty:nTF { #1 } \color { \color [ #1 ] } { #2 }
+ \__nicematrix_qpoint:n { col - 1}
+ \int_compare:nNnTF \l__nicematrix_first_col_int = 0
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x + 0.5 \arrayrulewidth } }
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } }
\__nicematrix_qpoint:n { col - \__nicematrix_succ:n \c@jCol }
- \dim_set_eq:NN \l_tmpa_dim \pgf@x
- \clist_map_inline:nn { #2 }
+ \dim_set:Nn \l_tmpa_dim { \pgf@x + 0.5 \arrayrulewidth }
+ \clist_map_inline:nn { #3 }
{
\tl_set:Nn \l_tmpa_tl { ##1 }
\tl_if_in:NnTF \l_tmpa_tl { - }
@@ -2768,26 +2860,29 @@
\int_compare:nNnT \l_tmpb_tl > \c@iRow
{ \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } }
\__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l_tmpb_tl }
+ \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth }
+ \__nicematrix_qpoint:n { row - \l_tmpa_tl }
+ \dim_set:Nn \l_tmpd_dim { \pgf@y + 0.5 \arrayrulewidth }
\pgfpathrectanglecorners
- { \__nicematrix_qpoint:n { row - \l_tmpa_tl } }
- { \pgfpoint \l_tmpa_dim \pgf@y }
+ { \pgfpoint \l_tmpc_dim \l_tmpd_dim }
+ { \pgfpoint \l_tmpa_dim \l_tmpb_dim }
}
\pgfusepathqfill
\endpgfpicture
}
}
-\cs_new_protected:Npn \__nicematrix_columncolor:nn #1 #2
+\NewDocumentCommand \__nicematrix_columncolor { O { } m m }
{
- \tl_if_blank:nF { #1 }
+ \tl_if_blank:nF { #2 }
{
\pgfpicture
\pgf@relevantforpicturesizefalse
- \pgfsetfillcolor { #1 }
+ \tl_if_empty:nTF { #1 } \color { \color [ #1 ] } { #2 }
\__nicematrix_qpoint:n { row - 1 }
- \dim_set_eq:NN \l_tmpa_dim \pgf@y
+ \dim_set:Nn \l_tmpa_dim {\pgf@y + 0.5 \arrayrulewidth }
\__nicematrix_qpoint:n { row - \__nicematrix_succ:n \c@iRow }
- \dim_set_eq:NN \l_tmpb_dim \pgf@y
- \clist_map_inline:nn { #2 }
+ \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth }
+ \clist_map_inline:nn { #3 }
{
\tl_set:Nn \l_tmpa_tl { ##1 }
\tl_if_in:NnTF \l_tmpa_tl { - }
@@ -2799,24 +2894,27 @@
\int_compare:nNnT \l_tmpb_tl > \c@jCol
{ \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } }
\__nicematrix_qpoint:n { col - \l_tmpa_tl }
- \dim_set_eq:NN \l_tmpc_dim \pgf@x
+ \int_compare:nNnTF \l__nicematrix_first_col_int = \l_tmpa_tl
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } }
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x + 0.5 \arrayrulewidth } }
\__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l_tmpb_tl }
+ \dim_set:Nn \l_tmpd_dim { \pgf@x + 0.5 \arrayrulewidth }
\pgfpathrectanglecorners
{ \pgfpoint \l_tmpc_dim \l_tmpa_dim }
- { \pgfpoint \pgf@x \l_tmpb_dim }
+ { \pgfpoint \l_tmpd_dim \l_tmpb_dim }
}
\pgfusepathqfill
\endpgfpicture
}
}
-\cs_new_protected:Npn \__nicematrix_cellcolor:nn #1 #2
+\NewDocumentCommand \__nicematrix_cellcolor { O { } m m }
{
- \tl_if_blank:nF { #1 }
+ \tl_if_blank:nF { #2 }
{
\pgfpicture
\pgf@relevantforpicturesizefalse
- \pgfsetfillcolor { #1 }
- \clist_map_inline:nn { #2 }
+ \tl_if_empty:nTF { #1 } \color { \color [ #1 ] } { #2 }
+ \clist_map_inline:nn { #3 }
{
\__nicematrix_cut_on_hyphen:w ##1 \q_stop
\__nicematrix_qpoint:n { row - \l_tmpa_tl }
@@ -2824,13 +2922,15 @@
{ \int_compare_p:n { \l_tmpa_tl <= \c@iRow } }
{ \int_compare_p:n { \l_tmpb_tl <= \c@jCol } }
{
- \dim_set_eq:NN \l_tmpb_dim \pgf@y
+ \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth }
\__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l_tmpa_tl }
- \dim_set_eq:NN \l_tmpa_dim \pgf@y
+ \dim_set:Nn \l_tmpa_dim { \pgf@y + 0.5 \arrayrulewidth }
\__nicematrix_qpoint:n { col - \l_tmpb_tl }
- \dim_set_eq:NN \l_tmpc_dim \pgf@x
+ \int_compare:nNnTF \l__nicematrix_first_col_int = \l_tmpb_tl
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } }
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x + 0.5 \arrayrulewidth } }
\__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l_tmpb_tl }
- \dim_set_eq:NN \l_tmpd_dim \pgf@x
+ \dim_set:Nn \l_tmpd_dim { \pgf@x + 0.5 \arrayrulewidth }
\pgfpathrectanglecorners
{ \pgfpoint \l_tmpc_dim \l_tmpb_dim }
{ \pgfpoint \l_tmpd_dim \l_tmpa_dim }
@@ -2838,33 +2938,35 @@
}
\pgfusepathqfill
\endpgfpicture
- }
+ }
}
-\cs_new_protected:Npn \__nicematrix_rectanglecolor:nnn #1 #2 #3
+\NewDocumentCommand \__nicematrix_rectanglecolor { O { } m m m }
{
- \tl_if_blank:nF { #1 }
+ \tl_if_blank:nF { #2 }
{
\pgfpicture
\pgf@relevantforpicturesizefalse
- \pgfsetfillcolor { #1 }
- \__nicematrix_cut_on_hyphen:w #2 \q_stop
+ \tl_if_empty:nTF { #1 } \color { \color [ #1 ] } { #2 }
+ \__nicematrix_cut_on_hyphen:w #3 \q_stop
\bool_lazy_and:nnT
{ \int_compare_p:n { \l_tmpa_tl <= \c@iRow } }
{ \int_compare_p:n { \l_tmpb_tl <= \c@jCol } }
{
\__nicematrix_qpoint:n { row - \l_tmpa_tl }
- \dim_set_eq:NN \l_tmpb_dim \pgf@y
+ \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth }
\__nicematrix_qpoint:n { col - \l_tmpb_tl }
- \__nicematrix_cut_on_hyphen:w #3 \q_stop
+ \int_compare:nNnTF \l__nicematrix_first_col_int = \l_tmpb_tl
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } }
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x + 0.5 \arrayrulewidth } }
+ \__nicematrix_cut_on_hyphen:w #4 \q_stop
\int_compare:nNnT \l_tmpa_tl > \c@iRow
{ \tl_set:Nx \l_tmpa_tl { \int_use:N \c@iRow } }
\int_compare:nNnT \l_tmpb_tl > \c@jCol
{ \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } }
- \dim_set_eq:NN \l_tmpc_dim \pgf@x
\__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l_tmpa_tl }
- \dim_set_eq:NN \l_tmpa_dim \pgf@y
+ \dim_set:Nn \l_tmpa_dim { \pgf@y + 0.5 \arrayrulewidth }
\__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l_tmpb_tl }
- \dim_set_eq:NN \l_tmpd_dim \pgf@x
+ \dim_set:Nn \l_tmpd_dim { \pgf@x + 0.5 \arrayrulewidth }
\pgfpathrectanglecorners
{ \pgfpoint \l_tmpc_dim \l_tmpb_dim }
{ \pgfpoint \l_tmpd_dim \l_tmpa_dim }
@@ -2873,24 +2975,26 @@
\endpgfpicture
}
}
-\cs_new_protected:Npn \__nicematrix_rowcolors:nnn #1 #2 #3
+\NewDocumentCommand \__nicematrix_rowcolors { O { } m m m }
{
- \int_step_inline:nnn { #1 } { \int_use:N \c@iRow }
+ \int_step_inline:nnn { #2 } { \int_use:N \c@iRow }
{
\int_if_odd:nTF { ##1 }
- { \__nicematrix_rowcolor:nn { #2 } { ##1 } }
- { \__nicematrix_rowcolor:nn { #3 } { ##1 } }
+ { \__nicematrix_rowcolor [ #1 ] { #3 } }
+ { \__nicematrix_rowcolor [ #1 ] { #4 } }
+ { ##1 }
}
}
-\cs_new_protected:Npn \__nicematrix_chessboardcolors:nn #1 #2
+\NewDocumentCommand \__nicematrix_chessboardcolors { O { } m m }
{
\int_step_inline:nn { \int_use:N \c@iRow }
{
\int_step_inline:nn { \int_use:N \c@jCol }
{
\int_if_even:nTF { ####1 + ##1 }
- { \__nicematrix_cellcolor:nn { #1 } { ####1 - ##1 } }
- { \__nicematrix_cellcolor:nn { #2 } { ####1 - ##1 } }
+ { \__nicematrix_cellcolor [ #1 ] { #2 } }
+ { \__nicematrix_cellcolor [ #1 ] { #3 } }
+ { ##1 - ####1 }
}
}
}
@@ -2925,16 +3029,14 @@
\pgfsetlinewidth \arrayrulewidth
\__nicematrix_qpoint:n { row - 1 }
\dim_set_eq:NN \l_tmpa_dim \pgf@y
- \pgfusepathqfill
\__nicematrix_qpoint:n { row - \__nicematrix_succ:n \c@iRow }
\dim_sub:Nn \l_tmpa_dim \pgf@y
- \pgfusepathqfill
\dim_zero:N \l_tmpb_dim
\int_compare:nNnT \l__nicematrix_last_row_int > { -1 }
{
\dim_set_eq:NN \l_tmpb_dim \g__nicematrix_dp_last_row_dim
\dim_add:Nn \l_tmpb_dim \g__nicematrix_ht_last_row_dim
- \__nicematrix_qpoint:n { row - \__nicematrix_succ:n\c@iRow }
+ \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \c@iRow }
\dim_add:Nn \l_tmpa_dim \pgf@y
\__nicematrix_qpoint:n { row - \__nicematrix_succ:n \g__nicematrix_row_total_int }
\dim_sub:Nn \l_tmpa_dim \pgf@y
@@ -2957,6 +3059,154 @@
\endpgfpicture
\group_end:
}
+%%
+\cs_new_protected:Npn \__nicematrix_draw_hlines:
+ {
+ \pgfpicture
+ \CT@arc@
+ \pgfrememberpicturepositiononpagetrue
+ \pgf@relevantforpicturesizefalse
+ \pgfsetlinewidth \arrayrulewidth
+ \int_step_inline:nnn
+ { \bool_if:NTF \l__nicematrix_NiceArray_bool 1 2 }
+ { \bool_if:NTF \l__nicematrix_NiceArray_bool { \__nicematrix_succ:n \c@iRow } \c@iRow }
+ {
+ \__nicematrix_qpoint:n { row - ##1 }
+ \dim_set_eq:NN \l_tmpa_dim \pgf@y
+ \pgfpathmoveto { \pgfpoint \pgf@x \pgf@y }
+ \__nicematrix_qpoint:n { col - \__nicematrix_succ:n { \c@jCol } }
+ \dim_set:Nn \l_tmpb_dim { \pgf@x + 0.5 \arrayrulewidth }
+ \pgfpathlineto { \pgfpoint \l_tmpb_dim \l_tmpa_dim }
+ }
+ \pgfusepathqstroke
+ \endpgfpicture
+ }
+\cs_new_protected:Npn \__nicematrix_draw_hvlines:
+ {
+ \bool_lazy_and:nnTF
+ { \seq_if_empty_p:N \g__nicematrix_pos_of_blocks_seq }
+ { \seq_if_empty_p:N \g__nicematrix_pos_of_xdots_seq }
+ \__nicematrix_draw_hvlines_i:
+ \__nicematrix_draw_hvlines_ii:
+ }
+\cs_new_protected:Npn \__nicematrix_draw_hvlines_i:
+ {
+ \__nicematrix_draw_hlines:
+ \__nicematrix_draw_vlines:
+ }
+\cs_new_protected:Npn \__nicematrix_draw_hvlines_ii:
+ {
+ \group_begin:
+ \CT@arc@
+ \bool_if:NT \l__nicematrix_NiceArray_bool
+ {
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgf@relevantforpicturesizefalse
+ \pgfsetlinewidth \arrayrulewidth
+ \pgfsetrectcap
+ \__nicematrix_qpoint:n { col - 1 }
+ \dim_set_eq:NN \l_tmpa_dim \pgf@x
+ \__nicematrix_qpoint:n { row -1 }
+ \dim_set_eq:NN \l_tmpb_dim \pgf@y
+ \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \c@jCol }
+ \dim_set_eq:NN \l_tmpc_dim \pgf@x
+ \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \c@iRow }
+ \pgfpathrectanglecorners
+ { \pgfpoint \l_tmpa_dim \l_tmpb_dim }
+ { \pgfpoint \l_tmpc_dim \pgf@y }
+ \pgfusepathqstroke
+ \endpgfpicture
+ }
+ \int_step_variable:nnNn 2 \c@iRow \l_tmpa_tl
+ {
+ \int_step_variable:nNn \c@jCol \l_tmpb_tl
+ {
+ \bool_gset_true:N \g_tmpa_bool
+ \seq_map_inline:Nn \g__nicematrix_pos_of_blocks_seq
+ { \__nicematrix_test_if_hline_in_block:nnnn ##1 }
+ \seq_map_inline:Nn \g__nicematrix_pos_of_xdots_seq
+ { \__nicematrix_test_if_hline_in_block:nnnn ##1 }
+ \bool_if:NT \g_tmpa_bool
+ {
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgf@relevantforpicturesizefalse
+ \pgfsetlinewidth \arrayrulewidth
+ \pgfsetrectcap
+ \__nicematrix_qpoint:n { row - \l_tmpa_tl }
+ \dim_set_eq:NN \l_tmpb_dim \pgf@y
+ \__nicematrix_qpoint:n { col - \l_tmpb_tl }
+ \dim_set_eq:NN \l_tmpa_dim \pgf@x
+ \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l_tmpb_tl }
+ \dim_set_eq:NN \l_tmpc_dim \pgf@x
+ \pgfpathmoveto { \pgfpoint \l_tmpa_dim \l_tmpb_dim }
+ \pgfpathlineto { \pgfpoint \l_tmpc_dim \l_tmpb_dim }
+ \pgfusepathqstroke
+ \endpgfpicture
+ }
+ }
+ }
+ \int_step_variable:nNn \c@iRow \l_tmpa_tl
+ {
+ \int_step_variable:nnNn 2 \c@jCol \l_tmpb_tl
+ {
+ \bool_gset_true:N \g_tmpa_bool
+ \seq_map_inline:Nn \g__nicematrix_pos_of_blocks_seq
+ { \__nicematrix_test_if_vline_in_block:nnnn ##1 }
+ \seq_map_inline:Nn \g__nicematrix_pos_of_xdots_seq
+ { \__nicematrix_test_if_vline_in_block:nnnn ##1 }
+ \bool_if:NT \g_tmpa_bool
+ {
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgf@relevantforpicturesizefalse
+ \pgfsetlinewidth \arrayrulewidth
+ \pgfsetrectcap
+ \__nicematrix_qpoint:n { row - \l_tmpa_tl }
+ \dim_set_eq:NN \l_tmpb_dim \pgf@y
+ \__nicematrix_qpoint:n { col - \l_tmpb_tl }
+ \dim_set_eq:NN \l_tmpa_dim \pgf@x
+ \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l_tmpa_tl }
+ \dim_set_eq:NN \l_tmpc_dim \pgf@y
+ \pgfpathmoveto { \pgfpoint \l_tmpa_dim \l_tmpb_dim }
+ \pgfpathlineto { \pgfpoint \l_tmpa_dim \l_tmpc_dim }
+ \pgfusepathqstroke
+ \endpgfpicture
+ }
+ }
+ }
+ \group_end:
+ \seq_gclear:N \g__nicematrix_pos_of_xdots_seq
+ }
+\cs_set_protected:Npn \__nicematrix_test_if_hline_in_block:nnnn #1 #2 #3 #4
+ {
+ \int_compare:nNnT \l_tmpa_tl > { #1 }
+ {
+ \int_compare:nNnT \l_tmpa_tl < { #3 + 1 }
+ {
+ \int_compare:nNnT \l_tmpb_tl > { #2 - 1 }
+ {
+ \int_compare:nNnT \l_tmpb_tl < { #4 + 1 }
+ { \bool_gset_false:N \g_tmpa_bool }
+ }
+ }
+ }
+ }
+\cs_set_protected:Npn \__nicematrix_test_if_vline_in_block:nnnn #1 #2 #3 #4
+ {
+ \int_compare:nNnT \l_tmpa_tl > { #1 - 1 }
+ {
+ \int_compare:nNnT \l_tmpa_tl < { #3 + 1 }
+ {
+ \int_compare:nNnT \l_tmpb_tl > { #2 }
+ {
+ \int_compare:nNnT \l_tmpb_tl < { #4 + 1 }
+ { \bool_gset_false:N \g_tmpa_bool }
+ }
+ }
+ }
+ }
\cs_new:Npn \__nicematrix_hdottedline:
{
\noalign { \skip_vertical:N 2\l__nicematrix_radius_dim }
@@ -3264,40 +3514,35 @@
\cs_new:Npn \__nicematrix_Block_i #1-#2 \q_stop { \__nicematrix_Block_ii:nnnnn { #1 } { #2 } }
\cs_new_protected:Npn \__nicematrix_Block_ii:nnnnn #1 #2 #3 #4 #5
{
- \tl_gput_left:Nx \g__nicematrix_internal_code_after_tl
+ \tl_set:Nx \l_tmpa_tl
{
- \__nicematrix_Block_iii:nnnnnn
{ \int_use:N \c@iRow }
{ \int_use:N \c@jCol }
{ \int_eval:n { \c@iRow + #1 - 1 } }
{ \int_eval:n { \c@jCol + #2 - 1 } }
- { #3 }
- \exp_not:n { { #4 $ #5 $ } }
}
- \cs_set_eq:NN \Block \__nicematrix_Block_error:nn
- }
-\cs_new:Npn \__nicematrix_Block_error:nn #1 #2
- {
- \__nicematrix_error:n { Second~Block }
- \cs_set_eq:NN \Block \use:nn
+ \seq_gput_left:NV \g__nicematrix_pos_of_blocks_seq \l_tmpa_tl
+ \seq_gput_left:Nx \g__nicematrix_blocks_seq
+ {
+ \l_tmpa_tl
+ { #3 }
+ \exp_not:n { { #4 \__nicematrix_math_toggle_token: #5 \__nicematrix_math_toggle_token: } }
+ }
}
\keys_define:nn { NiceMatrix / Block }
{
tikz .tl_set:N = \l__nicematrix_tikz_tl ,
tikz .value_required:n = true ,
- white .bool_set:N = \l__nicematrix_white_bool ,
- white .default:n = true ,
- white .value_forbidden:n = true ,
}
+\cs_new_protected:Npn \__nicematrix_draw_blocks:
+ { \seq_map_inline:Nn \g__nicematrix_blocks_seq { \__nicematrix_Block_iii:nnnnnn ##1 } }
\cs_new_protected:Npn \__nicematrix_Block_iii:nnnnnn #1 #2 #3 #4 #5 #6
{
\group_begin:
\keys_set:nn { NiceMatrix / Block } { #5 }
- \bool_if:nTF
- {
- \int_compare_p:nNn { #3 } > \c@iRow
- || \int_compare_p:nNn { #4 } > \c@jCol
- }
+ \bool_lazy_or:nnTF
+ { \int_compare_p:nNn { #3 } > \c@iRow }
+ { \int_compare_p:nNn { #4 } > \c@jCol }
{ \msg_error:nnnn { nicematrix } { Block~too~large } { #1 } { #2 } }
{
\hbox_set:Nn \l__nicematrix_cell_box { #6 }
@@ -3312,24 +3557,6 @@
\dim_set_eq:NN \l_tmpc_dim \pgf@y
\__nicematrix_qpoint:n { col - \__nicematrix_succ:n { #4 } }
\dim_set_eq:NN \l_tmpd_dim \pgf@x
- \bool_if:NT \l__nicematrix_white_bool
- {
- \begin { pgfscope }
- \pgfsetfillcolor { white }
- \pgfpathrectanglecorners
- {
- \pgfpoint
- { \l_tmpb_dim + 0.5 \arrayrulewidth }
- { \l_tmpa_dim - 0.5 \arrayrulewidth }
- }
- {
- \pgfpoint
- { \l_tmpd_dim - 0.5 \arrayrulewidth }
- { \l_tmpc_dim + 0.5 \arrayrulewidth }
- }
- \pgfusepathqfill
- \end { pgfscope }
- }
\begin { pgfscope }
\exp_args:Nx \pgfset { \l__nicematrix_tikz_tl }
\__nicematrix_pgf_rect_node:nnnnn
@@ -3434,21 +3661,23 @@
\cs_new_protected:Npn \__nicematrix_dotfill:
{
\__nicematrix_dotfill
- \group_insert_after:N \__nicematrix_dotfill_i:
+ \bool_if:NT \l__nicematrix_NiceTabular_bool
+ { \group_insert_after:N \__nicematrix_dotfill_ii: }
+ { \group_insert_after:N \__nicematrix_dotfill_i: }
}
\cs_new_protected:Npn \__nicematrix_dotfill_i: { \group_insert_after:N \__nicematrix_dotfill_ii: }
\cs_new_protected:Npn \__nicematrix_dotfill_ii: { \group_insert_after:N \__nicematrix_dotfill_iii: }
\cs_new_protected:Npn \__nicematrix_dotfill_iii:
{ \dim_compare:nNnT { \box_wd:N \l__nicematrix_cell_box } = \c_zero_dim \__nicematrix_dotfill }
-\cs_new_protected:Npn \__nicematrix_slashbox:nn #1 #2
+\cs_new_protected:Npn \__nicematrix_diagbox:nn #1 #2
{
\tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
{
- \__nicematrix_actually_slashbox:nnnn
+ \__nicematrix_actually_diagbox:nnnn
{ \int_use:N \c@iRow } { \int_use:N \c@jCol } { #1 } { #2 }
}
}
-\cs_new_protected:Npn \__nicematrix_actually_slashbox:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \__nicematrix_actually_diagbox:nnnn #1 #2 #3 #4
{
\pgfpicture
\pgf@relevantforpicturesizefalse
@@ -3471,10 +3700,12 @@
\pgfset { inner~sep = 1 pt }
\pgfscope
\pgftransformshift { \pgfpoint \l_tmpb_dim \l_tmpc_dim }
- \pgfnode { rectangle } { south~west } { $ #3 $ } { } { }
+ \pgfnode { rectangle } { south~west }
+ { \__nicematrix_math_toggle_token: #3 \__nicematrix_math_toggle_token: } { } { }
\endpgfscope
\pgftransformshift { \pgfpoint \l_tmpd_dim \l_tmpa_dim }
- \pgfnode { rectangle } { north~east } { $ #4 $ } { } { }
+ \pgfnode { rectangle } { north~east }
+ { \__nicematrix_math_toggle_token: #4 \__nicematrix_math_toggle_token: } { } { }
\endpgfpicture
}
\cs_new_protected:Npn \__nicematrix_CodeAfter:n #1 \end
@@ -3492,14 +3723,6 @@
\__nicematrix_CodeAfter:n
}
}
-\__nicematrix_msg_new:nn { obsolete~environments }
- {
- The~obsolete~environments~(eg.~{pNiceArrayC})~have~been~deleted~
- from~the~package~nicematrix.\\
- However,~if~you~still~want~to~use~them,~you~will~find~the~code~for~
- those~environments~at~the~end~of~the~file~'nicematrix.sty',~after~
- a~command~'\token_to_str:N\file_input_stop:'.
- }
\keys_define:nn { NiceMatrix / Package }
{
renew-dots .bool_set:N = \l__nicematrix_renew_dots_bool ,
@@ -3508,11 +3731,6 @@
renew-matrix .value_forbidden:n = true ,
transparent .meta:n = { renew-dots , renew-matrix } ,
transparent .value_forbidden:n = true,
- obsolete-environments .code:n = \__nicematrix_fatal:n { obsolete~environments },
- starred-commands .code:n =
- \__nicematrix_msg_redirect_name:nn { starred~commands } { none } ,
- starred-commands .value_forbidden:n = true ,
-
}
\ProcessKeysOptions { NiceMatrix / Package }
\cs_new_protected:Npn \__nicematrix_convert_to_str_seq:N #1
@@ -3622,13 +3840,10 @@
the~option~'light-syntax'.~You~must~use~the~character~'\l__nicematrix_end_of_row_tl'~
(set~by~the~option~'end-of-row').~This~error~is~fatal.
}
-\__nicematrix_msg_new:nn { starred~commands }
+\__nicematrix_msg_new:nn { standard-cline~in~document }
{
- The~starred~versions~of~\token_to_str:N \Cdots,~\token_to_str:N \Ldots,~
- \token_to_str:N \Vdots,~\token_to_str:N\Ddots\ and~\token_to_str:N\Iddots\
- are~deprecated.~However,~you~can~go~on~for~this~time.~If~you~don't~want~to~
- see~this~error~we~should~load~'nicematrix'~with~the~option~
- 'starred-commands'.
+ The~key~'standard-cline'~is~available~only~in~the~preamble.\\
+ If~you~go~on~this~command~will~be~ignored.
}
\__nicematrix_msg_new:nn { bad~value~for~baseline }
{
@@ -3637,11 +3852,6 @@
\int_use:N \g__nicematrix_row_total_int\ or~equal~to~'t',~'c'~or~'b'.\\
If~you~go~on,~a~value~of~1~will~be~used.
}
-\__nicematrix_msg_new:nn { Second~Block }
- {
- You~can't~use~\token_to_str:N \Block\ twice~in~the~same~cell~of~the~array.\\
- If~you~go~on,~this~command~(and~the~other)~will~be~ignored.
- }
\__nicematrix_msg_new:nn { empty~environment }
{ Your~\__nicematrix_full_name_env:\ is~empty.~This~error~is~fatal. }
\__nicematrix_msg_new:nn { unknown~cell~for~line~in~code-after }
@@ -3699,7 +3909,7 @@
The~key~'\tl_use:N\l_keys_key_str'~is~unknown~for~the~command~
\token_to_str:N \NiceMatrixOptions. \\
If~you~go~on,~it~will~be~ignored. \\
- For~a~list~of~the~available~keys,~type~H~<return>.
+ For~a~list~of~the~*principal*~available~keys,~type~H~<return>.
}
{
The~available~options~are~(in~alphabetic~order):~
@@ -3714,7 +3924,6 @@
create-medium-nodes,~
create-large-nodes,~
end-of-row,~
- exterior-arraycolsep,~
first-col,~
first-row,~
hlines,~
@@ -3725,7 +3934,6 @@
letter-for-dotted-lines,~
light-syntax,~
nullify-dots,~
- parallelize-diags,~
renew-dots,~
renew-matrix,~
right-margin,~
@@ -3741,7 +3949,7 @@
The~option~'\tl_use:N\l_keys_key_str'~is~unknown~for~the~environment~
\{NiceArray\}. \\
If~you~go~on,~it~will~be~ignored. \\
- For~a~list~of~the~available~options,~type~H~<return>.
+ For~a~list~of~the~*principal*~available~options,~type~H~<return>.
}
{
The~available~options~are~(in~alphabetic~order):~
@@ -3759,7 +3967,6 @@
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
- end-of-row,~
extra-left-margin,~
extra-right-margin,~
first-col,~
@@ -3772,9 +3979,10 @@
light-syntax,~
name,~
nullify-dots,~
- parallelize-diags,~
renew-dots,~
right-margin,~
+ rules/color,~
+ rules/width,~
small,~
t,~
vlines,~
@@ -3787,7 +3995,7 @@
The~option~'\tl_use:N\l_keys_key_str'~is~unknown~for~the~
\__nicematrix_full_name_env:. \\
If~you~go~on,~it~will~be~ignored. \\
- For~a~list~of~the~available~options,~type~H~<return>.
+ For~a~list~of~the~*principal*~available~options,~type~H~<return>.
}
{
The~available~options~are~(in~alphabetic~order):~
@@ -3805,7 +4013,6 @@
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
- end-of-row,~
extra-left-margin,~
extra-right-margin,~
first-col,~
@@ -3819,10 +4026,11 @@
light-syntax,~
name,~
nullify-dots,~
- parallelize-diags,~
r~(=R),~
renew-dots,~
right-margin,~
+ rules/color,~
+ rules/width,~
S,~
small,~
t,~
@@ -3836,7 +4044,7 @@
The~option~'\tl_use:N\l_keys_key_str'~is~unknown~for~the~environment~
\{NiceTabular\}. \\
If~you~go~on,~it~will~be~ignored. \\
- For~a~list~of~the~available~options,~type~H~<return>.
+ For~a~list~of~the~*principal*~available~options,~type~H~<return>.
}
{
The~available~options~are~(in~alphabetic~order):~
@@ -3854,7 +4062,6 @@
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
- end-of-row,~
extra-left-margin,~
extra-right-margin,~
first-col,~
@@ -3867,9 +4074,10 @@
light-syntax,~
name,~
nullify-dots,~
- parallelize-diags,~
renew-dots,~
right-margin,~
+ rules/color,~
+ rules/width,~
t,~
vlines,~
xdots/color,~
@@ -3900,85 +4108,6 @@
and~R~in~the~preamble~of~your~environment. \\
This~error~is~fatal.
}
-\file_input_stop:
-\NewDocumentEnvironment { pNiceArrayC } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \pNiceArray
- }
- { \endpNiceArray }
- \NewDocumentEnvironment { bNiceArrayC } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \bNiceArray
- }
- { \endbNiceArray }
-\NewDocumentEnvironment { BNiceArrayC } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \BNiceArray
- }
- { \endBNiceArray }
-\NewDocumentEnvironment { vNiceArrayC } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \vNiceArray
- }
- { \endvNiceArray }
-\NewDocumentEnvironment { VNiceArrayC } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \VNiceArray
- }
- { \endVNiceArray }
-\NewDocumentEnvironment { pNiceArrayRC } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \int_zero:N \l__nicematrix_first_row_int
- \pNiceArray
- }
- { \endpNiceArray }
-\NewDocumentEnvironment { bNiceArrayRC } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \int_zero:N \l__nicematrix_first_row_int
- \bNiceArray
- }
- { \endbNiceArray }
-\NewDocumentEnvironment { BNiceArrayRC } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \int_zero:N \l__nicematrix_first_row_int
- \BNiceArray
- }
- { \endBNiceArray }
-\NewDocumentEnvironment { vNiceArrayRC } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \int_zero:N \l__nicematrix_first_row_int
- \vNiceArray
- }
- { \endvNiceArray }
-\NewDocumentEnvironment { VNiceArrayRC } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \int_zero:N \l__nicematrix_first_row_int
- \VNiceArray
- }
- { \endVNiceArray }
-\NewDocumentEnvironment { NiceArrayCwithDelims } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \NiceArrayWithDelims
- }
- { \endNiceArrayWithDelims }
-\NewDocumentEnvironment { NiceArrayRCwithDelims } { }
- {
- \int_zero:N \l__nicematrix_last_col_int
- \int_zero:N \l__nicematrix_first_row_int
- \NiceArrayWithDelims
- }
- { \endNiceArrayWithDelims }
\endinput
%%