summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-11-08 21:43:02 +0000
committerKarl Berry <karl@freefriends.org>2020-11-08 21:43:02 +0000
commit330a5d5e1832e427f5b0b04fbc9dd67ea57641d0 (patch)
treee763145ea243a0ab676fe0bf0af9f9cb4e56a916
parent3ba883f307860f57384b9ce62c0ecb3c0d9f6376 (diff)
nicematrix (8nov20)
git-svn-id: svn://tug.org/texlive/trunk@56887 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdfbin423871 -> 424627 bytes
-rw-r--r--Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex142
-rw-r--r--Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdfbin1046980 -> 1061552 bytes
-rw-r--r--Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx649
-rw-r--r--Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty338
5 files changed, 793 insertions, 336 deletions
diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf
index 134a5ab09f9..d2425b4bb20 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 be326a01d4c..52949c1d76a 100644
--- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex
+++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex
@@ -413,12 +413,22 @@ Dans les environnements de \pkg{nicematrix}, on peut utiliser la commande
|\Block| pour placer un élément au centre d'un rectangle de cases fusionnées.
La commande |\Block| doit être utilisée dans la case supérieure gauche du bloc
-avec deux arguments. Le premier argument est la taille de ce bloc avec la
-syntaxe $i$-$j$ où $i$ est le nombre de rangées et $j$ le nombre de colonnes du
-bloc. Le deuxième argument, est, sans surprise, le contenu du bloc.
+avec deux arguments.
+
+\begin{itemize}
+\item Le premier argument est la taille de ce bloc avec la syntaxe $i$-$j$ où
+$i$ est le nombre de rangées et $j$ le nombre de colonnes du bloc.
+
+\colorbox{yellow!50}{\bfseries Nouveau 5.6}\enskip Si cet argument est laissé
+blanc, la valeur par défaut est |1-1|. Si le nombre de rangées n'est pas
+indiqué, le bloc s'étend jusqu'à la dernière rangée (idem pour les colonnes).
+
+\item Le deuxième argument, est le contenu du bloc. On peut utiliser |\\| dans
+ce contenu pour avoir un contenu sur plusieurs lignes. Dans |{NiceTabular}|, le
+contenu est composé en mode texte tandis que, dans les autres environnements, il
+est composé en mode mathématique.
+\end{itemize}
-Dans |{NiceTabular}|, le contenu est composé en mode texte. Dans les autres
-environnements, il est composé en mode mathématique.
\interitem
@@ -447,7 +457,10 @@ On peut souhaiter agrandir la taille du «$A$» placé dans le bloc de l'exemple
précédent. Comme il est composé en mode mathématique, on ne peut pas directement
utiliser une commande comme |\large|, |\Large| ou |\LARGE|. C'est pourquoi une
option à mettre entre chevrons est proposée par |\Block| pour spécifier du code
-LaTeX qui sera inséré \emph{avant} le début du mode mathématique.
+LaTeX qui sera inséré \emph{avant} le début du mode mathématique.\footnote{Cet
+ argument entre chevrons peut aussi être utilisé pour insérer une commande de
+ fonte comme |\bfseries| dans le cas où la commande |\\| est utilisée dans le
+ contenu du bloc.}
\medskip
\begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
@@ -469,8 +482,7 @@ $\begin{bNiceArray}{ccc|c}[margin]
\bigskip
-\colorbox{yellow!30}{Nouveau 5.3}\enskip On peut régler le positionnement
-horizontal du bloc avec l'une des clés |l|, |c| et |r|.
+On peut régler le positionnement horizontal du bloc avec l'une des clés |l|, |c| et |r|.
\medskip
@@ -493,9 +505,10 @@ $\begin{bNiceArray}{ccc|c}[margin]
\interitem
-\textbf{On doit remarquer que, par défaut, les blocs ne créent pas d'espace}
-(seuls les blocks mono-colonne font exception dans une certaine mesure : voir
-plus bas).
+\textbf{On doit remarquer que, par défaut, les blocs ne créent pas d'espace}. Il
+n'y a exception que pour les blocs mono-rangée et les blocs mono-colonne comme
+expliqué juste après.
+
\medskip
Dans l'exemple suivant, on a dû élargir à la main les colonnes 2 et 3 (avec la
@@ -524,6 +537,7 @@ arum & iris & jacinthe & muguet
+
\subsection{Les blocs mono-colonne}
\colorbox{yellow!30}{Nouveau 5.4}\enskip Les blocs mono-colonne ont un
@@ -534,7 +548,7 @@ largeur de la colonne courante.
\item La spécification d'alignement horizontal donnée par le type de
colonne (|c|, |r| ou |l|) est prise en compte pour le bloc (mais le bloc peut
-avoir sa propre specification d'alignement horizontal).
+avoir sa propre spécification d'alignement horizontal).
\item Les spécifications de fontes imposées à une colonne via la construction
|>{...}| dans le préambule du tableau sont prises en compte pour les
@@ -574,6 +588,63 @@ Henri & 14 \\ \hline
\end{scope}
+\subsection{Les blocs mono-rangée}
+
+\colorbox{yellow!50}{\textbf{Nouveau 5.6}}\enskip Pour les blocs mono-rangée, la
+hauteur (\emph{height}) et la profondeur (\emph{depth}) naturelles sont prises en
+compte pour la hauteur et la largeur de la rangée en cours (comme le fait la
+commande standard |\multicolumn| de LaTeX).
+
+
+
+
+\subsection{Les blocs mono-cellule}
+
+Les blocs mono-cellule héritent des caractéristiques des blocs mono-colonne et
+des blocs mono-rangée.
+
+\medskip
+Il y a deux raisons à l'utilisation d'un bloc mono-cellule.
+
+\begin{itemize}
+\item Un bloc mono-cellule permet d'utiliser la commande |\\| pour composer le
+bloc sur plusieurs lignes.
+
+\item On peut utiliser l'option d'alignement horizontal du bloc pour déroger à
+la consigne générale donnée dans le préambule pour cette colonne.
+\end{itemize}
+
+\medskip
+\begin{BVerbatim}[baseline=c,boxwidth=10cm]
+\begin{NiceTabular}{cc}
+\toprule
+Écrivain
+& ~emphase#\Block[l]{}{année de\\ naissance}@ \\
+\midrule
+Hugo & 1802 \\
+Balzac & 1799 \\
+\bottomrule
+\end{NiceTabular}
+\end{BVerbatim}
+%
+\begin{NiceTabular}{cc}
+\toprule
+Écrivain
+& \Block[l]{}{année de\\ naissance} \\
+\midrule
+Hugo & 1802 \\
+Balzac & 1799 \\
+\bottomrule
+\end{NiceTabular}
+
+\medskip
+On rappelle que si le premier argument obligatoire de |\Block| est laisssé
+blanc, alors le bloc est mono-cellule\footnote{On peut considérer que la valeur par
+défaut de ce premier argument obligatoire est |1-1|.}.
+
+
+
+
\subsection{Petite remarque}
On remarquera que le centrage horizontal du contenu des blocs est
@@ -836,7 +907,7 @@ $\begin{pNiceMatrix}[vlines,rules/width=0.2pt]
\label{hvlines}
La clé |hvlines| demande le tracé de tous les filets horizontaux et verticaux
-(sauf dans les blocs et dans les blocks virtuels déterminés par des
+(sauf dans les blocs et dans les blocs virtuels déterminés par des
lignes en pointillés).
\medskip
@@ -862,7 +933,7 @@ arum & iris & jacinthe & muguet
\subsection{La clé hvlines-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 blocks virtuels déterminés par des
+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.
\medskip
@@ -2266,7 +2337,7 @@ après le mot-clé |\CodeAfter|\footnote{Dans certaines circonstances, on doit
de la cellule courante.} (pour un exemple, voir page
\pageref{exemple-CodeAfter}). \colorbox{yellow!50}{\textbf{Nouveau 5.5}}\enskip
Avant la version 5.5, il fallait parfois mettre le mot-clé |\omit| devant
-|\CodeAfter| dans certains circonstances. Depuis la version 5.5, on ne doit
+|\CodeAfter| dans certaines circonstances. Depuis la version 5.5, on ne doit
\emph{jamais} mettre |\omit|.
@@ -2910,11 +2981,21 @@ $\begin{NiceArrayWithDelims}
\subsection{Les nœuds correspondant aux contenus des cases}
-L'extension \pkg{nicematrix} crée un nœud PGF-Tikz pour chaque case (non vide)
+L'extension \pkg{nicematrix} crée un nœud PGF-Tikz pour chaque case non vide
du tableau considéré. Ces nœuds sont utilisés, entre autres, pour tracer les
lignes en pointillés entre les cases du tableau.
\smallskip
+\textbf{Attention} : Par défaut, aucun nœud n'est créé dans une case vide.
+
+\smallskip
+\colorbox{yellow!50}{\textbf{Nouveau 5.6}}\enskip
+Néanmoins, on peut forcer la création d'un nœud avec la commande
+|\NotEmpty|.\footnote{Il faut toutefois remarquer qu'avec cette commande, la
+ case est considérée comme non vide, ce qui a des conséquences sur le tracé des
+lignes pointillées (cf.~p.~\pageref{Cdots}).}
+
+\bigskip
Tous les nœuds du document doivent avoir des noms deux à deux distincts et le
nom de ces nœuds doit donc faire intervenir le numéro de l'environnement
courant. Les environnements créés par \pkg{nicematrix} sont en effet numérotés
@@ -2937,6 +3018,8 @@ le nom donné au tableau et $i$ et $j$ les numéros de rangée et de colonne de
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.
+Dans les exemples qui suivent, on suppose que Tikz a été chargé par
+l'utilisateur.
\bigskip
\begin{BVerbatim}[baseline=c,boxwidth=11cm]
@@ -2962,8 +3045,8 @@ 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
-peut (et on doit) désigner les nœuds sous la forme $i$-$j$ : il n'y a pas besoin
-de préciser l'environnement qui est évidemment l'environnement courant.
+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.
\medskip
@@ -3328,7 +3411,7 @@ cellule courante (avec un argument optionnel entre crochets pour la couleur des
hachures). Il est possible de programmer une telle commande |\hatchcell| comme
suit, en utilisant explicitement la variable publique
|\g_nicematrix_code_before_tl| (ce code nécessite le chargement préalable de la
-bibliothèque Tikz \pkg{patterns}).
+bibliothèque Tikz \pkg{patterns} : |\usetikzlibrary{patterns}|).
\begin{scope}
@@ -3527,22 +3610,18 @@ a+b & \Cdots & a+b & 1
\end{scope}
\bigskip
-\colorbox{yellow!30}{Nouveau 5.3}\enskip On peut choisir l'instruction
- |\Ddots| qui sera tracée en premier (et qui servira pour tracer les suivantes
- quand la parallélisation est activée) avec la clé |draw-first| :
- |\Ddots[draw-first]|\rlap{.}
+On peut choisir l'instruction |\Ddots| qui sera tracée en premier (et qui
+servira pour tracer les suivantes quand la parallélisation est activée) avec la
+clé |draw-first| : |\Ddots[draw-first]|\rlap{.}
\subsection{Les cases «vides»}
\label{empty-cells}
Une instruction comme |\Ldots|, |\Cdots|, etc. essaye de déterminer la première
-case vide de part et d'autre de la case considérée. Néanmoins, une case vide
+case vide de part et d'autre de la case considérée. Néanmoins, une case «vide»
n'est pas nécessairement sans contenu dans le codage TeX (c'est-à-dire sans
-aucun token entre les deux esperluettes~|&|). En effet, une case dont le contenu
-est |\hspace*{1cm}| peut être considérée comme vide.
-
-\interitem
-Pour \pkg{nicematrix}, les règles précises sont les suivantes :
+aucun token entre les deux esperluettes~|&|). Les règles précises sont les
+suivantes :
\begin{itemize}
\item Une case implicite est vide. Par exemple, dans la matrice suivante
@@ -3560,6 +3639,10 @@ la dernière case (deuxième rangée et deuxième colonne) est vide.
\item Chaque case avec un rendu par TeX de largeur nulle est vide.
\medskip
+\item Une case qui contient la commande |\NotEmpty| est non vide (et un nœud
+PGF/Tikz est créé pour cette case).
+
+\medskip
\item Une case avec une commande |\Hspace| (ou |\Hspace*|) est vide. Cette
commande |\Hspace| est une commande définie par l'extension \pkg{nicematrix}
avec la même signification que |\hspace| excepté que la case où cette commande
@@ -4374,7 +4457,6 @@ L_i & a_{i1} & \Cdots & a_{ik} & \Cdots & a_{in} \\
\end{tikzpicture}
-\newpage
\section*{Autre documentation}
diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf
index 64a08064d46..c8e2b90a5cb 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 0383626f2f8..a8427171e27 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.5}
-\def\myfiledate{2020/10/20}
+\def\myfileversion{5.6}
+\def\myfiledate{2020/11/08}
%
%
%<*batchfile>
@@ -165,9 +165,9 @@ version 2005/12/01 or later.
%
% \bigskip
% This package requires and \textbf{loads} the packages \pkg{l3keys2e},
-% \pkg{xparse}, \pkg{array}, \pkg{amsmath}, \pkg{pgfcore} and the module
-% \pkg{shapes} of \textsc{pgf} (\pkg{tikz}, which is a layer over \textsc{pgf}
-% is \emph{not} loaded). The final user only has to load the package with
+% \pkg{array}, \pkg{amsmath}, \pkg{pgfcore} and the module \pkg{shapes} of
+% \textsc{pgf} (\pkg{tikz}, which is a layer over \textsc{pgf} is \emph{not}
+% loaded). The final user only has to load the package with
% |\usepackage{nicematrix}|.
%
%
@@ -452,13 +452,23 @@ version 2005/12/01 or later.
% cells of the array.
%
% The command |\Block| must be used in the upper leftmost cell of the array with
-% two arguments. The first argument is the size of the block with the syntax
+% two arguments.
+%
+% \begin{itemize}
+% \item The first argument is the size of the block with the syntax
% $i$\verb|-|$j$ where $i$ is the number of rows of the block and $j$ its number
-% of columns. The second argument is the content of the block.
+% of columns.
%
-% In |{NiceTabular}| the content of the block is composed in text mode. In the
-% other environments, it is composed in math mode.
+% \colorbox{yellow!50}{\bfseries New 5.6}\enskip If this argument is empty, its
+% default value is |1-1|. If the number of rows is not specified, the block
+% extends until the last row (idem for the columns).
%
+% \item The second argument is the content of the block. It's possible to use
+% |\\| in that content to have a content on several lines. In |{NiceTabular}|
+% the content of the block is composed in text mode whereas, in the other
+% environments, it is composed in math mode.
+% \end{itemize}
+%
%
% \interitem
% Here is an example of utilisation of the command |\Block| in mathematical matrices.
@@ -487,7 +497,9 @@ version 2005/12/01 or later.
% possible to use directly a command like |\large|, |\Large| and |\LARGE|.
% That's why the command |\Block| provides an option between angle brackets to
% specify some TeX code which will be inserted before the beginning of the
-% math mode.
+% math mode.\footnote{This argument between angular brackets may also be used to
+% insert a command of font such as |\bfseries| when the command |\\| is used in
+% the content of the block.}
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
@@ -510,8 +522,8 @@ version 2005/12/01 or later.
% \end{scope}
%
% \medskip
-% \colorbox{yellow!30}{New 5.3}\enskip It's possible to set the
-% horizontal position of the block with one of the keys |l|, |c| and |r|.
+% It's possible to set the horizontal position of the block with one of the keys
+% |l|, |c| and |r|.
%
%
% \medskip
@@ -534,8 +546,9 @@ version 2005/12/01 or later.
%
%
% \interitem
-% {\bfseries One must remark that, by default, the commands |\Blocks| don't create space}
-% (excepted, to some extent, the mono-column blocks: see below).
+% {\bfseries One must remark that, by default, the commands |\Blocks| don't create space}.
+% There is exception only for the blocks mono-row and the blocks mono-column as
+% explained just below.
%
% \medskip
% In the following example, we have had to enlarge by hand the columns 2 and 3
@@ -613,6 +626,53 @@ version 2005/12/01 or later.
% \end{scope}
%
%
+% \subsection{The mono-row blocks}
+%
+% \colorbox{yellow!50}{\textbf{New 5.6}}\enskip For the mono-row blocks, the
+% natural height and depth are taken into account for the height and depth of
+% the current row (as does a standard |\multicolumn| of LaTeX).
+%
+% \subsection{The mono-cell blocks}
+%
+% A mono-cell block inherits all the properties of the mono-row blocks and
+% mono-column blocks.
+%
+% \medskip
+% There are two reasons to use a mono-column block:
+% \begin{itemize}
+% \item It's possible to use the command |\\| in a (mono-cell) block.
+%
+% \item It's possible to use the option of horizontal alignment of the block in
+% derogation of the type of column given in the preamble of the array.
+% \end{itemize}
+%
+% \bigskip
+% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
+% \begin{NiceTabular}{cc}
+% \toprule
+% Write & ~emphase#\Block[l]{}{year\\ of birth}@ \\
+% \midrule
+% Hugo & 1802 \\
+% Balzac & 1799 \\
+% \bottomrule
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \begin{NiceTabular}{cc}
+% \toprule
+% Write & \Block[l]{}{year\\ of birth} \\
+% \midrule
+% Hugo & 1802 \\
+% Balzac & 1799 \\
+% \bottomrule
+% \end{NiceTabular}
+%
+% \medskip
+% We recall that if the first mandatory argument of |\Block| is left blank, the
+% block is mono-cell.\footnote{One may consider that the default value of the
+% first mandatory argument of |\Block| is |1-1|}
+%
+%
+%
%
% \subsection{A small remark}
%
@@ -2898,7 +2958,18 @@ version 2005/12/01 or later.
% of the considered array. These nodes are used to draw the dotted lines between
% the cells of the matrix (inter alia).
%
+%
% \smallskip
+% \textbf{Caution} : By default, no node is created in a empty cell.
+%
+% \smallskip
+% \colorbox{yellow!50}{\textbf{New 5.6}}\enskip
+% However, it's possible to impose the creation of a node with the command |\NotEmpty|.
+% \footnote{One should note that, with that command, the cell is considered as
+% non-empty, which has consequencies for the continuous dotted lines (cf.
+% p.~\pageref{Cdots}).}
+%
+% \medskip
% The nodes of a document must have distinct names. That's why the names of the
% nodes created by \pkg{nicematrix} contains the number of the current
% environment. Indeed, the environments of \pkg{nicematrix} are numbered by a
@@ -2921,6 +2992,7 @@ version 2005/12/01 or later.
% possible to use these nodes with \textsc{pgf} but the final user will
% probably prefer to use Tikz (which is a convenient layer upon \textsc{pgf}).
% However, one should remind that \pkg{nicematrix} doesn't load Tikz by default.
+% In the following examples, we assume that Tikz has been loaded.
%
% \bigskip
% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
@@ -2944,9 +3016,9 @@ version 2005/12/01 or later.
% Don't forget the options |remember picture| and |overlay|.
%
% \bigskip
-% In the |code-after|, and if Tikz is loaded, the things are easier. One may
-% design the nodes with the form $i$-$j$: there is no need to indicate the
-% environment which is of course the current environment.
+% In the |code-after|, 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).
%
%
% \medskip
@@ -3304,7 +3376,7 @@ version 2005/12/01 or later.
% cell (with an optional argument between brackets for the color). It's possible
% to program such command |\hatchcell| as follows, explicitely using the public
% variable |\g_nicematrix_code_before_tl| (this code requires the Tikz library
-% \pkg{patterns}).
+% \pkg{patterns}: |\usetikzlibrary{patterns}|).
%
%
% \begin{scope}
@@ -3497,22 +3569,17 @@ version 2005/12/01 or later.
%
% \end{scope}
%
-% \colorbox{yellow!30}{New 5.3}\enskip It's possible to specify the
-% instruction |\Ddots| which will be drawn first (and which will be used to draw
-% the other diagonal dotted lines when the parallelization is in force) with the
-% key |draw-first|: |\Ddots[draw-first]|.
+% It's possible to specify the instruction |\Ddots| which will be drawn first
+% (and which will be used to draw the other diagonal dotted lines when the
+% parallelization is in force) with the key |draw-first|: |\Ddots[draw-first]|.
%
% \subsection{The ``empty'' cells}
%
% \label{empty-cells}
% An instruction like |\Ldots|, |\Cdots|, etc. tries to determine the first
-% non-empty cells on both sides. However, an empty cell is not necessarily a
+% non-empty cell on both sides. However, an ``empty cell'' is not necessarily a
% cell with no TeX content (that is to say a cell with no token between the two
-% ampersands~|&|). Indeed, a cell which only contains |\hspace*{1cm}| may be
-% considered as empty.
-%
-% \interitem
-% For \pkg{nicematrix}, the precise rules are as follow.
+% ampersands~|&|). The precise rules are as follow.
%
% \begin{itemize}
% \item An implicit cell is empty. For example, in the following matrix:
@@ -3529,6 +3596,9 @@ version 2005/12/01 or later.
% \medskip
% \item Each cell whose TeX ouput has a width equal to zero is empty.
%
+% \medskip
+% \item A cell containing the command |\NotEmpty| is not empty (and a PGF/Tikz
+% node) is created in that cell.
%
% \medskip
% \item A cell with a command |\Hspace| (or |\Hspace*|) is empty. This command
@@ -4487,9 +4557,9 @@ version 2005/12/01 or later.
%
% \bigskip
% We define a command |\iddots| similar to |\ddots| ($\ddots$) but with dots
-% going forward ($\iddots$). We use |\ProvideDocumentCommand| of \pkg{xparse},
-% and so, if the command |\iddots| has already been defined (for example by the
-% package \pkg{mathdots}), we don't define it again.
+% going forward ($\iddots$). We use |\ProvideDocumentCommand| and so, if the
+% command |\iddots| has already been defined (for example by the package
+% \pkg{mathdots}), we don't define it again.
%
% \begin{macrocode}
\ProvideDocumentCommand \iddots { }
@@ -4927,14 +4997,21 @@ version 2005/12/01 or later.
% \bigskip
% When there is a mono-column block (created by the command |\Block|), we want
% to take into account the width of that block for the width of the column.
-% That's why we compute the width of that block in the |\g_@@_blocks_width_dim|
+% That's why we compute the width of that block in the |\g_@@_blocks_wd_dim|
% and, after the construction of the box |\l_@@_cell_box|, we change the width
-% of that box to take into account the length |\g_@@_blocks_width_dim|.
+% of that box to take into account the length |\g_@@_blocks_wd_dim|.
% \begin{macrocode}
-\dim_new:N \g_@@_blocks_width_dim
+\dim_new:N \g_@@_blocks_wd_dim
% \end{macrocode}
%
% \bigskip
+% Idem pour the blocks mono-row.
+% \begin{macrocode}
+\dim_new:N \g_@@_blocks_ht_dim
+\dim_new:N \g_@@_blocks_dp_dim
+% \end{macrocode}
+%
+% \bigskip
% The sequence |\g_@@_names_seq| will be the list of all the names of
% environments used (via the option |name|) in the document: two environments
% must not have the same name. However, it's possible to use the option
@@ -5033,7 +5110,7 @@ version 2005/12/01 or later.
%
% \bigskip
% The following token list corresponds to the option |code-after| (it's also
-% possible to set the value of that parameter with the command |\CodeAfter|).
+% possible to set the value of that parameter with the keyword |\CodeAfter|).
% \begin{macrocode}
\tl_new:N \g_nicematrix_code_after_tl
% \end{macrocode}
@@ -5078,6 +5155,13 @@ version 2005/12/01 or later.
\bool_new:N \g_@@_row_of_col_done_bool
% \end{macrocode}
%
+% \bigskip
+% It's possible to use the command |\NotEmpty| to specify explicitely that a
+% cell must be considered as non empty by \pkg{nicematrix} (the Tikz nodes are
+% constructed only the non empty cells).
+% \begin{macrocode}
+\bool_new:N \g_@@_not_empty_cell_bool
+% \end{macrocode}
%
% \bigskip
% |\l_@@_code_before_tl| may contain two types of informations:
@@ -6371,13 +6455,25 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_adjust_width_box:
+\cs_new_protected:Npn \@@_adjust_size_box:
{
- \dim_compare:nNnT \g_@@_blocks_width_dim > \c_zero_dim
+ \dim_compare:nNnT \g_@@_blocks_wd_dim > \c_zero_dim
{
\box_set_wd:Nn \l_@@_cell_box
- { \dim_max:nn { \box_wd:N \l_@@_cell_box } \g_@@_blocks_width_dim }
- \dim_gzero:N \g_@@_blocks_width_dim
+ { \dim_max:nn { \box_wd:N \l_@@_cell_box } \g_@@_blocks_wd_dim }
+ \dim_gzero:N \g_@@_blocks_wd_dim
+ }
+ \dim_compare:nNnT \g_@@_blocks_dp_dim > \c_zero_dim
+ {
+ \box_set_dp:Nn \l_@@_cell_box
+ { \dim_max:nn { \box_dp:N \l_@@_cell_box } \g_@@_blocks_dp_dim }
+ \dim_gzero:N \g_@@_blocks_dp_dim
+ }
+ \dim_compare:nNnT \g_@@_blocks_ht_dim > \c_zero_dim
+ {
+ \box_set_ht:Nn \l_@@_cell_box
+ { \dim_max:nn { \box_ht:N \l_@@_cell_box } \g_@@_blocks_ht_dim }
+ \dim_gzero:N \g_@@_blocks_ht_dim
}
}
% \end{macrocode}
@@ -6388,7 +6484,7 @@ version 2005/12/01 or later.
\@@_math_toggle_token:
\hbox_set_end:
\bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box:
- \@@_adjust_width_box:
+ \@@_adjust_size_box:
% \end{macrocode}
%
% \begin{macrocode}
@@ -6438,11 +6534,14 @@ version 2005/12/01 or later.
\bool_if:NTF \g_@@_empty_cell_bool
{ \box_use_drop:N \l_@@_cell_box }
{
- \dim_compare:nNnTF { \box_wd:N \l_@@_cell_box } > \c_zero_dim
+ \bool_lazy_or:nnTF
+ \g_@@_not_empty_cell_bool
+ { \dim_compare_p:nNn { \box_wd:N \l_@@_cell_box } > \c_zero_dim }
\@@_node_for_the_cell:
{ \box_use_drop:N \l_@@_cell_box }
}
\bool_gset_false:N \g_@@_empty_cell_bool
+ \bool_gset_false:N \g_@@_not_empty_cell_bool
}
% \end{macrocode}
%
@@ -6832,6 +6931,7 @@ version 2005/12/01 or later.
\cs_set_eq:NN \dotfill \@@_old_dotfill:
\cs_set_eq:NN \CodeAfter \@@_CodeAfter:
\cs_set_eq:NN \diagbox \@@_diagbox:nn
+ \cs_set_eq:NN \NotEmpty \@@_NotEmpty:
\bool_if:NT \l_@@_colortbl_like_bool \@@_colortbl_like:
\bool_if:NT \l_@@_renew_dots_bool \@@_renew_dots:
% \end{macrocode}
@@ -7496,7 +7596,7 @@ version 2005/12/01 or later.
}
{ \tl_gclear:N \g_@@_preamble_tl }
% \end{macrocode}
-% The counter |\l_tmpa_int| will be count the number of consecutive occurrences
+% The counter |\l_tmpa_int| will count the number of consecutive occurrences
% of the symbole \verb+|+.
% \begin{macrocode}
\int_zero:N \l_tmpa_int
@@ -7706,7 +7806,7 @@ version 2005/12/01 or later.
> {
\hbox_set:Nw \l_@@_cell_box
\@@_Cell:
- \tl_set:Nn \l_@@_cell_type_tl { #1 }
+ \tl_set:Nn \l_@@_cell_type_tl { #3 }
}
c
< {
@@ -7714,7 +7814,7 @@ version 2005/12/01 or later.
#1
\hbox_set_end:
\bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box:
- \@@_adjust_width_box:
+ \@@_adjust_size_box:
\makebox [ #4 ] [ #3 ] { \box_use_drop:N \l_@@_cell_box }
}
}
@@ -8445,7 +8545,7 @@ version 2005/12/01 or later.
\@@_math_toggle_token:
\hbox_set_end:
\bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box:
- \@@_adjust_width_box:
+ \@@_adjust_size_box:
\@@_update_for_first_and_last_row:
% \end{macrocode}
% We actualise the width of the ``first column'' because we will use this width
@@ -8515,7 +8615,7 @@ version 2005/12/01 or later.
\@@_math_toggle_token:
\hbox_set_end:
\bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box:
- \@@_adjust_width_box:
+ \@@_adjust_size_box:
\@@_update_for_first_and_last_row:
% \end{macrocode}
% We actualise the width of the ``last column'' because we will use this width
@@ -8628,6 +8728,14 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
+% The following command will be linked to |\NotEmpty| in the environments of
+% \pkg{nicematrix}.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_NotEmpty:
+ { \bool_gset_true:N \g_@@_not_empty_cell_bool }
+% \end{macrocode}
+%
+% \bigskip
% \subsection*{The environments \{NiceTabular\} and \{NiceTabular*\}}
%
% \begin{macrocode}
@@ -8845,6 +8953,13 @@ version 2005/12/01 or later.
% \begin{macrocode}
\@@_compute_corners:
% \end{macrocode}
+%
+% \bigskip
+% The sequence |\g_@@_pos_of_blocks_seq| must be ``adjusted'' (for the case
+% where the user have written something like |\Block{1-}|).
+% \begin{macrocode}
+ \@@_adjust_pos_of_blocks_seq:
+% \end{macrocode}
%
% \bigskip
% The following code is only for efficiency. We determine whether the potential
@@ -8950,6 +9065,40 @@ version 2005/12/01 or later.
% \end{macrocode}
%
%
+% \bigskip
+% We remind that the first mandatory argument of the command |\Block| is the
+% size of the block with the special format $i$|-|$j$. However, the user is
+% allowed to omit $i$ or $j$ (or both). This will be interpreted as: the last
+% row (resp. column) of the block will be the last row (resp. column) of the
+% block (without the potential exterior row---resp. column---of the array). By
+% convention, this is stored in |\g_@@_pos_of_blocks_seq| (and
+% |\g_@@_blocks_seq|) as a number of rows (resp. columns) for the block equal to
+% 100. It's possible, after the construction of the array, to replace these
+% values by the correct ones (since we know the number of rows and columns of
+% the array).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_adjust_pos_of_blocks_seq:
+ {
+ \seq_gclear:N \g_tmpa_seq
+ \seq_map_inline:Nn \g_@@_pos_of_blocks_seq
+ { \@@_adjust_pos_of_blocks_seq_i:nnnn ##1 }
+ \seq_gset_eq:NN \g_@@_pos_of_blocks_seq \g_tmpa_seq
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_adjust_pos_of_blocks_seq_i:nnnn #1 #2 #3 #4
+ {
+ \int_compare:nNnTF { #3 } > { 99 }
+ { \int_set_eq:NN \l_tmpa_int \c@iRow }
+ { \int_set:Nn \l_tmpa_int { #3 } }
+ \int_compare:nNnTF { #4 } > { 99 }
+ { \int_set_eq:NN \l_tmpb_int \c@jCol }
+ { \int_set:Nn \l_tmpb_int { #4 } }
+ \seq_gput_right:Nx \g_tmpa_seq
+ { { #1 } { #2 } { \int_use:N \l_tmpa_int } { \int_use:N \l_tmpb_int } }
+ }
+% \end{macrocode}
%
% \bigskip
% We recall that, when externalization is used, |\tikzpicture| and
@@ -10242,8 +10391,8 @@ version 2005/12/01 or later.
% \end{macrocode}
%
%
-% The command |\@@_Hdotsfor_i| is defined with the tools of \pkg{xparse} because
-% it has an optional argument. Note that such a command defined by
+% The command |\@@_Hdotsfor_i| is defined with |\NewDocumentCommand| because it
+% has an optional argument. Note that such a command defined by
% |\NewDocumentCommand| is protected and that's why we have put the
% |\multicolumn| before (in the definition of |\@@_Hdotsfor:|).
% \begin{macrocode}
@@ -11179,7 +11328,7 @@ version 2005/12/01 or later.
% \subsection*{The horizontal rules}
%
% \bigskip
-% The following command will be executed in the |internal-code-after|. The row
+% The following command will be executed in the |internal-code-after|. The rule
% will be drawn \emph{before} the row |#1|. |#2| is the number of consecutive
% occurrences of |\Hline|.
% \begin{macrocode}
@@ -11196,7 +11345,7 @@ version 2005/12/01 or later.
{
% \end{macrocode}
% |\l_tmpa_tl| is the number of row and |\l_tmpb_tl| the number of column. Whe,
-% we have found a column corresponding to a rule to draw, we note its numver in
+% we have found a column corresponding to a rule to draw, we note its number in
% |\l_tmpc_tl|.
% \begin{macrocode}
\tl_set:Nn \l_tmpa_tl { #1 }
@@ -12251,7 +12400,8 @@ version 2005/12/01 or later.
%
% \bigskip
% The options of the command |\Block| will be analyzed first in the cell of the
-% array (and once again when the block will be put in the array in the |code-after|).
+% array (and once again when the block will be put in the array in the
+% |code-after|). Here is the set of keys for the first pass.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / Block / FirstPass }
{
@@ -12265,21 +12415,28 @@ version 2005/12/01 or later.
% \end{macrocode}
%
%
-% The following command will be linked to |\Block| in the environments of
-% \pkg{nicematrix}. We define it with |\NewDocumentCommand| of \pkg{xparse}
-% because it has an optional argument between |<| and |>| (for TeX instructions
-% put before the math mode of the label)
+% The following command |\@@_Block:| will be linked to |\Block| in the
+% environments of \pkg{nicematrix}. We define it with
+% |\NewExpandableDocumentCommand| because it has an optional argument between
+% |<| and |>| (for TeX instructions put before the math mode of the label). It's
+% mandatory to use an expandable command.
%
-% It's mandatory to use an expandable command (why?).
% \begin{macrocode}
\NewExpandableDocumentCommand \@@_Block: { O { } m D < > { } m }
- { \@@_Block_i #2 \q_stop { #1 } { #3 } { #4 } }
+ {
+% \end{macrocode}
+% If the first mandatory argument of the command (which is the size of the block
+% with the syntax $i$|-|$j$) has not be provided by the user, you use |1-1|
+% (that is to say a block of only one cell).
+% \begin{macrocode}
+ \tl_if_blank:nTF { #2 } { \@@_Block_i 1-1 \q_stop } { \@@_Block_i #2 \q_stop }
+ { #1 } { #3 } { #4 }
+ }
% \end{macrocode}
%
% \medskip
-% The first mandatory argument of |\@@_Block:| has a special syntax. It must be
-% of the form $i$|-|$j$ where $i$ and $j$ are the size (in rows and columns) of
-% the block.
+% With the following construction, we extract the values of $i$ and $j$ in the
+% first mandatory argument of the command.
% \begin{macrocode}
\cs_new:Npn \@@_Block_i #1-#2 \q_stop { \@@_Block_ii:nnnnn { #1 } { #2 } }
% \end{macrocode}
@@ -12299,19 +12456,34 @@ version 2005/12/01 or later.
{ \tl_set:Nn \l_@@_pos_of_block_tl c }
{ \tl_set_eq:NN \l_@@_pos_of_block_tl \l_@@_cell_type_tl }
% \end{macrocode}
+%
% \medskip
% \begin{macrocode}
\keys_set_known:nn { NiceMatrix / Block / FirstPass } { #3 }
% \end{macrocode}
%
% \medskip
+% We recall that |#1| and |#2| have been extracted from the first mandatory
+% argument of |\Block| (which is of the syntax $i$|-|$j$). However, the user is
+% allowed to omit $i$ or $j$ (or both). We detect that situation by replacing a
+% missing value by 100 (it's a convention: when the block will actually be drawn
+% these values will be detected and interpreted as \emph{maximal possible value}).
+% \begin{macrocode}
+ \tl_if_empty:nTF { #1 }
+ { \int_set:Nn \l_tmpa_int { 100 } }
+ { \int_set:Nn \l_tmpa_int { #1 } }
+ \tl_if_empty:nTF { #2 }
+ { \int_set:Nn \l_tmpb_int { 100 } }
+ { \int_set:Nn \l_tmpb_int { #2 } }
+% \end{macrocode}
+%
% \begin{macrocode}
\tl_set:Nx \l_tmpa_tl
{
{ \int_use:N \c@iRow }
{ \int_use:N \c@jCol }
- { \int_eval:n { \c@iRow + #1 - 1 } }
- { \int_eval:n { \c@jCol + #2 - 1 } }
+ { \int_eval:n { \c@iRow + \l_tmpa_int - 1 } }
+ { \int_eval:n { \c@jCol + \l_tmpb_int - 1 } }
}
% \end{macrocode}
% Now, |\l_tmpa_tl| contains an ``object'' corresponding to the position of the
@@ -12332,41 +12504,62 @@ version 2005/12/01 or later.
% |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}{|\textsl{options}|}{|\textsl{contents}|}|.
%
% \medskip
-% If the block is mono-column, we have a special treatment.
+% If the block is mono-column or mono-row, we have a special treatment. That's
+% why we have two macros: |\@@_Block_iii:nnnnn| and |\@@_Block_iv:nnnnn| (the five
+% arguments of those macros are provided by curryfication).
% \begin{macrocode}
- \int_compare:nNnTF { #2 } = 1
+ \bool_lazy_or:nnTF
+ { \int_compare_p:nNn { \l_tmpa_int } = 1 }
+ { \int_compare_p:nNn { \l_tmpb_int } = 1 }
+ { \exp_args:Nxx \@@_Block_iii:nnnnn }
+ { \exp_args:Nxx \@@_Block_iv:nnnnn }
+ { \l_tmpa_int } { \l_tmpb_int } { #3 } { #4 } { #5 }
+ }
+% \end{macrocode}
+%
+%
+% \bigskip
+% The following macro is for the case of a |\Block| which is mono-row or
+% mono-column (or both). In that case, the content of the block is composed
+% right now in a box (because we have to take into account the dimensions of
+% that box for the width of the current column or the height and the depth of the
+% current row). However, that box will be put in the array \emph{after the
+% construction of the array} (by using \textsc{pgf}).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_Block_iii:nnnnn #1 #2 #3 #4 #5
+ {
+ \int_gincr:N \g_@@_block_box_int
+ \cs_set_protected_nopar:Npn \diagbox ##1 ##2
{
- \int_gincr:N \g_@@_block_box_int
- \cs_set_protected_nopar:Npn \diagbox ##1 ##2
- {
- \tl_gput_right:Nx \g_@@_internal_code_after_tl
- {
- \@@_actually_diagbox:nnnnnn
- { \int_use:N \c@iRow }
- { \int_use:N \c@jCol }
- { \int_eval:n { \c@iRow + #1 - 1 } }
- { \int_eval:n { \c@jCol + #2 - 1 } }
- { \exp_not:n { ##1 } } { \exp_not:n { ##2 } }
- }
- }
- \box_gclear_new:c
- { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
- \hbox_gset:cn
- { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
+ \tl_gput_right:Nx \g_@@_internal_code_after_tl
{
+ \@@_actually_diagbox:nnnnnn
+ { \int_use:N \c@iRow }
+ { \int_use:N \c@jCol }
+ { \int_eval:n { \c@iRow + #1 - 1 } }
+ { \int_eval:n { \c@jCol + #2 - 1 } }
+ { \exp_not:n { ##1 } } { \exp_not:n { ##2 } }
+ }
+ }
+ \box_gclear_new:c
+ { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
+ \hbox_gset:cn
+ { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
+ {
% \end{macrocode}
-% If the user has specified a color for the column in the preamble of the array,
-% we want to fix that color in the box we construct. We do that with
-% |\set@color| and not |\color_ensure_current:| because that command seems to be
-% bugged: it doesn't work in XeLaTeX when \pkg{fontspec} is loaded.
+% For a mono-column block, if the user has specified a color for the column in
+% the preamble of the array, we want to fix that color in the box we construct.
+% We do that with |\set@color| and not |\color_ensure_current:| because that
+% command seems to be bugged: it doesn't work in XeLaTeX when \pkg{fontspec} is
+% loaded.
% \begin{macrocode}
- \set@color
- \bool_if:NTF \l_@@_NiceTabular_bool
- {
- \group_begin:
- \cs_set:Npn \arraystretch { 1 }
- \dim_set_eq:NN \extrarowheight \c_zero_dim
- #4
+ \int_compare:nNnT { #2 } = 1 \set@color
+ \bool_if:NTF \l_@@_NiceTabular_bool
+ {
+ \group_begin:
+ \cs_set:Npn \arraystretch { 1 }
+ \dim_set_eq:NN \extrarowheight \c_zero_dim
+ #4
% \end{macrocode}
% If the box is rotated (the key |\rotate| may be in the previous |#4|), the
% tabular used for the content of the cell will be constructed with a format
@@ -12375,49 +12568,81 @@ version 2005/12/01 or later.
% the tabular is the same as the external alignment of the tabular (that is to
% say the position of the block in its zone of merged cells).
% \begin{macrocode}
- \bool_if:NT \g_@@_rotate_bool
- { \tl_set:Nn \l_@@_pos_of_block_tl c }
- \exp_args:Nnx \begin { tabular }
- { @ { } \l_@@_pos_of_block_tl @ { } }
- #5
- \end { tabular }
- \group_end:
- }
- {
- \group_begin:
- \cs_set:Npn \arraystretch { 1 }
- \dim_set_eq:NN \extrarowheight \c_zero_dim
- #4
- \bool_if:NT \g_@@_rotate_bool
- { \tl_set:Nn \l_@@_pos_of_block_tl c }
- \c_math_toggle_token
- \exp_args:Nnx \begin { array }
- { @ { } \l_@@_pos_of_block_tl @ { } }
- #5
- \end { array }
- \c_math_toggle_token
- \group_end:
- }
- }
- \bool_if:NT \g_@@_rotate_bool
- {
- \box_grotate:cn
- { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
- { 90 }
- \bool_gset_false:N \g_@@_rotate_bool
+ \bool_if:NT \g_@@_rotate_bool
+ { \tl_set:Nn \l_@@_pos_of_block_tl c }
+ \exp_args:Nnx \begin { tabular }
+ { @ { } \l_@@_pos_of_block_tl @ { } }
+ #5
+ \end { tabular }
+ \group_end:
+ }
+ {
+ \group_begin:
+ \cs_set:Npn \arraystretch { 1 }
+ \dim_set_eq:NN \extrarowheight \c_zero_dim
+ #4
+ \bool_if:NT \g_@@_rotate_bool
+ { \tl_set:Nn \l_@@_pos_of_block_tl c }
+ \c_math_toggle_token
+ \exp_args:Nnx \begin { array }
+ { @ { } \l_@@_pos_of_block_tl @ { } }
+ #5
+ \end { array }
+ \c_math_toggle_token
+ \group_end:
}
- \dim_gset:Nn \g_@@_blocks_width_dim
+ }
+ \bool_if:NT \g_@@_rotate_bool
+ {
+ \box_grotate:cn
+ { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
+ { 90 }
+ \bool_gset_false:N \g_@@_rotate_bool
+ }
+% \end{macrocode}
+% If we are in a mono-column block, we take into account the width of that block
+% for the width of the column.
+% \begin{macrocode}
+ \int_compare:nNnT { #2 } = 1
+ {
+ \dim_gset:Nn \g_@@_blocks_wd_dim
{
\dim_max:nn
- \g_@@_blocks_width_dim
+ \g_@@_blocks_wd_dim
{
\box_wd:c
{ g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
}
- }
- \seq_gput_right:Nx \g_@@_blocks_seq
- {
- \l_tmpa_tl
+ }
+ }
+% \end{macrocode}
+% If we are in a mono-row block, we take into account the height and the
+% depth of that block for the height and the depth of the row.
+% \begin{macrocode}
+ \int_compare:nNnT { #1 } = 1
+ {
+ \dim_gset:Nn \g_@@_blocks_ht_dim
+ {
+ \dim_max:nn
+ \g_@@_blocks_ht_dim
+ {
+ \box_ht:c
+ { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
+ }
+ }
+ \dim_gset:Nn \g_@@_blocks_dp_dim
+ {
+ \dim_max:nn
+ \g_@@_blocks_dp_dim
+ {
+ \box_dp:c
+ { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
+ }
+ }
+ }
+ \seq_gput_right:Nx \g_@@_blocks_seq
+ {
+ \l_tmpa_tl
% \end{macrocode}
% In the list of options |#3|, maybe there is a key for the horizontal alignment
% (|l|, |r| or |c|). In that case, that key has been read and stored in
@@ -12425,30 +12650,36 @@ version 2005/12/01 or later.
% alignement and that's why we put a key corresponding to the value of
% |\l_@@_pos_of_block_tl|, which is fixed by the type of current column.
% \begin{macrocode}
- { #3 , \l_@@_pos_of_block_tl }
- {
- \box_use_drop:c
- { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
- }
- }
- }
+ { #3 , \l_@@_pos_of_block_tl }
+ {
+ \box_use_drop:c
+ { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box }
+ }
+ }
+ }
% \end{macrocode}
-% In the standard case, that is to say a |\Block| which is \emph{not} mono-column.
+%
+% \bigskip
+% The following macro is for the standard case, where the block is not mono-row
+% and not mono-column. In that case, the content of the block is \emph{not}
+% composed right now in a box. The composition in a box will be done further,
+% just after the construction of the array.
% \begin{macrocode}
- {
- \seq_gput_right:Nx \g_@@_blocks_seq
- {
- \l_tmpa_tl
- { #3 }
- \exp_not:n
- {
- {
- \bool_if:NTF \l_@@_NiceTabular_bool
- {
- \group_begin:
- \cs_set:Npn \arraystretch { 1 }
- \dim_set_eq:NN \extrarowheight \c_zero_dim
- #4
+\cs_new_protected:Npn \@@_Block_iv:nnnnn #1 #2 #3 #4 #5
+ {
+ \seq_gput_right:Nx \g_@@_blocks_seq
+ {
+ \l_tmpa_tl
+ { #3 }
+ \exp_not:n
+ {
+ {
+ \bool_if:NTF \l_@@_NiceTabular_bool
+ {
+ \group_begin:
+ \cs_set:Npn \arraystretch { 1 }
+ \dim_set_eq:NN \extrarowheight \c_zero_dim
+ #4
% \end{macrocode}
% If the box is rotated (the key |\rotate| may be in the previous |#4|), the
% tabular used for the content of the cell will be constructed with a format
@@ -12457,36 +12688,39 @@ version 2005/12/01 or later.
% the tabular is the same as the external alignment of the tabular (that is to
% say the position of the block in its zone of merged cells).
% \begin{macrocode}
- \bool_if:NT \g_@@_rotate_bool
- { \tl_set:Nn \l_@@_pos_of_block_tl c }
- \exp_args:Nnx \begin { tabular }
- { @ { } \l_@@_pos_of_block_tl @ { } }
- #5
- \end { tabular }
- \group_end:
- }
- {
- \group_begin:
- \cs_set:Npn \arraystretch { 1 }
- \dim_set_eq:NN \extrarowheight \c_zero_dim
- #4
- \bool_if:NT \g_@@_rotate_bool
- { \tl_set:Nn \l_@@_pos_of_block_tl c }
- \c_math_toggle_token
- \exp_args:Nnx \begin { array }
- { @ { } \l_@@_pos_of_block_tl @ { } } #5 \end { array }
- \c_math_toggle_token
- \group_end:
- }
+ \bool_if:NT \g_@@_rotate_bool
+ { \tl_set:Nn \l_@@_pos_of_block_tl c }
+ \exp_args:Nnx \begin { tabular }
+ { @ { } \l_@@_pos_of_block_tl @ { } }
+ #5
+ \end { tabular }
+ \group_end:
}
- }
- }
- }
- }
+ {
+ \group_begin:
+ \cs_set:Npn \arraystretch { 1 }
+ \dim_set_eq:NN \extrarowheight \c_zero_dim
+ #4
+ \bool_if:NT \g_@@_rotate_bool
+ { \tl_set:Nn \l_@@_pos_of_block_tl c }
+ \c_math_toggle_token
+ \exp_args:Nnx \begin { array }
+ { @ { } \l_@@_pos_of_block_tl @ { } } #5 \end { array }
+ \c_math_toggle_token
+ \group_end:
+ }
+ }
+ }
+ }
+ }
% \end{macrocode}
-%
%
% \bigskip
+% We recall that the options of the command |\Block| are analyzed twice: first
+% in the cell of the array and once again when the block will be put in the
+% array \emph{after the construction of the array} (by using \textsc{pgf}).
+%
+% \medskip
% The key |tikz| is for Tikz options used when the \textsc{pgf} node of the
% block is created (the ``normal'' block node and not the ``short'' one nor the
% ``medium'' one). \textbf{In fact, as of now, it is \emph{not} documented}. Is
@@ -12531,6 +12765,29 @@ version 2005/12/01 or later.
\keys_set:nn { NiceMatrix / Block / SecondPass} { #5 }
% \end{macrocode}
%
+% The integer |\l_@@_last_row_int| will be the last row of the block and
+% |\l_@@_last_col_int| it's last column.
+% \begin{macrocode}
+ \int_zero_new:N \l_@@_last_row_int
+ \int_zero_new:N \l_@@_last_col_int
+% \end{macrocode}
+%
+% We remind that the first mandatory argument of the command |\Block| is the
+% size of the block with the special format $i$|-|$j$. However, the user is
+% allowed to omit $i$ or $j$ (or both). This will be interpreted as: the last
+% row (resp. column) of the block will be the last row (resp. column) of the
+% block (without the potential exterior row---resp. column---of the array). By
+% convention, this is stored in |\g_@@_blocks_seq| as a number of rows (resp.
+% columns) for the block equal to 100. That's what we detect now.
+% \begin{macrocode}
+ \int_compare:nNnTF { #3 } > { 99 }
+ { \int_set_eq:NN \l_@@_last_row_int \c@iRow }
+ { \int_set:Nn \l_@@_last_row_int { #3 } }
+ \int_compare:nNnTF { #4 } > { 99 }
+ { \int_set_eq:NN \l_@@_last_col_int \c@jCol }
+ { \int_set:Nn \l_@@_last_col_int { #4 } }
+% \end{macrocode}
+%
% \begin{macrocode}
\tl_if_empty:NF \l_@@_color_tl
{
@@ -12539,7 +12796,7 @@ version 2005/12/01 or later.
\exp_not:N \rectanglecolor
{ \l_@@_color_tl }
{ #1 - #2 }
- { #3 - #4 }
+ { \int_use:N \l_@@_last_row_int - \int_use:N \l_@@_last_col_int }
}
}
% \end{macrocode}
@@ -12551,7 +12808,10 @@ version 2005/12/01 or later.
\tl_gput_right:Nx \g_@@_internal_code_after_tl
{
\@@_actually_diagbox:nnnnnn
- { #1 } { #2 } { #3 } { #4 }
+ { #1 }
+ { #2 }
+ { \int_use:N \l_@@_last_row_int }
+ { \int_use:N \l_@@_last_col_int }
{ \exp_not:n { ##1 } } { \exp_not:n { ##2 } }
}
}
@@ -12560,8 +12820,8 @@ version 2005/12/01 or later.
% \medskip
% \begin{macrocode}
\bool_lazy_or:nnTF
- { \int_compare_p:nNn { #3 } > \g_@@_row_total_int }
- { \int_compare_p:nNn { #4 } > \g_@@_col_total_int }
+ { \int_compare_p:nNn \l_@@_last_row_int > \g_@@_row_total_int }
+ { \int_compare_p:nNn \l_@@_last_col_int > \g_@@_col_total_int }
{ \msg_error:nnnn { nicematrix } { Block~too~large } { #1 } { #2 } }
{
\hbox_set:Nn \l_@@_cell_box { #6 }
@@ -12625,9 +12885,9 @@ version 2005/12/01 or later.
\dim_set_eq:NN \l_tmpa_dim \pgf@y
\@@_qpoint:n { col - #2 }
\dim_set_eq:NN \l_tmpb_dim \pgf@x
- \@@_qpoint:n { row - \@@_succ:n { #3 } }
+ \@@_qpoint:n { row - \@@_succ:n { \l_@@_last_row_int } }
\dim_set_eq:NN \l_tmpc_dim \pgf@y
- \@@_qpoint:n { col - \@@_succ:n { #4 } }
+ \@@_qpoint:n { col - \@@_succ:n { \l_@@_last_col_int } }
\dim_set_eq:NN \l_tmpd_dim \pgf@x
% \end{macrocode}
%
@@ -12678,18 +12938,20 @@ version 2005/12/01 or later.
\int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int
{
\cs_if_exist:cT
- { pgf @ sh @ ns @ \@@_env: - ##1 - #4 }
+ { pgf @ sh @ ns @ \@@_env: - ##1 - \int_use:N \l_@@_last_col_int }
{
\seq_if_in:NnF \g_@@_multicolumn_cells_seq { ##1 - #2 }
{
- \pgfpointanchor { \@@_env: - ##1 - #4 } { east }
+ \pgfpointanchor
+ { \@@_env: - ##1 - \int_use:N \l_@@_last_col_int }
+ { east }
\dim_set:Nn \l_tmpd_dim { \dim_max:nn \l_tmpd_dim \pgf@x }
}
}
}
\dim_compare:nNnT \l_tmpd_dim = { - \c_max_dim }
{
- \@@_qpoint:n { col - \@@_succ:n { #4 } }
+ \@@_qpoint:n { col - \@@_succ:n { \l_@@_last_col_int } }
\dim_set_eq:NN \l_tmpd_dim \pgf@x
}
\@@_pgf_rect_node:nnnnn
@@ -12707,7 +12969,14 @@ version 2005/12/01 or later.
\@@_pgf_rect_node:nnn
{ \@@_env: - #1 - #2 - block - medium }
{ \pgfpointanchor { \@@_env: - #1 - #2 - medium } { north~west } }
- { \pgfpointanchor { \@@_env: - #3 - #4 - medium } { south~east } }
+ {
+ \pgfpointanchor
+ { \@@_env:
+ - \int_use:N \l_@@_last_row_int
+ - \int_use:N \l_@@_last_col_int - medium
+ }
+ { south~east }
+ }
}
% \end{macrocode}
% \medskip
@@ -14205,12 +14474,18 @@ version 2005/12/01 or later.
%
% Different behaviour for the mono-column blocks.
%
-% \subsection*{Changes between versions 5.3 and 5.4}
+% \subsection*{Changes between versions 5.4 and 5.5}
%
% The user must never put |\omit| before |\CodeAfter|.
%
% Correction of a bug: the tabular notes |\tabularnotes| were not composed when
% present in a block (except a mono-column block).
+%
+% \subsection*{Changes between versions 5.5 and 5.6}
+%
+% Different behaviour for the mono-row blocks.
+%
+% New command |\NotEmpty|.
%
% \PrintIndex
%
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
index a0d9e5a3c4e..595260e2658 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.5}
-\def\myfiledate{2020/10/20}
+\def\myfileversion{5.6}
+\def\myfiledate{2020/11/08}
\RequirePackage{pgfcore}
\usepgfmodule{shapes}
@@ -252,7 +252,9 @@
\dim_new:N \l__nicematrix_columns_width_dim
\tl_new:N \l__nicematrix_cell_type_tl
\tl_set:Nn \l__nicematrix_cell_type_tl { c }
-\dim_new:N \g__nicematrix_blocks_width_dim
+\dim_new:N \g__nicematrix_blocks_wd_dim
+\dim_new:N \g__nicematrix_blocks_ht_dim
+\dim_new:N \g__nicematrix_blocks_dp_dim
\seq_new:N \g__nicematrix_names_seq
\bool_new:N \l__nicematrix_in_env_bool
\bool_new:N \l__nicematrix_NiceArray_bool
@@ -282,6 +284,7 @@
\int_new:N \l__nicematrix_old_jCol_int
\tl_new:N \l__nicematrix_rules_color_tl
\bool_new:N \g__nicematrix_row_of_col_done_bool
+\bool_new:N \g__nicematrix_not_empty_cell_bool
\tl_new:N \l__nicematrix_code_before_tl
\bool_new:N \l__nicematrix_code_before_bool
\dim_new:N \l__nicematrix_x_initial_dim
@@ -848,13 +851,25 @@
}
\bool_gset_false:N \g__nicematrix_rotate_bool
}
-\cs_new_protected:Npn \__nicematrix_adjust_width_box:
+\cs_new_protected:Npn \__nicematrix_adjust_size_box:
{
- \dim_compare:nNnT \g__nicematrix_blocks_width_dim > \c_zero_dim
+ \dim_compare:nNnT \g__nicematrix_blocks_wd_dim > \c_zero_dim
{
\box_set_wd:Nn \l__nicematrix_cell_box
- { \dim_max:nn { \box_wd:N \l__nicematrix_cell_box } \g__nicematrix_blocks_width_dim }
- \dim_gzero:N \g__nicematrix_blocks_width_dim
+ { \dim_max:nn { \box_wd:N \l__nicematrix_cell_box } \g__nicematrix_blocks_wd_dim }
+ \dim_gzero:N \g__nicematrix_blocks_wd_dim
+ }
+ \dim_compare:nNnT \g__nicematrix_blocks_dp_dim > \c_zero_dim
+ {
+ \box_set_dp:Nn \l__nicematrix_cell_box
+ { \dim_max:nn { \box_dp:N \l__nicematrix_cell_box } \g__nicematrix_blocks_dp_dim }
+ \dim_gzero:N \g__nicematrix_blocks_dp_dim
+ }
+ \dim_compare:nNnT \g__nicematrix_blocks_ht_dim > \c_zero_dim
+ {
+ \box_set_ht:Nn \l__nicematrix_cell_box
+ { \dim_max:nn { \box_ht:N \l__nicematrix_cell_box } \g__nicematrix_blocks_ht_dim }
+ \dim_gzero:N \g__nicematrix_blocks_ht_dim
}
}
\cs_new_protected:Npn \__nicematrix_end_Cell:
@@ -862,7 +877,7 @@
\__nicematrix_math_toggle_token:
\hbox_set_end:
\bool_if:NT \g__nicematrix_rotate_bool \__nicematrix_rotate_cell_box:
- \__nicematrix_adjust_width_box:
+ \__nicematrix_adjust_size_box:
\box_set_ht:Nn \l__nicematrix_cell_box
{ \box_ht:N \l__nicematrix_cell_box + \l__nicematrix_cell_space_top_limit_dim }
\box_set_dp:Nn \l__nicematrix_cell_box
@@ -873,11 +888,14 @@
\bool_if:NTF \g__nicematrix_empty_cell_bool
{ \box_use_drop:N \l__nicematrix_cell_box }
{
- \dim_compare:nNnTF { \box_wd:N \l__nicematrix_cell_box } > \c_zero_dim
+ \bool_lazy_or:nnTF
+ \g__nicematrix_not_empty_cell_bool
+ { \dim_compare_p:nNn { \box_wd:N \l__nicematrix_cell_box } > \c_zero_dim }
\__nicematrix_node_for_the_cell:
{ \box_use_drop:N \l__nicematrix_cell_box }
}
\bool_gset_false:N \g__nicematrix_empty_cell_bool
+ \bool_gset_false:N \g__nicematrix_not_empty_cell_bool
}
\cs_new_protected:Npn \__nicematrix_node_for_the_cell:
{
@@ -1072,6 +1090,7 @@
\cs_set_eq:NN \dotfill \__nicematrix_old_dotfill:
\cs_set_eq:NN \CodeAfter \__nicematrix_CodeAfter:
\cs_set_eq:NN \diagbox \__nicematrix_diagbox:nn
+ \cs_set_eq:NN \NotEmpty \__nicematrix_NotEmpty:
\bool_if:NT \l__nicematrix_colortbl_like_bool \__nicematrix_colortbl_like:
\bool_if:NT \l__nicematrix_renew_dots_bool \__nicematrix_renew_dots:
\seq_gclear_new:N \g__nicematrix_multicolumn_cells_seq
@@ -1513,7 +1532,7 @@
> {
\hbox_set:Nw \l__nicematrix_cell_box
\__nicematrix_Cell:
- \tl_set:Nn \l__nicematrix_cell_type_tl { #1 }
+ \tl_set:Nn \l__nicematrix_cell_type_tl { #3 }
}
c
< {
@@ -1521,7 +1540,7 @@
#1
\hbox_set_end:
\bool_if:NT \g__nicematrix_rotate_bool \__nicematrix_rotate_cell_box:
- \__nicematrix_adjust_width_box:
+ \__nicematrix_adjust_size_box:
\makebox [ #4 ] [ #3 ] { \box_use_drop:N \l__nicematrix_cell_box }
}
}
@@ -1975,7 +1994,7 @@
\__nicematrix_math_toggle_token:
\hbox_set_end:
\bool_if:NT \g__nicematrix_rotate_bool \__nicematrix_rotate_cell_box:
- \__nicematrix_adjust_width_box:
+ \__nicematrix_adjust_size_box:
\__nicematrix_update_for_first_and_last_row:
\dim_gset:Nn \g__nicematrix_width_first_col_dim
{ \dim_max:nn \g__nicematrix_width_first_col_dim { \box_wd:N \l__nicematrix_cell_box } }
@@ -2019,7 +2038,7 @@
\__nicematrix_math_toggle_token:
\hbox_set_end:
\bool_if:NT \g__nicematrix_rotate_bool \__nicematrix_rotate_cell_box:
- \__nicematrix_adjust_width_box:
+ \__nicematrix_adjust_size_box:
\__nicematrix_update_for_first_and_last_row:
\dim_gset:Nn \g__nicematrix_width_last_col_dim
{ \dim_max:nn \g__nicematrix_width_last_col_dim { \box_wd:N \l__nicematrix_cell_box } }
@@ -2086,6 +2105,8 @@
}
{ \use:c { end #1 NiceArray } }
}
+\cs_new_protected:Npn \__nicematrix_NotEmpty:
+ { \bool_gset_true:N \g__nicematrix_not_empty_cell_bool }
\NewDocumentEnvironment { NiceTabular } { O { } m ! O { } }
{
\str_gset:Nn \g__nicematrix_name_env_str { NiceTabular }
@@ -2197,6 +2218,7 @@
}
\__nicematrix_draw_dotted_lines:
\__nicematrix_compute_corners:
+ \__nicematrix_adjust_pos_of_blocks_seq:
\bool_lazy_all:nT
{
{ \seq_if_empty_p:N \g__nicematrix_pos_of_blocks_seq }
@@ -2246,6 +2268,24 @@
\__nicematrix_restore_iRow_jCol:
\cs_gset_eq:NN \CT@arc@ \__nicematrix_old_CT@arc@
}
+\cs_new_protected:Npn \__nicematrix_adjust_pos_of_blocks_seq:
+ {
+ \seq_gclear:N \g_tmpa_seq
+ \seq_map_inline:Nn \g__nicematrix_pos_of_blocks_seq
+ { \__nicematrix_adjust_pos_of_blocks_seq_i:nnnn ##1 }
+ \seq_gset_eq:NN \g__nicematrix_pos_of_blocks_seq \g_tmpa_seq
+ }
+\cs_new_protected:Npn \__nicematrix_adjust_pos_of_blocks_seq_i:nnnn #1 #2 #3 #4
+ {
+ \int_compare:nNnTF { #3 } > { 99 }
+ { \int_set_eq:NN \l_tmpa_int \c@iRow }
+ { \int_set:Nn \l_tmpa_int { #3 } }
+ \int_compare:nNnTF { #4 } > { 99 }
+ { \int_set_eq:NN \l_tmpb_int \c@jCol }
+ { \int_set:Nn \l_tmpb_int { #4 } }
+ \seq_gput_right:Nx \g_tmpa_seq
+ { { #1 } { #2 } { \int_use:N \l_tmpa_int } { \int_use:N \l_tmpb_int } }
+ }
\AtBeginDocument
{
\cs_new_protected:Npx \__nicematrix_draw_dotted_lines:
@@ -4261,7 +4301,10 @@
c .value_forbidden:n = true ,
}
\NewExpandableDocumentCommand \__nicematrix_Block: { O { } m D < > { } m }
- { \__nicematrix_Block_i #2 \q_stop { #1 } { #3 } { #4 } }
+ {
+ \tl_if_blank:nTF { #2 } { \__nicematrix_Block_i 1-1 \q_stop } { \__nicematrix_Block_i #2 \q_stop }
+ { #1 } { #3 } { #4 }
+ }
\cs_new:Npn \__nicematrix_Block_i #1-#2 \q_stop { \__nicematrix_Block_ii:nnnnn { #1 } { #2 } }
\cs_new_protected:Npn \__nicematrix_Block_ii:nnnnn #1 #2 #3 #4 #5
{
@@ -4269,128 +4312,165 @@
{ \tl_set:Nn \l__nicematrix_pos_of_block_tl c }
{ \tl_set_eq:NN \l__nicematrix_pos_of_block_tl \l__nicematrix_cell_type_tl }
\keys_set_known:nn { NiceMatrix / Block / FirstPass } { #3 }
+ \tl_if_empty:nTF { #1 }
+ { \int_set:Nn \l_tmpa_int { 100 } }
+ { \int_set:Nn \l_tmpa_int { #1 } }
+ \tl_if_empty:nTF { #2 }
+ { \int_set:Nn \l_tmpb_int { 100 } }
+ { \int_set:Nn \l_tmpb_int { #2 } }
\tl_set:Nx \l_tmpa_tl
{
{ \int_use:N \c@iRow }
{ \int_use:N \c@jCol }
- { \int_eval:n { \c@iRow + #1 - 1 } }
- { \int_eval:n { \c@jCol + #2 - 1 } }
+ { \int_eval:n { \c@iRow + \l_tmpa_int - 1 } }
+ { \int_eval:n { \c@jCol + \l_tmpb_int - 1 } }
}
\seq_gput_left:NV \g__nicematrix_pos_of_blocks_seq \l_tmpa_tl
- \int_compare:nNnTF { #2 } = 1
+ \bool_lazy_or:nnTF
+ { \int_compare_p:nNn { \l_tmpa_int } = 1 }
+ { \int_compare_p:nNn { \l_tmpb_int } = 1 }
+ { \exp_args:Nxx \__nicematrix_Block_iii:nnnnn }
+ { \exp_args:Nxx \__nicematrix_Block_iv:nnnnn }
+ { \l_tmpa_int } { \l_tmpb_int } { #3 } { #4 } { #5 }
+ }
+\cs_new_protected:Npn \__nicematrix_Block_iii:nnnnn #1 #2 #3 #4 #5
+ {
+ \int_gincr:N \g__nicematrix_block_box_int
+ \cs_set_protected_nopar:Npn \diagbox ##1 ##2
{
- \int_gincr:N \g__nicematrix_block_box_int
- \cs_set_protected_nopar:Npn \diagbox ##1 ##2
+ \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
{
- \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
- {
- \__nicematrix_actually_diagbox:nnnnnn
- { \int_use:N \c@iRow }
- { \int_use:N \c@jCol }
- { \int_eval:n { \c@iRow + #1 - 1 } }
- { \int_eval:n { \c@jCol + #2 - 1 } }
- { \exp_not:n { ##1 } } { \exp_not:n { ##2 } }
- }
+ \__nicematrix_actually_diagbox:nnnnnn
+ { \int_use:N \c@iRow }
+ { \int_use:N \c@jCol }
+ { \int_eval:n { \c@iRow + #1 - 1 } }
+ { \int_eval:n { \c@jCol + #2 - 1 } }
+ { \exp_not:n { ##1 } } { \exp_not:n { ##2 } }
}
- \box_gclear_new:c
- { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box }
- \hbox_gset:cn
- { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box }
+ }
+ \box_gclear_new:c
+ { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box }
+ \hbox_gset:cn
+ { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box }
+ {
+ \int_compare:nNnT { #2 } = 1 \set@color
+ \bool_if:NTF \l__nicematrix_NiceTabular_bool
{
- \set@color
- \bool_if:NTF \l__nicematrix_NiceTabular_bool
- {
- \group_begin:
- \cs_set:Npn \arraystretch { 1 }
- \dim_set_eq:NN \extrarowheight \c_zero_dim
- #4
- \bool_if:NT \g__nicematrix_rotate_bool
- { \tl_set:Nn \l__nicematrix_pos_of_block_tl c }
- \exp_args:Nnx \begin { tabular }
- { @ { } \l__nicematrix_pos_of_block_tl @ { } }
- #5
- \end { tabular }
- \group_end:
- }
- {
- \group_begin:
- \cs_set:Npn \arraystretch { 1 }
- \dim_set_eq:NN \extrarowheight \c_zero_dim
- #4
- \bool_if:NT \g__nicematrix_rotate_bool
- { \tl_set:Nn \l__nicematrix_pos_of_block_tl c }
- \c_math_toggle_token
- \exp_args:Nnx \begin { array }
- { @ { } \l__nicematrix_pos_of_block_tl @ { } }
- #5
- \end { array }
- \c_math_toggle_token
- \group_end:
- }
+ \group_begin:
+ \cs_set:Npn \arraystretch { 1 }
+ \dim_set_eq:NN \extrarowheight \c_zero_dim
+ #4
+ \bool_if:NT \g__nicematrix_rotate_bool
+ { \tl_set:Nn \l__nicematrix_pos_of_block_tl c }
+ \exp_args:Nnx \begin { tabular }
+ { @ { } \l__nicematrix_pos_of_block_tl @ { } }
+ #5
+ \end { tabular }
+ \group_end:
}
- \bool_if:NT \g__nicematrix_rotate_bool
{
- \box_grotate:cn
- { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box }
- { 90 }
- \bool_gset_false:N \g__nicematrix_rotate_bool
+ \group_begin:
+ \cs_set:Npn \arraystretch { 1 }
+ \dim_set_eq:NN \extrarowheight \c_zero_dim
+ #4
+ \bool_if:NT \g__nicematrix_rotate_bool
+ { \tl_set:Nn \l__nicematrix_pos_of_block_tl c }
+ \c_math_toggle_token
+ \exp_args:Nnx \begin { array }
+ { @ { } \l__nicematrix_pos_of_block_tl @ { } }
+ #5
+ \end { array }
+ \c_math_toggle_token
+ \group_end:
}
- \dim_gset:Nn \g__nicematrix_blocks_width_dim
+ }
+ \bool_if:NT \g__nicematrix_rotate_bool
+ {
+ \box_grotate:cn
+ { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box }
+ { 90 }
+ \bool_gset_false:N \g__nicematrix_rotate_bool
+ }
+ \int_compare:nNnT { #2 } = 1
+ {
+ \dim_gset:Nn \g__nicematrix_blocks_wd_dim
{
\dim_max:nn
- \g__nicematrix_blocks_width_dim
+ \g__nicematrix_blocks_wd_dim
{
\box_wd:c
{ g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box }
}
}
- \seq_gput_right:Nx \g__nicematrix_blocks_seq
+ }
+ \int_compare:nNnT { #1 } = 1
+ {
+ \dim_gset:Nn \g__nicematrix_blocks_ht_dim
{
- \l_tmpa_tl
- { #3 , \l__nicematrix_pos_of_block_tl }
- {
- \box_use_drop:c
- { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box }
- }
+ \dim_max:nn
+ \g__nicematrix_blocks_ht_dim
+ {
+ \box_ht:c
+ { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box }
+ }
+ }
+ \dim_gset:Nn \g__nicematrix_blocks_dp_dim
+ {
+ \dim_max:nn
+ \g__nicematrix_blocks_dp_dim
+ {
+ \box_dp:c
+ { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box }
+ }
}
}
+ \seq_gput_right:Nx \g__nicematrix_blocks_seq
{
- \seq_gput_right:Nx \g__nicematrix_blocks_seq
+ \l_tmpa_tl
+ { #3 , \l__nicematrix_pos_of_block_tl }
+ {
+ \box_use_drop:c
+ { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box }
+ }
+ }
+ }
+\cs_new_protected:Npn \__nicematrix_Block_iv:nnnnn #1 #2 #3 #4 #5
+ {
+ \seq_gput_right:Nx \g__nicematrix_blocks_seq
+ {
+ \l_tmpa_tl
+ { #3 }
+ \exp_not:n
{
- \l_tmpa_tl
- { #3 }
- \exp_not:n
- {
+ {
+ \bool_if:NTF \l__nicematrix_NiceTabular_bool
{
- \bool_if:NTF \l__nicematrix_NiceTabular_bool
- {
- \group_begin:
- \cs_set:Npn \arraystretch { 1 }
- \dim_set_eq:NN \extrarowheight \c_zero_dim
- #4
- \bool_if:NT \g__nicematrix_rotate_bool
- { \tl_set:Nn \l__nicematrix_pos_of_block_tl c }
- \exp_args:Nnx \begin { tabular }
- { @ { } \l__nicematrix_pos_of_block_tl @ { } }
- #5
- \end { tabular }
- \group_end:
- }
- {
- \group_begin:
- \cs_set:Npn \arraystretch { 1 }
- \dim_set_eq:NN \extrarowheight \c_zero_dim
- #4
- \bool_if:NT \g__nicematrix_rotate_bool
- { \tl_set:Nn \l__nicematrix_pos_of_block_tl c }
- \c_math_toggle_token
- \exp_args:Nnx \begin { array }
- { @ { } \l__nicematrix_pos_of_block_tl @ { } } #5 \end { array }
- \c_math_toggle_token
- \group_end:
- }
+ \group_begin:
+ \cs_set:Npn \arraystretch { 1 }
+ \dim_set_eq:NN \extrarowheight \c_zero_dim
+ #4
+ \bool_if:NT \g__nicematrix_rotate_bool
+ { \tl_set:Nn \l__nicematrix_pos_of_block_tl c }
+ \exp_args:Nnx \begin { tabular }
+ { @ { } \l__nicematrix_pos_of_block_tl @ { } }
+ #5
+ \end { tabular }
+ \group_end:
}
- }
+ {
+ \group_begin:
+ \cs_set:Npn \arraystretch { 1 }
+ \dim_set_eq:NN \extrarowheight \c_zero_dim
+ #4
+ \bool_if:NT \g__nicematrix_rotate_bool
+ { \tl_set:Nn \l__nicematrix_pos_of_block_tl c }
+ \c_math_toggle_token
+ \exp_args:Nnx \begin { array }
+ { @ { } \l__nicematrix_pos_of_block_tl @ { } } #5 \end { array }
+ \c_math_toggle_token
+ \group_end:
+ }
+ }
}
}
}
@@ -4417,6 +4497,14 @@
{
\group_begin:
\keys_set:nn { NiceMatrix / Block / SecondPass} { #5 }
+ \int_zero_new:N \l__nicematrix_last_row_int
+ \int_zero_new:N \l__nicematrix_last_col_int
+ \int_compare:nNnTF { #3 } > { 99 }
+ { \int_set_eq:NN \l__nicematrix_last_row_int \c@iRow }
+ { \int_set:Nn \l__nicematrix_last_row_int { #3 } }
+ \int_compare:nNnTF { #4 } > { 99 }
+ { \int_set_eq:NN \l__nicematrix_last_col_int \c@jCol }
+ { \int_set:Nn \l__nicematrix_last_col_int { #4 } }
\tl_if_empty:NF \l__nicematrix_color_tl
{
\tl_gput_right:Nx \g_nicematrix_code_before_tl
@@ -4424,7 +4512,7 @@
\exp_not:N \rectanglecolor
{ \l__nicematrix_color_tl }
{ #1 - #2 }
- { #3 - #4 }
+ { \int_use:N \l__nicematrix_last_row_int - \int_use:N \l__nicematrix_last_col_int }
}
}
\cs_set_protected_nopar:Npn \diagbox ##1 ##2
@@ -4432,13 +4520,16 @@
\tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
{
\__nicematrix_actually_diagbox:nnnnnn
- { #1 } { #2 } { #3 } { #4 }
+ { #1 }
+ { #2 }
+ { \int_use:N \l__nicematrix_last_row_int }
+ { \int_use:N \l__nicematrix_last_col_int }
{ \exp_not:n { ##1 } } { \exp_not:n { ##2 } }
}
}
\bool_lazy_or:nnTF
- { \int_compare_p:nNn { #3 } > \g__nicematrix_row_total_int }
- { \int_compare_p:nNn { #4 } > \g__nicematrix_col_total_int }
+ { \int_compare_p:nNn \l__nicematrix_last_row_int > \g__nicematrix_row_total_int }
+ { \int_compare_p:nNn \l__nicematrix_last_col_int > \g__nicematrix_col_total_int }
{ \msg_error:nnnn { nicematrix } { Block~too~large } { #1 } { #2 } }
{
\hbox_set:Nn \l__nicematrix_cell_box { #6 }
@@ -4450,9 +4541,9 @@
\dim_set_eq:NN \l_tmpa_dim \pgf@y
\__nicematrix_qpoint:n { col - #2 }
\dim_set_eq:NN \l_tmpb_dim \pgf@x
- \__nicematrix_qpoint:n { row - \__nicematrix_succ:n { #3 } }
+ \__nicematrix_qpoint:n { row - \__nicematrix_succ:n { \l__nicematrix_last_row_int } }
\dim_set_eq:NN \l_tmpc_dim \pgf@y
- \__nicematrix_qpoint:n { col - \__nicematrix_succ:n { #4 } }
+ \__nicematrix_qpoint:n { col - \__nicematrix_succ:n { \l__nicematrix_last_col_int } }
\dim_set_eq:NN \l_tmpd_dim \pgf@x
\begin { pgfscope }
\exp_args:Nx \pgfset { \l__nicematrix_tikz_tl }
@@ -4482,18 +4573,20 @@
\int_step_inline:nnn \l__nicematrix_first_row_int \g__nicematrix_row_total_int
{
\cs_if_exist:cT
- { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - #4 }
+ { pgf @ sh @ ns @ \__nicematrix_env: - ##1 - \int_use:N \l__nicematrix_last_col_int }
{
\seq_if_in:NnF \g__nicematrix_multicolumn_cells_seq { ##1 - #2 }
{
- \pgfpointanchor { \__nicematrix_env: - ##1 - #4 } { east }
+ \pgfpointanchor
+ { \__nicematrix_env: - ##1 - \int_use:N \l__nicematrix_last_col_int }
+ { east }
\dim_set:Nn \l_tmpd_dim { \dim_max:nn \l_tmpd_dim \pgf@x }
}
}
}
\dim_compare:nNnT \l_tmpd_dim = { - \c_max_dim }
{
- \__nicematrix_qpoint:n { col - \__nicematrix_succ:n { #4 } }
+ \__nicematrix_qpoint:n { col - \__nicematrix_succ:n { \l__nicematrix_last_col_int } }
\dim_set_eq:NN \l_tmpd_dim \pgf@x
}
\__nicematrix_pgf_rect_node:nnnnn
@@ -4504,7 +4597,14 @@
\__nicematrix_pgf_rect_node:nnn
{ \__nicematrix_env: - #1 - #2 - block - medium }
{ \pgfpointanchor { \__nicematrix_env: - #1 - #2 - medium } { north~west } }
- { \pgfpointanchor { \__nicematrix_env: - #3 - #4 - medium } { south~east } }
+ {
+ \pgfpointanchor
+ { \__nicematrix_env:
+ - \int_use:N \l__nicematrix_last_row_int
+ - \int_use:N \l__nicematrix_last_col_int - medium
+ }
+ { south~east }
+ }
}
\int_compare:nNnTF { #1 } = { #3 }
{