diff options
author | Karl Berry <karl@freefriends.org> | 2020-05-09 22:07:16 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-05-09 22:07:16 +0000 |
commit | 3cb19e743727ad232d61a03a83bc57c8ae02901b (patch) | |
tree | 2b7d39256904d67aef4c52729feee7fb5134d3ce /Master | |
parent | a3a851278882764f613b4a2e225d4bdc40ca96ae (diff) |
nicematrix (10may20)
git-svn-id: svn://tug.org/texlive/trunk@55079 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf | bin | 343415 -> 349092 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex | 423 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf | bin | 814877 -> 845357 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx | 2952 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | 1565 |
5 files changed, 3446 insertions, 1494 deletions
diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf Binary files differindex 26f4bdf64ae..5e5910a1ed6 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex index 27ec881c96f..7adcadf7389 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex @@ -10,8 +10,9 @@ \usepackage{amsmath} \usepackage{array} -\usepackage{colortbl} \usepackage{nicematrix} +% \usepackage{colortbl} + \usepackage{tikz} \usetikzlibrary{fit} @@ -21,7 +22,7 @@ \usepackage{siunitx} -\usepackage{arydshln} +% \usepackage{arydshln} \usepackage{verbatim} % We use \MakeShortVerb of shortvrb and not \DefineShortVerb of fancyvrb @@ -84,9 +85,9 @@ \begin{abstract} L'extension LaTeX \pkg{nicematrix} fournit de nouveaux environnements similaires aux environnements classiques -|{array}| et |{matrix}| mais avec des fonctionnalités supplémentaires. Parmi ces fonctionnalités figurent la -possibilité de fixer la largeur des colonnes et de tracer des traits en pointillés continus entre les cases du -tableau. +|{tabular}|, |{array}| et |{matrix}| mais avec des fonctionnalités supplémentaires. Parmi ces fonctionnalités +figurent la possibilité de fixer la largeur des colonnes et de tracer des traits en pointillés continus entre les +cases du tableau. \end{abstract} \vspace{1cm} @@ -107,9 +108,7 @@ l'instruction habituelle : |\usepackage{nicematrix}|. Cette extension fournit quelques outils supplémentaires pour dessiner des matrices (au sens mathématique). Les principales caractéristiques sont les suivantes : \begin{itemize}\setlength{\itemsep}{0pt} -\item des lignes en pointillés continues\footnote{Si l'option de classe -\texttt{draft} est utilisée, ces lignes en pointillés ne sont pas tracées pour -accélérer la compilation.} ; +\item des lignes en pointillés continues ; \item des rangées et colonnes extérieures pour les labels ; \item un contrôle sur la largeur des colonnes. \end{itemize} @@ -134,9 +133,6 @@ L_n & a_{n1} & a_{n2} & \Cdots & a_{nn} Une commande|\NiceMatrixOptions| est fournie pour régler les options (la portée des options fixées par cette commande est le groupe TeX courant). - - - \bigskip \textbf{Un exemple d'utilisation pour les lignes en pointillés continues} @@ -193,17 +189,17 @@ L'extension \pkg{nicematrix} définit les nouveaux environnements suivants : \begin{ttfamily} \setlength{\tabcolsep}{3mm} \begin{tabular}{llll} -\{NiceMatrix\} & \{NiceArray\} & \{pNiceArray\} \\ -\{pNiceMatrix\} & & \{bNiceArray\} \\ -\{bNiceMatrix\} & & \{BNiceArray\} \\ -\{BNiceMatrix\} & & \{vNiceArray\} \\ -\{vNiceMatrix\} & & \{VNiceArray\} \\ -\{VNiceMatrix\} & & \{NiceArrayWithDelims\} \\ +\{NiceMatrix\} & \{NiceArray\} & \{NiceTabular\} \\ +\{pNiceMatrix\} & \{pNiceArray\} \\ +\{bNiceMatrix\} & \{bNiceArray\} \\ +\{BNiceMatrix\} & \{BNiceArray\} \\ +\{vNiceMatrix\} & \{vNiceArray\} \\ +\{VNiceMatrix\} & \{VNiceArray\} \\ + & \{NiceArrayWithDelims\} \end{tabular} \end{ttfamily} - \medskip Par défaut, les environnements |{NiceMatrix}|, |{pNiceMatrix}|, |{bNiceMatrix}|, |{BNiceMatrix}|, |{vNiceMatrix}| et |{VNiceMatrix}| se comportent quasiment comme les environnements correspondants de \pkg{amsmath} : |{matrix}|, @@ -211,13 +207,13 @@ et |{VNiceMatrix}| se comportent quasiment comme les environnements correspondan \medskip -L'environnement |{NiceArray}| est similaire à l'environnement |{array}| de l'extension |{array}|. Néanmoins, pour -des raisons techniques, dans le préambule de l'environnement |{NiceArray}|, l'utilisateur doit utiliser les lettres -|L|, |C| et~|R| au lieu de |l|, |c| et |r|. Il est possible d'utiliser les constructions |w{...}{...}|, -|W{...}{...}|\footnote{Pour les colonnes de type |w| et |W|, les cases sont composées en mode mathématique (dans - les environnements de \pkg{nicematrix}) alors que dans |{array}| de \pkg{array}, elles sont composées en mode - texte.}, \verb+|+, |>{...}|, |<{...}|, |@{...}|, |!{...}| et |*{n}{...}| mais les lettres |p|, |m| et |b| ne -doivent pas être employées. Voir p.~\pageref{NiceArray} la partie concernant |{NiceArray}|. +Les environnements |{NiceArray}| et |{NiceTabular}| sont similaires aux environnements |{array}| et |{tabular}| de +l'extension |{array}|. Néanmoins, pour des raisons techniques, dans le préambule de ces environnements, +l'utilisateur doit utiliser les lettres |L|, |C| et~|R| au lieu de |l|, |c| et |r|. Il est possible d'utiliser les +constructions |p{...}|, |m{...}|, |b{...}|, |w{...}{...}|, |W{...}{...}|, \verb+|+, |>{...}|, |<{...}|, |@{...}|, +|!{...}| et |*{n}{...}|. + +Voir p.~\pageref{NiceArray} la partie concernant |{NiceArray}| et |{NiceTabular}|. \section{Les lignes en pointillés continues} @@ -358,12 +354,12 @@ Considérons la matrice suivante qui a été composée classiquement avec l'envi \begin{BVerbatim}[baseline=c,boxwidth=10cm] $A = \begin{pmatrix} h & i & j & k & l & m \\ -x & & & & & x \\ +x & & & & & x \end{pmatrix}$ \end{BVerbatim} $A = \begin{pmatrix} h & i & j & k & l & m \\ -x & & & & & x \\ +x & & & & & x \end{pmatrix}$ @@ -375,12 +371,12 @@ modifiée.\par\nobreak \begin{BVerbatim}[baseline=c,boxwidth=10cm] $B = \begin{pmatrix} h & i & j & k & l & m \\ -x & \ldots & \ldots & \ldots & \ldots & x \\ +x & \ldots & \ldots & \ldots & \ldots & x \end{pmatrix}$ \end{BVerbatim} $B = \begin{pmatrix} h & i & j & k & l & m \\ -x & \ldots & \ldots & \ldots & \ldots & x \\ +x & \ldots & \ldots & \ldots & \ldots & x \end{pmatrix}$ \bigskip @@ -391,12 +387,12 @@ géométrie de la matrice n'est pas changée.\par\nobreak \begin{BVerbatim}[baseline=c,boxwidth=10cm] $C = \begin{pNiceMatrix} h & i & j & k & l & m \\ -x & \Ldots & \Ldots & \Ldots & \Ldots & x \\ +x & \Ldots & \Ldots & \Ldots & \Ldots & x \end{pNiceMatrix}$ \end{BVerbatim} $C = \begin{pNiceMatrix} h & i & j & k & l & m \\ -x & \Ldots & \Ldots & \Ldots & \Ldots & x \\ +x & \Ldots & \Ldots & \Ldots & \Ldots & x \end{pNiceMatrix}$ \bigskip @@ -408,12 +404,12 @@ seule instruction |\Ldots| suffit).\par\nobreak \begin{BVerbatim}[baseline=c,boxwidth=10cm] $D = \begin{pNiceMatrix}[~emphase#nullify-dots@] h & i & j & k & l & m \\ -x & \Ldots & & & & x \\ +x & \Ldots & & & & x \end{pNiceMatrix}$ \end{BVerbatim} $D = \begin{pNiceMatrix}[nullify-dots] h & i & j & k & l & m \\ -x & \Ldots & & & & x \\ +x & \Ldots & & & & x \end{pNiceMatrix}$ \medskip @@ -459,7 +455,7 @@ $\begin{pNiceMatrix} 1 & 2 & 3 & 4 & 5 \\ & ~emphase#\Hdotsfor{3}@ \\ 1 & 2 & 3 & 4 & 5 \\ -1 & 2 & 3 & 4 & 5 \\ +1 & 2 & 3 & 4 & 5 \end{pNiceMatrix}$ \end{BVerbatim} $\begin{pNiceMatrix} @@ -469,7 +465,7 @@ $\begin{pNiceMatrix} 1 & 2 & 3 & 4 & 5 \end{pNiceMatrix}$ - +\medskip Remarque : Contrairement à la commande |\hdotsfor| de \pkg{amsmath}, la commande |\Hdotsfor| est utilisable lorsque l'extension \pkg{colortbl} est chargée (mais vous risquez d'avoir des problèmes si vous utilisez |\rowcolor| sur la même rangée que |\Hdotsfor|). @@ -535,13 +531,13 @@ sont composés en mode mathématique avec |\scriptstyle|. $\begin{bNiceMatrix} 1 & \hspace*{1cm} & 0 \\[8mm] & ~emphase#\Ddots^{n \text{ times}}@ & \\ -0 & & 1 \\ +0 & & 1 \end{bNiceMatrix}$ \end{BVerbatim} $\begin{bNiceMatrix} 1 & \hspace*{1cm} & 0 \\[8mm] & \Ddots^{n \text{ times}} & \\ -0 & & 1 \\ +0 & & 1 \end{bNiceMatrix}$ \subsection{Personnalisation des lignes en pointillés} @@ -606,7 +602,7 @@ carrés et non pas ronds.\footnote{La raison de départ est que le format \texts \bigskip Voulant proposer des lignes avec des points ronds dans le style de celui de |\ldots| (au moins celui des fontes \emph{Computer Modern}), l'extension \pkg{nicematrix} contient en interne son propre système de ligne en pointillés -(qui, au passage n'utilise que \pkg{pgf} et non \pkg{tikz}). Ce style est appelé le style |standard|. Cette valeur +(qui, au passage, n'utilise que \pkg{pgf} et non \pkg{tikz}). Ce style est appelé le style |standard|. Cette valeur est la valeur initiale du paramètre |xdots/line-style|. \bigskip @@ -883,45 +879,23 @@ I & 0 & \Cdots &0 \\ \medskip Pour améliorer la lisibilité du code, une syntaxe alternative est proposée : on peut spécifier les instructions du -|code-after| à la fin de l'environnement, après le mot-clé |\CodeAfter|. +|code-after| à la fin de l'environnement, après le mot-clé |\CodeAfter|. Pour un exemple, voir page +\pageref{exemple-CodeAfter}. -\medskip -\begin{BVerbatim}[baseline=c,boxwidth=11cm] -\NiceMatrixOptions{xdots/shorten = 0.6 em} -\begin{pNiceMatrix} -I & 0 & \Cdots &0 \\ -0 & I & \Ddots &\Vdots\\ -\Vdots &\Ddots & I &0 \\ -0 &\Cdots & 0 &I -~emphase#\CodeAfter@ -~emphase#\line{2-2}{3-3}@ -\end{pNiceMatrix} -\end{BVerbatim} -\begin{scope} -\NiceMatrixOptions{xdots/shorten = 0.6 em} -$\begin{pNiceMatrix} -I & 0 & \Cdots &0 \\ -0 & I & \Ddots &\Vdots\\ -\Vdots &\Ddots & I &0 \\ -0 &\Cdots & 0 &I -\CodeAfter -\line{2-2}{3-3} -\end{pNiceMatrix}$ -\end{scope} - - -\section{L'environnement \{NiceArray\} et ses variantes} +\section{Les environnements \{NiceArray\} et \{NiceTabular\}} \label{NiceArray} -L'environnement |{NiceArray}| est similaire à l'environnement |{array}|. Comme pour |{array}|, l'argument -obligatoire est le préambule du tableau. Néanmoins, pour des raisons techniques, l'utilisateur doit utiliser les -lettres |L|, |C| et |R|\footnote{Les types de colonnes |L|, |C| et |R| sont définis localement à l'intérieur de - |{NiceArray}| avec la commande |\newcolumntype| de \pkg{array}. Cette définition masque une éventuelle définition - précédente. En fait, les types de colonnes |w| et |W| sont également redéfinis.} au lieu de |l|, |c| et |r|. +Les environnements |{NiceArray}| et |{NiceTabular}| sont similaires aux environnements |{array}| et |{tabular}|. +L'argument obligatoire est le préambule du tableau. Néanmoins, pour des raisons techniques, l'utilisateur doit +utiliser les lettres |L|, |C| et |R|\footnote{Les types de colonnes |L|, |C| et |R| sont définis localement à + l'intérieur de |{NiceArray}| avec la commande |\newcolumntype| de \pkg{array}. Cette définition masque une + éventuelle définition précédente.} au lieu de |l|, |c| et |r|. Dans une commande |\multicolumn|, on doit +également utiliser les lettres |L|, |C| et |R|. -Il est possible d'utiliser les constructions |w{...}{...}|, |W{...}{...}|, \verb+|+, |>{...}|, |<{...}|, |@{...}|, -|!{...}| et |*{n}{...}| mais les lettres |p|, |m| et |b| ne doivent pas être employées.\footnote{Dans une commande - |\multicolumn|, on doit également utiliser les lettres |L|, |C| et |R|.} +Il est possible d'utiliser les constructions |p{...}|, |m{...}|, |b{...}|, |w{...}{...}|, |W{...}{...}|, \verb+|+, +|>{...}|, |<{...}|, |@{...}|, |!{...}| et |*{n}{...}|. Néanmoins, dans l'environnement |{NiceArray}| (et ses +variantes), le contenu des colonnes de type |w| ou |W| est composé en mode mathématique (dans |{array}| de +\pkg{array}, elles sont composées en mode texte). \bigskip Sans surprise, l'extension \pkg{nicematrix} fournit également les variantes |{pNiceArray}|, |{vNiceArray}|, @@ -980,26 +954,26 @@ $\begin{~emphase#NiceArrayWithDelims@} {\downarrow}{\uparrow}{CCC}[margin] 1 & 2 & 3 \\ 4 & 5 & 6 \\ -7 & 8 & 9 \\ +7 & 8 & 9 \end{~emphase#NiceArrayWithDelims@}$ \end{BVerbatim} $\begin{NiceArrayWithDelims} {\downarrow}{\uparrow}{CCC}[margin] 1 & 2 & 3 \\ 4 & 5 & 6 \\ -7 & 8 & 9 \\ +7 & 8 & 9 \end{NiceArrayWithDelims}$ \bigskip \subsection{Le positionnement vertical des matrices} -L'extension \pkg{nicematrix} propose aussi une option |baseline| par la position verticale des matrices. Cette +L'extension \pkg{nicematrix} propose aussi une option |baseline| pour la position verticale des matrices. Cette option |baseline| prend comme valeur un entier qui indique le numéro de rangée dont la ligne de base servira de -ligne de base pour l'environnement |{NiceArray}|. +ligne de base pour le tableau. \medskip \begin{BVerbatim}[baseline=c,boxwidth=9cm] -$A = \begin{pNiceMatrix}[baseline=2] +$A = \begin{pNiceMatrix}[~emphase#baseline=2@] \frac{1}{\sqrt{1+p^2}} & p & 1-p \\ 1 & 1 & 1 \\ 1 & p & 1+p @@ -1134,7 +1108,7 @@ colonne |L| pour la dernière. composition de la «dernière rangée» et de la «dernière colonne». \begin{itemize} -\item Dans le cas d'un environnement avec préambule, comme |{NiceArray}| ou |{pNiceArray}|, le nombre de colonnes +\item Dans le cas d'un environnement avec préambule, comme |{NiceTabular}| ou |{pNiceArray}|, le nombre de colonnes se déduit évidemment du préambule. \item Dans le cas où l'option |light-syntax| (cf. p. \pageref{light-syntax}) est utilisée, \pkg{nicematrix} profite @@ -1146,7 +1120,7 @@ l'environnement donne le nombre de rangées (mais pas le nombre de colonnes). et l'écrit dans le fichier |.aux| pour pouvoir l'utiliser à la compilation suivante. \textsl{Néanmoins, il est possible de donner le numéro de la dernière rangée et le numéro de la dernière colonne en -arguments des options |last-row| et |last-col| pour ce qui permettra d'accélérer le processus complet de +arguments des options |last-row| et |last-col|, ce qui permettra d'accélérer le processus complet de compilation.} C'est ce que nous ferons dans la suite. \end{itemize} @@ -1294,36 +1268,7 @@ C_1 & C_2 & C_3 & C_4 \\ \bigskip Il est possible de changer dans \pkg{nicematrix} la lettre utilisée pour indiquer dans le préambule un trait -vertical en pointillés avec l'option |letter-for-dotted-lines| disponible dans |\NiceMatrixOptions|. Par exemple, -dans ce document, nous avons chargé l'extension \pkg{arydshln} qui utilise la lettre «|:|» pour indiquer un trait -vertical en tiretés. Par conséquent, en utilisant l'option |letter-for-dotted-lines|, on peut utiliser les traits -verticaux fournis à la fois par \pkg{arydshln} et par \pkg{nicematrix}. - - -\medskip -\begin{BVerbatim}[baseline=c,boxwidth=9.5cm] -\NiceMatrixOptions{letter-for-dotted-lines = I} -\arrayrulecolor{blue} -\begin{pNiceArray}{~emphase#C|C:CIC@} -1 & 2 & 3 & 4 \\ -5 & 6 & 7 & 8 \\ -9 & 10 & 11 & 12 -\end{pNiceArray} -\arrayrulecolor{black} -\end{BVerbatim} -\begin{scope} -\arrayrulecolor{blue} -\NiceMatrixOptions{letter-for-dotted-lines = I} -$\begin{pNiceArray}{C|C:CIC} -1 & 2 & 3 & 4 \\ -5 & 6 & 7 & 8 \\ -9 & 10 & 11 & 12 -\end{pNiceArray}$ -\arrayrulecolor{black} -\end{scope} - -\smallskip -On a utilisé |\arrayrulecolor| de \pkg{colortbl} pour colorier les trois traits. +vertical en pointillés avec l'option |letter-for-dotted-lines| disponible dans |\NiceMatrixOptions|. \bigskip @@ -1540,6 +1485,175 @@ Pour des raisons techniques, il n'est pas possible d'écrire |\Block{|$i$|-|$j$| (mais on peut écrire |\Block{|$i$|-|$j$|}<>{<}| avec le résultat attendu). +\section{Les couleurs des rangées et des colonnes} + +L'extension \pkg{colortbl} permet de colorier des cellules, des rangées ou des colonnes d'un tableau. Néanmoins, +l'affichage du \textsc{pdf} résultant n'est pas toujours parfait, en particulier quand on utilise également des +filets. Dans certains lecteurs de \textsc{pdf}, des filets verticaux semblent disparaître. De fines lignes +blanches peuvent également apparaître. + +\medskip +La version 4.0 de \pkg{nicematrix} propose des outils similaires qui ne présentent pas ces inconvénients. Elle +propose une option |code-before| pour du code qui sera exécuté \emph{avant} le tracé du tableau. Dans ce +|code-before|, de nouvelles commandes sont disponibles : |\cellcolor|, |\rectanglecolor|, |\rowcolor|, +|\columncolor|, |\rowcolors| et |\chessboardcolors|. + +\medskip +\begin{itemize} +\item La commande |\cellcolor| tient son nom de la commande |\cellcolor| de \pkg{colortbl}. + +Elle prend en arguments une couleur et une liste de cellules sous le format $i$-$j$ où $i$ est le numéro de ligne +et $j$ le numéro de colonne. + +\medskip +\begin{scope} +\hfuzz=10cm +\begin{BVerbatim}[boxwidth=10cm,baseline=c] +\begin{NiceTabular}{|C|C|C|}[code-before = ~emphase#\cellcolor{red!15}{3-1,2-2,1-3}@] +\hline +a & b & c \\ \hline +e & f & g \\ \hline +h & i & j \\ \hline +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{|C|C|C|}[code-before = \cellcolor{red!15}{3-1,2-2,1-3}] +\hline +a & b & c \\ \hline +e & f & g \\ \hline +h & i & j \\ \hline +\end{NiceTabular} +\end{scope} + +\bigskip +\item La commande |\rectanglecolor| prend trois arguments. Le premier est la couleur, les deux suivants fournissent +la case en haut à gauche et la case en bas à droite du rectangle. + +\medskip +\begin{scope} +\hfuzz=10cm +\begin{BVerbatim}[boxwidth=10cm,baseline=c] +\begin{NiceTabular}{|C|C|C|}[code-before = ~emphase#\rectanglecolor{red!15}{2-2}{3-3}@] +\hline +a & b & c \\ \hline +e & f & g \\ \hline +h & i & j \\ \hline +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{|C|C|C|}[code-before = \rectanglecolor{red!15}{2-2}{3-3}] +\hline +a & b & c \\ \hline +e & f & g \\ \hline +h & i & j \\ \hline +\end{NiceTabular} +\end{scope} + + + +\bigskip +\item La commande |\rowcolor| doit son nom à la commande |\rowcolor| de \pkg{colortbl}. Son premier argument est la +couleur et le deuxième est une liste de numéros de rangées ou bien d'intervalles de rangées sous la forme +$a$-$b$ (un intervalle de la forme $a$- représente toutes les rangées à partir de la rangée~$a$). + +\medskip + +\begin{scope} +\hfuzz=10cm +\begin{BVerbatim}[boxwidth=9cm,baseline=c] +$\begin{NiceArray}{LLL}[hvlines, ~emphase#code-before = \rowcolor{red!15}{1,3-5,8-}@] +a_1 & b_1 & c_1 \\ +a_2 & b_2 & c_2 \\ +a_3 & b_3 & c_3 \\ +a_4 & b_4 & c_4 \\ +a_5 & b_5 & c_5 \\ +a_6 & b_6 & c_6 \\ +a_7 & b_7 & c_7 \\ +a_8 & b_8 & c_8 \\ +a_9 & b_9 & c_9 \\ +a_{10} & b_{10} & c_{10} \\ +\end{NiceArray}$ +\end{BVerbatim} +% +$\begin{NiceArray}{LLL}% +[baseline=4,hvlines, code-before = \rowcolor{red!15}{1,3-5,8-}] +a_1 & b_1 & c_1 \\ +a_2 & b_2 & c_2 \\ +a_3 & b_3 & c_3 \\ +a_4 & b_4 & c_4 \\ +a_5 & b_5 & c_5 \\ +a_6 & b_6 & c_6 \\ +a_7 & b_7 & c_7 \\ +a_8 & b_8 & c_8 \\ +a_9 & b_9 & c_9 \\ +a_{10} & b_{10} & c_{10} \\ +\end{NiceArray}$ +\end{scope} + + +\bigskip +\item La commande |\columncolor| doit son nom à la commande |\columncolor| de \pkg{colortbl}. Sa syntaxe est +similaire à celle de |\rowcolor|. + +\bigskip +\item La commande |\rowcolors| (avec un \emph{s}) doit son nom à la commande |\rowcolors| de \pkg{xcolor}. Le +\emph{s} rappelle qu'il y a deux couleurs. Elle colorie alternativement les rangées avec les deux couleurs à partir +de la rangée dont le numéro est donné en premier argument. + +\medskip + + +\begin{scope} +\hfuzz=10cm +\begin{BVerbatim}[baseline=c,boxwidth=9cm] +\begin{NiceTabular}{LR}% +[~emphase#code-before = \rowcolor{red!15}{1} \rowcolors{3}{blue!10}{}@] +\toprule +Ville & habitants \\ +\midrule +Pau & 80000 \\ +Paris & 2000000 \\ +Toulouse & 700000 \\ +Reims & 40000 \\ +\bottomrule +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{LR}[code-before =\rowcolor{red!15}{1} \rowcolors{3}{blue!10}{}] +\toprule +Ville & habitants \\ +\midrule +Pau & 80000 \\ +Paris & 2000000 \\ +Toulouse & 700000 \\ +Reims & 40000 \\ +\bottomrule +\end{NiceTabular} +\end{scope} + +\bigskip +\item La commande |\chessboardcolors| prend en arguments deux couleurs et colorie les cellules en quinconces avec +les deux couleurs. + +\medskip +\begin{scope} +\hfuzz=10cm +\begin{BVerbatim}[baseline=c,boxwidth=9cm] +$\begin{pNiceMatrix}[R,margin, ~emphase#code-before=\chessboardcolors{red!15}{blue!15}@] +1 & -1 & 1 \\ +-1 & 1 & -1 \\ +1 & -1 & 1 +\end{pNiceMatrix}$ +\end{BVerbatim} +$\begin{pNiceMatrix}% +[baseline=1, R, margin, code-before = \chessboardcolors{red!15}{blue!15}] +1 & -1 & 1 \\ +-1 & 1 & -1 \\ +1 & -1 & 1 +\end{pNiceMatrix}$ +\end{scope} + +\end{itemize} + + + \section{Fonctionnalités avancées} \subsection{Option d'alignement dans NiceMatrix} @@ -1581,7 +1695,7 @@ $A = \begin{pNiceMatrix}[first-row,last-col=4] e_1 & e_2 & e_3 \\ 1 & 2 & 3 & e_1 \\ 4 & 5 & 6 & e_2 \\ -7 & 8 & 9 & e_3 \\ +7 & 8 & 9 & e_3 \end{pNiceMatrix}$ \end{BVerbatim} \begin{varwidth}{10cm} @@ -1597,7 +1711,7 @@ e_1 & e_2 & e_3 \\ \end{varwidth} \bigskip -Si la commande |\rotate| est utilisée dans la ``dernière rangée'' (extérieure à la matrice), les éléments qui +Si la commande |\rotate| est utilisée dans la «dernière rangée» (extérieure à la matrice), les éléments qui subissent cette rotation sont alignés vers le haut. \bigskip @@ -1609,7 +1723,7 @@ $A = \begin{pNiceMatrix}[last-row,last-col=4] 1 & 2 & 3 & e_1 \\ 4 & 5 & 6 & e_2 \\ 7 & 8 & 9 & e_3 \\ -\text{image de } e_1 & e_2 & e_3 \\ +\text{image de } e_1 & e_2 & e_3 \end{pNiceMatrix}$ \end{BVerbatim} \begin{varwidth}{10cm} @@ -1620,7 +1734,7 @@ $A = \begin{pNiceMatrix}[last-row,last-col=4] 1 & 2 & 3 & e_1 \\ 4 & 5 & 6 & e_2 \\ 7 & 8 & 9 & e_3 \\ -\text{image de } e_1 & e_2 & e_3 \\ +\text{image de } e_1 & e_2 & e_3 \end{pNiceMatrix}$ \end{varwidth} @@ -1641,14 +1755,14 @@ $\begin{bNiceArray}{CCCC|C}[~emphase#small@, columns-width = 3mm ] 1 & -2 & 3 & 4 & 5 \\ 0 & 3 & 2 & 1 & 2 & L_2 \gets 2 L_1 - L_2 \\ -0 & 1 & 1 & 2 & 3 & L_3 \gets L_1 + L_3 \\ +0 & 1 & 1 & 2 & 3 & L_3 \gets L_1 + L_3 \end{bNiceArray}$ \end{Verbatim} % \[\begin{bNiceArray}{CCCC|C}[small, last-col, code-for-last-col = \scriptscriptstyle, columns-width=3mm] 1 & -2 & 3 & 4 & 5 \\ 0 & 3 & 2 & 1 & 2 & L_2 \gets 2 L_1 - L_2 \\ -0 & 1 & 1 & 2 & 3 & L_3 \gets L_1 + L_3 \\ +0 & 1 & 1 & 2 & 3 & L_3 \gets L_1 + L_3 \end{bNiceArray}\] @@ -1710,8 +1824,8 @@ Si des compteurs LaTeX nommés |iRow| ou |jCol| sont créés dans le document pa \bigskip L'extension \pkg{nicematrix} propose aussi des commandes pour composer automatiquement des matrices à partir d'un -motif général. Ces commandes sont nommées |\pAutoNiceMatrix|, |\bAutoNiceMatrix|, |\vAutoNiceMatrix|, -|\VAutoNiceMatrix| et |\BAutoNiceMatrix|. +motif général. Ces commandes sont nommées |\AutoNiceMatrix|, |\pAutoNiceMatrix|, |\bAutoNiceMatrix|, +|\vAutoNiceMatrix|, |\VAutoNiceMatrix| et |\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 @@ -1740,11 +1854,12 @@ des options |hlines| et |vlines|. \medskip Dans l'exemple suivant, on utilise la commande |\arrayrulecolor| de \pkg{colortbl}. + + \medskip \begin{BVerbatim}[baseline=c,boxwidth=11cm] \arrayrulecolor{blue} -$\begin{NiceArray}{CCCC}% - [~emphase#hvlines@,first-row,first-col] +$\begin{NiceArray}{CCCC}[~emphase#hvlines@,first-row,first-col] & e & a & b & c \\ e & e & a & b & c \\ a & a & e & c & b \\ @@ -1765,8 +1880,9 @@ c & c & b & a & e \arrayrulecolor{black} + \bigskip -Il y a néanmoins une différence entre l'utilisation de l'option |vlines| et du spécificateur ``\verb+|+'' dans le +Il y a néanmoins une différence entre l'utilisation de l'option |vlines| et du spécificateur «\verb+|+» dans le préambule de l'environnement : les filets tracés par |vlines| traversent les double-filets horizontaux tracés par |\hline\hline|. @@ -2031,7 +2147,7 @@ Pour \pkg{nicematrix}, les règles précises sont les suivantes : \begin{Verbatim} \begin{pmatrix} a & b \\ -c \\ +c \end{pmatrix} \end{Verbatim} @@ -2068,11 +2184,6 @@ Avec cette option, des espaces extérieurs de longueur |\arraycolsep| seront ins |{NiceArray}| (les autres environnements de l'extension \pkg{nicematrix} ne sont pas affectés). -\subsection{L'option de classe draft} - -Quand l'option de classe |draft| est utilisée, les lignes en pointillés ne sont pas tracées, pour accélérer la -compilation. - \subsection{Un problème technique avec l'argument de \textbackslash\textbackslash} @@ -2144,8 +2255,8 @@ b & c La version 3.0 de \pkg{nicematrix} a introduit l'environnement |{pNiceArray}| (et ses variantes) avec les options |first-row|, |last-row|, |first-col| et |last-col|. -Par conséquent, les environnements suivants, présents dans les versions précédentes de \pkg{nicematrix} sont devenus -obsolètes : +Par conséquent, les environnements suivants, présents dans les versions précédentes de \pkg{nicematrix} ont été +supprimés. % \begin{itemize} \item |{NiceArrayCwithDelims}| ; @@ -2156,10 +2267,8 @@ obsolètes : |{VNiceArrayRC}|. \end{itemize} -\medskip -Depuis la version 3.12 de \pkg{nicematrix}, on ne peut utiliser ces environnements que si on a chargé l'extension -\pkg{nicematrix} avec l'option |obsolete-environments|. Il faut toutefois avoir conscience que ces environnements -seront certainement supprimés dans une prochaine version de \pkg{nicematrix}. +Le code correspondant est toutefois encore présent à la fin du fichier |nicematrix.sty|, après une +commande |\file_input_stop:|. @@ -2337,7 +2446,7 @@ $\begin{pNiceMatrix}[first-row,first-col] \Vdots[line-style={solid,<->}]_{n \text{ rows}} & 1 & 1 & 1 & & 1 \\ & 1 & 1 & 1 & & 1 \\ - & 1 & 1 & 1 & \Ldots & 1 \\ + & 1 & 1 & 1 & \Ldots & 1 \end{pNiceMatrix}$ \end{Verbatim} @@ -2351,7 +2460,7 @@ $\begin{pNiceMatrix}[first-row,first-col] & 1 & 1 & 1 & & 1 \\ \Vdots[line-style={solid,<->}]_{n \text{ rows}} & 1 & 1 & 1 & & 1 \\ & 1 & 1 & 1 & & 1 \\ - & 1 & 1 & 1 & \Ldots & 1 \\ + & 1 & 1 & 1 & \Ldots & 1 \end{pNiceMatrix}\] \end{scope} @@ -2366,16 +2475,17 @@ voulons la même largeur (automatique) pour toutes les colonnes. \bigskip \begin{BVerbatim} ~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@ -\NiceMatrixOptions{code-for-last-col = \color{blue}\scriptstyle,light-syntax} +\NiceMatrixOptions + { last-col,code-for-last-col = \color{blue}\scriptstyle,light-syntax} \setlength{\extrarowheight}{1mm} -$\begin{pNiceArray}{CCCC:C}[last-col] +$\begin{pNiceArray}{CCCC:C} 1 1 1 1 1 ; 2 4 8 16 9 ; 3 9 27 81 36 ; 4 16 64 256 100 \end{pNiceArray}$ \medskip -$\begin{pNiceArray}{CCCC:C}[last-col] +$\begin{pNiceArray}{CCCC:C} 1 1 1 1 1 ; 0 2 6 14 7 { L_2 \gets -2 L_1 + L_2 } ; 0 6 24 78 33 { L_3 \gets -3 L_1 + L_3 } ; @@ -2389,10 +2499,10 @@ $\begin{pNiceArray}{CCCC:C}[last-col] \begin{multicols}{2} \begin{NiceMatrixBlock}[auto-columns-width] -\NiceMatrixOptions{code-for-last-col = \color{blue}\scriptstyle,light-syntax} +\NiceMatrixOptions{last-col,code-for-last-col = \color{blue}\scriptstyle,light-syntax} \setlength{\extrarowheight}{1mm} -\enskip $\begin{pNiceArray}{CCCC:C}[last-col] +\enskip $\begin{pNiceArray}{CCCC:C} 1 1 1 1 1 ; 2 4 8 16 9 ; 3 9 27 81 36 ; @@ -2401,7 +2511,7 @@ $\begin{pNiceArray}{CCCC:C}[last-col] \medskip -\enskip $\begin{pNiceArray}{CCCC:C}[last-col] +\enskip $\begin{pNiceArray}{CCCC:C} 1 1 1 1 1 ; 0 2 6 14 7 { L_2 \gets -2 L_1 + L_2 } ; 0 6 24 78 33 { L_3 \gets -3 L_1 + L_3 } ; @@ -2410,7 +2520,7 @@ $\begin{pNiceArray}{CCCC:C}[last-col] \medskip -\enskip $\begin{pNiceArray}{CCCC:C}[last-col] +\enskip $\begin{pNiceArray}{CCCC:C} 1 1 1 1 1 ; 0 1 3 7 \frac72 { L_2 \gets \frac12 L_2 } ; 0 3 12 39 \frac{33}2 { L_3 \gets \frac12 L_3 } ; @@ -2419,7 +2529,7 @@ $\begin{pNiceArray}{CCCC:C}[last-col] \medskip -\enskip $\begin{pNiceArray}{CCCC:C}[last-col] +\enskip $\begin{pNiceArray}{CCCC:C} 1 1 1 1 1 ; 0 1 3 7 \frac72 ; 0 0 3 18 6 { L_3 \gets -3 L_2 + L_3 } ; @@ -2428,7 +2538,7 @@ $\begin{pNiceArray}{CCCC:C}[last-col] \medskip -\enskip $\begin{pNiceArray}{CCCC:C}[last-col] +\enskip $\begin{pNiceArray}{CCCC:C} 1 1 1 1 1 ; 0 1 3 7 \frac72 ; 0 0 1 6 2 { L_3 \gets \frac13 L_3 } ; @@ -2437,7 +2547,7 @@ $\begin{pNiceArray}{CCCC:C}[last-col] \medskip -\enskip $\begin{pNiceArray}{CCCC:C}[last-col] +\enskip $\begin{pNiceArray}{CCCC:C} 1 1 1 1 1 ; 0 1 3 7 \frac72 ; 0 0 1 6 2 ; @@ -2471,6 +2581,8 @@ Nous redessinons les nœuds avec de nouveaux nœuds en utilisant la bibliothèqu voulons recréer des nœuds identiques aux premiers, nous devons fixer |inner sep = 0pt| (si on ne fait pas cela, les nouveaux nœuds seront plus grands que les nœuds d'origine créés par \pkg{nicematrix}). +\label{exemple-CodeAfter} + \begin{Verbatim} $\begin{pNiceArray}{>{\strut}CCCC}[create-large-nodes,margin,extra-margin = 2pt] a_{11} & a_{12} & a_{13} & a_{14} \\ @@ -2578,25 +2690,6 @@ pour l'ensemble des cases avec pour nom $i$|-|$j$|-block| où $i$ et $j$ sont le la case en haut à gauche (où a été utilisée la commande |\Block|). Si on a demandé la création des nœuds |medium|, alors un nœud de ce type est aussi créé pour ce bloc avec un nom suffixé par |-medium|. -\medskip -% $\begin{pNiceMatrix}[margin,create-medium-nodes] -% \Block{3-3}<\Large>{A} & & & 0 \\ -% & \hspace*{1cm} & & \Vdots \\ -% & & & 0 \\ -% 0 & \Cdots& 0 & 0 -% \CodeAfter -% \tikz \node [~emphase#highlight = (1-1-block-medium)@] {} ; -% \end{pNiceMatrix}$ -% \end{BVerbatim} -% $\begin{pNiceMatrix}[margin,create-medium-nodes] -% \Block{3-3}<\Large>{A} & & & 0 \\ -% & \hspace*{1cm} & & \Vdots \\ -% & & & 0 \\ -% 0 & \Cdots& 0 & 0 -% \CodeAfter -% \tikz \node [highlight = (1-1-block-medium)] {} ; -% \end{pNiceMatrix}$ - \vspace{1cm} @@ -2775,7 +2868,7 @@ La matrice $A$ a une «première colonne» (pour $L_i$) d'où l'option |first-co & \Vdots & & & & \Vdots \\ ~emphase#L_i@ & a_{i1} & \Cdots & a_{ik} & \Cdots & a_{in} \\ & \Vdots & & & & \Vdots \\ - & a_{n1} & \Cdots & & & a_{nn} \\ + & a_{n1} & \Cdots & & & a_{nn} \end{bNiceArray} & \end{Verbatim} diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf Binary files differindex 8507028d229..8f7fb6b647e 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx index 2bd6e5ed434..a78a94ee50c 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{3.15} -\def\myfiledate{2020/04/06} +\def\myfileversion{4.0} +\def\myfiledate{2020/05/08} % % %<*batchfile> @@ -51,7 +51,6 @@ version 2005/12/01 or later. \usepackage[xetex]{geometry} \geometry{left=2.8cm,right=2.8cm,top=2.5cm,bottom=2.5cm,papersize={21cm,29.7cm}} -\usepackage{colortbl} \usepackage{tikz} \usetikzlibrary{fit} \usepackage{nicematrix} @@ -66,13 +65,41 @@ version 2005/12/01 or later. \titlespacing*{\section}{0pt}{6.5ex plus 1ex minus .2ex}{4.3ex plus .2ex} \titlespacing*{\subsection}{0pt}{4.5ex plus 1ex minus .2ex}{2ex plus .2ex} \usepackage{multicol} -\usepackage{arydshln} \setlength{\columnseprule}{0.4pt} \usepackage{footnotehyper} \usepackage{varwidth} \parindent 0pt \EnableCrossrefs +\makeatletter +\ExplSyntaxOn +\DoNotIndex{\begin,\end} +\DoNotIndex{\c@iRow,\c@jCol,\theiRow,\thejCol} +\DoNotIndex{\pgfpicture,\endpgfpicture,\tikzpicture,\endtikzpicture} +\DoNotIndex{\pgfpoint,\pgfnode,\pgfnodealias,\pgfcoordinate} +\DoNotIndex{\pgf@x,\pgf@y} +\DoNotIndex{\int_add:Nn,\int_case:nnTF,\int_compare:nNnTF,\int_compare:nTF, + \int_compare_p:nNn,\int_decr:N,\int_eval:n,\int_add:Nn,\int_gdecr:N,\int_gincr:N + \int_gset:Nn,\int_gset_eq:NN,\int_gzero:N,\int_gzero_new:N,\int_if_odd:nTF, + \int_max:nn,\int_new:N,\int_set:Nn,\int_set_eq:NN,\int_step_inline:nnn, + \int_step_variable:nNn,\int_step_variable:nnNn,\int_sub:Nn,\int_use:N,\int_zero:N, + \int_zero_new:N,\g_tmpa_int,\l_tmpa_int,\l_tmpb_int +} +\DoNotIndex{\dim_abs:n,\dim_add:Nn,\dim_compare:nNnTF,\dim_compare_p:nNn, +\dim_const:Nn,\dim_eval:n,\dim_gadd:Nn,\dim_gset:Nn,\dim_gset_eq:NN, +\dim_gset:Nn,\dim_gset_eq:NN,\dim_gsub:Nn,\dim_gzero_new:N,\dim_max:nn, +\dim_min:nn,\dim_new:N,\dim_ration:nn,\dim_set:Nn,\dim_set_eq:NN,\dim_sub:Nn, +\dim_use:N,\dim_zero:N,\dim_zero_new:N,\g_tmpa_dim,\l_tmpa_dim,\l_tmpb_dim, +\c_zero_dim} +\DoNotIndex{\cs_new_protected:Npn,\cs_new:Npn,\cs_set_eq:NN, +\cs_set_protected:Npn} +\DoNotIndex{\bool_if:NTF,\bool_new:N,\bool_set_false:N,\bool_set_true:N,\l_tmpa_bool} +\DoNotIndex{\group_begin:,\group_end:,\c_math_toggle_token} +\DoNotIndex{\tl_set:Nn,\l_tmpa_tl} +\ExplSyntaxOff +\makeatother + + \begin{document} \DocInput{nicematrix.dtx} \end{document} @@ -96,9 +123,10 @@ version 2005/12/01 or later. % % \begin{abstract} % The LaTeX package \pkg{nicematrix} provides new environments similar to the -% classical environments |{array}| and |{matrix}| but with some additional -% features. Among these features are the possibilities to fix the width of the -% columns and to draw continuous ellipsis dots between the cells of the array. +% classical environments |{tabular}|, |{array}| and |{matrix}| but with some +% additional features. Among these features are the possibilities to fix the +% width of the columns and to draw continuous ellipsis dots between the cells of +% the array. % \end{abstract} % % \vspace{1cm} @@ -120,8 +148,7 @@ version 2005/12/01 or later. % This package provides some new tools to draw mathematical matrices. The main % features are the following: % \begin{itemize}\setlength{\itemsep}{0pt} -% \item continuous dotted lines\footnote{If the class option |draft| is -% used, these dotted lines will not be drawn for a faster compilation.}; +% \item continuous dotted lines; % \item exterior rows and columns for labels; % \item a control of the width of the columns. % \end{itemize} @@ -197,12 +224,13 @@ version 2005/12/01 or later. % \begin{ttfamily} % \setlength{\tabcolsep}{3mm} % \begin{tabular}{llll} -% \{NiceMatrix\} & \{NiceArray\} & \{pNiceArray\} \\ -% \{pNiceMatrix\} & & \{bNiceArray\} \\ -% \{bNiceMatrix\} & & \{BNiceArray\} \\ -% \{BNiceMatrix\} & & \{vNiceArray\} \\ -% \{vNiceMatrix\} & & \{VNiceArray\} \\ -% \{VNiceMatrix\} & & \{NiceArrayWithDelims\} \\ +% \{NiceMatrix\} & \{NiceArray\} & \{NiceTabular\} \\ +% \{pNiceMatrix\} & \{pNiceArray\} \\ +% \{bNiceMatrix\} & \{bNiceArray\} \\ +% \{BNiceMatrix\} & \{BNiceArray\} \\ +% \{vNiceMatrix\} & \{vNiceArray\} \\ +% \{VNiceMatrix\} & \{VNiceArray\} \\ +% & \{NiceArrayWithDelims\} % \end{tabular} % \end{ttfamily} % @@ -215,16 +243,15 @@ version 2005/12/01 or later. % % % \medskip -% The environment |{NiceArray}| is similar to the environment |{array}| of the -% package |{array}|. However, for technical reasons, in the preamble of the -% environment |{NiceArray}|, the user must use the letters |L|, |C| and~|R| +% The environments |{NiceArray}| and |{NiceTabular}| are similar to the +% environments |{array}| and |{tabular}| of the +% package |{array}|. However, for technical reasons, in the preamble of these +% environments, the user must use the letters |L|, |C| and~|R| % instead of |l|, |c| and |r|. It's possible to use the constructions -% |w{...}{...}|, |W{...}{...}|\footnote{However, for the columns of type |w| and -% |W|, the cells are composed in math mode (in the environments of -% \pkg{nicematrix}) whereas in |{array}| of \pkg{array}, they are composed in -% text mode.}, "|", |>{...}|, |<{...}|, |@{...}|, |!{...}| and |*{n}{...}| but -% the letters |p|, |m| and |b| should not be used. See p.~\pageref{NiceArray} -% the section relating to |{NiceArray}|. +% |w{...}{...}|, |W{...}{...}|, "|", |>{...}|, |<{...}|, |@{...}|, |!{...}| and +% |*{n}{...}| but the letters |p|, |m| and |b| should not be used. +% +% See p.~\pageref{NiceArray} the section relating to |{NiceArray}| and |{NiceTabular}|. % % % \section{The continuous dotted lines} @@ -372,12 +399,12 @@ version 2005/12/01 or later. % \begin{BVerbatim}[baseline=c,boxwidth=10cm] % $A = \begin{pmatrix} % h & i & j & k & l & m \\ -% x & & & & & x \\ +% x & & & & & x % \end{pmatrix}$ % \end{BVerbatim} % $A = \begin{pmatrix} % h & i & j & k & l & m \\ -% x & & & & & x \\ +% x & & & & & x % \end{pmatrix}$ % % @@ -389,12 +416,12 @@ version 2005/12/01 or later. % \begin{BVerbatim}[baseline=c,boxwidth=10cm] % $B = \begin{pmatrix} % h & i & j & k & l & m \\ -% x & \ldots & \ldots & \ldots & \ldots & x \\ +% x & \ldots & \ldots & \ldots & \ldots & x % \end{pmatrix}$ % \end{BVerbatim} % $B = \begin{pmatrix} % h & i & j & k & l & m \\ -% x & \ldots & \ldots & \ldots & \ldots & x \\ +% x & \ldots & \ldots & \ldots & \ldots & x % \end{pmatrix}$ % % \bigskip @@ -406,12 +433,12 @@ version 2005/12/01 or later. % \begin{BVerbatim}[baseline=c,boxwidth=10cm] % $C = \begin{pNiceMatrix} % h & i & j & k & l & m \\ -% x & \Ldots & \Ldots & \Ldots & \Ldots & x \\ +% x & \Ldots & \Ldots & \Ldots & \Ldots & x % \end{pNiceMatrix}$ % \end{BVerbatim} % $C = \begin{pNiceMatrix} % h & i & j & k & l & m \\ -% x & \Ldots & \Ldots & \Ldots & \Ldots & x \\ +% x & \Ldots & \Ldots & \Ldots & \Ldots & x % \end{pNiceMatrix}$ % % \bigskip @@ -424,12 +451,12 @@ version 2005/12/01 or later. % \begin{BVerbatim}[baseline=c,boxwidth=10cm] % $D = \begin{pNiceMatrix}[~emphase#nullify-dots@] % h & i & j & k & l & m \\ -% x & \Ldots & & & & x \\ +% x & \Ldots & & & & x % \end{pNiceMatrix}$ % \end{BVerbatim} % $D = \begin{pNiceMatrix}[nullify-dots] % h & i & j & k & l & m \\ -% x & \Ldots & & & & x \\ +% x & \Ldots & & & & x % \end{pNiceMatrix}$ % % \medskip @@ -558,13 +585,13 @@ version 2005/12/01 or later. % $\begin{bNiceMatrix} % 1 & \hspace*{1cm} & 0 \\[8mm] % & ~emphase#\Ddots^{n \text{ times}}@ & \\ -% 0 & & 1 \\ +% 0 & & 1 % \end{bNiceMatrix}$ % \end{BVerbatim} % $\begin{bNiceMatrix} % 1 & \hspace*{1cm} & 0 \\[8mm] % & \Ddots^{n \text{ times}} & \\ -% 0 & & 1 \\ +% 0 & & 1 % \end{bNiceMatrix}$ % % \subsection{Customization of the dotted lines} @@ -918,46 +945,27 @@ version 2005/12/01 or later. % \medskip % For the readability of the code, an alternative syntax is provided: it's % possible to give the instructions of the |\code-after| at the end of the -% environment, after the keyword |\CodeAfter|. +% environment, after the keyword |\CodeAfter|. For an example, cf. +% p.~\pageref{example-CodeAfter}. % -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=11cm] -% \NiceMatrixOptions{xdots/shorten = 0.6 em} -% \begin{pNiceMatrix} -% I & 0 & \Cdots &0 \\ -% 0 & I & \Ddots &\Vdots\\ -% \Vdots &\Ddots & I &0 \\ -% 0 &\Cdots & 0 &I -% ~emphase#\CodeAfter@ -% ~emphase#\line{2-2}{3-3}@ -% \end{pNiceMatrix} -% \end{BVerbatim} -% \begin{scope} -% \NiceMatrixOptions{xdots/shorten = 0.6 em} -% $\begin{pNiceMatrix} -% I & 0 & \Cdots &0 \\ -% 0 & I & \Ddots &\Vdots\\ -% \Vdots &\Ddots & I &0 \\ -% 0 &\Cdots & 0 &I -% \CodeAfter -% \line{2-2}{3-3} -% \end{pNiceMatrix}$ -% \end{scope} % -% \section{The environment \{NiceArray\} and its variants} +% \section{The environments \{NiceArray\} and \{NiceTabular\}} % \label{NiceArray} % -% The environment |{NiceArray}| is similar to the environment |{array}|. As for -% |{array}|, the mandatory argument is the preamble of the array. However, for -% technical reasons, in this preamble, the user must use the letters |L|, |C| -% and~|R|\footnote{The column types |L|, |C| and |R| are defined locally inside -% |{NiceArray}| with |\newcolumntype| of \pkg{array}. This definition overrides -% an eventual previous definition. In fact, the column types |w| and |W| are -% also redefined.} instead of |l|, |c| and |r|. It's possible -% to use the constructions |w{...}{...}|, |W{...}{...}|, "|", |>{...}|, -% |<{...}|, |@{...}|, |!{...}| and |*{n}{...}| but the letters |p|, |m| and |b| -% should not be used.\footnote{In a command |\multicolumn|, one should also use -% the letters |L|, |C|, |R|.} +% The environments |{NiceArray}| and |{NiceTabular}| are similar to the +% environments |{array}| and |{tabular}|. The mandatory argument is the preamble +% of the array. However, for technical reasons, in this preamble, the user must +% use the letters |L|, |C| and~|R|\footnote{The column types |L|, |C| and |R| +% are defined locally inside |{NiceArray}| with |\newcolumntype| of \pkg{array}. +% This definition overrides an eventual previous definition.} instead of |l|, +% |c| and |r|. In a command |\multicolumn|, one should also use the letters |L|, +% |C|, |R|. +% +% It's possible to use the constructions |p{...}|, |m{...}|, |b{...}|, +% |w{...}{...}|, |W{...}{...}|, "|", |>{...}|, |<{...}|, |@{...}|, |!{...}| and +% |*{n}{...}|. However, in the environment |{NiceArray}| (and its variants), the +% content of the columns of type |w| or |W| is composed in math mode (in +% |{array}| of \pkg{array}, they are composed in text mode). % % \bigskip % The package \pkg{nicematrix} provides also the variants |{pNiceArray}|, @@ -1016,14 +1024,14 @@ version 2005/12/01 or later. % {\downarrow}{\uparrow}{CCC}[margin] % 1 & 2 & 3 \\ % 4 & 5 & 6 \\ -% 7 & 8 & 9 \\ +% 7 & 8 & 9 % \end{~emphase#NiceArrayWithDelims@}$ % \end{BVerbatim} % $\begin{NiceArrayWithDelims} % {\downarrow}{\uparrow}{CCC}[margin] % 1 & 2 & 3 \\ % 4 & 5 & 6 \\ -% 7 & 8 & 9 \\ +% 7 & 8 & 9 % \end{NiceArrayWithDelims}$ % % @@ -1036,7 +1044,7 @@ version 2005/12/01 or later. % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=9cm] -% $A = \begin{pNiceMatrix}[baseline=2] +% $A = \begin{pNiceMatrix}[~emphase#baseline=2@] % \frac{1}{\sqrt{1+p^2}} & p & 1-p \\ % 1 & 1 & 1 \\ % 1 & p & 1+p @@ -1170,7 +1178,7 @@ version 2005/12/01 or later. % columns which are needed for the composition of the ``last row'' and ``last % column''. % \begin{itemize} -% \item For the environments with explicit preamble, like |{NiceArray}| and +% \item For the environments with explicit preamble, like |{NiceTabular}| and % |{pNiceArray}|, the number of columns can obviously be computed from the % preamble. % @@ -1184,10 +1192,10 @@ version 2005/12/01 or later. % columns during the first compilation and write the result in the |aux| file % for the next run. % -% \textsl{However, it's possible to provide the number of the last row and the number of -% the last column as values of the options |last-row| and |last-col|, tending to -% an acceleration of the whole compilation of the document.} That's what we will -% do throughout the rest of the document. +% \textsl{However, it's possible to provide the number of the last row and the +% number of the last column as values of the options |last-row| and |last-col|, +% tending to an acceleration of the whole compilation of the document.} That's +% what we will do throughout the rest of the document. % \end{itemize} % \end{itemize} % @@ -1343,37 +1351,8 @@ version 2005/12/01 or later. % \bigskip % It's possible to change in \pkg{nicematrix} the letter used to specify a % vertical dotted line with the option |letter-for-dotted-lines| available in -% |\NiceMatrixOptions|. For example, in this document, we have loaded the -% package \pkg{arydshln} which uses the letter ``|:|'' to specify a vertical -% dashed line. Thus, by using |letter-for-dotted-lines|, we can use the -% vertical lines of both \pkg{arydshln} and \pkg{nicematrix}. +% |\NiceMatrixOptions|. % -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm] -% \NiceMatrixOptions{letter-for-dotted-lines = I} -% \arrayrulecolor{blue} -% \left(\begin{NiceArray}{~emphase#C|C:CIC@} -% 1 & 2 & 3 & 4 \\ -% 5 & 6 & 7 & 8 \\ -% 9 & 10 & 11 & 12 -% \end{NiceArray}\right) -% \arrayrulecolor{black} -% \end{BVerbatim} -% \begin{scope} -% \NiceMatrixOptions{letter-for-dotted-lines = I} -% \arrayrulecolor{blue} -% $\left(\begin{NiceArray}{C|C:CIC} -% 1 & 2 & 3 & 4 \\ -% 5 & 6 & 7 & 8 \\ -% 9 & 10 & 11 & 12 -% \end{NiceArray}\right)$ -% \arrayrulecolor{black} -% \end{scope} -% -% \smallskip -% We have used the command |\arrayrulecolor| (de \pkg{colortbl}) to draw in blue -% the three rules. -% % \bigskip % \emph{Remark} : In the package \pkg{array} (on which the package % \pkg{nicematrix} relies), horizontal and vertical rules make the array larger @@ -1462,23 +1441,23 @@ version 2005/12/01 or later. % \begin{BVerbatim}[baseline=c,boxwidth=8.5cm] % ~emphase#\NiceMatrixOptions{columns-width=10mm}@ % $\begin{pNiceMatrix} -% a & b \\ c & d \\ +% a & b \\ c & d % \end{pNiceMatrix} % = % \begin{pNiceMatrix} -% 1 & 1245 \\ 345 & 2 \\ +% 1 & 1245 \\ 345 & 2 % \end{pNiceMatrix}$ % \end{BVerbatim} % \begin{scope} % \NiceMatrixOptions{columns-width=10mm} % $\begin{pNiceMatrix} % a & b \\ -% c & d \\ +% c & d % \end{pNiceMatrix} % = % \begin{pNiceMatrix} % 1 & 1245 \\ -% 345 & 2 \\ +% 345 & 2 % \end{pNiceMatrix}$ % \end{scope} % @@ -1496,21 +1475,21 @@ version 2005/12/01 or later. % \begin{BVerbatim}[baseline=c,boxwidth=8.5cm] % ~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@ % $\begin{pNiceMatrix} -% a & b \\ c & d \\ +% a & b \\ c & d % \end{pNiceMatrix} % = % \begin{pNiceMatrix} -% 1 & 1245 \\ 345 & 2 \\ +% 1 & 1245 \\ 345 & 2 % \end{pNiceMatrix}$ % ~emphase#\end{NiceMatrixBlock}@ % \end{BVerbatim} % \begin{NiceMatrixBlock}[auto-columns-width] % $\begin{pNiceMatrix} -% a & b \\ c & d \\ +% a & b \\ c & d % \end{pNiceMatrix} % = % \begin{pNiceMatrix} -% 1 & 1245 \\ 345 & 2 \\ +% 1 & 1245 \\ 345 & 2 % \end{pNiceMatrix}$ % \end{NiceMatrixBlock} % @@ -1601,6 +1580,181 @@ version 2005/12/01 or later. % For technical reasons, you can't write |\Block{|$i$|-|$j$|}{<}|. But you can % write |\Block{|$i$|-|$j$|}<>{<}| with the expected result. % +% +% \section{The color of the rows and columns} +% +% With the classical package \pkg{colortbl}, it's possible to color the cells, +% rows and columns of a tabular. However, the resulting \textsc{pdf} is not +% always perfectly displayed by the \textsc{pdf} viewers, in particular in +% conjonction with rules. With some \textsc{pdf} viewers, some vertical rules +% seem to vanish. On the other side, some thin horizontal white lines may appear +% in some circonstances. +% +% +% \medskip +% The version 4.0 of \pkg{nicematrix} provide similar tools which do not +% present these drawbacks. This version provides a key |code-before| for some +% code which will be executed \emph{before} the drawing of the tabular. In this +% |code-before|, new commands are available: |\cellcolor|, |\rectanglecolor|, +% |\rowcolor|, |\columncolor|, |\rowcolors| and |\chessboardcolors|. +% +% \medskip +% \begin{itemize} +% \item The command |\cellcolor| takes its name from the command |\cellcolor| of +% \pkg{colortbl}. +% +% This command takes in arguments a color and a list of cells, each of which +% with the format $i$-$j$ where $i$ is the number of row and $j$ the number of +% colummn of the cell. +% +% +% \medskip +% \begin{scope} +% \hfuzz=10cm +% \begin{BVerbatim}[boxwidth=10cm,baseline=c] +% \begin{NiceTabular}{|C|C|C|}[code-before = ~emphase#\cellcolor{red!15}{3-1,2-2,1-3}@] +% \hline +% a & b & c \\ \hline +% e & f & g \\ \hline +% h & i & j \\ \hline +% \end{NiceTabular} +% \end{BVerbatim} +% \begin{NiceTabular}{|C|C|C|}[code-before = \cellcolor{red!15}{3-1,2-2,1-3}] +% \hline +% a & b & c \\ \hline +% e & f & g \\ \hline +% h & i & j \\ \hline +% \end{NiceTabular} +% \end{scope} +% +% \bigskip +% \item The command |\rectanglecolor| takes three arguments. The first is the +% color. The second is the upper-left cell of the rectangle and the third is +% the lower-right cell of the rectangle. +% +% \medskip +% \begin{scope} +% \hfuzz=10cm +% \begin{BVerbatim}[boxwidth=10cm,baseline=c] +% \begin{NiceTabular}{|C|C|C|}[code-before = ~emphase#\rectanglecolor{red!15}{2-2}{3-3}@] +% \hline +% a & b & c \\ \hline +% e & f & g \\ \hline +% h & i & j \\ \hline +% \end{NiceTabular} +% \end{BVerbatim} +% \begin{NiceTabular}{|C|C|C|}[code-before = \rectanglecolor{red!15}{2-2}{3-3}] +% \hline +% a & b & c \\ \hline +% e & f & g \\ \hline +% h & i & j \\ \hline +% \end{NiceTabular} +% \end{scope} +% +% +% +% \bigskip +% \item The command |\rowcolor| takes its name from the command |\rowcolor| of +% \pkg{colortbl}. Its first argument is the color and the second is a +% comma-separated list of rows or interval of rows with the form $a$-$b$ (an +% interval of the form $a$- represent all the rows from the row $a$ until the end). +% +% \medskip +% \begin{scope} +% \hfuzz = 10cm +% \begin{BVerbatim}[boxwidth=9cm,baseline=c] +% $\begin{NiceArray}{LLL}[hvlines, ~emphase#code-before = \rowcolor{red!15}{1,3-5,8-}@] +% a_1 & b_1 & c_1 \\ +% a_2 & b_2 & c_2 \\ +% a_3 & b_3 & c_3 \\ +% a_4 & b_4 & c_4 \\ +% a_5 & b_5 & c_5 \\ +% a_6 & b_6 & c_6 \\ +% a_7 & b_7 & c_7 \\ +% a_8 & b_8 & c_8 \\ +% a_9 & b_9 & c_9 \\ +% a_{10} & b_{10} & c_{10} \\ +% \end{NiceArray}$ +% \end{BVerbatim} +% $\begin{NiceArray}{LLL}[baseline=4,hvlines, code-before = \rowcolor{red!15}{1,3-5,8-}] +% a_1 & b_1 & c_1 \\ +% a_2 & b_2 & c_2 \\ +% a_3 & b_3 & c_3 \\ +% a_4 & b_4 & c_4 \\ +% a_5 & b_5 & c_5 \\ +% a_6 & b_6 & c_6 \\ +% a_7 & b_7 & c_7 \\ +% a_8 & b_8 & c_8 \\ +% a_9 & b_9 & c_9 \\ +% a_{10} & b_{10} & c_{10} \\ +% \end{NiceArray}$ +% \end{scope} +% +% +% \bigskip +% \item The command |\columncolor| takes its name from the command +% |\columncolor| of \pkg{colortbl}. Its syntax is similar to the syntaxe of +% |\rowcolor|. +% +% \bigskip +% \item The command |\rowcolors| (with a \emph{s}) takes its name from the +% command |\rowcolors| of \pkg{xcolor}. The \emph{s} emphasizes the fact that +% there is \emph{two} colors. This command colors alternately the rows of the +% tabular, beginning with the row whose number is given in first argument. The +% two other arguments are the colors. +% +% \medskip +% \begin{scope} +% \hfuzz=10cm +% \begin{BVerbatim}[baseline=c,boxwidth=9cm] +% \begin{NiceTabular}{LR}% +% [~emphase#code-before = \rowcolor{red!15}{1} \rowcolors{3}{blue!10}{}@] +% \toprule +% Town & Habitants \\ +% \midrule +% Pau & 80000 \\ +% Paris & 2000000 \\ +% Toulouse & 700000 \\ +% Reims & 40000 \\ +% \bottomrule +% \end{NiceTabular} +% \end{BVerbatim} +% \begin{NiceTabular}{LR}[code-before =\rowcolor{red!15}{1} \rowcolors{3}{blue!10}{}] +% \toprule +% Ville & habitants \\ +% \midrule +% Pau & 80000 \\ +% Paris & 2000000 \\ +% Toulouse & 700000 \\ +% Reims & 40000 \\ +% \bottomrule +% \end{NiceTabular} +% \end{scope} +% +% \bigskip +% \item The command |\chessboardcolors| take in arguments two colors and colors +% the cells of the tabular in quincunx with these colors. +% +% \medskip +% \begin{scope} +% \hfuzz=10cm +% \begin{BVerbatim}[baseline=c,boxwidth=9cm] +% $\begin{pNiceMatrix}[R,margin, ~emphase#code-before=\chessboardcolors{red!15}{blue!15}@] +% 1 & -1 & 1 \\ +% -1 & 1 & -1 \\ +% 1 & -1 & 1 +% \end{pNiceMatrix}$ +% \end{BVerbatim} +% $\begin{pNiceMatrix}[R,baseline=1, margin, code-before = \chessboardcolors{red!15}{blue!15}] +% 1 & -1 & 1 \\ +% -1 & 1 & -1 \\ +% 1 & -1 & 1 +% \end{pNiceMatrix}$ +% \end{scope} +% +% \end{itemize} +% +% % % \section{Advanced features} % @@ -1645,7 +1799,7 @@ version 2005/12/01 or later. % e_1 & e_2 & e_3 \\ % 1 & 2 & 3 & e_1 \\ % 4 & 5 & 6 & e_2 \\ -% 7 & 8 & 9 & e_3 \\ +% 7 & 8 & 9 & e_3 % \end{pNiceMatrix}$ % \end{BVerbatim} % \begin{varwidth}{10cm} @@ -1656,7 +1810,7 @@ version 2005/12/01 or later. % e_1 & e_2 & e_3 \\ % 1 & 2 & 3 & e_1 \\ % 4 & 5 & 6 & e_2 \\ -% 7 & 8 & 9 & e_3 \\ +% 7 & 8 & 9 & e_3 % \end{pNiceMatrix}$ % \end{varwidth} % @@ -1673,7 +1827,7 @@ version 2005/12/01 or later. % 1 & 2 & 3 & e_1 \\ % 4 & 5 & 6 & e_2 \\ % 7 & 8 & 9 & e_3 \\ -% \text{image of } e_1 & e_2 & e_3 \\ +% \text{image of } e_1 & e_2 & e_3 % \end{pNiceMatrix}$ % \end{BVerbatim} % \begin{varwidth}{10cm} @@ -1684,7 +1838,7 @@ version 2005/12/01 or later. % 1 & 2 & 3 & e_1 \\ % 4 & 5 & 6 & e_2 \\ % 7 & 8 & 9 & e_3 \\ -% \text{image of } e_1 & e_2 & e_3 \\ +% \text{image of } e_1 & e_2 & e_3 % \end{pNiceMatrix}$ % \end{varwidth} % @@ -1707,7 +1861,7 @@ version 2005/12/01 or later. % columns-width = 3mm ] % 1 & -2 & 3 & 4 & 5 \\ % 0 & 3 & 2 & 1 & 2 & L_2 \gets 2 L_1 - L_2 \\ -% 0 & 1 & 1 & 2 & 3 & L_3 \gets L_1 + L_3 \\ +% 0 & 1 & 1 & 2 & 3 & L_3 \gets L_1 + L_3 % \end{bNiceArray}$ % \end{Verbatim} % % @@ -1716,7 +1870,7 @@ version 2005/12/01 or later. % columns-width=3mm] % 1 & -2 & 3 & 4 & 5 \\ % 0 & 3 & 2 & 1 & 2 & L_2 \gets 2 L_1 - L_2 \\ -% 0 & 1 & 1 & 2 & 3 & L_3 \gets L_1 + L_3 \\ +% 0 & 1 & 1 & 2 & 3 & L_3 \gets L_1 + L_3 % \end{bNiceArray}\] % % @@ -1781,7 +1935,7 @@ version 2005/12/01 or later. % \bigskip % The package \pkg{nicematrix} also provides commands in order to compose % automatically matrices from a general pattern. These commands are -% |\pAutoNiceMatrix|, |\bAutoNiceMatrix|, |\vAutoNiceMatrix|, +% |\AutoNiceMatrix|, |\pAutoNiceMatrix|, |\bAutoNiceMatrix|, |\vAutoNiceMatrix|, % |\VAutoNiceMatrix| and |\BAutoNiceMatrix|. % % These commands take two mandatory arguments. The first is the format of the @@ -1818,7 +1972,7 @@ version 2005/12/01 or later. % \arrayrulecolor{blue} % $\begin{NiceArray}{CCCC}% % [~emphase#hvlines@,first-row,first-col] -% % & e & a & b & c \\ +% & e & a & b & c \\ % e & e & a & b & c \\ % a & a & e & c & b \\ % b & b & c & e & a \\ @@ -1869,7 +2023,7 @@ version 2005/12/01 or later. % $\begin{pNiceMatrix}[vlines] % 1 & 2 & 3 & 4 & 5 & 6 \\ % 1 & 2 & 3 & 4 & 5 & 6 \\ -% 1 & 2 & 3 & 4 & 5 & 6 \\ +% 1 & 2 & 3 & 4 & 5 & 6 % \end{pNiceMatrix}$ % \end{BVerbatim} % \begin{scope} @@ -1877,7 +2031,7 @@ version 2005/12/01 or later. % $\begin{pNiceMatrix}[vlines] % 1 & 2 & 3 & 4 & 5 & 6 \\ % 1 & 2 & 3 & 4 & 5 & 6 \\ -% 1 & 2 & 3 & 4 & 5 & 6 \\ +% 1 & 2 & 3 & 4 & 5 & 6 % \end{pNiceMatrix}$ % \end{scope} % @@ -2156,10 +2310,6 @@ version 2005/12/01 or later. % environments of \pkg{nicematrix} are not affected). % % -% \subsection{The class option draft} -% -% When the class option |draft| is used, the dotted lines are not drawn, for a -% faster compilation. % % \subsection{A technical problem with the argument of % \textbackslash\textbackslash} @@ -2228,14 +2378,14 @@ version 2005/12/01 or later. % \end{pNiceMatrix}$ % % -% \subsection{Obsolete environments} +% \subsection{Obsolete environments which have been deleted} % % The version 3.0 of \pkg{nicematrix} has introduced the environment % |{pNiceArray}| (and its variants) with the options |first-row|, |last-row|, % |first-col| and |last-col|. % % Consequently the following environments present in previous versions of -% \pkg{nicematrix} are deprecated: +% have been deleted from \pkg{nicematrix}. % % % \begin{itemize} % \item |{NiceArrayCwithDelims}| ; @@ -2245,12 +2395,9 @@ version 2005/12/01 or later. % \item |{pNiceArrayRC}|, |{bNiceArrayRC}|, |{BNiceArrayRC}|, |{vNiceArrayRC}|, % |{VNiceArrayRC}|. % \end{itemize} -% -% Since the version 3.12, the only way to use these environments is loading -% \pkg{nicematrix} with the option |obsolete-environments|. -% -% However, these environments will certainly be completely deleted in a future -% version of \pkg{nicematrix}. +% +% However, the definition of those environments is still available (temporarily) +% at the end of the file |nicematrix.sty| after a command |\file_input_stop:|. % % \section{Examples} % @@ -2428,7 +2575,7 @@ version 2005/12/01 or later. % & 1 & 1 & 1 & & 1 \\ % \Vdots[line-style={solid,<->}]_{n \text{ rows}} & 1 & 1 & 1 & & 1 \\ % & 1 & 1 & 1 & & 1 \\ -% & 1 & 1 & 1 & \Ldots & 1 \\ +% & 1 & 1 & 1 & \Ldots & 1 % \end{pNiceMatrix}$ % \end{Verbatim} % @@ -2442,7 +2589,7 @@ version 2005/12/01 or later. % & 1 & 1 & 1 & & 1 \\ % \Vdots[line-style={solid,<->}]_{n \text{ rows}} & 1 & 1 & 1 & & 1 \\ % & 1 & 1 & 1 & & 1 \\ -% & 1 & 1 & 1 & \Ldots & 1 \\ +% & 1 & 1 & 1 & \Ldots & 1 % \end{pNiceMatrix}\] % \end{scope} % @@ -2457,16 +2604,17 @@ version 2005/12/01 or later. % \bigskip % \begin{BVerbatim} % ~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@ -% \NiceMatrixOptions{code-for-last-col = \color{blue}\scriptstyle,light-syntax} +% \NiceMatrixOptions +% { last-col,code-for-last-col = \color{blue}\scriptstyle,light-syntax} % \setlength{\extrarowheight}{1mm} -% $\begin{pNiceArray}{CCCC:C}[last-col] +% $\begin{pNiceArray}{CCCC:C} % 1 1 1 1 1 ; % 2 4 8 16 9 ; % 3 9 27 81 36 ; % 4 16 64 256 100 % \end{pNiceArray}$ % \medskip -% $\begin{pNiceArray}{CCCC:C}[last-col] +% $\begin{pNiceArray}{CCCC:C} % 1 1 1 1 1 ; % 0 2 6 14 7 { L_2 \gets -2 L_1 + L_2 } ; % 0 6 24 78 33 { L_3 \gets -3 L_1 + L_3 } ; @@ -2475,15 +2623,15 @@ version 2005/12/01 or later. % ... % ~emphase#\end{NiceMatrixBlock}@ % \end{BVerbatim} -% +% % \bigskip -% -% % \begin{multicols}{2} +% +% \begin{multicols}{2} % \begin{NiceMatrixBlock}[auto-columns-width] -% \NiceMatrixOptions{code-for-last-col = \color{blue}\scriptstyle,light-syntax} +% \NiceMatrixOptions{last-col,code-for-last-col = \color{blue}\scriptstyle,light-syntax} % \setlength{\extrarowheight}{1mm} % -% \enskip $\begin{pNiceArray}{CCCC:C}[last-col] +% \enskip $\begin{pNiceArray}{CCCC:C} % 1 1 1 1 1 ; % 2 4 8 16 9 ; % 3 9 27 81 36 ; @@ -2492,7 +2640,7 @@ version 2005/12/01 or later. % % \medskip % -% \enskip $\begin{pNiceArray}{CCCC:C}[last-col] +% \enskip $\begin{pNiceArray}{CCCC:C} % 1 1 1 1 1 ; % 0 2 6 14 7 { L_2 \gets -2 L_1 + L_2 } ; % 0 6 24 78 33 { L_3 \gets -3 L_1 + L_3 } ; @@ -2501,7 +2649,7 @@ version 2005/12/01 or later. % % \medskip % -% \enskip $\begin{pNiceArray}{CCCC:C}[last-col] +% \enskip $\begin{pNiceArray}{CCCC:C} % 1 1 1 1 1 ; % 0 1 3 7 \frac72 { L_2 \gets \frac12 L_2 } ; % 0 3 12 39 \frac{33}2 { L_3 \gets \frac12 L_3 } ; @@ -2510,7 +2658,7 @@ version 2005/12/01 or later. % % \medskip % -% \enskip $\begin{pNiceArray}{CCCC:C}[last-col] +% \enskip $\begin{pNiceArray}{CCCC:C} % 1 1 1 1 1 ; % 0 1 3 7 \frac72 ; % 0 0 3 18 6 { L_3 \gets -3 L_2 + L_3 } ; @@ -2519,7 +2667,7 @@ version 2005/12/01 or later. % % \medskip % -% \enskip $\begin{pNiceArray}{CCCC:C}[last-col] +% \enskip $\begin{pNiceArray}{CCCC:C} % 1 1 1 1 1 ; % 0 1 3 7 \frac72 ; % 0 0 1 6 2 { L_3 \gets \frac13 L_3 } ; @@ -2528,7 +2676,7 @@ version 2005/12/01 or later. % % \medskip % -% \enskip $\begin{pNiceArray}{CCCC:C}[last-col] +% \enskip $\begin{pNiceArray}{CCCC:C} % 1 1 1 1 1 ; % 0 1 3 7 \frac72 ; % 0 0 1 6 2 ; @@ -2544,7 +2692,7 @@ version 2005/12/01 or later. % \label{highlight} % The following examples require Tikz (by default, \pkg{nicematrix} only loads % \textsc{pgf}) and the Tikz library |fit|. The following lines in the preamble -% of your document may do the job: +% of your document do the job: % \begin{verbatim} % \usepackage{tikz} % \usetikzlibrary{fit} @@ -2562,6 +2710,8 @@ version 2005/12/01 or later. % don't do that, the new nodes will be larger that the nodes created by % \pkg{nicematrix}). % +% \label{example-CodeAfter} +% % \begin{Verbatim} % $\begin{pNiceArray}{>{\strut}CCCC}[create-large-nodes,margin,extra-margin = 2pt] % a_{11} & a_{12} & a_{13} & a_{14} \\ @@ -2879,7 +3029,7 @@ version 2005/12/01 or later. % & \Vdots & & & & \Vdots \\ % L_i & a_{i1} & \Cdots & a_{ik} & \Cdots & a_{in} \\ % & \Vdots & & & & \Vdots \\ -% & a_{n1} & \Cdots & & & a_{nn} \\ +% & a_{n1} & \Cdots & & & a_{nn} % \end{bNiceArray} % & % \end{Verbatim} @@ -3010,24 +3160,12 @@ version 2005/12/01 or later. You~can~go~on~but~you~will~probably~have~other~errors~ if~you~use~the~functionalities~of~nicematrix. } -\cs_if_exist:NF \l_keys_key_str - { \msg_error:nn { nicematrix } { expl3~too~old } } +\cs_if_exist:NF \l_keys_key_str + { \msg_error:nn { nicematrix } { expl3~too~old } } % \end{macrocode} % % % \bigskip -% We test the class option |draft|. In this case, we raise the flag -% |\c_@@_draft_bool| because we won't draw the dotted lines if the option -% |draft| is used. -% \begin{macrocode} -\bool_new:N \c_@@_draft_bool -\DeclareOption { draft } { \bool_set_true:N \c_@@_draft_bool } -\DeclareOption* { } -\ProcessOptions \relax -% \end{macrocode} -% -% -% % The command for the treatment of the options of |\usepackage| is at the end of % this package for technical reasons. % @@ -3059,10 +3197,15 @@ version 2005/12/01 or later. % \bigskip % \subsection*{Technical definitions} % +% % \begin{macrocode} +\bool_new:N \c_@@_booktabs_loaded_bool \bool_new:N \c_@@_tikz_loaded_bool \AtBeginDocument { + \@ifpackageloaded { booktabs } + { \bool_set_true:N \c_@@_booktabs_loaded_bool } + { } \@ifpackageloaded { tikz } { % \end{macrocode} @@ -3071,8 +3214,8 @@ version 2005/12/01 or later. % between |{pgfpicture}| and |{tikzpicture}| can't be done dynamically with a % conditional because, when the Tikz library |external| is loaded by the user, % the pair |\tikzpicture|-|\endtikpicture| (or -% |\begin{tikzpicture}-\end{tikzpicture}| must be statically ``visible'' (even -% when extenalization is not activated). +% |\begin{tikzpicture}-\end{tikzpicture}|) must be statically ``visible'' (even +% when externalization is not activated). % % That's why we create |\c_@@_pgfortikzpicture_tl| and % |\c_@@_endpgfortikzpicture_tl| which will be used to construct in a @@ -3102,18 +3245,6 @@ version 2005/12/01 or later. { } % \end{macrocode} % -% -% The following message must be defined right now because it may be used during -% the loading of the package. -% \begin{macrocode} -\@@_msg_new:nn { Draft~mode } - { The~compilation~is~in~draft~mode:~the~dotted~lines~won't~be~drawn. } -% \end{macrocode} -% -% \begin{macrocode} -\bool_if:NT \c_@@_draft_bool { \msg_warning:nn { nicematrix } { Draft~mode } } -% \end{macrocode} -% % % \bigskip % We define a command |\iddots| similar to |\ddots| ($\ddots$) but with dots @@ -3141,6 +3272,204 @@ version 2005/12/01 or later. % This definition is a variant of the standard definition of |\ddots|. % % +% \bigskip +% In the |aux| file, we will have the references of the PGF/Tikz nodes created +% by \pkg{nicematrix}. However, when \pkg{booktabs} is used, some nodes (more +% precisely, some |row| nodes) will be defined twice because their position will +% be modified. In order to avoid an error message in this case, we will redefine +% |\pgfutil@check@rerun| in the |aux| file. +% \begin{macrocode} +\AtBeginDocument + { + \@ifpackageloaded { booktabs } + { \iow_now:Nn \@mainaux \nicematrix@redefine@check@rerun } + { } + } +\cs_set_protected:Npn \nicematrix@redefine@check@rerun + { + \cs_set_eq:NN \@@_old_pgfutil@check@rerun \pgfutil@check@rerun +% \end{macrocode} +% The new version of |\pgfutil@check@rerun| will not check the PGF nodes whose +% names start with |nm-| (which is the prefix for the nodes creates by +% \pkg{nicematrix}). +% \begin{macrocode} + \cs_set_protected:Npn \pgfutil@check@rerun ##1 ##2 + { + \str_set:Nx \l_tmpa_str { \tl_range:nnn { ##1 } 1 3 } + \str_if_eq:VnF \l_tmpa_str { nm- } + { \@@_old_pgfutil@check@rerun { ##1 } { ##2 } } + } + } +% \end{macrocode} +% +% \bigskip +% We have to know whether \pkg{colortbl} is loaded in particular for the +% redefinition of |\everycr|. +% \begin{macrocode} +\bool_new:N \c_@@_colortbl_loaded_bool +\AtBeginDocument + { + \@ifpackageloaded { colortbl } + { \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 +% the rules in the array. We will use it to store the instruction of color for +% the rules even if \pkg{colortbl} is not loaded. +% \begin{macrocode} + \cs_set_protected:Npn \CT@arc@ { } + \NewDocumentCommand { \arrayrulecolor } { m } + { \tl_gset:Nn \CT@arc@ { \color { #1 } } } +% \end{macrocode} +% The following line are from the redefinition of |\hline| of standard LaTeX by +% \pkg{colortbl} (\pkg{array} does not redefine |\hline|). +% \begin{macrocode} + \cs_set:Npn \hline + { + \noalign { \ifnum 0 = `} \fi + \let \hskip \vskip + \let \vrule \hrule + \let \@width \@height + { \CT@arc@ \vline } + \futurelet \reserved@a + \@xhline + } + } + } +% \end{macrocode} +% +% \bigskip +% The following command are only for efficiency. It must \emph{not} be protected +% because it will be used (for instance) in names of \textsc{pgf} nodes. +% \begin{macrocode} +\cs_new:Npn \@@_succ:n #1 { \the \numexpr #1 + 1 \relax } +\cs_new:Npn \@@_pred:n #1 { \the \numexpr #1 - 1 \relax } +% \end{macrocode} +% +% \bigskip +% \textbf{The column S of siunitx}\par\nobreak +% +% \medskip +% We want to know whether the package \pkg{siunitx} is loaded and, if it is +% loaded, we redefine the |S| columns of \pkg{siunitx}. +% \begin{macrocode} +\bool_new:N \c_@@_siunitx_loaded_bool +\AtBeginDocument + { + \@ifpackageloaded { siunitx } + { \bool_set_true:N \c_@@_siunitx_loaded_bool } + { } + } +% \end{macrocode} +% +% \medskip +% The command |\NC@rewrite@S| is a LaTeX command created by \pkg{siunitx} in +% connection with the |S| column. In the code of \pkg{siunitx}, this command is +% defined by: +% \begin{Verbatim}[commandchars=\~\!\+, formatcom = \small] +% \renewcommand*{\NC@rewrite@S}[1][] +% { +% \@temptokena \exp_after:wN +% { +% \tex_the:D \@temptokena +% > { \__siunitx_table_collect_begin: S {#1} } +% c +% < { \__siunitx_table_print: } +% } +% \NC@find +% } +% \end{Verbatim} +% We want to patch this command (in the environments of \pkg{nicematrix}) in +% order to have: +% \begin{Verbatim}[commandchars=\~\!\+, formatcom = \small] +% \renewcommand*{\NC@rewrite@S}[1][] +% { +% \@temptokena \exp_after:wN +% { +% \tex_the:D \@temptokena +% > { ~emphase!\@@_Cell:+ \__siunitx_table_collect_begin: S {#1} } +% c +% < { \__siunitx_table_print: ~emphase!\@@_end_Cell:+ } +% } +% \NC@find +% } +% \end{Verbatim} +% However, we don't want do use explicitly any private command of \pkg{siunitx}. +% That's why we will extract the name of the two |\__siunitx...| commands by +% their position in the code of |\NC@rewrite@S|. +% +% Since the command |\NC@rewrite@S| appends some tokens to the \emph{toks} list +% |\@temptokena|, we use the LaTeX command |\NC@rewrite@S| in a group +% (|\group_begin:|--|\group_end:|) and we extract the two command names which +% are in the toks |\@temptokena|. However, this extraction can be done only +% when \pkg{siunitx} is loaded (and it may be loaded after \pkg{nicematrix}) +% and, in fact, after the beginning of the document --- because some +% instructions of \pkg{siunitx} are executed in a |\AtBeginDocument|). That's +% why this extraction will be done only at the first use of an +% environment of \pkg{nicematrix} with the command |\@@_adapt_S_column:|. +% \begin{macrocode} +\cs_set_protected:Npn \@@_adapt_S_column: + { + \bool_if:NT \c_@@_siunitx_loaded_bool + { + \group_begin: + \@temptokena = { } +% \end{macrocode} +% We protect |\NC@find| which is at the end of |\NC@rewrite@S|. +% \begin{macrocode} + \cs_set_eq:NN \NC@find \prg_do_nothing: + \NC@rewrite@S { } +% \end{macrocode} +% Conversion of the \emph{toks} |\@temptokena| in a token list of \pkg{expl3} +% (the toks are not supported by \pkg{expl3} but we can, nevertheless, use the +% option |V| for |\tl_gset:NV|). +% \begin{macrocode} + \tl_gset:NV \g_tmpa_tl \@temptokena + \group_end: + \tl_new:N \c_@@_table_collect_begin_tl + \tl_set:Nx \l_tmpa_tl { \tl_item:Nn \g_tmpa_tl 2 } + \tl_gset:Nx \c_@@_table_collect_begin_tl { \tl_item:Nn \l_tmpa_tl 1 } + \tl_new:N \c_@@_table_print_tl + \tl_gset:Nx \c_@@_table_print_tl { \tl_item:Nn \g_tmpa_tl { -1 } } +% \end{macrocode} +% The token lists |\c_@@_table_collect_begin_tl| and |\c_@@_table_print_tl| +% contain now the two commands of \pkg{siunitx}. +% +% \smallskip +% If the adaptation has been done, the command |\@@_adapt_S_column:| becomes +% no-op (globally). +% \begin{macrocode} + \cs_gset_eq:NN \@@_adapt_S_column: \prg_do_nothing: + } + } +% \end{macrocode} +% +% \bigskip +% The command |\@@_renew_NC@rewrite@S:| will be used in each environment of +% \pkg{nicematrix} in order to ``rewrite'' the |S| column in each environment +% (only if the boolean |\c_@@_siunitx_loaded_bool| is raised, of course). +% \begin{macrocode} +\cs_new_protected:Npn \@@_renew_NC@rewrite@S: + { + \renewcommand*{\NC@rewrite@S}[1][] + { + \@temptokena \exp_after:wN + { + \tex_the:D \@temptokena + > { \@@_Cell: \c_@@_table_collect_begin_tl S {##1} } + c + < { \c_@@_table_print_tl \@@_end_Cell: } + } + \NC@find + } + } +% \end{macrocode} +% +% +% \bigskip +% \subsection*{Parameters} +% +% % \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 @@ -3148,15 +3477,24 @@ version 2005/12/01 or later. % \begin{macrocode} \int_new:N \g_@@_env_int % \end{macrocode} -% +% +% \bigskip +% The following command is only a syntaxic shortcut. It must \emph{not} be +% protected (it will be used in names of \textsc{pgf} nodes). % \begin{macrocode} \cs_new:Npn \@@_env: { nm - \int_use:N \g_@@_env_int } -\cs_new_protected:Npn \@@_qpoint: #1 +% \end{macrocode} +% +% \bigskip +% The following command is only a syntaxic shortcut. The |q| in |qpoint| means +% \emph{quick}. +% \begin{macrocode} +\cs_new_protected:Npn \@@_qpoint:n #1 { \pgfpointanchor { \@@_env: - #1 } { center } } % \end{macrocode} % % \bigskip -% We also define a counter to count the environments |{NiceMatrixBlock}|. +% the following counter will count the environments |{NiceMatrixBlock}|. % \begin{macrocode} \int_new:N \g_@@_NiceMatrixBlock_int % \end{macrocode} @@ -3179,14 +3517,12 @@ version 2005/12/01 or later. \seq_new:N \g_@@_names_seq % \end{macrocode} % - % \bigskip % We want to know if we are in an environment of \pkg{nicematrix} because we % will raise an error if the user tries to use nested environments. % \begin{macrocode} \bool_new:N \l_@@_in_env_bool % \end{macrocode} -% % % \bigskip % If the user uses |{NiceArray}| (and not another environment relying upon @@ -3198,7 +3534,12 @@ version 2005/12/01 or later. \bool_new:N \l_@@_NiceArray_bool % \end{macrocode} % -% +% \bigskip +% If the user uses |{NiceTabular}|, we will raise the following flag. +% \begin{macrocode} +\bool_new:N \l_@@_NiceTabular_bool +% \end{macrocode} +% % \bigskip % \begin{macrocode} \cs_new_protected:Npn \@@_test_if_math_mode: @@ -3210,77 +3551,33 @@ version 2005/12/01 or later. % \end{macrocode} % % -% % \bigskip -% We have to know whether \pkg{colortbl} is loaded for the redefinition of -% |\everycr| and |\vline| and for the options |hlines| and |vlines|. -% \begin{macrocode} -\bool_new:N \c_@@_colortbl_loaded_bool -\AtBeginDocument - { - \@ifpackageloaded { colortbl } - { - \bool_set_true:N \c_@@_colortbl_loaded_bool - \cs_set_protected:Npn \@@_vline_i: { { \CT@arc@ \vline } } - } - { } - } -% \end{macrocode} -% +% The following colors will be used to memorize le color of the potential ``first +% col'' and the potential ``first row''. % \begin{macrocode} \colorlet { nicematrix-last-col } { . } \colorlet { nicematrix-last-row } { . } % \end{macrocode} -% -% \bigskip -% The length |\l_@@_inter_dots_dim| is the distance between two dots for the -% dotted lines. The default value is 0.45~em but it will be changed if the -% option |small| is used. -% \begin{macrocode} -\dim_new:N \l_@@_inter_dots_dim -\dim_set:Nn \l_@@_inter_dots_dim { 0.45 em } -% \end{macrocode} -% -% \bigskip -% The length |\l_@@_xdots_shorten_dim| is the minimal distance between a -% node (in fact an anchor of that node) and a dotted line (we say ``minimal'' -% because, by definition, a dotted line is not a continuous line and, therefore, -% this distance may vary a little). -% \begin{macrocode} -\dim_new:N \l_@@_xdots_shorten_dim -\dim_set:Nn \l_@@_xdots_shorten_dim { 0.3 em } -% \end{macrocode} -% -% \bigskip -% The length |\l_@@_radius_dim| is the radius of the dots for the dotted lines -% (for |\hdottedline| and |\dottedline| and for all the other dotted lines when -% |line-style| is equal to |standard|, which is the initial value). The initial -% value is 0.53~pt but it will be changed if the option |small| is used (to -% 0.37~pt). -% \begin{macrocode} -\dim_new:N \l_@@_radius_dim -\dim_set:Nn \l_@@_radius_dim { 0.53 pt } -% \end{macrocode} -% % \bigskip -% The name of the current environment or the current command (despite the name -% which contains \textsl{env}). +% The following string is the name of the current environment or the current +% command of \pkg{nicematrix} (despite its name which contains \textsl{env}). % \begin{macrocode} \str_new:N \g_@@_name_env_str % \end{macrocode} % -% The string |\g_@@_com_or_env_str| will contain the word \emph{command} or -% \emph{environment} whether we are in a command of \pkg{nicematrix} or a an +% \bigskip +% The following string will contain the word \emph{command} or +% \emph{environment} whether we are in a command of \pkg{nicematrix} or in an % environment of \pkg{nicematrix}. The default value is \emph{environment}. % \begin{macrocode} \str_new:N \g_@@_com_or_env_str \str_set:Nn \g_@@_com_or_env_str { environment } % \end{macrocode} % -% The following control sequence will be able to reconstruct the full name of -% the current command or environment (despite the name which contains -% \textsl{env}). This command must \emph{not} be protected since it's used in -% error messages. +% \bigskip +% The following command will be able to reconstruct the full name of the current +% command or environment (despite its name which contains \textsl{env}). This +% command must \emph{not} be protected since it will be used in error messages. % \begin{macrocode} \cs_new:Npn \@@_full_name_env: { @@ -3291,35 +3588,56 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip +% The following token list corresponds to the option |code-after| (it's also +% possible to set the value of that parameter with the command |\CodeAfter|). % \begin{macrocode} -\tl_new:N \g_@@_internal_code_after_tl \tl_new:N \g_@@_code_after_tl % \end{macrocode} % -% % \bigskip -% The counters |\l_@@_save_iRow_int| and |\l_@@_save_jCol_int| will be used to -% save the values of the eventual LaTeX counters |iRow| and |jCol|. These LaTeX +% The following token list has a function similar to |\g_@@_code_after_tl| but +% it is used internally by \pkg{nicematrix}. In fact, we have to distinguish +% between |\g_@@_code_after_tl| and |\g_@@_internal_code_after_tl| because we +% must take care of the order in which instructions stored in that paremeters +% are executed. +% \begin{macrocode} +\tl_new:N \g_@@_internal_code_after_tl +% \end{macrocode} +% +% \bigskip +% The counters |\l_@@_old_iRow_int| and |\l_@@_old_jCol_int| will be used to +% save the values of the potential LaTeX counters |iRow| and |jCol|. These LaTeX % counters will be restored at the end of the environment. % \begin{macrocode} -\int_new:N \l_@@_save_iRow_int -\int_new:N \l_@@_save_jCol_int +\int_new:N \l_@@_old_iRow_int +\int_new:N \l_@@_old_jCol_int % \end{macrocode} % % The TeX counters |\c@iRow| and |\c@jCol| will be created in the beginning of % |{NiceArrayWithDelims}| (if they don't exist previously). % +% \bigskip +% A kind of false row will be inserted at the end of the array for the +% construction of the |col| nodes (and also to fix the width of the columns when +% |columns-width| is used). When this special row will be created, we will raise +% the flag |\g_@@_row_of_col_done_bool| in order to avoid some actions set in +% the redefinition of |\everycr| when the last |\cr| of the |\halign| will occur +% (after that row of |col| nodes). % \begin{macrocode} \bool_new:N \g_@@_row_of_col_done_bool % \end{macrocode} % +% \bigskip +% The following flag will be raised when the key |code-before| is used in the +% environment. Indeed, if there is a |code-before| in the environment, we will +% manage to have the |row| nodes and the |col| nodes available \emph{before} the +% creation of the array. % \begin{macrocode} -\tl_new:N \l_@@_initial_suffix_tl -\tl_new:N \l_@@_initial_anchor_tl -\tl_new:N \l_@@_final_suffix_tl -\tl_new:N \l_@@_final_anchor_tl -% \end{macrocode} +\bool_new:N \l_@@_code_before_bool +% \end{macrocode} % +% \bigskip +% The following dimensions will be used when drawing the dotted lines. % \begin{macrocode} \dim_new:N \l_@@_x_initial_dim \dim_new:N \l_@@_y_initial_dim @@ -3327,25 +3645,37 @@ version 2005/12/01 or later. \dim_new:N \l_@@_y_final_dim % \end{macrocode} % +% \bigskip +% \pkg{expl3} provides scratch dimension |\l_tmpa_dim| and |\l_tmpd_dim|. We +% creates two other in the same spirit (if they don't exist yet : that's why we +% use |\dim_zero_new:N|). % \begin{macrocode} -\dim_new:N \l_tmpc_dim -\dim_new:N \l_tmpd_dim +\dim_zero_new:N \l_tmpc_dim +\dim_zero_new:N \l_tmpd_dim % \end{macrocode} % +% \bigskip +% Some cells will be declared as ``empty'' (for example a cell with the +% instrution |\Cdot|). % \begin{macrocode} \bool_new:N \g_@@_empty_cell_bool % \end{macrocode} % -% \medskip -% The token list |\l_@@_xdots_line_style_tl| corresponds to the option |tikz| of the -% commands |\Cdots|, |\Ldots|, etc. and of the options |line-style| for the -% environments and |\NiceMatrixOptions|. The constant |\c_@@_standard_tl| will -% be used in some tests. +% \bigskip +% The following dimension will be used to save the current value of +% |\arraycolsep|. % \begin{macrocode} -\tl_new:N \l_@@_xdots_line_style_tl -\tl_const:Nn \c_@@_standard_tl { standard } -\tl_set_eq:NN \l_@@_xdots_line_style_tl \c_@@_standard_tl +\dim_new:N \@@_old_arraycolsep_dim +% \end{macrocode} +% +% \bigskip +% The following dimensions will be used internally to compute the width of the +% potential ``first column'' and ``last column''. +% \begin{macrocode} +\dim_new:N \g_@@_width_last_col_dim +\dim_new:N \g_@@_width_first_col_dim % \end{macrocode} +% % % \bigskip % \textbf{Variables for the exterior rows and columns}\par\nobreak @@ -3360,8 +3690,7 @@ version 2005/12/01 or later. % \item \textbf{First row}\par\nobreak % The integer |\l_@@_first_row_int| is the number of the first row of the % array. The default value is $1$, but, if the option |first-row| is used, -% the value will be~$0$. As usual, the global version is for the passage in the -% |\group_insert_after:N|. +% the value will be~$0$. % \begin{macrocode} \int_new:N \l_@@_first_row_int \int_set:Nn \l_@@_first_row_int 1 @@ -3409,7 +3738,7 @@ version 2005/12/01 or later. % \medskip % \item \textbf{Last column}\par\nobreak % -% For the eventual ``last column'', we use an integer. A value of $-2$ means +% For the potential ``last column'', we use an integer. A value of $-2$ means % that there is no last column. A value of $-1$ means that there is a last % column but we don't know its value because the user has used the option % |last-col| without value (it's possible in an environment without preamble @@ -3438,138 +3767,13 @@ version 2005/12/01 or later. % This boolean is set to |false| at the end of |\@@_pre_array:|. % \end{itemize} % -% \bigskip -% \textbf{The column S of siunitx}\par\nobreak -% -% \medskip -% We want to know whether the package \pkg{siunitx} is loaded and, if it is -% loaded, we redefine the |S| columns of \pkg{siunitx}. -% \begin{macrocode} -\bool_new:N \c_@@_siunitx_loaded_bool -\AtBeginDocument - { - \@ifpackageloaded { siunitx } - { \bool_set_true:N \c_@@_siunitx_loaded_bool } - { } - } -% \end{macrocode} % -% \medskip -% The command |\NC@rewrite@S| is a LaTeX command created by \pkg{siunitx} in -% connection with the |S| column. In the code of \pkg{siunitx}, this command is -% defined by: -% \begin{Verbatim}[commandchars=\~\!\+, formatcom = \small] -% \renewcommand*{\NC@rewrite@S}[1][] -% { -% \@temptokena \exp_after:wN -% { -% \tex_the:D \@temptokena -% > { \__siunitx_table_collect_begin: S {#1} } -% c -% < { \__siunitx_table_print: } -% } -% \NC@find -% } -% \end{Verbatim} -% We want to patch this command (in the environments of \pkg{nicematrix}) in -% order to have: -% \begin{Verbatim}[commandchars=\~\!\+, formatcom = \small] -% \renewcommand*{\NC@rewrite@S}[1][] -% { -% \@temptokena \exp_after:wN -% { -% \tex_the:D \@temptokena -% > { ~emphase!\@@_Cell:+ \__siunitx_table_collect_begin: S {#1} } -% c -% < { \__siunitx_table_print: ~emphase!\@@_end_Cell:+ } -% } -% \NC@find -% } -% \end{Verbatim} -% However, we don't want do use explicitly any private command of \pkg{siunitx}. -% That's why we will extract the name of the two |\__siunitx...| commands by -% their position in the code of |\NC@rewrite@S|. -% -% Since the command |\NC@rewrite@S| appends some tokens to the \emph{toks} list -% |\@temptokena|, we use the LaTeX command |\NC@rewrite@S| in a group -% (|\group_begin:|--|\group_end:|) and we extract the two command names which -% are in the toks |\@temptokena|. However, this extraction can be done only -% when \pkg{siunitx} is loaded (and it may be loaded after \pkg{nicematrix}) -% and, in fact, after the beginning of the document --- because some -% instructions of \pkg{siunitx} are executed in a |\AtBeginDocument|). That's -% why this extraction will be done only at the first use of an -% environment of \pkg{nicematrix} with the command |\@@_adapt_S_column:|. -% \begin{macrocode} -\cs_set_protected:Npn \@@_adapt_S_column: - { - \bool_if:NT \c_@@_siunitx_loaded_bool - { - \group_begin: - \@temptokena = { } -% \end{macrocode} -% We protect |\NC@find| which is at the end of |\NC@rewrite@S|. -% \begin{macrocode} - \cs_set_eq:NN \NC@find \prg_do_nothing: - \NC@rewrite@S { } -% \end{macrocode} -% Conversion of the \emph{toks} |\@temptokena| in a token list of \pkg{expl3} -% (the toks are not supported by \pkg{expl3} but we can, nevertheless, use the -% option |V| for |\tl_gset:NV|). -% \begin{macrocode} - \tl_gset:NV \g_tmpa_tl \@temptokena - \group_end: - \tl_new:N \c_@@_table_collect_begin_tl - \tl_set:Nx \l_tmpa_tl { \tl_item:Nn \g_tmpa_tl 2 } - \tl_gset:Nx \c_@@_table_collect_begin_tl { \tl_item:Nn \l_tmpa_tl 1 } - \tl_new:N \c_@@_table_print_tl - \tl_gset:Nx \c_@@_table_print_tl { \tl_item:Nn \g_tmpa_tl { -1 } } -% \end{macrocode} -% The token lists |\c_@@_table_collect_begin_tl| and |\c_@@_table_print_tl| -% contain now the two commands of \pkg{siunitx}. -% -% \smallskip -% If the adaptation has been done, the command |\@@_adapt_S_column:| becomes -% no-op (globally). -% \begin{macrocode} - \cs_gset_eq:NN \@@_adapt_S_column: \prg_do_nothing: - } - } -% \end{macrocode} -% -% \bigskip -% The command |\@@_renew_NC@rewrite@S:| will be used in each environment of -% \pkg{nicematrix} in order to ``rewrite'' the |S| column in each environment -% (only if the boolean |\c_@@_siunitx_loaded_bool| is raised, of course). -% \begin{macrocode} -\cs_new_protected:Npn \@@_renew_NC@rewrite@S: - { - \renewcommand*{\NC@rewrite@S}[1][] - { - \@temptokena \exp_after:wN - { - \tex_the:D \@temptokena - > { \@@_Cell: \c_@@_table_collect_begin_tl S {##1} } - c - < { \c_@@_table_print_tl \@@_end_Cell: } - } - \NC@find - } - } -% \end{macrocode} -% -% \bigskip -% The following command is only for efficiency. It must \emph{not} be protected -% because it will be used (for instance) in names of \textsc{pgf} nodes. -% \begin{macrocode} -\cs_new:Npn \@@_succ:n #1 { \the \numexpr #1 + 1 \relax } -\cs_new:Npn \@@_pred:n #1 { \the \numexpr #1 - 1 \relax } -% \end{macrocode} % % \subsection*{Command for creation of rectangle nodes} % % -% The following command should be used in a |{pgfpicture}|. It creates an -% rectangular (empty but with a name) when the four corners are given. +% The following command should be used in a |{pgfpicture}|. It creates a +% rectangle (empty but with a name). % % |#1| is the name of the node which will be created; % |#2| and |#3| are the coordinates of one of the corner of the rectangle; @@ -3637,13 +3841,61 @@ version 2005/12/01 or later. % \bigskip % \subsection*{The options} % +% +% The following dimensions correspond to the options |cell-space-top-limit| and co +% (these parameters are inspired by the package \pkg{cellspace}). +% \begin{macrocode} +\dim_new:N \l_@@_cell_space_top_limit_dim +\dim_new:N \l_@@_cell_space_bottom_limit_dim +% \end{macrocode} +% +% \bigskip +% The following dimension is the distance between two dots for the dotted lines +% (when |line-style| is equal to |standard|, which is the initial value). The +% initial value is 0.45~em but it will be changed if the option |small| is used. +% \begin{macrocode} +\dim_new:N \l_@@_inter_dots_dim +\dim_set:Nn \l_@@_inter_dots_dim { 0.45 em } +% \end{macrocode} +% +% \bigskip +% The following dimension is the minimal distance between a node (in fact an +% anchor of that node) and a dotted line (we say ``minimal'' because, by +% definition, a dotted line is not a continuous line and, therefore, this +% distance may vary a little). +% \begin{macrocode} +\dim_new:N \l_@@_xdots_shorten_dim +\dim_set:Nn \l_@@_xdots_shorten_dim { 0.3 em } +% \end{macrocode} +% +% \bigskip +% The following dimension is the radius of the dots for the dotted lines (when +% |line-style| is equal to |standard|, which is the initial value). The initial +% value is 0.53~pt but it will be changed if the option |small| is used. +% \begin{macrocode} +\dim_new:N \l_@@_radius_dim +\dim_set:Nn \l_@@_radius_dim { 0.53 pt } +% \end{macrocode} +% +% \bigskip +% The token list |\l_@@_xdots_line_style_tl| corresponds to the option |tikz| of the +% commands |\Cdots|, |\Ldots|, etc. and of the options |line-style| for the +% environments and |\NiceMatrixOptions|. The constant |\c_@@_standard_tl| will +% be used in some tests. +% \begin{macrocode} +\tl_new:N \l_@@_xdots_line_style_tl +\tl_const:Nn \c_@@_standard_tl { standard } +\tl_set_eq:NN \l_@@_xdots_line_style_tl \c_@@_standard_tl +% \end{macrocode} +% +% \bigskip % The boolean |\l_@@_light_syntax_bool| corresponds to the option |light-syntax|. % \begin{macrocode} \bool_new:N \l_@@_light_syntax_bool % \end{macrocode} % % \bigskip -% The token list |\l_@@_baseline_str| may contain one of the three values |t|, +% The string |\l_@@_baseline_str| may contain one of the three values |t|, % |c| or |b| as in the option of the environment |{array}|. However, it may also % contain an integer (which represents the number of the row to which align the % array). @@ -3698,7 +3950,7 @@ version 2005/12/01 or later. % % % \bigskip -% The token list |\l_@@_name_str| will contain the optional name of the +% The string |\l_@@_name_str| will contain the optional name of the % environment: this name can be used to access to the Tikz nodes created in the % array from outside the environment. % \begin{macrocode} @@ -3723,13 +3975,6 @@ version 2005/12/01 or later. \dim_new:N \l_@@_right_margin_dim % \end{macrocode} % -% \bigskip -% The following dimensions will be used internally to compute the width of the -% potential ``first column'' and ``last column''. -% \begin{macrocode} -\dim_new:N \g_@@_width_last_col_dim -\dim_new:N \g_@@_width_first_col_dim -% \end{macrocode} % % \bigskip % The dimensions |\l_@@_extra_left_margin_dim| and @@ -3809,12 +4054,20 @@ version 2005/12/01 or later. % \begin{macrocode} \keys_define:nn { NiceMatrix / Global } { + cell-space-top-limit .dim_set:N = \l_@@_cell_space_top_limit_dim , + cell-space-top-limit .value_required:n = true , + cell-space-bottom-limit .dim_set:N = \l_@@_cell_space_bottom_limit_dim , + cell-space-bottom-limit .value_required:n = true , xdots .code:n = \keys_set:nn { NiceMatrix / xdots } { #1 } , max-delimiter-width .bool_set:N = \l_@@_max_delimiter_width_bool , light-syntax .bool_set:N = \l_@@_light_syntax_bool , light-syntax .default:n = true , end-of-row .tl_set:N = \l_@@_end_of_row_tl , end-of-row .value_required:n = true , + first-col .code:n = \int_zero:N \l_@@_first_col_int , + first-row .code:n = \int_zero:N \l_@@_first_row_int , + last-row .int_set:N = \l_@@_last_row_int , + last-row .default:n = -1 , code-for-first-col .tl_set:N = \l_@@_code_for_first_col_tl , code-for-first-col .value_required:n = true , code-for-last-col .tl_set:N = \l_@@_code_for_last_col_tl , @@ -3823,7 +4076,6 @@ version 2005/12/01 or later. code-for-first-row .value_required:n = true , code-for-last-row .tl_set:N = \l_@@_code_for_last_row_tl , code-for-last-row .value_required:n = true , - small .bool_set:N = \l_@@_small_bool , hlines .bool_set:N = \l_@@_hlines_bool , vlines .bool_set:N = \l_@@_vlines_bool , hvlines .meta:n = { hlines , vlines } , @@ -3831,19 +4083,13 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% With the option |renew-dots|, the command |\cdots|, |\ldots|, |\vdots| and -% |\ddots| are redefined and behave like the commands |\Cdots|, |\Ldots|, -% |\Vdots| and |\Ddots|. +% With the option |renew-dots|, the command |\cdots|, |\ldots|, |\vdots|, +% |\ddots|, etc. are redefined and behave like the commands |\Cdots|, |\Ldots|, +% |\Vdots|, |\Ddots|, etc. % \begin{macrocode} renew-dots .bool_set:N = \l_@@_renew_dots_bool , renew-dots .value_forbidden:n = true , nullify-dots .bool_set:N = \l_@@_nullify_dots_bool , -% \end{macrocode} -% -% \bigskip -% In some circonstancies, the ``medium nodes'' are created automatically, for -% example when a dotted line has an ``open'' extremity (idem for the ``large nodes''). -% \begin{macrocode} create-medium-nodes .bool_set:N = \l_@@_medium_nodes_bool , create-large-nodes .bool_set:N = \l_@@_large_nodes_bool , create-extra-nodes .meta:n = @@ -3868,6 +4114,14 @@ version 2005/12/01 or later. % \begin{macrocode} \keys_define:nn { NiceMatrix / Env } { + code-before .code:n = + { + \tl_if_empty:nF { #1 } + { + \tl_set:Nn \l_@@_code_before_tl { #1 } + \bool_set_true:N \l_@@_code_before_bool + } + } , % \end{macrocode} % \bigskip % The options |c|, |t| and |b| of the environment |{NiceArray}| have the same @@ -3900,10 +4154,6 @@ version 2005/12/01 or later. name .value_required:n = true , code-after .tl_gset:N = \g_@@_code_after_tl , code-after .value_required:n = true , - first-col .code:n = \int_zero:N \l_@@_first_col_int , - first-row .code:n = \int_zero:N \l_@@_first_row_int , - last-row .int_set:N = \l_@@_last_row_int , - last-row .default:n = -1 , } % \end{macrocode} % @@ -3925,6 +4175,12 @@ version 2005/12/01 or later. NiceMatrix / Env , } , NiceMatrix / xdots .inherit:n = NiceMatrix / xdots , + NiceTabular .inherit:n = + { + NiceMatrix / Global , + NiceMatrix / Env + } , + NiceTabular / xdots .inherit:n = NiceMatrix / xdots , NiceArray .inherit:n = { NiceMatrix / Global , @@ -3948,6 +4204,11 @@ version 2005/12/01 or later. % \begin{macrocode} \keys_define:nn { NiceMatrix / NiceMatrixOptions } { + last-col .code:n = \tl_if_empty:nF { #1 } + { \@@_error:n { last-col~non~empty~for~NiceMatrixOptions } } + \int_zero:N \l_@@_last_col_int , + small .bool_set:N = \l_@@_small_bool , + small .value_forbidden:n = true , % \end{macrocode} % % With the option |renew-matrix|, the environment |{matrix}| of \pkg{amsmath} @@ -3981,7 +4242,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% Usually, an error is raised when the user tries to give the same to name two +% Usually, an error is raised when the user tries to give the same name to two % distincts environments of \pkg{nicematrix} (theses names are global and not % local to the current TeX scope). However, the option |allow-duplicate-names| % disables this feature. @@ -4041,6 +4302,11 @@ version 2005/12/01 or later. r .code:n = \tl_set:Nn \l_@@_type_of_col_tl R , L .code:n = \tl_set:Nn \l_@@_type_of_col_tl L , R .code:n = \tl_set:Nn \l_@@_type_of_col_tl R , + S .code:n = \bool_if:NTF \c_@@_siunitx_loaded_bool + { \tl_set:Nn \l_@@_type_of_col_tl S } + { \@@_error:n { option~S~without~siunitx } } , + small .bool_set:N = \l_@@_small_bool , + small .value_forbidden:n = true , unknown .code:n = \@@_error:n { Unknown~option~for~NiceMatrix } } % \end{macrocode} @@ -4060,6 +4326,8 @@ version 2005/12/01 or later. % be used without value because the number of columns of the array is read % from the preamble of the array. % \begin{macrocode} + small .bool_set:N = \l_@@_small_bool , + small .value_forbidden:n = true , last-col .code:n = \tl_if_empty:nF { #1 } { \@@_error:n { last-col~non~empty~for~NiceArray } } \int_zero:N \l_@@_last_col_int , @@ -4077,13 +4345,23 @@ version 2005/12/01 or later. { \@@_error:n { last-col~non~empty~for~NiceArray } } \int_zero:N \l_@@_last_col_int , first-row .code:n = \int_zero:N \l_@@_first_row_int , - last-row .int_set:N = \l_@@_last_row_int , - last-row .default:n = -1 , + small .bool_set:N = \l_@@_small_bool , + small .value_forbidden:n = true , unknown .code:n = \@@_error:n { Unknown~option~for~NiceMatrix } } % \end{macrocode} % +% \bigskip +% We finalise the definition of the set of keys ``|NiceMatrix / NiceTabular|'' +% with the options specific to |{NiceTabular}|. % +% \begin{macrocode} +\keys_define:nn { NiceMatrix / NiceTabular } + { + unknown .code:n = \@@_error:n { Unknown~option~for~NiceTabular } + } +% \end{macrocode} +% % \bigskip % \subsection*{Important code used by \{NiceArrayWithDelims\} } % @@ -4110,12 +4388,15 @@ version 2005/12/01 or later. % \end{macrocode} % The content of the cell is composed in the box |\l_@@_cell_box| because we want % to compute some dimensions of the box. The |\hbox_set_end:| corresponding to -% this |\hbox_set:Nw| will be in the |\@@_end_Cell:| (and the +% this |\hbox_set:Nw| will be in the |\@@_end_Cell:| (and the potential % |\c_math_toggle_token| also). % \begin{macrocode} \hbox_set:Nw \l_@@_cell_box - \c_math_toggle_token - \bool_if:NT \l_@@_small_bool \scriptstyle + \bool_if:NF \l_@@_NiceTabular_bool + { + \c_math_toggle_token + \bool_if:NT \l_@@_small_bool \scriptstyle + } % \end{macrocode} % % We will call \emph{corners} of the matrix the cases which are at the @@ -4158,12 +4439,12 @@ version 2005/12/01 or later. \pgfrememberpicturepositiononpagetrue \pgfcoordinate { \@@_env: - row - \int_use:N \c@iRow - base } - \pgfpointorigin + { \pgfpoint \c_zero_dim { 0.5 \arrayrulewidth } } \str_if_empty:NF \l_@@_name_str { \pgfnodealias - { \@@_env: - row - \int_use:N \c@iRow - base } { \l_@@_name_str - row - \int_use:N \c@iRow - base } + { \@@_env: - row - \int_use:N \c@iRow - base } } \endpgfpicture } @@ -4199,14 +4480,20 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Npn \@@_end_Cell: { - \c_math_toggle_token + \bool_if:NF \l_@@_NiceTabular_bool \c_math_toggle_token \hbox_set_end: % \end{macrocode} % +% \begin{macrocode} + \box_set_ht:Nn \l_@@_cell_box + { \box_ht:N \l_@@_cell_box + \l_@@_cell_space_top_limit_dim } + \box_set_dp:Nn \l_@@_cell_box + { \box_dp:N \l_@@_cell_box + \l_@@_cell_space_bottom_limit_dim } +% \end{macrocode} +% % We want to compute in |\g_@@_max_cell_width_dim| the width of the widest cell % of the array (except the cells of the ``first column'' and the ``last % column''). -% % \begin{macrocode} \dim_gset:Nn \g_@@_max_cell_width_dim { \dim_max:nn \g_@@_max_cell_width_dim { \box_wd:N \l_@@_cell_box } } @@ -4242,10 +4529,7 @@ version 2005/12/01 or later. % \end{itemize} % \begin{macrocode} \bool_if:NTF \g_@@_empty_cell_bool - { - \box_use_drop:N \l_@@_cell_box - \bool_gset_false:N \g_@@_empty_cell_bool - } + { \box_use_drop:N \l_@@_cell_box } { \dim_compare:nNnTF { \box_wd:N \l_@@_cell_box } > \c_zero_dim \@@_node_for_the_cell: @@ -4300,13 +4584,13 @@ version 2005/12/01 or later. % \begin{pNiceMatrix} % 1 & 2 & 3 & 4 \\ % 5 & \Cdots & & 6 \\ -% 7 & \Cdots[color=red] \\ +% 7 & \Cdots[color=red] % \end{pNiceMatrix} % \end{BVerbatim} % $\begin{pNiceMatrix} % 1 & 2 & 3 & 4 \\ % 5 & \Cdots & & 6 \\ -% 7 & \Cdots[color=red] \\ +% 7 & \Cdots[color=red] % \end{pNiceMatrix}$ % % \smallskip @@ -4322,29 +4606,23 @@ version 2005/12/01 or later. % % % \bigskip -% We begin with a test of the flag |\c_@@_draft_bool| because, if the key -% |draft| is used, the dotted lines are not drawn. % \begin{macrocode} -\bool_if:NTF \c_@@_draft_bool - { \cs_set_protected:Npn \@@_instruction_of_type:nn #1 #2 { } } - { - \cs_new_protected:Npn \@@_instruction_of_type:nn #1 #2 - { +\cs_new_protected:Npn \@@_instruction_of_type:nn #1 #2 + { % \end{macrocode} % It's important to use a |\tl_gput_right:cx| and not a |\tl_gput_left:cx| % because we want the |\Ddots| lines to be drawn in the order of appearance % in the array (for parallelisation). % \begin{macrocode} - \tl_gput_right:cx - { g_@@_ #1 _ lines _ tl } - { - \use:c { @@ _ draw _ #1 : nnn } - { \int_use:N \c@iRow } - { \int_use:N \c@jCol } - { \exp_not:n { #2 } } - } - } - } + \tl_gput_right:cx + { g_@@_ #1 _ lines _ tl } + { + \use:c { @@ _ draw _ #1 : nnn } + { \int_use:N \c@iRow } + { \int_use:N \c@jCol } + { \exp_not:n { #2 } } + } + } % \end{macrocode} % % @@ -4380,58 +4658,126 @@ version 2005/12/01 or later. % |\ialign| in the environment |{NiceArrayWithDelims}| but restore the standard % version for use in the cells of the array. % \begin{macrocode} -\cs_set_eq:NN \@@_standard_ialign: \ialign +\cs_set_eq:NN \@@_old_ialign: \ialign % \end{macrocode} % -% \bigskip -% The following must \emph{not} be protected because it begins with |\noalign|. -% \begin{macrocode} -\cs_new:Npn \@@_everycr: { \noalign { \@@_everycr_i: } } -% \end{macrocode} % +% The following command creates a |row| node (and not a row of nodes!). % \begin{macrocode} -\cs_new_protected:Npn \@@_everycr_i: - { - \int_gzero:N \c@jCol +\cs_new_protected:Npn \@@_create_row_node: + { % \end{macrocode} % The |\hbox:n| (or |\hbox|) is mandatory. % \begin{macrocode} \hbox { + \bool_if:NT \l_@@_code_before_bool + { + \vtop + { + \skip_vertical:N 0.5\arrayrulewidth + \pgfsys@markposition { \@@_env: - row - \@@_succ:n \c@iRow } + \skip_vertical:N -0.5\arrayrulewidth + } + } \pgfpicture \pgfrememberpicturepositiononpagetrue \pgfcoordinate { \@@_env: - row - \@@_succ:n \c@iRow } - \pgfpointorigin + { \pgfpoint \c_zero_dim { - 0.5 \arrayrulewidth } } \str_if_empty:NF \l_@@_name_str { \pgfnodealias - { \@@_env: - row - \int_use:N \c@iRow - row } - { \l_@@_name_str - row - \int_use:N \c@iRow - row } + { \l_@@_name_str - row - \int_use:N \c@iRow } + { \@@_env: - row - \int_use:N \c@iRow } } \endpgfpicture - } + } + } % \end{macrocode} -% We add the potential horizontal lines specified by the option |hlines|. +% +% +% +% \bigskip +% The following must \emph{not} be protected because it begins with |\noalign|. +% \begin{macrocode} +\cs_new:Npn \@@_everycr: { \noalign { \@@_everycr_i: } } +% \end{macrocode} +% +% % \begin{macrocode} - \bool_if:NT \l_@@_hlines_bool +\cs_new_protected:Npn \@@_everycr_i: + { + \int_gzero:N \c@jCol + \bool_if:NF \g_@@_row_of_col_done_bool { + \@@_create_row_node: +% \end{macrocode} +% We add the potential horizontal lines specified by the option |hlines|. +% \begin{macrocode} + \bool_if:NT \l_@@_hlines_bool + { % \end{macrocode} % The counter |\c@iRow| has the value $-1$ only if there is a ``first % row'' and that we are before that ``first row'', i.e. just before the % beginning of the array. % \begin{macrocode} - \int_compare:nNnT \c@iRow > { -1 } - { - \bool_if:NF \g_@@_row_of_col_done_bool + \int_compare:nNnT \c@iRow > { -1 } { \int_compare:nNnF \c@iRow = \l_@@_last_row_int - { - \bool_if:NTF \c_@@_colortbl_loaded_bool - { { \CT@arc@ \hrule height \arrayrulewidth } } - { \hrule height \arrayrulewidth } - } - } +% \end{macrocode} +% The command |\CT@arc@| is a command of \pkg{colortbl} which sets the color of +% the rules in the array. The package \pkg{nicematrix} uses it even if +% \pkg{colortbl} is not loaded. We use a TeX group in order to limit the scope +% of |\CT@arc@|. +% \begin{macrocode} + { { \CT@arc@ \hrule height \arrayrulewidth } } + } + } + } + } +% \end{macrocode} +% +% \bigskip +% The command |\@@_newcolumntype| is the command |\newcolumntype| of +% \pkg{array} without the warnings for redefinitions of columns types (we will +% use it to redefine the columns types |w|, |W|, |p|, |m| and |b|). +% \begin{macrocode} +\cs_set_protected:Npn \@@_newcolumntype #1 + { + \cs_if_free:cT { NC @ find @ #1 } + { \NC@list \expandafter { \the \NC@list \NC@do #1 } } + \cs_set:cpn {NC @ find @ #1 } ##1 #1 { \NC@ { ##1 } } + \peek_meaning:NTF [ + { \newcol@ #1 } + { \newcol@ #1 [ 0 ] } + } +% \end{macrocode} +% +% +% \bigskip +% The following command will be used to redefine the column types |p|, |m| and +% |b|. That means that it will be used three times. The first argument is the +% letter of the column type (|p|, |m| or |b|). The second is the letter of +% position for the environment |{minipage}| (|t|, |c| or |b|). +% \begin{macrocode} +\cs_new_protected:Npn \@@_define_columntype:nn #1 #2 + { +% \end{macrocode} +% We don't want a warning for redefinition of the column type. That's why we use +% |\@@_newcolumntype| and not |\newcolumntype|. +% \begin{macrocode} + \@@_newcolumntype #1 [ 1 ] + { + > { + \@@_Cell: + \begin { minipage } [ #2 ] { ##1 } + \mode_leave_vertical: \box_use:N \@arstrutbox } +% \end{macrocode} +% Here, we put |c| but we would have the result with |l| or |r|. +% \begin{macrocode} + c + < { \box_use:N \@arstrutbox \end { minipage } \@@_end_Cell: } } } % \end{macrocode} @@ -4444,12 +4790,26 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Npn \@@_pre_array: { +% \end{macrocode} +% If \pkg{booktabs} is loaded, we have to patch the macro |\@BTnormal| which is +% a macro of \pkg{booktabs}. The macro |\@BTnormal| draws an horizontal rule but +% it occurs after a vertical skip done by a low level TeX command. When this +% macro |\@BTnormal| occurs, the |row| node has yet been inserted by +% \pkg{nicematrix} \emph{before} the vertical skip (and thus, at a wrong place). +% That why we decide to create a new |row| node (for the same row). We patch the +% macro |\@BTnormal| to create this |row| node. This new |row| node will +% overwrite the previous definition of that |row| node and we have managed to +% avoid the error messages of that redefinition +% \footnote{cf. |\nicematrix@redefine@check@rerun|}. +% \begin{macrocode} + \bool_if:NT \c_@@_booktabs_loaded_bool + { \tl_put_left:Nn \@BTnormal \@@_create_row_node: } \box_clear_new:N \l_@@_cell_box \cs_if_exist:NT \theiRow - { \int_set_eq:NN \l_@@_save_iRow_int \c@iRow } + { \int_set_eq:NN \l_@@_old_iRow_int \c@iRow } \int_gzero_new:N \c@iRow \cs_if_exist:NT \thejCol - { \int_set_eq:NN \l_@@_save_jCol_int \c@jCol } + { \int_set_eq:NN \l_@@_old_jCol_int \c@jCol } \int_gzero_new:N \c@jCol \normalbaselines % \end{macrocode} @@ -4475,6 +4835,8 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_set:Npn \ialign { + \bool_if:NT \l_@@_NiceTabular_bool + { \dim_set_eq:NN \arraycolsep \@@_old_arraycolsep_dim } \bool_if:NTF \c_@@_colortbl_loaded_bool { \CT@everycr @@ -4513,31 +4875,24 @@ version 2005/12/01 or later. % After its first use, the definition of |\ialign| will revert % automatically to its default definition. With this programmation, we will % have, in the cells of the array, a clean version of |\ialign|.\footnote{The -% user will probably not employ directly |\ialign| in the array... but more +% user will probably not use directly |\ialign| in the array... but more % likely environments that utilize |\ialign| internally (e.g.: |{substack}|).} % \begin{macrocode} - \cs_set_eq:NN \ialign \@@_standard_ialign: + \cs_set_eq:NN \ialign \@@_old_ialign: \halign } % \end{macrocode} % -% We define the new column types |L|, |C| and |R| that must be used instead of -% |l|, |c| and |r| in the preamble of |{NiceArray}|. -% \begin{macrocode} - \newcolumntype L { > \@@_Cell: l < \@@_end_Cell: } - \newcolumntype C { > \@@_Cell: c < \@@_end_Cell: } - \newcolumntype R { > \@@_Cell: r < \@@_end_Cell: } -% \end{macrocode} % We keep in memory the old versions or |\ldots|, |\cdots|, etc. only because we % use them inside |\phantom| commands in order that the new commands |\Ldots|, % |\Cdots|, etc. give the same spacing (except when the option |nullify-dots| is % used). % \begin{macrocode} - \cs_set_eq:NN \@@_ldots \ldots - \cs_set_eq:NN \@@_cdots \cdots - \cs_set_eq:NN \@@_vdots \vdots - \cs_set_eq:NN \@@_ddots \ddots - \cs_set_eq:NN \@@_iddots \iddots + \cs_set_eq:NN \@@_old_ldots \ldots + \cs_set_eq:NN \@@_old_cdots \cdots + \cs_set_eq:NN \@@_old_vdots \vdots + \cs_set_eq:NN \@@_old_ddots \ddots + \cs_set_eq:NN \@@_old_iddots \iddots \cs_set_eq:NN \firsthline \hline \cs_set_eq:NN \lasthline \hline \cs_set_eq:NN \Ldots \@@_Ldots @@ -4548,11 +4903,14 @@ version 2005/12/01 or later. \cs_set_eq:NN \hdottedline \@@_hdottedline: \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 + \cs_set_eq:NN \dotfill \@@_dotfill: \cs_set_eq:NN \CodeAfter \@@_CodeAfter:n + \cs_set_eq:NN \slashbox \@@_slashbox:nn \bool_if:NT \l_@@_renew_dots_bool { \cs_set_eq:NN \ldots \@@_Ldots @@ -4604,14 +4962,31 @@ version 2005/12/01 or later. \cs_set_eq:NN \@ifnextchar \new@ifnextchar % \end{macrocode} % -% We nullify the definitions of the column types |w| and |W| before their -% redefinition because we want to avoid a warning in the log file for a -% redefinition of a column type. We must put |\relax| and not -% |\prg_do_nothing:|. +% \bigskip +% We define the new column types |L|, |C| and |R| that must be used instead of +% |l|, |c| and |r| in the preamble of |{NiceArray}|. We use |\@@_newcolumntype| +% because it will be slightly quicker thant |\newcolumtype|. +% \begin{macrocode} + \@@_newcolumntype L { > \@@_Cell: l < \@@_end_Cell: } + \@@_newcolumntype C { > \@@_Cell: c < \@@_end_Cell: } + \@@_newcolumntype R { > \@@_Cell: r < \@@_end_Cell: } +% \end{macrocode} +% +% \bigskip +% We redefine the column types |p|, |m| and |b|. The command +% |\@@_define_columntype:nn| is only used here. +% \begin{macrocode} + \@@_define_columntype:nn p t + \@@_define_columntype:nn m c + \@@_define_columntype:nn b b +% \end{macrocode} +% +% \bigskip +% We redefine the column types |w| and |W|. We use |\@@_newcolumntype| instead +% of |\newcolumtype| because we don't want warnings for column types already +% defined. % \begin{macrocode} - \cs_set_eq:NN \NC@find@w \relax - \cs_set_eq:NN \NC@find@W \relax - \newcolumntype w [ 2 ] + \@@_newcolumntype w [ 2 ] { > { \hbox_set:Nw \l_@@_cell_box @@ -4630,7 +5005,7 @@ version 2005/12/01 or later. { \box_use_drop:N \l_@@_cell_box } } } - \newcolumntype W [ 2 ] + \@@_newcolumntype W [ 2 ] { > { \hbox_set:Nw \l_@@_cell_box @@ -4726,7 +5101,7 @@ version 2005/12/01 or later. \tl_gclear_new:N \g_@@_Vdots_lines_tl \tl_gclear_new:N \g_@@_Ddots_lines_tl \tl_gclear_new:N \g_@@_Iddots_lines_tl - \tl_gclear_new:N \g_@@_Hdotsfor_lines_tl + \tl_gclear_new:N \g_@@_HVdotsfor_lines_tl } % \end{macrocode} % @@ -4742,7 +5117,9 @@ version 2005/12/01 or later. \str_if_empty:NT \g_@@_name_env_str { \str_gset:Nn \g_@@_name_env_str { NiceArrayWithDelims } } \@@_adapt_S_column: - \@@_test_if_math_mode: + \bool_if:NTF \l_@@_NiceTabular_bool + \mode_leave_vertical: + \@@_test_if_math_mode: \bool_if:NT \l_@@_in_env_bool { \@@_fatal:n { Yet~in~env } } \bool_set_true:N \l_@@_in_env_bool % \end{macrocode} @@ -4785,6 +5162,98 @@ version 2005/12/01 or later. { #3 , #5 } % \end{macrocode} % +% \bigskip +% If the key |code-before| is used, we have to create the |col| nodes and the +% |row| nodes before the creation of the array. First, we have to test whether +% the size of the array has been written in the |aux| file in a previous run. In +% this case, a command |\@@_size_|{\slshape\ttfamily nb_of_env}|:| has been +% created. +% \begin{macrocode} + \bool_if:NT \l_@@_code_before_bool + { + \seq_if_exist:cT { @@_size_ \int_use:N \g_@@_env_int _ seq } + { +% \end{macrocode} +% First, we give values to the LaTeX counters |iRow| and |jCol|. We remind that, +% in the |code-before| (and in the |code-after|) they represent the numbers of +% rows and columns of the array (without the potential last row and last column). +% \begin{macrocode} + \int_zero_new:N \c@iRow + \int_set:Nn \c@iRow + { \seq_item:cn { @@_size_ \int_use:N \g_@@_env_int _ seq } 2 } + \int_zero_new:N \c@jCol + \int_set:Nn \c@jCol + { \seq_item:cn { @@_size_ \int_use:N \g_@@_env_int _ seq } 4 } +% \end{macrocode} +% We have to adjust the values of |\c@iRow| and |\c@jCol| to take into account +% the potential last row and last column. A value of $-2$ for +% |\l_@@_last_row_int| means that there is no last row. Idem for the columns. +% \begin{macrocode} + \int_compare:nNnF \l_@@_last_row_int = { -2 } + { \int_decr:N \c@iRow } + \int_compare:nNnF \l_@@_last_col_int = { -2 } + { \int_decr:N \c@jCol } +% \end{macrocode} +% +% Now, we will create all the |col| nodes and |row| nodes with the informations +% written in the |aux| file. You use the technique described in the page~1229 of +% |pgfmanual.pdf|, version~3.1.4b. +% \begin{macrocode} + \pgfsys@markposition { \@@_env: - position } + \pgfsys@getposition { \@@_env: - position } \@@_picture_position: + \pgfpicture +% \end{macrocode} +% First, the creation of the |row| nodes. +% \begin{macrocode} + \int_step_inline:nnn + { \seq_item:cn { @@_size_ \int_use:N \g_@@_env_int _ seq } 1 } + { \seq_item:cn { @@_size_ \int_use:N \g_@@_env_int _ seq } 2 + 1 } + { + \pgfsys@getposition { \@@_env: - row - ##1 } \@@_node_position: + \pgfcoordinate { \@@_env: - row - ##1 } + { \pgfpointdiff \@@_picture_position: \@@_node_position: } + } +% \end{macrocode} +% Now, the creation of the |col| nodes. +% \begin{macrocode} + \int_step_inline:nnn + { \seq_item:cn { @@_size_ \int_use:N \g_@@_env_int _ seq } 3 } + { \seq_item:cn { @@_size_ \int_use:N \g_@@_env_int _ seq } 4 + 1 } + { + \pgfsys@getposition { \@@_env: - col - ##1 } \@@_node_position: + \pgfcoordinate { \@@_env: - col - ##1 } + { \pgfpointdiff \@@_picture_position: \@@_node_position: } + } + \endpgfpicture + \group_begin: + \bool_if:NT \c_@@_tikz_loaded_bool + { +% \end{macrocode} +% Be careful: we must \emph{not} put ``|remember picture|'' in the |\pgfset|. +% \begin{macrocode} + \pgfset + { + every~picture / .style = + { overlay , name~prefix = \@@_env: - } + } + } + \cs_set_eq:NN \cellcolor \@@_cellcolor:nn + \cs_set_eq:NN \rectanglecolor \@@_rectanglecolor:nnn + \cs_set_eq:NN \rowcolor \@@_rowcolor:nn + \cs_set_eq:NN \rowcolors \@@_rowcolors:nnn + \cs_set_eq:NN \columncolor \@@_columncolor:nn + \cs_set_eq:NN \chessboardcolors \@@_chessboardcolors:nn +% \end{macrocode} +% We compose the |code-before| in math mode in order to nullify the spaces put +% by the user between instructions in the |code-before|. +% \begin{macrocode} + \bool_if:NT \l_@@_NiceTabular_bool \c_math_toggle_token + \l_@@_code_before_tl + \bool_if:NT \l_@@_NiceTabular_bool \c_math_toggle_token + \group_end: + } + } +% \end{macrocode} % % A value of $-1$ for the counter |\l_@@_last_row_int| means that the user has % used the option |last-row| without value, that is to say without specifying @@ -4897,6 +5366,7 @@ version 2005/12/01 or later. \bool_lazy_all:nT { \l_@@_NiceArray_bool + { \bool_not_p:n \l_@@_NiceTabular_bool } { \bool_not_p:n \l_@@_vlines_bool } { \bool_not_p:n \l_@@_exterior_arraycolsep_bool } } @@ -4908,6 +5378,7 @@ version 2005/12/01 or later. \bool_lazy_all:nT { \l_@@_NiceArray_bool + { \bool_not_p:n \l_@@_NiceTabular_bool } { \bool_not_p:n \l_@@_vlines_bool } { \bool_not_p:n \l_@@_exterior_arraycolsep_bool } } @@ -4921,6 +5392,22 @@ version 2005/12/01 or later. % \begin{macrocode} \hbox_set:Nw \l_@@_the_array_box % \end{macrocode} +% Here is a trick. We will call |\array| and, at the beginning, |\array| will set +% |\col@sep| equal to the current value of |\arraycolsep|. In we are in an +% environment |{NiceTabular}|, we would like that |\array| sets |\col@sep| equal +% to the current value of |\tabcolsep|. That's why we set |\arraycolsep| equal +% to |\tabcolsep|. However, the value of |\tabcolsep| in each cell of the array +% should be equal to the current value of |\tabcolsep| outside |{NiceTabular}|. +% That's why we save the current value of |\arraycolsep| and we will restore the +% value just before the |\halign|. It's possible because we do a redefinition of +% |\ialign| (see just below). +% \begin{macrocode} + \bool_if:NT \l_@@_NiceTabular_bool + { + \dim_set_eq:NN \@@_old_arraycolsep_dim \arraycolsep + \dim_set_eq:NN \arraycolsep \tabcolsep + } +% \end{macrocode} % If the key |\vlines| is used, we increase |\arraycolsep| by % |0.5\arrayrulewidth| in order to reserve space for the width of the vertical % rules drawn with Tikz after the end of the array. However, the first @@ -4932,12 +5419,16 @@ version 2005/12/01 or later. \dim_add:Nn \arraycolsep { 0.5 \arrayrulewidth } \skip_horizontal:N 0.5\arrayrulewidth } +% \end{macrocode} +% +% +% \begin{macrocode} \skip_horizontal:N \l_@@_left_margin_dim \skip_horizontal:N \l_@@_extra_left_margin_dim \c_math_toggle_token \bool_if:NTF \l_@@_light_syntax_bool - { \begin { @@-light-syntax } } - { \begin { @@-normal-syntax } } + { \use:c { @@-light-syntax } } + { \use:c { @@-normal-syntax } } } % \end{macrocode} % @@ -4945,8 +5436,8 @@ version 2005/12/01 or later. % \begin{macrocode} { \bool_if:NTF \l_@@_light_syntax_bool - { \end { @@-light-syntax } } - { \end { @@-normal-syntax } } + { \use:c { end @@-light-syntax } } + { \use:c { end @@-normal-syntax } } \c_math_toggle_token \skip_horizontal:N \l_@@_right_margin_dim \skip_horizontal:N \l_@@_extra_right_margin_dim @@ -4964,7 +5455,7 @@ version 2005/12/01 or later. % % \bigskip % It the user has used the key |last-row| with a value, we control that the -% given value is correct (since we have just contructed the array, we know the +% given value is correct (since we have just constructed the array, we know the % real number of rows of the array). % \begin{macrocode} \int_compare:nNnT \l_@@_last_row_int > { -2 } @@ -5027,9 +5518,9 @@ version 2005/12/01 or later. \str_if_eq:VnTF \l_@@_baseline_str { b } { \pgfpicture - \@@_qpoint: { row - 1 } + \@@_qpoint:n { row - 1 } \dim_gset_eq:NN \g_tmpa_dim \pgf@y - \@@_qpoint: { row - \int_use:N \c@iRow - base } + \@@_qpoint:n { row - \int_use:N \c@iRow - base } \dim_gsub:Nn \g_tmpa_dim \pgf@y \endpgfpicture \int_compare:nNnT \l_@@_first_row_int = 0 @@ -5063,9 +5554,9 @@ version 2005/12/01 or later. \int_set:Nn \l_tmpa_int 1 } \pgfpicture - \@@_qpoint: { row - 1 } + \@@_qpoint:n { row - 1 } \dim_gset_eq:NN \g_tmpa_dim \pgf@y - \@@_qpoint: { row - \int_use:N \l_tmpa_int - base } + \@@_qpoint:n { row - \int_use:N \l_tmpa_int - base } \dim_gsub:Nn \g_tmpa_dim \pgf@y \endpgfpicture \int_compare:nNnT \l_@@_first_row_int = 0 @@ -5122,9 +5613,13 @@ version 2005/12/01 or later. \skip_vertical:N -\l_tmpa_dim \hbox { - \skip_horizontal:N -\arraycolsep + \bool_if:NTF \l_@@_NiceTabular_bool + { \skip_horizontal:N -\tabcolsep } + { \skip_horizontal:N -\arraycolsep } \box_use_drop:N \l_@@_the_array_box - \skip_horizontal:N -\arraycolsep + \bool_if:NTF \l_@@_NiceTabular_bool + { \skip_horizontal:N -\tabcolsep } + { \skip_horizontal:N -\arraycolsep } } % \end{macrocode} % We take into account the ``last row'' (we have previously computed its total @@ -5203,16 +5698,16 @@ version 2005/12/01 or later. \int_set:Nn \l_tmpa_int 1 } \pgfpicture - \@@_qpoint: { row - 1 } + \@@_qpoint:n { row - 1 } \dim_gset_eq:NN \g_tmpa_dim \pgf@y - \@@_qpoint: { row - \@@_succ:n \c@iRow } + \@@_qpoint:n { row - \@@_succ:n \c@iRow } \dim_gadd:Nn \g_tmpa_dim \pgf@y \dim_gset:Nn \g_tmpa_dim { 0.5 \g_tmpa_dim } % \end{macrocode} % Now, |\g_tmpa_dim| contains the $y$-value of the center of the array (the % delimiters are centered in relation with this value). % \begin{macrocode} - \@@_qpoint: { row - \int_use:N \l_tmpa_int - base } + \@@_qpoint:n { row - \int_use:N \l_tmpa_int - base } \dim_gsub:Nn \g_tmpa_dim \pgf@y % \end{macrocode} % We take into account the position of the mathematical axis. @@ -5314,6 +5809,7 @@ version 2005/12/01 or later. % \bigskip % When the key |light-syntax| is used, we use an environment which takes its whole % body as an argument (with the specifier |b| of \pkg{xparse}). +% % \label{code-light-syntax} % \begin{macrocode} \NewDocumentEnvironment { @@-light-syntax } { b } { @@ -5331,8 +5827,31 @@ version 2005/12/01 or later. { \@@_fatal:n { double-backslash~in~light-syntax } } } % \end{macrocode} -% The body of the environment, which is stored in the argument |#1|, is now -% splitted into items (and \emph{not} tokens) +% Now, you extract the |code-after| or the body of the environment. Maybe, there +% is no command |\CodeAfter| in the body. That's why you put a marker +% |\CodeAfter| after |#1|. If there is yet a |\CodeAfter| in |#1|, this second +% (or third...) |\CodeAfter| will be catched in the value of +% |\g_@@_code_after_tl|. That doesn't matter because |\CodeAfter| will be set to +% \textsl{no-op} before the execution of |\g_@@_code_after_tl|. +% \begin{macrocode} + \@@_light_syntax_i #1 \CodeAfter \q_stop + } +% \end{macrocode} +% Now, the second part of the environment. It is empty. That's not surprising +% because we have caught the whole body of the environment with the specifier +% |b| provided by \pkg{xparse}. +% \begin{macrocode} + { } +% \end{macrocode} +% +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_light_syntax_i #1\CodeAfter #2\q_stop + { + \tl_gput_right:Nn \g_@@_code_after_tl { #2 } +% \end{macrocode} +% The body of the array, which is stored in the argument |#1|, is now +% splitted into items (and \emph{not} tokens). % \begin{macrocode} \seq_gclear_new:N \g_@@_rows_seq \tl_set_rescan:Nno \l_@@_end_of_row_tl { } \l_@@_end_of_row_tl @@ -5361,11 +5880,10 @@ version 2005/12/01 or later. \endarray } % \end{macrocode} -% Now, the second part of the environment. It is empty. That's not surprising -% because we have caught the whole body of the environment with the specifier -% |b| provided by \pkg{xparse}. +% % \begin{macrocode} - { } +\cs_new_protected:Npn \@@_line_with_light_syntax:n #1 + { \tl_if_empty:nF { #1 } { \\ \@@_line_with_light_syntax_i:n { #1 } } } % \end{macrocode} % % \begin{macrocode} @@ -5375,22 +5893,10 @@ version 2005/12/01 or later. \seq_gset_split:Nnn \g_@@_cells_seq { ~ } { #1 } \seq_gpop_left:NN \g_@@_cells_seq \l_tmpa_tl \l_tmpa_tl - \seq_map_function:NN \g_@@_cells_seq \@@_cell_with_light_syntax:n + \seq_map_inline:Nn \g_@@_cells_seq { & ##1 } } % \end{macrocode} -% -% \begin{macrocode} -\cs_new_protected:Npn \@@_line_with_light_syntax:n #1 - { - \tl_if_empty:nF { #1 } - { \\ \@@_line_with_light_syntax_i:n { #1 } } - } -% \end{macrocode} % -% \begin{macrocode} -\cs_new_protected:Npn \@@_cell_with_light_syntax:n #1 { & #1 } -% \end{macrocode} -% % \bigskip % The following command is used by the code which detects whether the % environment is empty (we raise a fatal error in this case: it's only a @@ -5410,7 +5916,7 @@ version 2005/12/01 or later. % % \bigskip % The command |\@@_create_col_nodes:| will construct a special last row. -% That last row is a false row used to create the |col|-nodes and to fix the +% That last row is a false row used to create the |col| nodes and to fix the % width of the columns (when the array is constructed with an option which % specify the width of the columns). % \begin{macrocode} @@ -5421,12 +5927,14 @@ version 2005/12/01 or later. \int_compare:nNnT \l_@@_first_col_int = 0 { \omit - \skip_horizontal:N -2\arraycolsep + \skip_horizontal:N -2\col@sep + \bool_if:NT \l_@@_code_before_bool + { \pgfsys@markposition { \@@_env: - col - 0 } } \pgfpicture \pgfrememberpicturepositiononpagetrue \pgfcoordinate { \@@_env: - col - 0 } \pgfpointorigin \str_if_empty:NF \l_@@_name_str - { \pgfnodealias { \@@_env: - col - 0 } { \l_@@_name_str - col - 0 } } + { \pgfnodealias { \l_@@_name_str - col - 0 } { \@@_env: - col - 0 } } \endpgfpicture & } @@ -5436,15 +5944,46 @@ version 2005/12/01 or later. % \begin{macrocode} \bool_gset_true:N \g_@@_row_of_col_done_bool % \end{macrocode} -% First, we put a ``|col|'' node on the left of the first column (of course, we +% First, we put a |col| node on the left of the first column (of course, we % have to do that \emph{after} the |\omit|). % \begin{macrocode} - \pgfpicture - \pgfrememberpicturepositiononpagetrue - \pgfcoordinate { \@@_env: - col - 1 } \pgfpointorigin - \str_if_empty:NF \l_@@_name_str - { \pgfnodealias { \@@_env: - col - 1 } { \l_@@_name_str - col - 1 } } - \endpgfpicture + \int_compare:nNnTF \l_@@_first_col_int = 0 + { + \bool_if:NT \l_@@_code_before_bool + { + \hbox + { + \skip_horizontal:N -0.5\arrayrulewidth + \pgfsys@markposition { \@@_env: - col - 1 } + \skip_horizontal:N 0.5\arrayrulewidth + } + } + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgfcoordinate { \@@_env: - col - 1 } + { \pgfpoint { - 0.5 \arrayrulewidth } \c_zero_dim } + \str_if_empty:NF \l_@@_name_str + { \pgfnodealias { \l_@@_name_str - col - 1 } { \@@_env: - col - 1 } } + \endpgfpicture + } + { + \bool_if:NT \l_@@_code_before_bool + { + \hbox + { + \skip_horizontal:N 0.5 \arrayrulewidth + \pgfsys@markposition { \@@_env: - col - 1 } + \skip_horizontal:N -0.5\arrayrulewidth + } + } + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgfcoordinate { \@@_env: - col - 1 } + { \pgfpoint { 0.5 \arrayrulewidth } \c_zero_dim } + \str_if_empty:NF \l_@@_name_str + { \pgfnodealias { \l_@@_name_str - col - 1 } { \@@_env: - col - 1 } } + \endpgfpicture + } % \end{macrocode} % We compute in |\g_tmpa_skip| the common width of the columns (it's a skip and % not a dimension). We use a global variable because we are in a cell of an @@ -5465,16 +6004,26 @@ version 2005/12/01 or later. { \bool_not_p:n \l_@@_block_auto_columns_width_bool } { \skip_gset_eq:NN \g_tmpa_skip \g_@@_max_cell_width_dim } { \skip_gset_eq:NN \g_tmpa_skip \l_@@_columns_width_dim } - \skip_gadd:Nn \g_tmpa_skip { 2 \arraycolsep } + \skip_gadd:Nn \g_tmpa_skip { 2 \col@sep } } \skip_horizontal:N \g_tmpa_skip \hbox { + \bool_if:NT \l_@@_code_before_bool + { + \hbox + { + \skip_horizontal:N -0.5\arrayrulewidth + \pgfsys@markposition { \@@_env: - col - 2 } + \skip_horizontal:N 0.5\arrayrulewidth + } + } \pgfpicture \pgfrememberpicturepositiononpagetrue - \pgfcoordinate { \@@_env: - col - 2 } \pgfpointorigin + \pgfcoordinate { \@@_env: - col - 2 } + { \pgfpoint { - 0.5 \arrayrulewidth } \c_zero_dim } \str_if_empty:NF \l_@@_name_str - { \pgfnodealias { \@@_env: - col - 2 } { \l_@@_name_str - col - 2 } } + { \pgfnodealias { \l_@@_name_str - col - 2 } { \@@_env: - col - 2 } } \endpgfpicture } % \end{macrocode} @@ -5486,32 +6035,45 @@ version 2005/12/01 or later. { \prg_replicate:nn { \g_@@_col_total_int - 2 } } { \prg_replicate:nn { \g_@@_col_total_int - 1 } } { - & - \omit + & + \omit % \end{macrocode} % The incrementation of the counter |\g_tmpa_int| must be done after the |\omit| % of the cell. % \begin{macrocode} - \int_gincr:N \g_tmpa_int - \skip_horizontal:N \g_tmpa_skip + \int_gincr:N \g_tmpa_int + \skip_horizontal:N \g_tmpa_skip + \bool_if:NT \l_@@_code_before_bool + { + \hbox + { + \skip_horizontal:N -0.5\arrayrulewidth + \pgfsys@markposition { \@@_env: - col - \@@_succ:n \g_tmpa_int } + \skip_horizontal:N 0.5\arrayrulewidth + } + } % \end{macrocode} -% We create the ``|col|'' node on the right of the current column. +% We create the |col| node on the right of the current column. % \begin{macrocode} - \pgfpicture - \pgfrememberpicturepositiononpagetrue - \pgfcoordinate { \@@_env: - col - \@@_succ:n \g_tmpa_int } - \pgfpointorigin - \str_if_empty:NF \l_@@_name_str - { - \pgfnodealias - { \@@_env: - col - \@@_succ:n \g_tmpa_int } - { \l_@@_name_str - col - \@@_succ:n \g_tmpa_int } - } - \endpgfpicture + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgfcoordinate { \@@_env: - col - \@@_succ:n \g_tmpa_int } + { \pgfpoint { - 0.5 \arrayrulewidth } \c_zero_dim } + \str_if_empty:NF \l_@@_name_str + { + \pgfnodealias + { \l_@@_name_str - col - \@@_succ:n \g_tmpa_int } + { \@@_env: - col - \@@_succ:n \g_tmpa_int } + } + \endpgfpicture } \bool_if:NT \g_@@_last_col_found_bool { - \skip_horizontal:N 2\arraycolsep + \bool_if:NT \l_@@_code_before_bool + { + \pgfsys@markposition { \@@_env: - col - \@@_succ:n \g_@@_col_total_int } + } + \skip_horizontal:N 2\col@sep \pgfpicture \pgfrememberpicturepositiononpagetrue \pgfcoordinate { \@@_env: - col - \@@_succ:n \g_@@_col_total_int } @@ -5519,11 +6081,11 @@ version 2005/12/01 or later. \str_if_empty:NF \l_@@_name_str { \pgfnodealias - { \@@_env: - col - \@@_succ:n \g_@@_col_total_int } { \l_@@_name_str - col - \@@_succ:n \g_@@_col_total_int } + { \@@_env: - col - \@@_succ:n \g_@@_col_total_int } } \endpgfpicture - \skip_horizontal:N -2\arraycolsep + \skip_horizontal:N -2\col@sep } \cr } @@ -5544,7 +6106,7 @@ version 2005/12/01 or later. % have to compute some dimensions of this box. % \begin{macrocode} \hbox_set:Nw \l_@@_cell_box - \c_math_toggle_token + \bool_if:NF \l_@@_NiceTabular_bool \c_math_toggle_token \bool_if:NT \l_@@_small_bool \scriptstyle % \end{macrocode} % We insert |\l_@@_code_for_first_col_tl|... but we don't insert it in the @@ -5569,7 +6131,7 @@ version 2005/12/01 or later. l < { - \c_math_toggle_token + \bool_if:NF \l_@@_NiceTabular_bool \c_math_toggle_token \hbox_set_end: \@@_update_for_first_and_last_row: % \end{macrocode} @@ -5591,7 +6153,7 @@ version 2005/12/01 or later. \skip_horizontal:N \l_@@_left_margin_dim \skip_horizontal:N \l_@@_extra_left_margin_dim } - \skip_horizontal:N -2\arraycolsep + \skip_horizontal:N -2\col@sep } } % \end{macrocode} @@ -5616,7 +6178,7 @@ version 2005/12/01 or later. % have to compute some dimensions of this box. % \begin{macrocode} \hbox_set:Nw \l_@@_cell_box - \c_math_toggle_token + \bool_if:NF \l_@@_NiceTabular_bool \c_math_toggle_token \bool_if:NT \l_@@_small_bool \scriptstyle % \end{macrocode} % We insert |\l_@@_code_for_last_col_tl|... but we don't insert it in the @@ -5636,7 +6198,7 @@ version 2005/12/01 or later. l < { - \c_math_toggle_token + \bool_if:NF \l_@@_NiceTabular_bool \c_math_toggle_token \hbox_set_end: \@@_update_for_first_and_last_row: % \end{macrocode} @@ -5645,7 +6207,7 @@ version 2005/12/01 or later. % \begin{macrocode} \dim_gset:Nn \g_@@_width_last_col_dim { \dim_max:nn \g_@@_width_last_col_dim { \box_wd:N \l_@@_cell_box } } - \skip_horizontal:N -2\arraycolsep + \skip_horizontal:N -2\col@sep % \end{macrocode} % The content of the cell is inserted in an overlapping position. % \label{overlap-right} @@ -5758,14 +6320,14 @@ version 2005/12/01 or later. \keys_set:nn { NiceMatrix / NiceMatrix } { ##1 } \exp_args:Nnx \@@_begin_of_NiceMatrix:nn { #1 } \l_@@_type_of_col_tl } - { \end { #1 NiceArray } } + { \use:c { end #1 NiceArray } } } % \end{macrocode} % % \begin{macrocode} \cs_new_protected:Npn \@@_begin_of_NiceMatrix:nn #1 #2 { - \begin { #1 NiceArray } + \use:c { #1 NiceArray } { * { @@ -5787,8 +6349,18 @@ version 2005/12/01 or later. \@@_define_env:n V % \end{macrocode} % +% \bigskip +% \subsection*{The environment \{NiceTabular\}} +% \begin{macrocode} +\NewDocumentEnvironment { NiceTabular } { O { } m ! O { } } + { + \keys_set:nn { NiceMatrix / NiceTabular } { #1 , #3 } + \bool_set_true:N \l_@@_NiceTabular_bool + \NiceArray { #2 } + } + { \endNiceArray } +% \end{macrocode} % -% % % \bigskip % \subsection*{After the construction of the array} @@ -5873,7 +6445,38 @@ version 2005/12/01 or later. } % \end{macrocode} % -% +% If the key |code-before| is used, we have to write on the |aux| file the actual +% size of the array. +% \begin{macrocode} + \bool_if:NT \l_@@_code_before_bool + { + \iow_now:Nn \@mainaux \ExplSyntaxOn + \iow_now:Nx \@mainaux + { \seq_clear_new:c { @@_size _ \int_use:N \g_@@_env_int _ seq } } + \iow_now:Nx \@mainaux + { + \seq_gset_from_clist:cn { @@_size _ \int_use:N \g_@@_env_int _ seq } + { + \int_use:N \l_@@_first_row_int , + \int_use:N \g_@@_row_total_int , + \int_use:N \l_@@_first_col_int , +% \end{macrocode} +% If the user has used a key |last-row| in an environment with preamble (like +% |{pNiceArray}|) and that that last row has not been found, we have to +% increment the value because it will be decreased when used in the |code-before|. +% \begin{macrocode} + \bool_lazy_and:nnTF + { \int_compare_p:nNn \l_@@_last_col_int > { -2 } } + { \bool_not_p:n \g_@@_last_col_found_bool } + \@@_succ:n + \int_use:N + \g_@@_col_total_int + } + } + \iow_now:Nn \@mainaux \ExplSyntaxOff + } +% \end{macrocode} +% % By default, the diagonal lines will be parallelized\footnote{It's possible to % use the option |parallelize-diags| to disable this parallelization.}. There % are two types of diagonals lines: the $|\Ddots|$ diagonals and the |\Iddots| @@ -5936,7 +6539,7 @@ version 2005/12/01 or later. % % % \bigskip -% Now, we really draw the lines. +% Now, we really draw the dotted lines. % \begin{macrocode} \@@_draw_dotted_lines: % \end{macrocode} @@ -5950,7 +6553,7 @@ version 2005/12/01 or later. \tl_gclear:N \g_@@_internal_code_after_tl \bool_if:NT \c_@@_tikz_loaded_bool { - \tikzset + \tikzset { every~picture / .style = { @@ -5961,6 +6564,16 @@ version 2005/12/01 or later. } } \cs_set_eq:NN \line \@@_line +% \end{macrocode} +% When |light-syntax| is used, we insert systematically a |\CodeAfter| in the +% flow. Thus, it's possible to have two instructions |\CodeAfter| and the second +% one is eventually present in |\g_@@_code_after_tl|. That's why we set +% |\Code-after| to be \textsl{no-op} now. +% \begin{macrocode} + \cs_set_eq:NN \CodeAfter \prg_do_nothing: +% \end{macrocode} +% And here's the |code-after|: +% \begin{macrocode} \g_@@_code_after_tl \tl_gclear:N \g_@@_code_after_tl \group_end: @@ -5994,7 +6607,7 @@ version 2005/12/01 or later. { \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse - \g_@@_Hdotsfor_lines_tl + \g_@@_HVdotsfor_lines_tl \g_@@_Vdots_lines_tl \g_@@_Ddots_lines_tl \g_@@_Iddots_lines_tl @@ -6007,8 +6620,8 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Npn \@@_restore_iRow_jCol: { - \cs_if_exist:NT \theiRow { \int_gset_eq:NN \c@iRow \l_@@_save_iRow_int } - \cs_if_exist:NT \thejCol { \int_gset_eq:NN \c@jCol \l_@@_save_jCol_int } + \cs_if_exist:NT \theiRow { \int_gset_eq:NN \c@iRow \l_@@_old_iRow_int } + \cs_if_exist:NT \thejCol { \int_gset_eq:NN \c@jCol \l_@@_old_jCol_int } } % \end{macrocode} % @@ -6239,10 +6852,6 @@ version 2005/12/01 or later. % % \medskip % \begin{macrocode} -\cs_new:Nn \@@_initial_cell: - { \@@_env: - \int_use:N \l_@@_initial_i_int - \int_use:N \l_@@_initial_j_int } -\cs_new:Nn \@@_final_cell: - { \@@_env: - \int_use:N \l_@@_final_i_int - \int_use:N \l_@@_final_j_int } \cs_new_protected:Npn \@@_set_initial_coords: { \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x @@ -6255,12 +6864,24 @@ version 2005/12/01 or later. } \cs_new_protected:Npn \@@_set_initial_coords_from_anchor:n #1 { - \pgfpointanchor \@@_initial_cell: { #1 } + \pgfpointanchor + { + \@@_env: + - \int_use:N \l_@@_initial_i_int + - \int_use:N \l_@@_initial_j_int + } + { #1 } \@@_set_initial_coords: } \cs_new_protected:Npn \@@_set_final_coords_from_anchor:n #1 { - \pgfpointanchor \@@_final_cell: { #1 } + \pgfpointanchor + { + \@@_env: + - \int_use:N \l_@@_final_i_int + - \int_use:N \l_@@_final_j_int + } + { #1 } \@@_set_final_coords: } % \end{macrocode} @@ -6317,25 +6938,28 @@ version 2005/12/01 or later. { \bool_if:NTF \l_@@_initial_open_bool { - \@@_qpoint: { col - \int_use:N \l_@@_initial_j_int } + \@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int } \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x - \dim_add:Nn \l_@@_x_initial_dim \arraycolsep - \@@_qpoint: { row - \int_use:N \l_@@_initial_i_int - base } + \dim_add:Nn \l_@@_x_initial_dim + { \bool_if:NTF \l_@@_NiceTabular_bool \tabcolsep \arraycolsep } + \@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int - base } \dim_set_eq:NN \l_@@_y_initial_dim \pgf@y } { \@@_set_initial_coords_from_anchor:n { base~east } } \bool_if:NTF \l_@@_final_open_bool { - \@@_qpoint: { col - \@@_succ:n \l_@@_final_j_int } + \@@_qpoint:n { col - \@@_succ:n \l_@@_final_j_int } \dim_set_eq:NN \l_@@_x_final_dim \pgf@x - \dim_sub:Nn \l_@@_x_final_dim \arraycolsep - \@@_qpoint: { row - \int_use:N \l_@@_final_i_int - base } + \dim_sub:Nn \l_@@_x_final_dim + { \bool_if:NTF \l_@@_NiceTabular_bool \tabcolsep \arraycolsep } + \@@_qpoint:n { row - \int_use:N \l_@@_final_i_int - base } \dim_set_eq:NN \l_@@_y_final_dim \pgf@y } { \@@_set_final_coords_from_anchor:n { base~west } } % \end{macrocode} % We raise the line of a quantity equal to the radius of the dots because we -% want the dots really ``on'' the line of texte. +% want the dots really ``on'' the line of texte. Of course, maybe we should not +% do that when the option |line-style| is used (?). % \begin{macrocode} \dim_add:Nn \l_@@_y_initial_dim \l_@@_radius_dim \dim_add:Nn \l_@@_y_final_dim \l_@@_radius_dim @@ -6393,25 +7017,27 @@ version 2005/12/01 or later. { \bool_if:NTF \l_@@_initial_open_bool { - \@@_qpoint: { col - \int_use:N \l_@@_initial_j_int } + \@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int } \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x - \dim_add:Nn \l_@@_x_initial_dim \arraycolsep + \dim_add:Nn \l_@@_x_initial_dim + { \bool_if:NTF \l_@@_NiceTabular_bool \tabcolsep \arraycolsep } } { \@@_set_initial_coords_from_anchor:n { mid~east } } \bool_if:NTF \l_@@_final_open_bool { - \@@_qpoint: { col - \@@_succ:n \l_@@_final_j_int } + \@@_qpoint:n { col - \@@_succ:n \l_@@_final_j_int } \dim_set_eq:NN \l_@@_x_final_dim \pgf@x - \dim_sub:Nn \l_@@_x_final_dim \arraycolsep + \dim_sub:Nn \l_@@_x_final_dim + { \bool_if:NTF \l_@@_NiceTabular_bool \tabcolsep \arraycolsep } } { \@@_set_final_coords_from_anchor:n { mid~west } } \bool_lazy_and:nnTF \l_@@_initial_open_bool \l_@@_final_open_bool { - \@@_qpoint: { row - \int_use:N \l_@@_initial_i_int } + \@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int } \dim_set_eq:NN \l_tmpa_dim \pgf@y - \@@_qpoint: { row - \@@_succ:n \l_@@_initial_i_int } + \@@_qpoint:n { row - \@@_succ:n \l_@@_initial_i_int } \dim_set:Nn \l_@@_y_initial_dim { ( \l_tmpa_dim + \pgf@y ) / 2 } \dim_set_eq:NN \l_@@_y_final_dim \l_@@_y_initial_dim } @@ -6464,6 +7090,8 @@ version 2005/12/01 or later. % \item |\l_@@_final_j_int| % \item |\l_@@_final_open_bool|. % \end{itemize} +% +% The following function is also used by |\Vdotsfor|. % \begin{macrocode} \cs_new_protected:Npn \@@_actually_draw_Vdots: { @@ -6485,13 +7113,13 @@ version 2005/12/01 or later. % \begin{macrocode} \bool_if:NTF \l_@@_initial_open_bool { - \@@_qpoint: { row - 1 } + \@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int } \dim_set_eq:NN \l_@@_y_initial_dim \pgf@y } { \@@_set_initial_coords_from_anchor:n { south } } \bool_if:NTF \l_@@_final_open_bool { - \@@_qpoint: { row - \@@_succ:n \c@iRow } + \@@_qpoint:n { row - \@@_succ:n \l_@@_final_i_int } \dim_set_eq:NN \l_@@_y_final_dim \pgf@y } { \@@_set_final_coords_from_anchor:n { north } } @@ -6499,11 +7127,27 @@ version 2005/12/01 or later. { \bool_if:NTF \l_@@_final_open_bool { - \@@_qpoint: { col - \int_use:N \l_@@_initial_j_int } + \@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int } \dim_set_eq:NN \l_tmpa_dim \pgf@x - \@@_qpoint: { col - \@@_succ:n \l_@@_initial_j_int } + \@@_qpoint:n { col - \@@_succ:n \l_@@_initial_j_int } \dim_set:Nn \l_@@_x_initial_dim { ( \pgf@x + \l_tmpa_dim ) / 2 } \dim_set_eq:NN \l_@@_x_final_dim \l_@@_x_initial_dim +% \end{macrocode} +% We may think that the final user won't use a ``last column'' which contains +% only a command |\Vdots|. However, if the |\Vdots| is in fact used to draw, not +% a dotted line, but an arrow (to indicate the number of rows of the matrix), it +% may be really encountered. +% \begin{macrocode} + \int_compare:nNnT \l_@@_last_col_int > { -2 } + { + \int_compare:nNnT \l_@@_initial_j_int = \g_@@_col_total_int + { + \dim_set_eq:NN \l_tmpa_dim \l_@@_right_margin_dim + \dim_add:Nn \l_tmpa_dim \l_@@_extra_right_margin_dim + \dim_add:Nn \l_@@_x_initial_dim \l_tmpa_dim + \dim_add:Nn \l_@@_x_final_dim \l_tmpa_dim + } + } } { \dim_set_eq:NN \l_@@_x_initial_dim \l_@@_x_final_dim } } @@ -6574,17 +7218,17 @@ version 2005/12/01 or later. { \bool_if:NTF \l_@@_initial_open_bool { - \@@_qpoint: { row - \int_use:N \l_@@_initial_i_int } + \@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int } \dim_set_eq:NN \l_@@_y_initial_dim \pgf@y - \@@_qpoint: { col - \int_use:N \l_@@_initial_j_int } + \@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int } \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x } { \@@_set_initial_coords_from_anchor:n { south~east } } \bool_if:NTF \l_@@_final_open_bool { - \@@_qpoint: { row - \@@_succ:n \l_@@_final_i_int } + \@@_qpoint:n { row - \@@_succ:n \l_@@_final_i_int } \dim_set_eq:NN \l_@@_y_final_dim \pgf@y - \@@_qpoint: { col - \@@_succ:n \l_@@_final_j_int } + \@@_qpoint:n { col - \@@_succ:n \l_@@_final_j_int } \dim_set_eq:NN \l_@@_x_final_dim \pgf@x } { \@@_set_final_coords_from_anchor:n { north~west } } @@ -6671,17 +7315,17 @@ version 2005/12/01 or later. { \bool_if:NTF \l_@@_initial_open_bool { - \@@_qpoint: { row - \int_use:N \l_@@_initial_i_int } + \@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int } \dim_set_eq:NN \l_@@_y_initial_dim \pgf@y - \@@_qpoint: { col - \@@_succ:n \l_@@_initial_j_int } + \@@_qpoint:n { col - \@@_succ:n \l_@@_initial_j_int } \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x } { \@@_set_initial_coords_from_anchor:n { south~west } } \bool_if:NTF \l_@@_final_open_bool { - \@@_qpoint: { row - \@@_succ:n \l_@@_final_i_int } + \@@_qpoint:n { row - \@@_succ:n \l_@@_final_i_int } \dim_set_eq:NN \l_@@_y_final_dim \pgf@y - \@@_qpoint: { col - \int_use:N \l_@@_final_j_int } + \@@_qpoint:n { col - \int_use:N \l_@@_final_j_int } \dim_set_eq:NN \l_@@_x_final_dim \pgf@x } { \@@_set_final_coords_from_anchor:n { north~east } } @@ -7015,8 +7659,19 @@ version 2005/12/01 or later. { \bool_if:nTF { #1 } { \@@_error:n { starred~commands } } - { \@@_instruction_of_type:nn { Ldots } { #2 , down = #3 , up = #4 } } - \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_ldots } + { + \int_compare:nNnTF \c@jCol = 0 + { \@@_error:nn { in~first~col } \Ldots } + { + \int_compare:nNnTF \c@jCol = \l_@@_last_col_int + { \@@_error:nn { in~last~col } \Ldots } + { + \@@_instruction_of_type:nn { Ldots } + { #2 , down = #3 , up = #4 } + } + } + } + \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_ldots } \bool_gset_true:N \g_@@_empty_cell_bool } % \end{macrocode} @@ -7027,8 +7682,19 @@ version 2005/12/01 or later. { \bool_if:nTF { #1 } { \@@_error:n { starred~commands } } - { \@@_instruction_of_type:nn { Cdots } { #2 , down = #3 , up = #4 } } - \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_cdots } + { + \int_compare:nNnTF \c@jCol = 0 + { \@@_error:nn { in~first~col } \Cdots } + { + \int_compare:nNnTF \c@jCol = \l_@@_last_col_int + { \@@_error:nn { in~last~col } \Cdots } + { + \@@_instruction_of_type:nn { Cdots } + { #2 , down = #3 , up = #4 } + } + } + } + \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_cdots } \bool_gset_true:N \g_@@_empty_cell_bool } % \end{macrocode} @@ -7039,8 +7705,17 @@ version 2005/12/01 or later. { \bool_if:nTF { #1 } { \@@_error:n { starred~commands } } - { \@@_instruction_of_type:nn { Vdots } { #2 , down = #3 , up = #4 } } - \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_vdots } + \int_compare:nNnTF \c@iRow = 0 + { \@@_error:nn { in~first~row } \Vdots } + { + \int_compare:nNnTF \c@iRow = \l_@@_last_row_int + { \@@_error:nn { in~last~row } \Vdots } + { + \@@_instruction_of_type:nn { Vdots } + { #2 , down = #3 , up = #4 } + } + } + \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_vdots } \bool_gset_true:N \g_@@_empty_cell_bool } % \end{macrocode} @@ -7051,8 +7726,26 @@ version 2005/12/01 or later. { \bool_if:nTF { #1 } { \@@_error:n { starred~commands } } - { \@@_instruction_of_type:nn { Ddots } { #2 , down = #3 , up = #4 } } - \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_ddots } + { + \int_case:nnF \c@iRow + { + 0 { \@@_error:nn { in~first~row } \Ddots } + \l_@@_last_row_int { \@@_error:nn { in~last~row } \Ddots } + } + { + \int_case:nnF \c@jCol + { + 0 { \@@_error:nn { in~first~col } \Ddots } + \l_@@_last_col_int { \@@_error:nn { in~last~col } \Ddots } + } + { + \@@_instruction_of_type:nn { Ddots } + { #2 , down = #3 , up = #4 } + } + + } + } + \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_ddots } \bool_gset_true:N \g_@@_empty_cell_bool } % \end{macrocode} @@ -7063,8 +7756,26 @@ version 2005/12/01 or later. { \bool_if:nTF { #1 } { \@@_error:n { starred~commands } } - { \@@_instruction_of_type:nn { Iddots } { #2 , down = #3 , up = #4 } } - \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_iddots } + { + \int_case:nnF \c@iRow + { + 0 { \@@_error:nn { in~first~row } \Iddots } + \l_@@_last_row_int { \@@_error:nn { in~last~row } \Iddots } + } + { + \int_case:nnF \c@jCol + { + 0 { \@@_error:nn { in~first~col } \Iddots } + \l_@@_last_col_int { \@@_error:nn { in~last~col } \Iddots } + } + { + \@@_instruction_of_type:nn { Iddots } + { #2 , down = #3 , up = #4 } + } + + } + } + \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_iddots } \bool_gset_true:N \g_@@_empty_cell_bool } } @@ -7095,7 +7806,7 @@ version 2005/12/01 or later. \int_compare:nNnT #1 > 1 { \seq_gput_left:Nx \g_@@_multicolumn_cells_seq - { \int_eval:n \c@iRow - \int_use:N \c@jCol } + { \int_use:N \c@iRow - \int_use:N \c@jCol } \seq_gput_left:Nn \g_@@_multicolumn_sizes_seq { #1 } } \int_gadd:Nn \c@jCol { #1 - 1 } @@ -7105,11 +7816,8 @@ version 2005/12/01 or later. % % \bigskip % The command |\@@_Hdotsfor| will be linked to |\Hdotsfor| in -% |{NiceArrayWithDelims}|. This command uses an optional argument (as does -% |\hdotsfor|) but this argument is discarded (in |\hdotsfor|, this argument is -% used for fine tuning of the space between two consecutive dots). Tikz nodes -% are created also the implicit cells of the |\Hdotsfor| (maybe we should modify -% that point). +% |{NiceArrayWithDelims}|. Tikz nodes are created also in the implicit cells of +% the |\Hdotsfor| (maybe we should modify that point). % % \medskip % This command must \emph{not} be protected since it begins with |\multicolumn|. @@ -7121,12 +7829,6 @@ version 2005/12/01 or later. } % \end{macrocode} % -% \begin{macrocode} -\ExplSyntaxOff -\def \@tempa { O { } m O { } E { _ ^ } { { } { } } } -\ExplSyntaxOn -\tl_set_eq:NN \l_@@_a_signature_tl \@tempa -% \end{macrocode} % % The command |\@@_Hdotsfor_i| is defined with the tools of \pkg{xparse} because % it has an optional argument. Note that such a command defined by @@ -7137,28 +7839,24 @@ version 2005/12/01 or later. { \tl_set:Nn \l_@@_argspec_tl { O { } m O { } E { _ ^ } { { } { } } } \tl_set_rescan:Nno \l_@@_argspec_tl { } \l_@@_argspec_tl - \bool_if:NTF \c_@@_draft_bool - { % \end{macrocode} % We don't put |!| before the last optionnal argument for homogeneity with % |\Cdots|, etc. which have only one optional argument. % \begin{macrocode} - \exp_args:NNV \NewDocumentCommand \@@_Hdotsfor_i \l_@@_argspec_tl - { \prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { C } { } } } - } + \exp_args:NNV \NewDocumentCommand \@@_Hdotsfor_i \l_@@_argspec_tl { - \exp_args:NNV \NewDocumentCommand \@@_Hdotsfor_i \l_@@_argspec_tl + \tl_gput_right:Nx \g_@@_HVdotsfor_lines_tl { - \tl_gput_right:Nx \g_@@_Hdotsfor_lines_tl - { - \@@_Hdotsfor:nnnn - { \int_use:N \c@iRow } - { \int_use:N \c@jCol } - { #2 } - { #1 , #3 , down = #4 , up = #5 } - } - \prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { C } { } } - } + \@@_Hdotsfor:nnnn + { \int_use:N \c@iRow } + { \int_use:N \c@jCol } + { #2 } + { + #1 , #3 , + down = \exp_not:n { #4 } , up = \exp_not:n { #5 } + } + } + \prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { C } { } } } } % \end{macrocode} @@ -7240,11 +7938,111 @@ version 2005/12/01 or later. { \cs_set:cpn { @@ _ dotted _ #1 - ##1 } { } } } % \end{macrocode} -% % -% \bigskip -% The control sequence |\@@_rotate:| will be linked to |\rotate| in -% |{NiceArrayWithDelims}|. +% \bigskip +% \begin{macrocode} +\AtBeginDocument + { + \tl_set:Nn \l_@@_argspec_tl { O { } m O { } E { _ ^ } { { } { } } } + \tl_set_rescan:Nno \l_@@_argspec_tl { } \l_@@_argspec_tl + \exp_args:NNV \NewDocumentCommand \@@_Vdotsfor: \l_@@_argspec_tl + { + \tl_gput_right:Nx \g_@@_HVdotsfor_lines_tl + { + \@@_Vdotsfor:nnnn + { \int_use:N \c@iRow } + { \int_use:N \c@jCol } + { #2 } + { + #1 , #3 , + down = \exp_not:n { #4 } , up = \exp_not:n { #5 } + } + } + } + } +% \end{macrocode} +% Enf of |\AtBeginDocument|. +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_Vdotsfor:nnnn #1 #2 #3 #4 + { + \bool_set_false:N \l_@@_initial_open_bool + \bool_set_false:N \l_@@_final_open_bool +% \end{macrocode} +% For the column, it's easy. +% \begin{macrocode} + \int_set:Nn \l_@@_initial_j_int { #2 } + \int_set_eq:NN \l_@@_final_j_int \l_@@_initial_j_int +% \end{macrocode} +% For the row, it's a bit more complicated. +% \begin{macrocode} + \int_compare:nNnTF #1 = 1 + { + \int_set:Nn \l_@@_initial_i_int 1 + \bool_set_true:N \l_@@_initial_open_bool + } + { + \cs_if_exist:cTF + { + pgf @ sh @ ns @ \@@_env: + - \int_eval:n { #1 - 1 } + - \int_use:N \l_@@_initial_j_int + } + { \int_set:Nn \l_@@_initial_i_int { #1 - 1 } } + { + \int_set:Nn \l_@@_initial_i_int { #1 } + \bool_set_true:N \l_@@_initial_open_bool + } + } + \int_compare:nNnTF { #1 + #3 -1 } = \c@iRow + { + \int_set:Nn \l_@@_final_i_int { #1 + #3 - 1 } + \bool_set_true:N \l_@@_final_open_bool + } + { + \cs_if_exist:cTF + { + pgf @ sh @ ns @ \@@_env: + - \int_eval:n { #1 + #3 } + - \int_use:N \l_@@_final_j_int + } + { \int_set:Nn \l_@@_final_i_int { #1 + #3 } } + { + \int_set:Nn \l_@@_final_i_int { #1 + #3 - 1 } + \bool_set_true:N \l_@@_final_open_bool + } + } +% \end{macrocode} +% +% \begin{macrocode} + \group_begin: + \int_compare:nNnTF { #2 } = 0 + { \color { nicematrix-first-col } } + { + \int_compare:nNnT { #2 } = \g_@@_col_total_int + { \color { nicematrix-last-col } } + } + \keys_set:nn { NiceMatrix / xdots } { #4 } + \tl_if_empty:VF \l_@@_xdots_color_tl { \color { \l_@@_xdots_color_tl } } + \@@_actually_draw_Vdots: + \group_end: +% \end{macrocode} +% +% \medskip +% We declare all the cells concerned by the |\Vdotsfor| as ``dotted'' (for the +% dotted lines created by |\Cdots|, |\Ldots|, etc., this job is done by +% |\@@_find_extremities_of_line:nnnn|). This declaration is done by defining a +% special control sequence (to nil). +% \begin{macrocode} + \int_step_inline:nnn { #1 } { #1 + #3 - 1 } + { \cs_set:cpn { @@ _ dotted _ ##1 - #2 } { } } + } +% \end{macrocode} +% +% +% \vspace{1cm} +% The command |\@@_rotate:| will be linked to |\rotate| in +% |{NiceArrayWithDelims}|. % % The command will exit three levels of groups in order % to execute the command @@ -7297,12 +8095,6 @@ version 2005/12/01 or later. { \int_eval:n { #1 } - \int_eval:n { #2 } } % \end{macrocode} % -% \begin{macrocode} -\ExplSyntaxOff -\def \@tempa { O { } m m ! O { } E { _ ^ } { { } { } } } -\ExplSyntaxOn -\tl_set_eq:NN \l_@@_a_signature_tl \@tempa -% \end{macrocode} % % \medskip % With the following construction, the command |\@@_double_int_eval:n| is @@ -7331,24 +8123,20 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} -\bool_if:NTF \c_@@_draft_bool - { \cs_new_protected:Npn \@@_line_i:nn #1 #2 { } } +\cs_new_protected:Npn \@@_line_i:nn #1 #2 { - \cs_new_protected:Npn \@@_line_i:nn #1 #2 + \bool_set_false:N \l_@@_initial_open_bool + \bool_set_false:N \l_@@_final_open_bool + \bool_if:nTF { - \bool_set_false:N \l_@@_initial_open_bool - \bool_set_false:N \l_@@_final_open_bool - \bool_if:nTF - { - \cs_if_free_p:c { pgf @ sh @ ns @ \@@_env: - #1 } - || - \cs_if_free_p:c { pgf @ sh @ ns @ \@@_env: - #2 } - } - { - \@@_error:nnn { unknown~cell~for~line~in~code-after } { #1 } { #2 } - } - { \@@_draw_line_ii:nn { #1 } { #2 } } + \cs_if_free_p:c { pgf @ sh @ ns @ \@@_env: - #1 } + || + \cs_if_free_p:c { pgf @ sh @ ns @ \@@_env: - #2 } } + { + \@@_error:nnn { unknown~cell~for~line~in~code-after } { #1 } { #2 } + } + { \@@_draw_line_ii:nn { #1 } { #2 } } } % \end{macrocode} % @@ -7377,10 +8165,10 @@ version 2005/12/01 or later. \cs_new_protected:Npn \@@_draw_line_iii:nn #1 #2 { \pgfrememberpicturepositiononpagetrue - \pgfpointshapeborder { \@@_env: - #1 } { \@@_qpoint: { #2 } } + \pgfpointshapeborder { \@@_env: - #1 } { \@@_qpoint:n { #2 } } \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x \dim_set_eq:NN \l_@@_y_initial_dim \pgf@y - \pgfpointshapeborder { \@@_env: - #2 } { \@@_qpoint: { #1 } } + \pgfpointshapeborder { \@@_env: - #2 } { \@@_qpoint:n { #1 } } \dim_set_eq:NN \l_@@_x_final_dim \pgf@x \dim_set_eq:NN \l_@@_y_final_dim \pgf@y \@@_draw_line: @@ -7393,6 +8181,214 @@ version 2005/12/01 or later. % lines must be parallelized). % % \bigskip +% \subsection*{Commands available in the code-before} +% +% In the beginning of the |code-before|, the command |\@@_rowcolor:nn| will be +% linked to |\rowcolor| and the command |\@@_columncolor:nn| to |\columncolor|. +% +% \begin{macrocode} +\cs_set_protected:Npn \@@_cut_on_hyphen:w #1-#2\q_stop + { + \tl_set:Nn \l_tmpa_tl { #1 } + \tl_set:Nn \l_tmpb_tl { #2 } + } +% \end{macrocode} +% +% +% \bigskip +% Here an example : |\@@_rowcolor:nn {red!15} {1,3,5-7,10-}| +% \begin{macrocode} +\cs_new_protected:Npn \@@_rowcolor:nn #1 #2 + { + \tl_if_blank:nF { #1 } + { + \pgfpicture + \pgf@relevantforpicturesizefalse + \pgfsetfillcolor { #1 } +% \end{macrocode} +% |\l_tmpa_dim| is the $x$-value of the left side of the rows. +% \begin{macrocode} + \@@_qpoint:n { col - \@@_succ:n \c@jCol } + \dim_set_eq:NN \l_tmpa_dim \pgf@x + \clist_map_inline:nn { #2 } + { + \tl_set:Nn \l_tmpa_tl { ##1 } + \tl_if_in:NnTF \l_tmpa_tl { - } + { \@@_cut_on_hyphen:w ##1 \q_stop } + { \@@_cut_on_hyphen:w ##1 - ##1 \q_stop } + \tl_if_empty:NT \l_tmpa_tl { \tl_set:Nn \l_tmpa_tl { 1 } } + \tl_if_empty:NT \l_tmpb_tl + { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } } + \int_compare:nNnT \l_tmpb_tl > \c@iRow + { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } } +% \end{macrocode} +% Now, the numbers of both rows are in |\l_tmpa_tl| and |\l_tmpb_tl|. +% \begin{macrocode} + \@@_qpoint:n { row - \@@_succ:n \l_tmpb_tl } + \pgfpathrectanglecorners + { \@@_qpoint:n { row - \l_tmpa_tl } } + { \pgfpoint \l_tmpa_dim \pgf@y } + } + \pgfusepathqfill + \endpgfpicture + } + } +% \end{macrocode} +% +% \bigskip +% Here an example : |\@@_columncolor:nn {red!15} {1,3,5-7,10-}| +% \begin{macrocode} +\cs_new_protected:Npn \@@_columncolor:nn #1 #2 + { + \tl_if_blank:nF { #1 } + { + \pgfpicture + \pgf@relevantforpicturesizefalse + \pgfsetfillcolor { #1 } + \@@_qpoint:n { row - 1 } +% \end{macrocode} +% |\l_tmpa_dim| is the $y$-value of the top of the columns et |\l_tmpb_dim| is +% the $y$-value of the bottom. +% \begin{macrocode} + \dim_set_eq:NN \l_tmpa_dim \pgf@y + \@@_qpoint:n { row - \@@_succ:n \c@iRow } + \dim_set_eq:NN \l_tmpb_dim \pgf@y + \clist_map_inline:nn { #2 } + { + \tl_set:Nn \l_tmpa_tl { ##1 } + \tl_if_in:NnTF \l_tmpa_tl { - } + { \@@_cut_on_hyphen:w ##1 \q_stop } + { \@@_cut_on_hyphen:w ##1 - ##1 \q_stop } + \tl_if_empty:NT \l_tmpa_tl { \tl_set:Nn \l_tmpa_tl { 1 } } + \tl_if_empty:NT \l_tmpb_tl + { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } } + \int_compare:nNnT \l_tmpb_tl > \c@jCol + { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } } +% \end{macrocode} +% Now, the numbers of both columns are in |\l_tmpa_tl| and |\l_tmpb_tl|. +% \begin{macrocode} + \@@_qpoint:n { col - \l_tmpa_tl } + \dim_set_eq:NN \l_tmpc_dim \pgf@x + \@@_qpoint:n { col - \@@_succ:n \l_tmpb_tl } + \pgfpathrectanglecorners + { \pgfpoint \l_tmpc_dim \l_tmpa_dim } + { \pgfpoint \pgf@x \l_tmpb_dim } + } + \pgfusepathqfill + \endpgfpicture + } + } +% \end{macrocode} +% +% \bigskip +% Here an example : |\@@_cellcolor:nn {red!15}{2-3,3-4,4-5,5-6}| +% \begin{macrocode} +\cs_new_protected:Npn \@@_cellcolor:nn #1 #2 + { + \tl_if_blank:nF { #1 } + { + \pgfpicture + \pgf@relevantforpicturesizefalse + \pgfsetfillcolor { #1 } + \clist_map_inline:nn { #2 } + { + \@@_cut_on_hyphen:w ##1 \q_stop + \@@_qpoint:n { row - \l_tmpa_tl } + \bool_lazy_and:nnT + { \int_compare_p:n { \l_tmpa_tl <= \c@iRow } } + { \int_compare_p:n { \l_tmpb_tl <= \c@jCol } } + { + \dim_set_eq:NN \l_tmpb_dim \pgf@y + \@@_qpoint:n { row - \@@_succ:n \l_tmpa_tl } + \dim_set_eq:NN \l_tmpa_dim \pgf@y + \@@_qpoint:n { col - \l_tmpb_tl } + \dim_set_eq:NN \l_tmpc_dim \pgf@x + \@@_qpoint:n { col - \@@_succ:n \l_tmpb_tl } + \dim_set_eq:NN \l_tmpd_dim \pgf@x + \pgfpathrectanglecorners + { \pgfpoint \l_tmpc_dim \l_tmpb_dim } + { \pgfpoint \l_tmpd_dim \l_tmpa_dim } + } + } + \pgfusepathqfill + \endpgfpicture + } + } +% \end{macrocode} +% +% \bigskip +% Here an example : |\@@_rectanglecolor:nn {red!15}{2-3}{5-6}| +% \begin{macrocode} +\cs_new_protected:Npn \@@_rectanglecolor:nnn #1 #2 #3 + { + \tl_if_blank:nF { #1 } + { + \pgfpicture + \pgf@relevantforpicturesizefalse + \pgfsetfillcolor { #1 } + \@@_cut_on_hyphen:w #2 \q_stop + \bool_lazy_and:nnT + { \int_compare_p:n { \l_tmpa_tl <= \c@iRow } } + { \int_compare_p:n { \l_tmpb_tl <= \c@jCol } } + { + \@@_qpoint:n { row - \l_tmpa_tl } + \dim_set_eq:NN \l_tmpb_dim \pgf@y + \@@_qpoint:n { col - \l_tmpb_tl } + \@@_cut_on_hyphen:w #3 \q_stop + \int_compare:nNnT \l_tmpa_tl > \c@iRow + { \tl_set:Nx \l_tmpa_tl { \int_use:N \c@iRow } } + \int_compare:nNnT \l_tmpb_tl > \c@jCol + { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } } + \dim_set_eq:NN \l_tmpc_dim \pgf@x + \@@_qpoint:n { row - \@@_succ:n \l_tmpa_tl } + \dim_set_eq:NN \l_tmpa_dim \pgf@y + \@@_qpoint:n { col - \@@_succ:n \l_tmpb_tl } + \dim_set_eq:NN \l_tmpd_dim \pgf@x + \pgfpathrectanglecorners + { \pgfpoint \l_tmpc_dim \l_tmpb_dim } + { \pgfpoint \l_tmpd_dim \l_tmpa_dim } + \pgfusepathqfill + } + \endpgfpicture + } + } +% \end{macrocode} +% +% +% \bigskip +% The command |\rowcolors| (accessible in the |code-before|) is inspired by the +% command |\rowcolors| of the package \pkg{xcolor} (with the option |table|). +% However, the command |\rowcolors| of \pkg{nicematrix} has \emph{not} the +% optional argument of the command |\rowcolors| of \pkg{xcolor}. +% \begin{macrocode} +\cs_new_protected:Npn \@@_rowcolors:nnn #1 #2 #3 + { + \int_step_inline:nnn { #1 } { \int_use:N \c@iRow } + { + \int_if_odd:nTF { ##1 } + { \@@_rowcolor:nn { #2 } { ##1 } } + { \@@_rowcolor:nn { #3 } { ##1 } } + } + } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} +\cs_new_protected:Npn \@@_chessboardcolors:nn #1 #2 + { + \int_step_inline:nn { \int_use:N \c@iRow } + { + \int_step_inline:nn { \int_use:N \c@jCol } + { + \int_if_even:nTF { ####1 + ##1 } + { \@@_cellcolor:nn { #1 } { ####1 - ##1 } } + { \@@_cellcolor:nn { #2 } { ####1 - ##1 } } + } + } + } +% \end{macrocode} +% +% \bigskip % \subsection*{The vertical rules} % % We give to the user the possibility to define new types of columns (with @@ -7465,24 +8461,20 @@ version 2005/12/01 or later. % consecutive specifiers ``"|"'' (in a preambule like "ccc||ccc"). % % That's why we have done a redefinition of the macro |\@arrayrule| of -% \pkg{array} and this redefinition will add |\@@_vline:| instead of |\vline| to -% the preamble (that definition is in the beginning of |{NiceArrayWithDelims}|). +% \pkg{array} and this redefinition will add |\@@_vline:| instead of |\vline| +% in the preamble (that definition is in the beginning of +% |{NiceArrayWithDelims}|). % % Here is the definition of |\@@_vline:|. This definition \emph{must} be % protected because you don't want that macro expanded during the construction % of the preamble (the tests in |\@@_OnlyMainNiceMatrix:n| must be effective in -% each row and not once for all when the preamble is constructed). -% -% \medskip +% each row and not once for all when the preamble is constructed). The command +% |\CT@arc@| is a command of \pkg{colortbl} which sets the color of the rules in +% the array. The package \pkg{nicematrix} uses it even if \pkg{colortbl} is not +% loaded. % \begin{macrocode} -\cs_new_protected:Npn \@@_vline: { \@@_OnlyMainNiceMatrix:n { \@@_vline_i: } } -% \end{macrocode} -% -% If \pkg{colortbl} is loaded, the following macro will be redefined (in a -% |\AtBeginDocument|) to take into account the color fixed by |\arrayrulecolor| -% of \pkg{colortbl}. -% \begin{macrocode} -\cs_set_eq:NN \@@_vline_i: \vline +\cs_new_protected:Npn \@@_vline: + { \@@_OnlyMainNiceMatrix:n { { \CT@arc@ \vline } } } % \end{macrocode} % % \bigskip @@ -7493,9 +8485,12 @@ version 2005/12/01 or later. { \group_begin: % \end{macrocode} -% The command |\CT@arc@| is a command of color from \pkg{colortbl}. +% +% The command |\CT@arc@| is a command of \pkg{colortbl} which sets the color of +% the rules in the array. The package \pkg{nicematrix} uses it even if +% \pkg{colortbl} is not loaded. % \begin{macrocode} - \bool_if:NT \c_@@_colortbl_loaded_bool \CT@arc@ + \CT@arc@ \pgfpicture \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse @@ -7503,10 +8498,10 @@ version 2005/12/01 or later. % \end{macrocode} % First, we compute in |\l_tmpa_dim| the height of the rules we have to draw. % \begin{macrocode} - \@@_qpoint: {row - 1 } + \@@_qpoint:n { row - 1 } \dim_set_eq:NN \l_tmpa_dim \pgf@y \pgfusepathqfill - \@@_qpoint: { row - \@@_succ:n \c@iRow } + \@@_qpoint:n { row - \@@_succ:n \c@iRow } \dim_sub:Nn \l_tmpa_dim \pgf@y \pgfusepathqfill % \end{macrocode} @@ -7521,53 +8516,28 @@ version 2005/12/01 or later. % We adjust the value of |\l_tmpa_dim| by the width of the horizontal rule just % before the ``last row''. % \begin{macrocode} - \@@_qpoint: { row - \@@_succ:n\c@iRow } + \@@_qpoint:n { row - \@@_succ:n\c@iRow } \dim_add:Nn \l_tmpa_dim \pgf@y - \@@_qpoint: { row - \@@_succ:n \g_@@_row_total_int } + \@@_qpoint:n { row - \@@_succ:n \g_@@_row_total_int } \dim_sub:Nn \l_tmpa_dim \pgf@y \dim_sub:Nn \l_tmpa_dim \l_tmpb_dim } + \dim_add:Nn \l_tmpa_dim \arrayrulewidth % \end{macrocode} % -% Now, we can draw the lines with a loop. +% +% Now, we can draw the vertical rules with a loop. % \begin{macrocode} \int_step_inline:nnn { \bool_if:NTF \l_@@_NiceArray_bool 1 2 } { \bool_if:NTF \l_@@_NiceArray_bool { \@@_succ:n \c@jCol } \c@jCol } - { - \pgfpathmoveto - { - \pgfpointadd - { \@@_qpoint: { col - ##1 } } - { - \pgfpoint - { - -0.5 \arrayrulewidth - \int_compare:nNnT { ##1 } = 1 - { - \int_compare:nNnT \l_@@_first_col_int = 1 - { + \arrayrulewidth } - } - } - { \l_tmpb_dim } - } - } + { + \pgfpathmoveto { \@@_qpoint:n { col - ##1 } } \pgfpathlineto { \pgfpointadd - { \@@_qpoint: { col - ##1 } } - { - \pgfpoint - { - -0.5 \arrayrulewidth - \int_compare:nNnT { ##1 } = 1 - { - \int_compare:nNnT \l_@@_first_col_int = 1 - { + \arrayrulewidth } - } - } - { \l_tmpb_dim + \l_tmpa_dim } - } + { \@@_qpoint:n { col - ##1 } } + { \pgfpoint \c_zero_dim { \l_tmpb_dim + \l_tmpa_dim } } } } \pgfusepathqstroke @@ -7581,7 +8551,7 @@ version 2005/12/01 or later. % \subsection*{The commands to draw dotted lines to separate columns and rows} % % These commands don't use the normal nodes, the medium nor the large nodes. -% They only use the |col|-nodes and the |row|-nodes. +% They only use the |col| nodes and the |row| nodes. % % \textbf{Horizontal dotted lines}\par\nobreak % @@ -7589,14 +8559,10 @@ version 2005/12/01 or later. % The following command must \emph{not} be protected because it's meant to be % expanded in a |\noalign|. % \begin{macrocode} -\bool_if:NTF \c_@@_draft_bool - { \cs_new:Npn \@@_hdottedline: { } } +\cs_new:Npn \@@_hdottedline: { - \cs_new:Npn \@@_hdottedline: - { - \noalign { \skip_vertical:N 2\l_@@_radius_dim } - \@@_hdottedline_i: - } + \noalign { \skip_vertical:N 2\l_@@_radius_dim } + \@@_hdottedline_i: } % \end{macrocode} % @@ -7645,7 +8611,7 @@ version 2005/12/01 or later. \cs_new_protected:Npn \@@_hdottedline_i:n #1 { \pgfrememberpicturepositiononpagetrue - \@@_qpoint: { row - #1 } + \@@_qpoint:n { row - #1 } % \end{macrocode} % We do a translation par |-\l_@@_radius_dim| because we want the dotted line to % have exactly the same position as a vertical rule drawn by ``"|"'' @@ -7671,7 +8637,7 @@ version 2005/12/01 or later. % \hline % 1 & 2 & 3 & 4 \\ % \hdottedline -% 1 & 2 & 3 & 4 \\ +% 1 & 2 & 3 & 4 % \end{bNiceMatrix} % \end{BVerbatim} % $\begin{bNiceMatrix} @@ -7679,7 +8645,7 @@ version 2005/12/01 or later. % \hline % 1 & 2 & 3 & 4 \\ % \hdottedline -% 1 & 2 & 3 & 4 \\ +% 1 & 2 & 3 & 4 % \end{bNiceMatrix}$ % % \smallskip @@ -7693,7 +8659,7 @@ version 2005/12/01 or later. % \hline % 1 & 2 & 3 & 4 \\ % \hdottedline -% 1 & 2 & 3 & 4 \\ +% 1 & 2 & 3 & 4 % \end{bNiceMatrix} % \end{BVerbatim} % $\begin{bNiceMatrix}[margin] @@ -7701,17 +8667,25 @@ version 2005/12/01 or later. % \hline % 1 & 2 & 3 & 4 \\ % \hdottedline -% 1 & 2 & 3 & 4 \\ +% 1 & 2 & 3 & 4 % \end{bNiceMatrix}$ % % \medskip % \begin{macrocode} - \@@_qpoint: { col - 1 } + \@@_qpoint:n { col - 1 } \dim_set:Nn \l_@@_x_initial_dim - { \pgf@x + \arraycolsep - \l_@@_left_margin_dim } - \@@_qpoint: { col - \@@_succ:n \c@jCol } + { + \pgf@x + + \bool_if:NTF \l_@@_NiceTabular_bool \tabcolsep \arraycolsep + - \l_@@_left_margin_dim + } + \@@_qpoint:n { col - \@@_succ:n \c@jCol } \dim_set:Nn \l_@@_x_final_dim - { \pgf@x - \arraycolsep + \l_@@_right_margin_dim } + { + \pgf@x - + \bool_if:NTF \l_@@_NiceTabular_bool \tabcolsep \arraycolsep + + \l_@@_right_margin_dim + } % \end{macrocode} % For reasons purely aesthetic, we do an adjustment in the case of a rounded % bracket. The correction by |0.5 \l_@@_inter_dots_dim| is \emph{ad hoc} for a @@ -7743,29 +8717,25 @@ version 2005/12/01 or later. % % \medskip % \begin{macrocode} -\bool_if:nTF \c_@@_draft_bool - { \cs_new_protected:Npn \@@_vdottedline:n #1 { } } +\cs_new_protected:Npn \@@_vdottedline:n #1 { - \cs_new_protected:Npn \@@_vdottedline:n #1 - { - \bool_set_true:N \l_@@_initial_open_bool - \bool_set_true:N \l_@@_final_open_bool + \bool_set_true:N \l_@@_initial_open_bool + \bool_set_true:N \l_@@_final_open_bool % \end{macrocode} % We recall that, when externalization is used, |\tikzpicture| and % |\endtikzpicture| (or |\pgfpicture| and |\endpgfpicture|) must be directly % ``visible''. % \begin{macrocode} - \bool_if:NTF \c_@@_tikz_loaded_bool - { - \tikzpicture - \@@_vdottedline_i:n { #1 } - \endtikzpicture - } - { - \pgfpicture - \@@_vdottedline_i:n { #1 } - \endpgfpicture - } + \bool_if:NTF \c_@@_tikz_loaded_bool + { + \tikzpicture + \@@_vdottedline_i:n { #1 } + \endtikzpicture + } + { + \pgfpicture + \@@_vdottedline_i:n { #1 } + \endpgfpicture } } % \end{macrocode} @@ -7775,11 +8745,13 @@ version 2005/12/01 or later. \cs_new_protected:Npn \@@_vdottedline_i:n #1 { % \end{macrocode} -% The command |\CT@arc@| is a command of color from \pkg{colortbl}. +% The command |\CT@arc@| is a command of \pkg{colortbl} which sets the color of +% the rules in the array. The package \pkg{nicematrix} uses it even if \pkg{colortbl} is not +% loaded. % \begin{macrocode} - \bool_if:NT \c_@@_colortbl_loaded_bool \CT@arc@ + \CT@arc@ \pgfrememberpicturepositiononpagetrue - \@@_qpoint: { col - \int_eval:n { #1 + 1 } } + \@@_qpoint:n { col - \int_eval:n { #1 + 1 } } % \end{macrocode} % We do a translation par |-\l_@@_radius_dim| because we want the dotted line to % have exactly the same position as a vertical rule drawn by ``"|"'' @@ -7787,13 +8759,13 @@ version 2005/12/01 or later. % \begin{macrocode} \dim_set:Nn \l_@@_x_initial_dim { \pgf@x - \l_@@_radius_dim } \dim_set:Nn \l_@@_x_final_dim { \pgf@x - \l_@@_radius_dim } - \@@_qpoint: { row - 1 } + \@@_qpoint:n { row - 1 } % \end{macrocode} % We arbitrary decrease the height of the dotted line by a quantity equal to % |\l_@@_inter_dots_dim| in order to improve the visual impact. % \begin{macrocode} \dim_set:Nn \l_@@_y_initial_dim { \pgf@y - 0.5 \l_@@_inter_dots_dim } - \@@_qpoint: { row - \@@_succ:n \c@iRow } + \@@_qpoint:n { row - \@@_succ:n \c@iRow } \dim_set:Nn \l_@@_y_final_dim { \pgf@y + 0.5 \l_@@_inter_dots_dim } % \end{macrocode} % As for now, we have no option to control the style of the lines drawn by @@ -7984,7 +8956,7 @@ version 2005/12/01 or later. \dim_compare:nNnT { \dim_use:c { l_@@_row _ \@@_i: _ min _ dim } } = \c_max_dim { - \@@_qpoint: { row - \@@_i: - base } + \@@_qpoint:n { row - \@@_i: - base } \dim_set:cn { l_@@_row _ \@@_i: _ max _ dim } \pgf@y \dim_set:cn { l_@@_row _ \@@_i: _ min _ dim } \pgf@y } @@ -7994,7 +8966,7 @@ version 2005/12/01 or later. \dim_compare:nNnT { \dim_use:c { l_@@_column _ \@@_j: _ min _ dim } } = \c_max_dim { - \@@_qpoint: { col - \@@_j: } + \@@_qpoint:n { col - \@@_j: } \dim_set:cn { l_@@_column _ \@@_j: _ max _ dim } \pgf@y \dim_set:cn { l_@@_column _ \@@_j: _ min _ dim } \pgf@y } @@ -8110,9 +9082,9 @@ version 2005/12/01 or later. \dim_set_eq:cc { l_@@_column _ \@@_succ:n \@@_j: _ min _ dim } { l_@@_column _ \@@_j: _ max _ dim } } -% \end{macrocode} +% \end{macrocode} % Here, we have to use |\dim_sub:cn| because of the number 1 in the name. -% \begin{macrocode} +% \begin{macrocode} \dim_sub:cn { l_@@_column _ 1 _ min _ dim } \l_@@_left_margin_dim @@ -8125,7 +9097,7 @@ version 2005/12/01 or later. % % % \bigskip -% The control sequence |\@@_create_nodes:| is used twice: for the construction +% The command |\@@_create_nodes:| is used twice: for the construction % of the ``medium nodes'' and for the construction of the ``large nodes''. The % nodes are constructed with the value of all the dimensions % \texttt{l_@@_row_\textsl{i}_min_dim}, \texttt{l_@@_row_\textsl{i}_max_dim}, @@ -8318,13 +9290,13 @@ version 2005/12/01 or later. \pgfpicture \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse - \@@_qpoint: { row - #1 } + \@@_qpoint:n { row - #1 } \dim_set_eq:NN \l_tmpa_dim \pgf@y - \@@_qpoint: { col - #2 } + \@@_qpoint:n { col - #2 } \dim_set_eq:NN \l_tmpb_dim \pgf@x - \@@_qpoint: { row - \@@_succ:n { #3 } } + \@@_qpoint:n { row - \@@_succ:n { #3 } } \dim_set_eq:NN \l_tmpc_dim \pgf@y - \@@_qpoint: { col - \@@_succ:n { #4 } } + \@@_qpoint:n { col - \@@_succ:n { #4 } } \dim_set_eq:NN \l_tmpd_dim \pgf@x % \end{macrocode} % @@ -8337,24 +9309,19 @@ version 2005/12/01 or later. \begin { pgfscope } \pgfsetfillcolor { white } % \end{macrocode} -% Usually, the vertical rules are \emph{before} the |col|-nodes. But there is an -% exception: if there is no ``first col'', the first vertical rule is after the -% col node.\footnote{That's true for the vertical rules drawn by ``"|"'' due to -% the conception of |{array}| (of \pkg{array}) and we have managed to have the -% same behaviour with |vlines|.} % -% Since we don't want the white rectangle to erase a part of this -% first rule, we have to do an adjustment in this case. -% \emph{after} the ``col node''. % \begin{macrocode} - \int_compare:nNnT { #2 } = 1 + \pgfpathrectanglecorners + { + \pgfpoint + { \l_tmpb_dim + 0.5 \arrayrulewidth } + { \l_tmpa_dim - 0.5 \arrayrulewidth } + } { - \int_compare:nNnT \l_@@_first_col_int = 1 - { \dim_add:Nn \l_tmpb_dim \arrayrulewidth } + \pgfpoint + { \l_tmpd_dim - 0.5 \arrayrulewidth } + { \l_tmpc_dim + 0.5 \arrayrulewidth } } - \pgfpathrectanglecorners - { \pgfpoint \l_tmpb_dim { \l_tmpa_dim - \arrayrulewidth } } - { \pgfpoint { \l_tmpd_dim - \arrayrulewidth } \l_tmpc_dim } \pgfusepathqfill \end { pgfscope } } @@ -8398,11 +9365,11 @@ version 2005/12/01 or later. % |\pgfcoordinate| on the baseline of the row, in the first column of the array. % Now, we retrieve the $y$-value of that node and we store it in |\l_tmpa_dim|. % \begin{macrocode} - \pgfextracty \l_tmpa_dim { \@@_qpoint: { row - #1 - base } } + \pgfextracty \l_tmpa_dim { \@@_qpoint:n { row - #1 - base } } % \end{macrocode} % We retrieve (in |\pgf@x|) the $x$-value of the center of the block. % \begin{macrocode} - \@@_qpoint: { #1 - #2 - block } + \@@_qpoint:n { #1 - #2 - block } % \end{macrocode} % We put the label of the block which has been composed in |\l_@@_cell_box|. % \begin{macrocode} @@ -8418,7 +9385,7 @@ version 2005/12/01 or later. % |\l_@@_cell_box|). % \begin{macrocode} { - \pgftransformshift { \@@_qpoint: { #1 - #2 - block } } + \pgftransformshift { \@@_qpoint:n { #1 - #2 - block } } \pgfnode { rectangle } { center } { \box_use_drop:N \l_@@_cell_box } { } { } } @@ -8519,9 +9486,106 @@ version 2005/12/01 or later. \@@_define_com:nnn V \| \| \@@_define_com:nnn B \{ \} % \end{macrocode} +% +% \bigskip +% We define also an command |\AutoNiceMatrix| similar to the environment |{NiceMatrix}|. +% \begin{macrocode} +\NewDocumentCommand \AutoNiceMatrix { O { } m O { } m ! O { } } + { + \group_begin: + \bool_set_true:N \l_@@_NiceArray_bool + \AutoNiceMatrixWithDelims . . { #2 } { #4 } [ #1 , #3 , #5 ] + \group_end: + } +% \end{macrocode} +% +% \subsection*{The redefinition of the command \textbackslash dotfill } +% +% \begin{macrocode} +\cs_set_eq:NN \@@_dotfill \dotfill +\cs_new_protected:Npn \@@_dotfill: + { +% \end{macrocode} +% First, we insert |\@@_dotfill| (which is the saved version of |\dotfill|) in +% case of use of |\dotfill| ``internally'' in the cell (e.g. |\hbox to 1cm {\dotfill}|). +% \begin{macrocode} + \@@_dotfill + \group_insert_after:N \@@_dotfill_i: + } +\cs_new_protected:Npn \@@_dotfill_i: { \group_insert_after:N \@@_dotfill_ii: } +\cs_new_protected:Npn \@@_dotfill_ii: { \group_insert_after:N \@@_dotfill_iii: } +% \end{macrocode} +% Now, if the box if not empty (unfornately, we can't actually test whether the +% box is empty and that's why we only consider it's width), we insert +% |\@@_dotfill| (which is the saved version of |\dotfill|) in the cell of the +% array, and it will extends, since it's no longer in |\l_@@_cell_box|. +% \begin{macrocode} +\cs_new_protected:Npn \@@_dotfill_iii: + { \dim_compare:nNnT { \box_wd:N \l_@@_cell_box } = \c_zero_dim \@@_dotfill } +% \end{macrocode} +% +% \subsection*{The command \textbackslash slashbox} +% +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_slashbox:nn #1 #2 + { + \tl_gput_right:Nx \g_@@_internal_code_after_tl + { + \@@_actually_slashbox:nnnn + { \int_use:N \c@iRow } { \int_use:N \c@jCol } { #1 } { #2 } + } + } +% \end{macrocode} +% +% \medskip +% The two arguments of |\@@_actually_slashbox:nn| are the number of row and the +% number of column of the cell to slash. The two other are the elements to draw +% below and above the diagonal line. +% \begin{macrocode} +\cs_new_protected:Npn \@@_actually_slashbox:nnnn #1 #2 #3 #4 + { + \pgfpicture + \pgf@relevantforpicturesizefalse + \pgfrememberpicturepositiononpagetrue + \@@_qpoint:n { row - #1 } + \dim_set_eq:NN \l_tmpa_dim \pgf@y + \@@_qpoint:n { col - #2 } + \dim_set_eq:NN \l_tmpb_dim \pgf@x + \pgfpathmoveto { \pgfpoint \l_tmpb_dim \l_tmpa_dim } + \@@_qpoint:n { row - \@@_succ:n { #1 } } + \dim_set_eq:NN \l_tmpc_dim \pgf@y + \@@_qpoint:n { col - \@@_succ:n { #2 } } + \dim_set_eq:NN \l_tmpd_dim \pgf@x + \pgfpathlineto { \pgfpoint \l_tmpd_dim \l_tmpc_dim } + { +% \end{macrocode} +% The command |\CT@arc@| is a command of \pkg{colortbl} which sets the color of +% the rules in the array. The package \pkg{nicematrix} uses it even if \pkg{colortbl} is not +% loaded. +% \begin{macrocode} + \CT@arc@ + \pgfsetroundcap + \pgfusepathqstroke + } + \pgfset { inner~sep = 1 pt } + \pgfscope + \pgftransformshift { \pgfpoint \l_tmpb_dim \l_tmpc_dim } + \pgfnode { rectangle } { south~west } { $ #3 $ } { } { } + \endpgfscope + \pgftransformshift { \pgfpoint \l_tmpd_dim \l_tmpa_dim } + \pgfnode { rectangle } { north~east } { $ #4 $ } { } { } + \endpgfpicture + } +% \end{macrocode} % % \subsection*{The command \textbackslash CodeAfter} % +% In fact, in this subsection, we define the user command |\CodeAfter| for the +% case of the ``normal syntax''. For the case of ``light-syntax'', see the +% definition of the environment |{@@-light-syntax}| on +% p.~\pageref{code-light-syntax}. +% % The command |\CodeAfter| catches everything until the end of the current % environment (of \pkg{nicematrix}). % @@ -8542,7 +9606,8 @@ version 2005/12/01 or later. % If this is really the end of the current environment (of \pkg{nicematrix}), we % put back the command |\end| and its argument in the TeX flow. % \begin{macrocode} - \bool_if:NTF { \str_if_eq_p:Vn \g_@@_name_env_str { #1 } } + \str_set:NV \l_tmpa_str \@currenvir + \bool_if:NTF { \str_if_eq_p:Vn \l_tmpa_str { #1 } } { \end { #1 } } % \end{macrocode} % It this is not the |\end| we are looking for, we put those tokens in @@ -8560,6 +9625,18 @@ version 2005/12/01 or later. % \bigskip % \subsection*{We process the options} % +% +% \begin{macrocode} +\@@_msg_new:nn { obsolete~environments } + { + The~obsolete~environments~(eg.~{pNiceArrayC})~have~been~deleted~ + from~the~package~nicematrix.\\ + However,~if~you~still~want~to~use~them,~you~will~find~the~code~for~ + those~environments~at~the~end~of~the~file~'nicematrix.sty',~after~ + a~command~'\token_to_str:N\file_input_stop:'. + } +% \end{macrocode} +% % We process the options when the package is loaded (with |\usepackage|) but we % recommend to use |\NiceMatrixOptions| instead. % @@ -8570,7 +9647,6 @@ version 2005/12/01 or later. % Of course, the command |\NiceMatrix| must be defined before such an % instruction is executed. % \begin{macrocode} -\bool_new:N \c_@@_obsolete_environments_bool \keys_define:nn { NiceMatrix / Package } { renew-dots .bool_set:N = \l_@@_renew_dots_bool , @@ -8579,9 +9655,7 @@ version 2005/12/01 or later. renew-matrix .value_forbidden:n = true , transparent .meta:n = { renew-dots , renew-matrix } , transparent .value_forbidden:n = true, - obsolete-environments .bool_set:N = \c_@@_obsolete_environments_bool , - obsolete-environments .value_forbidden:n = true , - obsolete-environments .default:n = true , + obsolete-environments .code:n = \@@_fatal:n { obsolete~environments }, starred-commands .code:n = \@@_msg_redirect_name:nn { starred~commands } { none } , starred-commands .value_forbidden:n = true , @@ -8650,7 +9724,7 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new:Npn \@@_message_hdotsfor: { - \tl_if_empty:VF \g_@@_Hdotsfor_lines_tl + \tl_if_empty:VF \g_@@_HVdotsfor_lines_tl { ~Maybe~your~use~of~\token_to_str:N \Hdotsfor\ is~incorrect.} } % \end{macrocode} @@ -8692,7 +9766,47 @@ version 2005/12/01 or later. } % \end{macrocode} % -% +% \begin{macrocode} +\@@_msg_new:nn { in~first~col } + { + You~can't~use~the~command~#1 in~the~first~column~(number~0)~of~the~array.\\ + If~you~go~on,~this~command~will~be~ignored. + } +% \end{macrocode} +% +% \begin{macrocode} +\@@_msg_new:nn { in~last~col } + { + You~can't~use~the~command~#1 in~the~last~column~(exterior)~of~the~array.\\ + If~you~go~on,~this~command~will~be~ignored. + } +% \end{macrocode} +% +% \begin{macrocode} +\@@_msg_new:nn { in~first~row } + { + You~can't~use~the~command~#1 in~the~first~row~(number~0)~of~the~array.\\ + If~you~go~on,~this~command~will~be~ignored. + } +% \end{macrocode} +% +% \begin{macrocode} +\@@_msg_new:nn { in~last~row } + { + You~can't~use~the~command~#1 in~the~last~row~(exterior)~of~the~array.\\ + If~you~go~on,~this~command~will~be~ignored. + } +% \end{macrocode} +% +% \begin{macrocode} +\@@_msg_new:nn { option~S~without~siunitx } + { + You~can't~use~the~option~'S'~in~your~environment~\@@_full_name_env: + because~you~have~not~loaded~siunitx.\\ + If~you~go~on,~this~option~will~be~ignored. + } +% \end{macrocode} +% % \begin{macrocode} \@@_msg_new:nn { bad~option~for~line-style } { @@ -8782,6 +9896,16 @@ version 2005/12/01 or later. } % \end{macrocode} % +% \begin{macrocode} +\@@_msg_new:nn { last-col~non~empty~for~NiceMatrixOptions } + { + In~\NiceMatrixoptions,~you~must~use~the~option~ + 'last-col'~without~value.\\ + However,~you~can~go~on~for~this~time~ + (the~value~'\l_keys_value_tl'~will~be~ignored). + } +% \end{macrocode} +% % % \begin{macrocode} \@@_msg_new:nn { Block~too~large } @@ -8843,6 +9967,8 @@ version 2005/12/01 or later. The~available~options~are~(in~alphabetic~order):~ allow-duplicate-names,~ code-for-first-col,~ + cell-space-bottom-limit,~ + cell-space-top-limit,~ code-for-first-row,~ code-for-last-col,~ code-for-last-row,~ @@ -8851,8 +9977,12 @@ version 2005/12/01 or later. create-large-nodes,~ end-of-row,~ exterior-arraycolsep,~ + first-col,~ + first-row,~ hlines,~ hvlines,~ + last-col,~ + last-row,~ left-margin,~ letter-for-dotted-lines,~ light-syntax,~ @@ -8883,6 +10013,8 @@ version 2005/12/01 or later. b,~ baseline,~ c,~ + cell-space-bottom-limit,~ + cell-space-top-limit,~ code-after,~ code-for-first-col,~ code-for-first-row,~ @@ -8934,6 +10066,8 @@ version 2005/12/01 or later. b,~ baseline,~ c,~ + cell-space-bottom-limit,~ + cell-space-top-limit,~ code-after,~ code-for-first-col,~ code-for-first-row,~ @@ -8961,6 +10095,7 @@ version 2005/12/01 or later. r~(=R),~ renew-dots,~ right-margin,~ + S,~ small,~ t,~ vlines,~ @@ -8970,6 +10105,54 @@ version 2005/12/01 or later. } % \end{macrocode} % +% \begin{macrocode} +\@@_msg_new:nnn { Unknown~option~for~NiceTabular } + { + The~option~'\tl_use:N\l_keys_key_str'~is~unknown~for~the~environment~ + \{NiceTabular\}. \\ + If~you~go~on,~it~will~be~ignored. \\ + For~a~list~of~the~available~options,~type~H~<return>. + } + { + The~available~options~are~(in~alphabetic~order):~ + b,~ + baseline,~ + c,~ + cell-space-bottom-limit,~ + cell-space-top-limit,~ + code-after,~ + code-for-first-col,~ + code-for-first-row,~ + code-for-last-col,~ + code-for-last-row,~ + columns-width,~ + create-extra-nodes,~ + create-medium-nodes,~ + create-large-nodes,~ + end-of-row,~ + extra-left-margin,~ + extra-right-margin,~ + first-col,~ + first-row,~ + hlines,~ + hvlines,~ + last-col,~ + last-row,~ + left-margin,~ + light-syntax,~ + name,~ + nullify-dots,~ + parallelize-diags,~ + renew-dots,~ + right-margin,~ + t,~ + vlines,~ + xdots/color,~ + xdots/shorten~and~ + xdots/line-style. + } +% \end{macrocode} +% % % \begin{macrocode} \@@_msg_new:nnn { Duplicate~name } @@ -9013,87 +10196,85 @@ version 2005/12/01 or later. % completly deleted in a future version. % % \begin{macrocode} -\bool_if:NT \c_@@_obsolete_environments_bool +\file_input_stop: +\NewDocumentEnvironment { pNiceArrayC } { } { - \NewDocumentEnvironment { pNiceArrayC } { } - { - \int_zero:N \l_@@_last_col_int - \pNiceArray - } - { \endpNiceArray } - \NewDocumentEnvironment { bNiceArrayC } { } - { - \int_zero:N \l_@@_last_col_int - \bNiceArray - } - { \endbNiceArray } - \NewDocumentEnvironment { BNiceArrayC } { } - { - \int_zero:N \l_@@_last_col_int - \BNiceArray - } - { \endBNiceArray } - \NewDocumentEnvironment { vNiceArrayC } { } - { - \int_zero:N \l_@@_last_col_int - \vNiceArray - } - { \endvNiceArray } - \NewDocumentEnvironment { VNiceArrayC } { } - { - \int_zero:N \l_@@_last_col_int - \VNiceArray - } - { \endVNiceArray } - \NewDocumentEnvironment { pNiceArrayRC } { } - { - \int_zero:N \l_@@_last_col_int - \int_zero:N \l_@@_first_row_int - \pNiceArray - } - { \endpNiceArray } - \NewDocumentEnvironment { bNiceArrayRC } { } - { - \int_zero:N \l_@@_last_col_int - \int_zero:N \l_@@_first_row_int - \bNiceArray - } - { \endbNiceArray } - \NewDocumentEnvironment { BNiceArrayRC } { } - { - \int_zero:N \l_@@_last_col_int - \int_zero:N \l_@@_first_row_int - \BNiceArray - } - { \endBNiceArray } - \NewDocumentEnvironment { vNiceArrayRC } { } - { - \int_zero:N \l_@@_last_col_int - \int_zero:N \l_@@_first_row_int - \vNiceArray - } - { \endvNiceArray } - \NewDocumentEnvironment { VNiceArrayRC } { } - { - \int_zero:N \l_@@_last_col_int - \int_zero:N \l_@@_first_row_int - \VNiceArray - } - { \endVNiceArray } - \NewDocumentEnvironment { NiceArrayCwithDelims } { } - { - \int_zero:N \l_@@_last_col_int - \NiceArrayWithDelims - } - { \endNiceArrayWithDelims } - \NewDocumentEnvironment { NiceArrayRCwithDelims } { } - { - \int_zero:N \l_@@_last_col_int - \int_zero:N \l_@@_first_row_int - \NiceArrayWithDelims - } - { \endNiceArrayWithDelims } + \int_zero:N \l_@@_last_col_int + \pNiceArray + } + { \endpNiceArray } + \NewDocumentEnvironment { bNiceArrayC } { } + { + \int_zero:N \l_@@_last_col_int + \bNiceArray + } + { \endbNiceArray } +\NewDocumentEnvironment { BNiceArrayC } { } + { + \int_zero:N \l_@@_last_col_int + \BNiceArray + } + { \endBNiceArray } +\NewDocumentEnvironment { vNiceArrayC } { } + { + \int_zero:N \l_@@_last_col_int + \vNiceArray } + { \endvNiceArray } +\NewDocumentEnvironment { VNiceArrayC } { } + { + \int_zero:N \l_@@_last_col_int + \VNiceArray + } + { \endVNiceArray } +\NewDocumentEnvironment { pNiceArrayRC } { } + { + \int_zero:N \l_@@_last_col_int + \int_zero:N \l_@@_first_row_int + \pNiceArray + } + { \endpNiceArray } +\NewDocumentEnvironment { bNiceArrayRC } { } + { + \int_zero:N \l_@@_last_col_int + \int_zero:N \l_@@_first_row_int + \bNiceArray + } + { \endbNiceArray } +\NewDocumentEnvironment { BNiceArrayRC } { } + { + \int_zero:N \l_@@_last_col_int + \int_zero:N \l_@@_first_row_int + \BNiceArray + } + { \endBNiceArray } +\NewDocumentEnvironment { vNiceArrayRC } { } + { + \int_zero:N \l_@@_last_col_int + \int_zero:N \l_@@_first_row_int + \vNiceArray + } + { \endvNiceArray } +\NewDocumentEnvironment { VNiceArrayRC } { } + { + \int_zero:N \l_@@_last_col_int + \int_zero:N \l_@@_first_row_int + \VNiceArray + } + { \endVNiceArray } +\NewDocumentEnvironment { NiceArrayCwithDelims } { } + { + \int_zero:N \l_@@_last_col_int + \NiceArrayWithDelims + } + { \endNiceArrayWithDelims } +\NewDocumentEnvironment { NiceArrayRCwithDelims } { } + { + \int_zero:N \l_@@_last_col_int + \int_zero:N \l_@@_first_row_int + \NiceArrayWithDelims + } + { \endNiceArrayWithDelims } % \end{macrocode} % % @@ -9164,8 +10345,6 @@ version 2005/12/01 or later. % possible to externalize the Tikz elements constructed by \pkg{nicematrix} % because they use the options |overlay| and |remember picture|.} % -% \subsection*{Changes between version 2.1 and 2.1.2} -% Option |draft|: with this option, the dotted lines are not drawn (quicker). % % \subsection*{Changes between version 2.1.2 and 2.1.3} % @@ -9218,9 +10397,6 @@ version 2005/12/01 or later. % % Option |hlines|. % -% A warning is issued when the |draft| mode is used. In this case, the dotted -% lines are not drawn. -% % % \subsection*{Changes between version 2.3 and 3.0} % @@ -9393,6 +10569,14 @@ version 2005/12/01 or later. % % New command |\CodeAfter| (in the environments of \pkg{nicematrix}). % +% +% \subsection*{Changes between versions 3.15 and 4.0} +% +% New environment |{NiceTabular}| +% +% Commands to color cells, row and columns with a perfect result in the \textsc{pdf}. +% +% % \PrintIndex % % \tableofcontents diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index 4b5e8ce16bf..06c3fa98690 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{3.15} -\def\myfiledate{2020/04/06} +\def\myfileversion{4.0} +\def\myfiledate{2020/05/08} \RequirePackage{pgfcore} \usepgfmodule{shapes} \RequirePackage{l3keys2e} @@ -36,10 +36,6 @@ } \cs_if_exist:NF \l_keys_key_str { \msg_error:nn { nicematrix } { expl3~too~old } } -\bool_new:N \c__nicematrix_draft_bool -\DeclareOption { draft } { \bool_set_true:N \c__nicematrix_draft_bool } -\DeclareOption* { } -\ProcessOptions \relax \RequirePackage { array } \RequirePackage { amsmath } \RequirePackage { xparse } @@ -52,9 +48,13 @@ \cs_new_protected:Npn \__nicematrix_msg_new:nnn { \msg_new:nnnn { nicematrix } } \cs_new_protected:Npn \__nicematrix_msg_redirect_name:nn { \msg_redirect_name:nnn { nicematrix } } +\bool_new:N \c__nicematrix_booktabs_loaded_bool \bool_new:N \c__nicematrix_tikz_loaded_bool \AtBeginDocument { + \@ifpackageloaded { booktabs } + { \bool_set_true:N \c__nicematrix_booktabs_loaded_bool } + { } \@ifpackageloaded { tikz } { \bool_set_true:N \c__nicematrix_tikz_loaded_bool @@ -73,9 +73,6 @@ \@ifclassloaded { revtex4-2 } { \bool_set_true:N \c__nicematrix_revtex_bool } { } -\__nicematrix_msg_new:nn { Draft~mode } - { The~compilation~is~in~draft~mode:~the~dotted~lines~won't~be~drawn. } -\bool_if:NT \c__nicematrix_draft_bool { \msg_warning:nn { nicematrix } { Draft~mode } } \ProvideDocumentCommand \iddots { } { \mathinner @@ -90,79 +87,45 @@ \tex_mkern:D 1 mu } } -\int_new:N \g__nicematrix_env_int -\cs_new:Npn \__nicematrix_env: { nm - \int_use:N \g__nicematrix_env_int } -\cs_new_protected:Npn \__nicematrix_qpoint: #1 - { \pgfpointanchor { \__nicematrix_env: - #1 } { center } } -\int_new:N \g__nicematrix_NiceMatrixBlock_int -\dim_new:N \l__nicematrix_columns_width_dim -\seq_new:N \g__nicematrix_names_seq - -\bool_new:N \l__nicematrix_in_env_bool -\bool_new:N \l__nicematrix_NiceArray_bool -\cs_new_protected:Npn \__nicematrix_test_if_math_mode: +\AtBeginDocument { - \if_mode_math: \else: - \__nicematrix_fatal:n { Outside~math~mode } - \fi: + \@ifpackageloaded { booktabs } + { \iow_now:Nn \@mainaux \nicematrix@redefine@check@rerun } + { } + } +\cs_set_protected:Npn \nicematrix@redefine@check@rerun + { + \cs_set_eq:NN \__nicematrix_old_pgfutil@check@rerun \pgfutil@check@rerun + \cs_set_protected:Npn \pgfutil@check@rerun ##1 ##2 + { + \str_set:Nx \l_tmpa_str { \tl_range:nnn { ##1 } 1 3 } + \str_if_eq:VnF \l_tmpa_str { nm- } + { \__nicematrix_old_pgfutil@check@rerun { ##1 } { ##2 } } + } } \bool_new:N \c__nicematrix_colortbl_loaded_bool \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 \__nicematrix_vline_i: { { \CT@arc@ \vline } } + \cs_set_protected:Npn \CT@arc@ { } + \NewDocumentCommand { \arrayrulecolor } { m } + { \tl_gset:Nn \CT@arc@ { \color { #1 } } } + \cs_set:Npn \hline + { + \noalign { \ifnum 0 = `} \fi + \let \hskip \vskip + \let \vrule \hrule + \let \@width \@height + { \CT@arc@ \vline } + \futurelet \reserved@a + \@xhline + } } - { } } -\colorlet { nicematrix-last-col } { . } -\colorlet { nicematrix-last-row } { . } -\dim_new:N \l__nicematrix_inter_dots_dim -\dim_set:Nn \l__nicematrix_inter_dots_dim { 0.45 em } -\dim_new:N \l__nicematrix_xdots_shorten_dim -\dim_set:Nn \l__nicematrix_xdots_shorten_dim { 0.3 em } -\dim_new:N \l__nicematrix_radius_dim -\dim_set:Nn \l__nicematrix_radius_dim { 0.53 pt } -\str_new:N \g__nicematrix_name_env_str -\str_new:N \g__nicematrix_com_or_env_str -\str_set:Nn \g__nicematrix_com_or_env_str { environment } -\cs_new:Npn \__nicematrix_full_name_env: - { - \str_if_eq:VnTF \g__nicematrix_com_or_env_str { command } - { command \space \c_backslash_str \g__nicematrix_name_env_str } - { environment \space \{ \g__nicematrix_name_env_str \} } - } -\tl_new:N \g__nicematrix_internal_code_after_tl -\tl_new:N \g__nicematrix_code_after_tl -\int_new:N \l__nicematrix_save_iRow_int -\int_new:N \l__nicematrix_save_jCol_int -\bool_new:N \g__nicematrix_row_of_col_done_bool -\tl_new:N \l__nicematrix_initial_suffix_tl -\tl_new:N \l__nicematrix_initial_anchor_tl -\tl_new:N \l__nicematrix_final_suffix_tl -\tl_new:N \l__nicematrix_final_anchor_tl -\dim_new:N \l__nicematrix_x_initial_dim -\dim_new:N \l__nicematrix_y_initial_dim -\dim_new:N \l__nicematrix_x_final_dim -\dim_new:N \l__nicematrix_y_final_dim -\dim_new:N \l_tmpc_dim -\dim_new:N \l_tmpd_dim -\bool_new:N \g__nicematrix_empty_cell_bool -\tl_new:N \l__nicematrix_xdots_line_style_tl -\tl_const:Nn \c__nicematrix_standard_tl { standard } -\tl_set_eq:NN \l__nicematrix_xdots_line_style_tl \c__nicematrix_standard_tl -\int_new:N \l__nicematrix_first_row_int -\int_set:Nn \l__nicematrix_first_row_int 1 -\int_new:N \l__nicematrix_first_col_int -\int_set:Nn \l__nicematrix_first_col_int 1 -\int_new:N \l__nicematrix_last_row_int -\int_set:Nn \l__nicematrix_last_row_int { -2 } -\bool_new:N \l__nicematrix_last_row_without_value_bool -\bool_new:N \l__nicematrix_last_col_without_value_bool -\int_new:N \l__nicematrix_last_col_int -\int_set:Nn \l__nicematrix_last_col_int { -2 } -\bool_new:N \g__nicematrix_last_col_found_bool +\cs_new:Npn \__nicematrix_succ:n #1 { \the \numexpr #1 + 1 \relax } +\cs_new:Npn \__nicematrix_pred:n #1 { \the \numexpr #1 - 1 \relax } \bool_new:N \c__nicematrix_siunitx_loaded_bool \AtBeginDocument { @@ -202,8 +165,60 @@ \NC@find } } -\cs_new:Npn \__nicematrix_succ:n #1 { \the \numexpr #1 + 1 \relax } -\cs_new:Npn \__nicematrix_pred:n #1 { \the \numexpr #1 - 1 \relax } +\int_new:N \g__nicematrix_env_int +\cs_new:Npn \__nicematrix_env: { nm - \int_use:N \g__nicematrix_env_int } +\cs_new_protected:Npn \__nicematrix_qpoint:n #1 + { \pgfpointanchor { \__nicematrix_env: - #1 } { center } } +\int_new:N \g__nicematrix_NiceMatrixBlock_int +\dim_new:N \l__nicematrix_columns_width_dim +\seq_new:N \g__nicematrix_names_seq +\bool_new:N \l__nicematrix_in_env_bool +\bool_new:N \l__nicematrix_NiceArray_bool +\bool_new:N \l__nicematrix_NiceTabular_bool +\cs_new_protected:Npn \__nicematrix_test_if_math_mode: + { + \if_mode_math: \else: + \__nicematrix_fatal:n { Outside~math~mode } + \fi: + } +\colorlet { nicematrix-last-col } { . } +\colorlet { nicematrix-last-row } { . } +\str_new:N \g__nicematrix_name_env_str +\str_new:N \g__nicematrix_com_or_env_str +\str_set:Nn \g__nicematrix_com_or_env_str { environment } +\cs_new:Npn \__nicematrix_full_name_env: + { + \str_if_eq:VnTF \g__nicematrix_com_or_env_str { command } + { command \space \c_backslash_str \g__nicematrix_name_env_str } + { environment \space \{ \g__nicematrix_name_env_str \} } + } +\tl_new:N \g__nicematrix_code_after_tl +\tl_new:N \g__nicematrix_internal_code_after_tl +\int_new:N \l__nicematrix_old_iRow_int +\int_new:N \l__nicematrix_old_jCol_int +\bool_new:N \g__nicematrix_row_of_col_done_bool +\bool_new:N \l__nicematrix_code_before_bool +\dim_new:N \l__nicematrix_x_initial_dim +\dim_new:N \l__nicematrix_y_initial_dim +\dim_new:N \l__nicematrix_x_final_dim +\dim_new:N \l__nicematrix_y_final_dim +\dim_zero_new:N \l_tmpc_dim +\dim_zero_new:N \l_tmpd_dim +\bool_new:N \g__nicematrix_empty_cell_bool +\dim_new:N \__nicematrix_old_arraycolsep_dim +\dim_new:N \g__nicematrix_width_last_col_dim +\dim_new:N \g__nicematrix_width_first_col_dim +\int_new:N \l__nicematrix_first_row_int +\int_set:Nn \l__nicematrix_first_row_int 1 +\int_new:N \l__nicematrix_first_col_int +\int_set:Nn \l__nicematrix_first_col_int 1 +\int_new:N \l__nicematrix_last_row_int +\int_set:Nn \l__nicematrix_last_row_int { -2 } +\bool_new:N \l__nicematrix_last_row_without_value_bool +\bool_new:N \l__nicematrix_last_col_without_value_bool +\int_new:N \l__nicematrix_last_col_int +\int_set:Nn \l__nicematrix_last_col_int { -2 } +\bool_new:N \g__nicematrix_last_col_found_bool \cs_new_protected:Npn \__nicematrix_pgf_rect_node:nnnnn #1 #2 #3 #4 #5 { \begin { pgfscope } @@ -253,6 +268,17 @@ { } \end { pgfscope } } +\dim_new:N \l__nicematrix_cell_space_top_limit_dim +\dim_new:N \l__nicematrix_cell_space_bottom_limit_dim +\dim_new:N \l__nicematrix_inter_dots_dim +\dim_set:Nn \l__nicematrix_inter_dots_dim { 0.45 em } +\dim_new:N \l__nicematrix_xdots_shorten_dim +\dim_set:Nn \l__nicematrix_xdots_shorten_dim { 0.3 em } +\dim_new:N \l__nicematrix_radius_dim +\dim_set:Nn \l__nicematrix_radius_dim { 0.53 pt } +\tl_new:N \l__nicematrix_xdots_line_style_tl +\tl_const:Nn \c__nicematrix_standard_tl { standard } +\tl_set_eq:NN \l__nicematrix_xdots_line_style_tl \c__nicematrix_standard_tl \bool_new:N \l__nicematrix_light_syntax_bool \str_new:N \l__nicematrix_baseline_str \str_set:Nn \l__nicematrix_baseline_str c @@ -268,8 +294,6 @@ \bool_new:N \l__nicematrix_large_nodes_bool \dim_new:N \l__nicematrix_left_margin_dim \dim_new:N \l__nicematrix_right_margin_dim -\dim_new:N \g__nicematrix_width_last_col_dim -\dim_new:N \g__nicematrix_width_first_col_dim \dim_new:N \l__nicematrix_extra_left_margin_dim \dim_new:N \l__nicematrix_extra_right_margin_dim \tl_new:N \l__nicematrix_end_of_row_tl @@ -297,12 +321,20 @@ } \keys_define:nn { NiceMatrix / Global } { + cell-space-top-limit .dim_set:N = \l__nicematrix_cell_space_top_limit_dim , + cell-space-top-limit .value_required:n = true , + cell-space-bottom-limit .dim_set:N = \l__nicematrix_cell_space_bottom_limit_dim , + cell-space-bottom-limit .value_required:n = true , xdots .code:n = \keys_set:nn { NiceMatrix / xdots } { #1 } , max-delimiter-width .bool_set:N = \l__nicematrix_max_delimiter_width_bool , light-syntax .bool_set:N = \l__nicematrix_light_syntax_bool , light-syntax .default:n = true , end-of-row .tl_set:N = \l__nicematrix_end_of_row_tl , end-of-row .value_required:n = true , + first-col .code:n = \int_zero:N \l__nicematrix_first_col_int , + first-row .code:n = \int_zero:N \l__nicematrix_first_row_int , + last-row .int_set:N = \l__nicematrix_last_row_int , + last-row .default:n = -1 , code-for-first-col .tl_set:N = \l__nicematrix_code_for_first_col_tl , code-for-first-col .value_required:n = true , code-for-last-col .tl_set:N = \l__nicematrix_code_for_last_col_tl , @@ -311,7 +343,6 @@ code-for-first-row .value_required:n = true , code-for-last-row .tl_set:N = \l__nicematrix_code_for_last_row_tl , code-for-last-row .value_required:n = true , - small .bool_set:N = \l__nicematrix_small_bool , hlines .bool_set:N = \l__nicematrix_hlines_bool , vlines .bool_set:N = \l__nicematrix_vlines_bool , hvlines .meta:n = { hlines , vlines } , @@ -337,6 +368,14 @@ } \keys_define:nn { NiceMatrix / Env } { + code-before .code:n = + { + \tl_if_empty:nF { #1 } + { + \tl_set:Nn \l__nicematrix_code_before_tl { #1 } + \bool_set_true:N \l__nicematrix_code_before_bool + } + } , c .code:n = \str_set:Nn \l__nicematrix_baseline_str c , t .code:n = \str_set:Nn \l__nicematrix_baseline_str t , b .code:n = \str_set:Nn \l__nicematrix_baseline_str b , @@ -359,10 +398,6 @@ name .value_required:n = true , code-after .tl_gset:N = \g__nicematrix_code_after_tl , code-after .value_required:n = true , - first-col .code:n = \int_zero:N \l__nicematrix_first_col_int , - first-row .code:n = \int_zero:N \l__nicematrix_first_row_int , - last-row .int_set:N = \l__nicematrix_last_row_int , - last-row .default:n = -1 , } \keys_define:nn { NiceMatrix } { @@ -377,6 +412,12 @@ NiceMatrix / Env , } , NiceMatrix / xdots .inherit:n = NiceMatrix / xdots , + NiceTabular .inherit:n = + { + NiceMatrix / Global , + NiceMatrix / Env + } , + NiceTabular / xdots .inherit:n = NiceMatrix / xdots , NiceArray .inherit:n = { NiceMatrix / Global , @@ -392,6 +433,11 @@ } \keys_define:nn { NiceMatrix / NiceMatrixOptions } { + last-col .code:n = \tl_if_empty:nF { #1 } + { \__nicematrix_error:n { last-col~non~empty~for~NiceMatrixOptions } } + \int_zero:N \l__nicematrix_last_col_int , + small .bool_set:N = \l__nicematrix_small_bool , + small .value_forbidden:n = true , renew-matrix .code:n = \__nicematrix_renew_matrix: , renew-matrix .value_forbidden:n = true , transparent .meta:n = { renew-dots , renew-matrix } , @@ -429,10 +475,17 @@ r .code:n = \tl_set:Nn \l__nicematrix_type_of_col_tl R , L .code:n = \tl_set:Nn \l__nicematrix_type_of_col_tl L , R .code:n = \tl_set:Nn \l__nicematrix_type_of_col_tl R , + S .code:n = \bool_if:NTF \c__nicematrix_siunitx_loaded_bool + { \tl_set:Nn \l__nicematrix_type_of_col_tl S } + { \__nicematrix_error:n { option~S~without~siunitx } } , + small .bool_set:N = \l__nicematrix_small_bool , + small .value_forbidden:n = true , unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceMatrix } } \keys_define:nn { NiceMatrix / NiceArray } { + small .bool_set:N = \l__nicematrix_small_bool , + small .value_forbidden:n = true , last-col .code:n = \tl_if_empty:nF { #1 } { \__nicematrix_error:n { last-col~non~empty~for~NiceArray } } \int_zero:N \l__nicematrix_last_col_int , @@ -445,10 +498,14 @@ { \__nicematrix_error:n { last-col~non~empty~for~NiceArray } } \int_zero:N \l__nicematrix_last_col_int , first-row .code:n = \int_zero:N \l__nicematrix_first_row_int , - last-row .int_set:N = \l__nicematrix_last_row_int , - last-row .default:n = -1 , + small .bool_set:N = \l__nicematrix_small_bool , + small .value_forbidden:n = true , unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceMatrix } } +\keys_define:nn { NiceMatrix / NiceTabular } + { + unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceTabular } + } \cs_new_protected:Npn \__nicematrix_Cell: { \int_gincr:N \c@jCol @@ -456,8 +513,11 @@ { \int_compare:nNnT \l__nicematrix_first_col_int = 1 \__nicematrix_begin_of_row: } \int_gset:Nn \g__nicematrix_col_total_int { \int_max:nn \g__nicematrix_col_total_int \c@jCol } \hbox_set:Nw \l__nicematrix_cell_box - \c_math_toggle_token - \bool_if:NT \l__nicematrix_small_bool \scriptstyle + \bool_if:NF \l__nicematrix_NiceTabular_bool + { + \c_math_toggle_token + \bool_if:NT \l__nicematrix_small_bool \scriptstyle + } \int_compare:nNnTF \c@iRow = 0 { \int_compare:nNnT \c@jCol > 0 @@ -484,12 +544,12 @@ \pgfrememberpicturepositiononpagetrue \pgfcoordinate { \__nicematrix_env: - row - \int_use:N \c@iRow - base } - \pgfpointorigin + { \pgfpoint \c_zero_dim { 0.5 \arrayrulewidth } } \str_if_empty:NF \l__nicematrix_name_str { \pgfnodealias - { \__nicematrix_env: - row - \int_use:N \c@iRow - base } { \l__nicematrix_name_str - row - \int_use:N \c@iRow - base } + { \__nicematrix_env: - row - \int_use:N \c@iRow - base } } \endpgfpicture } @@ -512,16 +572,17 @@ } \cs_new_protected:Npn \__nicematrix_end_Cell: { - \c_math_toggle_token + \bool_if:NF \l__nicematrix_NiceTabular_bool \c_math_toggle_token \hbox_set_end: + \box_set_ht:Nn \l__nicematrix_cell_box + { \box_ht:N \l__nicematrix_cell_box + \l__nicematrix_cell_space_top_limit_dim } + \box_set_dp:Nn \l__nicematrix_cell_box + { \box_dp:N \l__nicematrix_cell_box + \l__nicematrix_cell_space_bottom_limit_dim } \dim_gset:Nn \g__nicematrix_max_cell_width_dim { \dim_max:nn \g__nicematrix_max_cell_width_dim { \box_wd:N \l__nicematrix_cell_box } } \__nicematrix_update_for_first_and_last_row: \bool_if:NTF \g__nicematrix_empty_cell_bool - { - \box_use_drop:N \l__nicematrix_cell_box - \bool_gset_false:N \g__nicematrix_empty_cell_bool - } + { \box_use_drop:N \l__nicematrix_cell_box } { \dim_compare:nNnTF { \box_wd:N \l__nicematrix_cell_box } > \c_zero_dim \__nicematrix_node_for_the_cell: @@ -553,19 +614,15 @@ } \endpgfpicture } -\bool_if:NTF \c__nicematrix_draft_bool - { \cs_set_protected:Npn \__nicematrix_instruction_of_type:nn #1 #2 { } } +\cs_new_protected:Npn \__nicematrix_instruction_of_type:nn #1 #2 { - \cs_new_protected:Npn \__nicematrix_instruction_of_type:nn #1 #2 + \tl_gput_right:cx + { g__nicematrix_ #1 _ lines _ tl } { - \tl_gput_right:cx - { g__nicematrix_ #1 _ lines _ tl } - { - \use:c { __nicematrix _ draw _ #1 : nnn } - { \int_use:N \c@iRow } - { \int_use:N \c@jCol } - { \exp_not:n { #2 } } - } + \use:c { __nicematrix _ draw _ #1 : nnn } + { \int_use:N \c@iRow } + { \int_use:N \c@jCol } + { \exp_not:n { #2 } } } } \cs_new_protected:Npn \__nicematrix_array: @@ -581,49 +638,82 @@ \array [ \str_if_eq:VnTF \l__nicematrix_baseline_str c c t ] } -\cs_set_eq:NN \__nicematrix_standard_ialign: \ialign -\cs_new:Npn \__nicematrix_everycr: { \noalign { \__nicematrix_everycr_i: } } -\cs_new_protected:Npn \__nicematrix_everycr_i: +\cs_set_eq:NN \__nicematrix_old_ialign: \ialign +\cs_new_protected:Npn \__nicematrix_create_row_node: { - \int_gzero:N \c@jCol \hbox { + \bool_if:NT \l__nicematrix_code_before_bool + { + \vtop + { + \skip_vertical:N 0.5\arrayrulewidth + \pgfsys@markposition { \__nicematrix_env: - row - \__nicematrix_succ:n \c@iRow } + \skip_vertical:N -0.5\arrayrulewidth + } + } \pgfpicture \pgfrememberpicturepositiononpagetrue \pgfcoordinate { \__nicematrix_env: - row - \__nicematrix_succ:n \c@iRow } - \pgfpointorigin + { \pgfpoint \c_zero_dim { - 0.5 \arrayrulewidth } } \str_if_empty:NF \l__nicematrix_name_str { \pgfnodealias - { \__nicematrix_env: - row - \int_use:N \c@iRow - row } - { \l__nicematrix_name_str - row - \int_use:N \c@iRow - row } + { \l__nicematrix_name_str - row - \int_use:N \c@iRow } + { \__nicematrix_env: - row - \int_use:N \c@iRow } } \endpgfpicture } - \bool_if:NT \l__nicematrix_hlines_bool + } +\cs_new:Npn \__nicematrix_everycr: { \noalign { \__nicematrix_everycr_i: } } +\cs_new_protected:Npn \__nicematrix_everycr_i: + { + \int_gzero:N \c@jCol + \bool_if:NF \g__nicematrix_row_of_col_done_bool { - \int_compare:nNnT \c@iRow > { -1 } + \__nicematrix_create_row_node: + \bool_if:NT \l__nicematrix_hlines_bool { - \bool_if:NF \g__nicematrix_row_of_col_done_bool + \int_compare:nNnT \c@iRow > { -1 } { \int_compare:nNnF \c@iRow = \l__nicematrix_last_row_int - { - \bool_if:NTF \c__nicematrix_colortbl_loaded_bool - { { \CT@arc@ \hrule height \arrayrulewidth } } - { \hrule height \arrayrulewidth } - } + { { \CT@arc@ \hrule height \arrayrulewidth } } } } } } +\cs_set_protected:Npn \__nicematrix_newcolumntype #1 + { + \cs_if_free:cT { NC @ find @ #1 } + { \NC@list \expandafter { \the \NC@list \NC@do #1 } } + \cs_set:cpn {NC @ find @ #1 } ##1 #1 { \NC@ { ##1 } } + \peek_meaning:NTF [ + { \newcol@ #1 } + { \newcol@ #1 [ 0 ] } + } +\cs_new_protected:Npn \__nicematrix_define_columntype:nn #1 #2 + { + \__nicematrix_newcolumntype #1 [ 1 ] + { + > { + \__nicematrix_Cell: + \begin { minipage } [ #2 ] { ##1 } + \mode_leave_vertical: \box_use:N \@arstrutbox + } + c + < { \box_use:N \@arstrutbox \end { minipage } \__nicematrix_end_Cell: } + } + } \cs_new_protected:Npn \__nicematrix_pre_array: { + \bool_if:NT \c__nicematrix_booktabs_loaded_bool + { \tl_put_left:Nn \@BTnormal \__nicematrix_create_row_node: } \box_clear_new:N \l__nicematrix_cell_box \cs_if_exist:NT \theiRow - { \int_set_eq:NN \l__nicematrix_save_iRow_int \c@iRow } + { \int_set_eq:NN \l__nicematrix_old_iRow_int \c@iRow } \int_gzero_new:N \c@iRow \cs_if_exist:NT \thejCol - { \int_set_eq:NN \l__nicematrix_save_jCol_int \c@jCol } + { \int_set_eq:NN \l__nicematrix_old_jCol_int \c@jCol } \int_gzero_new:N \c@jCol \normalbaselines \bool_if:NT \l__nicematrix_small_bool @@ -633,6 +723,8 @@ } \cs_set:Npn \ialign { + \bool_if:NT \l__nicematrix_NiceTabular_bool + { \dim_set_eq:NN \arraycolsep \__nicematrix_old_arraycolsep_dim } \bool_if:NTF \c__nicematrix_colortbl_loaded_bool { \CT@everycr @@ -654,17 +746,14 @@ \dim_gset:Nn \g__nicematrix_ht_last_row_dim { \box_ht:N \@arstrutbox } \dim_gzero_new:N \g__nicematrix_dp_last_row_dim \dim_gset:Nn \g__nicematrix_dp_last_row_dim { \box_dp:N \@arstrutbox } - \cs_set_eq:NN \ialign \__nicematrix_standard_ialign: + \cs_set_eq:NN \ialign \__nicematrix_old_ialign: \halign } - \newcolumntype L { > \__nicematrix_Cell: l < \__nicematrix_end_Cell: } - \newcolumntype C { > \__nicematrix_Cell: c < \__nicematrix_end_Cell: } - \newcolumntype R { > \__nicematrix_Cell: r < \__nicematrix_end_Cell: } - \cs_set_eq:NN \__nicematrix_ldots \ldots - \cs_set_eq:NN \__nicematrix_cdots \cdots - \cs_set_eq:NN \__nicematrix_vdots \vdots - \cs_set_eq:NN \__nicematrix_ddots \ddots - \cs_set_eq:NN \__nicematrix_iddots \iddots + \cs_set_eq:NN \__nicematrix_old_ldots \ldots + \cs_set_eq:NN \__nicematrix_old_cdots \cdots + \cs_set_eq:NN \__nicematrix_old_vdots \vdots + \cs_set_eq:NN \__nicematrix_old_ddots \ddots + \cs_set_eq:NN \__nicematrix_old_iddots \iddots \cs_set_eq:NN \firsthline \hline \cs_set_eq:NN \lasthline \hline \cs_set_eq:NN \Ldots \__nicematrix_Ldots @@ -675,11 +764,14 @@ \cs_set_eq:NN \hdottedline \__nicematrix_hdottedline: \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 + \cs_set_eq:NN \dotfill \__nicematrix_dotfill: \cs_set_eq:NN \CodeAfter \__nicematrix_CodeAfter:n + \cs_set_eq:NN \slashbox \__nicematrix_slashbox:nn \bool_if:NT \l__nicematrix_renew_dots_bool { \cs_set_eq:NN \ldots \__nicematrix_Ldots @@ -696,9 +788,13 @@ \int_gzero_new:N \g__nicematrix_row_total_int \int_gzero_new:N \g__nicematrix_col_total_int \cs_set_eq:NN \@ifnextchar \new@ifnextchar - \cs_set_eq:NN \NC@find@w \relax - \cs_set_eq:NN \NC@find@W \relax - \newcolumntype w [ 2 ] + \__nicematrix_newcolumntype L { > \__nicematrix_Cell: l < \__nicematrix_end_Cell: } + \__nicematrix_newcolumntype C { > \__nicematrix_Cell: c < \__nicematrix_end_Cell: } + \__nicematrix_newcolumntype R { > \__nicematrix_Cell: r < \__nicematrix_end_Cell: } + \__nicematrix_define_columntype:nn p t + \__nicematrix_define_columntype:nn m c + \__nicematrix_define_columntype:nn b b + \__nicematrix_newcolumntype w [ 2 ] { > { \hbox_set:Nw \l__nicematrix_cell_box @@ -712,7 +808,7 @@ { \box_use_drop:N \l__nicematrix_cell_box } } } - \newcolumntype W [ 2 ] + \__nicematrix_newcolumntype W [ 2 ] { > { \hbox_set:Nw \l__nicematrix_cell_box @@ -755,7 +851,7 @@ \tl_gclear_new:N \g__nicematrix_Vdots_lines_tl \tl_gclear_new:N \g__nicematrix_Ddots_lines_tl \tl_gclear_new:N \g__nicematrix_Iddots_lines_tl - \tl_gclear_new:N \g__nicematrix_Hdotsfor_lines_tl + \tl_gclear_new:N \g__nicematrix_HVdotsfor_lines_tl } \NewDocumentEnvironment { NiceArrayWithDelims } { m m O { } m ! O { } } { @@ -765,7 +861,9 @@ \str_if_empty:NT \g__nicematrix_name_env_str { \str_gset:Nn \g__nicematrix_name_env_str { NiceArrayWithDelims } } \__nicematrix_adapt_S_column: - \__nicematrix_test_if_math_mode: + \bool_if:NTF \l__nicematrix_NiceTabular_bool + \mode_leave_vertical: + \__nicematrix_test_if_math_mode: \bool_if:NT \l__nicematrix_in_env_bool { \__nicematrix_fatal:n { Yet~in~env } } \bool_set_true:N \l__nicematrix_in_env_bool \cs_if_exist:NT \tikz@library@external@loaded @@ -782,6 +880,61 @@ { \keys_set:nn { NiceMatrix / NiceArray } } { \keys_set:nn { NiceMatrix / pNiceArray } } { #3 , #5 } + \bool_if:NT \l__nicematrix_code_before_bool + { + \seq_if_exist:cT { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } + { + \int_zero_new:N \c@iRow + \int_set:Nn \c@iRow + { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 2 } + \int_zero_new:N \c@jCol + \int_set:Nn \c@jCol + { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 4 } + \int_compare:nNnF \l__nicematrix_last_row_int = { -2 } + { \int_decr:N \c@iRow } + \int_compare:nNnF \l__nicematrix_last_col_int = { -2 } + { \int_decr:N \c@jCol } + \pgfsys@markposition { \__nicematrix_env: - position } + \pgfsys@getposition { \__nicematrix_env: - position } \__nicematrix_picture_position: + \pgfpicture + \int_step_inline:nnn + { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 1 } + { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 2 + 1 } + { + \pgfsys@getposition { \__nicematrix_env: - row - ##1 } \__nicematrix_node_position: + \pgfcoordinate { \__nicematrix_env: - row - ##1 } + { \pgfpointdiff \__nicematrix_picture_position: \__nicematrix_node_position: } + } + \int_step_inline:nnn + { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 3 } + { \seq_item:cn { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } 4 + 1 } + { + \pgfsys@getposition { \__nicematrix_env: - col - ##1 } \__nicematrix_node_position: + \pgfcoordinate { \__nicematrix_env: - col - ##1 } + { \pgfpointdiff \__nicematrix_picture_position: \__nicematrix_node_position: } + } + \endpgfpicture + \group_begin: + \bool_if:NT \c__nicematrix_tikz_loaded_bool + { + \pgfset + { + every~picture / .style = + { overlay , name~prefix = \__nicematrix_env: - } + } + } + \cs_set_eq:NN \cellcolor \__nicematrix_cellcolor:nn + \cs_set_eq:NN \rectanglecolor \__nicematrix_rectanglecolor:nnn + \cs_set_eq:NN \rowcolor \__nicematrix_rowcolor:nn + \cs_set_eq:NN \rowcolors \__nicematrix_rowcolors:nnn + \cs_set_eq:NN \columncolor \__nicematrix_columncolor:nn + \cs_set_eq:NN \chessboardcolors \__nicematrix_chessboardcolors:nn + \bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token + \l__nicematrix_code_before_tl + \bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token + \group_end: + } + } \int_compare:nNnT \l__nicematrix_last_row_int > { -2 } { \tl_put_right:Nn \__nicematrix_update_for_first_and_last_row: @@ -851,6 +1004,7 @@ \bool_lazy_all:nT { \l__nicematrix_NiceArray_bool + { \bool_not_p:n \l__nicematrix_NiceTabular_bool } { \bool_not_p:n \l__nicematrix_vlines_bool } { \bool_not_p:n \l__nicematrix_exterior_arraycolsep_bool } } @@ -862,6 +1016,7 @@ \bool_lazy_all:nT { \l__nicematrix_NiceArray_bool + { \bool_not_p:n \l__nicematrix_NiceTabular_bool } { \bool_not_p:n \l__nicematrix_vlines_bool } { \bool_not_p:n \l__nicematrix_exterior_arraycolsep_bool } } @@ -869,6 +1024,11 @@ } \tl_put_right:Nn \l_tmpa_tl { > { \__nicematrix_error_too_much_cols: } L } \hbox_set:Nw \l__nicematrix_the_array_box + \bool_if:NT \l__nicematrix_NiceTabular_bool + { + \dim_set_eq:NN \__nicematrix_old_arraycolsep_dim \arraycolsep + \dim_set_eq:NN \arraycolsep \tabcolsep + } \bool_if:NT \l__nicematrix_vlines_bool { \dim_add:Nn \arraycolsep { 0.5 \arrayrulewidth } @@ -878,13 +1038,13 @@ \skip_horizontal:N \l__nicematrix_extra_left_margin_dim \c_math_toggle_token \bool_if:NTF \l__nicematrix_light_syntax_bool - { \begin { __nicematrix-light-syntax } } - { \begin { __nicematrix-normal-syntax } } + { \use:c { __nicematrix-light-syntax } } + { \use:c { __nicematrix-normal-syntax } } } { \bool_if:NTF \l__nicematrix_light_syntax_bool - { \end { __nicematrix-light-syntax } } - { \end { __nicematrix-normal-syntax } } + { \use:c { end __nicematrix-light-syntax } } + { \use:c { end __nicematrix-normal-syntax } } \c_math_toggle_token \skip_horizontal:N \l__nicematrix_right_margin_dim \skip_horizontal:N \l__nicematrix_extra_right_margin_dim @@ -915,9 +1075,9 @@ \str_if_eq:VnTF \l__nicematrix_baseline_str { b } { \pgfpicture - \__nicematrix_qpoint: { row - 1 } + \__nicematrix_qpoint:n { row - 1 } \dim_gset_eq:NN \g_tmpa_dim \pgf@y - \__nicematrix_qpoint: { row - \int_use:N \c@iRow - base } + \__nicematrix_qpoint:n { row - \int_use:N \c@iRow - base } \dim_gsub:Nn \g_tmpa_dim \pgf@y \endpgfpicture \int_compare:nNnT \l__nicematrix_first_row_int = 0 @@ -944,9 +1104,9 @@ \int_set:Nn \l_tmpa_int 1 } \pgfpicture - \__nicematrix_qpoint: { row - 1 } + \__nicematrix_qpoint:n { row - 1 } \dim_gset_eq:NN \g_tmpa_dim \pgf@y - \__nicematrix_qpoint: { row - \int_use:N \l_tmpa_int - base } + \__nicematrix_qpoint:n { row - \int_use:N \l_tmpa_int - base } \dim_gsub:Nn \g_tmpa_dim \pgf@y \endpgfpicture \int_compare:nNnT \l__nicematrix_first_row_int = 0 @@ -981,9 +1141,13 @@ \skip_vertical:N -\l_tmpa_dim \hbox { - \skip_horizontal:N -\arraycolsep + \bool_if:NTF \l__nicematrix_NiceTabular_bool + { \skip_horizontal:N -\tabcolsep } + { \skip_horizontal:N -\arraycolsep } \box_use_drop:N \l__nicematrix_the_array_box - \skip_horizontal:N -\arraycolsep + \bool_if:NTF \l__nicematrix_NiceTabular_bool + { \skip_horizontal:N -\tabcolsep } + { \skip_horizontal:N -\arraycolsep } } \skip_vertical:N -\l_tmpb_dim } @@ -1027,12 +1191,12 @@ \int_set:Nn \l_tmpa_int 1 } \pgfpicture - \__nicematrix_qpoint: { row - 1 } + \__nicematrix_qpoint:n { row - 1 } \dim_gset_eq:NN \g_tmpa_dim \pgf@y - \__nicematrix_qpoint: { row - \__nicematrix_succ:n \c@iRow } + \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \c@iRow } \dim_gadd:Nn \g_tmpa_dim \pgf@y \dim_gset:Nn \g_tmpa_dim { 0.5 \g_tmpa_dim } - \__nicematrix_qpoint: { row - \int_use:N \l_tmpa_int - base } + \__nicematrix_qpoint:n { row - \int_use:N \l_tmpa_int - base } \dim_gsub:Nn \g_tmpa_dim \pgf@y \dim_gsub:Nn \g_tmpa_dim { \fontdimen22 \textfont2 } \endpgfpicture @@ -1096,6 +1260,12 @@ \tl_if_eq:nnT { ##1 } { \\ } { \__nicematrix_fatal:n { double-backslash~in~light-syntax } } } + \__nicematrix_light_syntax_i #1 \CodeAfter \q_stop + } + { } +\cs_new_protected:Npn \__nicematrix_light_syntax_i #1\CodeAfter #2\q_stop + { + \tl_gput_right:Nn \g__nicematrix_code_after_tl { #2 } \seq_gclear_new:N \g__nicematrix_rows_seq \tl_set_rescan:Nno \l__nicematrix_end_of_row_tl { } \l__nicematrix_end_of_row_tl \exp_args:NNV \seq_gset_split:Nnn \g__nicematrix_rows_seq \l__nicematrix_end_of_row_tl { #1 } @@ -1108,21 +1278,16 @@ \__nicematrix_create_col_nodes: \endarray } - { } +\cs_new_protected:Npn \__nicematrix_line_with_light_syntax:n #1 + { \tl_if_empty:nF { #1 } { \\ \__nicematrix_line_with_light_syntax_i:n { #1 } } } \cs_new_protected:Npn \__nicematrix_line_with_light_syntax_i:n #1 { \seq_gclear_new:N \g__nicematrix_cells_seq \seq_gset_split:Nnn \g__nicematrix_cells_seq { ~ } { #1 } \seq_gpop_left:NN \g__nicematrix_cells_seq \l_tmpa_tl \l_tmpa_tl - \seq_map_function:NN \g__nicematrix_cells_seq \__nicematrix_cell_with_light_syntax:n - } -\cs_new_protected:Npn \__nicematrix_line_with_light_syntax:n #1 - { - \tl_if_empty:nF { #1 } - { \\ \__nicematrix_line_with_light_syntax_i:n { #1 } } + \seq_map_inline:Nn \g__nicematrix_cells_seq { & ##1 } } -\cs_new_protected:Npn \__nicematrix_cell_with_light_syntax:n #1 { & #1 } \cs_new_protected:Npn \__nicematrix_analyze_end:Nn #1 #2 { \str_if_eq:VnT \g__nicematrix_name_env_str { #2 } @@ -1136,23 +1301,56 @@ \int_compare:nNnT \l__nicematrix_first_col_int = 0 { \omit - \skip_horizontal:N -2\arraycolsep + \skip_horizontal:N -2\col@sep + \bool_if:NT \l__nicematrix_code_before_bool + { \pgfsys@markposition { \__nicematrix_env: - col - 0 } } \pgfpicture \pgfrememberpicturepositiononpagetrue \pgfcoordinate { \__nicematrix_env: - col - 0 } \pgfpointorigin \str_if_empty:NF \l__nicematrix_name_str - { \pgfnodealias { \__nicematrix_env: - col - 0 } { \l__nicematrix_name_str - col - 0 } } + { \pgfnodealias { \l__nicematrix_name_str - col - 0 } { \__nicematrix_env: - col - 0 } } \endpgfpicture & } \omit \bool_gset_true:N \g__nicematrix_row_of_col_done_bool - \pgfpicture - \pgfrememberpicturepositiononpagetrue - \pgfcoordinate { \__nicematrix_env: - col - 1 } \pgfpointorigin - \str_if_empty:NF \l__nicematrix_name_str - { \pgfnodealias { \__nicematrix_env: - col - 1 } { \l__nicematrix_name_str - col - 1 } } - \endpgfpicture + \int_compare:nNnTF \l__nicematrix_first_col_int = 0 + { + \bool_if:NT \l__nicematrix_code_before_bool + { + \hbox + { + \skip_horizontal:N -0.5\arrayrulewidth + \pgfsys@markposition { \__nicematrix_env: - col - 1 } + \skip_horizontal:N 0.5\arrayrulewidth + } + } + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgfcoordinate { \__nicematrix_env: - col - 1 } + { \pgfpoint { - 0.5 \arrayrulewidth } \c_zero_dim } + \str_if_empty:NF \l__nicematrix_name_str + { \pgfnodealias { \l__nicematrix_name_str - col - 1 } { \__nicematrix_env: - col - 1 } } + \endpgfpicture + } + { + \bool_if:NT \l__nicematrix_code_before_bool + { + \hbox + { + \skip_horizontal:N 0.5 \arrayrulewidth + \pgfsys@markposition { \__nicematrix_env: - col - 1 } + \skip_horizontal:N -0.5\arrayrulewidth + } + } + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgfcoordinate { \__nicematrix_env: - col - 1 } + { \pgfpoint { 0.5 \arrayrulewidth } \c_zero_dim } + \str_if_empty:NF \l__nicematrix_name_str + { \pgfnodealias { \l__nicematrix_name_str - col - 1 } { \__nicematrix_env: - col - 1 } } + \endpgfpicture + } \skip_gset:Nn \g_tmpa_skip { 0 pt~plus 1 fill } \bool_if:NF \l__nicematrix_auto_columns_width_bool { \dim_compare:nNnT \l__nicematrix_columns_width_dim > \c_zero_dim } @@ -1162,16 +1360,26 @@ { \bool_not_p:n \l__nicematrix_block_auto_columns_width_bool } { \skip_gset_eq:NN \g_tmpa_skip \g__nicematrix_max_cell_width_dim } { \skip_gset_eq:NN \g_tmpa_skip \l__nicematrix_columns_width_dim } - \skip_gadd:Nn \g_tmpa_skip { 2 \arraycolsep } + \skip_gadd:Nn \g_tmpa_skip { 2 \col@sep } } \skip_horizontal:N \g_tmpa_skip \hbox { + \bool_if:NT \l__nicematrix_code_before_bool + { + \hbox + { + \skip_horizontal:N -0.5\arrayrulewidth + \pgfsys@markposition { \__nicematrix_env: - col - 2 } + \skip_horizontal:N 0.5\arrayrulewidth + } + } \pgfpicture \pgfrememberpicturepositiononpagetrue - \pgfcoordinate { \__nicematrix_env: - col - 2 } \pgfpointorigin + \pgfcoordinate { \__nicematrix_env: - col - 2 } + { \pgfpoint { - 0.5 \arrayrulewidth } \c_zero_dim } \str_if_empty:NF \l__nicematrix_name_str - { \pgfnodealias { \__nicematrix_env: - col - 2 } { \l__nicematrix_name_str - col - 2 } } + { \pgfnodealias { \l__nicematrix_name_str - col - 2 } { \__nicematrix_env: - col - 2 } } \endpgfpicture } \int_gset:Nn \g_tmpa_int 1 @@ -1179,25 +1387,38 @@ { \prg_replicate:nn { \g__nicematrix_col_total_int - 2 } } { \prg_replicate:nn { \g__nicematrix_col_total_int - 1 } } { - & - \omit - \int_gincr:N \g_tmpa_int - \skip_horizontal:N \g_tmpa_skip - \pgfpicture - \pgfrememberpicturepositiononpagetrue - \pgfcoordinate { \__nicematrix_env: - col - \__nicematrix_succ:n \g_tmpa_int } - \pgfpointorigin - \str_if_empty:NF \l__nicematrix_name_str - { - \pgfnodealias - { \__nicematrix_env: - col - \__nicematrix_succ:n \g_tmpa_int } - { \l__nicematrix_name_str - col - \__nicematrix_succ:n \g_tmpa_int } - } - \endpgfpicture + & + \omit + \int_gincr:N \g_tmpa_int + \skip_horizontal:N \g_tmpa_skip + \bool_if:NT \l__nicematrix_code_before_bool + { + \hbox + { + \skip_horizontal:N -0.5\arrayrulewidth + \pgfsys@markposition { \__nicematrix_env: - col - \__nicematrix_succ:n \g_tmpa_int } + \skip_horizontal:N 0.5\arrayrulewidth + } + } + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgfcoordinate { \__nicematrix_env: - col - \__nicematrix_succ:n \g_tmpa_int } + { \pgfpoint { - 0.5 \arrayrulewidth } \c_zero_dim } + \str_if_empty:NF \l__nicematrix_name_str + { + \pgfnodealias + { \l__nicematrix_name_str - col - \__nicematrix_succ:n \g_tmpa_int } + { \__nicematrix_env: - col - \__nicematrix_succ:n \g_tmpa_int } + } + \endpgfpicture } \bool_if:NT \g__nicematrix_last_col_found_bool { - \skip_horizontal:N 2\arraycolsep + \bool_if:NT \l__nicematrix_code_before_bool + { + \pgfsys@markposition { \__nicematrix_env: - col - \__nicematrix_succ:n \g__nicematrix_col_total_int } + } + \skip_horizontal:N 2\col@sep \pgfpicture \pgfrememberpicturepositiononpagetrue \pgfcoordinate { \__nicematrix_env: - col - \__nicematrix_succ:n \g__nicematrix_col_total_int } @@ -1205,11 +1426,11 @@ \str_if_empty:NF \l__nicematrix_name_str { \pgfnodealias - { \__nicematrix_env: - col - \__nicematrix_succ:n \g__nicematrix_col_total_int } { \l__nicematrix_name_str - col - \__nicematrix_succ:n \g__nicematrix_col_total_int } + { \__nicematrix_env: - col - \__nicematrix_succ:n \g__nicematrix_col_total_int } } \endpgfpicture - \skip_horizontal:N -2\arraycolsep + \skip_horizontal:N -2\col@sep } \cr } @@ -1219,7 +1440,7 @@ { \__nicematrix_begin_of_row: \hbox_set:Nw \l__nicematrix_cell_box - \c_math_toggle_token + \bool_if:NF \l__nicematrix_NiceTabular_bool \c_math_toggle_token \bool_if:NT \l__nicematrix_small_bool \scriptstyle \bool_lazy_and:nnT { \int_compare_p:nNn \c@iRow > 0 } @@ -1236,7 +1457,7 @@ l < { - \c_math_toggle_token + \bool_if:NF \l__nicematrix_NiceTabular_bool \c_math_toggle_token \hbox_set_end: \__nicematrix_update_for_first_and_last_row: \dim_gset:Nn \g__nicematrix_width_first_col_dim @@ -1250,7 +1471,7 @@ \skip_horizontal:N \l__nicematrix_left_margin_dim \skip_horizontal:N \l__nicematrix_extra_left_margin_dim } - \skip_horizontal:N -2\arraycolsep + \skip_horizontal:N -2\col@sep } } \tl_const:Nn \c__nicematrix_preamble_last_col_tl @@ -1261,7 +1482,7 @@ \int_gincr:N \c@jCol \int_gset_eq:NN \g__nicematrix_col_total_int \c@jCol \hbox_set:Nw \l__nicematrix_cell_box - \c_math_toggle_token + \bool_if:NF \l__nicematrix_NiceTabular_bool \c_math_toggle_token \bool_if:NT \l__nicematrix_small_bool \scriptstyle \int_compare:nNnT \c@iRow > 0 { @@ -1277,12 +1498,12 @@ l < { - \c_math_toggle_token + \bool_if:NF \l__nicematrix_NiceTabular_bool \c_math_toggle_token \hbox_set_end: \__nicematrix_update_for_first_and_last_row: \dim_gset:Nn \g__nicematrix_width_last_col_dim { \dim_max:nn \g__nicematrix_width_last_col_dim { \box_wd:N \l__nicematrix_cell_box } } - \skip_horizontal:N -2\arraycolsep + \skip_horizontal:N -2\col@sep \hbox_overlap_right:n { \dim_compare:nNnT { \box_wd:N \l__nicematrix_cell_box } > \c_zero_dim @@ -1352,11 +1573,11 @@ \keys_set:nn { NiceMatrix / NiceMatrix } { ##1 } \exp_args:Nnx \__nicematrix_begin_of_NiceMatrix:nn { #1 } \l__nicematrix_type_of_col_tl } - { \end { #1 NiceArray } } + { \use:c { end #1 NiceArray } } } \cs_new_protected:Npn \__nicematrix_begin_of_NiceMatrix:nn #1 #2 { - \begin { #1 NiceArray } + \use:c { #1 NiceArray } { * { @@ -1373,6 +1594,13 @@ \__nicematrix_define_env:n B \__nicematrix_define_env:n v \__nicematrix_define_env:n V +\NewDocumentEnvironment { NiceTabular } { O { } m ! O { } } + { + \keys_set:nn { NiceMatrix / NiceTabular } { #1 , #3 } + \bool_set_true:N \l__nicematrix_NiceTabular_bool + \NiceArray { #2 } + } + { \endNiceArray } \cs_new_protected:Npn \__nicematrix_after_array: { \group_begin: @@ -1419,6 +1647,28 @@ \iow_shipout:Nn \@mainaux \ExplSyntaxOff } } + \bool_if:NT \l__nicematrix_code_before_bool + { + \iow_now:Nn \@mainaux \ExplSyntaxOn + \iow_now:Nx \@mainaux + { \seq_clear_new:c { __nicematrix_size _ \int_use:N \g__nicematrix_env_int _ seq } } + \iow_now:Nx \@mainaux + { + \seq_gset_from_clist:cn { __nicematrix_size _ \int_use:N \g__nicematrix_env_int _ seq } + { + \int_use:N \l__nicematrix_first_row_int , + \int_use:N \g__nicematrix_row_total_int , + \int_use:N \l__nicematrix_first_col_int , + \bool_lazy_and:nnTF + { \int_compare_p:nNn \l__nicematrix_last_col_int > { -2 } } + { \bool_not_p:n \g__nicematrix_last_col_found_bool } + \__nicematrix_succ:n + \int_use:N + \g__nicematrix_col_total_int + } + } + \iow_now:Nn \@mainaux \ExplSyntaxOff + } \bool_if:NT \l__nicematrix_parallelize_diags_bool { \int_gzero_new:N \g__nicematrix_ddots_int @@ -1464,6 +1714,7 @@ } } \cs_set_eq:NN \line \__nicematrix_line + \cs_set_eq:NN \CodeAfter \prg_do_nothing: \g__nicematrix_code_after_tl \tl_gclear:N \g__nicematrix_code_after_tl \group_end: @@ -1483,7 +1734,7 @@ { \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse - \g__nicematrix_Hdotsfor_lines_tl + \g__nicematrix_HVdotsfor_lines_tl \g__nicematrix_Vdots_lines_tl \g__nicematrix_Ddots_lines_tl \g__nicematrix_Iddots_lines_tl @@ -1492,8 +1743,8 @@ } \cs_new_protected:Npn \__nicematrix_restore_iRow_jCol: { - \cs_if_exist:NT \theiRow { \int_gset_eq:NN \c@iRow \l__nicematrix_save_iRow_int } - \cs_if_exist:NT \thejCol { \int_gset_eq:NN \c@jCol \l__nicematrix_save_jCol_int } + \cs_if_exist:NT \theiRow { \int_gset_eq:NN \c@iRow \l__nicematrix_old_iRow_int } + \cs_if_exist:NT \thejCol { \int_gset_eq:NN \c@jCol \l__nicematrix_old_jCol_int } } \cs_new_protected:Npn \__nicematrix_find_extremities_of_line:nnnn #1 #2 #3 #4 { @@ -1639,10 +1890,6 @@ } } } -\cs_new:Nn \__nicematrix_initial_cell: - { \__nicematrix_env: - \int_use:N \l__nicematrix_initial_i_int - \int_use:N \l__nicematrix_initial_j_int } -\cs_new:Nn \__nicematrix_final_cell: - { \__nicematrix_env: - \int_use:N \l__nicematrix_final_i_int - \int_use:N \l__nicematrix_final_j_int } \cs_new_protected:Npn \__nicematrix_set_initial_coords: { \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x @@ -1655,12 +1902,24 @@ } \cs_new_protected:Npn \__nicematrix_set_initial_coords_from_anchor:n #1 { - \pgfpointanchor \__nicematrix_initial_cell: { #1 } + \pgfpointanchor + { + \__nicematrix_env: + - \int_use:N \l__nicematrix_initial_i_int + - \int_use:N \l__nicematrix_initial_j_int + } + { #1 } \__nicematrix_set_initial_coords: } \cs_new_protected:Npn \__nicematrix_set_final_coords_from_anchor:n #1 { - \pgfpointanchor \__nicematrix_final_cell: { #1 } + \pgfpointanchor + { + \__nicematrix_env: + - \int_use:N \l__nicematrix_final_i_int + - \int_use:N \l__nicematrix_final_j_int + } + { #1 } \__nicematrix_set_final_coords: } \cs_new_protected:Npn \__nicematrix_draw_Ldots:nnn #1 #2 #3 @@ -1685,19 +1944,21 @@ { \bool_if:NTF \l__nicematrix_initial_open_bool { - \__nicematrix_qpoint: { col - \int_use:N \l__nicematrix_initial_j_int } + \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_initial_j_int } \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x - \dim_add:Nn \l__nicematrix_x_initial_dim \arraycolsep - \__nicematrix_qpoint: { row - \int_use:N \l__nicematrix_initial_i_int - base } + \dim_add:Nn \l__nicematrix_x_initial_dim + { \bool_if:NTF \l__nicematrix_NiceTabular_bool \tabcolsep \arraycolsep } + \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_initial_i_int - base } \dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y } { \__nicematrix_set_initial_coords_from_anchor:n { base~east } } \bool_if:NTF \l__nicematrix_final_open_bool { - \__nicematrix_qpoint: { col - \__nicematrix_succ:n \l__nicematrix_final_j_int } + \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l__nicematrix_final_j_int } \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x - \dim_sub:Nn \l__nicematrix_x_final_dim \arraycolsep - \__nicematrix_qpoint: { row - \int_use:N \l__nicematrix_final_i_int - base } + \dim_sub:Nn \l__nicematrix_x_final_dim + { \bool_if:NTF \l__nicematrix_NiceTabular_bool \tabcolsep \arraycolsep } + \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_final_i_int - base } \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y } { \__nicematrix_set_final_coords_from_anchor:n { base~west } } @@ -1727,25 +1988,27 @@ { \bool_if:NTF \l__nicematrix_initial_open_bool { - \__nicematrix_qpoint: { col - \int_use:N \l__nicematrix_initial_j_int } + \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_initial_j_int } \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x - \dim_add:Nn \l__nicematrix_x_initial_dim \arraycolsep + \dim_add:Nn \l__nicematrix_x_initial_dim + { \bool_if:NTF \l__nicematrix_NiceTabular_bool \tabcolsep \arraycolsep } } { \__nicematrix_set_initial_coords_from_anchor:n { mid~east } } \bool_if:NTF \l__nicematrix_final_open_bool { - \__nicematrix_qpoint: { col - \__nicematrix_succ:n \l__nicematrix_final_j_int } + \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l__nicematrix_final_j_int } \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x - \dim_sub:Nn \l__nicematrix_x_final_dim \arraycolsep + \dim_sub:Nn \l__nicematrix_x_final_dim + { \bool_if:NTF \l__nicematrix_NiceTabular_bool \tabcolsep \arraycolsep } } { \__nicematrix_set_final_coords_from_anchor:n { mid~west } } \bool_lazy_and:nnTF \l__nicematrix_initial_open_bool \l__nicematrix_final_open_bool { - \__nicematrix_qpoint: { row - \int_use:N \l__nicematrix_initial_i_int } + \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_initial_i_int } \dim_set_eq:NN \l_tmpa_dim \pgf@y - \__nicematrix_qpoint: { row - \__nicematrix_succ:n \l__nicematrix_initial_i_int } + \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l__nicematrix_initial_i_int } \dim_set:Nn \l__nicematrix_y_initial_dim { ( \l_tmpa_dim + \pgf@y ) / 2 } \dim_set_eq:NN \l__nicematrix_y_final_dim \l__nicematrix_y_initial_dim } @@ -1787,13 +2050,13 @@ } \bool_if:NTF \l__nicematrix_initial_open_bool { - \__nicematrix_qpoint: { row - 1 } + \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_initial_i_int } \dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y } { \__nicematrix_set_initial_coords_from_anchor:n { south } } \bool_if:NTF \l__nicematrix_final_open_bool { - \__nicematrix_qpoint: { row - \__nicematrix_succ:n \c@iRow } + \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l__nicematrix_final_i_int } \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y } { \__nicematrix_set_final_coords_from_anchor:n { north } } @@ -1801,11 +2064,21 @@ { \bool_if:NTF \l__nicematrix_final_open_bool { - \__nicematrix_qpoint: { col - \int_use:N \l__nicematrix_initial_j_int } + \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_initial_j_int } \dim_set_eq:NN \l_tmpa_dim \pgf@x - \__nicematrix_qpoint: { col - \__nicematrix_succ:n \l__nicematrix_initial_j_int } + \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l__nicematrix_initial_j_int } \dim_set:Nn \l__nicematrix_x_initial_dim { ( \pgf@x + \l_tmpa_dim ) / 2 } \dim_set_eq:NN \l__nicematrix_x_final_dim \l__nicematrix_x_initial_dim + \int_compare:nNnT \l__nicematrix_last_col_int > { -2 } + { + \int_compare:nNnT \l__nicematrix_initial_j_int = \g__nicematrix_col_total_int + { + \dim_set_eq:NN \l_tmpa_dim \l__nicematrix_right_margin_dim + \dim_add:Nn \l_tmpa_dim \l__nicematrix_extra_right_margin_dim + \dim_add:Nn \l__nicematrix_x_initial_dim \l_tmpa_dim + \dim_add:Nn \l__nicematrix_x_final_dim \l_tmpa_dim + } + } } { \dim_set_eq:NN \l__nicematrix_x_initial_dim \l__nicematrix_x_final_dim } } @@ -1842,17 +2115,17 @@ { \bool_if:NTF \l__nicematrix_initial_open_bool { - \__nicematrix_qpoint: { row - \int_use:N \l__nicematrix_initial_i_int } + \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_initial_i_int } \dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y - \__nicematrix_qpoint: { col - \int_use:N \l__nicematrix_initial_j_int } + \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_initial_j_int } \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x } { \__nicematrix_set_initial_coords_from_anchor:n { south~east } } \bool_if:NTF \l__nicematrix_final_open_bool { - \__nicematrix_qpoint: { row - \__nicematrix_succ:n \l__nicematrix_final_i_int } + \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l__nicematrix_final_i_int } \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y - \__nicematrix_qpoint: { col - \__nicematrix_succ:n \l__nicematrix_final_j_int } + \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l__nicematrix_final_j_int } \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x } { \__nicematrix_set_final_coords_from_anchor:n { north~west } } @@ -1893,17 +2166,17 @@ { \bool_if:NTF \l__nicematrix_initial_open_bool { - \__nicematrix_qpoint: { row - \int_use:N \l__nicematrix_initial_i_int } + \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_initial_i_int } \dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y - \__nicematrix_qpoint: { col - \__nicematrix_succ:n \l__nicematrix_initial_j_int } + \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l__nicematrix_initial_j_int } \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x } { \__nicematrix_set_initial_coords_from_anchor:n { south~west } } \bool_if:NTF \l__nicematrix_final_open_bool { - \__nicematrix_qpoint: { row - \__nicematrix_succ:n \l__nicematrix_final_i_int } + \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l__nicematrix_final_i_int } \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y - \__nicematrix_qpoint: { col - \int_use:N \l__nicematrix_final_j_int } + \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_final_j_int } \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x } { \__nicematrix_set_final_coords_from_anchor:n { north~east } } @@ -2121,40 +2394,107 @@ { \bool_if:nTF { #1 } { \__nicematrix_error:n { starred~commands } } - { \__nicematrix_instruction_of_type:nn { Ldots } { #2 , down = #3 , up = #4 } } - \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_ldots } + { + \int_compare:nNnTF \c@jCol = 0 + { \__nicematrix_error:nn { in~first~col } \Ldots } + { + \int_compare:nNnTF \c@jCol = \l__nicematrix_last_col_int + { \__nicematrix_error:nn { in~last~col } \Ldots } + { + \__nicematrix_instruction_of_type:nn { Ldots } + { #2 , down = #3 , up = #4 } + } + } + } + \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_ldots } \bool_gset_true:N \g__nicematrix_empty_cell_bool } \exp_args:NNV \NewDocumentCommand \__nicematrix_Cdots \l__nicematrix_argspec_tl { \bool_if:nTF { #1 } { \__nicematrix_error:n { starred~commands } } - { \__nicematrix_instruction_of_type:nn { Cdots } { #2 , down = #3 , up = #4 } } - \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_cdots } + { + \int_compare:nNnTF \c@jCol = 0 + { \__nicematrix_error:nn { in~first~col } \Cdots } + { + \int_compare:nNnTF \c@jCol = \l__nicematrix_last_col_int + { \__nicematrix_error:nn { in~last~col } \Cdots } + { + \__nicematrix_instruction_of_type:nn { Cdots } + { #2 , down = #3 , up = #4 } + } + } + } + \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_cdots } \bool_gset_true:N \g__nicematrix_empty_cell_bool } \exp_args:NNV \NewDocumentCommand \__nicematrix_Vdots \l__nicematrix_argspec_tl { \bool_if:nTF { #1 } { \__nicematrix_error:n { starred~commands } } - { \__nicematrix_instruction_of_type:nn { Vdots } { #2 , down = #3 , up = #4 } } - \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_vdots } + \int_compare:nNnTF \c@iRow = 0 + { \__nicematrix_error:nn { in~first~row } \Vdots } + { + \int_compare:nNnTF \c@iRow = \l__nicematrix_last_row_int + { \__nicematrix_error:nn { in~last~row } \Vdots } + { + \__nicematrix_instruction_of_type:nn { Vdots } + { #2 , down = #3 , up = #4 } + } + } + \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_vdots } \bool_gset_true:N \g__nicematrix_empty_cell_bool } \exp_args:NNV \NewDocumentCommand \__nicematrix_Ddots \l__nicematrix_argspec_tl { \bool_if:nTF { #1 } { \__nicematrix_error:n { starred~commands } } - { \__nicematrix_instruction_of_type:nn { Ddots } { #2 , down = #3 , up = #4 } } - \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_ddots } + { + \int_case:nnF \c@iRow + { + 0 { \__nicematrix_error:nn { in~first~row } \Ddots } + \l__nicematrix_last_row_int { \__nicematrix_error:nn { in~last~row } \Ddots } + } + { + \int_case:nnF \c@jCol + { + 0 { \__nicematrix_error:nn { in~first~col } \Ddots } + \l__nicematrix_last_col_int { \__nicematrix_error:nn { in~last~col } \Ddots } + } + { + \__nicematrix_instruction_of_type:nn { Ddots } + { #2 , down = #3 , up = #4 } + } + + } + } + \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_ddots } \bool_gset_true:N \g__nicematrix_empty_cell_bool } \exp_args:NNV \NewDocumentCommand \__nicematrix_Iddots \l__nicematrix_argspec_tl { \bool_if:nTF { #1 } { \__nicematrix_error:n { starred~commands } } - { \__nicematrix_instruction_of_type:nn { Iddots } { #2 , down = #3 , up = #4 } } - \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_iddots } + { + \int_case:nnF \c@iRow + { + 0 { \__nicematrix_error:nn { in~first~row } \Iddots } + \l__nicematrix_last_row_int { \__nicematrix_error:nn { in~last~row } \Iddots } + } + { + \int_case:nnF \c@jCol + { + 0 { \__nicematrix_error:nn { in~first~col } \Iddots } + \l__nicematrix_last_col_int { \__nicematrix_error:nn { in~last~col } \Iddots } + } + { + \__nicematrix_instruction_of_type:nn { Iddots } + { #2 , down = #3 , up = #4 } + } + + } + } + \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_iddots } \bool_gset_true:N \g__nicematrix_empty_cell_bool } } @@ -2170,7 +2510,7 @@ \int_compare:nNnT #1 > 1 { \seq_gput_left:Nx \g__nicematrix_multicolumn_cells_seq - { \int_eval:n \c@iRow - \int_use:N \c@jCol } + { \int_use:N \c@iRow - \int_use:N \c@jCol } \seq_gput_left:Nn \g__nicematrix_multicolumn_sizes_seq { #1 } } \int_gadd:Nn \c@jCol { #1 - 1 } @@ -2180,32 +2520,24 @@ \multicolumn { 1 } { C } { } \__nicematrix_Hdotsfor_i } -\ExplSyntaxOff -\def \@tempa { O { } m O { } E { _ ^ } { { } { } } } -\ExplSyntaxOn -\tl_set_eq:NN \l__nicematrix_a_signature_tl \@tempa \AtBeginDocument { \tl_set:Nn \l__nicematrix_argspec_tl { O { } m O { } E { _ ^ } { { } { } } } \tl_set_rescan:Nno \l__nicematrix_argspec_tl { } \l__nicematrix_argspec_tl - \bool_if:NTF \c__nicematrix_draft_bool + \exp_args:NNV \NewDocumentCommand \__nicematrix_Hdotsfor_i \l__nicematrix_argspec_tl { - \exp_args:NNV \NewDocumentCommand \__nicematrix_Hdotsfor_i \l__nicematrix_argspec_tl - { \prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { C } { } } } - } - { - \exp_args:NNV \NewDocumentCommand \__nicematrix_Hdotsfor_i \l__nicematrix_argspec_tl + \tl_gput_right:Nx \g__nicematrix_HVdotsfor_lines_tl { - \tl_gput_right:Nx \g__nicematrix_Hdotsfor_lines_tl + \__nicematrix_Hdotsfor:nnnn + { \int_use:N \c@iRow } + { \int_use:N \c@jCol } + { #2 } { - \__nicematrix_Hdotsfor:nnnn - { \int_use:N \c@iRow } - { \int_use:N \c@jCol } - { #2 } - { #1 , #3 , down = #4 , up = #5 } + #1 , #3 , + down = \exp_not:n { #4 } , up = \exp_not:n { #5 } } - \prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { C } { } } } + \prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { C } { } } } } \cs_new_protected:Npn \__nicematrix_Hdotsfor:nnnn #1 #2 #3 #4 @@ -2264,6 +2596,81 @@ \int_step_inline:nnn { #2 } { #2 + #3 - 1 } { \cs_set:cpn { __nicematrix _ dotted _ #1 - ##1 } { } } } +\AtBeginDocument + { + \tl_set:Nn \l__nicematrix_argspec_tl { O { } m O { } E { _ ^ } { { } { } } } + \tl_set_rescan:Nno \l__nicematrix_argspec_tl { } \l__nicematrix_argspec_tl + \exp_args:NNV \NewDocumentCommand \__nicematrix_Vdotsfor: \l__nicematrix_argspec_tl + { + \tl_gput_right:Nx \g__nicematrix_HVdotsfor_lines_tl + { + \__nicematrix_Vdotsfor:nnnn + { \int_use:N \c@iRow } + { \int_use:N \c@jCol } + { #2 } + { + #1 , #3 , + down = \exp_not:n { #4 } , up = \exp_not:n { #5 } + } + } + } + } +\cs_new_protected:Npn \__nicematrix_Vdotsfor:nnnn #1 #2 #3 #4 + { + \bool_set_false:N \l__nicematrix_initial_open_bool + \bool_set_false:N \l__nicematrix_final_open_bool + \int_set:Nn \l__nicematrix_initial_j_int { #2 } + \int_set_eq:NN \l__nicematrix_final_j_int \l__nicematrix_initial_j_int + \int_compare:nNnTF #1 = 1 + { + \int_set:Nn \l__nicematrix_initial_i_int 1 + \bool_set_true:N \l__nicematrix_initial_open_bool + } + { + \cs_if_exist:cTF + { + pgf @ sh @ ns @ \__nicematrix_env: + - \int_eval:n { #1 - 1 } + - \int_use:N \l__nicematrix_initial_j_int + } + { \int_set:Nn \l__nicematrix_initial_i_int { #1 - 1 } } + { + \int_set:Nn \l__nicematrix_initial_i_int { #1 } + \bool_set_true:N \l__nicematrix_initial_open_bool + } + } + \int_compare:nNnTF { #1 + #3 -1 } = \c@iRow + { + \int_set:Nn \l__nicematrix_final_i_int { #1 + #3 - 1 } + \bool_set_true:N \l__nicematrix_final_open_bool + } + { + \cs_if_exist:cTF + { + pgf @ sh @ ns @ \__nicematrix_env: + - \int_eval:n { #1 + #3 } + - \int_use:N \l__nicematrix_final_j_int + } + { \int_set:Nn \l__nicematrix_final_i_int { #1 + #3 } } + { + \int_set:Nn \l__nicematrix_final_i_int { #1 + #3 - 1 } + \bool_set_true:N \l__nicematrix_final_open_bool + } + } + \group_begin: + \int_compare:nNnTF { #2 } = 0 + { \color { nicematrix-first-col } } + { + \int_compare:nNnT { #2 } = \g__nicematrix_col_total_int + { \color { nicematrix-last-col } } + } + \keys_set:nn { NiceMatrix / xdots } { #4 } + \tl_if_empty:VF \l__nicematrix_xdots_color_tl { \color { \l__nicematrix_xdots_color_tl } } + \__nicematrix_actually_draw_Vdots: + \group_end: + \int_step_inline:nnn { #1 } { #1 + #3 - 1 } + { \cs_set:cpn { __nicematrix _ dotted _ ##1 - #2 } { } } + } \cs_new_protected:Npn \__nicematrix_rotate: { \group_insert_after:N \__nicematrix_rotate_i: } \cs_new_protected:Npn \__nicematrix_rotate_i: { \group_insert_after:N \__nicematrix_rotate_ii: } \cs_new_protected:Npn \__nicematrix_rotate_ii: { \group_insert_after:N \__nicematrix_rotate_iii: } @@ -2282,10 +2689,6 @@ } \cs_new:Npn \__nicematrix_double_int_eval:n #1-#2 \q_stop { \int_eval:n { #1 } - \int_eval:n { #2 } } -\ExplSyntaxOff -\def \@tempa { O { } m m ! O { } E { _ ^ } { { } { } } } -\ExplSyntaxOn -\tl_set_eq:NN \l__nicematrix_a_signature_tl \@tempa \AtBeginDocument { \tl_set:Nn \l__nicematrix_argspec_tl { O { } m m ! O { } E { _ ^ } { { } { } } } @@ -2304,24 +2707,20 @@ \group_end: } } -\bool_if:NTF \c__nicematrix_draft_bool - { \cs_new_protected:Npn \__nicematrix_line_i:nn #1 #2 { } } +\cs_new_protected:Npn \__nicematrix_line_i:nn #1 #2 { - \cs_new_protected:Npn \__nicematrix_line_i:nn #1 #2 + \bool_set_false:N \l__nicematrix_initial_open_bool + \bool_set_false:N \l__nicematrix_final_open_bool + \bool_if:nTF { - \bool_set_false:N \l__nicematrix_initial_open_bool - \bool_set_false:N \l__nicematrix_final_open_bool - \bool_if:nTF - { - \cs_if_free_p:c { pgf @ sh @ ns @ \__nicematrix_env: - #1 } - || - \cs_if_free_p:c { pgf @ sh @ ns @ \__nicematrix_env: - #2 } - } - { - \__nicematrix_error:nnn { unknown~cell~for~line~in~code-after } { #1 } { #2 } - } - { \__nicematrix_draw_line_ii:nn { #1 } { #2 } } + \cs_if_free_p:c { pgf @ sh @ ns @ \__nicematrix_env: - #1 } + || + \cs_if_free_p:c { pgf @ sh @ ns @ \__nicematrix_env: - #2 } + } + { + \__nicematrix_error:nnn { unknown~cell~for~line~in~code-after } { #1 } { #2 } } + { \__nicematrix_draw_line_ii:nn { #1 } { #2 } } } \AtBeginDocument { @@ -2335,14 +2734,166 @@ \cs_new_protected:Npn \__nicematrix_draw_line_iii:nn #1 #2 { \pgfrememberpicturepositiononpagetrue - \pgfpointshapeborder { \__nicematrix_env: - #1 } { \__nicematrix_qpoint: { #2 } } + \pgfpointshapeborder { \__nicematrix_env: - #1 } { \__nicematrix_qpoint:n { #2 } } \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x \dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y - \pgfpointshapeborder { \__nicematrix_env: - #2 } { \__nicematrix_qpoint: { #1 } } + \pgfpointshapeborder { \__nicematrix_env: - #2 } { \__nicematrix_qpoint:n { #1 } } \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y \__nicematrix_draw_line: } +\cs_set_protected:Npn \__nicematrix_cut_on_hyphen:w #1-#2\q_stop + { + \tl_set:Nn \l_tmpa_tl { #1 } + \tl_set:Nn \l_tmpb_tl { #2 } + } +\cs_new_protected:Npn \__nicematrix_rowcolor:nn #1 #2 + { + \tl_if_blank:nF { #1 } + { + \pgfpicture + \pgf@relevantforpicturesizefalse + \pgfsetfillcolor { #1 } + \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \c@jCol } + \dim_set_eq:NN \l_tmpa_dim \pgf@x + \clist_map_inline:nn { #2 } + { + \tl_set:Nn \l_tmpa_tl { ##1 } + \tl_if_in:NnTF \l_tmpa_tl { - } + { \__nicematrix_cut_on_hyphen:w ##1 \q_stop } + { \__nicematrix_cut_on_hyphen:w ##1 - ##1 \q_stop } + \tl_if_empty:NT \l_tmpa_tl { \tl_set:Nn \l_tmpa_tl { 1 } } + \tl_if_empty:NT \l_tmpb_tl + { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } } + \int_compare:nNnT \l_tmpb_tl > \c@iRow + { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } } + \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l_tmpb_tl } + \pgfpathrectanglecorners + { \__nicematrix_qpoint:n { row - \l_tmpa_tl } } + { \pgfpoint \l_tmpa_dim \pgf@y } + } + \pgfusepathqfill + \endpgfpicture + } + } +\cs_new_protected:Npn \__nicematrix_columncolor:nn #1 #2 + { + \tl_if_blank:nF { #1 } + { + \pgfpicture + \pgf@relevantforpicturesizefalse + \pgfsetfillcolor { #1 } + \__nicematrix_qpoint:n { row - 1 } + \dim_set_eq:NN \l_tmpa_dim \pgf@y + \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \c@iRow } + \dim_set_eq:NN \l_tmpb_dim \pgf@y + \clist_map_inline:nn { #2 } + { + \tl_set:Nn \l_tmpa_tl { ##1 } + \tl_if_in:NnTF \l_tmpa_tl { - } + { \__nicematrix_cut_on_hyphen:w ##1 \q_stop } + { \__nicematrix_cut_on_hyphen:w ##1 - ##1 \q_stop } + \tl_if_empty:NT \l_tmpa_tl { \tl_set:Nn \l_tmpa_tl { 1 } } + \tl_if_empty:NT \l_tmpb_tl + { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } } + \int_compare:nNnT \l_tmpb_tl > \c@jCol + { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } } + \__nicematrix_qpoint:n { col - \l_tmpa_tl } + \dim_set_eq:NN \l_tmpc_dim \pgf@x + \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l_tmpb_tl } + \pgfpathrectanglecorners + { \pgfpoint \l_tmpc_dim \l_tmpa_dim } + { \pgfpoint \pgf@x \l_tmpb_dim } + } + \pgfusepathqfill + \endpgfpicture + } + } +\cs_new_protected:Npn \__nicematrix_cellcolor:nn #1 #2 + { + \tl_if_blank:nF { #1 } + { + \pgfpicture + \pgf@relevantforpicturesizefalse + \pgfsetfillcolor { #1 } + \clist_map_inline:nn { #2 } + { + \__nicematrix_cut_on_hyphen:w ##1 \q_stop + \__nicematrix_qpoint:n { row - \l_tmpa_tl } + \bool_lazy_and:nnT + { \int_compare_p:n { \l_tmpa_tl <= \c@iRow } } + { \int_compare_p:n { \l_tmpb_tl <= \c@jCol } } + { + \dim_set_eq:NN \l_tmpb_dim \pgf@y + \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l_tmpa_tl } + \dim_set_eq:NN \l_tmpa_dim \pgf@y + \__nicematrix_qpoint:n { col - \l_tmpb_tl } + \dim_set_eq:NN \l_tmpc_dim \pgf@x + \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l_tmpb_tl } + \dim_set_eq:NN \l_tmpd_dim \pgf@x + \pgfpathrectanglecorners + { \pgfpoint \l_tmpc_dim \l_tmpb_dim } + { \pgfpoint \l_tmpd_dim \l_tmpa_dim } + } + } + \pgfusepathqfill + \endpgfpicture + } + } +\cs_new_protected:Npn \__nicematrix_rectanglecolor:nnn #1 #2 #3 + { + \tl_if_blank:nF { #1 } + { + \pgfpicture + \pgf@relevantforpicturesizefalse + \pgfsetfillcolor { #1 } + \__nicematrix_cut_on_hyphen:w #2 \q_stop + \bool_lazy_and:nnT + { \int_compare_p:n { \l_tmpa_tl <= \c@iRow } } + { \int_compare_p:n { \l_tmpb_tl <= \c@jCol } } + { + \__nicematrix_qpoint:n { row - \l_tmpa_tl } + \dim_set_eq:NN \l_tmpb_dim \pgf@y + \__nicematrix_qpoint:n { col - \l_tmpb_tl } + \__nicematrix_cut_on_hyphen:w #3 \q_stop + \int_compare:nNnT \l_tmpa_tl > \c@iRow + { \tl_set:Nx \l_tmpa_tl { \int_use:N \c@iRow } } + \int_compare:nNnT \l_tmpb_tl > \c@jCol + { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } } + \dim_set_eq:NN \l_tmpc_dim \pgf@x + \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l_tmpa_tl } + \dim_set_eq:NN \l_tmpa_dim \pgf@y + \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l_tmpb_tl } + \dim_set_eq:NN \l_tmpd_dim \pgf@x + \pgfpathrectanglecorners + { \pgfpoint \l_tmpc_dim \l_tmpb_dim } + { \pgfpoint \l_tmpd_dim \l_tmpa_dim } + \pgfusepathqfill + } + \endpgfpicture + } + } +\cs_new_protected:Npn \__nicematrix_rowcolors:nnn #1 #2 #3 + { + \int_step_inline:nnn { #1 } { \int_use:N \c@iRow } + { + \int_if_odd:nTF { ##1 } + { \__nicematrix_rowcolor:nn { #2 } { ##1 } } + { \__nicematrix_rowcolor:nn { #3 } { ##1 } } + } + } +\cs_new_protected:Npn \__nicematrix_chessboardcolors:nn #1 #2 + { + \int_step_inline:nn { \int_use:N \c@iRow } + { + \int_step_inline:nn { \int_use:N \c@jCol } + { + \int_if_even:nTF { ####1 + ##1 } + { \__nicematrix_cellcolor:nn { #1 } { ####1 - ##1 } } + { \__nicematrix_cellcolor:nn { #2 } { ####1 - ##1 } } + } + } + } \cs_set_eq:NN \OnlyMainNiceMatrix \use:n \cs_new_protected:Npn \__nicematrix_OnlyMainNiceMatrix:n #1 { @@ -2362,20 +2913,20 @@ \int_compare:nNnF \c@iRow = 0 { \int_compare:nNnF \c@iRow = \l__nicematrix_last_row_int { #1 } } } -\cs_new_protected:Npn \__nicematrix_vline: { \__nicematrix_OnlyMainNiceMatrix:n { \__nicematrix_vline_i: } } -\cs_set_eq:NN \__nicematrix_vline_i: \vline +\cs_new_protected:Npn \__nicematrix_vline: + { \__nicematrix_OnlyMainNiceMatrix:n { { \CT@arc@ \vline } } } \cs_new_protected:Npn \__nicematrix_draw_vlines: { \group_begin: - \bool_if:NT \c__nicematrix_colortbl_loaded_bool \CT@arc@ + \CT@arc@ \pgfpicture \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse \pgfsetlinewidth \arrayrulewidth - \__nicematrix_qpoint: {row - 1 } + \__nicematrix_qpoint:n { row - 1 } \dim_set_eq:NN \l_tmpa_dim \pgf@y \pgfusepathqfill - \__nicematrix_qpoint: { row - \__nicematrix_succ:n \c@iRow } + \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \c@iRow } \dim_sub:Nn \l_tmpa_dim \pgf@y \pgfusepathqfill \dim_zero:N \l_tmpb_dim @@ -2383,63 +2934,33 @@ { \dim_set_eq:NN \l_tmpb_dim \g__nicematrix_dp_last_row_dim \dim_add:Nn \l_tmpb_dim \g__nicematrix_ht_last_row_dim - \__nicematrix_qpoint: { row - \__nicematrix_succ:n\c@iRow } + \__nicematrix_qpoint:n { row - \__nicematrix_succ:n\c@iRow } \dim_add:Nn \l_tmpa_dim \pgf@y - \__nicematrix_qpoint: { row - \__nicematrix_succ:n \g__nicematrix_row_total_int } + \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \g__nicematrix_row_total_int } \dim_sub:Nn \l_tmpa_dim \pgf@y \dim_sub:Nn \l_tmpa_dim \l_tmpb_dim } + \dim_add:Nn \l_tmpa_dim \arrayrulewidth \int_step_inline:nnn { \bool_if:NTF \l__nicematrix_NiceArray_bool 1 2 } { \bool_if:NTF \l__nicematrix_NiceArray_bool { \__nicematrix_succ:n \c@jCol } \c@jCol } { - \pgfpathmoveto - { - \pgfpointadd - { \__nicematrix_qpoint: { col - ##1 } } - { - \pgfpoint - { - -0.5 \arrayrulewidth - \int_compare:nNnT { ##1 } = 1 - { - \int_compare:nNnT \l__nicematrix_first_col_int = 1 - { + \arrayrulewidth } - } - } - { \l_tmpb_dim } - } - } + \pgfpathmoveto { \__nicematrix_qpoint:n { col - ##1 } } \pgfpathlineto { \pgfpointadd - { \__nicematrix_qpoint: { col - ##1 } } - { - \pgfpoint - { - -0.5 \arrayrulewidth - \int_compare:nNnT { ##1 } = 1 - { - \int_compare:nNnT \l__nicematrix_first_col_int = 1 - { + \arrayrulewidth } - } - } - { \l_tmpb_dim + \l_tmpa_dim } - } + { \__nicematrix_qpoint:n { col - ##1 } } + { \pgfpoint \c_zero_dim { \l_tmpb_dim + \l_tmpa_dim } } } } \pgfusepathqstroke \endpgfpicture \group_end: } -\bool_if:NTF \c__nicematrix_draft_bool - { \cs_new:Npn \__nicematrix_hdottedline: { } } +\cs_new:Npn \__nicematrix_hdottedline: { - \cs_new:Npn \__nicematrix_hdottedline: - { - \noalign { \skip_vertical:N 2\l__nicematrix_radius_dim } - \__nicematrix_hdottedline_i: - } + \noalign { \skip_vertical:N 2\l__nicematrix_radius_dim } + \__nicematrix_hdottedline_i: } \cs_new_protected:Npn \__nicematrix_hdottedline_i: { @@ -2460,16 +2981,24 @@ \cs_new_protected:Npn \__nicematrix_hdottedline_i:n #1 { \pgfrememberpicturepositiononpagetrue - \__nicematrix_qpoint: { row - #1 } + \__nicematrix_qpoint:n { row - #1 } \dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y \dim_sub:Nn \l__nicematrix_y_initial_dim \l__nicematrix_radius_dim \dim_set_eq:NN \l__nicematrix_y_final_dim \l__nicematrix_y_initial_dim - \__nicematrix_qpoint: { col - 1 } + \__nicematrix_qpoint:n { col - 1 } \dim_set:Nn \l__nicematrix_x_initial_dim - { \pgf@x + \arraycolsep - \l__nicematrix_left_margin_dim } - \__nicematrix_qpoint: { col - \__nicematrix_succ:n \c@jCol } + { + \pgf@x + + \bool_if:NTF \l__nicematrix_NiceTabular_bool \tabcolsep \arraycolsep + - \l__nicematrix_left_margin_dim + } + \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \c@jCol } \dim_set:Nn \l__nicematrix_x_final_dim - { \pgf@x - \arraycolsep + \l__nicematrix_right_margin_dim } + { + \pgf@x - + \bool_if:NTF \l__nicematrix_NiceTabular_bool \tabcolsep \arraycolsep + + \l__nicematrix_right_margin_dim + } \tl_set:Nn \l_tmpa_tl { ( } \tl_if_eq:NNF \l__nicematrix_left_delim_tl \l_tmpa_tl { \dim_gadd:Nn \l__nicematrix_x_initial_dim { 0.5 \l__nicematrix_inter_dots_dim } } @@ -2479,36 +3008,32 @@ \tl_set_eq:NN \l__nicematrix_xdots_line_style_tl \c__nicematrix_standard_tl \__nicematrix_draw_line: } -\bool_if:nTF \c__nicematrix_draft_bool - { \cs_new_protected:Npn \__nicematrix_vdottedline:n #1 { } } +\cs_new_protected:Npn \__nicematrix_vdottedline:n #1 { - \cs_new_protected:Npn \__nicematrix_vdottedline:n #1 + \bool_set_true:N \l__nicematrix_initial_open_bool + \bool_set_true:N \l__nicematrix_final_open_bool + \bool_if:NTF \c__nicematrix_tikz_loaded_bool { - \bool_set_true:N \l__nicematrix_initial_open_bool - \bool_set_true:N \l__nicematrix_final_open_bool - \bool_if:NTF \c__nicematrix_tikz_loaded_bool - { - \tikzpicture - \__nicematrix_vdottedline_i:n { #1 } - \endtikzpicture - } - { - \pgfpicture - \__nicematrix_vdottedline_i:n { #1 } - \endpgfpicture - } + \tikzpicture + \__nicematrix_vdottedline_i:n { #1 } + \endtikzpicture + } + { + \pgfpicture + \__nicematrix_vdottedline_i:n { #1 } + \endpgfpicture } } \cs_new_protected:Npn \__nicematrix_vdottedline_i:n #1 { - \bool_if:NT \c__nicematrix_colortbl_loaded_bool \CT@arc@ + \CT@arc@ \pgfrememberpicturepositiononpagetrue - \__nicematrix_qpoint: { col - \int_eval:n { #1 + 1 } } + \__nicematrix_qpoint:n { col - \int_eval:n { #1 + 1 } } \dim_set:Nn \l__nicematrix_x_initial_dim { \pgf@x - \l__nicematrix_radius_dim } \dim_set:Nn \l__nicematrix_x_final_dim { \pgf@x - \l__nicematrix_radius_dim } - \__nicematrix_qpoint: { row - 1 } + \__nicematrix_qpoint:n { row - 1 } \dim_set:Nn \l__nicematrix_y_initial_dim { \pgf@y - 0.5 \l__nicematrix_inter_dots_dim } - \__nicematrix_qpoint: { row - \__nicematrix_succ:n \c@iRow } + \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \c@iRow } \dim_set:Nn \l__nicematrix_y_final_dim { \pgf@y + 0.5 \l__nicematrix_inter_dots_dim } \tl_set_eq:NN \l__nicematrix_xdots_line_style_tl \c__nicematrix_standard_tl \__nicematrix_draw_line: @@ -2600,7 +3125,7 @@ \dim_compare:nNnT { \dim_use:c { l__nicematrix_row _ \__nicematrix_i: _ min _ dim } } = \c_max_dim { - \__nicematrix_qpoint: { row - \__nicematrix_i: - base } + \__nicematrix_qpoint:n { row - \__nicematrix_i: - base } \dim_set:cn { l__nicematrix_row _ \__nicematrix_i: _ max _ dim } \pgf@y \dim_set:cn { l__nicematrix_row _ \__nicematrix_i: _ min _ dim } \pgf@y } @@ -2610,7 +3135,7 @@ \dim_compare:nNnT { \dim_use:c { l__nicematrix_column _ \__nicematrix_j: _ min _ dim } } = \c_max_dim { - \__nicematrix_qpoint: { col - \__nicematrix_j: } + \__nicematrix_qpoint:n { col - \__nicematrix_j: } \dim_set:cn { l__nicematrix_column _ \__nicematrix_j: _ max _ dim } \pgf@y \dim_set:cn { l__nicematrix_column _ \__nicematrix_j: _ min _ dim } \pgf@y } @@ -2779,26 +3304,29 @@ \pgfpicture \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse - \__nicematrix_qpoint: { row - #1 } + \__nicematrix_qpoint:n { row - #1 } \dim_set_eq:NN \l_tmpa_dim \pgf@y - \__nicematrix_qpoint: { col - #2 } + \__nicematrix_qpoint:n { col - #2 } \dim_set_eq:NN \l_tmpb_dim \pgf@x - \__nicematrix_qpoint: { row - \__nicematrix_succ:n { #3 } } + \__nicematrix_qpoint:n { row - \__nicematrix_succ:n { #3 } } \dim_set_eq:NN \l_tmpc_dim \pgf@y - \__nicematrix_qpoint: { col - \__nicematrix_succ:n { #4 } } + \__nicematrix_qpoint:n { col - \__nicematrix_succ:n { #4 } } \dim_set_eq:NN \l_tmpd_dim \pgf@x \bool_if:NT \l__nicematrix_white_bool { \begin { pgfscope } \pgfsetfillcolor { white } - \int_compare:nNnT { #2 } = 1 + \pgfpathrectanglecorners { - \int_compare:nNnT \l__nicematrix_first_col_int = 1 - { \dim_add:Nn \l_tmpb_dim \arrayrulewidth } + \pgfpoint + { \l_tmpb_dim + 0.5 \arrayrulewidth } + { \l_tmpa_dim - 0.5 \arrayrulewidth } + } + { + \pgfpoint + { \l_tmpd_dim - 0.5 \arrayrulewidth } + { \l_tmpc_dim + 0.5 \arrayrulewidth } } - \pgfpathrectanglecorners - { \pgfpoint \l_tmpb_dim { \l_tmpa_dim - \arrayrulewidth } } - { \pgfpoint { \l_tmpd_dim - \arrayrulewidth } \l_tmpc_dim } \pgfusepathqfill \end { pgfscope } } @@ -2817,14 +3345,14 @@ } \int_compare:nNnTF { #1 } = { #3 } { - \pgfextracty \l_tmpa_dim { \__nicematrix_qpoint: { row - #1 - base } } - \__nicematrix_qpoint: { #1 - #2 - block } + \pgfextracty \l_tmpa_dim { \__nicematrix_qpoint:n { row - #1 - base } } + \__nicematrix_qpoint:n { #1 - #2 - block } \pgftransformshift { \pgfpoint \pgf@x \l_tmpa_dim } \pgfnode { rectangle } { base } { \box_use_drop:N \l__nicematrix_cell_box } { } { } } { - \pgftransformshift { \__nicematrix_qpoint: { #1 - #2 - block } } + \pgftransformshift { \__nicematrix_qpoint:n { #1 - #2 - block } } \pgfnode { rectangle } { center } { \box_use_drop:N \l__nicematrix_cell_box } { } { } } @@ -2895,6 +3423,60 @@ \__nicematrix_define_com:nnn v | | \__nicematrix_define_com:nnn V \| \| \__nicematrix_define_com:nnn B \{ \} +\NewDocumentCommand \AutoNiceMatrix { O { } m O { } m ! O { } } + { + \group_begin: + \bool_set_true:N \l__nicematrix_NiceArray_bool + \AutoNiceMatrixWithDelims . . { #2 } { #4 } [ #1 , #3 , #5 ] + \group_end: + } +\cs_set_eq:NN \__nicematrix_dotfill \dotfill +\cs_new_protected:Npn \__nicematrix_dotfill: + { + \__nicematrix_dotfill + \group_insert_after:N \__nicematrix_dotfill_i: + } +\cs_new_protected:Npn \__nicematrix_dotfill_i: { \group_insert_after:N \__nicematrix_dotfill_ii: } +\cs_new_protected:Npn \__nicematrix_dotfill_ii: { \group_insert_after:N \__nicematrix_dotfill_iii: } +\cs_new_protected:Npn \__nicematrix_dotfill_iii: + { \dim_compare:nNnT { \box_wd:N \l__nicematrix_cell_box } = \c_zero_dim \__nicematrix_dotfill } +\cs_new_protected:Npn \__nicematrix_slashbox:nn #1 #2 + { + \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl + { + \__nicematrix_actually_slashbox:nnnn + { \int_use:N \c@iRow } { \int_use:N \c@jCol } { #1 } { #2 } + } + } +\cs_new_protected:Npn \__nicematrix_actually_slashbox:nnnn #1 #2 #3 #4 + { + \pgfpicture + \pgf@relevantforpicturesizefalse + \pgfrememberpicturepositiononpagetrue + \__nicematrix_qpoint:n { row - #1 } + \dim_set_eq:NN \l_tmpa_dim \pgf@y + \__nicematrix_qpoint:n { col - #2 } + \dim_set_eq:NN \l_tmpb_dim \pgf@x + \pgfpathmoveto { \pgfpoint \l_tmpb_dim \l_tmpa_dim } + \__nicematrix_qpoint:n { row - \__nicematrix_succ:n { #1 } } + \dim_set_eq:NN \l_tmpc_dim \pgf@y + \__nicematrix_qpoint:n { col - \__nicematrix_succ:n { #2 } } + \dim_set_eq:NN \l_tmpd_dim \pgf@x + \pgfpathlineto { \pgfpoint \l_tmpd_dim \l_tmpc_dim } + { + \CT@arc@ + \pgfsetroundcap + \pgfusepathqstroke + } + \pgfset { inner~sep = 1 pt } + \pgfscope + \pgftransformshift { \pgfpoint \l_tmpb_dim \l_tmpc_dim } + \pgfnode { rectangle } { south~west } { $ #3 $ } { } { } + \endpgfscope + \pgftransformshift { \pgfpoint \l_tmpd_dim \l_tmpa_dim } + \pgfnode { rectangle } { north~east } { $ #4 $ } { } { } + \endpgfpicture + } \cs_new_protected:Npn \__nicematrix_CodeAfter:n #1 \end { \tl_gput_right:Nn \g__nicematrix_code_after_tl { #1 } @@ -2902,14 +3484,22 @@ } \cs_new_protected:Npn \__nicematrix_CodeAfter_i:n #1 { - \bool_if:NTF { \str_if_eq_p:Vn \g__nicematrix_name_env_str { #1 } } + \str_set:NV \l_tmpa_str \@currenvir + \bool_if:NTF { \str_if_eq_p:Vn \l_tmpa_str { #1 } } { \end { #1 } } { \tl_gput_right:Nn \g__nicematrix_code_after_tl { \end { #1 } } \__nicematrix_CodeAfter:n } } -\bool_new:N \c__nicematrix_obsolete_environments_bool +\__nicematrix_msg_new:nn { obsolete~environments } + { + The~obsolete~environments~(eg.~{pNiceArrayC})~have~been~deleted~ + from~the~package~nicematrix.\\ + However,~if~you~still~want~to~use~them,~you~will~find~the~code~for~ + those~environments~at~the~end~of~the~file~'nicematrix.sty',~after~ + a~command~'\token_to_str:N\file_input_stop:'. + } \keys_define:nn { NiceMatrix / Package } { renew-dots .bool_set:N = \l__nicematrix_renew_dots_bool , @@ -2918,9 +3508,7 @@ renew-matrix .value_forbidden:n = true , transparent .meta:n = { renew-dots , renew-matrix } , transparent .value_forbidden:n = true, - obsolete-environments .bool_set:N = \c__nicematrix_obsolete_environments_bool , - obsolete-environments .value_forbidden:n = true , - obsolete-environments .default:n = true , + obsolete-environments .code:n = \__nicematrix_fatal:n { obsolete~environments }, starred-commands .code:n = \__nicematrix_msg_redirect_name:nn { starred~commands } { none } , starred-commands .value_forbidden:n = true , @@ -2961,7 +3549,7 @@ } \cs_new:Npn \__nicematrix_message_hdotsfor: { - \tl_if_empty:VF \g__nicematrix_Hdotsfor_lines_tl + \tl_if_empty:VF \g__nicematrix_HVdotsfor_lines_tl { ~Maybe~your~use~of~\token_to_str:N \Hdotsfor\ is~incorrect.} } \__nicematrix_msg_new:nn { too~much~cols~for~matrix~with~last~col } @@ -2986,6 +3574,32 @@ \int_eval:n { \c@jCol - 1 }~(plus~the~potential~exterior~ones).~ This~error~is~fatal. } +\__nicematrix_msg_new:nn { in~first~col } + { + You~can't~use~the~command~#1 in~the~first~column~(number~0)~of~the~array.\\ + If~you~go~on,~this~command~will~be~ignored. + } +\__nicematrix_msg_new:nn { in~last~col } + { + You~can't~use~the~command~#1 in~the~last~column~(exterior)~of~the~array.\\ + If~you~go~on,~this~command~will~be~ignored. + } +\__nicematrix_msg_new:nn { in~first~row } + { + You~can't~use~the~command~#1 in~the~first~row~(number~0)~of~the~array.\\ + If~you~go~on,~this~command~will~be~ignored. + } +\__nicematrix_msg_new:nn { in~last~row } + { + You~can't~use~the~command~#1 in~the~last~row~(exterior)~of~the~array.\\ + If~you~go~on,~this~command~will~be~ignored. + } +\__nicematrix_msg_new:nn { option~S~without~siunitx } + { + You~can't~use~the~option~'S'~in~your~environment~\__nicematrix_full_name_env: + because~you~have~not~loaded~siunitx.\\ + If~you~go~on,~this~option~will~be~ignored. + } \__nicematrix_msg_new:nn { bad~option~for~line-style } { Since~you~haven't~loaded~Tikz,~the~only~value~you~can~give~to~'line-style'~ @@ -3043,6 +3657,13 @@ However,~you~can~go~on~for~this~time~ (the~value~'\l_keys_value_tl'~will~be~ignored). } +\__nicematrix_msg_new:nn { last-col~non~empty~for~NiceMatrixOptions } + { + In~\NiceMatrixoptions,~you~must~use~the~option~ + 'last-col'~without~value.\\ + However,~you~can~go~on~for~this~time~ + (the~value~'\l_keys_value_tl'~will~be~ignored). + } \__nicematrix_msg_new:nn { Block~too~large } { You~try~to~draw~a~block~in~the~cell~#1-#2~of~your~matrix~but~the~matrix~is~ @@ -3084,6 +3705,8 @@ The~available~options~are~(in~alphabetic~order):~ allow-duplicate-names,~ code-for-first-col,~ + cell-space-bottom-limit,~ + cell-space-top-limit,~ code-for-first-row,~ code-for-last-col,~ code-for-last-row,~ @@ -3092,8 +3715,12 @@ create-large-nodes,~ end-of-row,~ exterior-arraycolsep,~ + first-col,~ + first-row,~ hlines,~ hvlines,~ + last-col,~ + last-row,~ left-margin,~ letter-for-dotted-lines,~ light-syntax,~ @@ -3121,6 +3748,8 @@ b,~ baseline,~ c,~ + cell-space-bottom-limit,~ + cell-space-top-limit,~ code-after,~ code-for-first-col,~ code-for-first-row,~ @@ -3165,6 +3794,8 @@ b,~ baseline,~ c,~ + cell-space-bottom-limit,~ + cell-space-top-limit,~ code-after,~ code-for-first-col,~ code-for-first-row,~ @@ -3192,6 +3823,7 @@ r~(=R),~ renew-dots,~ right-margin,~ + S,~ small,~ t,~ vlines,~ @@ -3199,6 +3831,51 @@ xdots/shorten~and~ xdots/line-style. } +\__nicematrix_msg_new:nnn { Unknown~option~for~NiceTabular } + { + The~option~'\tl_use:N\l_keys_key_str'~is~unknown~for~the~environment~ + \{NiceTabular\}. \\ + If~you~go~on,~it~will~be~ignored. \\ + For~a~list~of~the~available~options,~type~H~<return>. + } + { + The~available~options~are~(in~alphabetic~order):~ + b,~ + baseline,~ + c,~ + cell-space-bottom-limit,~ + cell-space-top-limit,~ + code-after,~ + code-for-first-col,~ + code-for-first-row,~ + code-for-last-col,~ + code-for-last-row,~ + columns-width,~ + create-extra-nodes,~ + create-medium-nodes,~ + create-large-nodes,~ + end-of-row,~ + extra-left-margin,~ + extra-right-margin,~ + first-col,~ + first-row,~ + hlines,~ + hvlines,~ + last-col,~ + last-row,~ + left-margin,~ + light-syntax,~ + name,~ + nullify-dots,~ + parallelize-diags,~ + renew-dots,~ + right-margin,~ + t,~ + vlines,~ + xdots/color,~ + xdots/shorten~and~ + xdots/line-style. + } \__nicematrix_msg_new:nnn { Duplicate~name } { The~name~'\l_keys_value_tl'~is~already~used~and~you~shouldn't~use~ @@ -3223,87 +3900,85 @@ and~R~in~the~preamble~of~your~environment. \\ This~error~is~fatal. } -\bool_if:NT \c__nicematrix_obsolete_environments_bool +\file_input_stop: +\NewDocumentEnvironment { pNiceArrayC } { } { - \NewDocumentEnvironment { pNiceArrayC } { } - { - \int_zero:N \l__nicematrix_last_col_int - \pNiceArray - } - { \endpNiceArray } - \NewDocumentEnvironment { bNiceArrayC } { } - { - \int_zero:N \l__nicematrix_last_col_int - \bNiceArray - } - { \endbNiceArray } - \NewDocumentEnvironment { BNiceArrayC } { } - { - \int_zero:N \l__nicematrix_last_col_int - \BNiceArray - } - { \endBNiceArray } - \NewDocumentEnvironment { vNiceArrayC } { } - { - \int_zero:N \l__nicematrix_last_col_int - \vNiceArray - } - { \endvNiceArray } - \NewDocumentEnvironment { VNiceArrayC } { } - { - \int_zero:N \l__nicematrix_last_col_int - \VNiceArray - } - { \endVNiceArray } - \NewDocumentEnvironment { pNiceArrayRC } { } - { - \int_zero:N \l__nicematrix_last_col_int - \int_zero:N \l__nicematrix_first_row_int - \pNiceArray - } - { \endpNiceArray } - \NewDocumentEnvironment { bNiceArrayRC } { } - { - \int_zero:N \l__nicematrix_last_col_int - \int_zero:N \l__nicematrix_first_row_int - \bNiceArray - } - { \endbNiceArray } - \NewDocumentEnvironment { BNiceArrayRC } { } - { - \int_zero:N \l__nicematrix_last_col_int - \int_zero:N \l__nicematrix_first_row_int - \BNiceArray - } - { \endBNiceArray } - \NewDocumentEnvironment { vNiceArrayRC } { } - { - \int_zero:N \l__nicematrix_last_col_int - \int_zero:N \l__nicematrix_first_row_int - \vNiceArray - } - { \endvNiceArray } - \NewDocumentEnvironment { VNiceArrayRC } { } - { - \int_zero:N \l__nicematrix_last_col_int - \int_zero:N \l__nicematrix_first_row_int - \VNiceArray - } - { \endVNiceArray } - \NewDocumentEnvironment { NiceArrayCwithDelims } { } - { - \int_zero:N \l__nicematrix_last_col_int - \NiceArrayWithDelims - } - { \endNiceArrayWithDelims } - \NewDocumentEnvironment { NiceArrayRCwithDelims } { } - { - \int_zero:N \l__nicematrix_last_col_int - \int_zero:N \l__nicematrix_first_row_int - \NiceArrayWithDelims - } - { \endNiceArrayWithDelims } + \int_zero:N \l__nicematrix_last_col_int + \pNiceArray + } + { \endpNiceArray } + \NewDocumentEnvironment { bNiceArrayC } { } + { + \int_zero:N \l__nicematrix_last_col_int + \bNiceArray + } + { \endbNiceArray } +\NewDocumentEnvironment { BNiceArrayC } { } + { + \int_zero:N \l__nicematrix_last_col_int + \BNiceArray + } + { \endBNiceArray } +\NewDocumentEnvironment { vNiceArrayC } { } + { + \int_zero:N \l__nicematrix_last_col_int + \vNiceArray } + { \endvNiceArray } +\NewDocumentEnvironment { VNiceArrayC } { } + { + \int_zero:N \l__nicematrix_last_col_int + \VNiceArray + } + { \endVNiceArray } +\NewDocumentEnvironment { pNiceArrayRC } { } + { + \int_zero:N \l__nicematrix_last_col_int + \int_zero:N \l__nicematrix_first_row_int + \pNiceArray + } + { \endpNiceArray } +\NewDocumentEnvironment { bNiceArrayRC } { } + { + \int_zero:N \l__nicematrix_last_col_int + \int_zero:N \l__nicematrix_first_row_int + \bNiceArray + } + { \endbNiceArray } +\NewDocumentEnvironment { BNiceArrayRC } { } + { + \int_zero:N \l__nicematrix_last_col_int + \int_zero:N \l__nicematrix_first_row_int + \BNiceArray + } + { \endBNiceArray } +\NewDocumentEnvironment { vNiceArrayRC } { } + { + \int_zero:N \l__nicematrix_last_col_int + \int_zero:N \l__nicematrix_first_row_int + \vNiceArray + } + { \endvNiceArray } +\NewDocumentEnvironment { VNiceArrayRC } { } + { + \int_zero:N \l__nicematrix_last_col_int + \int_zero:N \l__nicematrix_first_row_int + \VNiceArray + } + { \endVNiceArray } +\NewDocumentEnvironment { NiceArrayCwithDelims } { } + { + \int_zero:N \l__nicematrix_last_col_int + \NiceArrayWithDelims + } + { \endNiceArrayWithDelims } +\NewDocumentEnvironment { NiceArrayRCwithDelims } { } + { + \int_zero:N \l__nicematrix_last_col_int + \int_zero:N \l__nicematrix_first_row_int + \NiceArrayWithDelims + } + { \endNiceArrayWithDelims } \endinput %% |