diff options
author | Karl Berry <karl@freefriends.org> | 2020-01-10 21:41:22 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-01-10 21:41:22 +0000 |
commit | 6e40e8d9ab2cae35317a09775a62ec82f295d368 (patch) | |
tree | 53cb2ded0d6b85201067d75172d208687cd413dd /Master | |
parent | f53dd329bdfa3a20947143b0ab7fc79dd58127dd (diff) |
nicematrix (10jan20)
git-svn-id: svn://tug.org/texlive/trunk@53363 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf | bin | 315057 -> 317090 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex | 92 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf | bin | 686625 -> 699309 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx | 586 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | 292 |
5 files changed, 652 insertions, 318 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 02b227ed0dd..ccc4611524c 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 883a1acf69b..1035a9bab4a 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex @@ -560,6 +560,8 @@ $\begin{pmatrix} \section{Les nœuds Tikz créés par l'extension nicematrix} +\label{name} + L'extension \pkg{nicematrix} crée un nœud Tikz pour chaque case du tableau considéré. Ces nœuds sont utilisés pour tracer les lignes en pointillés entre les cases du tableau. Toutefois, l'utilisateur peut aussi utiliser directement ces nœuds. On commence par donner un nom au tableau (avec l'option |name|). Cela étant fait, les nœuds @@ -600,17 +602,18 @@ a & a & a \bigskip -En fait, l'extension \pkg{nicematrix} peut créer des nœuds supplémentaires (\emph{extra nodes} en anglais). Ces -nouveaux nœuds sont créés si l'option |create-extra-nodes| est utilisée. Il y a deux séries de nœuds -supplémentaires : les «nœuds moyens» (\emph{medium nodes} en anglais) et les «nœuds larges» (\emph{large nodes} en -anglais). +En fait, l'extension \pkg{nicematrix} peut créer deux séries de nœuds supplémentaires (\emph{extra nodes} en +anglais) : les «nœuds moyens» (\emph{medium nodes} en anglais) et les «nœuds larges» (\emph{large nodes} en +anglais). Les premiers sont créés avec l'option |create-medium-nodes| et les seconds avec l'option +|create-large-nodes|.\footnote{Il existe aussi l'option |create-extra-nodes| qui est un alias pour la conjonction +de |create-medium-nodes| et |create-large-nodes|.} \medskip Les noms des «nœuds moyens» s'obtiennent en ajoutant le suffixe «|-medium|» au 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-extra-nodes, + create-medium-nodes, code-after = {\begin{tikzpicture} [every node/.style = {fill = red!15, blend mode = multiply, @@ -639,7 +642,7 @@ définition de ces nœuds.\footnote{Il n'y a pas de «nœuds larges» créés da (pour ces lignes et colonnes, voir p.~\pageref{exterior}).} \[\begin{pNiceMatrix}[ - create-extra-nodes, + create-large-nodes, code-after = {\begin{tikzpicture} [every node/.style = {blend mode = multiply, inner sep = -\pgflinewidth/2}, @@ -669,7 +672,7 @@ dernière colonne. Dans l'exemple suivant, nous avons utilisé les options |left aucune valeur n'est donnée, c'est la valeur par défaut qui est utilisée et elle est égale à |\arraycolsep| (par défaut, 5~pt).Il existe aussi une option |margin| pour fixer à la fois |left-margin| et |right-margin|.} \[\begin{pNiceMatrix}[ - create-extra-nodes,left-margin,right-margin, + create-large-nodes,left-margin,right-margin, code-after = {\begin{tikzpicture} [every node/.style = {blend mode = multiply, inner sep = -\pgflinewidth/2}, @@ -694,7 +697,7 @@ Il est aussi possible d'ajouter de l'espace sur les côtés du tableau avec les |extra-right-margin|. Ces marges ne sont pas incorporées dans les «nœuds larges». Dans l'exemple suivant, nous avons utilisé |extra-left-margin| et |extra-right-margin| avec la valeur $3$~pt. \[\begin{pNiceMatrix}[ - create-extra-nodes,left-margin,right-margin,extra-right-margin=3pt,extra-left-margin=3pt, + create-large-nodes,left-margin,right-margin,extra-right-margin=3pt,extra-left-margin=3pt, code-after = {\begin{tikzpicture} [every node/.style = {blend mode = multiply, inner sep = -\pgflinewidth/2}, @@ -718,7 +721,7 @@ a & a & a Dans le cas présent, si on veut un contrôle sur la hauteur des rangées, on peut ajouter un |\strut| dans chaque rangée du tableau. \[\begin{pNiceMatrix}[ - create-extra-nodes,left-margin,right-margin,extra-right-margin=3pt,extra-left-margin=3pt, + create-large-nodes,left-margin,right-margin,extra-right-margin=3pt,extra-left-margin=3pt, code-after = {\begin{tikzpicture} [every node/.style = {blend mode = multiply, inner sep = -\pgflinewidth/2}, @@ -956,6 +959,9 @@ tableau) ne s'étend pas dans les rangées extérieures.\footnote{Ce dernier poi sont pas parfaitement compatibles car \pkg{arydshln} redéfinit beaucoup de structures internes à \pkg{array}. Par ailleurs, si on veut vraiment un filet qui s'étende dans la première et la dernière rangée, on peut utiliser |!{\vline}| dans le préambule à la place de \verb+|+.} + +Si on veut définir de nouveaux spécificateurs de colonnes pour des filets (par exemple plus épais), on aura +peut-être intérêt à utiliser la commande |\OnlyMainNiceMatrix| décrite p.~\pageref{OnlyMainNiceMatrix}. \item Sans surprise, une éventuelle option |columns-width| (décrite p.~\pageref{width}) ne s'applique pas à la «première colonne» ni à la «dernière colonne». \item Pour des raisons techniques, il n'est pas possible d'utiliser l'option de la commande |\\| après la @@ -1409,6 +1415,47 @@ En revanche, les colonnes |d| de l'extension \pkg{dcolumn} ne sont pas prises en \section{Remarques techniques} +\subsection{Pour définir de nouveaux types de colonnes} + +\label{OnlyMainNiceMatrix} + +L'extension \pkg{nicematrix} fournit la commande |\OnlyMainNiceMatrix| qui est destinée à être utilisée dans des +définitions de nouveaux types de colonnes. Son argument n'est exécuté que si on se place dans la partie principale +du tableau, c'est-à-dire que l'on n'est pas dans l'une des éventuelles rangées extérieures. + +Par exemple, si on souhaite définir un type de colonne |?| pour tracer un trait fort d'épaisseur 1~pt, on pourra +écrire : +\begin{Verbatim} +\newcolumntype{?}{!{\OnlyMainNiceMatrix{\vrule width 1 pt}}} +\end{Verbatim} + +Le trait fort correspondant ne s'étendra pas dans les rangées extérieures : + +\medskip +\begin{scope} +\newcolumntype{?}{!{\OnlyMainNiceMatrix{\vrule width 1 pt}}} + +\begin{BVerbatim}[baseline = c, boxwidth = 10.5cm] +$\begin{pNiceArray}{CC?CC}[first-row,last-row] +C_1 & C_2 & C_3 & C_4 \\ +a & b & c & d \\ +e & f & g & h \\ +C_1 & C_2 & C_3 & C_4 +\end{pNiceArray}$ +\end{BVerbatim} +$\begin{pNiceArray}{CC?CC}[first-row,last-row] +C_1 & C_2 & C_3 & C_4 \\ +a & b & c & d \\ +e & f & g & h \\ +C_1 & C_2 & C_3 & C_4 +\end{pNiceArray}$ +\end{scope} + +\medskip +Le spécificateur |?| ainsi créé est aussi utilisable dans les environnements |{array}| (de \pkg{array}) et, dans ce +cas, |\OnlyMainNiceMatrix| est sans effet. + + \subsection{Intersection des lignes pointillées} Depuis la version 3.1 de \pkg{nicematrix}, les lignes en pointillées créées par |\Cdots|, |\Ldots|, |\Vdots|, etc. @@ -1445,6 +1492,20 @@ $\begin{pNiceMatrix}[nullify-dots] \end{pNiceMatrix}$ +\subsection{Le nom des nœuds Tikz créés par nicematrix} + +Les nœuds Tikz créés par \pkg{nicematrix} peuvent être utilisés hors des environnements de \pkg{nicematrix} après +avoir nommé l'environnement concerné avec l'option |name| (cf. p.~\pageref{name}). Il s'agit là de la méthode +conseillée mais on décrit néanmoins maintenant le nom Tikz interne de ces nœuds. + +Les environnements créés par \pkg{nicematrix} sont numérotés par un compteur global interne. La commande +|\NiceMatrixLastEnv| donne le numéro du dernier de ces environnements (pour LaTeX, il s'agit d'une commande — +complètement développable — et non d'un compteur). + +Si l'environnement concerné a le numéro $n$, alors le nœud de la rangée~$i$ et de la colonne~$j$ a pour nom +|nm-|$n$|-|$i$|-|$j$. Les noms des nœuds |medium| et |large| correspondants s'obtiennent suffixant par |-medium| et +|-large|. + \subsection{Lignes diagonales} Par défaut, toutes les lignes diagonales\footnote{On parle des lignes créées par |\Ddots| et non des lignes créées @@ -1948,7 +2009,7 @@ doit fixer |inner sep = -\pgflinewidth/2|. \begin{Verbatim} $\begin{pNiceArray}{>{\strut}CCCC}% - [create-extra-nodes,margin,extra-margin=2pt, + [create-large-nodes,margin,extra-margin=2pt, code-after = {\begin{tikzpicture} [~emphase#name suffix = -large@, every node/.style = {draw, @@ -1967,7 +2028,7 @@ a_{41} & a_{42} & a_{43} & a_{44} \[\begin{pNiceArray}{>{\strut}CCCC}[ - create-extra-nodes,margin,extra-margin=2pt, + create-large-nodes,margin,extra-margin=2pt, code-after = {\begin{tikzpicture}[name suffix = -large, every node/.style = {draw, inner sep = -\pgflinewidth/2}] @@ -2050,7 +2111,7 @@ On considère maintenant la matrice suivante que l'on a appelée |exemple|. \medskip \begin{Verbatim} -$\begin{pNiceArray}{CCC}[~emphase#name=exemple@,create-extra-nodes,last-col] +$\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 @@ -2097,7 +2158,6 @@ On obtient la matrice suivante. \[\begin{pNiceArray}{CCC}[ last-col, - create-extra-nodes, code-after = {\begin{tikzpicture}[every node/.style = {fill = red!15, blend mode = multiply, inner sep = 0pt}] @@ -2126,7 +2186,7 @@ On obtient la matrice suivante. \[\begin{pNiceArray}{CCC}[ last-col, - create-extra-nodes, + create-medium-nodes, code-after = {\begin{tikzpicture}[every node/.style = {fill = red!15, blend mode = multiply, inner sep = 0pt}, @@ -2146,7 +2206,7 @@ a & a & a & L_3 Dans l'exemple suivant, on utilise les «nœuds larges» pour surligner une zone de la matrice.\par\nobreak \begin{Verbatim} \left(\,\begin{NiceArray}{>{\strut}CCCC}% - [create-extra-nodes,left-margin,right-margin, + [create-large-nodes,left-margin,right-margin, code-after = {\tikz \path [~emphase#name suffix = -large@, fill = red!15, blend mode = multiply] @@ -2164,7 +2224,7 @@ A_{41} & A_{42} & A_{43} & A_{44} \end{Verbatim} \[\left(\,\begin{NiceArray}{>{\strut}CCCC}[ - create-extra-nodes,left-margin,right-margin, + create-large-nodes,left-margin,right-margin, code-after = {\tikz \path [name suffix = -large, fill = red!15, blend mode = multiply] diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf Binary files differindex da9bd49dc66..01f2e3261be 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 3b0f3fcad4a..9ccfc120b5d 100644 --- a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx +++ b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx @@ -15,8 +15,8 @@ % % \fi % \iffalse -\def\myfileversion{3.8} -\def\myfiledate{2020/01/02} +\def\myfileversion{3.9} +\def\myfiledate{2020/01/10} % % %<*batchfile> @@ -26,7 +26,7 @@ \usedir{tex/latex/nicematrix} \preamble -Copyright (C) 2018-2019 by F. Pantigny +Copyright (C) 2018-2020 by F. Pantigny ----------------------------------- This file may be distributed and/or modified under the @@ -590,6 +590,8 @@ c & c & b & a & e % % \section{The Tikz nodes created by nicematrix} % +% \label{name} +% % The package \pkg{nicematrix} creates a Tikz node for each cell of the % considered array. These nodes are used to draw the dotted lines between the % cells of the matrix. However, the user may wish to use directly these nodes. @@ -632,9 +634,12 @@ c & c & b & a & e % % % \bigskip -% In fact, the package \pkg{nicematrix} can create ``extra nodes''. These new -% nodes are created if the option |create-extra-nodes| is used. There are two -% series of extra nodes: the ``medium nodes'' and the ``large nodes''. +% In fact, the package \pkg{nicematrix} can create ``extra nodes'': the ``medium +% nodes'' and the ``large nodes''. The first ones +% are created with the option |create-medium-nodes| and the second ones with the +% option |create-large-nodes|.\footnote{There is also an option +% |create-extra-nodes| which is an alias for the conjonction of +% |create-medium-nodes| and |create-large-nodes|.} % % \medskip % The names of the ``medium nodes'' are constructed by adding the suffix @@ -642,7 +647,7 @@ c & c & b & a & e % we have underlined the ``medium nodes''. We consider that this example is % self-explanatory. % \[\begin{pNiceMatrix}[ -% create-extra-nodes, +% create-medium-nodes, % code-after = {\begin{tikzpicture} % [every node/.style = {fill = red!15, % blend mode = multiply, @@ -672,7 +677,7 @@ c & c & b & a & e % rows and columns (for these rows and columns, cf. p.~\pageref{exterior}).} % % \[\begin{pNiceMatrix}[ -% create-extra-nodes, +% create-large-nodes, % code-after = {\begin{tikzpicture} % [every node/.style = {blend mode = multiply, % inner sep = -\pgflinewidth/2}, @@ -704,7 +709,7 @@ c & c & b & a & e % default: 5~pt). There is also an option |margin| to fix both |left-margin| and % |right-margin| to the same value.} % \[\begin{pNiceMatrix}[ -% create-extra-nodes,left-margin,right-margin, +% create-large-nodes,left-margin,right-margin, % code-after = {\begin{tikzpicture} % [every node/.style = {blend mode = multiply, % inner sep = -\pgflinewidth/2}, @@ -731,7 +736,7 @@ c & c & b & a & e % option |extra-margin| and, in the following example, we use |extra-margin| % with the value $3$~pt. % \[\begin{pNiceMatrix}[ -% create-extra-nodes,margin,extra-margin=3pt, +% create-large-nodes,margin,extra-margin=3pt, % code-after = {\begin{tikzpicture} % [every node/.style = {blend mode = multiply, % inner sep = -\pgflinewidth/2}, @@ -755,7 +760,7 @@ c & c & b & a & e % In this case, if we want a control over the height of the rows, we can add a % |\strut| in each row of the array. % \[\begin{pNiceMatrix}[ -% create-extra-nodes,left-margin,right-margin,extra-right-margin=3pt, +% create-large-nodes,left-margin,right-margin,extra-right-margin=3pt, % extra-left-margin=3pt, % code-after = {\begin{tikzpicture} % [every node/.style = {blend mode = multiply, @@ -941,9 +946,9 @@ c & c & b & a & e % computed from the preamble of the array. % \item For the potential last row, the option |last-row| may, in fact, be used % without value. In this case, \pkg{nicematrix} computes, during the first -% compilation, the number of row of the array and writes that information in the -% |.aux| file for the second run. In the following example, the option -% |last-row| will be used without value. +% compilation, the number of rows of the array and writes that information in +% the |.aux| file for the second run. In the following example, the option +% |last-row| will be used without value. % \end{itemize} % % \bigskip @@ -995,9 +1000,14 @@ c & c & b & a & e % rows.\footnote{The latter is not true when the extension \pkg{arydshln} is % loaded besides \pkg{nicematrix}. In fact, \pkg{nicematrix} and \pkg{arydhsln} % are not totally compatible because \pkg{arydshln} redefines many internals of -% \pkg{array}. On another note, if one really wants a vertical rule running in +% \pkg{array}. On another hand, if one really wants a vertical rule running in % the first and in the last row, he should use |!{\vline}| instead of \verb+|+ % in the preamble of the array.} +% +% If one wishes to define new specifiers for columns in order to draw vertical +% rules (for example thicker than the standard rules), he should consider the +% command |\OnlyMainNiceMatrix| described on page~\pageref{OnlyMainNiceMatrix}. +% % \item Logically, the potential option |columns-width| (described % p.~\pageref{width}) doesn't apply to the ``first column'' and ``last column''. % \item For technical reasons, it's not possible to use the option of the @@ -1356,9 +1366,9 @@ c & c & b & a & e % \medskip % In fact, the option |small| corresponds to the following tuning: % \begin{itemize} -% \item the cells of the array are composed with \verb|\scriptstyle| ; -% \item \verb|\arraystretch| is set to $0.47$ ; -% \item \verb|\arraycolsep| is set to $1.45$~pt ; +% \item the cells of the array are composed with \verb|\scriptstyle|; +% \item \verb|\arraystretch| is set to $0.47$; +% \item \verb|\arraycolsep| is set to $1.45$~pt; % \item the characteristics of the dotted lines are also modified. % \end{itemize} % @@ -1466,15 +1476,59 @@ c & c & b & a & e % 7.2 & 0 & \Cdots & 0 % \end{pNiceArray}$ % +% \medskip % On the other hand, the |d| columns of the package \pkg{dcolumn} are not % supported by \pkg{nicematrix}. % % \section{Technical remarks} +% +% \subsection{Definition of new column types} +% +% \label{OnlyMainNiceMatrix} +% +% The extension \pkg{nicematrix} provides the command |\OnlyMainNiceMatrix| +% which is meant to be used in definitions of new column types. Its argument is +% evaluated if and only if we are in the main part of the array, that is to say +% not in an eventual exterior row. % +% For example, one may wish to define a new column type |?| in order to draw a +% thick rule of width 1~pt. The following definition will do the job: +% +% \begin{Verbatim} +% \newcolumntype{?}{!{\OnlyMainNiceMatrix{\vrule width 1 pt}}} +% \end{Verbatim} +% +% The thick vertical rule won't extend in the exterior rows: +% \medskip +% \begin{scope} +% \newcolumntype{?}{!{\OnlyMainNiceMatrix{\vrule width 1 pt}}} +% +% \begin{BVerbatim}[baseline = c, boxwidth = 10.5cm] +% $\begin{pNiceArray}{CC?CC}[first-row,last-row] +% C_1 & C_2 & C_3 & C_4 \\ +% a & b & c & d \\ +% e & f & g & h \\ +% C_1 & C_2 & C_3 & C_4 +% \end{pNiceArray}$ +% \end{BVerbatim} +% $\begin{pNiceArray}{CC?CC}[first-row,last-row] +% C_1 & C_2 & C_3 & C_4 \\ +% a & b & c & d \\ +% e & f & g & h \\ +% C_1 & C_2 & C_3 & C_4 +% \end{pNiceArray}$ +% \end{scope} +% +% \medskip +% The specifier |?| may be used in a standard environment |{array}| (of the +% package \pkg{array}) and, in this case, the command |\OnlyMainNiceMatrix| is +% no-op. +% +% % \subsection{Intersections of dotted lines} % % Since the version 3.1 of \pkg{nicematrix}, the dotted lines created by -% |\Cdots|, |\Ldots|, |\Vdots|, etc. can't intersect.\footnote{Of the contrary, +% |\Cdots|, |\Ldots|, |\Vdots|, etc. can't intersect.\footnote{On the contrary, % dotted lines created by |\hdottedline|, the letter ``|:|'' in the preamble % of the array and the command |\line| in the |code-after| can have % intersections with other dotted lines.} @@ -1506,7 +1560,23 @@ c & c & b & a & e % & \Cdots & & & \\ % \end{pNiceMatrix}$ % +% \subsection{The names of the Tikz nodes created by nicematrix} +% +% We have said that, when a name is given to an environment of \pkg{nicematrix}, +% it's possible to access the Tikz nodes through this name (cf. +% p.~\pageref{name}). +% +% That's the recommended way to access these nodes. However, we describe now the +% internal names of these nodes. +% +% The environments created by \pkg{nicematrix} are numbered by an internal +% global counter. The command |\NiceMatrixLastEnv| provides the number of the +% last environment of \pkg{nicematrix} (for LaTeX, it's a —fully expandable— +% command and not a counter). % +% For the environment of number~$n$, the node in row~$i$ and column~$j$ has the +% name |nm-|$n$|-|$i$|-|$j$. The |medium| and |large| have the same name, suffixed by +% |-medium| and |-large|. % % % \subsection{Diagonal lines} @@ -1747,7 +1817,7 @@ c & c & b & a & e % used. It's still possible to use these environments by loading % \pkg{nicematrix} with the option |obsolete-environments|. % -% However, these environments will probably be completely deleted in future +% However, these environments will probably be completely deleted in a future % version of \pkg{nicematrix}. % % \section{Examples} @@ -2033,7 +2103,7 @@ c & c & b & a & e % % \begin{Verbatim} % $\begin{pNiceArray}{>{\strut}CCCC}% -% [create-extra-nodes,margin,extra-margin = 2pt , +% [create-large-nodes,margin,extra-margin = 2pt , % code-after = {\begin{tikzpicture} % [~emphase#name suffix = -large@, % every node/.style = {draw, @@ -2052,7 +2122,7 @@ c & c & b & a & e % % % \[\begin{pNiceArray}{>{\strut}CCCC}[ -% create-extra-nodes,margin,extra-margin = 2pt, +% create-large-nodes,margin,extra-margin = 2pt, % code-after = {\begin{tikzpicture}[name suffix = -large, % every node/.style = {draw, % inner sep = -\pgflinewidth/2}] @@ -2135,15 +2205,15 @@ c & c & b & a & e % % \medskip % \begin{Verbatim} -% $\begin{pNiceArray}{CCC}[~emphase#name=example@,last-col,create-extra-nodes] -% a & a + b & a + b + c & L_1\\ +% $\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] -% a & a + b & a + b + c & L_1\\ +% a & a + b & a + b + c & L_1 \\ % a & a & a + b & L_2 \\ % a & a & a & L_3 % \end{pNiceArray}\] @@ -2182,7 +2252,6 @@ c & c & b & a & e % % \[\begin{pNiceArray}{CCC}[ % last-col, -% create-extra-nodes, % code-after = {\begin{tikzpicture}[every node/.style = {fill = red!15, % blend mode = multiply, % inner sep = 0pt}] @@ -2212,7 +2281,7 @@ c & c & b & a & e % % \[\begin{pNiceArray}{CCC}[ % last-col, -% create-extra-nodes, +% create-medium-nodes, % code-after = {\begin{tikzpicture}[every node/.style = {fill = red!15, % blend mode = multiply, % inner sep = 0pt}, @@ -2233,7 +2302,7 @@ c & c & b & a & e % the matrix.\par\nobreak % \begin{Verbatim} % \begin{pNiceArray}{>{\strut}CCCC}% -% [create-extra-nodes,margin,extra-margin=2pt, +% [create-large-nodes,margin,extra-margin=2pt, % code-after = {\tikz \path [~emphase#name suffix = -large@, % fill = red!15, % blend mode = multiply] @@ -2251,7 +2320,7 @@ c & c & b & a & e % \end{Verbatim} % % \[ \begin{pNiceArray}{>{\strut}CCCC}[ -% create-extra-nodes,margin,extra-margin=2pt, +% create-large-nodes,margin,extra-margin=2pt, % code-after = {\tikz \path [name suffix = -large, % fill = red!15, % blend mode = multiply] @@ -2941,11 +3010,13 @@ c & c & b & a & e % \end{macrocode} % % \bigskip -% The boolean |\l_@@_extra_nodes_bool| will be used to indicate whether the -% ``medium nodes'' and ``large nodes'' are created in the array. +% The boolean |\l_@@_extra_medium_bool| will be used to indicate whether the +% ``medium nodes'' are created in the array. Idem for the ``large nodes''. % \begin{macrocode} -\bool_new:N \l_@@_extra_nodes_bool -\bool_new:N \g_@@_extra_nodes_bool +\bool_new:N \l_@@_medium_nodes_bool +\bool_new:N \g_@@_medium_nodes_bool +\bool_new:N \l_@@_large_nodes_bool +\bool_new:N \g_@@_large_nodes_bool % \end{macrocode} % % \bigskip @@ -2990,17 +3061,17 @@ c & c & b & a & e % |\Vdots| and |\Ddots|. % \begin{macrocode} renew-dots .bool_set:N = \l_@@_renew_dots_bool , - nullify-dots .bool_set:N = \l_@@_nullify_dots_bool , % \end{macrocode} % % \bigskip -% An option to test whether the extra nodes will be created (these nodes are the -% ``medium nodes'' and the ``large nodes''). In some circonstancies, the extra -% nodes are created automatically, for example when a dotted line has an -% ``open'' extremity. +% In some circonstancies, the ``medium nodes'' are created automatically, for +% example when a dotted line has an ``open'' extremity (idem for the ``large nodes''). % \begin{macrocode} - create-extra-nodes .bool_set:N = \l_@@_extra_nodes_bool , + create-medium-nodes .bool_set:N = \l_@@_medium_nodes_bool , + create-large-nodes .bool_set:N = \l_@@_large_nodes_bool , + create-extra-nodes .meta:n = + { create-medium-nodes , create-large-nodes } , left-margin .dim_set:N = \l_@@_left_margin_dim , left-margin .default:n = \arraycolsep , right-margin .dim_set:N = \l_@@_right_margin_dim , @@ -3623,12 +3694,12 @@ c & c & b & a & e % % % \medskip -% We switch to a global version of the boolean |\g_@@_extra_nodes_bool|, -% because, in some circonstancies, the boolean will be raised from inside a -% cell of the |\halign| (in particular in a column of type~|w|). -% +% We switch to a global version of the |\l_@@_medium_nodes_bool| and +% |\l_@@_large_nodes_bool| because these booleans may be raised in cells of the +% array (for exemple in commands |\Block|). % \begin{macrocode} - \bool_gset_eq:NN \g_@@_extra_nodes_bool \l_@@_extra_nodes_bool + \bool_gset_eq:NN \g_@@_medium_nodes_bool \l_@@_medium_nodes_bool + \bool_gset_eq:NN \g_@@_large_nodes_bool \l_@@_large_nodes_bool % \end{macrocode} % % \bigskip @@ -3710,6 +3781,7 @@ c & c & b & a & e \cs_set_eq:NN \Hdotsfor \@@_Hdotsfor: \cs_set_eq:NN \multicolumn \@@_multicolumn:nnn \cs_set_eq:NN \Block \@@_Block: + \cs_set_eq:NN \OnlyMainNiceMatrix \@@_OnlyMainNiceMatrix:n \bool_if:NT \l_@@_renew_dots_bool { \cs_set_eq:NN \ldots \@@_Ldots @@ -3741,9 +3813,10 @@ c & c & b & a & e % \end{macrocode} % % At the end of the environment |{array}|, |\c@iRow| will be the total -% number de rows and |\g_@@_row_total_int| will be the number or rows excepted -% the last row (if |\l_@@_last_row_bool| has been raised with the option -% |last-row|). +% number de rows. +% +% |\g_@@_row_total_int| will be the number or rows excepted the last row (if +% |\l_@@_last_row_bool| has been raised with the option |last-row|). % \begin{macrocode} \int_gzero_new:N \g_@@_row_total_int % \end{macrocode} @@ -3799,7 +3872,7 @@ c & c & b & a & e \l_@@_auto_columns_width_bool || \dim_compare_p:nNn \l_@@_columns_width_dim > \c_zero_dim } - { \bool_gset_true:N \g_@@_extra_nodes_bool } + { \bool_gset_true:N \g_@@_large_nodes_bool } % \end{macrocode} % % \medskip @@ -4769,12 +4842,21 @@ c & c & b & a & e } % \end{macrocode} % -% If the user has used the option |create-extra-nodes|, the ``medium nodes'' and -% ``large nodes'' are created. We recall that the command -% |\@@_create_extra_nodes:|, when used once, becomes no-op (in the current TeX -% group). +% The booleans |\g_@@_medium_nodes_bool| and |\g_@@_large_nodes_bool| may be +% raised directly in cells of the array (for example in commands |\Block|) but +% also because the user has used the options |create-medium-nodes| and +% |create-large-nodes| (these options raise the booleans +% |\l_@@_medium_nodes_bool| and |\l_@@_large_nodes_bool| but theses booleans are +% converted into the global version |\g_@@_medium_nodes_bool| and +% |\g_@@_large_nodes_bool| before the creation of the array). % \begin{macrocode} - \bool_if:NT \g_@@_extra_nodes_bool \@@_create_extra_nodes: + \bool_if:nTF \g_@@_medium_nodes_bool + { + \bool_if:NTF \g_@@_large_nodes_bool + \@@_create_medium_and_large_nodes: + \@@_create_medium_nodes: + } + { \bool_if:NT \g_@@_large_nodes_bool \@@_create_large_nodes: } \int_zero_new:N \l_@@_initial_i_int \int_zero_new:N \l_@@_initial_j_int \int_zero_new:N \l_@@_final_i_int @@ -4844,9 +4926,8 @@ c & c & b & a & e % a & a+b & a+b+c % \end{pNiceMatrix}\] % For a closed extremity, we use the normal node and for a open one, we use the -% ``medium node'' or, if it exists, the |w|~node (the medium and large nodes are -% created with |\@@_create_extra_nodes:| if they have not been created yet). -% \[ \begin{pNiceMatrix}[create-extra-nodes, +% ``medium node'' or, if it exists, the |w|~node. +% \[ \begin{pNiceMatrix}[create-medium-nodes, % code-after = {\begin{tikzpicture} % \node [highlight, fit={(2-1)}] {} ; % \node [highlight, fit={(2-3-medium)}] {}; @@ -5070,10 +5151,10 @@ c & c & b & a & e % matrix\footnote{We should change this. Indeed, for an open extremity of an % \emph{horizontal} dotted line, we use the |w|~node, if, it exists, and not the % ``medium node''.}. We remind that, when used once, the command -% |\@@_create_extra_nodes:| becomes no-op in the current TeX group. +% |\@@_create_medium_nodes:| becomes no-op in the current TeX group. % \begin{macrocode} - \bool_if:nT \l_@@_initial_open_bool \@@_create_extra_nodes: - \bool_if:NT \l_@@_final_open_bool \@@_create_extra_nodes: + \bool_if:nT \l_@@_initial_open_bool \@@_create_medium_nodes: + \bool_if:NT \l_@@_final_open_bool \@@_create_medium_nodes: } % \end{macrocode} % @@ -5461,6 +5542,18 @@ c & c & b & a & e } % \end{macrocode} % +% +% \bigskip +% The command |\NiceMatrixLastEnv| is not used by the package \pkg{nicematrix}. +% It's only a facility given to the final user. It gives the number of the last +% environment (in fact the number of the current environment but it's meant to +% be used after the environment in order to refer to that environment --- and +% its nodes --- without having to give it a name). +% \begin{macrocode} +\NewExpandableDocumentCommand \NiceMatrixLastEnv { } + { \int_use:N \g_@@_env_int } +% \end{macrocode} +% % \bigskip % \subsection{The actual instructions for drawing the dotted line with Tikz} % @@ -5796,7 +5889,7 @@ c & c & b & a & e } } \bool_if:nT { \l_@@_initial_open_bool || \l_@@_final_open_bool } - \@@_create_extra_nodes: + \@@_create_medium_nodes: \@@_actually_draw_Ldots: % \end{macrocode} % We declare all the cells concerned by the |\Hdotsfor| as ``dotted'' (for the @@ -5944,7 +6037,7 @@ c & c & b & a & e { \noalign { - \bool_gset_true:N \g_@@_extra_nodes_bool + \bool_gset_true:N \g_@@_large_nodes_bool \cs_if_exist:cTF { @@_width_ \int_use:N \g_@@_env_int } { \dim_set_eq:Nc \l_tmpa_dim { @@_width_ \int_use:N \g_@@_env_int } } { \dim_set:Nn \l_tmpa_dim { 5 mm } } @@ -6068,7 +6161,7 @@ c & c & b & a & e % { ! { \int_compare:nNnF \c@iRow = \c_zero_int \vline } } % \end{Verbatim} % -% However, this code fails is the user uses "\DefineShortVerb{\|}" of +% However, this code fails if the user uses "\DefineShortVerb{\|}" of % \pkg{fancyvrb}. Moreover, it would not be able to deal correctly with two % consecutive specifiers ``"|"'' (in a preambule like "ccc||ccc"). % @@ -6132,13 +6225,41 @@ c & c & b & a & e % \end{macrocode} % % \medskip -% If \pkg{colortbl} is loaded, the following macro will redefined (in a +% If \pkg{colortbl} is loaded, the following macro will be redefined (in a % |\AtBeginDocument|) to take into account the color fixed by |\arrayrulecolor| % of \pkg{colortbl}. % \begin{macrocode} \cs_set_eq:NN \@@_vline_i: \vline % \end{macrocode} % +% \bigskip +% We give now the definition of |\OnlyMainNiceMatrix|. Internally, it is not +% used by \pkg{nicematrix}. It's only a facility given to the final user, which +% may be useful in the definitions of new columns types (with |\newcolumntype|). +% +% \smallskip +% First, we give the definition of |\OnlyMainNiceMatrix| in the general case: +% it's no-op (thus, a definition of column type may be used outside the +% environments of \pkg{nicematrix}, in |{array}|, etc.). +% \begin{macrocode} +\cs_set_eq:NN \OnlyMainNiceMatrix \use:n +% \end{macrocode} +% +% \medskip +% Now, we give the definition of |\OnlyMainNiceMatrix| which will be used +% in the environments of \pkg{nicematrix}. This command +% |\@@_OnlyMainNiceMatrix:n| will be linked to |\OnlyMainNiceMatrix| in +% |\@@_pre_array:|. This command is ``fully expandable'' and that's why we have +% not protected it, even tough this characteristic will probably not be used. +% \begin{macrocode} +\cs_new:Npn \@@_OnlyMainNiceMatrix:n #1 + { + \int_compare:nNnF \c@iRow = \c_zero_int + { \int_compare:nNnF \c@iRow = \l_@@_last_row_int { #1 } } + } +% \end{macrocode} +% +% % \bigskip % \subsection{The environment \{NiceMatrixBlock\}} % @@ -6212,11 +6333,21 @@ c & c & b & a & e % \end{macrocode} % % \bigskip -% The macro |\@@_create_extra_nodes:| must \emph{not} be used in the -% |code-after| because the |code-after| is executed in a scope of |prefix name|. -% +% We have three macros of creation of nodes: |\@@_create_medium_nodes:|, |\@@_create_large_nodes:| and +% |\@@_create_medium_and_large_nodes:|. They must \emph{not} be used in the +% |code-after| because the |code-after| is executed in a scope of |prefix name| +% of Tikz. % % \bigskip +% We have to compute the mathematical coordinates of the ``medium nodes''. These +% mathematical coordinates are also used to compute the mathematical coordinates +% of the ``large nodes''. That's why we write a command +% |\@@_computations_for_medium_nodes:| to do these computations. +% +% \bigskip +% The command |\@@_computations_for_medium_nodes:| must be used in a +% |{tikzpicture}|. +% \medskip % For each row $i$, we compute two dimensions % \texttt{l_@@_row_\textsl{i}_min_dim} and \texttt{l_@@_row_\textsl{i}_max_dim}. % The dimension \texttt{l_@@_row_\textsl{i}_min_dim} is the minimal @@ -6234,68 +6365,81 @@ c & c & b & a & e % Since these dimensions will be computed as maximum or minimum, we initialize % them to |\c_max_dim| or |-\c_max_dim|. % \begin{macrocode} -\cs_new_protected:Nn \@@_create_extra_nodes: +\cs_new_protected:Npn \@@_computations_for_medium_nodes: { - \begin { tikzpicture } [ remember~picture , overlay ] - \int_step_variable:nnNn \l_@@_first_row_int \g_@@_row_total_int \@@_i: - { - \dim_zero_new:c { l_@@_row_\@@_i: _min_dim } - \dim_set_eq:cN { l_@@_row_\@@_i: _min_dim } \c_max_dim - \dim_zero_new:c { l_@@_row_\@@_i: _max_dim } - \dim_set:cn { l_@@_row_\@@_i: _max_dim } { - \c_max_dim } - } - \int_step_variable:nnNn \l_@@_first_col_int \g_@@_col_total_int \@@_j: - { - \dim_zero_new:c { l_@@_column_\@@_j: _min_dim } - \dim_set_eq:cN { l_@@_column_\@@_j: _min_dim } \c_max_dim - \dim_zero_new:c { l_@@_column_\@@_j: _max_dim } - \dim_set:cn { l_@@_column_\@@_j: _max_dim } { - \c_max_dim } - } + \int_step_variable:nnNn \l_@@_first_row_int \g_@@_row_total_int \@@_i: + { + \dim_zero_new:c { l_@@_row_\@@_i: _min_dim } + \dim_set_eq:cN { l_@@_row_\@@_i: _min_dim } \c_max_dim + \dim_zero_new:c { l_@@_row_\@@_i: _max_dim } + \dim_set:cn { l_@@_row_\@@_i: _max_dim } { - \c_max_dim } + } + \int_step_variable:nnNn \l_@@_first_col_int \g_@@_col_total_int \@@_j: + { + \dim_zero_new:c { l_@@_column_\@@_j: _min_dim } + \dim_set_eq:cN { l_@@_column_\@@_j: _min_dim } \c_max_dim + \dim_zero_new:c { l_@@_column_\@@_j: _max_dim } + \dim_set:cn { l_@@_column_\@@_j: _max_dim } { - \c_max_dim } + } % \end{macrocode} % We begin the two nested loops over the rows and the columns of the array. % \begin{macrocode} - \int_step_variable:nnNn \l_@@_first_row_int \g_@@_row_total_int \@@_i: - { - \int_step_variable:nnNn - \l_@@_first_col_int \g_@@_col_total_int \@@_j: + \int_step_variable:nnNn \l_@@_first_row_int \g_@@_row_total_int \@@_i: + { + \int_step_variable:nnNn + \l_@@_first_col_int \g_@@_col_total_int \@@_j: % \end{macrocode} % Maybe the cell ($i$-$j$) is an implicit cell (that is to say a cell after % implicit ampersands |&|). In this case, of course, we don't update the % dimensions we want to compute. % \begin{macrocode} - { \cs_if_exist:cT - { pgf@sh@ns@nm - \int_use:N \g_@@_env_int - \@@_i: - \@@_j: } + { \cs_if_exist:cT + { pgf@sh@ns@nm - \int_use:N \g_@@_env_int - \@@_i: - \@@_j: } % \end{macrocode} % We retrieve the coordinates of the anchor |south west| of the (normal) node of % the cell ($i$-$j$). They will be stored in |\pgf@x| and |\pgf@y|. % \begin{macrocode} - { - \tikz@parse@node \pgfutil@firstofone - ( nm - \int_use:N \g_@@_env_int - - \@@_i: - \@@_j: .south~west ) - \dim_set:cn { l_@@_row_\@@_i: _min_dim} - { \dim_min:vn { l_@@_row _ \@@_i: _min_dim } \pgf@y } - \seq_if_in:NxF \g_@@_multicolumn_cells_seq { \@@_i: - \@@_j: } - { - \dim_set:cn { l_@@_column _ \@@_j: _min_dim} - { \dim_min:vn { l_@@_column _ \@@_j: _min_dim } \pgf@x } - } + { + \tikz@parse@node \pgfutil@firstofone + ( nm - \int_use:N \g_@@_env_int + - \@@_i: - \@@_j: .south~west ) + \dim_set:cn { l_@@_row_\@@_i: _min_dim} + { \dim_min:vn { l_@@_row _ \@@_i: _min_dim } \pgf@y } + \seq_if_in:NxF \g_@@_multicolumn_cells_seq { \@@_i: - \@@_j: } + { + \dim_set:cn { l_@@_column _ \@@_j: _min_dim} + { \dim_min:vn { l_@@_column _ \@@_j: _min_dim } \pgf@x } + } % \end{macrocode} % We retrieve the coordinates of the anchor |north east| of the (normal) node of % the cell ($i$-$j$). They will be stored in |\pgf@x| and |\pgf@y|. % \begin{macrocode} - \tikz@parse@node \pgfutil@firstofone - ( nm - \int_use:N \g_@@_env_int - \@@_i: - \@@_j: .north~east ) - \dim_set:cn { l_@@_row _ \@@_i: _ max_dim } - { \dim_max:vn { l_@@_row _ \@@_i: _ max_dim } \pgf@y } - \seq_if_in:NxF \g_@@_multicolumn_cells_seq { \@@_i: - \@@_j: } - { - \dim_set:cn { l_@@_column _ \@@_j: _ max_dim } - { \dim_max:vn { l_@@_column _ \@@_j: _max_dim } \pgf@x } - } - } - } - } + \tikz@parse@node \pgfutil@firstofone + ( nm - \int_use:N \g_@@_env_int - \@@_i: - \@@_j: .north~east ) + \dim_set:cn { l_@@_row _ \@@_i: _ max_dim } + { \dim_max:vn { l_@@_row _ \@@_i: _ max_dim } \pgf@y } + \seq_if_in:NxF \g_@@_multicolumn_cells_seq { \@@_i: - \@@_j: } + { + \dim_set:cn { l_@@_column _ \@@_j: _ max_dim } + { \dim_max:vn { l_@@_column _ \@@_j: _max_dim } \pgf@x } + } + } + } + } + } +% \end{macrocode} +% +% +% \bigskip +% Here is the command |\@@_create_medium_nodes:|. When this command is used, the +% ``medium nodes'' are created. These nodes won't be constructed twice because +% when used once, this command becomes no-op. +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_create_medium_nodes: + { + \begin { tikzpicture } [ remember~picture , overlay ] + \@@_computations_for_medium_nodes: % \end{macrocode} % Now, we can create the ``medium nodes''. We use a command |\@@_create_nodes:| % because this command will also be used for the creation of the ``large nodes'' @@ -6303,93 +6447,115 @@ c & c & b & a & e % \begin{macrocode} \tikzset { name~suffix = -medium } \@@_create_nodes: + \end { tikzpicture } + \cs_set_protected:Npn \@@_create_medium_nodes: { } + \cs_set_protected:Npn \@@_create_medium_and_large_nodes: + { \@@_create_large_nodes: } + } % \end{macrocode} % +% +% \medskip +% The command |\@@_create_large_nodes:| must be used when we want to create only +% the ``large nodes'' and not the medium ones (if we want to create both, we +% have to use the command |\@@_create_medium_and_large_nodes:|). However, the +% computation of the mathematical coordinates of the ``large nodes'' needs the +% computation of the mathematical coordinates of the ``medium nodes''. That's +% why we use first |\@@_computations_for_medium_nodes:| and then the command +% |\@@_computations_for_large_nodes:|. +% \begin{macrocode} +\cs_new_protected:Npn \@@_create_large_nodes: + { + \begin { tikzpicture } [ remember~picture , overlay ] + \@@_computations_for_medium_nodes: + \@@_computations_for_large_nodes: + \tikzset { name~suffix = -large } + \@@_create_nodes: + \end { tikzpicture } + \@@_compute_width_of_array: + \cs_set_protected:Npn \@@_create_large_nodes: { } + \cs_set_protected:Npn \@@_create_medium_and_large_nodes: + { \@@_create_medium_nodes: } + } +% \end{macrocode} +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_create_medium_and_large_nodes: + { + \begin { tikzpicture } [ remember~picture , overlay ] + \@@_computations_for_medium_nodes: +% Now, we can create the ``medium nodes''. We use a command |\@@_create_nodes:| +% because this command will also be used for the creation of the ``large nodes'' +% (after changing the value of |name-suffix|). +% \begin{macrocode} + \tikzset { name~suffix = -medium } + \@@_create_nodes: + \@@_computations_for_large_nodes: + \tikzset { name~suffix = -large } + \@@_create_nodes: + \@@_compute_width_of_array: + \end { tikzpicture } + \@@_compute_width_of_array: + \cs_set_protected:Npn \@@_create_medium_and_large_nodes: { } + \cs_set_protected:Npn \@@_create_medium_nodes: { } + \cs_set_protected:Npn \@@_create_large_nodes: { } + } +% \end{macrocode} +% +% % \bigskip -% For ``large nodes'', the exterior rows and columns don't interfer. -% That's why the loop over the rows will start at 1 and the loop over the -% columns will stop at $|\c@jCol|$ (and not |\g_@@_col_total_int|). Idem -% for the rows. +% For ``large nodes'', the exterior rows and columns don't interfer. That's why +% the loop over the columns will start at 1 and stop at $|\c@jCol|$ (and not +% |\g_@@_col_total_int|). Idem for the rows. % \begin{macrocode} - \int_set:Nn \l_@@_first_row_int 1 - \int_set:Nn \l_@@_first_col_int 1 +\cs_new_protected:Npn \@@_computations_for_large_nodes: + { + \int_set:Nn \l_@@_first_row_int 1 + \int_set:Nn \l_@@_first_col_int 1 % \end{macrocode} % We have to change the values of all the dimensions % \texttt{l_@@_row_\textsl{i}_min_dim}, \texttt{l_@@_row_\textsl{i}_max_dim}, % \texttt{l_@@_column_\textsl{j}_min_dim} and % \texttt{l_@@_column_\textsl{j}_max_dim}. % \begin{macrocode} - \int_step_variable:nNn { \c@iRow - 1 } \@@_i: - { - \dim_set:cn { l_@@_row _ \@@_i: _ min _ dim } - { - ( - \dim_use:c { l_@@_row _ \@@_i: _ min _ dim } + - \dim_use:c { l_@@_row _ \int_eval:n { \@@_i: + 1 } _ max _ dim } - ) - / 2 - } - \dim_set_eq:cc { l_@@_row _ \int_eval:n { \@@_i: + 1 } _ max _ dim } - { l_@@_row_\@@_i: _min_dim } - } - \int_step_variable:nNn { \c@jCol - 1 } \@@_j: - { - \dim_set:cn { l_@@_column _ \@@_j: _ max _ dim } - { - ( - \dim_use:c - { l_@@_column _ \@@_j: _ max _ dim } + - \dim_use:c - { l_@@_column _ \int_eval:n { \@@_j: + 1 } _ min _ dim } - ) - / 2 - } - \dim_set_eq:cc { l_@@_column _ \int_eval:n { \@@_j: + 1 } _ min _ dim } - { l_@@_column _ \@@_j: _ max _ dim } - } - \dim_sub:cn - { l_@@_column _ 1 _ min _ dim } - \l_@@_left_margin_dim - \dim_add:cn - { l_@@_column _ \int_use:N \c@jCol _ max _ dim } - \l_@@_right_margin_dim -% \end{macrocode} -% Now, we can actually create the ``large nodes''. -% \begin{macrocode} - \tikzset { name~suffix = -large } - \@@_create_nodes: - \end{tikzpicture} -% \end{macrocode} -% -% \medskip -% When used once, the command |\@@_create_extra_nodes:| must become no-op (in -% the current TeX group). That's why we put a nullification of the command. -% \begin{macrocode} - \cs_set:Npn \@@_create_extra_nodes: { } -% \end{macrocode} -% -% \medskip -% We can now compute the width of the array (used by |\hdottedline|). -% \begin{macrocode} - \begin { tikzpicture } [ remember~picture , overlay ] - \tikz@parse@node \pgfutil@firstofone - ( nm - \int_use:N \g_@@_env_int - 1 - 1 - large .north~west ) - \dim_gset:Nn \g_tmpa_dim \pgf@x - \tikz@parse@node \pgfutil@firstofone - ( nm - \int_use:N \g_@@_env_int - 1 - - \int_use:N \c@jCol - large .north~east ) - \dim_gset:Nn \g_tmpb_dim \pgf@x - \end { tikzpicture } - \iow_now:Nn \@mainaux \ExplSyntaxOn - \iow_now:Nx \@mainaux - { - \cs_gset:cpn { @@_width_ \int_use:N \g_@@_env_int } - { \dim_eval:n { \g_tmpb_dim - \g_tmpa_dim } } - } - \iow_now:Nn \@mainaux \ExplSyntaxOff + \int_step_variable:nNn { \c@iRow - 1 } \@@_i: + { + \dim_set:cn { l_@@_row _ \@@_i: _ min _ dim } + { + ( + \dim_use:c { l_@@_row _ \@@_i: _ min _ dim } + + \dim_use:c { l_@@_row _ \int_eval:n { \@@_i: + 1 } _ max _ dim } + ) + / 2 + } + \dim_set_eq:cc { l_@@_row _ \int_eval:n { \@@_i: + 1 } _ max _ dim } + { l_@@_row_\@@_i: _min_dim } + } + \int_step_variable:nNn { \c@jCol - 1 } \@@_j: + { + \dim_set:cn { l_@@_column _ \@@_j: _ max _ dim } + { + ( + \dim_use:c + { l_@@_column _ \@@_j: _ max _ dim } + + \dim_use:c + { l_@@_column _ \int_eval:n { \@@_j: + 1 } _ min _ dim } + ) + / 2 + } + \dim_set_eq:cc { l_@@_column _ \int_eval:n { \@@_j: + 1 } _ min _ dim } + { l_@@_column _ \@@_j: _ max _ dim } + } + \dim_sub:cn + { l_@@_column _ 1 _ min _ dim } + \l_@@_left_margin_dim + \dim_add:cn + { l_@@_column _ \int_use:N \c@jCol _ max _ dim } + \l_@@_right_margin_dim } % \end{macrocode} -% +% +% % % \bigskip % The control sequence |\@@_create_nodes:| is used twice: for the construction @@ -6401,7 +6567,7 @@ c & c & b & a & e % ``medium nodes'' and the ``large nodes'', the values of these dimensions are % changed. % \begin{macrocode} -\cs_new_protected:Nn \@@_create_nodes: +\cs_new_protected:Npn \@@_create_nodes: { \int_step_variable:nnNn \l_@@_first_row_int \g_@@_row_total_int \@@_i: { @@ -6452,6 +6618,34 @@ c & c & b & a & e % \end{macrocode} % % +% +% \medskip +% We can now compute the width of the array (used by |\hdottedline|). We should +% modify this point because it's a waste to construct all the ``large nodes'' only +% for computing the width of the array. +% \begin{macrocode} +\cs_new_protected:Npn \@@_compute_width_of_array: + { + \begin { tikzpicture } [ remember~picture , overlay ] + \tikz@parse@node \pgfutil@firstofone + ( nm - \int_use:N \g_@@_env_int - 1 - 1 - large .north~west ) + \dim_gset:Nn \g_tmpa_dim \pgf@x + \tikz@parse@node \pgfutil@firstofone + ( nm - \int_use:N \g_@@_env_int - 1 - + \int_use:N \c@jCol - large .north~east ) + \dim_gset:Nn \g_tmpb_dim \pgf@x + \end { tikzpicture } + \iow_now:Nn \@mainaux \ExplSyntaxOn + \iow_now:Nx \@mainaux + { + \cs_gset:cpn { @@_width_ \int_use:N \g_@@_env_int } + { \dim_eval:n { \g_tmpb_dim - \g_tmpa_dim } } + } + \iow_now:Nn \@mainaux \ExplSyntaxOff + } +% \end{macrocode} +% +% \bigskip % \begin{macrocode} \cs_new_protected:Npn \@@_extract_coords: #1 - #2 \q_stop { @@ -6542,7 +6736,7 @@ c & c & b & a & e - \int_use:N \c@jCol ) ; \end { tikzpicture } } - \bool_gset_true:N \g_@@_extra_nodes_bool + \bool_gset_true:N \g_@@_medium_nodes_bool % \end{macrocode} % We write an instruction in the |code-after|. We write the instruction in the % beginning of the |code-after| (the |left| in |\tl_gput_left:Nx|) because we @@ -6867,6 +7061,9 @@ c & c & b & a & e code-for-first-row,~ code-for-last-col,~ code-for-last-row,~ + create-extra-nodes,~ + create-medium-nodes,~ + create-large-nodes,~ exterior-arraycolsep,~ hlines,~ left-margin,~ @@ -6900,6 +7097,8 @@ c & c & b & a & e code-for-last-row,~ columns-width,~ create-extra-nodes,~ + create-medium-nodes,~ + create-large-nodes,~ extra-left-margin,~ extra-right-margin,~ first-col,~ @@ -6920,7 +7119,7 @@ c & c & b & a & e % % \medskip % This error message is used for the set of keys |NiceMatrix/NiceMatrix| and -% |NiceMatrix/pNiceArray| (but not by |NiceMatrix/NiceArray| (because, for this +% |NiceMatrix/pNiceArray| (but not by |NiceMatrix/NiceArray| because, for this % set of keys, there is also the options |t|, |c| and~|b|). % \begin{macrocode} \@@_msg_new:nnn { Unknown~option~for~NiceMatrix } @@ -6939,6 +7138,8 @@ c & c & b & a & e code-for-last-row,~ columns-width,~ create-extra-nodes,~ + create-medium-nodes,~ + create-large-nodes,~ extra-left-margin,~ extra-right-margin,~ first-col,~ @@ -7374,6 +7575,13 @@ c & c & b & a & e % % An error is raised when an obsolete environment is used. % +% +% \subsection*{Changes between version 3.8 and 3.9} +% +% New commands |\NiceMatrixLastEnv| and |\OnlyMainNiceMatrix|. +% +% New options |create-medium-nodes| and |create-large-nodes|. +% % \PrintIndex % % \tableofcontents diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index fd41a0cf057..ce81093ceaa 100644 --- a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty +++ b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty @@ -18,8 +18,8 @@ %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% -\def\myfileversion{3.8} -\def\myfiledate{2020/01/02} +\def\myfileversion{3.9} +\def\myfiledate{2020/01/10} \RequirePackage{tikz} \usetikzlibrary{fit} \RequirePackage{expl3}[2019/07/01] @@ -158,8 +158,10 @@ \bool_new:N \l__nicematrix_nullify_dots_bool \bool_new:N \l__nicematrix_auto_columns_width_bool \str_new:N \l__nicematrix_name_str -\bool_new:N \l__nicematrix_extra_nodes_bool -\bool_new:N \g__nicematrix_extra_nodes_bool +\bool_new:N \l__nicematrix_medium_nodes_bool +\bool_new:N \g__nicematrix_medium_nodes_bool +\bool_new:N \l__nicematrix_large_nodes_bool +\bool_new:N \g__nicematrix_large_nodes_bool \dim_new:N \l__nicematrix_left_margin_dim \dim_new:N \l__nicematrix_right_margin_dim \dim_new:N \g__nicematrix_width_last_col_dim @@ -176,9 +178,11 @@ hlines .bool_set:N = \l__nicematrix_hlines_bool , parallelize-diags .bool_set:N = \l__nicematrix_parallelize_diags_bool , renew-dots .bool_set:N = \l__nicematrix_renew_dots_bool , - nullify-dots .bool_set:N = \l__nicematrix_nullify_dots_bool , - create-extra-nodes .bool_set:N = \l__nicematrix_extra_nodes_bool , + create-medium-nodes .bool_set:N = \l__nicematrix_medium_nodes_bool , + create-large-nodes .bool_set:N = \l__nicematrix_large_nodes_bool , + create-extra-nodes .meta:n = + { create-medium-nodes , create-large-nodes } , left-margin .dim_set:N = \l__nicematrix_left_margin_dim , left-margin .default:n = \arraycolsep , right-margin .dim_set:N = \l__nicematrix_right_margin_dim , @@ -484,7 +488,8 @@ \cs_set:Npn \arraystretch { 0.47 } \dim_set:Nn \arraycolsep { 1.45 pt } } - \bool_gset_eq:NN \g__nicematrix_extra_nodes_bool \l__nicematrix_extra_nodes_bool + \bool_gset_eq:NN \g__nicematrix_medium_nodes_bool \l__nicematrix_medium_nodes_bool + \bool_gset_eq:NN \g__nicematrix_large_nodes_bool \l__nicematrix_large_nodes_bool \cs_set:Npn \ialign { \bool_if:NTF \c__nicematrix_colortbl_loaded_bool @@ -530,6 +535,7 @@ \cs_set_eq:NN \Hdotsfor \__nicematrix_Hdotsfor: \cs_set_eq:NN \multicolumn \__nicematrix_multicolumn:nnn \cs_set_eq:NN \Block \__nicematrix_Block: + \cs_set_eq:NN \OnlyMainNiceMatrix \__nicematrix_OnlyMainNiceMatrix:n \bool_if:NT \l__nicematrix_renew_dots_bool { \cs_set_eq:NN \ldots \__nicematrix_Ldots @@ -562,7 +568,7 @@ \l__nicematrix_auto_columns_width_bool || \dim_compare_p:nNn \l__nicematrix_columns_width_dim > \c_zero_dim } - { \bool_gset_true:N \g__nicematrix_extra_nodes_bool } + { \bool_gset_true:N \g__nicematrix_large_nodes_bool } \int_compare:nNnT \c@jCol > \g__nicematrix_last_vdotted_col_int { \int_gset_eq:NN \g__nicematrix_last_vdotted_col_int \c@jCol @@ -1136,7 +1142,13 @@ \dim_zero_new:N \l__nicematrix_delta_x_two_dim \dim_zero_new:N \l__nicematrix_delta_y_two_dim } - \bool_if:NT \g__nicematrix_extra_nodes_bool \__nicematrix_create_extra_nodes: + \bool_if:nTF \g__nicematrix_medium_nodes_bool + { + \bool_if:NTF \g__nicematrix_large_nodes_bool + \__nicematrix_create_medium_and_large_nodes: + \__nicematrix_create_medium_nodes: + } + { \bool_if:NT \g__nicematrix_large_nodes_bool \__nicematrix_create_large_nodes: } \int_zero_new:N \l__nicematrix_initial_i_int \int_zero_new:N \l__nicematrix_initial_j_int \int_zero_new:N \l__nicematrix_final_i_int @@ -1303,8 +1315,8 @@ \bool_set_true:N \l__nicematrix_impossible_line_bool } } - \bool_if:nT \l__nicematrix_initial_open_bool \__nicematrix_create_extra_nodes: - \bool_if:NT \l__nicematrix_final_open_bool \__nicematrix_create_extra_nodes: + \bool_if:nT \l__nicematrix_initial_open_bool \__nicematrix_create_medium_nodes: + \bool_if:NT \l__nicematrix_final_open_bool \__nicematrix_create_medium_nodes: } \cs_new_protected:Nn \__nicematrix_retrieve_coords:nn { @@ -1588,6 +1600,8 @@ } } } +\NewExpandableDocumentCommand \NiceMatrixLastEnv { } + { \int_use:N \g__nicematrix_env_int } \cs_new_protected:Nn \__nicematrix_draw_tikz_line: { \dim_zero_new:N \l__nicematrix_l_dim @@ -1793,7 +1807,7 @@ } } \bool_if:nT { \l__nicematrix_initial_open_bool || \l__nicematrix_final_open_bool } - \__nicematrix_create_extra_nodes: + \__nicematrix_create_medium_nodes: \__nicematrix_actually_draw_Ldots: \int_step_inline:nnn { #2 } { #2 + #3 - 1 } { \cs_set:cpn { __nicematrix _ dotted _ #1 - ##1 } { } } @@ -1866,7 +1880,7 @@ { \noalign { - \bool_gset_true:N \g__nicematrix_extra_nodes_bool + \bool_gset_true:N \g__nicematrix_large_nodes_bool \cs_if_exist:cTF { __nicematrix_width_ \int_use:N \g__nicematrix_env_int } { \dim_set_eq:Nc \l_tmpa_dim { __nicematrix_width_ \int_use:N \g__nicematrix_env_int } } { \dim_set:Nn \l_tmpa_dim { 5 mm } } @@ -2003,6 +2017,12 @@ } } \cs_set_eq:NN \__nicematrix_vline_i: \vline +\cs_set_eq:NN \OnlyMainNiceMatrix \use:n +\cs_new:Npn \__nicematrix_OnlyMainNiceMatrix:n #1 + { + \int_compare:nNnF \c@iRow = \c_zero_int + { \int_compare:nNnF \c@iRow = \l__nicematrix_last_row_int { #1 } } + } \bool_new:N \l__nicematrix_block_auto_columns_width_bool \keys_define:nn { NiceMatrix / NiceMatrixBlock } { @@ -2042,112 +2062,132 @@ } \cs_generate_variant:Nn \dim_min:nn { v n } \cs_generate_variant:Nn \dim_max:nn { v n } -\cs_new_protected:Nn \__nicematrix_create_extra_nodes: +\cs_new_protected:Npn \__nicematrix_computations_for_medium_nodes: + { + \int_step_variable:nnNn \l__nicematrix_first_row_int \g__nicematrix_row_total_int \__nicematrix_i: + { + \dim_zero_new:c { l__nicematrix_row_\__nicematrix_i: _min_dim } + \dim_set_eq:cN { l__nicematrix_row_\__nicematrix_i: _min_dim } \c_max_dim + \dim_zero_new:c { l__nicematrix_row_\__nicematrix_i: _max_dim } + \dim_set:cn { l__nicematrix_row_\__nicematrix_i: _max_dim } { - \c_max_dim } + } + \int_step_variable:nnNn \l__nicematrix_first_col_int \g__nicematrix_col_total_int \__nicematrix_j: + { + \dim_zero_new:c { l__nicematrix_column_\__nicematrix_j: _min_dim } + \dim_set_eq:cN { l__nicematrix_column_\__nicematrix_j: _min_dim } \c_max_dim + \dim_zero_new:c { l__nicematrix_column_\__nicematrix_j: _max_dim } + \dim_set:cn { l__nicematrix_column_\__nicematrix_j: _max_dim } { - \c_max_dim } + } + \int_step_variable:nnNn \l__nicematrix_first_row_int \g__nicematrix_row_total_int \__nicematrix_i: + { + \int_step_variable:nnNn + \l__nicematrix_first_col_int \g__nicematrix_col_total_int \__nicematrix_j: + { \cs_if_exist:cT + { pgf@sh@ns@nm - \int_use:N \g__nicematrix_env_int - \__nicematrix_i: - \__nicematrix_j: } + { + \tikz@parse@node \pgfutil@firstofone + ( nm - \int_use:N \g__nicematrix_env_int + - \__nicematrix_i: - \__nicematrix_j: .south~west ) + \dim_set:cn { l__nicematrix_row_\__nicematrix_i: _min_dim} + { \dim_min:vn { l__nicematrix_row _ \__nicematrix_i: _min_dim } \pgf@y } + \seq_if_in:NxF \g__nicematrix_multicolumn_cells_seq { \__nicematrix_i: - \__nicematrix_j: } + { + \dim_set:cn { l__nicematrix_column _ \__nicematrix_j: _min_dim} + { \dim_min:vn { l__nicematrix_column _ \__nicematrix_j: _min_dim } \pgf@x } + } + \tikz@parse@node \pgfutil@firstofone + ( nm - \int_use:N \g__nicematrix_env_int - \__nicematrix_i: - \__nicematrix_j: .north~east ) + \dim_set:cn { l__nicematrix_row _ \__nicematrix_i: _ max_dim } + { \dim_max:vn { l__nicematrix_row _ \__nicematrix_i: _ max_dim } \pgf@y } + \seq_if_in:NxF \g__nicematrix_multicolumn_cells_seq { \__nicematrix_i: - \__nicematrix_j: } + { + \dim_set:cn { l__nicematrix_column _ \__nicematrix_j: _ max_dim } + { \dim_max:vn { l__nicematrix_column _ \__nicematrix_j: _max_dim } \pgf@x } + } + } + } + } + } +\cs_new_protected:Npn \__nicematrix_create_medium_nodes: { \begin { tikzpicture } [ remember~picture , overlay ] - \int_step_variable:nnNn \l__nicematrix_first_row_int \g__nicematrix_row_total_int \__nicematrix_i: - { - \dim_zero_new:c { l__nicematrix_row_\__nicematrix_i: _min_dim } - \dim_set_eq:cN { l__nicematrix_row_\__nicematrix_i: _min_dim } \c_max_dim - \dim_zero_new:c { l__nicematrix_row_\__nicematrix_i: _max_dim } - \dim_set:cn { l__nicematrix_row_\__nicematrix_i: _max_dim } { - \c_max_dim } - } - \int_step_variable:nnNn \l__nicematrix_first_col_int \g__nicematrix_col_total_int \__nicematrix_j: - { - \dim_zero_new:c { l__nicematrix_column_\__nicematrix_j: _min_dim } - \dim_set_eq:cN { l__nicematrix_column_\__nicematrix_j: _min_dim } \c_max_dim - \dim_zero_new:c { l__nicematrix_column_\__nicematrix_j: _max_dim } - \dim_set:cn { l__nicematrix_column_\__nicematrix_j: _max_dim } { - \c_max_dim } - } - \int_step_variable:nnNn \l__nicematrix_first_row_int \g__nicematrix_row_total_int \__nicematrix_i: - { - \int_step_variable:nnNn - \l__nicematrix_first_col_int \g__nicematrix_col_total_int \__nicematrix_j: - { \cs_if_exist:cT - { pgf@sh@ns@nm - \int_use:N \g__nicematrix_env_int - \__nicematrix_i: - \__nicematrix_j: } - { - \tikz@parse@node \pgfutil@firstofone - ( nm - \int_use:N \g__nicematrix_env_int - - \__nicematrix_i: - \__nicematrix_j: .south~west ) - \dim_set:cn { l__nicematrix_row_\__nicematrix_i: _min_dim} - { \dim_min:vn { l__nicematrix_row _ \__nicematrix_i: _min_dim } \pgf@y } - \seq_if_in:NxF \g__nicematrix_multicolumn_cells_seq { \__nicematrix_i: - \__nicematrix_j: } - { - \dim_set:cn { l__nicematrix_column _ \__nicematrix_j: _min_dim} - { \dim_min:vn { l__nicematrix_column _ \__nicematrix_j: _min_dim } \pgf@x } - } - \tikz@parse@node \pgfutil@firstofone - ( nm - \int_use:N \g__nicematrix_env_int - \__nicematrix_i: - \__nicematrix_j: .north~east ) - \dim_set:cn { l__nicematrix_row _ \__nicematrix_i: _ max_dim } - { \dim_max:vn { l__nicematrix_row _ \__nicematrix_i: _ max_dim } \pgf@y } - \seq_if_in:NxF \g__nicematrix_multicolumn_cells_seq { \__nicematrix_i: - \__nicematrix_j: } - { - \dim_set:cn { l__nicematrix_column _ \__nicematrix_j: _ max_dim } - { \dim_max:vn { l__nicematrix_column _ \__nicematrix_j: _max_dim } \pgf@x } - } - } - } - } + \__nicematrix_computations_for_medium_nodes: \tikzset { name~suffix = -medium } \__nicematrix_create_nodes: - \int_set:Nn \l__nicematrix_first_row_int 1 - \int_set:Nn \l__nicematrix_first_col_int 1 - \int_step_variable:nNn { \c@iRow - 1 } \__nicematrix_i: - { - \dim_set:cn { l__nicematrix_row _ \__nicematrix_i: _ min _ dim } - { - ( - \dim_use:c { l__nicematrix_row _ \__nicematrix_i: _ min _ dim } + - \dim_use:c { l__nicematrix_row _ \int_eval:n { \__nicematrix_i: + 1 } _ max _ dim } - ) - / 2 - } - \dim_set_eq:cc { l__nicematrix_row _ \int_eval:n { \__nicematrix_i: + 1 } _ max _ dim } - { l__nicematrix_row_\__nicematrix_i: _min_dim } - } - \int_step_variable:nNn { \c@jCol - 1 } \__nicematrix_j: - { - \dim_set:cn { l__nicematrix_column _ \__nicematrix_j: _ max _ dim } - { - ( - \dim_use:c - { l__nicematrix_column _ \__nicematrix_j: _ max _ dim } + - \dim_use:c - { l__nicematrix_column _ \int_eval:n { \__nicematrix_j: + 1 } _ min _ dim } - ) - / 2 - } - \dim_set_eq:cc { l__nicematrix_column _ \int_eval:n { \__nicematrix_j: + 1 } _ min _ dim } - { l__nicematrix_column _ \__nicematrix_j: _ max _ dim } - } - \dim_sub:cn - { l__nicematrix_column _ 1 _ min _ dim } - \l__nicematrix_left_margin_dim - \dim_add:cn - { l__nicematrix_column _ \int_use:N \c@jCol _ max _ dim } - \l__nicematrix_right_margin_dim + \end { tikzpicture } + \cs_set_protected:Npn \__nicematrix_create_medium_nodes: { } + \cs_set_protected:Npn \__nicematrix_create_medium_and_large_nodes: + { \__nicematrix_create_large_nodes: } + } +\cs_new_protected:Npn \__nicematrix_create_large_nodes: + { + \begin { tikzpicture } [ remember~picture , overlay ] + \__nicematrix_computations_for_medium_nodes: + \__nicematrix_computations_for_large_nodes: \tikzset { name~suffix = -large } \__nicematrix_create_nodes: - \end{tikzpicture} - \cs_set:Npn \__nicematrix_create_extra_nodes: { } - \begin { tikzpicture } [ remember~picture , overlay ] - \tikz@parse@node \pgfutil@firstofone - ( nm - \int_use:N \g__nicematrix_env_int - 1 - 1 - large .north~west ) - \dim_gset:Nn \g_tmpa_dim \pgf@x - \tikz@parse@node \pgfutil@firstofone - ( nm - \int_use:N \g__nicematrix_env_int - 1 - - \int_use:N \c@jCol - large .north~east ) - \dim_gset:Nn \g_tmpb_dim \pgf@x - \end { tikzpicture } - \iow_now:Nn \@mainaux \ExplSyntaxOn - \iow_now:Nx \@mainaux - { - \cs_gset:cpn { __nicematrix_width_ \int_use:N \g__nicematrix_env_int } - { \dim_eval:n { \g_tmpb_dim - \g_tmpa_dim } } - } - \iow_now:Nn \@mainaux \ExplSyntaxOff + \end { tikzpicture } + \__nicematrix_compute_width_of_array: + \cs_set_protected:Npn \__nicematrix_create_large_nodes: { } + \cs_set_protected:Npn \__nicematrix_create_medium_and_large_nodes: + { \__nicematrix_create_medium_nodes: } + } +\cs_new_protected:Npn \__nicematrix_create_medium_and_large_nodes: + { + \begin { tikzpicture } [ remember~picture , overlay ] + \__nicematrix_computations_for_medium_nodes: + \tikzset { name~suffix = -medium } + \__nicematrix_create_nodes: + \__nicematrix_computations_for_large_nodes: + \tikzset { name~suffix = -large } + \__nicematrix_create_nodes: + \__nicematrix_compute_width_of_array: + \end { tikzpicture } + \__nicematrix_compute_width_of_array: + \cs_set_protected:Npn \__nicematrix_create_medium_and_large_nodes: { } + \cs_set_protected:Npn \__nicematrix_create_medium_nodes: { } + \cs_set_protected:Npn \__nicematrix_create_large_nodes: { } } -\cs_new_protected:Nn \__nicematrix_create_nodes: +\cs_new_protected:Npn \__nicematrix_computations_for_large_nodes: + { + \int_set:Nn \l__nicematrix_first_row_int 1 + \int_set:Nn \l__nicematrix_first_col_int 1 + \int_step_variable:nNn { \c@iRow - 1 } \__nicematrix_i: + { + \dim_set:cn { l__nicematrix_row _ \__nicematrix_i: _ min _ dim } + { + ( + \dim_use:c { l__nicematrix_row _ \__nicematrix_i: _ min _ dim } + + \dim_use:c { l__nicematrix_row _ \int_eval:n { \__nicematrix_i: + 1 } _ max _ dim } + ) + / 2 + } + \dim_set_eq:cc { l__nicematrix_row _ \int_eval:n { \__nicematrix_i: + 1 } _ max _ dim } + { l__nicematrix_row_\__nicematrix_i: _min_dim } + } + \int_step_variable:nNn { \c@jCol - 1 } \__nicematrix_j: + { + \dim_set:cn { l__nicematrix_column _ \__nicematrix_j: _ max _ dim } + { + ( + \dim_use:c + { l__nicematrix_column _ \__nicematrix_j: _ max _ dim } + + \dim_use:c + { l__nicematrix_column _ \int_eval:n { \__nicematrix_j: + 1 } _ min _ dim } + ) + / 2 + } + \dim_set_eq:cc { l__nicematrix_column _ \int_eval:n { \__nicematrix_j: + 1 } _ min _ dim } + { l__nicematrix_column _ \__nicematrix_j: _ max _ dim } + } + \dim_sub:cn + { l__nicematrix_column _ 1 _ min _ dim } + \l__nicematrix_left_margin_dim + \dim_add:cn + { l__nicematrix_column _ \int_use:N \c@jCol _ max _ dim } + \l__nicematrix_right_margin_dim + } +\cs_new_protected:Npn \__nicematrix_create_nodes: { \int_step_variable:nnNn \l__nicematrix_first_row_int \g__nicematrix_row_total_int \__nicematrix_i: { @@ -2177,6 +2217,25 @@ \g__nicematrix_multicolumn_sizes_seq \__nicematrix_node_for_multicolumn:nn } +\cs_new_protected:Npn \__nicematrix_compute_width_of_array: + { + \begin { tikzpicture } [ remember~picture , overlay ] + \tikz@parse@node \pgfutil@firstofone + ( nm - \int_use:N \g__nicematrix_env_int - 1 - 1 - large .north~west ) + \dim_gset:Nn \g_tmpa_dim \pgf@x + \tikz@parse@node \pgfutil@firstofone + ( nm - \int_use:N \g__nicematrix_env_int - 1 - + \int_use:N \c@jCol - large .north~east ) + \dim_gset:Nn \g_tmpb_dim \pgf@x + \end { tikzpicture } + \iow_now:Nn \@mainaux \ExplSyntaxOn + \iow_now:Nx \@mainaux + { + \cs_gset:cpn { __nicematrix_width_ \int_use:N \g__nicematrix_env_int } + { \dim_eval:n { \g_tmpb_dim - \g_tmpa_dim } } + } + \iow_now:Nn \@mainaux \ExplSyntaxOff + } \cs_new_protected:Npn \__nicematrix_extract_coords: #1 - #2 \q_stop { \cs_set:Npn \__nicematrix_i: { #1 } @@ -2222,7 +2281,7 @@ - \int_use:N \c@jCol ) ; \end { tikzpicture } } - \bool_gset_true:N \g__nicematrix_extra_nodes_bool + \bool_gset_true:N \g__nicematrix_medium_nodes_bool \tl_gput_left:Nx \g__nicematrix_code_after_tl { \__nicematrix_Block_iii:nnnnn @@ -2427,6 +2486,9 @@ code-for-first-row,~ code-for-last-col,~ code-for-last-row,~ + create-extra-nodes,~ + create-medium-nodes,~ + create-large-nodes,~ exterior-arraycolsep,~ hlines,~ left-margin,~ @@ -2457,6 +2519,8 @@ code-for-last-row,~ columns-width,~ create-extra-nodes,~ + create-medium-nodes,~ + create-large-nodes,~ extra-left-margin,~ extra-right-margin,~ first-col,~ @@ -2489,6 +2553,8 @@ code-for-last-row,~ columns-width,~ create-extra-nodes,~ + create-medium-nodes,~ + create-large-nodes,~ extra-left-margin,~ extra-right-margin,~ first-col,~ |