From 6e18fe0f01e9a301f7fc4a40ee702864cec07a26 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 22 Aug 2021 20:06:55 +0000 Subject: nicematrix git-svn-id: svn://tug.org/texlive/trunk@60304 c570f23f-e606-0410-a88d-b1316a301751 --- .../doc/latex/nicematrix/nicematrix-french.pdf | Bin 470144 -> 471024 bytes .../doc/latex/nicematrix/nicematrix-french.tex | 89 ++-- .../texmf-dist/doc/latex/nicematrix/nicematrix.pdf | Bin 1377012 -> 1380062 bytes .../source/latex/nicematrix/nicematrix.dtx | 524 ++++++++++++--------- .../texmf-dist/tex/latex/nicematrix/nicematrix.sty | 278 ++++++----- 5 files changed, 496 insertions(+), 395 deletions(-) (limited to 'Master') diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf index 7a1973e08e3..0ae9b001659 100644 Binary files a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf and b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf differ diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex index 7d7d915bc38..52aee279929 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex @@ -118,7 +118,7 @@ avec une distribution TeX comme MiKTeX, TeXlive ou MacTeX. \emph{Remarque} : Si vous utilisez un service LaTeX via Internet (ex. : Overleaf) vous pouvez télécharger le fichier |nicematrix.sty| dans le dossier de votre projet pour bénéficier de la dernière version de -\pkg{nicematrix}.\footnote{La dernière version de \verb|nicematrix.sty| peut +\pkg{nicematrix}.\footnote{La dernière version de |nicematrix.sty| peut être téléchargée sur le serveur \textsc{svn} de TeXLive : \newline \small \url{https:www.tug.org/svn/texlive/trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty}} @@ -166,10 +166,10 @@ L'extension \pkg{nicematrix} définit les nouveaux environnements suivants : \begin{tabular}{llll} \{NiceTabular\} & \{NiceArray\} & \{NiceMatrix\} \\ \{NiceTabular*\} & \{pNiceArray\} & \{pNiceMatrix\} \\ - & \{bNiceArray\} & \{bNiceMatrix\} \\ - & \{BNiceArray\} & \{BNiceMatrix\} \\ - & \{vNiceArray\} & \{vNiceMatrix\} \\ - & \{VNiceArray\} & \{VNiceMatrix\} +\{NiceTabularX\} & \{bNiceArray\} & \{bNiceMatrix\} \\ + & \{BNiceArray\} & \{BNiceMatrix\} \\ + & \{vNiceArray\} & \{vNiceMatrix\} \\ + & \{VNiceArray\} & \{VNiceMatrix\} \end{tabular} \end{ttfamily} @@ -179,6 +179,7 @@ Les environnements |{NiceArray}|, |{NiceTabular}| et |{NiceTabular*}| sont similaires aux environnements |{array}|, |{tabular}| et |{tabular*}| de l'extension \pkg{array} (qui est chargée par \pkg{nicematrix}). + \medskip Les environnements |{pNiceArray}|, |{bNiceArray}|, etc. n'ont pas d'équivalents dans \pkg{array}. @@ -188,6 +189,14 @@ Les environnements |{NiceMatrix}|, |{pNiceMatrix}|, etc. sont similaires aux environnements correspondants de l'\pkg{amsmath} (qui est chargée par \pkg{nicematrix}) : |{matrix}|, |{pmatrix}|, etc. +\medskip +L'environnement |{NiceTabularX}| est similaire à l'environnement |{tabularx}| de +l'extension éponyme.\footnote{Néanmoins, on peut aussi utiliser directement les + colonnes |X| dans l'environnement |{NiceTabular}|, la largeur + souhaitée pour le tableau étant spécifiée par la clé |width|: cf. + p.~\pageref{colonne-X}.} + + \medskip \textbf{On conseille d'utiliser prioritairement les environnements classiques et de n'utiliser les environnements de \pkg{nicematrix} que lorsqu'on utilise les @@ -362,7 +371,7 @@ u_n & 1 & 2 & 4 & 8 & 16 & 32 \\ \bigskip On peut aussi utiliser la clé |baseline| pour aligner une matrice sur un filet horizontal (tracé par |\hline|). On doit pour cela donner la valeur -|line-|\textsl{i} où \textsl{i} est le numéro de la rangée qui suit ce filet +|line-|\textsl{i} où \textsl{i} est le numéro de la rangée qui \emph{suit} ce filet horizontal. \smallskip @@ -372,7 +381,7 @@ horizontal. \smallskip \begin{BVerbatim}[baseline=c,boxwidth=9cm] -$A=\begin{pNiceArray}{cc|cc}[baseline=line-3] +$A=\begin{pNiceArray}{cc|cc}~emphase#[baseline=line-3]@ \dfrac1A & \dfrac1B & 0 & 0 \\ \dfrac1C & \dfrac1D & 0 & 0 \\ \hline @@ -402,7 +411,7 @@ $A=\begin{pNiceArray}{cc|cc}[baseline=line-3] Dans les environnements de \pkg{nicematrix}, on peut utiliser la commande |\Block| pour placer un élément au centre d'un rectangle de cases -fusionnées.\footnote{Les espaces situés après une commande \verb|\Block| sont supprimés.} +fusionnées.\footnote{Les espaces situés après une commande |\Block| sont supprimés.} La commande |\Block| doit être utilisée dans la case supérieure gauche du bloc avec deux arguments obligatoires. @@ -729,10 +738,9 @@ Rang & \Block{1-3}{Premier groupe} & & & \Block{1-3}{Deuxième groupe} \\ \end{center} \medskip -\colorbox{yellow!50}{\bfseries Nouveau 5.17}\enskip Pour avoir un positionnement -horizontal du contenu du bloc qui s'appuie sur les limites des colonnes du -tableau LaTeX (et non sur le contenu de ces colonnes), il faut utiliser les clés -|L|, |R| et |C| de la commande |\Block|. +Pour avoir un positionnement horizontal du contenu du bloc qui s'appuie sur les +limites des colonnes du tableau LaTeX (et non sur le contenu de ces colonnes), +il faut utiliser les clés |L|, |R| et |C| de la commande |\Block|. \section{Les filets horizontaux et verticaux} @@ -800,7 +808,7 @@ a & b & c & d \\ \bigskip Il reste néanmoins possible de définir un spécificateur, nommé par exemple -\verb|I|, pour tracer des filets verticaux avec le comportement standard de +|I|, pour tracer des filets verticaux avec le comportement standard de \pkg{array} : % \begin{Verbatim} @@ -941,8 +949,8 @@ préambule) ; \begin{itemize} \item Les blocs en question sont : \begin{itemize} -\item ceux créés par la commande |\Block|\footnote{Et aussi la commande \verb|\multicolumn| même s'il - est recommandé d'utiliser plutôt \verb|\Block| quand on utilise l'extension +\item ceux créés par la commande |\Block|\footnote{Et aussi la commande |\multicolumn| même s'il + est recommandé d'utiliser plutôt |\Block| quand on utilise l'extension \pkg{nicematrix}.} de \pkg{nicematrix} présentée p.~\pageref{Block}; \item ceux délimités implicitement par des lignes en pointillés continues, créées @@ -1010,9 +1018,8 @@ arum & iris & jacinthe & muguet \bigskip -\colorbox{yellow!50}{\textbf{Nouveau 5.17}}\enskip La clé -|hvlines-except-borders| est similaire à la clé |hvlines| mais ne trace pas les -filets sur les bords horizontaux et verticaux du tableau. +La clé |hvlines-except-borders| est similaire à la clé |hvlines| mais ne trace +pas les filets sur les bords horizontaux et verticaux du tableau. \bigskip \subsubsection{Les coins (vides)} @@ -1300,7 +1307,7 @@ l'environnement. De nouvelles commandes sont disponibles dans ce |\CodeBefore|: |\cellcolor|, |\rectanglecolor|, |\rowcolor|, |\columncolor|, |\rowcolors|, |\rowlistcolors|, |\chessboardcolors| et |\arraycolor|.\footnote{On pourra remarquer que, dans le - \verb|\CodeBefore|, des nœuds PGF/Tikz de la forme \verb+(i-|j)+ correspondant + |\CodeBefore|, des nœuds PGF/Tikz de la forme \verb+(i-|j)+ correspondant à la position des filets éventuels sont également accessibles : cf. p.~\pageref{noeuds-i}.} \label{code-before} @@ -1779,23 +1786,33 @@ 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. Les clés disponibles sont |cell-space-top-limit|, -|cell-space-bottom-limit| et |cell-space-limits| avec le même effet que les clés -globales de même nom (cf. p.~\pageref{cell-space}). +couples clé-valeur. +\begin{itemize} +\item Les clés |cell-space-top-limit|, |cell-space-bottom-limit| +et |cell-space-limits| sont disponibles avec le même effet que les clés globales +de même nom (cf. p.~\pageref{cell-space}). +\item \colorbox{yellow!50}{\bfseries Nouveau 6.1}\enskip La clé |color| fixe la +couleur du texte.\footnote{La clé |color| utilise la commande |\color| +mais insère aussi une instruction |\leavevmode| devant. Cela évite un +espace vertical parasite dans les cellules qui correspondent à des colonnes de +type |p|, |b|, |m| et |X| (qui débutent en mode vertical).} +\end{itemize} \medskip \begin{BVerbatim}[boxwidth=11cm,baseline=c] -\begin{NiceTabular}{cccc}[hlines,colortbl-like] +\begin{NiceTabular}{cccc}[colortbl-like] +\hline ~emphase#\RowStyle[cell-space-limits=3pt]{\rotate}@ premier & deuxième & troisième & quatrième \\ -\rowcolor{blue!50}~emphase#\RowStyle{\color{white}\sffamily}@ +\rowcolor{blue!50}~emphase#\RowStyle[color=white]{\sffamily}@ 1 & 2 & 3 & 4 \\ \end{NiceTabular} \end{BVerbatim} -\begin{NiceTabular}{cccc}[hlines,colortbl-like] +\begin{NiceTabular}{cccc}[colortbl-like] +\hline \RowStyle[cell-space-limits=3pt]{\rotate} premier & deuxième & troisième & quatrième \\ -\rowcolor{blue!50}\RowStyle{\color{white}\sffamily} +\rowcolor{blue!50}\RowStyle[color=white]{\sffamily} 1 & 2 & 3 & 4 \\ \end{NiceTabular} @@ -1942,6 +1959,8 @@ $\begin{array}{c} \subsection{Les colonnes X} +\label{colonne-X} + \colorbox{yellow!50}{\textbf{Nouveau 6.0}} L'environnement |{NiceTabular}| propose aussi des colonnes |X| similaires à @@ -2029,7 +2048,7 @@ préambule de spécification de colonne pour les éventuelles première et derni colonne : ce sera automatiquement (et nécessairement) une colonne |r| pour la première colonne et une colonne |l| pour la dernière.\footnote{Si on souhaite une colonne extérieure avec un autre type d'alignement, on aura intérêt à - considérer la commande \verb|\SubMatrix| disponible dans le \verb|\CodeAfter| + considérer la commande |\SubMatrix| disponible dans le |\CodeAfter| (cf. p.~\pageref{sub-matrix}).} \item On peut se demander comment \pkg{nicematrix} détermine le nombre de rangées et de colonnes nécessaires à la @@ -2391,7 +2410,7 @@ $\begin{pNiceMatrix} \emph{Remarque} : Contrairement à la commande |\hdotsfor| de \pkg{amsmath}, la commande |\Hdotsfor| est utilisable même lorsque l'extension \pkg{colortbl}\footnote{On rappelle que lorsque l'extension \pkg{xcolor} est - chargée avec l'option \verb|table|, l'extension \pkg{colortbl} est chargée.} + chargée avec l'option |table|, l'extension \pkg{colortbl} est chargée.} est chargée (mais vous risquez d'avoir des problèmes si vous utilisez |\rowcolor| sur la même rangée que |\Hdotsfor|). @@ -2623,7 +2642,7 @@ Les lignes pointillées délimitent des blocs virtuels qui ont le même comportement vis à vis des filets que les blocs créés par |\Block| (les filets spécifiés par le spécificateur \verb+|+ dans le préambule, la commande |\Hline| et par les clés |vlines|, |hlines|, |hvlines| et |hvlines-except-borders| ne -sont pas tracés dans les blocs).\footnote{En revanche, la commande \verb|\line| dans le \verb|\CodeAfter| +sont pas tracés dans les blocs).\footnote{En revanche, la commande |\line| dans le |\CodeAfter| (cf.~p.~\pageref{line-in-code-after}) ne crée pas de bloc.} \medskip @@ -2745,10 +2764,10 @@ la syntaxe $i$|-|$j$ où $i$ est le numéro de rangée et $j$ le numéro de colo \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 -position car un crochet ouvrant juste après \verb|\SubMatrix| doit pouvoir être -interprété comme le premier argument (obligatoire) de \verb|\SubMatrix|: ce +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. : -\verb|\SubMatrix[{2-2}{4-7}]|).} +|\SubMatrix[{2-2}{4-7}]|).} \end{itemize} On remarquera que la commande |\SubMatrix| trace les délimiteurs après la @@ -2907,7 +2926,7 @@ PGF/Tikz : voir p.~\pageref{node-sub-matrix}. \bigskip Il est également possible de spécifier des délimiteurs\footnote{Les délimiteurs - en question sont \verb|(|, \verb|[| et \verb|\{| et les fermants correspondants. + en question sont |(|, |[| et |\{| et les fermants correspondants. On peut bien sûr aussi mettre des \verb+|+ et des \verb+||+ dans le préambule.} en les plaçant dans le préambule de l'environnement (pour les environnements à préambule : |{NiceArray}|, |{pNiceArray}|, etc.). Cette syntaxe @@ -4405,7 +4424,7 @@ L'extension \pkg{nicematrix} n'est pas compatible avec la classe \cls{ieeeaccess \begin{Verbatim} \ttfamily \small -\begin{NiceTabular}{m{4.5cm}m{4.5cm}m{4.5cm}}[hvlines] +\begin{NiceTabular}{X[m]X[m]X[m]}[hvlines,cell-space-limits=3pt] \Block[~emphase#tikz={pattern=grid,pattern color=lightgray}@]{} {pattern = grid,\\ pattern color = lightgray} & \Block[~emphase#tikz={pattern = north west lines,pattern color=blue}@]{} @@ -4421,7 +4440,7 @@ L'extension \pkg{nicematrix} n'est pas compatible avec la classe \cls{ieeeaccess \begin{center} \ttfamily \small -\begin{NiceTabular}{m{4.5cm}m{4.5cm}m{4.5cm}}[hvlines] +\begin{NiceTabular}{X[m]X[m]X[m]}[hvlines,cell-space-limits=3pt] \Block[tikz={pattern=grid,pattern color=lightgray}]{} {pattern = grid,\\ pattern color = lightgray} & \Block[tikz={pattern = north west lines,pattern color=blue}]{} diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf index 12158c89540..026c149a495 100644 Binary files a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf and b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf differ diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx index f2ecb695bc3..2f7bfdc597a 100644 --- a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx +++ b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx @@ -15,8 +15,8 @@ % % \fi % \iffalse -\def\myfileversion{6.0} -\def\myfiledate{2021/08/10} +\def\myfileversion{6.1} +\def\myfiledate{2021/08/20} % % %<*batchfile> @@ -65,7 +65,7 @@ version 2005/12/01 or later. \usepackage{titlesec} \titlespacing*{\section}{0pt}{6.5ex plus 1ex minus .2ex}{4.3ex plus .2ex} \titlespacing*{\subsection}{0pt}{4.5ex plus 1ex minus .2ex}{2ex plus .2ex} -\usepackage{footnotehyper} +\usepackage[hyperfootnotes=false]{footnotehyper} \usepackage{varwidth} \def\LetterAt{@} \parindent 0pt @@ -165,7 +165,7 @@ version 2005/12/01 or later. % can upload the file |nicematrix.sty| in the repertory of your % project in order to take full advantage of the latest version de % \pkg{nicematrix}.\footnote{The latest version of the file -% \verb|nicematrix.sty| may be downloaded from the \textsc{svn} server of +% |nicematrix.sty| may be downloaded from the \textsc{svn} server of % TeXLive:\newline % \small % \url{https:www.tug.org/svn/texlive/trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty}} @@ -216,7 +216,7 @@ version 2005/12/01 or later. % \begin{tabular}{llll} % \{NiceTabular\} & \{NiceArray\} & \{NiceMatrix\} \\ % \{NiceTabular*\} & \{pNiceArray\} & \{pNiceMatrix\} \\ -% & \{bNiceArray\} & \{bNiceMatrix\} \\ +% \{NiceTabularX\} & \{bNiceArray\} & \{bNiceMatrix\} \\ % & \{BNiceArray\} & \{BNiceMatrix\} \\ % & \{vNiceArray\} & \{vNiceMatrix\} \\ % & \{VNiceArray\} & \{VNiceMatrix\} @@ -241,6 +241,12 @@ version 2005/12/01 or later. % \pkg{nicematrix}): |{matrix}|, |{pmatrix}|, etc. % % \medskip +% L'environnement |{NiceTabularX}| is similar to the environment |{tabularx}| +% from the eponymous package.\footnote{In fact, it's possible to use directly the +% |X| columns in the environnement |{NiceTabular}| (and the required +% width for the tabular is fixed by the key |width|): cf. p.~\pageref{X-columns}}. +% +% \medskip % \textbf{It's recommended to use primarily the classical environments and to use the % environments of \pkg{nicematrix} only when some feature provided by these % environments is used (this will save memory).} @@ -412,7 +418,7 @@ version 2005/12/01 or later. % \bigskip % It's also possible to use the key |baseline| to align a matrix on an % horizontal rule (drawn by |\hline|). In this aim, one should give the value -% |line-|\textsl{i} where \textsl{i} is the number of the row following the +% |line-|\textsl{i} where \textsl{i} is the number of the row \emph{following} the % horizontal rule. % % \smallskip @@ -422,7 +428,7 @@ version 2005/12/01 or later. % % \smallskip % \begin{BVerbatim}[baseline=c,boxwidth=9cm] -% $A=\begin{pNiceArray}{cc|cc}[baseline=line-3] +% $A=\begin{pNiceArray}{cc|cc}~emphase#[baseline=line-3]@ % \dfrac1A & \dfrac1B & 0 & 0 \\ % \dfrac1C & \dfrac1D & 0 & 0 \\ % \hline @@ -449,14 +455,14 @@ version 2005/12/01 or later. % % In the environments of \pkg{nicematrix}, it's possible to use the command % |\Block| in order to place an element in the center of a rectangle of merged -% cells of the array.\footnote{The spaces after a command \verb|\Block| are deleted.} +% cells of the array.\footnote{The spaces after a command |\Block| are deleted.} % % The command |\Block| must be used in the upper leftmost cell of the array with % two arguments. % % \begin{itemize} % \item The first argument is the size of the block with the syntax -% $i$\verb|-|$j$ where $i$ is the number of rows of the block and $j$ its number +% $i$|-|$j$ where $i$ is the number of rows of the block and $j$ its number % of columns. % % If this argument is empty, its default @@ -689,7 +695,7 @@ version 2005/12/01 or later. % \item It's possible do draw a frame around the cell with the key |draw| of the % command |\Block| and to fill the background with rounded corners with the keys % |fill| and |rounded-corners|.\footnote{If one simply wishes to color the -% background of a unique celle, there is no point using the command |\Block|: +% background of a unique cell, there is no point using the command |\Block|: % it's possible to use the command |\cellcolor| (when the key |colortbl-like| is % used).} % @@ -767,10 +773,10 @@ version 2005/12/01 or later. % \end{center} % % \medskip -% \colorbox{yellow!50}{\bfseries New 5.17}\enskip In order to have an horizontal -% positionning of the content of the block computed with the limits of the -% columns of the LaTeX array (and not with the contents of those columns), one -% may use the key |L|, |R| and |C| of the command |\Block|. +% In order to have an horizontal positionning of the content of the block +% computed with the limits of the columns of the LaTeX array (and not with the +% contents of those columns), one may use the key |L|, |R| and |C| of the +% command |\Block|. % % % \section{The rules} @@ -965,7 +971,7 @@ version 2005/12/01 or later. % \begin{itemize} % \item These blocks are: % \begin{itemize} -% \item the blocks created by the command |\Block|\footnote{And also the command \verb|\multicolumn| but +% \item the blocks created by the command |\Block|\footnote{And also the command |\multicolumn| but % it's recommended to use instead |\Block| in the environments of % \pkg{nicematrix}.} presented % p.~\pageref{Block}; @@ -1032,9 +1038,8 @@ version 2005/12/01 or later. % \end{center} % % \bigskip -% \colorbox{yellow!50}{\bfseries New 5.17}\enskip The key -% |hvlines-except-borders| is similar to the key |hvlines| but does not draw the -% rules on the horizontal and vertical borders of the array. +% The key |hvlines-except-borders| is similar to the key |hvlines| but does not +% draw the rules on the horizontal and vertical borders of the array. % % \subsubsection{The (empty) corners} % @@ -1306,7 +1311,7 @@ version 2005/12/01 or later. % New commands are available in that |\CodeBefore|: |\cellcolor|, % |\rectanglecolor|, |\rowcolor|, |\columncolor|, |\rowcolors|, % |\rowlistcolors|, |\chessboardcolors| and |arraycolor|.\footnote{Remark that, -% in the \verb|\CodeBefore|, PGF/Tikz nodes of the form ``\verb+(i-|j)+'' are +% in the |\CodeBefore|, PGF/Tikz nodes of the form ``\verb+(i-|j)+'' are % also available to indicate the position to the potential rules: % cf.~p.~\pageref{nodes-i}.} % \label{code-before} @@ -1768,23 +1773,34 @@ version 2005/12/01 or later. % % \medskip % That command also takes in as optional argument (between square brackets) -% a list of key-value pairs. The available keys are |cell-space-top-limit|, -% |cell-space-bottom-limit| and |cell-space-limits| with the same meaning that -% the corresponding global keys (cf. p.~\pageref{cell-space}). -% +% a list of key-value pairs. +% \begin{itemize} +% \item The keys |cell-space-top-limit|, |cell-space-bottom-limit| and +% |cell-space-limits| are available with the same meaning that the corresponding +% global keys (cf. p.~\pageref{cell-space}). +% \item \colorbox{yellow!50}{\bfseries New 6.1}\enskip The key |color| sets the +% color of the text.\footnote{The key |color| uses the command +% |\color| but inserts also an instruction |\leavevmode| before. This +% instruction prevents a extra vertical space in the cells which belong to +% columns of type |p|, |b|, |m| and |X| (which start in +% vertical mode).} +% \end{itemize} +% % \medskip % \begin{BVerbatim}[boxwidth=11cm,baseline=c] -% \begin{NiceTabular}{cccc}[hlines,colortbl-like] +% \begin{NiceTabular}{cccc}[colortbl-like] +% \hline % ~emphase#\RowStyle[cell-space-limits=3pt]{\rotate}@ % first & second & third & fourth \\ -% \rowcolor{blue!50}~emphase#\RowStyle{\color{white}\sffamily}@ +% \rowcolor{blue!50}~emphase#\RowStyle[color=white]{\sffamily}@ % 1 & 2 & 3 & 4 \\ % \end{NiceTabular} % \end{BVerbatim} -% \begin{NiceTabular}{cccc}[hlines,colortbl-like] +% \begin{NiceTabular}{cccc}[colortbl-like] +% \hline % \RowStyle[cell-space-limits=3pt]{\rotate} % first & second & third & fourth \\ -% \rowcolor{blue!50}\RowStyle{\color{white}\sffamily} +% \rowcolor{blue!50}\RowStyle[color=white]{\sffamily} % 1 & 2 & 3 & 4 \\ % \end{NiceTabular} % @@ -1926,6 +1942,7 @@ version 2005/12/01 or later. % % \subsection{The columns X} % +% \label{X-columns} % \colorbox{yellow!50}{\textbf{New 6.0}} % % The environment |{NiceTabular}| provides |X| columns similar to those provided @@ -2247,7 +2264,7 @@ version 2005/12/01 or later. % % % Consider the following matrix composed classicaly with the environment -% \verb|{pmatrix}| of \pkg{amsmath}.\par\nobreak +% |{pmatrix}| of \pkg{amsmath}.\par\nobreak % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=10cm] @@ -2263,7 +2280,7 @@ version 2005/12/01 or later. % % % \bigskip -% If we add \verb|\ldots| instructions in the second row, the geometry of the +% If we add |\ldots| instructions in the second row, the geometry of the % matrix is modified.\par\nobreak % % \medskip @@ -2279,8 +2296,8 @@ version 2005/12/01 or later. % \end{pmatrix}$ % % \bigskip -% By default, with \pkg{nicematrix}, if we replace \verb|{pmatrix}| by -% \verb|{pNiceMatrix}| and \verb|\ldots| by \verb|\Ldots|, the geometry of the matrix is not +% By default, with \pkg{nicematrix}, if we replace |{pmatrix}| by +% |{pNiceMatrix}| and |\ldots| by |\Ldots|, the geometry of the matrix is not % changed.\par\nobreak % % \medskip @@ -2298,7 +2315,7 @@ version 2005/12/01 or later. % \bigskip % However, one may prefer the geometry of the first matrix $A$ and would like to % have such a geometry with a dotted line in the second row. It's possible by -% using the option \verb|nullify-dots| (and only one instruction \verb|\Ldots| is +% using the option |nullify-dots| (and only one instruction |\Ldots| is % necessary).\par\nobreak % % \medskip @@ -2369,7 +2386,7 @@ version 2005/12/01 or later. % \medskip % Remark: Unlike the command |\hdotsfor| of \pkg{amsmath}, the command % |\Hdotsfor| may be used even when the package \pkg{colortbl}\footnote{We -% recall that when \pkg{xcolor} is loaded with the option \verb|table|, the +% recall that when \pkg{xcolor} is loaded with the option |table|, the % package \pkg{colortbl} is loaded.} is loaded (but you might have problem if % you use |\rowcolor| on the same row as |\Hdotsfor|). % @@ -2591,8 +2608,8 @@ version 2005/12/01 or later. % regarding the rules (the rules specified by the specifier \verb+|+ in the % preamble, by the command |\Hline| and by the keys |hlines|, |vlines|, % |hvlines| and |hvlines-except-borders| are not drawn within the -% blocks).\footnote{On the other side, the command \verb|\line| in the -% \verb|\CodeAfter| (cf.~p.~\pageref{line-in-code-after}) does \emph{not} create +% blocks).\footnote{On the other side, the command |\line| in the +% |\CodeAfter| (cf.~p.~\pageref{line-in-code-after}) does \emph{not} create % block.} % % \medskip @@ -2877,7 +2894,7 @@ version 2005/12/01 or later. % % \bigskip % It's also possible to specify some delimiters\footnote{Those delimiters are -% \verb|(|, \verb|[|, |\{| and the closing ones. Of course, it's also +% |(|, |[|, |\{| and the closing ones. Of course, it's also % possible to put \verb+|+ and \verb+||+ in the preamble of the environement.} % by placing them in the preamble of the environment (for the environments with % a preamble: |{NiceArray}|, |{pNiceArray}|, etc.). This syntax is inspired by @@ -3294,7 +3311,7 @@ version 2005/12/01 or later. % rotation of 90° in the direct sens. % % In the following command, we use that command in the -% |code-for-first-row|.\footnote{It can also be used in \verb|RowStyle| +% |code-for-first-row|.\footnote{It can also be used in |\RowStyle| % (cf.~p.~\pageref{RowStyle}.} % %\bigskip @@ -3393,9 +3410,9 @@ version 2005/12/01 or later. % \medskip % In fact, the option |small| corresponds to the following tuning: % \begin{itemize} -% \item the cells of the array are composed with \verb|\scriptstyle|; -% \item \verb|\arraystretch| is set to $0.47$; -% \item \verb|\arraycolsep| is set to $1.45$~pt; +% \item the cells of the array are composed with |\scriptstyle|; +% \item |\arraystretch| is set to $0.47$; +% \item |\arraycolsep| is set to $1.45$~pt; % \item the characteristics of the dotted lines are also modified. % \end{itemize} % @@ -4336,7 +4353,7 @@ version 2005/12/01 or later. % % \begin{Verbatim} % \ttfamily \small -% \begin{NiceTabular}{m{4.5cm}m{4.5cm}m{4.5cm}}[hvlines] +% \begin{NiceTabular}{X[m]X[m]X[m]}[hvlines,cell-space-limits=3pt] % \Block[~emphase#tikz={pattern=grid,pattern color=lightgray}@]{} % {pattern = grid,\\ pattern color = lightgray} % & \Block[~emphase#tikz={pattern = north west lines,pattern color=blue}@]{} @@ -4352,7 +4369,7 @@ version 2005/12/01 or later. % % \begin{center} % \ttfamily \small -% \begin{NiceTabular}{m{4.5cm}m{4.5cm}m{4.5cm}}[hvlines] +% \begin{NiceTabular}{X[m]X[m]X[m]}[hvlines,cell-space-limits=3pt] % \Block[tikz={pattern=grid,pattern color=lightgray}]{} % {pattern = grid,\\ pattern color = lightgray} % & \Block[tikz={pattern = north west lines,pattern color=blue}]{} @@ -5528,52 +5545,18 @@ version 2005/12/01 or later. \bool_if:nTF { ! \c_@@_siunitx_loaded_bool } { \cs_set_eq:NN \@@_renew_NC@rewrite@S: \prg_do_nothing: } { -% \end{macrocode} -% For version of \pkg{siunitx} at least equal to 3.0, the adaptation is different -% from previous ones. We test the version of \pkg{siunitx} by the existence of the -% control sequence |\siunitx_cell_begin:w|. -% \begin{macrocode} - \cs_if_exist:NTF \siunitx_cell_begin:w + \cs_new_protected:Npn \@@_renew_NC@rewrite@S: { - \cs_new_protected:Npn \@@_renew_NC@rewrite@S: + \renewcommand*{\NC@rewrite@S}[1][] { - \renewcommand*{\NC@rewrite@S}[1][] - { - \@temptokena \exp_after:wN - { - \tex_the:D \@temptokena - > { - \@@_Cell: - \keys_set:nn { siunitx } { ##1 } - \siunitx_cell_begin:w - } -% \end{macrocode} -% |\@@_true_c:| will be replaced statically by |c| at the end of the construction -% of the preamble. -% \begin{macrocode} - \@@_true_c: - < { \siunitx_cell_end: \@@_end_Cell: } - } - \NC@find - } +% \end{macrocode} +% |\@temptokena| is a toks (not supported by \pkg{expl3}). +% \begin{macrocode} + \@temptokena \exp_after:wN + { \tex_the:D \@temptokena \@@_S: [ ##1 ] } + \NC@find } - } - { - \cs_new_protected:Npn \@@_renew_NC@rewrite@S: - { - \renewcommand*{\NC@rewrite@S}[1][] - { - \@temptokena \exp_after:wN - { - \tex_the:D \@temptokena - > { \@@_Cell: \c_@@_table_collect_begin_tl S {##1} } - \@@_true_c: - < { \c_@@_table_print_tl \@@_end_Cell: } - } - \NC@find - } - } - } + } } } % \end{macrocode} @@ -6002,10 +5985,11 @@ version 2005/12/01 or later. % \begin{macrocode} \seq_new:N \g_@@_blocks_seq % \end{macrocode} -% We also manage a sequence of the \emph{positions} of the blocks. Of course, -% it's redundant with the previous sequence, but it's for efficiency. In that +% We also manage a sequence of the \emph{positions} of the blocks. In that % sequence, each block is represented by only the four first components: -% |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}|. +% |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}|. A +% block with the key |hvlines| won't appear in that sequence (otherwise, the +% lines in that block would not be drawn!). % \begin{macrocode} \seq_new:N \g_@@_pos_of_blocks_seq % \end{macrocode} @@ -6038,9 +6022,9 @@ version 2005/12/01 or later. % \end{macrocode} % % \medskip -% If the user has used the key |corners| (or the key |hvlines-except-corners|), -% all the cells which are in an (empty) corner will be stored in the following -% sequence. +% If the user has used the key |corners| (or the key |hvlines-except-corners|, +% even though that key is deprecated), all the cells which are in an (empty) +% corner will be stored in the following sequence. % \begin{macrocode} \seq_new:N \l_@@_corners_cells_seq % \end{macrocode} @@ -7293,13 +7277,13 @@ version 2005/12/01 or later. % \bigskip % \subsection*{Important code used by \{NiceArrayWithDelims\} } % -% The pseudo-environment |\@@_Cell:|--|\@@_end_Cell:| will be used to format the +% The pseudo-environment |\@@_cell_begin:w|--|\@@_cell_end:| will be used to format the % cells of the array. In the code, the affectations are global because this % pseudo-environment will be used in the cells of a |\halign| (via an % environment |{array}|). % % \begin{macrocode} -\cs_new_protected:Npn \@@_Cell: +\cs_new_protected:Npn \@@_cell_begin:w { % \end{macrocode} % The token list |\g_@@_post_action_cell_tl| will be set during the @@ -7328,7 +7312,7 @@ version 2005/12/01 or later. % \end{macrocode} % The content of the cell is composed in the box |\l_@@_cell_box| because we want % to compute some dimensions of the box. The |\hbox_set_end:| corresponding to -% this |\hbox_set:Nw| will be in the |\@@_end_Cell:| (and the potential +% this |\hbox_set:Nw| will be in the |\@@_cell_end:| (and the potential % |\c_math_toggle_token| also). % \begin{macrocode} \hbox_set:Nw \l_@@_cell_box @@ -7462,7 +7446,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} -\cs_new_protected:Npn \@@_end_Cell: +\cs_new_protected:Npn \@@_cell_end: { \@@_math_toggle_token: \hbox_set_end: @@ -7644,9 +7628,9 @@ version 2005/12/01 or later. % \smallskip % \begin{scope} % \color{gray} -% \verb|\@@_draw_Cdots:nnn {2}{2}{}| +% |\@@_draw_Cdots:nnn {2}{2}{}| % -% \verb|\@@_draw_Cdots:nnn {3}{2}{color=red}| +% |\@@_draw_Cdots:nnn {3}{2}{color=red}| % \end{scope} % % @@ -7858,6 +7842,10 @@ version 2005/12/01 or later. \cs_new_protected:Npn \@@_pre_array_ii: { % \end{macrocode} +% The number of letters |X| in the preamble of the array. +% \begin{macrocode} + \int_gzero:N \g_@@_total_X_weight_int +% \end{macrocode} % If \pkg{booktabs} is loaded, we have to patch the macro |\@BTnormal| which is % a macro of \pkg{booktabs}. The macro |\@BTnormal| draws an horizontal rule but % it occurs after a vertical skip done by a low level TeX command. When this @@ -8028,7 +8016,7 @@ version 2005/12/01 or later. % The counter |\c@jCol| will be used to count the columns of the array. % Since we want to know the total number of columns of the matrix, we also % create a counter |\g_@@_col_total_int|. These counters are updated in the -% command |\@@_Cell:| executed at the beginning of each cell. +% command |\@@_cell_begin:w| executed at the beginning of each cell. % \begin{macrocode} \int_gzero_new:N \g_@@_col_total_int % \end{macrocode} @@ -8104,7 +8092,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% If there is a exterior row, we patch a command used in |\@@_Cell:| in order to +% If there is a exterior row, we patch a command used in |\@@_cell_begin:w| in order to % keep track of some dimensions needed to the construction of that ``last row''. % \begin{macrocode} \int_compare:nNnT \l_@@_last_row_int > { -2 } @@ -8252,6 +8240,13 @@ version 2005/12/01 or later. cell-space-top-limit = #1 , cell-space-bottom-limit = #1 , } , + color .code:n = + { + \leavevmode \color { #1 } + \tl_gput_right:Nn \g_@@_row_style_tl + { \leavevmode \color { #1 } } + } , + color .value_required:n = true , unknown .code:n = \@@_error:n { Unknown~key~for~RowStyle } } % \end{macrocode} @@ -8276,7 +8271,7 @@ version 2005/12/01 or later. { % \end{macrocode} % First, we give values to the LaTeX counters |iRow| and |jCol|. We remind that, -% in the |code-before| (and in the |\CodeAfter|) they represent the numbers of +% in the |\CodeBefore| (and in the |\CodeAfter|) they represent the numbers of % rows and columns of the array (without the potential last row and last % column). The value of |\g_@@_row_total_int| is the number of the last row % (with potentially a last exterior row) and |\g_@@_col_total_int| is the number @@ -8550,8 +8545,8 @@ version 2005/12/01 or later. % % The sequence |\g_@@_blocks_seq| will contain the carateristics of the blocks % (specified by |\Block|) of the array. The sequence |\g_@@_pos_of_blocks_seq| -% will contain only the position of the blocks. Of course, this is redundant but -% it's for efficiency. +% will contain only the position of the blocks (except the blocks with the key +% |hvlines|). % \begin{macrocode} \seq_gclear:N \g_@@_blocks_seq \seq_gclear:N \g_@@_pos_of_blocks_seq @@ -8605,15 +8600,16 @@ version 2005/12/01 or later. % \begin{macrocode} \tl_if_empty:NF \l_@@_rules_color_tl { \exp_after:wN \@@_set_CT@arc@: \l_@@_rules_color_tl \q_stop } -% \bigskip % \end{macrocode} +% +% \bigskip % The argument |#6| is the last argument of |{NiceArrayWithDelims}|. With that % argument of type ``|t \CodeBefore|'', we test whether there is the keyword -% |\CodeBefore| at the beginning of the environment. If that keyword is present, -% we have now to extract all the content between that keyword |\CodeBefore| and -% the (other) keyword |\Body|. It's the job that will do the command -% |\@@_pre_array_i:w|. After that job, the command |\@@_pre_array_i:w| will go -% on with |\@@_pre_array:|. +% |\CodeBefore| at the beginning of the body of the environment. If that keyword +% is present, we have now to extract all the content between that keyword +% |\CodeBefore| and the (other) keyword |\Body|. It's the job that will do the +% command |\@@_pre_array_i:w|. After that job, the command |\@@_pre_array_i:w| +% will go on with |\@@_pre_array:|. % \begin{macrocode} \IfBooleanTF { #6 } \@@_pre_array_i:w \@@_pre_array: } @@ -8644,25 +8640,34 @@ version 2005/12/01 or later. % \bigskip % Now, if there is at least one |X|-column in the environment, we compute the % width that those columns will have (in the next compilation). In fact, -% |l_@@_X_columns_dim| will the the width of a column of weight $1$. For a +% |l_@@_X_columns_dim| will be the width of a column of weight $1$. For a % |X|-column of weight~$n$, the width will be |l_@@_X_columns_dim| multiplied % by~$n$. % \begin{macrocode} \int_compare:nNnT \g_@@_total_X_weight_int > 0 { - \bool_if:NTF \l_@@_X_columns_aux_bool - { \dim_set_eq:NN \l_tmpa_dim \l_@@_X_columns_dim } - { - \dim_set:Nn \l_tmpa_dim - { - ( \l_@@_width_dim - \box_wd:N \l_@@_the_array_box ) - / \int_use:N \g_@@_total_X_weight_int - } - } \tl_gput_right:Nx \g_@@_aux_tl { \bool_set_true:N \l_@@_X_columns_aux_bool - \dim_set:Nn \l_@@_X_columns_dim { \dim_use:N \l_tmpa_dim } + \dim_set:Nn \l_@@_X_columns_dim + { + \dim_compare:nNnTF + { + \dim_abs:n + { \l_@@_width_dim - \box_wd:N \l_@@_the_array_box } + } + < + { 0.001 pt } + { \dim_use:N \l_@@_X_columns_dim } + { + \dim_eval:n + { + ( \l_@@_width_dim - \box_wd:N \l_@@_the_array_box ) + / \int_use:N \g_@@_total_X_weight_int + + \l_@@_X_columns_dim + } + } + } } } % \end{macrocode} @@ -8959,10 +8964,6 @@ version 2005/12/01 or later. } } % \end{macrocode} -% The number of letters |X| in the preamble of the array. -% \begin{macrocode} - \int_gzero:N \g_@@_total_X_weight_int -% \end{macrocode} % The sequence |\g_@@_cols_vlsim_seq| will contain the numbers of the columns % where you will to have to draw vertical lines in the potential sub-matrices % (hence the name |vlism|). @@ -9075,7 +9076,7 @@ version 2005/12/01 or later. m { \@@_patch_preamble_iv:n #1 } \@@_w: { \@@_patch_preamble_v:nnnn { } #1 } \@@_W: { \@@_patch_preamble_v:nnnn { \cs_set_eq:NN \hss \hfil } #1 } - \@@_true_c: { \@@_patch_preamble_vi:n #1 } + \@@_S: { \@@_patch_preamble_vi:n } ( { \@@_patch_preamble_vii:nn #1 } [ { \@@_patch_preamble_vii:nn #1 } \{ { \@@_patch_preamble_vii:nn #1 } @@ -9119,9 +9120,9 @@ version 2005/12/01 or later. { \tl_gput_right:Nn \g_@@_preamble_tl { - > { \@@_Cell: \str_set:Nn \l_@@_hpos_cell_str { #1 } } + > { \@@_cell_begin:w \str_set:Nn \l_@@_hpos_cell_str { #1 } } #1 - < \@@_end_Cell: + < \@@_cell_end: } % \end{macrocode} % @@ -9177,10 +9178,12 @@ version 2005/12/01 or later. } } \tl_gput_right:Nx \g_@@_internal_code_after_tl - { \@@_vline:nn { \@@_succ:n \c@jCol } { \int_use:N \l_tmpa_int } } + { + \@@_vline:nnnn + { \@@_succ:n \c@jCol } { \int_use:N \l_tmpa_int } { 1 } { } + } \int_zero:N \l_tmpa_int - \str_if_eq:nnT { #1 } { \q_stop } - { \bool_gset_true:N \g_tmpb_bool } + \str_if_eq:nnT { #1 } { \q_stop } { \bool_gset_true:N \g_tmpb_bool } \@@_patch_preamble:n #1 } } @@ -9204,13 +9207,15 @@ version 2005/12/01 or later. c .value_forbidden:n = true , l .code:n = \str_set:Nn \l_@@_hpos_col_str { l } , l .value_forbidden:n = true , + si .code:n = \str_set:Nn \l_@@_hpos_col_str { si } , + si .value_forbidden:n = true , p .code:n = \str_set:Nn \l_@@_vpos_col_str { p } , p .value_forbidden:n = true , t .meta:n = p , m .code:n = \str_set:Nn \l_@@_vpos_col_str { m } , m .value_forbidden:n = true , b .code:n = \str_set:Nn \l_@@_vpos_col_str { b } , - b .value_forbidden:n = true + b .value_forbidden:n = true , } % \end{macrocode} % @@ -9269,19 +9274,22 @@ version 2005/12/01 or later. { \use:x { - \@@_patch_preamble_iv_v:nnnn + \@@_patch_preamble_iv_v:nnnnnn { \str_if_eq:VnTF \l_@@_vpos_col_str { p } { t } { b } } { \dim_eval:n { #1 } } { % \end{macrocode} % The parameter |\l_@@_hpos_col_str| (as |\l_@@_vpos_col_str|) exists only -% during the contruction of the preamble. During the composition of the array +% during the construction of the preamble. During the composition of the array % itself, you will have, in each cell, the parameter |\l_@@_hpos_cell_str| which -% will provide +% will provide the horizontal alignment of the column to which belongs the cell. % \begin{macrocode} \str_if_eq:VnTF \l_@@_hpos_col_str j { \str_set:Nn \exp_not:N \l_@@_hpos_cell_str { c } } - { \str_set:Nn \exp_not:N \l_@@_hpos_cell_str \l_@@_hpos_col_str } + { + \str_set:Nn \exp_not:N \l_@@_hpos_cell_str + { \l_@@_hpos_col_str } + } \str_case:Vn \l_@@_hpos_col_str { c { \exp_not:N \centering } @@ -9290,6 +9298,8 @@ version 2005/12/01 or later. } } { \str_if_eq:VnT \l_@@_vpos_col_str { m } \@@_center_cell_box: } + { \str_if_eq:VnT \l_@@_hpos_col_str { si } \siunitx_cell_begin:w } + { \str_if_eq:VnT \l_@@_hpos_col_str { si } \siunitx_cell_end: } } % \end{macrocode} % @@ -9313,8 +9323,12 @@ version 2005/12/01 or later. % % |#4| is an extra-code which contains |\l_@@_center_cell_box| (when the column % is a |m| column) or nothing (in the other cases). +% +% |#5| is a code put just before the |c|. +% +% |#6| is a code put just after the |c|. % \begin{macrocode} -\cs_new_protected:Npn \@@_patch_preamble_iv_v:nnnn #1 #2 #3 #4 +\cs_new_protected:Npn \@@_patch_preamble_iv_v:nnnnnn #1 #2 #3 #4 #5 #6 { \tl_gput_right:Nn \g_@@_preamble_tl { @@ -9325,7 +9339,7 @@ version 2005/12/01 or later. % mono-column blocks. % \begin{macrocode} \dim_set:Nn \l_@@_col_width_dim { #2 } - \@@_Cell: + \@@_cell_begin:w \begin { minipage } [ #1 ] { #2 } % \end{macrocode} % The following lines have been taken from |array.sty|. @@ -9342,14 +9356,14 @@ version 2005/12/01 or later. #3 % \end{macrocode} % The following code is to allow something like |\centering| in |\RowStyle|. -% However, there is extra vertical space if |\color{...}| is used in -% |\RowStyle| (we should try to add a key |color| to the command |\RowStyle|. % \begin{macrocode} \g_@@_row_style_tl \arraybackslash + #5 } c < { + #6 % \end{macrocode} % The following line has been taken from |array.sty|. % \begin{macrocode} @@ -9360,7 +9374,7 @@ version 2005/12/01 or later. % |\@@_center_cell_box:| (see just below). % \begin{macrocode} #4 - \@@_end_Cell: + \@@_cell_end: } } } @@ -9417,12 +9431,12 @@ version 2005/12/01 or later. % \begin{macrocode} \dim_set:Nn \l_@@_col_width_dim { #4 } \hbox_set:Nw \l_@@_cell_box - \@@_Cell: + \@@_cell_begin:w \str_set:Nn \l_@@_hpos_cell_str { #3 } } c < { - \@@_end_Cell: + \@@_cell_end: #1 \hbox_set_end: \bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box: @@ -9439,17 +9453,65 @@ version 2005/12/01 or later. % \end{macrocode} % % \medskip -% For |\@@_true_c:| which will appear in our redefinition of the columns of type -% |S| (of \pkg{siunitx}). +% For |\@@_S:|. If the user has used |S[...]|, |S| has been replaced by |\@@_S:| +% during the first expansion of the preamble (done with the tools of standard +% LaTeX and \pkg{array}). % \begin{macrocode} \cs_new_protected:Npn \@@_patch_preamble_vi:n #1 { - \tl_gput_right:Nn \g_@@_preamble_tl { c } + \str_if_eq:nnTF { #1 } { [ } + { \@@_patch_preamble_vi_i:w [ } + { \@@_patch_preamble_vi_i:w [ ] { #1 } } + } +% \end{macrocode} +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_patch_preamble_vi_i:w [ #1 ] + { \@@_patch_preamble_vi_ii:n { #1 } } +% \end{macrocode} +% +% For version of \pkg{siunitx} at least equal to 3.0, the adaptation is different +% from previous ones. We test the version of \pkg{siunitx} by the existence of the +% control sequence |\siunitx_cell_begin:w|. When we will decide that only the +% previous posterior to 3.0 are supported by \pkg{nicematrix}, we will delete +% the second definition of |\@@_patch_preamble_vi_ii:n|. +% \begin{macrocode} +\AtBeginDocument + { + \cs_if_exist:NTF \siunitx_cell_begin:w + { + \cs_new_protected:Npn \@@_patch_preamble_vi_ii:n #1 + { + \tl_gput_right:Nn \g_@@_preamble_tl + { + > { + \@@_cell_begin:w + \keys_set:nn { siunitx } { #1 } + \siunitx_cell_begin:w + } + c + < { \siunitx_cell_end: \@@_cell_end: } + } % \end{macrocode} % We increment the counter of columns and then we test for the presence of a |<|. % \begin{macrocode} - \int_gincr:N \c@jCol - \@@_patch_preamble_x:n + \int_gincr:N \c@jCol + \@@_patch_preamble_x:n + } + } + { + \cs_new_protected:Npn \@@_patch_preamble_vi_ii:n #1 + { + \tl_gput_right:Nn \g_@@_preamble_tl + { + > { \@@_cell_begin:w \c_@@_table_collect_begin_tl S { #1 } } + c + < { \c_@@_table_print_tl \@@_cell_end: } + } + \int_gincr:N \c@jCol + \@@_patch_preamble_x:n + } + } } % \end{macrocode} % @@ -9585,7 +9647,7 @@ version 2005/12/01 or later. % % \medskip % The following set of keys is for the specifier |X| in the preamble of the -% array. Such specifier may have as key all the keys of +% array. Such specifier may have as keys all the keys of % |{ WithArrows / p-column }| but also a key as 1, 2, 3, etc. The following set % of keys will be used to retrieve that value (in the counter |\l_@@_weight_int|). % \begin{macrocode} @@ -9617,7 +9679,7 @@ version 2005/12/01 or later. % initial value is $1$). The user may specify a different value (such as $2$, % $3$, etc.) by putting that value in the optional argument of the specifier. % The weights of the |X| columns are used in the computation of the actual width -% of those columns. +% of those columns as in \pkg{tabu} of \pkg{tabularray}. % \begin{macrocode} \int_zero_new:N \l_@@_weight_int \int_set:Nn \l_@@_weight_int { 1 } @@ -9626,9 +9688,9 @@ version 2005/12/01 or later. \int_gadd:Nn \g_@@_total_X_weight_int \l_@@_weight_int % \end{macrocode} % -% We test whether we know the width of the |X|-columns by reading the |aux| file. +% We test whether we know the width of the |X|-columns by reading the |aux| file % (after the first compilation, the width of the |X|-columns is computed and -% written on the |aux| file). +% written in the |aux| file). % \begin{macrocode} \bool_if:NTF \l_@@_X_columns_aux_bool { \@@_patch_preamble_iv_iv:n { \l_@@_weight_int \l_@@_X_columns_dim } } @@ -9636,7 +9698,7 @@ version 2005/12/01 or later. \tl_gput_right:Nn \g_@@_preamble_tl { > { - \@@_Cell: + \@@_cell_begin:w \bool_set_true:N \l_@@_X_column_bool % \end{macrocode} % The following code will nullify the box of the cell. @@ -9652,7 +9714,7 @@ version 2005/12/01 or later. c < { \end { minipage } - \@@_end_Cell: + \@@_cell_end: } } \int_gincr:N \c@jCol @@ -9832,9 +9894,9 @@ version 2005/12/01 or later. { \tl_gput_right:Nn \g_@@_preamble_tl { - > { \@@_Cell: \str_set:Nn \l_@@_hpos_cell_str { #1 } } + > { \@@_cell_begin:w \str_set:Nn \l_@@_hpos_cell_str { #1 } } #1 - < \@@_end_Cell: + < \@@_cell_end: } % \end{macrocode} % @@ -9873,7 +9935,7 @@ version 2005/12/01 or later. \tl_gput_right:Nn \g_@@_preamble_tl { > { - \@@_Cell: + \@@_cell_begin:w \begin { minipage } [ #1 ] { \dim_eval:n { #3 } } \mode_leave_vertical: \arraybackslash @@ -9883,7 +9945,7 @@ version 2005/12/01 or later. < { \vrule height 0 pt depth \box_dp:N \@arstrutbox width 0 pt \end { minipage } - \@@_end_Cell: + \@@_cell_end: } } % \end{macrocode} @@ -9902,12 +9964,12 @@ version 2005/12/01 or later. { > { \hbox_set:Nw \l_@@_cell_box - \@@_Cell: + \@@_cell_begin:w \str_set:Nn \l_@@_hpos_cell_str { #3 } } c < { - \@@_end_Cell: + \@@_cell_end: #1 \hbox_set_end: \bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box: @@ -10895,7 +10957,7 @@ version 2005/12/01 or later. \c@MaxMatrixCols { \@@_pred:n \l_@@_last_col_int } } - { > \@@_Cell: #2 < \@@_end_Cell: } + { > \@@_cell_begin:w #2 < \@@_cell_end: } } } % \end{macrocode} @@ -11136,16 +11198,16 @@ version 2005/12/01 or later. % etc.) and no corners. In that case, we switch to a shortcut version of % |\@@_vline_i:nn| and |\@@_hline:nn|. % \begin{macrocode} - \bool_lazy_all:nT - { - { \seq_if_empty_p:N \g_@@_pos_of_blocks_seq } - { \seq_if_empty_p:N \g_@@_pos_of_xdots_seq } - { \seq_if_empty_p:N \l_@@_corners_cells_seq } - } - { - \cs_set_eq:NN \@@_vline_i:nn \@@_vline_i_complete:nn - \cs_set_eq:NN \@@_hline_i:nn \@@_hline_i_complete:nn - } + % \bool_lazy_all:nT + % { + % { \seq_if_empty_p:N \g_@@_pos_of_blocks_seq } + % { \seq_if_empty_p:N \g_@@_pos_of_xdots_seq } + % { \seq_if_empty_p:N \l_@@_corners_cells_seq } + % } + % { + % \cs_set_eq:NN \@@_vline_i:nn \@@_vline_i_complete:nn + % \cs_set_eq:NN \@@_hline_i:nn \@@_hline_i_complete:nn + % } \tl_if_empty:NF \l_@@_hlines_clist \@@_draw_hlines: \tl_if_empty:NF \l_@@_vlines_clist \@@_draw_vlines: % \end{macrocode} @@ -13779,7 +13841,7 @@ version 2005/12/01 or later. } } % \end{macrocode} -% This definition may seem complicated by we must remind that the number of row +% This definition may seem complicated but we must remind that the number of row % |\c@iRow| is incremented in the first cell of the row, \emph{after} a % potential vertical rule on the left side of the first cell. % @@ -13801,26 +13863,29 @@ 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+|+. +% |#2| is the number of consecutive occurrences of \verb+|+. |#3| and |#4| are +% 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. % \begin{macrocode} -\cs_new_protected:Npn \@@_vline:nn #1 #2 - { +\cs_new_protected:Npn \@@_vline:nnnn #1 #2 #3 #4 + { % \end{macrocode} -% The following test is for the case where the user don't use all the columns +% 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:nn { #1 } { #2 } + \@@_vline_i:nnnn { #1 } { #2 } { #3 } { #4 } \endpgfpicture } } % \end{macrocode} % % \begin{macrocode} -\cs_new_protected:Npn \@@_vline_i:nn #1 #2 +\cs_new_protected:Npn \@@_vline_i:nnnn #1 #2 #3 #4 { % \end{macrocode} % |\l_tmpa_tl| is the number of row and |\l_tmpb_tl| the number of column. When @@ -13829,7 +13894,10 @@ version 2005/12/01 or later. % \begin{macrocode} \tl_set:Nx \l_tmpb_tl { #1 } \tl_clear_new:N \l_tmpc_tl - \int_step_variable:nNn \c@iRow \l_tmpa_tl + \int_step_variable:nnNn + { #3 } + { \tl_if_blank:nTF { #4 } { \int_use:N \c@iRow } { #4 } } + \l_tmpa_tl { % \end{macrocode} % The boolean |\g_tmpa_bool| indicates whether the small vertical rule will be @@ -13845,8 +13913,7 @@ version 2005/12/01 or later. { \@@_test_vline_in_block:nnnn ##1 } \seq_map_inline:Nn \g_@@_pos_of_stroken_blocks_seq { \@@_test_vline_in_stroken_block:nnnn ##1 } - \clist_if_empty:NF \l_@@_corners_clist - \@@_test_in_corner_v: + \clist_if_empty:NF \l_@@_corners_clist \@@_test_in_corner_v: \bool_if:NTF \g_tmpa_bool { \tl_if_empty:NT \l_tmpc_tl @@ -13873,7 +13940,7 @@ version 2005/12/01 or later. { #1 } { #2 } \l_tmpc_tl - { \int_use:N \c@iRow } + { \tl_if_blank:nTF { #4 } { \int_use:N \c@iRow } { #4 } } \tl_clear:N \l_tmpc_tl } } @@ -13988,7 +14055,7 @@ version 2005/12/01 or later. { \tl_if_eq:NnF \l_@@_vlines_clist { all } { \clist_if_in:NnT \l_@@_vlines_clist { ##1 } } - { \@@_vline:nn { ##1 } 1 } + { \@@_vline:nnnn { ##1 } 1 1 { } } } } % \end{macrocode} @@ -14000,18 +14067,20 @@ 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 row |#1|. |#2| is the number of consecutive -% occurrences of |\Hline|. +% 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. % \begin{macrocode} -\cs_new_protected:Npn \@@_hline:nn #1 #2 +\cs_new_protected:Npn \@@_hline:nnnn #1 #2 #3 #4 { \pgfpicture - \@@_hline_i:nn { #1 } { #2 } + \@@_hline_i:nnnn { #1 } { #2 } { #3 } { #4 } \endpgfpicture } % \end{macrocode} % % \begin{macrocode} -\cs_new_protected:Npn \@@_hline_i:nn #1 #2 +\cs_new_protected:Npn \@@_hline_i:nnnn #1 #2 #3 #4 { % \end{macrocode} % |\l_tmpa_tl| is the number of row and |\l_tmpb_tl| the number of column. When @@ -14020,7 +14089,10 @@ version 2005/12/01 or later. % \begin{macrocode} \tl_set:Nn \l_tmpa_tl { #1 } \tl_clear_new:N \l_tmpc_tl - \int_step_variable:nNn \c@jCol \l_tmpb_tl + \int_step_variable:nnNn + { #3 } + { \tl_if_blank:nTF { #4 } { \int_use:N \c@jCol } { #4 } } + \l_tmpb_tl { % \end{macrocode} % The boolean |\g_tmpa_bool| indicates whether the small horizontal rule will be @@ -14063,7 +14135,7 @@ version 2005/12/01 or later. { #1 } { #2 } \l_tmpc_tl - { \int_use:N \c@jCol } + { \tl_if_blank:nTF { #4 } { \int_use:N \c@jCol } { #4 } } \tl_clear:N \l_tmpc_tl } } @@ -14172,7 +14244,7 @@ version 2005/12/01 or later. { \tl_if_eq:NnF \l_@@_hlines_clist { all } { \clist_if_in:NnT \l_@@_hlines_clist { ##1 } } - { \@@_hline:nn { ##1 } 1 } + { \@@_hline:nnnn { ##1 } 1 1 { } } } } % \end{macrocode} @@ -14209,7 +14281,7 @@ version 2005/12/01 or later. + \doublerulesep * ( \int_max:nn 0 { #1 - 1 } ) } \tl_gput_right:Nx \g_@@_internal_code_after_tl - { \@@_hline:nn { \@@_succ:n { \c@iRow } } { #1 } } + { \@@_hline:nnnn { \@@_succ:n { \c@iRow } } { #1 } 1 { } } \ifnum 0 = `{ \fi } } % \end{macrocode} @@ -15150,7 +15222,7 @@ 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 } % \end{macrocode} % @@ -15627,21 +15699,14 @@ version 2005/12/01 or later. \cs_new_protected:Npn \@@_Block_v:nnnnnn #1 #2 #3 #4 #5 #6 { % \end{macrocode} -% The sequence of the positions of the blocks will be used when drawing the rules -% (in fact, there is also the |\multicolumn| and the |\diagbox| in that sequence). -% \begin{macrocode} - \seq_gput_left:Nn \g_@@_pos_of_blocks_seq { { #1 } { #2 } { #3 } { #4 } } -% \end{macrocode} -% % The group is for the keys. % \begin{macrocode} \group_begin: \keys_set:nn { NiceMatrix / Block / SecondPass } { #5 } % \end{macrocode} % -% % \begin{macrocode} - \bool_if:NT \l_@@_hvlines_block_bool + \bool_if:NTF \l_@@_hvlines_block_bool { \tl_gput_right:Nx \g_nicematrix_code_after_tl { @@ -15651,6 +15716,15 @@ version 2005/12/01 or later. { \int_use:N \l_@@_last_row_int - \int_use:N \l_@@_last_col_int } } } + { +% \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 +% |\multicolumn| and the |\diagbox| in that sequence). +% \begin{macrocode} + \seq_gput_left:Nn \g_@@_pos_of_blocks_seq + { { #1 } { #2 } { #3 } { #4 } } + } % \end{macrocode} % % \begin{macrocode} @@ -16096,7 +16170,7 @@ version 2005/12/01 or later. } % \end{macrocode} % - +% % \bigskip % The first argument of |\@@_hvlines_block:nnn| is a list of options for the % rules that we will draw. The second argument is the upper-left cell of the @@ -16113,40 +16187,16 @@ version 2005/12/01 or later. \@@_cut_on_hyphen:w #3 \q_stop \tl_set:Nx \l_tmpa_tl { \int_eval:n { \l_tmpa_tl + 1 } } \tl_set:Nx \l_tmpb_tl { \int_eval:n { \l_tmpb_tl + 1 } } - \pgfpicture - \pgfrememberpicturepositiononpagetrue - \pgf@relevantforpicturesizefalse - \CT@arc@ - \pgfsetlinewidth { 1.1 \l_@@_line_width_dim } -% \end{macrocode} -% First, the vertical rules. -% \begin{macrocode} - \@@_qpoint:n { row - \l_tmpa_tl } - \dim_set_eq:NN \l_tmpa_dim \pgf@y - \@@_qpoint:n { row - \l_tmpc_tl } - \dim_set_eq:NN \l_tmpb_dim \pgf@y \int_step_inline:nnn \l_tmpd_tl \l_tmpb_tl - { - \@@_qpoint:n { col - ##1 } - \pgfpathmoveto { \pgfpoint \pgf@x \l_tmpa_dim } - \pgfpathlineto { \pgfpoint \pgf@x \l_tmpb_dim } - \pgfusepathqstroke - } -% \end{macrocode} -% Now, the horizontal rules. -% \begin{macrocode} - \@@_qpoint:n { col - \l_tmpb_tl } - \dim_set:Nn \l_tmpa_dim { \pgf@x + 0.5 \arrayrulewidth } - \@@_qpoint:n { col - \l_tmpd_tl } - \dim_set:Nn \l_tmpb_dim { \pgf@x - 0.5 \arrayrulewidth } + { + \use:x + { \@@_vline:nnnn { ##1 } 1 { \l_tmpc_tl } { \@@_pred:n \l_tmpa_tl } } + } \int_step_inline:nnn \l_tmpc_tl \l_tmpa_tl - { - \@@_qpoint:n { row - ##1 } - \pgfpathmoveto { \pgfpoint \l_tmpa_dim \pgf@y } - \pgfpathlineto { \pgfpoint \l_tmpb_dim \pgf@y } - \pgfusepathqstroke - } - \endpgfpicture + { + \use:x + { \@@_hline:nnnn { ##1 } 1 { \l_tmpd_tl } { \@@_pred:n \l_tmpb_tl } } + } } % \end{macrocode} % @@ -17562,8 +17612,8 @@ version 2005/12/01 or later. % \begin{macrocode} \@@_msg_new:nn { Unknown~key~for~RowStyle } { - As~for~now,~there~is~only~three~keys~available~here:~'cell-space-top-limit',~ - 'cell-space-bottom-limit~and~'cell-space-limits'~(and~you~try~to~use~ + As~for~now,~there~is~only~four~keys~available~here:~'cell-space-top-limit',~ + 'cell-space-bottom-limit~'cell-space-limits'~and~color~(and~you~try~to~use~ '\l_keys_key_str').~If~you~go~on,~this~key~will~be~ignored. } % \end{macrocode} @@ -18705,6 +18755,14 @@ version 2005/12/01 or later. % % The key |define-L-C-R| has been deleted. % +% +% \subsection*{Changes between versions 6.0 and 6.1} +% +% Better computation of the widths of the |X| columns. +% +% Key |\color| for the command |\RowStyle|. +% +% % \PrintIndex % % \tableofcontents diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index b0fa2412209..c50867a21dd 100644 --- a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty +++ b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty @@ -18,8 +18,8 @@ %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% -\def\myfileversion{6.0} -\def\myfiledate{2021/08/10} +\def\myfileversion{6.1} +\def\myfiledate{2021/08/20} \RequirePackage{pgfcore} \usepgfmodule{shapes} \RequirePackage{l3keys2e} @@ -207,41 +207,13 @@ \bool_if:nTF { ! \c__nicematrix_siunitx_loaded_bool } { \cs_set_eq:NN \__nicematrix_renew_NC@rewrite@S: \prg_do_nothing: } { - \cs_if_exist:NTF \siunitx_cell_begin:w + \cs_new_protected:Npn \__nicematrix_renew_NC@rewrite@S: { - \cs_new_protected:Npn \__nicematrix_renew_NC@rewrite@S: + \renewcommand*{\NC@rewrite@S}[1][] { - \renewcommand*{\NC@rewrite@S}[1][] - { - \@temptokena \exp_after:wN - { - \tex_the:D \@temptokena - > { - \__nicematrix_Cell: - \keys_set:nn { siunitx } { ##1 } - \siunitx_cell_begin:w - } - \__nicematrix_true_c: - < { \siunitx_cell_end: \__nicematrix_end_Cell: } - } - \NC@find - } - } - } - { - \cs_new_protected:Npn \__nicematrix_renew_NC@rewrite@S: - { - \renewcommand*{\NC@rewrite@S}[1][] - { - \@temptokena \exp_after:wN - { - \tex_the:D \@temptokena - > { \__nicematrix_Cell: \c__nicematrix_table_collect_begin_tl S {##1} } - \__nicematrix_true_c: - < { \c__nicematrix_table_print_tl \__nicematrix_end_Cell: } - } - \NC@find - } + \@temptokena \exp_after:wN + { \tex_the:D \@temptokena \__nicematrix_S: [ ##1 ] } + \NC@find } } } @@ -899,7 +871,7 @@ l .code:n = \__nicematrix_error:n { r~or~l~with~preamble } , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~NiceTabular } } -\cs_new_protected:Npn \__nicematrix_Cell: +\cs_new_protected:Npn \__nicematrix_cell_begin:w { \tl_gclear:N \g__nicematrix_post_action_cell_tl \cs_set_eq:NN \CodeAfter \__nicematrix_CodeAfter_i:n @@ -1001,7 +973,7 @@ \dim_gzero:N \g__nicematrix_blocks_ht_dim } } -\cs_new_protected:Npn \__nicematrix_end_Cell: +\cs_new_protected:Npn \__nicematrix_cell_end: { \__nicematrix_math_toggle_token: \hbox_set_end: @@ -1195,6 +1167,7 @@ } \cs_new_protected:Npn \__nicematrix_pre_array_ii: { + \int_gzero:N \g__nicematrix_total_X_weight_int \bool_if:NT \c__nicematrix_booktabs_loaded_bool { \tl_put_left:Nn \@BTnormal \__nicematrix_create_row_node: } \box_clear_new:N \l__nicematrix_cell_box @@ -1372,6 +1345,13 @@ cell-space-top-limit = #1 , cell-space-bottom-limit = #1 , } , + color .code:n = + { + \leavevmode \color { #1 } + \tl_gput_right:Nn \g__nicematrix_row_style_tl + { \leavevmode \color { #1 } } + } , + color .value_required:n = true , unknown .code:n = \__nicematrix_error:n { Unknown~key~for~RowStyle } } \NewDocumentCommand \__nicematrix_RowStyle:n { O { } m } @@ -1560,19 +1540,28 @@ } \int_compare:nNnT \g__nicematrix_total_X_weight_int > 0 { - \bool_if:NTF \l__nicematrix_X_columns_aux_bool - { \dim_set_eq:NN \l_tmpa_dim \l__nicematrix_X_columns_dim } - { - \dim_set:Nn \l_tmpa_dim - { - ( \l__nicematrix_width_dim - \box_wd:N \l__nicematrix_the_array_box ) - / \int_use:N \g__nicematrix_total_X_weight_int - } - } \tl_gput_right:Nx \g__nicematrix_aux_tl { \bool_set_true:N \l__nicematrix_X_columns_aux_bool - \dim_set:Nn \l__nicematrix_X_columns_dim { \dim_use:N \l_tmpa_dim } + \dim_set:Nn \l__nicematrix_X_columns_dim + { + \dim_compare:nNnTF + { + \dim_abs:n + { \l__nicematrix_width_dim - \box_wd:N \l__nicematrix_the_array_box } + } + < + { 0.001 pt } + { \dim_use:N \l__nicematrix_X_columns_dim } + { + \dim_eval:n + { + ( \l__nicematrix_width_dim - \box_wd:N \l__nicematrix_the_array_box ) + / \int_use:N \g__nicematrix_total_X_weight_int + + \l__nicematrix_X_columns_dim + } + } + } } } \int_compare:nNnT \l__nicematrix_last_row_int > { -2 } @@ -1706,7 +1695,6 @@ { ! { \skip_horizontal:N \arrayrulewidth } } } } - \int_gzero:N \g__nicematrix_total_X_weight_int \seq_clear:N \g__nicematrix_cols_vlism_seq \int_zero:N \l_tmpa_int \exp_after:wN \__nicematrix_patch_preamble:n \the \@temptokena \q_stop @@ -1771,7 +1759,7 @@ m { \__nicematrix_patch_preamble_iv:n #1 } \__nicematrix_w: { \__nicematrix_patch_preamble_v:nnnn { } #1 } \__nicematrix_W: { \__nicematrix_patch_preamble_v:nnnn { \cs_set_eq:NN \hss \hfil } #1 } - \__nicematrix_true_c: { \__nicematrix_patch_preamble_vi:n #1 } + \__nicematrix_S: { \__nicematrix_patch_preamble_vi:n } ( { \__nicematrix_patch_preamble_vii:nn #1 } [ { \__nicematrix_patch_preamble_vii:nn #1 } \{ { \__nicematrix_patch_preamble_vii:nn #1 } @@ -1810,9 +1798,9 @@ { \tl_gput_right:Nn \g__nicematrix_preamble_tl { - > { \__nicematrix_Cell: \str_set:Nn \l__nicematrix_hpos_cell_str { #1 } } + > { \__nicematrix_cell_begin:w \str_set:Nn \l__nicematrix_hpos_cell_str { #1 } } #1 - < \__nicematrix_end_Cell: + < \__nicematrix_cell_end: } \int_gincr:N \c@jCol \__nicematrix_patch_preamble_x:n @@ -1847,10 +1835,12 @@ } } \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl - { \__nicematrix_vline:nn { \__nicematrix_succ:n \c@jCol } { \int_use:N \l_tmpa_int } } + { + \__nicematrix_vline:nnnn + { \__nicematrix_succ:n \c@jCol } { \int_use:N \l_tmpa_int } { 1 } { } + } \int_zero:N \l_tmpa_int - \str_if_eq:nnT { #1 } { \q_stop } - { \bool_gset_true:N \g_tmpb_bool } + \str_if_eq:nnT { #1 } { \q_stop } { \bool_gset_true:N \g_tmpb_bool } \__nicematrix_patch_preamble:n #1 } } @@ -1863,13 +1853,15 @@ c .value_forbidden:n = true , l .code:n = \str_set:Nn \l__nicematrix_hpos_col_str { l } , l .value_forbidden:n = true , + si .code:n = \str_set:Nn \l__nicematrix_hpos_col_str { si } , + si .value_forbidden:n = true , p .code:n = \str_set:Nn \l__nicematrix_vpos_col_str { p } , p .value_forbidden:n = true , t .meta:n = p , m .code:n = \str_set:Nn \l__nicematrix_vpos_col_str { m } , m .value_forbidden:n = true , b .code:n = \str_set:Nn \l__nicematrix_vpos_col_str { b } , - b .value_forbidden:n = true + b .value_forbidden:n = true , } \cs_new_protected:Npn \__nicematrix_patch_preamble_iv:n #1 { @@ -1894,13 +1886,16 @@ { \use:x { - \__nicematrix_patch_preamble_iv_v:nnnn + \__nicematrix_patch_preamble_iv_v:nnnnnn { \str_if_eq:VnTF \l__nicematrix_vpos_col_str { p } { t } { b } } { \dim_eval:n { #1 } } { \str_if_eq:VnTF \l__nicematrix_hpos_col_str j { \str_set:Nn \exp_not:N \l__nicematrix_hpos_cell_str { c } } - { \str_set:Nn \exp_not:N \l__nicematrix_hpos_cell_str \l__nicematrix_hpos_col_str } + { + \str_set:Nn \exp_not:N \l__nicematrix_hpos_cell_str + { \l__nicematrix_hpos_col_str } + } \str_case:Vn \l__nicematrix_hpos_col_str { c { \exp_not:N \centering } @@ -1909,17 +1904,19 @@ } } { \str_if_eq:VnT \l__nicematrix_vpos_col_str { m } \__nicematrix_center_cell_box: } + { \str_if_eq:VnT \l__nicematrix_hpos_col_str { si } \siunitx_cell_begin:w } + { \str_if_eq:VnT \l__nicematrix_hpos_col_str { si } \siunitx_cell_end: } } \int_gincr:N \c@jCol \__nicematrix_patch_preamble_x:n } -\cs_new_protected:Npn \__nicematrix_patch_preamble_iv_v:nnnn #1 #2 #3 #4 +\cs_new_protected:Npn \__nicematrix_patch_preamble_iv_v:nnnnnn #1 #2 #3 #4 #5 #6 { \tl_gput_right:Nn \g__nicematrix_preamble_tl { > { \dim_set:Nn \l__nicematrix_col_width_dim { #2 } - \__nicematrix_Cell: + \__nicematrix_cell_begin:w \begin { minipage } [ #1 ] { #2 } \everypar { @@ -1929,13 +1926,15 @@ #3 \g__nicematrix_row_style_tl \arraybackslash + #5 } c < { + #6 \@finalstrut \@arstrutbox \end { minipage } #4 - \__nicematrix_end_Cell: + \__nicematrix_cell_end: } } } @@ -1967,12 +1966,12 @@ > { \dim_set:Nn \l__nicematrix_col_width_dim { #4 } \hbox_set:Nw \l__nicematrix_cell_box - \__nicematrix_Cell: + \__nicematrix_cell_begin:w \str_set:Nn \l__nicematrix_hpos_cell_str { #3 } } c < { - \__nicematrix_end_Cell: + \__nicematrix_cell_end: #1 \hbox_set_end: \bool_if:NT \g__nicematrix_rotate_bool \__nicematrix_rotate_cell_box: @@ -1985,9 +1984,45 @@ } \cs_new_protected:Npn \__nicematrix_patch_preamble_vi:n #1 { - \tl_gput_right:Nn \g__nicematrix_preamble_tl { c } - \int_gincr:N \c@jCol - \__nicematrix_patch_preamble_x:n + \str_if_eq:nnTF { #1 } { [ } + { \__nicematrix_patch_preamble_vi_i:w [ } + { \__nicematrix_patch_preamble_vi_i:w [ ] { #1 } } + } +\cs_new_protected:Npn \__nicematrix_patch_preamble_vi_i:w [ #1 ] + { \__nicematrix_patch_preamble_vi_ii:n { #1 } } +\AtBeginDocument + { + \cs_if_exist:NTF \siunitx_cell_begin:w + { + \cs_new_protected:Npn \__nicematrix_patch_preamble_vi_ii:n #1 + { + \tl_gput_right:Nn \g__nicematrix_preamble_tl + { + > { + \__nicematrix_cell_begin:w + \keys_set:nn { siunitx } { #1 } + \siunitx_cell_begin:w + } + c + < { \siunitx_cell_end: \__nicematrix_cell_end: } + } + \int_gincr:N \c@jCol + \__nicematrix_patch_preamble_x:n + } + } + { + \cs_new_protected:Npn \__nicematrix_patch_preamble_vi_ii:n #1 + { + \tl_gput_right:Nn \g__nicematrix_preamble_tl + { + > { \__nicematrix_cell_begin:w \c__nicematrix_table_collect_begin_tl S { #1 } } + c + < { \c__nicematrix_table_print_tl \__nicematrix_cell_end: } + } + \int_gincr:N \c@jCol + \__nicematrix_patch_preamble_x:n + } + } } \cs_new_protected:Npn \__nicematrix_patch_preamble_vii:nn #1 #2 { @@ -2094,7 +2129,7 @@ \tl_gput_right:Nn \g__nicematrix_preamble_tl { > { - \__nicematrix_Cell: + \__nicematrix_cell_begin:w \bool_set_true:N \l__nicematrix_X_column_bool \tl_gput_right:Nn \g__nicematrix_post_action_cell_tl { \hbox_set:Nn \l__nicematrix_cell_box { } } @@ -2103,7 +2138,7 @@ c < { \end { minipage } - \__nicematrix_end_Cell: + \__nicematrix_cell_end: } } \int_gincr:N \c@jCol @@ -2204,9 +2239,9 @@ { \tl_gput_right:Nn \g__nicematrix_preamble_tl { - > { \__nicematrix_Cell: \str_set:Nn \l__nicematrix_hpos_cell_str { #1 } } + > { \__nicematrix_cell_begin:w \str_set:Nn \l__nicematrix_hpos_cell_str { #1 } } #1 - < \__nicematrix_end_Cell: + < \__nicematrix_cell_end: } \__nicematrix_patch_m_preamble_x:n } @@ -2225,7 +2260,7 @@ \tl_gput_right:Nn \g__nicematrix_preamble_tl { > { - \__nicematrix_Cell: + \__nicematrix_cell_begin:w \begin { minipage } [ #1 ] { \dim_eval:n { #3 } } \mode_leave_vertical: \arraybackslash @@ -2235,7 +2270,7 @@ < { \vrule height 0 pt depth \box_dp:N \@arstrutbox width 0 pt \end { minipage } - \__nicematrix_end_Cell: + \__nicematrix_cell_end: } } \__nicematrix_patch_m_preamble_x:n @@ -2246,12 +2281,12 @@ { > { \hbox_set:Nw \l__nicematrix_cell_box - \__nicematrix_Cell: + \__nicematrix_cell_begin:w \str_set:Nn \l__nicematrix_hpos_cell_str { #3 } } c < { - \__nicematrix_end_Cell: + \__nicematrix_cell_end: #1 \hbox_set_end: \bool_if:NT \g__nicematrix_rotate_bool \__nicematrix_rotate_cell_box: @@ -2859,7 +2894,7 @@ \c@MaxMatrixCols { \__nicematrix_pred:n \l__nicematrix_last_col_int } } - { > \__nicematrix_Cell: #2 < \__nicematrix_end_Cell: } + { > \__nicematrix_cell_begin:w #2 < \__nicematrix_cell_end: } } } \clist_map_inline:nn { { } , p , b , B , v , V } @@ -2968,16 +3003,16 @@ \__nicematrix_draw_dotted_lines: \__nicematrix_compute_corners: \__nicematrix_adjust_pos_of_blocks_seq: - \bool_lazy_all:nT - { - { \seq_if_empty_p:N \g__nicematrix_pos_of_blocks_seq } - { \seq_if_empty_p:N \g__nicematrix_pos_of_xdots_seq } - { \seq_if_empty_p:N \l__nicematrix_corners_cells_seq } - } - { - \cs_set_eq:NN \__nicematrix_vline_i:nn \__nicematrix_vline_i_complete:nn - \cs_set_eq:NN \__nicematrix_hline_i:nn \__nicematrix_hline_i_complete:nn - } + % \bool_lazy_all:nT + % { + % { \seq_if_empty_p:N \g__nicematrix_pos_of_blocks_seq } + % { \seq_if_empty_p:N \g__nicematrix_pos_of_xdots_seq } + % { \seq_if_empty_p:N \l__nicematrix_corners_cells_seq } + % } + % { + % \cs_set_eq:NN \__nicematrix_vline_i:nn \__nicematrix_vline_i_complete:nn + % \cs_set_eq:NN \__nicematrix_hline_i:nn \__nicematrix_hline_i_complete:nn + % } \tl_if_empty:NF \l__nicematrix_hlines_clist \__nicematrix_draw_hlines: \tl_if_empty:NF \l__nicematrix_vlines_clist \__nicematrix_draw_vlines: \cs_set_eq:NN \SubMatrix \__nicematrix_SubMatrix @@ -4584,20 +4619,23 @@ \int_compare:nNnF \c@iRow = 0 { \int_compare:nNnF \c@iRow = \l__nicematrix_last_row_int { #1 } } } -\cs_new_protected:Npn \__nicematrix_vline:nn #1 #2 +\cs_new_protected:Npn \__nicematrix_vline:nnnn #1 #2 #3 #4 { \int_compare:nNnT { #1 } < { \c@jCol + 2 } { \pgfpicture - \__nicematrix_vline_i:nn { #1 } { #2 } + \__nicematrix_vline_i:nnnn { #1 } { #2 } { #3 } { #4 } \endpgfpicture } } -\cs_new_protected:Npn \__nicematrix_vline_i:nn #1 #2 +\cs_new_protected:Npn \__nicematrix_vline_i:nnnn #1 #2 #3 #4 { \tl_set:Nx \l_tmpb_tl { #1 } \tl_clear_new:N \l_tmpc_tl - \int_step_variable:nNn \c@iRow \l_tmpa_tl + \int_step_variable:nnNn + { #3 } + { \tl_if_blank:nTF { #4 } { \int_use:N \c@iRow } { #4 } } + \l_tmpa_tl { \bool_gset_true:N \g_tmpa_bool \seq_map_inline:Nn \g__nicematrix_pos_of_blocks_seq @@ -4606,8 +4644,7 @@ { \__nicematrix_test_vline_in_block:nnnn ##1 } \seq_map_inline:Nn \g__nicematrix_pos_of_stroken_blocks_seq { \__nicematrix_test_vline_in_stroken_block:nnnn ##1 } - \clist_if_empty:NF \l__nicematrix_corners_clist - \__nicematrix_test_in_corner_v: + \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 @@ -4631,7 +4668,7 @@ { #1 } { #2 } \l_tmpc_tl - { \int_use:N \c@iRow } + { \tl_if_blank:nTF { #4 } { \int_use:N \c@iRow } { #4 } } \tl_clear:N \l_tmpc_tl } } @@ -4720,20 +4757,23 @@ { \tl_if_eq:NnF \l__nicematrix_vlines_clist { all } { \clist_if_in:NnT \l__nicematrix_vlines_clist { ##1 } } - { \__nicematrix_vline:nn { ##1 } 1 } + { \__nicematrix_vline:nnnn { ##1 } 1 1 { } } } } -\cs_new_protected:Npn \__nicematrix_hline:nn #1 #2 +\cs_new_protected:Npn \__nicematrix_hline:nnnn #1 #2 #3 #4 { \pgfpicture - \__nicematrix_hline_i:nn { #1 } { #2 } + \__nicematrix_hline_i:nnnn { #1 } { #2 } { #3 } { #4 } \endpgfpicture } -\cs_new_protected:Npn \__nicematrix_hline_i:nn #1 #2 +\cs_new_protected:Npn \__nicematrix_hline_i:nnnn #1 #2 #3 #4 { \tl_set:Nn \l_tmpa_tl { #1 } \tl_clear_new:N \l_tmpc_tl - \int_step_variable:nNn \c@jCol \l_tmpb_tl + \int_step_variable:nnNn + { #3 } + { \tl_if_blank:nTF { #4 } { \int_use:N \c@jCol } { #4 } } + \l_tmpb_tl { \bool_gset_true:N \g_tmpa_bool \seq_map_inline:Nn \g__nicematrix_pos_of_blocks_seq @@ -4766,7 +4806,7 @@ { #1 } { #2 } \l_tmpc_tl - { \int_use:N \c@jCol } + { \tl_if_blank:nTF { #4 } { \int_use:N \c@jCol } { #4 } } \tl_clear:N \l_tmpc_tl } } @@ -4853,7 +4893,7 @@ { \tl_if_eq:NnF \l__nicematrix_hlines_clist { all } { \clist_if_in:NnT \l__nicematrix_hlines_clist { ##1 } } - { \__nicematrix_hline:nn { ##1 } 1 } + { \__nicematrix_hline:nnnn { ##1 } 1 1 { } } } } \cs_set:Npn \__nicematrix_Hline: { \noalign { \ifnum 0 = `} \fi \__nicematrix_Hline_i:n { 1 } } @@ -4872,7 +4912,7 @@ + \doublerulesep * ( \int_max:nn 0 { #1 - 1 } ) } \tl_gput_right:Nx \g__nicematrix_internal_code_after_tl - { \__nicematrix_hline:nn { \__nicematrix_succ:n { \c@iRow } } { #1 } } + { \__nicematrix_hline:nnnn { \__nicematrix_succ:n { \c@iRow } } { #1 } 1 { } } \ifnum 0 = `{ \fi } } \cs_new_protected:Npn \__nicematrix_test_hline_in_block:nnnn #1 #2 #3 #4 @@ -5360,7 +5400,7 @@ 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 } \NewExpandableDocumentCommand \__nicematrix_Block: { O { } m D < > { } m } { @@ -5660,10 +5700,9 @@ } \cs_new_protected:Npn \__nicematrix_Block_v:nnnnnn #1 #2 #3 #4 #5 #6 { - \seq_gput_left:Nn \g__nicematrix_pos_of_blocks_seq { { #1 } { #2 } { #3 } { #4 } } \group_begin: \keys_set:nn { NiceMatrix / Block / SecondPass } { #5 } - \bool_if:NT \l__nicematrix_hvlines_block_bool + \bool_if:NTF \l__nicematrix_hvlines_block_bool { \tl_gput_right:Nx \g_nicematrix_code_after_tl { @@ -5673,6 +5712,10 @@ { \int_use:N \l__nicematrix_last_row_int - \int_use:N \l__nicematrix_last_col_int } } } + { + \seq_gput_left:Nn \g__nicematrix_pos_of_blocks_seq + { { #1 } { #2 } { #3 } { #4 } } + } \tl_if_empty:NF \l__nicematrix_draw_tl { \tl_gput_right:Nx \g_nicematrix_code_after_tl @@ -5948,7 +5991,6 @@ 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 { \dim_set_eq:NN \l__nicematrix_line_width_dim \arrayrulewidth @@ -5959,34 +6001,16 @@ \__nicematrix_cut_on_hyphen:w #3 \q_stop \tl_set:Nx \l_tmpa_tl { \int_eval:n { \l_tmpa_tl + 1 } } \tl_set:Nx \l_tmpb_tl { \int_eval:n { \l_tmpb_tl + 1 } } - \pgfpicture - \pgfrememberpicturepositiononpagetrue - \pgf@relevantforpicturesizefalse - \CT@arc@ - \pgfsetlinewidth { 1.1 \l__nicematrix_line_width_dim } - \__nicematrix_qpoint:n { row - \l_tmpa_tl } - \dim_set_eq:NN \l_tmpa_dim \pgf@y - \__nicematrix_qpoint:n { row - \l_tmpc_tl } - \dim_set_eq:NN \l_tmpb_dim \pgf@y \int_step_inline:nnn \l_tmpd_tl \l_tmpb_tl { - \__nicematrix_qpoint:n { col - ##1 } - \pgfpathmoveto { \pgfpoint \pgf@x \l_tmpa_dim } - \pgfpathlineto { \pgfpoint \pgf@x \l_tmpb_dim } - \pgfusepathqstroke + \use:x + { \__nicematrix_vline:nnnn { ##1 } 1 { \l_tmpc_tl } { \__nicematrix_pred:n \l_tmpa_tl } } } - \__nicematrix_qpoint:n { col - \l_tmpb_tl } - \dim_set:Nn \l_tmpa_dim { \pgf@x + 0.5 \arrayrulewidth } - \__nicematrix_qpoint:n { col - \l_tmpd_tl } - \dim_set:Nn \l_tmpb_dim { \pgf@x - 0.5 \arrayrulewidth } \int_step_inline:nnn \l_tmpc_tl \l_tmpa_tl { - \__nicematrix_qpoint:n { row - ##1 } - \pgfpathmoveto { \pgfpoint \l_tmpa_dim \pgf@y } - \pgfpathlineto { \pgfpoint \l_tmpb_dim \pgf@y } - \pgfusepathqstroke + \use:x + { \__nicematrix_hline:nnnn { ##1 } 1 { \l_tmpd_tl } { \__nicematrix_pred:n \l_tmpb_tl } } } - \endpgfpicture } \cs_new_protected:Npn \__nicematrix_stroke_borders_block:nnn #1 #2 #3 { @@ -6854,8 +6878,8 @@ } \__nicematrix_msg_new:nn { Unknown~key~for~RowStyle } { - As~for~now,~there~is~only~three~keys~available~here:~'cell-space-top-limit',~ - 'cell-space-bottom-limit~and~'cell-space-limits'~(and~you~try~to~use~ + As~for~now,~there~is~only~four~keys~available~here:~'cell-space-top-limit',~ + 'cell-space-bottom-limit~'cell-space-limits'~and~color~(and~you~try~to~use~ '\l_keys_key_str').~If~you~go~on,~this~key~will~be~ignored. } \__nicematrix_msg_new:nn { Unknown~key~for~rowcolors } -- cgit v1.2.3