summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdfbin466543 -> 470144 bytes
-rw-r--r--Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex248
-rw-r--r--Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdfbin1355018 -> 1377012 bytes
-rw-r--r--Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx1105
-rw-r--r--Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty434
5 files changed, 1185 insertions, 602 deletions
diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf
index 6965309fe96..7a1973e08e3 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 d941d2f9f8a..7d7d915bc38 100644
--- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex
+++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex
@@ -139,7 +139,7 @@ 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
+\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}.\footnote{Si vous utilisez Overleaf, Overleaf effectue
automatiquement le nombre de
@@ -200,19 +200,6 @@ 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.}
-\bigskip
-\textbf{Important}\par\nobreak
-
-Avant la version 5.0, il fallait, pour des raisons techniques, utiliser les
-lettres |L|, |C| et |R| au lieu de |l|, |c| et |r| dans les préambules des
-environnements de \pkg{nicematrix}. Pour pouvoir continuer à utiliser ces
-lettres |L|, |C| et |R|, \pkg{nicematrix} doit être chargé avec l'option
-|define-L-C-R|.
-\begin{Verbatim}
-\usepackage[define-L-C-R]{nicematrix}
-\end{Verbatim}
-\textbf{Cette clé sera probablement supprimée dans une future version de
- \pkg{nicematrix}.}
\section{L'espace vertical entre les rangées}
@@ -512,7 +499,7 @@ $\begin{bNiceArray}{ccc|c}[margin]
\interitem
La commande |\Block| accepte en fait en premier argument optionnel (entre
-crochets) une liste de couples clé-valeur. Les clés sont les suivantes :
+crochets) une liste de couples \textsl{clé=valeur}. Les clés sont les suivantes :
\begin{itemize}
\item les clés |l|, |c| et |r| réglent le positionnement horizontal comme dit
précédemment ;
@@ -589,6 +576,10 @@ 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.
+\colorbox{yellow!50}{\textbf{Nouveau 6.0}}\enskip 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.
+
\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
avoir sa propre spécification d'alignement horizontal).
@@ -1307,8 +1298,8 @@ l'environnement.
\smallskip
De nouvelles commandes sont disponibles dans ce |\CodeBefore|:
-|\cellcolor|, |\rectanglecolor|, |\rowcolor|, |\columncolor|, |\rowcolors|
-|\chessboardcolors| et |\arraycolor|.\footnote{On pourra remarquer que, dans le
+|\cellcolor|, |\rectanglecolor|, |\rowcolor|, |\columncolor|, |\rowcolors|,
+|\rowlistcolors|, |\chessboardcolors| et |\arraycolor|.\footnote{On pourra remarquer que, dans le
\verb|\CodeBefore|, des nœuds PGF/Tikz de la forme \verb+(i-|j)+ correspondant
à la position des filets éventuels sont également accessibles : cf. p.~\pageref{noeuds-i}.}
\label{code-before}
@@ -1590,6 +1581,46 @@ Henri & 14 \\
+
+
+\bigskip
+\item \colorbox{yellow!50}{\textbf{Nouveau 6.0}}\enskip L'extension
+\pkg{nicematrix} propose aussi une commande |\rowlistcolors|. Cette commande
+généralise la commande |\rowcolors|: au lieu de prendre deux arguments
+successifs pour les couleurs, elle prend un seul argument qui est une liste de
+couleurs séparées par des virgules. Dans cette liste, le symbole |=| représente
+une couleur identique à la précédente.
+
+\smallskip
+\begin{BVerbatim}[boxwidth=10cm,baseline=c]
+\begin{NiceTabular}{c}
+\CodeBefore
+ ~emphase#\rowlistcolors{1}{red!15,blue!15,green!15}@
+\Body
+Mathilde \\
+Pierre \\
+Paul \\
+Amélie \\
+Jacques \\
+Antoine \\
+Stéphanie \\
+\end{NiceTabular}
+\end{BVerbatim}
+\begin{NiceTabular}{c}
+\CodeBefore
+ \rowlistcolors{1}{red!15,blue!15,green!15}
+\Body
+Mathilde \\
+Pierre \\
+Paul \\
+Amélie \\
+Jacques \\
+Antoine \\
+Stéphanie \\
+\end{NiceTabular}
+
+\end{itemize}
+
\bigskip
On rappelle que toutes les commandes de coloriage que l'on vient de décrire ne
colorient pas les cases qui sont dans les «coins». Dans l'exemple suivant, on
@@ -1601,7 +1632,7 @@ utilise la clé |corners| pour demander de considérer le coin \emph{north east}
\begin{BVerbatim}[boxwidth=9cm,baseline=c]
\begin{NiceTabular}{cccccc}[~emphase#corners=NE@,margin,hvlines,first-row,first-col]
\CodeBefore
- ~emphase#\rowcolors{1}{blue!15}{}@
+ ~emphase#\rowlistcolors{1}{blue!15, }@
\Body
& 0 & 1 & 2 & 3 & 4 & 5 & 6 \\
0 & 1 \\
@@ -1615,7 +1646,7 @@ utilise la clé |corners| pour demander de considérer le coin \emph{north east}
\end{BVerbatim}
\begin{NiceTabular}{ccccccc}[corners=NE,margin,hvlines,first-row,first-col]
\CodeBefore
- \rowcolors{1}{blue!15}{}
+ \rowlistcolors{1}{blue!15, }
\Body
& 0 & 1 & 2 & 3 & 4 & 5 & 6 \\
0 & 1 \\
@@ -1628,7 +1659,6 @@ utilise la clé |corners| pour demander de considérer le coin \emph{north east}
\end{NiceTabular}
\end{scope}
-\end{itemize}
\bigskip
@@ -1776,9 +1806,11 @@ La commande |\rotate| est présentée p.~\pageref{rotate}.
\section{La largeur des colonnes}
\label{width}
+\subsection{Techniques de base}
+
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}.
+lettres classiques |w|, |W|, |p|, |b| et |m| de l'extension \pkg{array}.
\medskip
\begin{BVerbatim}[baseline=c,boxwidth=9cm]
@@ -1797,8 +1829,9 @@ Rio & Tokyo & Oslo
\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|.
+largeur \emph{minimale} de toutes les colonnes (à l'exception des éventuelles
+colonnes extérieures: cf. p.~\pageref{exterior}) directement avec l'option
+|columns-width|.
\medskip
\begin{BVerbatim}[baseline=c,boxwidth=10cm]
@@ -1824,7 +1857,7 @@ supprimé (il est évidemment possible de le supprimer en mettant |\tabcolsep| o
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 PGF/Tikz écrivant des informations dans le fichier |.aux|,
+ compilation (mais PGF/Tikz écrivant des informations dans le fichier |aux|,
un message demandant une deuxième compilation apparaîtra).}\par\nobreak
\medskip
@@ -1843,7 +1876,7 @@ $\begin{pNiceMatrix}[columns-width = auto]
\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
+colonnes de tous les tableaux dans une certaine portion de document avec la
commande |\NiceMatrixOptions|.\par\nobreak
\medskip
@@ -1907,12 +1940,56 @@ $\begin{array}{c}
\end{NiceMatrixBlock}
+\subsection{Les colonnes X}
+
+\colorbox{yellow!50}{\textbf{Nouveau 6.0}}
+
+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|. La valeur initiale de ce paramètre est |\linewidth|.
+
+Pour se rapprocher davantage de l'environnement |{tabularx}|, \pkg{nicematrix}
+propose aussi un environnement |{NiceTabularX}| qui prend en premier argument
+(obligatoire) la largeur voulue pour le tableau.
+
+Comme avec les extensions \pkg{tabu} 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 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).
+\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}
\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|.
+|last-col|. C'est particulièrement intéressant pour les matrices (mathématiques).
\label{exterior}
Si elle est présente, la «première rangée» (extérieure) est numérotée par $0$
@@ -1970,7 +2047,7 @@ 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
+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
@@ -2466,7 +2543,7 @@ Pour la clarté, dans la suite, on utilisera ces noms-là.
\smallskip
L'option |xdots/color| indique bien entendu la couleur de la ligne tracée. On
remarquera néanmoins que les lignes tracées dans les rangées et colonnes
-extérieures (décrites plus loin) bénificient d'un régime spécial : cf.
+extérieures (décrites plus loin) bénéficient d'un régime spécial : cf.
p.~\pageref{exterior}.
@@ -2545,8 +2622,8 @@ b & a & b & \Ddots & & \Vdots \\
Les lignes pointillées délimitent des blocs virtuels qui ont le même
comportement vis à vis des filets que les blocs créés par |\Block| (les filets
spécifiés par le spécificateur \verb+|+ dans le préambule, la commande |\Hline|
-et par les clés |vlines|, |hlines| et |hvlines| ne sont pas tracés dans les
-blocs).\footnote{En revanche, la commande \verb|\line| dans le \verb|\CodeAfter|
+et par les clés |vlines|, |hlines|, |hvlines| et |hvlines-except-borders| ne
+sont pas tracés dans les blocs).\footnote{En revanche, la commande \verb|\line| dans le \verb|\CodeAfter|
(cf.~p.~\pageref{line-in-code-after}) ne crée pas de bloc.}
\medskip
@@ -2707,7 +2784,7 @@ $\begin{NiceArray}{ccc@{\hspace{1.5em}}c}[cell-space-limits=2pt,margin]
\bigskip
\colorbox{yellow!50}{\bfseries Nouveau 5.18}\enskip La commande |\SubMatrix|
accepte en fait également deux arguments optionnels spécifiés par les symboles
-traditionnels |^| et |_| pour des élements en exposant et en indice.
+traditionnels |^| et |_| pour des éléments en exposant et en indice.
\medskip
\begin{scope}
@@ -3184,14 +3261,14 @@ Pour un exemple de personnalisation des notes de tableau, voir p.~\pageref{ex:no
\subsection{Utilisation de \{NiceTabular\} avec threeparttable}
-Si vous souhaitez utiliser l'environnement |{NiceTabular}| ou |{NiceTabular*}|
-dans un environnement |{threeparttable}| de l'extension éponyme, vous devez
-patcher |{threeparttable}| avec le code suivant (avec une version de LaTeX
-postérieure à 2020/10/01).
+Si vous souhaitez utiliser les environnements |{NiceTabular}|, |{NiceTabular*}|
+ou |{NiceTabularX}| dans un environnement |{threeparttable}| de l'extension
+éponyme, vous devez patcher l'environnement |{threeparttable}| avec le code
+suivant (avec une version de LaTeX postérieure à 2020/10/01).
\begin{Verbatim}[commandchars=\~\#\!]
\makeatletter
\AddToHook{env/threeparttable/begin}
- {\TPT@hookin{NiceTabular}\TPT@hookin{NiceTabular*}}
+ {\TPT@hookin{NiceTabular}\TPT@hookin{NiceTabular*}\TPT@hookin{NiceTabularX}}
\makeatother
\end{Verbatim}
@@ -3369,7 +3446,7 @@ colonne courante\footnote{On rappelle que le numéro de la «première rangée»
existe) est $0$ également.}. 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-before| (cf. p. \pageref{code-before}) et dans le |\CodeAfter|
+Dans le |\CodeBefore| (cf. p. \pageref{code-before}) et dans le |\CodeAfter|
(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).
@@ -3412,8 +3489,8 @@ nommées |\AutoNiceMatrix|, |\pAutoNiceMatrix|, |\bAutoNiceMatrix|,
Chacune de ces commandes prend deux arguments obligatoires : le premier est la
taille de la matrice, sous la forme $n$-$p$, où $n$ est le nombre de rangées et
$p$ est le nombre de colonnes et le deuxième est le motif (c'est-à-dire
-simplement des tokens qui seront insérés dans chaque case de la matrice,
-exceptées celles des éventuelles rangées et colonnes extérieures).
+simplement des tokens qui seront insérés dans chaque case de la matrice).
+
\medskip
\begin{Verbatim}
@@ -4003,78 +4080,99 @@ L'extension \pkg{nicematrix} fournit deux variables internes mais publiques\foot
\end{itemize}
\medskip
-Ces variables constituent le code du «|code-before|» et du «|code-after|». Le
-développeur peut donc les utiliser pour y ajouter du code à partir d'une case
-du tableau (l'affectation devra être globale, ce qui permettra de sortir de la
-case, qui est un groupe au sens de TeX).
+Ces variables constituent le code du «|code-before|» (que l'on rentre souvent
+avec la syntaxte utilisant |\CodeBefore| et |\Body| en début d'environnement et
+du «|code-after|» (que l'on rentre souvent en fin d'environnement après le
+mot-clé |\CodeAfter|). Le développeur peut donc les utiliser pour y ajouter du
+code à partir d'une case du tableau (l'affectation devra être globale, ce qui
+permettra de sortir de la case, qui est un groupe au sens de TeX).
\medskip
On remarquera que l'utilisation de |\g_nicematrix_code_before_tl| nécessite une
compilation supplémentaire (car les instructions sont écrites dans le fichier
|aux| pour être utilisées à la compilation suivante).
-\bigskip
-\emph{Example} : On souhaite écrire une commande |\hatchcell| pour hachurer la
-case courante (avec un argument optionnel entre crochets pour la couleur des
-hachures). Il est possible de programmer une telle commande |\hatchcell| comme
-suit, en utilisant explicitement la variable publique
-|\g_nicematrix_code_before_tl| (ce code nécessite le chargement préalable de la
-bibliothèque Tikz \pkg{patterns} : |\usetikzlibrary{patterns}|).
+
+
+
+\medskip
+\emph{Exemple} : On souhaite écrire une commande |\crossbox| qui barre en croix
+la cellule courante. Cette commande prendra en argument optionnel une liste de
+couples \textsl{clé}-\textsl{valeur} qui sera passée à Tikz avant que la croix
+ne soit tracée.
+
+
+On peut alors programmer cette commande |\crossbox| de la manière suivante, qui
+utilise explicitement la variable publique |\g_nicematrix_code_after_tl|.
\begin{scope}
\fvset{commandchars=\§\¤\μ}
\begin{Verbatim}
\ExplSyntaxOn
-\cs_new_protected:Nn \__pantigny_hatch:nnn
+\cs_new_protected:Nn \__pantigny_crossbox:nnn
{
- \tikz \fill [ pattern = north~west~lines , pattern~color = #3 ]
- ( #1 -| #2) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ;
+ \tikz \draw [ #3 ]
+ ( #1 -| \int_eval:n { #2 + 1 } ) -- ( \int_eval:n { #1 + 1 } -| #2 )
+ ( #1 -| #2 ) -- ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ;
}
-\NewDocumentCommand \hatchcell { ! O { black } }
+\NewDocumentCommand \crossbox { ! O { } }
{
- \tl_gput_right:Nx §emphase¤\g_nicematrix_code_before_tlμ
- { \__pantigny_hatch:nnn { \arabic { iRow } } { \arabic { jCol } } { #1 } }
+ \tl_gput_right:Nx §emphase¤\g_nicematrix_code_after_tlμ
+ {
+ \__pantigny_crossbox:nnn
+ { \int_use:c { c@iRow } }
+ { \int_use:c { c@jCol } }
+ { \exp_not:n { #1 } }
+ }
}
\ExplSyntaxOff
\end{Verbatim}
\end{scope}
+
\ExplSyntaxOn
-\cs_new_protected:Nn \__pantigny_hatch:nnn
+\cs_new_protected:Nn \__pantigny_crossbox:nnn
{
- \tikz \fill [ pattern = north~west~lines , pattern~color = #3 ]
- ( #1 -| #2 ) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ;
+ \tikz \draw [ #3 ]
+ ( #1 -| \int_eval:n { #2 + 1 } ) -- ( \int_eval:n { #1 + 1 } -| #2 )
+ ( #1 -| #2 ) -- ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ;
}
-\NewDocumentCommand \hatchcell { ! O { black } }
+
+\NewDocumentCommand \crossbox { ! O { } }
{
- \tl_gput_right:Nx \g_nicematrix_code_before_tl
- { \__pantigny_hatch:nnn { \arabic { iRow } } { \arabic { jCol } } { #1 } }
+ \tl_gput_right:Nx \g_nicematrix_code_after_tl
+ {
+ \__pantigny_crossbox:nnn
+ { \int_use:c { c@iRow } }
+ { \int_use:c { c@jCol } }
+ { \exp_not:n { #1 } }
+ }
}
\ExplSyntaxOff
-
-
\bigskip
-Voici un exemple d'utilisation.
+Voici un exemple d'utilisation :
\medskip
\begin{BVerbatim}[baseline=c,boxwidth=9cm]
\begin{NiceTabular}{ccc}[hvlines]
-Tokyo & Paris & Londres \\
-Lima & ~emphase#\hatchcell[blue!30]@Oslo & Miami \\
-Los Angeles & Madrid & Rome
+merlan & requin & cabillaud \\
+baleine & ~emphase#\crossbox[red]@ & morue \\
+mante & raie & poule
\end{NiceTabular}
\end{BVerbatim}
\begin{NiceTabular}{ccc}[hvlines]
-Tokyo & Paris & Londres \\
-Lima & \hatchcell[blue!30]Oslo & Miami \\
-Los Angeles & Madrid & Rome
+merlan & requin & cabillaud \\
+baleine & \crossbox[red] & morue \\
+mante & raie & poule
\end{NiceTabular}
+
+
\section{Remarques techniques}
Première remarque : l'extension \pkg{nicematrix} doit être chargée après
@@ -4836,13 +4934,13 @@ a_{41} & a_{42} & a_{43} & \Block[draw]{}{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|, |\Hline|, le spécificateur «\verb+|+» ou les options
-|hlines|, |vlines| et |hvlines| «écartent» les composantes de la
-matrice.\footnote{Pour la commande |\cline|, voir la remarque
+les traits tracés par |\hline|, |\Hline|, le spécificateur «\verb+|+» ou les
+options |hlines|, |vlines|, |hvlines| et |hvlines-except-borders| «écartent» les
+composantes de la matrice.\footnote{Pour la commande |\cline|, voir la remarque
p.~\pageref{remark-cline}.}
\vspace{1cm}
-Il est possible de colorier une rangée avec |\rowcolor| dans le |code-before|
+Il est possible de colorier une rangée avec |\rowcolor| dans le |\CodeBefore|
(ou avec |\rowcolor| dans une case de la rangée si on utilise la clé
|colortbl-like| − même si \pkg{colortbl} n'est pas chargé).
diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf
index db334606dab..12158c89540 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 095a7763900..f2ecb695bc3 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{5.19}
-\def\myfiledate{2021/07/23}
+\def\myfileversion{6.0}
+\def\myfiledate{2021/08/10}
%
%
%<*batchfile>
@@ -188,7 +188,7 @@ version 2005/12/01 or later.
% 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
+% 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}.\footnote{If you use Overleaf, Overleaf will do automatically
% the right number of compilations.}
@@ -250,18 +250,6 @@ version 2005/12/01 or later.
% brackets, an optional list of \textsl{key=value} pairs. \textbf{There must be
% no space before the opening bracket (|[|) of this list of options.}
%
-%\bigskip
-% \textbf{Important}\par\nobreak
-%
-% Before the version 5.0, it was mandatory to use, for technical reasons, the
-% letters |L|, |C| et |R| instead of |l|, |c| et |r| in the preambles of the
-% environments of \pkg{nicematrix}. If we want to be able to go on using these
-% letters, \pkg{nicematrix} must be loaded with the option |define-L-C-R|.
-% \begin{Verbatim}
-% \usepackage[define-L-C-R]{nicematrix}
-% \end{Verbatim}
-% \textbf{This key will probably be deleted in a future version of
-% \pkg{nicematrix}.}
%
% \section{The vertical space between the rows}
%
@@ -633,6 +621,10 @@ 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.
%
+% \colorbox{yellow!50}{\textbf{New 6.0}}\enskip 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.
+%
% \item The specification of the horizontal position provided by the type of
% column (|c|, |r| or |l|) is taken into account for the blocks.
%
@@ -1313,9 +1305,9 @@ version 2005/12/01 or later.
%
% New commands are available in that |\CodeBefore|: |\cellcolor|,
% |\rectanglecolor|, |\rowcolor|, |\columncolor|, |\rowcolors|,
-% |\chessboardcolors| and |arraycolor|.\footnote{Remark that, in the
-% \verb|\CodeBefore|, PGF/Tikz nodes of the form ``\verb+(i-|j)+'' are also
-% available to indicate the position to the potential rules:
+% |\rowlistcolors|, |\chessboardcolors| and |arraycolor|.\footnote{Remark that,
+% in the \verb|\CodeBefore|, PGF/Tikz nodes of the form ``\verb+(i-|j)+'' are
+% also available to indicate the position to the potential rules:
% cf.~p.~\pageref{nodes-i}.}
% \label{code-before}
%
@@ -1582,19 +1574,58 @@ version 2005/12/01 or later.
% \end{scope}
%
%
+%
+%
+% \bigskip
+% \item \colorbox{yellow!50}{\textbf{New 6.0}}\enskip The extension
+% \pkg{nicematrix} provides also a command |\rowlistcolors|. This command
+% generalises the command |\rowcolors|: instead of two successive arguments for
+% the colors, this command takes in an argument which is a (comma-separated)
+% list of colors. In that list, the symbol |=| represent a color identical to
+% the previous one.
+% \end{itemize}
+%
+% \smallskip
+% \begin{BVerbatim}[boxwidth=10cm,baseline=c]
+% \begin{NiceTabular}{c}
+% \CodeBefore
+% ~emphase#\rowlistcolors{1}{red!15,blue!15,green!15}@
+% \Body
+% Peter \\
+% James \\
+% Abigail \\
+% Elisabeth \\
+% Claudius \\
+% Jane \\
+% Alexandra \\
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \begin{NiceTabular}{c}
+% \CodeBefore
+% \rowlistcolors{1}{red!15,blue!15,green!15}
+% \Body
+% Peter \\
+% James \\
+% Abigail \\
+% Elisabeth \\
+% Claudius \\
+% Jane \\
+% Alexandra \\
+% \end{NiceTabular}
+%
+%
% \medskip
% We recall that all the color commands we have described don't color the cells
% which are in the ``corners''. In the following example, we use the key
% |corners| to require the determination of the corner \emph{north east} (NE).
%
-%
%\medskip
% \begin{scope}
% \hfuzz=11cm
% \begin{BVerbatim}[boxwidth=9cm,baseline=c]
% \begin{NiceTabular}{cccccc}[~emphase#corners=NE@,margin,hvlines,first-row,first-col]
% \CodeBefore
-% ~emphase#\rowcolors{1}{blue!15}{}@
+% ~emphase#\rowlistcolors{1}{blue!15, }@
% \Body
% & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\
% 0 & 1 \\
@@ -1608,7 +1639,7 @@ version 2005/12/01 or later.
% \end{BVerbatim}
% \begin{NiceTabular}{ccccccc}[corners=NE,margin,hvlines,first-row,first-col]
% \CodeBefore
-% \rowcolors{1}{blue!15}{}
+% \rowlistcolors{1}{blue!15, }
% \Body
% & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\
% 0 & 1 \\
@@ -1621,8 +1652,6 @@ version 2005/12/01 or later.
% \end{NiceTabular}
% \end{scope}
%
-% \end{itemize}
-%
%
% \bigskip
% One should remark that all the previous commands are compatible with the
@@ -1765,9 +1794,11 @@ version 2005/12/01 or later.
% \section{The width of the columns}
% \label{width}
%
+% \subsection{Basic tools}
+%
% 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}.
+% the standard letters |w|, |W|, |p|, |b| and |m| of the package \pkg{array}.
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
@@ -1786,7 +1817,8 @@ version 2005/12/01 or later.
%
% \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|.
+% width of all the columns (excepted the potential exterior columns: cf. p.~\pageref{exterior}) directly
+% with the key |columns-width|.
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
@@ -1812,7 +1844,7 @@ version 2005/12/01 or later.
% 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 PGF/Tikz
-% will have written informations in the |.aux| file and a message requiring a
+% will have written informations in the |aux| file and a message requiring a
% second compilation will appear).}\par\nobreak
%
% \medskip
@@ -1831,7 +1863,7 @@ version 2005/12/01 or later.
%
% \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
+% the arrays of a current scope with the command
% |\NiceMatrixOptions|.\par\nobreak
%
% \medskip
@@ -1892,13 +1924,57 @@ version 2005/12/01 or later.
% \end{array}$
% \end{NiceMatrixBlock}
%
+% \subsection{The columns X}
+%
+% \colorbox{yellow!50}{\textbf{New 6.0}}
+%
+% 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|. The
+% initial value of this parameter is |\linewidth|.
+%
+% For sake of similarity with the environment |{tabularx}|, \pkg{nicematrix}
+% also provides an environment |{NiceTabularX}| with a first mandatory argument
+% which is the width of the tabular.
+%
+% As with the packages \pkg{tabu} 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 an 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$).
+% \item It's possible to specify an horizontal alignment with one of the
+% letters |l|, |c| and |r| (which inserts respectively |\raggedright|,
+% |\centering| and |\raggedleft| followed by |\arraybackslash|).
+% \item It's possible to specify a vertical alignement 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}
%
% 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}.
+% \pkg{nicematrix}. It's particularly interesting for the (methematical)
+% matrices.
% \label{exterior}
%
% A potential ``first row'' (exterior) has the number $0$ (and not $1$). Idem
@@ -2007,7 +2083,7 @@ version 2005/12/01 or later.
% \emph{Remarks}
% \begin{itemize}[beginpenalty=10000]
% \item As shown in the previous example, the horizontal and vertical rules
-% doesn't extend in the exterior rows and columns.
+% don'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
@@ -2015,7 +2091,7 @@ version 2005/12/01 or later.
% 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
+% a dotted line drawn in that 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
@@ -2053,7 +2129,7 @@ version 2005/12/01 or later.
% horizontal line; for |\Vdots|, it's a vertical line and for |\Ddots| and
% |\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
+% all these dotted lines with the option |xdots/color| (\textsl{xdots} to
% remind that it works for |\Cdots|, |\Ldots|, |\Vdots|, etc.): cf. p.
% \pageref{customisation}.}\par\nobreak
%
@@ -2513,10 +2589,11 @@ version 2005/12/01 or later.
%
% The dotted lines determine virtual blocks which have the same behaviour
% regarding the rules (the rules specified by the specifier \verb+|+ in the
-% preamble, by the command |\Hline| and by the keys |hlines|, |vlines| and
-% |hvlines| are not drawn within the blocks).\footnote{On the other side, the
-% command \verb|\line| in the \verb|\CodeAfter|
-% (cf.~p.~\pageref{line-in-code-after}) does \emph{not} create block.}
+% preamble, by the command |\Hline| and by the keys |hlines|, |vlines|,
+% |hvlines| and |hvlines-except-borders| are not drawn within the
+% blocks).\footnote{On the other side, the command \verb|\line| in the
+% \verb|\CodeAfter| (cf.~p.~\pageref{line-in-code-after}) does \emph{not} create
+% block.}
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
@@ -3140,14 +3217,14 @@ version 2005/12/01 or later.
% \subsection{Use of \{NiceTabular\} with threeparttable}
%
%
-% If you wish to use the environment |{NiceTabular}| or |{NiceTabular*}| in an
-% environment |{threeparttable}| of the eponymous package, you have to patch the
-% environment |{threeparttable}| with the following code (with a version of
-% LaTeX at least 2020/10/01).
+% If you wish to use the environment |{NiceTabular}|, |{NiceTabular*}|
+% |{NiceTabularX}|in an environment |{threeparttable}| of the eponymous package,
+% you have to patch the environment |{threeparttable}| with the following code
+% (with a version of LaTeX at least 2020/10/01).
% \begin{Verbatim}[commandchars=\~\#\!]
% \makeatletter
% \AddToHook{env/threeparttable/begin}
-% {\TPT@hookin{NiceTabular}\TPT@hookin{NiceTabular*}}
+% {\TPT@hookin{NiceTabular}\TPT@hookin{NiceTabular*}\TPT@hookin{NiceTabularX}}
% \makeatother
% \end{Verbatim}
%
@@ -3373,8 +3450,7 @@ version 2005/12/01 or later.
% These commands take in two mandatory arguments. The first is the format of the
% matrix, with the syntax $n$-$p$ where $n$ is the number of rows and $p$ the
% number of columns. The second argument is the pattern (it's a list of tokens
-% which are inserted in each cell of the constructed matrix, excepted in the
-% cells of the potential exterior rows and columns).
+% which are inserted in each cell of the constructed matrix).
%
% \medskip
% \begin{Verbatim}
@@ -3953,9 +4029,11 @@ version 2005/12/01 or later.
%
% \medskip
% These variables contain the code of what we have called the ``|code-before|''
-% and the ``|code-after|''. The developper can use them to add code from a cell
-% of the array (the affectation must be global, allowing to exit the cell, which
-% is a TeX group).
+% (usually specified at the beginning of the environment with the syntax using
+% the keywords |\CodeBefore| and |\Body|) and the ``|code-after|'' (usually
+% specified at the end of the environment after the keyword |\CodeAfter|). The
+% developper can use them to add code from a cell of the array (the affectation
+% must be global, allowing to exit the cell, which is a TeX group).
%
% \medskip
% One should remark that the use of |\g_nicematrix_code_before_tl| needs one
@@ -3963,27 +4041,34 @@ version 2005/12/01 or later.
% used during the next run).
%
% \bigskip
-% \emph{Example} : We want to write a command |\hatchcell| to hatch the current
-% cell (with an optional argument between brackets for the color). It's possible
-% to program such command |\hatchcell| as follows, explicitely using the public
-% variable |\g_nicematrix_code_before_tl| (this code requires the Tikz library
-% \pkg{patterns}: |\usetikzlibrary{patterns}|).
+% \emph{Example} : We want to write a command |\crossbox| to draw a cross in the
+% current cell. This command will take in an optional argument between square
+% brackets for a list of pairs \textsl{key}-\textsl{value} which will be given to
+% Tikz before the drawing.
%
+% It's possible to program such command |\crossbox| as follows, explicitely
+% using the public variable |\g_nicematrix_code_after_tl|.
%
% \begin{scope}
% \fvset{commandchars=\§\¤\μ}
% \begin{Verbatim}
-%\ExplSyntaxOn
-% \cs_new_protected:Nn \__pantigny_hatch:nnn
+% \ExplSyntaxOn
+% \cs_new_protected:Nn \__pantigny_crossbox:nnn
% {
-% \tikz \fill [ pattern = north~west~lines , pattern~color = #3 ]
-% ( #1 -| #2) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ;
+% \tikz \draw [ #3 ]
+% ( #1 -| \int_eval:n { #2 + 1 } ) -- ( \int_eval:n { #1 + 1 } -| #2 )
+% ( #1 -| #2 ) -- ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ;
% }
%
-% \NewDocumentCommand \hatchcell { ! O { black } }
+% \NewDocumentCommand \crossbox { ! O { } }
% {
-% \tl_gput_right:Nx §emphase¤\g_nicematrix_code_before_tlμ
-% { \__pantigny_hatch:nnn { \arabic { iRow } } { \arabic { jCol } } { #1 } }
+% \tl_gput_right:Nx §emphase¤\g_nicematrix_code_after_tlμ
+% {
+% \__pantigny_crossbox:nnn
+% { \int_use:c { c@iRow } }
+% { \int_use:c { c@jCol } }
+% { \exp_not:n { #1 } }
+% }
% }
% \ExplSyntaxOff
% \end{Verbatim}
@@ -3991,38 +4076,45 @@ version 2005/12/01 or later.
%
%
% \ExplSyntaxOn
-% \cs_new_protected:Nn \__pantigny_hatch:nnn
+% \cs_new_protected:Nn \__pantigny_crossbox:nnn
% {
-% \tikz \fill [ pattern = north~west~lines , pattern~color = #3 ]
-% ( #1 -| #2 ) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ;
+% \tikz \draw [ #3 ]
+% ( #1 -| \int_eval:n { #2 + 1 } ) -- ( \int_eval:n { #1 + 1 } -| #2 )
+% ( #1 -| #2 ) -- ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ;
% }
%
-% \NewDocumentCommand \hatchcell { ! O { black } }
+%
+% \NewDocumentCommand \crossbox { ! O { } }
% {
-% \tl_gput_right:Nx \g_nicematrix_code_before_tl
-% { \__pantigny_hatch:nnn { \arabic { iRow } } { \arabic { jCol } } { #1 } }
+% \tl_gput_right:Nx \g_nicematrix_code_after_tl
+% {
+% \__pantigny_crossbox:nnn
+% { \int_use:c { c@iRow } }
+% { \int_use:c { c@jCol } }
+% { \exp_not:n { #1 } }
+% }
% }
% \ExplSyntaxOff
%
-%
% \bigskip
-% Here is an example of use:
+% Here is an example of utilisation:
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
% \begin{NiceTabular}{ccc}[hvlines]
-% Tokyo & Paris & London \\
-% Lima & ~emphase#\hatchcell[blue!30]@Oslo & Miami \\
-% Los Angeles & Madrid & Roma
+% merlan & requin & cabillaud \\
+% baleine & ~emphase#\crossbox[red]@ & morue \\
+% mante & raie & poule
% \end{NiceTabular}
% \end{BVerbatim}
% \begin{NiceTabular}{ccc}[hvlines]
-% Tokyo & Paris & London \\
-% Lima & \hatchcell[blue!30]Oslo & Miami \\
-% Los Angeles & Madrid & Roma
+% merlan & requin & cabillaud \\
+% baleine & \crossbox[red] & morue \\
+% mante & raie & poule
% \end{NiceTabular}
%
%
+%
% \section{Technical remarks}
%
% \subsection{Definition of new column types}
@@ -4076,7 +4168,7 @@ version 2005/12/01 or later.
%
% \label{parallelization}
% By default, all the diagonal lines\footnote{We speak of the lines created by
-% |\Ddots| and not the lines created by a command |\line| in |code-after|.} of a
+% |\Ddots| and not the lines created by a command |\line| in the |\CodeAfter|.} of a
% same array are ``parallelized''. That means that the first diagonal line is
% drawn and, then, the other lines are drawn parallel to the first one (by
% rotation around the left-most extremity of the line). That's why the position
@@ -4233,7 +4325,7 @@ version 2005/12/01 or later.
%
%
% \bigskip
-% the package \pkg{nicematrix} is not compatible with the class \cls{ieeeaccess}
+% The package \pkg{nicematrix} is not compatible with the class \cls{ieeeaccess}
% (because that class is not compatible with PGF/Tikz).
%
% \section{Examples}
@@ -4767,10 +4859,10 @@ 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 commands |\hline| and |\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}.}
+% We recall that, on the other side, the commands |\hline| and |\Hline|, the
+% specifier ``"|"'' and the options |hlines|, |vlines|, |hvlines| and
+% |hvlines-except-borders| spread the cells.\footnote{For the command |\cline|,
+% see the remark p.~\pageref{remark-cline}.}
%
%
% \vspace{1cm}
@@ -5255,9 +5347,7 @@ version 2005/12/01 or later.
\AtBeginDocument
{
\@ifpackageloaded { colortbl }
- {
- \bool_set_true:N \c_@@_colortbl_loaded_bool
- }
+ { \bool_set_true:N \c_@@_colortbl_loaded_bool }
{
% \end{macrocode}
% The command |\CT@arc@| is a command of \pkg{colortbl} which sets the color of
@@ -5294,7 +5384,17 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
-%
+% \bigskip
+% We will use |\AtBeginEnvironment|. For version of LaTeX posterior to
+% 2020-10-01, the command is available in the LaTeX kernel (\pkg{l3hooks}). For
+% older versions, we load \pkg{etoolbox}.
+% \begin{macrocode}
+\cs_if_exist:NF \AtBeginEnvironment { \RequirePackage { etoolbox } }
+% \end{macrocode}
+% The command |\AtBeginDocument| will be used to patch |{tabular}| in order to
+% come back to the original versions of |\multicolumn| in the |{tabular}| nested
+% in the environments of \pkg{nicematrix}.
+%
% \bigskip
% We have to redefine |\cline| for several reasons. The command |\@@_cline| will
% be linked to |\cline| in the beginning of |{NiceArrayWithDelims}|. The
@@ -5515,26 +5615,6 @@ version 2005/12/01 or later.
% \subsection*{Parameters}
%
% \bigskip
-% For compatibility with versions prior to 5.0, we provide a load-time option
-% |define_L_C_R|. With this option, it's possible to use the letters |L|, |C|
-% and |R| instead of |l|, |c| and |r| in the preamble of the environments of
-% \pkg{nicematrix} as it was mandatory before version~5.0. This key will
-% probably be deleted in a future version.
-% \begin{macrocode}
-\bool_new:N \c_@@_define_L_C_R_bool
-% \end{macrocode}
-%
-%
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_define_L_C_R:
- {
- \newcolumntype L l
- \newcolumntype C c
- \newcolumntype R r
- }
-% \end{macrocode}
-%
-% \bigskip
% The following counter will count the environments |{NiceArray}|. The value of
% this counter will be used to prefix the names of the Tikz nodes created in the
% array.
@@ -5586,6 +5666,19 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
+% The dimension |\l_@@_col_width_dim| will be available in each cell which
+% belongs to a column of fixed width: |w{...}{...}|, |W{...}{...}|, |p{}|,
+% |m{}|, |b{}| but also |X| (when the actual width of that column is known, that
+% is to say after the first compilation). It's the width of that column. It will
+% be used by some commands |\Block|. A non positive value means that the column
+% has no fixed width (it's a column of type |c|, |r|, |l|, etc.).
+% \begin{macrocode}
+\dim_new:N \l_@@_col_width_dim
+\dim_set:Nn \l_@@_col_width_dim { -1 cm }
+% \end{macrocode}
+%
+%
+% \bigskip
% The following counters will be used to count the numbers of rows and columns
% of the array.
% \begin{macrocode}
@@ -5594,11 +5687,13 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% The following token list will contain the type of the current cell (|l|, |c|
-% or |r|). It will be used by the blocks.
+% The following token list will contain the type of horizontal alignment of the
+% current cell as provided by the corresponding column. The possible values are
+% |r|, |l|, |c|. For exemple, a column |p[l]{3cm}| will provide the value |l|
+% for all the cells of the column.
% \begin{macrocode}
-\tl_new:N \l_@@_cell_type_tl
-\tl_set:Nn \l_@@_cell_type_tl { c }
+\str_new:N \l_@@_hpos_cell_str
+\str_set:Nn \l_@@_hpos_cell_str { c }
% \end{macrocode}
%
% \bigskip
@@ -5672,6 +5767,13 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
+% In a cell, it will be possible to know whether we are in a cell of a column of
+% type |X| thanks to that flag.
+% \begin{macrocode}
+\bool_new:N \l_@@_X_column_bool
+% \end{macrocode}
+%
+% \bigskip
% We will write in |\g_@@_aux_tl| all the instructions that we have to write on
% the |aux| file for the current environment. The contain of that token list
% will be written on the |aux| file at the end of the environment (in an
@@ -5786,16 +5888,19 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% The number of letters |X| in the preamble of the array.
+% The sum of the weights of all the |X|-columns in the preamble. The weight of a
+% |X|-column is given as optional argument between square brackets. The default
+% value, of course, is $1$.
% \begin{macrocode}
-\int_new:N \g_@@_nb_of_X_int
+\int_new:N \g_@@_total_X_weight_int
% \end{macrocode}
%
% If there is at least one |X|-column in the preamble of the array, the
% following flag will be raised via the |aux| file. The length
-% |l_@@_x_columns_dim| will be the width of the |X|-columns. That value is
-% computed after the contruction of the array during the first compilation in
-% order to be used in the following run.
+% |l_@@_x_columns_dim| will be the width of |X|-columns of weight $1$ (the width
+% of a column of weigth $n$ will be that dimension multiplied by~$n$). That
+% value is computed after the construction of the array during the first
+% compilation in order to be used in the following run.
% \begin{macrocode}
\bool_new:N \l_@@_X_columns_aux_bool
\dim_new:N \l_@@_X_columns_dim
@@ -5947,7 +6052,14 @@ version 2005/12/01 or later.
% \begin{macrocode}
\seq_new:N \g_@@_submatrix_names_seq
% \end{macrocode}
-%
+%
+% \medskip
+% The following flag will be raised if the key |width| has been raised. You use
+% it to raise an error when this key is used while no column |X| is used.
+% \begin{macrocode}
+\bool_new:N \l_@@_width_used_bool
+% \end{macrocode}
+%
% \medskip
% The sequence |\g_@@_multicolumn_cells_seq| will contain the list of the cells
% of the array where a command |\multicolumn{|$n$|}{...}{...}| with $n>1$ is
@@ -6024,8 +6136,8 @@ version 2005/12/01 or later.
% |\l_@@_hpos_of_block_cap_bool| will be raised (in the second pass of the
% analyze of the keys of the command |\Block|).
% \begin{macrocode}
-\tl_new:N \l_@@_hpos_of_block_tl
-\tl_set:Nn \l_@@_hpos_of_block_tl { c }
+\str_new:N \l_@@_hpos_block_str
+\str_set:Nn \l_@@_hpos_block_str { c }
\bool_new:N \l_@@_hpos_of_block_cap_bool
% \end{macrocode}
%
@@ -6801,9 +6913,9 @@ version 2005/12/01 or later.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / Env }
{
-
% \end{macrocode}
-% The key |hvlines-except-corners| is now deprecated.
+% The key |hvlines-except-corners| is now deprecated (use |hvlines| and
+% |corners| instead).
% \begin{macrocode}
hvlines-except-corners .code:n =
{
@@ -7157,6 +7269,12 @@ version 2005/12/01 or later.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / NiceTabular }
{
+% \end{macrocode}
+% The dimension |width| will be used if at least a column of type |X| is used.
+% \begin{macrocode}
+ width .code:n = \dim_set:Nn \l_@@_width_dim { #1 }
+ \bool_set_true:N \l_@@_width_used_bool ,
+ width .value_required:n = true ,
notes / para .bool_set:N = \l_@@_notes_para_bool ,
notes / para .default:n = true ,
notes / bottomrule .bool_set:N = \l_@@_notes_bottomrule_bool ,
@@ -7184,12 +7302,12 @@ version 2005/12/01 or later.
\cs_new_protected:Npn \@@_Cell:
{
% \end{macrocode}
-% The token list |\g_@@_post_treatment_cell_tl| will be set during the
+% The token list |\g_@@_post_action_cell_tl| will be set during the
% composition of the box |\l_@@_cell_box| and will be used \emph{after} the
% composition in order to modify that box (that's why it's called a
-% \emph{post-treatment}).
+% \emph{post-action}).
% \begin{macrocode}
- \tl_gclear:N \g_@@_post_treatment_cell_tl
+ \tl_gclear:N \g_@@_post_action_cell_tl
% \end{macrocode}
% At the beginning of the cell, we link |\CodeAfter| to a command which do
% \emph{not} begin with |\omit| (whereas the standard version of |\CodeAfter|
@@ -7349,11 +7467,11 @@ version 2005/12/01 or later.
\@@_math_toggle_token:
\hbox_set_end:
% \end{macrocode}
-% The token list |\g_@@_post_treatment_cell_tl| is (potentially) set during the
+% The token list |\g_@@_post_action_cell_tl| is (potentially) set during the
% composition of the box |\l_@@_cell_box| and is used now \emph{after} the
% composition in order to modify that box.
% \begin{macrocode}
- \g_@@_post_treatment_cell_tl
+ \g_@@_post_action_cell_tl
\bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box:
\@@_adjust_size_box:
% \end{macrocode}
@@ -7856,7 +7974,6 @@ version 2005/12/01 or later.
\cs_set_eq:NN \Hspace \@@_Hspace:
\cs_set_eq:NN \Hdotsfor \@@_Hdotsfor:
\cs_set_eq:NN \Vdotsfor \@@_Vdotsfor:
- \cs_set_eq:NN \multicolumn \@@_multicolumn:nnn
\cs_set_eq:NN \Block \@@_Block:
\cs_set_eq:NN \rotate \@@_rotate:
\cs_set_eq:NN \OnlyMainNiceMatrix \@@_OnlyMainNiceMatrix:n
@@ -7868,6 +7985,18 @@ version 2005/12/01 or later.
\bool_if:NT \l_@@_colortbl_like_bool \@@_colortbl_like:
\bool_if:NT \l_@@_renew_dots_bool \@@_renew_dots:
% \end{macrocode}
+% We redefine |\multicolumn| and, since we want |\multicolumn| to be available
+% in the potential environments |{tabular}| nested in the environments of
+% \pkg{nicematrix}, we patch |{tabular}| to go back to the original definition.
+% The command |\AtBeginEnvironment| is the command of \pkg{l3hooks} and, if this
+% command is not available (versions of LaTeX prior to 2020-10-01),
+% \pkg{etoolbox} is loaded and the command |\AtBeginDocument| of \pkg{etoolbox}
+% is used.
+% \begin{macrocode}
+ \cs_set_eq:NN \multicolumn \@@_multicolumn:nnn
+ \AtBeginEnvironment { tabular }
+ { \cs_set_eq:NN \multicolumn \@@_old_multicolumn }
+% \end{macrocode}
%
%
% The sequence |\g_@@_multicolumn_cells_seq| will contain the list of the cells
@@ -8029,14 +8158,6 @@ version 2005/12/01 or later.
\box_clear_new:N \l_@@_the_array_box
% \end{macrocode}
%
-% \bigskip
-% If the user has loaded |nicematrix| with the option |define-L-C-R|, he will be
-% able to use |L|, |C| and |R| instead of |l|, |c| and |r| in the preambles of
-% the environments of \pkg{nicematrix} (it's a compatibility mode since |L|, |C|
-% and |R| were mandatory before version 5.0).
-% \begin{macrocode}
- \bool_if:NT \c_@@_define_L_C_R_bool \@@_define_L_C_R:
-% \end{macrocode}
%
% \bigskip
% The preamble will be constructed in |\g_@@_preamble_tl|.
@@ -8112,7 +8233,7 @@ version 2005/12/01 or later.
{
\tl_gput_right:Nn \g_@@_row_style_tl
{
- \tl_gput_right:Nn \g_@@_post_treatment_cell_tl
+ \tl_gput_right:Nn \g_@@_post_action_cell_tl
{ \dim_set:Nn \l_@@_cell_space_top_limit_dim { #1 } }
}
} ,
@@ -8121,7 +8242,7 @@ version 2005/12/01 or later.
{
\tl_gput_right:Nn \g_@@_row_style_tl
{
- \tl_gput_right:Nn \g_@@_post_treatment_cell_tl
+ \tl_gput_right:Nn \g_@@_post_action_cell_tl
{ \dim_set:Nn \l_@@_cell_space_bottom_limit_dim { #1 } }
}
} ,
@@ -8223,6 +8344,7 @@ version 2005/12/01 or later.
\cs_set_eq:NN \roundedrectanglecolor \@@_roundedrectanglecolor
\cs_set_eq:NN \rowcolor \@@_rowcolor
\cs_set_eq:NN \rowcolors \@@_rowcolors
+ \cs_set_eq:NN \rowlistcolors \@@_rowlistcolors
\cs_set_eq:NN \arraycolor \@@_arraycolor
\cs_set_eq:NN \columncolor \@@_columncolor
\cs_set_eq:NN \chessboardcolors \@@_chessboardcolors
@@ -8351,6 +8473,9 @@ version 2005/12/01 or later.
\NewDocumentEnvironment { NiceArrayWithDelims }
{ m m O { } m ! O { } t \CodeBefore }
{
+% \end{macrocode}
+%
+% \begin{macrocode}
\@@_provide_pgfsyspdfmark:
\bool_if:NT \c_@@_footnote_bool \savenotes
% \end{macrocode}
@@ -8507,18 +8632,31 @@ version 2005/12/01 or later.
% End of the construction of the array (in the box |\l_@@_the_array_box|).
%
% \bigskip
+% If the user has used the key |width| without any column |X|, we raise an error.
+% \begin{macrocode}
+ \bool_if:NT \l_@@_width_used_bool
+ {
+ \int_compare:nNnT \g_@@_total_X_weight_int = 0
+ { \@@_error:n { width~without~X~columns } }
+ }
+% \end{macrocode}
+%
+% \bigskip
% Now, if there is at least one |X|-column in the environment, we compute the
-% width that those columns will have (in the next compilation).
+% width that those columns will have (in the next compilation). In fact,
+% |l_@@_X_columns_dim| will the the width of a column of weight $1$. For a
+% |X|-column of weight~$n$, the width will be |l_@@_X_columns_dim| multiplied
+% by~$n$.
% \begin{macrocode}
- \int_compare:nNnT \g_@@_nb_of_X_int > 0
+ \int_compare:nNnT \g_@@_total_X_weight_int > 0
{
\bool_if:NTF \l_@@_X_columns_aux_bool
{ \dim_set_eq:NN \l_tmpa_dim \l_@@_X_columns_dim }
{
\dim_set:Nn \l_tmpa_dim
{
- ( \textwidth - \box_wd:N \l_@@_the_array_box )
- / \int_use:N \g_@@_nb_of_X_int
+ ( \l_@@_width_dim - \box_wd:N \l_@@_the_array_box )
+ / \int_use:N \g_@@_total_X_weight_int
}
}
\tl_gput_right:Nx \g_@@_aux_tl
@@ -8823,7 +8961,7 @@ version 2005/12/01 or later.
% \end{macrocode}
% The number of letters |X| in the preamble of the array.
% \begin{macrocode}
- \int_gzero:N \g_@@_nb_of_X_int
+ \int_gzero:N \g_@@_total_X_weight_int
% \end{macrocode}
% The sequence |\g_@@_cols_vlsim_seq| will contain the numbers of the columns
% where you will to have to draw vertical lines in the potential sub-matrices
@@ -8932,9 +9070,9 @@ version 2005/12/01 or later.
! { \@@_patch_preamble_ii:nn #1 }
@ { \@@_patch_preamble_ii:nn #1 }
| { \@@_patch_preamble_iii:n #1 }
- p { \@@_patch_preamble_iv:nnn t #1 }
- b { \@@_patch_preamble_iv:nnn b #1 }
- m { \@@_patch_preamble_iv:nnn b #1 }
+ p { \@@_patch_preamble_iv:n #1 }
+ b { \@@_patch_preamble_iv:n #1 }
+ m { \@@_patch_preamble_iv:n #1 }
\@@_w: { \@@_patch_preamble_v:nnnn { } #1 }
\@@_W: { \@@_patch_preamble_v:nnnn { \cs_set_eq:NN \hss \hfil } #1 }
\@@_true_c: { \@@_patch_preamble_vi:n #1 }
@@ -8944,10 +9082,7 @@ version 2005/12/01 or later.
) { \@@_patch_preamble_viii:nn #1 }
] { \@@_patch_preamble_viii:nn #1 }
\} { \@@_patch_preamble_viii:nn #1 }
- X { \@@_patch_preamble_xii: }
- C { \@@_error:nn { old~column~type } #1 }
- L { \@@_error:nn { old~column~type } #1 }
- R { \@@_error:nn { old~column~type } #1 }
+ X { \@@_patch_preamble_ix:n }
\q_stop { }
}
{
@@ -8984,7 +9119,7 @@ version 2005/12/01 or later.
{
\tl_gput_right:Nn \g_@@_preamble_tl
{
- > { \@@_Cell: \tl_set:Nn \l_@@_cell_type_tl { #1 } }
+ > { \@@_Cell: \str_set:Nn \l_@@_hpos_cell_str { #1 } }
#1
< \@@_end_Cell:
}
@@ -9055,16 +9190,143 @@ version 2005/12/01 or later.
\bool_new:N \l_@@_bar_at_end_of_pream_bool
% \end{macrocode}
%
+% \bigskip
+% The specifier |p| (and also the specifiers |m| and |b|) have an optional
+% argument between square brackets for a list of \emph{key}-\emph{value} pairs.
+% Here are the corresponding keys. This set of keys will also be used by the |X|
+% columns.
+% \begin{macrocode}
+\keys_define:nn { WithArrows / p-column }
+ {
+ r .code:n = \str_set:Nn \l_@@_hpos_col_str { r } ,
+ r .value_forbidden:n = true ,
+ c .code:n = \str_set:Nn \l_@@_hpos_col_str { c } ,
+ c .value_forbidden:n = true ,
+ l .code:n = \str_set:Nn \l_@@_hpos_col_str { l } ,
+ l .value_forbidden:n = true ,
+ p .code:n = \str_set:Nn \l_@@_vpos_col_str { p } ,
+ p .value_forbidden:n = true ,
+ t .meta:n = p ,
+ m .code:n = \str_set:Nn \l_@@_vpos_col_str { m } ,
+ m .value_forbidden:n = true ,
+ b .code:n = \str_set:Nn \l_@@_vpos_col_str { b } ,
+ b .value_forbidden:n = true
+ }
+% \end{macrocode}
+%
+%
+% \medskip
+% For |p|, |b| and |m|. The argument |#1| is that value : |p|, |b| or |m|.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_preamble_iv:n #1
+ {
+ \str_set:Nn \l_@@_vpos_col_str { #1 }
+% \end{macrocode}
+% Now, you look for a potential character |[| after the letter of the specifier
+% (for the options).
+% \begin{macrocode}
+ \@@_patch_preamble_iv_i:n
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_preamble_iv_i:n #1
+ {
+ \str_if_eq:nnTF { #1 } { [ }
+ { \@@_patch_preamble_iv_ii:w [ }
+ { \@@_patch_preamble_iv_ii:w [ ] { #1 } }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_preamble_iv_ii:w [ #1 ]
+ { \@@_patch_preamble_iv_iii:nn { #1 } }
+% \end{macrocode}
+%
% \medskip
-% For |p| and |b|
+% |#1| is the optional argument of the specifier (a list of
+% \emph{key}-\emph{value} pairs).
+%
+% |#2| is the mandatory argument of the specifier: the width of the column.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_patch_preamble_iv:nnn #1 #2 #3
+\cs_new_protected:Npn \@@_patch_preamble_iv_iii:nn #1 #2
{
+% \end{macrocode}
+% The possible values of |\l_@@_hpos_col_str| are |j| (for \emph{justified} which is
+% the initial value), |l|, |c| and |r| (when the user has used the corresponding
+% key in the optional argument of the specifier).
+% \begin{macrocode}
+ \str_set:Nn \l_@@_hpos_col_str { j }
+ \keys_set:nn { WithArrows / p-column } { #1 }
+ \@@_patch_preamble_iv_iv:n { #2 }
+ }
+% \end{macrocode}
+%
+% \medskip
+% The argument is the width of the column.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_preamble_iv_iv:n #1
+ {
+ \use:x
+ {
+ \@@_patch_preamble_iv_v:nnnn
+ { \str_if_eq:VnTF \l_@@_vpos_col_str { p } { t } { b } }
+ { \dim_eval:n { #1 } }
+ {
+% \end{macrocode}
+% The parameter |\l_@@_hpos_col_str| (as |\l_@@_vpos_col_str|) exists only
+% during the contruction of the preamble. During the composition of the array
+% itself, you will have, in each cell, the parameter |\l_@@_hpos_cell_str| which
+% will provide
+% \begin{macrocode}
+ \str_if_eq:VnTF \l_@@_hpos_col_str j
+ { \str_set:Nn \exp_not:N \l_@@_hpos_cell_str { c } }
+ { \str_set:Nn \exp_not:N \l_@@_hpos_cell_str \l_@@_hpos_col_str }
+ \str_case:Vn \l_@@_hpos_col_str
+ {
+ c { \exp_not:N \centering }
+ l { \exp_not:N \raggedright }
+ r { \exp_not:N \raggedleft }
+ }
+ }
+ { \str_if_eq:VnT \l_@@_vpos_col_str { m } \@@_center_cell_box: }
+ }
+% \end{macrocode}
+%
+% We increment the counter of columns, and then we test for the presence of a |<|.
+% \begin{macrocode}
+ \int_gincr:N \c@jCol
+ \@@_patch_preamble_x:n
+ }
+% \end{macrocode}
+%
+% \medskip
+% |#1| is the optional argument of |{minipage}|: |t| of |b|. Indeed, for the
+% columns of type |m|, we use the value |b| here because there is a special
+% post-action in order to center vertically the box (see |#4|).
+%
+% |#2| is the width of the |{minipage}|, that is to say also the width of the
+% column.
+%
+% |#3| is the coding for the horizontal position of the content of the cell
+% (|\centering|, |\raggedright|, |\raggedleft| or nothing).
+%
+% |#4| is an extra-code which contains |\l_@@_center_cell_box| (when the column
+% is a |m| column) or nothing (in the other cases).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_preamble_iv_v:nnnn #1 #2 #3 #4
+ {
\tl_gput_right:Nn \g_@@_preamble_tl
{
> {
+% \end{macrocode}
+% The parameter |\l_@@_col_width_dim|, which is the width of the current column,
+% will be available in each cell of the column. It will be used by the
+% mono-column blocks.
+% \begin{macrocode}
+ \dim_set:Nn \l_@@_col_width_dim { #2 }
\@@_Cell:
- \begin { minipage } [ #1 ] { \dim_eval:n { #3 } }
+ \begin { minipage } [ #1 ] { #2 }
% \end{macrocode}
% The following lines have been taken from |array.sty|.
% \begin{macrocode}
@@ -9073,7 +9335,17 @@ version 2005/12/01 or later.
\vrule height \box_ht:N \@arstrutbox width \c_zero_dim
\everypar { }
}
- \g_@@_row_style_tl % added the 2021-07-17
+% \end{macrocode}
+% Now, the potential code for the horizontal position of the content of the cell
+% (|\centering|, |\raggedright|, |\raggedleft| or nothing).
+% \begin{macrocode}
+ #3
+% \end{macrocode}
+% The following code is to allow something like |\centering| in |\RowStyle|.
+% However, there is extra vertical space if |\color{...}| is used in
+% |\RowStyle| (we should try to add a key |color| to the command |\RowStyle|.
+% \begin{macrocode}
+ \g_@@_row_style_tl
\arraybackslash
}
c
@@ -9084,18 +9356,13 @@ version 2005/12/01 or later.
\@finalstrut \@arstrutbox
\end { minipage }
% \end{macrocode}
-% If the letter in the preamble is |m|, you require a post-treatment for the box
-% |\l_@@_cell_box|.
+% If the letter in the preamble is |m|, |#3| will be equal to
+% |\@@_center_cell_box:| (see just below).
% \begin{macrocode}
- \str_if_eq:nnT { #2 } m \@@_center_cell_box:
+ #4
\@@_end_Cell:
}
}
-% \end{macrocode}
-% We increment the counter of columns, and then we test for the presence of a |<|.
-% \begin{macrocode}
- \int_gincr:N \c@jCol
- \@@_patch_preamble_x:n
}
% \end{macrocode}
%
@@ -9104,16 +9371,16 @@ version 2005/12/01 or later.
% vertically the box. In fact, despite its name, the command does not always
% center the cell. Indeed, if there is only one row in the cell, it should not
% be centered vertically. It's not possible to know the number of rows of the
-% cell. However, you consider (as in \pkg{array}) that if the height of the cell
+% cell. However, we consider (as in \pkg{array}) that if the height of the cell
% is no more that the height of |\@arstrutbox|, there is only one row.
% \begin{macrocode}
\cs_new_protected:Npn \@@_center_cell_box:
{
% \end{macrocode}
-% By putting instructions in |\g_@@_post_treatment_cell_tl|, we require a
-% post-treatment of the box |\l_@@_cell_box|.
+% By putting instructions in |\g_@@_post_action_cell_tl|, we require a
+% post-action of the box |\l_@@_cell_box|.
% \begin{macrocode}
- \tl_gput_right:Nn \g_@@_post_treatment_cell_tl
+ \tl_gput_right:Nn \g_@@_post_action_cell_tl
{
\int_compare:nNnT
{ \box_ht:N \l_@@_cell_box }
@@ -9143,9 +9410,15 @@ version 2005/12/01 or later.
\tl_gput_right:Nn \g_@@_preamble_tl
{
> {
+% \end{macrocode}
+% The parameter |\l_@@_col_width_dim|, which is the width of the current column,
+% will be available in each cell of the column. It will be used by the
+% mono-column blocks.
+% \begin{macrocode}
+ \dim_set:Nn \l_@@_col_width_dim { #4 }
\hbox_set:Nw \l_@@_cell_box
\@@_Cell:
- \tl_set:Nn \l_@@_cell_type_tl { #3 }
+ \str_set:Nn \l_@@_hpos_cell_str { #3 }
}
c
< {
@@ -9290,6 +9563,105 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+% \bigskip
+% For the case of a letter |X|. This specifier may take in an optional argument
+% (between square brackets). That's why we test whether there is a |[| after the
+% letter |X|.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_preamble_ix:n #1
+ {
+ \str_if_eq:nnTF { #1 } { [ }
+ { \@@_patch_preamble_ix_i:w [ }
+ { \@@_patch_preamble_ix_i:w [ ] #1 }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_preamble_ix_i:w [ #1 ]
+ { \@@_patch_preamble_ix_ii:n { #1 } }
+% \end{macrocode}
+% |#1| is the optional argument of the |X| specifier (a list of
+% \emph{key}-\emph{value} pairs).
+%
+% \medskip
+% The following set of keys is for the specifier |X| in the preamble of the
+% array. Such specifier may have as key all the keys of
+% |{ WithArrows / p-column }| but also a key as 1, 2, 3, etc. The following set
+% of keys will be used to retrieve that value (in the counter |\l_@@_weight_int|).
+% \begin{macrocode}
+\keys_define:nn { WithArrows / X-column }
+ { unknown .code:n = \int_set:Nn \l_@@_weight_int { \l_keys_key_str } }
+% \end{macrocode}
+%
+%
+% \medskip
+% In the following command, |#1| is the list of the options of the specifier |X|.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_preamble_ix_ii:n #1
+ {
+% \end{macrocode}
+% The possible values of |\l_@@_hpos_col_str| are |j| (for \emph{justified} which is
+% the initial value), |l|, |c| and |r| (when the user has used the corresponding
+% key in the optional argument of the specifier |X|).
+% \begin{macrocode}
+ \str_set:Nn \l_@@_hpos_col_str { j }
+% \end{macrocode}
+% The possible values of |\l_@@_vpos_col_str| are |p| (the initial value), |m| and |b|
+% (when the user has used the corresponding key in the optional argument of the
+% specifier |X|).
+% \begin{macrocode}
+ \tl_set:Nn \l_@@_vpos_col_str { p }
+% \end{macrocode}
+%
+% The integer |\l_@@_weight_int| will be the weight of the |X| column (the
+% initial value is $1$). The user may specify a different value (such as $2$,
+% $3$, etc.) by putting that value in the optional argument of the specifier.
+% The weights of the |X| columns are used in the computation of the actual width
+% of those columns.
+% \begin{macrocode}
+ \int_zero_new:N \l_@@_weight_int
+ \int_set:Nn \l_@@_weight_int { 1 }
+ \keys_set_known:nnN { WithArrows / p-column } { #1 } \l_tmpa_tl
+ \keys_set:nV { WithArrows / X-column } \l_tmpa_tl
+ \int_gadd:Nn \g_@@_total_X_weight_int \l_@@_weight_int
+% \end{macrocode}
+%
+% We test whether we know the width of the |X|-columns by reading the |aux| file.
+% (after the first compilation, the width of the |X|-columns is computed and
+% written on the |aux| file).
+% \begin{macrocode}
+ \bool_if:NTF \l_@@_X_columns_aux_bool
+ { \@@_patch_preamble_iv_iv:n { \l_@@_weight_int \l_@@_X_columns_dim } }
+ {
+ \tl_gput_right:Nn \g_@@_preamble_tl
+ {
+ > {
+ \@@_Cell:
+ \bool_set_true:N \l_@@_X_column_bool
+% \end{macrocode}
+% The following code will nullify the box of the cell.
+% \begin{macrocode}
+ \tl_gput_right:Nn \g_@@_post_action_cell_tl
+ { \hbox_set:Nn \l_@@_cell_box { } }
+% \end{macrocode}
+% We put a |{minipage}| to give to the user the ability to put a command such as
+% |\centering| in the |\RowStyle|.
+% \begin{macrocode}
+ \begin { minipage } { 5 cm } \arraybackslash
+ }
+ c
+ < {
+ \end { minipage }
+ \@@_end_Cell:
+ }
+ }
+ \int_gincr:N \c@jCol
+ \@@_patch_preamble_x:n
+ }
+ }
+% \end{macrocode}
+%
+% \bigskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_xi:n #1
{
@@ -9305,6 +9677,7 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+% \bigskip
% After a specifier of column, we have to test whether there is one or several
% |<{..}| because, after those potential |<{...}|, we have to insert
% |!{\skip_horizontal:N ...}| when the key |vlines| is used.
@@ -9312,7 +9685,7 @@ version 2005/12/01 or later.
\cs_new_protected:Npn \@@_patch_preamble_x:n #1
{
\str_if_eq:nnTF { #1 } { < }
- \@@_patch_preamble_ix:n
+ \@@_patch_preamble_xii:n
{
\tl_if_eq:NnTF \l_@@_vlines_clist { all }
{
@@ -9333,48 +9706,13 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_patch_preamble_ix:n #1
+\cs_new_protected:Npn \@@_patch_preamble_xii:n #1
{
\tl_gput_right:Nn \g_@@_preamble_tl { < { #1 } }
\@@_patch_preamble_x:n
}
% \end{macrocode}
%
-% \bigskip
-% For the case of a letter |X|
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_patch_preamble_xii:
- {
- \int_gincr:N \g_@@_nb_of_X_int
-% \end{macrocode}
-% We test whether you know the width of the |X|-columns by reading the value in
-% the |aux| file (of course, this is not possible at the first compilation).
-% \begin{macrocode}
- \bool_if:NTF \l_@@_X_columns_aux_bool
- { \exp_args:NNNV \@@_patch_preamble_iv:nnn t p \l_@@_X_columns_dim }
- {
- \tl_gput_right:Nn \g_@@_preamble_tl
- {
- > {
- \@@_Cell:
- \tl_set:Nn \l_@@_cell_type_tl { c }
-% \end{macrocode}
-% The following code will nullify the box of the cell.
-% \begin{macrocode}
- \tl_gput_right:Nn \g_@@_post_treatment_cell_tl
- { \hbox_set:Nn \l_@@_cell_box { } }
-% \end{macrocode}
-% The content of the cell is composed in |\l_tmpa_box| which will be discarded.
-% \begin{macrocode}
- }
- c
- < { \@@_end_Cell: }
- }
- \int_gincr:N \c@jCol
- \@@_patch_preamble_x:n
- }
- }
-% \end{macrocode}
%
% \bigskip
% \subsection*{The redefinition of \textbackslash multicolumn}
@@ -9481,9 +9819,6 @@ version 2005/12/01 or later.
\@@_w: { \@@_patch_m_preamble_v:nnnn { } #1 }
\@@_W: { \@@_patch_m_preamble_v:nnnn { \cs_set_eq:NN \hss \hfil } #1 }
\@@_true_c: { \@@_patch_m_preamble_vi:n #1 }
- C { \@@_error:nn { old~column~type } #1 }
- L { \@@_error:nn { old~column~type } #1 }
- R { \@@_error:nn { old~column~type } #1 }
\q_stop { }
}
{ \@@_fatal:nn { unknown~column~type } { #1 } }
@@ -9497,7 +9832,7 @@ version 2005/12/01 or later.
{
\tl_gput_right:Nn \g_@@_preamble_tl
{
- > { \@@_Cell: \tl_set:Nn \l_@@_cell_type_tl { #1 } }
+ > { \@@_Cell: \str_set:Nn \l_@@_hpos_cell_str { #1 } }
#1
< \@@_end_Cell:
}
@@ -9568,7 +9903,7 @@ version 2005/12/01 or later.
> {
\hbox_set:Nw \l_@@_cell_box
\@@_Cell:
- \tl_set:Nn \l_@@_cell_type_tl { #3 }
+ \str_set:Nn \l_@@_hpos_cell_str { #3 }
}
c
< {
@@ -10588,11 +10923,18 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% \subsection*{The environments \{NiceTabular\} and \{NiceTabular*\}}
+% \subsection*{\{NiceTabular\}, \{NiceTabularX\} and \{NiceTabular*\}}
%
% \begin{macrocode}
\NewDocumentEnvironment { NiceTabular } { O { } m ! O { } }
{
+% \end{macrocode}
+% The dimension |\l_@@_width_dim| will be used if at least one column of type
+% |X| is used.
+%
+% \begin{macrocode}
+ \dim_zero_new:N \l_@@_width_dim
+ \dim_set_eq:NN \l_@@_width_dim \linewidth
\str_gset:Nn \g_@@_name_env_str { NiceTabular }
\keys_set:nn { NiceMatrix / NiceTabular } { #1 , #3 }
\bool_set_true:N \l_@@_NiceTabular_bool
@@ -10601,6 +10943,20 @@ version 2005/12/01 or later.
{ \endNiceArray }
% \end{macrocode}
%
+% \bigskip
+% \begin{macrocode}
+\NewDocumentEnvironment { NiceTabularX } { m O { } m ! O { } }
+ {
+ \str_gset:Nn \g_@@_name_env_str { NiceTabularX }
+ \dim_zero_new:N \l_@@_width_dim
+ \dim_set:Nn \l_@@_width_dim { #1 }
+ \keys_set:nn { NiceMatrix / NiceTabular } { #2 , #4 }
+ \bool_set_true:N \l_@@_NiceTabular_bool
+ \NiceArray { #3 }
+ }
+ { \endNiceArray }
+% \end{macrocode}
+%
% \bigskip
% \begin{macrocode}
\NewDocumentEnvironment { NiceTabular* } { m O { } m ! O { } }
@@ -12414,6 +12770,10 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+% \bigskip
+% In the environments of |nicematrix|, the command |\multicolumn| is redefined.
+% We will patch the environment |{tabular}| to go back to the previous value of
+% |\multicolumn|.
% \begin{macrocode}
\cs_set_eq:NN \@@_old_multicolumn \multicolumn
% \end{macrocode}
@@ -12776,28 +13136,26 @@ version 2005/12/01 or later.
% We want to avoid the thin white lines that are shown in some \textsc{pdf}
% viewers (eg: with the engine MuPDF used by SumatraPDF). That's why we try to
% draw rectangles of the same color in the same instruction |\pgfusepath { fill }|
-% (and they will be in the same instruction |fill|---coded |f|--- in the
+% (and they will be in the same instruction |fill|---coded |f|---in the
% resulting \textsc{pdf}).
%
-% The commands |\@@_rowcolor|, |\@@_columncolor| and |\@@_rectanglecolor|
-% (which are linked to |\rowcolor|, |\columncolor| and |\rectanglecolor| before
-% the execution of the |code-before|) don't directly draw the corresponding
-% rectangles. Instead, they store their instructions color by color:
+% The commands |\@@_rowcolor|, |\@@_columncolor|, |\@@_rectanglecolor| and
+% |\@@_rowlistcolors| don't directly draw the corresponding rectangles. Instead,
+% they store their instructions color by color:
% \begin{itemize}
% \item A sequence |\g_@@_colors_seq| will be built containing all the colors
% used by at least one of these instructions. Each \emph{color} may be prefixed
-% by it color model (eg: |[gray]{0.5}|).
+% by its color model (eg: |[gray]{0.5}|).
% \item For the color whose index in |\g_@@_colors_seq| is equal to~$i$, a list of
% instructions which use that color will be constructed in the token list
% |\g_@@_color_|$i$|_tl|. In that token list, the instructions will be written
-% using |\@@_rowcolor:n|, |\@@_columncolor:n| and |\@@_rectanglecolor:nn|
-% (corresponding of |\@@_rowcolor|, |\@@_columncolor| and |\@@_rectanglecolor|).
+% using |\@@_cartesian_color:nn| and |\@@_rectanglecolor:nn|.
% \end{itemize}
%
%
-% bigskip
+% \bigskip
% |#1| is the color and |#2| is an instruction using that color. Despite its
-% name, the command |\@@_add_to_color_seq| doesn't only add a color to
+% name, the command |\@@_add_to_colors_seq:nn| doesn't only add a color to
% |\g_@@_colors_seq|: it also updates the corresponding token list
% |\g_@@_color_|$i$|_tl|. We add in a global way because the final user may use
% the instructions such as |\cellcolor| in a loop of \pkg{pgffor} in the
@@ -12832,6 +13190,7 @@ version 2005/12/01 or later.
%
% \begin{macrocode}
\cs_generate_variant:Nn \@@_add_to_colors_seq:nn { x n }
+\cs_generate_variant:Nn \@@_add_to_colors_seq:nn { x x }
% \end{macrocode}
%
% \bigskip
@@ -12862,6 +13221,14 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_cartesian_color:nn #1 #2
+ {
+ \tl_set:Nn \l_@@_rows_tl { #1 }
+ \tl_set:Nn \l_@@_cols_tl { #2 }
+ \@@_cartesian_path:
+ }
+% \end{macrocode}
%
% \bigskip
% Here is an example : |\@@_rowcolor {red!15} {1,3,5-7,10-}|
@@ -12872,25 +13239,11 @@ version 2005/12/01 or later.
{
\@@_add_to_colors_seq:xn
{ \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } }
- { \@@_rowcolor:n { #3 } }
+ { \@@_cartesian_color:nn { #3 } { - } }
}
}
% \end{macrocode}
%
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_rowcolor:n #1
- {
- \tl_set:Nn \l_@@_rows_tl { #1 }
- \tl_set:Nn \l_@@_cols_tl { - }
-% \end{macrocode}
-% The command |\@@_cartesian_path:| takes in two implicit arguments:
-% |\l_@@_cols_tl| and |\l_@@_rows_tl|.
-% \begin{macrocode}
- \@@_cartesian_path:
- }
-% \end{macrocode}
-%
-%
% \bigskip
% Here an example : |\@@_columncolor:nn {red!15} {1,3,5-7,10-}|
% \begin{macrocode}
@@ -12900,23 +13253,10 @@ version 2005/12/01 or later.
{
\@@_add_to_colors_seq:xn
{ \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } }
- { \@@_columncolor:n { #3 } }
+ { \@@_cartesian_color:nn { - } { #3 } }
}
}
% \end{macrocode}
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_columncolor:n #1
- {
- \tl_set:Nn \l_@@_rows_tl { - }
- \tl_set:Nn \l_@@_cols_tl { #1 }
-% \end{macrocode}
-% The command |\@@_cartesian_path:| takes in two implicit arguments:
-% |\l_@@_cols_tl| and |\l_@@_rows_tl|.
-% \begin{macrocode}
- \@@_cartesian_path:
- }
-% \end{macrocode}
-%
%
% \bigskip
% Here is an example : |\@@_rectanglecolor{red!15}{2-3}{5-6}|
@@ -13038,24 +13378,26 @@ version 2005/12/01 or later.
%
% |#1| (optional) is the color space ;
% |#2| is a list of intervals of rows ;
-% |#3| is the first color ;
-% |#4| is the second color ;
-% |#5| is for the optional list of pairs key-value.
+% |#3| is the list of colors ;
+% |#4| is for the optional list of pairs key-value.
% \begin{macrocode}
-\NewDocumentCommand \@@_rowcolors { O { } m m m O { } }
+\NewDocumentCommand \@@_rowlistcolors { O { } m m O { } }
{
% \end{macrocode}
-% The group is for the options.
+% The group is for the options. |\l_@@_colors_seq| will be the list of colors.
% \begin{macrocode}
\group_begin:
+ \seq_clear_new:N \l_@@_colors_seq
+ \seq_set_split:Nnn \l_@@_colors_seq { , } { #3 }
\tl_clear_new:N \l_@@_cols_tl
\tl_set:Nn \l_@@_cols_tl { - }
- \keys_set:nn { NiceMatrix / rowcolors } { #5 }
+ \keys_set:nn { NiceMatrix / rowcolors } { #4 }
% \end{macrocode}
-% The boolean |\l_tmpa_bool| will indicate whereas we are in a row of the first
-% color or of the second color.
+% The counter |\l_@@_color_int| will be the rank of the current color in the list of
+% colors (modulo the length of the list).
% \begin{macrocode}
- \bool_set_true:N \l_tmpa_bool
+ \int_zero_new:N \l_@@_color_int
+ \int_set:Nn \l_@@_color_int 1
\bool_if:NT \l_@@_respect_blocks_bool
{
% \end{macrocode}
@@ -13069,6 +13411,9 @@ version 2005/12/01 or later.
}
\pgfpicture
\pgf@relevantforpicturesizefalse
+% \end{macrocode}
+% |#2| is the list of intervals of rows.
+% \begin{macrocode}
\clist_map_inline:nn { #2 }
{
\tl_set:Nn \l_tmpa_tl { ##1 }
@@ -13076,12 +13421,14 @@ version 2005/12/01 or later.
{ \@@_cut_on_hyphen:w ##1 \q_stop }
{ \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } }
% \end{macrocode}
-% The counter |\l_tmpa_int| will be the index of the loop.
+% Now, |l_tmpa_tl| and |l_tmpb_tl| are the first row and the last row of the
+% interval of rows that we have to treat. The counter |\l_tmpa_int| will be the
+% index of the loop over the rows.
% \begin{macrocode}
\int_set:Nn \l_tmpa_int \l_tmpa_tl
\bool_if:NTF \l_@@_rowcolors_restart_bool
- { \bool_set_true:N \l_tmpa_bool }
- { \bool_set:Nn \l_tmpa_bool { \int_if_odd_p:n { \l_tmpa_tl } } }
+ { \int_set:Nn \l_@@_color_int 1 }
+ { \int_set:Nn \l_@@_color_int \l_tmpa_tl }
\int_zero_new:N \l_tmpc_int
\int_set:Nn \l_tmpc_int \l_tmpb_tl
\int_do_until:nNnn \l_tmpa_int > \l_tmpc_int
@@ -13105,39 +13452,27 @@ version 2005/12/01 or later.
}
\tl_set:Nx \l_@@_rows_tl
{ \int_use:N \l_tmpa_int - \int_use:N \l_tmpb_int }
- \bool_if:NTF \l_tmpa_bool
- {
- \tl_if_blank:nF { #3 }
- {
- \tl_if_empty:nTF { #1 }
- \color
- { \color [ #1 ] }
- { #3 }
% \end{macrocode}
-% The command |\@@_cartesian_path:| takes in two implicit arguments:
-% |\l_@@_cols_tl| and |\l_@@_rows_tl|.
+% |\l_tmpc_tl| will be the color that we will use.
% \begin{macrocode}
- \@@_cartesian_path:
- \pgfusepath { fill }
- }
- \bool_set_false:N \l_tmpa_bool
- }
+ \tl_clear_new:N \l_@@_color_tl
+ \tl_set:Nx \l_@@_color_tl
{
- \tl_if_blank:nF { #4 }
- {
- \tl_if_empty:nTF { #1 }
- \color
- { \color [ #1 ] }
- { #4 }
-% \end{macrocode}
-% The command |\@@_cartesian_path:| takes in two implicit arguments:
-% |\l_@@_cols_tl| and |\l_@@_row_tl|.
-% \begin{macrocode}
- \@@_cartesian_path:
- \pgfusepath { fill }
+ \@@_color_index:n
+ {
+ \int_mod:nn
+ { \l_@@_color_int - 1 }
+ { \seq_count:N \l_@@_colors_seq }
+ + 1
}
- \bool_set_true:N \l_tmpa_bool
}
+ \tl_if_empty:NF \l_@@_color_tl
+ {
+ \@@_add_to_colors_seq:xx
+ { \tl_if_blank:nF { #1 } { [ #1 ] } { \l_@@_color_tl } }
+ { \@@_cartesian_color:nn { \l_@@_rows_tl } { \l_@@_cols_tl } }
+ }
+ \int_incr:N \l_@@_color_int
\int_set:Nn \l_tmpa_int { \l_tmpb_int + 1 }
}
}
@@ -13146,6 +13481,27 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+% \medskip
+% The command |\@@_color_index:n| peeks in |\l_@@_colors_seq| the color at the
+% index |#1|. However, if that color is the symbol |=|, the previous one is
+% poken. This macro is recursive.
+% \begin{macrocode}
+\cs_new:Npn \@@_color_index:n #1
+ {
+ \str_if_eq:eeTF { \seq_item:Nn \l_@@_colors_seq { #1 } } { = }
+ { \@@_color_index:n { #1 - 1 } }
+ { \seq_item:Nn \l_@@_colors_seq { #1 } }
+ }
+% \end{macrocode}
+%
+% \bigskip
+% The command |\rowcolors| (available in the |\CodeBefore|) is a specialisation
+% of the most general command |\rowlistcolors|.
+% \begin{macrocode}
+\NewDocumentCommand \@@_rowcolors { O { } m m m O { } }
+ { \@@_rowlistcolors [ #1 ] { #2 } { { #3 } , { #4 } } [ #5 ] }
+% \end{macrocode}
+%
% \bigskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_rowcolors_i:nnnn #1 #2 #3 #4
@@ -13757,9 +14113,12 @@ version 2005/12/01 or later.
\dim_set_eq:NN \l_tmpb_dim \pgf@y
\@@_qpoint:n { col - \@@_succ:n { #4 } }
\dim_set_eq:NN \l_tmpc_dim \pgf@x
- \bool_lazy_and:nnT
- { \int_compare_p:nNn { #2 } > 1 }
- { ! \tl_if_blank_p:V \CT@drsc@ }
+ \bool_lazy_all:nT
+ {
+ { \int_compare_p:nNn { #2 } > 1 }
+ { \cs_if_exist_p:N \CT@drsc@ } % condition added in version 6.0
+ { ! \tl_if_blank_p:V \CT@drsc@ }
+ }
{
\group_begin:
\CT@drsc@
@@ -14385,7 +14744,7 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \medskip
-% At the end of the environment |{NiceMatrixBlock}|, we write in the main |.aux|
+% At the end of the environment |{NiceMatrixBlock}|, we write in the main |aux|
% file instructions for the column width of all the environments of the block
% (that's why we have stored the number of the first environment of the block in
% the counter |\l_@@_first_env_block_int|).
@@ -14774,21 +15133,21 @@ version 2005/12/01 or later.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / Block / FirstPass }
{
- l .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl l ,
+ l .code:n = \str_set:Nn \l_@@_hpos_block_str l ,
l .value_forbidden:n = true ,
- r .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl r ,
+ r .code:n = \str_set:Nn \l_@@_hpos_block_str r ,
r .value_forbidden:n = true ,
- c .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl c ,
+ c .code:n = \str_set:Nn \l_@@_hpos_block_str c ,
c .value_forbidden:n = true ,
- L .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl l ,
+ L .code:n = \str_set:Nn \l_@@_hpos_block_str l ,
L .value_forbidden:n = true ,
- R .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl r ,
+ R .code:n = \str_set:Nn \l_@@_hpos_block_str r ,
R .value_forbidden:n = true ,
- C .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl c ,
+ C .code:n = \str_set:Nn \l_@@_hpos_block_str c ,
C .value_forbidden:n = true ,
- t .code:n = \tl_set:Nn \l_@@_vpos_of_block_tl t ,
+ t .code:n = \str_set:Nn \l_@@_vpos_of_block_tl t ,
t .value_forbidden:n = true ,
- b .code:n = \tl_set:Nn \l_@@_vpos_of_block_tl b ,
+ b .code:n = \str_set:Nn \l_@@_vpos_of_block_tl b ,
b .value_forbidden:n = true ,
color .tl_set:N = \l_@@_color_tl ,
color .value_required:n = true ,
@@ -14799,9 +15158,7 @@ version 2005/12/01 or later.
% The following command |\@@_Block:| will be linked to |\Block| in the
% environments of \pkg{nicematrix}. We define it with
% |\NewExpandableDocumentCommand| because it has an optional argument between
-% |<| and |>| (for TeX instructions put before the math mode of the label and
-% before the beginning of the small array of the block). It's mandatory to use
-% an expandable command.
+% |<| and |>|. It's mandatory to use an expandable command.
%
% \begin{macrocode}
\NewExpandableDocumentCommand \@@_Block: { O { } m D < > { } m }
@@ -14863,13 +15220,13 @@ version 2005/12/01 or later.
% \begin{macrocode}
\int_compare:nNnTF \l_tmpb_int = 1
{
- \tl_if_empty:NTF \l_@@_cell_type_tl
- { \tl_set:Nn \l_@@_hpos_of_block_tl c }
- { \tl_set_eq:NN \l_@@_hpos_of_block_tl \l_@@_cell_type_tl }
+ \str_if_empty:NTF \l_@@_hpos_cell_str
+ { \str_set:Nn \l_@@_hpos_block_str c }
+ { \str_set_eq:NN \l_@@_hpos_block_str \l_@@_hpos_cell_str }
}
- { \tl_set:Nn \l_@@_hpos_of_block_tl c }
+ { \str_set:Nn \l_@@_hpos_block_str c }
% \end{macrocode}
-% The value of |\l_@@_hpos_of_block_tl| may be modified by the keys of the
+% The value of |\l_@@_hpos_block_str| may be modified by the keys of the
% command |\Block| that we will analyze now.
%
% \medskip
@@ -14905,6 +15262,16 @@ version 2005/12/01 or later.
\int_compare_p:nNn { \l_tmpb_int } = 1
)
&& ! \tl_if_empty_p:n { #5 }
+% \end{macrocode}
+% For the blocks mono-column, we will compose right now in a box in order to
+% compute its width and take that width into account for the width of the
+% column. However, if the column is a |X| column, we should not do that since
+% the width is determined by another way. This should be the same for the |p|,
+% |m| and |b| columns and we should modify that point. However, for the |X|
+% column, it's imperative. Otherwise, the process for the determination of the
+% widths of the columns will be wrong.
+% \begin{macrocode}
+ && ! \l_@@_X_column_bool
}
{ \exp_args:Nxx \@@_Block_iv:nnnnn }
{ \exp_args:Nxx \@@_Block_v:nnnnn }
@@ -14952,8 +15319,8 @@ version 2005/12/01 or later.
{ \int_compare:nNnT { #2 } = 1 \set@color }
{ \color { \l_@@_color_tl } }
% \end{macrocode}
-% If the block is mono-row, we use |\g_@@_row_style_tl| even it has yet been used
-% in the beginning of the cell where the command |\Block| has been issued
+% If the block is mono-row, we use |\g_@@_row_style_tl| even if it has yet been
+% used in the beginning of the cell where the command |\Block| has been issued
% because we want to be able to take into account a potential instruction of
% color of the font in |\g_@@_row_style_tl|.
% \begin{macrocode}
@@ -14970,23 +15337,43 @@ version 2005/12/01 or later.
% the tabular is the same as the external alignment of the tabular (that is to
% say the position of the block in its zone of merged cells).
% \begin{macrocode}
- \bool_if:NT \g_@@_rotate_bool { \tl_set:Nn \l_@@_hpos_of_block_tl c }
+ \bool_if:NT \g_@@_rotate_bool { \str_set:Nn \l_@@_hpos_block_str c }
\bool_if:NTF \l_@@_NiceTabular_bool
{
- \use:x
- {
- \exp_not:N \begin { tabular } [ \l_@@_vpos_of_block_tl ]
- { @ { } \l_@@_hpos_of_block_tl @ { } }
- }
- #5
- \end { tabular }
+ \bool_lazy_and:nnTF
+ { \int_compare_p:nNn { #2 } = 1 }
+ { \dim_compare_p:n { \l_@@_col_width_dim >= \c_zero_dim } }
+% \end{macrocode}
+% When the block is mono-column in a column with a fixed width (eg |p{3cm}|).
+% \begin{macrocode}
+ {
+ \begin { minipage } [ l_@@_vpos_of_block_tl ]
+ { \l_@@_col_width_dim }
+ \str_case:Vn \l_@@_hpos_block_str
+ {
+ c \centering
+ r \raggedleft
+ l \raggedright
+ }
+ #5
+ \end { minipage }
+ }
+ {
+ \use:x
+ {
+ \exp_not:N \begin { tabular } [ \l_@@_vpos_of_block_tl ]
+ { @ { } \l_@@_hpos_block_str @ { } }
+ }
+ #5
+ \end { tabular }
+ }
}
{
\c_math_toggle_token
\use:x
{
\exp_not:N \begin { array } [ \l_@@_vpos_of_block_tl ]
- { @ { } \l_@@_hpos_of_block_tl @ { } }
+ { @ { } \l_@@_hpos_block_str @ { } }
}
#5
\end { array }
@@ -15048,11 +15435,11 @@ version 2005/12/01 or later.
% \end{macrocode}
% In the list of options |#3|, maybe there is a key for the horizontal alignment
% (|l|, |r| or |c|). In that case, that key has been read and stored in
-% |\l_@@_hpos_of_block_tl|. However, maybe there were no key of the horizontal
+% |\l_@@_hpos_block_str|. However, maybe there were no key of the horizontal
% alignement and that's why we put a key corresponding to the value of
-% |\l_@@_hpos_of_block_tl|, which is fixed by the type of current column.
+% |\l_@@_hpos_block_str|, which is fixed by the type of current column.
% \begin{macrocode}
- { \exp_not:n { #3 } , \l_@@_hpos_of_block_tl }
+ { \exp_not:n { #3 } , \l_@@_hpos_block_str }
{
\box_use_drop:c
{ g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
@@ -15091,11 +15478,11 @@ version 2005/12/01 or later.
% say the position of the block in its zone of merged cells).
% \begin{macrocode}
\bool_if:NT \g_@@_rotate_bool
- { \tl_set:Nn \l_@@_hpos_of_block_tl c }
+ { \str_set:Nn \l_@@_hpos_block_str c }
\use:x
{
\exp_not:N \begin { tabular } [ \l_@@_vpos_of_block_tl ]
- { @ { } \l_@@_hpos_of_block_tl @ { } }
+ { @ { } \l_@@_hpos_block_str @ { } }
}
#5
\end { tabular }
@@ -15107,12 +15494,12 @@ version 2005/12/01 or later.
\dim_set_eq:NN \extrarowheight \c_zero_dim
#4
\bool_if:NT \g_@@_rotate_bool
- { \tl_set:Nn \l_@@_hpos_of_block_tl c }
+ { \str_set:Nn \l_@@_hpos_block_str c }
\c_math_toggle_token
\use:x
{
\exp_not:N \begin { array } [ \l_@@_vpos_of_block_tl ]
- { @ { } \l_@@_hpos_of_block_tl @ { } }
+ { @ { } \l_@@_hpos_block_str @ { } }
}
#5
\end { array }
@@ -15153,24 +15540,24 @@ version 2005/12/01 or later.
hvlines .default:n = true ,
line-width .dim_set:N = \l_@@_line_width_dim ,
line-width .value_required:n = true ,
- l .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl l ,
+ l .code:n = \str_set:Nn \l_@@_hpos_block_str l ,
l .value_forbidden:n = true ,
- r .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl r ,
+ r .code:n = \str_set:Nn \l_@@_hpos_block_str r ,
r .value_forbidden:n = true ,
- c .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl c ,
+ c .code:n = \str_set:Nn \l_@@_hpos_block_str c ,
c .value_forbidden:n = true ,
- L .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl l
+ L .code:n = \str_set:Nn \l_@@_hpos_block_str l
\bool_set_true:N \l_@@_hpos_of_block_cap_bool ,
L .value_forbidden:n = true ,
- R .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl r
+ R .code:n = \str_set:Nn \l_@@_hpos_block_str r
\bool_set_true:N \l_@@_hpos_of_block_cap_bool ,
R .value_forbidden:n = true ,
- C .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl c
+ C .code:n = \str_set:Nn \l_@@_hpos_block_str c
\bool_set_true:N \l_@@_hpos_of_block_cap_bool ,
C .value_forbidden:n = true ,
- t .code:n = \tl_set:Nn \l_@@_vpos_of_block_tl t ,
+ t .code:n = \str_set:Nn \l_@@_vpos_of_block_tl t ,
t .value_forbidden:n = true ,
- b .code:n = \tl_set:Nn \l_@@_vpos_of_block_tl b ,
+ b .code:n = \str_set:Nn \l_@@_vpos_of_block_tl b ,
b .value_forbidden:n = true ,
unknown .code:n = \@@_error:n { Unknown~key~for~Block }
}
@@ -15546,7 +15933,7 @@ version 2005/12/01 or later.
\bool_if:NF \l_@@_hpos_of_block_cap_bool { - short }
}
{
- \str_case:Vn \l_@@_hpos_of_block_tl
+ \str_case:Vn \l_@@_hpos_block_str
{
c { center }
l { west }
@@ -15561,7 +15948,7 @@ version 2005/12/01 or later.
\pgfnode
{ rectangle }
{
- \str_case:Vn \l_@@_hpos_of_block_tl
+ \str_case:Vn \l_@@_hpos_block_str
{
c { base }
l { base~west }
@@ -15582,11 +15969,11 @@ version 2005/12/01 or later.
% If we are in the first column, we must put the block as if it was with the key~|r|.
% \begin{macrocode}
\int_compare:nNnT { #2 } = 0
- { \tl_set:Nn \l_@@_hpos_of_block_tl r }
+ { \str_set:Nn \l_@@_hpos_block_str r }
\bool_if:nT \g_@@_last_col_found_bool
{
\int_compare:nNnT { #2 } = \g_@@_col_total_int
- { \tl_set:Nn \l_@@_hpos_of_block_tl l }
+ { \str_set:Nn \l_@@_hpos_block_str l }
}
\pgftransformshift
{
@@ -15596,7 +15983,7 @@ version 2005/12/01 or later.
\bool_if:NF \l_@@_hpos_of_block_cap_bool { - short }
}
{
- \str_case:Vn \l_@@_hpos_of_block_tl
+ \str_case:Vn \l_@@_hpos_block_str
{
c { center }
l { west }
@@ -15608,7 +15995,7 @@ version 2005/12/01 or later.
\pgfnode
{ rectangle }
{
- \str_case:Vn \l_@@_hpos_of_block_tl
+ \str_case:Vn \l_@@_hpos_block_str
{
c { center }
l { west }
@@ -15997,6 +16384,7 @@ version 2005/12/01 or later.
\group_end:
}
% \end{macrocode}
+%
%
% \bigskip
% \subsection*{The redefinition of the command \textbackslash dotfill }
@@ -16030,7 +16418,8 @@ version 2005/12/01 or later.
% \subsection*{The command \textbackslash diagbox}
%
% The command |\diagbox| will be linked to |\diagbox:nn| in the environments of
-% \pkg{nicematrix}.
+% \pkg{nicematrix}. However, there are also redefinitions of |\diagbox| in other
+% circonstancies.
%
% \begin{macrocode}
\cs_new_protected:Npn \@@_diagbox:nn #1 #2
@@ -16886,7 +17275,6 @@ version 2005/12/01 or later.
}
{
The~available~keys~are~(in~alphabetic~order):~
- define-L-C-R,~
footnote,~
footnotehyper,~
renew-dots,~and
@@ -16906,20 +17294,8 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \begin{macrocode}
-\@@_msg_new:nn { define-L-C-R }
- {
- You~have~used~the~key~'define-L-C-R'.~Please~note~that~this~key~
- will~probably~be~deleted~in~a~future~version~of~'nicematrix'.\\
- However,~you~can~go~on.
- }
-% \end{macrocode}
-%
-% \begin{macrocode}
\keys_define:nn { NiceMatrix / Package }
{
- define-L-C-R .code:n =
- \@@_error:n { define-L-C-R }
- \bool_set_true:N \c_@@_define_L_C_R_bool ,
renew-dots .bool_set:N = \l_@@_renew_dots_bool ,
renew-dots .value_forbidden:n = true ,
renew-matrix .code:n = \@@_renew_matrix: ,
@@ -17236,15 +17612,6 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
-% \begin{macrocode}
-\@@_msg_new:nn { old~column~type }
- {
- The~column~type~'#1'~is~no~longer~defined~in~'nicematrix'.~
- Since~version~5.0,~you~have~to~use~'l',~'c'~and~'r'~instead~of~'L',~
- 'C'~and~'R'.~You~can~also~use~the~key~'define-L-C-R'.\\
- This~error~is~fatal.
- }
-% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { bad~value~for~baseline }
@@ -17288,6 +17655,14 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \begin{macrocode}
+\@@_msg_new:nn { width~without~X~columns }
+ {
+ You~have~used~the~key~'width'~but~you~have~put~no~'X'~column. \\
+ If~you~go~on,~that~key~will~be~ignored.
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
\@@_msg_new:nn { empty~environment }
{ Your~\@@_full_name_env:\ is~empty.~This~error~is~fatal. }
% \end{macrocode}
@@ -18301,7 +18676,7 @@ version 2005/12/01 or later.
% \subsection*{Changes between versions 5.16 and 5.17}
%
% The key |define-L-C-R| (only available at load-time) now raises a (non fatal)
-% error (that key will probably be deleted in a future version of \pkg{nicematrix}).
+% error.
%
% Keys |L|, |C| and |R| for the command |\Block|.
%
@@ -18318,6 +18693,18 @@ version 2005/12/01 or later.
%
% New key |tikz| for the command |\Block|.
%
+%
+% \subsection*{Changes between versions 5.19 and 6.0}
+%
+% Columns |X| and environment |{NiceTabularX}|.
+%
+% Command |\rowlistcolors| available in the |\CodeBefore|.
+%
+% In columns with fixed width, the blocks are composed as paragraphs (wrapping
+% of the lines).
+%
+% The key |define-L-C-R| has been deleted.
+%
% \PrintIndex
%
% \tableofcontents
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
index c9122db838d..b0fa2412209 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{5.19}
-\def\myfiledate{2021/07/23}
+\def\myfileversion{6.0}
+\def\myfiledate{2021/08/10}
\RequirePackage{pgfcore}
\usepgfmodule{shapes}
\RequirePackage{l3keys2e}
@@ -123,9 +123,7 @@
\AtBeginDocument
{
\@ifpackageloaded { colortbl }
- {
- \bool_set_true:N \c__nicematrix_colortbl_loaded_bool
- }
+ { \bool_set_true:N \c__nicematrix_colortbl_loaded_bool }
{
\cs_set_protected:Npn \CT@arc@ { }
\cs_set:Npn \arrayrulecolor #1 # { \CT@arc { #1 } }
@@ -152,6 +150,7 @@
}
}
}
+\cs_if_exist:NF \AtBeginEnvironment { \RequirePackage { etoolbox } }
\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
{
@@ -271,13 +270,6 @@
}
}
}
-\bool_new:N \c__nicematrix_define_L_C_R_bool
-\cs_new_protected:Npn \__nicematrix_define_L_C_R:
- {
- \newcolumntype L l
- \newcolumntype C c
- \newcolumntype R r
- }
\int_new:N \g__nicematrix_env_int
\cs_new:Npn \__nicematrix_env: { nm - \int_use:N \g__nicematrix_env_int }
\NewExpandableDocumentCommand \NiceMatrixLastEnv { }
@@ -286,10 +278,12 @@
{ \pgfpointanchor { \__nicematrix_env: - #1 } { center } }
\int_new:N \g__nicematrix_NiceMatrixBlock_int
\dim_new:N \l__nicematrix_columns_width_dim
+\dim_new:N \l__nicematrix_col_width_dim
+\dim_set:Nn \l__nicematrix_col_width_dim { -1 cm }
\int_new:N \g__nicematrix_row_total_int
\int_new:N \g__nicematrix_col_total_int
-\tl_new:N \l__nicematrix_cell_type_tl
-\tl_set:Nn \l__nicematrix_cell_type_tl { c }
+\str_new:N \l__nicematrix_hpos_cell_str
+\str_set:Nn \l__nicematrix_hpos_cell_str { c }
\dim_new:N \g__nicematrix_blocks_wd_dim
\dim_new:N \g__nicematrix_blocks_ht_dim
\dim_new:N \g__nicematrix_blocks_dp_dim
@@ -300,6 +294,7 @@
\dim_new:N \l__nicematrix_tabular_width_dim
\bool_new:N \l__nicematrix_Matrix_bool
\bool_new:N \g__nicematrix_rotate_bool
+\bool_new:N \l__nicematrix_X_column_bool
\tl_new:N \g__nicematrix_aux_tl
\cs_new_protected:Npn \__nicematrix_test_if_math_mode:
{
@@ -325,7 +320,7 @@
\int_new:N \l__nicematrix_old_iRow_int
\int_new:N \l__nicematrix_old_jCol_int
\tl_new:N \l__nicematrix_rules_color_tl
-\int_new:N \g__nicematrix_nb_of_X_int
+\int_new:N \g__nicematrix_total_X_weight_int
\bool_new:N \l__nicematrix_X_columns_aux_bool
\dim_new:N \l__nicematrix_X_columns_dim
\bool_new:N \g__nicematrix_after_col_zero_bool
@@ -349,6 +344,7 @@
\seq_new:N \g__nicematrix_pos_of_stroken_blocks_seq
\seq_new:N \l__nicematrix_corners_cells_seq
\seq_new:N \g__nicematrix_submatrix_names_seq
+\bool_new:N \l__nicematrix_width_used_bool
\seq_new:N \g__nicematrix_multicolumn_cells_seq
\seq_new:N \g__nicematrix_multicolumn_sizes_seq
\int_new:N \l__nicematrix_row_min_int
@@ -364,8 +360,8 @@
\dim_new:N \l__nicematrix_rounded_corners_dim
\tl_new:N \l__nicematrix_color_tl
\dim_new:N \l__nicematrix_line_width_dim
-\tl_new:N \l__nicematrix_hpos_of_block_tl
-\tl_set:Nn \l__nicematrix_hpos_of_block_tl { c }
+\str_new:N \l__nicematrix_hpos_block_str
+\str_set:Nn \l__nicematrix_hpos_block_str { c }
\bool_new:N \l__nicematrix_hpos_of_block_cap_bool
\tl_new:N \l__nicematrix_vpos_of_block_tl
\tl_set:Nn \l__nicematrix_vpos_of_block_tl { c }
@@ -652,7 +648,6 @@
}
\keys_define:nn { NiceMatrix / Env }
{
-
hvlines-except-corners .code:n =
{
\clist_set:Nn \l__nicematrix_corners_clist { #1 }
@@ -888,6 +883,9 @@
}
\keys_define:nn { NiceMatrix / NiceTabular }
{
+ width .code:n = \dim_set:Nn \l__nicematrix_width_dim { #1 }
+ \bool_set_true:N \l__nicematrix_width_used_bool ,
+ width .value_required:n = true ,
notes / para .bool_set:N = \l__nicematrix_notes_para_bool ,
notes / para .default:n = true ,
notes / bottomrule .bool_set:N = \l__nicematrix_notes_bottomrule_bool ,
@@ -903,7 +901,7 @@
}
\cs_new_protected:Npn \__nicematrix_Cell:
{
- \tl_gclear:N \g__nicematrix_post_treatment_cell_tl
+ \tl_gclear:N \g__nicematrix_post_action_cell_tl
\cs_set_eq:NN \CodeAfter \__nicematrix_CodeAfter_i:n
\int_gincr:N \c@jCol
\int_compare:nNnT \c@jCol = 1
@@ -1007,7 +1005,7 @@
{
\__nicematrix_math_toggle_token:
\hbox_set_end:
- \g__nicematrix_post_treatment_cell_tl
+ \g__nicematrix_post_action_cell_tl
\bool_if:NT \g__nicematrix_rotate_bool \__nicematrix_rotate_cell_box:
\__nicematrix_adjust_size_box:
\box_set_ht:Nn \l__nicematrix_cell_box
@@ -1258,7 +1256,6 @@
\cs_set_eq:NN \Hspace \__nicematrix_Hspace:
\cs_set_eq:NN \Hdotsfor \__nicematrix_Hdotsfor:
\cs_set_eq:NN \Vdotsfor \__nicematrix_Vdotsfor:
- \cs_set_eq:NN \multicolumn \__nicematrix_multicolumn:nnn
\cs_set_eq:NN \Block \__nicematrix_Block:
\cs_set_eq:NN \rotate \__nicematrix_rotate:
\cs_set_eq:NN \OnlyMainNiceMatrix \__nicematrix_OnlyMainNiceMatrix:n
@@ -1269,6 +1266,9 @@
\cs_set_eq:NN \RowStyle \__nicematrix_RowStyle:n
\bool_if:NT \l__nicematrix_colortbl_like_bool \__nicematrix_colortbl_like:
\bool_if:NT \l__nicematrix_renew_dots_bool \__nicematrix_renew_dots:
+ \cs_set_eq:NN \multicolumn \__nicematrix_multicolumn:nnn
+ \AtBeginEnvironment { tabular }
+ { \cs_set_eq:NN \multicolumn \__nicematrix_old_multicolumn }
\seq_gclear:N \g__nicematrix_multicolumn_cells_seq
\seq_gclear:N \g__nicematrix_multicolumn_sizes_seq
\int_gset:Nn \c@iRow { \l__nicematrix_first_row_int - 1 }
@@ -1319,7 +1319,6 @@
\seq_gclear_new:N \g__nicematrix_multicolumn_sizes_seq
\__nicematrix_pre_array_ii:
\box_clear_new:N \l__nicematrix_the_array_box
- \bool_if:NT \c__nicematrix_define_L_C_R_bool \__nicematrix_define_L_C_R:
\__nicematrix_construct_preamble:
\dim_zero_new:N \l__nicematrix_left_delim_dim
\dim_zero_new:N \l__nicematrix_right_delim_dim
@@ -1354,7 +1353,7 @@
{
\tl_gput_right:Nn \g__nicematrix_row_style_tl
{
- \tl_gput_right:Nn \g__nicematrix_post_treatment_cell_tl
+ \tl_gput_right:Nn \g__nicematrix_post_action_cell_tl
{ \dim_set:Nn \l__nicematrix_cell_space_top_limit_dim { #1 } }
}
} ,
@@ -1363,7 +1362,7 @@
{
\tl_gput_right:Nn \g__nicematrix_row_style_tl
{
- \tl_gput_right:Nn \g__nicematrix_post_treatment_cell_tl
+ \tl_gput_right:Nn \g__nicematrix_post_action_cell_tl
{ \dim_set:Nn \l__nicematrix_cell_space_bottom_limit_dim { #1 } }
}
} ,
@@ -1420,6 +1419,7 @@
\cs_set_eq:NN \roundedrectanglecolor \__nicematrix_roundedrectanglecolor
\cs_set_eq:NN \rowcolor \__nicematrix_rowcolor
\cs_set_eq:NN \rowcolors \__nicematrix_rowcolors
+ \cs_set_eq:NN \rowlistcolors \__nicematrix_rowlistcolors
\cs_set_eq:NN \arraycolor \__nicematrix_arraycolor
\cs_set_eq:NN \columncolor \__nicematrix_columncolor
\cs_set_eq:NN \chessboardcolors \__nicematrix_chessboardcolors
@@ -1553,15 +1553,20 @@
\skip_horizontal:N \l__nicematrix_right_margin_dim
\skip_horizontal:N \l__nicematrix_extra_right_margin_dim
\hbox_set_end:
- \int_compare:nNnT \g__nicematrix_nb_of_X_int > 0
+ \bool_if:NT \l__nicematrix_width_used_bool
+ {
+ \int_compare:nNnT \g__nicematrix_total_X_weight_int = 0
+ { \__nicematrix_error:n { width~without~X~columns } }
+ }
+ \int_compare:nNnT \g__nicematrix_total_X_weight_int > 0
{
\bool_if:NTF \l__nicematrix_X_columns_aux_bool
{ \dim_set_eq:NN \l_tmpa_dim \l__nicematrix_X_columns_dim }
{
\dim_set:Nn \l_tmpa_dim
{
- ( \textwidth - \box_wd:N \l__nicematrix_the_array_box )
- / \int_use:N \g__nicematrix_nb_of_X_int
+ ( \l__nicematrix_width_dim - \box_wd:N \l__nicematrix_the_array_box )
+ / \int_use:N \g__nicematrix_total_X_weight_int
}
}
\tl_gput_right:Nx \g__nicematrix_aux_tl
@@ -1701,7 +1706,7 @@
{ ! { \skip_horizontal:N \arrayrulewidth } }
}
}
- \int_gzero:N \g__nicematrix_nb_of_X_int
+ \int_gzero:N \g__nicematrix_total_X_weight_int
\seq_clear:N \g__nicematrix_cols_vlism_seq
\int_zero:N \l_tmpa_int
\exp_after:wN \__nicematrix_patch_preamble:n \the \@temptokena \q_stop
@@ -1761,9 +1766,9 @@
! { \__nicematrix_patch_preamble_ii:nn #1 }
@ { \__nicematrix_patch_preamble_ii:nn #1 }
| { \__nicematrix_patch_preamble_iii:n #1 }
- p { \__nicematrix_patch_preamble_iv:nnn t #1 }
- b { \__nicematrix_patch_preamble_iv:nnn b #1 }
- m { \__nicematrix_patch_preamble_iv:nnn b #1 }
+ p { \__nicematrix_patch_preamble_iv:n #1 }
+ b { \__nicematrix_patch_preamble_iv:n #1 }
+ m { \__nicematrix_patch_preamble_iv:n #1 }
\__nicematrix_w: { \__nicematrix_patch_preamble_v:nnnn { } #1 }
\__nicematrix_W: { \__nicematrix_patch_preamble_v:nnnn { \cs_set_eq:NN \hss \hfil } #1 }
\__nicematrix_true_c: { \__nicematrix_patch_preamble_vi:n #1 }
@@ -1773,10 +1778,7 @@
) { \__nicematrix_patch_preamble_viii:nn #1 }
] { \__nicematrix_patch_preamble_viii:nn #1 }
\} { \__nicematrix_patch_preamble_viii:nn #1 }
- X { \__nicematrix_patch_preamble_xii: }
- C { \__nicematrix_error:nn { old~column~type } #1 }
- L { \__nicematrix_error:nn { old~column~type } #1 }
- R { \__nicematrix_error:nn { old~column~type } #1 }
+ X { \__nicematrix_patch_preamble_ix:n }
\q_stop { }
}
{
@@ -1808,7 +1810,7 @@
{
\tl_gput_right:Nn \g__nicematrix_preamble_tl
{
- > { \__nicematrix_Cell: \tl_set:Nn \l__nicematrix_cell_type_tl { #1 } }
+ > { \__nicematrix_Cell: \str_set:Nn \l__nicematrix_hpos_cell_str { #1 } }
#1
< \__nicematrix_end_Cell:
}
@@ -1853,35 +1855,93 @@
}
}
\bool_new:N \l__nicematrix_bar_at_end_of_pream_bool
-\cs_new_protected:Npn \__nicematrix_patch_preamble_iv:nnn #1 #2 #3
+\keys_define:nn { WithArrows / p-column }
+ {
+ r .code:n = \str_set:Nn \l__nicematrix_hpos_col_str { r } ,
+ r .value_forbidden:n = true ,
+ c .code:n = \str_set:Nn \l__nicematrix_hpos_col_str { c } ,
+ c .value_forbidden:n = true ,
+ l .code:n = \str_set:Nn \l__nicematrix_hpos_col_str { l } ,
+ l .value_forbidden:n = true ,
+ p .code:n = \str_set:Nn \l__nicematrix_vpos_col_str { p } ,
+ p .value_forbidden:n = true ,
+ t .meta:n = p ,
+ m .code:n = \str_set:Nn \l__nicematrix_vpos_col_str { m } ,
+ m .value_forbidden:n = true ,
+ b .code:n = \str_set:Nn \l__nicematrix_vpos_col_str { b } ,
+ b .value_forbidden:n = true
+ }
+\cs_new_protected:Npn \__nicematrix_patch_preamble_iv:n #1
+ {
+ \str_set:Nn \l__nicematrix_vpos_col_str { #1 }
+ \__nicematrix_patch_preamble_iv_i:n
+ }
+\cs_new_protected:Npn \__nicematrix_patch_preamble_iv_i:n #1
+ {
+ \str_if_eq:nnTF { #1 } { [ }
+ { \__nicematrix_patch_preamble_iv_ii:w [ }
+ { \__nicematrix_patch_preamble_iv_ii:w [ ] { #1 } }
+ }
+\cs_new_protected:Npn \__nicematrix_patch_preamble_iv_ii:w [ #1 ]
+ { \__nicematrix_patch_preamble_iv_iii:nn { #1 } }
+\cs_new_protected:Npn \__nicematrix_patch_preamble_iv_iii:nn #1 #2
+ {
+ \str_set:Nn \l__nicematrix_hpos_col_str { j }
+ \keys_set:nn { WithArrows / p-column } { #1 }
+ \__nicematrix_patch_preamble_iv_iv:n { #2 }
+ }
+\cs_new_protected:Npn \__nicematrix_patch_preamble_iv_iv:n #1
+ {
+ \use:x
+ {
+ \__nicematrix_patch_preamble_iv_v:nnnn
+ { \str_if_eq:VnTF \l__nicematrix_vpos_col_str { p } { t } { b } }
+ { \dim_eval:n { #1 } }
+ {
+ \str_if_eq:VnTF \l__nicematrix_hpos_col_str j
+ { \str_set:Nn \exp_not:N \l__nicematrix_hpos_cell_str { c } }
+ { \str_set:Nn \exp_not:N \l__nicematrix_hpos_cell_str \l__nicematrix_hpos_col_str }
+ \str_case:Vn \l__nicematrix_hpos_col_str
+ {
+ c { \exp_not:N \centering }
+ l { \exp_not:N \raggedright }
+ r { \exp_not:N \raggedleft }
+ }
+ }
+ { \str_if_eq:VnT \l__nicematrix_vpos_col_str { m } \__nicematrix_center_cell_box: }
+ }
+ \int_gincr:N \c@jCol
+ \__nicematrix_patch_preamble_x:n
+ }
+\cs_new_protected:Npn \__nicematrix_patch_preamble_iv_v:nnnn #1 #2 #3 #4
{
\tl_gput_right:Nn \g__nicematrix_preamble_tl
{
> {
+ \dim_set:Nn \l__nicematrix_col_width_dim { #2 }
\__nicematrix_Cell:
- \begin { minipage } [ #1 ] { \dim_eval:n { #3 } }
+ \begin { minipage } [ #1 ] { #2 }
\everypar
{
\vrule height \box_ht:N \@arstrutbox width \c_zero_dim
\everypar { }
}
- \g__nicematrix_row_style_tl % added the 2021-07-17
+ #3
+ \g__nicematrix_row_style_tl
\arraybackslash
}
c
< {
\@finalstrut \@arstrutbox
\end { minipage }
- \str_if_eq:nnT { #2 } m \__nicematrix_center_cell_box:
+ #4
\__nicematrix_end_Cell:
}
}
- \int_gincr:N \c@jCol
- \__nicematrix_patch_preamble_x:n
}
\cs_new_protected:Npn \__nicematrix_center_cell_box:
{
- \tl_gput_right:Nn \g__nicematrix_post_treatment_cell_tl
+ \tl_gput_right:Nn \g__nicematrix_post_action_cell_tl
{
\int_compare:nNnT
{ \box_ht:N \l__nicematrix_cell_box }
@@ -1905,9 +1965,10 @@
\tl_gput_right:Nn \g__nicematrix_preamble_tl
{
> {
+ \dim_set:Nn \l__nicematrix_col_width_dim { #4 }
\hbox_set:Nw \l__nicematrix_cell_box
\__nicematrix_Cell:
- \tl_set:Nn \l__nicematrix_cell_type_tl { #3 }
+ \str_set:Nn \l__nicematrix_hpos_cell_str { #3 }
}
c
< {
@@ -2008,6 +2069,47 @@
\__nicematrix_patch_preamble:n #3
}
}
+\cs_new_protected:Npn \__nicematrix_patch_preamble_ix:n #1
+ {
+ \str_if_eq:nnTF { #1 } { [ }
+ { \__nicematrix_patch_preamble_ix_i:w [ }
+ { \__nicematrix_patch_preamble_ix_i:w [ ] #1 }
+ }
+\cs_new_protected:Npn \__nicematrix_patch_preamble_ix_i:w [ #1 ]
+ { \__nicematrix_patch_preamble_ix_ii:n { #1 } }
+\keys_define:nn { WithArrows / X-column }
+ { unknown .code:n = \int_set:Nn \l__nicematrix_weight_int { \l_keys_key_str } }
+\cs_new_protected:Npn \__nicematrix_patch_preamble_ix_ii:n #1
+ {
+ \str_set:Nn \l__nicematrix_hpos_col_str { j }
+ \tl_set:Nn \l__nicematrix_vpos_col_str { p }
+ \int_zero_new:N \l__nicematrix_weight_int
+ \int_set:Nn \l__nicematrix_weight_int { 1 }
+ \keys_set_known:nnN { WithArrows / p-column } { #1 } \l_tmpa_tl
+ \keys_set:nV { WithArrows / X-column } \l_tmpa_tl
+ \int_gadd:Nn \g__nicematrix_total_X_weight_int \l__nicematrix_weight_int
+ \bool_if:NTF \l__nicematrix_X_columns_aux_bool
+ { \__nicematrix_patch_preamble_iv_iv:n { \l__nicematrix_weight_int \l__nicematrix_X_columns_dim } }
+ {
+ \tl_gput_right:Nn \g__nicematrix_preamble_tl
+ {
+ > {
+ \__nicematrix_Cell:
+ \bool_set_true:N \l__nicematrix_X_column_bool
+ \tl_gput_right:Nn \g__nicematrix_post_action_cell_tl
+ { \hbox_set:Nn \l__nicematrix_cell_box { } }
+ \begin { minipage } { 5 cm } \arraybackslash
+ }
+ c
+ < {
+ \end { minipage }
+ \__nicematrix_end_Cell:
+ }
+ }
+ \int_gincr:N \c@jCol
+ \__nicematrix_patch_preamble_x:n
+ }
+ }
\cs_new_protected:Npn \__nicematrix_patch_preamble_xi:n #1
{
\tl_gput_right:Nn \g__nicematrix_preamble_tl
@@ -2019,7 +2121,7 @@
\cs_new_protected:Npn \__nicematrix_patch_preamble_x:n #1
{
\str_if_eq:nnTF { #1 } { < }
- \__nicematrix_patch_preamble_ix:n
+ \__nicematrix_patch_preamble_xii:n
{
\tl_if_eq:NnTF \l__nicematrix_vlines_clist { all }
{
@@ -2037,32 +2139,11 @@
\__nicematrix_patch_preamble:n { #1 }
}
}
-\cs_new_protected:Npn \__nicematrix_patch_preamble_ix:n #1
+\cs_new_protected:Npn \__nicematrix_patch_preamble_xii:n #1
{
\tl_gput_right:Nn \g__nicematrix_preamble_tl { < { #1 } }
\__nicematrix_patch_preamble_x:n
}
-\cs_new_protected:Npn \__nicematrix_patch_preamble_xii:
- {
- \int_gincr:N \g__nicematrix_nb_of_X_int
- \bool_if:NTF \l__nicematrix_X_columns_aux_bool
- { \exp_args:NNNV \__nicematrix_patch_preamble_iv:nnn t p \l__nicematrix_X_columns_dim }
- {
- \tl_gput_right:Nn \g__nicematrix_preamble_tl
- {
- > {
- \__nicematrix_Cell:
- \tl_set:Nn \l__nicematrix_cell_type_tl { c }
- \tl_gput_right:Nn \g__nicematrix_post_treatment_cell_tl
- { \hbox_set:Nn \l__nicematrix_cell_box { } }
- }
- c
- < { \__nicematrix_end_Cell: }
- }
- \int_gincr:N \c@jCol
- \__nicematrix_patch_preamble_x:n
- }
- }
\cs_new:Npn \__nicematrix_multicolumn:nnn #1 #2 #3
{
\multispan { #1 }
@@ -2115,9 +2196,6 @@
\__nicematrix_w: { \__nicematrix_patch_m_preamble_v:nnnn { } #1 }
\__nicematrix_W: { \__nicematrix_patch_m_preamble_v:nnnn { \cs_set_eq:NN \hss \hfil } #1 }
\__nicematrix_true_c: { \__nicematrix_patch_m_preamble_vi:n #1 }
- C { \__nicematrix_error:nn { old~column~type } #1 }
- L { \__nicematrix_error:nn { old~column~type } #1 }
- R { \__nicematrix_error:nn { old~column~type } #1 }
\q_stop { }
}
{ \__nicematrix_fatal:nn { unknown~column~type } { #1 } }
@@ -2126,7 +2204,7 @@
{
\tl_gput_right:Nn \g__nicematrix_preamble_tl
{
- > { \__nicematrix_Cell: \tl_set:Nn \l__nicematrix_cell_type_tl { #1 } }
+ > { \__nicematrix_Cell: \str_set:Nn \l__nicematrix_hpos_cell_str { #1 } }
#1
< \__nicematrix_end_Cell:
}
@@ -2169,7 +2247,7 @@
> {
\hbox_set:Nw \l__nicematrix_cell_box
\__nicematrix_Cell:
- \tl_set:Nn \l__nicematrix_cell_type_tl { #3 }
+ \str_set:Nn \l__nicematrix_hpos_cell_str { #3 }
}
c
< {
@@ -2799,12 +2877,24 @@
{ \bool_gset_true:N \g__nicematrix_not_empty_cell_bool }
\NewDocumentEnvironment { NiceTabular } { O { } m ! O { } }
{
+ \dim_zero_new:N \l__nicematrix_width_dim
+ \dim_set_eq:NN \l__nicematrix_width_dim \linewidth
\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 }
}
{ \endNiceArray }
+\NewDocumentEnvironment { NiceTabularX } { m O { } m ! O { } }
+ {
+ \str_gset:Nn \g__nicematrix_name_env_str { NiceTabularX }
+ \dim_zero_new:N \l__nicematrix_width_dim
+ \dim_set:Nn \l__nicematrix_width_dim { #1 }
+ \keys_set:nn { NiceMatrix / NiceTabular } { #2 , #4 }
+ \bool_set_true:N \l__nicematrix_NiceTabular_bool
+ \NiceArray { #3 }
+ }
+ { \endNiceArray }
\NewDocumentEnvironment { NiceTabular* } { m O { } m ! O { } }
{
\str_gset:Nn \g__nicematrix_name_env_str { NiceTabular* }
@@ -4152,6 +4242,7 @@
{ \tl_gput_right:cx { g__nicematrix_color _ \int_use:N \l_tmpa_int _tl } { #2 } }
}
\cs_generate_variant:Nn \__nicematrix_add_to_colors_seq:nn { x n }
+\cs_generate_variant:Nn \__nicematrix_add_to_colors_seq:nn { x x }
\cs_new_protected:Npn \__nicematrix_actually_color:
{
\pgfpicture
@@ -4170,36 +4261,30 @@
\tl_set:Nn \l_tmpa_tl { #1 }
\tl_set:Nn \l_tmpb_tl { #2 }
}
+\cs_new_protected:Npn \__nicematrix_cartesian_color:nn #1 #2
+ {
+ \tl_set:Nn \l__nicematrix_rows_tl { #1 }
+ \tl_set:Nn \l__nicematrix_cols_tl { #2 }
+ \__nicematrix_cartesian_path:
+ }
\NewDocumentCommand \__nicematrix_rowcolor { O { } m m }
{
\tl_if_blank:nF { #2 }
{
\__nicematrix_add_to_colors_seq:xn
{ \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } }
- { \__nicematrix_rowcolor:n { #3 } }
+ { \__nicematrix_cartesian_color:nn { #3 } { - } }
}
}
-\cs_new_protected:Npn \__nicematrix_rowcolor:n #1
- {
- \tl_set:Nn \l__nicematrix_rows_tl { #1 }
- \tl_set:Nn \l__nicematrix_cols_tl { - }
- \__nicematrix_cartesian_path:
- }
\NewDocumentCommand \__nicematrix_columncolor { O { } m m }
{
\tl_if_blank:nF { #2 }
{
\__nicematrix_add_to_colors_seq:xn
{ \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } }
- { \__nicematrix_columncolor:n { #3 } }
+ { \__nicematrix_cartesian_color:nn { - } { #3 } }
}
}
-\cs_new_protected:Npn \__nicematrix_columncolor:n #1
- {
- \tl_set:Nn \l__nicematrix_rows_tl { - }
- \tl_set:Nn \l__nicematrix_cols_tl { #1 }
- \__nicematrix_cartesian_path:
- }
\NewDocumentCommand \__nicematrix_rectanglecolor { O { } m m m }
{
\tl_if_blank:nF { #2 }
@@ -4266,13 +4351,16 @@
restart .default:n = true ,
unknown .code:n = \__nicematrix_error:n { Unknown~key~for~rowcolors }
}
-\NewDocumentCommand \__nicematrix_rowcolors { O { } m m m O { } }
+\NewDocumentCommand \__nicematrix_rowlistcolors { O { } m m O { } }
{
\group_begin:
+ \seq_clear_new:N \l__nicematrix_colors_seq
+ \seq_set_split:Nnn \l__nicematrix_colors_seq { , } { #3 }
\tl_clear_new:N \l__nicematrix_cols_tl
\tl_set:Nn \l__nicematrix_cols_tl { - }
- \keys_set:nn { NiceMatrix / rowcolors } { #5 }
- \bool_set_true:N \l_tmpa_bool
+ \keys_set:nn { NiceMatrix / rowcolors } { #4 }
+ \int_zero_new:N \l__nicematrix_color_int
+ \int_set:Nn \l__nicematrix_color_int 1
\bool_if:NT \l__nicematrix_respect_blocks_bool
{
\seq_set_eq:NN \l_tmpb_seq \g__nicematrix_pos_of_blocks_seq
@@ -4289,8 +4377,8 @@
{ \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } }
\int_set:Nn \l_tmpa_int \l_tmpa_tl
\bool_if:NTF \l__nicematrix_rowcolors_restart_bool
- { \bool_set_true:N \l_tmpa_bool }
- { \bool_set:Nn \l_tmpa_bool { \int_if_odd_p:n { \l_tmpa_tl } } }
+ { \int_set:Nn \l__nicematrix_color_int 1 }
+ { \int_set:Nn \l__nicematrix_color_int \l_tmpa_tl }
\int_zero_new:N \l_tmpc_int
\int_set:Nn \l_tmpc_int \l_tmpb_tl
\int_do_until:nNnn \l_tmpa_int > \l_tmpc_int
@@ -4304,37 +4392,38 @@
}
\tl_set:Nx \l__nicematrix_rows_tl
{ \int_use:N \l_tmpa_int - \int_use:N \l_tmpb_int }
- \bool_if:NTF \l_tmpa_bool
+ \tl_clear_new:N \l__nicematrix_color_tl
+ \tl_set:Nx \l__nicematrix_color_tl
{
- \tl_if_blank:nF { #3 }
+ \__nicematrix_color_index:n
{
- \tl_if_empty:nTF { #1 }
- \color
- { \color [ #1 ] }
- { #3 }
- \__nicematrix_cartesian_path:
- \pgfusepath { fill }
+ \int_mod:nn
+ { \l__nicematrix_color_int - 1 }
+ { \seq_count:N \l__nicematrix_colors_seq }
+ + 1
}
- \bool_set_false:N \l_tmpa_bool
}
+ \tl_if_empty:NF \l__nicematrix_color_tl
{
- \tl_if_blank:nF { #4 }
- {
- \tl_if_empty:nTF { #1 }
- \color
- { \color [ #1 ] }
- { #4 }
- \__nicematrix_cartesian_path:
- \pgfusepath { fill }
- }
- \bool_set_true:N \l_tmpa_bool
+ \__nicematrix_add_to_colors_seq:xx
+ { \tl_if_blank:nF { #1 } { [ #1 ] } { \l__nicematrix_color_tl } }
+ { \__nicematrix_cartesian_color:nn { \l__nicematrix_rows_tl } { \l__nicematrix_cols_tl } }
}
+ \int_incr:N \l__nicematrix_color_int
\int_set:Nn \l_tmpa_int { \l_tmpb_int + 1 }
}
}
\endpgfpicture
\group_end:
}
+\cs_new:Npn \__nicematrix_color_index:n #1
+ {
+ \str_if_eq:eeTF { \seq_item:Nn \l__nicematrix_colors_seq { #1 } } { = }
+ { \__nicematrix_color_index:n { #1 - 1 } }
+ { \seq_item:Nn \l__nicematrix_colors_seq { #1 } }
+ }
+\NewDocumentCommand \__nicematrix_rowcolors { O { } m m m O { } }
+ { \__nicematrix_rowlistcolors [ #1 ] { #2 } { { #3 } , { #4 } } [ #5 ] }
\cs_new_protected:Npn \__nicematrix_rowcolors_i:nnnn #1 #2 #3 #4
{
\int_compare:nNnT { #3 } > \l_tmpb_int
@@ -4716,9 +4805,12 @@
\dim_set_eq:NN \l_tmpb_dim \pgf@y
\__nicematrix_qpoint:n { col - \__nicematrix_succ:n { #4 } }
\dim_set_eq:NN \l_tmpc_dim \pgf@x
- \bool_lazy_and:nnT
- { \int_compare_p:nNn { #2 } > 1 }
- { ! \tl_if_blank_p:V \CT@drsc@ }
+ \bool_lazy_all:nT
+ {
+ { \int_compare_p:nNn { #2 } > 1 }
+ { \cs_if_exist_p:N \CT@drsc@ } % condition added in version 6.0
+ { ! \tl_if_blank_p:V \CT@drsc@ }
+ }
{
\group_begin:
\CT@drsc@
@@ -5251,21 +5343,21 @@
}
\keys_define:nn { NiceMatrix / Block / FirstPass }
{
- l .code:n = \tl_set:Nn \l__nicematrix_hpos_of_block_tl l ,
+ l .code:n = \str_set:Nn \l__nicematrix_hpos_block_str l ,
l .value_forbidden:n = true ,
- r .code:n = \tl_set:Nn \l__nicematrix_hpos_of_block_tl r ,
+ r .code:n = \str_set:Nn \l__nicematrix_hpos_block_str r ,
r .value_forbidden:n = true ,
- c .code:n = \tl_set:Nn \l__nicematrix_hpos_of_block_tl c ,
+ c .code:n = \str_set:Nn \l__nicematrix_hpos_block_str c ,
c .value_forbidden:n = true ,
- L .code:n = \tl_set:Nn \l__nicematrix_hpos_of_block_tl l ,
+ L .code:n = \str_set:Nn \l__nicematrix_hpos_block_str l ,
L .value_forbidden:n = true ,
- R .code:n = \tl_set:Nn \l__nicematrix_hpos_of_block_tl r ,
+ R .code:n = \str_set:Nn \l__nicematrix_hpos_block_str r ,
R .value_forbidden:n = true ,
- C .code:n = \tl_set:Nn \l__nicematrix_hpos_of_block_tl c ,
+ C .code:n = \str_set:Nn \l__nicematrix_hpos_block_str c ,
C .value_forbidden:n = true ,
- t .code:n = \tl_set:Nn \l__nicematrix_vpos_of_block_tl t ,
+ t .code:n = \str_set:Nn \l__nicematrix_vpos_of_block_tl t ,
t .value_forbidden:n = true ,
- b .code:n = \tl_set:Nn \l__nicematrix_vpos_of_block_tl b ,
+ b .code:n = \str_set:Nn \l__nicematrix_vpos_of_block_tl b ,
b .value_forbidden:n = true ,
color .tl_set:N = \l__nicematrix_color_tl ,
color .value_required:n = true ,
@@ -5295,11 +5387,11 @@
{ \int_set:Nn \l_tmpb_int { #2 } }
\int_compare:nNnTF \l_tmpb_int = 1
{
- \tl_if_empty:NTF \l__nicematrix_cell_type_tl
- { \tl_set:Nn \l__nicematrix_hpos_of_block_tl c }
- { \tl_set_eq:NN \l__nicematrix_hpos_of_block_tl \l__nicematrix_cell_type_tl }
+ \str_if_empty:NTF \l__nicematrix_hpos_cell_str
+ { \str_set:Nn \l__nicematrix_hpos_block_str c }
+ { \str_set_eq:NN \l__nicematrix_hpos_block_str \l__nicematrix_hpos_cell_str }
}
- { \tl_set:Nn \l__nicematrix_hpos_of_block_tl c }
+ { \str_set:Nn \l__nicematrix_hpos_block_str c }
\keys_set_known:nn { NiceMatrix / Block / FirstPass } { #3 }
\tl_set:Nx \l_tmpa_tl
{
@@ -5316,6 +5408,7 @@
\int_compare_p:nNn { \l_tmpb_int } = 1
)
&& ! \tl_if_empty_p:n { #5 }
+ && ! \l__nicematrix_X_column_bool
}
{ \exp_args:Nxx \__nicematrix_Block_iv:nnnnn }
{ \exp_args:Nxx \__nicematrix_Block_v:nnnnn }
@@ -5349,23 +5442,40 @@
\cs_set:Npn \arraystretch { 1 }
\dim_set_eq:NN \extrarowheight \c_zero_dim
#4
- \bool_if:NT \g__nicematrix_rotate_bool { \tl_set:Nn \l__nicematrix_hpos_of_block_tl c }
+ \bool_if:NT \g__nicematrix_rotate_bool { \str_set:Nn \l__nicematrix_hpos_block_str c }
\bool_if:NTF \l__nicematrix_NiceTabular_bool
{
- \use:x
+ \bool_lazy_and:nnTF
+ { \int_compare_p:nNn { #2 } = 1 }
+ { \dim_compare_p:n { \l__nicematrix_col_width_dim >= \c_zero_dim } }
{
- \exp_not:N \begin { tabular } [ \l__nicematrix_vpos_of_block_tl ]
- { @ { } \l__nicematrix_hpos_of_block_tl @ { } }
+ \begin { minipage } [ l__nicematrix_vpos_of_block_tl ]
+ { \l__nicematrix_col_width_dim }
+ \str_case:Vn \l__nicematrix_hpos_block_str
+ {
+ c \centering
+ r \raggedleft
+ l \raggedright
+ }
+ #5
+ \end { minipage }
+ }
+ {
+ \use:x
+ {
+ \exp_not:N \begin { tabular } [ \l__nicematrix_vpos_of_block_tl ]
+ { @ { } \l__nicematrix_hpos_block_str @ { } }
+ }
+ #5
+ \end { tabular }
}
- #5
- \end { tabular }
}
{
\c_math_toggle_token
\use:x
{
\exp_not:N \begin { array } [ \l__nicematrix_vpos_of_block_tl ]
- { @ { } \l__nicematrix_hpos_of_block_tl @ { } }
+ { @ { } \l__nicematrix_hpos_block_str @ { } }
}
#5
\end { array }
@@ -5416,7 +5526,7 @@
\seq_gput_right:Nx \g__nicematrix_blocks_seq
{
\l_tmpa_tl
- { \exp_not:n { #3 } , \l__nicematrix_hpos_of_block_tl }
+ { \exp_not:n { #3 } , \l__nicematrix_hpos_block_str }
{
\box_use_drop:c
{ g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box }
@@ -5439,11 +5549,11 @@
\dim_set_eq:NN \extrarowheight \c_zero_dim
#4
\bool_if:NT \g__nicematrix_rotate_bool
- { \tl_set:Nn \l__nicematrix_hpos_of_block_tl c }
+ { \str_set:Nn \l__nicematrix_hpos_block_str c }
\use:x
{
\exp_not:N \begin { tabular } [ \l__nicematrix_vpos_of_block_tl ]
- { @ { } \l__nicematrix_hpos_of_block_tl @ { } }
+ { @ { } \l__nicematrix_hpos_block_str @ { } }
}
#5
\end { tabular }
@@ -5455,12 +5565,12 @@
\dim_set_eq:NN \extrarowheight \c_zero_dim
#4
\bool_if:NT \g__nicematrix_rotate_bool
- { \tl_set:Nn \l__nicematrix_hpos_of_block_tl c }
+ { \str_set:Nn \l__nicematrix_hpos_block_str c }
\c_math_toggle_token
\use:x
{
\exp_not:N \begin { array } [ \l__nicematrix_vpos_of_block_tl ]
- { @ { } \l__nicematrix_hpos_of_block_tl @ { } }
+ { @ { } \l__nicematrix_hpos_block_str @ { } }
}
#5
\end { array }
@@ -5492,24 +5602,24 @@
hvlines .default:n = true ,
line-width .dim_set:N = \l__nicematrix_line_width_dim ,
line-width .value_required:n = true ,
- l .code:n = \tl_set:Nn \l__nicematrix_hpos_of_block_tl l ,
+ l .code:n = \str_set:Nn \l__nicematrix_hpos_block_str l ,
l .value_forbidden:n = true ,
- r .code:n = \tl_set:Nn \l__nicematrix_hpos_of_block_tl r ,
+ r .code:n = \str_set:Nn \l__nicematrix_hpos_block_str r ,
r .value_forbidden:n = true ,
- c .code:n = \tl_set:Nn \l__nicematrix_hpos_of_block_tl c ,
+ c .code:n = \str_set:Nn \l__nicematrix_hpos_block_str c ,
c .value_forbidden:n = true ,
- L .code:n = \tl_set:Nn \l__nicematrix_hpos_of_block_tl l
+ L .code:n = \str_set:Nn \l__nicematrix_hpos_block_str l
\bool_set_true:N \l__nicematrix_hpos_of_block_cap_bool ,
L .value_forbidden:n = true ,
- R .code:n = \tl_set:Nn \l__nicematrix_hpos_of_block_tl r
+ R .code:n = \str_set:Nn \l__nicematrix_hpos_block_str r
\bool_set_true:N \l__nicematrix_hpos_of_block_cap_bool ,
R .value_forbidden:n = true ,
- C .code:n = \tl_set:Nn \l__nicematrix_hpos_of_block_tl c
+ C .code:n = \str_set:Nn \l__nicematrix_hpos_block_str c
\bool_set_true:N \l__nicematrix_hpos_of_block_cap_bool ,
C .value_forbidden:n = true ,
- t .code:n = \tl_set:Nn \l__nicematrix_vpos_of_block_tl t ,
+ t .code:n = \str_set:Nn \l__nicematrix_vpos_of_block_tl t ,
t .value_forbidden:n = true ,
- b .code:n = \tl_set:Nn \l__nicematrix_vpos_of_block_tl b ,
+ b .code:n = \str_set:Nn \l__nicematrix_vpos_of_block_tl b ,
b .value_forbidden:n = true ,
unknown .code:n = \__nicematrix_error:n { Unknown~key~for~Block }
}
@@ -5713,7 +5823,7 @@
\bool_if:NF \l__nicematrix_hpos_of_block_cap_bool { - short }
}
{
- \str_case:Vn \l__nicematrix_hpos_of_block_tl
+ \str_case:Vn \l__nicematrix_hpos_block_str
{
c { center }
l { west }
@@ -5725,7 +5835,7 @@
\pgfnode
{ rectangle }
{
- \str_case:Vn \l__nicematrix_hpos_of_block_tl
+ \str_case:Vn \l__nicematrix_hpos_block_str
{
c { base }
l { base~west }
@@ -5736,11 +5846,11 @@
}
{
\int_compare:nNnT { #2 } = 0
- { \tl_set:Nn \l__nicematrix_hpos_of_block_tl r }
+ { \str_set:Nn \l__nicematrix_hpos_block_str r }
\bool_if:nT \g__nicematrix_last_col_found_bool
{
\int_compare:nNnT { #2 } = \g__nicematrix_col_total_int
- { \tl_set:Nn \l__nicematrix_hpos_of_block_tl l }
+ { \str_set:Nn \l__nicematrix_hpos_block_str l }
}
\pgftransformshift
{
@@ -5750,7 +5860,7 @@
\bool_if:NF \l__nicematrix_hpos_of_block_cap_bool { - short }
}
{
- \str_case:Vn \l__nicematrix_hpos_of_block_tl
+ \str_case:Vn \l__nicematrix_hpos_block_str
{
c { center }
l { west }
@@ -5762,7 +5872,7 @@
\pgfnode
{ rectangle }
{
- \str_case:Vn \l__nicematrix_hpos_of_block_tl
+ \str_case:Vn \l__nicematrix_hpos_block_str
{
c { center }
l { west }
@@ -6566,7 +6676,6 @@
}
{
The~available~keys~are~(in~alphabetic~order):~
- define-L-C-R,~
footnote,~
footnotehyper,~
renew-dots,~and
@@ -6578,17 +6687,8 @@
is~not~clear).~You~should~use~the~conjonction~of~'renew-dots'~
and~'renew-matrix'.~However,~you~can~go~on.
}
-\__nicematrix_msg_new:nn { define-L-C-R }
- {
- You~have~used~the~key~'define-L-C-R'.~Please~note~that~this~key~
- will~probably~be~deleted~in~a~future~version~of~'nicematrix'.\\
- However,~you~can~go~on.
- }
\keys_define:nn { NiceMatrix / Package }
{
- define-L-C-R .code:n =
- \__nicematrix_error:n { define-L-C-R }
- \bool_set_true:N \c__nicematrix_define_L_C_R_bool ,
renew-dots .bool_set:N = \l__nicematrix_renew_dots_bool ,
renew-dots .value_forbidden:n = true ,
renew-matrix .code:n = \__nicematrix_renew_matrix: ,
@@ -6786,13 +6886,6 @@
The~key~'standard-cline'~is~available~only~in~the~preamble.\\
If~you~go~on~this~command~will~be~ignored.
}
-\__nicematrix_msg_new:nn { old~column~type }
- {
- The~column~type~'#1'~is~no~longer~defined~in~'nicematrix'.~
- Since~version~5.0,~you~have~to~use~'l',~'c'~and~'r'~instead~of~'L',~
- 'C'~and~'R'.~You~can~also~use~the~key~'define-L-C-R'.\\
- This~error~is~fatal.
- }
\__nicematrix_msg_new:nn { bad~value~for~baseline }
{
The~value~given~to~'baseline'~(\int_use:N \l_tmpa_int)~is~not~
@@ -6822,6 +6915,11 @@
{ ~Maybe~you~should~try~without~the~key~'slim'. } \\
If~you~go~on,~this~\token_to_str:N \SubMatrix\ will~be~ignored.
}
+\__nicematrix_msg_new:nn { width~without~X~columns }
+ {
+ You~have~used~the~key~'width'~but~you~have~put~no~'X'~column. \\
+ If~you~go~on,~that~key~will~be~ignored.
+ }
\__nicematrix_msg_new:nn { empty~environment }
{ Your~\__nicematrix_full_name_env:\ is~empty.~This~error~is~fatal. }
\__nicematrix_msg_new:nn { Delimiter~with~small }