From 6a2f87148a137f5014278229a8175b7babf238cf Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Wed, 7 Oct 2020 03:00:49 +0000 Subject: CTAN sync 202010070300 --- .../latex/contrib/nicematrix/nicematrix-french.pdf | Bin 420416 -> 423480 bytes .../latex/contrib/nicematrix/nicematrix-french.tex | 256 ++++-- macros/latex/contrib/nicematrix/nicematrix.dtx | 879 +++++++++++++++------ macros/latex/contrib/nicematrix/nicematrix.pdf | Bin 1024124 -> 1048234 bytes 4 files changed, 811 insertions(+), 324 deletions(-) (limited to 'macros/latex/contrib/nicematrix') diff --git a/macros/latex/contrib/nicematrix/nicematrix-french.pdf b/macros/latex/contrib/nicematrix/nicematrix-french.pdf index 1b03c3ddec..c60b8277c7 100644 Binary files a/macros/latex/contrib/nicematrix/nicematrix-french.pdf and b/macros/latex/contrib/nicematrix/nicematrix-french.pdf differ diff --git a/macros/latex/contrib/nicematrix/nicematrix-french.tex b/macros/latex/contrib/nicematrix/nicematrix-french.tex index ede56a3b74..6f158b920f 100644 --- a/macros/latex/contrib/nicematrix/nicematrix-french.tex +++ b/macros/latex/contrib/nicematrix/nicematrix-french.tex @@ -32,6 +32,7 @@ \usepackage{multicol} \setlength{\columnseprule}{0.4pt} +\def\LetterAt{@} \def\interitem{\vspace{7mm plus 2 mm minus 3mm}} \def\emphase{\bgroup\color{RoyalPurple}\let\next=} @@ -404,9 +405,12 @@ $A=\begin{pNiceArray}{cc|cc}[baseline=line-3] \section{Les blocs} \label{Block} + +\subsection{Cas général} + + Dans les environnements de \pkg{nicematrix}, on peut utiliser la commande -|\Block| pour placer un élément au centre d'un rectangle de cases fusionnées. La -commande |\Block| ne crée pas d'espace par elle-même. +|\Block| pour placer un élément au centre d'un rectangle de cases fusionnées. La commande |\Block| doit être utilisée dans la case supérieure gauche du bloc avec deux arguments. Le premier argument est la taille de ce bloc avec la @@ -416,11 +420,92 @@ bloc. Le deuxième argument, est, sans surprise, le contenu du bloc. Dans |{NiceTabular}|, le contenu est composé en mode texte. Dans les autres environnements, il est composé en mode mathématique. + +\interitem +Voici un exemple d'utilisation de la commande |\Block| dans une matrice mathématique. + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=10.6cm] +$\begin{bNiceArray}{ccc|c}[margin] +~emphase#\Block{3-3}{A}@ & & & 0 \\ +& \hspace*{1cm} & & \Vdots \\ +& & & 0 \\ +\hline +0 & \Cdots& 0 & 0 +\end{bNiceArray}$ +\end{BVerbatim} +$\begin{bNiceArray}{ccc|c}[margin] +\Block{3-3}{A} & & & 0 \\ +& \hspace*{1cm} & & \Vdots \\ +& & & 0 \\ +\hline +0 & \Cdots& 0 & 0 +\end{bNiceArray}$ + +\bigskip +On peut souhaiter agrandir la taille du «$A$» placé dans le bloc de l'exemple +précédent. Comme il est composé en mode mathématique, on ne peut pas directement +utiliser une commande comme |\large|, |\Large| ou |\LARGE|. C'est pourquoi une +option à mettre entre chevrons est proposée par |\Block| pour spécifier du code +LaTeX qui sera inséré \emph{avant} le début du mode mathématique. + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=10.6cm] +$\begin{bNiceArray}{ccc|c}[margin] +\Block{3-3}~emphase#<\LARGE>@{A} & & & 0 \\ +& \hspace*{1cm} & & \Vdots \\ +& & & 0 \\ +\hline +0 & \Cdots& 0 & 0 +\end{bNiceArray}$ +\end{BVerbatim} +$\begin{bNiceArray}{ccc|c}[margin] +\Block{3-3}<\LARGE>{A} & & & 0 \\ +& \hspace*{1cm} & & \Vdots \\ +& & & 0 \\ +\hline +0 & \Cdots& 0 & 0 +\end{bNiceArray}$ + + +\bigskip +On peut régler le positionnement horizontal du bloc avec l'une des clés |l|, |c| +et |r|. + + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=10.6cm] +$\begin{bNiceArray}{ccc|c}[margin] +\Block~emphase#[r]@{3-3}<\LARGE>{A} & & & 0 \\ +& \hspace*{1cm} & & \Vdots \\ +& & & 0 \\ +\hline +0 & \Cdots& 0 & 0 +\end{bNiceArray}$ +\end{BVerbatim} +$\begin{bNiceArray}{ccc|c}[margin] +\Block[r]{3-3}<\LARGE>{A} & & & 0 \\ +& \hspace*{1cm} & & \Vdots \\ +& & & 0 \\ +\hline +0 & \Cdots& 0 & 0 +\end{bNiceArray}$ + + +\interitem +\textbf{On doit remarquer que, par défaut, les blocs ne créent pas d'espace} +(seuls les blocks mono-colonne font exception dans une certaine mesure : voir +plus bas). + +\medskip +Dans l'exemple suivant, on a dû élargir à la main les colonnes 2 et 3 (avec la +construction |wc{...}| de \pkg{array}). + \medskip \begin{BVerbatim} -\begin{NiceTabular}{cccc} +\begin{NiceTabular}~emphase#{cwc{2cm}wc{3cm}c}@ rose & tulipe & marguerite & dahlia \\ -violette & ~emphase#\Block{2-2}{\LARGE\color{blue} fleurs}@ & & souci \\ +violette & \Block{2-2}{\LARGE\color{blue}De très jolies fleurs} & & souci \\ pervenche & & & lys \\ arum & iris & jacinthe & muguet \end{NiceTabular} @@ -429,16 +514,69 @@ arum & iris & jacinthe & muguet \medskip \begin{center} -\begin{NiceTabular}{cccc} +\begin{NiceTabular}{cwc{2cm}wc{3cm}c} rose & tulipe & marguerite & dahlia \\ -violette & \Block{2-2}{\LARGE\color{blue} fleurs} & & souci \\ +violette & \Block{2-2}{\LARGE\color{blue}De très jolies fleurs} & & souci \\ pervenche & & & lys \\ arum & iris & jacinthe & muguet \end{NiceTabular} \end{center} -\interitem On remarquera que le centrage horizontal du contenu des blocs est + +\subsection{Les blocs mono-colonne} + +\colorbox{yellow!50}{\textbf{Nouveau 5.4}}\enskip Les blocs mono-colonne ont un +comportement spécial. +\begin{itemize} +\item La largeur naturelle du contenu de ces blocs est prise en compte pour la +largeur de la colonne courante. + +\item La spécification d'alignement horizontal donnée par le type de +colonne (|c|, |r| ou |l|) est prise en compte pour le bloc (mais le bloc peut +avoir sa propre specification d'alignement horizontal). + +\item Les spécifications de fontes imposées à une colonne via la construction +|>{...}| dans le préambule du tableau sont prises en compte pour les +blocs mono-colonne de cette colonne (ce comportement est assez naturel). +\end{itemize} + + +\medskip +\begin{scope} +\hfuzz=10cm +\begin{BVerbatim}[baseline=c,boxwidth=12cm] +\begin{NiceTabular}{~LetterAt{}>{\bfseries}lr~LetterAt{}} \hline +\Block{2-1}{Pierre} & 12 \\ + & 13 \\ \hline +Jacques & 8 \\ \hline +\Block{3-1}{Stéphanie} & 18 \\ + & 17 \\ + & 15 \\ \hline +Amélie & 20 \\ \hline +Henri & 14 \\ \hline +\Block{2-1}{Estelle} & 15 \\ + & 19 \\ \hline +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{@{}>{\bfseries}lr@{}} \hline +\Block{2-1}{Pierre} & 12 \\ + & 13 \\ \hline +Jacques & 8 \\ \hline +\Block{3-1}{Stéphanie} & 18 \\ + & 17 \\ + & 15 \\ \hline +Amélie & 20 \\ \hline +Henri & 14 \\ \hline +\Block{2-1}{Estelle} & 15 \\ + & 19 \\ \hline +\end{NiceTabular} +\end{scope} + + +\subsection{Petite remarque} + +On remarquera que le centrage horizontal du contenu des blocs est correct même si un espacement des colonnes a été demandé par une instruction comme |!{\qquad}| dans le préambule (ce n'est pas le cas avec |\multicolumn|). Dans l'exemple suivant, l'en-tête «Premier groupe» est correctement centré. @@ -476,55 +614,6 @@ Rang & 1A & 1B & 1C & 2A & 2B & 2C \\ \end{NiceTabular} \end{center} -\interitem -\colorbox{yellow!50}{\textbf{Nouveau 5.3}}\enskip La commande |\Block| accepte -les options |l|, |c| et |r| pour le placement horizontal. - -\interitem -On peut aussi utiliser la commande |\Block| dans des matrices mathématiques. - -\medskip -\begin{BVerbatim}[baseline=c,boxwidth=10.6cm] -$\begin{bNiceArray}{ccc|c}[margin] -~emphase#\Block{3-3}{A}@ & & & 0 \\ -& \hspace*{1cm} & & \Vdots \\ -& & & 0 \\ -\hline -0 & \Cdots& 0 & 0 -\end{bNiceArray}$ -\end{BVerbatim} -$\begin{bNiceArray}{ccc|c}[margin] -\Block{3-3}{A} & & & 0 \\ -& \hspace*{1cm} & & \Vdots \\ -& & & 0 \\ -\hline -0 & \Cdots& 0 & 0 -\end{bNiceArray}$ - -\bigskip -On peut souhaiter agrandir la taille du «$A$» placé dans le bloc de l'exemple -précédent. Comme il est composé en mode mathématique, on ne peut pas directement -utiliser une commande comme |\large|, |\Large| ou |\LARGE|. C'est pourquoi une -option à mettre entre chevrons est proposée par |\Block| pour spécifier du code -LaTeX qui sera inséré \emph{avant} le début du mode mathématique. - -\medskip -\begin{BVerbatim}[baseline=c,boxwidth=10.6cm] -$\begin{bNiceArray}{ccc|c}[margin] -\Block{3-3}~emphase#<\LARGE>@{A} & & & 0 \\ -& \hspace*{1cm} & & \Vdots \\ -& & & 0 \\ -\hline -0 & \Cdots& 0 & 0 -\end{bNiceArray}$ -\end{BVerbatim} -$\begin{bNiceArray}{ccc|c}[margin] -\Block{3-3}<\LARGE>{A} & & & 0 \\ -& \hspace*{1cm} & & \Vdots \\ -& & & 0 \\ -\hline -0 & \Cdots& 0 & 0 -\end{bNiceArray}$ \section{Les filets horizontaux et verticaux} @@ -1146,31 +1235,30 @@ englober les blocs. \begin{BVerbatim}[baseline=c,boxwidth=9cm] \begin{NiceTabular}{lr}[hvlines,code-before = ~emphase#\rowcolors{1}{blue!10}{}[respect-blocks]@] -\Block[l]{2-1}{Pierre} & 12 \\ +\Block{2-1}{Pierre} & 12 \\ & 13 \\ -Jacques & 8 \\ -\hphantom{Stéphanie} -\Block[l]{3-1}{Stéphanie} & 18 \\ - & 17 \\ - & 15 \\ -Amélie & 20 \\ -Henri & 14 \\ -\Block[l]{2-1}{Estelle} & 15 \\ - & 19 +Jacques & 8 \\ +\Block{3-1}{Stéphanie} & 18 \\ + & 17 \\ + & 15 \\ +Amélie & 20 \\ +Henri & 14 \\ +\Block{2-1}{Estelle} & 15 \\ + & 19 \end{NiceTabular} \end{BVerbatim} -\begin{NiceTabular}{lr}[hvlines,code-before = \rowcolors{1}{blue!10}{}[respect-blocks],baseline=c] -\Block[l]{2-1}{Pierre} & 12 \\ - & 13 \\ -Jacques & 8 \\ -\hphantom{Stéphanie} -\Block[l]{3-1}{Stéphanie} & 18 \\ +\begin{NiceTabular}{lr}[hvlines,code-before = +\rowcolors{1}{blue!10}{}[respect-blocks],baseline=c] +\Block{2-1}{Pierre} & 12 \\ + & 13 \\ +Jacques & 8 \\ +\Block{3-1}{Stéphanie} & 18 \\ & 17 \\ & 15 \\ -Amélie & 20 \\ -Henri & 14 \\ -\Block[l]{2-1}{Estelle} & 15 \\ - & 19 +Amélie & 20 \\ +Henri & 14 \\ +\Block{2-1}{Estelle} & 15 \\ + & 19 \end{NiceTabular} \end{scope} @@ -1271,7 +1359,7 @@ autre commande, elle-même utilisée dans le préambule). \medskip \begin{Verbatim} -\NewDocumentCommand { \Blue } { } { ~emphase#\columncolor{blue!15}@ } +\NewDocumentCommand { \Blue } { } {~emphase#\columncolor{blue!15}@} \begin{NiceTabular}[colortbl-like]{>{\Blue}c>{\Blue}cc} \toprule ~emphase#\rowcolor{red!15}@ @@ -1287,7 +1375,7 @@ Dupont & Chantal & 15 janvier 1998 \\ \begin{center} -\NewDocumentCommand { \Blue } { } { \columncolor{blue!15} } +\NewDocumentCommand { \Blue } { } {\columncolor{blue!15}} \begin{NiceTabular}[colortbl-like]{>{\Blue}c>{\Blue}cc} \toprule \rowcolor{red!15} @@ -2269,7 +2357,8 @@ Dupont & Chantal & 15 janvier 1998 \\ \caption{Utilisation de \texttt{\textbackslash tabularnote}\tabularnote{On peut mettre une note dans le titre.}} \label{t:tabularnote} -\begin{NiceTabular}{@{}llc@{}}[notes/bottomrule] +\begin{NiceTabular}{@{}llc@{}}% + [notes/bottomrule, tabularnote = Un peu de texte avant les notes.] \toprule Nom & Prénom & Durée de vie \\ \midrule @@ -2304,6 +2393,10 @@ colonne). \item Si la clé |notes/para| est utilisée, les notes sont composées à la fin du tableau en un seul paragraphe. +\item \colorbox{yellow!50}{\textbf{Nouveau 5.4}}\enskip +Il existe une clé |tabularnote| qui permet d'insérer du texte dans la zone +des notes avant les notes numérotées. + \item Si l'extension \pkg{booktabs} a été chargée (avant ou après \pkg{nicematrix}), la clé |notes/bottomrule| permet de faire tracer un |\bottomrule| de \pkg{booktabs} \emph{après} les notes. @@ -2325,7 +2418,8 @@ remarques illustrées. Cette table a été composée avec le code suivant. tabularnote}~emphase#\tabularnote{On peut! ~emphase# mettre une note dans le titre.}!} \label{t:tabularnote} -\begin{NiceTabular}{@{}llc@{}}[~emphase#notes/bottomrule!] +\begin{NiceTabular}{@{}llc@{}}% + [~emphase#notes/bottomrule!, tabularnote = Un peu de texte avant les notes.] \toprule Nom & Prénom & Durée de vie \\ \midrule @@ -3436,7 +3530,7 @@ a+b & \Cdots & a+b & 1 \colorbox{yellow!50}{\textbf{Nouveau 5.3}}\enskip On peut choisir l'instruction |\Ddots| qui sera tracée en premier (et qui servira pour tracer les suivantes quand la parallélisation est activée) avec la clé |draw-first| : - |\Ddots[draw-first]|. + |\Ddots[draw-first]|\rlap{.} \subsection{Les cases «vides»} diff --git a/macros/latex/contrib/nicematrix/nicematrix.dtx b/macros/latex/contrib/nicematrix/nicematrix.dtx index 03a6705cd3..22c7112ee0 100644 --- a/macros/latex/contrib/nicematrix/nicematrix.dtx +++ b/macros/latex/contrib/nicematrix/nicematrix.dtx @@ -15,8 +15,8 @@ % % \fi % \iffalse -\def\myfileversion{5.3} -\def\myfiledate{2020/09/03} +\def\myfileversion{5.4} +\def\myfiledate{2020/10/06} % % %<*batchfile> @@ -68,6 +68,7 @@ version 2005/12/01 or later. \setlength{\columnseprule}{0.4pt} \usepackage{footnotehyper} \usepackage{varwidth} +\def\LetterAt{@} \parindent 0pt \EnableCrossrefs @@ -444,9 +445,11 @@ version 2005/12/01 or later. % \section{The blocks} % \label{Block} % +% \subsection{General case} +% % 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. The command |\Block| don't create space by itself. +% cells of the array. % % The command |\Block| must be used in the upper leftmost cell of the array with % two arguments. The first argument is the size of the block with the syntax @@ -456,11 +459,93 @@ version 2005/12/01 or later. % In |{NiceTabular}| the content of the block is composed in text mode. In the % other environments, it is composed in math mode. % +% +% \interitem +% Here is an example of utilisation of the command |\Block| in mathematical matrices. +% +% \medskip +% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm] +% $\begin{bNiceArray}{ccc|c}[margin] +% ~emphase#\Block{3-3}{A}@ & & & 0 \\ +% & \hspace*{1cm} & & \Vdots \\ +% & & & 0 \\ +% \hline +% 0 & \Cdots& 0 & 0 +% \end{bNiceArray}$ +% \end{BVerbatim} +% $\begin{bNiceArray}{ccc|c}[margin] +% \Block{3-3}{A} & & & 0 \\ +% & \hspace*{1cm} & & \Vdots \\ +% & & & 0 \\ +% \hline +% 0 & \Cdots& 0 & 0 +% \end{bNiceArray}$ +% +% \bigskip +% One may wish to raise the size of the ``$A$'' placed in the block of the +% previous example. Since this element is composed in math mode, it's not +% possible to use directly a command like |\large|, |\Large| and |\LARGE|. +% That's why the command |\Block| provides an option between angle brackets to +% specify some TeX code which will be inserted before the beginning of the +% math mode. +% +% \medskip +% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm] +% $\begin{bNiceArray}{ccc|c}[margin] +% \Block{3-3}~emphase#<\Large>@{A} & & & 0 \\ +% & \hspace*{1cm} & & \Vdots \\ +% & & & 0 \\ +% \hline +% 0 & \Cdots& 0 & 0 +% \end{bNiceArray}$ +% \end{BVerbatim} +% \begin{scope} +% $\begin{bNiceArray}{ccc|c}[margin] +% \Block{3-3}<\Large>{A} & & & 0 \\ +% & \hspace*{1cm} & & \Vdots \\ +% & & & 0 \\ +% \hline +% 0 & \Cdots& 0 & 0 +% \end{bNiceArray}$ +% \end{scope} +% +% \medskip +% \colorbox{yellow!50}{\textbf{New 5.3}}\enskip It's possible to set the +% horizontal position of the block with one of the keys |l|, |c| and |r|. +% +% +% \medskip +% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm] +% $\begin{bNiceArray}{ccc|c}[margin] +% \Block~emphase#[r]@{3-3}<\LARGE>{A} & & & 0 \\ +% & \hspace*{1cm} & & \Vdots \\ +% & & & 0 \\ +% \hline +% 0 & \Cdots& 0 & 0 +% \end{bNiceArray}$ +% \end{BVerbatim} +% $\begin{bNiceArray}{ccc|c}[margin] +% \Block[r]{3-3}<\LARGE>{A} & & & 0 \\ +% & \hspace*{1cm} & & \Vdots \\ +% & & & 0 \\ +% \hline +% 0 & \Cdots& 0 & 0 +% \end{bNiceArray}$ +% +% +% \interitem +% {\bfseries One must remark that, by default, the commands |\Blocks| don't create space} +% (excepted, to some extent, the mono-column blocks: see below). +% +% \medskip +% In the following example, we have had to enlarge by hand the columns 2 and 3 +% (with the construction |wc{...}| of \pkg{array}). +% % \medskip % \begin{BVerbatim} -% \begin{NiceTabular}{cccc} +% \begin{NiceTabular}~emphase#{cwc{2cm}wc{3cm}c}@ % rose & tulipe & marguerite & dahlia \\ -% violette & ~emphase#\Block{2-2}{\LARGE\color{blue} fleurs}@ & & souci \\ +% violette & \Block{2-2}{\LARGE\color{blue}De très jolies fleurs} & & souci \\ % pervenche & & & lys \\ % arum & iris & jacinthe & muguet % \end{NiceTabular} @@ -469,15 +554,68 @@ version 2005/12/01 or later. % % \medskip % \begin{center} -% \begin{NiceTabular}{cccc} +% \begin{NiceTabular}{cwc{2cm}wc{3cm}c} % rose & tulipe & marguerite & dahlia \\ -% violette & \Block{2-2}{\LARGE\color{blue} fleurs} & & souci \\ +% violette & \Block{2-2}{\LARGE\color{blue}De très jolies fleurs} & & souci \\ % pervenche & & & lys \\ % arum & iris & jacinthe & muguet % \end{NiceTabular} % \end{center} % -% \interitem +% +% \subsection{The mono-column blocks} +% +% % \colorbox{yellow!50}{\textbf{New 5.4}}\enskip The mono-column blocks have a +% special behaviour. +% +% \begin{itemize} +% \item The natural width of the contents of these blocks is taken into account +% for the width of the current column. +% +% \item The specification of the horizontal position provided by the type of +% column (|c|, |r| or |l|) is taken into account for the blocks. +% +% \item The specifications of font specified for the column by a construction +% |>{...}| in the preamble of the array are taken into account for the +% mono-column blocks of that column (this behaviour is probably expected). +% \end{itemize} +% +% +% \bigskip +% \begin{scope} +% \hfuzz=10cm +% \begin{BVerbatim}[baseline=c,boxwidth=12cm] +% \begin{NiceTabular}{~LetterAt{}>{\bfseries}lr~LetterAt{}} \hline +% \Block{2-1}{John} & 12 \\ +% & 13 \\ \hline +% Steph & 8 \\ \hline +% \Block{3-1}{Sarah} & 18 \\ +% & 17 \\ +% & 15 \\ \hline +% Ashley & 20 \\ \hline +% Henry & 14 \\ \hline +% \Block{2-1}{Madison} & 15 \\ +% & 19 \\ \hline +% \end{NiceTabular} +% \end{BVerbatim} +% \begin{NiceTabular}{@{}>{\bfseries}lr@{}}[baseline=c] \hline +% \Block{2-1}{John} & 12 \\ +% & 13 \\ \hline +% Steph & 8 \\ \hline +% \Block{3-1}{Sarah} & 18 \\ +% & 17 \\ +% & 15 \\ \hline +% Ashley & 20 \\ \hline +% Henry & 14 \\ \hline +% \Block{2-1}{Madison} & 15 \\ +% & 19 \\ \hline +% \end{NiceTabular} +% \end{scope} +% +% +% +% \subsection{A small remark} +% % One should remark that the horizontal centering of the contents of the blocks % is correct even when an instruction such as |!{\qquad}| has been used in the % preamble of the array in order to increase the space between two columns (this @@ -518,61 +656,6 @@ version 2005/12/01 or later. % \end{center} % % -% \interitem -% \colorbox{yellow!50}{\textbf{New 5.3}}\enskip -% -% It's possible to use with the command |\Block| the options |l|, |r| and |c| -% for the horizontal positionning. -% -% -% \interitem -% It's also possible to use the command |\Block| in mathematical matrices. -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm] -% $\begin{bNiceArray}{ccc|c}[margin] -% ~emphase#\Block{3-3}{A}@ & & & 0 \\ -% & \hspace*{1cm} & & \Vdots \\ -% & & & 0 \\ -% \hline -% 0 & \Cdots& 0 & 0 -% \end{bNiceArray}$ -% \end{BVerbatim} -% $\begin{bNiceArray}{ccc|c}[margin] -% \Block{3-3}{A} & & & 0 \\ -% & \hspace*{1cm} & & \Vdots \\ -% & & & 0 \\ -% \hline -% 0 & \Cdots& 0 & 0 -% \end{bNiceArray}$ -% -% \bigskip -% One may wish to raise the size of the ``$A$'' placed in the block of the -% previous example. Since this element is composed in math mode, it's not -% possible to use directly a command like |\large|, |\Large| and |\LARGE|. -% That's why the command |\Block| provides an option between angle brackets to -% specify some TeX code which will be inserted before the beginning of the -% math mode. -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm] -% $\begin{bNiceArray}{ccc|c}[margin] -% \Block{3-3}~emphase#<\Large>@{A} & & & 0 \\ -% & \hspace*{1cm} & & \Vdots \\ -% & & & 0 \\ -% \hline -% 0 & \Cdots& 0 & 0 -% \end{bNiceArray}$ -% \end{BVerbatim} -% \begin{scope} -% $\begin{bNiceArray}{ccc|c}[margin] -% \Block{3-3}<\Large>{A} & & & 0 \\ -% & \hspace*{1cm} & & \Vdots \\ -% & & & 0 \\ -% \hline -% 0 & \Cdots& 0 & 0 -% \end{bNiceArray}$ -% \end{scope} % % \section{The rules} % @@ -1140,7 +1223,7 @@ version 2005/12/01 or later. % \begin{scope} % \hfuzz=10cm % \begin{BVerbatim}[baseline=c,boxwidth=9cm] -% \begin{NiceTabular}{lr}[hlines,code-before = ~emphase#\rowcolors{1}{blue!10}{}@] +% \begin{NiceTabular}{~LetterAt{}lr~LetterAt{}}[hlines,code-before = ~emphase#\rowcolors{1}{blue!10}{}@] % John & 12 \\ % Stephen & 8 \\ % Sarah & 18 \\ @@ -1149,7 +1232,7 @@ version 2005/12/01 or later. % Madison & 15 % \end{NiceTabular} % \end{BVerbatim} -% \begin{NiceTabular}{lr}[hlines,code-before = \rowcolors{1}{blue!10}{},baseline=3] +% \begin{NiceTabular}{@{}lr@{}}[hlines,code-before = \rowcolors{1}{blue!10}{},baseline=3] % John & 12 \\ % Stephen & 8 \\ % Sarah & 18 \\ @@ -1162,7 +1245,7 @@ version 2005/12/01 or later. % \bigskip % \colorbox{yellow!30}{\textbf{New 5.2}}\enskip There is a key |respect-blocks| % for the instruction |\rowcolors|. With that key, the ``rows'' alternately -% colored may extend over several row if they have to incorporate blocks. +% colored may extend over several rows if they have to incorporate blocks. % % \medskip % \begin{scope} @@ -1170,28 +1253,29 @@ version 2005/12/01 or later. % \begin{BVerbatim}[baseline=c,boxwidth=9cm] % \begin{NiceTabular}{lr}[hvlines,code-before = % ~emphase#\rowcolors{1}{blue!10}{}[respect-blocks]@] -% \Block[l]{2-1}{John} & 12 \\ -% & 13 \\ -% Stephen & 8 \\ -% \Block[l]{3-1}{Sarah} & 18 \\ -% & 17 \\ -% & 15 \\ -% Ashley & 20 \\ -% Henry & 14 \\ -% \Block[l]{2-1}{Madison} & 15 \\ +% \Block{2-1}{John} & 12 \\ +% & 13 \\ +% Steph & 8 \\ +% \Block{3-1}{Sarah} & 18 \\ +% & 17 \\ +% & 15 \\ +% Ashley & 20 \\ +% Henry & 14 \\ +% \Block{2-1}{Madison} & 15 \\ % & 19 % \end{NiceTabular} % \end{BVerbatim} -% \begin{NiceTabular}{lr}[hvlines,code-before = \rowcolors{1}{blue!10}{}[respect-blocks],baseline=c] -% \Block[l]{2-1}{John} & 12 \\ -% & 13 \\ -% Stephen & 8 \\ -% \Block[l]{3-1}{Sarah} & 18 \\ -% & 17 \\ -% & 15 \\ -% Ashley & 20 \\ -% Henry & 14 \\ -% \Block[l]{2-1}{Madison} & 15 \\ +% \begin{NiceTabular}{lr}[hvlines,code-before = +% \rowcolors{1}{blue!10}{}[respect-blocks],baseline=c] +% \Block{2-1}{John} & 12 \\ +% & 13 \\ +% Steph & 8 \\ +% \Block{3-1}{Sarah} & 18 \\ +% & 17 \\ +% & 15 \\ +% Ashley & 20 \\ +% Henry & 14 \\ +% \Block{2-1}{Madison} & 15 \\ % & 19 % \end{NiceTabular} % \end{scope} @@ -2274,6 +2358,10 @@ version 2005/12/01 or later. % \item If the key |notes/para| is used, the notes are composed at the end of % the array in a single paragraph (as with the key |para| of \pkg{threeparttable}). % +% \item \colorbox{yellow!50}{\textbf{New 5.4}}\enskip There is a key +% |tabularnote| which provides a way to insert some texte in the zone of the +% notes before the numbered tabular notes. +% % \item If the package \pkg{booktabs} has been loaded (before or after % \pkg{nicematrix}), the key |notes/bottomrule| draws a |\bottomrule| of % \pkg{booktabs} \emph{after} the notes. @@ -2299,7 +2387,8 @@ version 2005/12/01 or later. % \caption{Use of \texttt{\textbackslash tabularnote}~emphase#\tabularnote{It's possible! % ~emphase#to put a note in the caption.}}! % \label{t:tabularnote} -% \begin{NiceTabular}{@{}llc@{}[~emphase#notes/bottomrule!] +% \begin{NiceTabular}{@{}llc@{} +% [~emphase#notes/bottomrule!, tabularnote = Some text before the notes.] % \toprule % Last name & First name & Length of life \\ % \midrule @@ -2323,7 +2412,8 @@ version 2005/12/01 or later. % \caption{Use of \texttt{\textbackslash tabularnote}\tabularnote{It's possible % to put a note in the caption.}} % \label{t:tabularnote} -% \begin{NiceTabular}{@{}llc@{}}[notes/bottomrule] +% \begin{NiceTabular}{@{}llc@{}}[notes/bottomrule, +% tabularnote = Some text before the notes.] % \toprule % Last name & First name & Length of life \\ % \midrule @@ -4341,6 +4431,21 @@ version 2005/12/01 or later. \RequirePackage { xparse } % \end{macrocode} % +% \begin{macrocode} +\cs_set_eq:NN \box_use_drop_i:N \box_use_drop:N +\cs_set_eq:NN \box_use_drop_ii:N \box_use_drop:N +\cs_set_eq:NN \box_use_drop_iii:N \box_use_drop:N +\cs_set_eq:NN \box_use_drop_iv:N \box_use_drop:N +\cs_set_eq:NN \box_use_drop_v:N \box_use_drop:N +\cs_set_eq:NN \box_use_drop_vi:N \box_use_drop:N +\cs_set_eq:NN \box_use_drop_vii:N \box_use_drop:N +\cs_set_eq:NN \box_use_drop_viii:N \box_use_drop:N +\cs_set_eq:NN \box_use_drop_ix:N \box_use_drop:N +\cs_set_eq:NN \box_use_drop_x:N \box_use_drop:N +\cs_set_eq:NN \box_use_drop_xi:N \box_use_drop:N +\cs_set_eq:NN \box_use_drop_xii:N \box_use_drop:N +% \end{macrocode} +% % \bigskip % \begin{macrocode} \cs_new_protected:Npn \@@_error:n { \msg_error:nn { nicematrix } } @@ -4621,11 +4726,6 @@ version 2005/12/01 or later. % \end{macrocode} % % -% \bigskip -% \begin{macrocode} -\cs_new:Npn \@@_tab_or_array_colsep: - { \bool_if:NTF \l_@@_NiceTabular_bool \tabcolsep \arraycolsep } -% \end{macrocode} % % \bigskip % \textbf{The column S of siunitx}\par\nobreak @@ -4856,6 +4956,24 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip +% The following token list will contain the type of the current cell (|l|, |c| +% or |r|). It will be used by the blocks. +% \begin{macrocode} +\tl_new:N \l_@@_cell_type_tl +\tl_set:Nn \l_@@_cell_type_tl { c } +% \end{macrocode} +% +% \bigskip +% When there is a mono-column block (created by the command |\Block|), we want +% to take into account the width of that block for the width of the column. +% That's why we compute the width of that block in the |\g_@@_blocks_width_dim| +% and, after the construction of the box |\l_@@_cell_box|, we change the width +% of that box to take into account the length |\g_@@_blocks_width_dim|. +% \begin{macrocode} +\dim_new:N \g_@@_blocks_width_dim +% \end{macrocode} +% +% \bigskip % The sequence |\g_@@_names_seq| will be the list of all the names of % environments used (via the option |name|) in the document: two environments % must not have the same name. However, it's possible to use the option @@ -4901,6 +5019,12 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip +% The following boolean will be raised when the command |\rotate| is used. +% \begin{macrocode} +\bool_new:N \g_@@_rotate_bool +% \end{macrocode} +% +% \bigskip % \begin{macrocode} \cs_new_protected:Npn \@@_test_if_math_mode: { @@ -5106,13 +5230,20 @@ version 2005/12/01 or later. \tl_new:N \l_@@_pos_of_block_tl \tl_set:Nn \l_@@_pos_of_block_tl { c } % \end{macrocode} -% +% % \medskip % Used when the key |draw-first| is used for |\Ddots| or |\Iddots|. % \begin{macrocode} \bool_new:N \l_@@_draw_first_bool % \end{macrocode} % +% \medskip +% The blocks which use the key |-| will store their content in a box. These +% boxes are numbered with the following counter. +% \begin{macrocode} +\int_new:N \g_@@_block_box_int +% \end{macrocode} +% % \bigskip % \textbf{Variables for the exterior rows and columns}\par\nobreak % @@ -5224,6 +5355,14 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip +% However, before the actual tabular notes, it's possible to put a text +% specified by the key |tabularnote| of the environment. The token list +% |\l_@@_tabularnote_tl| corresponds to the value of that key. +% \begin{macrocode} +\tl_new:N \l_@@_tabularnote_tl +% \end{macrocode} +% +% \bigskip % The following counter will be used to count the number of successive tabular % notes such as in % |\tabularnote{Note 1}\tabularnote{Note 2}\tabularnote{Note 3}|. @@ -5286,7 +5425,11 @@ version 2005/12/01 or later. \newlist { tabularnotes } { enumerate } { 1 } \setlist [ tabularnotes ] { - noitemsep , leftmargin = * , align = left , labelsep = 0pt , + topsep = 0pt , + noitemsep , + leftmargin = * , + align = left , + labelsep = 0pt , label = \@@_notes_label_in_list:n { \@@_notes_style:n { tabularnotesi } } , } @@ -5331,7 +5474,7 @@ version 2005/12/01 or later. % We expand the content of the note at the point of use of % |\tabularnote| as does |\footnote|. % \begin{macrocode} - \seq_gput_right:Nx \g_@@_tabularnotes_seq { #1 } + \seq_gput_right:Nn \g_@@_tabularnotes_seq { #1 } \peek_meaning:NF \tabularnote { % \end{macrocode} @@ -6087,6 +6230,8 @@ version 2005/12/01 or later. notes / para .default:n = true , notes / bottomrule .bool_set:N = \l_@@_notes_bottomrule_bool , notes / bottomrule .default:n = true , + tabularnote .tl_set:N = \l_@@_tabularnote_tl , + tabularnote .value_required:n = true , unknown .code:n = \@@_error:n { Unknown~option~for~NiceArray } } % \end{macrocode} @@ -6118,6 +6263,8 @@ version 2005/12/01 or later. notes / para .default:n = true , notes / bottomrule .bool_set:N = \l_@@_notes_bottomrule_bool , notes / bottomrule .default:n = true , + tabularnote .tl_set:N = \l_@@_tabularnote_tl , + tabularnote .value_required:n = true , last-col .code:n = \tl_if_empty:nF {#1} { \@@_error:n { last-col~non~empty~for~NiceArray } } \int_zero:N \l_@@_last_col_int , @@ -6239,12 +6386,42 @@ version 2005/12/01 or later. } % \end{macrocode} % +% \begin{macrocode} +\cs_new_protected:Npn \@@_rotate_cell_box: + { + \box_rotate:Nn \l_@@_cell_box { 90 } + \int_compare:nNnT \c@iRow = \l_@@_last_row_int + { + \vbox_set_top:Nn \l_@@_cell_box + { + \vbox_to_zero:n { } + \skip_vertical:n { - \box_ht:N \@arstrutbox + 0.8 ex } + \box_use:N \l_@@_cell_box + } + } + \bool_gset_false:N \g_@@_rotate_bool + } +% \end{macrocode} +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_adjust_width_box: + { + \dim_compare:nNnT \g_@@_blocks_width_dim > \c_zero_dim + { + \box_set_wd:Nn \l_@@_cell_box + { \dim_max:nn { \box_wd:N \l_@@_cell_box } \g_@@_blocks_width_dim } + \dim_gzero:N \g_@@_blocks_width_dim + } + } +% \end{macrocode} % % \begin{macrocode} \cs_new_protected:Npn \@@_end_Cell: { \@@_math_toggle_token: \hbox_set_end: + \bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box: + \@@_adjust_width_box: % \end{macrocode} % % \begin{macrocode} @@ -6292,11 +6469,11 @@ version 2005/12/01 or later. % \end{itemize} % \begin{macrocode} \bool_if:NTF \g_@@_empty_cell_bool - { \box_use_drop:N \l_@@_cell_box } + { \box_use_drop_i:N \l_@@_cell_box } { \dim_compare:nNnTF { \box_wd:N \l_@@_cell_box } > \c_zero_dim \@@_node_for_the_cell: - { \box_use_drop:N \l_@@_cell_box } + { \box_use_drop_ii:N \l_@@_cell_box } } \bool_gset_false:N \g_@@_empty_cell_bool } @@ -6319,7 +6496,7 @@ version 2005/12/01 or later. \pgfnode { rectangle } { base } - { \box_use_drop:N \l_@@_cell_box } + { \box_use_drop_iii:N \l_@@_cell_box } { \@@_env: - \int_use:N \c@iRow - \int_use:N \c@jCol } { } \str_if_empty:NF \l_@@_name_str @@ -6776,6 +6953,7 @@ version 2005/12/01 or later. \bgroup \tl_set:Nn \l_@@_left_delim_tl { #1 } \tl_set:Nn \l_@@_right_delim_tl { #2 } + \int_gzero:N \g_@@_block_box_int \dim_zero:N \g_@@_width_last_col_dim \dim_zero:N \g_@@_width_first_col_dim \bool_gset_false:N \g_@@_row_of_col_done_bool @@ -6800,11 +6978,13 @@ version 2005/12/01 or later. % \end{macrocode} % % We deactivate Tikz externalization because we will use \textsc{pgf} pictures -% with the options |overlay| and |remember picture| (or equivalent forms). +% with the options |overlay| and |remember picture| (or equivalent forms). We +% deactivate with |\tikzexternaldisable| and not with +% |\tikzset{external/export=false}| which is \emph{not} equivalent. % \begin{macrocode} \cs_if_exist:NT \tikz@library@external@loaded { - \tikzset { external / export = false } + \tikzexternaldisable \cs_if_exist:NT \ifstandalone { \tikzset { external / optimize = false } } } @@ -7153,8 +7333,21 @@ version 2005/12/01 or later. % \begin{macrocode} \int_compare:nNnT \l_@@_first_col_int = 0 { - \skip_horizontal:N \arraycolsep - \skip_horizontal:N \g_@@_width_first_col_dim + \skip_horizontal:N \col@sep + \dim_if_exist:cTF { g_@@_ block _ width _col _ 0 _ dim } + { + \skip_horizontal:n + { + \dim_max:nn + { + \dim_use:c { g_@@_ block _ width _col _ 0 _ dim } + - 2 \col@sep + } + \g_@@_width_first_col_dim + } + \dim_gzero:c { g_@@_ block _ width _col _ 0 _ dim } + } + { \skip_horizontal:N \g_@@_width_first_col_dim } } % \end{macrocode} % @@ -7254,8 +7447,27 @@ version 2005/12/01 or later. % \begin{macrocode} \bool_if:NT \g_@@_last_col_found_bool { - \skip_horizontal:N \g_@@_width_last_col_dim - \skip_horizontal:N \arraycolsep + \dim_if_exist:cTF + { g_@@_ block _ width _col _ \int_use:N \g_@@_col_total_int _ dim } + { + \skip_horizontal:n + { + \dim_max:nn + { + \dim_use:c + { + g_@@_ block _ width _col _ + \int_use:N \g_@@_col_total_int + _ dim + } + } + { \g_@@_width_first_col_dim + \col@sep } + } + } + { + \skip_horizontal:N \g_@@_width_last_col_dim + \skip_horizontal:N \col@sep + } } \@@_after_array: \egroup @@ -7449,7 +7661,12 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Npn \@@_patch_preamble_i:n #1 { - \tl_gput_right:Nn \g_@@_preamble_tl { > \@@_Cell: #1 < \@@_end_Cell: } + \tl_gput_right:Nn \g_@@_preamble_tl + { + > { \@@_Cell: \tl_set:Nn \l_@@_cell_type_tl { #1 } } + #1 + < \@@_end_Cell: + } % \end{macrocode} % We increment the counter of columns. % \begin{macrocode} @@ -7547,13 +7764,16 @@ version 2005/12/01 or later. > { \hbox_set:Nw \l_@@_cell_box \@@_Cell: + \tl_set:Nn \l_@@_cell_type_tl { #1 } } c < { \@@_end_Cell: #1 - \hbox_set_end: - \makebox [ #4 ] [ #3 ] { \box_use_drop:N \l_@@_cell_box } + \hbox_set_end: + \bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box: + \@@_adjust_width_box: + \makebox [ #4 ] [ #3 ] { \box_use_drop_iv:N \l_@@_cell_box } } } % \end{macrocode} @@ -7635,7 +7855,7 @@ version 2005/12/01 or later. \box_set_ht:Nn \l_tmpa_box { \box_ht:N \l_tmpa_box + \l_tmpa_dim } \box_set_dp:Nn \l_tmpa_box { \box_dp:N \l_tmpa_box + \l_tmpb_dim } \str_if_eq:VnTF \l_@@_baseline_str { c } - { \box_use_drop:N \l_tmpa_box } + { \box_use_drop_v:N \l_tmpa_box } \@@_put_box_in_flow_i: } % \end{macrocode} @@ -7693,8 +7913,8 @@ version 2005/12/01 or later. % Now, |\g_tmpa_dim| contains the value of the $y$ translation we have to to. % \begin{macrocode} \endpgfpicture - \box_move_up:nn \g_tmpa_dim { \box_use_drop:N \l_tmpa_box } - \box_use_drop:N \l_tmpa_box + \box_move_up:nn \g_tmpa_dim { \box_use_drop_vi:N \l_tmpa_box } + \box_use_drop_vii:N \l_tmpa_box } % \end{macrocode} % @@ -7702,11 +7922,13 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Npn \@@_use_arraybox_with_notes_c: { - \int_compare:nNnTF \c@tabularnote = 0 - { \box_use_drop:N \l_@@_the_array_box } + \bool_lazy_and:nnTF + { \int_compare_p:nNn \c@tabularnote = 0 } + { \tl_if_empty_p:V \l_@@_tabularnote_tl } + { \box_use_drop_viii:N \l_@@_the_array_box } { \begin { minipage } { \box_wd:N \l_@@_the_array_box } - \box_use_drop:N \l_@@_the_array_box + \box_use_drop_ix:N \l_@@_the_array_box \skip_vertical:N 0.65ex % \end{macrocode} % The TeX group is for potential specifications in the @@ -7714,26 +7936,30 @@ version 2005/12/01 or later. % \begin{macrocode} \group_begin: \l_@@_notes_code_before_tl + \tl_if_empty:NF \l_@@_tabularnote_tl { \l_@@_tabularnote_tl \par } % \end{macrocode} % We compose the tabular notes with a list of \pkg{enumitem}. The |\strut| and % the |\unskip| are designed to give the ability to put a |\bottomrule| at the % end of the notes with a good vertical space. % \begin{macrocode} - \bool_if:NTF \l_@@_notes_para_bool + \int_compare:nNnF \c@tabularnote = 0 { - \begin { tabularnotes* } - \seq_map_inline:Nn \g_@@_tabularnotes_seq { \item ##1 } \strut - \end { tabularnotes* } + \bool_if:NTF \l_@@_notes_para_bool + { + \begin { tabularnotes* } + \seq_map_inline:Nn \g_@@_tabularnotes_seq { \item ##1 } \strut + \end { tabularnotes* } % \end{macrocode} % The following |\par| is mandatory for the event that the user has put % |\footnotesize| (for example) in the |notes/code-before|. % \begin{macrocode} - \par - } - { - \tabularnotes - \seq_map_inline:Nn \g_@@_tabularnotes_seq { \item ##1 } \strut - \endtabularnotes + \par + } + { + \tabularnotes + \seq_map_inline:Nn \g_@@_tabularnotes_seq { \item ##1 } \strut + \endtabularnotes + } } \unskip \group_end: @@ -7799,18 +8025,31 @@ version 2005/12/01 or later. % Now, we convert the value of |\l_@@_baseline_str| (which should represent an % integer) to an integer stored in |\l_tmpa_int|. % \begin{macrocode} - \int_set:Nn \l_tmpa_int \l_@@_baseline_str - \bool_lazy_or:nnT - { \int_compare_p:nNn \l_tmpa_int < \l_@@_first_row_int } - { \int_compare_p:nNn \l_tmpa_int > \g_@@_row_total_int } - { - \@@_error:n { bad~value~for~baseline } - \int_set:Nn \l_tmpa_int 1 - } \pgfpicture \@@_qpoint:n { row - 1 } \dim_gset_eq:NN \g_tmpa_dim \pgf@y - \@@_qpoint:n { row - \int_use:N \l_tmpa_int - base } + \str_if_in:NnTF \l_@@_baseline_str { line- } + { + \int_set:Nn \l_tmpa_int + { + \str_range:Nnn + \l_@@_baseline_str + 6 + { \str_count:N \l_@@_baseline_str } + } + \@@_qpoint:n { row - \int_use:N \l_tmpa_int } + } + { + \int_set:Nn \l_tmpa_int \l_@@_baseline_str + \bool_lazy_or:nnT + { \int_compare_p:nNn \l_tmpa_int < \l_@@_first_row_int } + { \int_compare_p:nNn \l_tmpa_int > \g_@@_row_total_int } + { + \@@_error:n { bad~value~for~baseline } + \int_set:Nn \l_tmpa_int 1 + } + \@@_qpoint:n { row - \int_use:N \l_tmpa_int - base } + } \dim_gsub:Nn \g_tmpa_dim \pgf@y \endpgfpicture \dim_gadd:Nn \g_tmpa_dim \arrayrulewidth @@ -8029,15 +8268,19 @@ version 2005/12/01 or later. \int_compare:nNnT \l_@@_first_col_int = 0 { \omit - \skip_horizontal:N -2\col@sep - \bool_if:NT \l_@@_code_before_bool - { \pgfsys@markposition { \@@_env: - col - 0 } } - \pgfpicture - \pgfrememberpicturepositiononpagetrue - \pgfcoordinate { \@@_env: - col - 0 } \pgfpointorigin - \str_if_empty:NF \l_@@_name_str - { \pgfnodealias { \l_@@_name_str - col - 0 } { \@@_env: - col - 0 } } - \endpgfpicture + \hbox_overlap_left:n + { + \bool_if:NT \l_@@_code_before_bool + { \pgfsys@markposition { \@@_env: - col - 0 } } + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgfcoordinate { \@@_env: - col - 0 } \pgfpointorigin + \str_if_empty:NF \l_@@_name_str + { \pgfnodealias { \l_@@_name_str - col - 0 } { \@@_env: - col - 0 } } + \endpgfpicture + \skip_horizontal:N 2\col@sep + \skip_horizontal:N \g_@@_width_first_col_dim + } & } \omit @@ -8108,7 +8351,7 @@ version 2005/12/01 or later. { \skip_gset_eq:NN \g_tmpa_skip \l_@@_columns_width_dim } \skip_gadd:Nn \g_tmpa_skip { 2 \col@sep } } - \skip_horizontal:N \g_tmpa_skip + \skip_horizontal:N \g_tmpa_skip \hbox { \bool_if:NT \l_@@_code_before_bool @@ -8139,12 +8382,12 @@ version 2005/12/01 or later. { & \omit + \int_gincr:N \g_tmpa_int % \end{macrocode} % The incrementation of the counter |\g_tmpa_int| must be done after the |\omit| % of the cell. % \begin{macrocode} - \int_gincr:N \g_tmpa_int - \skip_horizontal:N \g_tmpa_skip + \skip_horizontal:N \g_tmpa_skip \bool_if:NT \l_@@_code_before_bool { \hbox @@ -8171,23 +8414,27 @@ version 2005/12/01 or later. } \bool_if:NT \g_@@_last_col_found_bool { - \bool_if:NT \l_@@_code_before_bool - { - \pgfsys@markposition { \@@_env: - col - \@@_succ:n \g_@@_col_total_int } - } - \skip_horizontal:N 2\col@sep - \pgfpicture - \pgfrememberpicturepositiononpagetrue - \pgfcoordinate { \@@_env: - col - \@@_succ:n \g_@@_col_total_int } - \pgfpointorigin - \str_if_empty:NF \l_@@_name_str - { - \pgfnodealias - { \l_@@_name_str - col - \@@_succ:n \g_@@_col_total_int } - { \@@_env: - col - \@@_succ:n \g_@@_col_total_int } - } - \endpgfpicture - \skip_horizontal:N -2\col@sep + \hbox_overlap_right:n + { + % \skip_horizontal:N \col@sep + \skip_horizontal:N \g_@@_width_last_col_dim + \bool_if:NT \l_@@_code_before_bool + { + \pgfsys@markposition + { \@@_env: - col - \@@_succ:n \g_@@_col_total_int } + } + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgfcoordinate { \@@_env: - col - \@@_succ:n \g_@@_col_total_int } + \pgfpointorigin + \str_if_empty:NF \l_@@_name_str + { + \pgfnodealias + { \l_@@_name_str - col - \@@_succ:n \g_@@_col_total_int } + { \@@_env: - col - \@@_succ:n \g_@@_col_total_int } + } + \endpgfpicture + } } \cr } @@ -8235,6 +8482,8 @@ version 2005/12/01 or later. { \@@_math_toggle_token: \hbox_set_end: + \bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box: + \@@_adjust_width_box: \@@_update_for_first_and_last_row: % \end{macrocode} % We actualise the width of the ``first column'' because we will use this width @@ -8250,7 +8499,7 @@ version 2005/12/01 or later. { \dim_compare:nNnTF { \box_wd:N \l_@@_cell_box } > \c_zero_dim \@@_node_for_the_cell: - { \box_use_drop:N \l_@@_cell_box } + { \box_use_drop_x:N \l_@@_cell_box } \skip_horizontal:N \l_@@_left_delim_dim \skip_horizontal:N \l_@@_left_margin_dim \skip_horizontal:N \l_@@_extra_left_margin_dim @@ -8303,6 +8552,8 @@ version 2005/12/01 or later. { \@@_math_toggle_token: \hbox_set_end: + \bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box: + \@@_adjust_width_box: \@@_update_for_first_and_last_row: % \end{macrocode} % We actualise the width of the ``last column'' because we will use this width @@ -8660,8 +8911,6 @@ version 2005/12/01 or later. } \bool_if:NT \l_@@_hlines_bool \@@_draw_hlines: \bool_if:NT \l_@@_vlines_bool \@@_draw_vlines: - \g_@@_internal_code_after_tl - \tl_gclear:N \g_@@_internal_code_after_tl % \end{macrocode} % % \bigskip @@ -8671,6 +8920,11 @@ version 2005/12/01 or later. \cs_set_eq:NN \ialign \@@_old_ialign: \seq_if_empty:NF \g_@@_blocks_seq \@@_draw_blocks: % \end{macrocode} +% +% \begin{macrocode} + \g_@@_internal_code_after_tl + \tl_gclear:N \g_@@_internal_code_after_tl +% \end{macrocode} % % \bigskip % Now, the |code-after|. @@ -9122,7 +9376,7 @@ version 2005/12/01 or later. { \@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int } \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x - \dim_add:Nn \l_@@_x_initial_dim \@@_tab_or_array_colsep: + \dim_add:Nn \l_@@_x_initial_dim \col@sep \@@_qpoint:n { row - \int_use:N \l_@@_initial_i_int - base } \dim_set_eq:NN \l_@@_y_initial_dim \pgf@y } @@ -9131,7 +9385,7 @@ version 2005/12/01 or later. { \@@_qpoint:n { col - \@@_succ:n \l_@@_final_j_int } \dim_set_eq:NN \l_@@_x_final_dim \pgf@x - \dim_sub:Nn \l_@@_x_final_dim \@@_tab_or_array_colsep: + \dim_sub:Nn \l_@@_x_final_dim \col@sep \@@_qpoint:n { row - \int_use:N \l_@@_final_i_int - base } \dim_set_eq:NN \l_@@_y_final_dim \pgf@y } @@ -9199,16 +9453,14 @@ version 2005/12/01 or later. { \@@_qpoint:n { col - \int_use:N \l_@@_initial_j_int } \dim_set_eq:NN \l_@@_x_initial_dim \pgf@x - \dim_add:Nn \l_@@_x_initial_dim - { \bool_if:NTF \l_@@_NiceTabular_bool \tabcolsep \arraycolsep } + \dim_add:Nn \l_@@_x_initial_dim \col@sep } { \@@_set_initial_coords_from_anchor:n { mid~east } } \bool_if:NTF \l_@@_final_open_bool { \@@_qpoint:n { col - \@@_succ:n \l_@@_final_j_int } \dim_set_eq:NN \l_@@_x_final_dim \pgf@x - \dim_sub:Nn \l_@@_x_final_dim - { \bool_if:NTF \l_@@_NiceTabular_bool \tabcolsep \arraycolsep } + \dim_sub:Nn \l_@@_x_final_dim \col@sep } { \@@_set_final_coords_from_anchor:n { mid~west } } \bool_lazy_and:nnTF @@ -10255,44 +10507,8 @@ version 2005/12/01 or later. % \vspace{1cm} % The command |\@@_rotate:| will be linked to |\rotate| in % |{NiceArrayWithDelims}|. -% -% The command will exit three levels of groups (only two in |{NiceTabular}| -% because there is not the group of the math mode to exit) in order -% to execute the command -% -% \qquad ``|\box_rotate:Nn \l_@@_cell_box { 90 }|'' -% -% just after the construction of the box |\l_@@_cell_box|. -% \begin{macrocode} -\cs_new_protected:Npn \@@_rotate: - { - \bool_if:NTF \l_@@_NiceTabular_bool - { \group_insert_after:N \@@_rotate_ii: } - { \group_insert_after:N \@@_rotate_i: } - } -\cs_new_protected:Npn \@@_rotate_i: { \group_insert_after:N \@@_rotate_ii: } -\cs_new_protected:Npn \@@_rotate_ii: { \group_insert_after:N \@@_rotate_iii: } -\cs_new_protected:Npn \@@_rotate_iii: - { - \box_rotate:Nn \l_@@_cell_box { 90 } -% \end{macrocode} -% If we are in the last row, we want all the boxes composed with the command -% |\rotate| aligned upwards. -% \begin{macrocode} - \int_compare:nNnT \c@iRow = \l_@@_last_row_int - { - \vbox_set_top:Nn \l_@@_cell_box - { - \vbox_to_zero:n { } -% \end{macrocode} -% |0.8 ex| will be the distance between the principal part of the array and our -% element (which is composed with |\rotate|). % \begin{macrocode} - \skip_vertical:n { - \box_ht:N \@arstrutbox + 0.8 ex } - \box_use:N \l_@@_cell_box - } - } - } +\cs_new_protected:Npn \@@_rotate: { \bool_gset_true:N \g_@@_rotate_bool } % \end{macrocode} % % \bigskip @@ -11468,7 +11684,9 @@ version 2005/12/01 or later. % \end{macrocode} % We recall that, when externalization is used, |\tikzpicture| and % |\endtikzpicture| (or |\pgfpicture| and |\endpgfpicture|) must be directly -% ``visible''. +% ``visible''. That's why we construct now a version of |\@@_hdottedline:n| with +% the right environment (|\begin{pgfpicture}\end{pgfpicture}| or +% |\begin{tikzpiture}...\end{tikzpicture}|). % \begin{macrocode} \cs_new_protected:Npx \@@_hdottedline:n #1 { @@ -11552,14 +11770,18 @@ version 2005/12/01 or later. \dim_set:Nn \l_@@_x_initial_dim { \pgf@x + - \bool_if:NTF \l_@@_NiceTabular_bool \tabcolsep \arraycolsep +% \end{macrocode} +% We do a reduction by |\arraycolsep| for the environments with delimiters (and +% not for the other). +% \begin{macrocode} + \bool_if:NTF \l_@@_NiceArray_bool \c_zero_dim \arraycolsep - \l_@@_left_margin_dim } \@@_qpoint:n { col - \@@_succ:n \c@jCol } \dim_set:Nn \l_@@_x_final_dim { \pgf@x - - \bool_if:NTF \l_@@_NiceTabular_bool \tabcolsep \arraycolsep + \bool_if:NTF \l_@@_NiceArray_bool \c_zero_dim \arraycolsep + \l_@@_right_margin_dim } % \end{macrocode} @@ -12059,14 +12281,28 @@ version 2005/12/01 or later. % The code deals with the command |\Block|. This command has no direct link with % the environment |{NiceMatrixBlock}|. % +% \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|). +% \begin{macrocode} +\keys_define:nn { NiceMatrix / Block / FirstPass } + { + 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 , + 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 following command will be linked to |\Block| in the environments of % \pkg{nicematrix}. We define it with |\NewDocumentCommand| of \pkg{xparse} % because it has an optional argument between |<| and |>| (for TeX instructions % put before the math mode of the label) % -% It's mandatory to use an expandable command (probably because of the first -% optional argument?). +% It's mandatory to use an expandable command (why?). % \begin{macrocode} \NewExpandableDocumentCommand \@@_Block: { O { } m D < > { } m } { \@@_Block_i #2 \q_stop { #1 } { #3 } { #4 } } @@ -12088,10 +12324,18 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Npn \@@_Block_ii:nnnnn #1 #2 #3 #4 #5 { - \bool_if:NT \l_@@_NiceTabular_bool - { \tl_if_empty:nF { #4 } { \@@_error:n { angle~option~in~NiceTabular } } } % \end{macrocode} % +% \begin{macrocode} + \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 } +% \end{macrocode} +% \medskip +% \begin{macrocode} + \keys_set_known:nn { NiceMatrix / Block / FirstPass } { #3 } +% \end{macrocode} +% % \medskip % \begin{macrocode} \tl_set:Nx \l_tmpa_tl @@ -12103,7 +12347,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 surrounded by curly brackets: +% block whith four components, each of them surrounded by curly brackets: % % |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}|. % @@ -12118,13 +12362,157 @@ version 2005/12/01 or later. % components: % % |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}{|\textsl{options}|}{|\textsl{contents}|}|. +% +% \medskip +% If the block is mono-column, we have a special treatment. % \begin{macrocode} - \seq_gput_left:Nx \g_@@_blocks_seq - { - \l_tmpa_tl - { #3 } - \exp_not:n { { #4 \@@_math_toggle_token: #5 \@@_math_toggle_token: } } - } + \int_compare:nNnTF { #2 } = 1 + { + \int_gincr:N \g_@@_block_box_int + \cs_set_protected_nopar:Npn \diagbox ##1 ##2 + { + \tl_gput_right:Nx \g_@@_internal_code_after_tl + { + \@@_actually_diagbox:nnnnnn + { \int_use:N \c@iRow } + { \int_use:N \c@jCol } + { \int_eval:n { \c@iRow + #1 - 1 } } + { \int_eval:n { \c@jCol + #2 - 1 } } + { \exp_not:n { ##1 } } { \exp_not:n { ##2 } } + } + } + \box_gclear_new:c + { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box } + \hbox_gset:cn + { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box } + { +% \end{macrocode} +% The main aim of the following |\color_ensure_current:| is to retrieve in the +% box a color specified for that column in the preamble (e.g. something like +% |>{\color{red}}|). +% \begin{macrocode} + \color_ensure_current: + \bool_if:NTF \l_@@_NiceTabular_bool + { + \group_begin: + \cs_set:Npn \arraystretch { 1 } + \dim_set_eq:NN \extrarowheight \c_zero_dim + #4 +% \end{macrocode} +% If the box is rotated (the key |\rotate| may be in the previous |#4|), the +% tabular used for the content of the cell will be constructed with a format +% |c|. In the other cases, the tabular will be constructed with a format equal +% to the key of position of the box. In other words: the alignement internal to +% the tabular is the same as the external alignment of the tabular (that is to +% say the position of the block in its zone of merged cells). +% \begin{macrocode} + \bool_if:NT \g_@@_rotate_bool + { \tl_set:Nn \l_@@_pos_of_block_tl c } + \exp_args:Nnx \begin { tabular } + { @ { } \l_@@_pos_of_block_tl @ { } } + #5 + \end { tabular } + \group_end: + } + { + \group_begin: + \cs_set:Npn \arraystretch { 1 } + \dim_set_eq:NN \extrarowheight \c_zero_dim + #4 + \bool_if:NT \g_@@_rotate_bool + { \tl_set:Nn \l_@@_pos_of_block_tl c } + \c_math_toggle_token + \exp_args:Nnx \begin { array } + { @ { } \l_@@_pos_of_block_tl @ { } } + #5 + \end { array } + \c_math_toggle_token + \group_end: + } + } + \bool_if:NT \g_@@_rotate_bool + { + \box_grotate:cn + { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box } + { 90 } + \bool_gset_false:N \g_@@_rotate_bool + } + \dim_gset:Nn \g_@@_blocks_width_dim + { + \dim_max:nn + \g_@@_blocks_width_dim + { + \box_wd:c + { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box } + } + } + \seq_gput_right:Nx \g_@@_blocks_seq + { + \l_tmpa_tl +% \end{macrocode} +% In the list of options |#3|, maybe there is a key for the horizontal alignment +% (|l|, |r| or |c|). In that case, that key has been read and stored in +% |\l_@@_pos_of_block_tl|. However, maybe there were no key of the horizontal +% alignement and that's why we put a key corresponding to the value of +% |\l_@@_pos_of_block_tl|, which is fixed by the type of current column. +% \begin{macrocode} + { #3 , \l_@@_pos_of_block_tl } + { + \box_use_drop:c + { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box } + } + } + } +% \end{macrocode} +% In the standard case, that is to say a |\Block| which is \emph{not} mono-column. +% \begin{macrocode} + { + \seq_gput_right:Nx \g_@@_blocks_seq + { + \l_tmpa_tl + { #3 } + \exp_not:n + { + { + \bool_if:NTF \l_@@_NiceTabular_bool + { + \group_begin: + \cs_set:Npn \arraystretch { 1 } + \dim_set_eq:NN \extrarowheight \c_zero_dim + #4 +% \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 +% |c|. In the other cases, the tabular will be constructed with a format equal +% to the key of position of the box. In other words: the alignement internal to +% the tabular is the same as the external alignment of the tabular (that is to +% say the position of the block in its zone of merged cells). +% \begin{macrocode} + \bool_if:NT \g_@@_rotate_bool + { \tl_set:Nn \l_@@_pos_of_block_tl c } + \exp_args:Nnx \begin { tabular } + { @ { } \l_@@_pos_of_block_tl @ { } } + #5 + \end { tabular } + \group_end: + } + { + \group_begin: + \cs_set:Npn \arraystretch { 1 } + \dim_set_eq:NN \extrarowheight \c_zero_dim + #4 + \bool_if:NT \g_@@_rotate_bool + { \tl_set:Nn \l_@@_pos_of_block_tl c } + \c_math_toggle_token + \exp_args:Nnx \begin { array } + { @ { } \l_@@_pos_of_block_tl @ { } } #5 \end { array } + \c_math_toggle_token + \group_end: + } + } + } + } + } } % \end{macrocode} % @@ -12135,7 +12523,7 @@ version 2005/12/01 or later. % ``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 } +\keys_define:nn { NiceMatrix / Block / SecondPass } { tikz .tl_set:N = \l_@@_tikz_tl , tikz .value_required:n = true , @@ -12166,7 +12554,7 @@ version 2005/12/01 or later. % The group is for the keys. % \begin{macrocode} \group_begin: - \keys_set:nn { NiceMatrix / Block } { #5 } + \keys_set:nn { NiceMatrix / Block / SecondPass} { #5 } % \end{macrocode} % % \begin{macrocode} @@ -12202,11 +12590,8 @@ version 2005/12/01 or later. { \int_compare_p:nNn { #4 } > \g_@@_col_total_int } { \msg_error:nnnn { nicematrix } { Block~too~large } { #1 } { #2 } } { -% \end{macrocode} -% We put the contents of the cell in the box |\l_@@_cell_box| because we want -% the command |\rotate| used in the content to be able to rotate the box. -% \begin{macrocode} - \hbox_set:Nn \l_@@_cell_box { #6 } + \hbox_set:Nn \l_@@_cell_box { #6 } + \bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box: % \end{macrocode} % % \bigskip @@ -12359,7 +12744,7 @@ version 2005/12/01 or later. { % \end{macrocode} % We take into account the case of a block of one row in the ``first row'' or -% the ``end row''. +% the ``last row''. % \begin{macrocode} \int_compare:nNnTF { #1 } = 0 { \l_@@_code_for_first_row_tl } @@ -12402,22 +12787,29 @@ version 2005/12/01 or later. r { base~east } } } - { \box_use_drop:N \l_@@_cell_box } { } { } + { \box_use_drop_xi:N \l_@@_cell_box } { } { } } % \end{macrocode} % % \medskip -% If the number of rows is different of $1$, we put the label of the block in -% using the short node (the label of the block has been composed in +% 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 % |\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 + { \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 } \pgftransformshift { \pgfpointanchor { \@@_env: - #1 - #2 - block - short } { - \str_case:Vn \l_@@_pos_of_block_tl + \str_case:Vn \l_@@_pos_of_block_tl { c { center } l { west } @@ -12436,7 +12828,7 @@ version 2005/12/01 or later. r { east } } } - { \box_use_drop:N \l_@@_cell_box } { } { } + { \box_use_drop_xii:N \l_@@_cell_box } { } { } } \endpgfpicture } @@ -13118,14 +13510,6 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} -\@@_msg_new:nn { angle~option~in~NiceTabular } - { - You~should~not~the~option~between~angle~brackets~(<~and~>)~for~a~command~ - \token_to_str:N \Block\ in~\{NiceTabular\}.~However,~you~can~go~on. - } -% \end{macrocode} -% -% \begin{macrocode} \@@_msg_new:nn { tabularnote~forbidden } { You~can't~use~the~command~\token_to_str:N\tabularnote\ @@ -13187,6 +13571,7 @@ version 2005/12/01 or later. } % \end{macrocode} % +% % \begin{macrocode} \@@_msg_new:nnn { Unknown~key~for~Block } { @@ -13195,7 +13580,7 @@ version 2005/12/01 or later. For~a~list~of~the~available~keys,~type~H~. } { - The~available~options~are~(in~alphabetic~order):~c,~ + The~available~options~are~(in~alphabetic~order):~-,~c,~ color,~l,~and~r. } % \end{macrocode} @@ -13297,6 +13682,7 @@ version 2005/12/01 or later. first-row,~ hlines,~ hvlines,~ + hvlines-except-corners,~ last-col,~ last-row,~ left-margin,~ @@ -13353,6 +13739,7 @@ version 2005/12/01 or later. first-row,~ hlines,~ hvlines,~ + hvlines-except-corners,~ l,~ last-col,~ last-row,~ @@ -13405,6 +13792,7 @@ version 2005/12/01 or later. first-row,~ hlines,~ hvlines,~ + hvlines-except-corners,~ last-col,~ last-row,~ left-margin,~ @@ -13824,7 +14212,12 @@ version 2005/12/01 or later. % specify which dotted line will be drawn first (the other lines will be drawn % parallel to that one if parallelization is activated). % +% \subsection*{Changes between versions 5.3 and 5.4} % +% Key |tabularnote|. +% +% Different behaviour for the mono-column blocks. +% % \PrintIndex % % \tableofcontents diff --git a/macros/latex/contrib/nicematrix/nicematrix.pdf b/macros/latex/contrib/nicematrix/nicematrix.pdf index 9743eb335d..12313e198a 100644 Binary files a/macros/latex/contrib/nicematrix/nicematrix.pdf and b/macros/latex/contrib/nicematrix/nicematrix.pdf differ -- cgit v1.2.3