From 17f5b660e0ce0c5c1b1dc095df8213e078963809 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 24 Jan 2022 03:02:10 +0000 Subject: CTAN sync 202201240302 --- .../latex/contrib/nicematrix/nicematrix-french.pdf | Bin 490739 -> 499106 bytes .../latex/contrib/nicematrix/nicematrix-french.tex | 181 +++- macros/latex/contrib/nicematrix/nicematrix.dtx | 1016 +++++++++++++++----- macros/latex/contrib/nicematrix/nicematrix.ins | 4 +- macros/latex/contrib/nicematrix/nicematrix.pdf | Bin 1434511 -> 1482850 bytes 5 files changed, 917 insertions(+), 284 deletions(-) (limited to 'macros/latex/contrib/nicematrix') diff --git a/macros/latex/contrib/nicematrix/nicematrix-french.pdf b/macros/latex/contrib/nicematrix/nicematrix-french.pdf index ff9d46251c..0e75045e9a 100644 Binary files a/macros/latex/contrib/nicematrix/nicematrix-french.pdf and b/macros/latex/contrib/nicematrix/nicematrix-french.pdf differ diff --git a/macros/latex/contrib/nicematrix/nicematrix-french.tex b/macros/latex/contrib/nicematrix/nicematrix-french.tex index 3690d37880..fc2cc12e34 100644 --- a/macros/latex/contrib/nicematrix/nicematrix-french.tex +++ b/macros/latex/contrib/nicematrix/nicematrix-french.tex @@ -533,8 +533,8 @@ cette clé prend comme valeur une liste d'éléments parmi les suivants : |left| |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 @@ applicables à un chemin de Tikz). Pour des exemple d'utilisation de cette clé |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,11 +891,9 @@ A&B&C&D \\ \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} @@ -1178,6 +1179,7 @@ Cette commande |\diagbox| peut aussi être utilisée dans un |\Block|. \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,7 +1240,71 @@ largeur du trait\footnote{En fait, avec l'extension \pkg{array}, cela est vrai 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} @@ -1507,10 +1573,10 @@ l'intervalle constitué de toutes les rangées du tableau à partir de la rangé \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 @@ seront appliquées à chacune des cases restantes sur la rangée en cours. \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 @@ la syntaxe $i$|-|$j$ où $i$ est le numéro de rangée et $j$ le numéro de colo \item le troisième argument est le coin inférieur droit avec la même syntaxe ; \item la quatrième argument est le délimiteur droit ; \item le cinquième argument, optionnel, entre crochets, est une liste de couples -clé-valeur.\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 @@ a_{31} & a_{32} & a_{33} -\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 @@ horizontales sur une partie du tableau. Ces commandes prennent trois arguments : \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 @@ $\begin{pNiceMatrix} \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,20 +3484,21 @@ La commande |\nobreak| est pour le cas où l'option |para| est utilisée. \item Les notes sont composées en fin de tableau en utilisant en interne un -style de liste 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. +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}) : -Valeur initiale :\quad |noitemsep , leftmargin = * , align = left , labelsep = 0pt| +|noitemsep , leftmargin = * , align = left , labelsep = 0pt| -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. +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}). -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}). +\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}). \item La clé |notes/enumitem-keys-para| est similaire à la précédente mais elle @@ -3441,7 +3508,9 @@ type |inline| (suivant le vocabulaire de \pkg{enumitem}) qui est utilisée et le 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 @@ -4182,6 +4251,50 @@ créés une première fois avant la construction du tableau en utilisant des 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} @@ -5188,12 +5301,10 @@ Dans ce tableau, les instructions |\SubMatrix| sont exécutés après la 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} diff --git a/macros/latex/contrib/nicematrix/nicematrix.dtx b/macros/latex/contrib/nicematrix/nicematrix.dtx index 5a6e2d1b85..80d98ae17e 100644 --- a/macros/latex/contrib/nicematrix/nicematrix.dtx +++ b/macros/latex/contrib/nicematrix/nicematrix.dtx @@ -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 @@ version 2005/12/01 or later. % % \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 @@ version 2005/12/01 or later. % 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 @@ version 2005/12/01 or later. % \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 @@ version 2005/12/01 or later. % \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 @@ version 2005/12/01 or later. % % \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,6 +1252,71 @@ version 2005/12/01 or later. % |\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} % @@ -1508,9 +1575,10 @@ version 2005/12/01 or later. % % % \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 @@ version 2005/12/01 or later. % % \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 @@ version 2005/12/01 or later. % |{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 @@ version 2005/12/01 or later. % syntax $i$|-|$j$ where $i$ the number of row and $j$ the number of column; % \item the third argument is the lower-right corner with the same syntax; % \item the fourth argument is the right delimiter; -% \item the last argument, which is optional, is a list of key-value +% \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 @@ version 2005/12/01 or later. % \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,20 +3440,23 @@ version 2005/12/01 or later. % % % \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 @@ -3393,7 +3464,8 @@ version 2005/12/01 or later. % \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 @@ version 2005/12/01 or later. % 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 @@ version 2005/12/01 or later. % 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 @@ version 2005/12/01 or later. % % %\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 @@ version 2005/12/01 or later. \cs_set:Npn \CT@arc #1 #2 { \dim_compare:nNnT \baselineskip = \c_zero_dim \noalign - { \cs_gset:Npn \CT@arc@ { \color #1 { #2 } } } + { \cs_gset:Npn \CT@arc@ { \color #1 { #2 } } } } % \end{macrocode} % Idem for |\CT@drs@|. @@ -5723,7 +5840,7 @@ version 2005/12/01 or later. \cs_set:Npn\CT@drs #1 #2 { \dim_compare:nNnT \baselineskip = \c_zero_dim \noalign - { \cs_gset:Npn \CT@drsc@ { \color #1 { #2 } } } + { \cs_gset:Npn \CT@drsc@ { \color #1 { #2 } } } } \cs_set:Npn \hline { @@ -5847,7 +5964,17 @@ version 2005/12/01 or later. \cs_new_protected:Npn \@@_set_CT@arc@_ii: #1 \q_stop { \cs_set:Npn \CT@arc@ { \color { #1 } } } % \end{macrocode} -% +% +% \bigskip +% \begin{macrocode} +\cs_new_protected:Npn \@@_set_CT@drsc@: + { \peek_meaning:NTF [ \@@_set_CT@drsc@_i: \@@_set_CT@drsc@_ii: } +\cs_new_protected:Npn \@@_set_CT@drsc@_i: [ #1 ] #2 \q_stop + { \cs_set:Npn \CT@drsc@ { \color [ #1 ] { #2 } } } +\cs_new_protected:Npn \@@_set_CT@drsc@_ii: #1 \q_stop + { \cs_set:Npn \CT@drsc@ { \color { #1 } } } +% \end{macrocode} +% % % \bigskip % \begin{macrocode} @@ -6342,6 +6469,7 @@ version 2005/12/01 or later. % \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 @@ version 2005/12/01 or later. % % % \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 @@ version 2005/12/01 or later. % % % \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,6 +7149,13 @@ version 2005/12/01 or later. \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 @@ -7174,8 +7311,8 @@ version 2005/12/01 or later. % \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 @@ version 2005/12/01 or later. 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 @@ version 2005/12/01 or later. % 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 @@ version 2005/12/01 or later. % \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 @@ version 2005/12/01 or later. % % \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 @@ version 2005/12/01 or later. % \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 @@ version 2005/12/01 or later. \} { \@@_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@jCol + 1 } } @@ -9517,20 +9658,40 @@ version 2005/12/01 or later. { \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 @@ version 2005/12/01 or later. { \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 @@ version 2005/12/01 or later. } \tl_gput_right:Nx \g_@@_internal_code_after_tl { - \@@_vline:nnnn - { \@@_succ:n \c@jCol } { \int_use:N \l_tmpa_int } { 1 } { } + \@@_vline:n + { + position = \@@_succ:n \c@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 @@ version 2005/12/01 or later. \seq_gput_left:Nn \g_@@_multicolumn_sizes_seq { #1 } \seq_gput_right:Nx \g_@@_pos_of_blocks_seq { - { \int_use:N \c@iRow } + { + \int_compare:nNnTF \c@jCol = 0 + { \int_eval:n { \c@iRow + 1 } } + { \int_use:N \c@iRow } + } % modified 2022/01/10 { \int_eval:n { \c@jCol + 1 } } - { \int_use:N \c@iRow } + { + \int_compare:nNnTF \c@jCol = 0 + { \int_eval:n { \c@iRow + 1 } } + { \int_use:N \c@iRow } + } % modified 2022/01/10 { \int_eval:n { \c@jCol + #1 } } { } % for the name of the block } @@ -11092,8 +11272,14 @@ version 2005/12/01 or later. % \begin{macrocode} & \omit - \int_gincr:N \g_tmpa_int +% \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 \bool_lazy_all:nT { \l_@@_NiceArray_bool @@ -13647,7 +13833,7 @@ version 2005/12/01 or later. 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 @@ version 2005/12/01 or later. % \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@iRow - \int_use:N \c@jCol } @@ -13993,7 +14171,7 @@ version 2005/12/01 or later. % |#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 @@ version 2005/12/01 or later. % % % +% \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 @@ version 2005/12/01 or later. % % % \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} +\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@arc@: #1 \q_stop , + color .value_required:n = true , + sep-color .code:n = \@@_set_CT@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:nnnn #1 #2 #3 #4 +\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@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@jCol + 2 } - { - \pgfpicture - \@@_vline_i:nnnn { #1 } { #2 } { #3 } { #4 } - \endpgfpicture - } + \int_compare:nNnT \l_@@_position_int < { \c@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@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 @@ version 2005/12/01 or later. \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@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 @@ version 2005/12/01 or later. % \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@relevantforpicturesizefalse - \@@_qpoint:n { row - #3 } + \@@_qpoint:n { row - \int_use:N \l_@@_local_start_int } \dim_set_eq:NN \l_tmpa_dim \pgf@y - \@@_qpoint:n { col - #1 } + \@@_qpoint:n { col - \int_use:N \l_@@_position_int } \dim_set_eq:NN \l_tmpb_dim \pgf@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@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@drsc@ } { ! \tl_if_blank_p:V \CT@drsc@ } } @@ -14570,7 +14804,10 @@ version 2005/12/01 or later. \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 @@ version 2005/12/01 or later. } \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,28 +14827,53 @@ version 2005/12/01 or later. \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@relevantforpicturesizefalse - \@@_qpoint:n { col - #1 } + \@@_qpoint:n { col - \int_use:N \l_@@_position_int } \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x \dim_set_eq:NN \l_@@_x_final_dim \pgf@x - \@@_qpoint:n { row - #2 } + \@@_qpoint:n { row - \int_use:N \l_@@_local_start_int } \dim_set_eq:NN \l_@@_y_initial_dim \pgf@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@y + \CT@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@relevantforpicturesizefalse + \@@_qpoint:n { row - \int_use:N \l_@@_local_start_int } + \dim_set_eq:NN \l_tmpa_dim \pgf@y + \@@_qpoint:n { col - \int_use:N \l_@@_position_int } + \dim_set_eq:NN \l_tmpb_dim \pgf@x + \@@_qpoint:n { row - \int_eval:n { \l_@@_local_end_int + 1 } } + \dim_set_eq:NN \l_tmpc_dim \pgf@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} % @@ -14636,43 +14898,46 @@ version 2005/12/01 or later. { \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} % % % -% \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@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@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 @@ version 2005/12/01 or later. \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@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 @@ version 2005/12/01 or later. % % \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@relevantforpicturesizefalse - \@@_qpoint:n { col - #3 } + \@@_qpoint:n { col - \int_use:N \l_@@_local_start_int } \dim_set_eq:NN \l_tmpa_dim \pgf@x - \@@_qpoint:n { row - #1 } + \@@_qpoint:n { row - \int_use:N \l_@@_position_int } \dim_set_eq:NN \l_tmpb_dim \pgf@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@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@drsc@ } { ! \tl_if_blank_p:V \CT@drsc@ } } @@ -14786,7 +15050,10 @@ version 2005/12/01 or later. \group_begin: \CT@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 @@ version 2005/12/01 or later. } \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 @@ version 2005/12/01 or later. \pgfsetlinewidth { 1.1 \arrayrulewidth } \pgfsetrectcap \pgfusepathqstroke + \endpgfpicture } % \end{macrocode} % @@ -14856,16 +15124,17 @@ version 2005/12/01 or later. % \end{bNiceMatrix}$ % % \begin{macrocode} -\cs_new_protected:Npn \@@_hline_iv:nnn #1 #2 #3 +\cs_new_protected:Npn \@@_hline_iv: { + \pgfpicture \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse - \@@_qpoint:n { row - #1 } + \@@_qpoint:n { row - \int_use:N \l_@@_position_int } \dim_set_eq:NN \l_@@_y_initial_dim \pgf@y \dim_set_eq:NN \l_@@_y_final_dim \pgf@y - \@@_qpoint:n { col - #2 } + \@@_qpoint:n { col - \int_use:N \l_@@_local_start_int } \dim_set_eq:NN \l_@@_x_initial_dim \pgf@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 @@ version 2005/12/01 or later. \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@x - \int_compare:nNnT { #3 } = \c@jCol + \int_compare:nNnT \l_@@_local_end_int = \c@jCol { \dim_add:Nn \l_@@_x_final_dim \l_@@_right_margin_dim \bool_if:NT \l_@@_NiceArray_bool @@ -14888,7 +15157,32 @@ version 2005/12/01 or later. \tl_if_eq:NnF \g_@@_right_delim_tl ) { \dim_gsub:Nn \l_@@_x_final_dim { 0.5 \l_@@_inter_dots_dim } } } + \CT@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@relevantforpicturesizefalse + \@@_qpoint:n { col - \int_use:N \l_@@_local_start_int } + \dim_set_eq:NN \l_tmpa_dim \pgf@x + \@@_qpoint:n { row - \int_use:N \l_@@_position_int } + \dim_set_eq:NN \l_tmpb_dim \pgf@y + \@@_qpoint:n { col - \int_eval:n { \l_@@_local_end_int + 1 } } + \dim_set_eq:NN \l_tmpc_dim \pgf@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} % @@ -14896,7 +15190,7 @@ version 2005/12/01 or later. % \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 @@ version 2005/12/01 or later. { \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,12 +15244,163 @@ version 2005/12/01 or later. + \doublerulesep * ( \int_max:nn 0 { #1 - 1 } ) } \tl_gput_right:Nx \g_@@_internal_code_after_tl - { \@@_hline:nnnn { \@@_succ:n { \c@iRow } } { #1 } 1 { } } + { + \@@_hline:n + { + position = \int_eval:n { \c@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@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@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 @@ -15248,12 +15693,7 @@ version 2005/12/01 or later. % 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@jCol } - \group_end: - } + { \@@_hline:n { position = #1 , end = \int_use:N \c@jCol , dotted } } % \end{macrocode} % % @@ -15264,12 +15704,7 @@ version 2005/12/01 or later. % \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@iRow } - \group_end: - } + { \@@_vline:n { position = \int_eval:n { #1 + 1 } , dotted } } % \end{macrocode} % % \bigskip @@ -15721,7 +16156,9 @@ version 2005/12/01 or later. 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 @@ version 2005/12/01 or later. % \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 @@ version 2005/12/01 or later. % \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 @@ version 2005/12/01 or later. \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 @@ version 2005/12/01 or later. r \raggedleft l \raggedright } - #5 + #5 \end { minipage } } { @@ -16037,7 +16479,8 @@ version 2005/12/01 or later. \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 @@ version 2005/12/01 or later. } { \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 @@ version 2005/12/01 or later. 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 @@ version 2005/12/01 or later. 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,16 +16657,28 @@ version 2005/12/01 or later. % \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 + { + \@@_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 { - \@@_hvlines_block:nnn + \@@_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 @@ -16689,7 +17150,7 @@ version 2005/12/01 or later. % 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 @@ version 2005/12/01 or later. \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 @@ version 2005/12/01 or later. % % % 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 @@ version 2005/12/01 or later. % \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 @@ version 2005/12/01 or later. \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 @@ version 2005/12/01 or later. \@@_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 @@ version 2005/12/01 or later. renew-dots .value_forbidden:n = true , renew-matrix .code:n = \@@_renew_matrix: , renew-matrix .value_forbidden:n = true , - transparent .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 @@ version 2005/12/01 or later. % \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 @@ version 2005/12/01 or later. % \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 @@ version 2005/12/01 or later. 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 @@ version 2005/12/01 or later. } { 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 @@ version 2005/12/01 or later. code-for-last-col,~ code-for-last-row,~ corners,~ + custom-key,~ create-extra-nodes,~ create-medium-nodes,~ create-large-nodes,~ @@ -18833,6 +19344,7 @@ version 2005/12/01 or later. nullify-dots,~ renew-dots,~ renew-matrix,~ + respect-arraystretch,~ right-margin,~ rules~(with~the~subkeys~'color'~and~'width'),~ small,~ @@ -18885,6 +19397,7 @@ version 2005/12/01 or later. notes/para,~ nullify-dots,~ renew-dots,~ + respect-arraystretch,~ right-margin,~ rules~(with~the~subkeys~'color'~and~'width'),~ small,~ @@ -18944,6 +19457,7 @@ version 2005/12/01 or later. nullify-dots,~ r,~ renew-dots,~ + respect-arraystretch,~ right-margin,~ rules~(with~the~subkeys~'color'~and~'width'),~ small,~ @@ -18979,6 +19493,7 @@ version 2005/12/01 or later. colortbl-like,~ columns-width,~ corners,~ + custom-line,~ create-extra-nodes,~ create-medium-nodes,~ create-large-nodes,~ @@ -18997,6 +19512,7 @@ version 2005/12/01 or later. notes/para,~ nullify-dots,~ renew-dots,~ + respect-arraystretch,~ right-margin,~ rules~(with~the~subkeys~'color'~and~'width'),~ t,~ @@ -19584,6 +20100,12 @@ version 2005/12/01 or later. % 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 % diff --git a/macros/latex/contrib/nicematrix/nicematrix.ins b/macros/latex/contrib/nicematrix/nicematrix.ins index b6fbed12ca..2bfd59f567 100644 --- a/macros/latex/contrib/nicematrix/nicematrix.ins +++ b/macros/latex/contrib/nicematrix/nicematrix.ins @@ -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 diff --git a/macros/latex/contrib/nicematrix/nicematrix.pdf b/macros/latex/contrib/nicematrix/nicematrix.pdf index d6c12ea75e..703b8f8c3b 100644 Binary files a/macros/latex/contrib/nicematrix/nicematrix.pdf and b/macros/latex/contrib/nicematrix/nicematrix.pdf differ -- cgit v1.2.3