summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/nicematrix
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-04-01 03:01:11 +0000
committerNorbert Preining <norbert@preining.info>2023-04-01 03:01:11 +0000
commit1c004b8b1b82512ea320e5d1e16e364d54878e6a (patch)
tree61c1c3e5f18f20f7d7df8c91164e7b0de75220d0 /macros/latex/contrib/nicematrix
parentff15e9aea45682289b6f31fa687c1b51f543d09e (diff)
CTAN sync 202304010301
Diffstat (limited to 'macros/latex/contrib/nicematrix')
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix-french.pdfbin545421 -> 551953 bytes
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix-french.tex317
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix.dtx501
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix.pdfbin1356332 -> 1364573 bytes
4 files changed, 556 insertions, 262 deletions
diff --git a/macros/latex/contrib/nicematrix/nicematrix-french.pdf b/macros/latex/contrib/nicematrix/nicematrix-french.pdf
index 85ec3103b5..a054c4fadf 100644
--- a/macros/latex/contrib/nicematrix/nicematrix-french.pdf
+++ b/macros/latex/contrib/nicematrix/nicematrix-french.pdf
Binary files differ
diff --git a/macros/latex/contrib/nicematrix/nicematrix-french.tex b/macros/latex/contrib/nicematrix/nicematrix-french.tex
index e9700dd86c..4ec05bce2c 100644
--- a/macros/latex/contrib/nicematrix/nicematrix-french.tex
+++ b/macros/latex/contrib/nicematrix/nicematrix-french.tex
@@ -40,6 +40,7 @@
\usepackage{booktabs}
\usepackage{varwidth}
\usepackage{tcolorbox}
+\usepackage{adjustbox}
\usepackage[auto-lang=false]{lipsum}
\usepackage[hyperfootnotes = false]{hyperref}
@@ -556,11 +557,11 @@ expliqué plus loin.
\medskip
Dans l'exemple suivant, on a dû élargir à la main les colonnes 2 et 3 (avec la
-construction |wc{...}| de \pkg{array}).
+construction |w{c}{...}| de \pkg{array}).
\medskip
\begin{BVerbatim}
-\begin{NiceTabular}{cwc{2cm}wc{3cm}c}
+\begin{NiceTabular}{cw{c}{2cm}w{c}{3cm}c}
rose & tulipe & marguerite & dahlia \\
violette
& ~emphase#\Block[draw=red,fill=[RGB]{204,204,255},rounded-corners]{2-2}@
@@ -574,7 +575,7 @@ arum & iris & jacinthe & muguet
\medskip
\begin{center}
-\begin{NiceTabular}{cwc{2cm}wc{3cm}c}
+\begin{NiceTabular}{cw{c}{2cm}w{c}{3cm}c}
rose & tulipe & marguerite & dahlia \\
violette & \Block[draw=red,fill=[RGB]{204,204,255},rounded-corners]{2-2}
{\LARGE De très jolies fleurs} & & souci \\
@@ -591,9 +592,9 @@ Les blocs mono-colonne ont un comportement spécial.
\item La largeur naturelle du contenu de ces blocs est prise en compte pour la
largeur de la colonne courante.
-Dans les colonnes à largeur fixée (colonnes |w{...}{...}|, |p{...}|, |b{...}|,
-|m{...}| et |X|), le contenu du bloc est mis en forme comme un paragraphe de
-cette largeur.
+Dans les colonnes à largeur fixée (|p{...}|, |b{...}|, |m{...}|, |w{...}{...}|,
+|W{...}{...}|, |V| et |X|), le contenu du bloc est mis en forme comme un
+paragraphe de cette largeur.
\item La spécification d'alignement horizontal donnée par le type de
colonne (|c|, |r| ou |l|) est prise en compte pour le bloc (mais le bloc peut
@@ -2189,7 +2190,7 @@ de même nom (cf. p.~\pageref{cell-space}).
couleur du texte.\footnote{La clé |color| utilise la commande |\color| mais
insère aussi une instruction |\leavevmode| devant. Cela évite un espace
vertical parasite dans les cellules qui correspondent à des colonnes de type
- |p|, |b|, |m| et |X| (qui débutent en mode vertical).}
+ |p|, |b|, |m|, |X| et |V| (qui débutent en mode vertical).}
\item La clé |bold| impose des caractères gras aux éléments de la rangée, qu'ils
soient en mode texte ou bien en mode mathématique.
@@ -2355,6 +2356,63 @@ $\begin{array}{c}
\end{array}$
\end{NiceMatrixBlock}
+
+\subsection{Les colonnes X}
+
+
+\label{colonne-X}
+
+L'environnement |{NiceTabular}| propose aussi des colonnes |X| similaires à
+celles proposées par l'environnement |{tabularx}| de l'extension éponyme.
+
+La valeur requise par la largeur du tableau peut être passée en argument de la
+clé |width| (dans |{NiceTabular}| ou dans |\NiceMatrixOptions|). La valeur
+initiale de ce paramètre est |\linewidth| (et non |\textwidth|).
+
+Pour se rapprocher davantage de l'environnement |{tabularx}|, \pkg{nicematrix}
+propose aussi un environnement |{NiceTabularX}| avec une syntaxe similaire à
+celle de |{tabularx}|, c'est-à-dire que la largeur voulue pour le tableau est
+spécifiée en premier argument (obligatoire).\footnote{Si \pkg{tabularx} est
+ chargé, on doit obligatoirement utiliser |{NiceTabularX}| pour utiliser les
+ colonnes |X| (cela est dû à un problème de conflit de définition des
+ spécificateurs de colonne |X|).}
+
+
+Comme avec les extensions \pkg{tabu}\footnote{L'extension \pkg{tabu} est
+ maintenant considérée comme obsolète.} et \pkg{tabularray}, le spécificateur |X|
+accepte entre crochets un argument optionnel qui est une liste de clés.
+\begin{itemize}
+\item On peut spécifier un poids pour la colonne en mettant directement un
+entier positif comme argument du spécificateur |X|. Par exemple, une colonne
+|X[2]| aura une largeur double de celle d'une colonne |X| (qui a un poids de
+1).\footnote{Les valeurs négatives pour les poids, comme proposées par
+ \pkg{tabu} (maintenant obsolète), ne sont \emph{pas} prises en charge par
+ \pkg{nicematrix}. Si une telle valeur est utilisée, une erreur sera levée.}
+\item On peut spécifier l'alignement horizontal avec une des lettres |l|, |c| et
+|r| (qui insèrent respectivement |\raggedright|, |\centering| et |\raggedleft|
+suivi de |\arraybackslash|).
+\item On peut spécifier l'alignement vertical avec l'une des lettres |t| (alias
+|p|), |m| et |b| (qui construisent respectivement des colonnes de types |p|, |m|
+et |b|). La valeur par défaut est |t|.
+\end{itemize}
+
+\begin{Verbatim}
+\begin{NiceTabular}~emphase#[width=9cm]{X[2,l]X[l]}@[hvlines]
+Un texte relativement long qui tient sur plusieurs lignes. &
+Un texte relativement long qui tient sur plusieurs lignes. \\
+Un texte plus court. & Un texte plus court.
+\end{NiceTabular}
+\end{Verbatim}
+
+
+\begin{center}
+\begin{NiceTabular}[width=9cm]{X[2,l]X[l]}[hvlines]
+Un texte relativement long qui tient sur plusieurs lignes. &
+Un texte relativement long qui tient sur plusieurs lignes. \\
+Un texte plus court. & Un texte plus court.
+\end{NiceTabular}
+\end{center}
+
\subsection{Les colonnes V de varwidth}
\label{varwidth}
@@ -2437,66 +2495,17 @@ colonnes de type |p|, |m| ou |b| est que, pour les cases d'une telle colonne,
le nœud PGF-TikZ créé pour le contenu d'une telle case a une largeur ajustée
au contenu de la cellule en question : cf. p.~\pageref{node-V}.
+
+\medskip
+Les colonnes |V| de \pkg{nicematrix} acceptent les clés |t|, |p|, |m|, |b|, |l|,
+|c| et |r| proposées par les colonnes~|X|: voir leur description à la section~\ref{colonne-X},
+p.~\pageref{colonne-X}.
+
\medskip
Remarquons que l'extension \pkg{varwidth} a quelques problèmes (au moins dans sa
version 0.92). Par exemple, avec LuaLaTeX, elle ne fonctionne pas si le contenu
commence par une instruction |\color|.
-\subsection{Les colonnes X}
-
-
-\label{colonne-X}
-
-L'environnement |{NiceTabular}| propose aussi des colonnes |X| similaires à
-celles proposées par l'environnement |{tabularx}| de l'extension éponyme.
-
-La valeur requise par la largeur du tableau peut être passée en argument de la
-clé |width| (dans |{NiceTabular}| ou dans |\NiceMatrixOptions|). La valeur
-initiale de ce paramètre est |\linewidth| (et non |\textwidth|).
-
-Pour se rapprocher davantage de l'environnement |{tabularx}|, \pkg{nicematrix}
-propose aussi un environnement |{NiceTabularX}| avec une syntaxe similaire à
-celle de |{tabularx}|, c'est-à-dire que la largeur voulue pour le tableau est
-spécifiée en premier argument (obligatoire).\footnote{Si \pkg{tabularx} est
- chargé, on doit obligatoirement utiliser |{NiceTabularX}| pour utiliser les
- colonnes |X| (cela est dû à un problème de conflit de définition des
- spécificateurs de colonne |X|).}
-
-
-Comme avec les extensions \pkg{tabu}\footnote{L'extension \pkg{tabu} est
- maintenant considérée comme obsolète.} et \pkg{tabularray}, le spécificateur |X|
-accepte entre crochets un argument optionnel qui est une liste de clés.
-\begin{itemize}
-\item On peut spécifier un poids pour la colonne en mettant directement un
-entier positif comme argument du spécificateur |X|. Par exemple, une colonne
-|X[2]| aura une largeur double de celle d'une colonne |X| (qui a un poids de
-1).\footnote{Les valeurs négatives pour les poids, comme proposées par
- \pkg{tabu} (maintenant obsolète), ne sont \emph{pas} prises en charge par
- \pkg{nicematrix}. Si une telle valeur est utilisée, une erreur sera levée.}
-\item On peut spécifier l'alignement horizontal avec une des lettres |l|, |c| et
-|r| (qui insèrent respectivement |\raggedright|, |\centering| et |\raggedleft|
-suivi de |\arraybackslash|).
-\item On peut spécifier l'alignement vertical avec l'une des lettres |t| (alias
-|p|), |m| et |b| (qui construisent respectivement des colonnes de types |p|, |m|
-et |b|). La valeur par défaut est |t|.
-\end{itemize}
-
-\begin{Verbatim}
-\begin{NiceTabular}~emphase#[width=9cm]{X[2,l]X[l]}@[hvlines]
-Un texte relativement long qui tient sur plusieurs lignes. &
-Un texte relativement long qui tient sur plusieurs lignes. \\
-Un texte plus court. & Un texte plus court.
-\end{NiceTabular}
-\end{Verbatim}
-
-
-\begin{center}
-\begin{NiceTabular}[width=9cm]{X[2,l]X[l]}[hvlines]
-Un texte relativement long qui tient sur plusieurs lignes. &
-Un texte relativement long qui tient sur plusieurs lignes. \\
-Un texte plus court. & Un texte plus court.
-\end{NiceTabular}
-\end{center}
\medskip
\section{Les rangées et colonnes extérieures}
@@ -3346,7 +3355,7 @@ autres lignes diagonales (par défaut, les lignes tracées par |\Ddots| sont
\subsection{La commande \textbackslash SubMatrix dans le \textbackslash
- CodeAfter (et aussi le \textbackslash CodeBefore)}
+ CodeAfter (et le \textbackslash CodeBefore)}
\label{sub-matrix}
@@ -3456,25 +3465,25 @@ $\begin{bNiceMatrix}[right-margin=1em]
Les clés disponibles pour la commande |\SubMatrix| sont les suivantes :
%
\begin{itemize}
-\item |left-xshift| et |right-xshift| déplacent horizontalement les délimiteurs
-(il existe aussi la clé |xshift| qui permet de régler simultanément ces deux
-clés) ;
-\item |extra-height| ajoute une quantité à la hauteur totale des délimiteurs
-(hauteur~|\ht| + profondeur |\dp|) ;
-\item |delimiters/color| permet de fixer la couleur des délimiteurs (cette clé
+\item \Definition{left-xshift} et \Definition{right-xshift} déplacent
+horizontalement les délimiteurs (il existe aussi la clé \Definition{xshift} qui
+permet de régler simultanément ces deux clés) ;
+\item \Definition{extra-height} ajoute une quantité à la hauteur totale des
+délimiteurs (hauteur~|\ht| + profondeur |\dp|) ;
+\item \Definition{delimiters/color} permet de fixer la couleur des délimiteurs (cette clé
est également disponible dans |\NiceMatrixOptions| et au niveau des
environnements à délimiteurs ou comme option de |\CodeAfter|) ;
-\item |slim| qui est une clé booléenne : lorsqu'elle est utilisée la position
+\item \Definition{slim} qui est une clé booléenne : lorsqu'elle est utilisée la position
horizontale des délimiteurs est calculée uniquement sur le contenu des cases
de la sous-matrice alors, que, dans le cas général, elle est calculée sur le
contenu des cases des colonnes mises en jeu (voir exemple ci-dessous) ;
-\item |vlines| contient une liste de numéros de filets verticaux à tracer dans
+\item \Definition{vlines} contient une liste de numéros de filets verticaux à tracer dans
la sous-matrice (si cette clé est utilisée sans valeur, tous les filets
verticaux sont tracés) ;
-\item |hlines| est similaire à |vlines| mais pour les filets horizontaux ;
-\item |hvlines|, qui s'utilise sans valeur, trace tous les filets dans la
+\item \Definition{hlines} est similaire à |vlines| mais pour les filets horizontaux ;
+\item \Definition{hvlines}, qui s'utilise sans valeur, trace tous les filets dans la
sous-matrice ;
-\item |code| permet d'insérer du code, en particulier du code TikZ, après la
+\item \Definition{code} permet d'insérer du code, en particulier du code TikZ, après la
construction de la matrice. Cette clé est décrite en détail plus loin.
\end{itemize}
On remarquera que tous les filets sont dessinés après la construction du tableau
@@ -3598,7 +3607,8 @@ Part A & the first part \\
surtout pour vocation d'être utilisée pour insérer des instructions TikZ,
sachant que, dans les instructions TikZ insérées dans cette clé, les nœuds de la
forme |i-j| et \verb+i-|j+ sont interprétés avec |i| et |j| étant des numéros de
-ligne et colonne \emph{relatifs à la sous-matrice}.
+ligne et colonne \emph{relatifs à la sous-matrice}.\footnote{Attention : la
+ syntaxe \texttt{j\string|-i} n'est autorisée.}
\medskip
\begin{scope}
@@ -4169,7 +4179,7 @@ charge par \pkg{nicematrix}.
Les environnements sans préambule (|{NiceMatrix}|, |{pNiceMatrix}|, etc.) ainsi
que la commande |\pAutoNiceMatrix| et ses variantes, acceptent la clé
-|columns-type| qui indique le type des colonne qui sera utilisé.
+|columns-type| qui indique le type de colonne qui sera utilisé.
\medskip
Les clés |l| et |r| sont des raccourcis pour |columns-type=l| et |columns-type=r|.
@@ -4205,7 +4215,7 @@ Dans l'exemple suivant, on l'utilise dans le |code-for-first-row|.\footnote{On
\medskip
\begin{BVerbatim}[baseline=c,boxwidth=12cm]
-\NiceMatrixOptions%
+\NiceMatrixOptions
{code-for-first-row = \scriptstyle ~emphase#\rotate@ \text{image de },
code-for-last-col = \scriptstyle }
$A = \begin{pNiceMatrix}[first-row,last-col=4]
@@ -4216,7 +4226,7 @@ e_1 & e_2 & e_3 \\
\end{pNiceMatrix}$
\end{BVerbatim}
\begin{varwidth}{10cm}
-\NiceMatrixOptions%
+\NiceMatrixOptions
{code-for-first-row = \scriptstyle\rotate \text{image de },
code-for-last-col = \scriptstyle }
$ A = \begin{pNiceMatrix}[first-row,last-col=4]
@@ -4233,7 +4243,7 @@ matrice), les éléments qui subissent cette rotation sont alignés vers le haut
\medskip
\begin{BVerbatim}[baseline=c,boxwidth=12cm]
-\NiceMatrixOptions%
+\NiceMatrixOptions
{code-for-last-row = \scriptstyle ~emphase#\rotate@ ,
code-for-last-col = \scriptstyle }
$A = \begin{pNiceMatrix}[last-row,last-col=4]
@@ -4244,7 +4254,7 @@ $A = \begin{pNiceMatrix}[last-row,last-col=4]
\end{pNiceMatrix}$
\end{BVerbatim}
\begin{varwidth}{10cm}
-\NiceMatrixOptions%
+\NiceMatrixOptions
{code-for-last-row = \scriptstyle\rotate ,
code-for-last-col = \scriptstyle }%
$A = \begin{pNiceMatrix}[last-row,last-col=4]
@@ -4491,9 +4501,13 @@ Pour un exemple d'utilisation, voir \url{tex.stackexchange.com/questions/488566}
\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.
+L'extension \pkg{nicematrix} crée un nœud PGF-TikZ\footnote{On rappelle que TikZ
+ est une sur-couche de PGF. L'extension \pkg{nicematrix} charge PGF et ne
+ charge pas TikZ. On parle de «nœud PGF-TikZ» pour rappeler que, en fait, les
+ nœuds créés par \pkg{nicematrix} avec PGF sont en fait aussi utilisables avec
+ TikZ. L'utilisateur final préférera sans doute les utiliser avec TikZ qu'avec
+ PGF.} 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
\textbf{Attention} : Par défaut, aucun nœud n'est créé dans une case vide.
@@ -4576,38 +4590,67 @@ $\begin{pNiceMatrix}
\tikz \draw (2-2) circle (2mm) ;
\end{pNiceMatrix}$
+\medskip
+Les nœuds de la dernière colonne (hors éventuelle «colonne extérieure» spécifiée
+par |last-col|\footnote{Pour les colonnes extérieures, cf.
+ partie~\ref{exterior}, p.~\pageref{exterior}.}) peuvent aussi être désignés
+par $i$-|last|. De même, les nœuds de la dernière ligne peuvent être désignés
+par |last|-$j$.
\medskip
-Dans l'exemple suivant, nous avons surligné tous les nœuds de la matrice (on
-explique plus loin la technique utilisée : cf. p. \pageref{highlight}).
+Dans l'exemple suivant, nous avons surligné tous les nœuds de la matrice.
-\[\begin{pNiceMatrix}
-\CodeBefore [create-cell-nodes]
- \begin{tikzpicture}%
- [every node/.style = { 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}
-\Body
+\[
+\NiceMatrixOptions
+ {
+ pgf-node-code =
+ {
+ \pgfsetfillcolor{red!15}%
+ \pgfusepathqfill
+ }
+ }
+\begin{pNiceMatrix}
a & a + b & a + b + c \\
a & a & a + b \\
a & a & a
\end{pNiceMatrix}\]
+\bigskip
+\colorbox{yellow!50}{\textbf{Nouveau 6.17}}\enskip Puisque ces nœuds sont des
+nœuds PGF, on ne sera pas étonné d'appendre qu'ils sont tracés en utilisant un
+style PGF spécifique. Ce style est nommé |nicematrix/cell-node| et sa définition
+dans le fichier source |nicematrix.sty| est la suivante :
-Les nœuds de la dernière colonne (hors éventuelle «colonne extérieure» spécifiée
-par |last-col|) peuvent aussi être désignés par $i$-|last|. De même, les nœuds
-de la dernière ligne peuvent être désignés par |last|-$j$.
+\begin{Verbatim}
+\pgfset
+ {
+ ~emphase#nicematrix / cell-node@ /.style =
+ {
+ inner sep = 0 pt ,
+ minimum width = 0 pt
+ }
+ }
+\end{Verbatim}
+
+L'utilisateur peut modifier ce style en changeant les valeurs des clés |text/rotate|,
+|inner xsep|, |inner ysep|, |inner sep|, |outer xsep|, |outer ysep|, |outer sep|,
+|minimum width|, |minimum height| et |minimum size|.
\medskip
+Pour un exemple d'utilisation, voir la partie \ref{triangular},
+p.~\pageref{triangular}.
+
+\subsubsection{La clé pgf-node-code}
+
+\colorbox{yellow!50}{\textbf{Nouveau 6.17}}\enskip \textbf{Pour les utilisateurs
+expérimentés}, \pkg{nicematrix} fournit la clé |pgf-node-code| qui correspond à
+du code PGF qui sera exécuté à la création, par PGF, des nœuds correspondants aux
+cases du tableau. Plus précisément, la valeur fournie à la clé |pgf-node-code|
+sera passée en cinquième argument de la commande |\pgfnode|. Cette valeur doit
+contenir au moins une instruction comme |\pgfusepath|, |\pgfusepathqstroke|,
+|\pgfusepathqfill|, etc.
+
\subsubsection{Les colonnes V de varwidth}
\label{node-V}
@@ -5154,7 +5197,7 @@ mante & raie & poule
\section{Remarques techniques}
Première remarque : l'extension \pkg{nicematrix} doit être chargée après
-l'extension \pkg{underscore}.
+l'extension \pkg{underscore}. Si elle est chargée après, une erreur sera levée.
\subsection{Lignes diagonales}
@@ -5265,7 +5308,7 @@ si) son contenu dans le codage TeX est vide (il n'y a que des espaces entre les
deux esperluettes |&|).
\medskip
-\item Pour les colonnes de typte |c|, |l|, |r| ou |w{...}{...}|, la case est
+\item Pour les colonnes de type |c|, |l|, |r| ou |w{...}{...}|, la case est
vide si (et seulement si) son rendu TeX est de largeur nulle.
\medskip
@@ -5288,7 +5331,7 @@ L'environnement |{array}| insère un espace horizontal égal à |\arraycolsep|
avant et après chaque colonne. En particulier, il y a un espace égal à
|\arraycolsep| avant et après le tableau. Cette caractéristique de
l'environnement |{array}| n'était probablement pas une bonne idée\footnote{Dans
- la documentation de |{amsmath}|, on peut lire : {\itshape The extra space of
+ la documentation de l'\pkg{amsmath}, on peut lire : {\itshape The extra space of
|\arraycolsep| that \pkg{array} adds on each side is a waste so we remove it
[in |{matrix}|] (perhaps we should instead remove it from array in general,
but that's a harder task).}}. L'environnement |{matrix}| et ses variantes
@@ -5319,7 +5362,7 @@ L'extension \pkg{nicematrix} n'est pas compatible avec la classe \cls{ieeeaccess
\medskip
Pour pouvoir utiliser \pkg{nicematrix} avec la classe \cls{aastex631} (de
-l'\emph{American Astronomical Society}, on doit ajouter dans le préambule du
+l'\emph{American Astronomical Society}), on doit ajouter dans le préambule du
fichier les lignes suivantes :
\begin{Verbatim}
@@ -6393,6 +6436,66 @@ de parenthèses ont été rajoutées avec |\SubMatrix| dans le |\CodeBefore|.
\end{Verbatim}
+\subsection{Un tableau triangulaire}
+
+\label{triangular}
+
+Dans l'exemple suivant, on utilise le style PGF/Tikz |nicematrix/cell-node| pour faire
+tourner le contenu des cellules (rotation que l'on compense ensuite en faisant
+tourner tout le tableau avec la commande |\adjustbox| de l'extension éponyme,
+qui doit donc être chargée préalablement).
+
+\medskip
+\begin{Verbatim}
+\pgfset
+ {
+ ~emphase#nicematrix/cell-node@/.append style =
+ { text/rotate = 45, minimum size = 6 mm }
+ }
+
+\setlength{\tabcolsep}{0pt}
+
+~emphase#\adjustbox@{rotate = -45, set depth = 6mm + 1.414 \arrayrulewidth}
+ {\begin{NiceTabular} [ hvlines, corners=SE, baseline = line-9 ] { cccccccc }
+ \CodeBefore
+ \chessboardcolors{red!15}{blue!15}
+ \Body
+ 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
+ 1 & 2 & 3 & 4 & 5 & 6 & 7 \\
+ 1 & 3 & 6 & 10 & 15 & 21 \\
+ 1 & 4 & 10 & 20 & 35 \\
+ 1 & 5 & 15 & 35 \\
+ 1 & 6 & 21 \\
+ 1 & 7 \\
+ 1
+ \end{NiceTabular}}
+\end{Verbatim}
+
+
+\begin{center}
+\pgfset
+ {
+ nicematrix/cell-node/.append style =
+ { text/rotate = 45, minimum size = 6 mm }
+ }%
+\setlength{\tabcolsep}{0pt}%
+\adjustbox{rotate = -45, set depth = 6mm + 1.414 \arrayrulewidth}
+ {\begin{NiceTabular} [ hvlines, corners=SE, baseline = line-9 ] { cccccccc }
+ \CodeBefore
+ \chessboardcolors{red!15}{blue!15}
+ \Body
+ 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
+ 1 & 2 & 3 & 4 & 5 & 6 & 7 \\
+ 1 & 3 & 6 & 10 & 15 & 21 \\
+ 1 & 4 & 10 & 20 & 35 \\
+ 1 & 5 & 15 & 35 \\
+ 1 & 6 & 21 \\
+ 1 & 7 \\
+ 1
+ \end{NiceTabular}}
+\end{center}
+
+
\section*{Autre documentation}
diff --git a/macros/latex/contrib/nicematrix/nicematrix.dtx b/macros/latex/contrib/nicematrix/nicematrix.dtx
index 6ef8d2a7f7..3620cc0f4b 100644
--- a/macros/latex/contrib/nicematrix/nicematrix.dtx
+++ b/macros/latex/contrib/nicematrix/nicematrix.dtx
@@ -3,7 +3,7 @@
% This file should be compiled with $xelatex$.
%
% Copyright (C) 2018-2023 by F. Pantigny
-% -----------------------------------
+% ------------------------------------------
%
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
@@ -17,8 +17,8 @@
%
% \fi
% \iffalse
-\def\myfileversion{6.16}
-\def\myfiledate{2023/03/06}
+\def\myfileversion{6.17}
+\def\myfiledate{2023/03/31}
%
%
%<*batchfile>
@@ -61,6 +61,7 @@ version 2005/12/01 or later.
\usepackage{caption}
\usepackage{varwidth}
\usepackage{tcolorbox}
+\usepackage{adjustbox}
\usepackage[auto-lang=false]{lipsum}
\NewDocumentEnvironment {scope} {} {} {}
@@ -556,9 +557,8 @@ version 2005/12/01 or later.
% block;\footnote{However, the rules are not drawn in the sub-blocks of the
% block, as always with \pkg{nicematrix}: the rules are not drawn in the blocks
% (cf. section~\ref{rules} p.~\pageref{rules}).}
-% \item the key \Definition{line-width} is the width of the rules (this key
-% is meaningful only when one of the keys |draw|, |hvlines|, |vlines| and
-% |hlines| is used);
+% \item the key \Definition{line-width} is the width of the rules (is relevant
+% only when one of the keys |draw|, |hvlines|, |vlines| and |hlines| is used);
% \item the key \Definition{rounded-corners} requires rounded corners (for the
% frame drawn by |draw| and the shape drawn by |fill|) with a radius equal to
% the value of that key (the default value is 4~pt\footnote{This value is the
@@ -582,7 +582,7 @@ version 2005/12/01 or later.
% the form |tikz={|\textsl{list}|}| where \textsl{list} is a list of couples
% \textsl{key=value} of Tikz specifying the graphical characteristics of the
% lines that will be drawn (for an example, see p.~\pageref{dashed}).
-% \item \colorbox{yellow!50}{\textbf{Nouveau 6.15}}\par\nobreak
+% \item \colorbox{yellow!50}{\textbf{New 6.15}}\par\nobreak
% By default, the rules are not drawn in the blocks (see the section about the
% rules: section~\ref{rules} p.~\pageref{rules}). However, if the key
% \Definition{transparent} is used, the rules are drawn. For an example, see
@@ -590,7 +590,7 @@ version 2005/12/01 or later.
% \end{itemize}
%
% There is also keys for the horizontal and vertical positions of the content of
-% the block: cf.~\ref{horizontal-block} p.~\pageref{horizontal-block}).
+% the block: cf.~\ref{horizontal-block} p.~\pageref{horizontal-block}.
%
% \interitem
% {\bfseries One must remark that, by default, the commands |\Blocks| don't create space}.
@@ -599,11 +599,11 @@ version 2005/12/01 or later.
%
% \medskip
% In the following example, we have had to enlarge by hand the columns 2 and 3
-% (with the construction |wc{...}| of \pkg{array}).
+% (with the construction |w{c}{...}| of \pkg{array}).
%
% \bigskip
% \begin{BVerbatim}
-% \begin{NiceTabular}{cwc{2cm}wc{3cm}c}
+% \begin{NiceTabular}{cw{c}{2cm}w{c}{3cm}c}
% rose & tulip & daisy & dahlia \\
% violet
% & ~emphase#\Block[draw=red,fill=[RGB]{204,204,255},rounded-corners]{2-2}@
@@ -616,7 +616,7 @@ version 2005/12/01 or later.
%
% \medskip
% \begin{center}
-% \begin{NiceTabular}{cwc{2cm}wc{3cm}c}
+% \begin{NiceTabular}{cw{c}{2cm}w{c}{3cm}c}
% rose & tulip & daisy & dahlia \\
% violet & \Block[draw=red,fill=[RGB]{204,204,255},rounded-corners]{2-2}
% {\LARGE Some beautiful flowers} & & marigold \\
@@ -633,9 +633,9 @@ version 2005/12/01 or later.
% \item The natural width of the contents of these blocks is taken into account
% for the width of the current column.
%
-% In the columns with a fixed width (columns |w{...}{...}|, |p{...}|, |b{...}|,
-% |m{...}| and |X|), the content of the block is formatted as a paragraph of
-% that width.
+% In the columns with a fixed width (columns |w{...}{...}|, |W{...}{...}|,
+% |p{...}|, |b{...}|, |m{...}|, |V| and |X|), the content of the block is
+% formatted as a paragraph of that width.
%
% \item The specification of the horizontal position provided by the type of
% column (|c|, |r| or |l|) is taken into account for the blocks (but the
@@ -764,7 +764,7 @@ version 2005/12/01 or later.
% \end{bNiceArray}$
%
%
-%
+% \medskip
% By default, the horizontal position of the content of a block is computed
% by using the positions of the \emph{contents} of the columns implied in that
% block. That's why, in the following example, the header ``First group'' is
@@ -852,7 +852,7 @@ version 2005/12/01 or later.
%
% \colorbox{yellow!50}{\textbf{New 6.14}}
%
-% For the vertical position, the commands |\Blocks| accepts the keys
+% For the vertical position, the command |\Blocks| accepts the keys
% |v-center|\footnote{That key could not have been named |c| since the key |c|
% is used for the horizontal alignement.},
% |t|, |b|, |T| and |B|.
@@ -1389,7 +1389,7 @@ version 2005/12/01 or later.
% will be created by \pkg{nicematrix} and that will be available for the final
% user in order to draw horizontal rules (similarly to |\hline|);
%
-% \item the key |cccommand| is the name (without the backslash) of a command
+% \item the key |ccommand| is the name (without the backslash) of a command
% that will be created by \pkg{nicematrix} and that will be available for the
% final user to order to draw partial horizontal rules (similarly to |\cline|,
% hence the name |ccommand|): the argument of that command is a list of
@@ -2180,7 +2180,7 @@ version 2005/12/01 or later.
% color of the text.\footnote{The key |color| uses the command
% |\color| but inserts also an instruction |\leavevmode| before. This
% instruction prevents a extra vertical space in the cells which belong to
-% columns of type |p|, |b|, |m| and |X| (which start in
+% columns of type |p|, |b|, |m|, |X| and |V| (which start in
% vertical mode).}
% \item The key |bold| enforces
% bold characters for the cells of the row, both in math and text mode.
@@ -2220,13 +2220,13 @@ version 2005/12/01 or later.
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
-% \begin{NiceTabular}{~emphase#Wc{2cm}@cc}[hvlines]
+% \begin{NiceTabular}{~emphase#W{c}{2cm}@cc}[hvlines]
% Paris & New York & Madrid \\
% Berlin & London & Roma \\
% Rio & Tokyo & Oslo
% \end{NiceTabular}
% \end{BVerbatim}
-% \begin{NiceTabular}{Wc{2cm}cc}[hvlines]
+% \begin{NiceTabular}{W{c}{2cm}cc}[hvlines]
% Paris & New York & Madrid \\
% Berlin & London & Roma \\
% Rio & Tokyo & Oslo
@@ -2342,6 +2342,60 @@ version 2005/12/01 or later.
% \end{array}$
% \end{NiceMatrixBlock}
%
+% \subsection{The columns X}
+%
+% \label{X-columns}
+%
+% The environment |{NiceTabular}| provides |X| columns similar to those provided
+% by the environment |{tabularx}| of the eponymous package.
+%
+% The required width of the tabular may be specified with the key |width| (in
+% |{NiceTabular}| or in |\NiceMatrixOptions|). The initial value of this
+% parameter is |\linewidth| (and not |\textwidth|).
+%
+% For sake of similarity with the environment |{tabularx}|, \pkg{nicematrix}
+% also provides an environment |{NiceTabularX}| with a syntax similar to the
+% syntax of |{tabularx}|, that is to say with a first mandatory argument
+% which is the width of the tabular.\footnote{If \pkg{tabularx} is loaded, one
+% must use |{NiceTabularX}| (and not |{NiceTabular}|) in order to use the
+% columns |X| (this point comes from a conflict in the definitions of the
+% specifier |X|).}
+%
+% As with the packages \pkg{tabu}\footnote{The extension \pkg{tabu} is now
+% considered as deprecated.} and \pkg{tabularray}, the specifier |X| takes
+% in an optional argument (between square brackets) which is a list of keys.
+% \begin{itemize}
+% \item It's possible to give a weight for the column by providing a positive
+% integer directly as argument of the specifier |X|. For example, a column
+% |X[2]| will have a width double of the width of a column~|X| (which has a
+% weight equal to $1$).\footnote{The negative values of the weight, as provided
+% by \pkg{tabu} (which is now obsolete), are \emph{not} supported by \pkg{nicematrix}.
+% If such a value is used, an error will be raised.}
+% \item It's possible to specify an horizontal alignment with one of the
+% letters |l|, |c| and |r| (which insert respectively |\raggedright|,
+% |\centering| and |\raggedleft| followed by |\arraybackslash|).
+% \item It's possible to specify a vertical alignment with one of the keys
+% |t| (alias |p|), |m| and |b| (which construct respectively columns of type
+% |p|, |m| and |b|). The default value is |t|.
+% \end{itemize}
+%
+% \begin{Verbatim}
+% \begin{NiceTabular}~emphase#[width=9cm]{X[2,l]X[l]}@[hvlines]
+% a rather long text which fits on several lines
+% & a rather long text which fits on several lines \\
+% a shorter text & a shorter text
+% \end{NiceTabular}
+% \end{Verbatim}
+%
+% \begin{center}
+% \begin{NiceTabular}[width=9cm]{X[2,l]X[l]}[hvlines]
+% a rather long text which fits on several lines
+% & a rather long text which fits on several lines \\
+% a shorter text & a shorter text
+% \end{NiceTabular}
+% \end{center}
+%
+%
% \subsection{The columns V of varwidth}
%
% \label{varwidth}
@@ -2423,66 +2477,18 @@ version 2005/12/01 or later.
% interests of this type of columns is that, for a cell of a column of type~|V|,
% the PGF/Tikz node created by \pkg{nicematrix} for the content of that cell has
% a width adjusted to the content of the cell : cf. p.~\pageref{node-V}.
-
+%
+%
+% \bigskip
+% The columns |V| of \pkg{nicematrix} supports the keys |t|, |p|, |m|, |b|, |l|,
+% |c| and |r| also supported by the columns |X|: see their description in the
+% section~\ref{X-columns}, p.~\pageref{X-columns}.
+%
% \bigskip
% One should remark that the extension \pkg{varwidth} (at least in its version
% 0.92) has some problems: for instance, with LuaLaTeX, it does not work when
% the content begins with |\color|.
%
-%
-% \subsection{The columns X}
-%
-% \label{X-columns}
-%
-% The environment |{NiceTabular}| provides |X| columns similar to those provided
-% by the environment |{tabularx}| of the eponymous package.
-%
-% The required width of the tabular may be specified with the key |width| (in
-% |{NiceTabular}| or in |\NiceMatrixOptions|). The initial value of this
-% parameter is |\linewidth| (and not |\textwidth|).
-%
-% For sake of similarity with the environment |{tabularx}|, \pkg{nicematrix}
-% also provides an environment |{NiceTabularX}| with a syntax similar to the
-% syntax of |{tabularx}|, that is to say with a first mandatory argument
-% which is the width of the tabular.\footnote{If \pkg{tabularx} is loaded, one
-% must use |{NiceTabularX}| (and not |{NiceTabular}|) in order to use the
-% columns |X| (this point comes from a conflict in the definitions of the
-% specifier |X|).}
-%
-% As with the packages \pkg{tabu}\footnote{The extension \pkg{tabu} is now
-% considered as deprecated.} and \pkg{tabularray}, the specifier |X| takes
-% in an optional argument (between square brackets) which is a list of keys.
-% \begin{itemize}
-% \item It's possible to give a weight for the column by providing a positive
-% integer directly as argument of the specifier |X|. For example, a column
-% |X[2]| will have a width double of the width of a column~|X| (which has a
-% weight equal to $1$).\footnote{The negative values of the weight, as provided
-% by \pkg{tabu} (which is now obsolete), are \emph{not} supported by \pkg{nicematrix}.
-% If such a value is used, an error will be raised.}
-% \item It's possible to specify an horizontal alignment with one of the
-% letters |l|, |c| and |r| (which insert respectively |\raggedright|,
-% |\centering| and |\raggedleft| followed by |\arraybackslash|).
-% \item It's possible to specify a vertical alignment with one of the keys
-% |t| (alias |p|), |m| and |b| (which construct respectively columns of type
-% |p|, |m| and |b|). The default value is |t|.
-% \end{itemize}
-%
-% \begin{Verbatim}
-% \begin{NiceTabular}~emphase#[width=9cm]{X[2,l]X[l]}@[hvlines]
-% a rather long text which fits on several lines
-% & a rather long text which fits on several lines \\
-% a shorter text & a shorter text
-% \end{NiceTabular}
-% \end{Verbatim}
-%
-% \begin{center}
-% \begin{NiceTabular}[width=9cm]{X[2,l]X[l]}[hvlines]
-% a rather long text which fits on several lines
-% & a rather long text which fits on several lines \\
-% a shorter text & a shorter text
-% \end{NiceTabular}
-% \end{center}
-%
% \bigskip
% \section{The exterior rows and columns}
%
@@ -3313,7 +3319,7 @@ version 2005/12/01 or later.
%
%
% \subsection{The command \textbackslash SubMatrix in the \textbackslash
-% CodeAfter (and also the \textbackslash CodeBefore)}
+% CodeAfter (and the \textbackslash CodeBefore)}
%
% \label{sub-matrix}
%
@@ -3419,26 +3425,27 @@ version 2005/12/01 or later.
% \bigskip
% The options of the command |\SubMatrix| are as follows:
% \begin{itemize}
-% \item |left-xshift| and |right-xshift| shift horizontally the delimiters (there
-% exists also the key |xshift| which fixes both parameters);
-% \item |extra-height| adds a quantity to the total height of the delimiters
-% (height |\ht| + depth |\dp|);
-% \item |delimiters/color| fixes the color of the delimiters (also
+% \item \Definition{left-xshift} and \Definition{right-xshift} shift
+% horizontally the delimiters (there exists also the key \Definition{xshift}
+% which fixes both parameters);
+% \item \Definition{extra-height} adds a quantity to the total height of the
+% delimiters (height |\ht| + depth |\dp|);
+% \item \Definition{delimiters/color} fixes the color of the delimiters (also
% available in |\NiceMatrixOptions|, in the environments with delimiters and as
% option of the keyword |\CodeAfter|);
-% \item |slim| is a boolean key: when that key is in force, the horizontal
+% \item \Definition{slim} is a boolean key: when that key is in force, the horizontal
% position of the delimiters is computed by using only the contents of the cells
% of the submatrix whereas, in the general case, the position is computed by
% taking into account the cells of the whole columns implied in the submatrix
% (see example below). ;
-% \item |vlines| contents a list of numbers of vertical rules that will be drawn in
-% the sub-matrix (if this key is used without value, all the vertical rules of
-% the sub-matrix are drawn);
-% \item |hlines| is similar to |vlines| but for the horizontal rules;
-% \item |hvlines|, which must be used without value, draws all the vertical and
-% horizontal rules;
-% \item |code| insert code, especially TikZ code, after the construcion of the
-% submatrix. That key is detailed below.
+% \item \Definition{vlines} contents a list of numbers of vertical rules that
+% will be drawn in the sub-matrix (if this key is used without value, all the
+% vertical rules of the sub-matrix are drawn);
+% \item \Definition{hlines} is similar to |vlines| but for the horizontal rules;
+% \item \Definition{hvlines}, which must be used without value, draws all the
+% vertical and horizontal rules;
+% \item \Definition{code} insert code, especially TikZ code, after the
+% construcion of the submatrix. That key is detailed below.
% \end{itemize}
% One should remark that the keys add their rules after the construction of
% the main matrix: no space is added between the rows and the columns of the
@@ -3561,7 +3568,8 @@ version 2005/12/01 or later.
% submatrix. It's meant to be used to insert TikZ instructions because, in the
% TikZ instructions inserted by that code, the nodes of the form |i-j| and
% \verb+i-|j+ are interpreted with |i| and |j| as numbers of row and columns
-% \emph{relative to the submatrix}.
+% \emph{relative to the submatrix}.\footnote{Be careful: the syntax
+% \verb+j|-i+ is not allowed.}
%
% \medskip
% \begin{scope}
@@ -4433,7 +4441,11 @@ version 2005/12/01 or later.
%
% \subsection{The nodes corresponding to the contents of the cells}
%
-% The package \pkg{nicematrix} creates a PGF/Tikz node for each (non-empty) cell
+% The package \pkg{nicematrix} creates a PGF/Tikz node\footnote{We recall that Tikz
+% is a layer over PGF. The extension \pkg{nicematrix} loads PGF but does not
+% load Tikz. We speak of PGF/Tikz nodes to emphase the fact that the PGF nodes
+% created by \pkg{nicematrix} may be used with PGF but also with Tikz. The final
+% user will probably prefer to use Tikz rather than PGF.} 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).
%
@@ -4518,36 +4530,65 @@ version 2005/12/01 or later.
% \tikz \draw (2-2) circle (2mm) ;
% \end{pNiceMatrix}$
%
+% \medskip
+% The nodes of the last column (excepted the potential «last column» specified
+% by |last-col|\footnote{For the exterior columns, cf. part~\ref{exterior},
+% p.~\pageref{exterior}.}) may also be indicated by $i$-|last|. Similarly, the
+% nodes of the last row may be indicated by |last|-$j$.
%
% \bigskip
-% In the following example, we have underlined all the nodes of the matrix (we
-% explain below the technic used : cf. p. \pageref{highlight}).
+% In the following example, we have underlined all the nodes of the matrix.
%
-%
-% \[\begin{pNiceMatrix}
-% \CodeBefore [create-cell-nodes]
-% \begin{tikzpicture}%
-% [every node/.style = { 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}
-% \Body
+% \[
+% \NiceMatrixOptions
+% {
+% pgf-node-code =
+% {
+% \pgfsetfillcolor{red!15}%
+% \pgfusepathqfill
+% }
+% }
+% \begin{pNiceMatrix}
% a & a + b & a + b + c \\
% a & a & a + b \\
-% a & a & a
+% a & a & a
% \end{pNiceMatrix}\]
%
%
-% The nodes of the last column (excepted the potential «last column» specified
-% by |last-col|) may also be indicated by $i$-|last|. Similarly, the nodes of
-% the last row may be indicated by |last|-$j$.
+% \bigskip
+% \colorbox{yellow!50}{\textbf{New 6.17}}\enskip Since those nodes are PGF
+% nodes, one won't be surprised to learn that they are drawn by using a specific
+% PGF style. That style is called |nicematrix/cell-node| and its definition in
+% the source file |nicematrix.sty| is as follows:
+%
+% \begin{Verbatim}
+% \pgfset
+% {
+% ~emphase#nicematrix / cell-node@ /.style =
+% {
+% inner sep = 0 pt ,
+% minimum width = 0 pt
+% }
+% }
+% \end{Verbatim}
+%
+% The final user may modify that style by changing the values of the keys |text/rotate|,
+% |inner xsep|, |inner ysep|, |inner sep|, |outer xsep|, |outer ysep|, |outer sep|,
+% |minimum width|, |minimum height| and |minimum size|.
+%
+% \medskip
+% For an example of utilisation, see part~\ref{triangular}, p.~\pageref{triangular}.
+%
+%
+% \subsubsection{The key pgf-node-code}
+%
+% \colorbox{yellow!50}{\textbf{New 6.17}}\enskip \textbf{For the experienced
+% users}, \pkg{nicematrix} provides the key |pgf-node-code| which corresponds to
+% some PGF node that will be executed at the creation, by PGF, of the nodes
+% corresponding to the cells of the array. More pricisely, the value given to
+% the key |pgf-node-code| will be passed in the fifth argument of the command
+% |\pgfnode|. That value should contain at least an instruction such as
+% |\pgfusepath|, |\pgfusepathqstroke|, |\pgfusepathqfill|, etc.
%
% \subsubsection{The columns V of varwidth}
%
@@ -5086,7 +5127,8 @@ version 2005/12/01 or later.
%
% \section{Technical remarks}
%
-% First remark: the package \pkg{underscore} must be loaded before \pkg{nicematrix}.
+% First remark: the package \pkg{underscore} must be loaded before
+% \pkg{nicematrix}. If it is loaded after, an error will be raised.
%
% \subsection{Diagonal lines}
%
@@ -5215,7 +5257,7 @@ version 2005/12/01 or later.
% before and after each column. In particular, there is a space equal to
% |\arraycolsep| before and after the array. This feature of the environment
% |{array}| was probably not a good idea\footnote{In the documentation of
-% |{amsmath}|, we can read: {\itshape The extra space of |\arraycolsep| that
+% \pkg{amsmath}, we can read: {\itshape The extra space of |\arraycolsep| that
% \pkg{array} adds on each side is a waste so we remove it [in |{matrix}|]
% (perhaps we should instead remove it from array in general, but that's a
% harder task).}}. The environment |{matrix}| of
@@ -6219,7 +6261,9 @@ version 2005/12/01 or later.
% a & a & a & L_3
% \end{pNiceArray}\]
%
-%
+%
+
+%
% \subsection{Utilisation of \textbackslash SubMatrix in the \textbackslash CodeBefore}
%
% \label{submatrix-in-codebefore}
@@ -6299,6 +6343,69 @@ version 2005/12/01 or later.
% \end{NiceArray}\]
% \end{Verbatim}
%
+%
+%
+% \subsection{A triangular tabular}
+%
+% \label{triangular}
+%
+% In the following example, we use the style PGF/TikZ |nicematrix/cell-node|
+% to rotate the contents of the cells (and, then, we compensate that rotation by
+% a rotation of the whole tabular with the command |\adjustbox| of the eponymous
+% package, which must be loaded previously).
+%
+%
+% \medskip
+% \begin{Verbatim}
+% \pgfset
+% {
+% ~emphase#nicematrix/cell-node@/.append style =
+% { text/rotate = 45, minimum size = 6 mm }
+% }
+%
+% \setlength{\tabcolsep}{0pt}
+%
+% ~emphase#\adjustbox@{rotate = -45, set depth = 6mm + 1.414 \arrayrulewidth}
+% {\begin{NiceTabular} [ hvlines, corners=SE, baseline = line-9 ] { cccccccc }
+% \CodeBefore
+% \chessboardcolors{red!15}{blue!15}
+% \Body
+% 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
+% 1 & 2 & 3 & 4 & 5 & 6 & 7 \\
+% 1 & 3 & 6 & 10 & 15 & 21 \\
+% 1 & 4 & 10 & 20 & 35 \\
+% 1 & 5 & 15 & 35 \\
+% 1 & 6 & 21 \\
+% 1 & 7 \\
+% 1
+% \end{NiceTabular}}
+% \end{Verbatim}
+%
+%
+% \begin{center}
+% \pgfset
+% {
+% nicematrix/cell-node/.append style =
+% { text/rotate = 45, minimum size = 6 mm }
+% }%
+% \setlength{\tabcolsep}{0pt}%
+% \adjustbox{rotate = -45, set depth = 6mm + 1.414 \arrayrulewidth}
+% {\begin{NiceTabular} [ hvlines, corners=SE, baseline = line-9 ] { cccccccc }
+% \CodeBefore
+% \chessboardcolors{red!15}{blue!15}
+% \Body
+% 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
+% 1 & 2 & 3 & 4 & 5 & 6 & 7 \\
+% 1 & 3 & 6 & 10 & 15 & 21 \\
+% 1 & 4 & 10 & 20 & 35 \\
+% 1 & 5 & 15 & 35 \\
+% 1 & 6 & 21 \\
+% 1 & 7 \\
+% 1
+% \end{NiceTabular}}
+% \end{center}
+%
+%
%
% \section{Implementation}
%
@@ -6578,7 +6685,7 @@ version 2005/12/01 or later.
%
% We test whether the current class is \cls{revtex4-1} (deprecated) or
% \cls{revtex4-2} because these classes redefines |\array| (of \pkg{array}) in a
-% way incompatible with our programmation. At the date January 2022, the current
+% way incompatible with our programmation. At the date March 2023, the current
% version \cls{revtex4-2} is 4.2e (compatible with \pkg{booktabs}).
%
% \begin{macrocode}
@@ -7251,6 +7358,13 @@ version 2005/12/01 or later.
% \begin{macrocode}
\tl_new:N \l_@@_code_tl
% \end{macrocode}
+%
+% \bigskip
+% For the key |pgf-node-code|. That code will be used when the nodes of the
+% cells (that is to say the nodes of the form |i-j|) will be created.
+% \begin{macrocode}
+\tl_new:N \l_@@_pgf_node_code_tl
+% \end{macrocode}
%
% \bigskip
% The following token list has a function similar to
@@ -7313,10 +7427,6 @@ version 2005/12/01 or later.
\dim_new:N \l_@@_X_columns_dim
% \end{macrocode}
%
-% \medskip
-% \begin{macrocode}
-\bool_new:N \l_@@_X_V_bool
-% \end{macrocode}
%
% \bigskip
% This boolean will be used only to detect in an expandable way whether we are
@@ -7508,7 +7618,7 @@ version 2005/12/01 or later.
% The following sequence will be used when the command |\SubMatrix| is used in
% the |\CodeBefore| (and not in the |\CodeAfter|). It will contain the position of
% all the sub-matrices specified in the |\CodeBefore|. Each sub-matrix is
-% represented by an ``object'' of the forme |{|$i$|}{|$j$|}{|$k$|}{|$l$|}|
+% represented by an ``object'' of the form |{|$i$|}{|$j$|}{|$k$|}{|$l$|}|
% where $i$ and $j$ are the number of row and column of the upper-left cell and
% $k$ and $l$ the number of row and column of the lower-right cell.
% \begin{macrocode}
@@ -8064,7 +8174,7 @@ version 2005/12/01 or later.
\begin { pgfscope }
\pgfset
{
- outer~sep = \c_zero_dim ,
+ % outer~sep = \c_zero_dim ,
inner~sep = \c_zero_dim ,
minimum~size = \c_zero_dim
}
@@ -8096,7 +8206,7 @@ version 2005/12/01 or later.
\begin { pgfscope }
\pgfset
{
- outer~sep = \c_zero_dim ,
+ % outer~sep = \c_zero_dim ,
inner~sep = \c_zero_dim ,
minimum~size = \c_zero_dim
}
@@ -8545,7 +8655,9 @@ version 2005/12/01 or later.
{ extra-left-margin = #1 , extra-right-margin = #1 } ,
extra-margin .value_required:n = true ,
respect-arraystretch .bool_set:N = \l_@@_respect_arraystretch_bool ,
- respect-arraystretch .default:n = true
+ respect-arraystretch .default:n = true ,
+ pgf-node-code .tl_set:N = \l_@@_pgf_node_code_tl ,
+ pgf-node-code .value_required:n = true
}
% \end{macrocode}
%
@@ -9078,6 +9190,13 @@ version 2005/12/01 or later.
{
\@@_math_toggle_token:
\hbox_set_end:
+ \@@_cell_end_i:
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_cell_end_i:
+ {
% \end{macrocode}
% The token list |\g_@@_cell_after_hook_tl| is (potentially) set during the
% composition of the box |\l_@@_cell_box| and is used now \emph{after} the
@@ -9136,13 +9255,13 @@ version 2005/12/01 or later.
% \end{itemize}
% \begin{macrocode}
\bool_if:NTF \g_@@_empty_cell_bool
- { \box_use_drop:N \l_@@_cell_box }
+ { \box_use_drop:N \l_@@_cell_box }
{
\bool_lazy_or:nnTF
\g_@@_not_empty_cell_bool
{ \dim_compare_p:nNn { \box_wd:N \l_@@_cell_box } > \c_zero_dim }
\@@_node_for_cell:
- { \box_use_drop:N \l_@@_cell_box }
+ { \box_use_drop:N \l_@@_cell_box }
}
\int_gset:Nn \g_@@_col_total_int { \int_max:nn \g_@@_col_total_int \c@jCol }
\bool_gset_false:N \g_@@_empty_cell_bool
@@ -9150,20 +9269,46 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
-% \medskip
+% \bigskip
+% The following variant of |\@@_cell_end:| is only for the columns of type
+% |w{s}{...}| or |W{s}{...}| (which use the horizontal alignement key |s| of
+% |\makebox|).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_cell_end_for_w_s:
+ {
+ \@@_math_toggle_token:
+ \hbox_set_end:
+ \bool_if:NF \g_@@_rotate_bool
+ {
+ \hbox_set:Nn \l_@@_cell_box
+ {
+ \makebox [ \l_@@_col_width_dim ] [ s ]
+ { \hbox_unpack_drop:N \l_@@_cell_box }
+ }
+ }
+ \@@_cell_end_i:
+ }
+% \end{macrocode}
+%
+%
+% \bigskip
% The following command creates the \textsc{pgf} name of the node with, of
% course, |\l_@@_cell_box| as the content.
% \begin{macrocode}
+\pgfset
+ {
+ nicematrix / cell-node /.style =
+ {
+ inner~sep = \c_zero_dim ,
+ minimum~width = \c_zero_dim
+ }
+ }
\cs_new_protected:Npn \@@_node_for_cell:
{
\pgfpicture
\pgfsetbaseline \c_zero_dim
\pgfrememberpicturepositiononpagetrue
- \pgfset
- {
- inner~sep = \c_zero_dim ,
- minimum~width = \c_zero_dim
- }
+ \pgfset { nicematrix / cell-node }
\pgfnode
{ rectangle }
{ base }
@@ -9176,7 +9321,7 @@ version 2005/12/01 or later.
\box_use_drop:N \l_@@_cell_box
}
{ \@@_env: - \int_use:N \c@iRow - \int_use:N \c@jCol }
- { }
+ { \l_@@_pgf_node_code_tl }
\str_if_empty:NF \l_@@_name_str
{
\pgfnodealias
@@ -11302,9 +11447,62 @@ version 2005/12/01 or later.
%
% \medskip
% For |w| and |W|
+%
+% |#1| is a special argument: empty for |w| and equal to |\@@_special_W:| for |W|;
+%
+% |#2| is the type of column (|w| or |W|);
+%
+% |#3| is the type of horizontal alignment (|c|, |l|, |r| or |s|);
+%
+% |#4| is the width of the column.
+%
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_vi:nnnn #1 #2 #3 #4
{
+ \str_if_eq:nnTF { #3 } { s }
+ { \@@_patch_preamble_vi_i:nnnn { #1 } { #4 } }
+ { \@@_patch_preamble_vi_ii:nnnn { #1 } { #2 } { #3 } { #4 } }
+ }
+% \end{macrocode}
+%
+% \bigskip
+% First, the case of an horizontal alignment equal to |s| (for \emph{stretch}).
+%
+% |#1| is a special argument: empty for |w| and equal to |\@@_special_W:| for
+% |W|;
+%
+% |#2| is the width of the column.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_preamble_vi_i:nnnn #1 #2
+ {
+ \tl_gput_right:NV \g_@@_preamble_tl \g_@@_pre_cell_tl
+ \tl_gclear:N \g_@@_pre_cell_tl
+ \tl_gput_right:Nn \g_@@_preamble_tl
+ {
+ > {
+ \dim_set:Nn \l_@@_col_width_dim { #2 }
+ \@@_cell_begin:w
+ \str_set:Nn \l_@@_hpos_cell_str { c }
+ }
+ c
+ < {
+ \@@_cell_end_for_w_s:
+ #1
+ \@@_adjust_size_box:
+ \box_use_drop:N \l_@@_cell_box
+ }
+ }
+ \int_gincr:N \c@jCol
+ \@@_patch_preamble_xi:n
+ }
+% \end{macrocode}
+%
+% \bigskip
+% Then, the most important version, for the horizontal alignments types of |c|,
+% |l| and |r| (and not |s|).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_preamble_vi_ii:nnnn #1 #2 #3 #4
+ {
\tl_gput_right:NV \g_@@_preamble_tl \g_@@_pre_cell_tl
\tl_gclear:N \g_@@_pre_cell_tl
\tl_gput_right:Nn \g_@@_preamble_tl
@@ -11324,10 +11522,11 @@ version 2005/12/01 or later.
< {
\@@_cell_end:
\hbox_set_end:
- \bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box:
+ % The following line is probably pointless
+ % \bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box:
#1
\@@_adjust_size_box:
- \makebox [ #4 ] [ #3 ] { \box_use_drop:N \l_@@_cell_box }
+ \makebox [ #4 ] [ #3 ] { \box_use_drop:N \l_@@_cell_box }
}
}
% \end{macrocode}
@@ -11342,10 +11541,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_special_W:
{
- \dim_compare:nNnT
- { \box_wd:N \l_@@_cell_box }
- >
- \l_@@_col_width_dim
+ \dim_compare:nNnT { \box_wd:N \l_@@_cell_box } > \l_@@_col_width_dim
{ \@@_warning:n { W~warning } }
}
% \end{macrocode}
@@ -11537,10 +11733,7 @@ version 2005/12/01 or later.
% of keys will be used to retrieve that value (in the counter |\l_@@_weight_int|).
% \begin{macrocode}
\keys_define:nn { WithArrows / X-column }
- {
- v .bool_set:N = \l_@@_X_V_bool ,
- unknown .code:n = \int_set:Nn \l_@@_weight_int { \l_keys_key_str }
- }
+ { unknown .code:n = \int_set:Nn \l_@@_weight_int { \l_keys_key_str } }
% \end{macrocode}
%
%
@@ -11574,7 +11767,6 @@ version 2005/12/01 or later.
\tl_set:Nn \l_tmpa_tl { #1 }
\tl_replace_all:Nnn \l_tmpa_tl { \@@_S: } { S }
\@@_keys_p_column:V \l_tmpa_tl
- \bool_set_false:N \l_@@_X_V_bool
\keys_set:nV { WithArrows / X-column } \l_tmpa_tl
\int_compare:nNnT \l_@@_weight_int < 0
{
@@ -11593,11 +11785,7 @@ version 2005/12/01 or later.
\exp_args:Nnx
\@@_patch_preamble_iv_iv:nn
{ \l_@@_weight_int \l_@@_X_columns_dim }
- {
- \bool_if:NTF \l_@@_X_V_bool
- { varwidth }
- { minipage }
- }
+ { minipage }
}
{
\tl_gput_right:Nn \g_@@_preamble_tl
@@ -11931,7 +12119,7 @@ version 2005/12/01 or later.
\bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box:
#1
\@@_adjust_size_box:
- \makebox [ #4 ] [ #3 ] { \box_use_drop:N \l_@@_cell_box }
+ \makebox [ #4 ] [ #3 ] { \box_use_drop:N \l_@@_cell_box }
}
}
% \end{macrocode}
@@ -12887,7 +13075,7 @@ version 2005/12/01 or later.
{
\dim_compare:nNnTF { \box_wd:N \l_@@_cell_box } > \c_zero_dim
\@@_node_for_cell:
- { \box_use_drop:N \l_@@_cell_box }
+ { \box_use_drop:N \l_@@_cell_box }
\skip_horizontal:N \l_@@_left_delim_dim
\skip_horizontal:N \l_@@_left_margin_dim
\skip_horizontal:N \l_@@_extra_left_margin_dim
@@ -21688,6 +21876,7 @@ version 2005/12/01 or later.
matrix/columns-type,~
notes~(several~subkeys),~
nullify-dots,~
+ pgf-node-code,~
renew-dots,~
renew-matrix,~
respect-arraystretch,~
@@ -21743,13 +21932,13 @@ version 2005/12/01 or later.
light-syntax,~
name,~
nullify-dots,~
+ pgf-node-code,~
renew-dots,~
respect-arraystretch,~
right-margin,~
rules~(with~the~subkeys~'color'~and~'width'),~
small,~
t,~
- tabularnote,~
vlines,~
xdots/color,~
xdots/shorten-start,~
@@ -21806,6 +21995,7 @@ version 2005/12/01 or later.
light-syntax,~
name,~
nullify-dots,~
+ pgf-node-code,~
r,~
renew-dots,~
respect-arraystretch,~
@@ -21867,6 +22057,7 @@ version 2005/12/01 or later.
name,~
notes~(several~subkeys),~
nullify-dots,~
+ pgf-node-code,~
renew-dots,~
respect-arraystretch,~
right-margin,~
@@ -21928,7 +22119,7 @@ version 2005/12/01 or later.
% \subsection*{Changes between version 6.15 and 6.16}
%
% It's now possible to put any LaTeX extensible delimiter (|\lgroup|, |\langle|,
-% etc.) in the preamble of an environment with pramble (such as |{NiceArray}|)
+% etc.) in the preamble of an environment with preamble (such as |{NiceArray}|)
% by prefixing them by |\left| and |\right|.
%
% New key |code| for the command |\SubMatrix| in the |\CodeAfter|.
diff --git a/macros/latex/contrib/nicematrix/nicematrix.pdf b/macros/latex/contrib/nicematrix/nicematrix.pdf
index f9c9e28bb7..3e990cb257 100644
--- a/macros/latex/contrib/nicematrix/nicematrix.pdf
+++ b/macros/latex/contrib/nicematrix/nicematrix.pdf
Binary files differ