summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdfbin424997 -> 426449 bytes
-rw-r--r--Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex152
-rw-r--r--Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdfbin1166775 -> 1183755 bytes
-rw-r--r--Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx531
-rw-r--r--Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty227
5 files changed, 723 insertions, 187 deletions
diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf
index 21154fbe675..f9d2004bed0 100644
--- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf
+++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex
index 9ae1a3a8abd..8656d61f09f 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}
@@ -521,6 +521,9 @@ d'intérêt que si |draw| est utilisée) ;
le fond dessiné par |fill|) avec un rayon égal à la valeur de cette clé (la
valeur par défaut est 4~pt\footnote{Cette valeur par défaut est la valeur
initiale des \emph{rounded corners} de Tikz.}).
+\item \colorbox{yellow!50}{\textbf{Nouveau 5.13}}\enskip la clé |borders| permet
+de ne tracer que certaines des bordures du bloc : cette clé prend comme valeur
+une liste d'éléments parmi les suivants : |left|, |right|, |top| et |bottom|.
\end{itemize}
@@ -748,7 +751,8 @@ Marie & Pauline \\ \hline
\bigskip
-En revanche, les filets verticaux ne sont pas tracés à l'intérieur des blocs.
+En revanche, les filets verticaux ne sont pas tracés à l'intérieur des blocs
+(créés par |\Block|: cf.~p.~\pageref{Block}).
\bigskip
@@ -898,6 +902,19 @@ p.~\pageref{OnlyMainNiceMatrix}.
+\bigskip
+\subsection{La commande \textbackslash Hline}
+
+On a dit que les traits verticaux spécifiés par un symbole «\verb+|+» dans le
+préambule (pour les environnements à préambule, bien entendu) n'étaient pas
+tracés dans les blocs.\footnote{Ces blocs sont ceux créés par les commandes
+ \verb|\Block| et \verb|\multicolumn| mais aussi ceux délimités implicitement
+ par des lignes en pointillés continues (créées par \verb|\Cdots|, etc.).}
+
+\smallskip
+\colorbox{yellow!50}{\textbf{Nouveau 5.13}}\enskip Pour proposer des filets horizontaux
+ayant le même comportement, l'extension \pkg{nicematrix} fournit la commande
+|\Hline|.
\bigskip
@@ -925,6 +942,10 @@ $\begin{pNiceMatrix}[vlines,rules/width=0.2pt]
1 & 2 & 3 & 4 & 5 & 6
\end{pNiceMatrix}$
+\medskip
+\colorbox{yellow!50}{\textbf{Nouveau 5.13}}\enskip Il est possible de donner à
+la clé |vlines| une liste de numéros qui seront les numéros des filets verticaux
+qui seront tracés. Il en est de même pour |hlines|.
\subsection{La clé hvlines}
@@ -957,6 +978,8 @@ arum & iris & jacinthe & muguet
\subsection{La clé hvlines-except-corners}
+\label{except-corners}
+
La clé |hvlines-except-corners| demande le tracé de tous les filets horizontaux
et verticaux sauf dans les blocs (y compris dans les blocs virtuels déterminés par des
lignes en pointillés) et sauf dans les coins vides.
@@ -1020,6 +1043,10 @@ prendre en considération, les coins étant désignés par |NW|, |SW|, |NE| et |
1&5&10&10&5&1
\end{NiceTabular}
+\medskip
+$\triangleright$ Le concept de coins est aussi utilisé par la commande
+|\arraycolor| dans le |\CodeBefore| qui accepte en option une clé
+|except-corners| : cf.~p.~\pageref{arraycolor}.
\subsection{La commande \textbackslash diagbox}
@@ -1101,17 +1128,18 @@ 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|.
Ainsi libérée, la lettre «|:|» peut être utilisée par ailleurs (par exemple par
-l'extension \pkg{arydshln}).
+l'extension \pkg{arydshln}\footnote{On remarquera néanmoins que l'extension
+ \pkg{arydshln} n'est pas parfaitement compatible avec l'extension \pkg{nicematrix}.}).
\bigskip
\emph{Remarque} : Quand l'extension \pkg{array} (sur laquelle s'appuie
\pkg{nicematrix}) est chargée, les traits verticaux et horizontaux que l'on
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 ce même effet.
+largeur du trait\footnote{En fait, avec l'extension \pkg{array}, 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 ce même effet.
@@ -1160,7 +1188,7 @@ L'extension \pkg{nicematrix} propose des outils qui permettent d'éviter ces
inconvénients.
\end{itemize}
-\subsection{Les outils de nicematrix dans le code-before}
+\subsection{Les outils de nicematrix dans le \textbackslash CodeBefore}
L'extension \pkg{nicematrix} propose des outils (indépendants de \pkg{colortbl})
pour tracer d'abord les rectangles colorés, puis le contenu des cases et les
@@ -1189,10 +1217,10 @@ proposée : on peut placer le contenu de ce |code-before| entre les mots-clés
\smallskip
De nouvelles commandes sont disponibles dans ce |\CodeBefore| :
-|\cellcolor|, |\rectanglecolor|, |\rowcolor|, |\columncolor|, |\rowcolors| et
-|\chessboardcolors|.\footnote{On pourra remarquer que, dans le
- \verb|code-before|, des nœuds PGF/Tikz correspondant à la position des filets
- éventuels sont également accessibles : cf. p.~\pageref{noeuds-i}.}
+|\cellcolor|, |\rectanglecolor|, |\rowcolor|, |\columncolor|, |\rowcolors|
+|\chessboardcolors| et |\arraycolor|.\footnote{On pourra remarquer que, dans le
+ \verb|\CodeBefore|, des nœuds PGF/Tikz de la forme \verb+(i-|j)+ correspondant
+ à la position des filets éventuels sont également accessibles : cf. p.~\pageref{noeuds-i}.}
\label{code-before}
\medskip
@@ -1214,7 +1242,7 @@ format $i$-$j$ où $i$ est le numéro de ligne et $j$ le numéro de colonne.
\begin{BVerbatim}[boxwidth=10cm,baseline=c]
\begin{NiceTabular}{|c|c|c|}
\CodeBefore
- ~emphase#\cellcolor{red!15}{3-1,2-2,1-3}@
+ ~emphase#\cellcolor[HTML]{FFFF88}{3-1,2-2,1-3}@
\Body
\hline
a & b & c \\ \hline
@@ -1224,7 +1252,7 @@ h & i & j \\ \hline
\end{BVerbatim}
\begin{NiceTabular}{|c|c|c|}
\CodeBefore
- \cellcolor{red!15}{3-1,2-2,1-3}
+ \cellcolor[HTML]{FFFF88}{3-1,2-2,1-3}
\Body
\hline
a & b & c \\ \hline
@@ -1349,7 +1377,7 @@ couleur.\footnote{Autrement, la couleur d'une rangée ne dépend que de la parit
de son numéro.}
-\item Avec la clé |respect-blocks|, qui est de type booléen, les ``rangées''
+\item Avec la clé |respect-blocks|, qui est de type booléen, les «rangées»
colorées alternativement peuvent s'étendre sur plusieurs rangées réelles du
tableau pour englober les blocs (créés par la commande |\Block| : cf.~p.~\pageref{Block}).
\end{itemize}
@@ -1361,7 +1389,7 @@ tableau pour englober les blocs (créés par la commande |\Block| : cf.~p.~\page
\begin{BVerbatim}[baseline=c,boxwidth=9cm]
\begin{NiceTabular}{clr}[hvlines]
\CodeBefore
- ~emphase#{\rowcolors{2}{blue!10}{}[cols=2-3,restart]}@
+ ~emphase#\rowcolors{2}{blue!10}{}[cols=2-3,restart]@
\Body
\Block{1-*}{Résultats} \\
\Block{2-1}{A}& Pierre & 12 \\
@@ -1439,7 +1467,7 @@ couleurs et colorie les cases en quinconces avec les deux couleurs.
\begin{BVerbatim}[baseline=c,boxwidth=9cm]
$\begin{pNiceMatrix}[r,margin]
\CodeBefore
- ~emphase#code-before=\chessboardcolors{red!15}{blue!15}@
+ ~emphase#\chessboardcolors{red!15}{blue!15}@
\Body
1 & -1 & 1 \\
-1 & 1 & -1 \\
@@ -1459,6 +1487,42 @@ $\begin{pNiceMatrix}[baseline=1, r, margin]
\medskip
On a utilisé la clé |r| qui impose que toutes les colonnes soient alignées à
droite (cf. p.~\pageref{key-R}).
+
+\item \colorbox{yellow!50}{\textbf{Nouveau 5.13}}\enskip La commande
+|\arraycolor| prend en argument obligatoire une couleur et colorie tout le
+tableau (sauf les éventuelles rangées et colonnes extérieures: cf.~p.~\pageref{exterior}) avec cette
+couleur. Elle est surtout intéressante du fait de la clé |except-corners|
+qu'elle accepte entre crochets en troisième argument (optionnel). La définition
+des coins a été donnée p.~\pageref{except-corners} quand on a présenté la clé
+|hvlines-except-corners|.
+
+\label{arraycolor}
+
+\medskip
+\begin{BVerbatim}[boxwidth=10cm,baseline=c]
+\begin{NiceTabular}{*{6}{c}}[cell-space-top-limit=3pt]
+\CodeBefore
+ ~emphase#\arraycolor{blue!10}[except-corners=NE]@
+\Body
+1\\
+1&1\\
+1&2&1\\
+1&3&3&1\\
+1&4&6&4&1\\
+1&5&10&10&5&1
+\end{NiceTabular}
+\end{BVerbatim}
+\begin{NiceTabular}{*{6}{c}}[cell-space-top-limit=3pt]
+\CodeBefore
+ \arraycolor{blue!10}[except-corners=NE]
+\Body
+1\\
+1&1\\
+1&2&1\\
+1&3&3&1\\
+1&4&6&4&1\\
+1&5&10&10&5&1
+\end{NiceTabular}
\end{itemize}
\bigskip
@@ -1704,9 +1768,6 @@ $\begin{array}{c}
\end{array}$
\end{NiceMatrixBlock}
-\medskip
-\textbf{Plusieurs compilations peuvent être nécessaires pour obtenir le résultat désiré.}
-
\bigskip
@@ -2431,7 +2492,6 @@ p.~\pageref{customization}).
\label{sub-matrix}
-\colorbox{yellow!30}{Nouveau 5.10}\enskip
La commande |\SubMatrix| permet de positionner des délimiteurs sur une partie du
tableau, partie qui est considérée comme une sous-matrice. La commande
|\SubMatrix| prend cinq arguments :
@@ -2497,20 +2557,7 @@ 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.
-
-\medskip
-\colorbox{yellow!50}{\textbf{Nouveau 5.12}}\enskip Il y a aussi les clés
-suivantes, qui ne sont accessibles que pour une commande |\SubMatrix|
-individuelle :
-%
-\begin{itemize}
+contenu des cases des colonnes mises en jeu (voir exemple ci-dessous) ;
\item |vlines| contient une liste de numéros de filets verticaux à tracer dans
la sous-matrice (si cette clé est utilisée sans valeur, tous les filets
verticaux sont tracés) ;
@@ -2521,6 +2568,12 @@ On remarquera que tous ces filets sont dessinés après la construction du table
principal : les colonnes et les rangées ne sont pas écartées.
\bigskip
+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}
\hfuzz=12cm
\fvset{commandchars=\~\#\!}%
@@ -3585,6 +3638,10 @@ l'intersection du filet horizontal de numéro $i$ et du filet vertical de
numéro~$j$ (ou plutôt la position potentielle de ces filets car ils ne sont
peut-être pas tracés). Ces nœuds sont accessibles dans le |\CodeAfter| mais
aussi dans le |code-before|.
+
+
+\colorbox{yellow!50}{Nouveau 5.13}\enskip Le dernier nœud a aussi un alias nommé
+|last|.
\begin{center}
\begin{NiceTabular}{ccc}[hvlines,rules={width=1pt,color=gray}]
rose & tulipe & lys \\
@@ -3648,7 +3705,6 @@ horizontal~$i$ et du filet vertical~$j$ avec la syntaxe |(|$i$\verb+-|+$j$|)|.
\label{node-sub-matrix}
-\colorbox{yellow!30}{Nouveau 5.10}\enskip
La commande |\SubMatrix| disponible dans le |\CodeAfter| a été présentée
p.~\pageref{sub-matrix}.
@@ -4233,8 +4289,8 @@ $\begin{pNiceMatrix}[first-row,first-col]
\subsection{Empilements de matrices}
-On a souvent besoin de présetner des matrices empilées les unes au-dessus des
-autres (par exemple pour la résolutiond de systèmes linéaires).
+On a souvent besoin de présenter des matrices empilées les unes au-dessus des
+autres (par exemple pour la résolution de systèmes linéaires).
\medskip
@@ -4416,11 +4472,11 @@ Bien sûr, ce tableau ne pourra pas être coupé par un saut de page.
0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm]
12 & -8 &7 &5 & 3 \\
0 & 64 &-41 & 1 & 19 \\
-~emphase#\CodeAfter@
-~emphase# \SubMatrix({1-1}{4-5})[vlines=4]@
-~emphase# \SubMatrix({5-1}{8-5})[vlines=4]@
-~emphase# \SubMatrix({9-1}{11-5})[vlines=4]@
-~emphase# \SubMatrix({12-1}{13-5})[vlines=4]@
+~emphase#\CodeAfter [sub-matrix/vlines=4]@
+~emphase# \SubMatrix({1-1}{4-5})@
+~emphase# \SubMatrix({5-1}{8-5})@
+~emphase# \SubMatrix({9-1}{11-5})@
+~emphase# \SubMatrix({12-1}{13-5})@
\end{NiceMatrix}\]
\end{Verbatim}
@@ -4442,11 +4498,11 @@ Bien sûr, ce tableau ne pourra pas être coupé par un saut de page.
0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm]
12 & -8 &7 &5 & 3 \\
0 & 64 &-41 & 1 & 19 \\
-\CodeAfter
- \SubMatrix({1-1}{4-5})[vlines=4]
- \SubMatrix({5-1}{8-5})[vlines=4]
- \SubMatrix({9-1}{11-5})[vlines=4]
- \SubMatrix({12-1}{13-5})[vlines=4]
+\CodeAfter [sub-matrix/vlines=4]
+ \SubMatrix({1-1}{4-5})
+ \SubMatrix({5-1}{8-5})
+ \SubMatrix({9-1}{11-5})
+ \SubMatrix({12-1}{13-5})
\end{NiceMatrix}\]
\end{scope}
diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf
index 18b9e7af326..00cce2d6b76 100644
--- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf
+++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx
index a84069b7c80..38269b145ca 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.12}
-\def\myfiledate{2021/03/10}
+\def\myfileversion{5.13}
+\def\myfiledate{2021/03/23}
%
%
%<*batchfile>
@@ -346,7 +346,7 @@ version 2005/12/01 or later.
% immediately after an |\item| of list. One should remark that the presence of a
% |\hline| at the beginning of the array doesn't prevent the alignment of the
% baseline with the baseline of the first row (with |{tabular}| or |{array}| of
-% \pkg{array}, one must use |\firsthline|.
+% \pkg{array}, one must use |\firsthline|).
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
@@ -566,6 +566,10 @@ version 2005/12/01 or later.
% |fill|) with a radius equal to the value of that key (the default value is
% 4~pt\footnote{This value is the initial value of the \emph{rounded corners} of
% Tikz.}).
+% \item \colorbox{yellow!50}{\textbf{New 5.13}}\enskip the key |borders| provides
+% the ability to draw only some borders of the blocks; the value of that key is
+% a (comma-separated) list of elements covered by |left|, |right|, |top| and
+% |bottom|.
% \end{itemize}
%
% \interitem
@@ -780,7 +784,8 @@ version 2005/12/01 or later.
%
%
% \bigskip
-% However, the vertical rules are not drawn in the blocks.
+% However, the vertical rules are not drawn in the blocks (created by |\Block|:
+% cf.~p.~\pageref{Block}).
%
% \bigskip
% If you use \pkg{booktabs} (which provides |\toprule|, |\midrule|,
@@ -920,6 +925,18 @@ version 2005/12/01 or later.
% he should consider the command |\OnlyMainNiceMatrix| described on
% page~\pageref{OnlyMainNiceMatrix}.
%
+%
+% \subsection{The command \textbackslash Hline}
+%
+% We have said that the vertical rules specified by a symbol ``\verb+|+'' in the
+% preamble (for the environments with preamble, of course) are not drawn in the
+% blocks.\footnote{Those blocks are those created by the commands \verb|\Block|
+% and |\multicolumn| but also those implicitely determined by the continuous
+% dotted lines (created by \verb|\Cdots|, etc.).}
+%
+% \smallskip
+% \colorbox{yellow!50}{\textbf{New 5.13}}\enskip In order to have horizontal
+% rules with the same behaviour, \pkg{nicematrix} provides the command |\Hline|.
%
%
% \subsection{The keys hlines and vlines}
@@ -928,7 +945,7 @@ version 2005/12/01 or later.
% the vertical rules excepted in the blocks, created by |\Block| and the virtual
% blocks determined by dotted lines: |\Cdots|, |\Vdots|, etc.. In fact, in the
% environments with delimiters (as |{pNiceMatrix}| or |{bNiceArray}|) the
-% exteriors rules are not drawn (as expected).
+% exterior rules are not drawn (as expected).
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
@@ -945,6 +962,11 @@ version 2005/12/01 or later.
% \end{pNiceMatrix}$
%
%
+% \bigskip
+% \colorbox{yellow!50}{\textbf{New 5.13}}\enskip It's possible to provide to the
+% key |vlines| a (comma-separated) list of numbers, which are the numbers of the
+% vertical rules to draw. The key |hlines| has a similar behaviour.
+%
%
% \subsection{The key hvlines}
% \label{hvlines}
@@ -978,6 +1000,8 @@ version 2005/12/01 or later.
%
% \subsection{The key hvlines-except-corners}
%
+% \label{except-corners}
+%
% The key |hvlines-except-corners| draws all the horizontal and vertical rules,
% excepted in the blocks (and the virtual blocks determined by dotted lines) and
% excepted in the empty corners.
@@ -1041,6 +1065,10 @@ version 2005/12/01 or later.
% 1&5&10&10&5&1
% \end{NiceTabular}
%
+% \bigskip
+% $\triangleright$ The concept of corner is also used by the command
+% |\arraycolor| in the |\CodeBefore| which takes in as option a key
+% |except-corners|: cf.~p.~\pageref{arraycolor}.
%
% \subsection{The command \textbackslash diagbox}
%
@@ -1119,14 +1147,16 @@ version 2005/12/01 or later.
% 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|. Thus released, the letter ``|:|'' can be used otherwise
-% (for example by the package \pkg{arydshln}).
+% (for example by the package \pkg{arydshln}\footnote{However, one should remark
+% that the package \pkg{arydshln} is not fully compatible with
+% \pkg{nicematrix}.}).
%
% \bigskip
-% \emph{Remark} : In the package \pkg{array} (on which the package
+% \emph{Remark}: In the package \pkg{array} (on which the package
% \pkg{nicematrix} relies), horizontal and vertical rules make the array larger
-% or wider by a quantity equal to the width of the rule\footnote{In fact, this
-% is true only for |\hline| and ``"|"'' but not for |\cline|: cf
-% p.~\pageref{remark-cline}}. In \pkg{nicematrix}, the dotted lines drawn by
+% or wider by a quantity equal to the width of the rule\footnote{In fact, with
+% \pkg{array}, this is true only for |\hline| and ``"|"'' but not for |\cline|:
+% cf p.~\pageref{remark-cline}}. In \pkg{nicematrix}, the dotted lines drawn by
% |\hdottedline| and ``|:|'' do likewise.
%
%
@@ -1147,7 +1177,7 @@ version 2005/12/01 or later.
% However, there is two drawbacks:
% \begin{itemize}
% \item The package \pkg{colortbl} patches \pkg{array}, leading to some
-% incompatibilities (for example with the command |\hdotsfor|).
+% incompatibilities (for instance with the command |\hdotsfor|).
%
% \item The package \pkg{colortbl} constructs the array row by row, alterning
% colored rectangles, rules and contents of the cells. The resulting
@@ -1171,7 +1201,7 @@ version 2005/12/01 or later.
% The package \pkg{nicematrix} provides tools to avoid those problems.
% \end{itemize}
%
-% \subsection{The tools of nicematrix in the code-before}
+% \subsection{The tools of nicematrix in the \textbackslash CodeBefore}
%
% The package \pkg{nicematrix} provides some tools (independent of
% \pkg{colortbl}) to draw the colored panels first, and, then, the content
@@ -1198,10 +1228,11 @@ version 2005/12/01 or later.
% \end{Verbatim}
%
% New commands are available in that |\CodeBefore|: |\cellcolor|,
-% |\rectanglecolor|, |\rowcolor|, |\columncolor|, |\rowcolors| and
-% |\chessboardcolors|.\footnote{Remark that, in the \verb|code-before|, some
-% PGF/Tikz nodes corresponding to the position to the potential rules are
-% available: cf.~p.~\pageref{nodes-i}.}
+% |\rectanglecolor|, |\rowcolor|, |\columncolor|, |\rowcolors|,
+% |\chessboardcolors| and |arraycolor|.\footnote{Remark that, in the
+% \verb|\CodeBefore|, PGF/Tikz nodes of the form ``\verb+(i-|j)+'' are also
+% available to indicate the position to the potential rules:
+% cf.~p.~\pageref{nodes-i}.}
% \label{code-before}
%
% \medskip
@@ -1224,7 +1255,7 @@ version 2005/12/01 or later.
% \begin{BVerbatim}[boxwidth=10cm,baseline=c]
% \begin{NiceTabular}{|c|c|c|}
% \CodeBefore
-% ~emphase#\cellcolor{red!15}{3-1,2-2,1-3}@
+% ~emphase#\cellcolor[HTML]{FFFF88}{3-1,2-2,1-3}@
% \Body
% \hline
% a & b & c \\ \hline
@@ -1234,7 +1265,7 @@ version 2005/12/01 or later.
% \end{BVerbatim}
% \begin{NiceTabular}{|c|c|c|}
% \CodeBefore
-% \cellcolor{red!15}{3-1,2-2,1-3}
+% \cellcolor[HTML]{FFFF88}{3-1,2-2,1-3}
% \Body
% \hline
% a & b & c \\ \hline
@@ -1436,7 +1467,7 @@ version 2005/12/01 or later.
% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
% $\begin{pNiceMatrix}[r,margin]
% \CodeBefore
-% ~emphase#code-before=\chessboardcolors{red!15}{blue!15}@
+% ~emphase#\chessboardcolors{red!15}{blue!15}@
% \Body
% 1 & -1 & 1 \\
% -1 & 1 & -1 \\
@@ -1454,7 +1485,47 @@ version 2005/12/01 or later.
% \end{scope}
%
% \medskip
-% We have used the key |r| which aligns all the columns rightwards (cf. p.~\pageref{key-R}).
+% We have used the key |r| which aligns all the columns rightwards (cf.
+% p.~\pageref{key-R}).
+%
+%
+% \item \colorbox{yellow!50}{\textbf{New 5.13}}\enskip
+% The command |\arraycolor| takes in as mandatory argument a color and color
+% the whole tabular with that color (excepted the potential exterior rows and
+% columns: cf.~p.~\pageref{exterior}). This command is useful thanks to its key
+% |except-corners| (in the third argument, which is a optional argument between
+% square brackets). The definition of these ``corners'' has been given
+% p.~\pageref{except-corners} when we have presented the key
+% |hvlines-except-corners|.
+%
+% \label{arraycolor}
+%
+%
+% \medskip
+% \begin{BVerbatim}[boxwidth=10cm,baseline=c]
+% \begin{NiceTabular}{*{6}{c}}[cell-space-top-limit=3pt]
+% \CodeBefore
+% ~emphase#\arraycolor{blue!10}[except-corners=NE]@
+% \Body
+% 1\\
+% 1&1\\
+% 1&2&1\\
+% 1&3&3&1\\
+% 1&4&6&4&1\\
+% 1&5&10&10&5&1
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \begin{NiceTabular}{*{6}{c}}[cell-space-top-limit=3pt]
+% \CodeBefore
+% \arraycolor{blue!10}[except-corners=NE]
+% \Body
+% 1\\
+% 1&1\\
+% 1&2&1\\
+% 1&3&3&1\\
+% 1&4&6&4&1\\
+% 1&5&10&10&5&1
+% \end{NiceTabular}
% \end{itemize}
%
%
@@ -1695,10 +1766,6 @@ version 2005/12/01 or later.
% \end{array}$
% \end{NiceMatrixBlock}
%
-% \medskip
-% \textbf{Several compilations may be necessary to achieve the job.}
-%
-%
%
% \bigskip
% \section{The exterior rows and columns}
@@ -2405,7 +2472,6 @@ version 2005/12/01 or later.
%
% \label{sub-matrix}
%
-% \colorbox{yellow!30}{New 5.10}\enskip
% The command |\SubMatrix| provides a way to put delimiters on a portion
% of the array considered as a submatrix. The command |\SubMatrix| takes in five
% arguments:
@@ -2469,33 +2535,24 @@ version 2005/12/01 or later.
% 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
-% \medskip
-% \colorbox{yellow!50}{\textbf{New 5.12}}\enskip There is also the following
-% keys, which are available only for an individual command |\SubMatrix|:
-%
-% \begin{itemize}
+% (see example below). ;
% \item |vlines| contents a list of numbers of vertical rules that will be drawn in
% the sub-matrix (if this key is used without value, all the vertical rules of
% the sub-matrix are drawn);
-%
% \item |hlines| is similar to |vlines| but for the horizontal rules;
-%
% \item |hvlines|, which must be used without value, draws all the vertical and
% horizontal rules.
% \end{itemize}
% One should remark that these keys add their rules after the construction of
% the main matrix: no space is added between the rows and the columns of the
% array for theses rules.
-%
+%
+% \bigskip
+% All 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}
% \hfuzz=12cm
@@ -3538,6 +3595,9 @@ version 2005/12/01 or later.
% number~$j$ (more specifically the potential position of those rules because
% maybe there are not actually drawn). These nodes are available in the
% |code-before| and the |\CodeAfter|.
+%
+% \colorbox{yellow!50}{\textbf{New 5.13}}\enskip The last node has also an alias called
+% |last|.
% \begin{center}
% \begin{NiceTabular}{ccc}[hvlines,rules/width=1pt,rules/color=gray]
% rose & tulipe & lys \\
@@ -3599,7 +3659,6 @@ version 2005/12/01 or later.
%
% \label{node-sub-matrix}
%
-% \colorbox{yellow!30}{New 5.10}\enskip
% The command |\SubMatrix| available in the |\CodeAfter| has been described
% p.~\pageref{sub-matrix}.
%
@@ -3892,7 +3951,7 @@ version 2005/12/01 or later.
% \pkg{amsmath} prefer to delete these spaces with explicit instructions
% |\hskip -\arraycolsep|\footnote{And not by inserting |@{}| on both sides of the
% preamble of the array. As a consequence, the length of the |\hline| is not
-% modified and may appear too long, in particular when using square brackets}.
+% modified and may appear too long, in particular when using square brackets.}.
% The package \pkg{nicematrix} does the same in all its environments,
% |{NiceArray}| included. However, if the user wants the environment
% |{NiceArray}| behaving by default like the environment |{array}| of
@@ -4349,11 +4408,11 @@ version 2005/12/01 or later.
% 0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm]
% 12 & -8 &7 &5 & 3 \\
% 0 & 64 &-41 & 1 & 19 \\
-% ~emphase#\CodeAfter@
-% ~emphase# \SubMatrix({1-1}{4-5})[vlines=4]@
-% ~emphase# \SubMatrix({5-1}{8-5})[vlines=4]@
-% ~emphase# \SubMatrix({9-1}{11-5})[vlines=4]@
-% ~emphase# \SubMatrix({12-1}{13-5})[vlines=4]@
+% ~emphase#\CodeAfter [sub-matrix/vlines=4]@
+% ~emphase# \SubMatrix({1-1}{4-5})@
+% ~emphase# \SubMatrix({5-1}{8-5})@
+% ~emphase# \SubMatrix({9-1}{11-5})@
+% ~emphase# \SubMatrix({12-1}{13-5})@
% \end{NiceMatrix}\]
% \end{Verbatim}
%
@@ -4374,11 +4433,11 @@ version 2005/12/01 or later.
% 0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm]
% 12 & -8 &7 &5 & 3 \\
% 0 & 64 &-41 & 1 & 19 \\
-% \CodeAfter
-% \SubMatrix({1-1}{4-5})[vlines=4]
-% \SubMatrix({5-1}{8-5})[vlines=4]
-% \SubMatrix({9-1}{11-5})[vlines=4]
-% \SubMatrix({12-1}{13-5})[vlines=4]
+% \CodeAfter [sub-matrix/vlines=4]
+% \SubMatrix({1-1}{4-5})
+% \SubMatrix({5-1}{8-5})
+% \SubMatrix({9-1}{11-5})
+% \SubMatrix({12-1}{13-5})
% \end{NiceMatrix}\]
% \end{scope}
%
@@ -5606,11 +5665,12 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \medskip
-% The following parameters correspond to the keys |fill|, |draw| and
+% The following parameters correspond to the keys |fill|, |draw|, |borders| and
% |rounded-corners| of the command |\Block|.
% \begin{macrocode}
\tl_new:N \l_@@_fill_tl
\tl_new:N \l_@@_draw_tl
+\clist_new:N \l_@@_borders_clist
\dim_new:N \l_@@_rounded_corners_dim
% \end{macrocode}
%
@@ -5659,6 +5719,8 @@ version 2005/12/01 or later.
\dim_new:N \l_@@_submatrix_right_xshift_dim
\clist_new:N \l_@@_hlines_clist
\clist_new:N \l_@@_vlines_clist
+\clist_new:N \l_@@_submatrix_hlines_clist
+\clist_new:N \l_@@_submatrix_vlines_clist
% \end{macrocode}
%
%
@@ -7497,7 +7559,8 @@ version 2005/12/01 or later.
}
\endpgfpicture
% \end{macrocode}
-% Now, you create the diagonal nodes by using the |row| nodes and the |col| nodes.
+% Now, you create the diagonal nodes by using the |row| nodes and the |col|
+% nodes. If the engine is |xetex| or |luatex| we also create the ``½ nodes''.
% \begin{macrocode}
\@@_create_diag_nodes:
% \end{macrocode}
@@ -7519,6 +7582,7 @@ version 2005/12/01 or later.
\cs_set_eq:NN \roundedrectanglecolor \@@_roundedrectanglecolor
\cs_set_eq:NN \rowcolor \@@_rowcolor
\cs_set_eq:NN \rowcolors \@@_rowcolors
+ \cs_set_eq:NN \arraycolor \@@_arraycolor
\cs_set_eq:NN \columncolor \@@_columncolor
\cs_set_eq:NN \chessboardcolors \@@_chessboardcolors
\cs_set_eq:NN \SubMatrix \@@_SubMatrix_in_code_before
@@ -7527,7 +7591,7 @@ version 2005/12/01 or later.
% by the user between instructions in the |code-before|.
% \begin{macrocode}
\bool_if:NT \l_@@_NiceTabular_bool \c_math_toggle_token
- \seq_clear_new:N \l_@@_colors_seq
+ \seq_gclear_new:N \g_@@_colors_seq
% \end{macrocode}
% Here is the |\CodeBefore|. As of now, the keys that may be provided to the
% keyword |\CodeBefore| are the same as keys that may be provided to
@@ -7699,9 +7763,10 @@ version 2005/12/01 or later.
% |\CodeBefore|). By definition, the |\CodeBefore| must be executed before the
% body of the array...
% \begin{macrocode}
- \@@_pre_array:
+ \@@_pre_array:
}
% \end{macrocode}
+%
%
% \bigskip
% \subsection*{The environment \{NiceArrayWithDelims\}}
@@ -9511,15 +9576,10 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \medskip
+% Now, you create the diagonal nodes by using the |row| nodes and the |col|
+% nodes. If the engine is |xetex| or |luatex| we also create the ``½ nodes''.
% \begin{macrocode}
- \@@_create_diag_nodes:
- \str_if_empty:NF \l_@@_name_str
- {
- \pgfpicture
- \pgfrememberpicturepositiononpagetrue
- \pgfnodealias { \l_@@_name_str - ##1 } { \@@_env: - ##1 }
- \endpgfpicture
- }
+ \@@_create_diag_nodes:
% \end{macrocode}
%
% By default, the diagonal lines will be parallelized\footnote{It's possible to
@@ -9584,7 +9644,9 @@ version 2005/12/01 or later.
%
% \bigskip
% The following computes the ``corners'' (made up of empty cells) but if there
-% is no corner to compute, it will do nothing.
+% is no corner to compute, it will do nothing. The corners are computed
+% in |\l_@@_empty_corner_cells_seq| which will contain all the empty cells (and
+% not in a block) considered in the corners of the array.
% \begin{macrocode}
\@@_compute_corners:
% \end{macrocode}
@@ -9804,18 +9866,50 @@ version 2005/12/01 or later.
% \bigskip
% The following command creates the diagonal nodes (in fact, if the matrix is
% not a square matrix, not all the nodes are on the diagonal).
-%
% \begin{macrocode}
\cs_new_protected:Npn \@@_create_diag_nodes:
{
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
\int_step_inline:nn { \int_max:nn \c@iRow \c@jCol + 1 }
{
- \pgfpicture
- \pgfrememberpicturepositiononpagetrue
\@@_qpoint:n { row - \int_min:nn { ##1 } { \c@iRow + 1 } }
\dim_set_eq:NN \l_tmpa_dim \pgf@y
\@@_qpoint:n { col - \int_min:nn { ##1 } { \c@jCol + 1 } }
\pgfcoordinate { \@@_env: - ##1 } { \pgfpoint \pgf@x \l_tmpa_dim }
+ }
+ \pgfnodealias
+ { \@@_env: - last }
+ { \@@_env: - \int_eval:n { \int_max:nn \c@iRow \c@jCol + 1 } }
+ \endpgfpicture
+ }
+% \end{macrocode}
+%
+% \bigskip
+% As for now, the ½ nodes are not documented and they are created only in the
+% native \textsc{utf8} engines, that is to say XeLaTeX and LuaLaTeX.
+% \begin{macrocode}
+\bool_if:nT
+ { \sys_if_engine_xetex_p: || \sys_if_engine_luatex_p: }
+ { \tl_put_right:Nn \@@_create_diag_nodes: \@@_create_half_nodes: }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_create_half_nodes:
+ {
+ \int_step_inline:nn { \int_max:nn \c@iRow \c@jCol }
+ {
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgfcoordinate { \@@_env: - ##1 ½ }
+ {
+ \pgfpointscale { 0.5 }
+ {
+ \pgfpointadd
+ { \@@_qpoint:n { ##1 } }
+ { \@@_qpoint:n { \int_eval:n { ##1 + 1 } } }
+ }
+ }
\endpgfpicture
}
}
@@ -11564,13 +11658,13 @@ version 2005/12/01 or later.
% the execution of the |code-before|) don't directly draw the corresponding
% rectangles. Instead, they store their instructions color by color:
% \begin{itemize}
-% \item A sequence |\l_@@_colors_seq| will be built containing all the colors
+% \item A sequence |\g_@@_colors_seq| will be built containing all the colors
% used by at least one of these instructions. Each \emph{color} may be prefixed
% by it color model (eg: |[gray]{0.5}|).
-% \item For the color whose index in |\l_@@_colors_seq| is equal to~$i$, a list of
+% \item For the color whose index in |\g_@@_colors_seq| is equal to~$i$, a list of
% instructions which use that color will be constructed in the token list
-% |\l_@@_color_|$i$|_tl|. In that token list, the instructions will
-% |\@@_rowcolor:n|, |\@@_columncolor:n| and |\@@_rectanglecolor:nn|
+% |\g_@@_color_|$i$|_tl|. In that token list, the instructions will be written
+% using |\@@_rowcolor:n|, |\@@_columncolor:n| and |\@@_rectanglecolor:nn|
% (corresponding of |\@@_rowcolor|, |\@@_columncolor| and |\@@_rectanglecolor|).
% \end{itemize}
%
@@ -11578,8 +11672,11 @@ version 2005/12/01 or later.
% bigskip
% |#1| is the color and |#2| is an instruction using that color. Despite its
% name, the command |\@@_add_to_color_seq| doesn't only add a color to
-% |\l_@@_colors_seq|: it also updates the corresponding token list
-% |\l_@@_color_|$i$|_tl|.
+% |\g_@@_colors_seq|: it also updates the corresponding token list
+% |\g_@@_color_|$i$|_tl|. We add in a global way because the final user may use
+% the instructions such as |\cellcolor| in a loop of \pkg{pgffor} in the
+% |\CodeBefore| (and we recall that a loop of \pkg{pgffor} is encapsulated in a
+% group).
% \begin{macrocode}
\cs_new_protected:Npn \@@_add_to_colors_seq:nn #1 #2
{
@@ -11589,21 +11686,21 @@ version 2005/12/01 or later.
% |\l_tmpa_int| will remain equal to $0$.
% \begin{macrocode}
\int_zero:N \l_tmpa_int
- \seq_map_indexed_inline:Nn \l_@@_colors_seq
+ \seq_map_indexed_inline:Nn \g_@@_colors_seq
{ \tl_if_eq:nnT { #1 } { ##2 } { \int_set:Nn \l_tmpa_int { ##1 } } }
\int_compare:nNnTF \l_tmpa_int = \c_zero_int
% \end{macrocode}
% First, the case where the color is a \emph{new} color (not in the sequence).
% \begin{macrocode}
{
- \seq_put_right:Nn \l_@@_colors_seq { #1 }
- \tl_set:cn { l_@@_color _ \seq_count:N \l_@@_colors_seq _ tl } { #2 }
+ \seq_gput_right:Nn \g_@@_colors_seq { #1 }
+ \tl_gset:cx { g_@@_color _ \seq_count:N \g_@@_colors_seq _ tl } { #2 }
}
% \end{macrocode}
% Now, the case where the color is \emph{not} a new color (the color is in the
% sequence at the position |\l_tmpa_int|).
% \begin{macrocode}
- { \tl_put_right:cn { l_@@_color _ \int_use:N \l_tmpa_int _tl } { #2 } }
+ { \tl_gput_right:cx { g_@@_color _ \int_use:N \l_tmpa_int _tl } { #2 } }
}
% \end{macrocode}
%
@@ -11620,10 +11717,11 @@ version 2005/12/01 or later.
{
\pgfpicture
\pgf@relevantforpicturesizefalse
- \seq_map_indexed_inline:Nn \l_@@_colors_seq
+ \seq_map_indexed_inline:Nn \g_@@_colors_seq
{
\color ##2
- \use:c { l_@@_color _ ##1 _tl }
+ \use:c { g_@@_color _ ##1 _tl }
+ \tl_gclear:c { g_@@_color _ ##1 _tl }
\pgfusepath { fill }
}
\endpgfpicture
@@ -11771,7 +11869,87 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+% \bigskip
+% \begin{macrocode}
+\keys_define:nn { NiceMatrix / arraycolor }
+ {
+ except-corners .clist_set:N = \l_tmpa_clist ,
+ except-corners .default:n = { NW , SW , NE , SE }
+ }
+% \end{macrocode}
+%
+% \bigskip
+% The command |\@@_arraycolor| (linked to |\arraycolor| at the beginning of
+% the |\CodeBefore|) will color the whole tabular (excepted the potential
+% exterior rows and columns). The third argument is a optional argument which a
+% list of pairs key-value. As for now, there is only one key: |except-corners|.
+% When that key is used, the cells in the corners are not colored.
+% \begin{macrocode}
+\NewDocumentCommand \@@_arraycolor { O { } m O { } }
+ {
+ \keys_set:nn { NiceMatrix / arraycolor } { #3 }
+% \end{macrocode}
+% If the key |except-corners| is not used, it's easy: we only have a rectangle
+% fo fill.
+% \begin{macrocode}
+ \clist_if_empty:NTF \l_tmpa_clist
+ {
+ \@@_rectanglecolor [ #1 ] { #2 }
+ { 1 - 1 } { \int_use:N \c@iRow - \int_use:N \c@jCol }
+ }
+% \end{macrocode}
+% The interesting case is when the key |except-corners| is used. In that case,
+% we can't fill now the tabular because we don't know the list of the cells
+% of the corners. That's why we postpone the treatment in the |\CodeAfter|.
+% \begin{macrocode}
+ {
+ \tl_gput_left:Nx \g_@@_internal_code_after_tl
+ {
+ \@@_arraycolor_code_after:nnn
+ { #1 }
+ { \exp_not:n { #2 } }
+ { \l_tmpa_clist }
+ }
+ }
+ }
+% \end{macrocode}
+%
+% \bigskip
+% The following command will be used in the |\CodeAfter|. |#1| is the color
+% model, |#2| the color and |#3| the value of the key |except-corners| (a
+% sublist of |{NW,NE,SW,SE}|).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_arraycolor_code_after:nnn #1 #2 #3
+ {
+ \group_begin:
+% \end{macrocode}
+% First, we compute the corners.
+% \begin{macrocode}
+ \clist_set:Nn \l_@@_except_corners_clist { #3 }
+ \@@_compute_corners:
+% \end{macrocode}
+% Now, for each cell of the array (excepted the potential exterior rows and
+% columns) we check whether we have to fill that cell. When we have to fill the
+% cell, we do the job by writing an instruction in the |\CodeBefore| (in fact,
+% the ``|\CodeBefore|'' which will be written on the |aux| file for the next
+% run).
+% \begin{macrocode}
+ \int_step_inline:nn \c@iRow
+ {
+ \int_step_inline:nn \c@jCol
+ {
+ \seq_if_in:NnF \l_@@_empty_corner_cells_seq { ##1 - ####1 }
+ {
+ \tl_gput_left:Nx \g_nicematrix_code_before_tl
+ { \@@_cellcolor [ #1 ] { \exp_not:n { #2 } } { ##1 - ####1 } }
+ }
+ }
+ }
+ \group_end:
+ }
+% \end{macrocode}
%
+%
% \bigskip
% \begin{macrocode}
\keys_define:nn { NiceMatrix / rowcolors }
@@ -13755,6 +13933,8 @@ version 2005/12/01 or later.
rounded-corners .default:n = 4 pt ,
color .code:n = \color { #1 } \tl_set:Nn \l_@@_draw_tl { #1 } ,
color .value_required:n = true ,
+ borders .clist_set:N = \l_@@_borders_clist ,
+ borders .value_required:n = true ,
line-width .dim_set:N = \l_@@_line_width_dim ,
line-width .value_required:n = true ,
l .code:n = \tl_set:Nn \l_@@_pos_of_block_tl l ,
@@ -13843,11 +14023,8 @@ version 2005/12/01 or later.
\keys_set:nn { NiceMatrix / Block / SecondPass } { #5 }
% \end{macrocode}
%
-%
% \begin{macrocode}
- \bool_lazy_or:nnT
- { ! \tl_if_empty_p:N \l_@@_draw_tl }
- { \dim_compare_p:nNn \l_@@_line_width_dim > \c_zero_dim }
+ \tl_if_empty:NF \l_@@_draw_tl
{
\tl_gput_right:Nx \g_nicematrix_code_after_tl
{
@@ -13862,6 +14039,19 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \begin{macrocode}
+ \clist_if_empty:NF \l_@@_borders_clist
+ {
+ \tl_gput_right:Nx \g_nicematrix_code_after_tl
+ {
+ \@@_stroke_borders_block:nnn
+ { \exp_not:n { #5 } }
+ { #1 - #2 }
+ { \int_use:N \l_@@_last_row_int - \int_use:N \l_@@_last_col_int }
+ }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
\tl_if_empty:NF \l_@@_fill_tl
{
\tl_gput_right:Nx \g_nicematrix_code_before_tl
@@ -14153,7 +14343,7 @@ version 2005/12/01 or later.
% % \bigskip
% The first argument of |\@@_stroke_block:nnn| is a list of options for the
% rectangle that you will stroke. The second argument is the upper-left cell of
-% the block (with, as usual, the syntex $i$|-|$j$) and the third is the last
+% the block (with, as usual, the syntax $i$|-|$j$) and the third is the last
% cell of the block (with the same syntax).
% \begin{macrocode}
\cs_new_protected:Npn \@@_stroke_block:nnn #1 #2 #3
@@ -14204,7 +14394,7 @@ version 2005/12/01 or later.
{ \pgfpoint \l_tmpd_dim \l_tmpa_dim }
\pgfsetlinewidth { 1.1 \l_@@_line_width_dim }
% \end{macrocode}
-% We can't use |\pgfusepathqtroke| because of the key |rounded-corners|.
+% We can't use |\pgfusepathqstroke| because of the key |rounded-corners|.
% \begin{macrocode}
\pgfusepath { stroke }
}
@@ -14217,10 +14407,6 @@ version 2005/12/01 or later.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / BlockStroke }
{
-% \end{macrocode}
-% We will uncomment the following line when we will give to the key |color| of
-% the command |\Block| its new definition.
-% \begin{macrocode}
color .tl_set:N = \l_@@_draw_tl ,
draw .tl_set:N = \l_@@_draw_tl ,
draw .default:n = default ,
@@ -14231,6 +14417,94 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
+% The first argument of |\@@_stroke_borders_block:nnn| is a list of options for
+% the borders that you will stroke. The second argument is the upper-left cell
+% of the block (with, as usual, the syntax $i$|-|$j$) and the third is the last
+% cell of the block (with the same syntax).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_stroke_borders_block:nnn #1 #2 #3
+ {
+ \dim_set_eq:NN \l_@@_line_width_dim \arrayrulewidth
+ \keys_set_known:nn { NiceMatrix / BlockBorders } { #1 }
+ \dim_compare:nNnTF \l_@@_rounded_corners_dim > \c_zero_dim
+ { \@@_error:n { borders~forbidden } }
+ {
+ \clist_map_inline:Nn \l_@@_borders_clist
+ {
+ \clist_if_in:nnF { top , bottom , left , right } { ##1 }
+ { \@@_error:nn { bad~border } { ##1 } }
+ }
+ \@@_cut_on_hyphen:w #2 \q_stop
+ \tl_set_eq:NN \l_tmpc_tl \l_tmpa_tl
+ \tl_set_eq:NN \l_tmpd_tl \l_tmpb_tl
+ \@@_cut_on_hyphen:w #3 \q_stop
+ \tl_set:Nx \l_tmpa_tl { \int_eval:n { \l_tmpa_tl + 1 } }
+ \tl_set:Nx \l_tmpb_tl { \int_eval:n { \l_tmpb_tl + 1 } }
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgf@relevantforpicturesizefalse
+ \CT@arc@
+ \pgfsetlinewidth { 1.1 \l_@@_line_width_dim }
+ \clist_if_in:NnT \l_@@_borders_clist { right }
+ { \@@_stroke_vertical:n \l_tmpb_tl }
+ \clist_if_in:NnT \l_@@_borders_clist { left }
+ { \@@_stroke_vertical:n \l_tmpd_tl }
+ \clist_if_in:NnT \l_@@_borders_clist { bottom }
+ { \@@_stroke_horizontal:n \l_tmpa_tl }
+ \clist_if_in:NnT \l_@@_borders_clist { top }
+ { \@@_stroke_horizontal:n \l_tmpc_tl }
+ \endpgfpicture
+ }
+ }
+% \end{macrocode}
+%
+% \medskip
+% The following command is used to stroke the left border and the right border.
+% The argument |#1| is the number of column (in the sense of the |col| node).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_stroke_vertical:n #1
+ {
+ \@@_qpoint:n \l_tmpc_tl
+ \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \l_@@_line_width_dim }
+ \@@_qpoint:n \l_tmpa_tl
+ \dim_set:Nn \l_tmpc_dim { \pgf@y + 0.5 \l_@@_line_width_dim }
+ \@@_qpoint:n { #1 }
+ \pgfpathmoveto { \pgfpoint \pgf@x \l_tmpb_dim }
+ \pgfpathlineto { \pgfpoint \pgf@x \l_tmpc_dim }
+ \pgfusepathqstroke
+ }
+% \end{macrocode}
+%
+% \medskip
+% The following command is used to stroke the top border and the bottom border.
+% The argument |#1| is the number of row (in the sense of the |row| node).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_stroke_horizontal:n #1
+ {
+ \@@_qpoint:n \l_tmpd_tl
+ \clist_if_in:NnTF \l_@@_borders_clist { left }
+ { \dim_set:Nn \l_tmpa_dim { \pgf@x - 0.5 \l_@@_line_width_dim } }
+ { \dim_set:Nn \l_tmpa_dim { \pgf@x + 0.5 \l_@@_line_width_dim } }
+ \@@_qpoint:n \l_tmpb_tl
+ \dim_set:Nn \l_tmpb_dim { \pgf@x + 0.5 \l_@@_line_width_dim }
+ \@@_qpoint:n { #1 }
+ \pgfpathmoveto { \pgfpoint \l_tmpa_dim \pgf@y }
+ \pgfpathlineto { \pgfpoint \l_tmpb_dim \pgf@y }
+ \pgfusepathqstroke
+ }
+% \end{macrocode}
+%
+% \bigskip
+% Here is the set of keys for the command |\@@_stroke_borders_block:nnn|.
+% \begin{macrocode}
+\keys_define:nn { NiceMatrix / BlockBorders }
+ {
+ borders .clist_set:N = \l_@@_borders_clist ,
+ rounded-corners .dim_set:N = \l_@@_rounded_corners_dim ,
+ rounded-corners .default:n = 4 pt ,
+ line-width .dim_set:N = \l_@@_line_width_dim
+ }
+% \end{macrocode}
%
% \subsection*{How to draw the dotted lines transparently}
% \begin{macrocode}
@@ -14456,7 +14730,10 @@ version 2005/12/01 or later.
% square brackets. Here is the corresponding set of keys.
% \begin{macrocode}
\keys_define:nn { NiceMatrix }
- { CodeAfter / rules .inherit:n = NiceMatrix / rules }
+ {
+ CodeAfter / rules .inherit:n = NiceMatrix / rules ,
+ CodeAfter / sub-matrix .inherit:n = NiceMatrix / sub-matrix
+ }
\keys_define:nn { NiceMatrix / CodeAfter }
{
sub-matrix .code:n = \keys_set:nn { NiceMatrix / sub-matrix } { #1 } ,
@@ -14639,11 +14916,21 @@ version 2005/12/01 or later.
delimiters / color .value_required:n = true ,
slim .bool_set:N = \l_@@_submatrix_slim_bool ,
slim .default:n = true ,
+ hlines .clist_set:N = \l_@@_submatrix_hlines_clist ,
+ hlines .default:n = all ,
+ vlines .clist_set:N = \l_@@_submatrix_vlines_clist ,
+ vlines .default:n = all ,
+ hvlines .meta:n = { hlines, vlines } ,
+ hvlines .value_forbidden:n = true ,
}
\keys_define:nn { NiceMatrix }
{
SubMatrix .inherit:n = NiceMatrix / sub-matrix ,
CodeAfter / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,
+ NiceMatrix / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,
+ NiceArray / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,
+ pNiceArray / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,
+ NiceMatrixOptions / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,
}
% \end{macrocode}
%
@@ -14653,9 +14940,9 @@ version 2005/12/01 or later.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / SubMatrix }
{
- hlines .clist_set:N = \l_@@_hlines_clist ,
+ hlines .clist_set:N = \l_@@_submatrix_hlines_clist ,
hlines .default:n = all ,
- vlines .clist_set:N = \l_@@_vlines_clist ,
+ vlines .clist_set:N = \l_@@_submatrix_vlines_clist ,
vlines .default:n = all ,
hvlines .meta:n = { hlines, vlines } ,
hvlines .value_forbidden:n = true ,
@@ -14738,8 +15025,6 @@ version 2005/12/01 or later.
{ \@@_error:n { SubMatrix~too~large } }
{
\str_clear_new:N \l_@@_submatrix_name_str
- \clist_clear:N \l_@@_hlines_clist
- \clist_clear:N \l_@@_vlines_clist
\keys_set:nn { NiceMatrix / SubMatrix } { #5 }
\pgfpicture
\pgfrememberpicturepositiononpagetrue
@@ -14837,9 +15122,9 @@ version 2005/12/01 or later.
% The last argument of |\int_step_inline:nn| or |\clist_map_inline:Nn| is given
% by curryfication.
% \begin{macrocode}
- \tl_if_eq:NnTF \l_@@_vlines_clist { all }
+ \tl_if_eq:NnTF \l_@@_submatrix_vlines_clist { all }
{ \int_step_inline:nn { \l_@@_last_j_tl - \l_@@_first_j_tl } }
- { \clist_map_inline:Nn \l_@@_vlines_clist }
+ { \clist_map_inline:Nn \l_@@_submatrix_vlines_clist }
{
\bool_lazy_and:nnTF
{ \int_compare_p:nNn { ##1 } > 0 }
@@ -14862,9 +15147,9 @@ version 2005/12/01 or later.
% The last argument of |\int_step_inline:nn| or |\clist_map_inline:Nn| is given
% by curryfication.
% \begin{macrocode}
- \tl_if_eq:NnTF \l_@@_hlines_clist { all }
+ \tl_if_eq:NnTF \l_@@_submatrix_hlines_clist { all }
{ \int_step_inline:nn { \l_@@_last_i_tl - \l_@@_first_i_tl } }
- { \clist_map_inline:Nn \l_@@_hlines_clist }
+ { \clist_map_inline:Nn \l_@@_submatrix_hlines_clist }
{
\bool_lazy_and:nnTF
{ \int_compare_p:nNn { ##1 } > 0 }
@@ -14910,8 +15195,8 @@ version 2005/12/01 or later.
%
% \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).
+% node with that name for the submatrix (this node does not encompass the
+% delimiters that we will put after).
% \begin{macrocode}
\str_if_empty:NF \l_@@_submatrix_name_str
{
@@ -15577,6 +15862,16 @@ version 2005/12/01 or later.
If~you~go~on,~this~specification~of~corner~will~be~ignored.
}
% \end{macrocode}
+%
+% \begin{macrocode}
+\@@_msg_new:nn { bad~border }
+ {
+ #1~is~an~incorrect~specification~for~a~border~(in~the~key~
+ 'borders'~of~the~command~\token_to_str:N \Block).~The~available~
+ values~are:~left,~right,~top~and~bottom.\\
+ If~you~go~on,~this~specification~of~border~will~be~ignored.
+ }
+% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { last-col~non~empty~for~NiceArray }
@@ -15642,6 +15937,16 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \begin{macrocode}
+\@@_msg_new:nn { borders~forbidden }
+ {
+ You~can't~use~the~key~'borders'~of~the~command~\token_to_str:N \Block\
+ because~the~option~'rounded-corners'~
+ is~in~force~with~a~non-zero~value.\\
+ If~you~go~on,~this~key~will~be~ignored.
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
\@@_msg_new:nn { bottomrule~without~booktabs }
{
You~can't~use~the~key~'tabular/bottomrule'~because~you~haven't~
@@ -15702,7 +16007,7 @@ version 2005/12/01 or later.
For~a~list~of~the~available~keys,~type~H~<return>.
}
{
- The~available~keys~are~(in~alphabetic~order):~c,~draw,~fill,~l,~
+ The~available~keys~are~(in~alphabetic~order):~borders,~c,~draw,~fill,~l,~
line-width,~rounded-corners~and~r.
}
% \end{macrocode}
@@ -16426,7 +16731,7 @@ version 2005/12/01 or later.
%
% New command |\SubMatrix| available in the |\CodeAfter|.
%
-% It's possible to provide options (between brackets) to the command |\CodeAfter|.
+% It's possible to provide options (between brackets) to the keyword |\CodeAfter|.
%
% A (non fatal) error is raised when the key |transparent|, which is
% deprecated, is used.
@@ -16434,10 +16739,10 @@ version 2005/12/01 or later.
% \subsection*{Changes between versions 5.10 and 5.11}
%
% It's now possible, in the |code-before| and in the |\CodeAfter|, to use the
-% syntax \verb+(i-|j)+ for the Tikz node at the intersection of the (potential)
+% syntax \verb+|(i-|j)+ for the Tikz node at the intersection of the (potential)
% horizontal rule number~$i$ and the (potential) vertical rule number~$j$.
%
-% % \subsection*{Changes between versions 5.11 and 5.12}
+% \subsection*{Changes between versions 5.11 and 5.12}
%
% Keywords |\CodeBefore| and |\Body| (alternative syntax to the key
% |code-before|).
@@ -16448,6 +16753,18 @@ version 2005/12/01 or later.
% |\CodeAfter|.
%
% New key |rounded-corners| for the command |\Block|.
+%
+% \subsection*{Changes between versions 5.12 and 5.13}
+%
+% New command |\arraycolor| in the |\CodeBefore| (with its key
+% |except-corners|).
+%
+% New key |borders| for the command |\Block|.
+%
+% New command |\Hline| (for horizontal rules not drawn in the blocks).
+%
+% The keys |vlines| and |hlines| takes in as value a (comma-separated) list of
+% numbers (for the rules to draw).
%
% \PrintIndex
%
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
index 671bc44ef0c..da3db9af6f1 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.12}
-\def\myfiledate{2021/03/10}
+\def\myfileversion{5.13}
+\def\myfiledate{2021/03/23}
\RequirePackage{pgfcore}
\usepgfmodule{shapes}
\RequirePackage{l3keys2e}
@@ -319,6 +319,7 @@
\int_new:N \g__nicematrix_static_num_of_col_int
\tl_new:N \l__nicematrix_fill_tl
\tl_new:N \l__nicematrix_draw_tl
+\clist_new:N \l__nicematrix_borders_clist
\dim_new:N \l__nicematrix_rounded_corners_dim
\tl_new:N \l__nicematrix_color_tl
\dim_new:N \l__nicematrix_line_width_dim
@@ -331,6 +332,8 @@
\dim_new:N \l__nicematrix_submatrix_right_xshift_dim
\clist_new:N \l__nicematrix_hlines_clist
\clist_new:N \l__nicematrix_vlines_clist
+\clist_new:N \l__nicematrix_submatrix_hlines_clist
+\clist_new:N \l__nicematrix_submatrix_vlines_clist
\int_new:N \l__nicematrix_first_row_int
\int_set:Nn \l__nicematrix_first_row_int 1
\int_new:N \l__nicematrix_first_col_int
@@ -1242,11 +1245,12 @@
\cs_set_eq:NN \roundedrectanglecolor \__nicematrix_roundedrectanglecolor
\cs_set_eq:NN \rowcolor \__nicematrix_rowcolor
\cs_set_eq:NN \rowcolors \__nicematrix_rowcolors
+ \cs_set_eq:NN \arraycolor \__nicematrix_arraycolor
\cs_set_eq:NN \columncolor \__nicematrix_columncolor
\cs_set_eq:NN \chessboardcolors \__nicematrix_chessboardcolors
\cs_set_eq:NN \SubMatrix \__nicematrix_SubMatrix_in_code_before
\bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token
- \seq_clear_new:N \l__nicematrix_colors_seq
+ \seq_gclear_new:N \g__nicematrix_colors_seq
\exp_last_unbraced:NV \__nicematrix_CodeAfter_keys: \l__nicematrix_code_before_tl
\__nicematrix_actually_color:
\bool_if:NT \l__nicematrix_NiceTabular_bool \c_math_toggle_token
@@ -2381,14 +2385,7 @@
}
\iow_now:Nn \@mainaux \ExplSyntaxOff
}
- \__nicematrix_create_diag_nodes:
- \str_if_empty:NF \l__nicematrix_name_str
- {
- \pgfpicture
- \pgfrememberpicturepositiononpagetrue
- \pgfnodealias { \l__nicematrix_name_str - ##1 } { \__nicematrix_env: - ##1 }
- \endpgfpicture
- }
+ \__nicematrix_create_diag_nodes:
\bool_if:NT \l__nicematrix_parallelize_diags_bool
{
\int_gzero_new:N \g__nicematrix_ddots_int
@@ -2514,14 +2511,38 @@
}
\cs_new_protected:Npn \__nicematrix_create_diag_nodes:
{
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
\int_step_inline:nn { \int_max:nn \c@iRow \c@jCol + 1 }
{
- \pgfpicture
- \pgfrememberpicturepositiononpagetrue
\__nicematrix_qpoint:n { row - \int_min:nn { ##1 } { \c@iRow + 1 } }
\dim_set_eq:NN \l_tmpa_dim \pgf@y
\__nicematrix_qpoint:n { col - \int_min:nn { ##1 } { \c@jCol + 1 } }
\pgfcoordinate { \__nicematrix_env: - ##1 } { \pgfpoint \pgf@x \l_tmpa_dim }
+ }
+ \pgfnodealias
+ { \__nicematrix_env: - last }
+ { \__nicematrix_env: - \int_eval:n { \int_max:nn \c@iRow \c@jCol + 1 } }
+ \endpgfpicture
+ }
+\bool_if:nT
+ { \sys_if_engine_xetex_p: || \sys_if_engine_luatex_p: }
+ { \tl_put_right:Nn \__nicematrix_create_diag_nodes: \__nicematrix_create_half_nodes: }
+\cs_new_protected:Npn \__nicematrix_create_half_nodes:
+ {
+ \int_step_inline:nn { \int_max:nn \c@iRow \c@jCol }
+ {
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgfcoordinate { \__nicematrix_env: - ##1 ½ }
+ {
+ \pgfpointscale { 0.5 }
+ {
+ \pgfpointadd
+ { \__nicematrix_qpoint:n { ##1 } }
+ { \__nicematrix_qpoint:n { \int_eval:n { ##1 + 1 } } }
+ }
+ }
\endpgfpicture
}
}
@@ -3646,24 +3667,25 @@
\cs_new_protected:Npn \__nicematrix_add_to_colors_seq:nn #1 #2
{
\int_zero:N \l_tmpa_int
- \seq_map_indexed_inline:Nn \l__nicematrix_colors_seq
+ \seq_map_indexed_inline:Nn \g__nicematrix_colors_seq
{ \tl_if_eq:nnT { #1 } { ##2 } { \int_set:Nn \l_tmpa_int { ##1 } } }
\int_compare:nNnTF \l_tmpa_int = \c_zero_int
{
- \seq_put_right:Nn \l__nicematrix_colors_seq { #1 }
- \tl_set:cn { l__nicematrix_color _ \seq_count:N \l__nicematrix_colors_seq _ tl } { #2 }
+ \seq_gput_right:Nn \g__nicematrix_colors_seq { #1 }
+ \tl_gset:cx { g__nicematrix_color _ \seq_count:N \g__nicematrix_colors_seq _ tl } { #2 }
}
- { \tl_put_right:cn { l__nicematrix_color _ \int_use:N \l_tmpa_int _tl } { #2 } }
+ { \tl_gput_right:cx { g__nicematrix_color _ \int_use:N \l_tmpa_int _tl } { #2 } }
}
\cs_generate_variant:Nn \__nicematrix_add_to_colors_seq:nn { x n }
\cs_new_protected:Npn \__nicematrix_actually_color:
{
\pgfpicture
\pgf@relevantforpicturesizefalse
- \seq_map_indexed_inline:Nn \l__nicematrix_colors_seq
+ \seq_map_indexed_inline:Nn \g__nicematrix_colors_seq
{
\color ##2
- \use:c { l__nicematrix_color _ ##1 _tl }
+ \use:c { g__nicematrix_color _ ##1 _tl }
+ \tl_gclear:c { g__nicematrix_color _ ##1 _tl }
\pgfusepath { fill }
}
\endpgfpicture
@@ -3751,6 +3773,47 @@
}
}
}
+\keys_define:nn { NiceMatrix / arraycolor }
+ {
+ except-corners .clist_set:N = \l_tmpa_clist ,
+ except-corners .default:n = { NW , SW , NE , SE }
+ }
+\NewDocumentCommand \__nicematrix_arraycolor { O { } m O { } }
+ {
+ \keys_set:nn { NiceMatrix / arraycolor } { #3 }
+ \clist_if_empty:NTF \l_tmpa_clist
+ {
+ \__nicematrix_rectanglecolor [ #1 ] { #2 }
+ { 1 - 1 } { \int_use:N \c@iRow - \int_use:N \c@jCol }
+ }
+ {
+ \tl_gput_left:Nx \g__nicematrix_internal_code_after_tl
+ {
+ \__nicematrix_arraycolor_code_after:nnn
+ { #1 }
+ { \exp_not:n { #2 } }
+ { \l_tmpa_clist }
+ }
+ }
+ }
+\cs_new_protected:Npn \__nicematrix_arraycolor_code_after:nnn #1 #2 #3
+ {
+ \group_begin:
+ \clist_set:Nn \l__nicematrix_except_corners_clist { #3 }
+ \__nicematrix_compute_corners:
+ \int_step_inline:nn \c@iRow
+ {
+ \int_step_inline:nn \c@jCol
+ {
+ \seq_if_in:NnF \l__nicematrix_empty_corner_cells_seq { ##1 - ####1 }
+ {
+ \tl_gput_left:Nx \g_nicematrix_code_before_tl
+ { \__nicematrix_cellcolor [ #1 ] { \exp_not:n { #2 } } { ##1 - ####1 } }
+ }
+ }
+ }
+ \group_end:
+ }
\keys_define:nn { NiceMatrix / rowcolors }
{
respect-blocks .bool_set:N = \l__nicematrix_respect_blocks_bool ,
@@ -4877,6 +4940,8 @@
rounded-corners .default:n = 4 pt ,
color .code:n = \color { #1 } \tl_set:Nn \l__nicematrix_draw_tl { #1 } ,
color .value_required:n = true ,
+ borders .clist_set:N = \l__nicematrix_borders_clist ,
+ borders .value_required:n = true ,
line-width .dim_set:N = \l__nicematrix_line_width_dim ,
line-width .value_required:n = true ,
l .code:n = \tl_set:Nn \l__nicematrix_pos_of_block_tl l ,
@@ -4927,9 +4992,7 @@
\seq_gput_left:Nn \g__nicematrix_pos_of_blocks_seq { { #1 } { #2 } { #3 } { #4 } }
\group_begin:
\keys_set:nn { NiceMatrix / Block / SecondPass } { #5 }
- \bool_lazy_or:nnT
- { ! \tl_if_empty_p:N \l__nicematrix_draw_tl }
- { \dim_compare_p:nNn \l__nicematrix_line_width_dim > \c_zero_dim }
+ \tl_if_empty:NF \l__nicematrix_draw_tl
{
\tl_gput_right:Nx \g_nicematrix_code_after_tl
{
@@ -4941,6 +5004,16 @@
\seq_gput_right:Nn \g__nicematrix_pos_of_stroken_blocks_seq
{ { #1 } { #2 } { #3 } { #4 } }
}
+ \clist_if_empty:NF \l__nicematrix_borders_clist
+ {
+ \tl_gput_right:Nx \g_nicematrix_code_after_tl
+ {
+ \__nicematrix_stroke_borders_block:nnn
+ { \exp_not:n { #5 } }
+ { #1 - #2 }
+ { \int_use:N \l__nicematrix_last_row_int - \int_use:N \l__nicematrix_last_col_int }
+ }
+ }
\tl_if_empty:NF \l__nicematrix_fill_tl
{
\tl_gput_right:Nx \g_nicematrix_code_before_tl
@@ -5164,6 +5237,71 @@
rounded-corners .dim_set:N = \l__nicematrix_rounded_corners_dim ,
rounded-corners .default:n = 4 pt
}
+\cs_new_protected:Npn \__nicematrix_stroke_borders_block:nnn #1 #2 #3
+ {
+ \dim_set_eq:NN \l__nicematrix_line_width_dim \arrayrulewidth
+ \keys_set_known:nn { NiceMatrix / BlockBorders } { #1 }
+ \dim_compare:nNnTF \l__nicematrix_rounded_corners_dim > \c_zero_dim
+ { \__nicematrix_error:n { borders~forbidden } }
+ {
+ \clist_map_inline:Nn \l__nicematrix_borders_clist
+ {
+ \clist_if_in:nnF { top , bottom , left , right } { ##1 }
+ { \__nicematrix_error:nn { bad~border } { ##1 } }
+ }
+ \__nicematrix_cut_on_hyphen:w #2 \q_stop
+ \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 #3 \q_stop
+ \tl_set:Nx \l_tmpa_tl { \int_eval:n { \l_tmpa_tl + 1 } }
+ \tl_set:Nx \l_tmpb_tl { \int_eval:n { \l_tmpb_tl + 1 } }
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgf@relevantforpicturesizefalse
+ \CT@arc@
+ \pgfsetlinewidth { 1.1 \l__nicematrix_line_width_dim }
+ \clist_if_in:NnT \l__nicematrix_borders_clist { right }
+ { \__nicematrix_stroke_vertical:n \l_tmpb_tl }
+ \clist_if_in:NnT \l__nicematrix_borders_clist { left }
+ { \__nicematrix_stroke_vertical:n \l_tmpd_tl }
+ \clist_if_in:NnT \l__nicematrix_borders_clist { bottom }
+ { \__nicematrix_stroke_horizontal:n \l_tmpa_tl }
+ \clist_if_in:NnT \l__nicematrix_borders_clist { top }
+ { \__nicematrix_stroke_horizontal:n \l_tmpc_tl }
+ \endpgfpicture
+ }
+ }
+\cs_new_protected:Npn \__nicematrix_stroke_vertical:n #1
+ {
+ \__nicematrix_qpoint:n \l_tmpc_tl
+ \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \l__nicematrix_line_width_dim }
+ \__nicematrix_qpoint:n \l_tmpa_tl
+ \dim_set:Nn \l_tmpc_dim { \pgf@y + 0.5 \l__nicematrix_line_width_dim }
+ \__nicematrix_qpoint:n { #1 }
+ \pgfpathmoveto { \pgfpoint \pgf@x \l_tmpb_dim }
+ \pgfpathlineto { \pgfpoint \pgf@x \l_tmpc_dim }
+ \pgfusepathqstroke
+ }
+\cs_new_protected:Npn \__nicematrix_stroke_horizontal:n #1
+ {
+ \__nicematrix_qpoint:n \l_tmpd_tl
+ \clist_if_in:NnTF \l__nicematrix_borders_clist { left }
+ { \dim_set:Nn \l_tmpa_dim { \pgf@x - 0.5 \l__nicematrix_line_width_dim } }
+ { \dim_set:Nn \l_tmpa_dim { \pgf@x + 0.5 \l__nicematrix_line_width_dim } }
+ \__nicematrix_qpoint:n \l_tmpb_tl
+ \dim_set:Nn \l_tmpb_dim { \pgf@x + 0.5 \l__nicematrix_line_width_dim }
+ \__nicematrix_qpoint:n { #1 }
+ \pgfpathmoveto { \pgfpoint \l_tmpa_dim \pgf@y }
+ \pgfpathlineto { \pgfpoint \l_tmpb_dim \pgf@y }
+ \pgfusepathqstroke
+ }
+\keys_define:nn { NiceMatrix / BlockBorders }
+ {
+ borders .clist_set:N = \l__nicematrix_borders_clist ,
+ rounded-corners .dim_set:N = \l__nicematrix_rounded_corners_dim ,
+ rounded-corners .default:n = 4 pt ,
+ line-width .dim_set:N = \l__nicematrix_line_width_dim
+ }
\cs_set_protected:Npn \__nicematrix_renew_matrix:
{
\RenewDocumentEnvironment { pmatrix } { }
@@ -5298,7 +5436,10 @@
\endpgfpicture
}
\keys_define:nn { NiceMatrix }
- { CodeAfter / rules .inherit:n = NiceMatrix / rules }
+ {
+ CodeAfter / rules .inherit:n = NiceMatrix / rules ,
+ CodeAfter / sub-matrix .inherit:n = NiceMatrix / sub-matrix
+ }
\keys_define:nn { NiceMatrix / CodeAfter }
{
sub-matrix .code:n = \keys_set:nn { NiceMatrix / sub-matrix } { #1 } ,
@@ -5393,17 +5534,27 @@
delimiters / color .value_required:n = true ,
slim .bool_set:N = \l__nicematrix_submatrix_slim_bool ,
slim .default:n = true ,
+ hlines .clist_set:N = \l__nicematrix_submatrix_hlines_clist ,
+ hlines .default:n = all ,
+ vlines .clist_set:N = \l__nicematrix_submatrix_vlines_clist ,
+ vlines .default:n = all ,
+ hvlines .meta:n = { hlines, vlines } ,
+ hvlines .value_forbidden:n = true ,
}
\keys_define:nn { NiceMatrix }
{
SubMatrix .inherit:n = NiceMatrix / sub-matrix ,
CodeAfter / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,
+ NiceMatrix / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,
+ NiceArray / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,
+ pNiceArray / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,
+ NiceMatrixOptions / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,
}
\keys_define:nn { NiceMatrix / SubMatrix }
{
- hlines .clist_set:N = \l__nicematrix_hlines_clist ,
+ hlines .clist_set:N = \l__nicematrix_submatrix_hlines_clist ,
hlines .default:n = all ,
- vlines .clist_set:N = \l__nicematrix_vlines_clist ,
+ vlines .clist_set:N = \l__nicematrix_submatrix_vlines_clist ,
vlines .default:n = all ,
hvlines .meta:n = { hlines, vlines } ,
hvlines .value_forbidden:n = true ,
@@ -5461,8 +5612,6 @@
{ \__nicematrix_error:n { SubMatrix~too~large } }
{
\str_clear_new:N \l__nicematrix_submatrix_name_str
- \clist_clear:N \l__nicematrix_hlines_clist
- \clist_clear:N \l__nicematrix_vlines_clist
\keys_set:nn { NiceMatrix / SubMatrix } { #5 }
\pgfpicture
\pgfrememberpicturepositiononpagetrue
@@ -5537,9 +5686,9 @@
}
}
}
- \tl_if_eq:NnTF \l__nicematrix_vlines_clist { all }
+ \tl_if_eq:NnTF \l__nicematrix_submatrix_vlines_clist { all }
{ \int_step_inline:nn { \l__nicematrix_last_j_tl - \l__nicematrix_first_j_tl } }
- { \clist_map_inline:Nn \l__nicematrix_vlines_clist }
+ { \clist_map_inline:Nn \l__nicematrix_submatrix_vlines_clist }
{
\bool_lazy_and:nnTF
{ \int_compare_p:nNn { ##1 } > 0 }
@@ -5554,9 +5703,9 @@
}
{ \__nicematrix_error:nnn { Wrong~line~in~SubMatrix } { vertical } { ##1 } }
}
- \tl_if_eq:NnTF \l__nicematrix_hlines_clist { all }
+ \tl_if_eq:NnTF \l__nicematrix_submatrix_hlines_clist { all }
{ \int_step_inline:nn { \l__nicematrix_last_i_tl - \l__nicematrix_first_i_tl } }
- { \clist_map_inline:Nn \l__nicematrix_hlines_clist }
+ { \clist_map_inline:Nn \l__nicematrix_submatrix_hlines_clist }
{
\bool_lazy_and:nnTF
{ \int_compare_p:nNn { ##1 } > 0 }
@@ -5986,6 +6135,13 @@
values~are:~NW,~SW,~NE~and~SE.\\
If~you~go~on,~this~specification~of~corner~will~be~ignored.
}
+\__nicematrix_msg_new:nn { bad~border }
+ {
+ #1~is~an~incorrect~specification~for~a~border~(in~the~key~
+ 'borders'~of~the~command~\token_to_str:N \Block).~The~available~
+ values~are:~left,~right,~top~and~bottom.\\
+ If~you~go~on,~this~specification~of~border~will~be~ignored.
+ }
\__nicematrix_msg_new:nn { last-col~non~empty~for~NiceArray }
{
In~the~\__nicematrix_full_name_env:,~you~must~use~the~key~
@@ -6028,6 +6184,13 @@
\{NiceTabular\},~\{NiceArray\}~and~\{NiceMatrix\}. \\
If~you~go~on,~this~command~will~be~ignored.
}
+\__nicematrix_msg_new:nn { borders~forbidden }
+ {
+ You~can't~use~the~key~'borders'~of~the~command~\token_to_str:N \Block\
+ because~the~option~'rounded-corners'~
+ is~in~force~with~a~non-zero~value.\\
+ If~you~go~on,~this~key~will~be~ignored.
+ }
\__nicematrix_msg_new:nn { bottomrule~without~booktabs }
{
You~can't~use~the~key~'tabular/bottomrule'~because~you~haven't~
@@ -6068,7 +6231,7 @@
For~a~list~of~the~available~keys,~type~H~<return>.
}
{
- The~available~keys~are~(in~alphabetic~order):~c,~draw,~fill,~l,~
+ The~available~keys~are~(in~alphabetic~order):~borders,~c,~draw,~fill,~l,~
line-width,~rounded-corners~and~r.
}
\__nicematrix_msg_new:nnn { Unknown~key~for~CodeAfter }