diff options
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf | bin | 462567 -> 461406 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex | 421 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf | bin | 1305091 -> 1300431 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx | 952 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | 316 |
5 files changed, 798 insertions, 891 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 646ec7e301a..55b39da0c40 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 c80c13f352d..5339ea7ac87 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex @@ -531,11 +531,10 @@ cette clé (la valeur par défaut est 4~pt\footnote{Cette valeur par défaut est \item la clé |borders| permet de ne tracer que certaines des bordures du bloc : cette clé prend comme valeur une liste d'éléments parmi les suivants : |left|, |right|, |top| et |bottom| ; +\item les clés |t| et |b| réglent la ligne de base qui sera donnée au bloc quand +celui-ci est constitué de plusieurs lignes (séparées par la commande |\\|) ; \item \colorbox{yellow!50}{\bfseries Nouveau 5.15}\enskip la clé |hvlines| trace -tous les filets horizontaux et verticaux dans le bloc ; -\item \colorbox{yellow!50}{\bfseries Nouveau 5.14}\enskip les clés |t| et |b| -réglent la ligne de base qui sera donnée au bloc quand celui-ci est constitué de -plusieurs lignes (séparées par la commande |\\|). +tous les filets horizontaux et verticaux dans le bloc. \end{itemize} @@ -1050,12 +1049,11 @@ A & A & A & A & A & A \\ \bigskip -\colorbox{yellow!50}{\textbf{Nouveau 5.14}}\enskip Quand la clé |corners| est -utilisée, \pkg{nicematrix} calcule les coins vides et ces coins sont alors pris -en compte par les outils de tracés de filets (les filets ne seront pas tracés -dans ces coins vides). \emph{Remarque} : Dans les versions précédentes de -\pkg{nicematrix}, il n'y avait qu'une clé |hvlines-except-corners| (maintenant -considérée comme obsolète). +Quand la clé |corners| est utilisée, \pkg{nicematrix} calcule les coins vides et +ces coins sont alors pris en compte par les outils de tracés de filets (les +filets ne seront pas tracés dans ces coins vides). \emph{Remarque} : Dans les +versions précédentes de \pkg{nicematrix}, il n'y avait qu'une clé +|hvlines-except-corners| (maintenant considérée comme obsolète). \bigskip \begin{BVerbatim}[boxwidth=11cm,baseline=c] @@ -3538,28 +3536,23 @@ Dans l'exemple suivant, nous avons surligné tous les nœuds de la matrice (on explique plus loin la technique utilisée : cf. p. \pageref{highlight}). \[\begin{pNiceMatrix} +\CodeBefore [create-cell-nodes] + \begin{tikzpicture}% + [every node/.style = { inner sep = 0 pt , fill = red!15 }] + \node [fit = (1-1)] {} ; + \node [fit = (1-3)] {} ; + \node [fit = (2-2)] {} ; + \node [fit = (3-1)] {} ; + \node [fit = (3-3)] {} ; + \node [fit = (1-2)] {} ; + \node [fit = (2-1)] {} ; + \node [fit = (2-3)] {} ; + \node [fit = (3-2)] {} ; + \end{tikzpicture} +\Body a & a + b & a + b + c \\ a & a & a + b \\ a & a & a -\CodeAfter -\begin{tikzpicture}[ - every node/.style = - { - blend mode = multiply, - inner sep = 0 pt , - fill = red!15 - } - ] -\node [fit = (1-1)] {} ; -\node [fit = (1-3)] {} ; -\node [fit = (2-2)] {} ; -\node [fit = (3-1)] {} ; -\node [fit = (3-3)] {} ; -\node [fit = (1-2)] {} ; -\node [fit = (2-1)] {} ; -\node [fit = (2-3)] {} ; -\node [fit = (3-2)] {} ; -\end{tikzpicture} \end{pNiceMatrix}\] @@ -3583,25 +3576,24 @@ nom des nœuds normaux. Dans l'exemple suivant, on a surligné tous les «nœuds moyens». Nous considérons que cet exemple se suffit à lui-même comme définition de ces nœuds. \[\begin{pNiceMatrix}[create-medium-nodes] +\CodeBefore [create-cell-nodes] + \begin{tikzpicture} + [every node/.style = {fill = red!15, inner sep = 0 pt}, + name suffix = -medium] + \node [fit = (1-1)] {} ; + \node [fit = (1-2)] {} ; + \node [fit = (1-3)] {} ; + \node [fit = (2-1)] {} ; + \node [fit = (2-2)] {} ; + \node [fit = (2-3)] {} ; + \node [fit = (3-1)] {} ; + \node [fit = (3-2)] {} ; + \node [fit = (3-3)] {} ; +\end{tikzpicture} +\Body a & a + b & a + b + c \\ a & a & a + b \\ a & a & a -\CodeAfter -\begin{tikzpicture} - [every node/.style = {fill = red!15, - blend mode = multiply, - inner sep = 0 pt}, - name suffix = -medium] -\node [fit = (1-1)] {} ; -\node [fit = (1-2)] {} ; -\node [fit = (1-3)] {} ; -\node [fit = (2-1)] {} ; -\node [fit = (2-2)] {} ; -\node [fit = (2-3)] {} ; -\node [fit = (3-1)] {} ; -\node [fit = (3-2)] {} ; -\node [fit = (3-3)] {} ; -\end{tikzpicture} \end{pNiceMatrix}\] @@ -3614,24 +3606,24 @@ de ces nœuds.\footnote{Il n'y a pas de «nœuds larges» créés dans les rangà p.~\pageref{exterior}).} \[\begin{pNiceMatrix}[create-large-nodes] +\CodeBefore [create-cell-nodes] + \begin{tikzpicture} + [every node/.style = { inner sep = 0 pt} , + name suffix = -large] + \node [fit = (1-1),fill = red!15] {} ; + \node [fit = (1-3),fill = red!15] {} ; + \node [fit = (2-2),fill = red!15] {} ; + \node [fit = (3-1),fill = red!15] {} ; + \node [fit = (3-3),fill = red!15] {} ; + \node [fit = (1-2),fill = blue!15] {} ; + \node [fit = (2-1),fill = blue!15] {} ; + \node [fit = (2-3),fill = blue!15] {} ; + \node [fit = (3-2),fill = blue!15] {} ; + \end{tikzpicture} +\Body a & a + b & a + b + c \\ a & a & a + b \\ a & a & a -\CodeAfter -\begin{tikzpicture} - [every node/.style = {blend mode = multiply, - inner sep = 0 pt}, - name suffix = -large] -\node [fit = (1-1),fill = red!15] {} ; -\node [fit = (1-3),fill = red!15] {} ; -\node [fit = (2-2),fill = red!15] {} ; -\node [fit = (3-1),fill = red!15] {} ; -\node [fit = (3-3),fill = red!15] {} ; -\node [fit = (1-2),fill = blue!15] {} ; -\node [fit = (2-1),fill = blue!15] {} ; -\node [fit = (2-3),fill = blue!15] {} ; -\node [fit = (3-2),fill = blue!15] {} ; -\end{tikzpicture} \end{pNiceMatrix}\] @@ -3647,24 +3639,24 @@ utilisé les options |left-margin| et |right-margin|.\footnote{Les options elle est égale à |\arraycolsep| (valeur initiale : 5~pt). Il existe aussi une option |margin| pour fixer à la fois |left-margin| et |right-margin|.} \[\begin{pNiceMatrix}[create-large-nodes,left-margin,right-margin] +\CodeBefore [create-cell-nodes] + \begin{tikzpicture} + [every node/.style = {inner sep = 0 pt}, + name suffix = -large] + \node [fit = (1-1),fill = red!15] {} ; + \node [fit = (1-3),fill = red!15] {} ; + \node [fit = (2-2),fill = red!15] {} ; + \node [fit = (3-1),fill = red!15] {} ; + \node [fit = (3-3),fill = red!15] {} ; + \node [fit = (1-2),fill = blue!15] {} ; + \node [fit = (2-1),fill = blue!15] {} ; + \node [fit = (2-3),fill = blue!15] {} ; + \node [fit = (3-2),fill = blue!15] {} ; + \end{tikzpicture} +\Body a & a + b & a + b + c \\ a & a & a + b \\ a & a & a -\CodeAfter -\begin{tikzpicture} - [every node/.style = {blend mode = multiply, - inner sep = 0 pt}, - name suffix = -large] -\node [fit = (1-1),fill = red!15] {} ; -\node [fit = (1-3),fill = red!15] {} ; -\node [fit = (2-2),fill = red!15] {} ; -\node [fit = (3-1),fill = red!15] {} ; -\node [fit = (3-3),fill = red!15] {} ; -\node [fit = (1-2),fill = blue!15] {} ; -\node [fit = (2-1),fill = blue!15] {} ; -\node [fit = (2-3),fill = blue!15] {} ; -\node [fit = (3-2),fill = blue!15] {} ; -\end{tikzpicture} \end{pNiceMatrix}\] \medskip @@ -3674,24 +3666,24 @@ incorporées dans les «nœuds larges». Dans l'exemple suivant, nous avons util |extra-left-margin| et |extra-right-margin| avec la valeur $3$~pt. \[\begin{pNiceMatrix}% [create-large-nodes,left-margin,right-margin,extra-right-margin=3pt,extra-left-margin=3pt] +\CodeBefore [create-cell-nodes] + \begin{tikzpicture} + [every node/.style = {inner sep = 0 pt}, + name suffix = -large] + \node [fit = (1-1),fill = red!15] {} ; + \node [fit = (1-3),fill = red!15] {} ; + \node [fit = (2-2),fill = red!15] {} ; + \node [fit = (3-1),fill = red!15] {} ; + \node [fit = (3-3),fill = red!15] {} ; + \node [fit = (1-2),fill = blue!15] {} ; + \node [fit = (2-1),fill = blue!15] {} ; + \node [fit = (2-3),fill = blue!15] {} ; + \node [fit = (3-2),fill = blue!15] {} ; +\end{tikzpicture} +\Body a & a + b & a + b + c \\ a & a & a + b \\ a & a & a -\CodeAfter -\begin{tikzpicture} - [every node/.style = {blend mode = multiply, - inner sep = 0 pt}, - name suffix = -large] -\node [fit = (1-1),fill = red!15] {} ; -\node [fit = (1-3),fill = red!15] {} ; -\node [fit = (2-2),fill = red!15] {} ; -\node [fit = (3-1),fill = red!15] {} ; -\node [fit = (3-3),fill = red!15] {} ; -\node [fit = (1-2),fill = blue!15] {} ; -\node [fit = (2-1),fill = blue!15] {} ; -\node [fit = (2-3),fill = blue!15] {} ; -\node [fit = (3-2),fill = blue!15] {} ; -\end{tikzpicture} \end{pNiceMatrix}\] @@ -3748,28 +3740,38 @@ Voici maintenant tous les «nœuds larges» de ce tableau (sans utilisation de \begin{scope} \large \begin{NiceTabular}[c]{w{l}{2cm}ll}[hvlines,create-large-nodes] +\CodeBefore [create-cell-nodes] + \begin{tikzpicture} + [every node/.style = {inner sep = 0 pt}, + name suffix = -large] + \node [fit = (1-1),fill = red!15] {} ; + \node [fit = (1-3),fill = red!15] {} ; + \node [fit = (2-2),fill = red!15] {} ; + \node [fit = (3-1),fill = red!15] {} ; + \node [fit = (3-3),fill = red!15] {} ; + \node [fit = (1-2),fill = blue!15] {} ; + \node [fit = (2-1),fill = blue!15] {} ; + \node [fit = (2-3),fill = blue!15] {} ; + \node [fit = (3-2),fill = blue!15] {} ; + \end{tikzpicture} +\Body fraise & amande & abricot \\ prune & pêche & poire \\[1ex] noix & noisette & brugnon -\CodeAfter -\begin{tikzpicture} - [every node/.style = {blend mode = multiply, - inner sep = 0 pt}, - name suffix = -large] -\node [fit = (1-1),fill = red!15] {} ; -\node [fit = (1-3),fill = red!15] {} ; -\node [fit = (2-2),fill = red!15] {} ; -\node [fit = (3-1),fill = red!15] {} ; -\node [fit = (3-3),fill = red!15] {} ; -\node [fit = (1-2),fill = blue!15] {} ; -\node [fit = (2-1),fill = blue!15] {} ; -\node [fit = (2-3),fill = blue!15] {} ; -\node [fit = (3-2),fill = blue!15] {} ; -\end{tikzpicture} \end{NiceTabular} \end{scope} +\vspace{1cm} +Les nœuds que l'on vient de décrire ne sont pas accessibles par défaut dans le +|\CodeBefore| (décrit p.~\pageref{code-before}). \par\nobreak + +\colorbox{yellow!50}{\textbf{Nouveau 5.16}}\enskip On peut rendre ces nœuds +accessibles dans le |\CodeBefore| en utilisant la clé |create-cell-nodes| du +mot-clé |\CodeBefore| (dans ce cas-là , les nœuds sont créés une première fois +avant la construction du tableau en utilisant des informations écrites dans le +fichier |aux| puis recréés lors de la composition du tableau proprement dit). + \subsection{Les nœuds indiquant la position des filets} @@ -3779,11 +3781,8 @@ L'extension \pkg{nicematrix} crée un nœud PGF-Tikz nommé simplement $i$ (pré du préfixe habituel) à l'intersection du filet horizontal de numéro $i$ et du filet vertical de numéro~$i$ (ou plutôt la position potentielle de ces filets car ils ne sont peut-être pas tracés). Le dernier nœud a aussi un alias nommé -simplement |last|. - -\smallskip -\colorbox{yellow!50}{\textbf{Nouveau 5.14}}\enskip Il existe aussi un nœud nommé -$i$|.5| à mi-chemin entre le nœud $i$ et le nœud $i+1$. +simplement |last|. Il existe aussi un nœud nommé $i$|.5| à mi-chemin entre le +nœud $i$ et le nœud $i+1$. Ces nœuds sont accessibles dans le |\CodeAfter| mais aussi dans le |\CodeBefore|. @@ -4759,17 +4758,12 @@ suivantes dans le préambule du document : \medskip Nous créons un nœud Tikz rectangulaire qui englobe les nœuds de la deuxième -rangée en utilisant les outils de la bibliothèque Tikz \pkg{fit}. Ce nœud est -rempli après la construction de la matrice. Pour que l'on puisse voir le texte -\emph{sous} le nœud, nous devons utiliser la transparence avec le |blend mode| -égal à |multiply|. \textbf{Attention} : Certains lecteurs de \textsc{pdf} -n'affichent pas la transparence.\footnote{Dans Overleaf, the lecteur de - \textsc{PDF} «intégré» n'affiche pas la transparence. On peut sélectionner le - lecteur «natif» dans ce cas-là .} +rangée en utilisant les outils de la bibliothèque Tikz \pkg{fit}. Ces nœuds ne +sont pas créés par défaut dans le |\CodeBefore| (par souci d'efficacité). Il +faut utiliser la clé |create-cell-nodes| du |\CodeBefore| pour demander leur création. \tikzset{highlight/.style={rectangle, fill=red!15, - blend mode = multiply, rounded corners = 0.5 mm, inner sep=1pt, fit=#1}} @@ -4778,119 +4772,59 @@ n'affichent pas la transparence.\footnote{Dans Overleaf, the lecteur de \begin{Verbatim} \tikzset{highlight/.style={rectangle, fill=red!15, - ~emphase#blend mode = multiply@, rounded corners = 0.5 mm, inner sep=1pt, fit=~#1}} $\begin{bNiceMatrix} +~emphase#\CodeBefore [create-cell-nodes] @ +~emphase# \tikz \node [highlight = (2-1) (2-3)] {} ; @ +~emphase# \Body @ 0 & \Cdots & 0 \\ 1 & \Cdots & 1 \\ 0 & \Cdots & 0 \\ -~emphase#\CodeAfter \tikz \node [highlight = (2-1) (2-3)] {} ;@ \end{bNiceMatrix}$ \end{Verbatim} \[\begin{bNiceMatrix} +\CodeBefore [create-cell-nodes] + \tikz \node [highlight = (2-1) (2-3)] {} ; +\Body 0 & \Cdots & 0 \\ 1 & \Cdots & 1 \\ 0 & \Cdots & 0 \\ -\CodeAfter \tikz \node [highlight = (2-1) (2-3)] {} ; \end{bNiceMatrix}\] -\vspace{1cm} On rappelle que dans le cas d'un ensemble de cases fusionnées (avec -la commande |\Block|), un nœud Tikz est créé pour l'ensemble des cases avec pour -nom $i$|-|$j$|-block| où $i$ et $j$ sont les numéros de ligne et de colonne de -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{BVerbatim}[baseline=c,boxwidth=11.6cm] -$\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} -On considère maintenant la matrice suivante que l'on a appelée |exemple|. +On considère maintenant la matrice suivante. Si on veut surligner chaque rangée +de la matrice, on peut utiliser la technique précédente trois fois. -\medskip \begin{Verbatim} -$\begin{pNiceArray}{ccc}[~emphase#name=exemple@,last-col,create-medium-nodes] -a & a + b & a + b + c & L_1 \\ -a & a & a + b & L_2 \\ -a & a & a & L_3 -\end{pNiceArray}$ -\end{Verbatim} - \[\begin{pNiceArray}{ccc}[last-col] +\CodeBefore [create-cell-nodes] + \begin{tikzpicture} +~emphase# \node [highlight = (1-1) (1-3)] {} ;@ +~emphase# \node [highlight = (2-1) (2-3)] {} ;@ +~emphase# \node [highlight = (3-1) (3-3)] {} ;@ + \end{tikzpicture} +\Body a & a + b & a + b + c & L_1 \\ a & a & a + b & L_2 \\ a & a & a & L_3 \end{pNiceArray}\] - -\bigskip -Si on veut surligner chaque rangée de la matrice, on peut utiliser la technique précédente trois fois. - -\begin{Verbatim} -\tikzset{mes-options/.style={remember picture, - overlay, - name prefix = exemple-, - highlight/.style = {fill = red!15, - blend mode = multiply, - inner sep = 0pt, - fit = ~#1}}} \end{Verbatim} - -\tikzset{mes-options/.style={remember picture, - overlay, - name prefix = exemple-, - highlight/.style = {fill = red!15, - blend mode = multiply, - inner sep = 0pt, - fit = #1}}} - - -\begin{Verbatim} -\begin{tikzpicture}[mes-options] -\node [highlight = (1-1) (1-3)] {} ; -\node [highlight = (2-1) (2-3)] {} ; -\node [highlight = (3-1) (3-3)] {} ; -\end{tikzpicture} -\end{Verbatim} - -\medskip -On obtient la matrice suivante. - -\[\begin{pNiceArray}{ccc}[ - last-col, - code-after = {\begin{tikzpicture}[highlight/.style = {fill = red!15, - blend mode = multiply, - inner sep = 0pt, - fit = #1}] - \node [highlight = (1-1) (1-3)] {} ; - \node [highlight = (2-1) (2-3)] {} ; - \node [highlight = (3-1) (3-3)] {} ; - \end{tikzpicture}}] +\[\begin{pNiceArray}{ccc}[last-col] +\CodeBefore [create-cell-nodes] + \begin{tikzpicture} + \node [highlight = (1-1) (1-3)] {} ; + \node [highlight = (2-1) (2-3)] {} ; + \node [highlight = (3-1) (3-3)] {} ; + \end{tikzpicture} +\Body a & a + b & a + b + c & L_1 \\ a & a & a + b & L_2 \\ a & a & a & L_3 @@ -4901,46 +4835,44 @@ Le résultat peut paraître décevant. On peut l'améliorer en utilisant les «n moyens» au lieu des «nœuds normaux». \begin{Verbatim} -\begin{tikzpicture}[mes-options, ~emphase#name suffix = -medium@] -\node [highlight = (1-1) (1-3)] {} ; -\node [highlight = (2-1) (2-3)] {} ; -\node [highlight = (3-1) (3-3)] {} ; -\end{tikzpicture} +\[\begin{pNiceArray}{ccc}[last-col,create-medium-nodes] +\CodeBefore [create-cell-nodes] + \begin{tikzpicture} ~emphase#[name suffix = -medium]@ + \node [highlight = (1-1) (1-3)] {} ; + \node [highlight = (2-1) (2-3)] {} ; + \node [highlight = (3-1) (3-3)] {} ; + \end{tikzpicture} +\Body +a & a + b & a + b + c & L_1 \\ +a & a & a + b & L_2 \\ +a & a & a & L_3 +\end{pNiceArray}\] \end{Verbatim} -\medskip -On obtient la matrice suivante. \[\begin{pNiceArray}{ccc}[last-col,create-medium-nodes] +\CodeBefore [create-cell-nodes] + \begin{tikzpicture} [name suffix = -medium] + \node [highlight = (1-1) (1-3)] {} ; + \node [highlight = (2-1) (2-3)] {} ; + \node [highlight = (3-1) (3-3)] {} ; + \end{tikzpicture} +\Body a & a + b & a + b + c & L_1 \\ a & a & a + b & L_2 \\ -a & a & a & L_3 \\ -\CodeAfter -\begin{tikzpicture}[highlight/.style = {fill = red!15, - blend mode = multiply, - inner sep = 0pt, - fit = #1}, - name suffix = -medium] -\node [highlight = (1-1) (1-3)] {} ; -\node [highlight = (2-1) (2-3)] {} ; -\node [highlight = (3-1) (3-3)] {} ; -\end{tikzpicture} +a & a & a & L_3 \end{pNiceArray}\] -\subsection{Utilisation de \textbackslash SubMatrix dans le code-before} +\subsection{Utilisation de \textbackslash SubMatrix dans le \textbackslash CodeBefore} Dans l'exemple suivant, on illustre le produit mathématique de deux matrices. L'ensemble de la figure est un environnement |{NiceArray}| et les trois paires -de parenthèses ont été rajoutées avec |\SubMatrix| dans le |code-before|. +de parenthèses ont été rajoutées avec |\SubMatrix| dans le |\CodeBefore|. + -Ceux qui sont intéressés par le code correspondant le trouveront dans le fichier -source de ce document. -% -% -% \tikzset{highlight/.style={rectangle, fill=red!15, rounded corners = 0.5 mm, @@ -4975,6 +4907,43 @@ source de ce document. \end{NiceArray}\] +\vspace{1cm} +\begin{Verbatim} +\tikzset{highlight/.style={rectangle, + fill=red!15, + rounded corners = 0.5 mm, + inner sep=1pt, + fit=~#1}} +\end{Verbatim} + +\begin{Verbatim}[formatcom = \small\color{gray}] +\[\begin{NiceArray}{*{6}{c}~LetterAt{\hspace{6mm}}*{5}{c}}[nullify-dots] +\CodeBefore [create-cell-nodes] + \SubMatrix({2-7}{6-11}) + \SubMatrix({7-2}{11-6}) + \SubMatrix({7-7}{11-11}) + \begin{tikzpicture} + \node [highlight = (9-2) (9-6)] { } ; + \node [highlight = (2-9) (6-9)] { } ; + \end{tikzpicture} +\Body + & & & & & & & & \color{blue}\scriptstyle C_j \\ + & & & & & & b_{11} & \Cdots & b_{1j} & \Cdots & b_{1n} \\ + & & & & & & \Vdots & & \Vdots & & \Vdots \\ + & & & & & & & & b_{kj} \\ + & & & & & & & & \Vdots \\ + & & & & & & b_{n1} & \Cdots & b_{nj} & \Cdots & b_{nn} \\[3mm] + & a_{11} & \Cdots & & & a_{1n} \\ + & \Vdots & & & & \Vdots & & & \Vdots \\ +\color{blue}\scriptstyle L_i + & a_{i1} & \Cdots & a_{ik} & \Cdots & a_{in} & \Cdots & & c_{ij} \\ + & \Vdots & & & & \Vdots \\ + & a_{n1} & \Cdots & & & a_{nn} \\ +\CodeAfter +\tikz \draw [gray,shorten > = 1mm, shorten < = 1mm] (9-4.north) to [bend left] (4-9.west) ; +\end{NiceArray}\] +\end{Verbatim} + \section*{Autre documentation} diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf Binary files differindex b096ea1e0fe..40b867d72eb 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 32206348c07..43fb1accbd8 100644 --- a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx +++ b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx @@ -15,8 +15,8 @@ % % \fi % \iffalse -\def\myfileversion{5.15b} -\def\myfiledate{2021/06/05} +\def\myfileversion{5.16} +\def\myfiledate{2021/06/20} % % %<*batchfile> @@ -386,7 +386,9 @@ version 2005/12/01 or later. % \end{minipage} % % \medskip -% However, it's also possible to use the tools of \pkg{booktabs}: |\toprule|, +% However, it's also possible to use the tools of +% \pkg{booktabs}\footnote{The extension \pkg{booktabs} is \emph{not} loaded +% by \pkg{nicematrix}.}: |\toprule|, % |\bottomrule|, |\midrule|, etc.\par\nobreak % % \smallskip @@ -577,11 +579,10 @@ version 2005/12/01 or later. % \item the key |borders| provides the ability to draw only some borders of the % blocks; the value of that key is a (comma-separated) list of elements covered % by |left|, |right|, |top| and |bottom|; +% \item the keys |t| and |b| fix the base line that will be given to the block +% when it has a multi-line content (the lines are separated by |\\|); % \item \colorbox{yellow!50}{\bfseries New 5.15}\enskip the keys |hvlines| draws -% all the vertical and horizontal rules in the block; -% \item \colorbox{yellow!50}{\bfseries New 5.14}\enskip the keys |t| and |b| fix -% the base line that will be given to the block when it has a multi-line content -% (the lines are separated by |\\|). +% all the vertical and horizontal rules in the block. % \end{itemize} % % \interitem @@ -1067,11 +1068,11 @@ version 2005/12/01 or later. % \end{NiceTabular} % % \bigskip -% \colorbox{yellow!50}{\textbf{New 5.14}}\enskip When the key |corners| is used, -% \pkg{nicematrix} computes the (empty) corners and these corners will be taken -% into account by the tools for drawing the rules (the rules won't be drawn in -% the corners). \emph{Remark}: In the previous versions of \pkg{nicematrix}, -% there was only a key |hvlines-except-corners| (now considered as obsolete). +% When the key |corners| is used, \pkg{nicematrix} computes the (empty) corners +% and these corners will be taken into account by the tools for drawing the +% rules (the rules won't be drawn in the corners). \emph{Remark}: In the +% previous versions of \pkg{nicematrix}, there was only a key +% |hvlines-except-corners| (now considered as obsolete). % % \bigskip % \begin{BVerbatim}[boxwidth=11cm,baseline=c] @@ -3252,7 +3253,7 @@ version 2005/12/01 or later. % exists) has also the number~$0$.}. Of course, the user must not change the % value of these counters which are used internally by \pkg{nicematrix}. % -% In the |code-before| (cf. p. \pageref{code-before}) and in the |\CodeAfter| +% In the |\CodeBefore| (cf. p. \pageref{code-before}) and in the |\CodeAfter| % (cf. p. \pageref{code-after}), |iRow| represents the total number of rows % (excepted the potential exterior rows) and |jCol| represents the total number % of columns (excepted the potential exterior columns). @@ -3489,26 +3490,26 @@ version 2005/12/01 or later. % In the following example, we have underlined all the nodes of the matrix (we % explain below the technic used : cf. p. \pageref{highlight}). % -% \[\begin{pNiceMatrix}[ -% code-after = {\begin{tikzpicture} -% [every node/.style = {blend mode = multiply, -% fill = red!15, -% inner sep = 0 pt }] -% \node [fit = (1-1)] {} ; -% \node [fit = (1-3)] {} ; -% \node [fit = (2-2)] {} ; -% \node [fit = (3-1)] {} ; -% \node [fit = (3-3)] {} ; -% \node [fit = (1-2)] {} ; -% \node [fit = (2-1)] {} ; -% \node [fit = (2-3)] {} ; -% \node [fit = (3-2)] {} ; -% \end{tikzpicture}}] +% +% \[\begin{pNiceMatrix} +% \CodeBefore [create-cell-nodes] +% \begin{tikzpicture}% +% [every node/.style = { inner sep = 0 pt , fill = red!15 }] +% \node [fit = (1-1)] {} ; +% \node [fit = (1-3)] {} ; +% \node [fit = (2-2)] {} ; +% \node [fit = (3-1)] {} ; +% \node [fit = (3-3)] {} ; +% \node [fit = (1-2)] {} ; +% \node [fit = (2-1)] {} ; +% \node [fit = (2-3)] {} ; +% \node [fit = (3-2)] {} ; +% \end{tikzpicture} +% \Body % a & a + b & a + b + c \\ % a & a & a + b \\ % a & a & a % \end{pNiceMatrix}\] -% % % % \subsection{The ``medium nodes'' and the ``large nodes''} @@ -3529,23 +3530,22 @@ version 2005/12/01 or later. % ``|-medium|'' to the names of the ``normal nodes''. In the following example, % we have underlined the ``medium nodes''. We consider that this example is % self-explanatory. -% \[\begin{pNiceMatrix}[ -% create-medium-nodes, -% code-after = {\begin{tikzpicture} -% [every node/.style = {fill = red!15, -% blend mode = multiply, -% inner sep = 0pt}, -% name suffix = -medium] -% \node [fit = (1-1)] {} ; -% \node [fit = (1-2)] {} ; -% \node [fit = (1-3)] {} ; -% \node [fit = (2-1)] {} ; -% \node [fit = (2-2)] {} ; -% \node [fit = (2-3)] {} ; -% \node [fit = (3-1)] {} ; -% \node [fit = (3-2)] {} ; -% \node [fit = (3-3)] {} ; -% \end{tikzpicture}}] +% \[\begin{pNiceMatrix}[create-medium-nodes] +% \CodeBefore [create-cell-nodes] +% \begin{tikzpicture} +% [every node/.style = {fill = red!15, inner sep = 0 pt}, +% name suffix = -medium] +% \node [fit = (1-1)] {} ; +% \node [fit = (1-2)] {} ; +% \node [fit = (1-3)] {} ; +% \node [fit = (2-1)] {} ; +% \node [fit = (2-2)] {} ; +% \node [fit = (2-3)] {} ; +% \node [fit = (3-1)] {} ; +% \node [fit = (3-2)] {} ; +% \node [fit = (3-3)] {} ; +% \end{tikzpicture} +% \Body % a & a + b & a + b + c \\ % a & a & a + b \\ % a & a & a @@ -3558,27 +3558,27 @@ version 2005/12/01 or later. % we have underlined the ``large nodes''. We consider that this example is % self-explanatory.\footnote{There is no ``large nodes'' created in the exterior % rows and columns (for these rows and columns, cf. p.~\pageref{exterior}).} -% -% \[\begin{pNiceMatrix}[ -% create-large-nodes, -% code-after = {\begin{tikzpicture} -% [every node/.style = {blend mode = multiply, -% inner sep = 0pt}, -% name suffix = -large] -% \node [fit = (1-1),fill = red!15] {} ; -% \node [fit = (1-3),fill = red!15] {} ; -% \node [fit = (2-2),fill = red!15] {} ; -% \node [fit = (3-1),fill = red!15] {} ; -% \node [fit = (3-3),fill = red!15] {} ; -% \node [fit = (1-2),fill = blue!15] {} ; -% \node [fit = (2-1),fill = blue!15] {} ; -% \node [fit = (2-3),fill = blue!15] {} ; -% \node [fit = (3-2),fill = blue!15] {} ; -% \end{tikzpicture}}] +% \[\begin{pNiceMatrix}[create-large-nodes] +% \CodeBefore [create-cell-nodes] +% \begin{tikzpicture} +% [every node/.style = { inner sep = 0 pt} , +% name suffix = -large] +% \node [fit = (1-1),fill = red!15] {} ; +% \node [fit = (1-3),fill = red!15] {} ; +% \node [fit = (2-2),fill = red!15] {} ; +% \node [fit = (3-1),fill = red!15] {} ; +% \node [fit = (3-3),fill = red!15] {} ; +% \node [fit = (1-2),fill = blue!15] {} ; +% \node [fit = (2-1),fill = blue!15] {} ; +% \node [fit = (2-3),fill = blue!15] {} ; +% \node [fit = (3-2),fill = blue!15] {} ; +% \end{tikzpicture} +% \Body % a & a + b & a + b + c \\ % a & a & a + b \\ % a & a & a % \end{pNiceMatrix}\] +% % % % \medskip @@ -3591,26 +3591,27 @@ version 2005/12/01 or later. % value is given, the default value is used, which is |\arraycolsep| (by % default: 5~pt). There is also an option |margin| to fix both |left-margin| and % |right-margin| to the same value.} -% \[\begin{pNiceMatrix}[ -% create-large-nodes,left-margin,right-margin, -% code-after = {\begin{tikzpicture} -% [every node/.style = {blend mode = multiply, -% inner sep = 0pt}, -% name suffix = -large] -% \node [fit = (1-1),fill = red!15] {} ; -% \node [fit = (1-3),fill = red!15] {} ; -% \node [fit = (2-2),fill = red!15] {} ; -% \node [fit = (3-1),fill = red!15] {} ; -% \node [fit = (3-3),fill = red!15] {} ; -% \node [fit = (1-2),fill = blue!15] {} ; -% \node [fit = (2-1),fill = blue!15] {} ; -% \node [fit = (2-3),fill = blue!15] {} ; -% \node [fit = (3-2),fill = blue!15] {} ; -% \end{tikzpicture}}] +% \[\begin{pNiceMatrix}[create-large-nodes,left-margin,right-margin] +% \CodeBefore [create-cell-nodes] +% \begin{tikzpicture} +% [every node/.style = {inner sep = 0 pt}, +% name suffix = -large] +% \node [fit = (1-1),fill = red!15] {} ; +% \node [fit = (1-3),fill = red!15] {} ; +% \node [fit = (2-2),fill = red!15] {} ; +% \node [fit = (3-1),fill = red!15] {} ; +% \node [fit = (3-3),fill = red!15] {} ; +% \node [fit = (1-2),fill = blue!15] {} ; +% \node [fit = (2-1),fill = blue!15] {} ; +% \node [fit = (2-3),fill = blue!15] {} ; +% \node [fit = (3-2),fill = blue!15] {} ; +% \end{tikzpicture} +% \Body % a & a + b & a + b + c \\ % a & a & a + b \\ % a & a & a % \end{pNiceMatrix}\] +% % % \medskip % It's also possible to add more space on both side of the array with the @@ -3618,22 +3619,22 @@ version 2005/12/01 or later. % incorporated in the ``large nodes''. It's possible to fix both values with the % option |extra-margin| and, in the following example, we use |extra-margin| % with the value $3$~pt. -% \[\begin{pNiceMatrix}[ -% create-large-nodes,margin,extra-margin=3pt, -% code-after = {\begin{tikzpicture} -% [every node/.style = {blend mode = multiply, -% inner sep = 0 pt}, -% name suffix = -large] -% \node [fit = (1-1),fill = red!15] {} ; -% \node [fit = (1-3),fill = red!15] {} ; -% \node [fit = (2-2),fill = red!15] {} ; -% \node [fit = (3-1),fill = red!15] {} ; -% \node [fit = (3-3),fill = red!15] {} ; -% \node [fit = (1-2),fill = blue!15] {} ; -% \node [fit = (2-1),fill = blue!15] {} ; -% \node [fit = (2-3),fill = blue!15] {} ; -% \node [fit = (3-2),fill = blue!15] {} ; -% \end{tikzpicture}}] +% \[\begin{pNiceMatrix}[create-large-nodes,left-margin,right-margin,extra-right-margin=3pt,extra-left-margin=3pt] +% \CodeBefore [create-cell-nodes] +% \begin{tikzpicture} +% [every node/.style = {inner sep = 0 pt}, +% name suffix = -large] +% \node [fit = (1-1),fill = red!15] {} ; +% \node [fit = (1-3),fill = red!15] {} ; +% \node [fit = (2-2),fill = red!15] {} ; +% \node [fit = (3-1),fill = red!15] {} ; +% \node [fit = (3-3),fill = red!15] {} ; +% \node [fit = (1-2),fill = blue!15] {} ; +% \node [fit = (2-1),fill = blue!15] {} ; +% \node [fit = (2-3),fill = blue!15] {} ; +% \node [fit = (3-2),fill = blue!15] {} ; +% \end{tikzpicture} +% \Body % a & a + b & a + b + c \\ % a & a & a + b \\ % a & a & a @@ -3693,22 +3694,22 @@ version 2005/12/01 or later. % \hspace{1.5cm} % \begin{scope} % \large -% \begin{NiceTabular}[c]{wl{2cm}ll}[hvlines, -% create-large-nodes, -% code-after = {\begin{tikzpicture} -% [every node/.style = {blend mode = multiply, -% inner sep = 0 pt}, -% name suffix = -large] -% \node [fit = (1-1),fill = red!15] {} ; -% \node [fit = (1-3),fill = red!15] {} ; -% \node [fit = (2-2),fill = red!15] {} ; -% \node [fit = (3-1),fill = red!15] {} ; -% \node [fit = (3-3),fill = red!15] {} ; -% \node [fit = (1-2),fill = blue!15] {} ; -% \node [fit = (2-1),fill = blue!15] {} ; -% \node [fit = (2-3),fill = blue!15] {} ; -% \node [fit = (3-2),fill = blue!15] {} ; -% \end{tikzpicture}}] +% \begin{NiceTabular}[c]{w{l}{2cm}ll}[hvlines,create-large-nodes] +% \CodeBefore [create-cell-nodes] +% \begin{tikzpicture} +% [every node/.style = {inner sep = 0 pt}, +% name suffix = -large] +% \node [fit = (1-1),fill = red!15] {} ; +% \node [fit = (1-3),fill = red!15] {} ; +% \node [fit = (2-2),fill = red!15] {} ; +% \node [fit = (3-1),fill = red!15] {} ; +% \node [fit = (3-3),fill = red!15] {} ; +% \node [fit = (1-2),fill = blue!15] {} ; +% \node [fit = (2-1),fill = blue!15] {} ; +% \node [fit = (2-3),fill = blue!15] {} ; +% \node [fit = (3-2),fill = blue!15] {} ; +% \end{tikzpicture} +% \Body % fraise & amande & abricot \\ % prune & pêche & poire \\[1ex] % noix & noisette & brugnon @@ -3716,7 +3717,15 @@ version 2005/12/01 or later. % \end{scope} % % +% \vspace{1cm} +% The nodes we have described are not available by default in the |\CodeBefore| +% (described p.~\pageref{code-before}).\par\nobreak % +% \colorbox{yellow!50}{\textbf{New 5.16}}\enskip It's possible to have these +% nodes available in the |\CodeBefore| by using the key |create-cell-nodes| of +% the keyword |\CodeBefore| (in that case, the nodes are created first before +% the construction of the array by using informations written on the |aux| file +% and created a second time during the contruction of the array itself). % % \subsection{The nodes which indicate the position of the rules} % @@ -3725,10 +3734,8 @@ version 2005/12/01 or later. % the classical prefix) at the intersection of the horizontal rule of number~$i$ % and the vertical rule of number~$i$ (more specifically the potential position % of those rules because maybe there are not actually drawn). The last node has -% also an alias called |last|. -% -% \colorbox{yellow!50}{\textbf{New 5.14}}\enskip There is also a node called -% $i$|.5| midway between the node $i$ and the node $i+1$. +% also an alias called |last|. There is also a node called $i$|.5| midway +% between the node $i$ and the node $i+1$. % % These nodes are available in the |\CodeBefore| and the |\CodeAfter|. % @@ -4690,9 +4697,14 @@ version 2005/12/01 or later. % \usetikzlibrary{fit} % \end{verbatim} % +% \medskip +% We create a rectangular Tikz node which encompasses the nodes of the second +% row by using the tools of the Tikz library \pkg{fit}. Those nodes are not +% available by default in the |\CodeBefore| (for efficiency). We have to require +% their creation with the key |create-cell-nodes| of the keyword |\CodeBefore|. +% % \tikzset{highlight/.style={rectangle, % fill=red!15, -% blend mode = multiply, % rounded corners = 0.5 mm, % inner sep=1pt, % fit = #1}} @@ -4701,120 +4713,58 @@ version 2005/12/01 or later. % \begin{Verbatim} % \tikzset{highlight/.style={rectangle, % fill=red!15, -% ~emphase#blend mode = multiply@, % rounded corners = 0.5 mm, % inner sep=1pt, -% fit = ~#1}} +% fit=~#1}} % -% % $\begin{bNiceMatrix} +% ~emphase#\CodeBefore [create-cell-nodes] @ +% ~emphase# \tikz \node [highlight = (2-1) (2-3)] {} ; @ +% ~emphase# \Body @ % 0 & \Cdots & 0 \\ % 1 & \Cdots & 1 \\ % 0 & \Cdots & 0 \\ -% ~emphase#\CodeAfter \tikz \node [highlight = (2-1) (2-3)] {} ;@ % \end{bNiceMatrix}$ % \end{Verbatim} % \[\begin{bNiceMatrix} +% \CodeBefore [create-cell-nodes] +% \tikz \node [highlight = (2-1) (2-3)] {} ; +% \Body % 0 & \Cdots & 0 \\ % 1 & \Cdots & 1 \\ % 0 & \Cdots & 0 \\ -% \CodeAfter \tikz \node [highlight = (2-1) (2-3)] {} ; % \end{bNiceMatrix}\] % -% -% -% \vspace{1cm} -% We recall that, for a rectangle of merged cells (with the command |\Block|), a -% Tikz node is created for the set of merged cells with the name -% $i$|-|$j$-|block| where $i$ and $j$ are the number of the row and the number -% of the column of the upper left cell (where the command |\Block| has been -% issued). If the user has required the creation of the |medium| nodes, a node -% of this type is also created with a name suffixed by |-medium|. -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=11.6cm] -% $\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} -% Consider now the following matrix which we have named |example|. +% We consider now the following matrix. If we want to highlight each row of +% this matrix, we can use the previous technique three times. % -% \medskip % \begin{Verbatim} -% $\begin{pNiceArray}{ccc}[~emphase#name=example@,last-col,create-medium-nodes] -% a & a + b & a + b + c & L_1 \\ -% a & a & a + b & L_2 \\ -% a & a & a & L_3 -% \end{pNiceArray}$ -% \end{Verbatim} -% % \[\begin{pNiceArray}{ccc}[last-col] +% \CodeBefore [create-cell-nodes] +% \begin{tikzpicture} +% ~emphase# \node [highlight = (1-1) (1-3)] {} ;@ +% ~emphase# \node [highlight = (2-1) (2-3)] {} ;@ +% ~emphase# \node [highlight = (3-1) (3-3)] {} ;@ +% \end{tikzpicture} +% \Body % a & a + b & a + b + c & L_1 \\ % a & a & a + b & L_2 \\ % a & a & a & L_3 % \end{pNiceArray}\] -% -% \bigskip -% If we want to highlight each row of this matrix, we can use the previous -% technique three times. -% -% \begin{Verbatim} -% \tikzset{mes-options/.style={remember picture, -% overlay, -% name prefix = exemple-, -% highlight/.style = {fill = red!15, -% blend mode = multiply, -% inner sep = 0pt, -% fit = ~#1}}} -% \end{Verbatim} -% -% -% \tikzset{mes-options/.style={remember picture, -% overlay, -% name prefix = exemple-, -% highlight/.style = {fill = red!15, -% blend mode = multiply, -% inner sep = 0pt, -% fit = #1}}} -% -% \begin{Verbatim} -% \begin{tikzpicture}[mes-options] -% \node [highlight = (1-1) (1-3)] {} ; -% \node [highlight = (2-1) (2-3)] {} ; -% \node [highlight = (3-1) (3-3)] {} ; -% \end{tikzpicture} % \end{Verbatim} % % -% \medskip -% We obtain the following matrix. -% -% \[\begin{pNiceArray}{ccc}[ -% last-col, -% code-after = {\begin{tikzpicture}[every node/.style = {fill = red!15, -% blend mode = multiply, -% inner sep = 0pt}] -% \node [fit = (1-1) (1-3)] {} ; -% \node [fit = (2-1) (2-3)] {} ; -% \node [fit = (3-1) (3-3)] {} ; -% \end{tikzpicture}}] -% a & a + b & a + b + c & L_1\\ +% \[\begin{pNiceArray}{ccc}[last-col] +% \CodeBefore [create-cell-nodes] +% \begin{tikzpicture} +% \node [highlight = (1-1) (1-3)] {} ; +% \node [highlight = (2-1) (2-3)] {} ; +% \node [highlight = (3-1) (3-3)] {} ; +% \end{tikzpicture} +% \Body +% a & a + b & a + b + c & L_1 \\ % a & a & a + b & L_2 \\ % a & a & a & L_3 % \end{pNiceArray}\] @@ -4824,28 +4774,29 @@ version 2005/12/01 or later. % nodes'' instead of the ``normal nodes''. % % \begin{Verbatim} -% \begin{tikzpicture}[mes-options, ~emphase#name suffix = -medium@] -% \node [highlight = (1-1) (1-3)] {} ; -% \node [highlight = (2-1) (2-3)] {} ; -% \node [highlight = (3-1) (3-3)] {} ; -% \end{tikzpicture} +% \[\begin{pNiceArray}{ccc}[last-col,create-medium-nodes] +% \CodeBefore [create-cell-nodes] +% \begin{tikzpicture} ~emphase#[name suffix = -medium]@ +% \node [highlight = (1-1) (1-3)] {} ; +% \node [highlight = (2-1) (2-3)] {} ; +% \node [highlight = (3-1) (3-3)] {} ; +% \end{tikzpicture} +% \Body +% a & a + b & a + b + c & L_1 \\ +% a & a & a + b & L_2 \\ +% a & a & a & L_3 +% \end{pNiceArray}\] % \end{Verbatim} % -% \medskip -% We obtain the following matrix. -% -% \[\begin{pNiceArray}{ccc}[ -% last-col, -% create-medium-nodes, -% code-after = {\begin{tikzpicture}[highlight/.style = {fill = red!15, -% blend mode = multiply, -% inner sep = 0pt, -% fit = #1}, -% name suffix = -medium] -% \node [highlight = (1-1) (1-3)] {} ; -% \node [highlight = (2-1) (2-3)] {} ; -% \node [highlight = (3-1) (3-3)] {} ; -% \end{tikzpicture}}] +% +%\[\begin{pNiceArray}{ccc}[last-col,create-medium-nodes] +% \CodeBefore [create-cell-nodes] +% \begin{tikzpicture} [name suffix = -medium] +% \node [highlight = (1-1) (1-3)] {} ; +% \node [highlight = (2-1) (2-3)] {} ; +% \node [highlight = (3-1) (3-3)] {} ; +% \end{tikzpicture} +% \Body % a & a + b & a + b + c & L_1 \\ % a & a & a + b & L_2 \\ % a & a & a & L_3 @@ -4858,10 +4809,8 @@ version 2005/12/01 or later. % matrices. % % The whole figure is an environment |{NiceArray}| and the three pairs of -% parenthesis have been added with |\SubMatrix| in the |code-before|. +% parenthesis have been added with |\SubMatrix| in the |\CodeBefore|. % -% You will find the LaTeX code of that figure in the source file of this -% document. % \tikzset{highlight/.style={rectangle, % fill=red!15, % rounded corners = 0.5 mm, @@ -4893,6 +4842,44 @@ version 2005/12/01 or later. % \tikz \draw [gray,shorten > = 1mm, shorten < = 1mm] (9-4.north) to [bend left] (4-9.west) ; % \end{NiceArray}\] % +% +% \vspace{1cm} +% \begin{Verbatim} +% \tikzset{highlight/.style={rectangle, +% fill=red!15, +% rounded corners = 0.5 mm, +% inner sep=1pt, +% fit=~#1}} +% \end{Verbatim} +% +% \begin{Verbatim}[formatcom = \small\color{gray}] +% \[\begin{NiceArray}{*{6}{c}~LetterAt{\hspace{6mm}}*{5}{c}}[nullify-dots] +% \CodeBefore [create-cell-nodes] +% \SubMatrix({2-7}{6-11}) +% \SubMatrix({7-2}{11-6}) +% \SubMatrix({7-7}{11-11}) +% \begin{tikzpicture} +% \node [highlight = (9-2) (9-6)] { } ; +% \node [highlight = (2-9) (6-9)] { } ; +% \end{tikzpicture} +% \Body +% & & & & & & & & \color{blue}\scriptstyle C_j \\ +% & & & & & & b_{11} & \Cdots & b_{1j} & \Cdots & b_{1n} \\ +% & & & & & & \Vdots & & \Vdots & & \Vdots \\ +% & & & & & & & & b_{kj} \\ +% & & & & & & & & \Vdots \\ +% & & & & & & b_{n1} & \Cdots & b_{nj} & \Cdots & b_{nn} \\[3mm] +% & a_{11} & \Cdots & & & a_{1n} \\ +% & \Vdots & & & & \Vdots & & & \Vdots \\ +% \color{blue}\scriptstyle L_i +% & a_{i1} & \Cdots & a_{ik} & \Cdots & a_{in} & \Cdots & & c_{ij} \\ +% & \Vdots & & & & \Vdots \\ +% & a_{n1} & \Cdots & & & a_{nn} \\ +% \CodeAfter +% \tikz \draw [gray,shorten > = 1mm, shorten < = 1mm] (9-4.north) to [bend left] (4-9.west) ; +% \end{NiceArray}\] +% \end{Verbatim} +% % %\section{Implementation} % @@ -5048,10 +5035,38 @@ version 2005/12/01 or later. \cs_if_exist:NT \rvtx@ifformat@geq { \bool_set_true:N \c_@@_revtex_bool } % \end{macrocode} % -% +% \bigskip % \begin{macrocode} \cs_generate_variant:Nn \tl_if_single_token_p:n { V } % \end{macrocode} +% +% \bigskip +% The following regex will be used to modify the preamble of the array when the +% key |colortbl-like| is used. +% \begin{macrocode} +\regex_const:Nn \c_@@_columncolor_regex { \c { columncolor } } +% \end{macrocode} +% +% \bigskip +% If the final user uses \pkg{nicematrix}, PGF/Tikz will write instruction +% |\pgfsyspdfmark| in the |aux| file. If he changes its mind and no longer loads +% \pkg{nicematrix}, an error may occur at the next compilation because of +% remanent instructions |\pgfsyspdfmark| in the |aux| file. With the following +% code, we try to avoid that situation. +% \begin{macrocode} +\cs_new_protected:Npn \@@_provide_pgfsyspdfmark: + { + \iow_now:Nn \@mainaux + { + \ExplSyntaxOn + \cs_if_free:NT \pgfsyspdfmark + { \cs_set_eq:NN \pgfsyspdfmark \@gobblethree } + \ExplSyntaxOff + } + \cs_gset_eq:NN \@@_provide_pgfsyspdfmark: \prg_do_nothing: + } +% \end{macrocode} +% % % \bigskip % We define a command |\iddots| similar to |\ddots| ($\ddots$) but with dots @@ -5342,53 +5357,33 @@ version 2005/12/01 or later. % |\c_@@_table_print_tl| when the version of \pkg{siunitx} is prior to 3.0. The % command |\@@_adapt_S_column| is used in the environment |{NiceArrayWithDelims}|. % \begin{macrocode} -\cs_set_protected:Npn \@@_adapt_S_column: +\AtBeginDocument { - \bool_if:NT \c_@@_siunitx_loaded_bool - { - \group_begin: - \@temptokena = { } - \cs_set_eq:NN \NC@find \prg_do_nothing: - \NC@rewrite@S { } - \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 } } - \cs_gset_eq:NN \@@_adapt_S_column: \prg_do_nothing: + \cs_set_eq:NN \@@_adapt_S_column: \prg_do_nothing: + \bool_lazy_and:nnT + { \c_@@_siunitx_loaded_bool } + { ! \cs_if_exist_p:N \siunitx_cell_begin:w } + { + \cs_set_protected:Npn \@@_adapt_S_column: + { + \group_begin: + \@temptokena = { } + \cs_set_eq:NN \NC@find \prg_do_nothing: + \NC@rewrite@S { } + \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 } } + \cs_gset_eq:NN \@@_adapt_S_column: \prg_do_nothing: + } } } % \end{macrocode} % % -% \bigskip -% The following regex will be used to modify the preamble of the array when the -% key |colortbl-like| is used. -% \begin{macrocode} -\regex_const:Nn \c_@@_columncolor_regex { \c { columncolor } } -% \end{macrocode} -% -% \bigskip -% If the final user uses \pkg{nicematrix}, PGF/Tikz will write instruction -% |\pgfsyspdfmark| in the |aux| file. If he changes its mind and no longer loads -% \pkg{nicematrix}, an error may occur at the next compilation because of -% remanent instructions |\pgfsyspdfmark| in the |aux| file. With the following -% code, we try to avoid that situation. -% \begin{macrocode} -\cs_new_protected:Npn \@@_provide_pgfsyspdfmark: - { - \iow_now:Nn \@mainaux - { - \ExplSyntaxOn - \cs_if_free:NT \pgfsyspdfmark - { \cs_set_eq:NN \pgfsyspdfmark \@gobblethree } - \ExplSyntaxOff - } - \cs_gset_eq:NN \@@_provide_pgfsyspdfmark: \prg_do_nothing: - } -% \end{macrocode} % % \bigskip % \subsection*{Parameters} @@ -5550,6 +5545,15 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip +% We will write in |\g_@@_aux_tl| all the instructions that we have to write on +% the |aux| file for the current environment. The contain of that token list +% will be written on the |aux| file at the end of the environment (in an +% instruction |\tl_gset:cn { c_@@_ \int_use:N \g_@@_env_int _ tl }|). +% \begin{macrocode} +\tl_new:N \g_@@_aux_tl +% \end{macrocode} +% +% \bigskip % \begin{macrocode} \cs_new_protected:Npn \@@_test_if_math_mode: { @@ -5795,6 +5799,17 @@ version 2005/12/01 or later. % \end{macrocode} % % \medskip +% The sequence |\g_@@_multicolumn_cells_seq| will contain the list of the cells +% of the array where a command |\multicolumn{|$n$|}{...}{...}| with $n>1$ is +% issued. In |\g_@@_multicolumn_sizes_seq|, the ``sizes'' (that is to say the +% values of $n$) correspondant will be stored. These lists will be used for the +% creation of the ``medium nodes'' (if they are created). +% \begin{macrocode} +\seq_new:N \g_@@_multicolumn_cells_seq +\seq_new:N \g_@@_multicolumn_sizes_seq +% \end{macrocode} +% +% \medskip % The following counters will be used when searching the extremities of a dotted % line (we need these counters because of the potential ``open'' lines in the % |\SubMatrix|---the |\SubMatrix| in the |code-before|). @@ -5854,7 +5869,7 @@ version 2005/12/01 or later. % \medskip % The parameters of position of the label of a block. For the horizontal % position, the possible values are |c|, |r| and |l|. For the vertical position, -% the possible values are |c|, |t| and |b|. Of course, it would be intesting to +% the possible values are |c|, |t| and |b|. Of course, it would be interesting to % program a key |T| and a key |B|. % \begin{macrocode} \tl_new:N \l_@@_hpos_of_block_tl @@ -7075,6 +7090,8 @@ version 2005/12/01 or later. \endpgfpicture } % \end{macrocode} +% Remark: If the key |recreate-cell-nodes| of the |\CodeBefore| is used, then we +% will add some lines to that command. % % % \interitem @@ -7244,7 +7261,7 @@ version 2005/12/01 or later. % \medskip % As its name says, the following command is a patch for the command % |\@@_node_for_cell:|. This patch will be appended on the left of -% |\@@_noce_for_the_cell:| when the construction of the cell nodes (of the forme +% |\@@_node_for_the_cell:| when the construction of the cell nodes (of the form % |(i-j)|) in the |\CodeBefore| is required. % \begin{macrocode} \cs_new_protected:Npn \@@_patch_node_for_cell:n #1 @@ -7278,6 +7295,8 @@ version 2005/12/01 or later. } % \end{macrocode} % +% \bigskip +% We have no explanation for the different behaviour between the TeX engines... % \begin{macrocode} \bool_lazy_or:nnTF \sys_if_engine_xetex_p: \sys_if_output_dvi_p: { @@ -7546,12 +7565,6 @@ version 2005/12/01 or later. \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_@@_old_iRow_int \c@iRow } - \int_gzero_new:N \c@iRow - \cs_if_exist:NT \thejCol - { \int_set_eq:NN \l_@@_old_jCol_int \c@jCol } - \int_gzero_new:N \c@jCol \normalbaselines % \end{macrocode} % If the option |small| is used, we have to do some tuning. In particular, we @@ -7567,6 +7580,17 @@ version 2005/12/01 or later. } % \end{macrocode} % +% \bigskip +% \begin{macrocode} + \bool_if:NT \g_@@_recreate_cell_nodes_bool + { + \tl_put_right:Nn \@@_begin_of_row: + { + \pgfsys@markposition + { \@@_env: - row - \int_use:N \c@iRow - base } + } + } +% \end{macrocode} % % \bigskip % The environment |{array}| uses internally the command |\ialign|. We change the @@ -7662,8 +7686,8 @@ version 2005/12/01 or later. % values of $n$) correspondant will be stored. These lists will be used for the % creation of the ``medium nodes'' (if they are created). % \begin{macrocode} - \seq_gclear_new:N \g_@@_multicolumn_cells_seq - \seq_gclear_new:N \g_@@_multicolumn_sizes_seq + \seq_gclear:N \g_@@_multicolumn_cells_seq + \seq_gclear:N \g_@@_multicolumn_sizes_seq % \end{macrocode} % % @@ -7724,18 +7748,45 @@ version 2005/12/01 or later. % % % \bigskip +% The command |\@@_pre_array:| will be executed after analyse of the keys of the +% environment. % \begin{macrocode} \cs_new_protected:Npn \@@_pre_array: { - \seq_gclear:N \g_@@_submatrix_seq - \bool_if:NT \l_@@_code_before_bool \@@_exec_code_before: % \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 -% the number of that last row. In this case, we try to read that value from the -% |aux| file (if it has been written on a previous run). +% \begin{macrocode} + \cs_if_exist:NT \theiRow { \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_@@_old_jCol_int \c@jCol } + \int_gzero_new:N \c@jCol +% \end{macrocode} +% +% \bigskip +% We recall that |\l_@@_last_row_int| and |\l_@@_last_column_int| are \emph{not} +% the numbers of the last row and last column of the array. There are only the +% values of the keys |last-row| and |last-column| (maybe the user has provided +% erroneous values). The meaning of that counters does not change during the +% environment of \pkg{nicematrix}. There is only a slight adjustment: if the +% user have used one of those keys without value, we provide now the right value +% as read on the |aux| file (of course, it's possible only after the first compilation). +% \begin{macrocode} + \int_compare:nNnT \l_@@_last_row_int = { -1 } + { + \bool_set_true:N \l_@@_last_row_without_value_bool + \bool_if:NT \g_@@_aux_found_bool + { \int_set:Nn \l_@@_last_row_int { \seq_item:Nn \c_@@_size_seq 3 } } + } + \int_compare:nNnT \l_@@_last_col_int = { -1 } + { + \bool_if:NT \g_@@_aux_found_bool + { \int_set:Nn \l_@@_last_col_int { \seq_item:Nn \c_@@_size_seq 6 } } + } +% \end{macrocode} % +% \bigskip +% If there is a exterior row, we patch a command used in |\@@_Cell:| in order to +% keep track of some dimensions needed to the construction of that ``last row''. % \begin{macrocode} \int_compare:nNnT \l_@@_last_row_int > { -2 } { @@ -7747,58 +7798,36 @@ version 2005/12/01 or later. { \dim_max:nn \g_@@_dp_last_row_dim { \box_dp:N \l_@@_cell_box } } } } - \int_compare:nNnT \l_@@_last_row_int = { -1 } - { - \bool_set_true:N \l_@@_last_row_without_value_bool % \end{macrocode} -% A value based on the name is more reliable than a value based on the number of -% the environment. +% +% \bigskip % \begin{macrocode} - \str_if_empty:NTF \l_@@_name_str - { - \cs_if_exist:cT { @@_last_row_ \int_use:N \g_@@_env_int } - { - \int_set:Nn \l_@@_last_row_int - { \use:c { @@_last_row_ \int_use:N \g_@@_env_int } } - } - } - { - \cs_if_exist:cT { @@_last_row_ \l_@@_name_str } - { - \int_set:Nn \l_@@_last_row_int - { \use:c { @@_last_row_ \l_@@_name_str } } - } - } - } + \seq_gclear:N \g_@@_submatrix_seq % \end{macrocode} -% -% A value of $-1$ for the counter |\l_@@_last_col_int| means that the user has -% used the option |last-col| without value, that is to say without specifying -% the number of that last column. In this case, we try to read that value from -% the |aux| file (if it has been written on a previous run). +% +% \bigskip +% Now the |\CodeBefore|. +% \begin{macrocode} + \bool_if:NT \l_@@_code_before_bool \@@_exec_code_before: +% \end{macrocode} +% +% \bigskip +% The value of |\g_@@_pos_of_blocks_seq| has been written on the |aux| file and +% loaded before the (potential) execution of the |\CodeBefore|. Now, we clear +% that variable because it will be reconstructed during the creation of the +% array. % \begin{macrocode} - \int_compare:nNnT \l_@@_last_col_int = { -1 } - { - \str_if_empty:NTF \l_@@_name_str - { - \cs_if_exist:cT { @@_last_col_ \int_use:N \g_@@_env_int } - { - \int_set:Nn \l_@@_last_col_int - { \use:c { @@_last_col_ \int_use:N \g_@@_env_int } } - } - } - { - \cs_if_exist:cT { @@_last_col_ \l_@@_name_str } - { - \int_set:Nn \l_@@_last_col_int - { \use:c { @@_last_col_ \l_@@_name_str } } - } - } - } + \seq_gclear:N \g_@@_pos_of_blocks_seq % \end{macrocode} +% Idem for other sequences written on the |aux| file. +% \begin{macrocode} + \seq_gclear_new:N \g_@@_multicolumn_cells_seq + \seq_gclear_new:N \g_@@_multicolumn_sizes_seq +% \end{macrocode} +% % % \interitem -% The code in |\@@_pre_array_ii:| is used only by |{NiceArrayWithDelims}|. +% The code in |\@@_pre_array_ii:| is used only here. % \begin{macrocode} \@@_pre_array_ii: % \end{macrocode} @@ -7896,24 +7925,17 @@ version 2005/12/01 or later. % \end{macrocode} % First, we give values to the LaTeX counters |iRow| and |jCol|. We remind that, % in the |code-before| (and in the |\CodeAfter|) they represent the numbers of -% rows and columns of the array (without the potential last row and last column). +% rows and columns of the array (without the potential last row and last +% column). The value of |\g_@@_row_total_int| is the number of the last row +% (with potentially a last exterior row) and |\g_@@_col_total_int| is the number +% of the last column (with potentially a last exterior 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 } + \int_set:Nn \c@iRow { \seq_item:Nn \c_@@_size_seq 2 } + \int_set:Nn \c@jCol { \seq_item:Nn \c_@@_size_seq 5 } + \int_set_eq:NN \g_@@_row_total_int { \seq_item:Nn \c_@@_size_seq 3 } + \int_set_eq:NN \g_@@_col_total_int { \seq_item:Nn \c_@@_size_seq 6 } % \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 @@ -7926,9 +7948,7 @@ version 2005/12/01 or later. % \end{macrocode} % First, the recreation 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 } + \int_step_inline:nnn \l_@@_first_row_int { \g_@@_row_total_int + 1 } { \pgfsys@getposition { \@@_env: - row - ##1 } \@@_node_position: \pgfcoordinate { \@@_env: - row - ##1 } @@ -7937,9 +7957,7 @@ version 2005/12/01 or later. % \end{macrocode} % Now, the recreation 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 } + \int_step_inline:nnn \l_@@_first_col_int { \g_@@_col_total_int + 1 } { \pgfsys@getposition { \@@_env: - col - ##1 } \@@_node_position: \pgfcoordinate { \@@_env: - col - ##1 } @@ -7952,8 +7970,9 @@ version 2005/12/01 or later. \@@_create_diag_nodes: % \end{macrocode} % -% \medskip -% Now, the creation of the cell nodes |(i-j)|. +% \medskip +% Now, the creation of the cell nodes |(i-j)|, and, maybe also the ``medium +% nodes'' and the ``large nodes''. % \begin{macrocode} \bool_if:NT \g_@@_recreate_cell_nodes_bool \@@_recreate_cell_nodes: \endpgfpicture @@ -7977,18 +7996,6 @@ version 2005/12/01 or later. \cs_set_eq:NN \columncolor \@@_columncolor \cs_set_eq:NN \chessboardcolors \@@_chessboardcolors \cs_set_eq:NN \SubMatrix \@@_SubMatrix_in_code_before -% \end{macrocode} -% The list of the cells which are in the (empty) corners is stored in the |aux| -% file because we have to know it before the execution of the |\CodeBefore| (the -% commands which color the cells, rows and columns won't color the cells which -% are in the corners). -% \begin{macrocode} - \seq_if_exist:cT - { c_@@_corners_cells_ \int_use:N \g_@@_env_int _ seq } - { - \seq_set_eq:Nc \l_@@_corners_cells_seq - { c_@@_corners_cells_ \int_use:N \g_@@_env_int _ seq } - } } % \end{macrocode} % @@ -8058,7 +8065,7 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Npn \@@_CodeBefore:w #1 \q_stop { - \seq_if_exist:cT { @@_size_ \int_use:N \g_@@_env_int _ seq } + \bool_if:NT \g_@@_aux_found_bool { \@@_pre_code_before: #1 @@ -8074,17 +8081,16 @@ version 2005/12/01 or later. % nodes and |diag| nodes are available in that |\CodeBefore|. With the key % |create-cell-nodes|, the cell nodes, that is to say the nodes of the form % |(i-j)| (but not the extra nodes) are also available because those nodes also -% are recreated and that recreation is done by the following command. +% are recreated and that recreation is done by the following command. % \begin{macrocode} \cs_new_protected:Npn \@@_recreate_cell_nodes: { - \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 } + \int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int { - \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 } + \pgfsys@getposition { \@@_env: - ##1 - base } \@@_node_position: + \pgfcoordinate { \@@_env: - row - ##1 - base } + { \pgfpointdiff \@@_picture_position: \@@_node_position: } + \int_step_inline:nnn \l_@@_first_col_int \g_@@_col_total_int { \cs_if_exist:cT { pgf @ sys @ pdf @ mark @ pos @ \@@_env: - ##1 - ####1 - NW } @@ -8102,6 +8108,7 @@ version 2005/12/01 or later. } } } + \@@_create_extra_nodes: } % \end{macrocode} % @@ -8116,6 +8123,7 @@ version 2005/12/01 or later. \@@_provide_pgfsyspdfmark: \bool_if:NT \c_@@_footnote_bool \savenotes % \end{macrocode} +% % The aim of the following |\bgroup| (the corresponding |\egroup| is, of course, % at the end of the environment) is to be able to put an exposant to a matrix in % a mathematical formula. @@ -8198,14 +8206,31 @@ version 2005/12/01 or later. % \begin{macrocode} \seq_gclear:N \g_@@_pos_of_stroken_blocks_seq \seq_gclear:N \g_@@_pos_of_xdots_seq + \tl_gclear_new:N \g_@@_code_before_tl +% \end{macrocode} +% +% \bigskip +% We load all the informations written in the |aux| file during previous +% compilations corresponding to the current environment. +% \begin{macrocode} + \bool_gset_false:N \g_@@_aux_found_bool + \tl_if_exist:cT { c_@@ _ \int_use:N \g_@@_env_int _ tl } + { + \bool_gset_true:N \g_@@_aux_found_bool + \use:c { c_@@ _ \int_use:N \g_@@_env_int _ tl } + } +% \end{macrocode} +% Now, we prepare the token list for the instructions that we will have to write +% on the |aux| file at the end of the environment. +% \begin{macrocode} + \tl_gclear:N \g_@@_aux_tl % \end{macrocode} % % \begin{macrocode} - \tl_if_exist:cT { g_@@_code_before_ \int_use:N \g_@@_env_int _ tl } + \tl_if_empty:NF \g_@@_code_before_tl { \bool_set_true:N \l_@@_code_before_bool - \exp_args:NNv \tl_put_right:Nn \l_@@_code_before_tl - { g_@@_code_before_ \int_use:N \g_@@_env_int _ tl } + \tl_put_right:NV \l_@@_code_before_tl \g_@@_code_before_tl } % \end{macrocode} % @@ -8431,6 +8456,23 @@ version 2005/12/01 or later. % a mathematical formula. % \begin{macrocode} \egroup +% \end{macrocode} +% +% \bigskip +% We want to write on the |aux| file all the informations corresponding to the +% current environment. +% \begin{macrocode} + \iow_now:Nn \@mainaux { \ExplSyntaxOn } + \iow_now:Nx \@mainaux + { + \tl_gset:cn { c_@@_ \int_use:N \g_@@_env_int _ tl } + \iow_newline: { \iow_newline: \exp_not:V \g_@@_aux_tl } + } + \iow_now:Nn \@mainaux { \ExplSyntaxOff } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} \bool_if:NT \c_@@_footnote_bool \endsavenotes } % \end{macrocode} @@ -8490,7 +8532,7 @@ version 2005/12/01 or later. \@tempswatrue % \end{macrocode} % The following line actually does the expansion (it's has been copied from -% |array.sty|). +% |array.sty|). The expanded version is still in |\@temptokena|. % \begin{macrocode} \@whilesw \if@tempswa \fi { \@tempswafalse \the \NC@list } % \end{macrocode} @@ -8505,7 +8547,7 @@ version 2005/12/01 or later. % |\@@_patch_preamble:n|. In the same time, we will count the columns with the % counter |\c@jCol|. % \begin{macrocode} - \int_gzero_new:N \c@jCol + \int_gzero:N \c@jCol \tl_gclear:N \g_@@_preamble_tl \tl_if_eq:NnTF \l_@@_vlines_clist { all } { @@ -9892,102 +9934,58 @@ version 2005/12/01 or later. % % If we are in an environment without preamble (like |{NiceMatrix}| or % |{pNiceMatrix}|) and if the option |last-col| has been used without value -% we fix the real value of |\l_@@_last_col_int|. +% we also fix the real value of |\l_@@_last_col_int|. % \begin{macrocode} \bool_if:NT \l_@@_last_col_without_value_bool - { - \dim_set_eq:NN \l_@@_last_col_int \g_@@_col_total_int - \iow_shipout:Nn \@mainaux \ExplSyntaxOn - \iow_shipout:Nx \@mainaux - { - \cs_gset:cpn { @@_last_col_ \int_use:N \g_@@_env_int } - { \int_use:N \g_@@_col_total_int } - } - \str_if_empty:NF \l_@@_name_str - { - \iow_shipout:Nx \@mainaux - { - \cs_gset:cpn { @@_last_col_ \l_@@_name_str } - { \int_use:N \g_@@_col_total_int } - } - } - \iow_shipout:Nn \@mainaux \ExplSyntaxOff - } + { \int_set_eq:NN \l_@@_last_col_int \g_@@_col_total_int } % \end{macrocode} % -% It's also time to give to |\l_@@_last_row_int| its real value. But, if the -% user had used the option |last-row| without value, we write in the |aux| file -% the number of that last row for the next run. +% \medskip +% It's also time to give to |\l_@@_last_row_int| its real value. % \begin{macrocode} \bool_if:NT \l_@@_last_row_without_value_bool - { - \dim_set_eq:NN \l_@@_last_row_int \g_@@_row_total_int -% \end{macrocode} -% If the option |light-syntax| is used, we have nothing to write since, in this -% case, the number of rows is directly determined. -% \begin{macrocode} - \bool_if:NF \l_@@_light_syntax_bool - { - \iow_shipout:Nn \@mainaux \ExplSyntaxOn - \iow_shipout:Nx \@mainaux - { - \cs_gset:cpn { @@_last_row_ \int_use:N \g_@@_env_int } - { \int_use:N \g_@@_row_total_int } - } + { \int_set_eq:NN \l_@@_last_row_int \g_@@_row_total_int } % \end{macrocode} -% If the environment has a name, we also write a value based on the name -% because it's more reliable than a value based on the number of the -% environment. +% +% \medskip % \begin{macrocode} - \str_if_empty:NF \l_@@_name_str - { - \iow_shipout:Nx \@mainaux - { - \cs_gset:cpn { @@_last_row_ \l_@@_name_str } - { \int_use:N \g_@@_row_total_int } - } - } - \iow_shipout:Nn \@mainaux \ExplSyntaxOff + \tl_gput_right:Nx \g_@@_aux_tl + { + \seq_gset_from_clist:Nn \exp_not:N \c_@@_size_seq + { + \int_use:N \l_@@_first_row_int , + \int_use:N \c@iRow , + \int_use:N \g_@@_row_total_int , + \int_use:N \l_@@_first_col_int , + \int_use:N \c@jCol , + \int_use:N \g_@@_col_total_int } + \iow_newline: } % \end{macrocode} -% -% If the key |code-before| is used, we have to write on the |aux| file the actual -% size of the array and other informations. -% \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 - } -% \end{macrocode} % We write also the potential content of |\g_@@_pos_of_blocks_seq| (it will be % useful if the command |\rowcolors| is used with the key |respect-blocks|). % \begin{macrocode} - \seq_gset_from_clist:cn - { c_@@_pos_of_blocks_ \int_use:N \g_@@_env_int _ seq } + \seq_if_empty:NF \g_@@_pos_of_blocks_seq + { + \tl_gput_right:Nx \g_@@_aux_tl + { + \seq_gset_from_clist:Nn \exp_not:N \g_@@_pos_of_blocks_seq { \seq_use:Nnnn \g_@@_pos_of_blocks_seq , , , } + \iow_newline: + } + } + \seq_if_empty:NF \g_@@_multicolumn_cells_seq + { + \tl_gput_right:Nx \g_@@_aux_tl + { + \seq_gset_from_clist:Nn \exp_not:N \g_@@_multicolumn_cells_seq + { \seq_use:Nnnn \g_@@_multicolumn_cells_seq , , , } + \iow_newline: + \seq_gset_from_clist:Nn \exp_not:N \g_@@_multicolumn_sizes_seq + { \seq_use:Nnnn \g_@@_multicolumn_sizes_seq , , , } + \iow_newline: } - \iow_now:Nn \@mainaux \ExplSyntaxOff } % \end{macrocode} % @@ -10166,14 +10164,12 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_set_protected:Npn \rectanglecolor { } \cs_set_protected:Npn \columncolor { } - \iow_now:Nn \@mainaux \ExplSyntaxOn - \iow_now:Nx \@mainaux + \tl_gput_right:Nx \g_@@_aux_tl { - \tl_gset:cn - { g_@@_code_before_ \int_use:N \g_@@_env_int _ tl } + \tl_gset:Nn \exp_not:N \g_@@_code_before_tl { \exp_not:V \g_nicematrix_code_before_tl } + \iow_newline: } - \iow_now:Nn \@mainaux \ExplSyntaxOff \bool_set_true:N \l_@@_code_before_bool } % \end{macrocode} @@ -12400,19 +12396,14 @@ version 2005/12/01 or later. % color or of the second color. % \begin{macrocode} \bool_set_true:N \l_tmpa_bool - \bool_lazy_and:nnT - \l_@@_respect_blocks_bool - { - \cs_if_exist_p:c - { c_@@_pos_of_blocks_ \int_use:N \g_@@_env_int _ seq } } + \bool_if:NT \l_@@_respect_blocks_bool { % \end{macrocode} % We don't want to take into account a block which is completely in the ``first % column'' of (number $0$) or in the ``last column'' and that's why we filter % the sequence of the blocks (in a the sequence |\l_tmpa_seq|). % \begin{macrocode} - \seq_set_eq:Nc \l_tmpb_seq - { c_@@_pos_of_blocks_ \int_use:N \g_@@_env_int _ seq } + \seq_set_eq:NN \l_tmpb_seq \g_@@_pos_of_blocks_seq \seq_set_filter:NNn \l_tmpa_seq \l_tmpb_seq { \@@_not_in_exterior_p:nnnn ##1 } } @@ -12443,12 +12434,7 @@ version 2005/12/01 or later. % If the key |respect-blocks| is in force, we have to adjust that value (of % course). % \begin{macrocode} - \bool_lazy_and:nnT - \l_@@_respect_blocks_bool - { - \cs_if_exist_p:c - { c_@@_pos_of_blocks_ \int_use:N \g_@@_env_int _ seq } - } + \bool_if:NT \l_@@_respect_blocks_bool { \seq_set_filter:NNn \l_tmpb_seq \l_tmpa_seq { \@@_intersect_our_row_p:nnnn ####1 } @@ -13299,14 +13285,12 @@ version 2005/12/01 or later. % commands which color the |rows|, |columns| and |cells| must not color the % cells in the corners. % \begin{macrocode} - \iow_now:Nn \@mainaux \ExplSyntaxOn - \iow_now:Nx \@mainaux + \tl_gput_right:Nx \g_@@_aux_tl { - \seq_gset_from_clist:cn - { c_@@_corners_cells_ \int_use:N \g_@@_env_int _ seq } + \seq_set_from_clist:Nn \exp_not:N \l_@@_corners_cells_seq { \seq_use:Nnnn \l_@@_corners_cells_seq , , , } + \iow_newline: } - \iow_now:Nn \@mainaux \ExplSyntaxOff } } % \end{macrocode} @@ -17481,6 +17465,12 @@ version 2005/12/01 or later. % The version 5.15b is compatible with the version 3.0+ of \pkg{siunitx} % (previous versions were not). % +% % \subsection*{Changes between versions 5.15 and 5.16} +% +% It's now possible to use the cells corresponding to the contents of the nodes +% (of the form |i-j|) in the |\CodeBefore| when the key |create-cell-nodes| of +% that |\CodeBefore| is used. The medium and the large nodes are also available +% if the corresponding keys are used. % % \PrintIndex % diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index 51469a73836..92d14db3298 100644 --- a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty +++ b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty @@ -18,8 +18,8 @@ %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% -\def\myfileversion{5.15b} -\def\myfiledate{2021/06/05} +\def\myfileversion{5.16} +\def\myfiledate{2021/06/20} \RequirePackage{pgfcore} \usepgfmodule{shapes} \RequirePackage{l3keys2e} @@ -78,6 +78,18 @@ { } \cs_if_exist:NT \rvtx@ifformat@geq { \bool_set_true:N \c__nicematrix_revtex_bool } \cs_generate_variant:Nn \tl_if_single_token_p:n { V } +\regex_const:Nn \c__nicematrix_columncolor_regex { \c { columncolor } } +\cs_new_protected:Npn \__nicematrix_provide_pgfsyspdfmark: + { + \iow_now:Nn \@mainaux + { + \ExplSyntaxOn + \cs_if_free:NT \pgfsyspdfmark + { \cs_set_eq:NN \pgfsyspdfmark \@gobblethree } + \ExplSyntaxOff + } + \cs_gset_eq:NN \__nicematrix_provide_pgfsyspdfmark: \prg_do_nothing: + } \ProvideDocumentCommand \iddots { } { \mathinner @@ -234,36 +246,30 @@ } } } -\cs_set_protected:Npn \__nicematrix_adapt_S_column: +\AtBeginDocument { - \bool_if:NT \c__nicematrix_siunitx_loaded_bool + \cs_set_eq:NN \__nicematrix_adapt_S_column: \prg_do_nothing: + \bool_lazy_and:nnT + { \c__nicematrix_siunitx_loaded_bool } + { ! \cs_if_exist_p:N \siunitx_cell_begin:w } { - \group_begin: - \@temptokena = { } - \cs_set_eq:NN \NC@find \prg_do_nothing: - \NC@rewrite@S { } - \tl_gset:NV \g_tmpa_tl \@temptokena - \group_end: - \tl_new:N \c__nicematrix_table_collect_begin_tl - \tl_set:Nx \l_tmpa_tl { \tl_item:Nn \g_tmpa_tl 2 } - \tl_gset:Nx \c__nicematrix_table_collect_begin_tl { \tl_item:Nn \l_tmpa_tl 1 } - \tl_new:N \c__nicematrix_table_print_tl - \tl_gset:Nx \c__nicematrix_table_print_tl { \tl_item:Nn \g_tmpa_tl { -1 } } - \cs_gset_eq:NN \__nicematrix_adapt_S_column: \prg_do_nothing: + \cs_set_protected:Npn \__nicematrix_adapt_S_column: + { + \group_begin: + \@temptokena = { } + \cs_set_eq:NN \NC@find \prg_do_nothing: + \NC@rewrite@S { } + \tl_gset:NV \g_tmpa_tl \@temptokena + \group_end: + \tl_new:N \c__nicematrix_table_collect_begin_tl + \tl_set:Nx \l_tmpa_tl { \tl_item:Nn \g_tmpa_tl 2 } + \tl_gset:Nx \c__nicematrix_table_collect_begin_tl { \tl_item:Nn \l_tmpa_tl 1 } + \tl_new:N \c__nicematrix_table_print_tl + \tl_gset:Nx \c__nicematrix_table_print_tl { \tl_item:Nn \g_tmpa_tl { -1 } } + \cs_gset_eq:NN \__nicematrix_adapt_S_column: \prg_do_nothing: + } } } -\regex_const:Nn \c__nicematrix_columncolor_regex { \c { columncolor } } -\cs_new_protected:Npn \__nicematrix_provide_pgfsyspdfmark: - { - \iow_now:Nn \@mainaux - { - \ExplSyntaxOn - \cs_if_free:NT \pgfsyspdfmark - { \cs_set_eq:NN \pgfsyspdfmark \@gobblethree } - \ExplSyntaxOff - } - \cs_gset_eq:NN \__nicematrix_provide_pgfsyspdfmark: \prg_do_nothing: - } \bool_new:N \c__nicematrix_define_L_C_R_bool \cs_new_protected:Npn \__nicematrix_define_L_C_R: { @@ -293,6 +299,7 @@ \dim_new:N \l__nicematrix_tabular_width_dim \bool_new:N \l__nicematrix_Matrix_bool \bool_new:N \g__nicematrix_rotate_bool +\tl_new:N \g__nicematrix_aux_tl \cs_new_protected:Npn \__nicematrix_test_if_math_mode: { \if_mode_math: \else: @@ -337,6 +344,8 @@ \seq_new:N \g__nicematrix_pos_of_stroken_blocks_seq \seq_new:N \l__nicematrix_corners_cells_seq \seq_new:N \g__nicematrix_submatrix_names_seq +\seq_new:N \g__nicematrix_multicolumn_cells_seq +\seq_new:N \g__nicematrix_multicolumn_sizes_seq \int_new:N \l__nicematrix_row_min_int \int_new:N \l__nicematrix_row_max_int \int_new:N \l__nicematrix_col_min_int @@ -1173,18 +1182,20 @@ \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_old_iRow_int \c@iRow } - \int_gzero_new:N \c@iRow - \cs_if_exist:NT \thejCol - { \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 { \cs_set_nopar:Npn \arraystretch { 0.47 } \dim_set:Nn \arraycolsep { 1.45 pt } } + \bool_if:NT \g__nicematrix_recreate_cell_nodes_bool + { + \tl_put_right:Nn \__nicematrix_begin_of_row: + { + \pgfsys@markposition + { \__nicematrix_env: - row - \int_use:N \c@iRow - base } + } + } \cs_set_nopar:Npn \ialign { \bool_if:NTF \c__nicematrix_colortbl_loaded_bool @@ -1239,8 +1250,8 @@ \cs_set_eq:NN \NotEmpty \__nicematrix_NotEmpty: \bool_if:NT \l__nicematrix_colortbl_like_bool \__nicematrix_colortbl_like: \bool_if:NT \l__nicematrix_renew_dots_bool \__nicematrix_renew_dots: - \seq_gclear_new:N \g__nicematrix_multicolumn_cells_seq - \seq_gclear_new:N \g__nicematrix_multicolumn_sizes_seq + \seq_gclear:N \g__nicematrix_multicolumn_cells_seq + \seq_gclear:N \g__nicematrix_multicolumn_sizes_seq \int_gset:Nn \c@iRow { \l__nicematrix_first_row_int - 1 } \int_gzero_new:N \g__nicematrix_row_total_int \int_gzero_new:N \g__nicematrix_col_total_int @@ -1257,8 +1268,21 @@ } \cs_new_protected:Npn \__nicematrix_pre_array: { - \seq_gclear:N \g__nicematrix_submatrix_seq - \bool_if:NT \l__nicematrix_code_before_bool \__nicematrix_exec_code_before: + \cs_if_exist:NT \theiRow { \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_old_jCol_int \c@jCol } + \int_gzero_new:N \c@jCol + \int_compare:nNnT \l__nicematrix_last_row_int = { -1 } + { + \bool_set_true:N \l__nicematrix_last_row_without_value_bool + \bool_if:NT \g__nicematrix_aux_found_bool + { \int_set:Nn \l__nicematrix_last_row_int { \seq_item:Nn \c__nicematrix_size_seq 3 } } + } + \int_compare:nNnT \l__nicematrix_last_col_int = { -1 } + { + \bool_if:NT \g__nicematrix_aux_found_bool + { \int_set:Nn \l__nicematrix_last_col_int { \seq_item:Nn \c__nicematrix_size_seq 6 } } + } \int_compare:nNnT \l__nicematrix_last_row_int > { -2 } { \tl_put_right:Nn \__nicematrix_update_for_first_and_last_row: @@ -1269,43 +1293,11 @@ { \dim_max:nn \g__nicematrix_dp_last_row_dim { \box_dp:N \l__nicematrix_cell_box } } } } - \int_compare:nNnT \l__nicematrix_last_row_int = { -1 } - { - \bool_set_true:N \l__nicematrix_last_row_without_value_bool - \str_if_empty:NTF \l__nicematrix_name_str - { - \cs_if_exist:cT { __nicematrix_last_row_ \int_use:N \g__nicematrix_env_int } - { - \int_set:Nn \l__nicematrix_last_row_int - { \use:c { __nicematrix_last_row_ \int_use:N \g__nicematrix_env_int } } - } - } - { - \cs_if_exist:cT { __nicematrix_last_row_ \l__nicematrix_name_str } - { - \int_set:Nn \l__nicematrix_last_row_int - { \use:c { __nicematrix_last_row_ \l__nicematrix_name_str } } - } - } - } - \int_compare:nNnT \l__nicematrix_last_col_int = { -1 } - { - \str_if_empty:NTF \l__nicematrix_name_str - { - \cs_if_exist:cT { __nicematrix_last_col_ \int_use:N \g__nicematrix_env_int } - { - \int_set:Nn \l__nicematrix_last_col_int - { \use:c { __nicematrix_last_col_ \int_use:N \g__nicematrix_env_int } } - } - } - { - \cs_if_exist:cT { __nicematrix_last_col_ \l__nicematrix_name_str } - { - \int_set:Nn \l__nicematrix_last_col_int - { \use:c { __nicematrix_last_col_ \l__nicematrix_name_str } } - } - } - } + \seq_gclear:N \g__nicematrix_submatrix_seq + \bool_if:NT \l__nicematrix_code_before_bool \__nicematrix_exec_code_before: + \seq_gclear:N \g__nicematrix_pos_of_blocks_seq + \seq_gclear_new:N \g__nicematrix_multicolumn_cells_seq + \seq_gclear_new:N \g__nicematrix_multicolumn_sizes_seq \__nicematrix_pre_array_ii: \box_clear_new:N \l__nicematrix_the_array_box \bool_if:NT \c__nicematrix_define_L_C_R_bool \__nicematrix_define_L_C_R: @@ -1339,31 +1331,21 @@ } \cs_new_protected:Npn \__nicematrix_pre_code_before: { - \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 } + \int_set:Nn \c@iRow { \seq_item:Nn \c__nicematrix_size_seq 2 } + \int_set:Nn \c@jCol { \seq_item:Nn \c__nicematrix_size_seq 5 } + \int_set_eq:NN \g__nicematrix_row_total_int { \seq_item:Nn \c__nicematrix_size_seq 3 } + \int_set_eq:NN \g__nicematrix_col_total_int { \seq_item:Nn \c__nicematrix_size_seq 6 } \pgfsys@markposition { \__nicematrix_env: - position } \pgfsys@getposition { \__nicematrix_env: - position } \__nicematrix_picture_position: \pgfpicture \pgf@relevantforpicturesizefalse - \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 } + \int_step_inline:nnn \l__nicematrix_first_row_int { \g__nicematrix_row_total_int + 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 } + \int_step_inline:nnn \l__nicematrix_first_col_int { \g__nicematrix_col_total_int + 1 } { \pgfsys@getposition { \__nicematrix_env: - col - ##1 } \__nicematrix_node_position: \pgfcoordinate { \__nicematrix_env: - col - ##1 } @@ -1389,12 +1371,6 @@ \cs_set_eq:NN \columncolor \__nicematrix_columncolor \cs_set_eq:NN \chessboardcolors \__nicematrix_chessboardcolors \cs_set_eq:NN \SubMatrix \__nicematrix_SubMatrix_in_code_before - \seq_if_exist:cT - { c__nicematrix_corners_cells_ \int_use:N \g__nicematrix_env_int _ seq } - { - \seq_set_eq:Nc \l__nicematrix_corners_cells_seq - { c__nicematrix_corners_cells_ \int_use:N \g__nicematrix_env_int _ seq } - } } \cs_new_protected:Npn \__nicematrix_exec_code_before: { @@ -1426,7 +1402,7 @@ } \cs_new_protected:Npn \__nicematrix_CodeBefore:w #1 \q_stop { - \seq_if_exist:cT { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } + \bool_if:NT \g__nicematrix_aux_found_bool { \__nicematrix_pre_code_before: #1 @@ -1434,13 +1410,12 @@ } \cs_new_protected:Npn \__nicematrix_recreate_cell_nodes: { - \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 } + \int_step_inline:nnn \l__nicematrix_first_row_int \g__nicematrix_row_total_int { - \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 } + \pgfsys@getposition { \__nicematrix_env: - ##1 - base } \__nicematrix_node_position: + \pgfcoordinate { \__nicematrix_env: - row - ##1 - base } + { \pgfpointdiff \__nicematrix_picture_position: \__nicematrix_node_position: } + \int_step_inline:nnn \l__nicematrix_first_col_int \g__nicematrix_col_total_int { \cs_if_exist:cT { pgf @ sys @ pdf @ mark @ pos @ \__nicematrix_env: - ##1 - ####1 - NW } @@ -1458,6 +1433,7 @@ } } } + \__nicematrix_create_extra_nodes: } \NewDocumentEnvironment { NiceArrayWithDelims } { m m O { } m ! O { } t \CodeBefore } @@ -1494,11 +1470,18 @@ \seq_gclear:N \g__nicematrix_pos_of_blocks_seq \seq_gclear:N \g__nicematrix_pos_of_stroken_blocks_seq \seq_gclear:N \g__nicematrix_pos_of_xdots_seq - \tl_if_exist:cT { g__nicematrix_code_before_ \int_use:N \g__nicematrix_env_int _ tl } + \tl_gclear_new:N \g__nicematrix_code_before_tl + \bool_gset_false:N \g__nicematrix_aux_found_bool + \tl_if_exist:cT { c__nicematrix _ \int_use:N \g__nicematrix_env_int _ tl } + { + \bool_gset_true:N \g__nicematrix_aux_found_bool + \use:c { c__nicematrix _ \int_use:N \g__nicematrix_env_int _ tl } + } + \tl_gclear:N \g__nicematrix_aux_tl + \tl_if_empty:NF \g__nicematrix_code_before_tl { \bool_set_true:N \l__nicematrix_code_before_bool - \exp_args:NNv \tl_put_right:Nn \l__nicematrix_code_before_tl - { g__nicematrix_code_before_ \int_use:N \g__nicematrix_env_int _ tl } + \tl_put_right:NV \l__nicematrix_code_before_tl \g__nicematrix_code_before_tl } \bool_if:NTF \l__nicematrix_NiceArray_bool { \keys_set:nn { NiceMatrix / NiceArray } } @@ -1612,6 +1595,13 @@ \group_end: \__nicematrix_after_array: \egroup + \iow_now:Nn \@mainaux { \ExplSyntaxOn } + \iow_now:Nx \@mainaux + { + \tl_gset:cn { c__nicematrix_ \int_use:N \g__nicematrix_env_int _ tl } + \iow_newline: { \iow_newline: \exp_not:V \g__nicematrix_aux_tl } + } + \iow_now:Nn \@mainaux { \ExplSyntaxOff } \bool_if:NT \c__nicematrix_footnote_bool \endsavenotes } \cs_new_protected:Npn \__nicematrix_construct_preamble: @@ -1624,7 +1614,7 @@ \exp_args:NV \@temptokena \g__nicematrix_preamble_tl \@tempswatrue \@whilesw \if@tempswa \fi { \@tempswafalse \the \NC@list } - \int_gzero_new:N \c@jCol + \int_gzero:N \c@jCol \tl_gclear:N \g__nicematrix_preamble_tl \tl_if_eq:NnTF \l__nicematrix_vlines_clist { all } { @@ -2506,70 +2496,42 @@ \bool_if:NT \g__nicematrix_last_col_found_bool { \int_set_eq:NN \l__nicematrix_last_col_int \g__nicematrix_col_total_int } \bool_if:NT \l__nicematrix_last_col_without_value_bool + { \int_set_eq:NN \l__nicematrix_last_col_int \g__nicematrix_col_total_int } + \bool_if:NT \l__nicematrix_last_row_without_value_bool + { \int_set_eq:NN \l__nicematrix_last_row_int \g__nicematrix_row_total_int } + \tl_gput_right:Nx \g__nicematrix_aux_tl { - \dim_set_eq:NN \l__nicematrix_last_col_int \g__nicematrix_col_total_int - \iow_shipout:Nn \@mainaux \ExplSyntaxOn - \iow_shipout:Nx \@mainaux + \seq_gset_from_clist:Nn \exp_not:N \c__nicematrix_size_seq { - \cs_gset:cpn { __nicematrix_last_col_ \int_use:N \g__nicematrix_env_int } - { \int_use:N \g__nicematrix_col_total_int } + \int_use:N \l__nicematrix_first_row_int , + \int_use:N \c@iRow , + \int_use:N \g__nicematrix_row_total_int , + \int_use:N \l__nicematrix_first_col_int , + \int_use:N \c@jCol , + \int_use:N \g__nicematrix_col_total_int } - \str_if_empty:NF \l__nicematrix_name_str - { - \iow_shipout:Nx \@mainaux - { - \cs_gset:cpn { __nicematrix_last_col_ \l__nicematrix_name_str } - { \int_use:N \g__nicematrix_col_total_int } - } - } - \iow_shipout:Nn \@mainaux \ExplSyntaxOff + \iow_newline: } - \bool_if:NT \l__nicematrix_last_row_without_value_bool + \seq_if_empty:NF \g__nicematrix_pos_of_blocks_seq { - \dim_set_eq:NN \l__nicematrix_last_row_int \g__nicematrix_row_total_int - \bool_if:NF \l__nicematrix_light_syntax_bool + \tl_gput_right:Nx \g__nicematrix_aux_tl { - \iow_shipout:Nn \@mainaux \ExplSyntaxOn - \iow_shipout:Nx \@mainaux - { - \cs_gset:cpn { __nicematrix_last_row_ \int_use:N \g__nicematrix_env_int } - { \int_use:N \g__nicematrix_row_total_int } - } - \str_if_empty:NF \l__nicematrix_name_str - { - \iow_shipout:Nx \@mainaux - { - \cs_gset:cpn { __nicematrix_last_row_ \l__nicematrix_name_str } - { \int_use:N \g__nicematrix_row_total_int } - } - } - \iow_shipout:Nn \@mainaux \ExplSyntaxOff + \seq_gset_from_clist:Nn \exp_not:N \g__nicematrix_pos_of_blocks_seq + { \seq_use:Nnnn \g__nicematrix_pos_of_blocks_seq , , , } + \iow_newline: } } - \bool_if:NT \l__nicematrix_code_before_bool + \seq_if_empty:NF \g__nicematrix_multicolumn_cells_seq { - \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 + \tl_gput_right:Nx \g__nicematrix_aux_tl { - \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 - } - \seq_gset_from_clist:cn - { c__nicematrix_pos_of_blocks_ \int_use:N \g__nicematrix_env_int _ seq } - { \seq_use:Nnnn \g__nicematrix_pos_of_blocks_seq , , , } + \seq_gset_from_clist:Nn \exp_not:N \g__nicematrix_multicolumn_cells_seq + { \seq_use:Nnnn \g__nicematrix_multicolumn_cells_seq , , , } + \iow_newline: + \seq_gset_from_clist:Nn \exp_not:N \g__nicematrix_multicolumn_sizes_seq + { \seq_use:Nnnn \g__nicematrix_multicolumn_sizes_seq , , , } + \iow_newline: } - \iow_now:Nn \@mainaux \ExplSyntaxOff } \__nicematrix_create_diag_nodes: \bool_if:NT \l__nicematrix_parallelize_diags_bool @@ -2636,14 +2598,12 @@ { \cs_set_protected:Npn \rectanglecolor { } \cs_set_protected:Npn \columncolor { } - \iow_now:Nn \@mainaux \ExplSyntaxOn - \iow_now:Nx \@mainaux + \tl_gput_right:Nx \g__nicematrix_aux_tl { - \tl_gset:cn - { g__nicematrix_code_before_ \int_use:N \g__nicematrix_env_int _ tl } + \tl_gset:Nn \exp_not:N \g__nicematrix_code_before_tl { \exp_not:V \g_nicematrix_code_before_tl } + \iow_newline: } - \iow_now:Nn \@mainaux \ExplSyntaxOff \bool_set_true:N \l__nicematrix_code_before_bool } % \bool_if:NT \l__nicematrix_code_before_bool \__nicematrix_write_aux_for_cell_nodes: @@ -4025,14 +3985,9 @@ \tl_set:Nn \l__nicematrix_cols_tl { - } \keys_set:nn { NiceMatrix / rowcolors } { #5 } \bool_set_true:N \l_tmpa_bool - \bool_lazy_and:nnT - \l__nicematrix_respect_blocks_bool - { - \cs_if_exist_p:c - { c__nicematrix_pos_of_blocks_ \int_use:N \g__nicematrix_env_int _ seq } } + \bool_if:NT \l__nicematrix_respect_blocks_bool { - \seq_set_eq:Nc \l_tmpb_seq - { c__nicematrix_pos_of_blocks_ \int_use:N \g__nicematrix_env_int _ seq } + \seq_set_eq:NN \l_tmpb_seq \g__nicematrix_pos_of_blocks_seq \seq_set_filter:NNn \l_tmpa_seq \l_tmpb_seq { \__nicematrix_not_in_exterior_p:nnnn ##1 } } @@ -4053,12 +4008,7 @@ \int_do_until:nNnn \l_tmpa_int > \l_tmpc_int { \int_set_eq:NN \l_tmpb_int \l_tmpa_int - \bool_lazy_and:nnT - \l__nicematrix_respect_blocks_bool - { - \cs_if_exist_p:c - { c__nicematrix_pos_of_blocks_ \int_use:N \g__nicematrix_env_int _ seq } - } + \bool_if:NT \l__nicematrix_respect_blocks_bool { \seq_set_filter:NNn \l_tmpb_seq \l_tmpa_seq { \__nicematrix_intersect_our_row_p:nnnn ####1 } @@ -4592,14 +4542,12 @@ } \seq_if_empty:NF \l__nicematrix_corners_cells_seq { - \iow_now:Nn \@mainaux \ExplSyntaxOn - \iow_now:Nx \@mainaux + \tl_gput_right:Nx \g__nicematrix_aux_tl { - \seq_gset_from_clist:cn - { c__nicematrix_corners_cells_ \int_use:N \g__nicematrix_env_int _ seq } + \seq_set_from_clist:Nn \exp_not:N \l__nicematrix_corners_cells_seq { \seq_use:Nnnn \l__nicematrix_corners_cells_seq , , , } + \iow_newline: } - \iow_now:Nn \@mainaux \ExplSyntaxOff } } \cs_new_protected:Npn \__nicematrix_compute_a_corner:nnnnnn #1 #2 #3 #4 #5 #6 |