From 94b0aea54634a3d04d70edb84500ecc3199c0637 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 20 Jun 2021 19:57:12 +0000 Subject: nicematrix (20jun21) git-svn-id: svn://tug.org/texlive/trunk@59657 c570f23f-e606-0410-a88d-b1316a301751 --- .../source/latex/nicematrix/nicematrix.dtx | 952 ++++++++++----------- 1 file changed, 471 insertions(+), 481 deletions(-) (limited to 'Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx') 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 % -- cgit v1.2.3