diff options
author | Karl Berry <karl@freefriends.org> | 2021-02-06 22:32:56 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-02-06 22:32:56 +0000 |
commit | 92e358816d81f23b2ff53fb04a1029b39482adb8 (patch) | |
tree | 71f67d3a46d902829e7370ec05ce22445325bcf5 /Master/texmf-dist | |
parent | f79993ce1baaff40acde1ac02130abefc6b0e0ef (diff) |
nicematrix (6feb21)
git-svn-id: svn://tug.org/texlive/trunk@57649 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf | bin | 425830 -> 439492 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex | 480 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf | bin | 1078565 -> 1131373 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx | 1145 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | 556 |
5 files changed, 1798 insertions, 383 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 833a876d410..b5ce89cab3e 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 ca8beb88fc0..ef0cd4123bd 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex @@ -1,4 +1,4 @@ -% -*- coding: utf-8 ; -*- +% -*- coding: utf-8 ; -*- \documentclass[dvipsnames]{article}% dvipsnames is for xcolor (loaded by Tikz, loaded by nicematrix) \usepackage{xltxtra} \usepackage[french]{babel} @@ -122,9 +122,10 @@ classique |latex|-|dvips|-|ps2pdf| (ou Adobe Distiller). \textsl{Néanmoins, le ne peut être compilé qu'avec XeLaTeX.} \bigskip -Cette extension nécessite et charge les extensions \pkg{l3keys2e}, \pkg{xparse}, \pkg{array}, \pkg{amsmath} et -\pkg{pgfcore} ainsi que le module \pkg{shapes} de \textsc{pgf} (l'extension \pkg{tikz}, qui est une surcouche de -\textsc{pgf}, n'est \emph{pas} chargée). L'utilisateur final n'a qu'à charger l'extension \pkg{nicematrix} avec +Cette extension nécessite et charge les extensions \pkg{l3keys2e}, \pkg{array}, +\pkg{amsmath} et \pkg{pgfcore} ainsi que le module \pkg{shapes} de \textsc{pgf} +(l'extension \pkg{tikz}, qui est une surcouche de \textsc{pgf}, n'est \emph{pas} +chargée). L'utilisateur final n'a qu'à charger l'extension \pkg{nicematrix} avec l'instruction habituelle : |\usepackage{nicematrix}|. @@ -215,7 +216,7 @@ doit être chargé avec l'option |define-L-C-R|. \section{L'espace vertical entre les rangées} -Il est bien connu que certaines rangées des tableaux créés par défault avec +Il est bien connu que certaines rangées des tableaux créés par défaut avec LaTeX sont trop proches l'une de l'autre. On en donne ci-dessous un exemple classique. @@ -538,11 +539,11 @@ arum & iris & jacinthe & muguet \end{center} \medskip -\colorbox{yellow!30}{Nouveau 5.7}\enskip 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|. +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|. @@ -1087,7 +1088,9 @@ $\begin{pNiceArray}{cccc:c} \bigskip Il est possible de changer dans \pkg{nicematrix} la lettre utilisée pour indiquer dans le préambule un trait vertical en pointillés avec l'option -|letter-for-dotted-lines| disponible dans |\NiceMatrixOptions|. +|letter-for-dotted-lines| disponible dans |\NiceMatrixOptions|. +Ainsi libérée, la lettre «|:|» peut être utilisée par ailleurs (par exemple par +l'extension \pkg{arydshln}). \bigskip @@ -1097,7 +1100,7 @@ insère rendent le tableau plus large ou plus long d'une quantité égale à la largeur du trait\footnote{En fait, cela est vrai pour |\hline| et «\verb+|+» mais pas pour |\cline| : cf. p.~\pageref{remark-cline}}. Avec \pkg{nicematrix}, les lignes en pointillés tracées par |\hdottedline| et «|:|» -ont le même effet. +ont ce même effet. @@ -1142,7 +1145,7 @@ Concernant ce phénomène, Adobe Reader donne de meilleurs résultats que MuPDF. \end{itemize} -L'extension \pkg{nicematrix} proposent des outils qui permettent d'éviter ces +L'extension \pkg{nicematrix} propose des outils qui permettent d'éviter ces inconvénients. \end{itemize} @@ -1277,11 +1280,11 @@ rangées avec les deux couleurs à partir de la rangée dont le numéro est donn premier argument (obligatoire), comme le fait la commande |\rowcolors| de \pkg{xcolor}. -\colorbox{yellow!50}{\textbf{Nouveau 5.8}}\enskip +\colorbox{yellow!30}{Nouveau 5.8}\enskip En fait, le premier argument (obligatoire) peut, plus généralement, contenir une liste d'intervalles correspondant à l'ensemble des rangées sur lesquelles portera l'effet de |\rowcolors| (un intervalle de la forme $i$ désigne en fait -l'intervalle constitué de toutes les rangées du tableau à partir de de la rangée~$i$). +l'intervalle constitué de toutes les rangées du tableau à partir de la rangée~$i$). \bigskip @@ -1290,12 +1293,12 @@ 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|. \begin{itemize} -\item \colorbox{yellow!50}{\textbf{Nouveau 5.8}}\enskip +\item \colorbox{yellow!30}{Nouveau 5.8}\enskip La clé |cols| décrit un ensemble de colonnes sur lesquelles portera l'effet de |\rowcolors|. Cet ensemble de colonnes est une liste d'intervalles de la forme $i$|-|$j$. -\item \colorbox{yellow!50}{\textbf{Nouveau 5.8}}\enskip Avec la clé |restart|, chacun +\item \colorbox{yellow!30}{Nouveau 5.8}\enskip Avec la clé |restart|, chacun des intervalles de rangées spécifié par le premier argument de |\rowcolors| recommence avec la même couleur.\footnote{Autrement, la couleur d'une rangée ne dépend que de la partié de son numéro.} @@ -1373,7 +1376,8 @@ Henri & 14 \\ \bigskip -\item La commande |\chessboardcolors| prend en arguments obligatoires deux +\item \label{chessboardcolors}% +La commande |\chessboardcolors| prend en arguments obligatoires deux couleurs et colorie les cases en quinconces avec les deux couleurs. \medskip @@ -2137,7 +2141,7 @@ $\begin{pmatrix} \subsection{Les labels des lignes en pointillés} Les commandes |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, |\Iddots| et |\Hdotsfor| -(ainsi que la commande |\line| dans le |code-after| décrite +(ainsi que la commande |\line| dans le |\CodeAfter| décrite p.~\pageref{line-in-code-after}) peuvent en fait prendre deux arguments optionnels spécifiés par les caractères |_| et |^| pour des labels situés au-dessous et au-dessus de la ligne. Les arguments sont composés en mode @@ -2161,7 +2165,7 @@ $\begin{bNiceMatrix} \label{customization} Les lignes pointillées tracées par |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, -|\Iddots| et |\Hdotsfor| (ainsi que par la commande |\line| dans le |code-after| +|\Iddots| et |\Hdotsfor| (ainsi que par la commande |\line| dans le |\CodeAfter| décrite p.~\pageref{line-in-code-after}) peuvent être paramétrées par trois options (que l'on met entre crochets après la commande) : % @@ -2289,47 +2293,193 @@ $\begin{bNiceMatrix}[margin,hvlines] \end{bNiceMatrix}$ -\section{Le code-after} +\section{Le \textbackslash CodeAfter} \label{code-after} +On a présenté p.~\pageref{code-before} la clé |code-before|. Il existe en fait +une clé similaire |code-after| qui peut être utilisée pour indiquer du code qui +sera exécuté après la construction du tableau. -L'option |code-after| peut être utilisée pour indiquer du code qui sera exécuté -après la construction de la matrice.\footnote{Il existe aussi une clé - |code-before| décrite p.~\pageref{code-before}.} +\medskip +Pour améliorer la lisibilité du code, une syntaxe alternative est proposée : on +peut spécifier les instructions du |code-after| à la fin de l'environnement, +après le mot-clé |\CodeAfter|. + +\medskip +Deux commandes spéciales sont disponibles dans le |\CodeAfter| : |\line| et +|\SubMatrix|. -Une commande spéciale, nommée |\line| est disponible pour tracer directement des -lignes en pointillés entre les cases. Elle prend deux arguments correspondant -aux deux cases à relier, chacun de la forme $i$-$j$ où $i$ est le numéro de -ligne et $j$ est le numéro de colonne. Elle peut par exemple être utilisée pour -tracer une ligne entre deux cases adjacentes comme dans l'exemple suivant. + +\subsection{La commande \textbackslash line dans le \textbackslash CodeAfter} + +La commande |\line| permet de tracer directement des lignes en pointillés entre +les cases. Elle prend deux arguments correspondant aux deux cases à relier, +chacun de la forme $i$-$j$ où $i$ est le numéro de ligne et $j$ est le numéro de +colonne. Elle peut par exemple être utilisée pour tracer une ligne entre deux +cases adjacentes comme dans l'exemple suivant. \label{line-in-code-after} \medskip \begin{BVerbatim}[baseline=c,boxwidth=11cm] \NiceMatrixOptions{xdots/shorten = 0.6 em} -\begin{pNiceMatrix}[~emphase#code-after=\line{2-2}{3-3}@] +\begin{pNiceMatrix} I & 0 & \Cdots &0 \\ 0 & I & \Ddots &\Vdots\\ \Vdots &\Ddots & I &0 \\ 0 &\Cdots & 0 &I +~emphase#\CodeAfter \line{2-2}{3-3}@ \end{pNiceMatrix} \end{BVerbatim} \begin{scope} \NiceMatrixOptions{xdots/shorten = 0.6 em} -$\begin{pNiceMatrix}[code-after=\line{2-2}{3-3}] +$\begin{pNiceMatrix} I & 0 & \Cdots &0 \\ 0 & I & \Ddots &\Vdots\\ \Vdots &\Ddots & I &0 \\ 0 &\Cdots & 0 &I +\CodeAfter \line{2-2}{3-3} \end{pNiceMatrix}$ \end{scope} +\subsection{La commande \textbackslash SubMatrix dans le \textbackslash CodeAfter} + +\label{sub-matrix} + +\colorbox{yellow!50}{\textbf{Nouveau 5.10}}\enskip +La commande |\SubMatrix| permet de positionner des délimiteurs sur une partie du +tableau considérée comme une sous-matrice. La commande |\SubMatrix| prend cinq +arguments : +\begin{itemize} +\item le premier argument est le délimiteur gauche qui peut être n'importe +quel délimiteur extensible de LaTeX : |(|, |[|, |\{|, |\langle|, |\lgroup|, +|\lfloor|, etc. mais aussi le délimiteur nul |.| ; +\item le deuxième argument est le coin supérieur gauche de la sous-matrice avec +la syntaxe $i$|-|$j$ où $i$ est le numéro de rangée et $j$ le numéro de colonne +; +\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. +\end{itemize} + +On remarquera que la commande |\SubMatrix| trace les délimiteurs après la +construction de la matrice : aucun espace n'est inséré par la commande +|\SubMatrix|. C'est pourquoi, dans l'exemple suivant, on a utilisé la clé +|margin| et on a inséré à la main de l'espace entre la troisième et la quatrième +colonne avec |@{\hspace{1.5em}}| dans le préambule du tableau. + \medskip -Pour améliorer la lisibilité du code, une syntaxe alternative est proposée : on -peut spécifier les instructions du |code-after| à la fin de l'environnement, -après le mot-clé |\CodeAfter| (pour un exemple, voir page -\pageref{exemple-CodeAfter}). +\begin{scope} +\fvset{commandchars=\~\#\+}% +\begin{BVerbatim}[boxwidth=11cm,baseline=c] +\[\begin{NiceArray}{ccc~emphase#@{\hspace{1.5em}}+c}% + [cell-space-limits=2pt,~emphase#margin+] + 1 & 1 & 1 & x \\ +\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})+ +\end{NiceArray}\] +\end{BVerbatim} +\end{scope} +$\begin{NiceArray}{ccc@{\hspace{1.5em}}c}[cell-space-limits=2pt,margin] + 1 & 1 & 1 & x \\ +\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}) +\end{NiceArray}$ +\bigskip +Les options de la commande |\SubMatrix| sont les suivantes : +% +\begin{itemize} +\item |left-xshift| et |right-xshift| déplacent horizontalement les délimiteurs +(il existe aussi la clé |xshift| qui permet de régler simultanément ces deux +clés) ; +\item |extra-height| ajoute une quantité à la hauteur totale des délimiteurs +(hauteur~|\ht| + profondeur |\dp|) ; +\item |delimiters-color| permet de fixer la couleur des délimiteurs (cette clé +est également disponible dans |\NiceMatrixOptions| et au niveau des +environnements à délimiteurs ou comme option de |\CodeAfter|) ; +\item |slim| qui est une clé booléenne : lorsqu'elle est utilisée la position +horizontale des délimiteurs est calculée uniquement sur le contenu des cases +de la sous-matrice alors, que, dans le cas général, elle est calculée sur le +contenu des cases des colonnes mises en jeu (voir exemple ci-dessous). +\end{itemize} + +Ces clés sont aussi accessibles dans |\NiceMatrixOptions|, au niveau des +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. + +\bigskip +\begin{scope} +\fvset{commandchars=\~\#\!}% +\begin{BVerbatim}[baseline=c,boxwidth=11cm] +$\begin{NiceArray}{cc@{\hspace{5mm}}l}[cell-space-limits=2pt] + & & \frac12 \\ + & & \frac14 \\[1mm] +a & b & \frac12a+\frac14b \\ +c & d & \frac12c+\frac14d \\ +\CodeAfter +\SubMatrix({1-3}{2-3}) +\SubMatrix({3-1}{4-2}) +\SubMatrix({3-3}{4-3}) +\end{NiceArray}$ +\end{BVerbatim} +\end{scope} +$\begin{NiceArray}{cc@{\hspace{5mm}}l}% + [cell-space-limits=2pt] + & & \frac12 \\ + & & \frac14 \\[1mm] +a & b & \frac12a+\frac14b \\ +c & d & \frac12c+\frac14d \\ +\CodeAfter +\SubMatrix({1-3}{2-3}) +\SubMatrix({3-1}{4-2}) +\SubMatrix({3-3}{4-3}) +\end{NiceArray}$ + +\medskip +Voici le même exemple avec la clé |slim| pour l'une des sous-matrices. + +\medskip +\begin{scope} +\fvset{commandchars=\~\#\!}% +\begin{BVerbatim}[baseline=c,boxwidth=11cm] +$\begin{NiceArray}{cc@{\hspace{5mm}}l}% + [cell-space-limits=2pt] + & & \frac12 \\ + & & \frac14 \\[1mm] +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}) +\end{NiceArray}$ +\end{BVerbatim} +\end{scope} +% +$\begin{NiceArray}{cc@{\hspace{5mm}}l}[cell-space-limits=2pt] + & & \frac12 \\ + & & \frac14 \\[1mm] +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}) +\end{NiceArray}$ + + +\bigskip +Il existe aussi une clé |name| qui permet de donner un nom à une sous-matrice +créée par une commande |\SubMatrix|. Ce nom est utilisé pour créer des nœuds +PGF/Tikz : voir p.~\pageref{node-sub-matrix}. \section{Les notes dans les tableaux} @@ -2654,7 +2804,7 @@ Pour un exemple de personnalisation des notes de tableau, voir p.~\pageref{ex:no \subsection{Utilisation de \{NiceTabular\} avec threeparttable} -Si vous souhaitez utiliser l'environnement |{NiceTabular}| ou |{NiceTAbular*}| +Si vous souhaitez utiliser l'environnement |{NiceTabular}| ou |{NiceTabular*}| dans un environnement |{threeparttable}| de l'extension éponyme, vous devez patcher |{threeparttable}| avec le code suivant (avec une version de LaTeX postérieure à 2020/10/01). @@ -2836,7 +2986,7 @@ colonne courante\footnote{On rappelle que le numéro de la «première rangée» existe) est $0$ également.}. Bien entendu, l'utilisateur ne doit pas modifier les valeurs de ces compteurs qui sont utilisés en interne par \pkg{nicematrix}. -Dans le |code-before| (cf. p. \pageref{code-before}) et dans le |code-after| +Dans le |code-before| (cf. p. \pageref{code-before}) et dans le |\CodeAfter| (cf. p. \pageref{code-after}), |iRow| représente le nombre total de rangées (hors éventuelles rangées extérieures) et |jCol| le nombre total de colonnes (hors potentielles colonnes extérieures). @@ -3024,7 +3174,7 @@ sont accessibles à travers les noms «\textsl{nom}-$i$-$j$» où \textsl{nom} e le nom donné au tableau et $i$ et $j$ les numéros de rangée et de colonne de la case considérée. On peut les utiliser avec \textsc{pgf} mais l'utilisateur final préférera sans doute utiliser Tikz (qui est une sur-couche de \textsc{pgf}). Il -faut néanmoins se souvenir que \pkg{nicematrix} ne charge pas Tikz par défault. +faut néanmoins se souvenir que \pkg{nicematrix} ne charge pas Tikz par défaut. Dans les exemples qui suivent, on suppose que Tikz a été chargé par l'utilisateur. @@ -3051,7 +3201,7 @@ Ne pas oublier les options |remember picture| et |overlay|. \bigskip -Dans le |code-after|, et si Tikz est chargé, les choses sont plus simples. On +Dans le |\CodeAfter|, et si Tikz est chargé, les choses sont plus simples. On peut (et on doit) désigner les nœuds sous la forme $i$-$j$ : il n'y a pas à préciser l'environnement qui est évidemment l'environnement courant. @@ -3118,33 +3268,33 @@ seconds avec l'option |create-large-nodes|.\footnote{Il existe aussi l'option |create-medium-nodes| et |create-large-nodes|.} \medskip -Ces nœuds ne sont pas utilisés par défault par \pkg{nicematrix}. +Ces nœuds ne sont pas utilisés par défaut par \pkg{nicematrix}. \medskip Les noms des «nœuds moyens» s'obtiennent en ajoutant le suffixe «|-medium|» au nom des nœuds normaux. Dans l'exemple suivant, on a surligné tous les «nœuds moyens». Nous considérons que cet exemple se suffit à lui-même comme définition de ces nœuds. -\[\begin{pNiceMatrix}[ - create-medium-nodes, - code-after = {\begin{tikzpicture} - [every node/.style = {fill = red!15, - blend mode = multiply, - inner sep = 0 pt}, - name suffix = -medium] - \node [fit = (1-1)] {} ; - \node [fit = (1-2)] {} ; - \node [fit = (1-3)] {} ; - \node [fit = (2-1)] {} ; - \node [fit = (2-2)] {} ; - \node [fit = (2-3)] {} ; - \node [fit = (3-1)] {} ; - \node [fit = (3-2)] {} ; - \node [fit = (3-3)] {} ; - \end{tikzpicture}}] +\[\begin{pNiceMatrix}[create-medium-nodes] a & a + b & a + b + c \\ a & a & a + b \\ a & a & a +\CodeAfter +\begin{tikzpicture} + [every node/.style = {fill = red!15, + blend mode = multiply, + inner sep = 0 pt}, + name suffix = -medium] +\node [fit = (1-1)] {} ; +\node [fit = (1-2)] {} ; +\node [fit = (1-3)] {} ; +\node [fit = (2-1)] {} ; +\node [fit = (2-2)] {} ; +\node [fit = (2-3)] {} ; +\node [fit = (3-1)] {} ; +\node [fit = (3-2)] {} ; +\node [fit = (3-3)] {} ; +\end{tikzpicture} \end{pNiceMatrix}\] @@ -3156,25 +3306,25 @@ de ces nœuds.\footnote{Il n'y a pas de «nœuds larges» créés dans les rangà colonnes extérieures (pour ces rangées et colonnes, voir p.~\pageref{exterior}).} -\[\begin{pNiceMatrix}[ - create-large-nodes, - code-after = {\begin{tikzpicture} - [every node/.style = {blend mode = multiply, - inner sep = 0 pt}, - name suffix = -large] - \node [fit = (1-1),fill = red!15] {} ; - \node [fit = (1-3),fill = red!15] {} ; - \node [fit = (2-2),fill = red!15] {} ; - \node [fit = (3-1),fill = red!15] {} ; - \node [fit = (3-3),fill = red!15] {} ; - \node [fit = (1-2),fill = blue!15] {} ; - \node [fit = (2-1),fill = blue!15] {} ; - \node [fit = (2-3),fill = blue!15] {} ; - \node [fit = (3-2),fill = blue!15] {} ; - \end{tikzpicture}}] +\[\begin{pNiceMatrix}[create-large-nodes] a & a + b & a + b + c \\ a & a & a + b \\ a & a & a +\CodeAfter +\begin{tikzpicture} + [every node/.style = {blend mode = multiply, + inner sep = 0 pt}, + name suffix = -large] +\node [fit = (1-1),fill = red!15] {} ; +\node [fit = (1-3),fill = red!15] {} ; +\node [fit = (2-2),fill = red!15] {} ; +\node [fit = (3-1),fill = red!15] {} ; +\node [fit = (3-3),fill = red!15] {} ; +\node [fit = (1-2),fill = blue!15] {} ; +\node [fit = (2-1),fill = blue!15] {} ; +\node [fit = (2-3),fill = blue!15] {} ; +\node [fit = (3-2),fill = blue!15] {} ; +\end{tikzpicture} \end{pNiceMatrix}\] @@ -3189,25 +3339,25 @@ utilisé les options |left-margin| et |right-margin|.\footnote{Les options aucune valeur n'est donnée, c'est la valeur par défaut qui est utilisée et elle est égale à |\arraycolsep| (valeur initiale : 5~pt). Il existe aussi une option |margin| pour fixer à la fois |left-margin| et |right-margin|.} -\[\begin{pNiceMatrix}[ - create-large-nodes,left-margin,right-margin, - code-after = {\begin{tikzpicture} - [every node/.style = {blend mode = multiply, - inner sep = 0 pt}, - name suffix = -large] - \node [fit = (1-1),fill = red!15] {} ; - \node [fit = (1-3),fill = red!15] {} ; - \node [fit = (2-2),fill = red!15] {} ; - \node [fit = (3-1),fill = red!15] {} ; - \node [fit = (3-3),fill = red!15] {} ; - \node [fit = (1-2),fill = blue!15] {} ; - \node [fit = (2-1),fill = blue!15] {} ; - \node [fit = (2-3),fill = blue!15] {} ; - \node [fit = (3-2),fill = blue!15] {} ; - \end{tikzpicture}}] +\[\begin{pNiceMatrix}[create-large-nodes,left-margin,right-margin] a & a + b & a + b + c \\ a & a & a + b \\ a & a & a +\CodeAfter +\begin{tikzpicture} + [every node/.style = {blend mode = multiply, + inner sep = 0 pt}, + name suffix = -large] +\node [fit = (1-1),fill = red!15] {} ; +\node [fit = (1-3),fill = red!15] {} ; +\node [fit = (2-2),fill = red!15] {} ; +\node [fit = (3-1),fill = red!15] {} ; +\node [fit = (3-3),fill = red!15] {} ; +\node [fit = (1-2),fill = blue!15] {} ; +\node [fit = (2-1),fill = blue!15] {} ; +\node [fit = (2-3),fill = blue!15] {} ; +\node [fit = (3-2),fill = blue!15] {} ; +\end{tikzpicture} \end{pNiceMatrix}\] \medskip @@ -3215,25 +3365,26 @@ Il est aussi possible d'ajouter de l'espace sur les côtés du tableau avec les options |extra-left-margin| et |extra-right-margin|. Ces marges ne sont pas incorporées dans les «nœuds larges». Dans l'exemple suivant, nous avons utilisé |extra-left-margin| et |extra-right-margin| avec la valeur $3$~pt. -\[\begin{pNiceMatrix}[ - create-large-nodes,left-margin,right-margin,extra-right-margin=3pt,extra-left-margin=3pt, - code-after = {\begin{tikzpicture} - [every node/.style = {blend mode = multiply, - inner sep = 0 pt}, - name suffix = -large] - \node [fit = (1-1),fill = red!15] {} ; - \node [fit = (1-3),fill = red!15] {} ; - \node [fit = (2-2),fill = red!15] {} ; - \node [fit = (3-1),fill = red!15] {} ; - \node [fit = (3-3),fill = red!15] {} ; - \node [fit = (1-2),fill = blue!15] {} ; - \node [fit = (2-1),fill = blue!15] {} ; - \node [fit = (2-3),fill = blue!15] {} ; - \node [fit = (3-2),fill = blue!15] {} ; - \end{tikzpicture}}] +\[\begin{pNiceMatrix}% + [create-large-nodes,left-margin,right-margin,extra-right-margin=3pt,extra-left-margin=3pt] a & a + b & a + b + c \\ a & a & a + b \\ a & a & a +\CodeAfter +\begin{tikzpicture} + [every node/.style = {blend mode = multiply, + inner sep = 0 pt}, + name suffix = -large] +\node [fit = (1-1),fill = red!15] {} ; +\node [fit = (1-3),fill = red!15] {} ; +\node [fit = (2-2),fill = red!15] {} ; +\node [fit = (3-1),fill = red!15] {} ; +\node [fit = (3-3),fill = red!15] {} ; +\node [fit = (1-2),fill = blue!15] {} ; +\node [fit = (2-1),fill = blue!15] {} ; +\node [fit = (2-3),fill = blue!15] {} ; +\node [fit = (3-2),fill = blue!15] {} ; +\end{tikzpicture} \end{pNiceMatrix}\] @@ -3267,7 +3418,8 @@ noix & noisette & brugnon \vspace{1cm} \begin{minipage}[c]{7cm} -Ci-contre, on a colorié toutes les cases de ce tableau avec |\chessboardcolors|. +Ci-contre, on a colorié toutes les cases de ce tableau avec +|\chessboardcolors| (cf.~p.~\pageref{chessboardcolors}). \end{minipage} \hspace{1.5cm} \begin{scope} @@ -3288,25 +3440,25 @@ Voici maintenant tous les «nœuds larges» de ce tableau (sans utilisation de \hspace{1.5cm} \begin{scope} \large -\begin{NiceTabular}[c]{w{l}{2cm}ll}[hvlines, - create-large-nodes, - code-after = {\begin{tikzpicture} - [every node/.style = {blend mode = multiply, - inner sep = 0 pt}, - name suffix = -large] - \node [fit = (1-1),fill = red!15] {} ; - \node [fit = (1-3),fill = red!15] {} ; - \node [fit = (2-2),fill = red!15] {} ; - \node [fit = (3-1),fill = red!15] {} ; - \node [fit = (3-3),fill = red!15] {} ; - \node [fit = (1-2),fill = blue!15] {} ; - \node [fit = (2-1),fill = blue!15] {} ; - \node [fit = (2-3),fill = blue!15] {} ; - \node [fit = (3-2),fill = blue!15] {} ; - \end{tikzpicture}}] +\begin{NiceTabular}[c]{w{l}{2cm}ll}[hvlines,create-large-nodes] fraise & amande & abricot \\ prune & pêche & poire \\[1ex] noix & noisette & brugnon +\CodeAfter +\begin{tikzpicture} + [every node/.style = {blend mode = multiply, + inner sep = 0 pt}, + name suffix = -large] +\node [fit = (1-1),fill = red!15] {} ; +\node [fit = (1-3),fill = red!15] {} ; +\node [fit = (2-2),fill = red!15] {} ; +\node [fit = (3-1),fill = red!15] {} ; +\node [fit = (3-3),fill = red!15] {} ; +\node [fit = (1-2),fill = blue!15] {} ; +\node [fit = (2-1),fill = blue!15] {} ; +\node [fit = (2-3),fill = blue!15] {} ; +\node [fit = (3-2),fill = blue!15] {} ; +\end{tikzpicture} \end{NiceTabular} \end{scope} @@ -3317,7 +3469,7 @@ noix & noisette & brugnon L'extension \pkg{nicematrix} crée un nœud PGF-Tikz indiquant la position potentielle de chaque filet horizontal (avec les noms |row-|$i$) et de chaque filet vertical (avec les noms |col-|$j$), comme décrit sur la figure ci-dessous. -Ces nœuds sont accessibles dans le |code-before| et dans le |code-after|. +Ces nœuds sont accessibles dans le |code-before| et dans le |\CodeAfter|. \begin{center} \begin{NiceTabular}{ccc}[hvlines,rules/width=1pt,rules/color=gray] rose & tulipe & lys \\ @@ -3343,7 +3495,7 @@ muguet & dahlia & souci \bigskip Si on utilise Tikz (on rappelle que \pkg{nicematrix} ne charge pas Tikz par -défaut), on peut donc accéder (dans le |code-before| et le |code-after|) à +défaut), on peut donc accéder (dans le |code-before| et le |\CodeAfter|) à l'intersection du filet horizontal~$i$ et du filet vertical~$j$ avec la syntaxe |(row-|$i$\verb+-|col-+$j$|)|. @@ -3390,6 +3542,45 @@ l'intersection du filet horizontal~$i$ et du filet vertical~$j$ avec la syntaxe \end{NiceMatrix}\] +\subsection{Les nœuds correspondant aux commandes \textbackslash SubMatrix} + +\label{node-sub-matrix} + +La commande |\SubMatrix| disponible dans le |\CodeAfter| a été présentée +p.~\pageref{sub-matrix}. + +\smallskip +Si une commande |\SubMatrix| est utilisée avec la clé |name| sous la forme +|name=|\textsl{\ttfamily MonNom}, trois nœuds PGF/Tikz sont créés avec les noms +\textsl{\ttfamily MonNom}|-left|, \textsl{\ttfamily MonNom} et \textsl{\ttfamily + MonNom}|-right|. + +\smallskip +Les nœuds \textsl{\ttfamily MonNom}|-left| et \textsl{\ttfamily MonNom}|-right| correspondent aux +délimiteurs gauche et droit et le nœud \textsl{\ttfamily MonNom} correspond à la +sous-matrice elle-même. + +\medskip +Dans l'exemple suivant, on a surligné ces trois nœuds (la sous-matrice elle-même +a été créée avec |\SubMatrix\{{2-2}{3-3}\}|). +% +\[\begin{pNiceMatrix} +121 & 23 & 345 & 345\\ +45 & 346 & 863 & 444\\ +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} +\end{pNiceMatrix}\] + + \section{API pour les développeurs} L'extension \pkg{nicematrix} fournit deux variables internes mais publiques\footnote{Conformément aux conventions de LaTeX3, @@ -3550,7 +3741,7 @@ est sans effet. Par défaut, toutes les lignes diagonales\footnote{On parle des lignes créées par |\Ddots| et non des lignes créées par une commande |\line| dans le - |code-after|.} d'un même tableau sont «parallélisées». Cela signifie que la + |\CodeAfter|.} d'un même tableau sont «parallélisées». Cela signifie que la première diagonale est tracée et que, ensuite, les autres lignes sont tracées parallèlement à la première (par rotation autour de l'extrémité la plus à gauche de la ligne). C'est pourquoi la position des instructions |\Ddots| dans un @@ -3692,6 +3883,18 @@ environnements de l'extension \pkg{nicematrix} ne sont pas affectés). L'extension \pkg{nicematrix} n'est pas parfaitement compatible avec l'extension \pkg{arydshln} (parce que cette extension redéfinit de nombreuses commandes internes de \pkg{array}). +Pour pouvoir utiliser \pkg{arydshln}, il faut, de toutes manières, au préalable, +libérer la lettre «|:|» en choisissant une autre lettre pour les filets verticaux +pointillés de \pkg{nicematrix} : + +\begin{Verbatim} +\NiceMatrixOptions{letter-for-dotted-lines=;} +\end{Verbatim} + +\bigskip +L'extension \pkg{nicematrix} n'est pas compatible avec la classe \cls{aastex63}. +Si vous souhaitez utiliser \pkg{nicematrix} with \cls{aastex63}, envoyez-moi un +courrier électronique et j'essaierai de résoudre les incompatibilités. \section{Exemples} @@ -4087,7 +4290,7 @@ $\begin{pNiceArray}{cccc:c} Pour mettre en évidence une case d'une matrice, il est possible de «dessiner» cette case avec la clé |draw| de la commande |\Block| (c'est l'un des usages des blocs mono-case\footnote{On rappelle que si le premier argument obligatoire de -la commande |\Block| est laissé vide, le bloc est considéré comme mono-case}). +la commande |\Block| est laissé vide, le bloc est considéré comme mono-case.}). \label{exemple-CodeAfter} @@ -4284,21 +4487,20 @@ moyens» au lieu des «nœuds normaux». \medskip On obtient la matrice suivante. -\[\begin{pNiceArray}{ccc}[ - last-col, - create-medium-nodes, - code-after = {\begin{tikzpicture}[highlight/.style = {fill = red!15, - blend mode = multiply, - inner sep = 0pt, - fit = #1}, - name suffix = -medium] - \node [highlight = (1-1) (1-3)] {} ; - \node [highlight = (2-1) (2-3)] {} ; - \node [highlight = (3-1) (3-3)] {} ; - \end{tikzpicture}}] +\[\begin{pNiceArray}{ccc}[last-col,create-medium-nodes] a & a + b & a + b + c & L_1 \\ a & a & a + b & L_2 \\ -a & a & a & L_3 +a & a & a & L_3 \\ +\CodeAfter +\begin{tikzpicture}[highlight/.style = {fill = red!15, + blend mode = multiply, + inner sep = 0pt, + fit = #1}, + name suffix = -medium] +\node [highlight = (1-1) (1-3)] {} ; +\node [highlight = (2-1) (2-3)] {} ; +\node [highlight = (3-1) (3-3)] {} ; +\end{tikzpicture} \end{pNiceArray}\] diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf Binary files differindex 750e4fd6834..12843620c06 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 c6f1a06f31a..3b7f4d278ec 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.9} -\def\myfiledate{2021/01/08} +\def\myfileversion{5.10} +\def\myfiledate{2021/02/05} % % %<*batchfile> @@ -581,11 +581,11 @@ version 2005/12/01 or later. % \end{NiceTabular} % \end{center} % -% \colorbox{yellow!30}{New 5.7}\enskip 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|. +% 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} % @@ -666,7 +666,7 @@ version 2005/12/01 or later. % \begin{BVerbatim}[baseline=c,boxwidth=10cm] % \begin{NiceTabular}{cc} % \toprule -% Write & ~emphase#\Block[l]{}{year\\ of birth}@ \\ +% Writer & ~emphase#\Block[l]{}{year\\ of birth}@ \\ % \midrule % Hugo & 1802 \\ % Balzac & 1799 \\ @@ -675,7 +675,7 @@ version 2005/12/01 or later. % \end{BVerbatim} % \begin{NiceTabular}{cc} % \toprule -% Write & \Block[l]{}{year\\ of birth} \\ +% Writer & \Block[l]{}{year\\ of birth} \\ % \midrule % Hugo & 1802 \\ % Balzac & 1799 \\ @@ -1105,7 +1105,8 @@ version 2005/12/01 or later. % \bigskip % It's possible to change in \pkg{nicematrix} the letter used to specify a % vertical dotted line with the option |letter-for-dotted-lines| available in -% |\NiceMatrixOptions|. +% |\NiceMatrixOptions|. Thus released, the letter ``|:|'' can be used otherwise +% (for example by the package \pkg{arydshln}). % % \bigskip % \emph{Remark} : In the package \pkg{array} (on which the package @@ -1287,7 +1288,7 @@ version 2005/12/01 or later. % tow colors (provided in second and third argument), beginning % with the row whose number is given in first (mandatory) argument. % -% \colorbox{yellow!50}{\textbf{New 5.8}}\enskip In fact, the first (mandatory) +% \colorbox{yellow!30}{New 5.8}\enskip In fact, the first (mandatory) % argument is, more generally, a comma separated list of intervals describing % the rows involved in the action of |\rowcolors| (an interval of the form % $i$|-| describes in fact the interval of all the rows of the tabular, @@ -1300,10 +1301,10 @@ version 2005/12/01 or later. % optional argument in the first position corresponds to the colorimetric % space). The available keys are |cols|, |restart| and |respect-blocks|. % \begin{itemize} -% \item \colorbox{yellow!50}{\textbf{New 5.8}}\enskip The key |cols| describes a +% \item \colorbox{yellow!30}{New 5.8}\enskip The key |cols| describes a % set of columns. The command |\rowcolors| will color only the cells of these % columns. The value is a comma-separated list of intervals of the form $i$-$j$. -% \item \colorbox{yellow!50}{\textbf{New 5.8}}\enskip With the key |restart|, +% \item \colorbox{yellow!30}{New 5.8}\enskip With the key |restart|, % each interval of rows (specified by the first mandatory argument) begins with % the same color.\footnote{Otherwise, the color of a given row relies only upon the % parity of its number.} @@ -2126,7 +2127,7 @@ version 2005/12/01 or later. % \subsection{The labels of the dotted lines} % % The commands |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, |\Iddots| and |\Hdotsfor| -% (and the command |\line| in the |code-after| which is described +% (and the command |\line| in the |\CodeAfter| which is described % p.~\pageref{line-in-code-after}) accept two optional arguments specified % by the tokens |_| and |^| for labels positionned below and above the line. The % arguments are composed in math mode with |\scriptstyle|. @@ -2148,7 +2149,7 @@ version 2005/12/01 or later. % % \label{customization} % The dotted lines drawn by |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, |\Iddots| -% and |\Hdotsfor| (and by the command |\line| in the |code-after| which is described +% and |\Hdotsfor| (and by the command |\line| in the |\CodeAfter| which is described % p.~\pageref{line-in-code-after}) may be customized by three options (specified % between square brackets after the command): % \begin{itemize} @@ -2269,47 +2270,189 @@ version 2005/12/01 or later. % % % -% \section{The code-after} +% \section{The \textbackslash CodeAfter} % % \label{code-after} % The option |code-after| may be used to give some code that will be executed % after the construction of the matrix.\footnote{There is also a key % |code-before| described p.~\pageref{code-before}.} % -% A special command, called |\line|, is available to draw directly -% dotted lines between nodes. It takes two arguments for the two cells to rely, -% both of the form $i$-$j$ where is the number of row and $j$ is the number of -% column. It may be used, for example, to draw a dotted line -% between two adjacent cells. \label{line-in-code-after} +% \medskip +% For the legibility of the code, an alternative syntax is provided: it's +% possible to give the instructions of the |\code-after| at the end of the +% environment, after the keyword |\CodeAfter|. +% +% \medskip +% Two special commands are available in the |\CodeAfter|: |line| and +% |\SubMatrix|. +% +% \subsection{The command \textbackslash line in the \textbackslash CodeAfter} +% +% The command |\line|draws directly dotted lines between nodes. It takes two +% arguments for the two cells to rely, both of the form $i$-$j$ where is the +% number of row and $j$ is the number of column. It may be used, for example, to +% draw a dotted line between two adjacent cells. \label{line-in-code-after} % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=11cm] % \NiceMatrixOptions{xdots/shorten = 0.6 em} -% \begin{pNiceMatrix}[~emphase#code-after=\line{2-2}{3-3}@] +% \begin{pNiceMatrix} % I & 0 & \Cdots &0 \\ % 0 & I & \Ddots &\Vdots\\ % \Vdots &\Ddots & I &0 \\ % 0 &\Cdots & 0 &I +% ~emphase#\CodeAfter \line{2-2}{3-3}@ % \end{pNiceMatrix} % \end{BVerbatim} % \begin{scope} % \NiceMatrixOptions{xdots/shorten = 0.6 em} -% $\begin{pNiceMatrix}[code-after=\line{2-2}{3-3}] +% $\begin{pNiceMatrix} % I & 0 & \Cdots &0 \\ % 0 & I & \Ddots &\Vdots\\ % \Vdots &\Ddots & I &0 \\ % 0 &\Cdots & 0 &I +% \CodeAfter \line{2-2}{3-3} % \end{pNiceMatrix}$ % \end{scope} % +% +% \subsection{The command \textbackslash SubMatrix in the \textbackslash CodeAfter} +% +% \label{sub-matrix} +% +% \colorbox{yellow!50}{\textbf{New 5.10}}\enskip +% The command |\SubMatrix| provides a way to put delimiters on an portion +% of the array considered as a submatrix. The command |\SubMatrix| takes in five +% arguments: +% \begin{itemize} +% \item the first argument is the left delimiter, which may be any extensible delimiter +% provided by LaTeX : |(|, |[|, |\{|, |\langle|, |\lgroup|, |\lfloor|, etc. but also +% the null delimiter |.|; +% \item the second argument is the upper-left corner of the submatrix with the +% 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. +% \end{itemize} +% +% One should remark that the command |\SubMatrix| draws the delimiters after the +% construction of the array: no space is inserted by the command |\SubMatrix| +% itself. That's why, in the following example, we have used the key |margin| +% and you have added by hand some space between the third and fourth column with +% |@{\hspace{1.5em}}| in the preamble of the array. +% % \medskip -% For the legibility of the code, an alternative syntax is provided: it's -% possible to give the instructions of the |\code-after| at the end of the -% environment, after the keyword |\CodeAfter| (for an example, cf. -% p.~\pageref{example-CodeAfter}). +% \begin{scope} +% \fvset{commandchars=\~\#\+}% +% \begin{BVerbatim}[boxwidth=11cm,baseline=c] +% \[\begin{NiceArray}{ccc~emphase#@{\hspace{1.5em}}+c}% +% [cell-space-limits=2pt,~emphase#margin+] +% 1 & 1 & 1 & x \\ +% \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})+ +% \end{NiceArray}\] +% \end{BVerbatim} +% \end{scope} +% $\begin{NiceArray}{ccc@{\hspace{1.5em}}c}[cell-space-limits=2pt,margin] +% 1 & 1 & 1 & x \\ +% \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}) +% \end{NiceArray}$ % +% \bigskip +% The options of the command |\SubMatrix| are as follows: +% \begin{itemize} +% \item |left-xshift| and |right-shift| shift horizontally the delimiters (there +% exists also the key |xshift| which fixes both parameters); +% \item |extra-height| adds a quantity to the total height of the delimiters +% (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|); +% \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 +% taking into account the cells of the whole columns implied in the submatrix +% (see example below). +% \end{itemize} % +% These keys are also available in |\NiceMatrixOptions|, at the level of the +% environments of \pkg{nicematrix} or as option of the command |\CodeAfter| with +% the prefix |sub-matrix| which means that their names are therefore +% |sub-matrix/left-xshift|, |sub-matrix/right-xshift|, |sub-matrix/xshift|, etc. +% % +% \bigskip +% \begin{scope} +% \fvset{commandchars=\~\#\!}% +% \begin{BVerbatim}[baseline=c,boxwidth=11cm] +% $\begin{NiceArray}{cc@{\hspace{5mm}}l}% +% [cell-space-limits=2pt] +% & & \frac12 \\ +% & & \frac14 \\[1mm] +% a & b & \frac12a+\frac14b \\ +% c & d & \frac12c+\frac14d \\ +% \CodeAfter +% \SubMatrix({1-3}{2-3}) +% \SubMatrix({3-1}{4-2}) +% \SubMatrix({3-3}{4-3}) +% \end{NiceArray}$ +% \end{BVerbatim} +% \end{scope} +% $\begin{NiceArray}{cc@{\hspace{5mm}}l}[cell-space-limits=2pt] +% & & \frac12 \\ +% & & \frac14 \\[1mm] +% a & b & \frac12a+\frac14b \\ +% c & d & \frac12c+\frac14d \\ +% \CodeAfter +% \SubMatrix({1-3}{2-3}) +% \SubMatrix({3-1}{4-2}) +% \SubMatrix({3-3}{4-3}) +% \end{NiceArray}$ +% +% \medskip +% Here is the same example with the key |slim| used for one of the submatrices. +% +% \medskip +% \begin{scope} +% \fvset{commandchars=\~\#\!}% +% \begin{BVerbatim}[baseline=c,boxwidth=11cm] +% $\begin{NiceArray}{cc@{\hspace{5mm}}l}% +% [cell-space-limits=2pt] +% & & \frac12 \\ +% & & \frac14 \\[1mm] +% 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}) +% \end{NiceArray}$ +% \end{BVerbatim} +% \end{scope} +% $\begin{NiceArray}{cc@{\hspace{5mm}}l}[cell-space-limits=2pt] +% & & \frac12 \\ +% & & \frac14 \\[1mm] +% 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}) +% \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/Tiks nodes: cf +% p.~\pageref{node-sub-matrix}. +% % \section{The notes in the tabulars} % % \label{s:notes} @@ -2812,7 +2955,7 @@ version 2005/12/01 or later. % exists) has also the number~$0$.}. Of course, the user must not change the % value of these counters which are used internally by \pkg{nicematrix}. % -% In the |code-before| (cf. p. \pageref{code-before}) and in the |code-after| +% In the |code-before| (cf. p. \pageref{code-before}) and in the |\CodeAfter| % (cf. p. \pageref{code-after}), |iRow| represents the total number of rows % (excepted the potential exterior rows) and |jCol| represents the total number % of columns (excepted the potential exterior columns). @@ -3019,7 +3162,7 @@ version 2005/12/01 or later. % Don't forget the options |remember picture| and |overlay|. % % \bigskip -% In the |code-after|, the things are easier : one must refer to the nodes with +% In the |\CodeAfter|, the things are easier : one must refer to the nodes with % the form $i$-$j$ (we don't have to indicate the environment which is of % course the current environment). % @@ -3281,7 +3424,7 @@ version 2005/12/01 or later. % The package \pkg{nicematrix} creates a PGF/Tikz node indicating the potential % position of each horizontal rule (with the names |row-|$i$) and each vertical % rule (with the names |col-|$j$), as described in the following figure. These -% nodes are available in the |code-before| and the |code-after|. +% nodes are available in the |code-before| and the |\CodeAfter|. % \begin{center} % \begin{NiceTabular}{ccc}[hvlines,rules/width=1pt,rules/color=gray] % rose & tulipe & lys \\ @@ -3306,7 +3449,7 @@ version 2005/12/01 or later. % % \bigskip % If we use Tikz (we remind that \pkg{nicematrix} does not load Tikz by -% default), we can access (in the |code-before| and the |code-after|) to the +% default), we can access (in the |code-before| and the |\CodeAfter|) to the % intersection of the horizontal rule~$i$ and the vertical rule~$j$ with the % syntax |(row-|$i$\verb+-|col-+$j$|)|. % @@ -3350,6 +3493,44 @@ version 2005/12/01 or later. % 1 & 8 & 28 & 56 & 70 & 56 & 28 & 8 & 1 % \end{NiceMatrix}\] % +% \subsection{The nodes corresponding to the command \textbackslash SubMatrix} +% +% \label{node-sub-matrix} +% +% The command |\SubMatrix| available in the |\CodeAfter| has been described +% p.~\pageref{sub-matrix}. +% +% \smallskip +% If a command |\SubMatrix| has been used with the key |name| with an expression +% such as |name=|\textsl{\ttfamily MyName} three PGF/Tikz nodes are created +% with the names \textsl{\ttfamily MyName}|-left|, \textsl{\ttfamily MyName} and +% \textsl{\ttfamily MyName}|-right|. +% +% \smallskip +% The nodes \textsl{\ttfamily MyName}|-left| and \textsl{\ttfamily +% MyName}|-right| correspond to the delimiters left and right and the node +% \textsl{\ttfamily MyName} correspond to the submatrix itself. +% +% \medskip +% In the following example, we have highlighted these nodes (the submatrix itself has +% been created with |\SubMatrix\{{2-2}{3-3}\}|). +% +% \[\begin{pNiceMatrix} +% 121 & 23 & 345 & 345\\ +% 45 & 346 & 863 & 444\\ +% 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} +% \end{pNiceMatrix}\] +% % \section{API for the developpers} % % The package \pkg{nicematrix} provides two variables which are internal but @@ -3643,6 +3824,17 @@ version 2005/12/01 or later. % The package \pkg{nicematrix} is not fully compatible with the package % \pkg{arydshln} (because this package redefines many internal of \pkg{array}). % +% Anyway, in order to use \pkg{arydshln}, one must first free the letter ``|:|'' +% by giving a new letter for the vertical dotted rules of \pkg{nicematrix}: +% +% \begin{Verbatim} +% \NiceMatrixOptions{letter-for-dotted-lines=;} +% \end{Verbatim} +% +% \bigskip +% As of now, the package \pkg{nicematrix} is not compatible with +% \cls{aastex63}. If you want to use \pkg{nicematrix} with \cls{aastex63}, send +% me an email and I will try to solve the incompatibilies. % % \section{Examples} % @@ -4459,7 +4651,6 @@ version 2005/12/01 or later. % \begin{macrocode} \RequirePackage { array } \RequirePackage { amsmath } -\RequirePackage { xparse } % \end{macrocode} % % \bigskip @@ -4482,6 +4673,8 @@ version 2005/12/01 or later. % \bigskip % \subsection*{Technical definitions} % +% +% \medskip % \begin{macrocode} \bool_new:N \c_@@_in_preamble_bool \bool_set_true:N \c_@@_in_preamble_bool @@ -4489,11 +4682,15 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} +\bool_new:N \c_@@_arydshln_loaded_bool \bool_new:N \c_@@_booktabs_loaded_bool \bool_new:N \c_@@_enumitem_loaded_bool \bool_new:N \c_@@_tikz_loaded_bool \AtBeginDocument { + \@ifpackageloaded { arydshln } + { \bool_set_true:N \c_@@_arydshln_loaded_bool } + { } \@ifpackageloaded { booktabs } { \bool_set_true:N \c_@@_booktabs_loaded_bool } { } @@ -4526,9 +4723,11 @@ version 2005/12/01 or later. } % \end{macrocode} % -% We test whether the current class is \cls{revtex4-1} or \cls{revtex4-2} -% because these classes redefines |\array| (of \pkg{array}) in a way -% incompatible with our programmation. +% We test whether the current class is \cls{revtex4-1} (deprecated) or +% \cls{revtex4-2} because these classes redefines |\array| (of \pkg{array}) in a +% way incompatible with our programmation. As of january 2021, the current +% version \cls{revtex4-2} is 4.2e (compatible with \pkg{booktabs}). +% % \begin{macrocode} \bool_new:N \c_@@_revtex_bool \@ifclassloaded { revtex4-1 } @@ -4538,8 +4737,17 @@ version 2005/12/01 or later. { \bool_set_true:N \c_@@_revtex_bool } { } % \end{macrocode} +% Maybe one of the previous classes will be loaded inside another class... We +% try to detect that situation. +% \begin{macrocode} +\cs_if_exist:NT \rvtx@ifformat@geq { \bool_set_true:N \c_@@_revtex_bool } +% \end{macrocode} % % +% \begin{macrocode} +\cs_generate_variant:Nn \tl_if_single_token_p:n { V } +% \end{macrocode} +% % \bigskip % We define a command |\iddots| similar to |\ddots| ($\ddots$) but with dots % going forward ($\iddots$). We use |\ProvideDocumentCommand| and so, if the @@ -5185,8 +5393,8 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% \pkg{expl3} provides scratch dimension |\l_tmpa_dim| and |\l_tmpd_dim|. We -% creates two other in the same spirit (if they don't exist yet : that's why we +% \pkg{expl3} provides scratch dimensions |\l_tmpa_dim| and |\l_tmpb_dim|. We +% creates two other in the same spirit (if they don't exist yet: that's why we % use |\dim_zero_new:N|). % \begin{macrocode} \dim_zero_new:N \l_tmpc_dim @@ -5195,7 +5403,7 @@ version 2005/12/01 or later. % % \bigskip % Some cells will be declared as ``empty'' (for example a cell with an -% instrution |\Cdots|). +% instruction |\Cdots|). % \begin{macrocode} \bool_new:N \g_@@_empty_cell_bool % \end{macrocode} @@ -5263,6 +5471,14 @@ version 2005/12/01 or later. % % % \medskip +% The list of the names of the potential |\SubMatrix| in the |code-after| of an +% environment. Unfortunately, that list has to be global (we have to use it +% inside the group for the options of a given |\SubMatrix|). +% \begin{macrocode} +\seq_new:N \g_@@_submatrix_names_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). @@ -5702,8 +5918,10 @@ version 2005/12/01 or later. % initial value is 0.45~em but it will be changed if the option |small| is used. % \begin{macrocode} \dim_new:N \l_@@_inter_dots_dim -\dim_set:Nn \l_@@_inter_dots_dim { 0.45 em } +\AtBeginDocument { \dim_set:Nn \l_@@_inter_dots_dim { 0.45 em } } % \end{macrocode} +% The |\AtBeginDocument| is only a security in case \cls{revtex4-1} is used +% (even though it is obsolete). % % \bigskip % The following dimension is the minimal distance between a node (in fact an @@ -5712,8 +5930,10 @@ version 2005/12/01 or later. % distance may vary a little). % \begin{macrocode} \dim_new:N \l_@@_xdots_shorten_dim -\dim_set:Nn \l_@@_xdots_shorten_dim { 0.3 em } +\AtBeginDocument { \dim_set:Nn \l_@@_xdots_shorten_dim { 0.3 em } } % \end{macrocode} +% The |\AtBeginDocument| is only a security in case \cls{revtex4-1} is used +% (even though it is obsolete). % % \bigskip % The following dimension is the radius of the dots for the dotted lines (when @@ -5721,8 +5941,11 @@ version 2005/12/01 or later. % value is 0.53~pt but it will be changed if the option |small| is used. % \begin{macrocode} \dim_new:N \l_@@_radius_dim -\dim_set:Nn \l_@@_radius_dim { 0.53 pt } +\AtBeginDocument { \dim_set:Nn \l_@@_radius_dim { 0.53 pt } } % \end{macrocode} +% The |\AtBeginDocument| is only a security in case \cls{revtex4-1} is used +% (even if it is obsolete). +% % % \bigskip % The token list |\l_@@_xdots_line_style_tl| corresponds to the option |tikz| of the @@ -5795,8 +6018,10 @@ version 2005/12/01 or later. % % \begin{macrocode} \dim_new:N \l_@@_notes_above_space_dim -\dim_set:Nn \l_@@_notes_above_space_dim { 1 mm } +\AtBeginDocument { \dim_set:Nn \l_@@_notes_above_space_dim { 1 mm } } % \end{macrocode} +% The |\AtBeginDocument| is only a security in case \cls{revtex4-1} is used +% (even if it is obsolete). % % \bigskip % The flag |\l_@@_nullify_dots_bool| corresponds to the option |nullify-dots|. @@ -5955,10 +6180,10 @@ version 2005/12/01 or later. cell-space-top-limit .value_required:n = true , cell-space-bottom-limit .dim_set:N = \l_@@_cell_space_bottom_limit_dim , cell-space-bottom-limit .value_required:n = true , - cell-space-limits .code:n = + cell-space-limits .meta:n = { - \dim_set:Nn \l_@@_cell_space_bottom_limit_dim { #1 } - \dim_set:Nn \l_@@_cell_space_top_limit_dim { #1 } + cell-space-top-limit = #1 , + cell-space-bottom-limit = #1 , } , cell-spaces-limits .value_required:n = true , xdots .code:n = \keys_set:nn { NiceMatrix / xdots } { #1 } , @@ -6143,6 +6368,8 @@ version 2005/12/01 or later. NiceMatrixOptions / xdots .inherit:n = NiceMatrix / xdots , NiceMatrixOptions / rules .inherit:n = NiceMatrix / rules , NiceMatrixOptions / notes .inherit:n = NiceMatrix / notes , + NiceMatrixOptions / sub-matrix .inherit:n = NiceMatrix / sub-matrix , + CodeAfter / xdots .inherit:n = NiceMatrix / xdots , NiceMatrix .inherit:n = { NiceMatrix / Global , @@ -6200,7 +6427,12 @@ version 2005/12/01 or later. % \end{macrocode} % The key |transparent| is now considered as obsolete (because its name is ambiguous). % \begin{macrocode} - transparent .meta:n = { renew-dots , renew-matrix } , + transparent .code:n = + { + \@@_renew_matrix: + \bool_set_true:N \l_@@_renew_dots_bool + \@@_error:n { Key~transparent } + } , transparent .value_forbidden:n = true, % \end{macrocode} % @@ -6251,6 +6483,9 @@ version 2005/12/01 or later. letter-for-dotted-lines .value_required:n = true , notes .code:n = \keys_set:nn { NiceMatrix / notes } { #1 } , notes .value_required:n = true , + sub-matrix .code:n = + \keys_set:nn { NiceMatrix / sub-matrix } { #1 } , + sub-matrix .value_required:n = true , unknown .code:n = \@@_error:n { Unknown~key~for~NiceMatrixOptions } } % \end{macrocode} @@ -6953,11 +7188,11 @@ version 2005/12/01 or later. % |\Cdots|, etc. give the same spacing (except when the option |nullify-dots| is % used). % \begin{macrocode} - \cs_set_eq:NN \@@_old_ldots \ldots - \cs_set_eq:NN \@@_old_cdots \cdots - \cs_set_eq:NN \@@_old_vdots \vdots - \cs_set_eq:NN \@@_old_ddots \ddots - \cs_set_eq:NN \@@_old_iddots \iddots + \cs_set_eq:NN \@@_old_ldots \ldots + \cs_set_eq:NN \@@_old_cdots \cdots + \cs_set_eq:NN \@@_old_vdots \vdots + \cs_set_eq:NN \@@_old_ddots \ddots + \cs_set_eq:NN \@@_old_iddots \iddots \bool_if:NTF \l_@@_standard_cline_bool { \cs_set_eq:NN \cline \@@_standard_cline } { \cs_set_eq:NN \cline \@@_cline } @@ -7065,8 +7300,19 @@ version 2005/12/01 or later. % 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 @@ -7321,7 +7567,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \medskip -% We compute the width of the two delimiters. +% We compute the width of both delimiters. % \begin{macrocode} \dim_zero_new:N \l_@@_left_delim_dim \dim_zero_new:N \l_@@_right_delim_dim @@ -7334,9 +7580,9 @@ version 2005/12/01 or later. % \end{macrocode} % The command |\bBigg@| is a command of \pkg{amsmath}. % \begin{macrocode} - \hbox_set:Nn \l_tmpa_box { $ \bBigg@ 5 #1 $ } + \hbox_set:Nn \l_tmpa_box { $ \bBigg@ 5 \l_@@_left_delim_tl $ } \dim_set:Nn \l_@@_left_delim_dim { \box_wd:N \l_tmpa_box } - \hbox_set:Nn \l_tmpa_box { $ \bBigg@ 5 #2 $ } + \hbox_set:Nn \l_tmpa_box { $ \bBigg@ 5 \l_@@_right_delim_tl $ } \dim_set:Nn \l_@@_right_delim_dim { \box_wd:N \l_tmpa_box } } % \end{macrocode} @@ -7360,7 +7606,7 @@ version 2005/12/01 or later. % \bigskip % The preamble will be constructed in |\g_@@_preamble_tl|. % \begin{macrocode} - \@@_construct_preamble:n { #4 } + \@@_construct_preamble: % \end{macrocode} % % Now, the preamble is constructed in |\g_@@_preamble_tl| @@ -7505,7 +7751,7 @@ version 2005/12/01 or later. \c_math_toggle_token \tl_if_empty:NF \l_@@_delimiters_color_tl { \color { \l_@@_delimiters_color_tl } } - \left #1 + \exp_after:wN \left \l_@@_left_delim_tl \vcenter { % \end{macrocode} @@ -7513,7 +7759,6 @@ version 2005/12/01 or later. % height in |\l_tmpa_dim|). The |\hbox:n| (or |\hbox|) is necessary here. % \begin{macrocode} \skip_vertical:N -\l_tmpa_dim - \skip_vertical:N -\arrayrulewidth \hbox { \bool_if:NTF \l_@@_NiceTabular_bool @@ -7529,9 +7774,8 @@ version 2005/12/01 or later. % height in |\l_tmpb_dim|). % \begin{macrocode} \skip_vertical:N -\l_tmpb_dim - \skip_vertical:N \arrayrulewidth } - \right #2 + \exp_after:wN \right \l_@@_right_delim_tl \c_math_toggle_token } % \end{macrocode} @@ -7583,12 +7827,11 @@ version 2005/12/01 or later. % The transformation of the preamble is an operation in several steps. % % \bigskip -% The argument of |\@@_construct_preamble:n| is the preamble as given by the -% final user to the environement |{NiceTabular}| (or a variant). The preamble -% will be constructed in |\g_@@_preamble_tl|. -% +% The preamble given by the final use is in |\g_@@_preamble_tl| and the modified +% version will be stored in |\g_@@_preamble_tl| also. +% % \begin{macrocode} -\cs_new_protected:Npn \@@_construct_preamble:n #1 +\cs_new_protected:Npn \@@_construct_preamble: { % \end{macrocode} % First, we will do an ``expansion'' of the preamble with the tools of the @@ -7616,8 +7859,7 @@ version 2005/12/01 or later. % (excepted the treatment on both sides of the preamble which will be done at % the end). % \begin{macrocode} - \bool_if:NTF \l_@@_Matrix_bool - { \tl_gset:Nn \g_@@_preamble_tl { #1 } } + \bool_if:NF \l_@@_Matrix_bool { \@@_newcolumntype w [ 2 ] { \@@_w: { ##1 } { ##2 } } \@@_newcolumntype W [ 2 ] { \@@_W: { ##1 } { ##2 } } @@ -7626,7 +7868,7 @@ version 2005/12/01 or later. % First, we have to store our preamble in the token register |\@temptokena| % (those ``token registers'' are not supported by \pkg{expl3}). % \begin{macrocode} - \@temptokena { #1 } + \exp_args:NV \@temptokena \g_@@_preamble_tl % \end{macrocode} % Initialisation of a flag used by \pkg{array} to detect the end of the expansion. % \begin{macrocode} @@ -7638,6 +7880,7 @@ version 2005/12/01 or later. \@whilesw \if@tempswa \fi { \@tempswafalse \the \NC@list } % \end{macrocode} % +% % \bigskip % Now, we have to ``patch'' that preamble by transforming some columns. % We will insert in the TeX flow the preamble in its actual form (that is to say @@ -7656,7 +7899,7 @@ version 2005/12/01 or later. { \tl_gclear:N \g_@@_preamble_tl } % \end{macrocode} % The counter |\l_tmpa_int| will count the number of consecutive occurrences -% of the symbole \verb+|+. +% of the symbol \verb+|+. % \begin{macrocode} \int_zero:N \l_tmpa_int % \end{macrocode} @@ -7747,15 +7990,30 @@ version 2005/12/01 or later. \@@_w: { \@@_patch_preamble_v:nnnn { } #1 } \@@_W: { \@@_patch_preamble_v:nnnn { \cs_set_eq:NN \hss \hfil } #1 } \@@_true_c: { \@@_patch_preamble_vi:n #1 } - C { \@@_error:nn { old~column~type } C } - L { \@@_error:nn { old~column~type } L } - R { \@@_error:nn { old~column~type } R } + ( { \@@_patch_preamble_vii:n #1 } + [ { \@@_patch_preamble_vii:n #1 } + \{ { \@@_patch_preamble_vii:n #1 } + ) { \@@_patch_preamble_viii:n #1 } + ] { \@@_patch_preamble_viii:n #1 } + \} { \@@_patch_preamble_viii:n #1 } + C { \@@_error:nn { old~column~type } #1 } + L { \@@_error:nn { old~column~type } #1 } + R { \@@_error:nn { old~column~type } #1 } \q_stop { } } { \str_if_eq:VnTF \l_@@_letter_for_dotted_lines_str { #1 } - { \@@_patch_preamble_vii:n #1 } - { \@@_fatal:nn { unknown~column~type } { #1 } } + { \@@_patch_preamble_xi:n #1 } + { + \bool_lazy_and:nnTF + { \str_if_eq_p:nn { : } { #1 } } + \c_@@_arydshln_loaded_bool + { + \tl_gput_right:Nn \g_@@_preamble_tl { : } + \@@_patch_preamble:n + } + { \@@_fatal:nn { unknown~column~type } { #1 } } + } } } % \end{macrocode} @@ -7772,14 +8030,13 @@ version 2005/12/01 or later. < \@@_end_Cell: } % \end{macrocode} -% We increment the counter of columns. +% +% We increment the counter of columns and then we test for the presence of a |<|. % \begin{macrocode} \int_gincr:N \c@jCol - \@@_patch_preamble_viii:n + \@@_patch_preamble_x:n } % \end{macrocode} -% -% % % \medskip % For |>|, |!| and |@| @@ -7852,10 +8109,10 @@ version 2005/12/01 or later. < { \box_use:N \@arstrutbox \end { minipage } \@@_end_Cell: } } % \end{macrocode} -% We increment the counter of columns. +% We increment the counter of columns, and then we test for the presence of a |<|. % \begin{macrocode} \int_gincr:N \c@jCol - \@@_patch_preamble_viii:n + \@@_patch_preamble_x:n } % \end{macrocode} % @@ -7882,10 +8139,10 @@ version 2005/12/01 or later. } } % \end{macrocode} -% We increment the counter of columns. +% We increment the counter of columns and then we test for the presence of a |<|. % \begin{macrocode} \int_gincr:N \c@jCol - \@@_patch_preamble_viii:n + \@@_patch_preamble_x:n } % \end{macrocode} % @@ -7897,15 +8154,67 @@ version 2005/12/01 or later. { \tl_gput_right:Nn \g_@@_preamble_tl { c } % \end{macrocode} -% We increment the counter of columns. +% We increment the counter of columns and then we test for the presence of a |<|. % \begin{macrocode} \int_gincr:N \c@jCol - \@@_patch_preamble_viii:n + \@@_patch_preamble_x:n + } +% \end{macrocode} +% +% \medskip +% For |(|, |[| and |\{|. +% \begin{macrocode} +\cs_new_protected:Npn \@@_patch_preamble_vii:n #1 + { + \bool_if:NT \l_@@_small_bool + { \@@_fatal:n { Delimiter~with~small } } +% \end{macrocode} +% If we are before the column 1, we reserve space for the left delimiter. +% \begin{macrocode} + \int_compare:nNnT \c@jCol = \c_zero_int + { \tl_gput_right:Nx \g_@@_preamble_tl { ! { \enskip } } } + \tl_gput_right:Nx \g_@@_internal_code_after_tl + { \@@_delimiter:nnn #1 { \@@_succ:n \c@jCol } \c_true_bool } + \@@_patch_preamble:n + } +% \end{macrocode} +% +% \bigskip +% For |)|, |]| and |\}|. +% \begin{macrocode} +\cs_new_protected:Npn \@@_patch_preamble_viii:n #1 + { + \bool_if:NT \l_@@_small_bool + { \@@_fatal:n { Delimiter~with~small } } + \tl_gput_right:Nx \g_@@_internal_code_after_tl + { \@@_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool } +% \end{macrocode} +% After this closing delimiter, we have to test whether there is a opening +% delimiter (we consider that there can't be a second closing delimiter) in +% order to add an horizontal space (equal to 0.5 em). +% \begin{macrocode} + \@@_patch_preamble_viii_i:n + } +% \end{macrocode} +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_patch_preamble_viii_i:n #1 + { + \bool_lazy_any:nT + { + { \str_if_eq_p:nn { #1 } ( } + { \str_if_eq_p:nn { #1 } [ } + { \str_if_eq_p:nn { #1 } \{ } + { \str_if_eq_p:nn { #1 } \q_stop } + } + { \tl_gput_right:Nn \g_@@_preamble_tl { ! { \enskip } } } + \@@_patch_preamble:n #1 } % \end{macrocode} % +% % \begin{macrocode} -\cs_new_protected:Npn \@@_patch_preamble_vii:n #1 +\cs_new_protected:Npn \@@_patch_preamble_xi:n #1 { \tl_gput_right:Nn \g_@@_preamble_tl { ! { \skip_horizontal:N 2\l_@@_radius_dim } } @@ -7923,7 +8232,7 @@ version 2005/12/01 or later. % |<{..}| because, after those potential |<{...}|, we have to insert % |!{\skip_horizontal:N ...}| when the key |vlines| is used. % \begin{macrocode} -\cs_new_protected:Npn \@@_patch_preamble_viii:n #1 +\cs_new_protected:Npn \@@_patch_preamble_x:n #1 { \str_if_eq:nnTF { #1 } { < } \@@_patch_preamble_ix:n @@ -7942,10 +8251,11 @@ version 2005/12/01 or later. \cs_new_protected:Npn \@@_patch_preamble_ix:n #1 { \tl_gput_right:Nn \g_@@_preamble_tl { < { #1 } } - \@@_patch_preamble_viii:n + \@@_patch_preamble_x:n } % \end{macrocode} % +% % % \bigskip % The command |\@@_put_box_in_flow:| puts the box |\l_tmpa_box| (which contains @@ -8105,7 +8415,7 @@ version 2005/12/01 or later. % \begin{macrocode} { \CT@arc@ \hrule height \heavyrulewidth } } - { \@@_error:n { bottomule~without~booktabs } } + { \@@_error:n { bottomrule~without~booktabs } } } \l_@@_notes_code_after_tl \seq_gclear:N \g_@@_tabularnotes_seq @@ -8315,7 +8625,7 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Npn \@@_light_syntax_i #1\CodeAfter #2\q_stop { - \tl_gput_right:Nn \g_nicematrix_code_after_tl { #2 } + \tl_gput_right:Nn \g_nicematrix_code_after_tl { #2 } % \end{macrocode} % The body of the array, which is stored in the argument |#1|, is now % splitted into items (and \emph{not} tokens). @@ -9068,6 +9378,7 @@ version 2005/12/01 or later. } } \cs_set_eq:NN \line \@@_line + \cs_set_eq:NN \SubMatrix \@@_SubMatrix % \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 @@ -9076,9 +9387,18 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_set_eq:NN \CodeAfter \prg_do_nothing: % \end{macrocode} -% And here's the |code-after|: +% +% We clear the list of the names of the potential |\SubMatrix| that will appear +% in the |code-after| (unfortunately, that list has to be global). % \begin{macrocode} - \g_nicematrix_code_after_tl + \seq_gclear:N \g_@@_submatrix_names_seq +% \end{macrocode} +% And here's the |code-after|. Since the |code-after| may begin with an +% ``argument'' between square brackets of the options, we extract and treat that +% potential ``argument'' with the command |\@@_CodeAfter_keys:|. +% \begin{macrocode} + \exp_last_unbraced:NV \@@_CodeAfter_keys: \g_nicematrix_code_after_tl + \scan_stop: \tl_gclear:N \g_nicematrix_code_after_tl \group_end: % \end{macrocode} @@ -9128,6 +9448,15 @@ version 2005/12/01 or later. } % \end{macrocode} % +% \bigskip +% The following command will extract the potential options (between square +% brackets) at the beginning of the |code-after| (that is to say, when +% |\CodeAfter| is used, the options of that ``command'' |\CodeAfter|). +% \begin{macrocode} +\NewDocumentCommand \@@_CodeAfter_keys: { O { } } + { \keys_set:nn { NiceMatrix / CodeAfter } { #1 } } +% \end{macrocode} +% % % \bigskip % We remind that the first mandatory argument of the command |\Block| is the @@ -9970,9 +10299,69 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Npn \@@_draw_line: { + \pgfrememberpicturepositiononpagetrue + \pgf@relevantforpicturesizefalse + \tl_if_eq:NNTF \l_@@_xdots_line_style_tl \c_@@_standard_tl + \@@_draw_standard_dotted_line: + \@@_draw_non_standard_dotted_line: + } +% \end{macrocode} +% +% \medskip +% We have to do a special construction with |\exp_args:NV| to be able to put in +% the list of options in the correct place in the Tikz instruction. +% \begin{macrocode} +\cs_new_protected:Npn \@@_draw_non_standard_dotted_line: + { + \begin { scope } + \exp_args:No \@@_draw_non_standard_dotted_line:n + { \l_@@_xdots_line_style_tl , \l_@@_xdots_color_tl } + } +% \end{macrocode} +% We have used the fact that, in \textsc{pgf}, un color name can be put directly +% in a list of options (that's why we have put diredtly |\l_@@_xdots_color_tl|). +% +% \smallskip +% The argument of |\@@_draw_non_standard_dotted_line:n| is, in fact, the list of options. +% \begin{macrocode} +\cs_new_protected:Npn \@@_draw_non_standard_dotted_line:n #1 + { + \@@_draw_non_standard_dotted_line:nVV + { #1 } + \l_@@_xdots_up_tl + \l_@@_xdots_down_tl + } % \end{macrocode} -% First, we put the labels. +% % \begin{macrocode} +\cs_new_protected:Npn \@@_draw_non_standard_dotted_line:nnn #1 #2 #3 + { + \draw + [ + #1 , + shorten~> = \l_@@_xdots_shorten_dim , + shorten~< = \l_@@_xdots_shorten_dim , + ] + ( \l_@@_x_initial_dim , \l_@@_y_initial_dim ) +% \end{macrocode} +% Be careful: We can't put |\c_math_toggle_token| instead of |$| in the +% following lines because we are in the contents of Tikz nodes (and they will be +% \emph{rescanned} if the Tikz library \pkg{babel} is loaded). +% \begin{macrocode} + -- node [ sloped , above ] { $ \scriptstyle #2 $ } + node [ sloped , below ] { $ \scriptstyle #3 $ } + ( \l_@@_x_final_dim , \l_@@_y_final_dim ) ; + \end { scope } + } +\cs_generate_variant:Nn \@@_draw_non_standard_dotted_line:nnn { n V V } +% \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). +% \begin{macrocode} +\cs_new_protected:Npn \@@_draw_standard_dotted_line: + { \bool_lazy_and:nnF { \tl_if_empty_p:N \l_@@_xdots_up_tl } { \tl_if_empty_p:N \l_@@_xdots_down_tl } @@ -10017,52 +10406,6 @@ version 2005/12/01 or later. { \pgfusepath { } } \endpgfscope } - \pgfrememberpicturepositiononpagetrue - \pgf@relevantforpicturesizefalse - \tl_if_eq:NNTF \l_@@_xdots_line_style_tl \c_@@_standard_tl - \@@_draw_standard_dotted_line: - \@@_draw_non_standard_dotted_line: - } -% \end{macrocode} -% -% \medskip -% We have to do a special construction with |\exp_args:NV| to be able to put in -% the list of options in the correct place in the Tikz instruction. -% \begin{macrocode} -\cs_new_protected:Npn \@@_draw_non_standard_dotted_line: - { - \begin { scope } - \exp_args:No \@@_draw_non_standard_dotted_line:n - { \l_@@_xdots_line_style_tl , \l_@@_xdots_color_tl } - } -% \end{macrocode} -% We have used the fact that, in \textsc{pgf}, un color name can be put directly -% in a list of options (that's why we have put diredtly |\l_@@_xdots_color_tl|). -% -% \smallskip -% The argument of |\@@_draw_non_standard_dotted_line:n| is, in fact, the list of options. -% \begin{macrocode} -\cs_new_protected:Npn \@@_draw_non_standard_dotted_line:n #1 - { - \draw - [ - #1 , - shorten~> = \l_@@_xdots_shorten_dim , - shorten~< = \l_@@_xdots_shorten_dim , - ] - ( \l_@@_x_initial_dim , \l_@@_y_initial_dim ) - -- - ( \l_@@_x_final_dim , \l_@@_y_final_dim ) ; - \end { scope } - } -% \end{macrocode} -% -% \bigskip -% The command |\@@_draw_standard_dotted_line:| draws the line with our system of points -% (which give a dotted line with real round points). -% \begin{macrocode} -\cs_new_protected:Npn \@@_draw_standard_dotted_line: - { \group_begin: % \end{macrocode} % The dimension |\l_@@_l_dim| is the length $\ell$ of the line to draw. We use @@ -10132,7 +10475,7 @@ version 2005/12/01 or later. \l_@@_inter_dots_dim } } - { + { \int_set:Nn \l_tmpa_int { \dim_ratio:nn @@ -10244,7 +10587,8 @@ version 2005/12/01 or later. { #1 , down = #2 , up = #3 } } } - \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_ldots } + \bool_if:NF \l_@@_nullify_dots_bool + { \phantom { \ensuremath { \@@_old_ldots } } } \bool_gset_true:N \g_@@_empty_cell_bool } % \end{macrocode} @@ -10263,7 +10607,8 @@ version 2005/12/01 or later. { #1 , down = #2 , up = #3 } } } - \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_cdots } + \bool_if:NF \l_@@_nullify_dots_bool + { \phantom { \ensuremath { \@@_old_cdots } } } \bool_gset_true:N \g_@@_empty_cell_bool } % \end{macrocode} @@ -10282,7 +10627,8 @@ version 2005/12/01 or later. { #1 , down = #2 , up = #3 } } } - \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_vdots } + \bool_if:NF \l_@@_nullify_dots_bool + { \phantom { \ensuremath { \@@_old_vdots } } } \bool_gset_true:N \g_@@_empty_cell_bool } % \end{macrocode} @@ -10310,7 +10656,8 @@ version 2005/12/01 or later. } } - \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_ddots } + \bool_if:NF \l_@@_nullify_dots_bool + { \phantom { \ensuremath { \@@_old_ddots } } } \bool_gset_true:N \g_@@_empty_cell_bool } % \end{macrocode} @@ -10335,9 +10682,9 @@ version 2005/12/01 or later. \@@_instruction_of_type:nnn \l_@@_draw_first_bool { Iddots } { #1 , down = #2 , up = #3 } } - } - \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_iddots } + \bool_if:NF \l_@@_nullify_dots_bool + { \phantom { \ensuremath { \@@_old_iddots } } } \bool_gset_true:N \g_@@_empty_cell_bool } } @@ -10375,9 +10722,9 @@ version 2005/12/01 or later. \cs_set_eq:NN \@@_old_multicolumn \multicolumn \cs_new:Npn \@@_multicolumn:nnn #1 #2 #3 { -% \begin{macrocode} +% \end{macrocode} % We have to act in an expandable way since it will begin by a |\multicolumn|. -% \end{macrocode +% \begin{macrocode} \exp_args:NNe \@@_old_multicolumn { #1 } @@ -13412,6 +13759,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip +% % \subsection*{How to draw the dotted lines transparently} % \begin{macrocode} \cs_set_protected:Npn \@@_renew_matrix: @@ -13630,15 +13978,33 @@ version 2005/12/01 or later. % \bigskip % \subsection*{The keyword \textbackslash CodeAfter} % +% +% The |code-after| (inserted with the key |code-after| or after the keyword +% |\CodeAfter| can always begin with a list of pairs \emph{key-value} between +% square brackets). Here the corresponding set of keys. +% \begin{macrocode} +\keys_define:nn { NiceMatrix / CodeAfter } + { + sub-matrix .code:n = + \keys_set:nn { NiceMatrix / sub-matrix } { #1 } , + sub-matrix .value_required:n = true , + delimiters-color .tl_set:N = \l_@@_delimiters_color_tl , + delimiters-color .value_required:n = true , + unknown .code:n = \@@_error:n { Unknown~key~for~CodeAfter } + } +% \end{macrocode} +% +% \medskip % In fact, in this subsection, we define the user command |\CodeAfter| for the % case of the ``normal syntax''. For the case of ``light-syntax'', see the % definition of the environment |{@@-light-syntax}| on % p.~\pageref{code-light-syntax}. % +% % \medskip -% In the environments of \pkg{nicematrix}, |\CodeAfter| will be linked to the -% following command |\@@_CodeAfter:|. That macro must \emph{not} be protected -% since it begins with |\omit|. +% In the environments of \pkg{nicematrix}, |\CodeAfter| will be linked to +% |\@@_CodeAfter:|. That macro must \emph{not} be protected since it begins with +% |\omit|. % \begin{macrocode} \cs_new:Npn \@@_CodeAfter: { \omit \@@_CodeAfter_i:n } % \end{macrocode} @@ -13683,8 +14049,363 @@ version 2005/12/01 or later. % \end{macrocode} % % +% \subsection*{The delimiters in the preamble} +% +% The command |\@@_delimiter:nnn| will be used to draw delimiters inside the +% matrix when delimiters are specified in the preamble of the array. It does +% \emph{not} concern the exterior delimiters added by |{NiceArrayWithDelims}| +% (and |{pNiceArray}|, |{pNiceMatrix}|, etc.). +% +% A delimiter in the preamble of the array will write an instruction +% |\@@_delimiter:nnn| in the |\g_@@_internal_code_after_tl| (and also +% potentially add instructions in the preamble provided to |\array| in order to +% add spaces between columns). +% +% \smallskip +% The first argument is the type of delimiter (|(|, |[|, |\{|, |)|, |]| ou +% |\}|). The second argument is the number of colummn. The third argument is a +% boolean equal to |\c_true_bool| (resp. |\c_false_true|) when the delimiter +% must be put on the left (resp. right) side. +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_delimiter:nnn #1 #2 #3 + { + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgf@relevantforpicturesizefalse +% \end{macrocode} +% +% \medskip +% |\l_@@_y_initial_dim| and |\l_@@_y_final_dim| will be the $y$-values of the +% extremities of the delimiter we will have to construct. +% \begin{macrocode} + \@@_qpoint:n { row - 1 } + \dim_set_eq:NN \l_@@_y_initial_dim \pgf@y + \@@_qpoint:n { row - \@@_succ:n \c@iRow } + \dim_set_eq:NN \l_@@_y_final_dim \pgf@y +% \end{macrocode} +% +% \medskip +% We will compute in |\l_tmpa_dim| the $x$-value where we will have to put our +% delimiter (on the left side or on the right side). +% \begin{macrocode} + \bool_if:nTF { #3 } + { \dim_set_eq:NN \l_tmpa_dim \c_max_dim } + { \dim_set:Nn \l_tmpa_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 - #2 } + { + \pgfpointanchor + { \@@_env: - ##1 - #2 } + { \bool_if:nTF { #3 } { west } { east } } + \dim_set:Nn \l_tmpa_dim + { \bool_if:nTF { #3 } \dim_min:nn \dim_max:nn \l_tmpa_dim \pgf@x } + } + } +% \end{macrocode} +% +% +% Now we can put the delimiter with a node of \textsc{pgf}. +% \begin{macrocode} + \pgfset { inner~sep = \c_zero_dim } + \dim_zero:N \nulldelimiterspace + \pgftransformshift + { + \pgfpoint + { \l_tmpa_dim } + { ( \l_@@_y_initial_dim + \l_@@_y_final_dim + \arrayrulewidth ) / 2 } + } + \pgfnode + { rectangle } + { \bool_if:nTF { #3 } { east } { west } } + { +% \end{macrocode} +% Here is the content of the \textsc{pgf} node, that is to say the delimiter, +% constructed with its right size. +% \begin{macrocode} + \nullfont + \c_math_toggle_token + \tl_if_empty:NF \l_@@_delimiters_color_tl + { \color { \l_@@_delimiters_color_tl } } + \bool_if:nTF { #3 } { \left #1 } { \left . } + \vcenter + { + \nullfont + \hrule \@height + \dim_eval:n { \l_@@_y_initial_dim - \l_@@_y_final_dim } + \@depth \c_zero_dim + \@width \c_zero_dim + } + \bool_if:nTF { #3 } { \right . } { \right #1 } + \c_math_toggle_token + } + { } + { } + \endpgfpicture + } +% \end{macrocode} +% +% \subsection*{The command SubMatrix} +% +% +% \begin{macrocode} +\keys_define:nn { NiceMatrix / sub-matrix } + { + extra-height .dim_set:N = \l_@@_submatrix_extra_height_dim , + extra-height .value_required:n = true , + left-xshift .dim_set:N = \l_@@_submatrix_left_xshift_dim , + left-xshift .value_required:n = true , + right-xshift .dim_set:N = \l_@@_submatrix_right_xshift_dim , + right-xshift .value_required:n = true , + xshift .meta:n = { left-xshift = #1, right-xshift = #1 } , + xshift .value_required:n = true , + delimiters-color .tl_set:N = \l_@@_delimiters_color_tl , + delimiters-color .value_required:n = true , + slim .bool_set:N = \l_@@_submatrix_slim_bool , + slim .default:n = true , + } +\keys_define:nn { NiceMatrix } + { + SubMatrix .inherit:n = NiceMatrix /sub-matrix , + CodeAfter / sub-matrix .inherit:n = NiceMatrix / sub-matrix + } +% \end{macrocode} +% +% \medskip +% The following keys set is for the command |\SubMatrix| itself (not the tuning +% of |\SubMatrix| that can be done elsewhere). +% \begin{macrocode} +\keys_define:nn { NiceMatrix / SubMatrix } + { + name .code:n = + \tl_if_empty:nTF { #1 } + { \@@_error:n { Invalid~name~format } } + { + \regex_match:nnTF { \A[A-Za-z][A-Za-z0-9]*\Z } { #1 } + { + \seq_if_in:NnTF \g_@@_submatrix_names_seq { #1 } + { \@@_error:nn { Duplicate~name~for~SubMatrix } { #1 } } + { + \str_set:Nn \l_@@_submatrix_name_str { #1 } + \seq_gput_right:Nn \g_@@_submatrix_names_seq { #1 } + } + } + { \@@_error:n { Invalid~name~format } } + } , + 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{itemize} +% \item |#1| is the left delimiter; +% \item |#2| is the upper-left cell of the matrix with the format $i$-$j$; +% \item |#2| is the lower-right cell of the matrix with the format $i$-$j$; +% \item |#4| is the right delimiter; +% \item |#5| is the list of options of the command. +% \end{itemize} +% \begin{macrocode} +\NewDocumentCommand \@@_SubMatrix { m m m m ! O { } } + { + \group_begin: +% \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 + \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 } + { \@@_error:n { SubMatrix~too~large } } + { + \dim_zero_new:N \l_@@_submatrix_extra_height_dim + \dim_zero_new:N \l_@@_submatrix_left_xshift_dim + \dim_zero_new:N \l_@@_submatrix_right_xshift_dim + \str_clear_new:N \l_@@_submatrix_name_str + \keys_set:nn { NiceMatrix / SubMatrix } { #5 } + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgf@relevantforpicturesizefalse + \pgfset { inner~sep = \c_zero_dim } + \dim_set_eq:NN \l_@@_x_initial_dim \c_max_dim + \dim_set:Nn \l_@@_x_final_dim { - \c_max_dim } +% \end{macrocode} +% 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_row_int \g_@@_row_total_int } + { + \cs_if_exist:cT + { pgf @ sh @ ns @ \@@_env: - ##1 - \l_tmpb_tl } + { + \pgfpointanchor { \@@_env: - ##1 - \l_tmpb_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 } + { + \pgfpointanchor { \@@_env: - ##1 - \l_tmpd_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 } + \dim_set:Nn \l_@@_y_initial_dim + { \pgf@y + ( \box_ht:N \strutbox + \extrarowheight ) * \arraystretch } + \@@_qpoint:n { row - \l_tmpc_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 } + { + \pgfpointanchor { \@@_env: - \l_tmpa_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 } + { + \pgfpointanchor { \@@_env: - \l_tmpc_tl - ##1 } { south } + \dim_set:Nn \l_@@_y_final_dim + { \dim_min:nn \l_@@_y_final_dim \pgf@y } + } + } + \dim_set:Nn \l_tmpa_dim + { + \l_@@_y_initial_dim - \l_@@_y_final_dim + + \l_@@_submatrix_extra_height_dim - \arrayrulewidth + } + \dim_set_eq:NN \nulldelimiterspace \c_zero_dim +% \end{macrocode} +% +% \medskip +% If the key |name| has been used for the command |\SubMatrix|, we create a PGF +% node with that name for the submatrix (this node does not take into account +% the delimiters that we will put after). +% \begin{macrocode} + \str_if_empty:NF \l_@@_submatrix_name_str + { + \@@_pgf_rect_node:nnnnn \l_@@_submatrix_name_str + \l_@@_x_initial_dim \l_@@_y_initial_dim + \l_@@_x_final_dim \l_@@_y_final_dim + } +% \end{macrocode} +% +% \medskip +% Now, we deal with the left delimiter. Of course, the environment +% |{pgfscope}| is for the |\pgftransformshift|. +% \begin{macrocode} + \begin { pgfscope } + \pgftransformshift + { + \pgfpoint + { \l_@@_x_initial_dim - \l_@@_submatrix_left_xshift_dim } + { ( \l_@@_y_initial_dim + \l_@@_y_final_dim ) / 2 } + } + \str_if_empty:NTF \l_@@_submatrix_name_str + { \@@_node_left:nn #1 { } } + { \@@_node_left:nn #1 { \@@_env: - \l_@@_submatrix_name_str - left } } + \end { pgfscope } +% \end{macrocode} +% +% \medskip +% Now, we deal with the right delimiter. +% \begin{macrocode} + \pgftransformshift + { + \pgfpoint + { \l_@@_x_final_dim + \l_@@_submatrix_right_xshift_dim } + { ( \l_@@_y_initial_dim + \l_@@_y_final_dim ) / 2 } + } + \str_if_empty:NTF \l_@@_submatrix_name_str + { \@@_node_right:nn #4 { } } + { + \@@_node_right:nn #4 { \@@_env: - \l_@@_submatrix_name_str - right } + } + \endpgfpicture + } + \group_end: + } +% \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 +% will give to this PGF node (if the key |name| has been used in |\SubMatrix|). +% \begin{macrocode} +\cs_new_protected:Npn \@@_node_left:nn #1 #2 + { + \pgfnode + { rectangle } + { east } + { + \nullfont + \c_math_toggle_token + \tl_if_empty:NF \l_@@_delimiters_color_tl + { \color { \l_@@_delimiters_color_tl } } + \left #1 + \vcenter + { + \nullfont + \hrule \@height \l_tmpa_dim + \@depth \c_zero_dim + \@width \c_zero_dim + } + \right . + \c_math_toggle_token + } + { #2 } + { } + } +% \end{macrocode} +% +% \medskip +% The command |\@@_node_right:nn| puts the right delimiter with the correct size. +% The argument |#1| is the delimiter to put. The argument |#2| is the name we +% will give to this PGF node (if the key |name| has been used in |\SubMatrix|). +% \begin{macrocode} +\cs_new_protected:Npn \@@_node_right:nn #1 #2 + { + \pgfnode + { rectangle } + { west } + { + \nullfont + \c_math_toggle_token + \tl_if_empty:NF \l_@@_delimiters_color_tl + { \color { \l_@@_delimiters_color_tl } } + \left . + \vcenter + { + \nullfont + \hrule \@height \l_tmpa_dim + \@depth \c_zero_dim + \@width \c_zero_dim + } + \right #1 + \c_math_toggle_token + } + { #2 } + { } + } +% \end{macrocode} +% +% \bigskip % \subsection*{We process the options at package loading} % % @@ -13726,12 +14447,19 @@ version 2005/12/01 or later. define-L-C-R,~ footnote,~ footnotehyper,~ - renew-dots,~ - renew-matrix~and~ - transparent. + renew-dots,~and + renew-matrix. } % \end{macrocode} % +% \begin{macrocode} +\@@_msg_new:nn { Key~transparent } + { + The~key~'transparent'~is~now~obsolete~(because~it's~name~ + is~not~clear).~You~should~use~the~conjonction~of~'renew-dots'~ + and~'renew-matrix'.~However,~you~can~go~on. + } +% \end{macrocode} % % \begin{macrocode} \keys_define:nn { NiceMatrix / Package } @@ -13742,7 +14470,12 @@ version 2005/12/01 or later. renew-dots .value_forbidden:n = true , renew-matrix .code:n = \@@_renew_matrix: , renew-matrix .value_forbidden:n = true , - transparent .meta:n = { renew-dots , renew-matrix } , + transparent .code:n = + { + \@@_renew_matrix: + \bool_set_true:N \l_@@_renew_dots_bool + \@@_error:n { Key~transparent } + } , transparent .value_forbidden:n = true, footnote .bool_set:N = \c_@@_footnote_bool , footnotehyper .bool_set:N = \c_@@_footnotehyper_bool , @@ -13780,8 +14513,12 @@ version 2005/12/01 or later. % \begin{macrocode} \bool_if:NT \c_@@_footnote_bool { +% \end{macrocode} +% The class \cls{beamer} has its own system to extract footnotes and that's why +% we have nothing to do if \cls{beamer} is used. +% \begin{macrocode} \@ifclassloaded { beamer } - { \msg_info:nn { nicematrix } { Option~incompatible~with~Beamer } } + { \bool_set_false:N \c_@@_footnote_bool } { \@ifpackageloaded { footnotehyper } { \@@_error:n { footnote~with~footnotehyper~package } } @@ -13793,8 +14530,12 @@ version 2005/12/01 or later. % \begin{macrocode} \bool_if:NT \c_@@_footnotehyper_bool { +% \end{macrocode} +% The class \cls{beamer} has its own system to extract footnotes and that's why +% we have nothing to do if \cls{beamer} is used. +% \begin{macrocode} \@ifclassloaded { beamer } - { \@@_info:n { Option~incompatible~with~Beamer } } + { \bool_set_false:N \c_@@_footnote_bool } { \@ifpackageloaded { footnote } { \@@_error:n { footnotehyper~with~footnote~package } } @@ -13987,6 +14728,15 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} +\@@_msg_new:nn { SubMatrix~too~large } + { + Your~command~\token_to_str:N \SubMatrix\ + can't~be~drawn~because~your~matrix~is~too~small.\\ + If~you~go~on,~this~command~will~be~ignored. + } +% \end{macrocode} +% +% \begin{macrocode} \@@_msg_new:nn { double-backslash~in~light-syntax } { You~can't~use~\token_to_str:N \\~to~separate~rows~because~you~have~used~ @@ -14023,6 +14773,15 @@ version 2005/12/01 or later. } % \end{macrocode} % +% \begin{macrocode} +\@@_msg_new:nn { Invalid~name~format } + { + You~can't~give~the~name~'\l_keys_value_tl'~to~a~\token_to_str:N + \SubMatrix.\\ + A~name~must~be~accepted~by~the~regular~expression~[A-Za-z][A-Za-z0-9]*.\\ + If~you~go~on,~this~key~will~be~ignored. + } +% \end{macrocode} % % \begin{macrocode} \@@_msg_new:nn { empty~environment } @@ -14030,6 +14789,15 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} +\@@_msg_new:nn { Delimiter~with~small } + { + You~can't~put~a~delimiter~in~the~preamble~of~your~\@@_full_name_env:\ + because~the~key~'small'~is~in~force.\\ + This~error~is~fatal. + } +% \end{macrocode} +% +% \begin{macrocode} \@@_msg_new:nn { unknown~cell~for~line~in~code-after } { Your~command~\token_to_str:N\line\{#1\}\{#2\}~in~the~'code-after'~ @@ -14038,6 +14806,21 @@ version 2005/12/01 or later. } % \end{macrocode} % +% +% \begin{macrocode} +\@@_msg_new:nnn { Duplicate~name~for~SubMatrix } + { + The~name~'#1'~is~already~used~for~a~\token_to_str:N \SubMatrix\ + in~this~\@@_full_name_env:.\\ + If~you~go~on,~this~key~will~be~ignored.\\ + For~a~list~of~the~names~already~used,~type~H~<return>. + } + { + The~names~already~defined~in~this~\@@_full_name_env:\ are:~ + \seq_use:Nnnn \g_@@_submatrix_names_seq { ~and~ } { ,~ } { ~and~ }. + } +% \end{macrocode} +% % \begin{macrocode} \@@_msg_new:nn { Hdotsfor~in~col~0 } { @@ -14066,7 +14849,7 @@ version 2005/12/01 or later. } % \end{macrocode} % -% +% % \begin{macrocode} \@@_msg_new:nn { last-col~non~empty~for~NiceMatrixOptions } { @@ -14120,7 +14903,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} -\@@_msg_new:nn { bottomule~without~booktabs } +\@@_msg_new:nn { bottomrule~without~booktabs } { You~can't~use~the~key~'tabular/bottomrule'~because~you~haven't~ loaded~'booktabs'.\\ @@ -14184,8 +14967,35 @@ version 2005/12/01 or later. line-width~and~r. } % \end{macrocode} +% +% \begin{macrocode} +\@@_msg_new:nnn { Unknown~key~for~CodeAfter } + { + The~key~'\l_keys_key_str'~is~unknown.\\ + If~you~go~on,~it~will~be~ignored. \\ + For~a~list~of~the~available~keys~in~\token_to_str:N + \CodeAfter,~type~H~<return>. + } + { + The~available~keys~are~(in~alphabetic~order):~ + delimiters-color,~ + sub-matrix~(several~subkeys)~ + and~xdots~(several~subkeys).~ + The~latter~is~for~the~command~\token_to_str:N \line. + } +% \end{macrocode} % % \begin{macrocode} +\@@_msg_new:nn { Unknown~key~for~SubMatrix } + { + The~key~'\l_keys_key_str'~is~unknown.\\ + The~only~keys~available~here~are~'delimiters-color',~'extra-height',~ + 'left-xshift',~'name',~'right-xshift',~'slim'~and~'xshift'.\\ + If~you~go~on,~this~key~will~be~ignored. \\ + } +% \end{macrocode} +% +% \begin{macrocode} \@@_msg_new:nnn { Unknown~key~for~notes } { The~key~'\l_keys_key_str'~is~unknown.\\ @@ -14239,17 +15049,15 @@ version 2005/12/01 or later. left-margin,~ letter-for-dotted-lines,~ light-syntax,~ - notes~(several subkeys),~ + notes~(several~subkeys),~ nullify-dots,~ renew-dots,~ renew-matrix,~ right-margin,~ small,~ - transparent,~ + sub-matrix~(several~subkeys), vlines,~ - xdots/color,~ - xdots/shorten~and~ - xdots/line-style. + xdots~(several~subkeys). } % \end{macrocode} % @@ -14434,7 +15242,7 @@ version 2005/12/01 or later. } { The~names~already~defined~in~this~document~are:~ - \seq_use:Nnnn \g_@@_names_seq { ,~ } { ,~ } { ~and~ }. + \seq_use:Nnnn \g_@@_names_seq { ~and~ } { ,~ } { ~and~ }. } % \end{macrocode} % @@ -14447,6 +15255,7 @@ version 2005/12/01 or later. % \end{macrocode} % % +% % \vspace{1cm} % \section{History} % @@ -14861,6 +15670,15 @@ version 2005/12/01 or later. % % New key |cell-space-limits|. % +% \subsection*{Changes between versions 5.9 and 5.10} +% +% New command |\SubMatrix| available in the |\CodeAfter|. +% +% It's possible to provide options (between brackets) to the command |\CodeAfter|. +% +% A (non fatal) error is raised when the key |transparent|, which is +% deprecated, is used. +% % \PrintIndex % % \tableofcontents @@ -14873,3 +15691,4 @@ version 2005/12/01 or later. % fill-column: 80 % End: + diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index 8e8cb2bc878..6a423f2b113 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.9} -\def\myfiledate{2021/01/08} +\def\myfileversion{5.10} +\def\myfiledate{2021/02/05} \RequirePackage{pgfcore} \usepgfmodule{shapes} \RequirePackage{l3keys2e} @@ -30,7 +30,6 @@ {Enhanced arrays with the help of PGF/TikZ} \RequirePackage { array } \RequirePackage { amsmath } -\RequirePackage { xparse } \cs_new_protected:Npn \__nicematrix_error:n { \msg_error:nn { nicematrix } } \cs_new_protected:Npn \__nicematrix_error:nn { \msg_error:nnn { nicematrix } } \cs_new_protected:Npn \__nicematrix_error:nnn { \msg_error:nnnn { nicematrix } } @@ -43,11 +42,15 @@ \bool_new:N \c__nicematrix_in_preamble_bool \bool_set_true:N \c__nicematrix_in_preamble_bool \AtBeginDocument { \bool_set_false:N \c__nicematrix_in_preamble_bool } +\bool_new:N \c__nicematrix_arydshln_loaded_bool \bool_new:N \c__nicematrix_booktabs_loaded_bool \bool_new:N \c__nicematrix_enumitem_loaded_bool \bool_new:N \c__nicematrix_tikz_loaded_bool \AtBeginDocument { + \@ifpackageloaded { arydshln } + { \bool_set_true:N \c__nicematrix_arydshln_loaded_bool } + { } \@ifpackageloaded { booktabs } { \bool_set_true:N \c__nicematrix_booktabs_loaded_bool } { } @@ -72,6 +75,8 @@ \@ifclassloaded { revtex4-2 } { \bool_set_true:N \c__nicematrix_revtex_bool } { } +\cs_if_exist:NT \rvtx@ifformat@geq { \bool_set_true:N \c__nicematrix_revtex_bool } +\cs_generate_variant:Nn \tl_if_single_token_p:n { V } \ProvideDocumentCommand \iddots { } { \mathinner @@ -301,6 +306,7 @@ \seq_new:N \g__nicematrix_pos_of_blocks_seq \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 \g__nicematrix_static_num_of_col_int \tl_new:N \l__nicematrix_fill_tl \tl_new:N \l__nicematrix_draw_tl @@ -443,11 +449,11 @@ \dim_new:N \l__nicematrix_cell_space_top_limit_dim \dim_new:N \l__nicematrix_cell_space_bottom_limit_dim \dim_new:N \l__nicematrix_inter_dots_dim -\dim_set:Nn \l__nicematrix_inter_dots_dim { 0.45 em } +\AtBeginDocument { \dim_set:Nn \l__nicematrix_inter_dots_dim { 0.45 em } } \dim_new:N \l__nicematrix_xdots_shorten_dim -\dim_set:Nn \l__nicematrix_xdots_shorten_dim { 0.3 em } +\AtBeginDocument { \dim_set:Nn \l__nicematrix_xdots_shorten_dim { 0.3 em } } \dim_new:N \l__nicematrix_radius_dim -\dim_set:Nn \l__nicematrix_radius_dim { 0.53 pt } +\AtBeginDocument { \dim_set:Nn \l__nicematrix_radius_dim { 0.53 pt } } \tl_new:N \l__nicematrix_xdots_line_style_tl \tl_const:Nn \c__nicematrix_standard_tl { standard } \tl_set_eq:NN \l__nicematrix_xdots_line_style_tl \c__nicematrix_standard_tl @@ -461,7 +467,7 @@ \bool_new:N \l__nicematrix_hlines_bool \clist_new:N \l__nicematrix_except_corners_clist \dim_new:N \l__nicematrix_notes_above_space_dim -\dim_set:Nn \l__nicematrix_notes_above_space_dim { 1 mm } +\AtBeginDocument { \dim_set:Nn \l__nicematrix_notes_above_space_dim { 1 mm } } \bool_new:N \l__nicematrix_nullify_dots_bool \bool_new:N \l__nicematrix_auto_columns_width_bool \str_new:N \l__nicematrix_name_str @@ -511,10 +517,10 @@ cell-space-top-limit .value_required:n = true , cell-space-bottom-limit .dim_set:N = \l__nicematrix_cell_space_bottom_limit_dim , cell-space-bottom-limit .value_required:n = true , - cell-space-limits .code:n = + cell-space-limits .meta:n = { - \dim_set:Nn \l__nicematrix_cell_space_bottom_limit_dim { #1 } - \dim_set:Nn \l__nicematrix_cell_space_top_limit_dim { #1 } + cell-space-top-limit = #1 , + cell-space-bottom-limit = #1 , } , cell-spaces-limits .value_required:n = true , xdots .code:n = \keys_set:nn { NiceMatrix / xdots } { #1 } , @@ -667,6 +673,8 @@ NiceMatrixOptions / xdots .inherit:n = NiceMatrix / xdots , NiceMatrixOptions / rules .inherit:n = NiceMatrix / rules , NiceMatrixOptions / notes .inherit:n = NiceMatrix / notes , + NiceMatrixOptions / sub-matrix .inherit:n = NiceMatrix / sub-matrix , + CodeAfter / xdots .inherit:n = NiceMatrix / xdots , NiceMatrix .inherit:n = { NiceMatrix / Global , @@ -707,7 +715,12 @@ small .value_forbidden:n = true , renew-matrix .code:n = \__nicematrix_renew_matrix: , renew-matrix .value_forbidden:n = true , - transparent .meta:n = { renew-dots , renew-matrix } , + transparent .code:n = + { + \__nicematrix_renew_matrix: + \bool_set_true:N \l__nicematrix_renew_dots_bool + \__nicematrix_error:n { Key~transparent } + } , transparent .value_forbidden:n = true, exterior-arraycolsep .bool_set:N = \l__nicematrix_exterior_arraycolsep_bool , columns-width .code:n = @@ -726,6 +739,9 @@ letter-for-dotted-lines .value_required:n = true , notes .code:n = \keys_set:nn { NiceMatrix / notes } { #1 } , notes .value_required:n = true , + sub-matrix .code:n = + \keys_set:nn { NiceMatrix / sub-matrix } { #1 } , + sub-matrix .value_required:n = true , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~NiceMatrixOptions } } \str_new:N \l__nicematrix_letter_for_dotted_lines_str @@ -1134,6 +1150,7 @@ \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 @@ -1285,14 +1302,14 @@ \dim_gset:Nn \l__nicematrix_right_delim_dim { 2 \arraycolsep } } { - \hbox_set:Nn \l_tmpa_box { $ \bBigg@ 5 #1 $ } + \hbox_set:Nn \l_tmpa_box { $ \bBigg@ 5 \l__nicematrix_left_delim_tl $ } \dim_set:Nn \l__nicematrix_left_delim_dim { \box_wd:N \l_tmpa_box } - \hbox_set:Nn \l_tmpa_box { $ \bBigg@ 5 #2 $ } + \hbox_set:Nn \l_tmpa_box { $ \bBigg@ 5 \l__nicematrix_right_delim_tl $ } \dim_set:Nn \l__nicematrix_right_delim_dim { \box_wd:N \l_tmpa_box } } \box_clear_new:N \l__nicematrix_the_array_box \bool_if:NT \c__nicematrix_define_L_C_R_bool \__nicematrix_define_L_C_R: - \__nicematrix_construct_preamble:n { #4 } + \__nicematrix_construct_preamble: \hbox_set:Nw \l__nicematrix_the_array_box \skip_horizontal:N \l__nicematrix_left_margin_dim \skip_horizontal:N \l__nicematrix_extra_left_margin_dim @@ -1361,11 +1378,10 @@ \c_math_toggle_token \tl_if_empty:NF \l__nicematrix_delimiters_color_tl { \color { \l__nicematrix_delimiters_color_tl } } - \left #1 + \exp_after:wN \left \l__nicematrix_left_delim_tl \vcenter { \skip_vertical:N -\l_tmpa_dim - \skip_vertical:N -\arrayrulewidth \hbox { \bool_if:NTF \l__nicematrix_NiceTabular_bool @@ -1377,9 +1393,8 @@ { \skip_horizontal:N -\arraycolsep } } \skip_vertical:N -\l_tmpb_dim - \skip_vertical:N \arrayrulewidth } - \right #2 + \exp_after:wN \right \l__nicematrix_right_delim_tl \c_math_toggle_token } \bool_if:NTF \l__nicematrix_max_delimiter_width_bool @@ -1404,15 +1419,14 @@ \egroup \bool_if:NT \c__nicematrix_footnote_bool \endsavenotes } -\cs_new_protected:Npn \__nicematrix_construct_preamble:n #1 +\cs_new_protected:Npn \__nicematrix_construct_preamble: { \group_begin: - \bool_if:NTF \l__nicematrix_Matrix_bool - { \tl_gset:Nn \g__nicematrix_preamble_tl { #1 } } + \bool_if:NF \l__nicematrix_Matrix_bool { \__nicematrix_newcolumntype w [ 2 ] { \__nicematrix_w: { ##1 } { ##2 } } \__nicematrix_newcolumntype W [ 2 ] { \__nicematrix_W: { ##1 } { ##2 } } - \@temptokena { #1 } + \exp_args:NV \@temptokena \g__nicematrix_preamble_tl \@tempswatrue \@whilesw \if@tempswa \fi { \@tempswafalse \the \NC@list } \int_gzero_new:N \c@jCol @@ -1482,15 +1496,30 @@ \__nicematrix_w: { \__nicematrix_patch_preamble_v:nnnn { } #1 } \__nicematrix_W: { \__nicematrix_patch_preamble_v:nnnn { \cs_set_eq:NN \hss \hfil } #1 } \__nicematrix_true_c: { \__nicematrix_patch_preamble_vi:n #1 } - C { \__nicematrix_error:nn { old~column~type } C } - L { \__nicematrix_error:nn { old~column~type } L } - R { \__nicematrix_error:nn { old~column~type } R } + ( { \__nicematrix_patch_preamble_vii:n #1 } + [ { \__nicematrix_patch_preamble_vii:n #1 } + \{ { \__nicematrix_patch_preamble_vii:n #1 } + ) { \__nicematrix_patch_preamble_viii:n #1 } + ] { \__nicematrix_patch_preamble_viii:n #1 } + \} { \__nicematrix_patch_preamble_viii:n #1 } + C { \__nicematrix_error:nn { old~column~type } #1 } + L { \__nicematrix_error:nn { old~column~type } #1 } + R { \__nicematrix_error:nn { old~column~type } #1 } \q_stop { } } { \str_if_eq:VnTF \l__nicematrix_letter_for_dotted_lines_str { #1 } - { \__nicematrix_patch_preamble_vii:n #1 } - { \__nicematrix_fatal:nn { unknown~column~type } { #1 } } + { \__nicematrix_patch_preamble_xi:n #1 } + { + \bool_lazy_and:nnTF + { \str_if_eq_p:nn { : } { #1 } } + \c__nicematrix_arydshln_loaded_bool + { + \tl_gput_right:Nn \g__nicematrix_preamble_tl { : } + \__nicematrix_patch_preamble:n + } + { \__nicematrix_fatal:nn { unknown~column~type } { #1 } } + } } } \cs_new_protected:Npn \__nicematrix_patch_preamble_i:n #1 @@ -1502,7 +1531,7 @@ < \__nicematrix_end_Cell: } \int_gincr:N \c@jCol - \__nicematrix_patch_preamble_viii:n + \__nicematrix_patch_preamble_x:n } \cs_new_protected:Npn \__nicematrix_patch_preamble_ii:nn #1 #2 { @@ -1554,7 +1583,7 @@ < { \box_use:N \@arstrutbox \end { minipage } \__nicematrix_end_Cell: } } \int_gincr:N \c@jCol - \__nicematrix_patch_preamble_viii:n + \__nicematrix_patch_preamble_x:n } \cs_new_protected:Npn \__nicematrix_patch_preamble_v:nnnn #1 #2 #3 #4 { @@ -1576,23 +1605,53 @@ } } \int_gincr:N \c@jCol - \__nicematrix_patch_preamble_viii:n + \__nicematrix_patch_preamble_x:n } \cs_new_protected:Npn \__nicematrix_patch_preamble_vi:n #1 { \tl_gput_right:Nn \g__nicematrix_preamble_tl { c } \int_gincr:N \c@jCol - \__nicematrix_patch_preamble_viii:n + \__nicematrix_patch_preamble_x:n } \cs_new_protected:Npn \__nicematrix_patch_preamble_vii:n #1 { + \bool_if:NT \l__nicematrix_small_bool + { \__nicematrix_fatal:n { Delimiter~with~small } } + \int_compare:nNnT \c@jCol = \c_zero_int + { \tl_gput_right:Nx \g__nicematrix_preamble_tl { ! { \enskip } } } + \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl + { \__nicematrix_delimiter:nnn #1 { \__nicematrix_succ:n \c@jCol } \c_true_bool } + \__nicematrix_patch_preamble:n + } +\cs_new_protected:Npn \__nicematrix_patch_preamble_viii:n #1 + { + \bool_if:NT \l__nicematrix_small_bool + { \__nicematrix_fatal:n { Delimiter~with~small } } + \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl + { \__nicematrix_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool } + \__nicematrix_patch_preamble_viii_i:n + } +\cs_new_protected:Npn \__nicematrix_patch_preamble_viii_i:n #1 + { + \bool_lazy_any:nT + { + { \str_if_eq_p:nn { #1 } ( } + { \str_if_eq_p:nn { #1 } [ } + { \str_if_eq_p:nn { #1 } \{ } + { \str_if_eq_p:nn { #1 } \q_stop } + } + { \tl_gput_right:Nn \g__nicematrix_preamble_tl { ! { \enskip } } } + \__nicematrix_patch_preamble:n #1 + } +\cs_new_protected:Npn \__nicematrix_patch_preamble_xi:n #1 + { \tl_gput_right:Nn \g__nicematrix_preamble_tl { ! { \skip_horizontal:N 2\l__nicematrix_radius_dim } } \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl { \__nicematrix_vdottedline:n { \int_use:N \c@jCol } } \__nicematrix_patch_preamble:n } -\cs_new_protected:Npn \__nicematrix_patch_preamble_viii:n #1 +\cs_new_protected:Npn \__nicematrix_patch_preamble_x:n #1 { \str_if_eq:nnTF { #1 } { < } \__nicematrix_patch_preamble_ix:n @@ -1608,7 +1667,7 @@ \cs_new_protected:Npn \__nicematrix_patch_preamble_ix:n #1 { \tl_gput_right:Nn \g__nicematrix_preamble_tl { < { #1 } } - \__nicematrix_patch_preamble_viii:n + \__nicematrix_patch_preamble_x:n } \cs_new_protected:Npn \__nicematrix_put_box_in_flow: { @@ -1701,7 +1760,7 @@ \skip_vertical:N \aboverulesep { \CT@arc@ \hrule height \heavyrulewidth } } - { \__nicematrix_error:n { bottomule~without~booktabs } } + { \__nicematrix_error:n { bottomrule~without~booktabs } } } \l__nicematrix_notes_code_after_tl \seq_gclear:N \g__nicematrix_tabularnotes_seq @@ -2278,8 +2337,11 @@ } } \cs_set_eq:NN \line \__nicematrix_line + \cs_set_eq:NN \SubMatrix \__nicematrix_SubMatrix \cs_set_eq:NN \CodeAfter \prg_do_nothing: - \g_nicematrix_code_after_tl + \seq_gclear:N \g__nicematrix_submatrix_names_seq + \exp_last_unbraced:NV \__nicematrix_CodeAfter_keys: \g_nicematrix_code_after_tl + \scan_stop: \tl_gclear:N \g_nicematrix_code_after_tl \group_end: \tl_if_empty:NF \g_nicematrix_code_before_tl @@ -2300,6 +2362,8 @@ \__nicematrix_restore_iRow_jCol: \cs_gset_eq:NN \CT@arc@ \__nicematrix_old_CT@arc@ } +\NewDocumentCommand \__nicematrix_CodeAfter_keys: { O { } } + { \keys_set:nn { NiceMatrix / CodeAfter } { #1 } } \cs_new_protected:Npn \__nicematrix_adjust_pos_of_blocks_seq: { \seq_gset_map_x:NNn \g__nicematrix_pos_of_blocks_seq \g__nicematrix_pos_of_blocks_seq @@ -2806,6 +2870,42 @@ } \cs_new_protected:Npn \__nicematrix_draw_line: { + \pgfrememberpicturepositiononpagetrue + \pgf@relevantforpicturesizefalse + \tl_if_eq:NNTF \l__nicematrix_xdots_line_style_tl \c__nicematrix_standard_tl + \__nicematrix_draw_standard_dotted_line: + \__nicematrix_draw_non_standard_dotted_line: + } +\cs_new_protected:Npn \__nicematrix_draw_non_standard_dotted_line: + { + \begin { scope } + \exp_args:No \__nicematrix_draw_non_standard_dotted_line:n + { \l__nicematrix_xdots_line_style_tl , \l__nicematrix_xdots_color_tl } + } +\cs_new_protected:Npn \__nicematrix_draw_non_standard_dotted_line:n #1 + { + \__nicematrix_draw_non_standard_dotted_line:nVV + { #1 } + \l__nicematrix_xdots_up_tl + \l__nicematrix_xdots_down_tl + } +\cs_new_protected:Npn \__nicematrix_draw_non_standard_dotted_line:nnn #1 #2 #3 + { + \draw + [ + #1 , + shorten~> = \l__nicematrix_xdots_shorten_dim , + shorten~< = \l__nicematrix_xdots_shorten_dim , + ] + ( \l__nicematrix_x_initial_dim , \l__nicematrix_y_initial_dim ) + -- node [ sloped , above ] { $ \scriptstyle #2 $ } + node [ sloped , below ] { $ \scriptstyle #3 $ } + ( \l__nicematrix_x_final_dim , \l__nicematrix_y_final_dim ) ; + \end { scope } + } +\cs_generate_variant:Nn \__nicematrix_draw_non_standard_dotted_line:nnn { n V V } +\cs_new_protected:Npn \__nicematrix_draw_standard_dotted_line: + { \bool_lazy_and:nnF { \tl_if_empty_p:N \l__nicematrix_xdots_up_tl } { \tl_if_empty_p:N \l__nicematrix_xdots_down_tl } @@ -2850,33 +2950,6 @@ { \pgfusepath { } } \endpgfscope } - \pgfrememberpicturepositiononpagetrue - \pgf@relevantforpicturesizefalse - \tl_if_eq:NNTF \l__nicematrix_xdots_line_style_tl \c__nicematrix_standard_tl - \__nicematrix_draw_standard_dotted_line: - \__nicematrix_draw_non_standard_dotted_line: - } -\cs_new_protected:Npn \__nicematrix_draw_non_standard_dotted_line: - { - \begin { scope } - \exp_args:No \__nicematrix_draw_non_standard_dotted_line:n - { \l__nicematrix_xdots_line_style_tl , \l__nicematrix_xdots_color_tl } - } -\cs_new_protected:Npn \__nicematrix_draw_non_standard_dotted_line:n #1 - { - \draw - [ - #1 , - shorten~> = \l__nicematrix_xdots_shorten_dim , - shorten~< = \l__nicematrix_xdots_shorten_dim , - ] - ( \l__nicematrix_x_initial_dim , \l__nicematrix_y_initial_dim ) - -- - ( \l__nicematrix_x_final_dim , \l__nicematrix_y_final_dim ) ; - \end { scope } - } -\cs_new_protected:Npn \__nicematrix_draw_standard_dotted_line: - { \group_begin: \dim_zero_new:N \l__nicematrix_l_dim \dim_set:Nn \l__nicematrix_l_dim @@ -2994,7 +3067,8 @@ { #1 , down = #2 , up = #3 } } } - \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_ldots } + \bool_if:NF \l__nicematrix_nullify_dots_bool + { \phantom { \ensuremath { \__nicematrix_old_ldots } } } \bool_gset_true:N \g__nicematrix_empty_cell_bool } \exp_args:NNV \NewDocumentCommand \__nicematrix_Cdots \l__nicematrix_argspec_tl @@ -3009,7 +3083,8 @@ { #1 , down = #2 , up = #3 } } } - \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_cdots } + \bool_if:NF \l__nicematrix_nullify_dots_bool + { \phantom { \ensuremath { \__nicematrix_old_cdots } } } \bool_gset_true:N \g__nicematrix_empty_cell_bool } \exp_args:NNV \NewDocumentCommand \__nicematrix_Vdots \l__nicematrix_argspec_tl @@ -3024,7 +3099,8 @@ { #1 , down = #2 , up = #3 } } } - \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_vdots } + \bool_if:NF \l__nicematrix_nullify_dots_bool + { \phantom { \ensuremath { \__nicematrix_old_vdots } } } \bool_gset_true:N \g__nicematrix_empty_cell_bool } \exp_args:NNV \NewDocumentCommand \__nicematrix_Ddots \l__nicematrix_argspec_tl @@ -3047,7 +3123,8 @@ } } - \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_ddots } + \bool_if:NF \l__nicematrix_nullify_dots_bool + { \phantom { \ensuremath { \__nicematrix_old_ddots } } } \bool_gset_true:N \g__nicematrix_empty_cell_bool } \exp_args:NNV \NewDocumentCommand \__nicematrix_Iddots \l__nicematrix_argspec_tl @@ -3068,9 +3145,9 @@ \__nicematrix_instruction_of_type:nnn \l__nicematrix_draw_first_bool { Iddots } { #1 , down = #2 , up = #3 } } - } - \bool_if:NF \l__nicematrix_nullify_dots_bool { \phantom \__nicematrix_old_iddots } + \bool_if:NF \l__nicematrix_nullify_dots_bool + { \phantom { \ensuremath { \__nicematrix_old_iddots } } } \bool_gset_true:N \g__nicematrix_empty_cell_bool } } @@ -4975,6 +5052,15 @@ { \__nicematrix_math_toggle_token: #6 \__nicematrix_math_toggle_token: } { } { } \endpgfpicture } +\keys_define:nn { NiceMatrix / CodeAfter } + { + sub-matrix .code:n = + \keys_set:nn { NiceMatrix / sub-matrix } { #1 } , + sub-matrix .value_required:n = true , + delimiters-color .tl_set:N = \l__nicematrix_delimiters_color_tl , + delimiters-color .value_required:n = true , + unknown .code:n = \__nicematrix_error:n { Unknown~key~for~CodeAfter } + } \cs_new:Npn \__nicematrix_CodeAfter: { \omit \__nicematrix_CodeAfter_i:n } \cs_new_protected:Npn \__nicematrix_CodeAfter_i:n #1 \end { @@ -4990,6 +5076,255 @@ \__nicematrix_CodeAfter_i:n } } +\cs_new_protected:Npn \__nicematrix_delimiter:nnn #1 #2 #3 + { + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgf@relevantforpicturesizefalse + \__nicematrix_qpoint:n { row - 1 } + \dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf@y + \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \c@iRow } + \dim_set_eq:NN \l__nicematrix_y_final_dim \pgf@y + \bool_if:nTF { #3 } + { \dim_set_eq:NN \l_tmpa_dim \c_max_dim } + { \dim_set:Nn \l_tmpa_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 - #2 } + { + \pgfpointanchor + { \__nicematrix_env: - ##1 - #2 } + { \bool_if:nTF { #3 } { west } { east } } + \dim_set:Nn \l_tmpa_dim + { \bool_if:nTF { #3 } \dim_min:nn \dim_max:nn \l_tmpa_dim \pgf@x } + } + } + \pgfset { inner~sep = \c_zero_dim } + \dim_zero:N \nulldelimiterspace + \pgftransformshift + { + \pgfpoint + { \l_tmpa_dim } + { ( \l__nicematrix_y_initial_dim + \l__nicematrix_y_final_dim + \arrayrulewidth ) / 2 } + } + \pgfnode + { rectangle } + { \bool_if:nTF { #3 } { east } { west } } + { + \nullfont + \c_math_toggle_token + \tl_if_empty:NF \l__nicematrix_delimiters_color_tl + { \color { \l__nicematrix_delimiters_color_tl } } + \bool_if:nTF { #3 } { \left #1 } { \left . } + \vcenter + { + \nullfont + \hrule \@height + \dim_eval:n { \l__nicematrix_y_initial_dim - \l__nicematrix_y_final_dim } + \@depth \c_zero_dim + \@width \c_zero_dim + } + \bool_if:nTF { #3 } { \right . } { \right #1 } + \c_math_toggle_token + } + { } + { } + \endpgfpicture + } +\keys_define:nn { NiceMatrix / sub-matrix } + { + extra-height .dim_set:N = \l__nicematrix_submatrix_extra_height_dim , + extra-height .value_required:n = true , + left-xshift .dim_set:N = \l__nicematrix_submatrix_left_xshift_dim , + left-xshift .value_required:n = true , + right-xshift .dim_set:N = \l__nicematrix_submatrix_right_xshift_dim , + right-xshift .value_required:n = true , + xshift .meta:n = { left-xshift = #1, right-xshift = #1 } , + xshift .value_required:n = true , + delimiters-color .tl_set:N = \l__nicematrix_delimiters_color_tl , + delimiters-color .value_required:n = true , + slim .bool_set:N = \l__nicematrix_submatrix_slim_bool , + slim .default:n = true , + } +\keys_define:nn { NiceMatrix } + { + SubMatrix .inherit:n = NiceMatrix /sub-matrix , + CodeAfter / sub-matrix .inherit:n = NiceMatrix / sub-matrix + } +\keys_define:nn { NiceMatrix / SubMatrix } + { + name .code:n = + \tl_if_empty:nTF { #1 } + { \__nicematrix_error:n { Invalid~name~format } } + { + \regex_match:nnTF { \A[A-Za-z][A-Za-z0-9]*\Z } { #1 } + { + \seq_if_in:NnTF \g__nicematrix_submatrix_names_seq { #1 } + { \__nicematrix_error:nn { Duplicate~name~for~SubMatrix } { #1 } } + { + \str_set:Nn \l__nicematrix_submatrix_name_str { #1 } + \seq_gput_right:Nn \g__nicematrix_submatrix_names_seq { #1 } + } + } + { \__nicematrix_error:n { Invalid~name~format } } + } , + name .value_required:n = true , + unknown .code:n = \__nicematrix_error:n { Unknown~key~for~SubMatrix } + } +\NewDocumentCommand \__nicematrix_SubMatrix { 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 + \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 } + { \__nicematrix_error:n { SubMatrix~too~large } } + { + \dim_zero_new:N \l__nicematrix_submatrix_extra_height_dim + \dim_zero_new:N \l__nicematrix_submatrix_left_xshift_dim + \dim_zero_new:N \l__nicematrix_submatrix_right_xshift_dim + \str_clear_new:N \l__nicematrix_submatrix_name_str + \keys_set:nn { NiceMatrix / SubMatrix } { #5 } + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgf@relevantforpicturesizefalse + \pgfset { inner~sep = \c_zero_dim } + \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_row_int \g__nicematrix_row_total_int } + { + \cs_if_exist:cT + { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - \l_tmpb_tl } + { + \pgfpointanchor { \__nicematrix_env: - ##1 - \l_tmpb_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 } + { + \pgfpointanchor { \__nicematrix_env: - ##1 - \l_tmpd_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 } + \dim_set:Nn \l__nicematrix_y_initial_dim + { \pgf@y + ( \box_ht:N \strutbox + \extrarowheight ) * \arraystretch } + \__nicematrix_qpoint:n { row - \l_tmpc_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 } + { + \pgfpointanchor { \__nicematrix_env: - \l_tmpa_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 } + { + \pgfpointanchor { \__nicematrix_env: - \l_tmpc_tl - ##1 } { south } + \dim_set:Nn \l__nicematrix_y_final_dim + { \dim_min:nn \l__nicematrix_y_final_dim \pgf@y } + } + } + \dim_set:Nn \l_tmpa_dim + { + \l__nicematrix_y_initial_dim - \l__nicematrix_y_final_dim + + \l__nicematrix_submatrix_extra_height_dim - \arrayrulewidth + } + \dim_set_eq:NN \nulldelimiterspace \c_zero_dim + \str_if_empty:NF \l__nicematrix_submatrix_name_str + { + \__nicematrix_pgf_rect_node:nnnnn \l__nicematrix_submatrix_name_str + \l__nicematrix_x_initial_dim \l__nicematrix_y_initial_dim + \l__nicematrix_x_final_dim \l__nicematrix_y_final_dim + } + \begin { pgfscope } + \pgftransformshift + { + \pgfpoint + { \l__nicematrix_x_initial_dim - \l__nicematrix_submatrix_left_xshift_dim } + { ( \l__nicematrix_y_initial_dim + \l__nicematrix_y_final_dim ) / 2 } + } + \str_if_empty:NTF \l__nicematrix_submatrix_name_str + { \__nicematrix_node_left:nn #1 { } } + { \__nicematrix_node_left:nn #1 { \__nicematrix_env: - \l__nicematrix_submatrix_name_str - left } } + \end { pgfscope } + \pgftransformshift + { + \pgfpoint + { \l__nicematrix_x_final_dim + \l__nicematrix_submatrix_right_xshift_dim } + { ( \l__nicematrix_y_initial_dim + \l__nicematrix_y_final_dim ) / 2 } + } + \str_if_empty:NTF \l__nicematrix_submatrix_name_str + { \__nicematrix_node_right:nn #4 { } } + { + \__nicematrix_node_right:nn #4 { \__nicematrix_env: - \l__nicematrix_submatrix_name_str - right } + } + \endpgfpicture + } + \group_end: + } +\cs_new_protected:Npn \__nicematrix_node_left:nn #1 #2 + { + \pgfnode + { rectangle } + { east } + { + \nullfont + \c_math_toggle_token + \tl_if_empty:NF \l__nicematrix_delimiters_color_tl + { \color { \l__nicematrix_delimiters_color_tl } } + \left #1 + \vcenter + { + \nullfont + \hrule \@height \l_tmpa_dim + \@depth \c_zero_dim + \@width \c_zero_dim + } + \right . + \c_math_toggle_token + } + { #2 } + { } + } +\cs_new_protected:Npn \__nicematrix_node_right:nn #1 #2 + { + \pgfnode + { rectangle } + { west } + { + \nullfont + \c_math_toggle_token + \tl_if_empty:NF \l__nicematrix_delimiters_color_tl + { \color { \l__nicematrix_delimiters_color_tl } } + \left . + \vcenter + { + \nullfont + \hrule \@height \l_tmpa_dim + \@depth \c_zero_dim + \@width \c_zero_dim + } + \right #1 + \c_math_toggle_token + } + { #2 } + { } + } %% \medskip \bool_new:N \c__nicematrix_footnotehyper_bool \bool_new:N \c__nicematrix_footnote_bool @@ -5004,9 +5339,14 @@ define-L-C-R,~ footnote,~ footnotehyper,~ - renew-dots,~ - renew-matrix~and~ - transparent. + renew-dots,~and + renew-matrix. + } +\__nicematrix_msg_new:nn { Key~transparent } + { + The~key~'transparent'~is~now~obsolete~(because~it's~name~ + is~not~clear).~You~should~use~the~conjonction~of~'renew-dots'~ + and~'renew-matrix'.~However,~you~can~go~on. } \keys_define:nn { NiceMatrix / Package } { @@ -5016,7 +5356,12 @@ renew-dots .value_forbidden:n = true , renew-matrix .code:n = \__nicematrix_renew_matrix: , renew-matrix .value_forbidden:n = true , - transparent .meta:n = { renew-dots , renew-matrix } , + transparent .code:n = + { + \__nicematrix_renew_matrix: + \bool_set_true:N \l__nicematrix_renew_dots_bool + \__nicematrix_error:n { Key~transparent } + } , transparent .value_forbidden:n = true, footnote .bool_set:N = \c__nicematrix_footnote_bool , footnotehyper .bool_set:N = \c__nicematrix_footnotehyper_bool , @@ -5044,7 +5389,7 @@ \bool_if:NT \c__nicematrix_footnote_bool { \@ifclassloaded { beamer } - { \msg_info:nn { nicematrix } { Option~incompatible~with~Beamer } } + { \bool_set_false:N \c__nicematrix_footnote_bool } { \@ifpackageloaded { footnotehyper } { \__nicematrix_error:n { footnote~with~footnotehyper~package } } @@ -5054,7 +5399,7 @@ \bool_if:NT \c__nicematrix_footnotehyper_bool { \@ifclassloaded { beamer } - { \__nicematrix_info:n { Option~incompatible~with~Beamer } } + { \bool_set_false:N \c__nicematrix_footnote_bool } { \@ifpackageloaded { footnote } { \__nicematrix_error:n { footnotehyper~with~footnote~package } } @@ -5171,6 +5516,12 @@ You~can't~use~an~ampersand~(\token_to_str:N &)~to~separate~columns~because~ ~you~have~used~the~key~'light-syntax'.~This~error~is~fatal. } +\__nicematrix_msg_new:nn { SubMatrix~too~large } + { + Your~command~\token_to_str:N \SubMatrix\ + can't~be~drawn~because~your~matrix~is~too~small.\\ + If~you~go~on,~this~command~will~be~ignored. + } \__nicematrix_msg_new:nn { double-backslash~in~light-syntax } { You~can't~use~\token_to_str:N \\~to~separate~rows~because~you~have~used~ @@ -5196,14 +5547,38 @@ \int_use:N \g__nicematrix_row_total_int\ or~equal~to~'t',~'c'~or~'b'.\\ If~you~go~on,~a~value~of~1~will~be~used. } +\__nicematrix_msg_new:nn { Invalid~name~format } + { + You~can't~give~the~name~'\l_keys_value_tl'~to~a~\token_to_str:N + \SubMatrix.\\ + A~name~must~be~accepted~by~the~regular~expression~[A-Za-z][A-Za-z0-9]*.\\ + If~you~go~on,~this~key~will~be~ignored. + } \__nicematrix_msg_new:nn { empty~environment } { Your~\__nicematrix_full_name_env:\ is~empty.~This~error~is~fatal. } +\__nicematrix_msg_new:nn { Delimiter~with~small } + { + You~can't~put~a~delimiter~in~the~preamble~of~your~\__nicematrix_full_name_env:\ + because~the~key~'small'~is~in~force.\\ + This~error~is~fatal. + } \__nicematrix_msg_new:nn { unknown~cell~for~line~in~code-after } { Your~command~\token_to_str:N\line\{#1\}\{#2\}~in~the~'code-after'~ can't~be~executed~because~a~cell~doesn't~exist.\\ If~you~go~on~this~command~will~be~ignored. } +\__nicematrix_msg_new:nnn { Duplicate~name~for~SubMatrix } + { + The~name~'#1'~is~already~used~for~a~\token_to_str:N \SubMatrix\ + in~this~\__nicematrix_full_name_env:.\\ + If~you~go~on,~this~key~will~be~ignored.\\ + For~a~list~of~the~names~already~used,~type~H~<return>. + } + { + 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 { Hdotsfor~in~col~0 } { You~can't~use~\token_to_str:N \Hdotsfor\ in~an~exterior~column~of~ @@ -5258,7 +5633,7 @@ \{NiceTabular\},~\{NiceArray\}~and~\{NiceMatrix\}. \\ If~you~go~on,~this~command~will~be~ignored. } -\__nicematrix_msg_new:nn { bottomule~without~booktabs } +\__nicematrix_msg_new:nn { bottomrule~without~booktabs } { You~can't~use~the~key~'tabular/bottomrule'~because~you~haven't~ loaded~'booktabs'.\\ @@ -5301,6 +5676,27 @@ The~available~keys~are~(in~alphabetic~order):~-,~c,~draw,~fill,~l,~ line-width~and~r. } +\__nicematrix_msg_new:nnn { Unknown~key~for~CodeAfter } + { + The~key~'\l_keys_key_str'~is~unknown.\\ + If~you~go~on,~it~will~be~ignored. \\ + For~a~list~of~the~available~keys~in~\token_to_str:N + \CodeAfter,~type~H~<return>. + } + { + The~available~keys~are~(in~alphabetic~order):~ + delimiters-color,~ + sub-matrix~(several~subkeys)~ + and~xdots~(several~subkeys).~ + The~latter~is~for~the~command~\token_to_str:N \line. + } +\__nicematrix_msg_new:nn { Unknown~key~for~SubMatrix } + { + The~key~'\l_keys_key_str'~is~unknown.\\ + The~only~keys~available~here~are~'delimiters-color',~'extra-height',~ + 'left-xshift',~'name',~'right-xshift',~'slim'~and~'xshift'.\\ + If~you~go~on,~this~key~will~be~ignored. \\ + } \__nicematrix_msg_new:nnn { Unknown~key~for~notes } { The~key~'\l_keys_key_str'~is~unknown.\\ @@ -5351,17 +5747,15 @@ left-margin,~ letter-for-dotted-lines,~ light-syntax,~ - notes~(several subkeys),~ + notes~(several~subkeys),~ nullify-dots,~ renew-dots,~ renew-matrix,~ right-margin,~ small,~ - transparent,~ + sub-matrix~(several~subkeys), vlines,~ - xdots/color,~ - xdots/shorten~and~ - xdots/line-style. + xdots~(several~subkeys). } \__nicematrix_msg_new:nnn { Unknown~option~for~NiceArray } { @@ -5529,7 +5923,7 @@ } { The~names~already~defined~in~this~document~are:~ - \seq_use:Nnnn \g__nicematrix_names_seq { ,~ } { ,~ } { ~and~ }. + \seq_use:Nnnn \g__nicematrix_names_seq { ~and~ } { ,~ } { ~and~ }. } \__nicematrix_msg_new:nn { Option~auto~for~columns-width } { |