diff options
author | Karl Berry <karl@freefriends.org> | 2020-11-23 22:01:33 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-11-23 22:01:33 +0000 |
commit | 586739881a834da18ee485728bdf9182e02025f8 (patch) | |
tree | 66ed5516b8812957e64d20353933abdb4f2c19e2 /Master | |
parent | c23682f2c0c9d6928d1a2d9f362b8b7ed708fb72 (diff) |
nicematrix (23nov20)
git-svn-id: svn://tug.org/texlive/trunk@56990 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf | bin | 424627 -> 429184 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex | 187 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf | bin | 1061552 -> 1078185 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx | 514 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | 207 |
5 files changed, 657 insertions, 251 deletions
diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf Binary files differindex d2425b4bb20..6ce7fd41b2e 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex index 52949c1d76a..d634e3ff1e3 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex @@ -419,7 +419,7 @@ avec deux arguments. \item Le premier argument est la taille de ce bloc avec la syntaxe $i$-$j$ où $i$ est le nombre de rangées et $j$ le nombre de colonnes du bloc. -\colorbox{yellow!50}{\bfseries Nouveau 5.6}\enskip Si cet argument est laissé +\colorbox{yellow!30}{Nouveau 5.6}\enskip Si cet argument est laissé blanc, la valeur par défaut est |1-1|. Si le nombre de rangées n'est pas indiqué, le bloc s'étend jusqu'à la dernière rangée (idem pour les colonnes). @@ -518,7 +518,8 @@ construction |wc{...}| de \pkg{array}). \begin{BVerbatim} \begin{NiceTabular}~emphase#{cwc{2cm}wc{3cm}c}@ rose & tulipe & marguerite & dahlia \\ -violette & \Block{2-2}{\LARGE\color{blue}De très jolies fleurs} & & souci \\ +violette +& \Block[draw=red,fill=red!15]{2-2}{\LARGE De très jolies fleurs} & & souci \\ pervenche & & & lys \\ arum & iris & jacinthe & muguet \end{NiceTabular} @@ -529,12 +530,18 @@ arum & iris & jacinthe & muguet \begin{center} \begin{NiceTabular}{cwc{2cm}wc{3cm}c} rose & tulipe & marguerite & dahlia \\ -violette & \Block{2-2}{\LARGE\color{blue}De très jolies fleurs} & & souci \\ +violette & \Block[draw=red,fill=red!15]{2-2}{\LARGE De très jolies fleurs} & & souci \\ pervenche & & & lys \\ arum & iris & jacinthe & muguet \end{NiceTabular} \end{center} +\medskip +\colorbox{yellow!50}{\bfseries Nouveau 5.7}\enskip Comme on le voit sur cet +exemple, on peut fixer la couleur de fond avec la clé |fill| et la couleur du +cadre avec la clé |draw|\footnote{Si la clé |draw| est utilisée sans valeur, +c'est la couleur par défaut des filets de tableaux qui est utilisée.}. On peut +aussi fixer l'épaisseur du trait avec la clé |line-width|. @@ -590,7 +597,7 @@ Henri & 14 \\ \hline \subsection{Les blocs mono-rangée} -\colorbox{yellow!50}{\textbf{Nouveau 5.6}}\enskip Pour les blocs mono-rangée, la +\colorbox{yellow!30}{Nouveau 5.6}\enskip Pour les blocs mono-rangée, la hauteur (\emph{height}) et la profondeur (\emph{depth}) naturelles sont prises en compte pour la hauteur et la largeur de la rangée en cours (comme le fait la commande standard |\multicolumn| de LaTeX). @@ -598,20 +605,26 @@ commande standard |\multicolumn| de LaTeX). -\subsection{Les blocs mono-cellule} +\subsection{Les blocs mono-case} -Les blocs mono-cellule héritent des caractéristiques des blocs mono-colonne et +Les blocs mono-case héritent des caractéristiques des blocs mono-colonne et des blocs mono-rangée. \medskip -Il y a deux raisons à l'utilisation d'un bloc mono-cellule. +On pourrait penser que des blocs d'une seule case n'ont aucune utilité mais, en +fait, il y a plusieurs situations où leur utilisation peut présenter des avantages. \begin{itemize} -\item Un bloc mono-cellule permet d'utiliser la commande |\\| pour composer le +\item Un bloc mono-case permet d'utiliser la commande |\\| pour composer le bloc sur plusieurs lignes. \item On peut utiliser l'option d'alignement horizontal du bloc pour déroger à la consigne générale donnée dans le préambule pour cette colonne. + +\item On peut tracer un cadre autour du bloc avec la clé |draw| de la commande +|\Block|.\footnote{Pour colorier le fond d'une case, il n'est pas besoin + d'utiliser un bloc mono-case : on peut utiliser la commande |\cellcolor| si la + clé |colortbl-like| est utilisée : voir p.~\pageref{colortbl-like}.} \end{itemize} \medskip @@ -638,8 +651,8 @@ Balzac & 1799 \\ \end{NiceTabular} \medskip -On rappelle que si le premier argument obligatoire de |\Block| est laisssé -blanc, alors le bloc est mono-cellule\footnote{On peut considérer que la valeur par +On rappelle que si le premier argument obligatoire de |\Block| est laissé +blanc, alors le bloc est mono-case\footnote{On peut considérer que la valeur par défaut de ce premier argument obligatoire est |1-1|.}. @@ -908,13 +921,14 @@ $\begin{pNiceMatrix}[vlines,rules/width=0.2pt] La clé |hvlines| demande le tracé de tous les filets horizontaux et verticaux (sauf dans les blocs et dans les blocs virtuels déterminés par des -lignes en pointillés). +lignes en pointillés et sauf les filets correspondants à des clés |draw| de +commandes |\Block|, filets qui sont tracés avec leurs caractéristiques). \medskip \begin{Verbatim} \begin{NiceTabular}{cccc}[~emphase#hvlines@,rules/color=blue,rules/width=1pt] rose & tulipe & marguerite & dahlia \\ -violette & \Block{2-2}{\LARGE\color{blue} fleurs} & & souci \\ +violette & \Block[~emphase#draw=red@]{2-2}{\LARGE fleurs} & & souci \\ pervenche & & & lys \\ arum & iris & jacinthe & muguet \end{NiceTabular} @@ -923,7 +937,7 @@ arum & iris & jacinthe & muguet \begin{center} \begin{NiceTabular}{cccc}[hvlines,rules/color=blue,rules/width=1pt] rose & tulipe & marguerite & dahlia \\ -violette & \Block{2-2}{\LARGE\color{blue} fleurs} & & souci \\ +violette & \Block[draw=red]{2-2}{\LARGE fleurs} & & souci \\ pervenche & & & lys \\ arum & iris & jacinthe & muguet \end{NiceTabular} @@ -1119,10 +1133,10 @@ tracés postérieurement (conformément à l'esprit du «modèle du peintre» de PostScript et PDF). De ce point de vue, MuPDF (qui est utilisé par exemple par SumatraPDF) donne de meilleurs résultats que Adobe Reader. -\item Une fine ligne blanche semble apparaître entre deux cellules de même -couleur. Ce phénomène se produit quand chaque cellule est coloriée avec sa +\item Une fine ligne blanche semble apparaître entre deux cases de même +couleur. Ce phénomène se produit quand chaque case est coloriée avec sa propre instruction |fill| (opérateur |fill| de PostScript noté |f| en PDF). -C'est le cas avec \pkg{colortbl} avec lequel chaque cellule est coloriée +C'est le cas avec \pkg{colortbl} avec lequel chaque case est coloriée individuellement même si on utilise |\columncolor| ou |\rowcolor|. Concernant ce phénomène, Adobe Reader donne de meilleurs résultats que @@ -1409,6 +1423,8 @@ On a utilisé le type de colonne |S| de \pkg{siunitx}. \subsection{Outils de coloriage avec la syntaxe de colortbl} +\label{colortbl-like} + On peut accéder aux outils de coloriage précédents avec une syntaxe proche de celle proposée par \pkg{colortbl}. On doit pour cela utiliser la clé |colortbl-like| dans l'environnement concerné.\footnote{Pour le moment, cette @@ -2334,8 +2350,8 @@ Pour améliorer la lisibilité du code, une syntaxe alternative est proposée : peut spécifier les instructions du |code-after| à la fin de l'environnement, après le mot-clé |\CodeAfter|\footnote{Dans certaines circonstances, on doit mettre |\omit \CodeAfter|, |\omit| étant un mot-clé de TeX qui annule le motif - de la cellule courante.} (pour un exemple, voir page -\pageref{exemple-CodeAfter}). \colorbox{yellow!50}{\textbf{Nouveau 5.5}}\enskip + de la case courante.} (pour un exemple, voir page +\pageref{exemple-CodeAfter}). \colorbox{yellow!30}{Nouveau 5.5}\enskip Avant la version 5.5, il fallait parfois mettre le mot-clé |\omit| devant |\CodeAfter| dans certaines circonstances. Depuis la version 5.5, on ne doit \emph{jamais} mettre |\omit|. @@ -2457,7 +2473,7 @@ titre inséré par |\caption| dans un environnement |{table}| de LaTeX. séparés par une virgule (comme avec l'option |multiple| de \pkg{footmisc} pour les notes de pied de page). -\item Si une commande |\tabularnote{...}| se trouve exactement à la fin d'une cellule +\item Si une commande |\tabularnote{...}| se trouve exactement à la fin d'une case (sans aucun espace après), l'appel de note est composé en débordement vers la droite (cela peut permettre de mieux conserver l'alignement des contenus d'une colonne). @@ -2946,6 +2962,25 @@ d'éléments en verbatim (avec par exemple la commande environnement de LaTeX qui se contente d'insérer des commandes avant et après.} +\subsection{Couleur des délimiteurs} + +Pour les environnements avec délimiteurs (|{pNiceArray}|, |{pNiceMatrix}|, +etc.), il est possible de changer la couleur des délimiteurs avec la clé +|delimiters-color|. + +\medskip +\begin{BVerbatim}[boxwidth=12cm,baseline=c] +$\begin{bNiceMatrix}[delimiters-color=red] +1 & 2 \\ +3 & 4 +\end{bNiceMatrix}$ +\end{BVerbatim} +$\begin{bNiceMatrix}[delimiters-color=red] +1 & 2 \\ +3 & 4 +\end{bNiceMatrix}$ + + \subsection{L'environnement \{NiceArrayWithDelims\}} En fait, l'environnement |{pNiceArray}| et ses variantes sont fondés sur un @@ -2989,7 +3024,7 @@ lignes en pointillés entre les cases du tableau. \textbf{Attention} : Par défaut, aucun nœud n'est créé dans une case vide. \smallskip -\colorbox{yellow!50}{\textbf{Nouveau 5.6}}\enskip +\colorbox{yellow!30}{Nouveau 5.6}\enskip Néanmoins, on peut forcer la création d'un nœud avec la commande |\NotEmpty|.\footnote{Il faut toutefois remarquer qu'avec cette commande, la case est considérée comme non vide, ce qui a des conséquences sur le tracé des @@ -3396,9 +3431,9 @@ L'extension \pkg{nicematrix} fournit deux variables internes mais publiques\foot \medskip Ces variables constituent le code du «|code-before|» et du «|code-after|». Le -développeur peut donc les utiliser pour y ajouter du code à partir d'une cellule +développeur peut donc les utiliser pour y ajouter du code à partir d'une case du tableau (l'affectation devra être globale, ce qui permettra de sortir de la -cellule, qui est un groupe au sens de TeX). +case, qui est un groupe au sens de TeX). \medskip On remarquera que l'utilisation de |\g_nicematrix_code_before_tl| nécessite une @@ -3407,7 +3442,7 @@ compilation supplémentaire (car les instructions sont écrites dans le fichier \bigskip \emph{Example} : On souhaite écrire une commande |\hatchcell| pour hachurer la -cellule courante (avec un argument optionnel entre crochets pour la couleur des +case courante (avec un argument optionnel entre crochets pour la couleur des hachures). Il est possible de programmer une telle commande |\hatchcell| comme suit, en utilisant explicitement la variable publique |\g_nicematrix_code_before_tl| (ce code nécessite le chargement préalable de la @@ -4072,67 +4107,35 @@ $\begin{pNiceArray}{cccc:c} \end{multicols} -\subsection{Comment surligner les cases} +\subsection{Comment surligner les cases d'une matrice} \label{highlight} \medskip -Les exemples suivants nécessitent d'avoir chargé Tikz (\pkg{nicematrix} ne -charge que \textsc{pgf}) ainsi que la bibliothèque Tikz |fit|, ce qui peut se -faire avec les deux instructions suivantes dans le préambule du document : - -\begin{verbatim} -\usepackage{tikz} -\usetikzlibrary{fit} -\end{verbatim} - - - -\medskip -Pour mettre en évidence une case, il est possible de «dessiner» l'un des nœuds -(le «nœud normal», le «nœud moyen» ou le «nœud large»). Dans l'exemple suivant, -on utilise les «nœuds larges» de la diagonale de la matrice (avec la clé de Tikz -«|name suffix|», il est facile d'utiliser les «nœuds larges»). - -Nous redessinons les nœuds avec de nouveaux nœuds en utilisant la bibliothèque -\pkg{fit} de Tikz. Comme nous voulons recréer des nœuds identiques aux premiers, -nous devons fixer |inner sep = 0pt| (si on ne fait pas cela, les nouveaux nœuds -seront plus grands que les nœuds d'origine créés par \pkg{nicematrix}). +Pour mettre en évidence une case d'une matrice, il est possible de «dessiner» +cette case avec la clé |draw| de la commande |\Block| (c'est l'un des usages des +blocs mono-case\footnote{On rappelle que si le premier argument obligatoire de +la commande |\Block| est laissé vide, le bloc est considéré comme mono-case}). \label{exemple-CodeAfter} \begin{Verbatim} -$\begin{pNiceArray}{>{\strut}cccc}[create-large-nodes,margin,extra-margin = 2pt] - a_{11} & a_{12} & a_{13} & a_{14} \\ - a_{21} & a_{22} & a_{23} & a_{24} \\ - a_{31} & a_{32} & a_{33} & a_{34} \\ - a_{41} & a_{42} & a_{43} & a_{44} \\ -\CodeAfter - \begin{tikzpicture}[~emphase#name suffix = -large@, - every node/.style = {draw,~emphase#inner sep = 0 pt@}] - \node [fit = (1-1)] {} ; - \node [fit = (2-2)] {} ; - \node [fit = (3-3)] {} ; - \node [fit = (4-4)] {} ; - \end{tikzpicture} +$\begin{pNiceArray}{>{\strut}cccc}[margin,rules/color=blue] +~emphase#\Block[draw]{}{a_{11}}@ & a_{12} & a_{13} & a_{14} \\ +a_{21} & \Block[draw]{}{a_{22}} & a_{23} & a_{24} \\ +a_{31} & a_{32} & \Block[draw]{}{a_{33}} & a_{34} \\ +a_{41} & a_{42} & a_{43} & \Block[draw]{}{a_{44}} \\ \end{pNiceArray}$ \end{Verbatim} % -\[\begin{pNiceArray}{>{\strut}cccc}[create-large-nodes,margin,extra-margin = 2pt] -a_{11} & a_{12} & a_{13} & a_{14} \\ -a_{21} & a_{22} & a_{23} & a_{24} \\ -a_{31} & a_{32} & a_{33} & a_{34} \\ -a_{41} & a_{42} & a_{43} & a_{44} \\ -\CodeAfter -\begin{tikzpicture}[name suffix = -large, - every node/.style = {draw,inner sep = 0 pt}] - \node [fit = (1-1)] {} ; - \node [fit = (2-2)] {} ; - \node [fit = (3-3)] {} ; - \node [fit = (4-4)] {} ; -\end{tikzpicture} +\[\begin{pNiceArray}{>{\strut}cccc}[margin,rules/color=blue] +\Block[draw]{}{a_{11}} & a_{12} & a_{13} & a_{14} \\ +a_{21} & \Block[draw]{}{a_{22}} & a_{23} & a_{24} \\ +a_{31} & a_{32} & \Block[draw]{}{a_{33}} & a_{34} \\ +a_{41} & a_{42} & a_{43} & \Block[draw]{}{a_{44}} \\ \end{pNiceArray}\] + On remarquera que les traits que l'on vient de tracer sont dessinés \emph{après} la matrice sans modifier la position des composantes de celle-ci. En revanche, les traits tracés par |\hline|, le spécificateur «\verb+|+» ou les options @@ -4140,15 +4143,29 @@ les traits tracés par |\hline|, le spécificateur «\verb+|+» ou les options matrice.\footnote{Pour la commande |\cline|, voir la remarque p.~\pageref{remark-cline}.} -\vspace{1cm} Il est possible de colorier une rangée avec |\rowcolor| dans le -|code-before| (ou avec |\rowcolor| dans la première case de la -rangée). Les possibilités de réglages sont néanmoins limitées. C'est pourquoi -nous présentons ici une autre méthode pour surligner une rangée de la matrice. -Nous créons un nœud Tikz rectangulaire qui englobe les nœuds de la deuxième -rangée en utilisant les outils de la bibliothèque Tikz \pkg{fit}. Ce nœud est -rempli après la construction de la matrice. Pour que l'on puisse voir le texte -\emph{sous} le nœud, nous devons utiliser la transparence avec le |blend mode| -égal à |multiply|. +\vspace{1cm} +Il est possible de colorier une rangée avec |\rowcolor| dans le |code-before| +(ou avec |\rowcolor| dans la première case de la rangée si on utilise la clé +|colortbl-like|). Les possibilités de réglages sont néanmoins limitées. C'est +pourquoi nous présentons ici une autre méthode pour surligner une rangée d'une +matrice. + +\medskip +Cet exemple et les suivants nécessitent d'avoir chargé Tikz (\pkg{nicematrix} ne +charge que \textsc{pgf}) ainsi que la bibliothèque Tikz |fit|, ce qui peut se +faire avec les deux instructions suivantes dans le préambule du document : + +\begin{verbatim} +\usepackage{tikz} +\usetikzlibrary{fit} +\end{verbatim} + +\medskip +Nous créons un nœud Tikz rectangulaire qui englobe les nœuds de la +deuxième rangée en utilisant les outils de la bibliothèque Tikz \pkg{fit}. Ce +nœud est rempli après la construction de la matrice. Pour que l'on puisse voir +le texte \emph{sous} le nœud, nous devons utiliser la transparence avec le +|blend mode| égal à |multiply|. \tikzset{highlight/.style={rectangle, @@ -4167,17 +4184,19 @@ rempli après la construction de la matrice. Pour que l'on puisse voir le texte inner sep=1pt, fit=~#1}} -$\begin{bNiceMatrix}[~emphase#code-after = {\tikz \node [highlight = (2-1) (2-3)] {} ;}@] +$\begin{bNiceMatrix} 0 & \Cdots & 0 \\ 1 & \Cdots & 1 \\ -0 & \Cdots & 0 +0 & \Cdots & 0 \\ +~emphase#\CodeAfter \tikz \node [highlight = (2-1) (2-3)] {} ;@ \end{bNiceMatrix}$ \end{Verbatim} -\[\begin{bNiceMatrix}[code-after = {\tikz \node [highlight = (2-1) (2-3)] {} ;}] +\[\begin{bNiceMatrix} 0 & \Cdots & 0 \\ 1 & \Cdots & 1 \\ -0 & \Cdots & 0 +0 & \Cdots & 0 \\ +\CodeAfter \tikz \node [highlight = (2-1) (2-3)] {} ; \end{bNiceMatrix}\] diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf Binary files differindex c8e2b90a5cb..3f0097097d4 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx index a8427171e27..b485a9139d3 100644 --- a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx +++ b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx @@ -15,8 +15,8 @@ % % \fi % \iffalse -\def\myfileversion{5.6} -\def\myfiledate{2020/11/08} +\def\myfileversion{5.7} +\def\myfiledate{2020/11/23} % % %<*batchfile> @@ -459,7 +459,7 @@ version 2005/12/01 or later. % $i$\verb|-|$j$ where $i$ is the number of rows of the block and $j$ its number % of columns. % -% \colorbox{yellow!50}{\bfseries New 5.6}\enskip If this argument is empty, its +% \colorbox{yellow!30}{New 5.6}\enskip If this argument is empty, its % default value is |1-1|. If the number of rows is not specified, the block % extends until the last row (idem for the columns). % @@ -558,7 +558,8 @@ version 2005/12/01 or later. % \begin{BVerbatim} % \begin{NiceTabular}~emphase#{cwc{2cm}wc{3cm}c}@ % rose & tulipe & marguerite & dahlia \\ -% violette & \Block{2-2}{\LARGE\color{blue}De très jolies fleurs} & & souci \\ +% violette +% & \Block[draw=red,fill=red!15]{2-2}{\LARGE De très jolies fleurs} & & souci \\ % pervenche & & & lys \\ % arum & iris & jacinthe & muguet % \end{NiceTabular} @@ -569,12 +570,18 @@ version 2005/12/01 or later. % \begin{center} % \begin{NiceTabular}{cwc{2cm}wc{3cm}c} % rose & tulipe & marguerite & dahlia \\ -% violette & \Block{2-2}{\LARGE\color{blue}De très jolies fleurs} & & souci \\ +% violette & +% \Block[draw=red,fill=red!15]{2-2}{\LARGE De très jolies fleurs} & & souci \\ % pervenche & & & lys \\ % arum & iris & jacinthe & muguet % \end{NiceTabular} % \end{center} % +% \colorbox{yellow!50}{\bfseries New 5.7}\enskip As we can see on this example, +% it's possible to fill the block by using the key |fill| and to draw the frame +% with the key |draw|\footnote{If the key |draw| is used without value, the +% default color the rules of the tabulars is used}. It's also possible to change +% the width (thickness) of that rules with the key |line-width|. % % \subsection{The mono-column blocks} % @@ -628,7 +635,7 @@ version 2005/12/01 or later. % % \subsection{The mono-row blocks} % -% \colorbox{yellow!50}{\textbf{New 5.6}}\enskip For the mono-row blocks, the +% \colorbox{yellow!30}{New 5.6}\enskip For the mono-row blocks, the % natural height and depth are taken into account for the height and depth of % the current row (as does a standard |\multicolumn| of LaTeX). % @@ -638,12 +645,18 @@ version 2005/12/01 or later. % mono-column blocks. % % \medskip -% There are two reasons to use a mono-column block: +% At first sight, one may think that there is no point using a mono-cell block. +% However, there are some good reasons to use such a block. % \begin{itemize} % \item It's possible to use the command |\\| in a (mono-cell) block. % % \item It's possible to use the option of horizontal alignment of the block in % derogation of the type of column given in the preamble of the array. +% +% \item It's possible do draw a frame around the cell with the key |draw| of the +% command |\Block|.\footnote{If one wishes to color the background of a unique +% celle, there is no point using the command |\Block|: it's possible to use the +% command |\cellcolor| (when the key |colortbl-like| is used).} % \end{itemize} % % \bigskip @@ -669,7 +682,7 @@ version 2005/12/01 or later. % \medskip % We recall that if the first mandatory argument of |\Block| is left blank, the % block is mono-cell.\footnote{One may consider that the default value of the -% first mandatory argument of |\Block| is |1-1|} +% first mandatory argument of |\Block| is |1-1|.} % % % @@ -920,15 +933,17 @@ version 2005/12/01 or later. % \subsection{The key hvlines} % \label{hvlines} % -% The key |hvlines| draws all the vertical and horizontal rules excepted -% in the blocks (and the virtual blocks determined by dotted lines). +% The key |hvlines| draws all the vertical and horizontal rules (excepted +% in the blocks and the virtual blocks determined by dotted lines and excepted +% the rules corresponding of the frame of the blocks using the key |draw| which +% are drawn with their own characteristics). % % \medskip % \begin{Verbatim} % \setlength{\arrayrulewidth}{1pt} % \begin{NiceTabular}{cccc}[~emphase#hvlines@,rules/color=blue] % rose & tulipe & marguerite & dahlia \\ -% violette & \Block{2-2}{\LARGE\color{blue} fleurs} & & souci \\ +% violette & \Block[draw=red]{2-2}{\LARGE fleurs} & & souci \\ % pervenche & & & lys \\ % arum & iris & jacinthe & muguet % \end{NiceTabular} @@ -938,7 +953,7 @@ version 2005/12/01 or later. % \setlength{\arrayrulewidth}{1pt} % \begin{NiceTabular}{cccc}[hvlines,rules/color=blue] % rose & tulipe & marguerite & dahlia \\ -% violette & \Block{2-2}{\LARGE\color{blue} fleurs} & & souci \\ +% violette & \Block[draw=red]{2-2}{\LARGE fleurs} & & souci \\ % pervenche & & & lys \\ % arum & iris & jacinthe & muguet % \end{NiceTabular} @@ -2074,9 +2089,9 @@ version 2005/12/01 or later. % \Vdots & \Ddots & \Vdots & \Hdotsfor{1} & \Vdots & \Ddots & \Vdots \\ % C[a_n^{(p)},a_1] & \Cdots & C[a_n^{(p)},a_n] & & C[a_n^{(p)},a_1^{(p)}] & \Cdots & C[a_n^{(p)},a_n^{(p)}] % \end{bNiceMatrix}\] - - - +% +% +% % % \subsection{How to generate the continuous dotted lines transparently} % @@ -2314,7 +2329,7 @@ version 2005/12/01 or later. % For the legibility of the code, an alternative syntax is provided: it's % possible to give the instructions of the |\code-after| at the end of the % environment, after the keyword |\CodeAfter| (for an example, cf. -% p.~\pageref{example-CodeAfter}). \colorbox{yellow!50}{\textbf{New 5.5}}\enskip +% p.~\pageref{example-CodeAfter}). \colorbox{yellow!30}{New 5.5}\enskip % Before the version 5.5, it was necessary, in some circonstancies, to put the % keyword |\omit| before |\CodeAfter|. Since version~5.5, one must never put~|\omit|. % @@ -2889,9 +2904,6 @@ version 2005/12/01 or later. % TeX world, the spaces after a control sequence are discarded and the elements % between curly braces are considered as a whole. % -% \bigskip -% The following example has been composed with XeLaTeX with \pkg{unicode-math}, -% which allows the use of greek letters directly in the TeX source. % % \medskip % \begin{scope} @@ -2922,6 +2934,24 @@ version 2005/12/01 or later. % environment of LaTeX which only put TeX commands before and after the content.} % % +% \subsection{Color of the delimiters} +% +% For the environements with delimiters (|{pNiceArray}|, |{pNiceMatrix}|, etc.), +% it's possible to change the color of the delimiters with the key +% |delimiters-color|. +% +% \medskip +% \begin{BVerbatim}[boxwidth=12cm,baseline=c] +% $\begin{bNiceMatrix}[delimiters-color=red] +% 1 & 2 \\ +% 3 & 4 +% \end{bNiceMatrix}$ +% \end{BVerbatim} +% $\begin{bNiceMatrix}[delimiters-color=red] +% 1 & 2 \\ +% 3 & 4 +% \end{bNiceMatrix}$ +% % % \subsection{The environment \{NiceArrayWithDelims\}} % @@ -2963,7 +2993,7 @@ version 2005/12/01 or later. % \textbf{Caution} : By default, no node is created in a empty cell. % % \smallskip -% \colorbox{yellow!50}{\textbf{New 5.6}}\enskip +% \colorbox{yellow!30}{New 5.6}\enskip % However, it's possible to impose the creation of a node with the command |\NotEmpty|. % \footnote{One should note that, with that command, the cell is considered as % non-empty, which has consequencies for the continuous dotted lines (cf. @@ -4026,64 +4056,34 @@ version 2005/12/01 or later. % \end{multicols} % % -% \subsection{How to highlight cells of the matrix} +% \subsection{How to highlight cells of a matrix} % % % \label{highlight} -% The following examples require Tikz (by default, \pkg{nicematrix} only loads -% \textsc{pgf}) and the Tikz library |fit|. The following lines in the preamble -% of your document do the job: -% \begin{verbatim} -% \usepackage{tikz} -% \usetikzlibrary{fit} -% \end{verbatim} % % \medskip -% In order to highlight a cell of a matrix, it's possible to ``draw'' one of the -% correspondant nodes (the ``normal node'', the ``medium node'' or the ``large -% node''). In the following example, we use the ``large nodes'' of the diagonal -% of the matrix (with the Tikz key ``|name suffix|'', it's easy to use the -% ``large nodes''). -% -% We redraw the nodes with other nodes by using the Tikz library |fit|. Since we -% want to redraw the nodes exactly, we have to set |inner sep = 0 pt| (if we -% don't do that, the new nodes will be larger that the nodes created by -% \pkg{nicematrix}). +% In order to highlight a cell of a matrix, it's possible to ``draw'' that cell +% with the key |draw| of the command |\Block| (this is one of the uses of a +% mono-cell block\footnote{We recall that, if the first mandatory argument of +% the command |\Block| is left empty, that means that the block is a mono-cell block}). % % \label{example-CodeAfter} % +% % \begin{Verbatim} -% $\begin{pNiceArray}{>{\strut}cccc}[create-large-nodes,margin,extra-margin = 2pt] -% a_{11} & a_{12} & a_{13} & a_{14} \\ -% a_{21} & a_{22} & a_{23} & a_{24} \\ -% a_{31} & a_{32} & a_{33} & a_{34} \\ -% a_{41} & a_{42} & a_{43} & a_{44} \\ -% \CodeAfter -% \begin{tikzpicture}[~emphase#name suffix = -large@, -% every node/.style = {draw,~emphase#inner sep = 0 pt@}] -% \node [fit = (1-1)] {} ; -% \node [fit = (2-2)] {} ; -% \node [fit = (3-3)] {} ; -% \node [fit = (4-4)] {} ; -% \end{tikzpicture} +% $\begin{pNiceArray}{>{\strut}cccc}[margin,rules/color=blue] +% ~emphase#\Block[draw]{}{a_{11}}@ & a_{12} & a_{13} & a_{14} \\ +% a_{21} & \Block[draw]{}{a_{22}} & a_{23} & a_{24} \\ +% a_{31} & a_{32} & \Block[draw]{}{a_{33}} & a_{34} \\ +% a_{41} & a_{42} & a_{43} & \Block[draw]{}{a_{44}} \\ % \end{pNiceArray}$ % \end{Verbatim} -% -% \[\begin{pNiceArray}{>{\strut}cccc}[create-large-nodes,margin,extra-margin = 2pt] -% a_{11} & a_{12} & a_{13} & a_{14} \\ -% a_{21} & a_{22} & a_{23} & a_{24} \\ -% a_{31} & a_{32} & a_{33} & a_{34} \\ -% a_{41} & a_{42} & a_{43} & a_{44} \\ -% \CodeAfter -% \begin{tikzpicture}[name suffix = -large, -% every node/.style = {draw,inner sep = 0 pt}] -% \node [fit = (1-1)] {} ; -% \node [fit = (2-2)] {} ; -% \node [fit = (3-3)] {} ; -% \node [fit = (4-4)] {} ; -% \end{tikzpicture} +% \[\begin{pNiceArray}{>{\strut}cccc}[margin,rules/color=blue] +% \Block[draw]{}{a_{11}} & a_{12} & a_{13} & a_{14} \\ +% a_{21} & \Block[draw]{}{a_{22}} & a_{23} & a_{24} \\ +% a_{31} & a_{32} & \Block[draw]{}{a_{33}} & a_{34} \\ +% a_{41} & a_{42} & a_{43} & \Block[draw]{}{a_{44}} \\ % \end{pNiceArray}\] -% % % We should remark that the rules we have drawn are drawn \emph{after} the % construction of the array and thus, they don't spread the cells of the array. @@ -4095,13 +4095,23 @@ version 2005/12/01 or later. % % \vspace{1cm} % It's possible to color a row with |\rowcolor| in the |code-before| (or with -% |\rowcolor| of \pkg{colortbl} in the first cell of the row). However, it's not -% possible to do a fine tuning. That's why we describe now method to highlight a -% row of the matrix. We create a rectangular Tikz node which encompasses the -% nodes of the second row with the Tikz library \pkg{fit}. This Tikz node is -% filled after the construction of the matrix. In order to see the text -% \emph{under} this node, we have to use transparency with the |blend mode| -% equal to |multiply|. +% |\rowcolor| in the first cell of the row if the key |colortbl-like| is used). +% However, it's not possible to do a fine tuning. That's why we describe now a +% method to highlight a row of the matrix. We create a rectangular Tikz node +% which encompasses the nodes of the second row with the Tikz library \pkg{fit}. +% This Tikz node is filled after the construction of the matrix. In order to see +% the text \emph{under} this node, we have to use transparency with the +% |blend mode| equal to |multiply|. +% +% +% \medskip +% That example and the following ones require Tikz (by default, \pkg{nicematrix} +% only loads \textsc{pgf}) and the Tikz library |fit|. The following lines in +% the preamble of your document do the job: +% \begin{verbatim} +% \usepackage{tikz} +% \usetikzlibrary{fit} +% \end{verbatim} % % \tikzset{highlight/.style={rectangle, % fill=red!15, @@ -4119,19 +4129,21 @@ version 2005/12/01 or later. % inner sep=1pt, % fit = ~#1}} % -% $\begin{bNiceMatrix}[~emphase#code-after = {\tikz \node [highlight = (2-1) (2-3)] {} ;}@] +% +% $\begin{bNiceMatrix} % 0 & \Cdots & 0 \\ % 1 & \Cdots & 1 \\ -% 0 & \Cdots & 0 +% 0 & \Cdots & 0 \\ +% ~emphase#\CodeAfter \tikz \node [highlight = (2-1) (2-3)] {} ;@ % \end{bNiceMatrix}$ % \end{Verbatim} -% -% \[\begin{bNiceMatrix}[code-after = {\tikz \node [highlight = (2-1) (2-3)] {} ;}] +% \[\begin{bNiceMatrix} % 0 & \Cdots & 0 \\ % 1 & \Cdots & 1 \\ -% 0 & \Cdots & 0 +% 0 & \Cdots & 0 \\ +% \CodeAfter \tikz \node [highlight = (2-1) (2-3)] {} ; % \end{bNiceMatrix}\] -% +% % % % \vspace{1cm} @@ -5144,6 +5156,15 @@ version 2005/12/01 or later. \tl_new:N \l_@@_rules_color_tl % \end{macrocode} % +% +% \bigskip +% This boolean will be used only to detect in an expandable way whether we are +% at the beginning of the (potential) column zero, in order to raise an error if +% |\Hdotsfor| is used in that column. +% \begin{macrocode} +\bool_new:N \g_@@_after_col_zero_bool +% \end{macrocode} +% % \bigskip % A kind of false row will be inserted at the end of the array for the % construction of the |col| nodes (and also to fix the width of the columns when @@ -5158,7 +5179,7 @@ version 2005/12/01 or later. % \bigskip % It's possible to use the command |\NotEmpty| to specify explicitely that a % cell must be considered as non empty by \pkg{nicematrix} (the Tikz nodes are -% constructed only the non empty cells). +% constructed only in the non empty cells). % \begin{macrocode} \bool_new:N \g_@@_not_empty_cell_bool % \end{macrocode} @@ -5220,7 +5241,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% The following sequence will contain the caracteristics of the blocks of the +% The following sequence will contain the characteristics of the blocks of the % array, specified by the command |\Block|. Each block is represented by 6 % components surrounded by braces: % @@ -5256,6 +5277,17 @@ version 2005/12/01 or later. % blocks corresponding to the dotted lines). % % \medskip +% The final user may decide to ``stroke'' a block (using, for example, the key +% |color=red!15| when using the command |\Block|). In that case, the rules +% specified, for instance, by |hvlines| must not be drawn around the block. +% That's why we keep the information of all that stroken blocks in the following +% sequence. +% \begin{macrocode} +\seq_new:N \g_@@_pos_of_stroken_blocks_seq +% \end{macrocode} +% +% +% \medskip % We are able to determine the number of columns specified in the preamble (for % the environments with explicit preamble, of course and without the potential % exterior columns). @@ -5263,12 +5295,32 @@ version 2005/12/01 or later. \int_new:N \g_@@_static_num_of_col_int % \end{macrocode} % +% \medskip +% The following token lists correspond to the keys |fill| and |draw| of +% a command |\Block|. +% \begin{macrocode} +\tl_new:N \l_@@_fill_tl +\tl_new:N \l_@@_draw_tl +% \end{macrocode} +% % \medskip -% Used for the color of the blocks. +% The following token list correspond to the key |color| of the command +% |\Block|. However, as of now (v. 5.7 of \pkg{nicematrix}), the key |color| +% linked to |fill| with an error. We will give to the key |color| of |\Block| +% its new meaning in a few months (with its new definition, the key |color| will +% draw the frame with the given color but also color the content of the block +% (that is to say the text) as does the key |color| of a Tikz node). % \begin{macrocode} \tl_new:N \l_@@_color_tl % \end{macrocode} -% +% +% \medskip +% Here is the dimension for the width of the rule when a block (created by +% |\Block|) is stroked. +% \begin{macrocode} +\dim_new:N \l_@@_line_width_dim +% \end{macrocode} +% % \medskip % The parameter of position of the label of a block (|c|, |r| or |l|). % \begin{macrocode} @@ -5844,7 +5896,13 @@ version 2005/12/01 or later. \tl_new:N \l_@@_xdots_color_tl % \end{macrocode} % -% \medskip +% \bigskip +% The following token list corresponds to the key |delimiters-color|. +% \begin{macrocode} +\tl_new:N \l_@@_delimiters_color_tl +% \end{macrocode} +% +% \bigskip % Sometimes, we want to have several arrays vertically juxtaposed in order to % have an alignment of the columns of these arrays. To acheive this goal, one % may wish to use the same width for all the columns (for example with the @@ -6143,6 +6201,8 @@ version 2005/12/01 or later. % \begin{macrocode} \keys_define:nn { NiceMatrix / NiceMatrixOptions } { + delimiters-color .tl_set:N = \l_@@_delimiters_color_tl , + delimiters-color .value_required:n = true , last-col .code:n = \tl_if_empty:nF { #1 } { \@@_error:n { last-col~non~empty~for~NiceMatrixOptions } } \int_zero:N \l_@@_last_col_int , @@ -6247,6 +6307,8 @@ version 2005/12/01 or later. r .code:n = \tl_set:Nn \l_@@_type_of_col_tl r , small .bool_set:N = \l_@@_small_bool , small .value_forbidden:n = true , + delimiters-color .tl_set:N = \l_@@_delimiters_color_tl , + delimiters-color .value_required:n = true , unknown .code:n = \@@_error:n { Unknown~option~for~NiceMatrix } } % \end{macrocode} @@ -6277,6 +6339,8 @@ version 2005/12/01 or later. notes / bottomrule .default:n = true , tabularnote .tl_set:N = \l_@@_tabularnote_tl , tabularnote .value_required:n = true , + delimiters-color .tl_set:N = \l_@@_delimiters_color_tl , + delimiters-color .value_required:n = true , unknown .code:n = \@@_error:n { Unknown~option~for~NiceArray } } % \end{macrocode} @@ -6392,7 +6456,7 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Npn \@@_begin_of_row: { - \int_gincr:N \c@iRow + \refstepcounter { iRow } \dim_gset_eq:NN \g_@@_dp_ante_last_row_dim \g_@@_dp_last_row_dim \dim_gset:Nn \g_@@_dp_last_row_dim { \box_dp:N \@arstrutbox } \dim_gset:Nn \g_@@_ht_last_row_dim { \box_ht:N \@arstrutbox } @@ -6733,6 +6797,7 @@ version 2005/12/01 or later. \cs_new_protected:Npn \@@_everycr_i: { \int_gzero:N \c@jCol + \bool_gset_false:N \g_@@_after_col_zero_bool \bool_if:NF \g_@@_row_of_col_done_bool { \@@_create_row_node: @@ -7073,10 +7138,14 @@ version 2005/12/01 or later. % \begin{macrocode} \seq_gclear:N \g_@@_blocks_seq \seq_gclear:N \g_@@_pos_of_blocks_seq - \seq_gclear:N \g_@@_pos_of_xdots_seq % \end{macrocode} % In fact, the sequence |\g_@@_pos_of_blocks_seq| will also contain the % positions of the cells with a |\diagbox|. +% +% \begin{macrocode} + \seq_gclear:N \g_@@_pos_of_stroken_blocks_seq + \seq_gclear:N \g_@@_pos_of_xdots_seq +% \end{macrocode} % % \begin{macrocode} \tl_if_exist:cT { g_@@_code_before_ \int_use:N \g_@@_env_int _ tl } @@ -7455,6 +7524,8 @@ version 2005/12/01 or later. \hbox_set:Nn \l_tmpa_box { \c_math_toggle_token + \tl_if_empty:NF \l_@@_delimiters_color_tl + { \color { \l_@@_delimiters_color_tl } } \left #1 \vcenter { @@ -7688,6 +7759,9 @@ version 2005/12/01 or later. \@@_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 } + C { \@@_error:nn { old~column~type } C } + L { \@@_error:nn { old~column~type } L } + R { \@@_error:nn { old~column~type } R } \q_stop { } } { @@ -7963,7 +8037,7 @@ version 2005/12/01 or later. % \bigskip % The following command is \emph{always} used by |{NiceArrayWithDelims}| (even % if, in fact, there is no tabular notes: in fact, it's not possible to know -% whether there is or not before the composition of the blocks). +% whether there is tabular notes or not before the composition of the blocks). % \begin{macrocode} \cs_new_protected:Npn \@@_use_arraybox_with_notes_c: { @@ -8511,6 +8585,7 @@ version 2005/12/01 or later. { > { + \bool_gset_true:N \g_@@_after_col_zero_bool \@@_begin_of_row: % \end{macrocode} % The contents of the cell is constructed in the box |\l_@@_cell_box| because we @@ -10381,8 +10456,15 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new:Npn \@@_Hdotsfor: { - \int_compare:nNnTF \c@jCol = 0 - { \@@_error:n { Hdotsfor~in~col~0 } } + \int_compare:nNnTF \c@jCol = 0 + { + \bool_if:NTF \g_@@_after_col_zero_bool + { + \multicolumn { 1 } { c } { } + \@@_Hdotsfor_i + } + { \@@_fatal:n { Hdotsfor~in~col~0 } } + } { \multicolumn { 1 } { c } { } \@@_Hdotsfor_i @@ -10416,7 +10498,7 @@ version 2005/12/01 or later. #1 , #3 , down = \exp_not:n { #4 } , up = \exp_not:n { #5 } } - } + } \prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { c } { } } } } @@ -11086,6 +11168,9 @@ version 2005/12/01 or later. } } % \end{macrocode} +% +% +% % % \bigskip % \subsection*{The vertical rules} @@ -11189,6 +11274,8 @@ version 2005/12/01 or later. { \@@_test_if_vline_in_block:nnnn ##1 } \seq_map_inline:Nn \g_@@_pos_of_xdots_seq { \@@_test_if_vline_in_block:nnnn ##1 } + \seq_map_inline:Nn \g_@@_pos_of_stroken_blocks_seq + { \@@_test_if_vline_in_stroken_block:nnnn ##1 } \clist_if_empty:NF \l_@@_except_corners_clist \@@_test_in_corner_v: \bool_if:NTF \g_tmpa_bool @@ -11364,6 +11451,8 @@ version 2005/12/01 or later. { \@@_test_if_hline_in_block:nnnn ##1 } \seq_map_inline:Nn \g_@@_pos_of_xdots_seq { \@@_test_if_hline_in_block:nnnn ##1 } + \seq_map_inline:Nn \g_@@_pos_of_stroken_blocks_seq + { \@@_test_if_hline_in_stroken_block:nnnn ##1 } \clist_if_empty:NF \l_@@_except_corners_clist \@@_test_in_corner_h: \bool_if:NTF \g_tmpa_bool { @@ -11565,7 +11654,34 @@ version 2005/12/01 or later. } % \end{macrocode} % +% \begin{macrocode} +\cs_new_protected:Npn \@@_test_if_hline_in_stroken_block:nnnn #1 #2 #3 #4 + { + \bool_lazy_all:nT + { + { \int_compare_p:nNn \l_tmpa_tl > { #1 - 1 } } + { \int_compare_p:nNn \l_tmpa_tl < { #3 + 2 } } + { \int_compare_p:nNn \l_tmpb_tl > { #2 - 1 } } + { \int_compare_p:nNn \l_tmpb_tl < { #4 + 1 } } + } + { \bool_gset_false:N \g_tmpa_bool } + } +% \end{macrocode} % +% \begin{macrocode} +\cs_new_protected:Npn \@@_test_if_vline_in_stroken_block:nnnn #1 #2 #3 #4 + { + \bool_lazy_all:nT + { + { \int_compare_p:nNn \l_tmpa_tl > { #1 - 1 } } + { \int_compare_p:nNn \l_tmpa_tl < { #3 + 1 } } + { \int_compare_p:nNn \l_tmpb_tl > { #2 - 1 } } + { \int_compare_p:nNn \l_tmpb_tl < { #4 + 2 } } + } + { \bool_gset_false:N \g_tmpa_bool } + } +% \end{macrocode} +% % \bigskip % \subsubsection*{The key except-corners} % @@ -12400,8 +12516,8 @@ version 2005/12/01 or later. % % \bigskip % The options of the command |\Block| will be analyzed first in the cell of the -% array (and once again when the block will be put in the array in the -% |code-after|). Here is the set of keys for the first pass. +% array (and once again when the block will be put in the array). +% Here is the set of keys for the first pass. % \begin{macrocode} \keys_define:nn { NiceMatrix / Block / FirstPass } { @@ -12411,6 +12527,12 @@ version 2005/12/01 or later. r .value_forbidden:n = true , c .code:n = \tl_set:Nn \l_@@_pos_of_block_tl c , c .value_forbidden:n = true , +% \end{macrocode} +% The two following lines will be uncommented when we will give to the key +% |color| its new definition. +% \begin{macrocode} + % color .tl_set:N = \l_@@_color_tl , + % color .value_required:n = true , } % \end{macrocode} % @@ -12418,8 +12540,9 @@ version 2005/12/01 or later. % The following command |\@@_Block:| will be linked to |\Block| in the % environments of \pkg{nicematrix}. We define it with % |\NewExpandableDocumentCommand| because it has an optional argument between -% |<| and |>| (for TeX instructions put before the math mode of the label). It's -% mandatory to use an expandable command. +% |<| and |>| (for TeX instructions put before the math mode of the label and +% before the beginning of the small array of the block). It's mandatory to use +% an expandable command. % % \begin{macrocode} \NewExpandableDocumentCommand \@@_Block: { O { } m D < > { } m } @@ -12444,17 +12567,21 @@ 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 |#5| is the -% label of the block. +% 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. % \begin{macrocode} \cs_new_protected:Npn \@@_Block_ii:nnnnn #1 #2 #3 #4 #5 { % \end{macrocode} % % \begin{macrocode} - \tl_if_empty:NTF \l_@@_cell_type_tl + \int_compare:nNnTF { #2 } = 1 + { + \tl_if_empty:NTF \l_@@_cell_type_tl + { \tl_set:Nn \l_@@_pos_of_block_tl c } + { \tl_set_eq:NN \l_@@_pos_of_block_tl \l_@@_cell_type_tl } + } { \tl_set:Nn \l_@@_pos_of_block_tl c } - { \tl_set_eq:NN \l_@@_pos_of_block_tl \l_@@_cell_type_tl } % \end{macrocode} % % \medskip @@ -12488,7 +12615,7 @@ version 2005/12/01 or later. % \end{macrocode} % Now, |\l_tmpa_tl| contains an ``object'' corresponding to the position of the % block whith four components, each of them surrounded by curly brackets: -% +% % |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}|. % % We store this information in the sequence |\g_@@_pos_of_blocks_seq|. @@ -12553,13 +12680,13 @@ version 2005/12/01 or later. % command seems to be bugged: it doesn't work in XeLaTeX when \pkg{fontspec} is % loaded. % \begin{macrocode} - \int_compare:nNnT { #2 } = 1 \set@color - \bool_if:NTF \l_@@_NiceTabular_bool - { - \group_begin: - \cs_set:Npn \arraystretch { 1 } - \dim_set_eq:NN \extrarowheight \c_zero_dim - #4 + \tl_if_empty:NTF \l_@@_color_tl + { \int_compare:nNnT { #2 } = 1 \set@color } + { \color { \l_@@_color_tl } } + \group_begin: + \cs_set:Npn \arraystretch { 1 } + \dim_set_eq:NN \extrarowheight \c_zero_dim + #4 % \end{macrocode} % If the box is rotated (the key |\rotate| may be in the previous |#4|), the % tabular used for the content of the cell will be constructed with a format @@ -12568,29 +12695,23 @@ version 2005/12/01 or later. % the tabular is the same as the external alignment of the tabular (that is to % say the position of the block in its zone of merged cells). % \begin{macrocode} - \bool_if:NT \g_@@_rotate_bool - { \tl_set:Nn \l_@@_pos_of_block_tl c } + \bool_if:NT \g_@@_rotate_bool { \tl_set:Nn \l_@@_pos_of_block_tl c } + \bool_if:NTF \l_@@_NiceTabular_bool + { \exp_args:Nnx \begin { tabular } { @ { } \l_@@_pos_of_block_tl @ { } } #5 \end { tabular } - \group_end: } { - \group_begin: - \cs_set:Npn \arraystretch { 1 } - \dim_set_eq:NN \extrarowheight \c_zero_dim - #4 - \bool_if:NT \g_@@_rotate_bool - { \tl_set:Nn \l_@@_pos_of_block_tl c } \c_math_toggle_token \exp_args:Nnx \begin { array } { @ { } \l_@@_pos_of_block_tl @ { } } #5 \end { array } \c_math_toggle_token - \group_end: } + \group_end: } \bool_if:NT \g_@@_rotate_bool { @@ -12721,17 +12842,25 @@ version 2005/12/01 or later. % array \emph{after the construction of the array} (by using \textsc{pgf}). % % \medskip -% The key |tikz| is for Tikz options used when the \textsc{pgf} node of the -% block is created (the ``normal'' block node and not the ``short'' one nor the -% ``medium'' one). \textbf{In fact, as of now, it is \emph{not} documented}. Is -% it really a good idea to provide such a key? % \begin{macrocode} \keys_define:nn { NiceMatrix / Block / SecondPass } { - tikz .tl_set:N = \l_@@_tikz_tl , - tikz .value_required:n = true , - color .tl_set:N = \l_@@_color_tl , + fill .tl_set:N = \l_@@_fill_tl , + fill .value_required:n = true , + draw .tl_set:N = \l_@@_draw_tl , + draw .default:n = default , +% \end{macrocode} +% The following definition for the key |color| will be deleted when we will give +% to the key |color| of the command |\Block| its new definition. It will be +% replaced by the line which is commented. +% \begin{macrocode} + color .code:n = + \@@_error:n { Key~color~for~Block } + \tl_set:Nn \l_@@_fill_tl { #1 } , + % color .code:n = \color { #1 } \tl_set:Nn \l_@@_draw_tl { #1 } , color .value_required:n = true , + line-width .dim_set:N = \l_@@_line_width_dim , + line-width .value_required:n = true , l .code:n = \tl_set:Nn \l_@@_pos_of_block_tl l , l .value_forbidden:n = true , r .code:n = \tl_set:Nn \l_@@_pos_of_block_tl r , @@ -12762,11 +12891,11 @@ version 2005/12/01 or later. % The group is for the keys. % \begin{macrocode} \group_begin: - \keys_set:nn { NiceMatrix / Block / SecondPass} { #5 } + \keys_set:nn { NiceMatrix / Block / SecondPass } { #5 } % \end{macrocode} % % The integer |\l_@@_last_row_int| will be the last row of the block and -% |\l_@@_last_col_int| it's last column. +% |\l_@@_last_col_int| its last column. % \begin{macrocode} \int_zero_new:N \l_@@_last_row_int \int_zero_new:N \l_@@_last_col_int @@ -12789,12 +12918,29 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} - \tl_if_empty:NF \l_@@_color_tl + \bool_lazy_or:nnT + { ! \tl_if_empty_p:N \l_@@_draw_tl } + { \dim_compare_p:nNn \l_@@_line_width_dim > \c_zero_dim } + { + \tl_gput_right:Nx \g_nicematrix_code_after_tl + { + \@@_stroke_block:nnn + { #5 } + { #1 - #2 } + { \int_use:N \l_@@_last_row_int - \int_use:N \l_@@_last_col_int } + } + \seq_gput_right:Nn \g_@@_pos_of_stroken_blocks_seq + { { #1 } { #2 } { #3 } { #4 } } + } +% \end{macrocode} +% +% \begin{macrocode} + \tl_if_empty:NF \l_@@_fill_tl { \tl_gput_right:Nx \g_nicematrix_code_before_tl { \exp_not:N \rectanglecolor - { \l_@@_color_tl } + { \l_@@_fill_tl } { #1 - #2 } { \int_use:N \l_@@_last_row_int - \int_use:N \l_@@_last_col_int } } @@ -12897,7 +13043,6 @@ version 2005/12/01 or later. % and the four coordinates of two opposite corner points of the rectangle. % \begin{macrocode} \begin { pgfscope } - \exp_args:Nx \pgfset { \l_@@_tikz_tl } \@@_pgf_rect_node:nnnnn { \@@_env: - #1 - #2 - block } \l_tmpb_dim \l_tmpa_dim \l_tmpd_dim \l_tmpc_dim @@ -13036,17 +13181,20 @@ version 2005/12/01 or later. % % \medskip % If the number of rows is different of $1$, we will put the label of the block -% in using the short node (the label of the block has been composed in +% by using the short node (the label of the block has been composed in % |\l_@@_cell_box|). % \begin{macrocode} { % \end{macrocode} % If we are in the first column, we must put the block as if it was with the key~|r|. % \begin{macrocode} - \int_compare:nNnT \c@jCol = 0 + \int_compare:nNnT { #2 } = 0 { \tl_set:Nn \l_@@_pos_of_block_tl r } - \int_compare:nNnT \c@jCol = \l_@@_last_col_int - { \tl_set:Nn \l_@@_pos_of_block_tl l } + \bool_if:nT \g_@@_last_col_found_bool + { + \int_compare:nNnT { #2 } = \g_@@_col_total_int + { \tl_set:Nn \l_@@_pos_of_block_tl l } + } \pgftransformshift { \pgfpointanchor @@ -13079,6 +13227,76 @@ version 2005/12/01 or later. } % \end{macrocode} % +% +% % \bigskip +% The first argument of |\@@_stroke_block:nnn| is a list of options for the +% rectangle that you will stoke. The second argument is the upper-left cell of +% the block (with, as usual, the syntex $i$|-|$j$) and the third is the last +% cell of the block (with the same syntax). +% \begin{macrocode} +\cs_new_protected:Npn \@@_stroke_block:nnn #1 #2 #3 + { + \group_begin: + \tl_clear:N \l_@@_draw_tl + \dim_set_eq:NN \l_@@_line_width_dim \arrayrulewidth + \keys_set_known:nn { NiceMatrix / BlockStroke } { #1 } + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgf@relevantforpicturesizefalse + \tl_if_empty:NF \l_@@_draw_tl + { +% \end{macrocode} +% If the user has used the key |color| of the command |\Block| without value, +% the color fixed by |\arrayrulecolor| is used. +% \begin{macrocode} + \str_if_eq:VnTF \l_@@_draw_tl { default } + { \CT@arc@ } + { \pgfsetstrokecolor { \l_@@_draw_tl } } + } + \@@_cut_on_hyphen:w #2 \q_stop + \bool_lazy_and:nnT + { \int_compare_p:n { \l_tmpa_tl <= \c@iRow } } + { \int_compare_p:n { \l_tmpb_tl <= \c@jCol } } + { + \@@_qpoint:n { row - \l_tmpa_tl } + \dim_set:Nn \l_tmpb_dim { \pgf@y } + \@@_qpoint:n { col - \l_tmpb_tl } + \dim_set:Nn \l_tmpc_dim { \pgf@x } + \@@_cut_on_hyphen:w #3 \q_stop + \int_compare:nNnT \l_tmpa_tl > \c@iRow + { \tl_set:Nx \l_tmpa_tl { \int_use:N \c@iRow } } + \int_compare:nNnT \l_tmpb_tl > \c@jCol + { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } } + \@@_qpoint:n { row - \@@_succ:n \l_tmpa_tl } + \dim_set:Nn \l_tmpa_dim { \pgf@y } + \@@_qpoint:n { col - \@@_succ:n \l_tmpb_tl } + \dim_set:Nn \l_tmpd_dim { \pgf@x } + \pgfpathrectanglecorners + { \pgfpoint \l_tmpc_dim \l_tmpb_dim } + { \pgfpoint \l_tmpd_dim \l_tmpa_dim } + \pgfsetlinewidth { 1.1 \l_@@_line_width_dim } + \pgfusepathqstroke + } + \endpgfpicture + \group_end: + } +% \end{macrocode} +% +% Here is the set of keys for the command |\@@_stroke_block:nnn|. +% \begin{macrocode} +\keys_define:nn { NiceMatrix / BlockStroke } + { +% \end{macrocode} +% We will uncomment the following line when we will give to the key |color| of +% the command |\Block| its new definition. +% \begin{macrocode} + % color .tl_set:N = \l_@@_draw_tl , + draw .tl_set:N = \l_@@_draw_tl , + draw .default:n = default , + line-width .dim_set:N = \l_@@_line_width_dim , + } +% \end{macrocode} +% % \bigskip % \subsection*{How to draw the dotted lines transparently} % \begin{macrocode} @@ -13658,6 +13876,16 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} +\@@_msg_new:nn { Key~color~for~Block } + { + The~key~'color'~for~the~command~\token_to_str:N \Block\ + is~deprecated:~you~should~use~'fill'~instead.\\ + You~can~go~on~for~this~time~but~remember~that~that~key~ + will~be~deleted~in~a~future~version. + } +% \end{macrocode} +% +% \begin{macrocode} \@@_msg_new:nn { ampersand~in~light-syntax } { You~can't~use~an~ampersand~(\token_to_str &)~to~separate~columns~because @@ -13682,7 +13910,16 @@ version 2005/12/01 or later. } % \end{macrocode} % -% +% \begin{macrocode} +\@@_msg_new:nn { old~column~type } + { + The~column~type~'#1'~is~no~longer~defined~in~'nicematrix'.~ + Since~version~5.0,~you~have~to~use~'l',~'c'~and~'r'~instead~of~'L',~ + 'C'~and~'R'.~You~can~also~use~the~key~'define-L-C-R'.\\ + This~error~is~fatal. + } +% \end{macrocode} +% % \begin{macrocode} \@@_msg_new:nn { bad~value~for~baseline } { @@ -13712,7 +13949,7 @@ version 2005/12/01 or later. \@@_msg_new:nn { Hdotsfor~in~col~0 } { You~can't~use~\token_to_str:N \Hdotsfor\ in~an~exterior~column~of~ - the~array.~If~you~go~on,~the~corresponding~dotted~line~won't~be~drawn. + the~array.~This~error~is~fatal. } % \end{macrocode} % @@ -13882,6 +14119,7 @@ version 2005/12/01 or later. create-extra-nodes,~ create-medium-nodes,~ create-large-nodes,~ + delimiters-color,~ end-of-row,~ first-col,~ first-row,~ @@ -13932,6 +14170,7 @@ version 2005/12/01 or later. create-extra-nodes,~ create-medium-nodes,~ create-large-nodes,~ + delimiters-color,~ extra-left-margin,~ extra-right-margin,~ first-col,~ @@ -13989,6 +14228,7 @@ version 2005/12/01 or later. create-extra-nodes,~ create-medium-nodes,~ create-large-nodes,~ + delimiters-color,~ extra-left-margin,~ extra-right-margin,~ first-col,~ @@ -14486,6 +14726,12 @@ version 2005/12/01 or later. % Different behaviour for the mono-row blocks. % % New command |\NotEmpty|. +% +% \subsection*{Changes between versions 5.6 and 5.7} +% +% New key |delimiters-color| +% +% Keys |fill|, |draw| and |line-width| for the command |\Block|. % % \PrintIndex % diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index 595260e2658..a43579d0b61 100644 --- a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty +++ b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty @@ -18,9 +18,8 @@ %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% -\def\myfileversion{5.6} -\def\myfiledate{2020/11/08} - +\def\myfileversion{5.7} +\def\myfiledate{2020/11/23} \RequirePackage{pgfcore} \usepgfmodule{shapes} \RequirePackage{l3keys2e} @@ -283,6 +282,7 @@ \int_new:N \l__nicematrix_old_iRow_int \int_new:N \l__nicematrix_old_jCol_int \tl_new:N \l__nicematrix_rules_color_tl +\bool_new:N \g__nicematrix_after_col_zero_bool \bool_new:N \g__nicematrix_row_of_col_done_bool \bool_new:N \g__nicematrix_not_empty_cell_bool \tl_new:N \l__nicematrix_code_before_tl @@ -300,8 +300,12 @@ \seq_new:N \g__nicematrix_blocks_seq \seq_new:N \g__nicematrix_pos_of_blocks_seq \seq_new:N \g__nicematrix_pos_of_xdots_seq +\seq_new:N \g__nicematrix_pos_of_stroken_blocks_seq \int_new:N \g__nicematrix_static_num_of_col_int +\tl_new:N \l__nicematrix_fill_tl +\tl_new:N \l__nicematrix_draw_tl \tl_new:N \l__nicematrix_color_tl +\dim_new:N \l__nicematrix_line_width_dim \tl_new:N \l__nicematrix_pos_of_block_tl \tl_set:Nn \l__nicematrix_pos_of_block_tl { c } \bool_new:N \l__nicematrix_draw_first_bool @@ -470,6 +474,7 @@ \tl_new:N \l__nicematrix_end_of_row_tl \tl_set:Nn \l__nicematrix_end_of_row_tl { ; } \tl_new:N \l__nicematrix_xdots_color_tl +\tl_new:N \l__nicematrix_delimiters_color_tl \bool_new:N \l__nicematrix_max_delimiter_width_bool \keys_define:nn { NiceMatrix / xdots } { @@ -687,6 +692,8 @@ } \keys_define:nn { NiceMatrix / NiceMatrixOptions } { + delimiters-color .tl_set:N = \l__nicematrix_delimiters_color_tl , + delimiters-color .value_required:n = true , last-col .code:n = \tl_if_empty:nF { #1 } { \__nicematrix_error:n { last-col~non~empty~for~NiceMatrixOptions } } \int_zero:N \l__nicematrix_last_col_int , @@ -731,6 +738,8 @@ r .code:n = \tl_set:Nn \l__nicematrix_type_of_col_tl r , small .bool_set:N = \l__nicematrix_small_bool , small .value_forbidden:n = true , + delimiters-color .tl_set:N = \l__nicematrix_delimiters_color_tl , + delimiters-color .value_required:n = true , unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceMatrix } } \keys_define:nn { NiceMatrix / NiceArray } @@ -746,6 +755,8 @@ notes / bottomrule .default:n = true , tabularnote .tl_set:N = \l__nicematrix_tabularnote_tl , tabularnote .value_required:n = true , + delimiters-color .tl_set:N = \l__nicematrix_delimiters_color_tl , + delimiters-color .value_required:n = true , unknown .code:n = \__nicematrix_error:n { Unknown~option~for~NiceArray } } \keys_define:nn { NiceMatrix / pNiceArray } @@ -803,7 +814,7 @@ } \cs_new_protected:Npn \__nicematrix_begin_of_row: { - \int_gincr:N \c@iRow + \refstepcounter { iRow } \dim_gset_eq:NN \g__nicematrix_dp_ante_last_row_dim \g__nicematrix_dp_last_row_dim \dim_gset:Nn \g__nicematrix_dp_last_row_dim { \box_dp:N \@arstrutbox } \dim_gset:Nn \g__nicematrix_ht_last_row_dim { \box_ht:N \@arstrutbox } @@ -986,6 +997,7 @@ \cs_new_protected:Npn \__nicematrix_everycr_i: { \int_gzero:N \c@jCol + \bool_gset_false:N \g__nicematrix_after_col_zero_bool \bool_if:NF \g__nicematrix_row_of_col_done_bool { \__nicematrix_create_row_node: @@ -1140,6 +1152,7 @@ { \dim_gzero_new:N \g__nicematrix_max_cell_width_dim } \seq_gclear:N \g__nicematrix_blocks_seq \seq_gclear:N \g__nicematrix_pos_of_blocks_seq + \seq_gclear:N \g__nicematrix_pos_of_stroken_blocks_seq \seq_gclear:N \g__nicematrix_pos_of_xdots_seq \tl_if_exist:cT { g__nicematrix_code_before_ \int_use:N \g__nicematrix_env_int _ tl } { @@ -1343,6 +1356,8 @@ \hbox_set:Nn \l_tmpa_box { \c_math_toggle_token + \tl_if_empty:NF \l__nicematrix_delimiters_color_tl + { \color { \l__nicematrix_delimiters_color_tl } } \left #1 \vcenter { @@ -1455,6 +1470,9 @@ \__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 } + C { \__nicematrix_error:nn { old~column~type } C } + L { \__nicematrix_error:nn { old~column~type } L } + R { \__nicematrix_error:nn { old~column~type } R } \q_stop { } } { @@ -1972,6 +1990,7 @@ { > { + \bool_gset_true:N \g__nicematrix_after_col_zero_bool \__nicematrix_begin_of_row: \hbox_set:Nw \l__nicematrix_cell_box \__nicematrix_math_toggle_token: @@ -3107,7 +3126,14 @@ \cs_new:Npn \__nicematrix_Hdotsfor: { \int_compare:nNnTF \c@jCol = 0 - { \__nicematrix_error:n { Hdotsfor~in~col~0 } } + { + \bool_if:NTF \g__nicematrix_after_col_zero_bool + { + \multicolumn { 1 } { c } { } + \__nicematrix_Hdotsfor_i + } + { \__nicematrix_fatal:n { Hdotsfor~in~col~0 } } + } { \multicolumn { 1 } { c } { } \__nicematrix_Hdotsfor_i @@ -3614,6 +3640,8 @@ { \__nicematrix_test_if_vline_in_block:nnnn ##1 } \seq_map_inline:Nn \g__nicematrix_pos_of_xdots_seq { \__nicematrix_test_if_vline_in_block:nnnn ##1 } + \seq_map_inline:Nn \g__nicematrix_pos_of_stroken_blocks_seq + { \__nicematrix_test_if_vline_in_stroken_block:nnnn ##1 } \clist_if_empty:NF \l__nicematrix_except_corners_clist \__nicematrix_test_in_corner_v: \bool_if:NTF \g_tmpa_bool @@ -3734,6 +3762,8 @@ { \__nicematrix_test_if_hline_in_block:nnnn ##1 } \seq_map_inline:Nn \g__nicematrix_pos_of_xdots_seq { \__nicematrix_test_if_hline_in_block:nnnn ##1 } + \seq_map_inline:Nn \g__nicematrix_pos_of_stroken_blocks_seq + { \__nicematrix_test_if_hline_in_stroken_block:nnnn ##1 } \clist_if_empty:NF \l__nicematrix_except_corners_clist \__nicematrix_test_in_corner_h: \bool_if:NTF \g_tmpa_bool { @@ -3875,6 +3905,28 @@ } { \bool_gset_false:N \g_tmpa_bool } } +\cs_new_protected:Npn \__nicematrix_test_if_hline_in_stroken_block:nnnn #1 #2 #3 #4 + { + \bool_lazy_all:nT + { + { \int_compare_p:nNn \l_tmpa_tl > { #1 - 1 } } + { \int_compare_p:nNn \l_tmpa_tl < { #3 + 2 } } + { \int_compare_p:nNn \l_tmpb_tl > { #2 - 1 } } + { \int_compare_p:nNn \l_tmpb_tl < { #4 + 1 } } + } + { \bool_gset_false:N \g_tmpa_bool } + } +\cs_new_protected:Npn \__nicematrix_test_if_vline_in_stroken_block:nnnn #1 #2 #3 #4 + { + \bool_lazy_all:nT + { + { \int_compare_p:nNn \l_tmpa_tl > { #1 - 1 } } + { \int_compare_p:nNn \l_tmpa_tl < { #3 + 1 } } + { \int_compare_p:nNn \l_tmpb_tl > { #2 - 1 } } + { \int_compare_p:nNn \l_tmpb_tl < { #4 + 2 } } + } + { \bool_gset_false:N \g_tmpa_bool } + } \cs_new_protected:Npn \__nicematrix_compute_corners: { \seq_clear_new:N \l__nicematrix_empty_corner_cells_seq @@ -4299,6 +4351,8 @@ r .value_forbidden:n = true , c .code:n = \tl_set:Nn \l__nicematrix_pos_of_block_tl c , c .value_forbidden:n = true , + % color .tl_set:N = \l__nicematrix_color_tl , + % color .value_required:n = true , } \NewExpandableDocumentCommand \__nicematrix_Block: { O { } m D < > { } m } { @@ -4308,9 +4362,13 @@ \cs_new:Npn \__nicematrix_Block_i #1-#2 \q_stop { \__nicematrix_Block_ii:nnnnn { #1 } { #2 } } \cs_new_protected:Npn \__nicematrix_Block_ii:nnnnn #1 #2 #3 #4 #5 { - \tl_if_empty:NTF \l__nicematrix_cell_type_tl + \int_compare:nNnTF { #2 } = 1 + { + \tl_if_empty:NTF \l__nicematrix_cell_type_tl + { \tl_set:Nn \l__nicematrix_pos_of_block_tl c } + { \tl_set_eq:NN \l__nicematrix_pos_of_block_tl \l__nicematrix_cell_type_tl } + } { \tl_set:Nn \l__nicematrix_pos_of_block_tl c } - { \tl_set_eq:NN \l__nicematrix_pos_of_block_tl \l__nicematrix_cell_type_tl } \keys_set_known:nn { NiceMatrix / Block / FirstPass } { #3 } \tl_if_empty:nTF { #1 } { \int_set:Nn \l_tmpa_int { 100 } } @@ -4353,36 +4411,30 @@ \hbox_gset:cn { g__nicematrix_ block _ box _ \int_use:N \g__nicematrix_block_box_int _ box } { - \int_compare:nNnT { #2 } = 1 \set@color + \tl_if_empty:NTF \l__nicematrix_color_tl + { \int_compare:nNnT { #2 } = 1 \set@color } + { \color { \l__nicematrix_color_tl } } + \group_begin: + \cs_set:Npn \arraystretch { 1 } + \dim_set_eq:NN \extrarowheight \c_zero_dim + #4 + \bool_if:NT \g__nicematrix_rotate_bool { \tl_set:Nn \l__nicematrix_pos_of_block_tl c } \bool_if:NTF \l__nicematrix_NiceTabular_bool { - \group_begin: - \cs_set:Npn \arraystretch { 1 } - \dim_set_eq:NN \extrarowheight \c_zero_dim - #4 - \bool_if:NT \g__nicematrix_rotate_bool - { \tl_set:Nn \l__nicematrix_pos_of_block_tl c } \exp_args:Nnx \begin { tabular } { @ { } \l__nicematrix_pos_of_block_tl @ { } } #5 \end { tabular } - \group_end: } { - \group_begin: - \cs_set:Npn \arraystretch { 1 } - \dim_set_eq:NN \extrarowheight \c_zero_dim - #4 - \bool_if:NT \g__nicematrix_rotate_bool - { \tl_set:Nn \l__nicematrix_pos_of_block_tl c } \c_math_toggle_token \exp_args:Nnx \begin { array } { @ { } \l__nicematrix_pos_of_block_tl @ { } } #5 \end { array } \c_math_toggle_token - \group_end: } + \group_end: } \bool_if:NT \g__nicematrix_rotate_bool { @@ -4476,10 +4528,17 @@ } \keys_define:nn { NiceMatrix / Block / SecondPass } { - tikz .tl_set:N = \l__nicematrix_tikz_tl , - tikz .value_required:n = true , - color .tl_set:N = \l__nicematrix_color_tl , + fill .tl_set:N = \l__nicematrix_fill_tl , + fill .value_required:n = true , + draw .tl_set:N = \l__nicematrix_draw_tl , + draw .default:n = default , + color .code:n = + \__nicematrix_error:n { Key~color~for~Block } + \tl_set:Nn \l__nicematrix_fill_tl { #1 } , + % color .code:n = \color { #1 } \tl_set:Nn \l__nicematrix_draw_tl { #1 } , color .value_required:n = true , + line-width .dim_set:N = \l__nicematrix_line_width_dim , + line-width .value_required:n = true , l .code:n = \tl_set:Nn \l__nicematrix_pos_of_block_tl l , l .value_forbidden:n = true , r .code:n = \tl_set:Nn \l__nicematrix_pos_of_block_tl r , @@ -4496,7 +4555,7 @@ \cs_new_protected:Npn \__nicematrix_Block_iii:nnnnnn #1 #2 #3 #4 #5 #6 { \group_begin: - \keys_set:nn { NiceMatrix / Block / SecondPass} { #5 } + \keys_set:nn { NiceMatrix / Block / SecondPass } { #5 } \int_zero_new:N \l__nicematrix_last_row_int \int_zero_new:N \l__nicematrix_last_col_int \int_compare:nNnTF { #3 } > { 99 } @@ -4505,12 +4564,26 @@ \int_compare:nNnTF { #4 } > { 99 } { \int_set_eq:NN \l__nicematrix_last_col_int \c@jCol } { \int_set:Nn \l__nicematrix_last_col_int { #4 } } - \tl_if_empty:NF \l__nicematrix_color_tl + \bool_lazy_or:nnT + { ! \tl_if_empty_p:N \l__nicematrix_draw_tl } + { \dim_compare_p:nNn \l__nicematrix_line_width_dim > \c_zero_dim } + { + \tl_gput_right:Nx \g_nicematrix_code_after_tl + { + \__nicematrix_stroke_block:nnn + { #5 } + { #1 - #2 } + { \int_use:N \l__nicematrix_last_row_int - \int_use:N \l__nicematrix_last_col_int } + } + \seq_gput_right:Nn \g__nicematrix_pos_of_stroken_blocks_seq + { { #1 } { #2 } { #3 } { #4 } } + } + \tl_if_empty:NF \l__nicematrix_fill_tl { \tl_gput_right:Nx \g_nicematrix_code_before_tl { \exp_not:N \rectanglecolor - { \l__nicematrix_color_tl } + { \l__nicematrix_fill_tl } { #1 - #2 } { \int_use:N \l__nicematrix_last_row_int - \int_use:N \l__nicematrix_last_col_int } } @@ -4546,7 +4619,6 @@ \__nicematrix_qpoint:n { col - \__nicematrix_succ:n { \l__nicematrix_last_col_int } } \dim_set_eq:NN \l_tmpd_dim \pgf@x \begin { pgfscope } - \exp_args:Nx \pgfset { \l__nicematrix_tikz_tl } \__nicematrix_pgf_rect_node:nnnnn { \__nicematrix_env: - #1 - #2 - block } \l_tmpb_dim \l_tmpa_dim \l_tmpd_dim \l_tmpc_dim @@ -4640,10 +4712,13 @@ { \box_use_drop:N \l__nicematrix_cell_box } { } { } } { - \int_compare:nNnT \c@jCol = 0 + \int_compare:nNnT { #2 } = 0 { \tl_set:Nn \l__nicematrix_pos_of_block_tl r } - \int_compare:nNnT \c@jCol = \l__nicematrix_last_col_int - { \tl_set:Nn \l__nicematrix_pos_of_block_tl l } + \bool_if:nT \g__nicematrix_last_col_found_bool + { + \int_compare:nNnT { #2 } = \g__nicematrix_col_total_int + { \tl_set:Nn \l__nicematrix_pos_of_block_tl l } + } \pgftransformshift { \pgfpointanchor @@ -4674,6 +4749,55 @@ } \group_end: } +\cs_new_protected:Npn \__nicematrix_stroke_block:nnn #1 #2 #3 + { + \group_begin: + \tl_clear:N \l__nicematrix_draw_tl + \dim_set_eq:NN \l__nicematrix_line_width_dim \arrayrulewidth + \keys_set_known:nn { NiceMatrix / BlockStroke } { #1 } + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgf@relevantforpicturesizefalse + \tl_if_empty:NF \l__nicematrix_draw_tl + { + \str_if_eq:VnTF \l__nicematrix_draw_tl { default } + { \CT@arc@ } + { \pgfsetstrokecolor { \l__nicematrix_draw_tl } } + } + \__nicematrix_cut_on_hyphen:w #2 \q_stop + \bool_lazy_and:nnT + { \int_compare_p:n { \l_tmpa_tl <= \c@iRow } } + { \int_compare_p:n { \l_tmpb_tl <= \c@jCol } } + { + \__nicematrix_qpoint:n { row - \l_tmpa_tl } + \dim_set:Nn \l_tmpb_dim { \pgf@y } + \__nicematrix_qpoint:n { col - \l_tmpb_tl } + \dim_set:Nn \l_tmpc_dim { \pgf@x } + \__nicematrix_cut_on_hyphen:w #3 \q_stop + \int_compare:nNnT \l_tmpa_tl > \c@iRow + { \tl_set:Nx \l_tmpa_tl { \int_use:N \c@iRow } } + \int_compare:nNnT \l_tmpb_tl > \c@jCol + { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@jCol } } + \__nicematrix_qpoint:n { row - \__nicematrix_succ:n \l_tmpa_tl } + \dim_set:Nn \l_tmpa_dim { \pgf@y } + \__nicematrix_qpoint:n { col - \__nicematrix_succ:n \l_tmpb_tl } + \dim_set:Nn \l_tmpd_dim { \pgf@x } + \pgfpathrectanglecorners + { \pgfpoint \l_tmpc_dim \l_tmpb_dim } + { \pgfpoint \l_tmpd_dim \l_tmpa_dim } + \pgfsetlinewidth { 1.1 \l__nicematrix_line_width_dim } + \pgfusepathqstroke + } + \endpgfpicture + \group_end: + } +\keys_define:nn { NiceMatrix / BlockStroke } + { + % color .tl_set:N = \l__nicematrix_draw_tl , + draw .tl_set:N = \l__nicematrix_draw_tl , + draw .default:n = default , + line-width .dim_set:N = \l__nicematrix_line_width_dim , + } \cs_set_protected:Npn \__nicematrix_renew_matrix: { \RenewDocumentEnvironment { pmatrix } { } @@ -5003,6 +5127,13 @@ (and~you~try~to~use~'\l_keys_key_tl').~If~you~go~on,~ this~option~will~be~ignored. } +\__nicematrix_msg_new:nn { Key~color~for~Block } + { + The~key~'color'~for~the~command~\token_to_str:N \Block\ + is~deprecated:~you~should~use~'fill'~instead.\\ + You~can~go~on~for~this~time~but~remember~that~that~key~ + will~be~deleted~in~a~future~version. + } \__nicematrix_msg_new:nn { ampersand~in~light-syntax } { You~can't~use~an~ampersand~(\token_to_str &)~to~separate~columns~because @@ -5019,6 +5150,13 @@ The~key~'standard-cline'~is~available~only~in~the~preamble.\\ If~you~go~on~this~command~will~be~ignored. } +\__nicematrix_msg_new:nn { old~column~type } + { + The~column~type~'#1'~is~no~longer~defined~in~'nicematrix'.~ + Since~version~5.0,~you~have~to~use~'l',~'c'~and~'r'~instead~of~'L',~ + 'C'~and~'R'.~You~can~also~use~the~key~'define-L-C-R'.\\ + This~error~is~fatal. + } \__nicematrix_msg_new:nn { bad~value~for~baseline } { The~value~given~to~'baseline'~(\int_use:N \l_tmpa_int)~is~not~ @@ -5037,7 +5175,7 @@ \__nicematrix_msg_new:nn { Hdotsfor~in~col~0 } { You~can't~use~\token_to_str:N \Hdotsfor\ in~an~exterior~column~of~ - the~array.~If~you~go~on,~the~corresponding~dotted~line~won't~be~drawn. + the~array.~This~error~is~fatal. } \__nicematrix_msg_new:nn { bad~corner } { @@ -5158,6 +5296,7 @@ create-extra-nodes,~ create-medium-nodes,~ create-large-nodes,~ + delimiters-color,~ end-of-row,~ first-col,~ first-row,~ @@ -5205,6 +5344,7 @@ create-extra-nodes,~ create-medium-nodes,~ create-large-nodes,~ + delimiters-color,~ extra-left-margin,~ extra-right-margin,~ first-col,~ @@ -5255,6 +5395,7 @@ create-extra-nodes,~ create-medium-nodes,~ create-large-nodes,~ + delimiters-color,~ extra-left-margin,~ extra-right-margin,~ first-col,~ |