diff options
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf | bin | 420606 -> 424997 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex | 652 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf | bin | 1133328 -> 1166775 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx | 1810 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | 636 |
5 files changed, 2040 insertions, 1058 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 7c58a0449ce..21154fbe675 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 75a1954df9b..9ae1a3a8abd 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex @@ -232,8 +232,8 @@ l'extension \pkg{nicematrix} propose deux clés |cell-space-top-limit| et |cell-space-bottom-limit| qui sont similaires aux deux paramètres |\cellspacetoplimit| et |\cellspacebottomlimit| proposés par \pkg{cellspace}. -\colorbox{yellow!30}{Nouveau 5.9}\enskip Il existe aussi une clé -|cell-space-limits| pour régler simultanément les deux paramètres. +Il existe aussi une clé |cell-space-limits| pour régler simultanément les deux +paramètres. La valeur initiale de ces paramètres est $0$~pt pour que les environnements de \pkg{nicematrix} aient par défaut le même comportement que ceux de \pkg{array} @@ -409,7 +409,7 @@ Dans les environnements de \pkg{nicematrix}, on peut utiliser la commande |\Block| pour placer un élément au centre d'un rectangle de cases fusionnées. La commande |\Block| doit être utilisée dans la case supérieure gauche du bloc -avec deux arguments. +avec deux arguments obligatoires. \begin{itemize} \item Le premier argument est la taille de ce bloc avec la syntaxe $i$-$j$ où @@ -500,10 +500,34 @@ $\begin{bNiceArray}{ccc|c}[margin] \end{bNiceArray}$ + +\interitem +La commande |\Block| accepte en fait en premier argument optionnel (entre +crochets) une liste de couples clé-valeur. Les clés sont les suivantes : +\begin{itemize} +\item les clés |l|, |c| et |r| réglent le positionnement horizontal comme dit +précédemment ; +\item la clé |fill| prend en argument une couleur et remplit le bloc avec cette +couleur ; +\item la clé |draw| prend en argument une couleur et trace le cadre avec cette +couleur (la valeur par défaut de cette clé est la couleur courante des filets du +tableau) ; +\item la clé |color| prend en argument une couleur et l'applique au contenu et +trace également le cadre avec cette couleur. +\item la clé |line-width| fixe la largeur des filets servant pour le cadre (n'a +d'intérêt que si |draw| est utilisée) ; +\item \colorbox{yellow!50}{\textbf{Nouveau 5.12}}\enskip la clé +|rounded-corners| impose des coins arrondis (pour le cadre dessiné par |draw| et +le fond dessiné par |fill|) avec un rayon égal à la valeur de cette clé (la +valeur par défaut est 4~pt\footnote{Cette valeur par défaut est la valeur + initiale des \emph{rounded corners} de Tikz.}). +\end{itemize} + + \interitem \textbf{On doit remarquer que, par défaut, les blocs ne créent pas d'espace}. Il n'y a exception que pour les blocs mono-rangée et les blocs mono-colonne comme -expliqué juste après. +expliqué plus loin. \medskip @@ -512,10 +536,11 @@ construction |wc{...}| de \pkg{array}). \medskip \begin{BVerbatim} -\begin{NiceTabular}~emphase#{cwc{2cm}wc{3cm}c}@ +\begin{NiceTabular}{cwc{2cm}wc{3cm}c} rose & tulipe & marguerite & dahlia \\ violette -& \Block[draw=red,fill=red!15]{2-2}{\LARGE De très jolies fleurs} & & souci \\ +& ~emphase#\Block[draw=red,fill=red!15,rounded-corners]{2-2}{\LARGE De très jolies fleurs}@ + & & souci \\ pervenche & & & lys \\ arum & iris & jacinthe & muguet \end{NiceTabular} @@ -526,20 +551,13 @@ arum & iris & jacinthe & muguet \begin{center} \begin{NiceTabular}{cwc{2cm}wc{3cm}c} rose & tulipe & marguerite & dahlia \\ -violette & \Block[draw=red,fill=red!15]{2-2}{\LARGE De très jolies fleurs} & & souci \\ +violette & \Block[draw=red,fill=red!15,rounded-corners]{2-2} + {\LARGE De très jolies fleurs} & & souci \\ pervenche & & & lys \\ arum & iris & jacinthe & muguet \end{NiceTabular} \end{center} -\medskip -Comme on le voit sur cet exemple, on peut fixer la couleur de fond avec la clé -|fill| et la couleur du cadre avec la clé |draw|\footnote{Si la clé |draw| est - utilisée sans valeur, c'est la couleur par défaut des filets de tableaux qui - est utilisée.}. On peut aussi fixer l'épaisseur du trait avec la clé -|line-width|. - - \subsection{Les blocs mono-colonne} @@ -616,7 +634,8 @@ bloc sur plusieurs lignes. la consigne générale donnée dans le préambule pour cette colonne. \item On peut tracer un cadre autour du bloc avec la clé |draw| de la commande -|\Block|.\footnote{Pour colorier le fond d'une case, il n'y a pas besoin +|\Block| ou colorier le fond avec des bords arrondis avec les clés |fill| et +|rounded-corners|.\footnote{Pour colorier simplement le fond d'une case, il n'y a pas besoin d'utiliser un bloc mono-case : on peut utiliser la commande |\cellcolor| si la clé |colortbl-like| est utilisée : voir p.~\pageref{colortbl-like}.} \end{itemize} @@ -885,11 +904,11 @@ p.~\pageref{OnlyMainNiceMatrix}. \subsection{Les clés hlines et vlines} La clé |hlines| demande un tracé de tous les filets horizontaux et la clé -|vlines| demande un tracé de tous les filets verticaux (sauf dans les blocs et -dans les blocs virtuels déterminés par des lignes en pointillés). En fait, dans les -environnements avec délimiteurs (comme |{pNiceMatrix}| ou |{bNiceArray}|), les -filets extérieurs ne sont pas tracés (ce qui est le comportement certainement -attendu). +|vlines| demande un tracé de tous les filets verticaux (sauf dans les blocs, +créés par |\Block| et dans les blocs virtuels déterminés par des lignes en +pointillés : |\Cdots|, |\Vdots|, etc.). En fait, dans les environnements avec +délimiteurs (comme |{pNiceMatrix}| ou |{bNiceArray}|), les filets extérieurs ne +sont pas tracés (ce qui est le comportement certainement attendu). \medskip @@ -1143,16 +1162,33 @@ inconvénients. \subsection{Les outils de nicematrix dans le code-before} -L'extension \pkg{nicematrix} proposent des outils (indépendants de -\pkg{colortbl}) pour tracer d'abord les rectangles colorés, puis le contenu des -cases et les filets. Cette manière de faire est plus dans l'esprit du «modèle du -peintre» des formats PostScript et \textsc{pdf} et convient donc mieux aux -lecteurs de \textsc{pdf}. L'inconvénient est qu'elle nécessite plusieurs -compilations successives. +L'extension \pkg{nicematrix} propose des outils (indépendants de \pkg{colortbl}) +pour tracer d'abord les rectangles colorés, puis le contenu des cases et les +filets. Cette manière de faire est plus dans l'esprit du «modèle du peintre» des +formats PostScript et \textsc{pdf} et convient donc mieux aux lecteurs de +\textsc{pdf}. L'inconvénient est qu'elle nécessite plusieurs compilations +successives. \medskip L'extension \pkg{nicematrix} fournit une clé |code-before| pour du code qui sera -exécuté avant le tracé du tableau. De nouvelles commandes y sont disponibles : +exécuté avant le tracé du tableau. + +\smallskip +\colorbox{yellow!50}{\textbf{Nouveau 5.12}}\enskip Une syntaxe alternative est +proposée : on peut placer le contenu de ce |code-before| entre les mots-clés +|\CodeBefore| et |\Body| juste au début de l'environnement. + +\begin{Verbatim} +\begin{pNiceArray}{~textsl#preamble@} +~emphase#\CodeBefore@ +~textsl#instructions du code-before@ +~emphase#\Body@ +~textsl#contenu de l'environnement@ +\end{pNiceArray} +\end{Verbatim} + +\smallskip +De nouvelles commandes sont disponibles dans ce |\CodeBefore| : |\cellcolor|, |\rectanglecolor|, |\rowcolor|, |\columncolor|, |\rowcolors| et |\chessboardcolors|.\footnote{On pourra remarquer que, dans le \verb|code-before|, des nœuds PGF/Tikz correspondant à la position des filets @@ -1176,14 +1212,20 @@ format $i$-$j$ où $i$ est le numéro de ligne et $j$ le numéro de colonne. \begin{scope} \hfuzz=10cm \begin{BVerbatim}[boxwidth=10cm,baseline=c] -\begin{NiceTabular}{|c|c|c|}[code-before = ~emphase#\cellcolor{red!15}{3-1,2-2,1-3}@] +\begin{NiceTabular}{|c|c|c|} +\CodeBefore + ~emphase#\cellcolor{red!15}{3-1,2-2,1-3}@ +\Body \hline a & b & c \\ \hline e & f & g \\ \hline h & i & j \\ \hline \end{NiceTabular} \end{BVerbatim} -\begin{NiceTabular}{|c|c|c|}[code-before = \cellcolor{red!15}{3-1,2-2,1-3}] +\begin{NiceTabular}{|c|c|c|} +\CodeBefore + \cellcolor{red!15}{3-1,2-2,1-3} +\Body \hline a & b & c \\ \hline e & f & g \\ \hline @@ -1201,14 +1243,20 @@ et la case en bas à droite du rectangle. \begin{scope} \hfuzz=10cm \begin{BVerbatim}[boxwidth=10cm,baseline=c] -\begin{NiceTabular}{|c|c|c|}[code-before = ~emphase#\rectanglecolor{blue!15}{2-2}{3-3}@] +\begin{NiceTabular}{|c|c|c|} +\CodeBefore + ~emphase#\rectanglecolor{blue!15}{2-2}{3-3}@ +\Body \hline a & b & c \\ \hline e & f & g \\ \hline h & i & j \\ \hline \end{NiceTabular} \end{BVerbatim} -\begin{NiceTabular}{|c|c|c|}[code-before = \rectanglecolor{blue!15}{2-2}{3-3}] +\begin{NiceTabular}{|c|c|c|} +\CodeBefore + \rectanglecolor{blue!15}{2-2}{3-3} +\Body \hline a & b & c \\ \hline e & f & g \\ \hline @@ -1230,7 +1278,10 @@ partir de la rangée~$a$). \begin{scope} \hfuzz=10cm \begin{BVerbatim}[boxwidth=9cm,baseline=c] -$\begin{NiceArray}{lll}[hvlines, ~emphase#code-before = \rowcolor{red!15}{1,3-5,8-}@] +$\begin{NiceArray}{lll}[hvlines] +\CodeBefore + ~emphase#\rowcolor{red!15}{1,3-5,8-}@ +\Body a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \\ a_3 & b_3 & c_3 \\ @@ -1244,8 +1295,10 @@ a_{10} & b_{10} & c_{10} \\ \end{NiceArray}$ \end{BVerbatim} % -$\begin{NiceArray}{lll}% -[baseline=4,hvlines, code-before = \rowcolor{red!15}{1,3-5,8-}] +$\begin{NiceArray}{lll}[baseline=4,hvlines] +\CodeBefore + \rowcolor{red!15}{1,3-5,8-} +\Body a_1 & b_1 & c_1 \\ a_2 & b_2 & c_2 \\ a_3 & b_3 & c_3 \\ @@ -1281,7 +1334,7 @@ l'intervalle constitué de toutes les rangées du tableau à partir de la rangé \bigskip -La commande |\rowcolors| accepte une liste de paires clé-valeur comme argument +La commande |\rowcolors| accepte une liste de couples clé-valeur comme argument optionnel en dernière position (l'argument optionel en première position correspond à l'espace colorimétrique). Les clés disponibles sont |cols|, |restart| et |respect-blocks|. @@ -1306,8 +1359,10 @@ tableau pour englober les blocs (créés par la commande |\Block| : cf.~p.~\page \begin{scope} \hfuzz=10cm \begin{BVerbatim}[baseline=c,boxwidth=9cm] -\begin{NiceTabular}{clr}% - [hvlines,code-before = ~emphase#{\rowcolors{2}{blue!10}{}[cols=2-3,restart]}@] +\begin{NiceTabular}{clr}[hvlines] +\CodeBefore + ~emphase#{\rowcolors{2}{blue!10}{}[cols=2-3,restart]}@ +\Body \Block{1-*}{Résultats} \\ \Block{2-1}{A}& Pierre & 12 \\ & Jacques & 8 \\ @@ -1317,8 +1372,10 @@ tableau pour englober les blocs (créés par la commande |\Block| : cf.~p.~\page & Estelle & 15 \end{NiceTabular} \end{BVerbatim} -\begin{NiceTabular}{clr}[hvlines, - code-before = {\rowcolors{2}{blue!10}{}[cols=2-3,restart]},baseline=2] +\begin{NiceTabular}{clr}[hvlines,baseline=2] +\CodeBefore + \rowcolors{2}{blue!10}{}[cols=2-3,restart] +\Body \Block{1-*}{Résultats} \\ \Block{2-1}{A}& Pierre & 12 \\ & Jacques & 8 \\ @@ -1335,8 +1392,10 @@ tableau pour englober les blocs (créés par la commande |\Block| : cf.~p.~\page \begin{scope} \hfuzz=10cm \begin{BVerbatim}[baseline=c,boxwidth=11cm] -\begin{NiceTabular}{lr}[hvlines,code-before = -~emphase#\rowcolors{1}{blue!10}{}[respect-blocks]@] +\begin{NiceTabular}{lr}[hvlines] +\CodeBefore + ~emphase#\rowcolors{1}{blue!10}{}[respect-blocks]@ +\Body \Block{2-1}{Pierre} & 12 \\ & 13 \\ Jacques & 8 \\ @@ -1349,8 +1408,10 @@ Henri & 14 \\ & 19 \end{NiceTabular} \end{BVerbatim} -\begin{NiceTabular}{lr}[hvlines,code-before = -\rowcolors{1}{blue!10}{}[respect-blocks],baseline=c] +\begin{NiceTabular}{lr}[hvlines,baseline=c] +\CodeBefore + \rowcolors{1}{blue!10}{}[respect-blocks] +\Body \Block{2-1}{Pierre} & 12 \\ & 13 \\ Jacques & 8 \\ @@ -1376,14 +1437,19 @@ couleurs et colorie les cases en quinconces avec les deux couleurs. \begin{scope} \hfuzz=10cm \begin{BVerbatim}[baseline=c,boxwidth=9cm] -$\begin{pNiceMatrix}[r,margin, ~emphase#code-before=\chessboardcolors{red!15}{blue!15}@] +$\begin{pNiceMatrix}[r,margin] +\CodeBefore + ~emphase#code-before=\chessboardcolors{red!15}{blue!15}@ +\Body 1 & -1 & 1 \\ -1 & 1 & -1 \\ 1 & -1 & 1 \end{pNiceMatrix}$ \end{BVerbatim} -$\begin{pNiceMatrix}% -[baseline=1, r, margin, code-before = \chessboardcolors{red!15}{blue!15}] +$\begin{pNiceMatrix}[baseline=1, r, margin] +\CodeBefore + \chessboardcolors{red!15}{blue!15} +\Body 1 & -1 & 1 \\ -1 & 1 & -1 \\ 1 & -1 & 1 @@ -1404,8 +1470,11 @@ l'extension \pkg{booktabs} n'est pas chargée par \pkg{nicematrix}. \begin{scope} \hfuzz=10cm \begin{BVerbatim}[baseline=c,boxwidth=8.5cm] -\begin{NiceTabular}{lSSSS}% -[code-before = \rowcolor{red!15}{1-2} \rowcolors{3}{blue!15}{}] +\begin{NiceTabular}{lSSSS} +\CodeBefore + \rowcolor{red!15}{1-2} + \rowcolors{3}{blue!15}{} +\Body ~emphase#\toprule@ \Block{2-1}{Produit} & \Block{1-3}{dimensions (cm)} & & & @@ -1421,8 +1490,11 @@ spécial & 12 & 12 & 0.5 & 70 \\ ~emphase#\bottomrule@ \end{NiceTabular} \end{BVerbatim} -\begin{NiceTabular}[c]{lSSSS}% -[code-before = \rowcolor{red!15}{1-2} \rowcolors{3}{blue!15}{}] +\begin{NiceTabular}[c]{lSSSS} +\CodeBefore + \rowcolor{red!15}{1-2} + \rowcolors{3}{blue!15}{} +\Body \toprule \Block{2-1}{Produit} & \Block{1-3}{dimensions (cm)} & & & @@ -2062,7 +2134,7 @@ C[a_1,a_1] & \Cdots & C[a_1,a_n] & ~emphase#\Hdotsfor{1}@ & \Vdots & \Ddots & \Vdots \\ C[a_n,a_1] & \Cdots & C[a_n,a_n] & & C[a_n,a_1^{(p)}] & \Cdots & C[a_n,a_n^{(p)}] \\ -\rule{0pt}{15mm} & ~emphase#\Vdotsfor{1}@ & & \Ddots & & ~emphase#\Vdotsfor{1}@ \\ +\rule{0pt}{15mm}\NotEmpty & ~emphase#\Vdotsfor{1}@ & & \Ddots & & ~emphase#\Vdotsfor{1}@ \\ C[a_1^{(p)},a_1] & \Cdots & C[a_1^{(p)},a_n] & & C[a_1^{(p)},a_1^{(p)}] & \Cdots & C[a_1^{(p)},a_n^{(p)}] \\ \Vdots & \Ddots & \Vdots @@ -2077,7 +2149,7 @@ C[a_n^{(p)},a_1] & \Cdots & C[a_n^{(p)},a_n] C[a_1,a_1] & \Cdots & C[a_1,a_n] & \hspace*{20mm} & C[a_1,a_1^{(p)}] & \Cdots & C[a_1,a_n^{(p)}] \\ \Vdots & \Ddots & \Vdots & \Hdotsfor{1} & \Vdots & \Ddots & \Vdots \\ C[a_n,a_1] & \Cdots & C[a_n,a_n] & & C[a_n,a_1^{(p)}] & \Cdots & C[a_n,a_n^{(p)}] \\ -\rule{0pt}{15mm} & \Vdotsfor{1} & & \Ddots & & \Vdotsfor{1} \\ +\rule{0pt}{15mm}\NotEmpty & \Vdotsfor{1} & & \Ddots & & \Vdotsfor{1} \\ C[a_1^{(p)},a_1] & \Cdots & C[a_1^{(p)},a_n] & & C[a_1^{(p)},a_1^{(p)}] & \Cdots & C[a_1^{(p)},a_n^{(p)}] \\ \Vdots & \Ddots & \Vdots & \Hdotsfor{1} & \Vdots & \Ddots & \Vdots \\ C[a_n^{(p)},a_1] & \Cdots & C[a_n^{(p)},a_n] & & C[a_n^{(p)},a_1^{(p)}] & \Cdots & C[a_n^{(p)},a_n^{(p)}] @@ -2359,7 +2431,7 @@ p.~\pageref{customization}). \label{sub-matrix} -\colorbox{yellow!50}{\textbf{Nouveau 5.10}}\enskip +\colorbox{yellow!30}{Nouveau 5.10}\enskip La commande |\SubMatrix| permet de positionner des délimiteurs sur une partie du tableau, partie qui est considérée comme une sous-matrice. La commande |\SubMatrix| prend cinq arguments : @@ -2373,7 +2445,11 @@ la syntaxe $i$|-|$j$ où $i$ est le numéro de rangée et $j$ le numéro de colo \item le troisième argument est le coin inférieur droit avec la même syntaxe ; \item la quatrième argument est le délimiteur droit ; \item le cinquième argument, optionnel, entre crochets, est une liste de couples -clé-valeur. +clé-valeur.\footnote{Il n'y a pas d'argument optionnel entre crochets en première +position car un crochet ouvrant juste après \verb|\SubMatrix| doit pouvoir être +interprété comme le premier argument (obligatoire) de \verb|\SubMatrix|: ce +crochet est alors le délimiteur gauche de la sous-matrice (ex. : +\verb|\SubMatrix[{2-2}{4-7}]|).} \end{itemize} On remarquera que la commande |\SubMatrix| trace les délimiteurs après la @@ -2392,8 +2468,8 @@ colonne avec |@{\hspace{1.5em}}| dans le préambule du tableau. \dfrac{1}{4} & \dfrac{1}{2} & \dfrac{1}{4} & y \\ 1 & 2 & 3 & z \CodeAfter -~emphase#\SubMatrix({1-1}{3-3})+ -~emphase#\SubMatrix({1-4}{3-4})+ + ~emphase#\SubMatrix({1-1}{3-3})+ + ~emphase#\SubMatrix({1-4}{3-4})+ \end{NiceArray}\] \end{BVerbatim} \end{scope} @@ -2402,8 +2478,8 @@ $\begin{NiceArray}{ccc@{\hspace{1.5em}}c}[cell-space-limits=2pt,margin] \dfrac{1}{4} & \dfrac{1}{2} & \dfrac{1}{4} & y \\ 1 & 2 & 3 & z \CodeAfter -\SubMatrix({1-1}{3-3}) -\SubMatrix({1-4}{3-4}) + \SubMatrix({1-1}{3-3}) + \SubMatrix({1-4}{3-4}) \end{NiceArray}$ \bigskip @@ -2429,6 +2505,21 @@ environnements de \pkg{nicematrix} ou comme option de |\CodeAfter| avec le préfixe |sub-matrix|, c'est-à-dire qu'elles sont alors nommées |sub-matrix/left-xshift|, |sub-matrix/right-xshift|, |sub-matrix/xshift|, etc. +\medskip +\colorbox{yellow!50}{\textbf{Nouveau 5.12}}\enskip Il y a aussi les clés +suivantes, qui ne sont accessibles que pour une commande |\SubMatrix| +individuelle : +% +\begin{itemize} +\item |vlines| contient une liste de numéros de filets verticaux à tracer dans +la sous-matrice (si cette clé est utilisée sans valeur, tous les filets +verticaux sont tracés) ; +\item |hlines| est similaire à |vlines| mais pour les filets horizontaux ; +\item |hvlines|, qui s'utilise sans valeur, trace tous les filets dans la sous-matrice. +\end{itemize} +On remarquera que tous ces filets sont dessinés après la construction du tableau +principal : les colonnes et les rangées ne sont pas écartées. + \bigskip \begin{scope} \hfuzz=12cm @@ -2440,9 +2531,9 @@ $\begin{NiceArray}{cc@{\hspace{5mm}}l}[cell-space-limits=2pt] a & b & \frac12a+\frac14b \\ c & d & \frac12c+\frac14d \\ \CodeAfter -\SubMatrix({1-3}{2-3}) -\SubMatrix({3-1}{4-2}) -\SubMatrix({3-3}{4-3}) + \SubMatrix({1-3}{2-3}) + \SubMatrix({3-1}{4-2}) + \SubMatrix({3-3}{4-3}) \end{NiceArray}$ \end{BVerbatim} \end{scope} @@ -2452,9 +2543,9 @@ $\begin{NiceArray}{cc@{\hspace{5mm}}l}[cell-space-limits=2pt] a & b & \frac12a+\frac14b \\ c & d & \frac12c+\frac14d \\ \CodeAfter -\SubMatrix({1-3}{2-3}) -\SubMatrix({3-1}{4-2}) -\SubMatrix({3-3}{4-3}) + \SubMatrix({1-3}{2-3}) + \SubMatrix({3-1}{4-2}) + \SubMatrix({3-3}{4-3}) \end{NiceArray}$ \medskip @@ -2471,9 +2562,9 @@ $\begin{NiceArray}{cc@{\hspace{5mm}}l}[cell-space-limits=2pt] a & b & \frac12a+\frac14b \\ c & d & \frac12c+\frac14d \\ \CodeAfter -\SubMatrix({1-3}{2-3})[~emphase#slim!] -\SubMatrix({3-1}{4-2}) -\SubMatrix({3-3}{4-3}) + \SubMatrix({1-3}{2-3})[~emphase#slim!] + \SubMatrix({3-1}{4-2}) + \SubMatrix({3-3}{4-3}) \end{NiceArray}$ \end{BVerbatim} \end{scope} @@ -2484,9 +2575,9 @@ $\begin{NiceArray}{cc@{\hspace{5mm}}l}[cell-space-limits=2pt] a & b & \frac12a+\frac14b \\ c & d & \frac12c+\frac14d \\ \CodeAfter -\SubMatrix({1-3}{2-3})[slim] -\SubMatrix({3-1}{4-2}) -\SubMatrix({3-3}{4-3}) + \SubMatrix({1-3}{2-3})[slim] + \SubMatrix({3-1}{4-2}) + \SubMatrix({3-3}{4-3}) \end{NiceArray}$ @@ -3488,7 +3579,7 @@ noix & noisette & brugnon \label{noeuds-i} -\colorbox{yellow!50}{\textbf{Nouveau 5.11}}\enskip L'extension \pkg{nicematrix} +\colorbox{yellow!30}{Nouveau 5.11}\enskip L'extension \pkg{nicematrix} crée un nœud PGF-Tikz nommé simplement $i$ (précédé du préfixe habituel) à l'intersection du filet horizontal de numéro $i$ et du filet vertical de numéro~$j$ (ou plutôt la position potentielle de ces filets car ils ne sont @@ -3521,13 +3612,10 @@ horizontal~$i$ et du filet vertical~$j$ avec la syntaxe |(|$i$\verb+-|+$j$|)|. \medskip \begin{Verbatim} -\[\begin{NiceMatrix}[ - code-before = - { -~emphase# \tikz \draw [fill = red!15] @ -~emphase# (7-|4) -- (8-|4) -- (8-|5) -- (9-|5) -- (9-|6) |- cycle ; @ - } -] +\begin{NiceMatrix} +\CodeBefore +~emphase#\tikz \draw [fill=red!15] (7-|4) |- (8-|5) |- (9-|6) |- cycle ;@ +\Body 1 \\ 1 & 1 \\ 1 & 2 & 1 \\ @@ -3537,16 +3625,13 @@ horizontal~$i$ et du filet vertical~$j$ avec la syntaxe |(|$i$\verb+-|+$j$|)|. 1 & 6 & 15 & 20 & 15 & 6 & 1 \\ 1 & 7 & 21 & 35 & 35 & 21 & 7 & 1 \\ 1 & 8 & 28 & 56 & 70 & 56 & 28 & 8 & 1 -\end{NiceMatrix}\] +\end{NiceMatrix} \end{Verbatim} % -\[\begin{NiceMatrix}[ - code-before = - { - \tikz \draw [fill = red!15] - (7-|4) -- (8-|4) -- (8-|5) -- (9-|5) -- (9-|6) |- cycle ; - } -] +\[\begin{NiceMatrix} +\CodeBefore +\tikz \draw [fill=red!15] (7-|4) |- (8-|5) |- (9-|6) |- cycle ; +\Body 1 \\ 1 & 1 \\ 1 & 2 & 1 \\ @@ -3563,7 +3648,7 @@ horizontal~$i$ et du filet vertical~$j$ avec la syntaxe |(|$i$\verb+-|+$j$|)|. \label{node-sub-matrix} -\colorbox{yellow!50}{\textbf{Nouveau 5.10}}\enskip +\colorbox{yellow!30}{Nouveau 5.10}\enskip La commande |\SubMatrix| disponible dans le |\CodeAfter| a été présentée p.~\pageref{sub-matrix}. @@ -3636,10 +3721,8 @@ bibliothèque Tikz \pkg{patterns} : |\usetikzlibrary{patterns}|). \ExplSyntaxOn \cs_new_protected:Nn \__pantigny_hatch:nnn { - \begin { tikzpicture } - \fill [ pattern = north~west~lines , pattern~color = #3 ] - ( #1 -| #2) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ; - \end { tikzpicture } + \tikz \fill [ pattern = north~west~lines , pattern~color = #3 ] + ( #1 -| #2) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ; } \NewDocumentCommand \hatchcell { ! O { black } } @@ -3654,10 +3737,8 @@ bibliothèque Tikz \pkg{patterns} : |\usetikzlibrary{patterns}|). \ExplSyntaxOn \cs_new_protected:Nn \__pantigny_hatch:nnn { - \begin { tikzpicture } - \fill [ pattern = north~west~lines , pattern~color = #3 ] - ( #1 -| #2 ) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ; - \end { tikzpicture } + \tikz \fill [ pattern = north~west~lines , pattern~color = #3 ] + ( #1 -| #2 ) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ; } \NewDocumentCommand \hatchcell { ! O { black } } @@ -4150,96 +4231,224 @@ $\begin{pNiceMatrix}[first-row,first-col] -\subsection{Largeur des colonnes} +\subsection{Empilements de matrices} + +On a souvent besoin de présetner des matrices empilées les unes au-dessus des +autres (par exemple pour la résolutiond de systèmes linéaires). + \medskip -Dans l'exemple suivant, nous utilisons |{NiceMatrixBlock}| avec l'option -|auto-columns-width| parce que nous voulons la même largeur (automatique) pour -toutes les colonnes. +Pour avoir les colonnes alignées les unes sous les autres, on peut imposer une +largeur commune à toutes les colonnes, ce que l'on fait dans l'exemple suivant +avec l'environnement |{NiceMatrixBlock}| et l'option |auto-columns-width|. -\bigskip -\begin{BVerbatim} +\begin{Verbatim}[formatcom=\small\color{gray}] ~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@ \NiceMatrixOptions - { last-col,code-for-last-col = \color{blue}\scriptstyle,light-syntax} + { + light-syntax, + last-col, code-for-last-col = \color{blue} \scriptstyle, + } \setlength{\extrarowheight}{1mm} -$\begin{pNiceArray}{cccc:c} - 1 1 1 1 1 { } ; - 2 4 8 16 9 ; - 3 9 27 81 36 ; - 4 16 64 256 100 + +$\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 {} ; + 3 -18 12 1 4 ; +-3 -46 29 -2 -15 ; + 9 10 -5 4 7 \end{pNiceArray}$ -\medskip -$\begin{pNiceArray}{cccc:c} - 1 1 1 1 1 ; - 0 2 6 14 7 { L_2 \gets -2 L_1 + L_2 } ; - 0 6 24 78 33 { L_3 \gets -3 L_1 + L_3 } ; - 0 12 60 252 96 { L_4 \gets -4 L_1 + L_4 } + +\smallskip +$\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 ; +0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ; +0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ; +0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ; \end{pNiceArray}$ -... + +\smallskip +$\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 ; +0 64 -41 1 19 ; +0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 } +\end{pNiceArray}$ + +\smallskip +$\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 {} ; +0 64 -41 1 19 ; +\end{pNiceArray}$ + ~emphase#\end{NiceMatrixBlock}@ -\end{BVerbatim} +\end{Verbatim} \bigskip - -\begin{multicols}{2} \begin{NiceMatrixBlock}[auto-columns-width] -\NiceMatrixOptions{last-col,code-for-last-col = \color{blue}\scriptstyle,light-syntax} +\NiceMatrixOptions + { + light-syntax, + last-col, code-for-last-col = \color{blue} \scriptstyle , + } \setlength{\extrarowheight}{1mm} -\enskip $\begin{pNiceArray}{cccc:c} -1 1 1 1 1 { } ; -2 4 8 16 9 ; -3 9 27 81 36 ; -4 16 64 256 100 +\quad $\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 {} ; + 3 -18 12 1 4 ; +-3 -46 29 -2 -15 ; + 9 10 -5 4 7 \end{pNiceArray}$ -\medskip - -\enskip $\begin{pNiceArray}{cccc:c} -1 1 1 1 1 ; -0 2 6 14 7 { L_2 \gets -2 L_1 + L_2 } ; -0 6 24 78 33 { L_3 \gets -3 L_1 + L_3 } ; -0 12 60 252 96 { L_4 \gets -4 L_1 + L_4 } +\smallskip +\quad $\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 ; +0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ; +0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ; +0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ; \end{pNiceArray}$ -\medskip +\smallskip +\quad $\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 ; +0 64 -41 1 19 ; +0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 } +\end{pNiceArray}$ -\enskip $\begin{pNiceArray}{cccc:c} -1 1 1 1 1 ; -0 1 3 7 \frac72 { L_2 \gets \frac12 L_2 } ; -0 3 12 39 \frac{33}2 { L_3 \gets \frac12 L_3 } ; -0 1 5 21 8 { L_4 \gets \frac1{12} L_4 } +\smallskip +\quad $\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 {} ; +0 64 -41 1 19 ; \end{pNiceArray}$ +\end{NiceMatrixBlock} + +\bigskip +On constate que la dernière matrice n'est pas parfaitement alignée avec les +précédentes. C'est que les parenthèses, en LaTeX, n'ont pas toutes la même +largeur suivant leur taille. \medskip +\colorbox{yellow!50}{\textbf{Nouveau 5.12}}\enskip Pour résoudre ce problème, on +peut demander que les délimiteurs soient composés avec leur largeur maximale +grâce à la clé booléenne |delimiters/max-width|. + +\begin{Verbatim}[formatcom=\small\color{gray}] +~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@ +\NiceMatrixOptions + { + ~emphase#delimiters/max-width@, + light-syntax, + last-col, code-for-last-col = \color{blue}\scriptstyle, + } +\setlength{\extrarowheight}{1mm} -\enskip $\begin{pNiceArray}{cccc:c} -1 1 1 1 1 ; -0 1 3 7 \frac72 ; -0 0 3 18 6 { L_3 \gets -3 L_2 + L_3 } ; -0 0 -2 -14 -\frac92 { L_4 \gets L_2 - L_4 } +$\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 {} ; + 3 -18 12 1 4 ; +-3 -46 29 -2 -15 ; + 9 10 -5 4 7 \end{pNiceArray}$ -\medskip +... +~emphase#\end{NiceMatrixBlock}@ +\end{Verbatim} -\enskip $\begin{pNiceArray}{cccc:c} -1 1 1 1 1 ; -0 1 3 7 \frac72 ; -0 0 1 6 2 { L_3 \gets \frac13 L_3 } ; -0 0 -2 -14 -\frac92 +\bigskip +\begin{NiceMatrixBlock}[auto-columns-width] +\NiceMatrixOptions + { + delimiters/max-width, + light-syntax, + last-col, code-for-last-col = \color{blue}\scriptstyle, + } +\setlength{\extrarowheight}{1mm} + +\quad $\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 {} ; + 3 -18 12 1 4 ; +-3 -46 29 -2 -15 ; + 9 10 -5 4 7 \end{pNiceArray}$ -\medskip +\smallskip +\quad $\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 ; +0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ; +0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ; +0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ; +\end{pNiceArray}$ -\enskip $\begin{pNiceArray}{cccc:c} -1 1 1 1 1 ; -0 1 3 7 \frac72 ; -0 0 1 6 2 ; -0 0 0 -2 -\frac12 { L_4 \gets L_3 + L_4 } +\smallskip +\quad $\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 ; +0 64 -41 1 19 ; +0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 } \end{pNiceArray}$ + +\smallskip +\quad $\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 {} ; +0 64 -41 1 19 ; +\end{pNiceArray}$ + \end{NiceMatrixBlock} -\end{multicols} + + +\interitem +Si on souhaite un alignement des colonnes des différentes matrices sans imposer +la même largeur à toutes les colonnes, on peut utiliser un grand tableau unique +et placer les parenthèses avec des commandes |\SubMatrix| dans le |\CodeAfter|. +Bien sûr, ce tableau ne pourra pas être coupé par un saut de page. + +\medskip +\begin{Verbatim} +\setlength{\extrarowheight}{1mm} +\[\begin{NiceMatrix}% + [ r, last-col=6, code-for-last-col = \scriptstyle \color{blue} ] +12 & -8 & 7 & 5 & 3 \\ + 3 & -18 & 12 & 1 & 4 \\ +-3 & -46 & 29 &-2 &-15 \\ + 9 & 10 &-5 &4 & 7 \\[1mm] +12 & -8 & 7 &5 & 3 \\ +0 & 64 &-41 & 1 & 19 & L_2 \gets L_1-4L_2 \\ +0 & -192 &123 &-3 &-57 & L_3 \gets L_1+4L_3 \\ +0 & -64 & 41 &-1 &-19 & L_4 \gets 3L_1-4L_4 \\[1mm] +12 & -8 &7 &5 & 3 \\ +0 & 64 &-41 &1 &19 \\ +0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm] +12 & -8 &7 &5 & 3 \\ +0 & 64 &-41 & 1 & 19 \\ +~emphase#\CodeAfter@ +~emphase# \SubMatrix({1-1}{4-5})[vlines=4]@ +~emphase# \SubMatrix({5-1}{8-5})[vlines=4]@ +~emphase# \SubMatrix({9-1}{11-5})[vlines=4]@ +~emphase# \SubMatrix({12-1}{13-5})[vlines=4]@ +\end{NiceMatrix}\] +\end{Verbatim} + +\medskip +\begin{scope} +\setlength{\extrarowheight}{1mm} +\[\begin{NiceMatrix}% + [ r, last-col=6, code-for-last-col = \scriptstyle \color{blue} ] +12 & -8 & 7 & 5 & 3 \\ + 3 & -18 & 12 & 1 & 4 \\ +-3 & -46 & 29 &-2 &-15 \\ + 9 & 10 &-5 &4 & 7 \\[1mm] +12 & -8 & 7 &5 & 3 \\ +0 & 64 &-41 & 1 & 19 & L_2 \gets L_1-4L_2 \\ +0 & -192 &123 &-3 &-57 & L_3 \gets L_1+4L_3 \\ +0 & -64 & 41 &-1 &-19 & L_4 \gets 3L_1-4L_4 \\[1mm] +12 & -8 &7 &5 & 3 \\ +0 & 64 &-41 &1 &19 \\ +0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm] +12 & -8 &7 &5 & 3 \\ +0 & 64 &-41 & 1 & 19 \\ +\CodeAfter + \SubMatrix({1-1}{4-5})[vlines=4] + \SubMatrix({5-1}{8-5})[vlines=4] + \SubMatrix({9-1}{11-5})[vlines=4] + \SubMatrix({12-1}{13-5})[vlines=4] +\end{NiceMatrix}\] +\end{scope} \subsection{Comment surligner les cases d'une matrice} @@ -4280,7 +4489,7 @@ matrice.\footnote{Pour la commande |\cline|, voir la remarque \vspace{1cm} Il est possible de colorier une rangée avec |\rowcolor| dans le |code-before| -(ou avec |\rowcolor| dans la première case de la rangée si on utilise la clé +(ou avec |\rowcolor| dans une case de la rangée si on utilise la clé |colortbl-like| − même si \pkg{colortbl} n'est pas chargé). @@ -4491,112 +4700,43 @@ a & a & a & L_3 \\ -\subsection{Utilisation directe des nœuds Tikz} - -Dans l'exemple suivant, on souhaite illustrer le produit mathématique de deux matrices. - -\medskip -L'utilisation de |{NiceMatrixBlock}| avec l'option |auto-columns-width| va -permettre que toutes les colonnes aient la même largeur ce qui permettra un -alignement des deux matrices superposées. -\begin{Verbatim} -\begin{NiceMatrixBlock}[auto-columns-width] -\end{Verbatim} - -\begin{Verbatim} -\NiceMatrixOptions{nullify-dots} -\end{Verbatim} +\subsection{Utilisation de \textbackslash SubMatrix dans le code-before} -Les trois matrices vont être disposées les unes par rapport aux autres grâce à un tableau de LaTeX. -\begin{Verbatim} -$\begin{array}{cc} -& -\end{Verbatim} +Dans l'exemple suivant, on illustre le produit mathématique de deux matrices. -La matrice $B$ a une «première rangée» (pour $C_j$) d'où l'option |first-row|. -\begin{Verbatim} -\begin{bNiceArray}{c>{\strut}cccc}[name=B,first-row] - & & ~emphase#C_j@ \\ -b_{11} & \Cdots & b_{1j} & \Cdots & b_{1n} \\ -\Vdots & & \Vdots & & \Vdots \\ - & & b_{kj} \\ - & & \Vdots \\ - b_{n1} & \Cdots & b_{nj} & \Cdots & b_{nn} -\end{bNiceArray} \\ \\ -\end{Verbatim} +L'ensemble de la figure est un environnement |{NiceArray}| et les trois paires +de parenthèses ont été rajoutées avec |\SubMatrix| dans le |code-before|. -La matrice $A$ a une «première colonne» (pour $L_i$) d'où l'option |first-col|. -\begin{Verbatim} -\begin{bNiceArray}{cc>{\strut}ccc}[name=A,first-col] +Ceux qui sont intéressés par le code correspondant le trouveront dans le fichier +source de ce document. +% +% +% +\[\begin{NiceArray}{*{6}{c}@{\hspace{6mm}}*{5}{c}}[nullify-dots] +\CodeBefore + \SubMatrix({2-7}{6-11}) + \SubMatrix({7-2}{11-6}) + \SubMatrix({7-7}{11-11}) +\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 \\ -~emphase#L_i@ & a_{i1} & \Cdots & a_{ik} & \Cdots & a_{in} \\ - & \Vdots & & & & \Vdots \\ - & a_{n1} & \Cdots & & & a_{nn} -\end{bNiceArray} -& -\end{Verbatim} - -Dans la matrice produit, on remarquera que les lignes en pointillés sont «semi-ouvertes». -\begin{Verbatim} -\begin{bNiceArray}{cc>{\strut}ccc} - & & & & \\ - & & \Vdots \\ -\Cdots & & c_{ij} \\ -\\ -\\ -\end{bNiceArray} -\end{array}$ - -\end{NiceMatrixBlock} -\end{Verbatim} - -\begin{Verbatim} -\begin{tikzpicture}[remember picture, overlay] - \node [highlight = (A-3-1) (A-3-5) ] {} ; - \node [highlight = (B-1-3) (B-5-3) ] {} ; - \draw [color = gray] (A-3-3) to [bend left] (B-3-3) ; -\end{tikzpicture} -\end{Verbatim} - - - -\begin{NiceMatrixBlock}[auto-columns-width] -\NiceMatrixOptions{nullify-dots} -$\begin{array}{cc} -& -\begin{bNiceArray}{c>{\strut}cccc}[name=B,first-row] - & & C_j \\ -b_{11} & \Cdots & b_{1j} & \Cdots & b_{1n} \\ -\Vdots & & \Vdots & & \Vdots \\ - & & b_{kj} \\ - & & \Vdots \\ - b_{n1} & \Cdots & b_{nj} & \Cdots & b_{nn} -\end{bNiceArray} \\ \\ -\begin{bNiceArray}{cc>{\strut}ccc}[name=A,first-col] - & a_{11} & \Cdots & & & a_{1n} \\ - & \Vdots & & & & \Vdots \\ -L_i & a_{i1} & \Cdots & a_{ik} & \Cdots & a_{in} \\ - & \Vdots & & & & \Vdots \\ - & a_{n1} & \Cdots & & & a_{nn} \\ -\end{bNiceArray} -& -\begin{bNiceArray}{cc>{\strut}ccc} - & & & & \\ - & & \Vdots \\ -\Cdots & & c_{ij} \\ -\\ -\\ -\end{bNiceArray} -\end{array}$ - -\end{NiceMatrixBlock} - -\begin{tikzpicture}[remember picture, overlay] - \node [highlight = (A-3-1) (A-3-5) ] {} ; - \node [highlight = (B-1-3) (B-5-3) ] {} ; - \draw [color = gray] (A-3-3) to [bend left] (B-3-3) ; + & a_{n1} & \Cdots & & & a_{nn} \\ +\CodeAfter +\begin{tikzpicture} +\node [highlight = (9-2) (9-6)] { } ; +\node [highlight = (2-9) (6-9)] { } ; +\draw [gray,shorten > = 1mm, shorten < = 1mm] (9-4.north) to [bend left] (4-9.west) ; \end{tikzpicture} +\end{NiceArray}\] diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf Binary files differindex a8e3ae524ee..18b9e7af326 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 24732c133c6..a84069b7c80 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.11} -\def\myfiledate{2021/02/22} +\def\myfileversion{5.12} +\def\myfiledate{2021/03/10} % % %<*batchfile> @@ -279,8 +279,7 @@ version 2005/12/01 or later. % |cell-space-bottom-limit| similar to the parameters |\cellspacetoplimit| and % |\cellspacebottomlimit| of \pkg{cellspace}. % -% \colorbox{yellow!30}{New 5.9}\enskip There is also a key |cell-space-limits| -% to set both parameters at once. +% There is also a key |cell-space-limits| to set both parameters at once. % % The initial value of these parameters is $0$~pt in order to have for the % environments of \pkg{nicematrix} the same behaviour as those of \pkg{array} @@ -546,7 +545,29 @@ version 2005/12/01 or later. % 0 & \Cdots& 0 & 0 % \end{bNiceArray}$ % -% +% \interitem +% In fact, the command |\Block| accepts as first optional argument (between +% square brackets) a list of couples key-value. The available keys are as +% follows: +% \begin{itemize} +% \item the keys |l|, |c| and |r| are used to fix the horizontal position of the +% content of the block, as explained previously; +% \item the key |fill| takes in as value a color and fills the block with that +% color; +% \item the key |draw| takes in as value a color and strokes the frame of the +% block with that color (the default value of that key is the current color of +% the rules of the array); +% \item the key |color| takes in as value a color and apply that color the +% content of the block but draws also the frame of the block with that color; +% \item the key |line-width| is the width (thickness) of the frame (this key +% should be used only when the key |draw| is in force); +% \item \colorbox{yellow!50}{\textbf{New 5.12}}\enskip the key |rounded-corners| +% requires rounded corners (for the frame drawn by |draw| and the shape drawn by +% |fill|) with a radius equal to the value of that key (the default value is +% 4~pt\footnote{This value is the initial value of the \emph{rounded corners} of +% Tikz.}). +% \end{itemize} +% % \interitem % {\bfseries One must remark that, by default, the commands |\Blocks| don't create space}. % There is exception only for the blocks mono-row and the blocks mono-column as @@ -556,35 +577,29 @@ version 2005/12/01 or later. % In the following example, we have had to enlarge by hand the columns 2 and 3 % (with the construction |wc{...}| of \pkg{array}). % -% \medskip +% \bigskip % \begin{BVerbatim} -% \begin{NiceTabular}~emphase#{cwc{2cm}wc{3cm}c}@ +% \begin{NiceTabular}{cwc{2cm}wc{3cm}c} % rose & tulipe & marguerite & dahlia \\ % violette -% & \Block[draw=red,fill=red!15]{2-2}{\LARGE De très jolies fleurs} & & souci \\ +% & ~emphase#\Block[draw=red,fill=red!15,rounded-corners]{2-2}{\LARGE De très jolies fleurs}@ +% & & souci \\ % pervenche & & & lys \\ % arum & iris & jacinthe & muguet % \end{NiceTabular} % \end{BVerbatim} % -% % \medskip % \begin{center} % \begin{NiceTabular}{cwc{2cm}wc{3cm}c} % rose & tulipe & marguerite & dahlia \\ -% violette & -% \Block[draw=red,fill=red!15]{2-2}{\LARGE De très jolies fleurs} & & souci \\ +% violette & \Block[draw=red,fill=red!15,rounded-corners]{2-2} +% {\LARGE De très jolies fleurs} & & souci \\ % pervenche & & & lys \\ % arum & iris & jacinthe & muguet % \end{NiceTabular} % \end{center} % -% As we can see on this example, it's possible to fill the block by using the -% key |fill| and to draw the frame with the key |draw|\footnote{If the key -% |draw| is used without value, the default color the rules of the tabulars is -% used}. It's also possible to change the width (thickness) of that rules with -% the key |line-width|. -% % \subsection{The mono-column blocks} % % The mono-column blocks have a special behaviour. @@ -655,9 +670,11 @@ version 2005/12/01 or later. % derogation of the type of column given in the preamble of the array. % % \item It's possible do draw a frame around the cell with the key |draw| of the -% command |\Block|.\footnote{If one wishes to color the background of a unique -% celle, there is no point using the command |\Block|: it's possible to use the -% command |\cellcolor| (when the key |colortbl-like| is used).} +% command |\Block| and to fill the background with rounded corners with the keys +% |fill| and |rounded-corners|.\footnote{If one simply wishes to color the +% background of a unique celle, there is no point using the command |\Block|: +% it's possible to use the command |\cellcolor| (when the key |colortbl-like| is +% used).} % \end{itemize} % % \bigskip @@ -908,10 +925,10 @@ version 2005/12/01 or later. % \subsection{The keys hlines and vlines} % % The key |hlines| draws all the horizontal rules and the key |vlines| draws all -% the vertical rules excepted in the blocks (and the virtual blocks determined -% by dotted lines). In fact, in the environments with delimiters (as -% |{pNiceMatrix}| or |{bNiceArray}|) the exteriors rules are not drawn (as -% expected). +% the vertical rules excepted in the blocks, created by |\Block| and the virtual +% blocks determined by dotted lines: |\Cdots|, |\Vdots|, etc.. In fact, in the +% environments with delimiters (as |{pNiceMatrix}| or |{bNiceArray}|) the +% exteriors rules are not drawn (as expected). % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=10.6cm] @@ -1164,11 +1181,27 @@ version 2005/12/01 or later. % % \medskip % The extension \pkg{nicematrix} provides a key |code-before| for some code that -% will be executed before the drawing of the tabular. In this |code-before|, new -% commands are available: |\cellcolor|, |\rectanglecolor|, |\rowcolor|, -% |\columncolor|, |\rowcolors| and |\chessboardcolors|.\footnote{Remark that, in -% the \verb|code-before|, some PGF/Tikz nodes corresponding to the position to -% the potential rules are available: cf.~p.~\pageref{nodes-i}.} +% will be executed before the drawing of the tabular. +% +% \medskip +% \colorbox{yellow!50}{\textbf{New 5.12}}\enskip An alternative syntax is +% provided: it's possible to put the content of that |code-before| between the +% keywords |\CodeBefore| and |\Body| at the beginning of the environment. +% +% \begin{Verbatim} +% \begin{pNiceArray}{~textsl#preamble@} +% ~emphase#\CodeBefore@ +% ~textsl#instructions of the code-before@ +% ~emphase#\Body@ +% ~textsl#contents of the environnement@ +% \end{pNiceArray} +% \end{Verbatim} +% +% New commands are available in that |\CodeBefore|: |\cellcolor|, +% |\rectanglecolor|, |\rowcolor|, |\columncolor|, |\rowcolors| and +% |\chessboardcolors|.\footnote{Remark that, in the \verb|code-before|, some +% PGF/Tikz nodes corresponding to the position to the potential rules are +% available: cf.~p.~\pageref{nodes-i}.} % \label{code-before} % % \medskip @@ -1189,16 +1222,20 @@ version 2005/12/01 or later. % \begin{scope} % \hfuzz=10cm % \begin{BVerbatim}[boxwidth=10cm,baseline=c] -% \begin{NiceTabular}{|c|c|c|}[code-before = -% ~emphase#\cellcolor{red!15}{3-1,2-2,1-3}@] +% \begin{NiceTabular}{|c|c|c|} +% \CodeBefore +% ~emphase#\cellcolor{red!15}{3-1,2-2,1-3}@ +% \Body % \hline % a & b & c \\ \hline % e & f & g \\ \hline % h & i & j \\ \hline % \end{NiceTabular} % \end{BVerbatim} -% \begin{NiceTabular}{|c|c|c|}[code-before = -% \cellcolor{red!15}{3-1,2-2,1-3}] +% \begin{NiceTabular}{|c|c|c|} +% \CodeBefore +% \cellcolor{red!15}{3-1,2-2,1-3} +% \Body % \hline % a & b & c \\ \hline % e & f & g \\ \hline @@ -1215,16 +1252,20 @@ version 2005/12/01 or later. % \begin{scope} % \hfuzz=10cm % \begin{BVerbatim}[boxwidth=10cm,baseline=c] -% \begin{NiceTabular}{|c|c|c|}[code-before = -% ~emphase#\rectanglecolor{blue!15}{2-2}{3-3}@] +% \begin{NiceTabular}{|c|c|c|} +% \CodeBefore +% ~emphase#\rectanglecolor{blue!15}{2-2}{3-3}@ +% \Body % \hline % a & b & c \\ \hline % e & f & g \\ \hline % h & i & j \\ \hline % \end{NiceTabular} % \end{BVerbatim} -% \begin{NiceTabular}{|c|c|c|}[code-before = -% \rectanglecolor{blue!15}{2-2}{3-3}] +% \begin{NiceTabular}{|c|c|c|} +% \CodeBefore +% \rectanglecolor{blue!15}{2-2}{3-3} +% \Body % \hline % a & b & c \\ \hline % e & f & g \\ \hline @@ -1244,7 +1285,10 @@ version 2005/12/01 or later. % \begin{scope} % \hfuzz = 10cm % \begin{BVerbatim}[boxwidth=9cm,baseline=c] -% $\begin{NiceArray}{lll}[hvlines, ~emphase#code-before = \rowcolor{red!15}{1,3-5,8-}@] +% $\begin{NiceArray}{lll}[hvlines] +% \CodeBefore +% ~emphase#code-before = \rowcolor{red!15}{1,3-5,8-}@ +% \Body % a_1 & b_1 & c_1 \\ % a_2 & b_2 & c_2 \\ % a_3 & b_3 & c_3 \\ @@ -1257,7 +1301,10 @@ version 2005/12/01 or later. % a_{10} & b_{10} & c_{10} \\ % \end{NiceArray}$ % \end{BVerbatim} -% $\begin{NiceArray}{lll}[baseline=4,hvlines, code-before = \rowcolor{red!15}{1,3-5,8-}] +% $\begin{NiceArray}{lll}[baseline=4,hvlines] +% \CodeBefore +% \rowcolor{red!15}{1,3-5,8-} +% \Body % a_1 & b_1 & c_1 \\ % a_2 & b_2 & c_2 \\ % a_3 & b_3 & c_3 \\ @@ -1314,9 +1361,11 @@ version 2005/12/01 or later. % \begin{scope} % \hfuzz=10cm % \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% \begin{NiceTabular}{clr} -% [hvlines,code-before = ~emphase#{\rowcolors{2}{blue!10}{}[cols=2-3,restart]}@] -% \Block{1-}{Results} \\ +% \begin{NiceTabular}{clr}[hvlines] +% \CodeBefore +% ~emphase#\rowcolors{2}{blue!10}{}[cols=2-3,restart]@ +% \Body +% \Block{1-*}{Results} \\ % John & 12 \\ % Stephen & 8 \\ % Sarah & 18 \\ @@ -1325,9 +1374,11 @@ version 2005/12/01 or later. % Madison & 15 % \end{NiceTabular} % \end{BVerbatim} -% \begin{NiceTabular}{clr}[hvlines,code-before = -% {\rowcolors{2}{blue!10}{}[cols=2-3,restart]},baseline=2] -% \Block{1-}{Results} \\ +% \begin{NiceTabular}{clr}[hvlines,baseline=2] +% \CodeBefore +% \rowcolors{2}{blue!10}{}[cols=2-3,restart] +% \Body +% \Block{1-*}{Results} \\ % \Block{2-1}{A}& John & 12 \\ % & Stephen & 8 \\ % \Block{4-1}{B}& Sarah & 18 \\ @@ -1341,8 +1392,10 @@ version 2005/12/01 or later. % \begin{scope} % \hfuzz=10cm % \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% \begin{NiceTabular}{lr}[hvlines,code-before = -% ~emphase#\rowcolors{1}{blue!10}{}[respect-blocks]@] +% \begin{NiceTabular}{lr}[hvlines] +% \CodeBefore +% ~emphase#\rowcolors{1}{blue!10}{}[respect-blocks]@ +% \Body % \Block{2-1}{John} & 12 \\ % & 13 \\ % Steph & 8 \\ @@ -1355,8 +1408,10 @@ version 2005/12/01 or later. % & 19 % \end{NiceTabular} % \end{BVerbatim} -% \begin{NiceTabular}{lr}[hvlines,code-before = -% \rowcolors{1}{blue!10}{}[respect-blocks],baseline=c] +% \begin{NiceTabular}{lr}[hvlines,baseline=c] +% \CodeBefore +% \rowcolors{1}{blue!10}{}[respect-blocks] +% \Body % \Block{2-1}{John} & 12 \\ % & 13 \\ % Steph & 8 \\ @@ -1379,13 +1434,19 @@ version 2005/12/01 or later. % \begin{scope} % \hfuzz=10cm % \begin{BVerbatim}[baseline=c,boxwidth=9cm] -% $\begin{pNiceMatrix}[r,margin, ~emphase#code-before=\chessboardcolors{red!15}{blue!15}@] +% $\begin{pNiceMatrix}[r,margin] +% \CodeBefore +% ~emphase#code-before=\chessboardcolors{red!15}{blue!15}@ +% \Body % 1 & -1 & 1 \\ % -1 & 1 & -1 \\ % 1 & -1 & 1 % \end{pNiceMatrix}$ % \end{BVerbatim} -% $\begin{pNiceMatrix}[r,baseline=1, margin, code-before = \chessboardcolors{red!15}{blue!15}] +% $\begin{pNiceMatrix}[r,baseline=1, margin] +% \CodeBefore +% \chessboardcolors{red!15}{blue!15} +% \Body % 1 & -1 & 1 \\ % -1 & 1 & -1 \\ % 1 & -1 & 1 @@ -1407,8 +1468,11 @@ version 2005/12/01 or later. % \begin{scope} % \hfuzz=10cm % \begin{BVerbatim}[baseline=c,boxwidth=8.5cm] -% \begin{NiceTabular}[c]{lSSSS}% -% [code-before = \rowcolor{red!15}{1-2} \rowcolors{3}{blue!15}{}] +% \begin{NiceTabular}[c]{lSSSS} +% \CodeBefore +% \rowcolor{red!15}{1-2} +% \rowcolors{3}{blue!15}{} +% \Body % ~emphase#\toprule@ % \Block{2-1}{Product} & % \Block{1-3}{dimensions (cm)} & & & @@ -1424,8 +1488,11 @@ version 2005/12/01 or later. % ~emphase#\bottomrule@ % \end{NiceTabular} % \end{BVerbatim} -% \begin{NiceTabular}[c]{lSSSS}[code-before = \rowcolor{red!15}{1-2} -% \rowcolors{3}{blue!15}{}] +% \begin{NiceTabular}[c]{lSSSS} +% \CodeBefore +% \rowcolor{red!15}{1-2} +% \rowcolors{3}{blue!15}{} +% \Body % \toprule % \Block{2-1}{Product} & % \Block{1-3}{dimensions (cm)} & & & @@ -1645,7 +1712,6 @@ version 2005/12/01 or later. % for the potential ``first column''. % % \begin{Verbatim} -% $\begin{pNiceMatrix}[~emphase#first-row,last-row,first-col,last-col@] % $\begin{pNiceMatrix}[~emphase#first-row,last-row,first-col,last-col@,nullify-dots] % & C_1 & \Cdots & & C_4 & \\ % L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\ @@ -1654,7 +1720,6 @@ version 2005/12/01 or later. % L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\ % & C_1 & \Cdots & & C_4 & % \end{pNiceMatrix}$ -% \end{pNiceMatrix}$ % \end{Verbatim} % % \[\begin{pNiceMatrix}[first-row,last-row,first-col,last-col,nullify-dots] @@ -2053,7 +2118,7 @@ version 2005/12/01 or later. % & ~emphase#\Hdotsfor{1}@ & \Vdots & \Ddots & \Vdots \\ % C[a_n,a_1] & \Cdots & C[a_n,a_n] % & & C[a_n,a_1^{(p)}] & \Cdots & C[a_n,a_n^{(p)}] \\ -% \rule{0pt}{15mm} & ~emphase#\Vdotsfor{1}@ & & \Ddots & & ~emphase#\Vdotsfor{1}@ \\ +% \rule{0pt}{15mm}\NotEmpty & ~emphase#\Vdotsfor{1}@ & & \Ddots & & ~emphase#\Vdotsfor{1}@ \\ % C[a_1^{(p)},a_1] & \Cdots & C[a_1^{(p)},a_n] % & & C[a_1^{(p)},a_1^{(p)}] & \Cdots & C[a_1^{(p)},a_n^{(p)}] \\ % \Vdots & \Ddots & \Vdots @@ -2068,7 +2133,7 @@ version 2005/12/01 or later. % C[a_1,a_1] & \Cdots & C[a_1,a_n] & \hspace*{20mm} & C[a_1,a_1^{(p)}] & \Cdots & C[a_1,a_n^{(p)}] \\ % \Vdots & \Ddots & \Vdots & \Hdotsfor{1} & \Vdots & \Ddots & \Vdots \\ % C[a_n,a_1] & \Cdots & C[a_n,a_n] & & C[a_n,a_1^{(p)}] & \Cdots & C[a_n,a_n^{(p)}] \\ -% \rule{0pt}{15mm} & \Vdotsfor{1} & & \Ddots & & \Vdotsfor{1} \\ +% \rule{0pt}{15mm}\NotEmpty & \Vdotsfor{1} & & \Ddots & & \Vdotsfor{1} \\ % C[a_1^{(p)},a_1] & \Cdots & C[a_1^{(p)},a_n] & & C[a_1^{(p)},a_1^{(p)}] & \Cdots & C[a_1^{(p)},a_n^{(p)}] \\ % \Vdots & \Ddots & \Vdots & \Hdotsfor{1} & \Vdots & \Ddots & \Vdots \\ % C[a_n^{(p)},a_1] & \Cdots & C[a_n^{(p)},a_n] & & C[a_n^{(p)},a_1^{(p)}] & \Cdots & C[a_n^{(p)},a_n^{(p)}] @@ -2340,7 +2405,7 @@ version 2005/12/01 or later. % % \label{sub-matrix} % -% \colorbox{yellow!50}{\textbf{New 5.10}}\enskip +% \colorbox{yellow!30}{New 5.10}\enskip % The command |\SubMatrix| provides a way to put delimiters on a portion % of the array considered as a submatrix. The command |\SubMatrix| takes in five % arguments: @@ -2352,7 +2417,12 @@ version 2005/12/01 or later. % syntax $i$|-|$j$ where $i$ the number of row and $j$ the number of column; % \item the third argument is the lower-right corner with the same syntax; % \item the fourth argument is the right delimiter; -% \item the last argument, which is optional, is a list of key-value pairs. +% \item the last argument, which is optional, is a list of key-value +% pairs.\footnote{There is no optional argument between square brackets in first +% position because a square bracket just after |\SubMatrix| must be interpreted +% as the first (mandatory) argument of the command |\SubMatrix|: that bracket is +% the left delimiter of the sub-matrix to construct (eg.: +% |\SubMatrix[{2-2}{4-7}]|).} % \end{itemize} % % One should remark that the command |\SubMatrix| draws the delimiters after the @@ -2371,8 +2441,8 @@ version 2005/12/01 or later. % \dfrac{1}{4} & \dfrac{1}{2} & \dfrac{1}{4} & y \\ % 1 & 2 & 3 & z % \CodeAfter -% ~emphase#\SubMatrix({1-1}{3-3})+ -% ~emphase#\SubMatrix({1-4}{3-4})+ +% ~emphase#\SubMatrix({1-1}{3-3})+ +% ~emphase#\SubMatrix({1-4}{3-4})+ % \end{NiceArray}\] % \end{BVerbatim} % \end{scope} @@ -2381,8 +2451,8 @@ version 2005/12/01 or later. % \dfrac{1}{4} & \dfrac{1}{2} & \dfrac{1}{4} & y \\ % 1 & 2 & 3 & z % \CodeAfter -% \SubMatrix({1-1}{3-3}) -% \SubMatrix({1-4}{3-4}) +% \SubMatrix({1-1}{3-3}) +% \SubMatrix({1-4}{3-4}) % \end{NiceArray}$ % % \bigskip @@ -2394,7 +2464,7 @@ version 2005/12/01 or later. % (height |\ht| + depth |\dp|); % \item |delimiters/color| fixes the color of the delimiters (also % available in |\NiceMatrixOptions|, in the environments with delimiters and as -% option of the command |\CodeAfter|); +% option of the keyword |\CodeAfter|); % \item |slim| is a boolean key: when that key is in force, the horizontal % position of the delimiters is computed by using only the contents of the cells % of the submatrix whereas, in the general case, the position is computed by @@ -2407,6 +2477,24 @@ version 2005/12/01 or later. % the prefix |sub-matrix| which means that their names are therefore % |sub-matrix/left-xshift|, |sub-matrix/right-xshift|, |sub-matrix/xshift|, etc. % +% \bigskip +% \medskip +% \colorbox{yellow!50}{\textbf{New 5.12}}\enskip There is also the following +% keys, which are available only for an individual command |\SubMatrix|: +% +% \begin{itemize} +% \item |vlines| contents a list of numbers of vertical rules that will be drawn in +% the sub-matrix (if this key is used without value, all the vertical rules of +% the sub-matrix are drawn); +% +% \item |hlines| is similar to |vlines| but for the horizontal rules; +% +% \item |hvlines|, which must be used without value, draws all the vertical and +% horizontal rules. +% \end{itemize} +% One should remark that these keys add their rules after the construction of +% the main matrix: no space is added between the rows and the columns of the +% array for theses rules. % % \bigskip % \begin{scope} @@ -2419,9 +2507,9 @@ version 2005/12/01 or later. % a & b & \frac12a+\frac14b \\ % c & d & \frac12c+\frac14d \\ % \CodeAfter -% \SubMatrix({1-3}{2-3}) -% \SubMatrix({3-1}{4-2}) -% \SubMatrix({3-3}{4-3}) +% \SubMatrix({1-3}{2-3}) +% \SubMatrix({3-1}{4-2}) +% \SubMatrix({3-3}{4-3}) % \end{NiceArray}$ % \end{BVerbatim} % \end{scope} @@ -2431,9 +2519,9 @@ version 2005/12/01 or later. % a & b & \frac12a+\frac14b \\ % c & d & \frac12c+\frac14d \\ % \CodeAfter -% \SubMatrix({1-3}{2-3}) -% \SubMatrix({3-1}{4-2}) -% \SubMatrix({3-3}{4-3}) +% \SubMatrix({1-3}{2-3}) +% \SubMatrix({3-1}{4-2}) +% \SubMatrix({3-3}{4-3}) % \end{NiceArray}$ % % \medskip @@ -2450,9 +2538,9 @@ version 2005/12/01 or later. % a & b & \frac12a+\frac14b \\ % c & d & \frac12c+\frac14d \\ % \CodeAfter -% \SubMatrix({1-3}{2-3})[~emphase#slim!] -% \SubMatrix({3-1}{4-2}) -% \SubMatrix({3-3}{4-3}) +% \SubMatrix({1-3}{2-3})[~emphase#slim!] +% \SubMatrix({3-1}{4-2}) +% \SubMatrix({3-3}{4-3}) % \end{NiceArray}$ % \end{BVerbatim} % \end{scope} @@ -2462,15 +2550,15 @@ version 2005/12/01 or later. % a & b & \frac12a+\frac14b \\ % c & d & \frac12c+\frac14d \\ % \CodeAfter -% \SubMatrix({1-3}{2-3})[slim] -% \SubMatrix({3-1}{4-2}) -% \SubMatrix({3-3}{4-3}) +% \SubMatrix({1-3}{2-3})[slim] +% \SubMatrix({3-1}{4-2}) +% \SubMatrix({3-3}{4-3}) % \end{NiceArray}$ % % % \bigskip % There is also a key |name| which gives a name to the submatrix created by -% |\SubMatrix|. That name is used to created PGF/Tikz nodes: cf +% |\SubMatrix|. That name is used to create PGF/Tikz nodes: cf % p.~\pageref{node-sub-matrix}. % % \section{The notes in the tabulars} @@ -3196,7 +3284,7 @@ version 2005/12/01 or later. % 4 & 5 & 6 \\ % 7 & 8 & 9 % \CodeAfter -% \tikz \draw ~emphase#(2-2)@ circle (2mm) ; +% \tikz \draw ~emphase#(2-2)@ circle (2mm) ; % \end{pNiceMatrix}$ % \end{BVerbatim} % $\begin{pNiceMatrix} @@ -3204,7 +3292,7 @@ version 2005/12/01 or later. % 4 & 5 & 6 \\ % 7 & 8 & 9 % \CodeAfter -% \tikz \draw (2-2) circle (2mm) ; +% \tikz \draw (2-2) circle (2mm) ; % \end{pNiceMatrix}$ % % @@ -3444,7 +3532,7 @@ version 2005/12/01 or later. % \subsection{The nodes which indicate the position of the rules} % % \label{nodes-i} -% \colorbox{yellow!50}{\textbf{New 5.11}}\enskip The package \pkg{nicematrix} +% \colorbox{yellow!30}{New 5.11}\enskip The package \pkg{nicematrix} % creates a PGF/Tikz node merely called $i$ (with the classical prefix) at the % intersection of the horizontal rule of number~$i$ and the vertical rule of % number~$j$ (more specifically the potential position of those rules because @@ -3456,32 +3544,30 @@ version 2005/12/01 or later. % arum & iris & violette \\ % muguet & dahlia & souci % \CodeAfter -% \tiny -% \begin{tikzpicture} -% \foreach \i in {1,2,3,4} -% { -% \fill [red] (\i) circle (0.5mm) ; -% \node [red,above right] at (\i) {\i} ; -% } -% \end{tikzpicture} +% \tiny +% \begin{tikzpicture} +% \foreach \i in {1,2,3,4} +% { +% \fill [red] (\i) circle (0.5mm) ; +% \node [red,above right] at (\i) {\i} ; +% } +% \end{tikzpicture} % \end{NiceTabular} % \end{center} % % \bigskip % If we use Tikz (we remind that \pkg{nicematrix} does not load Tikz by default, % by only \textsc{pgf}, which is a sub-layer of Tikz), we can access, in the -% |\CodeAfter| but also in the |code-before|) to the intersection of the horizontal -% rule~$i$ and the vertical rule~$j$ with the syntax |(|$i$\verb+-|+$j$|)|. +% |\CodeAfter| but also in the |code-before|, to the intersection of the +% (potential) horizontal rule~$i$ and the (potential) vertical rule~$j$ with the +% syntax |(|$i$\verb+-|+$j$|)|. % % \medskip % \begin{Verbatim} -% \[\begin{NiceMatrix}[ -% code-before = -% { -% ~emphase# \tikz \draw [fill = red!15] @ -% ~emphase# (7-|4) -- (8-|4) -- (8-|5) -- (9-|5) -- (9-|6) |- cycle ; @ -% } -% ] +% \begin{NiceMatrix} +% \CodeBefore +% ~emphase#\tikz \draw [fill=red!15] (7-|4) |- (8-|5) |- (9-|6) |- cycle ;@ +% \Body % 1 \\ % 1 & 1 \\ % 1 & 2 & 1 \\ @@ -3491,15 +3577,13 @@ version 2005/12/01 or later. % 1 & 6 & 15 & 20 & 15 & 6 & 1 \\ % 1 & 7 & 21 & 35 & 35 & 21 & 7 & 1 \\ % 1 & 8 & 28 & 56 & 70 & 56 & 28 & 8 & 1 -% \end{NiceMatrix}\] +% \end{NiceMatrix} % \end{Verbatim} -% \[\begin{NiceMatrix}[ -% code-before = -% { -% \tikz \draw [fill = red!15] -% (7-|4) -- (8-|4) -- (8-|5) -- (9-|5) -- (9-|6) |- cycle ; -% } -% ] +% % +% \[\begin{NiceMatrix} +% \CodeBefore +% \tikz \draw [fill=red!15] (7-|4) |- (8-|5) |- (9-|6) |- cycle ; +% \Body % 1 \\ % 1 & 1 \\ % 1 & 2 & 1 \\ @@ -3515,7 +3599,7 @@ version 2005/12/01 or later. % % \label{node-sub-matrix} % -% \colorbox{yellow!50}{\textbf{New 5.10}}\enskip +% \colorbox{yellow!30}{New 5.10}\enskip % The command |\SubMatrix| available in the |\CodeAfter| has been described % p.~\pageref{sub-matrix}. % @@ -3540,14 +3624,14 @@ version 2005/12/01 or later. % 3462 & 38458 & 34 & 294 \\ % 34 & 7 & 78 & 309 \\ % \CodeAfter -% \SubMatrix\{{2-2}{3-3}\}[name=A] -% \begin{tikzpicture} -% [every node/.style = {blend mode = multiply, -% inner sep = 0 pt}] -% \node [fit = (A),fill = red!15] {} ; -% \node [fit = (A-left),fill = blue!15] {} ; -% \node [fit = (A-right),fill = blue!15] {} ; -% \end{tikzpicture} +% \SubMatrix\{{2-2}{3-3}\}[name=A] +% \begin{tikzpicture} +% [every node/.style = {blend mode = multiply, +% inner sep = 0 pt}] +% \node [fit = (A),fill = red!15] {} ; +% \node [fit = (A-left),fill = blue!15] {} ; +% \node [fit = (A-right),fill = blue!15] {} ; +% \end{tikzpicture} % \end{pNiceMatrix}\] % % \section{API for the developpers} @@ -3588,10 +3672,8 @@ version 2005/12/01 or later. %\ExplSyntaxOn % \cs_new_protected:Nn \__pantigny_hatch:nnn % { -% \begin { tikzpicture } -% \fill [ pattern = north~west~lines , pattern~color = #3 ] -% ( #1 -| #2) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ; -% \end { tikzpicture } +% \tikz \fill [ pattern = north~west~lines , pattern~color = #3 ] +% ( #1 -| #2) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ; % } % % \NewDocumentCommand \hatchcell { ! O { black } } @@ -3607,10 +3689,8 @@ version 2005/12/01 or later. % \ExplSyntaxOn % \cs_new_protected:Nn \__pantigny_hatch:nnn % { -% \begin { tikzpicture } -% \fill [ pattern = north~west~lines , pattern~color = #3 ] -% ( #1 -| #2 ) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ; -% \end { tikzpicture } +% \tikz \fill [ pattern = north~west~lines , pattern~color = #3 ] +% ( #1 -| #2 ) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ; % } % % \NewDocumentCommand \hatchcell { ! O { black } } @@ -4085,97 +4165,223 @@ version 2005/12/01 or later. % \end{pNiceMatrix}\] % \end{scope} % -% \subsection{Width of the columns} -% +% +% \subsection{Stacks of matrices} +% +% We often need to compose mathematical matrices on top on each other (for +% example for the resolution of linear systems). % % \medskip -% In the following example, we use |{NiceMatrixBlock}| with the option -% |auto-columns-width| because we want the same automatic width for all the -% columns of the matrices. +% In order to have the columns aligned one above the other, it's possible to +% fix a width for all the columns. That's what is done in the following example +% with the environment |{NiceMatrixBlock}| and its option |auto-columns-width|. % -% \bigskip -% \begin{BVerbatim} +% \begin{Verbatim}[formatcom=\small\color{gray}] % ~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@ % \NiceMatrixOptions -% { last-col,code-for-last-col = \color{blue}\scriptstyle,light-syntax} +% { +% light-syntax, +% last-col, code-for-last-col = \color{blue} \scriptstyle, +% } % \setlength{\extrarowheight}{1mm} -% $\begin{pNiceArray}{cccc:c} -% 1 1 1 1 1 {} ; -% 2 4 8 16 9 ; -% 3 9 27 81 36 ; -% 4 16 64 256 100 +% +% $\begin{pNiceArray}{rrrr|r} +% 12 -8 7 5 3 {} ; +% 3 -18 12 1 4 ; +% -3 -46 29 -2 -15 ; +% 9 10 -5 4 7 % \end{pNiceArray}$ -% \medskip -% $\begin{pNiceArray}{cccc:c} -% 1 1 1 1 1 ; -% 0 2 6 14 7 { L_2 \gets -2 L_1 + L_2 } ; -% 0 6 24 78 33 { L_3 \gets -3 L_1 + L_3 } ; -% 0 12 60 252 96 { L_4 \gets -4 L_1 + L_4 } +% +% \smallskip +% $\begin{pNiceArray}{rrrr|r} +% 12 -8 7 5 3 ; +% 0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ; +% 0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ; +% 0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ; % \end{pNiceArray}$ -% ... +% +% \smallskip +% $\begin{pNiceArray}{rrrr|r} +% 12 -8 7 5 3 ; +% 0 64 -41 1 19 ; +% 0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 } +% \end{pNiceArray}$ +% +% \smallskip +% $\begin{pNiceArray}{rrrr|r} +% 12 -8 7 5 3 {} ; +% 0 64 -41 1 19 ; +% \end{pNiceArray}$ +% % ~emphase#\end{NiceMatrixBlock}@ -% \end{BVerbatim} +% \end{Verbatim} % % \bigskip -% -% \begin{multicols}{2} % \begin{NiceMatrixBlock}[auto-columns-width] -% \NiceMatrixOptions{last-col,code-for-last-col = \color{blue}\scriptstyle,light-syntax} +% \NiceMatrixOptions +% { +% light-syntax, +% last-col, code-for-last-col = \color{blue} \scriptstyle , +% } % \setlength{\extrarowheight}{1mm} % -% \enskip $\begin{pNiceArray}{cccc:c} -% 1 1 1 1 1 {} ; -% 2 4 8 16 9 ; -% 3 9 27 81 36 ; -% 4 16 64 256 100 +% \quad $\begin{pNiceArray}{rrrr|r} +% 12 -8 7 5 3 {} ; +% 3 -18 12 1 4 ; +% -3 -46 29 -2 -15 ; +% 9 10 -5 4 7 % \end{pNiceArray}$ % -% \medskip -% -% \enskip $\begin{pNiceArray}{cccc:c} -% 1 1 1 1 1 ; -% 0 2 6 14 7 { L_2 \gets -2 L_1 + L_2 } ; -% 0 6 24 78 33 { L_3 \gets -3 L_1 + L_3 } ; -% 0 12 60 252 96 { L_4 \gets -4 L_1 + L_4 } +% \smallskip +% \quad $\begin{pNiceArray}{rrrr|r} +% 12 -8 7 5 3 ; +% 0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ; +% 0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ; +% 0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ; % \end{pNiceArray}$ % -% \medskip +% \smallskip +% \quad $\begin{pNiceArray}{rrrr|r} +% 12 -8 7 5 3 ; +% 0 64 -41 1 19 ; +% 0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 } +% \end{pNiceArray}$ % -% \enskip $\begin{pNiceArray}{cccc:c} -% 1 1 1 1 1 ; -% 0 1 3 7 \frac72 { L_2 \gets \frac12 L_2 } ; -% 0 3 12 39 \frac{33}2 { L_3 \gets \frac12 L_3 } ; -% 0 1 5 21 8 { L_4 \gets \frac1{12} L_4 } +% \smallskip +% \quad $\begin{pNiceArray}{rrrr|r} +% 12 -8 7 5 3 {} ; +% 0 64 -41 1 19 ; % \end{pNiceArray}$ +% \end{NiceMatrixBlock} +% +% \bigskip +% However, one can see that the last matrix is not perfectly aligned with the +% other. That's why, in LaTeX, the parenthesis have not exactly the same width +% (smaller parenthesis are a bit slimer). % % \medskip +% \colorbox{yellow!50}{\textbf{New 5.12}}\enskip In order the solve that +% problem, it's possible to require the delimiters to be composed with the +% maximal width, thanks to the boolean key |delimiters/max-width|. % -% \enskip $\begin{pNiceArray}{cccc:c} -% 1 1 1 1 1 ; -% 0 1 3 7 \frac72 ; -% 0 0 3 18 6 { L_3 \gets -3 L_2 + L_3 } ; -% 0 0 -2 -14 -\frac92 { L_4 \gets L_2 - L_4 } +% \begin{Verbatim}[formatcom=\small\color{gray}] +% ~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@ +% \NiceMatrixOptions +% { +% ~emphase#delimiters/max-width@, +% light-syntax, +% last-col, code-for-last-col = \color{blue}\scriptstyle, +% } +% \setlength{\extrarowheight}{1mm} +% +% $\begin{pNiceArray}{rrrr|r} +% 12 -8 7 5 3 {} ; +% 3 -18 12 1 4 ; +% -3 -46 29 -2 -15 ; +% 9 10 -5 4 7 % \end{pNiceArray}$ % -% \medskip +% ... +% ~emphase#\end{NiceMatrixBlock}@ +% \end{Verbatim} % -% \enskip $\begin{pNiceArray}{cccc:c} -% 1 1 1 1 1 ; -% 0 1 3 7 \frac72 ; -% 0 0 1 6 2 { L_3 \gets \frac13 L_3 } ; -% 0 0 -2 -14 -\frac92 +% \bigskip +% \begin{NiceMatrixBlock}[auto-columns-width] +% \NiceMatrixOptions +% { +% delimiters/max-width, +% light-syntax, +% last-col, code-for-last-col = \color{blue}\scriptstyle, +% } +% \setlength{\extrarowheight}{1mm} +% +% \quad $\begin{pNiceArray}{rrrr|r} +% 12 -8 7 5 3 {} ; +% 3 -18 12 1 4 ; +% -3 -46 29 -2 -15 ; +% 9 10 -5 4 7 % \end{pNiceArray}$ % -% \medskip +% \smallskip +% \quad $\begin{pNiceArray}{rrrr|r} +% 12 -8 7 5 3 ; +% 0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ; +% 0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ; +% 0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ; +% \end{pNiceArray}$ % -% \enskip $\begin{pNiceArray}{cccc:c} -% 1 1 1 1 1 ; -% 0 1 3 7 \frac72 ; -% 0 0 1 6 2 ; -% 0 0 0 -2 -\frac12 { L_4 \gets L_3 + L_4 } +% \smallskip +% \quad $\begin{pNiceArray}{rrrr|r} +% 12 -8 7 5 3 ; +% 0 64 -41 1 19 ; +% 0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 } +% \end{pNiceArray}$ +% +% \smallskip +% \quad $\begin{pNiceArray}{rrrr|r} +% 12 -8 7 5 3 {} ; +% 0 64 -41 1 19 ; % \end{pNiceArray}$ +% % \end{NiceMatrixBlock} -% \end{multicols} +% +% +% \interitem +% If you wish an alignment of the different matrices without the same width +% for all the columns, you can construct a unique array and place the +% parenthesis with commands |\SubMatrix| in the |\CodeAfter|. Of course, that +% array can't be broken by a page break. +% +% \medskip +% \begin{Verbatim} +% \setlength{\extrarowheight}{1mm} +% \[\begin{NiceMatrix}[ r, last-col=6, code-for-last-col = \scriptstyle \color{blue} ] +% 12 & -8 & 7 & 5 & 3 \\ +% 3 & -18 & 12 & 1 & 4 \\ +% -3 & -46 & 29 &-2 &-15 \\ +% 9 & 10 &-5 &4 & 7 \\[1mm] +% 12 & -8 & 7 &5 & 3 \\ +% 0 & 64 &-41 & 1 & 19 & L_2 \gets L_1-4L_2 \\ +% 0 & -192 &123 &-3 &-57 & L_3 \gets L_1+4L_3 \\ +% 0 & -64 & 41 &-1 &-19 & L_4 \gets 3L_1-4L_4 \\[1mm] +% 12 & -8 &7 &5 & 3 \\ +% 0 & 64 &-41 &1 &19 \\ +% 0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm] +% 12 & -8 &7 &5 & 3 \\ +% 0 & 64 &-41 & 1 & 19 \\ +% ~emphase#\CodeAfter@ +% ~emphase# \SubMatrix({1-1}{4-5})[vlines=4]@ +% ~emphase# \SubMatrix({5-1}{8-5})[vlines=4]@ +% ~emphase# \SubMatrix({9-1}{11-5})[vlines=4]@ +% ~emphase# \SubMatrix({12-1}{13-5})[vlines=4]@ +% \end{NiceMatrix}\] +% \end{Verbatim} +% +% \medskip +% \begin{scope} +% \setlength{\extrarowheight}{1mm} +% \[\begin{NiceMatrix}[ r, last-col=6, code-for-last-col = \scriptstyle \color{blue} ] +% 12 & -8 & 7 & 5 & 3 \\ +% 3 & -18 & 12 & 1 & 4 \\ +% -3 & -46 & 29 &-2 &-15 \\ +% 9 & 10 &-5 &4 & 7 \\[1mm] +% 12 & -8 & 7 &5 & 3 \\ +% 0 & 64 &-41 & 1 & 19 & L_2 \gets L_1-4L_2 \\ +% 0 & -192 &123 &-3 &-57 & L_3 \gets L_1+4L_3 \\ +% 0 & -64 & 41 &-1 &-19 & L_4 \gets 3L_1-4L_4 \\[1mm] +% 12 & -8 &7 &5 & 3 \\ +% 0 & 64 &-41 &1 &19 \\ +% 0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm] +% 12 & -8 &7 &5 & 3 \\ +% 0 & 64 &-41 & 1 & 19 \\ +% \CodeAfter +% \SubMatrix({1-1}{4-5})[vlines=4] +% \SubMatrix({5-1}{8-5})[vlines=4] +% \SubMatrix({9-1}{11-5})[vlines=4] +% \SubMatrix({12-1}{13-5})[vlines=4] +% \end{NiceMatrix}\] +% \end{scope} +% % % % \subsection{How to highlight cells of a matrix} @@ -4320,7 +4526,7 @@ version 2005/12/01 or later. % & & & 0 \\ % 0 & \Cdots& 0 & 0 % \CodeAfter -% \tikz \node [highlight = (1-1-block-medium)] {} ; +% \tikz \node [highlight = (1-1-block-medium)] {} ; % \end{pNiceMatrix}$ % % @@ -4424,117 +4630,42 @@ version 2005/12/01 or later. % \end{pNiceArray}\] % % -% \subsection{Direct use of the Tikz nodes} +% \subsection{Utilisation of \textbackslash SubMatrix in the code-before} % % In the following example, we illustrate the mathematical product of two % matrices. % -% \medskip -% The use of |{NiceMatrixBlock}| with the option |auto-columns-width| -% gives the same width for all the columns and, therefore, a perfect alignment -% of the two superposed matrices. -% \begin{Verbatim} -% \begin{NiceMatrixBlock}[auto-columns-width] -% \end{Verbatim} -% -% \begin{Verbatim} -% \NiceMatrixOptions{nullify-dots} -% \end{Verbatim} -% -% The three matrices will be displayed using an environment |{array}| (an -% environment |{tabular}| may also be possible). -% \begin{Verbatim} -% $\begin{array}{cc} -% & -% \end{Verbatim} -% -% The matrix $B$ has a ``first row'' (for $C_j$) and that's why we use the key -% |first-row|. -% \begin{Verbatim} -% \begin{bNiceArray}{c>{\strut}cccc}[name=B,first-row] -% & & C_j \\ -% b_{11} & \Cdots & b_{1j} & \Cdots & b_{1n} \\ -% \Vdots & & \Vdots & & \Vdots \\ -% & & b_{kj} \\ -% & & \Vdots \\ -% b_{n1} & \Cdots & b_{nj} & \Cdots & b_{nn} -% \end{bNiceArray} \\ \\ -% \end{Verbatim} -% -% The matrix $A$ has a ``first column'' (for $L_i$) and that's why we use the -% key |first-col|. -% \begin{Verbatim} -% \begin{bNiceArray}{cc>{\strut}ccc}[name=A,first-col] +% The whole figure is an environment |{NiceArray}| and the three pairs of +% parenthesis have been added with |\SubMatrix| in the |code-before|. +% +% You will find the LaTeX code of that figure in the source file of this +% document. +% +% \[\begin{NiceArray}{*{6}{c}@{\hspace{6mm}}*{5}{c}}[nullify-dots] +% \CodeBefore +% \SubMatrix({2-7}{6-11}) +% \SubMatrix({7-2}{11-6}) +% \SubMatrix({7-7}{11-11}) +% \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 \\ -% L_i & a_{i1} & \Cdots & a_{ik} & \Cdots & a_{in} \\ -% & \Vdots & & & & \Vdots \\ -% & a_{n1} & \Cdots & & & a_{nn} -% \end{bNiceArray} -% & -% \end{Verbatim} -% -% In the matrix product, the two dotted lines have an open extremity. -% \begin{Verbatim} -% \begin{bNiceArray}{cc>{\strut}ccc} -% & & & & \\ -% & & \Vdots \\ -% \Cdots & & c_{ij} \\ -% \\ -% \\ -% \end{bNiceArray} -% \end{array}$ -% -% \end{NiceMatrixBlock} -% \end{Verbatim} -% -% \begin{Verbatim} -% \begin{tikzpicture}[remember picture, overlay] -% \node [highlight = (A-3-1) (A-3-5) ] {} ; -% \node [highlight = (B-1-3) (B-5-3) ] {} ; -% \draw [color = gray] (A-3-3) to [bend left] (B-3-3) ; -% \end{tikzpicture} -% \end{Verbatim} -% -% -% \begin{NiceMatrixBlock}[auto-columns-width] -% \NiceMatrixOptions{nullify-dots} -% $\begin{array}{cc} -% & -% \begin{bNiceArray}{c>{\strut}cccc}[name=B,first-row] -% & & C_j \\ -% b_{11} & \Cdots & b_{1j} & \Cdots & b_{1n} \\ -% \Vdots & & \Vdots & & \Vdots \\ -% & & b_{kj} \\ -% & & \Vdots \\ -% b_{n1} & \Cdots & b_{nj} & \Cdots & b_{nn} -% \end{bNiceArray} \\ \\ -% \begin{bNiceArray}{cc>{\strut}ccc}[name=A,first-col] -% & a_{11} & \Cdots & & & a_{1n} \\ -% & \Vdots & & & & \Vdots \\ -% L_i & a_{i1} & \Cdots & a_{ik} & \Cdots & a_{in} \\ -% & \Vdots & & & & \Vdots \\ -% & a_{n1} & \Cdots & & & a_{nn} \\ -% \end{bNiceArray} -% & -% \begin{bNiceArray}{cc>{\strut}ccc} -% & & & & \\ -% & & \Vdots \\ -% \Cdots & & c_{ij} \\ -% \\ -% \\ -% \end{bNiceArray} -% \end{array}$ -% -% \end{NiceMatrixBlock} -% -% \begin{tikzpicture}[remember picture, overlay] -% \node [highlight = (A-3-1) (A-3-5) ] {} ; -% \node [highlight = (B-1-3) (B-5-3) ] {} ; -% \draw [color = gray] (A-3-3) to [bend left] (B-3-3) ; -% \end{tikzpicture} -% -% +% & a_{n1} & \Cdots & & & a_{nn} \\ +% \CodeAfter +% \begin{tikzpicture} +% \node [highlight = (9-2) (9-6)] { } ; +% \node [highlight = (2-9) (6-9)] { } ; +% \draw [gray,shorten > = 1mm, shorten < = 1mm] (9-4.north) to [bend left] (4-9.west) ; +% \end{tikzpicture} +% \end{NiceArray}\] % %\section{Implementation} % @@ -4897,7 +5028,11 @@ version 2005/12/01 or later. % \end{macrocode} % % -% +% \bigskip +% \begin{macrocode} +\cs_set_eq:NN \@@_old_pgfpointanchor \pgfpointanchor +% \end{macrocode} +% % \bigskip % \textbf{The column S of siunitx}\par\nobreak % @@ -5271,6 +5406,13 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip +% For the key |code| of the command |\SubMatrix| (itself in the main +% |\CodeAfter|), we will use the following token list. +% \begin{macrocode} +\tl_new:N \l_@@_code_tl +% \end{macrocode} +% +% \bigskip % The following token list has a function similar to % |\g_nicematrix_code_after_tl| but it is used internally by \pkg{nicematrix}. % In fact, we have to distinguish between |\g_nicematrix_code_after_tl| and @@ -5335,8 +5477,9 @@ version 2005/12/01 or later. % |\g_@@_code_before_|\textsl{i}|_tl| (where \textsl{i} is the number of the % environment) and, at the beginning of the environment, it will be put in % |\l_@@_code_before_tl|. -% \item The final user can explicitely add material in |\l_@@_code_before_tl| by -% using the key |code-before|. +% \item The final user can explicitly add material in |\l_@@_code_before_tl| by +% using the key |code-before| or the keyword |\CodeBefore| (with the keyword +% |\Body|). % \end{itemize} % \begin{macrocode} \tl_new:N \l_@@_code_before_tl @@ -5432,8 +5575,29 @@ version 2005/12/01 or later. \seq_new:N \g_@@_submatrix_names_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|). +% \begin{macrocode} +\int_new:N \l_@@_row_min_int +\int_new:N \l_@@_row_max_int +\int_new:N \l_@@_col_min_int +\int_new:N \l_@@_col_max_int +% \end{macrocode} % % \medskip +% The following sequence will be used when the command |\SubMatrix| is used in +% the |code-before| (and not in the |\CodeAfter|). It will contain the position of +% all the sub-matrices specified in the |code-before|. Each sub-matrix is +% represented by an ``object'' of the forme |{|$i$|}{|$j$|}{|$k$|}{|$l$|}| +% where $i$ and $j$ are the number of row and column of the upper-left cell and +% $k$ and $l$ the number of row and column of the lower-right cell. +% \begin{macrocode} +\seq_new:N \g_@@_submatrix_seq +% \end{macrocode} +% +% \medskip % We are able to determine the number of columns specified in the preamble (for % the environments with explicit preamble, of course and without the potential % exterior columns). @@ -5442,11 +5606,12 @@ version 2005/12/01 or later. % \end{macrocode} % % \medskip -% The following token lists correspond to the keys |fill| and |draw| of -% a command |\Block|. +% The following parameters correspond to the keys |fill|, |draw| and +% |rounded-corners| of the command |\Block|. % \begin{macrocode} \tl_new:N \l_@@_fill_tl \tl_new:N \l_@@_draw_tl +\dim_new:N \l_@@_rounded_corners_dim % \end{macrocode} % % \medskip @@ -5492,8 +5657,8 @@ version 2005/12/01 or later. \dim_new:N \l_@@_submatrix_extra_height_dim \dim_new:N \l_@@_submatrix_left_xshift_dim \dim_new:N \l_@@_submatrix_right_xshift_dim -\clist_new:N \l_@@_submatrix_hlines_clist -\clist_new:N \l_@@_submatrix_vlines_clist +\clist_new:N \l_@@_hlines_clist +\clist_new:N \l_@@_vlines_clist % \end{macrocode} % % @@ -5586,7 +5751,7 @@ version 2005/12/01 or later. % \begin{macrocode} \bool_new:N \g_@@_last_col_found_bool % \end{macrocode} -% This boolean is set to |false| at the end of |\@@_pre_array:|. +% This boolean is set to |false| at the end of |\@@_pre_array_ii:|. % \end{itemize} % % \bigskip @@ -5957,21 +6122,6 @@ version 2005/12/01 or later. \bool_set_true:N \l_@@_parallelize_diags_bool % \end{macrocode} % -% \bigskip -% If the flag |\l_@@_vlines_bool| is raised, horizontal space will be reserved -% in the the preamble of the array (for the vertical rules) and, after the -% construction of the array, the vertical rules will be drawn. -% \begin{macrocode} -\bool_new:N \l_@@_vlines_bool -% \end{macrocode} -% -% \bigskip -% If the flag |\l_@@_hlines_bool| is raised, vertical space will be reserved -% between the rows of the array (for the horizontal rules) and, after the -% construction of the array, the vertical rules will be drawn. -% \begin{macrocode} -\bool_new:N \l_@@_hlines_bool -% \end{macrocode} % % \bigskip % The flag |\l_@@_except_corners_bool| will be raised when the key @@ -6076,11 +6226,11 @@ version 2005/12/01 or later. % |{NiceMatrixBlock}|). However, even if we use the same type of delimiters, the % width of the delimiters may be different from an array to another because the % width of the delimiter is fonction of its size. That's why we create an option -% called |max-delimiter-width| which will give to the delimiters the width of +% called |delimiters/max-width| which will give to the delimiters the width of % a delimiter (of the same type) of big size. The following boolean corresponds % to this option. % \begin{macrocode} -\bool_new:N \l_@@_max_delimiter_width_bool +\bool_new:N \l_@@_delimiters_max_width_bool % \end{macrocode} % % \bigskip @@ -6153,9 +6303,8 @@ version 2005/12/01 or later. cell-space-top-limit = #1 , cell-space-bottom-limit = #1 , } , - cell-spaces-limits .value_required:n = true , + cell-space-limits .value_required:n = true , xdots .code:n = \keys_set:nn { NiceMatrix / xdots } { #1 } , - max-delimiter-width .bool_set:N = \l_@@_max_delimiter_width_bool , light-syntax .bool_set:N = \l_@@_light_syntax_bool , light-syntax .default:n = true , end-of-row .tl_set:N = \l_@@_end_of_row_tl , @@ -6172,8 +6321,10 @@ version 2005/12/01 or later. code-for-first-row .value_required:n = true , code-for-last-row .tl_set:N = \l_@@_code_for_last_row_tl , code-for-last-row .value_required:n = true , - hlines .bool_set:N = \l_@@_hlines_bool , - vlines .bool_set:N = \l_@@_vlines_bool , + hlines .clist_set:N = \l_@@_hlines_clist , + vlines .clist_set:N = \l_@@_vlines_clist , + hlines .default:n = all , + vlines .default:n = all , vlines-in-sub-matrix .code:n = { \tl_if_single_token:nTF { #1 } @@ -6183,8 +6334,8 @@ version 2005/12/01 or later. vlines-in-sub-matrix .value_required:n = true , hvlines .code:n = { - \bool_set_true:N \l_@@_vlines_bool - \bool_set_true:N \l_@@_hlines_bool + \clist_set:Nn \l_@@_vlines_clist { all } + \clist_set:Nn \l_@@_hlines_clist { all } } , parallelize-diags .bool_set:N = \l_@@_parallelize_diags_bool , % \end{macrocode} @@ -6221,13 +6372,14 @@ version 2005/12/01 or later. % \begin{macrocode} \keys_define:nn { NiceMatrix / Env } { + delimiters/max-width .bool_set:N = \l_@@_delimiters_max_width_bool , except-corners .clist_set:N = \l_@@_except_corners_clist , except-corners .default:n = { NW , SW , NE , SE } , hvlines-except-corners .code:n = { \clist_set:Nn \l_@@_except_corners_clist { #1 } - \bool_set_true:N \l_@@_vlines_bool - \bool_set_true:N \l_@@_hlines_bool + \clist_set:Nn \l_@@_vlines_clist { all } + \clist_set:Nn \l_@@_hlines_clist { all } } , hvlines-except-corners .default:n = { NW , SW , NE , SE } , code-before .code:n = @@ -6385,6 +6537,7 @@ version 2005/12/01 or later. % \begin{macrocode} \keys_define:nn { NiceMatrix / NiceMatrixOptions } { + delimiters / max-width .bool_set:N = \l_@@_delimiters_max_width_bool , delimiters / color .tl_set:N = \l_@@_delimiters_color_tl , delimiters / color .value_required:n = true , delimiters-color .tl_set:N = \l_@@_delimiters_color_tl , @@ -6539,6 +6692,8 @@ version 2005/12/01 or later. delimiters-color .value_required:n = true , delimiters / color .tl_set:N = \l_@@_delimiters_color_tl , delimiters / color .value_required:n = true , + r .code:n = \@@_error:n { r~or~l~with~preamble } , + l .code:n = \@@_error:n { r~or~l~with~preamble } , unknown .code:n = \@@_error:n { Unknown~option~for~NiceArray } } % \end{macrocode} @@ -6555,6 +6710,8 @@ version 2005/12/01 or later. first-row .code:n = \int_zero:N \l_@@_first_row_int , small .bool_set:N = \l_@@_small_bool , small .value_forbidden:n = true , + r .code:n = \@@_error:n { r~or~l~with~preamble } , + l .code:n = \@@_error:n { r~or~l~with~preamble } , unknown .code:n = \@@_error:n { Unknown~option~for~NiceMatrix } } % \end{macrocode} @@ -6575,6 +6732,8 @@ version 2005/12/01 or later. last-col .code:n = \tl_if_empty:nF {#1} { \@@_error:n { last-col~non~empty~for~NiceArray } } \int_zero:N \l_@@_last_col_int , + r .code:n = \@@_error:n { r~or~l~with~preamble } , + l .code:n = \@@_error:n { r~or~l~with~preamble } , unknown .code:n = \@@_error:n { Unknown~option~for~NiceTabular } } % \end{macrocode} @@ -6999,24 +7158,33 @@ version 2005/12/01 or later. % We don't draw the rules of the key |hlines| (or |hvlines|) but we reserve the % vertical space for theses rules. % \begin{macrocode} - \bool_if:NT \l_@@_hlines_bool + \tl_if_empty:NF \l_@@_hlines_clist { + \tl_if_eq:NnF \l_@@_hlines_clist { all } + { + \exp_args:NNx + \clist_if_in:NnT + \l_@@_hlines_clist + { \@@_succ:n \c@iRow } + } + { % \end{macrocode} % The counter |\c@iRow| has the value $-1$ only if there is a ``first % row'' and that we are before that ``first row'', i.e. just before the % beginning of the array. % \begin{macrocode} - \int_compare:nNnT \c@iRow > { -1 } - { - \int_compare:nNnF \c@iRow = \l_@@_last_row_int + \int_compare:nNnT \c@iRow > { -1 } + { + \int_compare:nNnF \c@iRow = \l_@@_last_row_int % \end{macrocode} % The command |\CT@arc@| is a command of \pkg{colortbl} which sets the color of % the rules in the array. The package \pkg{nicematrix} uses it even if % \pkg{colortbl} is not loaded. We use a TeX group in order to limit the scope % of |\CT@arc@|. % \begin{macrocode} - { \hrule height \arrayrulewidth width \c_zero_dim } - } + { \hrule height \arrayrulewidth width \c_zero_dim } + } + } } } } @@ -7064,12 +7232,12 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% The following code |\@@_pre_array:| is used in |{NiceArrayWithDelims}|. It +% The following code |\@@_pre_array_ii:| is used in |{NiceArrayWithDelims}|. It % exists as a standalone macro only for legibility. % \label{prearray} % % \begin{macrocode} -\cs_new_protected:Npn \@@_pre_array: +\cs_new_protected:Npn \@@_pre_array_ii: { % \end{macrocode} % If \pkg{booktabs} is loaded, we have to patch the macro |\@BTnormal| which is @@ -7260,124 +7428,8 @@ version 2005/12/01 or later. \tl_gclear_new:N \g_nicematrix_code_before_tl } % \end{macrocode} -% This is the end of |\@@_pre_array:|. -% -% -% \bigskip -% \subsection*{The environment \{NiceArrayWithDelims\}} -% -% \begin{macrocode} -\NewDocumentEnvironment { NiceArrayWithDelims } { m m O { } m ! O { } } - { - \@@_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. -% \begin{macrocode} - \bgroup -% \end{macrocode} -% -% \bigskip -% \begin{macrocode} - \tl_set:Nn \l_@@_left_delim_tl { #1 } - \tl_set:Nn \l_@@_right_delim_tl { #2 } - \tl_gset:Nn \g_@@_preamble_tl { #4 } -% \end{macrocode} -% -% -% \bigskip -% -% \begin{macrocode} - \int_gzero:N \g_@@_block_box_int - \dim_zero:N \g_@@_width_last_col_dim - \dim_zero:N \g_@@_width_first_col_dim - \bool_gset_false:N \g_@@_row_of_col_done_bool - \str_if_empty:NT \g_@@_name_env_str - { \str_gset:Nn \g_@@_name_env_str { NiceArrayWithDelims } } - \@@_adapt_S_column: - \bool_if:NTF \l_@@_NiceTabular_bool - \mode_leave_vertical: - \@@_test_if_math_mode: - \bool_if:NT \l_@@_in_env_bool { \@@_fatal:n { Yet~in~env } } - \bool_set_true:N \l_@@_in_env_bool -% \end{macrocode} -% The command |\CT@arc@| contains the instruction of color for the rules of the -% array\footnote{e.g. |\color[rgb]{0.5,0.5,0}|}. This command is used by |\CT@arc@| but -% we use it also for compatibility with \pkg{colortbl}. But we want also to be -% able to use color for the rules of the array when \pkg{colortbl} is \emph{not} -% loaded. That's why we do the following instruction which is in the patch of -% the beginning of arrays done by \pkg{colortbl}. Of course, we restore the -% value of |\CT@arc@| at the end of our environment. -% \begin{macrocode} - \cs_gset_eq:NN \@@_old_CT@arc@ \CT@arc@ -% \end{macrocode} -% -% We deactivate Tikz externalization because we will use \textsc{pgf} pictures -% with the options |overlay| and |remember picture| (or equivalent forms). We -% deactivate with |\tikzexternaldisable| and not with -% |\tikzset{external/export=false}| which is \emph{not} equivalent. -% \begin{macrocode} - \cs_if_exist:NT \tikz@library@external@loaded - { - \tikzexternaldisable - \cs_if_exist:NT \ifstandalone - { \tikzset { external / optimize = false } } - } -% \end{macrocode} -% -% We increment the counter |\g_@@_env_int| which counts the environments -% of the package. -% \begin{macrocode} - \int_gincr:N \g_@@_env_int - \bool_if:NF \l_@@_block_auto_columns_width_bool - { \dim_gzero_new:N \g_@@_max_cell_width_dim } -% \end{macrocode} -% -% -% The sequence |\g_@@_blocks_seq| will contain the carateristics of the blocks -% (specified by |\Block|) of the array. The sequence |\g_@@_pos_of_blocks_seq| -% will contain only the position of the blocks. Of course, this is redundant but -% it's for efficiency. -% \begin{macrocode} - \seq_gclear:N \g_@@_blocks_seq - \seq_gclear:N \g_@@_pos_of_blocks_seq -% \end{macrocode} -% In fact, the sequence |\g_@@_pos_of_blocks_seq| will also contain the -% positions of the cells with a |\diagbox|. +% This is the end of |\@@_pre_array_ii:|. % -% \begin{macrocode} - \seq_gclear:N \g_@@_pos_of_stroken_blocks_seq - \seq_gclear:N \g_@@_pos_of_xdots_seq -% \end{macrocode} -% -% \begin{macrocode} - \tl_if_exist:cT { g_@@_code_before_ \int_use:N \g_@@_env_int _ 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 } - } -% \end{macrocode} -% -% The set of keys is not exactly the same for |{NiceArray}| and for the variants -% of |{NiceArray}| (|{pNiceArray}|, |{bNiceArray}|, etc.) because, for -% |{NiceArray}|, we have the options |t|, |c|, |b| and |baseline|. -% \begin{macrocode} - \bool_if:NTF \l_@@_NiceArray_bool - { \keys_set:nn { NiceMatrix / NiceArray } } - { \keys_set:nn { NiceMatrix / pNiceArray } } - { #3 , #5 } -% \end{macrocode} -% -% \bigskip -% \begin{macrocode} - \tl_if_empty:NF \l_@@_rules_color_tl - { \exp_after:wN \@@_set_CT@arc@: \l_@@_rules_color_tl \q_stop } -% \end{macrocode} -% -% % \bigskip % If the key |code-before| is used, we have to create the |col| nodes and the % |row| nodes before the creation of the array. First, we have to test whether @@ -7385,6 +7437,9 @@ version 2005/12/01 or later. % this case, a command |\@@_size_|{\slshape\ttfamily nb_of_env}|:| has been % created. % \begin{macrocode} +\cs_new_protected:Npn \@@_pre_array: + { + \seq_gclear:N \g_@@_submatrix_seq \bool_if:NT \l_@@_code_before_bool { \seq_if_exist:cT { @@_size_ \int_use:N \g_@@_env_int _ seq } @@ -7448,7 +7503,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \medskip -% Now, yet another settings before the executation of the |code-before|. +% Now, yet other settings before the execution of the |code-before|. % \begin{macrocode} \group_begin: \bool_if:NT \c_@@_tikz_loaded_bool @@ -7461,17 +7516,30 @@ version 2005/12/01 or later. } \cs_set_eq:NN \cellcolor \@@_cellcolor \cs_set_eq:NN \rectanglecolor \@@_rectanglecolor + \cs_set_eq:NN \roundedrectanglecolor \@@_roundedrectanglecolor \cs_set_eq:NN \rowcolor \@@_rowcolor \cs_set_eq:NN \rowcolors \@@_rowcolors \cs_set_eq:NN \columncolor \@@_columncolor \cs_set_eq:NN \chessboardcolors \@@_chessboardcolors + \cs_set_eq:NN \SubMatrix \@@_SubMatrix_in_code_before % \end{macrocode} % We compose the |code-before| in math mode in order to nullify the spaces put % by the user between instructions in the |code-before|. % \begin{macrocode} \bool_if:NT \l_@@_NiceTabular_bool \c_math_toggle_token \seq_clear_new:N \l_@@_colors_seq - \l_@@_code_before_tl +% \end{macrocode} +% Here is the |\CodeBefore|. As of now, the keys that may be provided to the +% keyword |\CodeBefore| are the same as keys that may be provided to +% |\CodeAfter|, hence the |\@@_CodeAfter_keys:|. +% \begin{macrocode} + \exp_last_unbraced:NV \@@_CodeAfter_keys: \l_@@_code_before_tl +% \end{macrocode} +% Now, all the cells which are specified to be colored by instructions in the +% |\CodeBefore| will actually be colored. It's a two-stages mechanism because we +% want to draw all the cells with the same color at the same time to absolutely +% avoid thin white lines in some \textsc{pdf} viewers. +% \begin{macrocode} \@@_actually_color: \bool_if:NT \l_@@_NiceTabular_bool \c_math_toggle_token \group_end: @@ -7547,9 +7615,9 @@ version 2005/12/01 or later. % \end{macrocode} % % \interitem -% The code in |\@@_pre_array:| is used only by |{NiceArrayWithDelims}|. +% The code in |\@@_pre_array_ii:| is used only by |{NiceArrayWithDelims}|. % \begin{macrocode} - \@@_pre_array: + \@@_pre_array_ii: % \end{macrocode} % % \medskip @@ -7617,6 +7685,150 @@ version 2005/12/01 or later. } % \end{macrocode} % +% \bigskip +% The following command |\@@_pre_array_i:w| will be used when the keyword +% |\CodeBefore| is present at the beginning of the environment. +% \begin{macrocode} +\cs_new_protected:Npn \@@_pre_array_i:w #1 \Body + { + \tl_put_right:Nn \l_@@_code_before_tl { #1 } + \bool_set_true:N \l_@@_code_before_bool +% \end{macrocode} +% We go on with |\@@_pre_array:| which will (among other) execute the +% |\CodeBefore| (specified in the key |code-before| or after the keyword +% |\CodeBefore|). By definition, the |\CodeBefore| must be executed before the +% body of the array... +% \begin{macrocode} + \@@_pre_array: + } +% \end{macrocode} +% +% \bigskip +% \subsection*{The environment \{NiceArrayWithDelims\}} +% +% \begin{macrocode} +\NewDocumentEnvironment { NiceArrayWithDelims } + { m m O { } m ! O { } t \CodeBefore } + { + \@@_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. +% \begin{macrocode} + \bgroup +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} + \tl_set:Nn \l_@@_left_delim_tl { #1 } + \tl_set:Nn \l_@@_right_delim_tl { #2 } + \tl_gset:Nn \g_@@_preamble_tl { #4 } +% \end{macrocode} +% +% +% \bigskip +% +% \begin{macrocode} + \int_gzero:N \g_@@_block_box_int + \dim_zero:N \g_@@_width_last_col_dim + \dim_zero:N \g_@@_width_first_col_dim + \bool_gset_false:N \g_@@_row_of_col_done_bool + \str_if_empty:NT \g_@@_name_env_str + { \str_gset:Nn \g_@@_name_env_str { NiceArrayWithDelims } } + \@@_adapt_S_column: + \bool_if:NTF \l_@@_NiceTabular_bool + \mode_leave_vertical: + \@@_test_if_math_mode: + \bool_if:NT \l_@@_in_env_bool { \@@_fatal:n { Yet~in~env } } + \bool_set_true:N \l_@@_in_env_bool +% \end{macrocode} +% The command |\CT@arc@| contains the instruction of color for the rules of the +% array\footnote{e.g. |\color[rgb]{0.5,0.5,0}|}. This command is used by |\CT@arc@| but +% we use it also for compatibility with \pkg{colortbl}. But we want also to be +% able to use color for the rules of the array when \pkg{colortbl} is \emph{not} +% loaded. That's why we do the following instruction which is in the patch of +% the beginning of arrays done by \pkg{colortbl}. Of course, we restore the +% value of |\CT@arc@| at the end of our environment. +% \begin{macrocode} + \cs_gset_eq:NN \@@_old_CT@arc@ \CT@arc@ +% \end{macrocode} +% +% We deactivate Tikz externalization because we will use \textsc{pgf} pictures +% with the options |overlay| and |remember picture| (or equivalent forms). We +% deactivate with |\tikzexternaldisable| and not with +% |\tikzset{external/export=false}| which is \emph{not} equivalent. +% \begin{macrocode} + \cs_if_exist:NT \tikz@library@external@loaded + { + \tikzexternaldisable + \cs_if_exist:NT \ifstandalone + { \tikzset { external / optimize = false } } + } +% \end{macrocode} +% +% We increment the counter |\g_@@_env_int| which counts the environments +% of the package. +% \begin{macrocode} + \int_gincr:N \g_@@_env_int + \bool_if:NF \l_@@_block_auto_columns_width_bool + { \dim_gzero_new:N \g_@@_max_cell_width_dim } +% \end{macrocode} +% +% +% The sequence |\g_@@_blocks_seq| will contain the carateristics of the blocks +% (specified by |\Block|) of the array. The sequence |\g_@@_pos_of_blocks_seq| +% will contain only the position of the blocks. Of course, this is redundant but +% it's for efficiency. +% \begin{macrocode} + \seq_gclear:N \g_@@_blocks_seq + \seq_gclear:N \g_@@_pos_of_blocks_seq +% \end{macrocode} +% In fact, the sequence |\g_@@_pos_of_blocks_seq| will also contain the +% positions of the cells with a |\diagbox|. +% +% \begin{macrocode} + \seq_gclear:N \g_@@_pos_of_stroken_blocks_seq + \seq_gclear:N \g_@@_pos_of_xdots_seq +% \end{macrocode} +% +% \begin{macrocode} + \tl_if_exist:cT { g_@@_code_before_ \int_use:N \g_@@_env_int _ 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 } + } +% \end{macrocode} +% +% The set of keys is not exactly the same for |{NiceArray}| and for the variants +% of |{NiceArray}| (|{pNiceArray}|, |{bNiceArray}|, etc.) because, for +% |{NiceArray}|, we have the options |t|, |c|, |b| and |baseline|. +% \begin{macrocode} + \bool_if:NTF \l_@@_NiceArray_bool + { \keys_set:nn { NiceMatrix / NiceArray } } + { \keys_set:nn { NiceMatrix / pNiceArray } } + { #3 , #5 } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} + \tl_if_empty:NF \l_@@_rules_color_tl + { \exp_after:wN \@@_set_CT@arc@: \l_@@_rules_color_tl \q_stop } +% \bigskip +% \end{macrocode} +% The argument |#6| is the last argument of |{NiceArrayWithDelims}|. With that +% argument of type ``|t \CodeBefore|'', we test whether there is the keyword +% |\CodeBefore| at the beginning of the environment. If that keyword is present, +% we have now to extract all the content between that keyword |\CodeBefore| and +% the (other) keyword |\Body|. It's the job that will do the command +% |\@@_pre_array_i:w|. After that job, the command |\@@_pre_array_i:w| will go +% on with |\@@_pre_array:|. +% \begin{macrocode} + \IfBooleanTF { #6 } \@@_pre_array_i:w \@@_pre_array: + } +% \end{macrocode} % % \begin{macrocode} { @@ -7761,6 +7973,13 @@ version 2005/12/01 or later. % \begin{macrocode} \skip_vertical:N -\l_tmpb_dim } +% \end{macrocode} +% Curiously, we have to put again the following specification of color. +% Otherwise, with XeLaTeX (and not with the other engines), the closing +% delimiter is not colored. +% \begin{macrocode} + \tl_if_empty:NF \l_@@_delimiters_color_tl + { \color { \l_@@_delimiters_color_tl } } \exp_after:wN \right \l_@@_right_delim_tl \c_math_toggle_token } @@ -7769,9 +7988,9 @@ version 2005/12/01 or later. % % \smallskip % We will put the box in the TeX flow. However, we have a small work to do -% when the option |max-delimiter-width| is used. +% when the option |delimiters/max-width| is used. % \begin{macrocode} - \bool_if:NTF \l_@@_max_delimiter_width_bool + \bool_if:NTF \l_@@_delimiters_max_width_bool { \@@_put_box_in_flow_bis:nn { #1 } { #2 } } \@@_put_box_in_flow: } @@ -7877,12 +8096,19 @@ version 2005/12/01 or later. % counter |\c@jCol|. % \begin{macrocode} \int_gzero_new:N \c@jCol - \bool_if:NTF \l_@@_vlines_bool + \tl_gclear:N \g_@@_preamble_tl + \tl_if_eq:NnTF \l_@@_vlines_clist { all } { \tl_gset:Nn \g_@@_preamble_tl { ! { \skip_horizontal:N \arrayrulewidth } } } - { \tl_gclear:N \g_@@_preamble_tl } + { + \clist_if_in:NnT \l_@@_vlines_clist 1 + { + \tl_gset:Nn \g_@@_preamble_tl + { ! { \skip_horizontal:N \arrayrulewidth } } + } + } % \end{macrocode} % The sequence |\g_@@_cols_vlsim_seq| will contain the numbers of the columns % where you will to have to draw vertical lines in the potential sub-matrices @@ -7925,7 +8151,7 @@ version 2005/12/01 or later. { \l_@@_NiceArray_bool { \bool_not_p:n \l_@@_NiceTabular_bool } - { \bool_not_p:n \l_@@_vlines_bool } + { \tl_if_empty_p:N \l_@@_vlines_clist } { \bool_not_p:n \l_@@_exterior_arraycolsep_bool } } { \tl_gput_left:Nn \g_@@_preamble_tl { @ { } } } @@ -7937,7 +8163,7 @@ version 2005/12/01 or later. { \l_@@_NiceArray_bool { \bool_not_p:n \l_@@_NiceTabular_bool } - { \bool_not_p:n \l_@@_vlines_bool } + { \tl_if_empty_p:N \l_@@_vlines_clist } { \bool_not_p:n \l_@@_exterior_arraycolsep_bool } } { \tl_gput_right:Nn \g_@@_preamble_tl { @ { } } } @@ -8242,11 +8468,19 @@ version 2005/12/01 or later. \str_if_eq:nnTF { #1 } { < } \@@_patch_preamble_ix:n { - \bool_if:NT \l_@@_vlines_bool + \tl_if_eq:NnTF \l_@@_vlines_clist { all } { \tl_gput_right:Nn \g_@@_preamble_tl { ! { \skip_horizontal:N \arrayrulewidth } } } + { + \exp_args:NNx + \clist_if_in:NnT \l_@@_vlines_clist { \@@_succ:n \c@jCol } + { + \tl_gput_right:Nn \g_@@_preamble_tl + { ! { \skip_horizontal:N \arrayrulewidth } } + } + } \@@_patch_preamble:n { #1 } } } @@ -8506,7 +8740,7 @@ version 2005/12/01 or later. % % \bigskip % The command |\@@_put_box_in_flow_bis:| is used when the option -% |max-delimiter-width| is used because, in this case, we have to adjust the +% |delimiters/max-width| is used because, in this case, we have to adjust the % widths of the delimiters. The arguments |#1| and |#2| are the delimiters % specified by the user. % \begin{macrocode} @@ -9380,17 +9614,16 @@ version 2005/12/01 or later. \cs_set_eq:NN \@@_vline_i:nn \@@_vline_i_complete:nn \cs_set_eq:NN \@@_hline_i:nn \@@_hline_i_complete:nn } - \bool_if:NT \l_@@_hlines_bool \@@_draw_hlines: - \bool_if:NT \l_@@_vlines_bool \@@_draw_vlines: + \tl_if_empty:NF \l_@@_hlines_clist \@@_draw_hlines: + \tl_if_empty:NF \l_@@_vlines_clist \@@_draw_vlines: % \end{macrocode} % % \begin{macrocode} - \g_@@_internal_code_after_tl - \tl_gclear:N \g_@@_internal_code_after_tl + \cs_set_eq:NN \SubMatrix \@@_SubMatrix % \end{macrocode} % % \bigskip -% Now, the |\CodeAfter|. +% Now, the internal |code-after| and then, the |\CodeAfter|. % \begin{macrocode} \bool_if:NT \c_@@_tikz_loaded_bool { @@ -9405,7 +9638,8 @@ version 2005/12/01 or later. } } \cs_set_eq:NN \line \@@_line - \cs_set_eq:NN \SubMatrix \@@_SubMatrix + \g_@@_internal_code_after_tl + \tl_gclear:N \g_@@_internal_code_after_tl % \end{macrocode} % When |light-syntax| is used, we insert systematically a |\CodeAfter| in the % flow. Thus, it's possible to have two instructions |\CodeAfter| and the second @@ -9654,23 +9888,23 @@ version 2005/12/01 or later. % We test if we are still in the matrix. % \begin{macrocode} \bool_set_false:N \l_@@_final_open_bool - \int_compare:nNnTF \l_@@_final_i_int > \c@iRow + \int_compare:nNnTF \l_@@_final_i_int > \l_@@_row_max_int { \int_compare:nNnTF { #3 } = 1 { \bool_set_true:N \l_@@_final_open_bool } { - \int_compare:nNnT \l_@@_final_j_int > \c@jCol + \int_compare:nNnT \l_@@_final_j_int > \l_@@_col_max_int { \bool_set_true:N \l_@@_final_open_bool } } } { - \int_compare:nNnTF \l_@@_final_j_int < 1 + \int_compare:nNnTF \l_@@_final_j_int < \l_@@_col_min_int { \int_compare:nNnT { #4 } = { -1 } { \bool_set_true:N \l_@@_final_open_bool } } { - \int_compare:nNnT \l_@@_final_j_int > \c@jCol + \int_compare:nNnT \l_@@_final_j_int > \l_@@_col_max_int { \int_compare:nNnT { #4 } = 1 { \bool_set_true:N \l_@@_final_open_bool } @@ -9722,7 +9956,7 @@ version 2005/12/01 or later. % a dotted line have to be marked as ``dotted'' because we don't want % intersections between dotted lines. We recall that the research of the % extremities of the lines are all done in the same TeX group (the group of the -% environnement), even though, when the extremities are found, each line is +% environment), even though, when the extremities are found, each line is % drawn in a TeX group that we will open for the options of the line. % \begin{macrocode} { @@ -9749,23 +9983,23 @@ version 2005/12/01 or later. \int_sub:Nn \l_@@_initial_i_int { #3 } \int_sub:Nn \l_@@_initial_j_int { #4 } \bool_set_false:N \l_@@_initial_open_bool - \int_compare:nNnTF \l_@@_initial_i_int < 1 + \int_compare:nNnTF \l_@@_initial_i_int < \l_@@_row_min_int { \int_compare:nNnTF { #3 } = 1 { \bool_set_true:N \l_@@_initial_open_bool } { - \int_compare:nNnT \l_@@_initial_j_int = 0 + \int_compare:nNnT \l_@@_initial_j_int = { \l_@@_col_min_int -1 } { \bool_set_true:N \l_@@_initial_open_bool } } } { - \int_compare:nNnTF \l_@@_initial_j_int < 1 + \int_compare:nNnTF \l_@@_initial_j_int < \l_@@_col_min_int { \int_compare:nNnT { #4 } = 1 { \bool_set_true:N \l_@@_initial_open_bool } } { - \int_compare:nNnT \l_@@_initial_j_int > \c@jCol + \int_compare:nNnT \l_@@_initial_j_int > \l_@@_col_max_int { \int_compare:nNnT { #4 } = { -1 } { \bool_set_true:N \l_@@_initial_open_bool } @@ -9827,6 +10061,51 @@ version 2005/12/01 or later. % \end{macrocode} % % \medskip +% The following commmand (\emph{when it will be written}) will set the four +% counters |\l_@@_row_min_int|, |\l_@@_row_max_int|, |\l_@@_col_min_int| and +% |\l_@@_col_max_int| to the intersections of the sub-matrices which contains +% the cell of row |#1| and column |#2|. +% As of now, it's only the whole array (excepted exterior row and columns). +% \begin{macrocode} +\cs_new_protected:Npn \@@_adjust_to_submatrix:nn #1 #2 + { + \int_set:Nn \l_@@_row_min_int 1 + \int_set:Nn \l_@@_col_min_int 1 + \int_set_eq:NN \l_@@_row_max_int \c@iRow + \int_set_eq:NN \l_@@_col_max_int \c@jCol +% \end{macrocode} +% We do a loop over all the submatrices specified in the |code-before|. We have +% stored the position of all those submatrices in |\g_@@_submatrix_seq|. +% \begin{macrocode} + \seq_map_inline:Nn \g_@@_submatrix_seq + { \@@_adjust_to_submatrix:nnnnnn { #1 } { #2 } ##1 } + } +% \end{macrocode} +% +% \medskip +% |#1| and |#2| are the numbers of row and columns of the cell where the command +% of dotted line (ex.: |\Vdots|) has been issued. |#3|, |#4|, |#5| and |#6| are +% the specification (in $i$ and $j$) of the submatrix where are analysing. +% \begin{macrocode} +\cs_set_protected:Npn \@@_adjust_to_submatrix:nnnnnn #1 #2 #3 #4 #5 #6 + { + \bool_if:nT + { + \int_compare_p:n { #3 <= #1 } + && \int_compare_p:n { #1 <= #5 } + && \int_compare_p:n { #4 <= #2 } + && \int_compare_p:n { #2 <= #6 } + } + { + \int_set:Nn \l_@@_row_min_int { \int_max:nn \l_@@_row_min_int { #3 } } + \int_set:Nn \l_@@_col_min_int { \int_max:nn \l_@@_col_min_int { #4 } } + \int_set:Nn \l_@@_row_max_int { \int_min:nn \l_@@_row_max_int { #5 } } + \int_set:Nn \l_@@_col_max_int { \int_min:nn \l_@@_col_max_int { #6 } } + } + } +% \end{macrocode} +% +% \medskip % \begin{macrocode} \cs_new_protected:Npn \@@_set_initial_coords: { @@ -9862,12 +10141,74 @@ version 2005/12/01 or later. } % \end{macrocode} % +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_open_x_initial_dim: + { + \dim_set_eq:NN \l_@@_x_initial_dim \c_max_dim + \int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int + { + \cs_if_exist:cT + { pgf @ sh @ ns @ \@@_env: - ##1 - \int_use:N \l_@@_initial_j_int } + { + \pgfpointanchor + { \@@_env: - ##1 - \int_use:N \l_@@_initial_j_int } + { west } + \dim_set:Nn \l_@@_x_initial_dim + { \dim_min:nn \l_@@_x_initial_dim \pgf@x } + } + } +% \end{macrocode} +% If, in fact, all the cells of the columns are empty (no PGF/Tikz nodes in +% those cells). +% \begin{macrocode} + \dim_compare:nNnT \l_@@_x_initial_dim = \c_max_dim + { + \@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int } + \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x + \dim_add:Nn \l_@@_x_initial_dim \col@sep + } + } +% \end{macrocode} +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_open_x_final_dim: + { + \dim_set:Nn \l_@@_x_final_dim { - \c_max_dim } + \int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int + { + \cs_if_exist:cT + { pgf @ sh @ ns @ \@@_env: - ##1 - \int_use:N \l_@@_final_j_int } + { + \pgfpointanchor + { \@@_env: - ##1 - \int_use:N \l_@@_final_j_int } + { east } + \dim_set:Nn \l_@@_x_final_dim + { \dim_max:nn \l_@@_x_final_dim \pgf@x } + } + } +% \end{macrocode} +% If, in fact, all the cells of the columns are empty (no PGF/Tikz nodes in +% those cells). +% \begin{macrocode} + \dim_compare:nNnT \l_@@_x_final_dim = { - \c_max_dim } + { + \@@_qpoint:n { col - \@@_succ:n \l_@@_final_j_int } + \dim_set_eq:NN \l_@@_x_final_dim \pgf@x + \dim_sub:Nn \l_@@_x_final_dim \col@sep + } + } +% \end{macrocode} +% +% +% % \interitem % The first and the second arguments are the coordinates of the cell where the % command has been issued. The third argument is the list of the options. % \begin{macrocode} \cs_new_protected:Npn \@@_draw_Ldots:nnn #1 #2 #3 { + \@@_adjust_to_submatrix:nn { #1 } { #2 } \cs_if_free:cT { @@ _ dotted _ #1 - #2 } { \@@_find_extremities_of_line:nnnn { #1 } { #2 } 0 1 @@ -9914,18 +10255,14 @@ version 2005/12/01 or later. { \bool_if:NTF \l_@@_initial_open_bool { - \@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int } - \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x - \dim_add:Nn \l_@@_x_initial_dim \col@sep + \@@_open_x_initial_dim: \@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int - base } \dim_set_eq:NN \l_@@_y_initial_dim \pgf@y } { \@@_set_initial_coords_from_anchor:n { base~east } } \bool_if:NTF \l_@@_final_open_bool { - \@@_qpoint:n { col - \@@_succ:n \l_@@_final_j_int } - \dim_set_eq:NN \l_@@_x_final_dim \pgf@x - \dim_sub:Nn \l_@@_x_final_dim \col@sep + \@@_open_x_final_dim: \@@_qpoint:n { row - \int_use:N \l_@@_final_i_int - base } \dim_set_eq:NN \l_@@_y_final_dim \pgf@y } @@ -9947,6 +10284,7 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Npn \@@_draw_Cdots:nnn #1 #2 #3 { + \@@_adjust_to_submatrix:nn { #1 } { #2 } \cs_if_free:cT { @@ _ dotted _ #1 - #2 } { \@@_find_extremities_of_line:nnnn { #1 } { #2 } 0 1 @@ -9975,6 +10313,7 @@ version 2005/12/01 or later. } % \end{macrocode} % +% % \medskip % The command |\@@_actually_draw_Cdots:| has the following implicit arguments: % \begin{itemize} @@ -9990,18 +10329,10 @@ version 2005/12/01 or later. \cs_new_protected:Npn \@@_actually_draw_Cdots: { \bool_if:NTF \l_@@_initial_open_bool - { - \@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int } - \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x - \dim_add:Nn \l_@@_x_initial_dim \col@sep - } + { \@@_open_x_initial_dim: } { \@@_set_initial_coords_from_anchor:n { mid~east } } \bool_if:NTF \l_@@_final_open_bool - { - \@@_qpoint:n { col - \@@_succ:n \l_@@_final_j_int } - \dim_set_eq:NN \l_@@_x_final_dim \pgf@x - \dim_sub:Nn \l_@@_x_final_dim \col@sep - } + { \@@_open_x_final_dim: } { \@@_set_final_coords_from_anchor:n { mid~west } } \bool_lazy_and:nnTF \l_@@_initial_open_bool @@ -10023,12 +10354,55 @@ version 2005/12/01 or later. } % \end{macrocode} % +% \begin{macrocode} +\cs_new_protected:Npn \@@_open_y_initial_dim: + { + \@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int - base } + \dim_set:Nn \l_@@_y_initial_dim + { \pgf@y + ( \box_ht:N \strutbox + \extrarowheight ) * \arraystretch } + \int_step_inline:nnn \l_@@_first_col_int \g_@@_col_total_int + { + \cs_if_exist:cT + { pgf @ sh @ ns @ \@@_env: - \int_use:N \l_@@_initial_i_int - ##1 } + { + \pgfpointanchor + { \@@_env: - \int_use:N \l_@@_initial_i_int - ##1 } + { north } + \dim_set:Nn \l_@@_y_initial_dim + { \dim_max:nn \l_@@_y_initial_dim \pgf@y } + } + } + } +% \end{macrocode} % +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_open_y_final_dim: + { + \@@_qpoint:n { row - \int_use:N \l_@@_final_i_int - base } + \dim_set:Nn \l_@@_y_final_dim + { \pgf@y - ( \box_dp:N \strutbox ) * \arraystretch } + \int_step_inline:nnn \l_@@_first_col_int \g_@@_col_total_int + { + \cs_if_exist:cT + { pgf @ sh @ ns @ \@@_env: - \int_use:N \l_@@_final_i_int - ##1 } + { + \pgfpointanchor + { \@@_env: - \int_use:N \l_@@_final_i_int - ##1 } + { south } + \dim_set:Nn \l_@@_y_final_dim + { \dim_min:nn \l_@@_y_final_dim \pgf@y } + } + } + } +% \end{macrocode} +% % The first and the second arguments are the coordinates of the cell where the % command has been issued. The third argument is the list of the options. % \begin{macrocode} \cs_new_protected:Npn \@@_draw_Vdots:nnn #1 #2 #3 { + \@@_adjust_to_submatrix:nn { #1 } { #2 } \cs_if_free:cT { @@ _ dotted _ #1 - #2 } { \@@_find_extremities_of_line:nnnn { #1 } { #2 } 1 0 @@ -10073,6 +10447,9 @@ version 2005/12/01 or later. % be considered as if. % \begin{macrocode} \bool_set_false:N \l_tmpa_bool +% \end{macrocode} +% First the case when the line is closed on both ends. +% \begin{macrocode} \bool_lazy_or:nnF \l_@@_initial_open_bool \l_@@_final_open_bool { \@@_set_initial_coords_from_anchor:n { south~west } @@ -10085,16 +10462,10 @@ version 2005/12/01 or later. % considered as if. % \begin{macrocode} \bool_if:NTF \l_@@_initial_open_bool - { - \@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int } - \dim_set_eq:NN \l_@@_y_initial_dim \pgf@y - } + \@@_open_y_initial_dim: { \@@_set_initial_coords_from_anchor:n { south } } \bool_if:NTF \l_@@_final_open_bool - { - \@@_qpoint:n { row - \@@_succ:n \l_@@_final_i_int } - \dim_set_eq:NN \l_@@_y_final_dim \pgf@y - } + \@@_open_y_final_dim: { \@@_set_final_coords_from_anchor:n { north } } \bool_if:NTF \l_@@_initial_open_bool { @@ -10130,8 +10501,7 @@ version 2005/12/01 or later. { % \end{macrocode} % Now the case where both extremities are closed. The first conditional tests -% whether the column is of type |c| (|C| of |{NiceArray}|) or may be considered -% as if. +% whether the column is of type |c| or may be considered as if. % \begin{macrocode} \dim_compare:nNnF \l_@@_x_initial_dim = \l_@@_x_final_dim { @@ -10158,6 +10528,7 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Npn \@@_draw_Ddots:nnn #1 #2 #3 { + \@@_adjust_to_submatrix:nn { #1 } { #2 } \cs_if_free:cT { @@ _ dotted _ #1 - #2 } { \@@_find_extremities_of_line:nnnn { #1 } { #2 } 1 1 @@ -10191,17 +10562,17 @@ version 2005/12/01 or later. { \bool_if:NTF \l_@@_initial_open_bool { - \@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int } - \dim_set_eq:NN \l_@@_y_initial_dim \pgf@y - \@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int } - \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x + \@@_open_y_initial_dim: + % \@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int } + % \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x + \@@_open_x_initial_dim: } { \@@_set_initial_coords_from_anchor:n { south~east } } \bool_if:NTF \l_@@_final_open_bool { - \@@_qpoint:n { row - \@@_succ:n \l_@@_final_i_int } - \dim_set_eq:NN \l_@@_y_final_dim \pgf@y - \@@_qpoint:n { col - \@@_succ:n \l_@@_final_j_int } + % \@@_open_y_final_dim: + % \@@_qpoint:n { col - \@@_succ:n \l_@@_final_j_int } + \@@_open_x_final_dim: \dim_set_eq:NN \l_@@_x_final_dim \pgf@x } { \@@_set_final_coords_from_anchor:n { north~west } } @@ -10255,6 +10626,7 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Npn \@@_draw_Iddots:nnn #1 #2 #3 { + \@@_adjust_to_submatrix:nn { #1 } { #2 } \cs_if_free:cT { @@ _ dotted _ #1 - #2 } { \@@_find_extremities_of_line:nnnn { #1 } { #2 } 1 { -1 } @@ -10288,18 +10660,22 @@ version 2005/12/01 or later. { \bool_if:NTF \l_@@_initial_open_bool { - \@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int } - \dim_set_eq:NN \l_@@_y_initial_dim \pgf@y - \@@_qpoint:n { col - \@@_succ:n \l_@@_initial_j_int } - \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x + % \@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int } + % \dim_set_eq:NN \l_@@_y_initial_dim \pgf@y + \@@_open_y_initial_dim: + % \@@_qpoint:n { col - \@@_succ:n \l_@@_initial_j_int } + % \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x + \@@_open_x_initial_dim: } { \@@_set_initial_coords_from_anchor:n { south~west } } \bool_if:NTF \l_@@_final_open_bool { - \@@_qpoint:n { row - \@@_succ:n \l_@@_final_i_int } - \dim_set_eq:NN \l_@@_y_final_dim \pgf@y - \@@_qpoint:n { col - \int_use:N \l_@@_final_j_int } - \dim_set_eq:NN \l_@@_x_final_dim \pgf@x + % \@@_qpoint:n { row - \@@_succ:n \l_@@_final_i_int } + % \dim_set_eq:NN \l_@@_y_final_dim \pgf@y + \@@_open_y_final_dim: + % \@@_qpoint:n { col - \int_use:N \l_@@_final_j_int } + % \dim_set_eq:NN \l_@@_x_final_dim \pgf@x + \@@_open_x_final_dim: } { \@@_set_final_coords_from_anchor:n { north~east } } \bool_if:NT \l_@@_parallelize_diags_bool @@ -10404,8 +10780,8 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% The command |\@@_draw_standard_dotted_line:| draws the line with our system of points -% (which gives a dotted line with real round points). +% The command |\@@_draw_standard_dotted_line:| draws the line with our system of dots +% (which gives a dotted line with real round dots). % \begin{macrocode} \cs_new_protected:Npn \@@_draw_standard_dotted_line: { @@ -10494,7 +10870,7 @@ version 2005/12/01 or later. \cs_new_protected:Npn \@@_draw_standard_dotted_line_i: { % \end{macrocode} -% The integer |\l_tmpa_int| is the number of dots of the dotted line. +% The number of dots will be |\l_tmpa_int + 1|. % \begin{macrocode} \bool_if:NTF \l_@@_initial_open_bool { @@ -10532,6 +10908,8 @@ version 2005/12/01 or later. } } % \end{macrocode} +% +% \medskip % The dimensions |\l_tmpa_dim| and |\l_tmpb_dim| are the coordinates of the % vector between two dots in the dotted line. % \begin{macrocode} @@ -10860,7 +11238,7 @@ version 2005/12/01 or later. \AtBeginDocument { \tl_set:Nn \l_@@_argspec_tl { O { } m O { } E { _ ^ } { { } { } } } - \tl_set_rescan:Nno \l_@@_argspec_tl { } \l_@@_argspec_tl + \tl_set_rescan:Nno \l_@@_argspec_tl { } \l_@@_argspec_tl % \end{macrocode} % We don't put |!| before the last optionnal argument for homogeneity with % |\Cdots|, etc. which have only one optional argument. @@ -11177,7 +11555,7 @@ version 2005/12/01 or later. % % We want to avoid the thin white lines that are shown in some \textsc{pdf} % viewers (eg: with the engine MuPDF used by SumatraPDF). That's why we try to -% draw rectangles of the same color in the same instruction |\pgfusepathqfill| +% draw rectangles of the same color in the same instruction |\pgfusepath { fill }| % (and they will be in the same instruction |fill|---coded |f|--- in the % resulting \textsc{pdf}). % @@ -11246,7 +11624,7 @@ version 2005/12/01 or later. { \color ##2 \use:c { l_@@_color _ ##1 _tl } - \pgfusepathqfill + \pgfusepath { fill } } \endpgfpicture } @@ -11282,7 +11660,7 @@ version 2005/12/01 or later. \tl_set:Nn \l_@@_cols_tl { - } % \end{macrocode} % The command |\@@_cartesian_path:| takes in two implicit arguments: -% |\l_@@_cols_tl| and |\l_@@_row_tl|. +% |\l_@@_cols_tl| and |\l_@@_rows_tl|. % \begin{macrocode} \@@_cartesian_path: } @@ -11309,7 +11687,7 @@ version 2005/12/01 or later. \tl_set:Nn \l_@@_cols_tl { #1 } % \end{macrocode} % The command |\@@_cartesian_path:| takes in two implicit arguments: -% |\l_@@_cols_tl| and |\l_@@_row_tl|. +% |\l_@@_cols_tl| and |\l_@@_rows_tl|. % \begin{macrocode} \@@_cartesian_path: } @@ -11325,14 +11703,29 @@ version 2005/12/01 or later. { \@@_add_to_colors_seq:xn { \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } } - { \@@_rectanglecolor:nn { #3 } { #4 } } + { \@@_rectanglecolor:nnn { #3 } { #4 } { 0 pt }} } } % \end{macrocode} % % \bigskip +% The last argument is the radius of the corners of the rectangle. % \begin{macrocode} -\cs_new_protected:Npn \@@_rectanglecolor:nn #1 #2 +\NewDocumentCommand \@@_roundedrectanglecolor { O { } m m m m } + { + \tl_if_blank:nF { #2 } + { + \@@_add_to_colors_seq:xn + { \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } } + { \@@_rectanglecolor:nnn { #3 } { #4 } { #5 } } + } + } +% \end{macrocode} +% +% \bigskip +% The last argument is the radius of the corners of the rectangle. +% \begin{macrocode} +\cs_new_protected:Npn \@@_rectanglecolor:nnn #1 #2 #3 { \@@_cut_on_hyphen:w #1 \q_stop \tl_clear_new:N \l_tmpc_tl @@ -11343,10 +11736,10 @@ version 2005/12/01 or later. \tl_set:Nx \l_@@_rows_tl { \l_tmpc_tl - \l_tmpa_tl } \tl_set:Nx \l_@@_cols_tl { \l_tmpd_tl - \l_tmpb_tl } % \end{macrocode} -% The command |\@@_cartesian_path:| takes in two implicit arguments: -% |\l_@@_cols_tl| and |\l_@@_row_tl|. +% The command |\@@_cartesian_path:n| takes in two implicit arguments: +% |\l_@@_cols_tl| and |\l_@@_rows_tl|. % \begin{macrocode} - \@@_cartesian_path: + \@@_cartesian_path:n { #3 } } % \end{macrocode} % @@ -11488,10 +11881,10 @@ version 2005/12/01 or later. { #3 } % \end{macrocode} % The command |\@@_cartesian_path:| takes in two implicit arguments: -% |\l_@@_cols_tl| and |\l_@@_row_tl|. +% |\l_@@_cols_tl| and |\l_@@_rows_tl|. % \begin{macrocode} \@@_cartesian_path: - \pgfusepathqfill + \pgfusepath { fill } } \bool_set_false:N \l_tmpa_bool } @@ -11507,7 +11900,7 @@ version 2005/12/01 or later. % |\l_@@_cols_tl| and |\l_@@_row_tl|. % \begin{macrocode} \@@_cartesian_path: - \pgfusepathqfill + \pgfusepath { fill } } \bool_set_true:N \l_tmpa_bool } @@ -11559,14 +11952,17 @@ version 2005/12/01 or later. % \end{macrocode} % % -% +% \begin{macrocode} +\cs_new:Npn \@@_cartesian_path: { \@@_cartesian_path:n { 0 pt } } +% \end{macrocode} +% % \bigskip % The following command uses two implicit arguments : |\l_@@_rows_tl| and % |\l_@@_cols_tl| which are specifications for a set of rows and a set of % columns. It creates a path but does \emph{not} fill it. It must be filled by -% another command after. +% another command after. The argument is the radius of the corners. % \begin{macrocode} -\cs_new_protected:Npn \@@_cartesian_path: +\cs_new_protected:Npn \@@_cartesian_path:n #1 { % \end{macrocode} % We begin the loop over the columns. @@ -11582,6 +11978,13 @@ version 2005/12/01 or later. { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } } \int_compare:nNnT \l_tmpb_tl > \c@jCol { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } } +% \end{macrocode} +% If we decide to provide the commands |\cellcolor|, |\rectanglecolor|, +% |\rowcolor|, |\columncolor|, |\rowcolors| and |\chessboardcolors| available in +% the |code-before| of a |\SubMatrix|, we will have to modify the following +% line, by adding a kind of offset. We will have also some other rows below in +% the same command |\@@_cartesian_path:|. +% \begin{macrocode} \@@_qpoint:n { col - \l_tmpa_tl } \int_compare:nNnTF \l_@@_first_col_int = \l_tmpa_tl { \dim_set:Nn \l_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } } @@ -11589,7 +11992,7 @@ version 2005/12/01 or later. \@@_qpoint:n { col - \@@_succ:n \l_tmpb_tl } \dim_set:Nn \l_tmpa_dim { \pgf@x + 0.5 \arrayrulewidth } % \end{macrocode} -% We begin the loop over the rows +% We begin the loop over the rows. % \begin{macrocode} \clist_map_inline:Nn \l_@@_rows_tl { @@ -11609,6 +12012,7 @@ version 2005/12/01 or later. \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth } \@@_qpoint:n { row - \l_tmpa_tl } \dim_set:Nn \l_tmpd_dim { \pgf@y + 0.5 \arrayrulewidth } + \pgfsetcornersarced { \pgfpoint { #1 } { #1 } } \pgfpathrectanglecorners { \pgfpoint \l_tmpc_dim \l_tmpd_dim } { \pgfpoint \l_tmpa_dim \l_tmpb_dim } @@ -11625,7 +12029,15 @@ version 2005/12/01 or later. \NewDocumentCommand \@@_cellcolor_tabular { O { } m } { \tl_gput_right:Nx \g_nicematrix_code_before_tl - { \cellcolor [ #1 ] { #2 } { \int_use:N \c@iRow - \int_use:N \c@jCol } } + { +% \end{macrocode} +% We must not expand the color (|#2|) because the color may contain the token +% |!| which may be activated by some packages (ex.: \pkg{babel} with the option +% |french| on latex and pdflatex). +% \begin{macrocode} + \cellcolor [ #1 ] { \exp_not:n { #2 } } + { \int_use:N \c@iRow - \int_use:N \c@jCol } + } } % \end{macrocode} % @@ -11637,7 +12049,7 @@ version 2005/12/01 or later. { \tl_gput_right:Nx \g_nicematrix_code_before_tl { - \exp_not:N \rectanglecolor [ #1 ] { #2 } + \exp_not:N \rectanglecolor [ #1 ] { \exp_not:n { #2 } } { \int_use:N \c@iRow - \int_use:N \c@jCol } { \int_use:N \c@iRow - \exp_not:n { \int_use:N \c@jCol } } } @@ -11655,7 +12067,10 @@ version 2005/12/01 or later. % columns drawn before the specifications of color for the rows (and the cells). % \begin{macrocode} \tl_gput_left:Nx \g_nicematrix_code_before_tl - { \exp_not:N \columncolor [ #1 ] { #2 } { \int_use:N \c@jCol } } + { + \exp_not:N \columncolor [ #1 ] + { \exp_not:n { #2 } } { \int_use:N \c@jCol } + } } } % \end{macrocode} @@ -11858,7 +12273,7 @@ version 2005/12/01 or later. \pgfpathrectanglecorners { \pgfpoint \l_tmpb_dim \l_tmpa_dim } { \pgfpoint \l_tmpd_dim \l_tmpc_dim } - \pgfusepathqfill + \pgfusepath { fill } \group_end: } \pgfpathmoveto { \pgfpoint \l_tmpb_dim \l_tmpa_dim } @@ -11897,7 +12312,11 @@ version 2005/12/01 or later. \int_step_inline:nnn { \bool_if:NTF \l_@@_NiceArray_bool 1 2 } { \bool_if:NTF \l_@@_NiceArray_bool { \@@_succ:n \c@jCol } \c@jCol } - { \@@_vline:nn { ##1 } 1 } + { + \tl_if_eq:NnF \l_@@_vlines_clist { all } + { \clist_if_in:NnT \l_@@_vlines_clist { ##1 } } + { \@@_vline:nn { ##1 } 1 } + } } % \end{macrocode} % @@ -12067,7 +12486,11 @@ version 2005/12/01 or later. \int_step_inline:nnn { \bool_if:NTF \l_@@_NiceArray_bool 1 2 } { \bool_if:NTF \l_@@_NiceArray_bool { \@@_succ:n \c@iRow } \c@iRow } - { \@@_hline:nn { ##1 } 1 } + { + \tl_if_eq:NnF \l_@@_hlines_clist { all } + { \clist_if_in:NnT \l_@@_hlines_clist { ##1 } } + { \@@_hline:nn { ##1 } 1 } + } } % \end{macrocode} % @@ -13016,12 +13439,8 @@ version 2005/12/01 or later. r .value_forbidden:n = true , c .code:n = \tl_set:Nn \l_@@_pos_of_block_tl c , c .value_forbidden:n = true , -% \end{macrocode} -% The two following lines will be uncommented when we will give to the key -% |color| its new definition. -% \begin{macrocode} - % color .tl_set:N = \l_@@_color_tl , - % color .value_required:n = true , + color .tl_set:N = \l_@@_color_tl , + color .value_required:n = true , } % \end{macrocode} % @@ -13068,7 +13487,8 @@ version 2005/12/01 or later. % argument of |\Block| (which is of the syntax $i$|-|$j$). However, the user is % allowed to omit $i$ or $j$ (or both). We detect that situation by replacing a % missing value by 100 (it's a convention: when the block will actually be drawn -% these values will be detected and interpreted as \emph{maximal possible value}). +% these values will be detected and interpreted as \emph{maximal possible +% value} according to the actual size of the array). % \begin{macrocode} \bool_lazy_or:nnTF { \tl_if_blank_p:n { #1 } } @@ -13096,7 +13516,6 @@ version 2005/12/01 or later. % \begin{macrocode} \keys_set_known:nn { NiceMatrix / Block / FirstPass } { #3 } % \end{macrocode} -% % % \begin{macrocode} \tl_set:Nx \l_tmpa_tl @@ -13332,15 +13751,9 @@ version 2005/12/01 or later. fill .value_required:n = true , draw .tl_set:N = \l_@@_draw_tl , draw .default:n = default , -% \end{macrocode} -% The following definition for the key |color| will be deleted when we will give -% to the key |color| of the command |\Block| its new definition. It will be -% replaced by the line which is commented. -% \begin{macrocode} - color .code:n = - \@@_fatal:n { Key~color~for~Block } - \tl_set:Nn \l_@@_fill_tl { #1 } , - % color .code:n = \color { #1 } \tl_set:Nn \l_@@_draw_tl { #1 } , + rounded-corners .dim_set:N = \l_@@_rounded_corners_dim , + rounded-corners .default:n = 4 pt , + color .code:n = \color { #1 } \tl_set:Nn \l_@@_draw_tl { #1 } , color .value_required:n = true , line-width .dim_set:N = \l_@@_line_width_dim , line-width .value_required:n = true , @@ -13453,10 +13866,11 @@ version 2005/12/01 or later. { \tl_gput_right:Nx \g_nicematrix_code_before_tl { - \exp_not:N \rectanglecolor + \exp_not:N \roundedrectanglecolor { \exp_not:V \l_@@_fill_tl } { #1 - #2 } { \int_use:N \l_@@_last_row_int - \int_use:N \l_@@_last_col_int } + { \dim_use:N \l_@@_rounded_corners_dim } } } % \end{macrocode} @@ -13479,7 +13893,7 @@ version 2005/12/01 or later. % % \medskip % \begin{macrocode} - \hbox_set:Nn \l_@@_cell_box { #6 } + \hbox_set:Nn \l_@@_cell_box { \set@color #6 } \bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box: % \end{macrocode} % @@ -13738,7 +14152,7 @@ version 2005/12/01 or later. % % % \bigskip % The first argument of |\@@_stroke_block:nnn| is a list of options for the -% rectangle that you will stoke. The second argument is the upper-left cell of +% rectangle that you will stroke. The second argument is the upper-left cell of % the block (with, as usual, the syntex $i$|-|$j$) and the third is the last % cell of the block (with the same syntax). % \begin{macrocode} @@ -13759,8 +14173,14 @@ version 2005/12/01 or later. % \begin{macrocode} \str_if_eq:VnTF \l_@@_draw_tl { default } { \CT@arc@ } - { \pgfsetstrokecolor { \l_@@_draw_tl } } + { \exp_args:NV \pgfsetstrokecolor \l_@@_draw_tl } } + \pgfsetcornersarced + { + \pgfpoint + { \dim_use:N \l_@@_rounded_corners_dim } + { \dim_use:N \l_@@_rounded_corners_dim } + } \@@_cut_on_hyphen:w #2 \q_stop \bool_lazy_and:nnT { \int_compare_p:n { \l_tmpa_tl <= \c@iRow } } @@ -13783,7 +14203,10 @@ version 2005/12/01 or later. { \pgfpoint \l_tmpc_dim \l_tmpb_dim } { \pgfpoint \l_tmpd_dim \l_tmpa_dim } \pgfsetlinewidth { 1.1 \l_@@_line_width_dim } - \pgfusepathqstroke +% \end{macrocode} +% We can't use |\pgfusepathqtroke| because of the key |rounded-corners|. +% \begin{macrocode} + \pgfusepath { stroke } } \endpgfpicture \group_end: @@ -13798,10 +14221,12 @@ version 2005/12/01 or later. % We will uncomment the following line when we will give to the key |color| of % the command |\Block| its new definition. % \begin{macrocode} - % color .tl_set:N = \l_@@_draw_tl , + color .tl_set:N = \l_@@_draw_tl , draw .tl_set:N = \l_@@_draw_tl , draw .default:n = default , line-width .dim_set:N = \l_@@_line_width_dim , + rounded-corners .dim_set:N = \l_@@_rounded_corners_dim , + rounded-corners .default:n = 4 pt } % \end{macrocode} % @@ -14228,10 +14653,12 @@ version 2005/12/01 or later. % \begin{macrocode} \keys_define:nn { NiceMatrix / SubMatrix } { - hlines .clist_set:N = \l_@@_submatrix_hlines_clist , + hlines .clist_set:N = \l_@@_hlines_clist , hlines .default:n = all , - vlines .clist_set:N = \l_@@_submatrix_vlines_clist , + vlines .clist_set:N = \l_@@_vlines_clist , vlines .default:n = all , + hvlines .meta:n = { hlines, vlines } , + hvlines .value_forbidden:n = true , name .code:n = \tl_if_empty:nTF { #1 } { \@@_error:n { Invalid~name~format } } @@ -14249,14 +14676,33 @@ version 2005/12/01 or later. } , rules .code:n = \keys_set:nn { NiceMatrix / rules } { #1 } , rules .value_required:n = true , + code .tl_set:N = \l_@@_code_tl , + code .value_required:n = true , name .value_required:n = true , unknown .code:n = \@@_error:n { Unknown~key~for~SubMatrix } } % \end{macrocode} % % \bigskip -% In the |code-after|, the following command |\@@_SubMatrix| will be linked to -% |\SubMatrix|. +% \begin{macrocode} +\NewDocumentCommand \@@_SubMatrix_in_code_before { m m m m ! O { } } + { + \@@_cut_on_hyphen:w #3 \q_stop + \tl_clear_new:N \l_tmpc_tl + \tl_clear_new:N \l_tmpd_tl + \tl_set_eq:NN \l_tmpc_tl \l_tmpa_tl + \tl_set_eq:NN \l_tmpd_tl \l_tmpb_tl + \@@_cut_on_hyphen:w #2 \q_stop + \seq_gput_right:Nx \g_@@_submatrix_seq + { { \l_tmpa_tl } { \l_tmpb_tl } { \l_tmpc_tl } { \l_tmpd_tl } } + \tl_gput_right:Nn \g_@@_internal_code_after_tl + { \SubMatrix { #1 } { #2 } { #3 } { #4 } [ #5 ] } + } +% \end{macrocode} +% +% \bigskip +% In the internal |code-after| and in the |\CodeAfter| the following command +% |\@@_SubMatrix| will be linked to |\SubMatrix|. % \begin{itemize} % \item |#1| is the left delimiter; % \item |#2| is the upper-left cell of the matrix with the format $i$-$j$; @@ -14265,26 +14711,35 @@ version 2005/12/01 or later. % \item |#5| is the list of options of the command. % \end{itemize} % \begin{macrocode} -\NewDocumentCommand \@@_SubMatrix { m m m m ! O { } } +\NewDocumentCommand \@@_SubMatrix { m m m m O { } } { \group_begin: % \end{macrocode} +% The four following token lists correspond to the position of the |\SubMatrix|. +% \begin{macrocode} + \tl_clear_new:N \l_@@_first_i_tl + \tl_clear_new:N \l_@@_first_j_tl + \tl_clear_new:N \l_@@_last_i_tl + \tl_clear_new:N \l_@@_last_j_tl +% \end{macrocode} % The command |\@@_cut_on_hyphen:w| cuts on the hyphen an argument of the form % $i$-$j$. The value of $i$ is stored in |\l_tmpa_tl| and the value of $j$ is % stored in |\l_tmpb_tl|. % \begin{macrocode} - \@@_cut_on_hyphen:w #3 \q_stop - \tl_clear_new:N \l_tmpc_tl - \tl_clear_new:N \l_tmpd_tl - \tl_set_eq:NN \l_tmpc_tl \l_tmpa_tl - \tl_set_eq:NN \l_tmpd_tl \l_tmpb_tl \@@_cut_on_hyphen:w #2 \q_stop + \tl_set_eq:NN \l_@@_first_i_tl \l_tmpa_tl + \tl_set_eq:NN \l_@@_first_j_tl \l_tmpb_tl + \@@_cut_on_hyphen:w #3 \q_stop + \tl_set_eq:NN \l_@@_last_i_tl \l_tmpa_tl + \tl_set_eq:NN \l_@@_last_j_tl \l_tmpb_tl \bool_lazy_or:nnTF - { \int_compare_p:nNn \l_tmpc_tl > \g_@@_row_total_int } - { \int_compare_p:nNn \l_tmpd_tl > \g_@@_col_total_int } + { \int_compare_p:nNn \l_@@_last_i_tl > \g_@@_row_total_int } + { \int_compare_p:nNn \l_@@_last_j_tl > \g_@@_col_total_int } { \@@_error:n { SubMatrix~too~large } } { \str_clear_new:N \l_@@_submatrix_name_str + \clist_clear:N \l_@@_hlines_clist + \clist_clear:N \l_@@_vlines_clist \keys_set:nn { NiceMatrix / SubMatrix } { #5 } \pgfpicture \pgfrememberpicturepositiononpagetrue @@ -14296,43 +14751,43 @@ version 2005/12/01 or later. % The last value of |\int_step_inline:nnn| is provided by currifycation. % \begin{macrocode} \bool_if:NTF \l_@@_submatrix_slim_bool - { \int_step_inline:nnn \l_tmpa_tl \l_tmpc_tl } + { \int_step_inline:nnn \l_@@_first_i_tl \l_@@_last_i_tl } { \int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int } { \cs_if_exist:cT - { pgf @ sh @ ns @ \@@_env: - ##1 - \l_tmpb_tl } + { pgf @ sh @ ns @ \@@_env: - ##1 - \l_@@_first_j_tl } { - \pgfpointanchor { \@@_env: - ##1 - \l_tmpb_tl } { west } + \pgfpointanchor { \@@_env: - ##1 - \l_@@_first_j_tl } { west } \dim_set:Nn \l_@@_x_initial_dim { \dim_min:nn \l_@@_x_initial_dim \pgf@x } } \cs_if_exist:cT - { pgf @ sh @ ns @ \@@_env: - ##1 - \l_tmpd_tl } + { pgf @ sh @ ns @ \@@_env: - ##1 - \l_@@_last_j_tl } { - \pgfpointanchor { \@@_env: - ##1 - \l_tmpd_tl } { east } + \pgfpointanchor { \@@_env: - ##1 - \l_@@_last_j_tl } { east } \dim_set:Nn \l_@@_x_final_dim { \dim_max:nn \l_@@_x_final_dim \pgf@x } } } - \@@_qpoint:n { row - \l_tmpa_tl - base } + \@@_qpoint:n { row - \l_@@_first_i_tl - base } \dim_set:Nn \l_@@_y_initial_dim { \pgf@y + ( \box_ht:N \strutbox + \extrarowheight ) * \arraystretch } - \@@_qpoint:n { row - \l_tmpc_tl - base } + \@@_qpoint:n { row - \l_@@_last_i_tl - base } \dim_set:Nn \l_@@_y_final_dim { \pgf@y - ( \box_dp:N \strutbox ) * \arraystretch } \int_step_inline:nnn \l_@@_first_col_int \g_@@_col_total_int { \cs_if_exist:cT - { pgf @ sh @ ns @ \@@_env: - \l_tmpa_tl - ##1 } + { pgf @ sh @ ns @ \@@_env: - \l_@@_first_i_tl - ##1 } { - \pgfpointanchor { \@@_env: - \l_tmpa_tl - ##1 } { north } + \pgfpointanchor { \@@_env: - \l_@@_first_i_tl - ##1 } { north } \dim_set:Nn \l_@@_y_initial_dim { \dim_max:nn \l_@@_y_initial_dim \pgf@y } } \cs_if_exist:cT - { pgf @ sh @ ns @ \@@_env: - \l_tmpc_tl - ##1 } + { pgf @ sh @ ns @ \@@_env: - \l_@@_last_i_tl - ##1 } { - \pgfpointanchor { \@@_env: - \l_tmpc_tl - ##1 } { south } + \pgfpointanchor { \@@_env: - \l_@@_last_i_tl - ##1 } { south } \dim_set:Nn \l_@@_y_final_dim { \dim_min:nn \l_@@_y_final_dim \pgf@y } } @@ -14360,9 +14815,10 @@ version 2005/12/01 or later. % \begin{macrocode} \seq_map_inline:Nn \g_@@_cols_vlism_seq { - \int_compare:nNnT \l_tmpb_tl < { ##1 } + \int_compare:nNnT \l_@@_first_j_tl < { ##1 } { - \int_compare:nNnT { ##1 } < { \int_eval:n { \l_tmpd_tl + 1 } } + \int_compare:nNnT + { ##1 } < { \int_eval:n { \l_@@_last_j_tl + 1 } } { % \end{macrocode} % First, we extract the value of the abscissa of the rule we have to draw. @@ -14381,15 +14837,17 @@ version 2005/12/01 or later. % The last argument of |\int_step_inline:nn| or |\clist_map_inline:Nn| is given % by curryfication. % \begin{macrocode} - \tl_if_eq:NnTF \l_@@_submatrix_vlines_clist { all } - { \int_step_inline:nn { \l_tmpd_tl - \l_tmpb_tl } } - { \clist_map_inline:Nn \l_@@_submatrix_vlines_clist } + \tl_if_eq:NnTF \l_@@_vlines_clist { all } + { \int_step_inline:nn { \l_@@_last_j_tl - \l_@@_first_j_tl } } + { \clist_map_inline:Nn \l_@@_vlines_clist } { \bool_lazy_and:nnTF { \int_compare_p:nNn { ##1 } > 0 } - { \int_compare_p:nNn { ##1 } < { \l_tmpd_tl - \l_tmpb_tl + 1 } } + { + \int_compare_p:nNn + { ##1 } < { \l_@@_last_j_tl - \l_@@_first_j_tl + 1 } } { - \@@_qpoint:n { col - \int_eval:n { ##1 + \l_tmpb_tl } } + \@@_qpoint:n { col - \int_eval:n { ##1 + \l_@@_first_j_tl } } \pgfpathmoveto { \pgfpoint \pgf@x \l_@@_y_initial_dim } \pgfpathlineto { \pgfpoint \pgf@x \l_@@_y_final_dim } \pgfusepathqstroke @@ -14404,15 +14862,17 @@ version 2005/12/01 or later. % The last argument of |\int_step_inline:nn| or |\clist_map_inline:Nn| is given % by curryfication. % \begin{macrocode} - \tl_if_eq:NnTF \l_@@_submatrix_hlines_clist { all } - { \int_step_inline:nn { \l_tmpc_tl - \l_tmpa_tl } } - { \clist_map_inline:Nn \l_@@_submatrix_hlines_clist } + \tl_if_eq:NnTF \l_@@_hlines_clist { all } + { \int_step_inline:nn { \l_@@_last_i_tl - \l_@@_first_i_tl } } + { \clist_map_inline:Nn \l_@@_hlines_clist } { \bool_lazy_and:nnTF { \int_compare_p:nNn { ##1 } > 0 } - { \int_compare_p:nNn { ##1 } < { \l_tmpc_tl - \l_tmpa_tl + 1 } } + { + \int_compare_p:nNn + { ##1 } < { \l_@@_last_i_tl - \l_@@_first_i_tl + 1 } } { - \@@_qpoint:n { row - \int_eval:n { ##1 + \l_tmpa_tl } } + \@@_qpoint:n { row - \int_eval:n { ##1 + \l_@@_first_i_tl } } % \end{macrocode} % We use a group to protect |\l_tmpa_dim| and |\l_tmpb_dim|. % \begin{macrocode} @@ -14495,11 +14955,121 @@ version 2005/12/01 or later. \@@_node_right:nn #4 { \@@_env: - \l_@@_submatrix_name_str - right } } \endpgfpicture +% \end{macrocode} +% +% \begin{macrocode} + \cs_set_eq:NN \pgfpointanchor \@@_pgfpointanchor:n + \flag_clear_new:n { nicematrix } + \l_@@_code_tl } \group_end: } % \end{macrocode} +% The group was a group for the whole |\SubMatrix|. +% +% \bigskip +% In the key |code| of the command |\SubMatrix| there may be Tikz instructions. +% We want that, in these instructions, the $i$ and $j$ in specifications of +% nodes of the forms $i$|-|$j$, |row-|$i$, |col-|$j$ and $i$\verb+-|+$j$ refer +% to the number of row and columm \emph{relative} of the current |\SubMatrix|. +% That's why we will patch (locally in the |\SubMatrix|) the command +% |\pgfpointanchor|. +% \begin{macrocode} +\cs_set_eq:NN \@@_old_pgfpointanchor \pgfpointanchor +% \end{macrocode} +% +% \bigskip +% The following command will be linked to |\pgfpointanchor| just before the +% execution of the option |code| of the command |\SubMatrix|. In this command, +% we catch the argument |#1| of |\pgfpointanchor| and we apply to it the command +% |\@@_pgfpointanchor_i:nn| before passing it to the original |\pgfpointanchor|. +% We have to act in an expandable way because the command |\pgfpointanchor| is +% used in names of Tikz nodes which are computed in an expandable way. +% \begin{macrocode} +\cs_new_protected:Npn \@@_pgfpointanchor:n #1 + { + \use:e + { \exp_not:N \@@_old_pgfpointanchor { \@@_pgfpointanchor_i:nn #1 } } + } +% \end{macrocode} +% +% \bigskip +% In fact, the argument of |\pgfpointanchor| is always of the form +% |\a_command { name_of_node }| where ``|name_of_node|'' is the name of the Tikz +% node without the potential prefix and suffix. That's why we catch two +% arguments and work only on the second by trying (first) to extract an hyphen |-|. +% \begin{macrocode} +\cs_new:Npn \@@_pgfpointanchor_i:nn #1 #2 + { #1 { \@@_pgfpointanchor_ii:w #2 - \q_stop } } +% \end{macrocode} % +% \bigskip +% Since |\seq_if_in:NnTF| and |\clist_if_in:NnTF| are not expandable, we will +% use the following token list and |\str_case:nVTF| to test whether we have an +% integer or not. +% \begin{macrocode} +\tl_const:Nn \c_@@_integers_alist_tl + { + { 1 } { } { 2 } { } { 3 } { } { 4 } { } { 5 } { } + { 6 } { } { 7 } { } { 8 } { } { 9 } { } { 10 } { } + { 11 } { } { 12 } { } { 13 } { } { 14 } { } { 15 } { } + { 16 } { } { 17 } { } { 18 } { } { 19 } { } { 20 } { } + } +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} +\cs_new:Npn \@@_pgfpointanchor_ii:w #1-#2\q_stop + { +% \end{macrocode} +% If there is no hyphen, that means that the node is of the form of a single +% number (ex.: |5| or |11|). In that case, we are in an analysis which result +% from a specification of node of the form $i$\verb+-|+$j$. In that case, the +% $i$ of the number of row arrives first (and alone) in a |\pgfpointanchor| and, +% the, the $j$ arrives (alone) in the following |\pgfpointanchor|. In order to +% know whether we have a number of row of a number of column, we keep track of +% the number of such treatments by the expandable flag called |nicematrix|. +% \begin{macrocode} + \tl_if_empty:nTF { #2 } + { + \str_case:nVTF { #1 } \c_@@_integers_alist_tl + { + \flag_raise:n { nicematrix } + \int_if_even:nTF { \flag_height:n { nicematrix } } + { \int_eval:n { #1 + \l_@@_first_i_tl - 1 } } + { \int_eval:n { #1 + \l_@@_first_j_tl - 1 } } + } + { #1 } + } +% \end{macrocode} +% If there is an hyphen, we have to see whether we have a node of the form +% $i$|-|$j$, |row-|$i$ or |col-|$j$. +% \begin{macrocode} + { \@@_pgfpointanchor_iii:w { #1 } #2 } + } +% \end{macrocode} +% +% \bigskip +% There was an hyphen in the name of the node and that's why we have to retrieve +% the extra hyphen we have put (cf. |\@@_pgfpointanchor_i:nn|). +% \begin{macrocode} +\cs_new:Npn \@@_pgfpointanchor_iii:w #1 #2 - + { + \str_case:nnF { #1 } + { + { row } { row - \int_eval:n { #2 + \l_@@_first_i_tl - 1 } } + { col } { col - \int_eval:n { #2 + \l_@@_first_j_tl - 1 } } + } +% \end{macrocode} +% Now the case of a node of the form $i$|-|$j$. +% \begin{macrocode} + { + \int_eval:n { #1 + \l_@@_first_i_tl - 1 } + - \int_eval:n { #2 + \l_@@_first_j_tl - 1 } + } + } +% \end{macrocode} +% % \medskip % The command |\@@_node_left:nn| puts the left delimiter with the correct size. % The argument |#1| is the delimiter to put. The argument |#2| is the name we @@ -14868,15 +15438,6 @@ version 2005/12/01 or later. } % \end{macrocode} % -% \begin{macrocode} -\@@_msg_new:nn { Key~color~for~Block } - { - The~key~'color'~for~the~command~\token_to_str:N \Block\ - is~deprecated:~you~should~use~'fill'~instead.\\ - This~error~is~fatal. - - } -% \end{macrocode} % % \begin{macrocode} \@@_msg_new:nn { ampersand~in~light-syntax } @@ -14988,6 +15549,16 @@ version 2005/12/01 or later. \seq_use:Nnnn \g_@@_submatrix_names_seq { ~and~ } { ,~ } { ~and~ }. } % \end{macrocode} +% +% \begin{macrocode} +\@@_msg_new:nn { r~or~l~with~preamble } + { + You~can't~use~the~key~'\l_keys_key_str'~in~your~\@@_full_name_env:.~ + You~must~specify~the~alignment~of~your~columns~with~the~preamble~of~ + your~\@@_full_name_env:.\\ + If~you~go~on,~this~key~will~be~ignored. + } +% \end{macrocode} % % \begin{macrocode} \@@_msg_new:nn { Hdotsfor~in~col~0 } @@ -15131,8 +15702,8 @@ version 2005/12/01 or later. For~a~list~of~the~available~keys,~type~H~<return>. } { - The~available~keys~are~(in~alphabetic~order):~-,~c,~draw,~fill,~l,~ - line-width~and~r. + The~available~keys~are~(in~alphabetic~order):~c,~draw,~fill,~l,~ + line-width,~rounded-corners~and~r. } % \end{macrocode} % @@ -15167,12 +15738,13 @@ version 2005/12/01 or later. 'delimiters/color',~ 'extra-height',~ 'hlines',~ + 'hvlines',~ 'left-xshift',~ 'name',~ 'right-xshift',~ 'rules'~(with~the~subkeys~'color'~and~'width'),~ 'slim',~ - 'vlines'~and~'xshift'~(which~set~both~'left-xshift'~ + 'vlines'~and~'xshift'~(which~sets~both~'left-xshift'~ and~'right-xshift').\\ } % \end{macrocode} @@ -15862,9 +16434,21 @@ version 2005/12/01 or later. % \subsection*{Changes between versions 5.10 and 5.11} % % It's now possible, in the |code-before| and in the |\CodeAfter|, to use the -% syntax \verb+|(i-|j)+ for the Tikz node at the intersection of the (potential) +% syntax \verb+(i-|j)+ for the Tikz node at the intersection of the (potential) % horizontal rule number~$i$ and the (potential) vertical rule number~$j$. % +% % \subsection*{Changes between versions 5.11 and 5.12} +% +% Keywords |\CodeBefore| and |\Body| (alternative syntax to the key +% |code-before|). +% +% New key |delimiters/max-width|. +% +% New keys |hlines|, |vlines| and |hvlines| for the command |\SubMatrix| in the +% |\CodeAfter|. +% +% New key |rounded-corners| for the command |\Block|. +% % \PrintIndex % % \tableofcontents diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index 3a1076b1831..671bc44ef0c 100644 --- a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty +++ b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty @@ -18,8 +18,8 @@ %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% -\def\myfileversion{5.11} -\def\myfiledate{2021/02/22} +\def\myfileversion{5.12} +\def\myfiledate{2021/03/10} \RequirePackage{pgfcore} \usepgfmodule{shapes} \RequirePackage{l3keys2e} @@ -182,6 +182,7 @@ { \cs_set:Npn \CT@arc@ { \color [ #1 ] { #2 } } } \cs_new_protected:Npn \__nicematrix_set_CT@arc@_ii: #1 \q_stop { \cs_set:Npn \CT@arc@ { \color { #1 } } } +\cs_set_eq:NN \__nicematrix_old_pgfpointanchor \pgfpointanchor \bool_new:N \c__nicematrix_siunitx_loaded_bool \AtBeginDocument { @@ -286,6 +287,7 @@ { environment \space \{ \g__nicematrix_name_env_str \} } } \tl_new:N \g_nicematrix_code_after_tl +\tl_new:N \l__nicematrix_code_tl \tl_new:N \g__nicematrix_internal_code_after_tl \int_new:N \l__nicematrix_old_iRow_int \int_new:N \l__nicematrix_old_jCol_int @@ -309,9 +311,15 @@ \seq_new:N \g__nicematrix_pos_of_xdots_seq \seq_new:N \g__nicematrix_pos_of_stroken_blocks_seq \seq_new:N \g__nicematrix_submatrix_names_seq +\int_new:N \l__nicematrix_row_min_int +\int_new:N \l__nicematrix_row_max_int +\int_new:N \l__nicematrix_col_min_int +\int_new:N \l__nicematrix_col_max_int +\seq_new:N \g__nicematrix_submatrix_seq \int_new:N \g__nicematrix_static_num_of_col_int \tl_new:N \l__nicematrix_fill_tl \tl_new:N \l__nicematrix_draw_tl +\dim_new:N \l__nicematrix_rounded_corners_dim \tl_new:N \l__nicematrix_color_tl \dim_new:N \l__nicematrix_line_width_dim \tl_new:N \l__nicematrix_pos_of_block_tl @@ -321,8 +329,8 @@ \dim_new:N \l__nicematrix_submatrix_extra_height_dim \dim_new:N \l__nicematrix_submatrix_left_xshift_dim \dim_new:N \l__nicematrix_submatrix_right_xshift_dim -\clist_new:N \l__nicematrix_submatrix_hlines_clist -\clist_new:N \l__nicematrix_submatrix_vlines_clist +\clist_new:N \l__nicematrix_hlines_clist +\clist_new:N \l__nicematrix_vlines_clist \int_new:N \l__nicematrix_first_row_int \int_set:Nn \l__nicematrix_first_row_int 1 \int_new:N \l__nicematrix_first_col_int @@ -470,8 +478,6 @@ \bool_new:N \l__nicematrix_exterior_arraycolsep_bool \bool_new:N \l__nicematrix_parallelize_diags_bool \bool_set_true:N \l__nicematrix_parallelize_diags_bool -\bool_new:N \l__nicematrix_vlines_bool -\bool_new:N \l__nicematrix_hlines_bool \clist_new:N \l__nicematrix_except_corners_clist \dim_new:N \l__nicematrix_notes_above_space_dim \AtBeginDocument { \dim_set:Nn \l__nicematrix_notes_above_space_dim { 1 mm } } @@ -488,7 +494,7 @@ \tl_set:Nn \l__nicematrix_end_of_row_tl { ; } \tl_new:N \l__nicematrix_xdots_color_tl \tl_new:N \l__nicematrix_delimiters_color_tl -\bool_new:N \l__nicematrix_max_delimiter_width_bool +\bool_new:N \l__nicematrix_delimiters_max_width_bool \keys_define:nn { NiceMatrix / xdots } { line-style .code:n = @@ -531,9 +537,8 @@ cell-space-top-limit = #1 , cell-space-bottom-limit = #1 , } , - cell-spaces-limits .value_required:n = true , + cell-space-limits .value_required:n = true , xdots .code:n = \keys_set:nn { NiceMatrix / xdots } { #1 } , - max-delimiter-width .bool_set:N = \l__nicematrix_max_delimiter_width_bool , light-syntax .bool_set:N = \l__nicematrix_light_syntax_bool , light-syntax .default:n = true , end-of-row .tl_set:N = \l__nicematrix_end_of_row_tl , @@ -550,8 +555,10 @@ code-for-first-row .value_required:n = true , code-for-last-row .tl_set:N = \l__nicematrix_code_for_last_row_tl , code-for-last-row .value_required:n = true , - hlines .bool_set:N = \l__nicematrix_hlines_bool , - vlines .bool_set:N = \l__nicematrix_vlines_bool , + hlines .clist_set:N = \l__nicematrix_hlines_clist , + vlines .clist_set:N = \l__nicematrix_vlines_clist , + hlines .default:n = all , + vlines .default:n = all , vlines-in-sub-matrix .code:n = { \tl_if_single_token:nTF { #1 } @@ -561,8 +568,8 @@ vlines-in-sub-matrix .value_required:n = true , hvlines .code:n = { - \bool_set_true:N \l__nicematrix_vlines_bool - \bool_set_true:N \l__nicematrix_hlines_bool + \clist_set:Nn \l__nicematrix_vlines_clist { all } + \clist_set:Nn \l__nicematrix_hlines_clist { all } } , parallelize-diags .bool_set:N = \l__nicematrix_parallelize_diags_bool , renew-dots .bool_set:N = \l__nicematrix_renew_dots_bool , @@ -586,13 +593,14 @@ } \keys_define:nn { NiceMatrix / Env } { + delimiters/max-width .bool_set:N = \l__nicematrix_delimiters_max_width_bool , except-corners .clist_set:N = \l__nicematrix_except_corners_clist , except-corners .default:n = { NW , SW , NE , SE } , hvlines-except-corners .code:n = { \clist_set:Nn \l__nicematrix_except_corners_clist { #1 } - \bool_set_true:N \l__nicematrix_vlines_bool - \bool_set_true:N \l__nicematrix_hlines_bool + \clist_set:Nn \l__nicematrix_vlines_clist { all } + \clist_set:Nn \l__nicematrix_hlines_clist { all } } , hvlines-except-corners .default:n = { NW , SW , NE , SE } , code-before .code:n = @@ -723,6 +731,7 @@ } \keys_define:nn { NiceMatrix / NiceMatrixOptions } { + delimiters / max-width .bool_set:N = \l__nicematrix_delimiters_max_width_bool , delimiters / color .tl_set:N = \l__nicematrix_delimiters_color_tl , delimiters / color .value_required:n = true , delimiters-color .tl_set:N = \l__nicematrix_delimiters_color_tl , @@ -802,6 +811,8 @@ delimiters-color .value_required:n = true , delimiters / color .tl_set:N = \l__nicematrix_delimiters_color_tl , delimiters / color .value_required:n = true , + r .code:n = \__nicematrix_error:n { r~or~l~with~preamble } , + l .code:n = \__nicematrix_error:n { r~or~l~with~preamble } , unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceArray } } \keys_define:nn { NiceMatrix / pNiceArray } @@ -813,6 +824,8 @@ first-row .code:n = \int_zero:N \l__nicematrix_first_row_int , small .bool_set:N = \l__nicematrix_small_bool , small .value_forbidden:n = true , + r .code:n = \__nicematrix_error:n { r~or~l~with~preamble } , + l .code:n = \__nicematrix_error:n { r~or~l~with~preamble } , unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceMatrix } } \keys_define:nn { NiceMatrix / NiceTabular } @@ -826,6 +839,8 @@ last-col .code:n = \tl_if_empty:nF {#1} { \__nicematrix_error:n { last-col~non~empty~for~NiceArray } } \int_zero:N \l__nicematrix_last_col_int , + r .code:n = \__nicematrix_error:n { r~or~l~with~preamble } , + l .code:n = \__nicematrix_error:n { r~or~l~with~preamble } , unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceTabular } } \cs_new_protected:Npn \__nicematrix_Cell: @@ -1046,12 +1061,21 @@ \bool_if:NF \g__nicematrix_row_of_col_done_bool { \__nicematrix_create_row_node: - \bool_if:NT \l__nicematrix_hlines_bool + \tl_if_empty:NF \l__nicematrix_hlines_clist { - \int_compare:nNnT \c@iRow > { -1 } + \tl_if_eq:NnF \l__nicematrix_hlines_clist { all } { - \int_compare:nNnF \c@iRow = \l__nicematrix_last_row_int - { \hrule height \arrayrulewidth width \c_zero_dim } + \exp_args:NNx + \clist_if_in:NnT + \l__nicematrix_hlines_clist + { \__nicematrix_succ:n \c@iRow } + } + { + \int_compare:nNnT \c@iRow > { -1 } + { + \int_compare:nNnF \c@iRow = \l__nicematrix_last_row_int + { \hrule height \arrayrulewidth width \c_zero_dim } + } } } } @@ -1079,7 +1103,7 @@ \cs_set_eq:NN \rowcolor \__nicematrix_rowcolor_tabular \cs_set_eq:NN \columncolor \__nicematrix_columncolor_preamble } -\cs_new_protected:Npn \__nicematrix_pre_array: +\cs_new_protected:Npn \__nicematrix_pre_array_ii: { \bool_if:NT \c__nicematrix_booktabs_loaded_bool { \tl_put_left:Nn \@BTnormal \__nicematrix_create_row_node: } @@ -1166,52 +1190,9 @@ \tl_gclear_new:N \g__nicematrix_HVdotsfor_lines_tl \tl_gclear_new:N \g_nicematrix_code_before_tl } -\NewDocumentEnvironment { NiceArrayWithDelims } { m m O { } m ! O { } } +\cs_new_protected:Npn \__nicematrix_pre_array: { - \__nicematrix_provide_pgfsyspdfmark: - \bool_if:NT \c__nicematrix_footnote_bool \savenotes - \bgroup - \tl_set:Nn \l__nicematrix_left_delim_tl { #1 } - \tl_set:Nn \l__nicematrix_right_delim_tl { #2 } - \tl_gset:Nn \g__nicematrix_preamble_tl { #4 } - \int_gzero:N \g__nicematrix_block_box_int - \dim_zero:N \g__nicematrix_width_last_col_dim - \dim_zero:N \g__nicematrix_width_first_col_dim - \bool_gset_false:N \g__nicematrix_row_of_col_done_bool - \str_if_empty:NT \g__nicematrix_name_env_str - { \str_gset:Nn \g__nicematrix_name_env_str { NiceArrayWithDelims } } - \__nicematrix_adapt_S_column: - \bool_if:NTF \l__nicematrix_NiceTabular_bool - \mode_leave_vertical: - \__nicematrix_test_if_math_mode: - \bool_if:NT \l__nicematrix_in_env_bool { \__nicematrix_fatal:n { Yet~in~env } } - \bool_set_true:N \l__nicematrix_in_env_bool - \cs_gset_eq:NN \__nicematrix_old_CT@arc@ \CT@arc@ - \cs_if_exist:NT \tikz@library@external@loaded - { - \tikzexternaldisable - \cs_if_exist:NT \ifstandalone - { \tikzset { external / optimize = false } } - } - \int_gincr:N \g__nicematrix_env_int - \bool_if:NF \l__nicematrix_block_auto_columns_width_bool - { \dim_gzero_new:N \g__nicematrix_max_cell_width_dim } - \seq_gclear:N \g__nicematrix_blocks_seq - \seq_gclear:N \g__nicematrix_pos_of_blocks_seq - \seq_gclear:N \g__nicematrix_pos_of_stroken_blocks_seq - \seq_gclear:N \g__nicematrix_pos_of_xdots_seq - \tl_if_exist:cT { g__nicematrix_code_before_ \int_use:N \g__nicematrix_env_int _ tl } - { - \bool_set_true:N \l__nicematrix_code_before_bool - \exp_args:NNv \tl_put_right:Nn \l__nicematrix_code_before_tl - { g__nicematrix_code_before_ \int_use:N \g__nicematrix_env_int _ tl } - } - \bool_if:NTF \l__nicematrix_NiceArray_bool - { \keys_set:nn { NiceMatrix / NiceArray } } - { \keys_set:nn { NiceMatrix / pNiceArray } } - { #3 , #5 } - \tl_if_empty:NF \l__nicematrix_rules_color_tl - { \exp_after:wN \__nicematrix_set_CT@arc@: \l__nicematrix_rules_color_tl \q_stop } + \seq_gclear:N \g__nicematrix_submatrix_seq \bool_if:NT \l__nicematrix_code_before_bool { \seq_if_exist:cT { __nicematrix_size_ \int_use:N \g__nicematrix_env_int _ seq } @@ -1258,13 +1239,15 @@ } \cs_set_eq:NN \cellcolor \__nicematrix_cellcolor \cs_set_eq:NN \rectanglecolor \__nicematrix_rectanglecolor + \cs_set_eq:NN \roundedrectanglecolor \__nicematrix_roundedrectanglecolor \cs_set_eq:NN \rowcolor \__nicematrix_rowcolor \cs_set_eq:NN \rowcolors \__nicematrix_rowcolors \cs_set_eq:NN \columncolor \__nicematrix_columncolor \cs_set_eq:NN \chessboardcolors \__nicematrix_chessboardcolors + \cs_set_eq:NN \SubMatrix \__nicematrix_SubMatrix_in_code_before \bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token \seq_clear_new:N \l__nicematrix_colors_seq - \l__nicematrix_code_before_tl + \exp_last_unbraced:NV \__nicematrix_CodeAfter_keys: \l__nicematrix_code_before_tl \__nicematrix_actually_color: \bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token \group_end: @@ -1317,7 +1300,7 @@ } } } - \__nicematrix_pre_array: + \__nicematrix_pre_array_ii: \dim_zero_new:N \l__nicematrix_left_delim_dim \dim_zero_new:N \l__nicematrix_right_delim_dim \bool_if:NTF \l__nicematrix_NiceArray_bool @@ -1342,6 +1325,61 @@ { \use:c { __nicematrix-light-syntax } } { \use:c { __nicematrix-normal-syntax } } } +\cs_new_protected:Npn \__nicematrix_pre_array_i:w #1 \Body + { + \tl_put_right:Nn \l__nicematrix_code_before_tl { #1 } + \bool_set_true:N \l__nicematrix_code_before_bool + \__nicematrix_pre_array: + } +\NewDocumentEnvironment { NiceArrayWithDelims } + { m m O { } m ! O { } t \CodeBefore } + { + \__nicematrix_provide_pgfsyspdfmark: + \bool_if:NT \c__nicematrix_footnote_bool \savenotes + \bgroup + \tl_set:Nn \l__nicematrix_left_delim_tl { #1 } + \tl_set:Nn \l__nicematrix_right_delim_tl { #2 } + \tl_gset:Nn \g__nicematrix_preamble_tl { #4 } + \int_gzero:N \g__nicematrix_block_box_int + \dim_zero:N \g__nicematrix_width_last_col_dim + \dim_zero:N \g__nicematrix_width_first_col_dim + \bool_gset_false:N \g__nicematrix_row_of_col_done_bool + \str_if_empty:NT \g__nicematrix_name_env_str + { \str_gset:Nn \g__nicematrix_name_env_str { NiceArrayWithDelims } } + \__nicematrix_adapt_S_column: + \bool_if:NTF \l__nicematrix_NiceTabular_bool + \mode_leave_vertical: + \__nicematrix_test_if_math_mode: + \bool_if:NT \l__nicematrix_in_env_bool { \__nicematrix_fatal:n { Yet~in~env } } + \bool_set_true:N \l__nicematrix_in_env_bool + \cs_gset_eq:NN \__nicematrix_old_CT@arc@ \CT@arc@ + \cs_if_exist:NT \tikz@library@external@loaded + { + \tikzexternaldisable + \cs_if_exist:NT \ifstandalone + { \tikzset { external / optimize = false } } + } + \int_gincr:N \g__nicematrix_env_int + \bool_if:NF \l__nicematrix_block_auto_columns_width_bool + { \dim_gzero_new:N \g__nicematrix_max_cell_width_dim } + \seq_gclear:N \g__nicematrix_blocks_seq + \seq_gclear:N \g__nicematrix_pos_of_blocks_seq + \seq_gclear:N \g__nicematrix_pos_of_stroken_blocks_seq + \seq_gclear:N \g__nicematrix_pos_of_xdots_seq + \tl_if_exist:cT { g__nicematrix_code_before_ \int_use:N \g__nicematrix_env_int _ tl } + { + \bool_set_true:N \l__nicematrix_code_before_bool + \exp_args:NNv \tl_put_right:Nn \l__nicematrix_code_before_tl + { g__nicematrix_code_before_ \int_use:N \g__nicematrix_env_int _ tl } + } + \bool_if:NTF \l__nicematrix_NiceArray_bool + { \keys_set:nn { NiceMatrix / NiceArray } } + { \keys_set:nn { NiceMatrix / pNiceArray } } + { #3 , #5 } + \tl_if_empty:NF \l__nicematrix_rules_color_tl + { \exp_after:wN \__nicematrix_set_CT@arc@: \l__nicematrix_rules_color_tl \q_stop } + \IfBooleanTF { #6 } \__nicematrix_pre_array_i:w \__nicematrix_pre_array: + } { \bool_if:NTF \l__nicematrix_light_syntax_bool { \use:c { end __nicematrix-light-syntax } } @@ -1418,10 +1456,12 @@ } \skip_vertical:N -\l_tmpb_dim } + \tl_if_empty:NF \l__nicematrix_delimiters_color_tl + { \color { \l__nicematrix_delimiters_color_tl } } \exp_after:wN \right \l__nicematrix_right_delim_tl \c_math_toggle_token } - \bool_if:NTF \l__nicematrix_max_delimiter_width_bool + \bool_if:NTF \l__nicematrix_delimiters_max_width_bool { \__nicematrix_put_box_in_flow_bis:nn { #1 } { #2 } } \__nicematrix_put_box_in_flow: } @@ -1454,12 +1494,19 @@ \@tempswatrue \@whilesw \if@tempswa \fi { \@tempswafalse \the \NC@list } \int_gzero_new:N \c@jCol - \bool_if:NTF \l__nicematrix_vlines_bool + \tl_gclear:N \g__nicematrix_preamble_tl + \tl_if_eq:NnTF \l__nicematrix_vlines_clist { all } { \tl_gset:Nn \g__nicematrix_preamble_tl { ! { \skip_horizontal:N \arrayrulewidth } } } - { \tl_gclear:N \g__nicematrix_preamble_tl } + { + \clist_if_in:NnT \l__nicematrix_vlines_clist 1 + { + \tl_gset:Nn \g__nicematrix_preamble_tl + { ! { \skip_horizontal:N \arrayrulewidth } } + } + } \seq_clear:N \g__nicematrix_cols_vlism_seq \int_zero:N \l_tmpa_int \exp_after:wN \__nicematrix_patch_preamble:n \the \@temptokena \q_stop @@ -1479,7 +1526,7 @@ { \l__nicematrix_NiceArray_bool { \bool_not_p:n \l__nicematrix_NiceTabular_bool } - { \bool_not_p:n \l__nicematrix_vlines_bool } + { \tl_if_empty_p:N \l__nicematrix_vlines_clist } { \bool_not_p:n \l__nicematrix_exterior_arraycolsep_bool } } { \tl_gput_left:Nn \g__nicematrix_preamble_tl { @ { } } } @@ -1491,7 +1538,7 @@ { \l__nicematrix_NiceArray_bool { \bool_not_p:n \l__nicematrix_NiceTabular_bool } - { \bool_not_p:n \l__nicematrix_vlines_bool } + { \tl_if_empty_p:N \l__nicematrix_vlines_clist } { \bool_not_p:n \l__nicematrix_exterior_arraycolsep_bool } } { \tl_gput_right:Nn \g__nicematrix_preamble_tl { @ { } } } @@ -1694,11 +1741,19 @@ \str_if_eq:nnTF { #1 } { < } \__nicematrix_patch_preamble_ix:n { - \bool_if:NT \l__nicematrix_vlines_bool + \tl_if_eq:NnTF \l__nicematrix_vlines_clist { all } { \tl_gput_right:Nn \g__nicematrix_preamble_tl { ! { \skip_horizontal:N \arrayrulewidth } } } + { + \exp_args:NNx + \clist_if_in:NnT \l__nicematrix_vlines_clist { \__nicematrix_succ:n \c@jCol } + { + \tl_gput_right:Nn \g__nicematrix_preamble_tl + { ! { \skip_horizontal:N \arrayrulewidth } } + } + } \__nicematrix_patch_preamble:n { #1 } } } @@ -2368,10 +2423,9 @@ \cs_set_eq:NN \__nicematrix_vline_i:nn \__nicematrix_vline_i_complete:nn \cs_set_eq:NN \__nicematrix_hline_i:nn \__nicematrix_hline_i_complete:nn } - \bool_if:NT \l__nicematrix_hlines_bool \__nicematrix_draw_hlines: - \bool_if:NT \l__nicematrix_vlines_bool \__nicematrix_draw_vlines: - \g__nicematrix_internal_code_after_tl - \tl_gclear:N \g__nicematrix_internal_code_after_tl + \tl_if_empty:NF \l__nicematrix_hlines_clist \__nicematrix_draw_hlines: + \tl_if_empty:NF \l__nicematrix_vlines_clist \__nicematrix_draw_vlines: + \cs_set_eq:NN \SubMatrix \__nicematrix_SubMatrix \bool_if:NT \c__nicematrix_tikz_loaded_bool { \tikzset @@ -2385,7 +2439,8 @@ } } \cs_set_eq:NN \line \__nicematrix_line - \cs_set_eq:NN \SubMatrix \__nicematrix_SubMatrix + \g__nicematrix_internal_code_after_tl + \tl_gclear:N \g__nicematrix_internal_code_after_tl \cs_set_eq:NN \CodeAfter \prg_do_nothing: \seq_gclear:N \g__nicematrix_submatrix_names_seq \exp_last_unbraced:NV \__nicematrix_CodeAfter_keys: \g_nicematrix_code_after_tl @@ -2483,23 +2538,23 @@ \int_add:Nn \l__nicematrix_final_i_int { #3 } \int_add:Nn \l__nicematrix_final_j_int { #4 } \bool_set_false:N \l__nicematrix_final_open_bool - \int_compare:nNnTF \l__nicematrix_final_i_int > \c@iRow + \int_compare:nNnTF \l__nicematrix_final_i_int > \l__nicematrix_row_max_int { \int_compare:nNnTF { #3 } = 1 { \bool_set_true:N \l__nicematrix_final_open_bool } { - \int_compare:nNnT \l__nicematrix_final_j_int > \c@jCol + \int_compare:nNnT \l__nicematrix_final_j_int > \l__nicematrix_col_max_int { \bool_set_true:N \l__nicematrix_final_open_bool } } } { - \int_compare:nNnTF \l__nicematrix_final_j_int < 1 + \int_compare:nNnTF \l__nicematrix_final_j_int < \l__nicematrix_col_min_int { \int_compare:nNnT { #4 } = { -1 } { \bool_set_true:N \l__nicematrix_final_open_bool } } { - \int_compare:nNnT \l__nicematrix_final_j_int > \c@jCol + \int_compare:nNnT \l__nicematrix_final_j_int > \l__nicematrix_col_max_int { \int_compare:nNnT { #4 } = 1 { \bool_set_true:N \l__nicematrix_final_open_bool } @@ -2551,23 +2606,23 @@ \int_sub:Nn \l__nicematrix_initial_i_int { #3 } \int_sub:Nn \l__nicematrix_initial_j_int { #4 } \bool_set_false:N \l__nicematrix_initial_open_bool - \int_compare:nNnTF \l__nicematrix_initial_i_int < 1 + \int_compare:nNnTF \l__nicematrix_initial_i_int < \l__nicematrix_row_min_int { \int_compare:nNnTF { #3 } = 1 { \bool_set_true:N \l__nicematrix_initial_open_bool } { - \int_compare:nNnT \l__nicematrix_initial_j_int = 0 + \int_compare:nNnT \l__nicematrix_initial_j_int = { \l__nicematrix_col_min_int -1 } { \bool_set_true:N \l__nicematrix_initial_open_bool } } } { - \int_compare:nNnTF \l__nicematrix_initial_j_int < 1 + \int_compare:nNnTF \l__nicematrix_initial_j_int < \l__nicematrix_col_min_int { \int_compare:nNnT { #4 } = 1 { \bool_set_true:N \l__nicematrix_initial_open_bool } } { - \int_compare:nNnT \l__nicematrix_initial_j_int > \c@jCol + \int_compare:nNnT \l__nicematrix_initial_j_int > \l__nicematrix_col_max_int { \int_compare:nNnT { #4 } = { -1 } { \bool_set_true:N \l__nicematrix_initial_open_bool } @@ -2621,6 +2676,31 @@ { \int_use:N \l__nicematrix_final_j_int } } } +\cs_new_protected:Npn \__nicematrix_adjust_to_submatrix:nn #1 #2 + { + \int_set:Nn \l__nicematrix_row_min_int 1 + \int_set:Nn \l__nicematrix_col_min_int 1 + \int_set_eq:NN \l__nicematrix_row_max_int \c@iRow + \int_set_eq:NN \l__nicematrix_col_max_int \c@jCol + \seq_map_inline:Nn \g__nicematrix_submatrix_seq + { \__nicematrix_adjust_to_submatrix:nnnnnn { #1 } { #2 } ##1 } + } +\cs_set_protected:Npn \__nicematrix_adjust_to_submatrix:nnnnnn #1 #2 #3 #4 #5 #6 + { + \bool_if:nT + { + \int_compare_p:n { #3 <= #1 } + && \int_compare_p:n { #1 <= #5 } + && \int_compare_p:n { #4 <= #2 } + && \int_compare_p:n { #2 <= #6 } + } + { + \int_set:Nn \l__nicematrix_row_min_int { \int_max:nn \l__nicematrix_row_min_int { #3 } } + \int_set:Nn \l__nicematrix_col_min_int { \int_max:nn \l__nicematrix_col_min_int { #4 } } + \int_set:Nn \l__nicematrix_row_max_int { \int_min:nn \l__nicematrix_row_max_int { #5 } } + \int_set:Nn \l__nicematrix_col_max_int { \int_min:nn \l__nicematrix_col_max_int { #6 } } + } + } \cs_new_protected:Npn \__nicematrix_set_initial_coords: { \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x @@ -2653,8 +2733,53 @@ { #1 } \__nicematrix_set_final_coords: } +\cs_new_protected:Npn \__nicematrix_open_x_initial_dim: + { + \dim_set_eq:NN \l__nicematrix_x_initial_dim \c_max_dim + \int_step_inline:nnn \l__nicematrix_first_row_int \g__nicematrix_row_total_int + { + \cs_if_exist:cT + { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - \int_use:N \l__nicematrix_initial_j_int } + { + \pgfpointanchor + { \__nicematrix_env: - ##1 - \int_use:N \l__nicematrix_initial_j_int } + { west } + \dim_set:Nn \l__nicematrix_x_initial_dim + { \dim_min:nn \l__nicematrix_x_initial_dim \pgf@x } + } + } + \dim_compare:nNnT \l__nicematrix_x_initial_dim = \c_max_dim + { + \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_initial_j_int } + \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x + \dim_add:Nn \l__nicematrix_x_initial_dim \col@sep + } + } +\cs_new_protected:Npn \__nicematrix_open_x_final_dim: + { + \dim_set:Nn \l__nicematrix_x_final_dim { - \c_max_dim } + \int_step_inline:nnn \l__nicematrix_first_row_int \g__nicematrix_row_total_int + { + \cs_if_exist:cT + { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - \int_use:N \l__nicematrix_final_j_int } + { + \pgfpointanchor + { \__nicematrix_env: - ##1 - \int_use:N \l__nicematrix_final_j_int } + { east } + \dim_set:Nn \l__nicematrix_x_final_dim + { \dim_max:nn \l__nicematrix_x_final_dim \pgf@x } + } + } + \dim_compare:nNnT \l__nicematrix_x_final_dim = { - \c_max_dim } + { + \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l__nicematrix_final_j_int } + \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x + \dim_sub:Nn \l__nicematrix_x_final_dim \col@sep + } + } \cs_new_protected:Npn \__nicematrix_draw_Ldots:nnn #1 #2 #3 { + \__nicematrix_adjust_to_submatrix:nn { #1 } { #2 } \cs_if_free:cT { __nicematrix _ dotted _ #1 - #2 } { \__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } 0 1 @@ -2675,18 +2800,14 @@ { \bool_if:NTF \l__nicematrix_initial_open_bool { - \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_initial_j_int } - \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x - \dim_add:Nn \l__nicematrix_x_initial_dim \col@sep + \__nicematrix_open_x_initial_dim: \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_initial_i_int - base } \dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y } { \__nicematrix_set_initial_coords_from_anchor:n { base~east } } \bool_if:NTF \l__nicematrix_final_open_bool { - \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l__nicematrix_final_j_int } - \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x - \dim_sub:Nn \l__nicematrix_x_final_dim \col@sep + \__nicematrix_open_x_final_dim: \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_final_i_int - base } \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y } @@ -2697,6 +2818,7 @@ } \cs_new_protected:Npn \__nicematrix_draw_Cdots:nnn #1 #2 #3 { + \__nicematrix_adjust_to_submatrix:nn { #1 } { #2 } \cs_if_free:cT { __nicematrix _ dotted _ #1 - #2 } { \__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } 0 1 @@ -2716,18 +2838,10 @@ \cs_new_protected:Npn \__nicematrix_actually_draw_Cdots: { \bool_if:NTF \l__nicematrix_initial_open_bool - { - \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_initial_j_int } - \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x - \dim_add:Nn \l__nicematrix_x_initial_dim \col@sep - } + { \__nicematrix_open_x_initial_dim: } { \__nicematrix_set_initial_coords_from_anchor:n { mid~east } } \bool_if:NTF \l__nicematrix_final_open_bool - { - \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l__nicematrix_final_j_int } - \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x - \dim_sub:Nn \l__nicematrix_x_final_dim \col@sep - } + { \__nicematrix_open_x_final_dim: } { \__nicematrix_set_final_coords_from_anchor:n { mid~west } } \bool_lazy_and:nnTF \l__nicematrix_initial_open_bool @@ -2747,8 +2861,45 @@ } \__nicematrix_draw_line: } +\cs_new_protected:Npn \__nicematrix_open_y_initial_dim: + { + \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_initial_i_int - base } + \dim_set:Nn \l__nicematrix_y_initial_dim + { \pgf@y + ( \box_ht:N \strutbox + \extrarowheight ) * \arraystretch } + \int_step_inline:nnn \l__nicematrix_first_col_int \g__nicematrix_col_total_int + { + \cs_if_exist:cT + { pgf @ sh @ ns @ \__nicematrix_env: - \int_use:N \l__nicematrix_initial_i_int - ##1 } + { + \pgfpointanchor + { \__nicematrix_env: - \int_use:N \l__nicematrix_initial_i_int - ##1 } + { north } + \dim_set:Nn \l__nicematrix_y_initial_dim + { \dim_max:nn \l__nicematrix_y_initial_dim \pgf@y } + } + } + } +\cs_new_protected:Npn \__nicematrix_open_y_final_dim: + { + \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_final_i_int - base } + \dim_set:Nn \l__nicematrix_y_final_dim + { \pgf@y - ( \box_dp:N \strutbox ) * \arraystretch } + \int_step_inline:nnn \l__nicematrix_first_col_int \g__nicematrix_col_total_int + { + \cs_if_exist:cT + { pgf @ sh @ ns @ \__nicematrix_env: - \int_use:N \l__nicematrix_final_i_int - ##1 } + { + \pgfpointanchor + { \__nicematrix_env: - \int_use:N \l__nicematrix_final_i_int - ##1 } + { south } + \dim_set:Nn \l__nicematrix_y_final_dim + { \dim_min:nn \l__nicematrix_y_final_dim \pgf@y } + } + } + } \cs_new_protected:Npn \__nicematrix_draw_Vdots:nnn #1 #2 #3 { + \__nicematrix_adjust_to_submatrix:nn { #1 } { #2 } \cs_if_free:cT { __nicematrix _ dotted _ #1 - #2 } { \__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } 1 0 @@ -2777,16 +2928,10 @@ { \dim_compare_p:nNn \l__nicematrix_x_initial_dim = \l__nicematrix_x_final_dim } } \bool_if:NTF \l__nicematrix_initial_open_bool - { - \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_initial_i_int } - \dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y - } + \__nicematrix_open_y_initial_dim: { \__nicematrix_set_initial_coords_from_anchor:n { south } } \bool_if:NTF \l__nicematrix_final_open_bool - { - \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l__nicematrix_final_i_int } - \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y - } + \__nicematrix_open_y_final_dim: { \__nicematrix_set_final_coords_from_anchor:n { north } } \bool_if:NTF \l__nicematrix_initial_open_bool { @@ -2829,6 +2974,7 @@ } \cs_new_protected:Npn \__nicematrix_draw_Ddots:nnn #1 #2 #3 { + \__nicematrix_adjust_to_submatrix:nn { #1 } { #2 } \cs_if_free:cT { __nicematrix _ dotted _ #1 - #2 } { \__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } 1 1 @@ -2843,17 +2989,17 @@ { \bool_if:NTF \l__nicematrix_initial_open_bool { - \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_initial_i_int } - \dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y - \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_initial_j_int } - \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x + \__nicematrix_open_y_initial_dim: + % \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_initial_j_int } + % \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x + \__nicematrix_open_x_initial_dim: } { \__nicematrix_set_initial_coords_from_anchor:n { south~east } } \bool_if:NTF \l__nicematrix_final_open_bool { - \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l__nicematrix_final_i_int } - \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y - \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l__nicematrix_final_j_int } + % \__nicematrix_open_y_final_dim: + % \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l__nicematrix_final_j_int } + \__nicematrix_open_x_final_dim: \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x } { \__nicematrix_set_final_coords_from_anchor:n { north~west } } @@ -2880,6 +3026,7 @@ } \cs_new_protected:Npn \__nicematrix_draw_Iddots:nnn #1 #2 #3 { + \__nicematrix_adjust_to_submatrix:nn { #1 } { #2 } \cs_if_free:cT { __nicematrix _ dotted _ #1 - #2 } { \__nicematrix_find_extremities_of_line:nnnn { #1 } { #2 } 1 { -1 } @@ -2894,18 +3041,22 @@ { \bool_if:NTF \l__nicematrix_initial_open_bool { - \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_initial_i_int } - \dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y - \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l__nicematrix_initial_j_int } - \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x + % \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_initial_i_int } + % \dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y + \__nicematrix_open_y_initial_dim: + % \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l__nicematrix_initial_j_int } + % \dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf@x + \__nicematrix_open_x_initial_dim: } { \__nicematrix_set_initial_coords_from_anchor:n { south~west } } \bool_if:NTF \l__nicematrix_final_open_bool { - \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l__nicematrix_final_i_int } - \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y - \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_final_j_int } - \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x + % \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l__nicematrix_final_i_int } + % \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y + \__nicematrix_open_y_final_dim: + % \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_final_j_int } + % \dim_set_eq:NN \l__nicematrix_x_final_dim \pgf@x + \__nicematrix_open_x_final_dim: } { \__nicematrix_set_final_coords_from_anchor:n { north~east } } \bool_if:NT \l__nicematrix_parallelize_diags_bool @@ -3288,7 +3439,7 @@ \AtBeginDocument { \tl_set:Nn \l__nicematrix_argspec_tl { O { } m O { } E { _ ^ } { { } { } } } - \tl_set_rescan:Nno \l__nicematrix_argspec_tl { } \l__nicematrix_argspec_tl + \tl_set_rescan:Nno \l__nicematrix_argspec_tl { } \l__nicematrix_argspec_tl \exp_args:NNV \NewDocumentCommand \__nicematrix_Hdotsfor_i \l__nicematrix_argspec_tl { \tl_gput_right:Nx \g__nicematrix_HVdotsfor_lines_tl @@ -3513,7 +3664,7 @@ { \color ##2 \use:c { l__nicematrix_color _ ##1 _tl } - \pgfusepathqfill + \pgfusepath { fill } } \endpgfpicture } @@ -3558,10 +3709,19 @@ { \__nicematrix_add_to_colors_seq:xn { \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } } - { \__nicematrix_rectanglecolor:nn { #3 } { #4 } } + { \__nicematrix_rectanglecolor:nnn { #3 } { #4 } { 0 pt }} } } -\cs_new_protected:Npn \__nicematrix_rectanglecolor:nn #1 #2 +\NewDocumentCommand \__nicematrix_roundedrectanglecolor { O { } m m m m } + { + \tl_if_blank:nF { #2 } + { + \__nicematrix_add_to_colors_seq:xn + { \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } } + { \__nicematrix_rectanglecolor:nnn { #3 } { #4 } { #5 } } + } + } +\cs_new_protected:Npn \__nicematrix_rectanglecolor:nnn #1 #2 #3 { \__nicematrix_cut_on_hyphen:w #1 \q_stop \tl_clear_new:N \l_tmpc_tl @@ -3571,7 +3731,7 @@ \__nicematrix_cut_on_hyphen:w #2 \q_stop \tl_set:Nx \l__nicematrix_rows_tl { \l_tmpc_tl - \l_tmpa_tl } \tl_set:Nx \l__nicematrix_cols_tl { \l_tmpd_tl - \l_tmpb_tl } - \__nicematrix_cartesian_path: + \__nicematrix_cartesian_path:n { #3 } } \NewDocumentCommand \__nicematrix_cellcolor { O { } m m } { @@ -3657,7 +3817,7 @@ { \color [ #1 ] } { #3 } \__nicematrix_cartesian_path: - \pgfusepathqfill + \pgfusepath { fill } } \bool_set_false:N \l_tmpa_bool } @@ -3669,7 +3829,7 @@ { \color [ #1 ] } { #4 } \__nicematrix_cartesian_path: - \pgfusepathqfill + \pgfusepath { fill } } \bool_set_true:N \l_tmpa_bool } @@ -3703,7 +3863,8 @@ \prg_return_true: \prg_return_false: } -\cs_new_protected:Npn \__nicematrix_cartesian_path: +\cs_new:Npn \__nicematrix_cartesian_path: { \__nicematrix_cartesian_path:n { 0 pt } } +\cs_new_protected:Npn \__nicematrix_cartesian_path:n #1 { \clist_map_inline:Nn \l__nicematrix_cols_tl { @@ -3737,6 +3898,7 @@ \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth } \__nicematrix_qpoint:n { row - \l_tmpa_tl } \dim_set:Nn \l_tmpd_dim { \pgf@y + 0.5 \arrayrulewidth } + \pgfsetcornersarced { \pgfpoint { #1 } { #1 } } \pgfpathrectanglecorners { \pgfpoint \l_tmpc_dim \l_tmpd_dim } { \pgfpoint \l_tmpa_dim \l_tmpb_dim } @@ -3746,13 +3908,16 @@ \NewDocumentCommand \__nicematrix_cellcolor_tabular { O { } m } { \tl_gput_right:Nx \g_nicematrix_code_before_tl - { \cellcolor [ #1 ] { #2 } { \int_use:N \c@iRow - \int_use:N \c@jCol } } + { + \cellcolor [ #1 ] { \exp_not:n { #2 } } + { \int_use:N \c@iRow - \int_use:N \c@jCol } + } } \NewDocumentCommand \__nicematrix_rowcolor_tabular { O { } m } { \tl_gput_right:Nx \g_nicematrix_code_before_tl { - \exp_not:N \rectanglecolor [ #1 ] { #2 } + \exp_not:N \rectanglecolor [ #1 ] { \exp_not:n { #2 } } { \int_use:N \c@iRow - \int_use:N \c@jCol } { \int_use:N \c@iRow - \exp_not:n { \int_use:N \c@jCol } } } @@ -3762,7 +3927,10 @@ \int_compare:nNnT \c@iRow = 1 { \tl_gput_left:Nx \g_nicematrix_code_before_tl - { \exp_not:N \columncolor [ #1 ] { #2 } { \int_use:N \c@jCol } } + { + \exp_not:N \columncolor [ #1 ] + { \exp_not:n { #2 } } { \int_use:N \c@jCol } + } } } \cs_set_eq:NN \OnlyMainNiceMatrix \use:n @@ -3883,7 +4051,7 @@ \pgfpathrectanglecorners { \pgfpoint \l_tmpb_dim \l_tmpa_dim } { \pgfpoint \l_tmpd_dim \l_tmpc_dim } - \pgfusepathqfill + \pgfusepath { fill } \group_end: } \pgfpathmoveto { \pgfpoint \l_tmpb_dim \l_tmpa_dim } @@ -3907,7 +4075,11 @@ \int_step_inline:nnn { \bool_if:NTF \l__nicematrix_NiceArray_bool 1 2 } { \bool_if:NTF \l__nicematrix_NiceArray_bool { \__nicematrix_succ:n \c@jCol } \c@jCol } - { \__nicematrix_vline:nn { ##1 } 1 } + { + \tl_if_eq:NnF \l__nicematrix_vlines_clist { all } + { \clist_if_in:NnT \l__nicematrix_vlines_clist { ##1 } } + { \__nicematrix_vline:nn { ##1 } 1 } + } } \cs_new_protected:Npn \__nicematrix_hline:nn #1 #2 { @@ -4026,7 +4198,11 @@ \int_step_inline:nnn { \bool_if:NTF \l__nicematrix_NiceArray_bool 1 2 } { \bool_if:NTF \l__nicematrix_NiceArray_bool { \__nicematrix_succ:n \c@iRow } \c@iRow } - { \__nicematrix_hline:nn { ##1 } 1 } + { + \tl_if_eq:NnF \l__nicematrix_hlines_clist { all } + { \clist_if_in:NnT \l__nicematrix_hlines_clist { ##1 } } + { \__nicematrix_hline:nn { ##1 } 1 } + } } \cs_set:Npn \__nicematrix_Hline: { \noalign { \ifnum 0 = `} \fi \__nicematrix_Hline_i:n { 1 } } \cs_set:Npn \__nicematrix_Hline_i:n #1 @@ -4513,8 +4689,8 @@ r .value_forbidden:n = true , c .code:n = \tl_set:Nn \l__nicematrix_pos_of_block_tl c , c .value_forbidden:n = true , - % color .tl_set:N = \l__nicematrix_color_tl , - % color .value_required:n = true , + color .tl_set:N = \l__nicematrix_color_tl , + color .value_required:n = true , } \NewExpandableDocumentCommand \__nicematrix_Block: { O { } m D < > { } m } { @@ -4697,10 +4873,9 @@ fill .value_required:n = true , draw .tl_set:N = \l__nicematrix_draw_tl , draw .default:n = default , - color .code:n = - \__nicematrix_fatal:n { Key~color~for~Block } - \tl_set:Nn \l__nicematrix_fill_tl { #1 } , - % color .code:n = \color { #1 } \tl_set:Nn \l__nicematrix_draw_tl { #1 } , + rounded-corners .dim_set:N = \l__nicematrix_rounded_corners_dim , + rounded-corners .default:n = 4 pt , + color .code:n = \color { #1 } \tl_set:Nn \l__nicematrix_draw_tl { #1 } , color .value_required:n = true , line-width .dim_set:N = \l__nicematrix_line_width_dim , line-width .value_required:n = true , @@ -4770,10 +4945,11 @@ { \tl_gput_right:Nx \g_nicematrix_code_before_tl { - \exp_not:N \rectanglecolor + \exp_not:N \roundedrectanglecolor { \exp_not:V \l__nicematrix_fill_tl } { #1 - #2 } { \int_use:N \l__nicematrix_last_row_int - \int_use:N \l__nicematrix_last_col_int } + { \dim_use:N \l__nicematrix_rounded_corners_dim } } } \cs_set_protected_nopar:Npn \diagbox ##1 ##2 @@ -4788,7 +4964,7 @@ { \exp_not:n { ##1 } } { \exp_not:n { ##2 } } } } - \hbox_set:Nn \l__nicematrix_cell_box { #6 } + \hbox_set:Nn \l__nicematrix_cell_box { \set@color #6 } \bool_if:NT \g__nicematrix_rotate_bool \__nicematrix_rotate_cell_box: \pgfpicture \pgfrememberpicturepositiononpagetrue @@ -4944,7 +5120,13 @@ { \str_if_eq:VnTF \l__nicematrix_draw_tl { default } { \CT@arc@ } - { \pgfsetstrokecolor { \l__nicematrix_draw_tl } } + { \exp_args:NV \pgfsetstrokecolor \l__nicematrix_draw_tl } + } + \pgfsetcornersarced + { + \pgfpoint + { \dim_use:N \l__nicematrix_rounded_corners_dim } + { \dim_use:N \l__nicematrix_rounded_corners_dim } } \__nicematrix_cut_on_hyphen:w #2 \q_stop \bool_lazy_and:nnT @@ -4968,17 +5150,19 @@ { \pgfpoint \l_tmpc_dim \l_tmpb_dim } { \pgfpoint \l_tmpd_dim \l_tmpa_dim } \pgfsetlinewidth { 1.1 \l__nicematrix_line_width_dim } - \pgfusepathqstroke + \pgfusepath { stroke } } \endpgfpicture \group_end: } \keys_define:nn { NiceMatrix / BlockStroke } { - % color .tl_set:N = \l__nicematrix_draw_tl , + color .tl_set:N = \l__nicematrix_draw_tl , draw .tl_set:N = \l__nicematrix_draw_tl , draw .default:n = default , line-width .dim_set:N = \l__nicematrix_line_width_dim , + rounded-corners .dim_set:N = \l__nicematrix_rounded_corners_dim , + rounded-corners .default:n = 4 pt } \cs_set_protected:Npn \__nicematrix_renew_matrix: { @@ -5217,10 +5401,12 @@ } \keys_define:nn { NiceMatrix / SubMatrix } { - hlines .clist_set:N = \l__nicematrix_submatrix_hlines_clist , + hlines .clist_set:N = \l__nicematrix_hlines_clist , hlines .default:n = all , - vlines .clist_set:N = \l__nicematrix_submatrix_vlines_clist , + vlines .clist_set:N = \l__nicematrix_vlines_clist , vlines .default:n = all , + hvlines .meta:n = { hlines, vlines } , + hvlines .value_forbidden:n = true , name .code:n = \tl_if_empty:nTF { #1 } { \__nicematrix_error:n { Invalid~name~format } } @@ -5238,24 +5424,45 @@ } , rules .code:n = \keys_set:nn { NiceMatrix / rules } { #1 } , rules .value_required:n = true , + code .tl_set:N = \l__nicematrix_code_tl , + code .value_required:n = true , name .value_required:n = true , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~SubMatrix } } -\NewDocumentCommand \__nicematrix_SubMatrix { m m m m ! O { } } +\NewDocumentCommand \__nicematrix_SubMatrix_in_code_before { m m m m ! O { } } { - \group_begin: \__nicematrix_cut_on_hyphen:w #3 \q_stop \tl_clear_new:N \l_tmpc_tl \tl_clear_new:N \l_tmpd_tl \tl_set_eq:NN \l_tmpc_tl \l_tmpa_tl \tl_set_eq:NN \l_tmpd_tl \l_tmpb_tl \__nicematrix_cut_on_hyphen:w #2 \q_stop + \seq_gput_right:Nx \g__nicematrix_submatrix_seq + { { \l_tmpa_tl } { \l_tmpb_tl } { \l_tmpc_tl } { \l_tmpd_tl } } + \tl_gput_right:Nn \g__nicematrix_internal_code_after_tl + { \SubMatrix { #1 } { #2 } { #3 } { #4 } [ #5 ] } + } +\NewDocumentCommand \__nicematrix_SubMatrix { m m m m O { } } + { + \group_begin: + \tl_clear_new:N \l__nicematrix_first_i_tl + \tl_clear_new:N \l__nicematrix_first_j_tl + \tl_clear_new:N \l__nicematrix_last_i_tl + \tl_clear_new:N \l__nicematrix_last_j_tl + \__nicematrix_cut_on_hyphen:w #2 \q_stop + \tl_set_eq:NN \l__nicematrix_first_i_tl \l_tmpa_tl + \tl_set_eq:NN \l__nicematrix_first_j_tl \l_tmpb_tl + \__nicematrix_cut_on_hyphen:w #3 \q_stop + \tl_set_eq:NN \l__nicematrix_last_i_tl \l_tmpa_tl + \tl_set_eq:NN \l__nicematrix_last_j_tl \l_tmpb_tl \bool_lazy_or:nnTF - { \int_compare_p:nNn \l_tmpc_tl > \g__nicematrix_row_total_int } - { \int_compare_p:nNn \l_tmpd_tl > \g__nicematrix_col_total_int } + { \int_compare_p:nNn \l__nicematrix_last_i_tl > \g__nicematrix_row_total_int } + { \int_compare_p:nNn \l__nicematrix_last_j_tl > \g__nicematrix_col_total_int } { \__nicematrix_error:n { SubMatrix~too~large } } { \str_clear_new:N \l__nicematrix_submatrix_name_str + \clist_clear:N \l__nicematrix_hlines_clist + \clist_clear:N \l__nicematrix_vlines_clist \keys_set:nn { NiceMatrix / SubMatrix } { #5 } \pgfpicture \pgfrememberpicturepositiononpagetrue @@ -5264,43 +5471,43 @@ \dim_set_eq:NN \l__nicematrix_x_initial_dim \c_max_dim \dim_set:Nn \l__nicematrix_x_final_dim { - \c_max_dim } \bool_if:NTF \l__nicematrix_submatrix_slim_bool - { \int_step_inline:nnn \l_tmpa_tl \l_tmpc_tl } + { \int_step_inline:nnn \l__nicematrix_first_i_tl \l__nicematrix_last_i_tl } { \int_step_inline:nnn \l__nicematrix_first_row_int \g__nicematrix_row_total_int } { \cs_if_exist:cT - { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - \l_tmpb_tl } + { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - \l__nicematrix_first_j_tl } { - \pgfpointanchor { \__nicematrix_env: - ##1 - \l_tmpb_tl } { west } + \pgfpointanchor { \__nicematrix_env: - ##1 - \l__nicematrix_first_j_tl } { west } \dim_set:Nn \l__nicematrix_x_initial_dim { \dim_min:nn \l__nicematrix_x_initial_dim \pgf@x } } \cs_if_exist:cT - { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - \l_tmpd_tl } + { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - \l__nicematrix_last_j_tl } { - \pgfpointanchor { \__nicematrix_env: - ##1 - \l_tmpd_tl } { east } + \pgfpointanchor { \__nicematrix_env: - ##1 - \l__nicematrix_last_j_tl } { east } \dim_set:Nn \l__nicematrix_x_final_dim { \dim_max:nn \l__nicematrix_x_final_dim \pgf@x } } } - \__nicematrix_qpoint:n { row - \l_tmpa_tl - base } + \__nicematrix_qpoint:n { row - \l__nicematrix_first_i_tl - base } \dim_set:Nn \l__nicematrix_y_initial_dim { \pgf@y + ( \box_ht:N \strutbox + \extrarowheight ) * \arraystretch } - \__nicematrix_qpoint:n { row - \l_tmpc_tl - base } + \__nicematrix_qpoint:n { row - \l__nicematrix_last_i_tl - base } \dim_set:Nn \l__nicematrix_y_final_dim { \pgf@y - ( \box_dp:N \strutbox ) * \arraystretch } \int_step_inline:nnn \l__nicematrix_first_col_int \g__nicematrix_col_total_int { \cs_if_exist:cT - { pgf @ sh @ ns @ \__nicematrix_env: - \l_tmpa_tl - ##1 } + { pgf @ sh @ ns @ \__nicematrix_env: - \l__nicematrix_first_i_tl - ##1 } { - \pgfpointanchor { \__nicematrix_env: - \l_tmpa_tl - ##1 } { north } + \pgfpointanchor { \__nicematrix_env: - \l__nicematrix_first_i_tl - ##1 } { north } \dim_set:Nn \l__nicematrix_y_initial_dim { \dim_max:nn \l__nicematrix_y_initial_dim \pgf@y } } \cs_if_exist:cT - { pgf @ sh @ ns @ \__nicematrix_env: - \l_tmpc_tl - ##1 } + { pgf @ sh @ ns @ \__nicematrix_env: - \l__nicematrix_last_i_tl - ##1 } { - \pgfpointanchor { \__nicematrix_env: - \l_tmpc_tl - ##1 } { south } + \pgfpointanchor { \__nicematrix_env: - \l__nicematrix_last_i_tl - ##1 } { south } \dim_set:Nn \l__nicematrix_y_final_dim { \dim_min:nn \l__nicematrix_y_final_dim \pgf@y } } @@ -5318,9 +5525,10 @@ \CT@arc@ \seq_map_inline:Nn \g__nicematrix_cols_vlism_seq { - \int_compare:nNnT \l_tmpb_tl < { ##1 } + \int_compare:nNnT \l__nicematrix_first_j_tl < { ##1 } { - \int_compare:nNnT { ##1 } < { \int_eval:n { \l_tmpd_tl + 1 } } + \int_compare:nNnT + { ##1 } < { \int_eval:n { \l__nicematrix_last_j_tl + 1 } } { \__nicematrix_qpoint:n { col - ##1 } \pgfpathmoveto { \pgfpoint \pgf@x \l__nicematrix_y_initial_dim } @@ -5329,30 +5537,34 @@ } } } - \tl_if_eq:NnTF \l__nicematrix_submatrix_vlines_clist { all } - { \int_step_inline:nn { \l_tmpd_tl - \l_tmpb_tl } } - { \clist_map_inline:Nn \l__nicematrix_submatrix_vlines_clist } + \tl_if_eq:NnTF \l__nicematrix_vlines_clist { all } + { \int_step_inline:nn { \l__nicematrix_last_j_tl - \l__nicematrix_first_j_tl } } + { \clist_map_inline:Nn \l__nicematrix_vlines_clist } { \bool_lazy_and:nnTF { \int_compare_p:nNn { ##1 } > 0 } - { \int_compare_p:nNn { ##1 } < { \l_tmpd_tl - \l_tmpb_tl + 1 } } { - \__nicematrix_qpoint:n { col - \int_eval:n { ##1 + \l_tmpb_tl } } + \int_compare_p:nNn + { ##1 } < { \l__nicematrix_last_j_tl - \l__nicematrix_first_j_tl + 1 } } + { + \__nicematrix_qpoint:n { col - \int_eval:n { ##1 + \l__nicematrix_first_j_tl } } \pgfpathmoveto { \pgfpoint \pgf@x \l__nicematrix_y_initial_dim } \pgfpathlineto { \pgfpoint \pgf@x \l__nicematrix_y_final_dim } \pgfusepathqstroke } { \__nicematrix_error:nnn { Wrong~line~in~SubMatrix } { vertical } { ##1 } } } - \tl_if_eq:NnTF \l__nicematrix_submatrix_hlines_clist { all } - { \int_step_inline:nn { \l_tmpc_tl - \l_tmpa_tl } } - { \clist_map_inline:Nn \l__nicematrix_submatrix_hlines_clist } + \tl_if_eq:NnTF \l__nicematrix_hlines_clist { all } + { \int_step_inline:nn { \l__nicematrix_last_i_tl - \l__nicematrix_first_i_tl } } + { \clist_map_inline:Nn \l__nicematrix_hlines_clist } { \bool_lazy_and:nnTF { \int_compare_p:nNn { ##1 } > 0 } - { \int_compare_p:nNn { ##1 } < { \l_tmpc_tl - \l_tmpa_tl + 1 } } { - \__nicematrix_qpoint:n { row - \int_eval:n { ##1 + \l_tmpa_tl } } + \int_compare_p:nNn + { ##1 } < { \l__nicematrix_last_i_tl - \l__nicematrix_first_i_tl + 1 } } + { + \__nicematrix_qpoint:n { row - \int_eval:n { ##1 + \l__nicematrix_first_i_tl } } \group_begin: \dim_set:Nn \l_tmpa_dim { \l__nicematrix_x_initial_dim - \l__nicematrix_submatrix_left_xshift_dim } @@ -5407,9 +5619,54 @@ \__nicematrix_node_right:nn #4 { \__nicematrix_env: - \l__nicematrix_submatrix_name_str - right } } \endpgfpicture + \cs_set_eq:NN \pgfpointanchor \__nicematrix_pgfpointanchor:n + \flag_clear_new:n { nicematrix } + \l__nicematrix_code_tl } \group_end: } +\cs_set_eq:NN \__nicematrix_old_pgfpointanchor \pgfpointanchor +\cs_new_protected:Npn \__nicematrix_pgfpointanchor:n #1 + { + \use:e + { \exp_not:N \__nicematrix_old_pgfpointanchor { \__nicematrix_pgfpointanchor_i:nn #1 } } + } +\cs_new:Npn \__nicematrix_pgfpointanchor_i:nn #1 #2 + { #1 { \__nicematrix_pgfpointanchor_ii:w #2 - \q_stop } } +\tl_const:Nn \c__nicematrix_integers_alist_tl + { + { 1 } { } { 2 } { } { 3 } { } { 4 } { } { 5 } { } + { 6 } { } { 7 } { } { 8 } { } { 9 } { } { 10 } { } + { 11 } { } { 12 } { } { 13 } { } { 14 } { } { 15 } { } + { 16 } { } { 17 } { } { 18 } { } { 19 } { } { 20 } { } + } +\cs_new:Npn \__nicematrix_pgfpointanchor_ii:w #1-#2\q_stop + { + \tl_if_empty:nTF { #2 } + { + \str_case:nVTF { #1 } \c__nicematrix_integers_alist_tl + { + \flag_raise:n { nicematrix } + \int_if_even:nTF { \flag_height:n { nicematrix } } + { \int_eval:n { #1 + \l__nicematrix_first_i_tl - 1 } } + { \int_eval:n { #1 + \l__nicematrix_first_j_tl - 1 } } + } + { #1 } + } + { \__nicematrix_pgfpointanchor_iii:w { #1 } #2 } + } +\cs_new:Npn \__nicematrix_pgfpointanchor_iii:w #1 #2 - + { + \str_case:nnF { #1 } + { + { row } { row - \int_eval:n { #2 + \l__nicematrix_first_i_tl - 1 } } + { col } { col - \int_eval:n { #2 + \l__nicematrix_first_j_tl - 1 } } + } + { + \int_eval:n { #1 + \l__nicematrix_first_i_tl - 1 } + - \int_eval:n { #2 + \l__nicematrix_first_j_tl - 1 } + } + } \cs_new_protected:Npn \__nicematrix_node_left:nn #1 #2 { \pgfnode @@ -5636,13 +5893,6 @@ (and~you~try~to~use~'\l_keys_key_str').~If~you~go~on,~ this~key~will~be~ignored. } -\__nicematrix_msg_new:nn { Key~color~for~Block } - { - The~key~'color'~for~the~command~\token_to_str:N \Block\ - is~deprecated:~you~should~use~'fill'~instead.\\ - This~error~is~fatal. - - } \__nicematrix_msg_new:nn { ampersand~in~light-syntax } { You~can't~use~an~ampersand~(\token_to_str:N &)~to~separate~columns~because~ @@ -5717,6 +5967,13 @@ The~names~already~defined~in~this~\__nicematrix_full_name_env:\ are:~ \seq_use:Nnnn \g__nicematrix_submatrix_names_seq { ~and~ } { ,~ } { ~and~ }. } +\__nicematrix_msg_new:nn { r~or~l~with~preamble } + { + You~can't~use~the~key~'\l_keys_key_str'~in~your~\__nicematrix_full_name_env:.~ + You~must~specify~the~alignment~of~your~columns~with~the~preamble~of~ + your~\__nicematrix_full_name_env:.\\ + If~you~go~on,~this~key~will~be~ignored. + } \__nicematrix_msg_new:nn { Hdotsfor~in~col~0 } { You~can't~use~\token_to_str:N \Hdotsfor\ in~an~exterior~column~of~ @@ -5811,8 +6068,8 @@ For~a~list~of~the~available~keys,~type~H~<return>. } { - The~available~keys~are~(in~alphabetic~order):~-,~c,~draw,~fill,~l,~ - line-width~and~r. + The~available~keys~are~(in~alphabetic~order):~c,~draw,~fill,~l,~ + line-width,~rounded-corners~and~r. } \__nicematrix_msg_new:nnn { Unknown~key~for~CodeAfter } { @@ -5841,12 +6098,13 @@ 'delimiters/color',~ 'extra-height',~ 'hlines',~ + 'hvlines',~ 'left-xshift',~ 'name',~ 'right-xshift',~ 'rules'~(with~the~subkeys~'color'~and~'width'),~ 'slim',~ - 'vlines'~and~'xshift'~(which~set~both~'left-xshift'~ + 'vlines'~and~'xshift'~(which~sets~both~'left-xshift'~ and~'right-xshift').\\ } \__nicematrix_msg_new:nnn { Unknown~key~for~notes } |