texlive[61715] Master/texmf-dist: nicematrix (23jan22)
commits+karl at tug.org
commits+karl at tug.org
Sun Jan 23 22:12:07 CET 2022
Revision: 61715
http://tug.org/svn/texlive?view=revision&revision=61715
Author: karl
Date: 2022-01-23 22:12:06 +0100 (Sun, 23 Jan 2022)
Log Message:
-----------
nicematrix (23jan22)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf
trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex
trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf
trunk/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx
trunk/Master/texmf-dist/source/latex/nicematrix/nicematrix.ins
trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
Modified: trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex
===================================================================
--- trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex 2022-01-23 21:11:30 UTC (rev 61714)
+++ trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex 2022-01-23 21:12:06 UTC (rev 61715)
@@ -533,8 +533,8 @@
|right|, |top| et |bottom| ;
\item les clés |t| et |b| réglent la ligne de base qui sera donnée au bloc quand
celui-ci est constitué de plusieurs lignes (séparées par la commande |\\|) ;
-\item la clé |hvlines| trace tous les filets horizontaux et verticaux dans le
-bloc ;
+\item les clés |hlines|, |vlines| et |hvlines| tracent les filets correspondants
+dans le bloc ;
\item quand la clé |tikz| est utilisée, le chemin Tikz correspondant au
rectangle délimitant le bloc est exécuté avec Tikz\footnote{Tikz doit être
chargé préalablement (par défaut, \pkg{nicematrix} ne charge que
@@ -544,7 +544,10 @@
|tikz|, voir p.~\pageref{tikz-key-examples} ;
\item \colorbox{yellow!50}{\textbf{Nouveau 6.3}}\enskip la clé |name| donne un
nom au nœud Tikz rectangulaire correspondant au bloc ; on peut utiliser ce nom
-avec Tikz dans le |\CodeAfter| (cf p.~\pageref{code-after}).
+avec Tikz dans le |\CodeAfter| (cf p.~\pageref{code-after});
+\item \colorbox{yellow!50}{\textbf{Nouveau 6.5}}\enskip la clé
+|respect-arraystretch| évite la remise à $1$ de |\arraystretch| en début de
+bloc (qui a lieu par défaut).
\end{itemize}
@@ -888,12 +891,10 @@
\end{scope}
\medskip
-\colorbox{yellow!50}{\textbf{Nouveau 6.2}}\enskip
+Dans les environnements de \pkg{nicematrix}, une instruction
+|\cline{|\textsl{\texttt{i}}|}| est équivalente à
+|\cline{|\textsl{\texttt{i}}|-|\textsl{\texttt{i}}|}|.
-Dans les environnements de
-\pkg{nicematrix}, une instruction |\cline{|\textsl{\texttt{i}}|}| est
-équivalente à |\cline{|\textsl{\texttt{i}}|-|\textsl{\texttt{i}}|}|.
-
\subsection{L'épaisseur et la couleur des filets}
Les environnements de \pkg{nicematrix} proposent une clé |rules/width| pour
@@ -1178,6 +1179,7 @@
\subsection{Filets en pointillés}
+\label{dotted}
Dans les environnements de \pkg{nicematrix}, il est possible d'utiliser la
commande |\hdottedline| (fournie par \pkg{nicematrix}) qui est l'équivalent pour
@@ -1238,9 +1240,73 @@
p.~\pageref{remark-cline}}. Avec \pkg{nicematrix}, les lignes en pointillés
tracées par |\hdottedline| et «|:|» ont ce même effet.
+\subsection{Commandes pour filets personnalisés}
+\colorbox{yellow!50}{\textbf{Nouveau 6.5}}\enskip Il est possible de définir des
+commandes et des lettres pour des filets personnalisés avec la clé
+|custom-line|, utilisable dans |\NiceMatrixOptions| ou bien dans un
+environnement. Cette clé prend en argument une liste de paires de la forme
+\textsl{clé=valeur}. Les clés disponibles sont les suivantes :
+\begin{itemize}
+\item la clé |command| indique le nom (sans la contre-oblique) d'une commande
+qui sera créée par \pkg{nicematrix} et que l'utilisateur pourra utiliser pour
+tracer des filets horizontaux (de manière similaire à |\hline|) ;
+\item la clé |letter| prend en argument une lettre\footnote{Les lettres
+ suivantes ne sont pas autorisées : \verb+lcrpmbVX:|()[]!@<>+} qui pourra être utilisée par
+l'utilisateur dans le préambule d'un environnement à préambule (comme
+|{NiceTabular}|) pour spécifier un filet vertical ;
+
+\item la clé |multiplicity| indique le nombre de traits successifs qui seront
+tracés : par exemple, une valeur de~$2$ va créer des filets doubles comme créés
+en standard par |\hline\hline| ou bien \verb+||+ dans le préambule d'un
+environnement ;
+
+\item la clé |color| fixe la couleur des filets ;
+
+\item la clé |sep-color| fixe la couleur entre deux filets consécutifs (n'a
+d'intérêt que dans le cas où la clé |multiplicity| est utilisée) ;
+
+\item la clé |dotted| impose un style de pointillés qui utilise le système
+de pointillés de la commande |\hdottedline| (et de la lettre \verb|:|) décrit à
+la partie précédente (cf. p.~\pageref{dotted}).
+\end{itemize}
+
+\medskip
+Ce système permet en particulier de définir des commandes pour tracer des filets
+avec une couleur spécifique (et ces filets respecteront les blocs comme les
+autres filets de \pkg{nicematrix}).
+
+\medskip
+\begin{Verbatim}
+\begin{NiceTabular}{lcIcIc}~emphase#[custom-line = {letter=I, color=blue}]@
+\hline
+ & \Block{1-3}{dimensions} \\
+ & L & l & h \\
+\hline
+Produit A & 3 & 1 & 2 \\
+Produit B & 1 & 3 & 4 \\
+Produit C & 5 & 4 & 1 \\
+\hline
+\end{NiceTabular}
+\end{Verbatim}
+
+
+\begin{center}
+\begin{NiceTabular}{lcIcIc}[custom-line = {letter=I, color=blue}]
+\hline
+ & \Block{1-3}{dimensions} \\
+ & L & l & H \\
+\hline
+Produit A & 3 & 1 & 2 \\
+Produit B & 1 & 3 & 4 \\
+Produit C & 5 & 4 & 1 \\
+\hline
+\end{NiceTabular}
+\end{center}
+
+
\section{Les couleurs des rangées et des colonnes}
\subsection{Utilisation de colortbl}
@@ -1507,10 +1573,10 @@
\medskip
-La commande |\rowcolors| accepte une liste de couples clé-valeur comme argument
-optionnel en dernière position (l'argument optionel en première position
-correspond à l'espace colorimétrique). Les clés disponibles sont |cols|,
-|restart| et |respect-blocks|.
+La commande |\rowcolors| accepte une liste de couples \textsl{clé=valeur} comme
+argument optionnel en dernière position (l'argument optionel en première
+position correspond à l'espace colorimétrique). Les clés disponibles sont
+|cols|, |restart| et |respect-blocks|.
\begin{itemize}
\item La clé |cols| décrit un ensemble de colonnes sur lesquelles portera
l'effet de |\rowcolors|. Cet ensemble de colonnes est une liste d'intervalles de
@@ -1797,7 +1863,7 @@
\medskip
Elle prend aussi en premier argument optionnel, entre crochets, une liste de
-couples clé-valeur.
+couples \textsl{clé=valeur}.
\begin{itemize}
\item \colorbox{yellow!50}{\bfseries Nouveau 6.3}\enskip La clé |nb-rows|
indique le nombre de rangées consécutives concernées par les spécifications de
@@ -2878,7 +2944,7 @@
\item le troisième argument est le coin inférieur droit avec la même syntaxe ;
\item la quatrième argument est le délimiteur droit ;
\item le cinquième argument, optionnel, entre crochets, est une liste de couples
-clé-valeur.\footnote{Il n'y a pas d'argument optionnel entre crochets en première
+\textsl{clé=valeur}.\footnote{Il n'y a pas d'argument optionnel entre crochets en première
position car un crochet ouvrant juste après |\SubMatrix| doit pouvoir être
interprété comme le premier argument (obligatoire) de |\SubMatrix|: ce
crochet est alors le délimiteur gauche de la sous-matrice (ex. :
@@ -3068,7 +3134,7 @@
-\subsection{Les commandes \textbackslash OverBrace et le \textbackslash
+\subsection{Les commandes \textbackslash OverBrace et \textbackslash
UnderBrace dans le \textbackslash CodeAfter}
\colorbox{yellow!50}{\textbf{Nouveau 6.4}}
@@ -3078,7 +3144,7 @@
\begin{itemize}
\item le premier argument est le coin supérieur gauche du rectangle de cellules
impliquées dans l'accolade avec la syntaxe habituelle $i$|-|$j$ où $i$ est le
-numéro de rangée et $hj$ le numéro de colonne ;
+numéro de rangée et $j$ le numéro de colonne ;
\item le deuxième argument est le coin inférieur droit avec la même syntaxe ;
@@ -3107,8 +3173,8 @@
\bigskip
Les commandes |\OverBrace| et |\UnderBrace| acceptent en fait un premier
-argument optionnel (entre crochets) pour une liste de couples clé-valeur. Les
-clés disponibles sont les suivantes :
+argument optionnel (entre crochets) pour une liste de couples
+\textsl{clé=valeur}. Les clés disponibles sont les suivantes :
\begin{itemize}
\item |left-shorten| et |right-shorten| qui ne prennent pas de valeur ; quand
|left-shorten| est utilisée, l'abscisse de l'extrémité de gauche de l'accolade
@@ -3418,22 +3484,23 @@
\item Les notes sont composées en fin de tableau en utilisant en interne un
-style de liste de \pkg{enumitem}.
+style de liste de \pkg{enumitem}. Ce style de liste est défini de la manière
+suivante (avec, bien sûr, des clés de \pkg{enumitem}) :
-La clé |notes/enumitem-keys| permet de spécifier une liste de paires
-\textsl{clé=valeur} (au format de \pkg{enumitem}) permettant de paramétrer ce
-type de liste.
+|noitemsep , leftmargin = * , align = left , labelsep = 0pt|
-Valeur initiale :\quad |noitemsep , leftmargin = * , align = left , labelsep = 0pt|
+La spécification |align = left| de ce style demande que le label de la note soit
+composé à gauche dans la boîte qui lui est dévolue. Ce réglage a l'avantage
+d'avoir les notes calées à gauche, ce qui est plaisant si on compose des
+tableaux dans l'esprit de \pkg{booktabs} (voir par exemple la table
+\ref{t:tabularnote}, p.~\pageref{t:tabularnote}).
-Cette valeur initiale contient la spécification |align = left| qui demande que
-le label de la note soit composé à gauche dans la boîte qui lui est dévolue.
+\medskip
+La clé |notes/enumitem-keys| fournie par \pkg{nicematrix} permet modifier ce
+type de liste de \pkg{enumitem} (en utilisant en interne la commande |\setlist*|
+de \pkg{enumitem}).
-Ce réglage a l'avantage d'avoir les notes calées à gauche, ce qui est plaisant
-si on compose des tableaux dans l'esprit de \pkg{booktabs} (voir par exemple la
-table \ref{t:tabularnote}, p.~\pageref{t:tabularnote}).
-
\item La clé |notes/enumitem-keys-para| est similaire à la précédente mais elle
est utilisée pour le type de liste qui sera utilisé quand l'option |para| est
choisie. Bien entendu, quand cette option |para| est active, c'est une liste de
@@ -3441,9 +3508,11 @@
paires \textsl{clé=valeur} doivent donc correspondre à une telle liste de type
|inline|.
-Valeur initiale :\quad |afterlabel = \nobreak, itemjoin = \quad|
+Initialement, le style de liste utilisé est défini par :\quad
+|afterlabel = \nobreak, itemjoin = \quad|
+
\item La clé |notes/code-before| est une liste de tokens qui seront insérés
avant la composition de la liste de notes.
@@ -4182,7 +4251,51 @@
informations écrites dans le fichier |aux| puis recréés lors de la composition
du tableau proprement dit).
+\bigskip
+Voici un exemple d'utilisation de ces nœuds dans le |\CodeAfter|.
+\begin{center}
+\fvset{commandchars=\~\#\+}
+\begin{Verbatim}
+\begin{NiceArray}{c@{\;}c@{\;}c@{\;}c@{\;}c}[create-medium-nodes]
+ u_1 &-& u_0 &=& r \\
+ u_2 &-& u_1 &=& r \\
+ u_3 &-& u_2 &=& r \\
+ u_4 &-& u_3 &=& r \\
+ \phantom{u_5} & & \phantom{u_4} &\smash{\vdots} & \\
+ u_n &-& u_{n-1} &=& r \\[3pt]
+ \hline
+ u_n &-& u_0 &=& nr \\
+\CodeAfter
+ \tikz[very thick, red, opacity=0.4,name suffix = -medium]
+ \draw (1-1.north west) -- (2-3.south east)
+ (2-1.north west) -- (3-3.south east)
+ (3-1.north west) -- (4-3.south east)
+ (4-1.north west) -- (5-3.south east)
+ (5-1.north west) -- (6-3.south east) ;
+\end{NiceArray}
+\end{Verbatim}
+\end{center}
+%
+\[\begin{NiceArray}{c@{\;}c@{\;}c@{\;}c@{\;}c}[create-medium-nodes]
+ u_1 &-& u_0 &=& r \\
+ u_2 &-& u_1 &=& r \\
+ u_3 &-& u_2 &=& r \\
+ u_4 &-& u_3 &=& r \\
+ \phantom{u_5} & & \phantom{u_4} &\smash{\vdots} & \\
+ u_n &-& u_{n-1} &=& r \\[3pt]
+ \hline
+ u_n &-& u_0 &=& nr \\
+ \CodeAfter
+ \tikz[very thick, red, opacity=0.4,name suffix = -medium]
+ \draw (1-1.north west) -- (2-3.south east)
+ (2-1.north west) --(3-3.south east)
+ (3-1.north west) -- (4-3.south east)
+ (4-1.north west) -- (5-3.south east)
+ (5-1.north west) -- (6-3.south east) ;
+\end{NiceArray}\]
+
+
\subsection{Les nœuds indiquant la position des filets}
\label{nodes-i}
@@ -5188,12 +5301,10 @@
composition du tableau et les traits verticaux sont donc tracés sans espacer les
colonnes.
-
\medskip
-\colorbox{yellow!50}{\textbf{Nouveau 6.2}}\enskip En fait, on peut avec la clé
-|vlines-in-sub-matrix| choisir un spécificateur dans le préambule du tableau
-pour indiquer des filets verticaux qui seront tracés dans les |\SubMatrix|
-uniquement (en espaçant les colonnes).
+En fait, on peut avec la clé |vlines-in-sub-matrix| choisir un spécificateur
+dans le préambule du tableau pour indiquer des filets verticaux qui seront
+tracés dans les |\SubMatrix| uniquement (en espaçant les colonnes).
\medskip
\begin{Verbatim}
Modified: trunk/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx 2022-01-23 21:11:30 UTC (rev 61714)
+++ trunk/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx 2022-01-23 21:12:06 UTC (rev 61715)
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% Copyright (C) 2018-2021 by F. Pantigny
+% Copyright (C) 2018-2022 by F. Pantigny
% -----------------------------------
%
% This file may be distributed and/or modified under the
@@ -15,8 +15,8 @@
%
% \fi
% \iffalse
-\def\myfileversion{6.4}
-\def\myfiledate{2021/11/23}
+\def\myfileversion{6.5}
+\def\myfiledate{2022/01/23}
%
%
%<*batchfile>
@@ -27,7 +27,7 @@
\preamble
-Copyright (C) 2018-2021 by F. Pantigny
+Copyright (C) 2018-2022 by F. Pantigny
-----------------------------------
This file may be distributed and/or modified under the
@@ -553,7 +553,7 @@
%
% \interitem
% In fact, the command |\Block| accepts as first optional argument (between
-% square brackets) a list of couples key-value. The available keys are as
+% square brackets) a list of couples \textsl{key=value}. The available keys are as
% follows:
% \begin{itemize}
% \item the keys |l|, |c| and |r| are used to fix the horizontal position of the
@@ -576,8 +576,8 @@
% by |left|, |right|, |top| and |bottom|;
% \item the keys |t| and |b| fix the base line that will be given to the block
% when it has a multi-line content (the lines are separated by |\\|);
-% \item the keys |hvlines| draws all the vertical and horizontal rules in the
-% block;
+% \item the keys |hlines|, |vlines| and |hvlines| draw all the corresponding
+% rules in the block;
% \item when the key |tikz| is used, the Tikz path corresponding of the
% rectangle which delimits the block is executed with Tikz\footnote{Tikz should
% be loaded (by default, \pkg{nicematrix} only loads \textsc{pgf}) and, if it's
@@ -587,7 +587,10 @@
% \item \colorbox{yellow!50}{\textbf{New 6.3}}\enskip the key |name| provides a
% name to the rectangular Tikz node corresponding to the block; it's possible to
% use that name with Tikz in the |\CodeAfter| of the environment
-% (cf.~p.~\pageref{code-after}).
+% (cf.~p.~\pageref{code-after});
+% \item \colorbox{yellow!50}{\textbf{New 6.5}}\enskip the key
+% |respect-arraystretch| prevents the setting of |\arraystretch| to $1$ at the
+% beginning of the block (which is the behaviour by default).
% \end{itemize}
%
% \interitem
@@ -913,8 +916,6 @@
% \end{scope}
%
% \medskip
-% \colorbox{yellow!50}{\textbf{New 6.2}}
-%
% In the environments of \pkg{nicematrix}, an instruction |\cline{|\textsl{\texttt{i}}|}|
% is equivalent to |\cline{|\textsl{\texttt{i}}|-|\textsl{\texttt{i}}|}|.
%
@@ -1191,6 +1192,7 @@
%
% \subsection{Dotted rules}
%
+% \label{dotted}
%
% In the environments of the package \pkg{nicematrix}, it's possible to use
% the command |\hdottedline| (provided by \pkg{nicematrix}) which is a
@@ -1250,7 +1252,72 @@
% |\hdottedline| and ``|:|'' do likewise.
%
%
+% \subsection{Commands for customized rules}
%
+% \colorbox{yellow!50}{\textbf{New 6.5}}\enskip It's possible to define commands
+% and letters for customized rules with the key |custom-line| available in
+% |\NiceMatrixOptions| and in the options of individual environments. That key
+% takes in as argument a list of \textsl{key=value} pairs. The available keys
+% are the following:
+% \begin{itemize}
+% \item the key |command| is the name (without the backslahs) of a command that
+% will be created by \pkg{nicematrix} and that will be available for the final
+% user in order to draw horizontal rules (similarly to |\hline|);
+%
+% \item the key |letter| takes in as argument a letter\footnote{The following
+% letters are forbidden: \verb+lcrpmbVX:|()[]!@<>+} that the user will use in
+% the preamble of an environment with preamble (such as |{NiceTabular}| in order
+% to specify a vertical rule;
+%
+% \item the key |multiplicity| is the number to consecutive rules that will be
+% drawn: for instance, a value of $2$ will create double rules such those
+% created by |\hline\hline| or \verb+||+ in the preamble of an environment;
+%
+% \item the key |color| sets the color of the rule ;
+%
+% \item the key |sep-color| sets the color between two successive rules (should be
+% used only in conjonction with |multiplicity|);
+%
+% \item the key |dotted| forces a style with dotted rules such as those created by
+% |\hdottedline| or the letter ``|:|'' in the preamble (cf. p.~\pageref{dotted}).
+% \end{itemize}
+%
+% \medskip
+% That system may be used, in particular, for the definition of commands and
+% letters to draw rules with a specific color (and those rules will respect the
+% blocks as do all rules of \pkg{nicematrix}).
+%
+%
+% \medskip
+% \begin{Verbatim}
+% \begin{NiceTabular}{lcIcIc}~emphase#[custom-line = {letter=I, color=blue}]@
+% \hline
+% & \Block{1-3}{dimensions} \\
+% & L & l & h \\
+% \hline
+% Product A & 3 & 1 & 2 \\
+% Product B & 1 & 3 & 4 \\
+% Product C & 5 & 4 & 1 \\
+% \hline
+% \end{NiceTabular}
+% \end{Verbatim}
+%
+%
+% \begin{center}
+% \begin{NiceTabular}{lcIcIc}[custom-line = {letter=I, color=blue}]
+% \hline
+% & \Block{1-3}{dimensions} \\
+% & L & l & H \\
+% \hline
+% Product A & 3 & 1 & 2 \\
+% Product B & 1 & 3 & 4 \\
+% Product C & 5 & 4 & 1 \\
+% \hline
+% \end{NiceTabular}
+% \end{center}
+%
+%
+%
%\section{The color of the rows and columns}
%
% \subsection{Use of colortbl}
@@ -1508,9 +1575,10 @@
%
%
% \bigskip
-% The last argument of |\rowcolors| is an optional list of pairs key-value (the
-% optional argument in the first position corresponds to the colorimetric
-% space). The available keys are |cols|, |restart| and |respect-blocks|.
+% The last argument of |\rowcolors| is an optional list of pairs
+% \textsl{key=value} (the optional argument in the first position corresponds to
+% the colorimetric space). The available keys are |cols|, |restart| and
+% |respect-blocks|.
% \begin{itemize}
% \item The key |cols| describes a set of columns. The command |\rowcolors| will
% color only the cells of these columns. The value is a comma-separated list of
@@ -1784,7 +1852,7 @@
%
% \medskip
% That command also takes in as optional argument (between square brackets)
-% a list of key-value pairs.
+% a list of \textsl{key=value} pairs.
% \begin{itemize}
% \item \colorbox{yellow!50}{\bfseries New 6.3}\enskip The key |nb-rows| sets
% the number of rows to which the specifications of the current command will
@@ -2139,7 +2207,7 @@
% |{NiceArray}| and its variants), no letter must be given in that preamble for
% the potential first column and the potential last column: they will
% automatically (and necessarily) be of type |r| for the first column and |l|
-% for the last one.\footnote{The users wishing exteriors columns with another
+% for the last one.\footnote{The users wishing exterior columns with another
% type of alignment should consider the command |\SubMatrix| available in the
% |\CodeAfter| (cf.~p.~\pageref{sub-matrix}).}
% \item One may wonder how \pkg{nicematrix} determines the number of rows and
@@ -2841,7 +2909,7 @@
% syntax $i$|-|$j$ where $i$ the number of row and $j$ the number of column;
% \item the third argument is the lower-right corner with the same syntax;
% \item the fourth argument is the right delimiter;
-% \item the last argument, which is optional, is a list of key-value
+% \item the last argument, which is optional, is a list of \textsl{key=value}
% pairs.\footnote{There is no optional argument between square brackets in first
% position because a square bracket just after |\SubMatrix| must be interpreted
% as the first (mandatory) argument of the command |\SubMatrix|: that bracket is
@@ -3070,7 +3138,7 @@
% \bigskip
% In fact, the commands |\OverBrace| and |\UnderBrace| take in an optional
% argument (in first position and between square brackets) for a list of
-% key-value pairs. The available keys are:
+% \textsl{key=value} pairs. The available keys are:
% \begin{itemize}
% \item |left-shorten| and |right-shorten| which do not take in value; when the
% key |left-shorten| is used, the abscissa of the left extremity of the brace is
@@ -3372,21 +3440,24 @@
%
%
% \item The notes are composed at the end of the tabular by using internally a
-% style of list of \pkg{enumitem}.
+% style of list of \pkg{enumitem}. This style of list is defined as follows (with, of
+% course, keys of \pkg{enumitem}):
%
-% The key |notes/enumitem-keys| specifies a list of pairs
-% \textsl{key=value} (following the specifications of \pkg{enumitem}) to
-% customize that type of list.
+% |noitemsep , leftmargin = * , align = left , labelsep = 0pt|
%
-% Initial value:\quad |noitemsep , leftmargin = * , align = left , labelsep = 0pt|
-%
-% This initial value contains the specification |align = left| which requires a
+% The specification |align = left| in that style requires a
% composition of the label leftwards in the box affected to that label.
% With that tuning, the notes are composed flush left, which is pleasant when
% composing tabulars in the spirit of \pkg{booktabs} (see for example the
% table \ref{t:tabularnote}, p.~\pageref{t:tabularnote}).
%
+% \medskip
+% The key |notes/enumitem-keys| specifies a list of pairs
+% \textsl{key=value} (following the specifications of \pkg{enumitem}) to
+% customize that style of list (it uses internally the command |\setlist*| of
+% \pkg{enumitem}).
%
+%
% \item The key |notes/enumitem-keys-para| is similar to the previous one but
% corresponds to the type of list used when the option |para| is in force. Of
% course, when the option |para| is used, a list of type |inline| (as called by
@@ -3393,7 +3464,8 @@
% \pkg{enumitem}) is used and the pairs \textsl{key=value} should correspond to
% such a list of type |inline|.
%
-% Initial value:\quad |afterlabel = \nobreak, itemjoin = \quad|
+% Initially, the style of list is defined by:\quad
+% |afterlabel = \nobreak, itemjoin = \quad|
%
%
% \item The key |notes/code-before| is a token list inserted by \pkg{nicematrix}
@@ -4128,6 +4200,52 @@
% written on the |aux| file and created a second time during the contruction of
% the array itself).
%
+% \bigskip
+% Here is an example which uses these nodes in the |\CodeAfter|.
+%
+% \begin{center}
+% \fvset{commandchars=\~\#\+}
+% \begin{Verbatim}
+% \begin{NiceArray}{c@{\;}c@{\;}c@{\;}c@{\;}c}[create-medium-nodes]
+% u_1 &-& u_0 &=& r \\
+% u_2 &-& u_1 &=& r \\
+% u_3 &-& u_2 &=& r \\
+% u_4 &-& u_3 &=& r \\
+% \phantom{u_5} & & \phantom{u_4} &\smash{\vdots} & \\
+% u_n &-& u_{n-1} &=& r \\[3pt]
+% \hline
+% u_n &-& u_0 &=& nr \\
+% \CodeAfter
+% \tikz[very thick, red, opacity=0.4,name suffix = -medium]
+% \draw (1-1.north west) -- (2-3.south east)
+% (2-1.north west) -- (3-3.south east)
+% (3-1.north west) -- (4-3.south east)
+% (4-1.north west) -- (5-3.south east)
+% (5-1.north west) -- (6-3.south east) ;
+% \end{NiceArray}
+% \end{Verbatim}
+% \end{center}
+%
+% \[\begin{NiceArray}{c@{\;}c@{\;}c@{\;}c@{\;}c}[create-medium-nodes]
+% u_1 &-& u_0 &=& r \\
+% u_2 &-& u_1 &=& r \\
+% u_3 &-& u_2 &=& r \\
+% u_4 &-& u_3 &=& r \\
+% \phantom{u_5} & & \phantom{u_4} &\smash{\vdots} & \\
+% u_n &-& u_{n-1} &=& r \\[3pt]
+% \hline
+% u_n &-& u_0 &=& nr \\
+% \CodeAfter
+% \tikz[very thick, red, opacity=0.4,name suffix = -medium]
+% \draw (1-1.north west) -- (2-3.south east)
+% (2-1.north west) --(3-3.south east)
+% (3-1.north west) -- (4-3.south east)
+% (4-1.north west) -- (5-3.south east)
+% (5-1.north west) -- (6-3.south east) ;
+% \end{NiceArray}\]
+%
+%
+%
% \subsection{The nodes which indicate the position of the rules}
%
% \label{nodes-i}
@@ -4603,7 +4721,7 @@
% loaded.\footnote{By default, \pkg{nicematrix} only loads \textsc{pgf}, which is
% a sub-layer of Tikz.}
%
-% For the following example, you need also the Tikz library |patterns|
+% For the following example, we need also the Tikz library |patterns|.
%
% \begin{Verbatim}
% \usetikzlibrary{patterns}
@@ -5110,10 +5228,9 @@
%
%
%\bigskip
-% \colorbox{yellow!50}{\textbf{New 6.2}}\enskip In fact, it's possible, with the
-% key |vlines-in-sub-matrix|, to choice a letter in the preamble of the
-% array to specify vertical rules which will be drawn in the |\SubMatrix| only
-% (by adding space between the columns).
+% In fact, it's possible, with the key |vlines-in-sub-matrix|, to choice a
+% letter in the preamble of the array to specify vertical rules which will be
+% drawn in the |\SubMatrix| only (by adding space between the columns).
%
% \medskip
% \begin{Verbatim}
@@ -5714,7 +5831,7 @@
\cs_set:Npn \CT at arc #1 #2
{
\dim_compare:nNnT \baselineskip = \c_zero_dim \noalign
- { \cs_gset:Npn \CT at arc@ { \color #1 { #2 } } }
+ { \cs_gset:Npn \CT at arc@ { \color #1 { #2 } } }
}
% \end{macrocode}
% Idem for |\CT at drs@|.
@@ -5723,7 +5840,7 @@
\cs_set:Npn\CT at drs #1 #2
{
\dim_compare:nNnT \baselineskip = \c_zero_dim \noalign
- { \cs_gset:Npn \CT at drsc@ { \color #1 { #2 } } }
+ { \cs_gset:Npn \CT at drsc@ { \color #1 { #2 } } }
}
\cs_set:Npn \hline
{
@@ -5847,10 +5964,20 @@
\cs_new_protected:Npn \@@_set_CT at arc@_ii: #1 \q_stop
{ \cs_set:Npn \CT at arc@ { \color { #1 } } }
% \end{macrocode}
-%
%
% \bigskip
% \begin{macrocode}
+\cs_new_protected:Npn \@@_set_CT at drsc@:
+ { \peek_meaning:NTF [ \@@_set_CT at drsc@_i: \@@_set_CT at drsc@_ii: }
+\cs_new_protected:Npn \@@_set_CT at drsc@_i: [ #1 ] #2 \q_stop
+ { \cs_set:Npn \CT at drsc@ { \color [ #1 ] { #2 } } }
+\cs_new_protected:Npn \@@_set_CT at drsc@_ii: #1 \q_stop
+ { \cs_set:Npn \CT at drsc@ { \color { #1 } } }
+% \end{macrocode}
+%
+%
+% \bigskip
+% \begin{macrocode}
\cs_set_eq:NN \@@_old_pgfpointanchor \pgfpointanchor
% \end{macrocode}
%
@@ -6342,6 +6469,7 @@
% \begin{macrocode}
\seq_new:N \g_@@_pos_of_stroken_blocks_seq
% \end{macrocode}
+%
%
% \medskip
% If the user has used the key |corners| (or the key |hvlines-except-corners|,
@@ -6465,9 +6593,11 @@
%
%
% \medskip
-% The following flag corresponds to the key |hvlines| of the command |\Block|.
+% The following flag corresponds to the keys |vlines| and |hlines| of the
+% command |\Block| (the key |hvlines| is the conjunction of both).
% \begin{macrocode}
-\bool_new:N \l_@@_hvlines_block_bool
+\bool_new:N \l_@@_vlines_block_bool
+\bool_new:N \l_@@_hlines_block_bool
% \end{macrocode}
%
%
@@ -6491,7 +6621,7 @@
%
%
% \bigskip
-% The following flag will be used by (for instance) |\@@_vline_ii:nnnn|.
+% The following flag will be used by (for instance) |\@@_vline_ii:|.
% When |\l_@@_dotted_bool| is |true|, a dotted line (with our system) will be drawn.
% \begin{macrocode}
\bool_new:N \l_@@_dotted_bool
@@ -7019,7 +7149,14 @@
\bool_new:N \l_@@_nullify_dots_bool
% \end{macrocode}
%
+% \medskip
+% The following flag corresponds to the key |respect-arraystretch| (that key has
+% an effect on the blocks).
+% \begin{macrocode}
+\bool_new:N \l_@@_respect_arraystretch_bool
+% \end{macrocode}
%
+%
% \bigskip
% The following flag will be used when the current options specify that all the
% columns of the array must have the same width equal to the largest width of a
@@ -7174,8 +7311,8 @@
% \begin{macrocode}
\keys_define:nn { NiceMatrix / Global }
{
- delimiters .code:n =
- \keys_set:nn { NiceMatrix / delimiters } { #1 } ,
+ custom-line .code:n = \@@_custom_line:n { #1 } ,
+ delimiters .code:n = \keys_set:nn { NiceMatrix / delimiters } { #1 } ,
delimiters .value_required:n = true ,
rules .code:n = \keys_set:nn { NiceMatrix / rules } { #1 } ,
rules .value_required:n = true ,
@@ -7256,6 +7393,8 @@
extra-margin .meta:n =
{ extra-left-margin = #1 , extra-right-margin = #1 } ,
extra-margin .value_required:n = true ,
+ respect-arraystretch .bool_set:N = \l_@@_respect_arraystretch_bool ,
+ respect-arraystretch .default:n = true
}
% \end{macrocode}
%
@@ -8284,7 +8423,7 @@
% The box |\@arstrutbox| is a box constructed in the beginning of the
% environment |{array}|. The construction of that box takes into account the
% current value of |\arraystretch|\footnote{The option |small| of
-% \pkg{nicematrix} changes (among other) the value of |\arraystretch|. This is
+% \pkg{nicematrix} changes (among others) the value of |\arraystretch|. This is
% done, of course, before the call of |{array}|.} and |\extrarowheight| (of
% \pkg{array}). That box is inserted (via |\@arstrut|) in the beginning of each
% row of the array. That's why we use the dimensions of that box to initialize
@@ -9305,11 +9444,11 @@
% \bigskip
% We redefine the column types |w| and |W|. We use |\@@_newcolumntype| instead
% of |\newcolumtype| because we don't want warnings for column types already
-% defined. These redefinitions are in fact \emph{protections} of the letters |w|
+% defined. These redefinitions are in fact \emph{protections} of the letters |w|
% and |W|. We don't want these columns type expanded because we will do the
-% patch ourselves after. We want to be able the standard column types |w| and
-% |W| in potential |{tabular}| of \pkg{array} in some cells of our array. That's
-% why we do those redefinitions in a TeX group.
+% patch ourselves after. We want to be able to use the standard column types |w|
+% and |W| in potential |{tabular}| of \pkg{array} in some cells of our array.
+% That's why we do those redefinitions in a TeX group.
% \begin{macrocode}
\group_begin:
% \end{macrocode}
@@ -9408,7 +9547,7 @@
%
% \medskip
% Now, we can close the TeX group which was opened for the redefinition of
-% the columns of type |w| and |W|.
+% the columns of type |w| and~|W|.
% \begin{macrocode}
\group_end:
% \end{macrocode}
@@ -9470,6 +9609,8 @@
% \end{macrocode}
%
% \bigskip
+% The command |\@@_patch_preamble:n| is the main function for the transformation
+% of the preamble. It is recursive.
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble:n #1
{
@@ -9498,18 +9639,18 @@
\} { \@@_patch_preamble_ix:nn #1 }
X { \@@_patch_preamble_x:n }
% \end{macrocode}
-% When \pkg{tabularx} is loaded, a local redefinition of the specifier `X` is
-% done to replace `X` by `\@@_X`. Thus, our column type `X` will be used in the
-% `{NiceTabularX}`.
+% When \pkg{tabularx} is loaded, a local redefinition of the specifier |X| is
+% done to replace |X| by |\@@_X|. Thus, our column type |X| will be used in the
+% |{NiceTabularX}|.
% \begin{macrocode}
\@@_X { \@@_patch_preamble_x:n }
\q_stop { }
}
{
- \str_if_eq:VnTF \l_@@_letter_for_dotted_lines_str { #1 }
- { \@@_patch_preamble_xii:n #1 }
+ \str_case_e:nnF { #1 }
{
- \str_if_eq:VnTF \l_@@_letter_vlism_tl { #1 }
+ \l_@@_letter_for_dotted_lines_str { \@@_patch_preamble_xii:n #1 }
+ \l_@@_letter_vlism_tl
{
\seq_gput_right:Nx \g_@@_cols_vlism_seq
{ \int_eval:n { \c at jCol + 1 } }
@@ -9517,20 +9658,40 @@
{ \exp_not:N ! { \skip_horizontal:N \arrayrulewidth } }
\@@_patch_preamble:n
}
- {
- \bool_lazy_and:nnTF
- { \str_if_eq_p:nn { : } { #1 } }
- \c_@@_arydshln_loaded_bool
+ { : }
+ {
+ \bool_if:NTF \c_@@_arydshln_loaded_bool
{
\tl_gput_right:Nn \g_@@_preamble_tl { : }
\@@_patch_preamble:n
}
- { \@@_fatal:nn { unknown~column~type } { #1 } }
- }
+ { \@@_fatal:n { colon~without~arydshln } }
+ }
}
+% \end{macrocode}
+% Now the case of a letter set by the final user for a customized rule. Such
+% customized rule is defined by using the key |custom-line| in
+% |\NiceMatrixOptions|. That key takes in as value a list of \textsl{key=value}
+% pairs. Among the keys avalaible in that list, there is the key |letter|. All
+% the letters defined by this way by the final user for such customized rules
+% are added in the set of keys |{NiceMatrix/ColumnTypes}|. That set of keys is
+% used to store the characteristics of those types of rules for convenience: the
+% keys of that set of keys won't never be used as keys by the final user (he
+% will use, instead, letters in the preamble of its array).
+% \begin{macrocode}
+ {
+ \keys_set_known:nnN { NiceMatrix / ColumnTypes } { #1 } \l_tmpa_tl
+ \tl_if_empty:NTF \l_tmpa_tl
+ \@@_patch_preamble:n
+ { \@@_fatal:nn { unknown~column~type } { #1 } }
+ }
}
}
% \end{macrocode}
+%
+% \bigskip
+% Now, we will list all the auxiliary functions for the different types of
+% entries in the preamble of the array.
%
% \medskip
% For |c|, |l| and |r|
@@ -9588,6 +9749,9 @@
{
\skip_horizontal:n
{
+% \end{macrocode}
+% Here, the command |\dim_eval:n| is mandatory.
+% \begin{macrocode}
\dim_eval:n
{
\arrayrulewidth * \l_tmpa_int
@@ -9598,8 +9762,16 @@
}
\tl_gput_right:Nx \g_@@_internal_code_after_tl
{
- \@@_vline:nnnn
- { \@@_succ:n \c at jCol } { \int_use:N \l_tmpa_int } { 1 } { }
+ \@@_vline:n
+ {
+ position = \@@_succ:n \c at jCol ,
+ multiplicity = \int_use:N \l_tmpa_int ,
+ }
+% \end{macrocode}
+% We don't have provided value for |start| nor for |end|, which means that the
+% rule will cover (potentially) all the rows of the array.
+%
+% \begin{macrocode}
}
\int_zero:N \l_tmpa_int
\str_if_eq:nnT { #1 } { \q_stop } { \bool_gset_true:N \g_tmpb_bool }
@@ -10288,9 +10460,17 @@
\seq_gput_left:Nn \g_@@_multicolumn_sizes_seq { #1 }
\seq_gput_right:Nx \g_@@_pos_of_blocks_seq
{
- { \int_use:N \c at iRow }
+ {
+ \int_compare:nNnTF \c at jCol = 0
+ { \int_eval:n { \c at iRow + 1 } }
+ { \int_use:N \c at iRow }
+ } % modified 2022/01/10
{ \int_eval:n { \c at jCol + 1 } }
- { \int_use:N \c at iRow }
+ {
+ \int_compare:nNnTF \c at jCol = 0
+ { \int_eval:n { \c at iRow + 1 } }
+ { \int_use:N \c at iRow }
+ } % modified 2022/01/10
{ \int_eval:n { \c at jCol + #1 } }
{ } % for the name of the block
}
@@ -11092,8 +11272,14 @@
% \begin{macrocode}
&
\omit
+% \end{macrocode}
+% The two following lines have been added on 2021-12-15 to solve a bug
+% mentionned by Joao Luis Soares by mail.
+% \begin{macrocode}
+ \int_compare:nNnT \g_@@_col_total_int = 1
+ { \skip_gset:Nn \g_tmpa_skip { 0 pt~plus 1 fill } }
+ \skip_horizontal:N \g_tmpa_skip
\int_gincr:N \g_tmpa_int
- \skip_horizontal:N \g_tmpa_skip
\bool_lazy_all:nT
{
\l_@@_NiceArray_bool
@@ -13647,7 +13833,7 @@
nb-rows .initial:n = 1 ,
rowcolor .tl_set:N = \l_tmpc_tl ,
rowcolor .value_required:n = true ,
- rowcolor .initial:n = \c_empty_tl ,
+ rowcolor .initial:n = ,
unknown .code:n = \@@_error:n { Unknown~key~for~RowStyle }
}
% \end{macrocode}
@@ -13950,20 +14136,12 @@
% \end{macrocode}
%
% \bigskip
-% \begin{macrocode}
-\keys_define:nn { NiceMatrix / arraycolor }
- { except-corners .code:n = \@@_error:n { key~except-corners } }
-% \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.
+% exterior rows and columns) and the cells in the ``corners''.
% \begin{macrocode}
-\NewDocumentCommand \@@_arraycolor { O { } m O { } }
+\NewDocumentCommand \@@_arraycolor { O { } m }
{
- \keys_set:nn { NiceMatrix / arraycolor } { #3 }
\@@_rectanglecolor [ #1 ] { #2 }
{ 1 - 1 }
{ \int_use:N \c at iRow - \int_use:N \c at jCol }
@@ -13993,7 +14171,7 @@
% |#1| (optional) is the color space ;
% |#2| is a list of intervals of rows ;
% |#3| is the list of colors ;
-% |#4| is for the optional list of pairs key-value.
+% |#4| is for the optional list of pairs \textsl{key=value}.
% \begin{macrocode}
\NewDocumentCommand \@@_rowlistcolors { O { } m m O { } }
{
@@ -14354,9 +14532,12 @@
%
%
%
+% \bigskip
+% \subsection*{The vertical and horizontal rules}
+%
%
% \bigskip
-% \subsection*{The vertical rules}
+% \subsubsection*{OnlyMainNiceMatrix}
%
% We give to the user the possibility to define new types of columns (with
% |\newcolumntype| of \pkg{array}) for special vertical rules (\emph{e.g.} rules
@@ -14413,42 +14594,101 @@
%
%
% \bigskip
-% The following command will be executed in the |internal-code-after|. The rule
-% will be drawn \emph{before} the column |#1| (that is to say on the left side).
-% |#2| is the number of consecutive occurrences of \verb+|+. |#3| and |#4| are
-% the numbers of rows that define the delimitation of the horizontal rule that
-% we have to draw. If |#4| is empty, that means that the rule extends until the
-% last row.
+% \subsubsection*{General system for drawing rules}
+%
+% When a command, environment or ``subsystem'' of \pkg{nicematrix} wants to draw
+% a rule, it will write in the internal |\CodeAfter| a command |\@@_vline:n| or
+% |\@@_hline:n|. Both commands take in as argument a list of \textsl{key=value}
+% pairs. That list will first be analyzed with the following set of keys.
+% However, unknown keys will be analyzed further with another set of keys.
+%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_vline:nnnn #1 #2 #3 #4
+\keys_define:nn { NiceMatrix / Rules }
+ {
+ position .int_set:N = \l_@@_position_int ,
+ position .value_required:n = true ,
+ start .int_set:N = \l_@@_start_int ,
+ start .initial:n = 1 ,
+ end .int_set:N = \l_@@_end_int ,
+% \end{macrocode}
+% The following keys are no-op because there are keys which may be inherited
+% from a list of pairs \textsl{key=value} of a definition of a customized rule
+% (with the key |custom-line| of |\NiceMatrixOptions|).
+% \begin{macrocode}
+ letter .code:n = \prg_do_nothing: ,
+ command .code:n = \prg_do_nothing:
+ }
+% \end{macrocode}
+%
+% \bigskip
+% It's possible that the rule won't be drawn continuously from |start| ot |end|
+% because of the blocks (created with the command |\Block|), the virtual blocks
+% (created by |\Cdots|, etc.), etc. That's why an analyse is done and the rule
+% is cut in small rules which will actually be drawn. The small continuous rules
+% will be drawn by |\@@_vline_ii:| and |\@@_hline_ii:|. Those commands use the
+% following set of keys.
+%
+% \begin{macrocode}
+\keys_define:nn { NiceMatrix / RulesBis }
+ {
+ multiplicity .int_set:N = \l_@@_multiplicity_int ,
+ multiplicity .initial:n = 1 ,
+ dotted .bool_set:N = \l_@@_dotted_bool ,
+ dotted .initial:n = false ,
+ dotted .default:n = true ,
+ color .code:n = \@@_set_CT at arc@: #1 \q_stop ,
+ color .value_required:n = true ,
+ sep-color .code:n = \@@_set_CT at drsc@: #1 \q_stop ,
+ sep-color .value_required:n = true ,
+% \end{macrocode}
+% If the user uses the key |tikz|, the rule (or more precisely: the different
+% sub-rules since a rule may be broken by blocks or others) will be drawn with
+% Tikz.
+% \begin{macrocode}
+ tikz .tl_set:N = \l_@@_tikz_rule_tl ,
+ tikz .value_required:n = true ,
+ tikz .initial:n =
+ }
+% \end{macrocode}
+%
+%
+% \subsubsection*{The vertical rules}
+%
+% The following command will be executed in the internal |\CodeAfter|. The
+% argument |#1| is a list of \textsl{key=value} pairs.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_vline:n #1
{
% \end{macrocode}
+% The group is for the options.
+% \begin{macrocode}
+ \group_begin:
+ \int_zero_new:N \l_@@_end_int
+ \int_set_eq:NN \l_@@_end_int \c at iRow
+ \keys_set_known:nnN { NiceMatrix / Rules } { #1 } \l_@@_other_keys_tl
+% \end{macrocode}
% The following test is for the case where the user does not use all the columns
% specified in the preamble of the environment (for instance, a preamble of
% \verb+|c|c|c|+ but only two columns used).
% \begin{macrocode}
- \int_compare:nNnT { #1 } < { \c at jCol + 2 }
- {
- \pgfpicture
- \@@_vline_i:nnnn { #1 } { #2 } { #3 } { #4 }
- \endpgfpicture
- }
+ \int_compare:nNnT \l_@@_position_int < { \c at jCol + 2 }
+ \@@_vline_i:
+ \group_end:
}
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_vline_i:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \@@_vline_i:
{
+ \int_zero_new:N \l_@@_local_start_int
+ \int_zero_new:N \l_@@_local_end_int
% \end{macrocode}
% |\l_tmpa_tl| is the number of row and |\l_tmpb_tl| the number of column. When
% we have found a row corresponding to a rule to draw, we note its number in
% |\l_tmpc_tl|.
% \begin{macrocode}
- \tl_set:Nx \l_tmpb_tl { #1 }
- \tl_clear_new:N \l_tmpc_tl
- \int_step_variable:nnNn
- { #3 }
- { \tl_if_blank:nTF { #4 } { \int_use:N \c at iRow } { #4 } }
+ \tl_set:Nx \l_tmpb_tl { \int_eval:n \l_@@_position_int }
+ \int_step_variable:nnNn \l_@@_start_int \l_@@_end_int
\l_tmpa_tl
{
% \end{macrocode}
@@ -14468,32 +14708,26 @@
\clist_if_empty:NF \l_@@_corners_clist \@@_test_in_corner_v:
\bool_if:NTF \g_tmpa_bool
{
- \tl_if_empty:NT \l_tmpc_tl
+ \int_compare:nNnT \l_@@_local_start_int = 0
% \end{macrocode}
-% We keep in memory that we have a rule to draw.
+% We keep in memory that we have a rule to draw. |\l_@@_local_start_int| will be
+% the starting row of the rule that we will have to draw.
% \begin{macrocode}
- { \tl_set_eq:NN \l_tmpc_tl \l_tmpa_tl }
+ { \int_set:Nn \l_@@_local_start_int \l_tmpa_tl }
}
{
- \tl_if_empty:NF \l_tmpc_tl
+ \int_compare:nNnT \l_@@_local_start_int > 0
{
- \@@_vline_ii:nnnn
- { #1 }
- { #2 }
- \l_tmpc_tl
- { \int_eval:n { \l_tmpa_tl - 1 } }
- \tl_clear:N \l_tmpc_tl
+ \int_set:Nn \l_@@_local_end_int { \l_tmpa_tl - 1 }
+ \@@_vline_ii:
+ \int_zero:N \l_@@_local_start_int
}
}
}
- \tl_if_empty:NF \l_tmpc_tl
+ \int_compare:nNnT \l_@@_local_start_int > 0
{
- \@@_vline_ii:nnnn
- { #1 }
- { #2 }
- \l_tmpc_tl
- { \tl_if_blank:nTF { #4 } { \int_use:N \c at iRow } { #4 } }
- \tl_clear:N \l_tmpc_tl
+ \int_set_eq:NN \l_@@_local_end_int \l_@@_end_int
+ \@@_vline_ii:
}
}
% \end{macrocode}
@@ -14528,39 +14762,39 @@
% \end{macrocode}
%
% \bigskip
-% |#1| is the number of the column; |#2| is the number of vertical rules to
-% draw (with potentially a color between); |#3| and |#4| are the numbers of the
-% rows between which the rule has to be drawn.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_vline_ii:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \@@_vline_ii:
{
+ \bool_set_false:N \l_@@_dotted_bool
+ \keys_set:nV { NiceMatrix / RulesBis } \l_@@_other_keys_tl
\bool_if:NTF \l_@@_dotted_bool
- { \@@_vline_iv:nnn { #1 } { #3 } { #4 } }
- { \@@_vline_iii:nnnn { #1 } { #2 } { #3 } { #4 } }
+ \@@_vline_iv:
+ {
+ \tl_if_empty:NTF \l_@@_tikz_rule_tl
+ \@@_vline_iii:
+ \@@_vline_v:
+ }
}
% \end{macrocode}
%
% \bigskip
-% The following code is for the standard case (the rule which is drawn is a
-% solid rule).
-%
-% |#1| is the number of the column; |#2| is the number of vertical rules to
-% draw (with potentially a color between); |#3| and |#4| are the numbers of the
-% rows between which the rule has to be drawn.
+% First the case of a standard rule, that is to say a rule which is not dotted
+% (and the user has not used the key |tikz|).
% \begin{macrocode}
-\cs_new_protected:Npn \@@_vline_iii:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \@@_vline_iii:
{
+ \pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgf at relevantforpicturesizefalse
- \@@_qpoint:n { row - #3 }
+ \@@_qpoint:n { row - \int_use:N \l_@@_local_start_int }
\dim_set_eq:NN \l_tmpa_dim \pgf at y
- \@@_qpoint:n { col - #1 }
+ \@@_qpoint:n { col - \int_use:N \l_@@_position_int }
\dim_set_eq:NN \l_tmpb_dim \pgf at x
- \@@_qpoint:n { row - \@@_succ:n { #4 } }
+ \@@_qpoint:n { row - \int_eval:n { \l_@@_local_end_int + 1 } }
\dim_set_eq:NN \l_tmpc_dim \pgf at y
\bool_lazy_all:nT
{
- { \int_compare_p:nNn { #2 } > 1 }
+ { \int_compare_p:nNn \l_@@_multiplicity_int > 1 }
{ \cs_if_exist_p:N \CT at drsc@ }
{ ! \tl_if_blank_p:V \CT at drsc@ }
}
@@ -14570,7 +14804,10 @@
\dim_add:Nn \l_tmpa_dim { 0.5 \arrayrulewidth }
\dim_sub:Nn \l_tmpc_dim { 0.5 \arrayrulewidth }
\dim_set:Nn \l_tmpd_dim
- { \l_tmpb_dim - ( \doublerulesep + \arrayrulewidth ) * ( #2 - 1 ) }
+ {
+ \l_tmpb_dim - ( \doublerulesep + \arrayrulewidth )
+ * ( \l_@@_multiplicity_int - 1 )
+ }
\pgfpathrectanglecorners
{ \pgfpoint \l_tmpb_dim \l_tmpa_dim }
{ \pgfpoint \l_tmpd_dim \l_tmpc_dim }
@@ -14579,7 +14816,7 @@
}
\pgfpathmoveto { \pgfpoint \l_tmpb_dim \l_tmpa_dim }
\pgfpathlineto { \pgfpoint \l_tmpb_dim \l_tmpc_dim }
- \prg_replicate:nn { #2 - 1 }
+ \prg_replicate:nn { \l_@@_multiplicity_int - 1 }
{
\dim_sub:Nn \l_tmpb_dim \arrayrulewidth
\dim_sub:Nn \l_tmpb_dim \doublerulesep
@@ -14590,32 +14827,57 @@
\pgfsetlinewidth { 1.1 \arrayrulewidth }
\pgfsetrectcap
\pgfusepathqstroke
+ \endpgfpicture
}
% \end{macrocode}
%
%
% \bigskip
-% The following code is for the case of a dotted rule (with our system).
-%
-% |#1| is the number of the column; |#2| and |#3| are the numbers of the
-% rows between which the rule has to be drawn.
+% The following code is for the case of a dotted rule (with our system of
+% rounded dots).
% \begin{macrocode}
-\cs_new_protected:Npn \@@_vline_iv:nnn #1 #2 #3
+\cs_new_protected:Npn \@@_vline_iv:
{
+ \pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgf at relevantforpicturesizefalse
- \@@_qpoint:n { col - #1 }
+ \@@_qpoint:n { col - \int_use:N \l_@@_position_int }
\dim_set_eq:NN \l_@@_x_initial_dim \pgf at x
\dim_set_eq:NN \l_@@_x_final_dim \pgf at x
- \@@_qpoint:n { row - #2 }
+ \@@_qpoint:n { row - \int_use:N \l_@@_local_start_int }
\dim_set_eq:NN \l_@@_y_initial_dim \pgf at y
- \@@_qpoint:n { row - \@@_succ:n { #3 } }
+ \@@_qpoint:n { row - \int_eval:n { \l_@@_local_end_int + 1 } }
\dim_set_eq:NN \l_@@_y_final_dim \pgf at y
+ \CT at arc@
\@@_draw_line:
+ \endpgfpicture
}
% \end{macrocode}
%
+% \bigskip
+% The following code is for the case when the user uses the key |tikz| (in the
+% definition of a customized rule by using the key |custom-line|).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_vline_v:
+ {
+ \begin {tikzpicture }
+ \pgfrememberpicturepositiononpagetrue
+ \pgf at relevantforpicturesizefalse
+ \@@_qpoint:n { row - \int_use:N \l_@@_local_start_int }
+ \dim_set_eq:NN \l_tmpa_dim \pgf at y
+ \@@_qpoint:n { col - \int_use:N \l_@@_position_int }
+ \dim_set_eq:NN \l_tmpb_dim \pgf at x
+ \@@_qpoint:n { row - \int_eval:n { \l_@@_local_end_int + 1 } }
+ \dim_set_eq:NN \l_tmpc_dim \pgf at y
+ \exp_args:NV \tikzset \l_@@_tikz_rule_tl
+ \use:x { \exp_not:N \draw [ \l_@@_tikz_rule_tl ] }
+ ( \l_tmpb_dim , \l_tmpa_dim ) --
+ ( \l_tmpb_dim , \l_tmpc_dim ) ;
+ \end { tikzpicture }
+ }
+% \end{macrocode}
%
+%
% \bigskip
% The command |\@@_draw_vlines:| draws all the vertical rules excepted in the
% blocks, in the virtual blocks (determined by a command such as |\Cdots|) and in
@@ -14636,7 +14898,7 @@
{
\tl_if_eq:NnF \l_@@_vlines_clist { all }
{ \clist_if_in:NnT \l_@@_vlines_clist { ##1 } }
- { \@@_vline:nnnn { ##1 } 1 1 { } }
+ { \@@_vline:n { position = ##1 } }
}
}
% \end{macrocode}
@@ -14643,36 +14905,39 @@
%
%
%
-% \subsection*{The horizontal rules}
+% \subsubsection*{The horizontal rules}
%
% \bigskip
-% The following command will be executed in the internal |\CodeAfter|. The rule
-% will be drawn \emph{before} the row |#1|. |#2| is the number of consecutive
-% occurrences of |\Hline|. |#3| and |#4| are numbers of columns that define the
-% delimitation of the horizontal rule that we have to draw. If |#4| is empty,
-% that means that the rule extends until the last column.
+% The following command will be executed in the internal |\CodeAfter|. The
+% argument |#1| is a list of \textsl{key=value} pairs of the form
+% |{NiceMatrix/Rules}|.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_hline:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \@@_hline:n #1
{
- \pgfpicture
- \@@_hline_i:nnnn { #1 } { #2 } { #3 } { #4 }
- \endpgfpicture
+% \end{macrocode}
+% The group is for the options.
+% \begin{macrocode}
+ \group_begin:
+ \int_zero_new:N \l_@@_end_int
+ \int_set_eq:NN \l_@@_end_int \c at jCol
+ \keys_set_known:nnN { NiceMatrix / Rules } { #1 } \l_@@_other_keys_tl
+ \@@_hline_i:
+ \group_end:
}
% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_hline_i:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \@@_hline_i:
{
+ \int_zero_new:N \l_@@_local_start_int
+ \int_zero_new:N \l_@@_local_end_int
% \end{macrocode}
% |\l_tmpa_tl| is the number of row and |\l_tmpb_tl| the number of column. When
% 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 }
- \tl_clear_new:N \l_tmpc_tl
- \int_step_variable:nnNn
- { #3 }
- { \tl_if_blank:nTF { #4 } { \int_use:N \c at jCol } { #4 } }
+ \tl_set:Nx \l_tmpa_tl { \int_use:N \l_@@_position_int }
+ \int_step_variable:nnNn \l_@@_start_int \l_@@_end_int
\l_tmpb_tl
{
% \end{macrocode}
@@ -14692,32 +14957,26 @@
\clist_if_empty:NF \l_@@_corners_clist \@@_test_in_corner_h:
\bool_if:NTF \g_tmpa_bool
{
- \tl_if_empty:NT \l_tmpc_tl
+ \int_compare:nNnT \l_@@_local_start_int = 0
% \end{macrocode}
-% We keep in memory that we have a rule to draw.
+% We keep in memory that we have a rule to draw. |\l_@@_local_start_int| will be
+% the starting row of the rule that we will have to draw.
% \begin{macrocode}
- { \tl_set_eq:NN \l_tmpc_tl \l_tmpb_tl }
+ { \int_set:Nn \l_@@_local_start_int \l_tmpb_tl }
}
{
- \tl_if_empty:NF \l_tmpc_tl
+ \int_compare:nNnT \l_@@_local_start_int > 0
{
- \@@_hline_ii:nnnn
- { #1 }
- { #2 }
- \l_tmpc_tl
- { \int_eval:n { \l_tmpb_tl - 1 } }
- \tl_clear:N \l_tmpc_tl
+ \int_set:Nn \l_@@_local_end_int { \l_tmpb_tl - 1 }
+ \@@_hline_ii:
+ \int_zero:N \l_@@_local_start_int
}
}
}
- \tl_if_empty:NF \l_tmpc_tl
+ \int_compare:nNnT \l_@@_local_start_int > 0
{
- \@@_hline_ii:nnnn
- { #1 }
- { #2 }
- \l_tmpc_tl
- { \tl_if_blank:nTF { #4 } { \int_use:N \c at jCol } { #4 } }
- \tl_clear:N \l_tmpc_tl
+ \int_set_eq:NN \l_@@_local_end_int \l_@@_end_int
+ \@@_hline_ii:
}
}
% \end{macrocode}
@@ -14753,32 +15012,37 @@
%
% \bigskip
% \begin{macrocode}
-\cs_new_protected:Npn \@@_hline_ii:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \@@_hline_ii:
{
+ \bool_set_false:N \l_@@_dotted_bool
+ \keys_set:nV { NiceMatrix / RulesBis } \l_@@_other_keys_tl
\bool_if:NTF \l_@@_dotted_bool
- { \@@_hline_iv:nnn { #1 } { #3 } { #4 } }
- { \@@_hline_iii:nnnn { #1 } { #2 } { #3 } { #4 } }
+ \@@_hline_iv:
+ {
+ \tl_if_empty:NTF \l_@@_tikz_rule_tl
+ \@@_hline_iii:
+ \@@_hline_v:
+ }
}
% \end{macrocode}
%
% \bigskip
-% |#1| is the number of the row; |#2| is the number of horizontal rules to
-% draw (with potentially a color between); |#3| and |#4| are the number of the
-% columns between which the rule has to be drawn.
+% First the case of a standard rule, that is to say a rule which is not dotted.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_hline_iii:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \@@_hline_iii:
{
+ \pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgf at relevantforpicturesizefalse
- \@@_qpoint:n { col - #3 }
+ \@@_qpoint:n { col - \int_use:N \l_@@_local_start_int }
\dim_set_eq:NN \l_tmpa_dim \pgf at x
- \@@_qpoint:n { row - #1 }
+ \@@_qpoint:n { row - \int_use:N \l_@@_position_int }
\dim_set_eq:NN \l_tmpb_dim \pgf at y
- \@@_qpoint:n { col - \@@_succ:n { #4 } }
+ \@@_qpoint:n { col - \int_eval:n { \l_@@_local_end_int + 1 } }
\dim_set_eq:NN \l_tmpc_dim \pgf at x
\bool_lazy_all:nT
{
- { \int_compare_p:nNn { #2 } > 1 }
+ { \int_compare_p:nNn \l_@@_multiplicity_int > 1 }
{ \cs_if_exist_p:N \CT at drsc@ }
{ ! \tl_if_blank_p:V \CT at drsc@ }
}
@@ -14786,7 +15050,10 @@
\group_begin:
\CT at drsc@
\dim_set:Nn \l_tmpd_dim
- { \l_tmpb_dim - ( \doublerulesep + \arrayrulewidth ) * ( #2 - 1 ) }
+ {
+ \l_tmpb_dim - ( \doublerulesep + \arrayrulewidth )
+ * ( \l_@@_multiplicity_int - 1 )
+ }
\pgfpathrectanglecorners
{ \pgfpoint \l_tmpa_dim \l_tmpb_dim }
{ \pgfpoint \l_tmpc_dim \l_tmpd_dim }
@@ -14795,7 +15062,7 @@
}
\pgfpathmoveto { \pgfpoint \l_tmpa_dim \l_tmpb_dim }
\pgfpathlineto { \pgfpoint \l_tmpc_dim \l_tmpb_dim }
- \prg_replicate:nn { #2 - 1 }
+ \prg_replicate:nn { \l_@@_multiplicity_int - 1 }
{
\dim_sub:Nn \l_tmpb_dim \arrayrulewidth
\dim_sub:Nn \l_tmpb_dim \doublerulesep
@@ -14806,6 +15073,7 @@
\pgfsetlinewidth { 1.1 \arrayrulewidth }
\pgfsetrectcap
\pgfusepathqstroke
+ \endpgfpicture
}
% \end{macrocode}
%
@@ -14856,16 +15124,17 @@
% \end{bNiceMatrix}$
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_hline_iv:nnn #1 #2 #3
+\cs_new_protected:Npn \@@_hline_iv:
{
+ \pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgf at relevantforpicturesizefalse
- \@@_qpoint:n { row - #1 }
+ \@@_qpoint:n { row - \int_use:N \l_@@_position_int }
\dim_set_eq:NN \l_@@_y_initial_dim \pgf at y
\dim_set_eq:NN \l_@@_y_final_dim \pgf at y
- \@@_qpoint:n { col - #2 }
+ \@@_qpoint:n { col - \int_use:N \l_@@_local_start_int }
\dim_set_eq:NN \l_@@_x_initial_dim \pgf at x
- \int_compare:nNnT { #2 } = 1
+ \int_compare:nNnT \l_@@_local_start_int = 1
{
\dim_sub:Nn \l_@@_x_initial_dim \l_@@_left_margin_dim
\bool_if:NT \l_@@_NiceArray_bool
@@ -14878,9 +15147,9 @@
\tl_if_eq:NnF \g_@@_left_delim_tl (
{ \dim_add:Nn \l_@@_x_initial_dim { 0.5 \l_@@_inter_dots_dim } }
}
- \@@_qpoint:n { col - \@@_succ:n { #3 } }
+ \@@_qpoint:n { col - \int_eval:n { \l_@@_local_end_int + 1 } }
\dim_set_eq:NN \l_@@_x_final_dim \pgf at x
- \int_compare:nNnT { #3 } = \c at jCol
+ \int_compare:nNnT \l_@@_local_end_int = \c at jCol
{
\dim_add:Nn \l_@@_x_final_dim \l_@@_right_margin_dim
\bool_if:NT \l_@@_NiceArray_bool
@@ -14888,15 +15157,40 @@
\tl_if_eq:NnF \g_@@_right_delim_tl )
{ \dim_gsub:Nn \l_@@_x_final_dim { 0.5 \l_@@_inter_dots_dim } }
}
+ \CT at arc@
\@@_draw_line:
+ \endpgfpicture
}
% \end{macrocode}
%
+% \bigskip
+% The following code is for the case when the user uses the key |tikz| (in the
+% definition of a customized rule by using the key |custom-line|).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_hline_v:
+ {
+ \begin { tikzpicture }
+ \pgfrememberpicturepositiononpagetrue
+ \pgf at relevantforpicturesizefalse
+ \@@_qpoint:n { col - \int_use:N \l_@@_local_start_int }
+ \dim_set_eq:NN \l_tmpa_dim \pgf at x
+ \@@_qpoint:n { row - \int_use:N \l_@@_position_int }
+ \dim_set_eq:NN \l_tmpb_dim \pgf at y
+ \@@_qpoint:n { col - \int_eval:n { \l_@@_local_end_int + 1 } }
+ \dim_set_eq:NN \l_tmpc_dim \pgf at x
+ \exp_args:NV \tikzset \l_@@_tikz_rule_tl
+ \use:x { \exp_not:N \draw [ \l_@@_tikz_rule_tl ] }
+ ( \l_tmpa_dim , \l_tmpb_dim ) --
+ ( \l_tmpc_dim , \l_tmpb_dim ) ;
+ \end { tikzpicture }
+ }
+% \end{macrocode}
%
+%
% \bigskip
% The command |\@@_draw_hlines:| draws all the horizontal rules excepted in the
% blocks (even the virtual blocks determined by commands such as |\Cdots| and in
-% the corners (if the key |corners| is used).
+% the corners (if the key |corners| is used)).
% \begin{macrocode}
\cs_new_protected:Npn \@@_draw_hlines:
{
@@ -14913,7 +15207,7 @@
{
\tl_if_eq:NnF \l_@@_hlines_clist { all }
{ \clist_if_in:NnT \l_@@_hlines_clist { ##1 } }
- { \@@_hline:nnnn { ##1 } 1 1 { } }
+ { \@@_hline:n { position = ##1 } }
}
}
% \end{macrocode}
@@ -14950,13 +15244,164 @@
+ \doublerulesep * ( \int_max:nn 0 { #1 - 1 } )
}
\tl_gput_right:Nx \g_@@_internal_code_after_tl
- { \@@_hline:nnnn { \@@_succ:n { \c at iRow } } { #1 } 1 { } }
+ {
+ \@@_hline:n
+ {
+ position = \int_eval:n { \c at iRow + 1 } ,
+ multiplicity = #1
+ }
+ }
\ifnum 0 = `{ \fi }
}
% \end{macrocode}
%
-% \subsection*{The key hvlines}
+% \subsubsection*{Customized rules defined by the final user}
%
+% The final user can define a customized rule by using the key |custom-line| in
+% |\NiceMatrixOptions|. That key takes in as value a list of \textsl{key=value}
+% pairs.
+%
+%
+%
+% \medskip
+% Among the keys avalaible in that list, there is the key |letter| to specify a
+% letter that the final user will use in the preamble of the array. All the
+% letters defined by this way by the final user for such customized rules are
+% added in the set of keys |{NiceMatrix / ColumnTypes}|. That set of keys is
+% used to store the characteristics of those types of rules for convenience: the
+% keys of that set of keys won't never be used as keys by the final user (he
+% will use, instead, letters in the preamble of its array).
+%
+% \begin{macrocode}
+\keys_define:nn { NiceMatrix / ColumnTypes } { }
+% \end{macrocode}
+%
+%
+% \medskip
+% The following command will create the customized rule (it is executed when the
+% final user uses the key |custom-line| in |\NiceMatrixOption|).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_custom_line:n #1
+ {
+ \keys_set_known:nn { NiceMatrix / Custom-Line } { #1 }
+% \end{macrocode}
+% If the final user only wants to draw horizontal rules, he does not need to
+% specify a letter (for the vertical rules in the preamble of the array). On the
+% other hand, if he only wants to draw vertical rules, the does not need to
+% define a command (which is the tool to draw horizontal rules in the array). Of
+% course, a definition of custom lines with no letter and no command would be point-less.
+%
+% \begin{macrocode}
+ \bool_lazy_and:nnTF
+ { \str_if_empty_p:N \l_@@_letter_str }
+ { \str_if_empty_p:N \l_@@_command_str }
+ { \@@_error:n { No~letter~and~no~command } }
+ {
+ \str_if_empty:NF \l_@@_letter_str
+ {
+ \int_compare:nNnTF { \str_count:N \l_@@_letter_str } = 1
+ {
+ \exp_args:NnV \tl_if_in:NnTF
+ \c_@@_forbidden_letters_str \l_@@_letter_str
+ { \@@_error:n { Forbidden~letter } }
+ {
+ \exp_args:Nnx \keys_define:nn { NiceMatrix / ColumnTypes }
+ {
+ \l_@@_letter_str .code:n =
+ { \@@_custom_line_i:n { \exp_not:n { #1 } } }
+ }
+ }
+ }
+ { \@@_error:n { Several~letters } }
+ }
+ \str_if_empty:NF \l_@@_command_str
+ { \exp_args:NnV \@@_define_h_custom_line:nn { #1 } \l_tmpc_int }
+ }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\str_const:Nn \c_@@_forbidden_letters_str { lcrpmbVX:|()[]!@<> }
+% \end{macrocode}
+%
+% \medskip
+% The previous command |\@@_custom_line:n| uses the following set of keys.
+% However, the whole definition of the customized lines (as provided by the
+% final user as argument of |custom-line|) will also be used further with
+% other sets of keys (for instance |{NiceMatrix/Rules}|). That's why the
+% following set of keys has only entries for three keys.
+% \begin{macrocode}
+\keys_define:nn { NiceMatrix / Custom-Line }
+ {
+ letter .str_set:N = \l_@@_letter_str ,
+ letter .value_required:n = true ,
+ letter .initial:n = ,
+ command .str_set:N = \l_@@_command_str ,
+ command .value_required:n = true ,
+ command .initial:n = ,
+% \end{macrocode}
+% We need to know the multiplicity of the rule right now in order to compute the
+% total width of the rule (and reserve space both in vertical and horizontal rules).
+% \begin{macrocode}
+ multiplicity .int_set:N = \l_tmpc_int ,
+ multiplicity .initial:n = 1 ,
+ multiplicity .value_required:n = true ,
+ }
+% \end{macrocode}
+%
+% \bigskip
+% The following command will create the command that the final user will use in
+% its array to draw a horizontal rule (hence the `|h|` in the name). |#1| is the
+% whole set of keys to pass to |\@@_line:n| and |#2| is the multiplicity of
+% the line (number of consecutive rules).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_define_h_custom_line:nn #1 #2
+ {
+% \end{macrocode}
+% We use |\cs_set:cpn| and not |\cs_new:cpn| because we want a local définition.
+% Moreover, the command must \emph{not} be protected since it begins with |\noalign|.
+% \begin{macrocode}
+ \cs_set:cpn \l_@@_command_str
+ {
+ \noalign
+ {
+ \skip_vertical:n
+ {
+ \dim_eval:n
+ { \arrayrulewidth * #2 + \doublerulesep * ( #2 - 1) }
+ }
+ \tl_gput_right:Nx \g_@@_internal_code_after_tl
+ { \@@_hline:n { #1 , position = \int_eval:n { \c at iRow + 1 } } }
+ }
+ }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_custom_line_i:n #1
+ {
+ \tl_gput_right:Nx \g_@@_preamble_tl
+ {
+ \exp_not:N !
+ {
+ \skip_horizontal:n
+ {
+ \dim_eval:n
+ {
+ \arrayrulewidth * \l_tmpc_int
+ + \doublerulesep * ( \l_tmpc_int - 1)
+ }
+ }
+ }
+ }
+ \tl_gput_right:Nx \g_@@_internal_code_after_tl
+ { \@@_vline:n { #1 , position = \@@_succ:n \c at jCol } }
+ }
+% \end{macrocode}
+%
+%
+% \subsubsection*{The key hvlines}
+%
% The following command tests whether the current position in the array (given by
% |\l_tmpa_tl| for the row and |\l_tmpb_tl| for the column) would provide an
% horizontal rule towards the right in the block delimited by the four arguments
@@ -15248,12 +15693,7 @@
% number of the row \emph{before} which we will draw the row.
% \begin{macrocode}
\cs_new_protected:Npn \@@_hdottedline:n #1
- {
- \group_begin:
- \bool_set_true:N \l_@@_dotted_bool
- \@@_hline:nnnn { #1 } { 1 } { 1 } { \int_use:N \c at jCol }
- \group_end:
- }
+ { \@@_hline:n { position = #1 , end = \int_use:N \c at jCol , dotted } }
% \end{macrocode}
%
%
@@ -15264,12 +15704,7 @@
% \medskip
% \begin{macrocode}
\cs_new_protected:Npn \@@_vdottedline:n #1
- {
- \group_begin:
- \bool_set_true:N \l_@@_dotted_bool
- \@@_vline:nnnn { \int_eval:n { #1 + 1 } } { 1 } { 1 } { \int_use:N \c at iRow }
- \group_end:
- }
+ { \@@_vline:n { position = \int_eval:n { #1 + 1 } , dotted } }
% \end{macrocode}
%
% \bigskip
@@ -15721,7 +16156,9 @@
b .code:n = \str_set:Nn \l_@@_vpos_of_block_tl b ,
b .value_forbidden:n = true ,
color .tl_set:N = \l_@@_color_tl ,
- color .value_required:n = true
+ color .value_required:n = true ,
+ respect-arraystretch .bool_set:N = \l_@@_respect_arraystretch_bool ,
+ respect-arraystretch .default:n = true ,
}
% \end{macrocode}
%
@@ -15759,8 +16196,9 @@
% \medskip
% Now, the arguments have been extracted: |#1| is $i$ (the number of rows of the
% block), |#2| is $j$ (the number of columns of the block), |#3| is the list of
-% key-values, |#4| are the tokens to put before the math mode and the beginning
-% of the small array of the block and |#5| is the label of the block.
+% \textsl{key=values} pairs, |#4| are the tokens to put before the math mode and
+% the beginning of the small array of the block and |#5| is the label of the
+% block.
% \begin{macrocode}
\cs_new_protected:Npn \@@_Block_ii:nnnnn #1 #2 #3 #4 #5
{
@@ -15897,7 +16335,8 @@
% \begin{macrocode}
\int_compare:nNnT { #1 } = 1 \g_@@_row_style_tl
\group_begin:
- \cs_set:Npn \arraystretch { 1 }
+ \bool_if:NF \l_@@_respect_arraystretch_bool
+ { \cs_set:Npn \arraystretch { 1 } }
\dim_zero:N \extrarowheight
#4
% \end{macrocode}
@@ -15911,9 +16350,12 @@
\bool_if:NT \g_@@_rotate_bool { \str_set:Nn \l_@@_hpos_block_str c }
\bool_if:NTF \l_@@_NiceTabular_bool
{
- \bool_lazy_and:nnTF
- { \int_compare_p:nNn { #2 } = 1 }
- { \dim_compare_p:n { \l_@@_col_width_dim >= \c_zero_dim } }
+ \bool_lazy_all:nTF
+ {
+ { \int_compare_p:nNn { #2 } = 1 }
+ { \dim_compare_p:n { \l_@@_col_width_dim >= \c_zero_dim } }
+ { ! \l_@@_respect_arraystretch_bool }
+ }
% \end{macrocode}
% When the block is mono-column in a column with a fixed width (eg |p{3cm}|).
% \begin{macrocode}
@@ -15926,7 +16368,7 @@
r \raggedleft
l \raggedright
}
- #5
+ #5
\end { minipage }
}
{
@@ -16037,7 +16479,8 @@
\bool_if:NTF \l_@@_NiceTabular_bool
{
\group_begin:
- \cs_set:Npn \arraystretch { 1 }
+ \bool_if:NF \l_@@_respect_arraystretch_bool
+ { \cs_set:Npn \arraystretch { 1 } }
\dim_zero:N \extrarowheight
#4
% \end{macrocode}
@@ -16061,7 +16504,8 @@
}
{
\group_begin:
- \cs_set:Npn \arraystretch { 1 }
+ \bool_if:NF \l_@@_respect_arraystretch_bool
+ { \cs_set:Npn \arraystretch { 1 } }
\dim_zero:N \extrarowheight
#4
\bool_if:NT \g_@@_rotate_bool
@@ -16107,8 +16551,11 @@
color .value_required:n = true ,
borders .clist_set:N = \l_@@_borders_clist ,
borders .value_required:n = true ,
- hvlines .bool_set:N = \l_@@_hvlines_block_bool ,
- hvlines .default:n = true ,
+ hvlines .meta:n = { vlines = #1 , hlines = #1 } ,
+ vlines .bool_set:N = \l_@@_vlines_block_bool,
+ vlines .default:n = true ,
+ hlines .bool_set:N = \l_@@_hlines_block_bool,
+ hlines .default:n = true ,
line-width .dim_set:N = \l_@@_line_width_dim ,
line-width .value_required:n = true ,
l .code:n = \str_set:Nn \l_@@_hpos_block_str l ,
@@ -16132,7 +16579,9 @@
b .value_forbidden:n = true ,
name .tl_set:N = \l_@@_block_name_str ,
name .value_required:n = true ,
- name .initial:n = \c_empty_tl ,
+ name .initial:n = ,
+ respect-arraystretch .bool_set:N = \l_@@_respect_arraystretch_bool ,
+ respect-arraystretch .default:n = true ,
unknown .code:n = \@@_error:n { Unknown~key~for~Block }
}
% \end{macrocode}
@@ -16208,17 +16657,29 @@
% \end{macrocode}
%
% \begin{macrocode}
- \bool_if:NTF \l_@@_hvlines_block_bool
+ \bool_if:NT \l_@@_vlines_block_bool
{
\tl_gput_right:Nx \g_nicematrix_code_after_tl
{
- \@@_hvlines_block:nnn
+ \@@_vlines_block:nnn
{ \exp_not:n { #5 } }
{ #1 - #2 }
{ \int_use:N \l_@@_last_row_int - \int_use:N \l_@@_last_col_int }
}
}
+ \bool_if:NT \l_@@_hlines_block_bool
{
+ \tl_gput_right:Nx \g_nicematrix_code_after_tl
+ {
+ \@@_hlines_block:nnn
+ { \exp_not:n { #5 } }
+ { #1 - #2 }
+ { \int_use:N \l_@@_last_row_int - \int_use:N \l_@@_last_col_int }
+ }
+ }
+ \bool_if:nT
+ { ! \l_@@_vlines_block_bool && ! \l_@@_hlines_block_bool }
+ {
% \end{macrocode}
% The sequence of the positions of the blocks (excepted the blocks with the key
% |hvlines|) will be used when drawing the rules (in fact, there is also the
@@ -16689,7 +17150,7 @@
% 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 \@@_hvlines_block:nnn #1 #2 #3
+\cs_new_protected:Npn \@@_vlines_block:nnn #1 #2 #3
{
\dim_set_eq:NN \l_@@_line_width_dim \arrayrulewidth
\keys_set_known:nn { NiceMatrix / BlockBorders } { #1 }
@@ -16702,12 +17163,37 @@
\int_step_inline:nnn \l_tmpd_tl \l_tmpb_tl
{
\use:x
- { \@@_vline:nnnn { ##1 } 1 { \l_tmpc_tl } { \@@_pred:n \l_tmpa_tl } }
+ {
+ \@@_vline:n
+ {
+ position = ##1 ,
+ start = \l_tmpc_tl ,
+ end = \@@_pred:n \l_tmpa_tl
+ }
+ }
}
+ }
+\cs_new_protected:Npn \@@_hlines_block:nnn #1 #2 #3
+ {
+ \dim_set_eq:NN \l_@@_line_width_dim \arrayrulewidth
+ \keys_set_known:nn { NiceMatrix / BlockBorders } { #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 } }
\int_step_inline:nnn \l_tmpc_tl \l_tmpa_tl
{
\use:x
- { \@@_hline:nnnn { ##1 } 1 { \l_tmpd_tl } { \@@_pred:n \l_tmpb_tl } }
+ {
+ \@@_hline:n
+ {
+ position = ##1 ,
+ start = \l_tmpd_tl ,
+ end = \int_eval:n { \l_tmpb_tl - 1 }
+ }
+ }
}
}
% \end{macrocode}
@@ -17083,7 +17569,7 @@
%
%
% The |\CodeAfter| (inserted with the key |code-after| or after the keyword
-% |\CodeAfter|) may always begin with a list of pairs \emph{key-value} between
+% |\CodeAfter|) may always begin with a list of pairs \textsl{key=value} between
% square brackets. Here is the corresponding set of keys.
% \begin{macrocode}
\keys_define:nn { NiceMatrix }
@@ -17301,6 +17787,8 @@
% \begin{macrocode}
\keys_define:nn { NiceMatrix / SubMatrix }
{
+ delimiters / color .tl_set:N = \l_@@_delimiters_color_tl ,
+ delimiters / color .value_required:n = true ,
hlines .clist_set:N = \l_@@_submatrix_hlines_clist ,
hlines .default:n = all ,
vlines .clist_set:N = \l_@@_submatrix_vlines_clist ,
@@ -17886,7 +18374,7 @@
\group_begin:
% \end{macrocode}
% The four following token lists correspond to the position of the sub-matrix to
-% which an brace will be attached.
+% which a brace will be attached.
% \begin{macrocode}
\@@_compute_i_j:nn { #1 } { #2 }
\bool_lazy_or:nnTF
@@ -18082,8 +18570,8 @@
\@@_msg_new:nn { Key~transparent }
{
The~key~'transparent'~is~now~obsolete~(because~it's~name~
- is~not~clear).~You~should~use~the~conjonction~of~'renew-dots'~
- and~'renew-matrix'.~However,~you~can~go~on.
+ is~not~clear).~You~must~use~the~conjonction~of~'renew-dots'~
+ and~'renew-matrix'.~This~error~is~fatal.
}
% \end{macrocode}
%
@@ -18094,12 +18582,7 @@
renew-dots .value_forbidden:n = true ,
renew-matrix .code:n = \@@_renew_matrix: ,
renew-matrix .value_forbidden:n = true ,
- transparent .code:n =
- {
- \@@_renew_matrix:
- \bool_set_true:N \l_@@_renew_dots_bool
- \@@_error:n { Key~transparent }
- } ,
+ transparent .code:n = \@@_fatal:n { Key~transparent } ,
transparent .value_forbidden:n = true,
footnote .bool_set:N = \c_@@_footnote_bool ,
footnotehyper .bool_set:N = \c_@@_footnotehyper_bool ,
@@ -18176,18 +18659,6 @@
% \bigskip
% \subsection*{Error messages of the package}
%
-%
-% The following message will be deleted when we will delete the key
-% |except-corners| for the command |\arraycolor|.
-% \begin{macrocode}
-\@@_msg_new:nn { key~except-corners }
- {
- The~key~'except-corners'~has~been~deleted~for~the~command~\token_to_str:N
- \arraycolor\ in~the~\token_to_str:N \CodeBefore.~You~should~instead~use~
- the~key~'corners'~in~your~\@@_full_name_env:.\\
- If~you~go~on,~this~key~will~be~ignored.
- }
-% \end{macrocode}
%
%
% \begin{macrocode}
@@ -18462,6 +18933,33 @@
% \end{macrocode}
%
% \begin{macrocode}
+\@@_msg_new:nn { No~letter~and~no~command }
+ {
+ Your~use~of~'custom-line'~is~no-op~since~you~don't~have~used~the~
+ key~'letter'~(for~a~letter~for~vertical~rules)~nor~the~key~'command'~
+ (to~draw~horizontal~rules).\\
+ However,~you~can~go~on.
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@@_msg_new:nn { Forbidden~letter }
+ {
+ You~can't~use~the~letter~'\l_@@_letter_str'~for~a~customized~line.\\
+ If~you~go~on,~it~will~be~ignored.
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\@@_msg_new:nn { Several~letters }
+ {
+ You~must~use~only~one~letter~as~value~for~the~key~'letter'~(and~
+ have~used~'\l_@@_letter_str').\\
+ If~you~go~on,~it~will~be~ignored.
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
\@@_msg_new:nn { Delimiter~with~small }
{
You~can't~put~a~delimiter~in~the~preamble~of~your~\@@_full_name_env:\
@@ -18593,6 +19091,17 @@
This~error~is~fatal.
}
% \end{macrocode}
+%
+% \begin{macrocode}
+\@@_msg_new:nn { colon~without~arydshln }
+ {
+ The~column~type~':'~in~your~\@@_full_name_env:\
+ is~unknown.~If~you~want~to~use~':'~of~'arydshln',~you~should~
+ load~that~package.~If~you~want~a~dotted~line~of~'nicematrix',~you~
+ should~use~'\l_@@_letter_for_dotted_lines_str'.\\
+ This~error~is~fatal.
+ }
+% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { tabularnote~forbidden }
@@ -18684,7 +19193,8 @@
}
{
The~available~keys~are~(in~alphabetic~order):~b,~borders,~c,~draw,~fill,~
- hvlines,~l,~line-width,~name,~rounded-corners,~r,~t~and~tikz.
+ hlines,~hvlines,~l,~line-width,~name,~rounded-corners,~r,~respect-arraystretch,
+ ~t,~tikz~and~vlines.
}
% \end{macrocode}
%
@@ -18815,6 +19325,7 @@
code-for-last-col,~
code-for-last-row,~
corners,~
+ custom-key,~
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
@@ -18833,6 +19344,7 @@
nullify-dots,~
renew-dots,~
renew-matrix,~
+ respect-arraystretch,~
right-margin,~
rules~(with~the~subkeys~'color'~and~'width'),~
small,~
@@ -18885,6 +19397,7 @@
notes/para,~
nullify-dots,~
renew-dots,~
+ respect-arraystretch,~
right-margin,~
rules~(with~the~subkeys~'color'~and~'width'),~
small,~
@@ -18944,6 +19457,7 @@
nullify-dots,~
r,~
renew-dots,~
+ respect-arraystretch,~
right-margin,~
rules~(with~the~subkeys~'color'~and~'width'),~
small,~
@@ -18979,6 +19493,7 @@
colortbl-like,~
columns-width,~
corners,~
+ custom-line,~
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
@@ -18997,6 +19512,7 @@
notes/para,~
nullify-dots,~
renew-dots,~
+ respect-arraystretch,~
right-margin,~
rules~(with~the~subkeys~'color'~and~'width'),~
t,~
@@ -19584,6 +20100,12 @@
% Correction of a bug: the use of |\hdottedline| and |:| in the preamble of the
% array (of another letter specified by |letter-for-dotted-lines|) was
% incompatible with the key |xdots/line-style|.
+%
+% \subsection*{Changes between versions 6.4 and 6.5}
+%
+% Key |custom-line| in |\NiceMatrixOptions|.
+%
+% Key |respect-arraystretch|.
%
% \PrintIndex
%
Modified: trunk/Master/texmf-dist/source/latex/nicematrix/nicematrix.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/nicematrix/nicematrix.ins 2022-01-23 21:11:30 UTC (rev 61714)
+++ trunk/Master/texmf-dist/source/latex/nicematrix/nicematrix.ins 2022-01-23 21:12:06 UTC (rev 61715)
@@ -1,5 +1,5 @@
%%
-%% Copyright (C) 2018-2021 by F. Pantigny
+%% Copyright (C) 2018-2022 by F. Pantigny
%%
%%
%% This file may be distributed and/or modified under the
@@ -17,7 +17,7 @@
\usedir{tex/latex/nicematrix}
\preamble
-Copyright (C) 2018-2021 by F. Pantigny
+Copyright (C) 2018-2022 by F. Pantigny
This file may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either
Modified: trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty 2022-01-23 21:11:30 UTC (rev 61714)
+++ trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty 2022-01-23 21:12:06 UTC (rev 61715)
@@ -6,7 +6,7 @@
%%
%% nicematrix.dtx (with options: `package')
%%
-%% Copyright (C) 2018-2021 by F. Pantigny
+%% Copyright (C) 2018-2022 by F. Pantigny
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
@@ -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{6.4}
-\def\myfiledate{2021/11/23}
+\def\myfileversion{6.5}
+\def\myfiledate{2022/01/23}
\RequirePackage{pgfcore}
\usepgfmodule{shapes}
\RequirePackage{l3keys2e}
@@ -138,13 +138,13 @@
\cs_set:Npn \CT at arc #1 #2
{
\dim_compare:nNnT \baselineskip = \c_zero_dim \noalign
- { \cs_gset:Npn \CT at arc@ { \color #1 { #2 } } }
+ { \cs_gset:Npn \CT at arc@ { \color #1 { #2 } } }
}
\cs_set:Npn \doublerulesepcolor #1 # { \CT at drs { #1 } }
\cs_set:Npn\CT at drs #1 #2
{
\dim_compare:nNnT \baselineskip = \c_zero_dim \noalign
- { \cs_gset:Npn \CT at drsc@ { \color #1 { #2 } } }
+ { \cs_gset:Npn \CT at drsc@ { \color #1 { #2 } } }
}
\cs_set:Npn \hline
{
@@ -209,6 +209,12 @@
{ \cs_set:Npn \CT at arc@ { \color [ #1 ] { #2 } } }
\cs_new_protected:Npn \__nicematrix_set_CT at arc@_ii: #1 \q_stop
{ \cs_set:Npn \CT at arc@ { \color { #1 } } }
+\cs_new_protected:Npn \__nicematrix_set_CT at drsc@:
+ { \peek_meaning:NTF [ \__nicematrix_set_CT at drsc@_i: \__nicematrix_set_CT at drsc@_ii: }
+\cs_new_protected:Npn \__nicematrix_set_CT at drsc@_i: [ #1 ] #2 \q_stop
+ { \cs_set:Npn \CT at drsc@ { \color [ #1 ] { #2 } } }
+\cs_new_protected:Npn \__nicematrix_set_CT at drsc@_ii: #1 \q_stop
+ { \cs_set:Npn \CT at drsc@ { \color { #1 } } }
\cs_set_eq:NN \__nicematrix_old_pgfpointanchor \pgfpointanchor
\bool_new:N \c__nicematrix_siunitx_loaded_bool
\AtBeginDocument
@@ -331,7 +337,8 @@
\tl_new:N \l__nicematrix_vpos_of_block_tl
\tl_set:Nn \l__nicematrix_vpos_of_block_tl { c }
\bool_new:N \l__nicematrix_draw_first_bool
-\bool_new:N \l__nicematrix_hvlines_block_bool
+\bool_new:N \l__nicematrix_vlines_block_bool
+\bool_new:N \l__nicematrix_hlines_block_bool
\int_new:N \g__nicematrix_block_box_int
\dim_new:N \l__nicematrix_submatrix_extra_height_dim
\dim_new:N \l__nicematrix_submatrix_left_xshift_dim
@@ -516,6 +523,7 @@
\dim_new:N \l__nicematrix_notes_above_space_dim
\AtBeginDocument { \dim_set:Nn \l__nicematrix_notes_above_space_dim { 1 mm } }
\bool_new:N \l__nicematrix_nullify_dots_bool
+\bool_new:N \l__nicematrix_respect_arraystretch_bool
\bool_new:N \l__nicematrix_auto_columns_width_bool
\bool_new:N \g__nicematrix_recreate_cell_nodes_bool
\str_new:N \l__nicematrix_name_str
@@ -560,8 +568,8 @@
}
\keys_define:nn { NiceMatrix / Global }
{
- delimiters .code:n =
- \keys_set:nn { NiceMatrix / delimiters } { #1 } ,
+ custom-line .code:n = \__nicematrix_custom_line:n { #1 } ,
+ delimiters .code:n = \keys_set:nn { NiceMatrix / delimiters } { #1 } ,
delimiters .value_required:n = true ,
rules .code:n = \keys_set:nn { NiceMatrix / rules } { #1 } ,
rules .value_required:n = true ,
@@ -635,6 +643,8 @@
extra-margin .meta:n =
{ extra-left-margin = #1 , extra-right-margin = #1 } ,
extra-margin .value_required:n = true ,
+ respect-arraystretch .bool_set:N = \l__nicematrix_respect_arraystretch_bool ,
+ respect-arraystretch .default:n = true
}
\keys_define:nn { NiceMatrix / Env }
{
@@ -1803,10 +1813,10 @@
\q_stop { }
}
{
- \str_if_eq:VnTF \l__nicematrix_letter_for_dotted_lines_str { #1 }
- { \__nicematrix_patch_preamble_xii:n #1 }
+ \str_case_e:nnF { #1 }
{
- \str_if_eq:VnTF \l__nicematrix_letter_vlism_tl { #1 }
+ \l__nicematrix_letter_for_dotted_lines_str { \__nicematrix_patch_preamble_xii:n #1 }
+ \l__nicematrix_letter_vlism_tl
{
\seq_gput_right:Nx \g__nicematrix_cols_vlism_seq
{ \int_eval:n { \c at jCol + 1 } }
@@ -1814,17 +1824,22 @@
{ \exp_not:N ! { \skip_horizontal:N \arrayrulewidth } }
\__nicematrix_patch_preamble:n
}
+ { : }
{
- \bool_lazy_and:nnTF
- { \str_if_eq_p:nn { : } { #1 } }
- \c__nicematrix_arydshln_loaded_bool
+ \bool_if:NTF \c__nicematrix_arydshln_loaded_bool
{
\tl_gput_right:Nn \g__nicematrix_preamble_tl { : }
\__nicematrix_patch_preamble:n
}
- { \__nicematrix_fatal:nn { unknown~column~type } { #1 } }
+ { \__nicematrix_fatal:n { colon~without~arydshln } }
}
}
+ {
+ \keys_set_known:nnN { NiceMatrix / ColumnTypes } { #1 } \l_tmpa_tl
+ \tl_if_empty:NTF \l_tmpa_tl
+ \__nicematrix_patch_preamble:n
+ { \__nicematrix_fatal:nn { unknown~column~type } { #1 } }
+ }
}
}
\cs_new_protected:Npn \__nicematrix_patch_preamble_i:n #1
@@ -1869,8 +1884,11 @@
}
\tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
{
- \__nicematrix_vline:nnnn
- { \__nicematrix_succ:n \c at jCol } { \int_use:N \l_tmpa_int } { 1 } { }
+ \__nicematrix_vline:n
+ {
+ position = \__nicematrix_succ:n \c at jCol ,
+ multiplicity = \int_use:N \l_tmpa_int ,
+ }
}
\int_zero:N \l_tmpa_int
\str_if_eq:nnT { #1 } { \q_stop } { \bool_gset_true:N \g_tmpb_bool }
@@ -2257,9 +2275,17 @@
\seq_gput_left:Nn \g__nicematrix_multicolumn_sizes_seq { #1 }
\seq_gput_right:Nx \g__nicematrix_pos_of_blocks_seq
{
- { \int_use:N \c at iRow }
+ {
+ \int_compare:nNnTF \c at jCol = 0
+ { \int_eval:n { \c at iRow + 1 } }
+ { \int_use:N \c at iRow }
+ } % modified 2022/01/10
{ \int_eval:n { \c at jCol + 1 } }
- { \int_use:N \c at iRow }
+ {
+ \int_compare:nNnTF \c at jCol = 0
+ { \int_eval:n { \c at iRow + 1 } }
+ { \int_use:N \c at iRow }
+ } % modified 2022/01/10
{ \int_eval:n { \c at jCol + #1 } }
{ } % for the name of the block
}
@@ -2753,8 +2779,10 @@
}
&
\omit
+ \int_compare:nNnT \g__nicematrix_col_total_int = 1
+ { \skip_gset:Nn \g_tmpa_skip { 0 pt~plus 1 fill } }
+ \skip_horizontal:N \g_tmpa_skip
\int_gincr:N \g_tmpa_int
- \skip_horizontal:N \g_tmpa_skip
\bool_lazy_all:nT
{
\l__nicematrix_NiceArray_bool
@@ -4327,7 +4355,7 @@
nb-rows .initial:n = 1 ,
rowcolor .tl_set:N = \l_tmpc_tl ,
rowcolor .value_required:n = true ,
- rowcolor .initial:n = \c_empty_tl ,
+ rowcolor .initial:n = ,
unknown .code:n = \__nicematrix_error:n { Unknown~key~for~RowStyle }
}
\NewDocumentCommand \__nicematrix_RowStyle:n { O { } m }
@@ -4502,11 +4530,8 @@
}
}
}
-\keys_define:nn { NiceMatrix / arraycolor }
- { except-corners .code:n = \__nicematrix_error:n { key~except-corners } }
-\NewDocumentCommand \__nicematrix_arraycolor { O { } m O { } }
+\NewDocumentCommand \__nicematrix_arraycolor { O { } m }
{
- \keys_set:nn { NiceMatrix / arraycolor } { #3 }
\__nicematrix_rectanglecolor [ #1 ] { #2 }
{ 1 - 1 }
{ \int_use:N \c at iRow - \int_use:N \c at jCol }
@@ -4753,22 +4778,47 @@
\int_compare:nNnF \c at iRow = 0
{ \int_compare:nNnF \c at iRow = \l__nicematrix_last_row_int { #1 } }
}
-\cs_new_protected:Npn \__nicematrix_vline:nnnn #1 #2 #3 #4
+\keys_define:nn { NiceMatrix / Rules }
{
- \int_compare:nNnT { #1 } < { \c at jCol + 2 }
- {
- \pgfpicture
- \__nicematrix_vline_i:nnnn { #1 } { #2 } { #3 } { #4 }
- \endpgfpicture
- }
+ position .int_set:N = \l__nicematrix_position_int ,
+ position .value_required:n = true ,
+ start .int_set:N = \l__nicematrix_start_int ,
+ start .initial:n = 1 ,
+ end .int_set:N = \l__nicematrix_end_int ,
+ letter .code:n = \prg_do_nothing: ,
+ command .code:n = \prg_do_nothing:
}
-\cs_new_protected:Npn \__nicematrix_vline_i:nnnn #1 #2 #3 #4
+\keys_define:nn { NiceMatrix / RulesBis }
{
- \tl_set:Nx \l_tmpb_tl { #1 }
- \tl_clear_new:N \l_tmpc_tl
- \int_step_variable:nnNn
- { #3 }
- { \tl_if_blank:nTF { #4 } { \int_use:N \c at iRow } { #4 } }
+ multiplicity .int_set:N = \l__nicematrix_multiplicity_int ,
+ multiplicity .initial:n = 1 ,
+ dotted .bool_set:N = \l__nicematrix_dotted_bool ,
+ dotted .initial:n = false ,
+ dotted .default:n = true ,
+ color .code:n = \__nicematrix_set_CT at arc@: #1 \q_stop ,
+ color .value_required:n = true ,
+ sep-color .code:n = \__nicematrix_set_CT at drsc@: #1 \q_stop ,
+ sep-color .value_required:n = true ,
+ tikz .tl_set:N = \l__nicematrix_tikz_rule_tl ,
+ tikz .value_required:n = true ,
+ tikz .initial:n =
+ }
+\cs_new_protected:Npn \__nicematrix_vline:n #1
+ {
+ \group_begin:
+ \int_zero_new:N \l__nicematrix_end_int
+ \int_set_eq:NN \l__nicematrix_end_int \c at iRow
+ \keys_set_known:nnN { NiceMatrix / Rules } { #1 } \l__nicematrix_other_keys_tl
+ \int_compare:nNnT \l__nicematrix_position_int < { \c at jCol + 2 }
+ \__nicematrix_vline_i:
+ \group_end:
+ }
+\cs_new_protected:Npn \__nicematrix_vline_i:
+ {
+ \int_zero_new:N \l__nicematrix_local_start_int
+ \int_zero_new:N \l__nicematrix_local_end_int
+ \tl_set:Nx \l_tmpb_tl { \int_eval:n \l__nicematrix_position_int }
+ \int_step_variable:nnNn \l__nicematrix_start_int \l__nicematrix_end_int
\l_tmpa_tl
{
\bool_gset_true:N \g_tmpa_bool
@@ -4781,29 +4831,22 @@
\clist_if_empty:NF \l__nicematrix_corners_clist \__nicematrix_test_in_corner_v:
\bool_if:NTF \g_tmpa_bool
{
- \tl_if_empty:NT \l_tmpc_tl
- { \tl_set_eq:NN \l_tmpc_tl \l_tmpa_tl }
+ \int_compare:nNnT \l__nicematrix_local_start_int = 0
+ { \int_set:Nn \l__nicematrix_local_start_int \l_tmpa_tl }
}
{
- \tl_if_empty:NF \l_tmpc_tl
+ \int_compare:nNnT \l__nicematrix_local_start_int > 0
{
- \__nicematrix_vline_ii:nnnn
- { #1 }
- { #2 }
- \l_tmpc_tl
- { \int_eval:n { \l_tmpa_tl - 1 } }
- \tl_clear:N \l_tmpc_tl
+ \int_set:Nn \l__nicematrix_local_end_int { \l_tmpa_tl - 1 }
+ \__nicematrix_vline_ii:
+ \int_zero:N \l__nicematrix_local_start_int
}
}
}
- \tl_if_empty:NF \l_tmpc_tl
+ \int_compare:nNnT \l__nicematrix_local_start_int > 0
{
- \__nicematrix_vline_ii:nnnn
- { #1 }
- { #2 }
- \l_tmpc_tl
- { \tl_if_blank:nTF { #4 } { \int_use:N \c at iRow } { #4 } }
- \tl_clear:N \l_tmpc_tl
+ \int_set_eq:NN \l__nicematrix_local_end_int \l__nicematrix_end_int
+ \__nicematrix_vline_ii:
}
}
\cs_new_protected:Npn \__nicematrix_test_in_corner_v:
@@ -4831,25 +4874,32 @@
}
}
}
-\cs_new_protected:Npn \__nicematrix_vline_ii:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \__nicematrix_vline_ii:
{
+ \bool_set_false:N \l__nicematrix_dotted_bool
+ \keys_set:nV { NiceMatrix / RulesBis } \l__nicematrix_other_keys_tl
\bool_if:NTF \l__nicematrix_dotted_bool
- { \__nicematrix_vline_iv:nnn { #1 } { #3 } { #4 } }
- { \__nicematrix_vline_iii:nnnn { #1 } { #2 } { #3 } { #4 } }
+ \__nicematrix_vline_iv:
+ {
+ \tl_if_empty:NTF \l__nicematrix_tikz_rule_tl
+ \__nicematrix_vline_iii:
+ \__nicematrix_vline_v:
+ }
}
-\cs_new_protected:Npn \__nicematrix_vline_iii:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \__nicematrix_vline_iii:
{
+ \pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgf at relevantforpicturesizefalse
- \__nicematrix_qpoint:n { row - #3 }
+ \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_local_start_int }
\dim_set_eq:NN \l_tmpa_dim \pgf at y
- \__nicematrix_qpoint:n { col - #1 }
+ \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_position_int }
\dim_set_eq:NN \l_tmpb_dim \pgf at x
- \__nicematrix_qpoint:n { row - \__nicematrix_succ:n { #4 } }
+ \__nicematrix_qpoint:n { row - \int_eval:n { \l__nicematrix_local_end_int + 1 } }
\dim_set_eq:NN \l_tmpc_dim \pgf at y
\bool_lazy_all:nT
{
- { \int_compare_p:nNn { #2 } > 1 }
+ { \int_compare_p:nNn \l__nicematrix_multiplicity_int > 1 }
{ \cs_if_exist_p:N \CT at drsc@ }
{ ! \tl_if_blank_p:V \CT at drsc@ }
}
@@ -4859,7 +4909,10 @@
\dim_add:Nn \l_tmpa_dim { 0.5 \arrayrulewidth }
\dim_sub:Nn \l_tmpc_dim { 0.5 \arrayrulewidth }
\dim_set:Nn \l_tmpd_dim
- { \l_tmpb_dim - ( \doublerulesep + \arrayrulewidth ) * ( #2 - 1 ) }
+ {
+ \l_tmpb_dim - ( \doublerulesep + \arrayrulewidth )
+ * ( \l__nicematrix_multiplicity_int - 1 )
+ }
\pgfpathrectanglecorners
{ \pgfpoint \l_tmpb_dim \l_tmpa_dim }
{ \pgfpoint \l_tmpd_dim \l_tmpc_dim }
@@ -4868,7 +4921,7 @@
}
\pgfpathmoveto { \pgfpoint \l_tmpb_dim \l_tmpa_dim }
\pgfpathlineto { \pgfpoint \l_tmpb_dim \l_tmpc_dim }
- \prg_replicate:nn { #2 - 1 }
+ \prg_replicate:nn { \l__nicematrix_multiplicity_int - 1 }
{
\dim_sub:Nn \l_tmpb_dim \arrayrulewidth
\dim_sub:Nn \l_tmpb_dim \doublerulesep
@@ -4879,20 +4932,41 @@
\pgfsetlinewidth { 1.1 \arrayrulewidth }
\pgfsetrectcap
\pgfusepathqstroke
+ \endpgfpicture
}
-\cs_new_protected:Npn \__nicematrix_vline_iv:nnn #1 #2 #3
+\cs_new_protected:Npn \__nicematrix_vline_iv:
{
+ \pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgf at relevantforpicturesizefalse
- \__nicematrix_qpoint:n { col - #1 }
+ \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_position_int }
\dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf at x
\dim_set_eq:NN \l__nicematrix_x_final_dim \pgf at x
- \__nicematrix_qpoint:n { row - #2 }
+ \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_local_start_int }
\dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf at y
- \__nicematrix_qpoint:n { row - \__nicematrix_succ:n { #3 } }
+ \__nicematrix_qpoint:n { row - \int_eval:n { \l__nicematrix_local_end_int + 1 } }
\dim_set_eq:NN \l__nicematrix_y_final_dim \pgf at y
+ \CT at arc@
\__nicematrix_draw_line:
+ \endpgfpicture
}
+\cs_new_protected:Npn \__nicematrix_vline_v:
+ {
+ \begin {tikzpicture }
+ \pgfrememberpicturepositiononpagetrue
+ \pgf at relevantforpicturesizefalse
+ \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_local_start_int }
+ \dim_set_eq:NN \l_tmpa_dim \pgf at y
+ \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_position_int }
+ \dim_set_eq:NN \l_tmpb_dim \pgf at x
+ \__nicematrix_qpoint:n { row - \int_eval:n { \l__nicematrix_local_end_int + 1 } }
+ \dim_set_eq:NN \l_tmpc_dim \pgf at y
+ \exp_args:NV \tikzset \l__nicematrix_tikz_rule_tl
+ \use:x { \exp_not:N \draw [ \l__nicematrix_tikz_rule_tl ] }
+ ( \l_tmpb_dim , \l_tmpa_dim ) --
+ ( \l_tmpb_dim , \l_tmpc_dim ) ;
+ \end { tikzpicture }
+ }
\cs_new_protected:Npn \__nicematrix_draw_vlines:
{
\int_step_inline:nnn
@@ -4908,22 +4982,24 @@
{
\tl_if_eq:NnF \l__nicematrix_vlines_clist { all }
{ \clist_if_in:NnT \l__nicematrix_vlines_clist { ##1 } }
- { \__nicematrix_vline:nnnn { ##1 } 1 1 { } }
+ { \__nicematrix_vline:n { position = ##1 } }
}
}
-\cs_new_protected:Npn \__nicematrix_hline:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \__nicematrix_hline:n #1
{
- \pgfpicture
- \__nicematrix_hline_i:nnnn { #1 } { #2 } { #3 } { #4 }
- \endpgfpicture
+ \group_begin:
+ \int_zero_new:N \l__nicematrix_end_int
+ \int_set_eq:NN \l__nicematrix_end_int \c at jCol
+ \keys_set_known:nnN { NiceMatrix / Rules } { #1 } \l__nicematrix_other_keys_tl
+ \__nicematrix_hline_i:
+ \group_end:
}
-\cs_new_protected:Npn \__nicematrix_hline_i:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \__nicematrix_hline_i:
{
- \tl_set:Nn \l_tmpa_tl { #1 }
- \tl_clear_new:N \l_tmpc_tl
- \int_step_variable:nnNn
- { #3 }
- { \tl_if_blank:nTF { #4 } { \int_use:N \c at jCol } { #4 } }
+ \int_zero_new:N \l__nicematrix_local_start_int
+ \int_zero_new:N \l__nicematrix_local_end_int
+ \tl_set:Nx \l_tmpa_tl { \int_use:N \l__nicematrix_position_int }
+ \int_step_variable:nnNn \l__nicematrix_start_int \l__nicematrix_end_int
\l_tmpb_tl
{
\bool_gset_true:N \g_tmpa_bool
@@ -4936,29 +5012,22 @@
\clist_if_empty:NF \l__nicematrix_corners_clist \__nicematrix_test_in_corner_h:
\bool_if:NTF \g_tmpa_bool
{
- \tl_if_empty:NT \l_tmpc_tl
- { \tl_set_eq:NN \l_tmpc_tl \l_tmpb_tl }
+ \int_compare:nNnT \l__nicematrix_local_start_int = 0
+ { \int_set:Nn \l__nicematrix_local_start_int \l_tmpb_tl }
}
{
- \tl_if_empty:NF \l_tmpc_tl
+ \int_compare:nNnT \l__nicematrix_local_start_int > 0
{
- \__nicematrix_hline_ii:nnnn
- { #1 }
- { #2 }
- \l_tmpc_tl
- { \int_eval:n { \l_tmpb_tl - 1 } }
- \tl_clear:N \l_tmpc_tl
+ \int_set:Nn \l__nicematrix_local_end_int { \l_tmpb_tl - 1 }
+ \__nicematrix_hline_ii:
+ \int_zero:N \l__nicematrix_local_start_int
}
}
}
- \tl_if_empty:NF \l_tmpc_tl
+ \int_compare:nNnT \l__nicematrix_local_start_int > 0
{
- \__nicematrix_hline_ii:nnnn
- { #1 }
- { #2 }
- \l_tmpc_tl
- { \tl_if_blank:nTF { #4 } { \int_use:N \c at jCol } { #4 } }
- \tl_clear:N \l_tmpc_tl
+ \int_set_eq:NN \l__nicematrix_local_end_int \l__nicematrix_end_int
+ \__nicematrix_hline_ii:
}
}
\cs_new_protected:Npn \__nicematrix_test_in_corner_h:
@@ -4986,25 +5055,32 @@
}
}
}
-\cs_new_protected:Npn \__nicematrix_hline_ii:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \__nicematrix_hline_ii:
{
+ \bool_set_false:N \l__nicematrix_dotted_bool
+ \keys_set:nV { NiceMatrix / RulesBis } \l__nicematrix_other_keys_tl
\bool_if:NTF \l__nicematrix_dotted_bool
- { \__nicematrix_hline_iv:nnn { #1 } { #3 } { #4 } }
- { \__nicematrix_hline_iii:nnnn { #1 } { #2 } { #3 } { #4 } }
+ \__nicematrix_hline_iv:
+ {
+ \tl_if_empty:NTF \l__nicematrix_tikz_rule_tl
+ \__nicematrix_hline_iii:
+ \__nicematrix_hline_v:
+ }
}
-\cs_new_protected:Npn \__nicematrix_hline_iii:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \__nicematrix_hline_iii:
{
+ \pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgf at relevantforpicturesizefalse
- \__nicematrix_qpoint:n { col - #3 }
+ \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_local_start_int }
\dim_set_eq:NN \l_tmpa_dim \pgf at x
- \__nicematrix_qpoint:n { row - #1 }
+ \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_position_int }
\dim_set_eq:NN \l_tmpb_dim \pgf at y
- \__nicematrix_qpoint:n { col - \__nicematrix_succ:n { #4 } }
+ \__nicematrix_qpoint:n { col - \int_eval:n { \l__nicematrix_local_end_int + 1 } }
\dim_set_eq:NN \l_tmpc_dim \pgf at x
\bool_lazy_all:nT
{
- { \int_compare_p:nNn { #2 } > 1 }
+ { \int_compare_p:nNn \l__nicematrix_multiplicity_int > 1 }
{ \cs_if_exist_p:N \CT at drsc@ }
{ ! \tl_if_blank_p:V \CT at drsc@ }
}
@@ -5012,7 +5088,10 @@
\group_begin:
\CT at drsc@
\dim_set:Nn \l_tmpd_dim
- { \l_tmpb_dim - ( \doublerulesep + \arrayrulewidth ) * ( #2 - 1 ) }
+ {
+ \l_tmpb_dim - ( \doublerulesep + \arrayrulewidth )
+ * ( \l__nicematrix_multiplicity_int - 1 )
+ }
\pgfpathrectanglecorners
{ \pgfpoint \l_tmpa_dim \l_tmpb_dim }
{ \pgfpoint \l_tmpc_dim \l_tmpd_dim }
@@ -5021,7 +5100,7 @@
}
\pgfpathmoveto { \pgfpoint \l_tmpa_dim \l_tmpb_dim }
\pgfpathlineto { \pgfpoint \l_tmpc_dim \l_tmpb_dim }
- \prg_replicate:nn { #2 - 1 }
+ \prg_replicate:nn { \l__nicematrix_multiplicity_int - 1 }
{
\dim_sub:Nn \l_tmpb_dim \arrayrulewidth
\dim_sub:Nn \l_tmpb_dim \doublerulesep
@@ -5032,17 +5111,19 @@
\pgfsetlinewidth { 1.1 \arrayrulewidth }
\pgfsetrectcap
\pgfusepathqstroke
+ \endpgfpicture
}
-\cs_new_protected:Npn \__nicematrix_hline_iv:nnn #1 #2 #3
+\cs_new_protected:Npn \__nicematrix_hline_iv:
{
+ \pgfpicture
\pgfrememberpicturepositiononpagetrue
\pgf at relevantforpicturesizefalse
- \__nicematrix_qpoint:n { row - #1 }
+ \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_position_int }
\dim_set_eq:NN \l__nicematrix_y_initial_dim \pgf at y
\dim_set_eq:NN \l__nicematrix_y_final_dim \pgf at y
- \__nicematrix_qpoint:n { col - #2 }
+ \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_local_start_int }
\dim_set_eq:NN \l__nicematrix_x_initial_dim \pgf at x
- \int_compare:nNnT { #2 } = 1
+ \int_compare:nNnT \l__nicematrix_local_start_int = 1
{
\dim_sub:Nn \l__nicematrix_x_initial_dim \l__nicematrix_left_margin_dim
\bool_if:NT \l__nicematrix_NiceArray_bool
@@ -5050,9 +5131,9 @@
\tl_if_eq:NnF \g__nicematrix_left_delim_tl (
{ \dim_add:Nn \l__nicematrix_x_initial_dim { 0.5 \l__nicematrix_inter_dots_dim } }
}
- \__nicematrix_qpoint:n { col - \__nicematrix_succ:n { #3 } }
+ \__nicematrix_qpoint:n { col - \int_eval:n { \l__nicematrix_local_end_int + 1 } }
\dim_set_eq:NN \l__nicematrix_x_final_dim \pgf at x
- \int_compare:nNnT { #3 } = \c at jCol
+ \int_compare:nNnT \l__nicematrix_local_end_int = \c at jCol
{
\dim_add:Nn \l__nicematrix_x_final_dim \l__nicematrix_right_margin_dim
\bool_if:NT \l__nicematrix_NiceArray_bool
@@ -5060,8 +5141,27 @@
\tl_if_eq:NnF \g__nicematrix_right_delim_tl )
{ \dim_gsub:Nn \l__nicematrix_x_final_dim { 0.5 \l__nicematrix_inter_dots_dim } }
}
+ \CT at arc@
\__nicematrix_draw_line:
+ \endpgfpicture
}
+\cs_new_protected:Npn \__nicematrix_hline_v:
+ {
+ \begin { tikzpicture }
+ \pgfrememberpicturepositiononpagetrue
+ \pgf at relevantforpicturesizefalse
+ \__nicematrix_qpoint:n { col - \int_use:N \l__nicematrix_local_start_int }
+ \dim_set_eq:NN \l_tmpa_dim \pgf at x
+ \__nicematrix_qpoint:n { row - \int_use:N \l__nicematrix_position_int }
+ \dim_set_eq:NN \l_tmpb_dim \pgf at y
+ \__nicematrix_qpoint:n { col - \int_eval:n { \l__nicematrix_local_end_int + 1 } }
+ \dim_set_eq:NN \l_tmpc_dim \pgf at x
+ \exp_args:NV \tikzset \l__nicematrix_tikz_rule_tl
+ \use:x { \exp_not:N \draw [ \l__nicematrix_tikz_rule_tl ] }
+ ( \l_tmpa_dim , \l_tmpb_dim ) --
+ ( \l_tmpc_dim , \l_tmpb_dim ) ;
+ \end { tikzpicture }
+ }
\cs_new_protected:Npn \__nicematrix_draw_hlines:
{
\int_step_inline:nnn
@@ -5077,7 +5177,7 @@
{
\tl_if_eq:NnF \l__nicematrix_hlines_clist { all }
{ \clist_if_in:NnT \l__nicematrix_hlines_clist { ##1 } }
- { \__nicematrix_hline:nnnn { ##1 } 1 1 { } }
+ { \__nicematrix_hline:n { position = ##1 } }
}
}
\cs_set:Npn \__nicematrix_Hline: { \noalign { \ifnum 0 = `} \fi \__nicematrix_Hline_i:n { 1 } }
@@ -5096,9 +5196,93 @@
+ \doublerulesep * ( \int_max:nn 0 { #1 - 1 } )
}
\tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
- { \__nicematrix_hline:nnnn { \__nicematrix_succ:n { \c at iRow } } { #1 } 1 { } }
+ {
+ \__nicematrix_hline:n
+ {
+ position = \int_eval:n { \c at iRow + 1 } ,
+ multiplicity = #1
+ }
+ }
\ifnum 0 = `{ \fi }
}
+\keys_define:nn { NiceMatrix / ColumnTypes } { }
+\cs_new_protected:Npn \__nicematrix_custom_line:n #1
+ {
+ \keys_set_known:nn { NiceMatrix / Custom-Line } { #1 }
+ \bool_lazy_and:nnTF
+ { \str_if_empty_p:N \l__nicematrix_letter_str }
+ { \str_if_empty_p:N \l__nicematrix_command_str }
+ { \__nicematrix_error:n { No~letter~and~no~command } }
+ {
+ \str_if_empty:NF \l__nicematrix_letter_str
+ {
+ \int_compare:nNnTF { \str_count:N \l__nicematrix_letter_str } = 1
+ {
+ \exp_args:NnV \tl_if_in:NnTF
+ \c__nicematrix_forbidden_letters_str \l__nicematrix_letter_str
+ { \__nicematrix_error:n { Forbidden~letter } }
+ {
+ \exp_args:Nnx \keys_define:nn { NiceMatrix / ColumnTypes }
+ {
+ \l__nicematrix_letter_str .code:n =
+ { \__nicematrix_custom_line_i:n { \exp_not:n { #1 } } }
+ }
+ }
+ }
+ { \__nicematrix_error:n { Several~letters } }
+ }
+ \str_if_empty:NF \l__nicematrix_command_str
+ { \exp_args:NnV \__nicematrix_define_h_custom_line:nn { #1 } \l_tmpc_int }
+ }
+ }
+\str_const:Nn \c__nicematrix_forbidden_letters_str { lcrpmbVX:|()[]!@<> }
+\keys_define:nn { NiceMatrix / Custom-Line }
+ {
+ letter .str_set:N = \l__nicematrix_letter_str ,
+ letter .value_required:n = true ,
+ letter .initial:n = ,
+ command .str_set:N = \l__nicematrix_command_str ,
+ command .value_required:n = true ,
+ command .initial:n = ,
+ multiplicity .int_set:N = \l_tmpc_int ,
+ multiplicity .initial:n = 1 ,
+ multiplicity .value_required:n = true ,
+ }
+\cs_new_protected:Npn \__nicematrix_define_h_custom_line:nn #1 #2
+ {
+ \cs_set:cpn \l__nicematrix_command_str
+ {
+ \noalign
+ {
+ \skip_vertical:n
+ {
+ \dim_eval:n
+ { \arrayrulewidth * #2 + \doublerulesep * ( #2 - 1) }
+ }
+ \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
+ { \__nicematrix_hline:n { #1 , position = \int_eval:n { \c at iRow + 1 } } }
+ }
+ }
+ }
+\cs_new_protected:Npn \__nicematrix_custom_line_i:n #1
+ {
+ \tl_gput_right:Nx \g__nicematrix_preamble_tl
+ {
+ \exp_not:N !
+ {
+ \skip_horizontal:n
+ {
+ \dim_eval:n
+ {
+ \arrayrulewidth * \l_tmpc_int
+ + \doublerulesep * ( \l_tmpc_int - 1)
+ }
+ }
+ }
+ }
+ \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl
+ { \__nicematrix_vline:n { #1 , position = \__nicematrix_succ:n \c at jCol } }
+ }
\cs_new_protected:Npn \__nicematrix_test_hline_in_block:nnnnn #1 #2 #3 #4
{
\bool_lazy_all:nT
@@ -5266,19 +5450,9 @@
{ \__nicematrix_hdottedline:n { \int_use:N \c at iRow } }
}
\cs_new_protected:Npn \__nicematrix_hdottedline:n #1
- {
- \group_begin:
- \bool_set_true:N \l__nicematrix_dotted_bool
- \__nicematrix_hline:nnnn { #1 } { 1 } { 1 } { \int_use:N \c at jCol }
- \group_end:
- }
+ { \__nicematrix_hline:n { position = #1 , end = \int_use:N \c at jCol , dotted } }
\cs_new_protected:Npn \__nicematrix_vdottedline:n #1
- {
- \group_begin:
- \bool_set_true:N \l__nicematrix_dotted_bool
- \__nicematrix_vline:nnnn { \int_eval:n { #1 + 1 } } { 1 } { 1 } { \int_use:N \c at iRow }
- \group_end:
- }
+ { \__nicematrix_vline:n { position = \int_eval:n { #1 + 1 } , dotted } }
\bool_new:N \l__nicematrix_block_auto_columns_width_bool
\keys_define:nn { NiceMatrix / NiceMatrixBlock }
{
@@ -5529,7 +5703,9 @@
b .code:n = \str_set:Nn \l__nicematrix_vpos_of_block_tl b ,
b .value_forbidden:n = true ,
color .tl_set:N = \l__nicematrix_color_tl ,
- color .value_required:n = true
+ color .value_required:n = true ,
+ respect-arraystretch .bool_set:N = \l__nicematrix_respect_arraystretch_bool ,
+ respect-arraystretch .default:n = true ,
}
\NewExpandableDocumentCommand \__nicematrix_Block: { O { } m D < > { } +m }
{
@@ -5608,16 +5784,20 @@
{ \color { \l__nicematrix_color_tl } }
\int_compare:nNnT { #1 } = 1 \g__nicematrix_row_style_tl
\group_begin:
- \cs_set:Npn \arraystretch { 1 }
+ \bool_if:NF \l__nicematrix_respect_arraystretch_bool
+ { \cs_set:Npn \arraystretch { 1 } }
\dim_zero:N \extrarowheight
#4
\bool_if:NT \g__nicematrix_rotate_bool { \str_set:Nn \l__nicematrix_hpos_block_str c }
\bool_if:NTF \l__nicematrix_NiceTabular_bool
{
- \bool_lazy_and:nnTF
- { \int_compare_p:nNn { #2 } = 1 }
- { \dim_compare_p:n { \l__nicematrix_col_width_dim >= \c_zero_dim } }
+ \bool_lazy_all:nTF
{
+ { \int_compare_p:nNn { #2 } = 1 }
+ { \dim_compare_p:n { \l__nicematrix_col_width_dim >= \c_zero_dim } }
+ { ! \l__nicematrix_respect_arraystretch_bool }
+ }
+ {
\begin { minipage } [ \l__nicematrix_vpos_of_block_tl ]
{ \l__nicematrix_col_width_dim }
\str_case:Vn \l__nicematrix_hpos_block_str
@@ -5714,7 +5894,8 @@
\bool_if:NTF \l__nicematrix_NiceTabular_bool
{
\group_begin:
- \cs_set:Npn \arraystretch { 1 }
+ \bool_if:NF \l__nicematrix_respect_arraystretch_bool
+ { \cs_set:Npn \arraystretch { 1 } }
\dim_zero:N \extrarowheight
#4
\bool_if:NT \g__nicematrix_rotate_bool
@@ -5730,7 +5911,8 @@
}
{
\group_begin:
- \cs_set:Npn \arraystretch { 1 }
+ \bool_if:NF \l__nicematrix_respect_arraystretch_bool
+ { \cs_set:Npn \arraystretch { 1 } }
\dim_zero:N \extrarowheight
#4
\bool_if:NT \g__nicematrix_rotate_bool
@@ -5767,8 +5949,11 @@
color .value_required:n = true ,
borders .clist_set:N = \l__nicematrix_borders_clist ,
borders .value_required:n = true ,
- hvlines .bool_set:N = \l__nicematrix_hvlines_block_bool ,
- hvlines .default:n = true ,
+ hvlines .meta:n = { vlines = #1 , hlines = #1 } ,
+ vlines .bool_set:N = \l__nicematrix_vlines_block_bool,
+ vlines .default:n = true ,
+ hlines .bool_set:N = \l__nicematrix_hlines_block_bool,
+ hlines .default:n = true ,
line-width .dim_set:N = \l__nicematrix_line_width_dim ,
line-width .value_required:n = true ,
l .code:n = \str_set:Nn \l__nicematrix_hpos_block_str l ,
@@ -5792,7 +5977,9 @@
b .value_forbidden:n = true ,
name .tl_set:N = \l__nicematrix_block_name_str ,
name .value_required:n = true ,
- name .initial:n = \c_empty_tl ,
+ name .initial:n = ,
+ respect-arraystretch .bool_set:N = \l__nicematrix_respect_arraystretch_bool ,
+ respect-arraystretch .default:n = true ,
unknown .code:n = \__nicematrix_error:n { Unknown~key~for~Block }
}
\cs_new_protected:Npn \__nicematrix_draw_blocks:
@@ -5834,17 +6021,29 @@
{
\group_begin:
\keys_set:nn { NiceMatrix / Block / SecondPass } { #5 }
- \bool_if:NTF \l__nicematrix_hvlines_block_bool
+ \bool_if:NT \l__nicematrix_vlines_block_bool
{
\tl_gput_right:Nx \g_nicematrix_code_after_tl
{
- \__nicematrix_hvlines_block:nnn
+ \__nicematrix_vlines_block:nnn
{ \exp_not:n { #5 } }
{ #1 - #2 }
{ \int_use:N \l__nicematrix_last_row_int - \int_use:N \l__nicematrix_last_col_int }
}
}
+ \bool_if:NT \l__nicematrix_hlines_block_bool
{
+ \tl_gput_right:Nx \g_nicematrix_code_after_tl
+ {
+ \__nicematrix_hlines_block:nnn
+ { \exp_not:n { #5 } }
+ { #1 - #2 }
+ { \int_use:N \l__nicematrix_last_row_int - \int_use:N \l__nicematrix_last_col_int }
+ }
+ }
+ \bool_if:nT
+ { ! \l__nicematrix_vlines_block_bool && ! \l__nicematrix_hlines_block_bool }
+ {
\seq_gput_left:Nx \g__nicematrix_pos_of_blocks_seq
{ { #1 } { #2 } { #3 } { #4 } { \l__nicematrix_block_name_str } }
}
@@ -6133,7 +6332,7 @@
rounded-corners .dim_set:N = \l__nicematrix_rounded_corners_dim ,
rounded-corners .default:n = 4 pt
}
-\cs_new_protected:Npn \__nicematrix_hvlines_block:nnn #1 #2 #3
+\cs_new_protected:Npn \__nicematrix_vlines_block:nnn #1 #2 #3
{
\dim_set_eq:NN \l__nicematrix_line_width_dim \arrayrulewidth
\keys_set_known:nn { NiceMatrix / BlockBorders } { #1 }
@@ -6146,12 +6345,37 @@
\int_step_inline:nnn \l_tmpd_tl \l_tmpb_tl
{
\use:x
- { \__nicematrix_vline:nnnn { ##1 } 1 { \l_tmpc_tl } { \__nicematrix_pred:n \l_tmpa_tl } }
+ {
+ \__nicematrix_vline:n
+ {
+ position = ##1 ,
+ start = \l_tmpc_tl ,
+ end = \__nicematrix_pred:n \l_tmpa_tl
+ }
+ }
}
+ }
+\cs_new_protected:Npn \__nicematrix_hlines_block:nnn #1 #2 #3
+ {
+ \dim_set_eq:NN \l__nicematrix_line_width_dim \arrayrulewidth
+ \keys_set_known:nn { NiceMatrix / BlockBorders } { #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 } }
\int_step_inline:nnn \l_tmpc_tl \l_tmpa_tl
{
\use:x
- { \__nicematrix_hline:nnnn { ##1 } 1 { \l_tmpd_tl } { \__nicematrix_pred:n \l_tmpb_tl } }
+ {
+ \__nicematrix_hline:n
+ {
+ position = ##1 ,
+ start = \l_tmpd_tl ,
+ end = \int_eval:n { \l_tmpb_tl - 1 }
+ }
+ }
}
}
\cs_new_protected:Npn \__nicematrix_stroke_borders_block:nnn #1 #2 #3
@@ -6508,6 +6732,8 @@
}
\keys_define:nn { NiceMatrix / SubMatrix }
{
+ delimiters / color .tl_set:N = \l__nicematrix_delimiters_color_tl ,
+ delimiters / color .value_required:n = true ,
hlines .clist_set:N = \l__nicematrix_submatrix_hlines_clist ,
hlines .default:n = all ,
vlines .clist_set:N = \l__nicematrix_submatrix_vlines_clist ,
@@ -7032,8 +7258,8 @@
\__nicematrix_msg_new:nn { Key~transparent }
{
The~key~'transparent'~is~now~obsolete~(because~it's~name~
- is~not~clear).~You~should~use~the~conjonction~of~'renew-dots'~
- and~'renew-matrix'.~However,~you~can~go~on.
+ is~not~clear).~You~must~use~the~conjonction~of~'renew-dots'~
+ and~'renew-matrix'.~This~error~is~fatal.
}
\keys_define:nn { NiceMatrix / Package }
{
@@ -7041,12 +7267,7 @@
renew-dots .value_forbidden:n = true ,
renew-matrix .code:n = \__nicematrix_renew_matrix: ,
renew-matrix .value_forbidden:n = true ,
- transparent .code:n =
- {
- \__nicematrix_renew_matrix:
- \bool_set_true:N \l__nicematrix_renew_dots_bool
- \__nicematrix_error:n { Key~transparent }
- } ,
+ transparent .code:n = \__nicematrix_fatal:n { Key~transparent } ,
transparent .value_forbidden:n = true,
footnote .bool_set:N = \c__nicematrix_footnote_bool ,
footnotehyper .bool_set:N = \c__nicematrix_footnotehyper_bool ,
@@ -7092,13 +7313,6 @@
}
\bool_set_true:N \c__nicematrix_footnote_bool
}
-\__nicematrix_msg_new:nn { key~except-corners }
- {
- The~key~'except-corners'~has~been~deleted~for~the~command~\token_to_str:N
- \arraycolor\ in~the~\token_to_str:N \CodeBefore.~You~should~instead~use~
- the~key~'corners'~in~your~\__nicematrix_full_name_env:.\\
- If~you~go~on,~this~key~will~be~ignored.
- }
\seq_new:N \c__nicematrix_types_of_matrix_seq
\seq_set_from_clist:Nn \c__nicematrix_types_of_matrix_seq
{
@@ -7269,6 +7483,24 @@
}
\__nicematrix_msg_new:nn { empty~environment }
{ Your~\__nicematrix_full_name_env:\ is~empty.~This~error~is~fatal. }
+\__nicematrix_msg_new:nn { No~letter~and~no~command }
+ {
+ Your~use~of~'custom-line'~is~no-op~since~you~don't~have~used~the~
+ key~'letter'~(for~a~letter~for~vertical~rules)~nor~the~key~'command'~
+ (to~draw~horizontal~rules).\\
+ However,~you~can~go~on.
+ }
+\__nicematrix_msg_new:nn { Forbidden~letter }
+ {
+ You~can't~use~the~letter~'\l__nicematrix_letter_str'~for~a~customized~line.\\
+ If~you~go~on,~it~will~be~ignored.
+ }
+\__nicematrix_msg_new:nn { Several~letters }
+ {
+ You~must~use~only~one~letter~as~value~for~the~key~'letter'~(and~
+ have~used~'\l__nicematrix_letter_str').\\
+ If~you~go~on,~it~will~be~ignored.
+ }
\__nicematrix_msg_new:nn { Delimiter~with~small }
{
You~can't~put~a~delimiter~in~the~preamble~of~your~\__nicematrix_full_name_env:\
@@ -7359,6 +7591,14 @@
is~unknown. \\
This~error~is~fatal.
}
+\__nicematrix_msg_new:nn { colon~without~arydshln }
+ {
+ The~column~type~':'~in~your~\__nicematrix_full_name_env:\
+ is~unknown.~If~you~want~to~use~':'~of~'arydshln',~you~should~
+ load~that~package.~If~you~want~a~dotted~line~of~'nicematrix',~you~
+ should~use~'\l__nicematrix_letter_for_dotted_lines_str'.\\
+ This~error~is~fatal.
+ }
\__nicematrix_msg_new:nn { tabularnote~forbidden }
{
You~can't~use~the~command~\token_to_str:N\tabularnote\
@@ -7420,7 +7660,8 @@
}
{
The~available~keys~are~(in~alphabetic~order):~b,~borders,~c,~draw,~fill,~
- hvlines,~l,~line-width,~name,~rounded-corners,~r,~t~and~tikz.
+ hlines,~hvlines,~l,~line-width,~name,~rounded-corners,~r,~respect-arraystretch,
+ ~t,~tikz~and~vlines.
}
\__nicematrix_msg_new:nn { Version~of~siunitx~too~old }
{
@@ -7529,6 +7770,7 @@
code-for-last-col,~
code-for-last-row,~
corners,~
+ custom-key,~
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
@@ -7547,6 +7789,7 @@
nullify-dots,~
renew-dots,~
renew-matrix,~
+ respect-arraystretch,~
right-margin,~
rules~(with~the~subkeys~'color'~and~'width'),~
small,~
@@ -7596,6 +7839,7 @@
notes/para,~
nullify-dots,~
renew-dots,~
+ respect-arraystretch,~
right-margin,~
rules~(with~the~subkeys~'color'~and~'width'),~
small,~
@@ -7648,6 +7892,7 @@
nullify-dots,~
r,~
renew-dots,~
+ respect-arraystretch,~
right-margin,~
rules~(with~the~subkeys~'color'~and~'width'),~
small,~
@@ -7680,6 +7925,7 @@
colortbl-like,~
columns-width,~
corners,~
+ custom-line,~
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
@@ -7698,6 +7944,7 @@
notes/para,~
nullify-dots,~
renew-dots,~
+ respect-arraystretch,~
right-margin,~
rules~(with~the~subkeys~'color'~and~'width'),~
t,~
More information about the tex-live-commits
mailing list.