summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2020-05-27 21:45:50 +0000
committerKarl Berry <karl@freefriends.org>2020-05-27 21:45:50 +0000
commitae777e8c9cd9b932a2ebcad4bc6af2c185ac09e5 (patch)
tree1375a62a0417ff2fd35f32a31f6ea4f690593bdf /Master/texmf-dist/source
parent5ee27d9c2742c9956bae4c3e3fa9f7b9c0a58d45 (diff)
nicematrix (27may20)
git-svn-id: svn://tug.org/texlive/trunk@55302 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r--Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx4061
1 files changed, 2334 insertions, 1727 deletions
diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx
index a78a94ee50c..7e220667699 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{4.0}
-\def\myfiledate{2020/05/08}
+\def\myfileversion{4.1}
+\def\myfiledate{2020/05/27}
%
%
%<*batchfile>
@@ -123,38 +123,12 @@ version 2005/12/01 or later.
%
% \begin{abstract}
% The LaTeX package \pkg{nicematrix} provides new environments similar to the
-% classical environments |{tabular}|, |{array}| and |{matrix}| but with some
-% additional features. Among these features are the possibilities to fix the
-% width of the columns and to draw continuous ellipsis dots between the cells of
-% the array.
+% classical environments |{tabular}|, |{array}| and |{matrix}| of \pkg{array}
+% and \pkg{amsmath} but with extended features.
% \end{abstract}
%
% \vspace{1cm}
-% \section{Presentation}
-%
-%
-% This package can be used with |xelatex|, |lualatex|, |pdflatex| but also by
-% the classical workflow |latex|-|dvips|-|ps2pdf| (or Adobe Distiller). Two or
-% three compilations may be necessary. This package requires and \textbf{loads}
-% the packages \pkg{l3keys2e}, \pkg{xparse}, \pkg{array}, \pkg{amsmath},
-% \pkg{pgfcore} and the module \pkg{shapes} of \textsc{pgf} (\pkg{tikz} is
-% \emph{not} loaded). The final user only has to load the package with
-% |\usepackage{nicematrix}|.
-%
-%
-% \medskip
-% \begin{savenotes}
-% \begin{minipage}{0.6\linewidth}
-% This package provides some new tools to draw mathematical matrices. The main
-% features are the following:
-% \begin{itemize}\setlength{\itemsep}{0pt}
-% \item continuous dotted lines;
-% \item exterior rows and columns for labels;
-% \item a control of the width of the columns.
-% \end{itemize}
-% \end{minipage}
-% \end{savenotes}
-% \hspace{1.4cm}
+% \hspace{1cm}
% $\begin{bNiceArray}{CCCC}[first-row,first-col,
% code-for-first-col=\color{blue}\scriptstyle,
% code-for-first-row=\color{blue}\scriptstyle,
@@ -164,98 +138,1155 @@ version 2005/12/01 or later.
% L_2 & a_{21} & a_{22} & \Cdots & a_{2n} \\
% \Vdots & \Vdots & \Vdots & \Ddots & \Vdots\\
% L_n & a_{n1} & a_{n2} & \Cdots & a_{nn}
-% \end{bNiceArray}$
+% \end{bNiceArray}$\hspace{2cm}
+% \begin{NiceTabular}{LSSSS}[code-before = \rowcolor{red!15}{1-2} \rowcolors{3}{blue!15}{}]
+% \toprule
+% \Block{2-1}{Product} & \multicolumn{3}{C}{dimensions (cm)} & \Block{2-1}{\rotate Price} \\
+% \cmidrule(rl){2-4}
+% & L & l & h \\
+% \midrule
+% small & 3 & 5.5 & 1 & 30 \\
+% standard & 5.5 & 8 & 1.5 & 50.5 \\
+% premium & 8.5 & 10.5 & 2 & 80 \\
+% extra & 8.5 & 10 & 1.5 & 85.5 \\
+% special & 12 & 12 & 0.5 & 70 \\
+% \bottomrule
+% \end{NiceTabular}
+%
+% \vspace{1cm}
+% The package \pkg{nicematrix} is entirely contained in the file
+% |nicematrix.sty|. This file may be put in the current directory or in a
+% |texmf| tree. However, the best is to install \pkg{nicematrix} with a TeX
+% distribution as MiKTeX or TeXlive.
+%
+% \bigskip
+% This package can be used with |xelatex|, |lualatex|, |pdflatex| but also by
+% the classical workflow |latex|-|dvips|-|ps2pdf| (or Adobe Distiller).
+%
+% \bigskip
+% This package requires and \textbf{loads} the packages \pkg{l3keys2e},
+% \pkg{xparse}, \pkg{array}, \pkg{amsmath}, \pkg{pgfcore} and the module
+% \pkg{shapes} of \textsc{pgf} (\pkg{tikz}, which is a layer over \textsc{pgf}
+% is \emph{not} loaded). The final user only has to load the package with
+% |\usepackage{nicematrix}|.
+%
+%
+% \bigskip
+% The idea of \pkg{nicematrix} is to create \textsc{pgf} nodes under the cells
+% and the positions of the rules of the tabular created by \pkg{array} and to
+% use these nodes to develop new features. As usual with \textsc{pgf}, the
+% coordinates of these nodes are written in the |.aux| to be used on the next
+% compilation and that's why \pkg{nicematrix} may need \textbf{several
+% compilations}.
%
-% \medskip
+% \bigskip
+% Most features of \pkg{nicematrix} may be used without explicit use of
+% \textsc{pgf} or Tikz (which, in fact, is not loaded by default).
+%
+% \bigskip
% A command |\NiceMatrixOptions| is provided to fix the options (the
-% scope of the options fixed by this command is the current TeX group).
+% scope of the options fixed by this command is the current TeX group: they are
+% semi-global).
+%
%
+% \newpage
+%
+% \section{The environments of this package}
+%
+% The package \pkg{nicematrix} defines the following new environments.
+%
+% \medskip
+% \begin{ttfamily}
+% \setlength{\tabcolsep}{3mm}
+% \begin{tabular}{llll}
+% \{NiceTabular\} & \{NiceArray\} & \{NiceMatrix\} \\
+% & \{pNiceArray\} & \{pNiceMatrix\} \\
+% & \{bNiceArray\} & \{bNiceMatrix\} \\
+% & \{BNiceArray\} & \{BNiceMatrix\} \\
+% & \{vNiceArray\} & \{vNiceMatrix\} \\
+% & \{VNiceArray\} & \{VNiceMatrix\}
+% \end{tabular}
+% \end{ttfamily}
+%
+%
+%
+%
+% \medskip
+% The environments |{NiceArray}| and |{NiceTabular}| are similar to the
+% environments |{array}| and |{tabular}| of the package \pkg{array} (which is
+% loaded by \pkg{nicematrix} ).
+%
+% \medskip
+% However, there are some small differences:
+% \begin{itemize}
+% \item For technical reasons, in the preamble of these environments, the user
+% must use the letters |L|, |C| and~|R|\footnote{The column types |L|, |C| and
+% |R| are defined locally inside |{NiceTabular}| or |{NiceArray}| with
+% |\newcolumntype| of \pkg{array}. This definition overrides an eventual
+% previous definition.} instead of |l|, |c| and |r|, included in the commands
+% |\multicolumn| and in the types of columns defined by |\newcolumntype|.
+%
+% * In |{NiceArray}| (and its variants), the columns of type |w| (ex. :
+% |wc{1cm}|) are composed in math mode whereas, in |{array}| of \pkg{array},
+% they are composed in text mode.
+% \end{itemize}
+%
+% \medskip
+% The environments |{pNiceArray}|, |{bNiceArray}|, etc. have no equivalent in
+% \pkg{array}.
+%
+% \medskip
+% The environments |{NiceMatrix}|, |{pNiceMatrix}|, etc. are similar to the
+% corresponding environments of \pkg{amsmath} (which is loaded by
+% \pkg{nicematrix}): |{matrix}|, |{pmatrix}|, etc.
+%
+% \medskip
+% All the environments of the package \pkg{nicematrix} accept, between square
+% brackets, an optional list of \textsl{key=value} pairs. \textbf{There must be
+% no space before the opening bracket (|[|) of this list of options.}
+%
+% \section{The vertical space between the rows}
+%
+% It's well known that some rows of the arrays created by default with LaTeX
+% are, by default, too close to each other. Here is a classical example.
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
+% $\begin{pmatrix}
+% \frac12 & -\frac12 \\
+% \frac13 & \frac14 \\
+% \end{pmatrix}$
+% \end{BVerbatim}
+% $\begin{pmatrix}
+% \frac12 & -\frac12 \\
+% \frac13 & \frac14 \\
+% \end{pmatrix}$
%
% \bigskip
-% \textbf{An example for the continuous dotted lines}
+% Inspired by the package \pkg{cellspace} which deals with that problem, the
+% package \pkg{nicematrix} provides two keys |cell-space-top-limit| and
+% |cell-space-bottom-limit| similar to the parameters |\cellspacetoplimit| and
+% |\cellspacebottomlimit| of \pkg{cellspace}. The initial value of these
+% parameters is $0$~pt in order to have for the environments of \pkg{nicematrix}
+% the same behaviour as those of \pkg{array} and \pkg{amsmath}. However, a value
+% of $1$~pt would probably be a good choice and we suggest to set them with
+% |\NiceMatrixOptions|.
%
% \medskip
-% \begin{minipage}{10cm}
-% For example, consider the following code which uses an environment |{pmatrix}|
-% of \pkg{amsmath}.
+% \begin{Verbatim}
+% \NiceMatrixOptions{~emphase#cell-space-top-limit = 1pt,cell-space-bottom-limit = 1pt@}
+% \end{Verbatim}
%
+% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
+% $\begin{pNiceMatrix}
+% \frac12 & -\frac12 \\
+% \frac13 & \frac14 \\
+% \end{pNiceMatrix}$
+% \end{BVerbatim}
+% \begin{scope}
+% \NiceMatrixOptions{
+% cell-space-top-limit = 1pt ,
+% cell-space-bottom-limit = 1pt ,
+% }
+% $\begin{pNiceMatrix}
+% \frac12 & -\frac12 \\
+% \frac13 & \frac14 \\
+% \end{pNiceMatrix}$
+% \end{scope}
+%
+%
+%
+%
+%
+% \bigskip
+% \section{The vertical position of the arrays}
+%
+% The package \pkg{nicematrix} provides a option |baseline| for the vertical
+% position of the arrays. This option takes as value an integer which is the
+% number of the row on which the array will be aligned.
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
+% $A = \begin{pNiceMatrix}[~emphase#baseline=2@]
+% \frac{1}{\sqrt{1+p^2}} & p & 1-p \\
+% 1 & 1 & 1 \\
+% 1 & p & 1+p
+% \end{pNiceMatrix}$
+% \end{BVerbatim}
+% $A = \begin{pNiceMatrix}[baseline=2]
+% \frac{1}{\sqrt{1+p^2}} & p & 1-p \\
+% 1 & 1 & 1 \\
+% 1 & p & 1+p
+% \end{pNiceMatrix}$
+%
+%
+% \medskip
+% It's also possible to use the option |baseline| with one of the special values
+% |t|, |c| or |b|. These letters may also be used absolutely like the option of
+% the environments |{tabular}| and |{array}| of \pkg{array}. The initial value
+% of |baseline| is~|c|.
+%
+%
+% \medskip
+% In the following example, we use the option |t| (equivalent to |baseline=t|)
+% immediately after an |\item| of list. One should remark that the presence of a
+% |\hline| at the beginning of the array doesn't prevent the alignment of the
+% baseline with the baseline of the first row (with |{tabular}| or |{array}| of
+% \pkg{array}, one must use |\firsthline|\footnote{It's also possible to use
+% |\firsthline| in the environments of \pkg{nicematrix}.}).
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
+% \begin{enumerate}
+% \item an item
+% \smallskip
+% \item \renewcommand{\arraystretch}{1.2}
+% $\begin{NiceArray}~emphase#[t]@{LCCCCCC}
+% \hline
+% n & 0 & 1 & 2 & 3 & 4 & 5 \\
+% u_n & 1 & 2 & 4 & 8 & 16 & 32
+% \hline
+% \end{NiceArray}$
+% \end{enumerate}
+% \end{BVerbatim}
+% \begin{minipage}{5cm}
+% \begin{enumerate}
+% \item an item
+% \smallskip
+% \item \renewcommand{\arraystretch}{1.2}
+% $\begin{NiceArray}[t]{LCCCCCC}
+% \hline
+% n & 0 & 1 & 2 & 3 & 4 & 5 \\
+% u_n & 1 & 2 & 4 & 8 & 16 & 32 \\
+% \hline
+% \end{NiceArray}$
+% \end{enumerate}
+% \end{minipage}
+%
+% \medskip
+% However, it's also possible to use the tools of \pkg{booktabs}: |\toprule|,
+% |\bottomrule|, |\midrule|, etc.\par\nobreak
+%
+% \smallskip
+% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
+% \begin{enumerate}
+% \item an item
+% \smallskip
+% \item
+% $\begin{NiceArray}[t]{LCCCCCC}
+% ~emphase#\toprule@
+% n & 0 & 1 & 2 & 3 & 4 & 5 \\
+% ~emphase#\midrule@
+% u_n & 1 & 2 & 4 & 8 & 16 & 32
+% ~emphase#\bottomrule@
+% \end{NiceArray}$
+% \end{enumerate}
+% \end{BVerbatim}
+% \begin{minipage}{5cm}
+% \begin{enumerate}
+% \item an item
% \smallskip
+% \item
+% $\begin{NiceArray}[t]{LCCCCCC}
+% \toprule
+% n & 0 & 1 & 2 & 3 & 4 & 5 \\
+% \midrule
+% u_n & 1 & 2 & 4 & 8 & 16 & 32 \\
+% \bottomrule
+% \end{NiceArray}$
+% \end{enumerate}
+% \end{minipage}
+%
+%
+% \section{The blocks}
+% \label{Block}
+%
+% 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.
+%
+% 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
+% $i$\verb|-|$j$ where $i$ is the number of rows of the block and $j$ its number
+% of columns. The second argument is the content of the block.
+%
+% In |{NiceTabular}| the content of the block is composed in text mode. In the
+% other environments, it is composed in math mode.
+%
+% \medskip
% \begin{BVerbatim}
-% $A = \begin{pmatrix}
-% 1 & \cdots & \cdots & 1 \\
-% 0 & \ddots & & \vdots \\
-% \vdots & \ddots & \ddots & \vdots \\
-% 0 & \cdots & 0 & 1
-% \end{pmatrix}$
+% \begin{NiceTabular}{CCCC}
+% rose & tulipe & marguerite & dahlia \\
+% violette & ~emphase#\Block{2-2}{\LARGE\color{blue} fleurs}@ & & souci \\
+% pervenche & & & lys \\
+% arum & iris & jacinthe & muguet
+% \end{NiceTabular}
% \end{BVerbatim}
%
+%
+% \medskip
+% \begin{center}
+% \begin{NiceTabular}{CCCC}
+% rose & tulipe & marguerite & dahlia \\
+% violette & \Block{2-2}{\LARGE\color{blue} fleurs} & & souci \\
+% pervenche & & & lys \\
+% arum & iris & jacinthe & muguet
+% \end{NiceTabular}
+% \end{center}
+%
+%
+%
+% \medskip
+% 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}
+%
+% The usual techniques for the rules may be used in the environments of
+% \pkg{nicematrix} (excepted |\vline|).
+%
+%
+% \subsection{The thickness and the color of the rules}
+%
+% The environments of \pkg{nicematrix} provide a key |rules/width| to set the
+% width (in fact the thickness) of the rules in the current environment. In
+% fact, this key merely sets the value of the length |\arrayrulewidth|.
+%
% \smallskip
-% This code composes the matrix $A$ on the right.
-% \end{minipage}\hspace{1cm}
-% $A = \begin{pmatrix}
-% 1 &\cdots &\cdots &1 \\
-% 0 &\ddots & &\vdots \\
-% \vdots &\ddots &\ddots &\vdots \\
-% 0 &\cdots &0 &1
-% \end{pmatrix}$
+% It's well known that \pkg{colortbl} provides the command |\arrayrulecolor| in
+% order to specify the color of the rules.
+%
+% \smallskip
+% With \pkg{nicematrix}, it's possible to specify the color of the rules even
+% when \pkg{colortbl} is not loaded. For sake of compatibility, the command is
+% also named |\arrayrulecolor|. The environments of \pkg{nicematrix} also
+% provide a key |rules/color| to fix the color of the rules in the current
+% environment.
+%
+% \medskip
+% \begin{scope}
+% \hfuzz=10cm
+% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm]
+% \begin{NiceTabular}{|CCC|}[~emphase#rules/color=[gray]{0.9},rules/width=1pt@]
+% \hline
+% rose & tulipe & lys \\
+% arum & iris & violette \\
+% muguet & dahlia & souci \\
+% \hline
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \begin{NiceTabular}{|CCC|}[rules/color=[gray]{0.9},rules/width=1pt]
+% \hline
+% rose & tulipe & lys \\
+% arum & iris & violette \\
+% muguet & dahlia & souci \\
+% \hline
+% \end{NiceTabular}
+% \end{scope}
+%
+% \medskip
+% If one wishes to define new specifiers for columns in order to draw vertical
+% rules (for example with a specific color or thicker than the standard rules),
+% he should consider the command |\OnlyMainNiceMatrix| described on
+% page~\pageref{OnlyMainNiceMatrix}.
%
%
% \bigskip
+% \subsection{A remark about \textbackslash cline}
+%
+%\label{remark-cline}
+%
+% The horizontal and vertical rules drawn by |\hline| and the specifier
+% ``\verb+|+'' make the array larger or wider by a quantity equal to the width of the rule.
+%
+% \smallskip
+% For historical reasons, this is not the case with the command |\cline|, as
+% shown by the following example.
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
+% \setlength{\arrayrulewidth}{2pt}
+% \begin{tabular}{cccc} \hline
+% A&B&C&D \\ ~emphase#\cline{2-2}@
+% A&B&C&D \\ \hline
+% \end{tabular}
+% \end{BVerbatim}
% \begin{scope}
-% \NiceMatrixOptions{transparent}
-% \begin{minipage}{10cm}
-% Now, if we use the package \pkg{nicematrix} with the option \\
-% |transparent|, the same code will give the result on the right.
-% \end{minipage}\hspace{1cm}
-% $A = \begin{pmatrix}
-% 1 & \cdots & \cdots & 1 \\
-% 0 & \ddots & & \vdots \\
-% \vdots & \ddots & \ddots & \vdots \\
-% 0 & \cdots & 0 & 1
-% \end{pmatrix}$
+% \setlength{\arrayrulewidth}{2pt}
+% \begin{tabular}[c]{cccc}
+% \hline
+% A&B&C&D \\
+% \cline{2-2}
+% A&B&C&D \\
+% \hline
+% \end{tabular}
% \end{scope}
%
+% \medskip
+% In the environments of \pkg{nicematrix}, this situation is corrected (it's
+% still possible to go to the standard behaviour of |\cline| with the key |standard-cline|).
%
-% \section{The environments of this package}
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
+% \setlength{\arrayrulewidth}{2pt}
+% \begin{NiceTabular}{CCCC} \hline
+% A&B&C&D \\ ~emphase#\cline{2-2}@
+% A&B&C&D \\ \hline
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \begin{scope}
+% \setlength{\arrayrulewidth}{2pt}
+% \begin{NiceTabular}[c]{CCCC}
+% \hline
+% A&B&C&D \\
+% \cline{2-2}
+% A&B&C&D \\
+% \hline
+% \end{NiceTabular}
+% \end{scope}
%
-% The package \pkg{nicematrix} defines the following new environments.
+% \subsection{The keys hlines and vlines}
+%
+% The key |hlines| draws all the horizontal rules and the key |vlines| draws all
+% the vertical rules. In fact, in the environments with delimiters (as
+% |{pNiceMatrix}| or |{bNiceArray}|) the exteriors rules are not drawn (as
+% expected).
%
% \medskip
-% \begin{ttfamily}
-% \setlength{\tabcolsep}{3mm}
-% \begin{tabular}{llll}
-% \{NiceMatrix\} & \{NiceArray\} & \{NiceTabular\} \\
-% \{pNiceMatrix\} & \{pNiceArray\} \\
-% \{bNiceMatrix\} & \{bNiceArray\} \\
-% \{BNiceMatrix\} & \{BNiceArray\} \\
-% \{vNiceMatrix\} & \{vNiceArray\} \\
-% \{VNiceMatrix\} & \{VNiceArray\} \\
-% & \{NiceArrayWithDelims\}
-% \end{tabular}
-% \end{ttfamily}
+% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
+% $\begin{pNiceMatrix}[~emphase#vlines@,rules/width=0.2pt]
+% 1 & 2 & 3 & 4 & 5 & 6 \\
+% 1 & 2 & 3 & 4 & 5 & 6 \\
+% 1 & 2 & 3 & 4 & 5 & 6
+% \end{pNiceMatrix}$
+% \end{BVerbatim}
+% $\begin{pNiceMatrix}[vlines,rules/width=0.2pt]
+% 1 & 2 & 3 & 4 & 5 & 6 \\
+% 1 & 2 & 3 & 4 & 5 & 6 \\
+% 1 & 2 & 3 & 4 & 5 & 6
+% \end{pNiceMatrix}$
%
+% \bigskip
+% However, there is a difference between the key |vlines| and the use of
+% the specifier ``"|"'' in the preamble of the environment: the rules drawn by
+% |vlines| completely cross the double-rules drawn by |\hline\hline| (you don't
+% need \pkg{hhline}).
%
% \medskip
-% By default, the environments |{NiceMatrix}|, |{pNiceMatrix}|, |{bNiceMatrix}|,
-% |{BNiceMatrix}|, |{vNiceMatrix}| and |{VNiceMatrix}| behave almost exactly as
-% the corresponding environments of \pkg{amsmath}: |{matrix}|, |{pmatrix}|,
-% |{bmatrix}|, |{Bmatrix}|, |{vmatrix}| and |{Vmatrix}|.
+% \begin{BVerbatim}[baseline=c,boxwidth=11.5cm]
+% $\begin{NiceMatrix}[~emphase#vlines@] \hline
+% a & b & c & d \\ \hline \hline
+% 1 & 2 & 3 & 4 \\
+% 1 & 2 & 3 & 4 \\ \hline
+% \end{NiceMatrix}$
+% \end{BVerbatim}
+% $\begin{NiceMatrix}[vlines]
+% \hline
+% a & b & c & d \\
+% \hline \hline
+% 1 & 2 & 3 & 4 \\
+% 1 & 2 & 3 & 4 \\
+% \hline
+% \end{NiceMatrix}$
+%
+%
+% \bigskip
+% If you use \pkg{booktabs} (which provides |\toprule|, |midrule|, |bottomrule|,
+% etc.) and you really want to draw vertical rules (something opposed to the
+% spirit of \pkg{booktabs}), you should remark that the key |vlines| in
+% compatible with \pkg{booktabs}.
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=11.5cm]
+% $\begin{NiceMatrix}[~emphase#vlines@] \toprule
+% a & b & c & d \\ \midrule
+% 1 & 2 & 3 & 4 \\
+% 1 & 2 & 3 & 4 \\ \bottomrule
+% \end{NiceMatrix}$
+% \end{BVerbatim}
+% $\begin{NiceMatrix}[vlines]
+% \toprule
+% a & b & c & d \\
+% \midrule
+% 1 & 2 & 3 & 4 \\
+% 1 & 2 & 3 & 4 \\
+% \bottomrule
+% \end{NiceMatrix}$
+%
+%
+% \subsection{The key hvlines}
+% \label{hvlines}
+%
+% The key |hvlines| draws all the vertical and horizontal rules \emph{excepted
+% in the blocks}.\footnote{In fact, when the key |hvlines| is in force, the
+% rules are also not drawn in the virtual blocks delimited by cells relied par
+% dotted lines (cf. p. \pageref{dotted-and-hvlines}).}
+%
+% \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 \\
+% pervenche & & & lys \\
+% arum & iris & jacinthe & muguet
+% \end{NiceTabular}
+% \end{Verbatim}
+%
+% \begin{center}
+% \setlength{\arrayrulewidth}{1pt}
+% \begin{NiceTabular}{CCCC}[hvlines,rules/color=blue]
+% rose & tulipe & marguerite & dahlia \\
+% violette & \Block{2-2}{\LARGE\color{blue} fleurs} & & souci \\
+% pervenche & & & lys \\
+% arum & iris & jacinthe & muguet
+% \end{NiceTabular}
+% \end{center}
+%
+%
%
+% \subsection{La commande \textbackslash diagbox}
+%
+% The command |\diagbox| (inspired by the package \pkg{diagbox}), allows, when
+% it is used in a cell, to slash that cell diagonally downwards.\footnote{The
+% author of this document considers that type of construction as graphically
+% poor.}.
%
% \medskip
-% The environments |{NiceArray}| and |{NiceTabular}| are similar to the
-% environments |{array}| and |{tabular}| of the
-% package |{array}|. However, for technical reasons, in the preamble of these
-% environments, the user must use the letters |L|, |C| and~|R|
-% instead of |l|, |c| and |r|. It's possible to use the constructions
-% |w{...}{...}|, |W{...}{...}|, "|", |>{...}|, |<{...}|, |@{...}|, |!{...}| and
-% |*{n}{...}| but the letters |p|, |m| and |b| should not be used.
+% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
+% $\begin{NiceArray}{*{5}{C}}[hvlines]
+% ~emphase#\diagbox{x}{y}@ & e & a & b & c \\
+% e & e & a & b & c \\
+% a & a & e & c & b \\
+% b & b & c & e & a \\
+% c & c & b & a & e
+% \end{NiceArray}$
+% \end{BVerbatim}
+% $\begin{NiceArray}{*{5}{C}}[hvlines]
+% \diagbox{x}{y} & e & a & b & c \\
+% e & e & a & b & c \\
+% a & a & e & c & b \\
+% b & b & c & e & a \\
+% c & c & b & a & e
+% \end{NiceArray}$
+%
+%
+%
+% \subsection{Dotted rules}
+%
+%
+% In the environments of the package \pkg{nicematrix}, it's possible to use
+% the command |\hdottedline| (provided by \pkg{nicematrix}) which is a
+% counterpart of the classical commands |\hline| and |\hdashline| (the latter is
+% a command of \pkg{arydshln}).
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm]
+% \begin{pNiceMatrix}
+% 1 & 2 & 3 & 4 & 5 \\
+% ~emphase#\hdottedline@
+% 6 & 7 & 8 & 9 & 10 \\
+% 11 & 12 & 13 & 14 & 15
+% \end{pNiceMatrix}
+% \end{BVerbatim}
+% $\begin{pNiceMatrix}
+% 1 & 2 & 3 & 4 & 5 \\
+% \hdottedline
+% 6 & 7 & 8 & 9 & 10 \\
+% 11 & 12 & 13 & 14 & 15
+% \end{pNiceMatrix}$
+%
+%
+% \bigskip
+% In the environments with an explicit preamble (like |{NiceTabular}|,
+% |{NiceArray}|, etc.), it's possible to draw a vertical dotted line with the
+% specifier ``|:|''.
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm]
+% \left(\begin{NiceArray}{CCCC~emphase#:@C}
+% 1 & 2 & 3 & 4 & 5 \\
+% 6 & 7 & 8 & 9 & 10 \\
+% 11 & 12 & 13 & 14 & 15
+% \end{NiceArray}\right)
+% \end{BVerbatim}
+% $\left(\begin{NiceArray}{CCCC:C}
+% 1 & 2 & 3 & 4 & 5 \\
+% 6 & 7 & 8 & 9 & 10 \\
+% 11 & 12 & 13 & 14 & 15
+% \end{NiceArray}\right)$
+%
+% \bigskip
+% It's possible to change in \pkg{nicematrix} the letter used to specify a
+% vertical dotted line with the option |letter-for-dotted-lines| available in
+% |\NiceMatrixOptions|.
+%
+% \bigskip
+% \emph{Remark} : In the package \pkg{array} (on which the package
+% \pkg{nicematrix} relies), horizontal and vertical rules make the array larger
+% or wider by a quantity equal to the width of the rule\footnote{In fact, this
+% is true only for |\hline| and ``"|"'' but not for |\cline|.}. In
+% \pkg{nicematrix}, the dotted lines drawn by |\hdottedline| and ``|:|'' do
+% likewise.
+%
+%
+%
+%\section{The color of the rows and columns}
+%
+% With the classical package \pkg{colortbl}, it's possible to color the cells,
+% rows and columns of a tabular. However, the resulting \textsc{pdf} is not
+% always perfectly displayed by the \textsc{pdf} viewers, in particular in
+% conjonction with rules. With some \textsc{pdf} viewers, some vertical rules
+% seem to vanish. On the other side, some thin horizontal white lines may appear
+% in some circonstances.
+%
+%
+% \medskip
+% The package \pkg{nicematrix} provides similar tools which do not present these
+% drawbacks. It provides a key |code-before|\footnote{There is also a key
+% |code-after| : see p.~\pageref{code-after}.} for some code which will be
+% executed \emph{before} the drawing of the tabular. In this |code-before|, new
+% commands are available: |\cellcolor|, |\rectanglecolor|, |\rowcolor|,
+% |\columncolor|, |\rowcolors| and |\chessboardcolors|.
+% \label{code-before}
+%
+% \medskip
+% These commands are independent of \pkg{colortbl}.\footnote{Thus, it's possible
+% to coloror the rules, the cells, the rows, the columns, etc. without loading \pkg{colortbl}.}
+%
+% \medskip
+% All these commands accept an optional argument (between square brackets and
+% in first position) which is the color model for the specification of the colors.
+%
+% \medskip
+% \begin{itemize}
+% \item The command |\cellcolor| takes its name from the command |\cellcolor| of
+% \pkg{colortbl}.
+%
+% This command takes in mandatory arguments a color and a list of cells, each of
+% which with the format $i$-$j$ where $i$ is the number of row and $j$ the
+% number of colummn of the cell.
+%
+%
+% \medskip
+% \begin{scope}
+% \hfuzz=10cm
+% \begin{BVerbatim}[boxwidth=10cm,baseline=c]
+% \begin{NiceTabular}{|C|C|C|}[code-before =
+% ~emphase#\cellcolor{red!15}{3-1,2-2,1-3}@]
+% \hline
+% a & b & c \\ \hline
+% e & f & g \\ \hline
+% h & i & j \\ \hline
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \begin{NiceTabular}{|C|C|C|}[hvlines, code-before =
+% \cellcolor{red!15}{3-1,2-2,1-3}]
+% \hline
+% a & b & c \\ \hline
+% e & f & g \\ \hline
+% h & i & j \\ \hline
+% \end{NiceTabular}
+% \end{scope}
+%
+% \bigskip
+% \item The command |\rectanglecolor| takes three mandatory arguments. The first
+% is the color. The second is the upper-left cell of the rectangle and the third
+% is the lower-right cell of the rectangle.
%
-% See p.~\pageref{NiceArray} the section relating to |{NiceArray}| and |{NiceTabular}|.
+% \medskip
+% \begin{scope}
+% \hfuzz=10cm
+% \begin{BVerbatim}[boxwidth=10cm,baseline=c]
+% \begin{NiceTabular}{|C|C|C|}[code-before =
+% ~emphase#\rectanglecolor{blue!15}{2-2}{3-3}@]
+% \hline
+% a & b & c \\ \hline
+% e & f & g \\ \hline
+% h & i & j \\ \hline
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \begin{NiceTabular}{|C|C|C|}[hvlines, code-before =
+% \rectanglecolor{blue!15}{2-2}{3-3}]
+% \hline
+% a & b & c \\ \hline
+% e & f & g \\ \hline
+% h & i & j \\ \hline
+% \end{NiceTabular}
+% \end{scope}
%
+%
+%
+% \bigskip
+% \item The command |\rowcolor| takes its name from the command |\rowcolor| of
+% \pkg{colortbl}. Its first mandatory argument is the color and the second is a
+% comma-separated list of rows or interval of rows with the form $a$-$b$ (an
+% interval of the form $a$- represent all the rows from the row $a$ until the end).
+%
+% \medskip
+% \begin{scope}
+% \hfuzz = 10cm
+% \begin{BVerbatim}[boxwidth=9cm,baseline=c]
+% $\begin{NiceArray}{LLL}[hvlines, ~emphase#code-before = \rowcolor{red!15}{1,3-5,8-}@]
+% a_1 & b_1 & c_1 \\
+% a_2 & b_2 & c_2 \\
+% a_3 & b_3 & c_3 \\
+% a_4 & b_4 & c_4 \\
+% a_5 & b_5 & c_5 \\
+% a_6 & b_6 & c_6 \\
+% a_7 & b_7 & c_7 \\
+% a_8 & b_8 & c_8 \\
+% a_9 & b_9 & c_9 \\
+% a_{10} & b_{10} & c_{10} \\
+% \end{NiceArray}$
+% \end{BVerbatim}
+% $\begin{NiceArray}{LLL}[baseline=4,hvlines, code-before = \rowcolor{red!15}{1,3-5,8-}]
+% a_1 & b_1 & c_1 \\
+% a_2 & b_2 & c_2 \\
+% a_3 & b_3 & c_3 \\
+% a_4 & b_4 & c_4 \\
+% a_5 & b_5 & c_5 \\
+% a_6 & b_6 & c_6 \\
+% a_7 & b_7 & c_7 \\
+% a_8 & b_8 & c_8 \\
+% a_9 & b_9 & c_9 \\
+% a_{10} & b_{10} & c_{10} \\
+% \end{NiceArray}$
+% \end{scope}
+%
+%
+% \bigskip
+% \item The command |\columncolor| takes its name from the command
+% |\columncolor| of \pkg{colortbl}. Its syntax is similar to the syntaxe of
+% |\rowcolor|.
+%
+% \bigskip
+% \item The command |\rowcolors| (with a \emph{s}) takes its name from the
+% command |\rowcolors| of \pkg{xcolor}\footnote{The command |\rowcolors| of
+% \pkg{color} is available when \pkg{xcolor} is loaded with the
+% option~|table|.}. The \emph{s} emphasizes the fact that there is \emph{two}
+% colors. This command colors alternately the rows of the tabular, beginning
+% with the row whose number is given in first (mandatory) argument. The two
+% other (mandatory) arguments are the colors.
+%
+% \medskip
+% \begin{scope}
+% \hfuzz=10cm
+% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
+% \begin{NiceTabular}{LR}[hlines,code-before = ~emphase#\rowcolors{1}{blue!10}{}@]
+% John & 12 \\
+% Stephen & 8 \\
+% Sarah & 18 \\
+% Ashley & 20 \\
+% Henry & 14 \\
+% Madison & 15
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \begin{NiceTabular}{LR}[hlines,code-before = \rowcolors{1}{blue!10}{},baseline=3]
+% John & 12 \\
+% Stephen & 8 \\
+% Sarah & 18 \\
+% Ashley & 20 \\
+% Henry & 14 \\
+% Madison & 15
+% \end{NiceTabular}
+% \end{scope}
+%
+% \bigskip
+% \item The command |\chessboardcolors| takes in mandatory arguments two colors
+% and colors the cells of the tabular in quincunx with these colors.
+%
+% \medskip
+% \begin{scope}
+% \hfuzz=10cm
+% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
+% $\begin{pNiceMatrix}[R,margin, ~emphase#code-before=\chessboardcolors{red!15}{blue!15}@]
+% 1 & -1 & 1 \\
+% -1 & 1 & -1 \\
+% 1 & -1 & 1
+% \end{pNiceMatrix}$
+% \end{BVerbatim}
+% $\begin{pNiceMatrix}[R,baseline=1, margin, code-before = \chessboardcolors{red!15}{blue!15}]
+% 1 & -1 & 1 \\
+% -1 & 1 & -1 \\
+% 1 & -1 & 1
+% \end{pNiceMatrix}$
+% \end{scope}
+%
+% \medskip
+% We have used the key |R| which aligns all the columns rightwards (cf. p.~\pageref{key-R}).
+% \end{itemize}
+%
+%
+%
+% \bigskip
+% One should remark that these commands are compatible with the commands de
+% \pkg{booktabs} (|\toprule|, |\midrule|, |\bottomrule|, etc).
+%
+% \medskip
+% \begin{scope}
+% \hfuzz=10cm
+% \begin{BVerbatim}[baseline=c,boxwidth=8.5cm]
+% \begin{NiceTabular}[c]{LSSSS}%
+% [code-before = \rowcolor{red!15}{1-2} \rowcolors{3}{blue!15}{}]
+% ~emphase#\toprule@
+% \Block{2-1}{Product} \\
+% \Block{1-3}{dimensions (cm)} & & &
+% \Block{2-1}{\rotate Price} \\
+% ~emphase#\cmidrule(rl){2-4}@
+% & L & l & h \\
+% ~emphase#\midrule@
+% small & 3 & 5.5 & 1 & 30 \\
+% standard & 5.5 & 8 & 1.5 & 50.5 \\
+% premium & 8.5 & 10.5 & 2 & 80 \\
+% extra & 8.5 & 10 & 1.5 & 85.5 \\
+% special & 12 & 12 & 0.5 & 70 \\
+% ~emphase#\bottomrule@
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \begin{NiceTabular}[c]{LSSSS}[code-before = \rowcolor{red!15}{1-2}
+% \rowcolors{3}{blue!15}{}]
+% \toprule
+% \Block{2-1}{Product} &
+% \Block{1-3}{dimensions (cm)} & & &
+% \Block{2-1}{\rotate Price} \\
+% \cmidrule(rl){2-4}
+% & L & l & h \\
+% \midrule
+% small & 3 & 5.5 & 1 & 30 \\
+% standard & 5.5 & 8 & 1.5 & 50.5 \\
+% premium & 8.5 & 10.5 & 2 & 80 \\
+% extra & 8.5 & 10 & 1.5 & 85.5 \\
+% special & 12 & 12 & 0.5 & 70 \\
+% \bottomrule
+% \end{NiceTabular}
+% \end{scope}
+%
+% \medskip
+% We have used the type of column |S| of \pkg{siunitx}.
+%
+% \section{The width of the columns}
+% \label{width}
+%
+% In the environments with an explicit preamble (like |{NiceTabular}|,
+% |{NiceArray}|, etc.), it's possible to fix the width of a given column with
+% the standard letters |w| and |W| of the package \pkg{array}. In
+% |{NiceTabular}|, the cells of such columns are composed in texte mode but, in
+% |{NiceArray}|, |{pNiceArray}|, etc., they are composed in math mode (whereas,
+% in |{array}| of \pkg{array}, they are composed in text mode).
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
+% \begin{NiceTabular}{~emphase#Wc{2cm}@CC}[hvlines]
+% Paris & New York & Madrid \\
+% Berlin & London & Roma \\
+% Rio & Tokyo & Oslo
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \begin{NiceTabular}{Wc{2cm}CC}[hvlines]
+% Paris & New York & Madrid \\
+% Berlin & London & Roma \\
+% Rio & Tokyo & Oslo
+% \end{NiceTabular}
+%
+%
+% \bigskip
+% In the environments of \pkg{nicematrix}, it's also possible to fix the \emph{minimal}
+% width of all the columns of an array directly with the key |columns-width|.
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
+% $\begin{pNiceMatrix}[~emphase#columns-width = 1cm@]
+% 1 & 12 & -123 \\
+% 12 & 0 & 0 \\
+% 4 & 1 & 2
+% \end{pNiceMatrix}$
+% \end{BVerbatim}
+% $\begin{pNiceMatrix}[columns-width = 1cm]
+% 1 & 12 & -123 \\
+% 12 & 0 & 0 \\
+% 4 & 1 & 2
+% \end{pNiceMatrix}$
+%
+% \medskip
+% Note that the space inserted between two columns (equal to 2 |\tabcolsep| in
+% |{NiceTabular}| and to 2 |\arraycolsep| in the other environments)
+% is not suppressed (of course, it's possible to suppress this space by setting
+% |\tabcolsep| or |\arraycolsep| equal to $0$~pt before the environment).
+%
+% \bigskip
+% It's possible to give the special value |auto| to the option |columns-width|:
+% all the columns of the array will have a width equal to the widest cell of
+% the array.\footnote{The result is achieved with only one compilation (but Tikz
+% will have written informations in the |.aux| file and a message requiring a
+% second compilation will appear).}\par\nobreak
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
+% $\begin{pNiceMatrix}[~emphase#columns-width = auto@]
+% 1 & 12 & -123 \\
+% 12 & 0 & 0 \\
+% 4 & 1 & 2
+% \end{pNiceMatrix}$
+% \end{BVerbatim}
+% $\begin{pNiceMatrix}[columns-width = auto]
+% 1 & 12 & -123 \\
+% 12 & 0 & 0 \\
+% 4 & 1 & 2
+% \end{pNiceMatrix}$
+%
+% \bigskip
+% Without surprise, it's possible to fix the minimal width of the columns of all
+% the matrices of a current scope with the command
+% |\NiceMatrixOptions|.\par\nobreak
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=8.5cm]
+% ~emphase#\NiceMatrixOptions{columns-width=10mm}@
+% $\begin{pNiceMatrix}
+% a & b \\ c & d
+% \end{pNiceMatrix}
+% =
+% \begin{pNiceMatrix}
+% 1 & 1245 \\ 345 & 2
+% \end{pNiceMatrix}$
+% \end{BVerbatim}
+% \begin{scope}
+% \NiceMatrixOptions{columns-width=10mm}
+% $\begin{pNiceMatrix}
+% a & b \\
+% c & d
+% \end{pNiceMatrix}
+% =
+% \begin{pNiceMatrix}
+% 1 & 1245 \\
+% 345 & 2
+% \end{pNiceMatrix}$
+% \end{scope}
+%
+%
+% \bigskip
+% But it's also possible to fix a zone where all the matrices will have their
+% columns of the same width, equal to the widest cell of all the matrices. This
+% construction uses the environment |{NiceMatrixBlock}| with the option
+% |auto-columns-width|\footnote{At this time, this is the only usage of the
+% environment |{NiceMatrixBlock}| but it may have other usages in the future.}.
+% The environment |{NiceMatrixBlock}| has no direct link with the command
+% |\Block| presented previously in this document (cf.~p.~\pageref{Block}).
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=8.5cm]
+% ~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@
+% $\begin{array}{c}
+% \begin{bNiceMatrix}
+% 9 & 17 \\ -2 & 5
+% \end{bNiceMatrix} \\ \\
+% \begin{bNiceMatrix}
+% 1 & 1245345 \\ 345 & 2
+% \end{bNiceMatrix}
+% \end{array}$
+% ~emphase#\end{NiceMatrixBlock}@
+% \end{BVerbatim}
+% \begin{NiceMatrixBlock}[auto-columns-width]
+% $\begin{array}{c}
+% \begin{bNiceMatrix}
+% 9 & 17 \\ -2 & 5
+% \end{bNiceMatrix} \\ \\
+% \begin{bNiceMatrix}
+% 1 & 1245345 \\ 345 & 2
+% \end{bNiceMatrix}
+% \end{array}$
+% \end{NiceMatrixBlock}
+%
+% \medskip
+% \textbf{Several compilations may be necessary to achieve the job.}
+%
+%
+%
+% \bigskip
+% \section{The exterior rows and columns}
+%
+% The options |first-row|, |last-row|, |first-col| and |last-col| allow the
+% composition of exterior rows and columns in the environments of
+% \pkg{nicematrix}.
+% \label{exterior}
+%
+% A potential ``first row'' (exterior) has the number $0$ (and not $1$). Idem
+% for the potential ``first column''.
+%
+% \begin{Verbatim}
+% $\begin{pNiceMatrix}[~emphase#first-row,last-row,first-col,last-col@]
+% $\begin{pNiceMatrix}[~emphase#first-row,last-row,first-col,last-col@,nullify-dots]
+% & C_1 & \Cdots & & C_4 & \\
+% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
+% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
+% & a_{31} & a_{32} & a_{33} & a_{34} & \\
+% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
+% & C_1 & \Cdots & & C_4 &
+% \end{pNiceMatrix}$
+% \end{pNiceMatrix}$
+% \end{Verbatim}
+%
+% \[\begin{pNiceMatrix}[first-row,last-row,first-col,last-col,nullify-dots]
+% & C_1 & \Cdots & & C_4 & \\
+% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
+% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
+% & a_{31} & a_{32} & a_{33} & a_{34} & \\
+% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
+% & C_1 & \Cdots & & C_4 &
+% \end{pNiceMatrix}\]
+%
+% \medskip
+% The dotted lines have been drawn with the tools presented p.~\pageref{Cdots}.
+%
+% \bigskip
+% We have several remarks to do.
+% \begin{itemize}
+% \item For the environments with an explicit preamble (i.e. |{NiceArray}| and
+% its variants), no letter must be given in that preamble for the potential
+% first column and the potential last column: they will automatically (and
+% necessarily) be of type |R| for the first column and |L| for the last one.
+% \item One may wonder how \pkg{nicematrix} determines the number of rows and
+% columns which are needed for the composition of the ``last row'' and ``last
+% column''.
+% \begin{itemize}
+% \item For the environments with explicit preamble, like |{NiceTabular}| and
+% |{pNiceArray}|, the number of columns can obviously be computed from the
+% preamble.
+%
+% \item When the option |light-syntax| (cf. p. \pageref{light-syntax}) is used,
+% \pkg{nicematrix} has, in any case, to load the whole body of the environment
+% (and that's why it's not possible to put verbatim material in the array with
+% the option |light-syntax|). The analysis of this whole body gives the number
+% of rows (but not the number of columns).
+%
+% \item In the other cases, \pkg{nicematrix} compute the number of rows and
+% columns during the first compilation and write the result in the |aux| file
+% for the next run.
+%
+% \textsl{However, it's possible to provide the number of the last row and the
+% number of the last column as values of the options |last-row| and |last-col|,
+% tending to an acceleration of the whole compilation of the document.} That's
+% what we will do throughout the rest of the document.
+% \end{itemize}
+% \end{itemize}
+%
+% \bigskip
+% It's possible to control the appearance of these rows and columns with options
+% |code-for-first-row|, |code-for-last-row|, |code-for-first-col| and
+% |code-for-last-col|. These options
+% specify tokens that will be inserted before each cell of the corresponding row
+% or column.
+%
+%
+% \begin{Verbatim}
+% \NiceMatrixOptions{~emphase#code-for-first-row@ = \color{red},
+% ~emphase#code-for-first-col@ = \color{blue},
+% ~emphase#code-for-last-row@ = \color{green},
+% ~emphase#code-for-last-col@ = \color{magenta}}
+% $\begin{pNiceArray}{CC|CC}[first-row,last-row=5,first-col,last-col,nullify-dots]
+% & C_1 & \Cdots & & C_4 & \\
+% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
+% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
+% \hline
+% & a_{31} & a_{32} & a_{33} & a_{34} & \\
+% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
+% & C_1 & \Cdots & & C_4 &
+% \end{pNiceArray}$
+% \end{Verbatim}
+%
+% \begin{scope}
+% \NiceMatrixOptions{code-for-first-row = \color{red},
+% code-for-first-col = \color{blue},
+% code-for-last-row = \color{green},
+% code-for-last-col = \color{magenta}}
+% \begin{displaymath}
+% \begin{pNiceArray}{CC|CC}[first-row,last-row=5,first-col,last-col,nullify-dots]
+% & C_1 & \multicolumn1C{\Cdots} & & C_4 & \\
+% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
+% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
+% \hline
+% & a_{31} & a_{32} & a_{33} & a_{34} & \\
+% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
+% & C_1 & \multicolumn1C{\Cdots} & & C_4 &
+% \end{pNiceArray}
+% \end{displaymath}
+% \end{scope}
+%
+%
+% \emph{Remarks}
+% \begin{itemize}[beginpenalty=10000]
+% \item As shown in the previous example, the horizontal and rules doesn't
+% extend in the exterior rows and columns.
+%
+% However, if one wishes to define new specifiers for columns in order to draw
+% vertical rules (for example thicker than the standard rules), he should
+% consider the command |\OnlyMainNiceMatrix| described on
+% page~\pageref{OnlyMainNiceMatrix}.
+%
+% \item A specification of color present in |code-for-first-row| also applies to
+% a dotted line draw in this exterior ``first row'' (excepted if a value has
+% been given to |xdots/color|). Idem for the other exterior rows and columns.
+%
+% \item Logically, the potential option |columns-width| (described
+% p.~\pageref{width}) doesn't apply to the ``first column'' and ``last column''.
+% \item For technical reasons, it's not possible to use the option of the
+% command |\\| after the ``first row'' or before the ``last row'' (the placement
+% of the delimiters would be wrong).
+% \end{itemize}
+%
+%
+%
+%
%
% \section{The continuous dotted lines}
%
+% \label{Cdots}
% Inside the environments of the package \pkg{nicematrix}, new commands are
% defined: |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, and |\Iddots|. These commands
% are intended to be used in place of |\dots|, |\cdots|, |\vdots|, |\ddots| and
@@ -275,7 +1306,8 @@ version 2005/12/01 or later.
% |\Iddots| diagonal ones. It's possible to change the color of these lines
% with the option |color|.\footnote{It's also possible to change the color of
% all theses dotted lines with the option |xdots/color| (\textsl{xdots} to
-% remind that it works for |\Cdots|, |\Ldots|, |\Vdots|, etc.): cf. p. \pageref{customization}.}\par\nobreak
+% remind that it works for |\Cdots|, |\Ldots|, |\Vdots|, etc.): cf. p.
+% \pageref{customization}.}\par\nobreak
%
% \bigskip
% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
@@ -463,9 +1495,6 @@ version 2005/12/01 or later.
% The option |nullify-dots| smashes the instructions |\Ldots| (and the variants)
% horizontally but also vertically.
%
-% \medskip
-% \textbf{There must be no space before the opening bracket (|[|) of the options
-% of the environment.}
%
%
% \subsection{The command \textbackslash Hdotsfor}
@@ -692,234 +1721,52 @@ version 2005/12/01 or later.
% \end{pNiceMatrix}\]
%
%
-%
-% \section{The PGF/Tikz nodes created by nicematrix}
-%
-% \label{name}
+% \subsection{The dotted lines and the key hvlines}
%
-% The package \pkg{nicematrix} creates a PGF/Tikz node for each (non-empty) cell
-% of the considered array. These nodes are used to draw the dotted lines between
-% the cells of the matrix. However, the user may wish to use directly these
-% nodes. It's possible (if Tikz has been loaded\footnote{We remind that, since
-% the version 3.13, \pkg{nicematrix} doesn't load Tikz by default by only
-% \textsc{pgf} (Tikz is a layer over \textsc{pfg}).}). First, the user have to
-% give a name to the array (with the key called |name|). Then, the nodes are
-% accessible through the names ``\textsl{name}-$i$-$j$'' where \textsl{name} is
-% the name given to the array and $i$ and $j$ the numbers of the row and the
-% column of the considered cell.
+% \label{dotted-and-hvlines}
%
+% We have said (cf. p. \pageref{hvlines}) that the key |hvlines| draws all the
+% horizontal and vertical rules, excepted in the blocks. In fact, when this key
+% is in force, the rules are also not drawn in the virtual blocks delimited by
+% cells relied par dotted lines.
+%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
-% $\begin{pNiceMatrix}[name=~emphase#mymatrix@]
-% 1 & 2 & 3 \\
-% 4 & 5 & 6 \\
-% 7 & 8 & 9
+% \NiceMatrixOptions{nullify-dots}
+% $\begin{pNiceMatrix}[rules/color=gray,~emphase#hvlines@,margin]
+% 0 & \Cdots & & & & 0 \\
+% 1 & \Cdots & & & 1 & 2 \\
+% 0 & \Ddots & & & \Vdots & \Vdots \\
+% \Vdots & \Ddots & & & & \\
+% & & & & & \\
+% 0 & \Cdots & & 0 & 1 & 2 \\
% \end{pNiceMatrix}$
-% \tikz[remember picture,overlay]
-% \draw ~emphase#(mymatrix-2-2)@ circle (2mm) ;
% \end{BVerbatim}
-% $\begin{pNiceMatrix}[name=mymatrix]
-% 1 & 2 & 3 \\
-% 4 & 5 & 6 \\
-% 7 & 8 & 9
+% \begin{scope}
+% \NiceMatrixOptions{nullify-dots}
+% $\begin{pNiceMatrix}[rules/color=gray,hvlines,margin]
+% 0 & \Cdots & & & & 0 \\
+% 1 & \Cdots & & & 1 & 2 \\
+% 0 & \Ddots & & & \Vdots & \Vdots \\
+% \Vdots & \Ddots & & & & \\
+% & & & & & \\
+% 0 & \Cdots & & 0 & 1 & 2 \\
% \end{pNiceMatrix}$
-% \tikz[remember picture,overlay]
-% \draw (mymatrix-2-2) circle (2mm) ;
-%
-% \medskip
-% Don't forget the options |remember picture| and |overlay|.
-%
-% \bigskip
-% In the following example, we have underlined all the nodes of the matrix.
-% \[\begin{pNiceMatrix}[
-% code-after = {\begin{tikzpicture}
-% [every node/.style = {blend mode = multiply,
-% fill = red!15,
-% inner sep = 0 pt }]
-% \node [fit = (1-1)] {} ;
-% \node [fit = (1-3)] {} ;
-% \node [fit = (2-2)] {} ;
-% \node [fit = (3-1)] {} ;
-% \node [fit = (3-3)] {} ;
-% \node [fit = (1-2)] {} ;
-% \node [fit = (2-1)] {} ;
-% \node [fit = (2-3)] {} ;
-% \node [fit = (3-2)] {} ;
-% \end{tikzpicture}}]
-% a & a + b & a + b + c \\
-% a & a & a + b \\
-% a & a & a
-% \end{pNiceMatrix}\]
-%
-%
-% \bigskip
-% In fact, the package \pkg{nicematrix} can create ``extra nodes'': the ``medium
-% nodes'' and the ``large nodes''. The first ones
-% are created with the option |create-medium-nodes| and the second ones with the
-% option |create-large-nodes|.\footnote{There is also an option
-% |create-extra-nodes| which is an alias for the conjonction of
-% |create-medium-nodes| and |create-large-nodes|.}
-%
-% \medskip
-% The names of the ``medium nodes'' are constructed by adding the suffix
-% ``|-medium|'' to the names of the ``normal nodes''. In the following example,
-% we have underlined the ``medium nodes''. We consider that this example is
-% self-explanatory.
-% \[\begin{pNiceMatrix}[
-% create-medium-nodes,
-% code-after = {\begin{tikzpicture}
-% [every node/.style = {fill = red!15,
-% blend mode = multiply,
-% inner sep = 0pt},
-% name suffix = -medium]
-% \node [fit = (1-1)] {} ;
-% \node [fit = (1-2)] {} ;
-% \node [fit = (1-3)] {} ;
-% \node [fit = (2-1)] {} ;
-% \node [fit = (2-2)] {} ;
-% \node [fit = (2-3)] {} ;
-% \node [fit = (3-1)] {} ;
-% \node [fit = (3-2)] {} ;
-% \node [fit = (3-3)] {} ;
-% \end{tikzpicture}}]
-% a & a + b & a + b + c \\
-% a & a & a + b \\
-% a & a & a
-% \end{pNiceMatrix}\]
-%
-%
-% \medskip
-% The names of the ``large nodes'' are constructed by adding the suffix
-% ``|-large|'' to the names of the ``normal nodes''. In the following example,
-% we have underlined the ``large nodes''. We consider that this example is
-% self-explanatory.\footnote{There is no ``large nodes'' created in the exterior
-% rows and columns (for these rows and columns, cf. p.~\pageref{exterior}).}
-%
-% \[\begin{pNiceMatrix}[
-% create-large-nodes,
-% code-after = {\begin{tikzpicture}
-% [every node/.style = {blend mode = multiply,
-% inner sep = 0pt},
-% name suffix = -large]
-% \node [fit = (1-1),fill = red!15] {} ;
-% \node [fit = (1-3),fill = red!15] {} ;
-% \node [fit = (2-2),fill = red!15] {} ;
-% \node [fit = (3-1),fill = red!15] {} ;
-% \node [fit = (3-3),fill = red!15] {} ;
-% \node [fit = (1-2),fill = blue!15] {} ;
-% \node [fit = (2-1),fill = blue!15] {} ;
-% \node [fit = (2-3),fill = blue!15] {} ;
-% \node [fit = (3-2),fill = blue!15] {} ;
-% \end{tikzpicture}}]
-% a & a + b & a + b + c \\
-% a & a & a + b \\
-% a & a & a
-% \end{pNiceMatrix}\]
+% \end{scope}
%
%
-% \medskip
-% The ``large nodes'' of the first column and last column may appear too small
-% for some usage. That's why it's possible to use the options |left-margin| and
-% |right-margin| to add space on both sides of the array and also space in the
-% ``large nodes'' of the first column and last column. In the following example,
-% we have used the options |left-margin| and |right-margin|.\footnote{The
-% options |left-margin| and |right-margin| take dimensions as values but, if no
-% value is given, the default value is used, which is |\arraycolsep| (by
-% default: 5~pt). There is also an option |margin| to fix both |left-margin| and
-% |right-margin| to the same value.}
-% \[\begin{pNiceMatrix}[
-% create-large-nodes,left-margin,right-margin,
-% code-after = {\begin{tikzpicture}
-% [every node/.style = {blend mode = multiply,
-% inner sep = 0pt},
-% name suffix = -large]
-% \node [fit = (1-1),fill = red!15] {} ;
-% \node [fit = (1-3),fill = red!15] {} ;
-% \node [fit = (2-2),fill = red!15] {} ;
-% \node [fit = (3-1),fill = red!15] {} ;
-% \node [fit = (3-3),fill = red!15] {} ;
-% \node [fit = (1-2),fill = blue!15] {} ;
-% \node [fit = (2-1),fill = blue!15] {} ;
-% \node [fit = (2-3),fill = blue!15] {} ;
-% \node [fit = (3-2),fill = blue!15] {} ;
-% \end{tikzpicture}}]
-% a & a + b & a + b + c \\
-% a & a & a + b \\
-% a & a & a
-% \end{pNiceMatrix}\]
-%
-% \medskip
-% It's also possible to add more space on both side of the array with the
-% options |extra-left-margin| and |extra-right-margin|. These margins are not
-% incorporated in the ``large nodes''. It's possible to fix both values with the
-% option |extra-margin| and, in the following example, we use |extra-margin|
-% with the value $3$~pt.
-% \[\begin{pNiceMatrix}[
-% create-large-nodes,margin,extra-margin=3pt,
-% code-after = {\begin{tikzpicture}
-% [every node/.style = {blend mode = multiply,
-% inner sep = 0 pt},
-% name suffix = -large]
-% \node [fit = (1-1),fill = red!15] {} ;
-% \node [fit = (1-3),fill = red!15] {} ;
-% \node [fit = (2-2),fill = red!15] {} ;
-% \node [fit = (3-1),fill = red!15] {} ;
-% \node [fit = (3-3),fill = red!15] {} ;
-% \node [fit = (1-2),fill = blue!15] {} ;
-% \node [fit = (2-1),fill = blue!15] {} ;
-% \node [fit = (2-3),fill = blue!15] {} ;
-% \node [fit = (3-2),fill = blue!15] {} ;
-% \end{tikzpicture}}]
-% a & a + b & a + b + c \\
-% a & a & a + b \\
-% a & a & a
-% \end{pNiceMatrix}\]
-%
-% \medskip
-% In this case, if we want a control over the height of the rows, we can add a
-% |\strut| in each row of the array.
-% \[\begin{pNiceMatrix}[
-% create-large-nodes,left-margin,right-margin,extra-right-margin=3pt,
-% extra-left-margin=3pt,
-% code-after = {\begin{tikzpicture}
-% [every node/.style = {blend mode = multiply,
-% inner sep = 0 pt},
-% name suffix = -large]
-% \node [fit = (1-1),fill = red!15] {} ;
-% \node [fit = (1-3),fill = red!15] {} ;
-% \node [fit = (2-2),fill = red!15] {} ;
-% \node [fit = (3-1),fill = red!15] {} ;
-% \node [fit = (3-3),fill = red!15] {} ;
-% \node [fit = (1-2),fill = blue!15] {} ;
-% \node [fit = (2-1),fill = blue!15] {} ;
-% \node [fit = (2-3),fill = blue!15] {} ;
-% \node [fit = (3-2),fill = blue!15] {} ;
-% \end{tikzpicture}}]
-% \strut a & a + b & a + b + c \\
-% \strut a & a & a + b \\
-% \strut a & a & a
-% \end{pNiceMatrix}\]
-%
-% \bigskip
-% We explain below how to fill the nodes created by \pkg{nicematrix} (cf. p.
-% \pageref{highlight}).
%
% \section{The code-after}
%
% \label{code-after}
% The option |code-after| may be used to give some code that will be excuted
-% after the construction of the matrix (and thus after the construction of
-% all the nodes).
+% after the construction of the matrix.\footnote{There is also a key
+% |code-before| described p.~\pageref{code-before}.}
%
-% \smallskip
-% \textbf{If Tikz is loaded}\footnote{We remind that, since the version 3.13,
-% \pkg{nicematrix} doesn't load Tikz by default but only \textsc{pgf} (Tikz is a
-% layer over \textsc{pfg}).}, one may access to that nodes with classical Tikz
-% instructions. The nodes should be designed as $i$-$j$ (without the prefix
-% corresponding to the name of the environment).
-%
-% Moreover, a special command, called |\line|, is available to draw directly
-% dotted lines between nodes. It may be used, for example, to draw a dotted line
+% A special command, called |\line|, is available to draw directly
+% dotted lines between nodes. It takes two arguments for the two cells to rely,
+% both of the form $i$-$j$ where is the number of row and $j$ is the number of
+% column. It may be used, for example, to draw a dotted line
% between two adjacents cells. \label{line-in-code-after}
%
% \medskip
@@ -949,823 +1796,49 @@ version 2005/12/01 or later.
% p.~\pageref{example-CodeAfter}.
%
%
-% \section{The environments \{NiceArray\} and \{NiceTabular\}}
-% \label{NiceArray}
-%
-% The environments |{NiceArray}| and |{NiceTabular}| are similar to the
-% environments |{array}| and |{tabular}|. The mandatory argument is the preamble
-% of the array. However, for technical reasons, in this preamble, the user must
-% use the letters |L|, |C| and~|R|\footnote{The column types |L|, |C| and |R|
-% are defined locally inside |{NiceArray}| with |\newcolumntype| of \pkg{array}.
-% This definition overrides an eventual previous definition.} instead of |l|,
-% |c| and |r|. In a command |\multicolumn|, one should also use the letters |L|,
-% |C|, |R|.
-%
-% It's possible to use the constructions |p{...}|, |m{...}|, |b{...}|,
-% |w{...}{...}|, |W{...}{...}|, "|", |>{...}|, |<{...}|, |@{...}|, |!{...}| and
-% |*{n}{...}|. However, in the environment |{NiceArray}| (and its variants), the
-% content of the columns of type |w| or |W| is composed in math mode (in
-% |{array}| of \pkg{array}, they are composed in text mode).
-%
-% \bigskip
-% The package \pkg{nicematrix} provides also the variants |{pNiceArray}|,
-%|{vNiceArray}|, |{VNiceArray}|, |{bNiceArray}| and |{BNiceArray}|.
-%
-% \bigskip
-% Of course, one of the benefits of |{pNiceArray}| over |{pNiceMatrix}| is the
-% possibility of drawing vertical rules:
-%
-%\bigskip
-% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
-% $\left[\begin{NiceArray}{CCCC|C}
-% a_1 & ? & \Cdots & ? & ? \\
-% 0 & & \Ddots & \Vdots & \Vdots\\
-% \Vdots & \Ddots & \Ddots & ? \\
-% 0 & \Cdots & 0 & a_n & ?
-% \end{NiceArray}\right]$
-% \end{BVerbatim}
-% $\left[\begin{NiceArray}{CCCC|C}
-% a_1 & ? & \Cdots & ? & ? \\
-% 0 & & \Ddots & \Vdots & \Vdots\\
-% \Vdots & \Ddots & \Ddots & ? \\
-% 0 & \Cdots & 0 & a_n & ?
-% \end{NiceArray}\right]$
-%
-% \bigskip
-% Another benefit is the possibility of using different alignments of columns.
-%
-% \bigskip
-% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
-% $\begin{pNiceArray}{LCR}
-% a_{11} & \Cdots & a_{1n} \\
-% a_{21} & & a_{2n} \\
-% \Vdots & & \Vdots \\
-% a_{n-1,1} & \Cdots & a_{n-1,n}
-% \end{pNiceArray}$
-% \end{BVerbatim}
-% $\begin{pNiceArray}{LCR}
-% a_{11} & \Cdots & a_{1n} \\
-% a_{21} & & a_{2n} \\
-% \Vdots & & \Vdots \\
-% a_{n-1,1} & \Cdots & a_{n-1,n}
-% \end{pNiceArray}$
-%
-%
-% \bigskip
-% In fact, the environment |{pNiceArray}| and its variants are based upon a
-% more general environment, called |{NiceArrayWithDelims}|. The first two
-% mandatory arguments of this environment are the left and right delimiters used
-% in the construction of the matrix. It's possible to use
-% |{NiceArrayWithDelims}| if we want to use atypical or asymetrical delimiters.
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
-% $\begin{~emphase#NiceArrayWithDelims@}
-% {\downarrow}{\uparrow}{CCC}[margin]
-% 1 & 2 & 3 \\
-% 4 & 5 & 6 \\
-% 7 & 8 & 9
-% \end{~emphase#NiceArrayWithDelims@}$
-% \end{BVerbatim}
-% $\begin{NiceArrayWithDelims}
-% {\downarrow}{\uparrow}{CCC}[margin]
-% 1 & 2 & 3 \\
-% 4 & 5 & 6 \\
-% 7 & 8 & 9
-% \end{NiceArrayWithDelims}$
-%
-%
-% \bigskip
-% \section{The vertical position of the arrays}
-%
-% The package \pkg{nicematrix} provides a option |baseline| for the vertical
-% position of the arrays. This option takes as value an integer which is the
-% number of the row on which the array will be aligned.
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
-% $A = \begin{pNiceMatrix}[~emphase#baseline=2@]
-% \frac{1}{\sqrt{1+p^2}} & p & 1-p \\
-% 1 & 1 & 1 \\
-% 1 & p & 1+p
-% \end{pNiceMatrix}$
-% \end{BVerbatim}
-% $A = \begin{pNiceMatrix}[baseline=2]
-% \frac{1}{\sqrt{1+p^2}} & p & 1-p \\
-% 1 & 1 & 1 \\
-% 1 & p & 1+p
-% \end{pNiceMatrix}$
-%
-%
-% \medskip
-% It's also possible to use the option |baseline| with one of the special values
-% |t|, |c| or |b|. These letters may also be used absolutely like the option of
-% the environment |{array}| of \pkg{array}. The initial value of |baseline| is~|c|.
-%
-%
-% \medskip
-% In the following example, we use the option |t| (equivalent to |baseline=t|)
-% immediately after an |\item| of list. One should remark that the presence of
-% a |\hline| at the beginning of the array doesn't prevent the alignment of the
-% baseline with the baseline of the first row (with |{array}| of \pkg{array},
-% one must use |\firsthline|\footnote{It's also possible to use |\firsthline|
-% with |{NiceArray}|.}).
-%
-% \smallskip
-% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
-% \begin{enumerate}
-% \item an item
-% \smallskip
-% \item \renewcommand{\arraystretch}{1.2}
-% $\begin{NiceArray}~emphase#[t]@{LCCCCCC}
-% \hline
-% n & 0 & 1 & 2 & 3 & 4 & 5 \\
-% u_n & 1 & 2 & 4 & 8 & 16 & 32
-% \hline
-% \end{NiceArray}$
-% \end{enumerate}
-% \end{BVerbatim}
-% \begin{minipage}{5cm}
-% \begin{enumerate}
-% \item an item
-% \smallskip
-% \item \renewcommand{\arraystretch}{1.2}
-% $\begin{NiceArray}[t]{LCCCCCC}
-% \hline
-% n & 0 & 1 & 2 & 3 & 4 & 5 \\
-% u_n & 1 & 2 & 4 & 8 & 16 & 32 \\
-% \hline
-% \end{NiceArray}$
-% \end{enumerate}
-% \end{minipage}
-%
-% \medskip
-% However, it's also possible to use the tools of \pkg{booktabs}: |\toprule|,
-% |\bottomrule| and |\midrule|.\par\nobreak
-%
-% \smallskip
-% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
-% \begin{enumerate}
-% \item an item
-% \smallskip
-% \item
-% $\begin{NiceArray}[t]{LCCCCCC}
-% ~emphase#\toprule@
-% n & 0 & 1 & 2 & 3 & 4 & 5 \\
-% ~emphase#\midrule@
-% u_n & 1 & 2 & 4 & 8 & 16 & 32
-% ~emphase#\bottomrule@
-% \end{NiceArray}$
-% \end{enumerate}
-% \end{BVerbatim}
-% \begin{minipage}{5cm}
-% \begin{enumerate}
-% \item an item
-% \smallskip
-% \item
-% $\begin{NiceArray}[t]{LCCCCCC}
-% \toprule
-% n & 0 & 1 & 2 & 3 & 4 & 5 \\
-% \midrule
-% u_n & 1 & 2 & 4 & 8 & 16 & 32 \\
-% \bottomrule
-% \end{NiceArray}$
-% \end{enumerate}
-% \end{minipage}
-%
-%
-% \bigskip
-% \section{The exterior rows and columns}
-% The options |first-row|, |last-row|, |first-col| and |last-col| allow the
-% composition of exterior rows and columns in the environments of
-% \pkg{nicematrix}.
-% \label{exterior}
-%
-% A potential ``first row'' (exterior) has the number $0$ (and not $1$). Idem
-% for the potential ``first column''.
-%
-% \begin{Verbatim}
-% $\begin{pNiceMatrix}[~emphase#first-row,last-row,first-col,last-col@]
-% $\begin{pNiceMatrix}[~emphase#first-row,last-row,first-col,last-col@,nullify-dots]
-% & C_1 & \Cdots & & C_4 & \\
-% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
-% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
-% & a_{31} & a_{32} & a_{33} & a_{34} & \\
-% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
-% & C_1 & \Cdots & & C_4 &
-% \end{pNiceMatrix}$
-% \end{pNiceMatrix}$
-% \end{Verbatim}
-%
-% \[\begin{pNiceMatrix}[first-row,last-row,first-col,last-col,nullify-dots]
-% & C_1 & \Cdots & & C_4 & \\
-% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
-% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
-% & a_{31} & a_{32} & a_{33} & a_{34} & \\
-% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
-% & C_1 & \Cdots & & C_4 &
-% \end{pNiceMatrix}\]
-%
-%
-% \bigskip
-% We have several remarks to do.
-% \begin{itemize}
-% \item For the environments with an explicit preamble (i.e. |{NiceArray}| and
-% its variants), no letter must be given in that preamble for the potential
-% first column and the potential last column: they will automatically (and
-% necessarily) be of type |R| for the first column and |L| for the last one.
-% \item One may wonder how \pkg{nicematrix} determines the number of rows and
-% columns which are needed for the composition of the ``last row'' and ``last
-% column''.
-% \begin{itemize}
-% \item For the environments with explicit preamble, like |{NiceTabular}| and
-% |{pNiceArray}|, the number of columns can obviously be computed from the
-% preamble.
-%
-% \item When the option |light-syntax| (cf. p. \pageref{light-syntax}) is used,
-% \pkg{nicematrix} has, in any case, to load the whole body of the environment
-% (and that's why it's not possible to put verbatim material in the array with
-% the option |light-syntax|). The analysis of this whole body gives the number
-% of rows (but not the number of columns).
-%
-% \item In the other cases, \pkg{nicematrix} compute the number of rows and
-% columns during the first compilation and write the result in the |aux| file
-% for the next run.
-%
-% \textsl{However, it's possible to provide the number of the last row and the
-% number of the last column as values of the options |last-row| and |last-col|,
-% tending to an acceleration of the whole compilation of the document.} That's
-% what we will do throughout the rest of the document.
-% \end{itemize}
-% \end{itemize}
-%
-% \bigskip
-% It's possible to control the appearance of these rows and columns with options
-% |code-for-first-row|, |code-for-last-row|, |code-for-first-col| and
-% |code-for-last-col|. These options
-% specify tokens that will be inserted before each cell of the corresponding row
-% or column.
-%
-%
-% \begin{Verbatim}
-% \NiceMatrixOptions{~emphase#code-for-first-row@ = \color{red},
-% ~emphase#code-for-first-col@ = \color{blue},
-% ~emphase#code-for-last-row@ = \color{green},
-% ~emphase#code-for-last-col@ = \color{magenta}}
-% $\begin{pNiceArray}{CC|CC}[first-row,last-row=5,first-col,last-col,nullify-dots]
-% & C_1 & \Cdots & & C_4 & \\
-% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
-% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
-% \hline
-% & a_{31} & a_{32} & a_{33} & a_{34} & \\
-% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
-% & C_1 & \Cdots & & C_4 &
-% \end{pNiceArray}$
-% \end{Verbatim}
-%
-% \begin{scope}
-% \NiceMatrixOptions{code-for-first-row = \color{red},
-% code-for-first-col = \color{blue},
-% code-for-last-row = \color{green},
-% code-for-last-col = \color{magenta}}
-% \begin{displaymath}
-% \begin{pNiceArray}{CC|CC}[first-row,last-row=5,first-col,last-col,nullify-dots]
-% & C_1 & \multicolumn1C{\Cdots} & & C_4 & \\
-% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\
-% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\
-% \hline
-% & a_{31} & a_{32} & a_{33} & a_{34} & \\
-% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\
-% & C_1 & \multicolumn1C{\Cdots} & & C_4 &
-% \end{pNiceArray}
-% \end{displaymath}
-% \end{scope}
-%
-%
-% \emph{Remarks}
-% \begin{itemize}[beginpenalty=10000]
-% \item As shown in the previous example, an horizontal rule (drawn by |\hline|)
-% doesn't extend in the exterior columns and a vertical rule (specified by a
-% ``\verb+|+'' in the preamble of the array) doesn't extend in the exterior
-% rows.\footnote{The latter is not true when the package \pkg{arydshln} is
-% loaded besides \pkg{nicematrix}. In fact, \pkg{nicematrix} and \pkg{arydhsln}
-% are not totally compatible because \pkg{arydshln} redefines many internals of
-% \pkg{array}. On another hand, if one really wants a vertical rule running in
-% the first and in the last row, he should use |!{\vline}| instead of \verb+|+
-% in the preamble of the array.}
-%
-% If one wishes to define new specifiers for columns in order to draw vertical
-% rules (for example thicker than the standard rules), he should consider the
-% command |\OnlyMainNiceMatrix| described on page~\pageref{OnlyMainNiceMatrix}.
-%
-% \item A specification of color present in |code-for-first-row| also applies to
-% a dotted line draw in this exterior ``first row'' (excepted if a value has
-% been given to |xdots/color|). Idem for the other exterior rows and columns.
-%
-% \item Logically, the potential option |columns-width| (described
-% p.~\pageref{width}) doesn't apply to the ``first column'' and ``last column''.
-% \item For technical reasons, it's not possible to use the option of the
-% command |\\| after the ``first row'' or before the ``last row'' (the placement
-% of the delimiters would be wrong).
-% \end{itemize}
-%
%
%
+% \section{Other features}
%
+% \subsection{Use of the column type S of siunitx}
%
-% \section{The dotted lines to separate rows or columns}
-%
-%
-% In the environments of the package \pkg{nicematrix}, it's possible to use
-% the command |\hdottedline| (provided by \pkg{nicematrix}) which is a
-% counterpart of the classical commands |\hline| and |\hdashline| (the latter is
-% a command of \pkg{arydshln}).
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm]
-% \begin{pNiceMatrix}
-% 1 & 2 & 3 & 4 & 5 \\
-% ~emphase#\hdottedline@
-% 6 & 7 & 8 & 9 & 10 \\
-% 11 & 12 & 13 & 14 & 15
-% \end{pNiceMatrix}
-% \end{BVerbatim}
-% $\begin{pNiceMatrix}
-% 1 & 2 & 3 & 4 & 5 \\
-% \hdottedline
-% 6 & 7 & 8 & 9 & 10 \\
-% 11 & 12 & 13 & 14 & 15
-% \end{pNiceMatrix}$
-%
-%
-% \bigskip
-% In the environments with an explicit preamble (like |{NiceArray}|, etc.), it's
-% possible to draw a vertical dotted line with the specifier ``|:|''.
+% If the package \pkg{siunitx} is loaded (before or after \pkg{nicematrix}),
+% it's possible to use the |S| column type of \pkg{siunitx} in the environments
+% of \pkg{nicematrix}. The implementation doesn't use explicitly any private
+% macro of \pkg{siunitx}.
%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm]
-% \left(\begin{NiceArray}{CCCC~emphase#:@C}
-% 1 & 2 & 3 & 4 & 5 \\
-% 6 & 7 & 8 & 9 & 10 \\
-% 11 & 12 & 13 & 14 & 15
-% \end{NiceArray}\right)
-% \end{BVerbatim}
-% $\left(\begin{NiceArray}{CCCC:C}
-% 1 & 2 & 3 & 4 & 5 \\
-% 6 & 7 & 8 & 9 & 10 \\
-% 11 & 12 & 13 & 14 & 15
-% \end{NiceArray}\right)$
-%
-%
-% \bigskip
-% These dotted lines do \emph{not} extend in the potential exterior rows and
-% columns.
-%
%
% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm]
-% $\begin{pNiceArray}{CCC:C}[
-% first-row,last-col,
-% code-for-first-row = \color{blue}\scriptstyle,
-% code-for-last-col = \color{blue}\scriptstyle ]
-% C_1 & C_2 & C_3 & C_4 \\
-% 1 & 2 & 3 & 4 & L_1 \\
-% 5 & 6 & 7 & 8 & L_2 \\
-% 9 & 10 & 11 & 12 & L_3 \\
-% \hdottedline
-% 13 & 14 & 15 & 16 & L_4
+% \begin{BVerbatim}[baseline = c, boxwidth = 10.5cm]
+% $\begin{pNiceArray}{~emphase#S@CWc{1cm}C}[nullify-dots,first-row]
+% {C_1} & \Cdots & & C_n \\
+% 2.3 & 0 & \Cdots & 0 \\
+% 12.4 & \Vdots & & \Vdots \\
+% 1.45 \\
+% 7.2 & 0 & \Cdots & 0
% \end{pNiceArray}$
% \end{BVerbatim}
-% $\begin{pNiceArray}{CCC:C}[
-% first-row,last-col,
-% code-for-first-row = \color{blue}\scriptstyle,
-% code-for-last-col = \color{blue}\scriptstyle ]
-% C_1 & C_2 & C_3 & C_4 \\
-% 1 & 2 & 3 & 4 & L_1 \\
-% 5 & 6 & 7 & 8 & L_2 \\
-% 9 & 10 & 11 & 12 & L_3 \\
-% \hdottedline
-% 13 & 14 & 15 & 16 & L_4
+% $\begin{pNiceArray}{SCWc{1cm}C}[nullify-dots,first-row]
+% {C_1} & \Cdots & & C_n \\
+% 2.3 & 0 & \Cdots & 0 \\
+% 12.4 & \Vdots & & \Vdots \\
+% 1.45 \\
+% 7.2 & 0 & \Cdots & 0
% \end{pNiceArray}$
%
-% \bigskip
-% It's possible to change in \pkg{nicematrix} the letter used to specify a
-% vertical dotted line with the option |letter-for-dotted-lines| available in
-% |\NiceMatrixOptions|.
-%
-% \bigskip
-% \emph{Remark} : In the package \pkg{array} (on which the package
-% \pkg{nicematrix} relies), horizontal and vertical rules make the array larger
-% or wider by a quantity equal to the width of the rule\footnote{In fact, this
-% is true only for |\hline| and ``"|"'' but not for |\cline|.}. In
-% \pkg{nicematrix}, the dotted lines drawn by |\hdottedline| and ``|:|'' do
-% likewise.
-%
-%
-%
-% \section{The width of the columns}
-% \label{width}
-%
-% In the environments with an explicit preamble (like |{NiceArray}|,
-% |{pNiceArray}|, etc.), it's possible to fix the width of a given column with
-% the standard letters |w| and |W| of the package \pkg{array}. In the
-% environments of \pkg{nicematrix}, the cells of such columns are composed in
-% mathematical mode, whereas, in |{array}| of \pkg{array}, they are composed in
-% text mode.
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
-% $\left(\begin{NiceArray}{~emphase#wc{1cm}@CC}
-% 1 & 12 & -123 \\
-% 12 & 0 & 0 \\
-% 4 & 1 & 2
-% \end{NiceArray}\right)$
-% \end{BVerbatim}
-% $\left(\begin{NiceArray}{wc{1cm}CC}
-% 1 & 12 & -123 \\
-% 12 & 0 & 0 \\
-% 4 & 1 & 2
-% \end{NiceArray}\right)$
-%
-%
-% \bigskip
-% In the environments of \pkg{nicematrix}, it's also possible to fix the \emph{minimal}
-% width of all the columns of a matrix directly with the option |columns-width|.
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
-% $\begin{pNiceMatrix}[~emphase#columns-width = 1cm@]
-% 1 & 12 & -123 \\
-% 12 & 0 & 0 \\
-% 4 & 1 & 2
-% \end{pNiceMatrix}$
-% \end{BVerbatim}
-% $\begin{pNiceMatrix}[columns-width = 1cm]
-% 1 & 12 & -123 \\
-% 12 & 0 & 0 \\
-% 4 & 1 & 2
-% \end{pNiceMatrix}$
-%
-% \medskip
-% Note that the space inserted between two columns (equal to 2 |\arraycolsep|)
-% is not suppressed (of course, it's possible to suppress this space by setting
-% |\arraycolsep| equal to $0$~pt).
-%
-% \bigskip
-% It's possible to give the special value |auto| to the option |columns-width|:
-% all the columns of the array will have a width equal to the widest cell of
-% the array.\footnote{The result is achieved with only one compilation (but Tikz
-% will have written informations in the |.aux| file and a message requiring a
-% second compilation will appear).}\par\nobreak
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
-% $\begin{pNiceMatrix}[~emphase#columns-width = auto@]
-% 1 & 12 & -123 \\
-% 12 & 0 & 0 \\
-% 4 & 1 & 2
-% \end{pNiceMatrix}$
-% \end{BVerbatim}
-% $\begin{pNiceMatrix}[columns-width = auto]
-% 1 & 12 & -123 \\
-% 12 & 0 & 0 \\
-% 4 & 1 & 2
-% \end{pNiceMatrix}$
-%
-% \bigskip
-% Without surprise, it's possible to fix the minimal width of the columns of all
-% the matrices of a current scope with the command
-% |\NiceMatrixOptions|.\par\nobreak
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=8.5cm]
-% ~emphase#\NiceMatrixOptions{columns-width=10mm}@
-% $\begin{pNiceMatrix}
-% a & b \\ c & d
-% \end{pNiceMatrix}
-% =
-% \begin{pNiceMatrix}
-% 1 & 1245 \\ 345 & 2
-% \end{pNiceMatrix}$
-% \end{BVerbatim}
-% \begin{scope}
-% \NiceMatrixOptions{columns-width=10mm}
-% $\begin{pNiceMatrix}
-% a & b \\
-% c & d
-% \end{pNiceMatrix}
-% =
-% \begin{pNiceMatrix}
-% 1 & 1245 \\
-% 345 & 2
-% \end{pNiceMatrix}$
-% \end{scope}
-%
-%
-% \bigskip
-% But it's also possible to fix a zone where all the matrices will have their
-% columns of the same width, equal to the widest cell of all the matrices. This
-% construction uses the environment |{NiceMatrixBlock}| with the option
-% |auto-columns-width|\footnote{At this time, this is the only usage of the
-% environment |{NiceMatrixBlock}| but it may have other usages in the future.}.
-% The environment |{NiceMatrixBlock}| has no direct link with the command
-% |\Block| presented just below (cf.~p.~\pageref{Block}).
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=8.5cm]
-% ~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@
-% $\begin{pNiceMatrix}
-% a & b \\ c & d
-% \end{pNiceMatrix}
-% =
-% \begin{pNiceMatrix}
-% 1 & 1245 \\ 345 & 2
-% \end{pNiceMatrix}$
-% ~emphase#\end{NiceMatrixBlock}@
-% \end{BVerbatim}
-% \begin{NiceMatrixBlock}[auto-columns-width]
-% $\begin{pNiceMatrix}
-% a & b \\ c & d
-% \end{pNiceMatrix}
-% =
-% \begin{pNiceMatrix}
-% 1 & 1245 \\ 345 & 2
-% \end{pNiceMatrix}$
-% \end{NiceMatrixBlock}
-%
-% \medskip
-% \textbf{Several compilations may be necessary to achieve the job.}
-%
-%
-% \section{Block matrices}
-% \label{Block}
-%
-% This section has no direct link with the previous one where an environment
-% |{NiceMatrixBlock}| was introduced.
-%
-% 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| 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
-% $i$\verb|-|$j$ where $i$ is the number of rows of the block and $j$ its number
-% of columns. The second argument is the content of the block (composed in math
-% mode). A Tikz node corresponding to the merged cells is created with the name
-% ``$i$-$j$-block''. If the user has required the creation of the ``medium
-% nodes'', a node of this type is also created with a name suffixed by
-% |-medium|.
-%
-% \medskip
-% In the following examples, we use the command |\arrayrulecolor| of
-% \pkg{colortbl}.
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
-% \arrayrulecolor{blue}
-% $\begin{bNiceArray}{CCC|C}[margin]
-% ~emphase#\Block{3-3}{A}@ & & & 0 \\
-% & \hspace*{1cm} & & \Vdots \\
-% & & & 0 \\
-% \hline
-% 0 & \Cdots& 0 & 0
-% \end{bNiceArray}$
-% \arrayrulecolor{black}
-% \end{BVerbatim}
-% \begin{scope}
-% \arrayrulecolor{blue}
-% $\begin{bNiceArray}{CCC|C}[margin]
-% \Block{3-3}{A} & & & 0 \\
-% & \hspace*{1cm} & & \Vdots \\
-% & & & 0 \\
-% \hline
-% 0 & \Cdots& 0 & 0
-% \end{bNiceArray}$
-% \arrayrulecolor{black}
-% \end{scope}
-%
-% \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]
-% \arrayrulecolor{blue}
-% $\begin{bNiceArray}{CCC|C}[margin]
-% \Block{3-3}~emphase#<\Large>@{A} & & & 0 \\
-% & \hspace*{1cm} & & \Vdots \\
-% & & & 0 \\
-% \hline
-% 0 & \Cdots& 0 & 0
-% \end{bNiceArray}$
-% \arrayrulecolor{black}
-% \end{BVerbatim}
-% \begin{scope}
-% \arrayrulecolor{blue}
-% $\begin{bNiceArray}{CCC|C}[margin]
-% \Block{3-3}<\Large>{A} & & & 0 \\
-% & \hspace*{1cm} & & \Vdots \\
-% & & & 0 \\
-% \hline
-% 0 & \Cdots& 0 & 0
-% \end{bNiceArray}$
-% \arrayrulecolor{black}
-% \end{scope}
-%
-% \medskip
-% For technical reasons, you can't write |\Block{|$i$|-|$j$|}{<}|. But you can
-% write |\Block{|$i$|-|$j$|}<>{<}| with the expected result.
-%
-%
-% \section{The color of the rows and columns}
-%
-% With the classical package \pkg{colortbl}, it's possible to color the cells,
-% rows and columns of a tabular. However, the resulting \textsc{pdf} is not
-% always perfectly displayed by the \textsc{pdf} viewers, in particular in
-% conjonction with rules. With some \textsc{pdf} viewers, some vertical rules
-% seem to vanish. On the other side, some thin horizontal white lines may appear
-% in some circonstances.
-%
-%
-% \medskip
-% The version 4.0 of \pkg{nicematrix} provide similar tools which do not
-% present these drawbacks. This version provides a key |code-before| for some
-% code which will be executed \emph{before} the drawing of the tabular. In this
-% |code-before|, new commands are available: |\cellcolor|, |\rectanglecolor|,
-% |\rowcolor|, |\columncolor|, |\rowcolors| and |\chessboardcolors|.
-%
% \medskip
-% \begin{itemize}
-% \item The command |\cellcolor| takes its name from the command |\cellcolor| of
-% \pkg{colortbl}.
-%
-% This command takes in arguments a color and a list of cells, each of which
-% with the format $i$-$j$ where $i$ is the number of row and $j$ the number of
-% colummn of the cell.
-%
-%
-% \medskip
-% \begin{scope}
-% \hfuzz=10cm
-% \begin{BVerbatim}[boxwidth=10cm,baseline=c]
-% \begin{NiceTabular}{|C|C|C|}[code-before = ~emphase#\cellcolor{red!15}{3-1,2-2,1-3}@]
-% \hline
-% a & b & c \\ \hline
-% e & f & g \\ \hline
-% h & i & j \\ \hline
-% \end{NiceTabular}
-% \end{BVerbatim}
-% \begin{NiceTabular}{|C|C|C|}[code-before = \cellcolor{red!15}{3-1,2-2,1-3}]
-% \hline
-% a & b & c \\ \hline
-% e & f & g \\ \hline
-% h & i & j \\ \hline
-% \end{NiceTabular}
-% \end{scope}
-%
-% \bigskip
-% \item The command |\rectanglecolor| takes three arguments. The first is the
-% color. The second is the upper-left cell of the rectangle and the third is
-% the lower-right cell of the rectangle.
-%
-% \medskip
-% \begin{scope}
-% \hfuzz=10cm
-% \begin{BVerbatim}[boxwidth=10cm,baseline=c]
-% \begin{NiceTabular}{|C|C|C|}[code-before = ~emphase#\rectanglecolor{red!15}{2-2}{3-3}@]
-% \hline
-% a & b & c \\ \hline
-% e & f & g \\ \hline
-% h & i & j \\ \hline
-% \end{NiceTabular}
-% \end{BVerbatim}
-% \begin{NiceTabular}{|C|C|C|}[code-before = \rectanglecolor{red!15}{2-2}{3-3}]
-% \hline
-% a & b & c \\ \hline
-% e & f & g \\ \hline
-% h & i & j \\ \hline
-% \end{NiceTabular}
-% \end{scope}
-%
-%
-%
-% \bigskip
-% \item The command |\rowcolor| takes its name from the command |\rowcolor| of
-% \pkg{colortbl}. Its first argument is the color and the second is a
-% comma-separated list of rows or interval of rows with the form $a$-$b$ (an
-% interval of the form $a$- represent all the rows from the row $a$ until the end).
-%
-% \medskip
-% \begin{scope}
-% \hfuzz = 10cm
-% \begin{BVerbatim}[boxwidth=9cm,baseline=c]
-% $\begin{NiceArray}{LLL}[hvlines, ~emphase#code-before = \rowcolor{red!15}{1,3-5,8-}@]
-% a_1 & b_1 & c_1 \\
-% a_2 & b_2 & c_2 \\
-% a_3 & b_3 & c_3 \\
-% a_4 & b_4 & c_4 \\
-% a_5 & b_5 & c_5 \\
-% a_6 & b_6 & c_6 \\
-% a_7 & b_7 & c_7 \\
-% a_8 & b_8 & c_8 \\
-% a_9 & b_9 & c_9 \\
-% a_{10} & b_{10} & c_{10} \\
-% \end{NiceArray}$
-% \end{BVerbatim}
-% $\begin{NiceArray}{LLL}[baseline=4,hvlines, code-before = \rowcolor{red!15}{1,3-5,8-}]
-% a_1 & b_1 & c_1 \\
-% a_2 & b_2 & c_2 \\
-% a_3 & b_3 & c_3 \\
-% a_4 & b_4 & c_4 \\
-% a_5 & b_5 & c_5 \\
-% a_6 & b_6 & c_6 \\
-% a_7 & b_7 & c_7 \\
-% a_8 & b_8 & c_8 \\
-% a_9 & b_9 & c_9 \\
-% a_{10} & b_{10} & c_{10} \\
-% \end{NiceArray}$
-% \end{scope}
-%
-%
-% \bigskip
-% \item The command |\columncolor| takes its name from the command
-% |\columncolor| of \pkg{colortbl}. Its syntax is similar to the syntaxe of
-% |\rowcolor|.
-%
-% \bigskip
-% \item The command |\rowcolors| (with a \emph{s}) takes its name from the
-% command |\rowcolors| of \pkg{xcolor}. The \emph{s} emphasizes the fact that
-% there is \emph{two} colors. This command colors alternately the rows of the
-% tabular, beginning with the row whose number is given in first argument. The
-% two other arguments are the colors.
-%
-% \medskip
-% \begin{scope}
-% \hfuzz=10cm
-% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
-% \begin{NiceTabular}{LR}%
-% [~emphase#code-before = \rowcolor{red!15}{1} \rowcolors{3}{blue!10}{}@]
-% \toprule
-% Town & Habitants \\
-% \midrule
-% Pau & 80000 \\
-% Paris & 2000000 \\
-% Toulouse & 700000 \\
-% Reims & 40000 \\
-% \bottomrule
-% \end{NiceTabular}
-% \end{BVerbatim}
-% \begin{NiceTabular}{LR}[code-before =\rowcolor{red!15}{1} \rowcolors{3}{blue!10}{}]
-% \toprule
-% Ville & habitants \\
-% \midrule
-% Pau & 80000 \\
-% Paris & 2000000 \\
-% Toulouse & 700000 \\
-% Reims & 40000 \\
-% \bottomrule
-% \end{NiceTabular}
-% \end{scope}
-%
-% \bigskip
-% \item The command |\chessboardcolors| take in arguments two colors and colors
-% the cells of the tabular in quincunx with these colors.
-%
-% \medskip
-% \begin{scope}
-% \hfuzz=10cm
-% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
-% $\begin{pNiceMatrix}[R,margin, ~emphase#code-before=\chessboardcolors{red!15}{blue!15}@]
-% 1 & -1 & 1 \\
-% -1 & 1 & -1 \\
-% 1 & -1 & 1
-% \end{pNiceMatrix}$
-% \end{BVerbatim}
-% $\begin{pNiceMatrix}[R,baseline=1, margin, code-before = \chessboardcolors{red!15}{blue!15}]
-% 1 & -1 & 1 \\
-% -1 & 1 & -1 \\
-% 1 & -1 & 1
-% \end{pNiceMatrix}$
-% \end{scope}
-%
-% \end{itemize}
-%
+% On the other hand, the |d| columns of the package \pkg{dcolumn} are not
+% supported by \pkg{nicematrix}.
%
-%
-% \section{Advanced features}
%
+% \subsection{Alignement option in \{NiceMatrix\}}
%
-% \subsection{Alignement option in NiceMatrix}
+% \label{key-R}
%
% The environments without preamble (|{NiceMatrix}|, |{pNiceMatrix}|,
% |{bNiceMatrix}|, etc.) provide two options |l| and |r| (equivalent at |L| and
% |R|) which generate all the columns aligned leftwards (or
-% rightwards).\footnote{This is a part of the functionality provided by the
-% environments |{pmatrix*}|, |{bmatrix*}|, etc. of \pkg{mathtools}.}
+% rightwards).
%
%
% \medskip
@@ -1780,6 +1853,11 @@ version 2005/12/01 or later.
% \sin x & \cos x
% \end{bNiceMatrix}$
%
+% \medskip
+% There is also a key |S| which sets all the columns all type |S| of
+% \pkg{siunitx} (if this package is loaded).\footnote{This is a part of the
+% functionality provided by the environments |{pmatrix*}|, |{bmatrix*}|, etc. of
+% \pkg{mathtools}.}
%
% \subsection{The command \textbackslash rotate}
%
@@ -1900,9 +1978,10 @@ version 2005/12/01 or later.
% exists) has also the number~$0$.}. Of course, the user must not change the
% value of these counters which are used internally by \pkg{nicematrix}.
%
-% In the |code-after| (cf. p. \pageref{code-after}), |iRow| represents the total
-% number of rows (excepted the potential exterior rows) and |jCol| represents
-% the total number of columns (excepted the potential exterior columns).
+% In the |code-before| (cf. p. \pageref{code-before}) and in the |code-after|
+% (cf. p. \pageref{code-after}), |iRow| represents the total number of rows
+% (excepted the potential exterior rows) and |jCol| represents the total number
+% of columns (excepted the potential exterior columns).
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
@@ -1929,8 +2008,8 @@ version 2005/12/01 or later.
%
% \medskip
% If LaTeX counters called |iRow| and |jCol| are defined in the document by
-% packages other than \pkg{nicematrix} (or by the user), they are shadowed in
-% the environments of \pkg{nicematrix}.
+% packages other than \pkg{nicematrix} (or by the final user), they are shadowed
+% in the environments of \pkg{nicematrix}.
%
% \bigskip
% The package \pkg{nicematrix} also provides commands in order to compose
@@ -1950,98 +2029,15 @@ version 2005/12/01 or later.
% \end{Verbatim}
%
%
-% $C = \pAutoNiceMatrix{3-3}{C_{\arabic{iRow},\arabic{jCol}}}$
-%
-% \subsection{The options hlines, vlines and hvlines}
-%
-% \label{hvlines}
-% You can add horizontal rules between rows in the environments of
-% \pkg{nicematrix} with the usual command |\hline| and you can use the specifier
-% ``"|"'' to add vertical rules. However, by convenience, the package
-% \pkg{nicematrix} also provides the option |hlines| (resp. |vlines|) which will
-% draw all the horizontal (resp. vertical) rules (excepted, of course, the
-% exterior rules corresponding to the exterior rows and columns). The key
-% |hvlines| is an alias for the conjonction for the keys |hlines| et |vlines|.
-%
-% % \medskip
-% In the following example, we use the command |\arrayrulecolor| of
-% \pkg{colortbl}.
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
-% \arrayrulecolor{blue}
-% $\begin{NiceArray}{CCCC}%
-% [~emphase#hvlines@,first-row,first-col]
-% & e & a & b & c \\
-% e & e & a & b & c \\
-% a & a & e & c & b \\
-% b & b & c & e & a \\
-% c & c & b & a & e
-% \end{NiceArray}$
-% \arrayrulecolor{black}
-% \end{BVerbatim}
-% \arrayrulecolor{blue}
-% $\begin{NiceArray}{CCCC}[hvlines,first-row,first-col]
-% & e & a & b & c \\
-% e & e & a & b & c \\
-% a & a & e & c & b \\
-% b & b & c & e & a \\
-% c & c & b & a & e
-% \end{NiceArray}$
-% \arrayrulecolor{black}
-%
-% \bigskip
-% However, there is a difference between the key |vlines| and the use of
-% the specifier ``"|"'' in the preamble of the environment: the rules drawn by
-% |vlines| completely cross the double-rules drawn by |\hline\hline|.
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=11.5cm]
-% $\begin{NiceArray}{CCCC}[vlines] \hline
-% a & b & c & d \\ \hline \hline
-% 1 & 2 & 3 & 4 \\
-% 1 & 2 & 3 & 4 \\ \hline
-% \end{NiceArray}$
-% \end{BVerbatim}
-% $\begin{NiceArray}{CCCC}[vlines]
-% \hline
-% a & b & c & d \\
-% \hline \hline
-% 1 & 2 & 3 & 4 \\
-% 1 & 2 & 3 & 4 \\
-% \hline
-% \end{NiceArray}$
-%
-% \bigskip
-% For the environments with delimiters (for example |{pNiceArray}| or
-% |{pNiceMatrix}|), the option |vlines| don't draw vertical rules on both sides,
-% where are the delimiters (fortunately).
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
-% \setlength{\arrayrulewidth}{0.2pt}
-% $\begin{pNiceMatrix}[vlines]
-% 1 & 2 & 3 & 4 & 5 & 6 \\
-% 1 & 2 & 3 & 4 & 5 & 6 \\
-% 1 & 2 & 3 & 4 & 5 & 6
-% \end{pNiceMatrix}$
-% \end{BVerbatim}
-% \begin{scope}
-% \setlength{\arrayrulewidth}{0.2pt}
-% $\begin{pNiceMatrix}[vlines]
-% 1 & 2 & 3 & 4 & 5 & 6 \\
-% 1 & 2 & 3 & 4 & 5 & 6 \\
-% 1 & 2 & 3 & 4 & 5 & 6
-% \end{pNiceMatrix}$
-% \end{scope}
+% \[C = \pAutoNiceMatrix{3-3}{C_{\arabic{iRow},\arabic{jCol}}}\]
%
%
% \subsection{The option light-syntax}
%
% \label{light-syntax}
-% The option |light-syntax|\footnote{This option is inspired by the package
-% \pkg{spalign} of Joseph Rabinoff.} allows the user to compose the arrays with a
-% lighter syntax, which gives a more readable TeX source.
+% The option |light-syntax| (inpired by the package \pkg{spalign}) allows the
+% user to compose the arrays with a lighter syntax, which gives a better
+% legibility of the TeX source.
%
% When this option is used, one should use the semicolon for the end of a row
% and spaces or tabulations to separate the columns. However, as usual in the
@@ -2080,36 +2076,419 @@ version 2005/12/01 or later.
% analyzed. The environment doesn't behave in that case as a standard
% environment of LaTeX which only put TeX commands before and after the content.}
%
-% \subsection{Use of the column type S of siunitx}
%
-% If the package \pkg{siunitx} is loaded (before or after \pkg{nicematrix}),
-% it's possible to use the |S| column type of \pkg{siunitx} in the environments
-% of \pkg{nicematrix}. The implementation doesn't use explicitly any private
-% macro of \pkg{siunitx}.
+%
+% \subsection{The environment \{NiceArrayWithDelims\}}
+%
+% In fact, the environment |{pNiceArray}| and its variants are based upon a
+% more general environment, called |{NiceArrayWithDelims}|. The first two
+% mandatory arguments of this environment are the left and right delimiters used
+% in the construction of the matrix. It's possible to use
+% |{NiceArrayWithDelims}| if we want to use atypical or asymetrical delimiters.
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
+% $\begin{~emphase#NiceArrayWithDelims@}
+% {\downarrow}{\uparrow}{CCC}[margin]
+% 1 & 2 & 3 \\
+% 4 & 5 & 6 \\
+% 7 & 8 & 9
+% \end{~emphase#NiceArrayWithDelims@}$
+% \end{BVerbatim}
+% $\begin{NiceArrayWithDelims}
+% {\downarrow}{\uparrow}{CCC}[margin]
+% 1 & 2 & 3 \\
+% 4 & 5 & 6 \\
+% 7 & 8 & 9
+% \end{NiceArrayWithDelims}$
+%
+%
+%
+% \section{Utilisation of Tikz with nicematrix}
%
+% \label{name}
+% \subsection{The nodes corresponding to the contents of the cells}
+%
+% The package \pkg{nicematrix} creates a PGF/Tikz node for each (non-empty) cell
+% of the considered array. These nodes are used to draw the dotted lines between
+% the cells of the matrix (inter alia).
+%
+% \smallskip
+% The nodes of a document must have distinct names. That's why the names of the
+% nodes created by \pkg{nicematrix} contains the number of the current
+% environment. Indeed, the environments of \pkg{nicematrix} are numbered by a
+% internal global counter.
+%
+% \smallskip
+% In the environment with the number $n$, the node of the row $i$ and
+% column~$j$ has for name |nm-|$n$|-|$i$|-|$j$.
+%
+% \smallskip
+% The command |\NiceMatrixLastEnv| provides the number of the last environment
+% of \pkg{nicematrix} (for LaTeX, it's a ``fully expandable'' command and not a
+% counter).
+%
+% \smallskip
+% However, it's advisable to use instead the key |name|. This key gives a name
+% to the current environment. When the environment has a name, the nodes are
+% accessible with the name ``\textsl{name}-$i$-$j$'' where \textsl{name} is the
+% name given to the array and $i$ and $j$ the numbers of row and column. It's
+% possible to use these nodes with \textsc{pgf} but the final user will
+% probably prefer to use Tikz (which is a convenient layer upon \textsc{pgf}).
+% However, one should remind that \pkg{nicematrix} doesn't load Tikz by default.
%
+% \bigskip
+% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
+% $\begin{pNiceMatrix}[name=~emphase#mymatrix@]
+% 1 & 2 & 3 \\
+% 4 & 5 & 6 \\
+% 7 & 8 & 9
+% \end{pNiceMatrix}$
+% \tikz[remember picture,overlay]
+% \draw ~emphase#(mymatrix-2-2)@ circle (2mm) ;
+% \end{BVerbatim}
+% $\begin{pNiceMatrix}[name=mymatrix]
+% 1 & 2 & 3 \\
+% 4 & 5 & 6 \\
+% 7 & 8 & 9
+% \end{pNiceMatrix}$
+% \tikz[remember picture,overlay]
+% \draw (mymatrix-2-2) circle (2mm) ;
+%
% \medskip
-% \begin{BVerbatim}[baseline = c, boxwidth = 10.5cm]
-% $\begin{pNiceArray}{~emphase#S@CWc{1cm}C}[nullify-dots,first-row]
-% {C_1} & \Cdots & & C_n \\
-% 2.3 & 0 & \Cdots & 0 \\
-% 12.4 & \Vdots & & \Vdots \\
-% 1.45 \\
-% 7.2 & 0 & \Cdots & 0
-% \end{pNiceArray}$
+% Don't forget the options |remember picture| and |overlay|.
+%
+% \bigskip
+% In the |code-after|, and if Tikz is loaded, the things are easier. One may
+% design the nodes with the form $i$-$j$: there is no need to indicate the
+% environment which is of course the current environment.
+%
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
+% $\begin{pNiceMatrix}
+% 1 & 2 & 3 \\
+% 4 & 5 & 6 \\
+% 7 & 8 & 9
+% \CodeAfter
+% \tikz \draw ~emphase#(2-2)@ circle (2mm) ;
+% \end{pNiceMatrix}$
% \end{BVerbatim}
-% $\begin{pNiceArray}{SCWc{1cm}C}[nullify-dots,first-row]
-% {C_1} & \Cdots & & C_n \\
-% 2.3 & 0 & \Cdots & 0 \\
-% 12.4 & \Vdots & & \Vdots \\
-% 1.45 \\
-% 7.2 & 0 & \Cdots & 0
-% \end{pNiceArray}$
+% $\begin{pNiceMatrix}
+% 1 & 2 & 3 \\
+% 4 & 5 & 6 \\
+% 7 & 8 & 9
+% \CodeAfter
+% \tikz \draw (2-2) circle (2mm) ;
+% \end{pNiceMatrix}$
+%
+%
+% \bigskip
+% In the following example, we have underlined all the nodes of the matrix (we
+% explain below the technic used : cf. p. \pageref{highlight}).
+%
+% \[\begin{pNiceMatrix}[
+% code-after = {\begin{tikzpicture}
+% [every node/.style = {blend mode = multiply,
+% fill = red!15,
+% inner sep = 0 pt }]
+% \node [fit = (1-1)] {} ;
+% \node [fit = (1-3)] {} ;
+% \node [fit = (2-2)] {} ;
+% \node [fit = (3-1)] {} ;
+% \node [fit = (3-3)] {} ;
+% \node [fit = (1-2)] {} ;
+% \node [fit = (2-1)] {} ;
+% \node [fit = (2-3)] {} ;
+% \node [fit = (3-2)] {} ;
+% \end{tikzpicture}}]
+% a & a + b & a + b + c \\
+% a & a & a + b \\
+% a & a & a
+% \end{pNiceMatrix}\]
+%
+%
%
+% \subsection{The ``medium nodes'' and the ``large nodes''}
+%
+% In fact, the package \pkg{nicematrix} can create ``extra nodes'': the ``medium
+% nodes'' and the ``large nodes''. The first ones
+% are created with the option |create-medium-nodes| and the second ones with the
+% option |create-large-nodes|.\footnote{There is also an option
+% |create-extra-nodes| which is an alias for the conjonction of
+% |create-medium-nodes| and |create-large-nodes|.}
+%
% \medskip
-% On the other hand, the |d| columns of the package \pkg{dcolumn} are not
-% supported by \pkg{nicematrix}.
+% These nodes are not used by \pkg{nicematrix} by default, and that's why they
+% are not created by default.
+%
+% \medskip
+% The names of the ``medium nodes'' are constructed by adding the suffix
+% ``|-medium|'' to the names of the ``normal nodes''. In the following example,
+% we have underlined the ``medium nodes''. We consider that this example is
+% self-explanatory.
+% \[\begin{pNiceMatrix}[
+% create-medium-nodes,
+% code-after = {\begin{tikzpicture}
+% [every node/.style = {fill = red!15,
+% blend mode = multiply,
+% inner sep = 0pt},
+% name suffix = -medium]
+% \node [fit = (1-1)] {} ;
+% \node [fit = (1-2)] {} ;
+% \node [fit = (1-3)] {} ;
+% \node [fit = (2-1)] {} ;
+% \node [fit = (2-2)] {} ;
+% \node [fit = (2-3)] {} ;
+% \node [fit = (3-1)] {} ;
+% \node [fit = (3-2)] {} ;
+% \node [fit = (3-3)] {} ;
+% \end{tikzpicture}}]
+% a & a + b & a + b + c \\
+% a & a & a + b \\
+% a & a & a
+% \end{pNiceMatrix}\]
+%
+%
+% \medskip
+% The names of the ``large nodes'' are constructed by adding the suffix
+% ``|-large|'' to the names of the ``normal nodes''. In the following example,
+% we have underlined the ``large nodes''. We consider that this example is
+% self-explanatory.\footnote{There is no ``large nodes'' created in the exterior
+% rows and columns (for these rows and columns, cf. p.~\pageref{exterior}).}
+%
+% \[\begin{pNiceMatrix}[
+% create-large-nodes,
+% code-after = {\begin{tikzpicture}
+% [every node/.style = {blend mode = multiply,
+% inner sep = 0pt},
+% name suffix = -large]
+% \node [fit = (1-1),fill = red!15] {} ;
+% \node [fit = (1-3),fill = red!15] {} ;
+% \node [fit = (2-2),fill = red!15] {} ;
+% \node [fit = (3-1),fill = red!15] {} ;
+% \node [fit = (3-3),fill = red!15] {} ;
+% \node [fit = (1-2),fill = blue!15] {} ;
+% \node [fit = (2-1),fill = blue!15] {} ;
+% \node [fit = (2-3),fill = blue!15] {} ;
+% \node [fit = (3-2),fill = blue!15] {} ;
+% \end{tikzpicture}}]
+% a & a + b & a + b + c \\
+% a & a & a + b \\
+% a & a & a
+% \end{pNiceMatrix}\]
+%
+%
+% \medskip
+% The ``large nodes'' of the first column and last column may appear too small
+% for some usage. That's why it's possible to use the options |left-margin| and
+% |right-margin| to add space on both sides of the array and also space in the
+% ``large nodes'' of the first column and last column. In the following example,
+% we have used the options |left-margin| and |right-margin|.\footnote{The
+% options |left-margin| and |right-margin| take dimensions as values but, if no
+% value is given, the default value is used, which is |\arraycolsep| (by
+% default: 5~pt). There is also an option |margin| to fix both |left-margin| and
+% |right-margin| to the same value.}
+% \[\begin{pNiceMatrix}[
+% create-large-nodes,left-margin,right-margin,
+% code-after = {\begin{tikzpicture}
+% [every node/.style = {blend mode = multiply,
+% inner sep = 0pt},
+% name suffix = -large]
+% \node [fit = (1-1),fill = red!15] {} ;
+% \node [fit = (1-3),fill = red!15] {} ;
+% \node [fit = (2-2),fill = red!15] {} ;
+% \node [fit = (3-1),fill = red!15] {} ;
+% \node [fit = (3-3),fill = red!15] {} ;
+% \node [fit = (1-2),fill = blue!15] {} ;
+% \node [fit = (2-1),fill = blue!15] {} ;
+% \node [fit = (2-3),fill = blue!15] {} ;
+% \node [fit = (3-2),fill = blue!15] {} ;
+% \end{tikzpicture}}]
+% a & a + b & a + b + c \\
+% a & a & a + b \\
+% a & a & a
+% \end{pNiceMatrix}\]
+%
+% \medskip
+% It's also possible to add more space on both side of the array with the
+% options |extra-left-margin| and |extra-right-margin|. These margins are not
+% incorporated in the ``large nodes''. It's possible to fix both values with the
+% option |extra-margin| and, in the following example, we use |extra-margin|
+% with the value $3$~pt.
+% \[\begin{pNiceMatrix}[
+% create-large-nodes,margin,extra-margin=3pt,
+% code-after = {\begin{tikzpicture}
+% [every node/.style = {blend mode = multiply,
+% inner sep = 0 pt},
+% name suffix = -large]
+% \node [fit = (1-1),fill = red!15] {} ;
+% \node [fit = (1-3),fill = red!15] {} ;
+% \node [fit = (2-2),fill = red!15] {} ;
+% \node [fit = (3-1),fill = red!15] {} ;
+% \node [fit = (3-3),fill = red!15] {} ;
+% \node [fit = (1-2),fill = blue!15] {} ;
+% \node [fit = (2-1),fill = blue!15] {} ;
+% \node [fit = (2-3),fill = blue!15] {} ;
+% \node [fit = (3-2),fill = blue!15] {} ;
+% \end{tikzpicture}}]
+% a & a + b & a + b + c \\
+% a & a & a + b \\
+% a & a & a
+% \end{pNiceMatrix}\]
+%
+%
+%
+% \bigskip
+% \textbf{Be careful} : These nodes are reconstructed from the contents of the
+% contents cells of the array. Usually, they do not correspond to the cells
+% delimited by the rules (if we consider that these rules are drawn).
+%
+% \bigskip
+% \begin{minipage}[c]{7.6cm}
+% Here is a array composed with the following code:
+%
+% \medskip
+% \begin{BVerbatim}
+% \large
+% \begin{NiceTabular}{wl{2cm}LL}[hvlines]
+% fraise & amande & abricot \\
+% prune & pêche & poire \\[1ex]
+% noix & noisette & brugnon
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \end{minipage}
+% \hspace{0.9cm}
+% \begin{scope}
+% \large
+% \begin{NiceTabular}[c]{wl{2cm}LL}[hvlines]
+% fraise & amande & abricot \\
+% prune & pêche & poire \\[1ex]
+% noix & noisette & brugnon
+% \end{NiceTabular}
+% \end{scope}
%
+% \vspace{1cm}
+% \begin{minipage}[c]{7cm}
+% Here, we have colored all the cells of the array with |\chessboardcolors|.
+% \end{minipage}
+% \hspace{1.5cm}
+% \begin{scope}
+% \large
+% \begin{NiceTabular}[c]{wl{2cm}LL}[hvlines,code-before = \chessboardcolors{red!15}{blue!15}]
+% fraise & amande & abricot \\
+% prune & pêche & poire \\[1ex]
+% noix & noisette & brugnon
+% \end{NiceTabular}
+% \end{scope}
+%
+%
+% \vspace{1cm}
+% \begin{minipage}[c]{7cm}
+% Here are the ``large nodes'' of this array (without utilisation of |margin|
+% nor |extra-margin|).
+% \end{minipage}
+% \hspace{1.5cm}
+% \begin{scope}
+% \large
+% \begin{NiceTabular}[c]{wl{2cm}LL}[hvlines,
+% create-large-nodes,
+% code-after = {\begin{tikzpicture}
+% [every node/.style = {blend mode = multiply,
+% inner sep = 0 pt},
+% name suffix = -large]
+% \node [fit = (1-1),fill = red!15] {} ;
+% \node [fit = (1-3),fill = red!15] {} ;
+% \node [fit = (2-2),fill = red!15] {} ;
+% \node [fit = (3-1),fill = red!15] {} ;
+% \node [fit = (3-3),fill = red!15] {} ;
+% \node [fit = (1-2),fill = blue!15] {} ;
+% \node [fit = (2-1),fill = blue!15] {} ;
+% \node [fit = (2-3),fill = blue!15] {} ;
+% \node [fit = (3-2),fill = blue!15] {} ;
+% \end{tikzpicture}}]
+% fraise & amande & abricot \\
+% prune & pêche & poire \\[1ex]
+% noix & noisette & brugnon
+% \end{NiceTabular}
+% \end{scope}
+%
+%
+%
+%
+% \subsection{The ``row-nodes'' and the ``col-nodes''}
+%
+% The package \pkg{nicematrix} creates a PGF/Tikz node indicating the potential
+% position of each horizontal rule (with the names |row-|$i$) and each vertical
+% rule (with the names |col-|$j$), as described in the following figure. These
+% nodes are available in the |code-before| and the |code-after|.
+% \begin{center}
+% \begin{NiceTabular}{CCC}[hvlines,rules/width=1pt,rules/color=gray]
+% rose & tulipe & lys \\
+% arum & iris & violette \\
+% muguet & dahlia & souci
+% \CodeAfter
+% \tiny
+% \begin{tikzpicture}
+% \foreach \i in {1,2,3,4}
+% {
+% \fill [red] (row-\i) circle (0.5mm) ;
+% \node [red,anchor=east] at (row-\i) {row-\i} ;
+% }
+% \foreach \j in {1,2,3,4}
+% {
+% \fill [blue] (col-\j) circle (0.5mm) ;
+% \node [blue,anchor=north] at (col-\j) {col-\j} ;
+% }
+% \end{tikzpicture}
+% \end{NiceTabular}
+% \end{center}
+%
+% \bigskip
+% If we use Tikz (we remind that \pkg{nicematrix} does not load Tikz by
+% default), we can access (in the |code-before| and the |code-after|) to the
+% intersection of the horizontal rule~$i$ and the vertical rule~$j$ with the
+% syntax |(row-|$i$\verb+-|col-+$j$|)|.
+%
+% \medskip
+% \begin{Verbatim}
+% \[\begin{NiceMatrix}[
+% code-before =
+% {
+% ~emphase# \tikz \draw [fill = red!15] @
+% ~emphase# (row-7-|col-4) -- (row-8-|col-4) -- (row-8-|col-5) -- @
+% ~emphase# (row-9-|col-5) -- (row-9-|col-6) |- cycle ; @
+% }
+% ]
+% 1 \\
+% 1 & 1 \\
+% 1 & 2 & 1 \\
+% 1 & 3 & 3 & 1 \\
+% 1 & 4 & 6 & 4 & 1 \\
+% 1 & 5 & 10 & 10 & 5 & 1 \\
+% 1 & 6 & 15 & 20 & 15 & 6 & 1 \\
+% 1 & 7 & 21 & 35 & 35 & 21 & 7 & 1 \\
+% 1 & 8 & 28 & 56 & 70 & 56 & 28 & 8 & 1
+% \end{NiceMatrix}\]
+% \end{Verbatim}
+% \[\begin{NiceMatrix}[
+% code-before =
+% {
+% \tikz \draw [fill = red!15]
+% (row-7-|col-4) -- (row-8-|col-4) -- (row-8-|col-5) --
+% (row-9-|col-5) -- (row-9-|col-6) |- cycle ;
+% }
+% ]
+% 1 \\
+% 1 & 1 \\
+% 1 & 2 & 1 \\
+% 1 & 3 & 3 & 1 \\
+% 1 & 4 & 6 & 4 & 1 \\
+% 1 & 5 & 10 & 10 & 5 & 1 \\
+% 1 & 6 & 15 & 20 & 15 & 6 & 1 \\
+% 1 & 7 & 21 & 35 & 35 & 21 & 7 & 1 \\
+% 1 & 8 & 28 & 56 & 70 & 56 & 28 & 8 & 1
+% \end{NiceMatrix}\]
%
%
% \section{Technical remarks}
@@ -2153,28 +2532,10 @@ version 2005/12/01 or later.
% \end{scope}
%
% \medskip
-% The specifier |?| may be used in a standard environment |{array}| (of the
-% package \pkg{array}) and, in this case, the command |\OnlyMainNiceMatrix| is
-% no-op.
-%
-%
-% \subsection{The names of the PGF nodes created by nicematrix}
-%
-% We have said that, when a name is given to an environment of \pkg{nicematrix},
-% it's possible to access the PGF/Tikz nodes through this name (cf.
-% p.~\pageref{name}).
+% This specifier |?| may be used in the standard environments |{tabular}| and
+% |{array}| (of the package \pkg{array}) and, in this case, the command
+% |\OnlyMainNiceMatrix| is no-op.
%
-% That's the recommended way to access these nodes. However, we describe now the
-% internal names of these nodes.
-%
-% The environments created by \pkg{nicematrix} are numbered by an internal
-% global counter. The command |\NiceMatrixLastEnv| provides the number of the
-% last environment of \pkg{nicematrix} (for LaTeX, it's a ``fully expandable''
-% command and not a counter).
-%
-% For the environment of number~$n$, the node in row~$i$ and column~$j$ has the
-% name |nm-|$n$|-|$i$|-|$j$. The |medium| and |large| nodes have the same name,
-% suffixed by |-medium| and |-large|.
%
%
% \subsection{Diagonal lines}
@@ -2310,95 +2671,16 @@ version 2005/12/01 or later.
% environments of \pkg{nicematrix} are not affected).
%
%
-%
-% \subsection{A technical problem with the argument of
-% \textbackslash\textbackslash}
-%
-%
-% For technical, reasons, if you use the optional argument of the command |\\|,
-% the vertical space added will also be added to the ``normal'' node
-% corresponding at the previous node.
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
-% \begin{pNiceMatrix}
-% a & \frac AB \\~emphase#[2mm]@
-% b & c
-% \end{pNiceMatrix}
-% \end{BVerbatim}
-% $\begin{pNiceMatrix}[
-% code-after = {\tikz \node [inner sep = 0pt,
-% fill = red!15,
-% blend mode = multiply,
-% fit = (1-2) ] {} ; } ]
-% a & \frac AB \\[2mm]
-% b & c
-% \end{pNiceMatrix}$
%
-% \bigskip
-% There are two solutions to solve this problem. The first solution is to use a
-% TeX command to insert space between the rows.
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
-% \begin{pNiceMatrix}
-% a & \frac AB \\
-% ~emphase#\noalign{\kern2mm}@
-% b & c
-% \end{pNiceMatrix}
-% \end{BVerbatim}
-% $\begin{pNiceMatrix}[
-% code-after = {\tikz \node [inner sep = 0pt,
-% fill = red!15,
-% blend mode = multiply,
-% fit = (1-2) ] {} ; } ]
-% a & \frac AB \\
-% \noalign{\kern2mm}
-% b & c
-% \end{pNiceMatrix}$
-%
-%
-% \bigskip
-% The other solution is to use the command |\multicolumn| in the previous cell.
+% \subsection{Incompatibilities}
%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
-% \begin{pNiceMatrix}
-% a & ~emphase#\multicolumn1C{\frac AB}@ \\[2mm]
-% b & c
-% \end{pNiceMatrix}
-% \end{BVerbatim}
-% $\begin{pNiceMatrix}[
-% code-after = {\tikz \node [inner sep = 0pt,
-% fill = red!15,
-% blend mode = multiply,
-% fit = (1-2) ] {} ; } ]
-% a & \multicolumn1C{\frac AB} \\[2mm]
-% b & c
-% \end{pNiceMatrix}$
-%
-%
-% \subsection{Obsolete environments which have been deleted}
+% The package \pkg{nicematrix} is not compatible with \pkg{threeparttable}.
%
-% The version 3.0 of \pkg{nicematrix} has introduced the environment
-% |{pNiceArray}| (and its variants) with the options |first-row|, |last-row|,
-% |first-col| and |last-col|.
+% \medskip
+% The package \pkg{nicematrix} is not fully compatible with the package
+% \pkg{arydshln} (because this package redefines many internal of \pkg{array}).
%
-% Consequently the following environments present in previous versions of
-% have been deleted from \pkg{nicematrix}.
-% %
-% \begin{itemize}
-% \item |{NiceArrayCwithDelims}| ;
-% \item |{pNiceArrayC}|, |{bNiceArrayC}|, |{BNiceArrayC}|, |{vNiceArrayC}|,
-% |{VNiceArrayC}| ;
-% \item |{NiceArrayRCwithDelims}| ;
-% \item |{pNiceArrayRC}|, |{bNiceArrayRC}|, |{BNiceArrayRC}|, |{vNiceArrayRC}|,
-% |{VNiceArrayRC}|.
-% \end{itemize}
%
-% However, the definition of those environments is still available (temporarily)
-% at the end of the file |nicematrix.sty| after a command |\file_input_stop:|.
-%
% \section{Examples}
%
% \subsection{Dotted lines}
@@ -2531,11 +2813,9 @@ version 2005/12/01 or later.
% \end{scope}
%
% \vspace{2cm}
-% An example for a linear system (the vertical rule has been drawn in blue with
-% the tools of \pkg{colortbl}):\par\nobreak
+% An example for a linear system:\par\nobreak
%
% \begin{Verbatim}
-% \arrayrulecolor{blue}
% $\begin{pNiceArray}{*6C|C}[nullify-dots,last-col,code-for-last-col=\scriptstyle]
% 1 & 1 & 1 &\Cdots & & 1 & 0 & \\
% 0 & 1 & 0 &\Cdots & & 0 & & L_2 \gets L_2-L_1 \\
@@ -2544,10 +2824,9 @@ version 2005/12/01 or later.
% \Vdots & & &\Ddots & & 0 & \\
% 0 & & &\Cdots & 0 & 1 & 0 & L_n \gets L_n-L_1
% \end{pNiceArray}$
-% \arrayrulecolor{black}
% \end{Verbatim}
%
-% \arrayrulecolor{blue}
+%
% \[\begin{pNiceArray}{*6C|C}[nullify-dots,last-col,code-for-last-col=\scriptstyle]
% 1 & 1 & 1 &\Cdots & & 1 & 0 & \\
% 0 & 1 & 0 &\Cdots & & 0 & & L_2 \gets L_2-L_1 \\
@@ -2556,7 +2835,6 @@ version 2005/12/01 or later.
% \Vdots & & &\Ddots & & 0 & \\
% 0 & & &\Cdots & 0 & 1 & 0 & L_n \gets L_n-L_1
% \end{pNiceArray}\]
-% \arrayrulecolor{black}
%
%
%
@@ -2746,24 +3024,22 @@ version 2005/12/01 or later.
%
%
% 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. We recall that, on the other side, the command |\hline|, the specifier
-% ``"|"'' and the options |hlines| and |vlines| spread the cells (when the
-% package \pkg{array} is loaded but, when the package \pkg{nicematrix} is
-% loaded, \pkg{array} is always loaded).\footnote{On the other side, the command
-% |\cline| doesn't spread the rows of the array.}
+% construction of the array and thus, they don't spread the cells of the array.
+% We recall that, on the other side, the command |\hline|, the specifier ``"|"''
+% and the options |hlines|, |vlines| and |hvlines| spread the
+% cells.\footnote{For the command |\cline|, see the remark
+% p.~\pageref{remark-cline}.}
%
%
% \vspace{1cm}
-% The package \pkg{nicematrix} is constructed upon the environment |{array}|
-% and, therefore, it's possible to use the package \pkg{colortbl} in the
-% environments of \pkg{nicematrix}. However, it's not always easy to do a fine
-% tuning of \pkg{colortbl}. That's why we propose another method to highlight a
+% 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|.
+% equal to |multiply|.
%
% \tikzset{highlight/.style={rectangle,
% fill=red!15,
@@ -3318,28 +3594,91 @@ version 2005/12/01 or later.
% the rules even if \pkg{colortbl} is not loaded.
% \begin{macrocode}
\cs_set_protected:Npn \CT@arc@ { }
- \NewDocumentCommand { \arrayrulecolor } { m }
- { \tl_gset:Nn \CT@arc@ { \color { #1 } } }
-% \end{macrocode}
-% The following line are from the redefinition of |\hline| of standard LaTeX by
-% \pkg{colortbl} (\pkg{array} does not redefine |\hline|).
-% \begin{macrocode}
+ \cs_set:Npn \arrayrulecolor #1 # { \CT@arc { #1 } }
+ \cs_set:Npn \CT@arc #1 #2
+ {
+ \dim_compare:nNnT \baselineskip = \c_zero_dim \noalign
+ { \cs_gset:Npn \CT@arc@ { \color #1 { #2 } } }
+ }
\cs_set:Npn \hline
{
\noalign { \ifnum 0 = `} \fi
- \let \hskip \vskip
- \let \vrule \hrule
- \let \@width \@height
+ \cs_set_eq:NN \hskip \vskip
+ \cs_set_eq:NN \vrule \hrule
+ \cs_set_eq:NN \@width \@height
{ \CT@arc@ \vline }
\futurelet \reserved@a
\@xhline
}
}
+ }
+% \end{macrocode}
+%
+% \bigskip
+% We have to redefine |\cline| for several reasons. The command |\@@_cline| will
+% be linked to |\cline| in the beginning of |{NiceArrayWithDelims}|. The
+% following commands must \emph{not} be protected.
+% \begin{macrocode}
+\cs_set:Npn \@@_standard_cline #1 { \@@_standard_cline:w #1 \q_stop }
+\cs_set:Npn \@@_standard_cline:w #1-#2 \q_stop
+ {
+ \int_compare:nNnT \l_@@_first_col_int = 0 { \omit & }
+ \int_compare:nNnT { #1 } > 1 { \multispan { \@@_pred:n { #1 } } & }
+ \multispan { \int_eval:n { #2 - #1 + 1 } }
+ { \CT@arc@ \leaders \hrule \@height \arrayrulewidth \hfill }
+% \end{macrocode}
+% Our |\everycr| has been modified. In particular, the creation of the |row|
+% node is in the |\everycr| (maybe we should put it with the incrementation of
+% |\c@iRow|). Since the following |\cr| correspond to a ``false row'', we have
+% to nullify |\everycr|.
+% \begin{macrocode}
+ \everycr { }
+ \cr
+ \noalign { \skip_vertical:N -\arrayrulewidth }
}
% \end{macrocode}
%
% \bigskip
-% The following command are only for efficiency. It must \emph{not} be protected
+% The following version of |\cline| spreads the array of a quantity equal
+% to |\arrayrulewidth| as does |\hline|. It will be loaded except if the key
+% |standard-cline| has been used.
+% \begin{macrocode}
+\cs_set:Npn \@@_cline
+% \end{macrocode}
+% We have to act in a fully expandable way since there may be |\noalign| (in the
+% |\multispan|) to detect. That's why we use |\exp_arg:Ne| and not |\exp_arg:Nx|.
+% \begin{macrocode}
+ { \exp_args:Ne \@@_cline_i:nn \l_@@_first_col_int }
+% \end{macrocode}
+% The command |\cline_i:nn| has two arguments. The first is the number of the
+% current column (it \emph{must} be used in that column). The second is a
+% standard argument of |\cline| of the form \textsl{i}-\textsl{j}.
+% \begin{macrocode}
+\cs_set:Npn \@@_cline_i:nn #1 #2 { \@@_cline_i:w #1-#2 \q_stop }
+\cs_set:Npn \@@_cline_i:w #1-#2-#3 \q_stop
+ {
+% \end{macrocode}
+% Now, |#1| is the number of the current column and we have to draw a line from
+% the column |#2| to the column |#3| (both included).
+% \begin{macrocode}
+ \int_compare:nNnT { #1 } < { #2 }
+ { \multispan { \int_eval:n { #2 - #1 } } & }
+ \multispan { \int_eval:n { #3 - #2 + 1 } }
+ { \CT@arc@ \leaders \hrule \@height \arrayrulewidth \hfill }
+% \end{macrocode}
+% You look whether there is another |\cline| to draw (the final user may put
+% several |\cline|).
+% \begin{macrocode}
+ \peek_meaning_remove_ignore_spaces:NTF \cline
+ { & \exp_args:Ne \@@_cline_i:nn { \@@_succ:n { #3 } } }
+ { \everycr { } \cr }
+ }
+
+
+% \end{macrocode}
+%
+% \bigskip
+% The following commands are only for efficiency. It must \emph{not} be protected
% because it will be used (for instance) in names of \textsc{pgf} nodes.
% \begin{macrocode}
\cs_new:Npn \@@_succ:n #1 { \the \numexpr #1 + 1 \relax }
@@ -3347,6 +3686,23 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
+% The following command is a small shortcut.
+% \begin{macrocode}
+\cs_new:Npn \@@_math_toggle_token:
+ { \bool_if:NF \l_@@_NiceTabular_bool \c_math_toggle_token }
+% \end{macrocode}
+%
+% \bigskip
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_set_CT@arc@:
+ { \peek_meaning:NTF [ \@@_set_CT@arc@_i: \@@_set_CT@arc@_ii: }
+\cs_new_protected:Npn \@@_set_CT@arc@_i: [ #1 ] #2 \q_stop
+ { \cs_set:Npn \CT@arc@ { \color [ #1 ] { #2 } } }
+\cs_new_protected:Npn \@@_set_CT@arc@_ii: #1 \q_stop
+ { \cs_set:Npn \CT@arc@ { \color { #1 } } }
+% \end{macrocode}
+%
+% \bigskip
% \textbf{The column S of siunitx}\par\nobreak
%
% \medskip
@@ -3486,6 +3842,20 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
+% The command |\NiceMatrixLastEnv| is not used by the package \pkg{nicematrix}.
+% It's only a facility given to the final user. It gives the number of the last
+% environment (in fact the number of the current environment but it's meant to
+% be used after the environment in order to refer to that environment --- and
+% its nodes --- without having to give it a name). This command \emph{must} be
+% expandable since it will be used in \pkg{pgf} nodes.
+% \begin{macrocode}
+\NewExpandableDocumentCommand \NiceMatrixLastEnv { }
+ { \int_use:N \g_@@_env_int }
+% \end{macrocode}
+%
+%
+%
+% \bigskip
% The following command is only a syntaxic shortcut. The |q| in |qpoint| means
% \emph{quick}.
% \begin{macrocode}
@@ -3525,11 +3895,8 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% If the user uses |{NiceArray}| (and not another environment relying upon
-% |{NiceArrayWithDelims}| like |{pNiceArray}|), we will raise the flag
-% |\l_@@_NiceArray_bool|. We have to know that, because, in |{NiceArray}|, we
-% won't use a structure with |\left| and |\right| and we will use the option of
-% position (|t|, |b| or |c|).
+% If the user uses |{NiceArray}| or |{NiceTabular}| the flag
+% |\l_@@_NiceArray_bool| will be raised.
% \begin{macrocode}
\bool_new:N \l_@@_NiceArray_bool
% \end{macrocode}
@@ -3615,7 +3982,14 @@ version 2005/12/01 or later.
%
% The TeX counters |\c@iRow| and |\c@jCol| will be created in the beginning of
% |{NiceArrayWithDelims}| (if they don't exist previously).
-%
+%
+% \bigskip
+% The following token list corresponds to the key |rules/color| available
+% in the environments.
+% \begin{macrocode}
+\tl_new:N \l_@@_rules_color_tl
+% \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
@@ -3676,6 +4050,42 @@ version 2005/12/01 or later.
\dim_new:N \g_@@_width_first_col_dim
% \end{macrocode}
%
+% \bigskip
+% The following sequence will contain the caracteristics of the blocks of the
+% array, specified by the command |\Block|. Each block is represented by 6
+% components surrounded by braces:
+%
+% |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}{|\textsl{options}|}{|\textsl{contents}|}|.
+%
+% The variable is global because it will be modified in the cells of the array.
+% \begin{macrocode}
+\seq_new:N \g_@@_blocks_seq
+% \end{macrocode}
+% We also manage a sequence of the \emph{positions} of the blocks. Of course,
+% it's redundant with the previous sequence, but it's for efficiency. In that
+% sequence, each block is represented by only the four first components:
+% |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}|.
+% \begin{macrocode}
+\seq_new:N \g_@@_pos_of_blocks_seq
+% \end{macrocode}
+% The sequence |\g_@@_pos_of_blocks_seq| will be used by the test of
+% non-overlapping of two blocks and when we will draw the rules required by the
+% key |hvlines| (these rules won't be drawn within the blocks).
+%
+% \bigskip
+% We will also manage a sequence for the positions of the dotted lines. These
+% dotted lines are created in the array by |\Cdots|, |\Vdots|, |\Ddots|, etc.
+% However, their positions, that is to say, their extremities, will be
+% determined only after the construction of the array. In this sequence, each
+% item contains four components:
+% |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}|.
+% \begin{macrocode}
+\seq_new:N \g_@@_pos_of_xdots_seq
+% \end{macrocode}
+% The sequence |\g_@@_pos_of_xdots_seq| will be used when we will draw the rules
+% required by the key |hvlines| (these rules won't be drawn within the virtual
+% blocks corresponding to the dotted lines).
+%
%
% \bigskip
% \textbf{Variables for the exterior rows and columns}\par\nobreak
@@ -3841,7 +4251,15 @@ version 2005/12/01 or later.
% \bigskip
% \subsection*{The options}
%
+% By default, the behaviour of |\cline| is changed in the environments of
+% \pkg{nicematrix}: a |\cline| spreads the array by an amount equal to
+% |\arrayrulewidht|. It's possible to disable this feature with the key
+% |\l_@@_standard_line_bool|.
+% \begin{macrocode}
+\bool_new:N \l_@@_standard_cline_bool
+% \end{macrocode}
%
+% \bigskip
% The following dimensions correspond to the options |cell-space-top-limit| and co
% (these parameters are inspired by the package \pkg{cellspace}).
% \begin{macrocode}
@@ -3922,11 +4340,15 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% The flag |\l_@@_hlines_bool| corresponds to the option |\hlines| and the flag
-% |\l_@@_vlines_bool| to the option |\vlines|.
+% The flag |\l_@@_hlines_bool| corresponds to the key |hlines|, the flag
+% |\l_@@_vlines_bool| to the key |vlines| and the flag |hvlines| to the key
+% |hvlines|. Since version 4.1, the key |hvlines| is no longer a mere alias for
+% the conjonction of |hlines| and |vlines|. Indeed, with |hvlines|, the vertical
+% and horizontal rules are \emph{not} drawn within the blocks (created by |\Block|).
% \begin{macrocode}
\bool_new:N \l_@@_hlines_bool
\bool_new:N \l_@@_vlines_bool
+\bool_new:N \l_@@_hvlines_bool
% \end{macrocode}
%
% \bigskip
@@ -4052,8 +4474,20 @@ version 2005/12/01 or later.
%
%
% \begin{macrocode}
+\keys_define:nn { NiceMatrix / rules }
+ {
+ color .tl_set:N = \l_@@_rules_color_tl ,
+ color .value_required:n = true ,
+ width .dim_set:N = \arrayrulewidth ,
+ width .value_required:n = true
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
\keys_define:nn { NiceMatrix / Global }
{
+ standard-cline .bool_set:N = \l_@@_standard_cline_bool ,
+ standard-cline .default:n = true ,
cell-space-top-limit .dim_set:N = \l_@@_cell_space_top_limit_dim ,
cell-space-top-limit .value_required:n = true ,
cell-space-bottom-limit .dim_set:N = \l_@@_cell_space_bottom_limit_dim ,
@@ -4078,7 +4512,12 @@ version 2005/12/01 or later.
code-for-last-row .value_required:n = true ,
hlines .bool_set:N = \l_@@_hlines_bool ,
vlines .bool_set:N = \l_@@_vlines_bool ,
- hvlines .meta:n = { hlines , vlines } ,
+ hvlines .code:n =
+ {
+ \bool_set_true:N \l_@@_hvlines_bool
+ \bool_set_true:N \l_@@_vlines_bool
+ \bool_set_true:N \l_@@_hlines_bool
+ } ,
parallelize-diags .bool_set:N = \l_@@_parallelize_diags_bool ,
% \end{macrocode}
%
@@ -4175,24 +4614,28 @@ version 2005/12/01 or later.
NiceMatrix / Env ,
} ,
NiceMatrix / xdots .inherit:n = NiceMatrix / xdots ,
+ NiceMatrix / rules .inherit:n = NiceMatrix / rules ,
NiceTabular .inherit:n =
{
NiceMatrix / Global ,
NiceMatrix / Env
} ,
NiceTabular / xdots .inherit:n = NiceMatrix / xdots ,
+ NiceTabular / rules .inherit:n = NiceMatrix / rules ,
NiceArray .inherit:n =
{
NiceMatrix / Global ,
NiceMatrix / Env ,
} ,
NiceArray / xdots .inherit:n = NiceMatrix / xdots ,
+ NiceArray / rules .inherit:n = NiceMatrix / rules ,
pNiceArray .inherit:n =
{
NiceMatrix / Global ,
NiceMatrix / Env ,
} ,
- pNiceArray / xdots .inherit:n = NiceMatrix / xdots
+ pNiceArray / xdots .inherit:n = NiceMatrix / xdots ,
+ pNiceArray / rules .inherit:n = NiceMatrix / rules ,
}
% \end{macrocode}
%
@@ -4358,6 +4801,9 @@ version 2005/12/01 or later.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / NiceTabular }
{
+ last-col .code:n = \tl_if_empty:nF {#1}
+ { \@@_error:n { last-col~non~empty~for~NiceArray } }
+ \int_zero:N \l_@@_last_col_int ,
unknown .code:n = \@@_error:n { Unknown~option~for~NiceTabular }
}
% \end{macrocode}
@@ -4480,7 +4926,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_end_Cell:
{
- \bool_if:NF \l_@@_NiceTabular_bool \c_math_toggle_token
+ \@@_math_toggle_token:
\hbox_set_end:
% \end{macrocode}
%
@@ -4712,7 +5158,8 @@ version 2005/12/01 or later.
{
\@@_create_row_node:
% \end{macrocode}
-% We add the potential horizontal lines specified by the option |hlines|.
+% We don't draw the rules of the key |hlines| (or |hvlines|) but we reserve the
+% vertical space for theses rules.
% \begin{macrocode}
\bool_if:NT \l_@@_hlines_bool
{
@@ -4730,7 +5177,7 @@ version 2005/12/01 or later.
% \pkg{colortbl} is not loaded. We use a TeX group in order to limit the scope
% of |\CT@arc@|.
% \begin{macrocode}
- { { \CT@arc@ \hrule height \arrayrulewidth } }
+ { \hrule height \arrayrulewidth width \c_zero_dim }
}
}
}
@@ -4895,6 +5342,9 @@ version 2005/12/01 or later.
\cs_set_eq:NN \@@_old_iddots \iddots
\cs_set_eq:NN \firsthline \hline
\cs_set_eq:NN \lasthline \hline
+ \bool_if:NTF \l_@@_standard_cline_bool
+ { \cs_set_eq:NN \cline \@@_standard_cline }
+ { \cs_set_eq:NN \cline \@@_cline }
\cs_set_eq:NN \Ldots \@@_Ldots
\cs_set_eq:NN \Cdots \@@_Cdots
\cs_set_eq:NN \Vdots \@@_Vdots
@@ -4910,7 +5360,7 @@ version 2005/12/01 or later.
\cs_set_eq:NN \OnlyMainNiceMatrix \@@_OnlyMainNiceMatrix:n
\cs_set_eq:NN \dotfill \@@_dotfill:
\cs_set_eq:NN \CodeAfter \@@_CodeAfter:n
- \cs_set_eq:NN \slashbox \@@_slashbox:nn
+ \cs_set_eq:NN \diagbox \@@_diagbox:nn
\bool_if:NT \l_@@_renew_dots_bool
{
\cs_set_eq:NN \ldots \@@_Ldots
@@ -5123,9 +5573,19 @@ version 2005/12/01 or later.
\bool_if:NT \l_@@_in_env_bool { \@@_fatal:n { Yet~in~env } }
\bool_set_true:N \l_@@_in_env_bool
% \end{macrocode}
+% The command |\CT@arc@| contains the instruction of color for the rules of the
+% array\footnote{e.g. |\color[rgb]{0.5,0.5,0}|)}. This command is used by |\CT@arc@| but
+% we use it also for compatibility with \pkg{colortbl}. But we want also to be
+% able to use color for the rules of the array when \pkg{colortbl} is \emph{not}
+% loaded. That's why we do the following instruction which is in the patch of
+% the beginning of arrays done by \pkg{colortbl}. Of course, we restore the
+% value of |\CT@arc@| at the end of our environment.
+% \begin{macrocode}
+ \cs_gset_eq:NN \@@_old_CT@arc@ \CT@arc@
+% \end{macrocode}
%
-% We deactivate Tikz externalization because we will use \textsc{pgf} pictures with the
-% options |overlay| and |remember picture| (or equivalent forms).
+% We deactivate Tikz externalization because we will use \textsc{pgf} pictures
+% with the options |overlay| and |remember picture| (or equivalent forms).
% \begin{macrocode}
\cs_if_exist:NT \tikz@library@external@loaded
{
@@ -5151,7 +5611,16 @@ version 2005/12/01 or later.
\cs_set_protected:Npn \@arrayrule { \@addtopreamble \@@_vline: }
% \end{macrocode}
%
-%
+% The sequence |\g_@@_blocks_seq| will contain the carateristics of the blocks
+% (specified by |\Block|) of the array. The sequence |\g_@@_pos_of_blocks_seq|
+% will contain only the position of the blocks. Of course, this is redundant but
+% it's for efficiency.
+% \begin{macrocode}
+ \seq_clear:N \g_@@_blocks_seq
+ \seq_clear:N \g_@@_pos_of_blocks_seq
+% \end{macrocode}
+%
+%
% The set of keys is not exactly the same for |{NiceArray}| and for the variants
% of |{NiceArray}| (|{pNiceArray}|, |{bNiceArray}|, etc.) because, for
% |{NiceArray}|, we have the options |t|, |c|, |b| and |baseline|.
@@ -5161,7 +5630,13 @@ version 2005/12/01 or later.
{ \keys_set:nn { NiceMatrix / pNiceArray } }
{ #3 , #5 }
% \end{macrocode}
-%
+%
+% \bigskip
+% \begin{macrocode}
+ \tl_if_empty:NF \l_@@_rules_color_tl
+ { \exp_after:wN \@@_set_CT@arc@: \l_@@_rules_color_tl \q_stop }
+% \end{macrocode}
+%
% \bigskip
% If the key |code-before| is used, we have to create the |col| nodes and the
% |row| nodes before the creation of the array. First, we have to test whether
@@ -5228,21 +5703,18 @@ version 2005/12/01 or later.
\group_begin:
\bool_if:NT \c_@@_tikz_loaded_bool
{
-% \end{macrocode}
-% Be careful: we must \emph{not} put ``|remember picture|'' in the |\pgfset|.
-% \begin{macrocode}
- \pgfset
+ \tikzset
{
every~picture / .style =
- { overlay , name~prefix = \@@_env: - }
+ { overlay , name~prefix = \@@_env: - }
}
- }
- \cs_set_eq:NN \cellcolor \@@_cellcolor:nn
- \cs_set_eq:NN \rectanglecolor \@@_rectanglecolor:nnn
- \cs_set_eq:NN \rowcolor \@@_rowcolor:nn
- \cs_set_eq:NN \rowcolors \@@_rowcolors:nnn
- \cs_set_eq:NN \columncolor \@@_columncolor:nn
- \cs_set_eq:NN \chessboardcolors \@@_chessboardcolors:nn
+ }
+ \cs_set_eq:NN \cellcolor \@@_cellcolor
+ \cs_set_eq:NN \rectanglecolor \@@_rectanglecolor
+ \cs_set_eq:NN \rowcolor \@@_rowcolor
+ \cs_set_eq:NN \rowcolors \@@_rowcolors
+ \cs_set_eq:NN \columncolor \@@_columncolor
+ \cs_set_eq:NN \chessboardcolors \@@_chessboardcolors
% \end{macrocode}
% We compose the |code-before| in math mode in order to nullify the spaces put
% by the user between instructions in the |code-before|.
@@ -5745,7 +6217,7 @@ version 2005/12/01 or later.
{ \box_ht:N \l_tmpa_box + \box_dp:N \l_tmpa_box }
{ }
}
- \right .
+ \right .
\c_math_toggle_token
}
\dim_set:Nn \l_@@_real_left_delim_dim
@@ -6106,7 +6578,7 @@ version 2005/12/01 or later.
% have to compute some dimensions of this box.
% \begin{macrocode}
\hbox_set:Nw \l_@@_cell_box
- \bool_if:NF \l_@@_NiceTabular_bool \c_math_toggle_token
+ \@@_math_toggle_token:
\bool_if:NT \l_@@_small_bool \scriptstyle
% \end{macrocode}
% We insert |\l_@@_code_for_first_col_tl|... but we don't insert it in the
@@ -6131,7 +6603,7 @@ version 2005/12/01 or later.
l
<
{
- \bool_if:NF \l_@@_NiceTabular_bool \c_math_toggle_token
+ \@@_math_toggle_token:
\hbox_set_end:
\@@_update_for_first_and_last_row:
% \end{macrocode}
@@ -6178,7 +6650,7 @@ version 2005/12/01 or later.
% have to compute some dimensions of this box.
% \begin{macrocode}
\hbox_set:Nw \l_@@_cell_box
- \bool_if:NF \l_@@_NiceTabular_bool \c_math_toggle_token
+ \@@_math_toggle_token:
\bool_if:NT \l_@@_small_bool \scriptstyle
% \end{macrocode}
% We insert |\l_@@_code_for_last_col_tl|... but we don't insert it in the
@@ -6198,7 +6670,7 @@ version 2005/12/01 or later.
l
<
{
- \bool_if:NF \l_@@_NiceTabular_bool \c_math_toggle_token
+ \@@_math_toggle_token:
\hbox_set_end:
\@@_update_for_first_and_last_row:
% \end{macrocode}
@@ -6354,6 +6826,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\NewDocumentEnvironment { NiceTabular } { O { } m ! O { } }
{
+ \str_gset:Nn \g_@@_name_env_str { NiceTabular }
\keys_set:nn { NiceMatrix / NiceTabular } { #1 , #3 }
\bool_set_true:N \l_@@_NiceTabular_bool
\NiceArray { #2 }
@@ -6537,18 +7010,26 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
-%
% \bigskip
-% Now, we really draw the dotted lines.
+% Now, we actually draw the dotted lines.
% \begin{macrocode}
\@@_draw_dotted_lines:
% \end{macrocode}
%
-% We draw the vertical rules of the option |vlines| before the
-% |internal-code-after| because the option |white| of a |\Block| may have to
-% erase these vertical rules.
% \begin{macrocode}
- \bool_if:NT \l_@@_vlines_bool \@@_draw_vlines:
+ \bool_if:NTF \l_@@_hvlines_bool
+ \@@_draw_hvlines:
+ {
+ \bool_if:NT \l_@@_hlines_bool \@@_draw_hlines:
+ \bool_if:NT \l_@@_vlines_bool \@@_draw_vlines:
+ }
+% \end{macrocode}
+%
+% We have to revert to a clean version of |\ialign| because there may be
+% tabulars in the |\Block| instructions that will be composed now.
+% \begin{macrocode}
+ \cs_set_eq:NN \ialign \@@_old_ialign:
+ \seq_if_empty:NF \g_@@_blocks_seq \@@_draw_blocks:
\g_@@_internal_code_after_tl
\tl_gclear:N \g_@@_internal_code_after_tl
\bool_if:NT \c_@@_tikz_loaded_bool
@@ -6579,9 +7060,19 @@ version 2005/12/01 or later.
\group_end:
\str_gclear:N \g_@@_name_env_str
\@@_restore_iRow_jCol:
+% \end{macrocode}
+% The command |\CT@arc@| contains the instruction of color for the rules of the
+% array\footnote{e.g. |\color[rgb]{0.5,0.5,0}|)}. This command is used by
+% |\CT@arc@| but we use it also for compatibility with \pkg{colortbl}. But we
+% want also to be able to use color for the rules of the array when
+% \pkg{colortbl} is \emph{not} loaded. That's why we do the following
+% instruction which is in the patch of the end of arrays done by \pkg{colortbl}.
+% \begin{macrocode}
+ \cs_gset_eq:NN \CT@arc@ \@@_old_CT@arc@
}
% \end{macrocode}
%
+%
% \bigskip
% We recall that, when externalization is used, |\tikzpicture| and
% |\endtikzpicture| (or |\pgfpicture| and |\endpgfpicture|) must be directly
@@ -6625,7 +7116,10 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+%
% \bigskip
+% \subsection*{We draw the dotted lines}
+%
% A dotted line will be said \emph{open} in one of its extremities when it stops
% on the edge of the matrix and \emph{closed} otherwise. In the following
% matrix, the dotted line is closed on its left extremity and open on its right.
@@ -6847,6 +7341,21 @@ version 2005/12/01 or later.
}
}
}
+% \end{macrocode}
+% If the key |hvlines| is used, we remind the rectangle described by all the
+% dotted lines in order to respect the corresponding virtual ``block'' when
+% drawing the horizontal and vertical rules.
+% \begin{macrocode}
+ \bool_if:NT \l_@@_hvlines_bool
+ {
+ \seq_gput_right:Nx \g_@@_pos_of_xdots_seq
+ {
+ { \int_use:N \l_@@_initial_i_int }
+ { \int_use:N \l_@@_initial_j_int }
+ { \int_use:N \l_@@_final_i_int }
+ { \int_use:N \l_@@_final_j_int }
+ }
+ }
}
% \end{macrocode}
%
@@ -7354,17 +7863,6 @@ version 2005/12/01 or later.
%
%
% \bigskip
-% The command |\NiceMatrixLastEnv| is not used by the package \pkg{nicematrix}.
-% It's only a facility given to the final user. It gives the number of the last
-% environment (in fact the number of the current environment but it's meant to
-% be used after the environment in order to refer to that environment --- and
-% its nodes --- without having to give it a name).
-% \begin{macrocode}
-\NewExpandableDocumentCommand \NiceMatrixLastEnv { }
- { \int_use:N \g_@@_env_int }
-% \end{macrocode}
-%
-% \bigskip
% \subsection*{The actual instructions for drawing the dotted line with Tikz}
%
% The command |\@@_draw_line:| should be used in a |{pgfpicture}|. It has six
@@ -7653,23 +8151,19 @@ version 2005/12/01 or later.
% \begin{macrocode}
\AtBeginDocument
{
- \tl_set:Nn \l_@@_argspec_tl { s O { } E { _ ^ } { { } { } } }
+ \tl_set:Nn \l_@@_argspec_tl { O { } E { _ ^ } { { } { } } }
\tl_set_rescan:Nno \l_@@_argspec_tl { } \l_@@_argspec_tl
\exp_args:NNV \NewDocumentCommand \@@_Ldots \l_@@_argspec_tl
{
- \bool_if:nTF { #1 }
- { \@@_error:n { starred~commands } }
+ \int_compare:nNnTF \c@jCol = 0
+ { \@@_error:nn { in~first~col } \Ldots }
{
- \int_compare:nNnTF \c@jCol = 0
- { \@@_error:nn { in~first~col } \Ldots }
+ \int_compare:nNnTF \c@jCol = \l_@@_last_col_int
+ { \@@_error:nn { in~last~col } \Ldots }
{
- \int_compare:nNnTF \c@jCol = \l_@@_last_col_int
- { \@@_error:nn { in~last~col } \Ldots }
- {
- \@@_instruction_of_type:nn { Ldots }
- { #2 , down = #3 , up = #4 }
- }
- }
+ \@@_instruction_of_type:nn { Ldots }
+ { #1 , down = #2 , up = #3 }
+ }
}
\bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_ldots }
\bool_gset_true:N \g_@@_empty_cell_bool
@@ -7680,19 +8174,15 @@ version 2005/12/01 or later.
% \begin{macrocode}
\exp_args:NNV \NewDocumentCommand \@@_Cdots \l_@@_argspec_tl
{
- \bool_if:nTF { #1 }
- { \@@_error:n { starred~commands } }
+ \int_compare:nNnTF \c@jCol = 0
+ { \@@_error:nn { in~first~col } \Cdots }
{
- \int_compare:nNnTF \c@jCol = 0
- { \@@_error:nn { in~first~col } \Cdots }
+ \int_compare:nNnTF \c@jCol = \l_@@_last_col_int
+ { \@@_error:nn { in~last~col } \Cdots }
{
- \int_compare:nNnTF \c@jCol = \l_@@_last_col_int
- { \@@_error:nn { in~last~col } \Cdots }
- {
- \@@_instruction_of_type:nn { Cdots }
- { #2 , down = #3 , up = #4 }
- }
- }
+ \@@_instruction_of_type:nn { Cdots }
+ { #1 , down = #2 , up = #3 }
+ }
}
\bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_cdots }
\bool_gset_true:N \g_@@_empty_cell_bool
@@ -7703,18 +8193,16 @@ version 2005/12/01 or later.
% \begin{macrocode}
\exp_args:NNV \NewDocumentCommand \@@_Vdots \l_@@_argspec_tl
{
- \bool_if:nTF { #1 }
- { \@@_error:n { starred~commands } }
- \int_compare:nNnTF \c@iRow = 0
- { \@@_error:nn { in~first~row } \Vdots }
+ \int_compare:nNnTF \c@iRow = 0
+ { \@@_error:nn { in~first~row } \Vdots }
+ {
+ \int_compare:nNnTF \c@iRow = \l_@@_last_row_int
+ { \@@_error:nn { in~last~row } \Vdots }
{
- \int_compare:nNnTF \c@iRow = \l_@@_last_row_int
- { \@@_error:nn { in~last~row } \Vdots }
- {
- \@@_instruction_of_type:nn { Vdots }
- { #2 , down = #3 , up = #4 }
- }
- }
+ \@@_instruction_of_type:nn { Vdots }
+ { #1 , down = #2 , up = #3 }
+ }
+ }
\bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_vdots }
\bool_gset_true:N \g_@@_empty_cell_bool
}
@@ -7724,27 +8212,23 @@ version 2005/12/01 or later.
% \begin{macrocode}
\exp_args:NNV \NewDocumentCommand \@@_Ddots \l_@@_argspec_tl
{
- \bool_if:nTF { #1 }
- { \@@_error:n { starred~commands } }
+ \int_case:nnF \c@iRow
+ {
+ 0 { \@@_error:nn { in~first~row } \Ddots }
+ \l_@@_last_row_int { \@@_error:nn { in~last~row } \Ddots }
+ }
{
- \int_case:nnF \c@iRow
+ \int_case:nnF \c@jCol
{
- 0 { \@@_error:nn { in~first~row } \Ddots }
- \l_@@_last_row_int { \@@_error:nn { in~last~row } \Ddots }
+ 0 { \@@_error:nn { in~first~col } \Ddots }
+ \l_@@_last_col_int { \@@_error:nn { in~last~col } \Ddots }
}
- {
- \int_case:nnF \c@jCol
- {
- 0 { \@@_error:nn { in~first~col } \Ddots }
- \l_@@_last_col_int { \@@_error:nn { in~last~col } \Ddots }
- }
- {
- \@@_instruction_of_type:nn { Ddots }
- { #2 , down = #3 , up = #4 }
- }
+ {
+ \@@_instruction_of_type:nn { Ddots }
+ { #1 , down = #2 , up = #3 }
+ }
- }
- }
+ }
\bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_ddots }
\bool_gset_true:N \g_@@_empty_cell_bool
}
@@ -7754,27 +8238,23 @@ version 2005/12/01 or later.
% \begin{macrocode}
\exp_args:NNV \NewDocumentCommand \@@_Iddots \l_@@_argspec_tl
{
- \bool_if:nTF { #1 }
- { \@@_error:n { starred~commands } }
+ \int_case:nnF \c@iRow
+ {
+ 0 { \@@_error:nn { in~first~row } \Iddots }
+ \l_@@_last_row_int { \@@_error:nn { in~last~row } \Iddots }
+ }
{
- \int_case:nnF \c@iRow
+ \int_case:nnF \c@jCol
{
- 0 { \@@_error:nn { in~first~row } \Iddots }
- \l_@@_last_row_int { \@@_error:nn { in~last~row } \Iddots }
+ 0 { \@@_error:nn { in~first~col } \Iddots }
+ \l_@@_last_col_int { \@@_error:nn { in~last~col } \Iddots }
}
- {
- \int_case:nnF \c@jCol
- {
- 0 { \@@_error:nn { in~first~col } \Iddots }
- \l_@@_last_col_int { \@@_error:nn { in~last~col } \Iddots }
- }
- {
- \@@_instruction_of_type:nn { Iddots }
- { #2 , down = #3 , up = #4 }
- }
+ {
+ \@@_instruction_of_type:nn { Iddots }
+ { #1 , down = #2 , up = #3 }
+ }
- }
- }
+ }
\bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_iddots }
\bool_gset_true:N \g_@@_empty_cell_bool
}
@@ -7803,13 +8283,26 @@ version 2005/12/01 or later.
\cs_new:Npn \@@_multicolumn:nnn #1 #2 #3
{
\@@_old_multicolumn { #1 } { #2 } { #3 }
- \int_compare:nNnT #1 > 1
+% \end{macrocode}
+% The |\peek_remove_spaces:n| is mandatory.
+% \begin{macrocode}
+ \peek_remove_spaces:n
{
- \seq_gput_left:Nx \g_@@_multicolumn_cells_seq
- { \int_use:N \c@iRow - \int_use:N \c@jCol }
- \seq_gput_left:Nn \g_@@_multicolumn_sizes_seq { #1 }
- }
- \int_gadd:Nn \c@jCol { #1 - 1 }
+ \int_compare:nNnT #1 > 1
+ {
+ \seq_gput_left:Nx \g_@@_multicolumn_cells_seq
+ { \int_use:N \c@iRow - \int_use:N \c@jCol }
+ \seq_gput_left:Nn \g_@@_multicolumn_sizes_seq { #1 }
+ \seq_gput_right:Nx \g_@@_pos_of_blocks_seq
+ {
+ { \int_use:N \c@iRow }
+ { \int_use:N \c@jCol }
+ { \int_use:N \c@iRow }
+ { \int_eval:n { \c@jCol + #1 - 1 } }
+ }
+ }
+ \int_gadd:Nn \c@jCol { #1 - 1 }
+ }
}
% \end{macrocode}
%
@@ -8044,14 +8537,20 @@ version 2005/12/01 or later.
% The command |\@@_rotate:| will be linked to |\rotate| in
% |{NiceArrayWithDelims}|.
%
-% The command will exit three levels of groups in order
+% 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: { \group_insert_after:N \@@_rotate_i: }
+\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:
@@ -8196,21 +8695,25 @@ version 2005/12/01 or later.
%
%
% \bigskip
-% Here an example : |\@@_rowcolor:nn {red!15} {1,3,5-7,10-}|
+% Here an example : |\@@_rowcolor {red!15} {1,3,5-7,10-}|
% \begin{macrocode}
-\cs_new_protected:Npn \@@_rowcolor:nn #1 #2
+\NewDocumentCommand \@@_rowcolor { O { } m m }
{
- \tl_if_blank:nF { #1 }
+ \tl_if_blank:nF { #2 }
{
\pgfpicture
\pgf@relevantforpicturesizefalse
- \pgfsetfillcolor { #1 }
+ \tl_if_empty:nTF { #1 } \color { \color [ #1 ] } { #2 }
% \end{macrocode}
-% |\l_tmpa_dim| is the $x$-value of the left side of the rows.
+% |\l_tmpa_dim| is the $x$-value of the right side of the rows.
% \begin{macrocode}
+ \@@_qpoint:n { col - 1}
+ \int_compare:nNnTF \l_@@_first_col_int = 0
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x + 0.5 \arrayrulewidth } }
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } }
\@@_qpoint:n { col - \@@_succ:n \c@jCol }
- \dim_set_eq:NN \l_tmpa_dim \pgf@x
- \clist_map_inline:nn { #2 }
+ \dim_set:Nn \l_tmpa_dim { \pgf@x + 0.5 \arrayrulewidth }
+ \clist_map_inline:nn { #3 }
{
\tl_set:Nn \l_tmpa_tl { ##1 }
\tl_if_in:NnTF \l_tmpa_tl { - }
@@ -8225,9 +8728,12 @@ version 2005/12/01 or later.
% Now, the numbers of both rows are in |\l_tmpa_tl| and |\l_tmpb_tl|.
% \begin{macrocode}
\@@_qpoint:n { row - \@@_succ:n \l_tmpb_tl }
+ \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth }
+ \@@_qpoint:n { row - \l_tmpa_tl }
+ \dim_set:Nn \l_tmpd_dim { \pgf@y + 0.5 \arrayrulewidth }
\pgfpathrectanglecorners
- { \@@_qpoint:n { row - \l_tmpa_tl } }
- { \pgfpoint \l_tmpa_dim \pgf@y }
+ { \pgfpoint \l_tmpc_dim \l_tmpd_dim }
+ { \pgfpoint \l_tmpa_dim \l_tmpb_dim }
}
\pgfusepathqfill
\endpgfpicture
@@ -8238,22 +8744,22 @@ version 2005/12/01 or later.
% \bigskip
% Here an example : |\@@_columncolor:nn {red!15} {1,3,5-7,10-}|
% \begin{macrocode}
-\cs_new_protected:Npn \@@_columncolor:nn #1 #2
+\NewDocumentCommand \@@_columncolor { O { } m m }
{
- \tl_if_blank:nF { #1 }
+ \tl_if_blank:nF { #2 }
{
\pgfpicture
\pgf@relevantforpicturesizefalse
- \pgfsetfillcolor { #1 }
+ \tl_if_empty:nTF { #1 } \color { \color [ #1 ] } { #2 }
\@@_qpoint:n { row - 1 }
% \end{macrocode}
% |\l_tmpa_dim| is the $y$-value of the top of the columns et |\l_tmpb_dim| is
% the $y$-value of the bottom.
% \begin{macrocode}
- \dim_set_eq:NN \l_tmpa_dim \pgf@y
+ \dim_set:Nn \l_tmpa_dim {\pgf@y + 0.5 \arrayrulewidth }
\@@_qpoint:n { row - \@@_succ:n \c@iRow }
- \dim_set_eq:NN \l_tmpb_dim \pgf@y
- \clist_map_inline:nn { #2 }
+ \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth }
+ \clist_map_inline:nn { #3 }
{
\tl_set:Nn \l_tmpa_tl { ##1 }
\tl_if_in:NnTF \l_tmpa_tl { - }
@@ -8268,11 +8774,14 @@ version 2005/12/01 or later.
% Now, the numbers of both columns are in |\l_tmpa_tl| and |\l_tmpb_tl|.
% \begin{macrocode}
\@@_qpoint:n { col - \l_tmpa_tl }
- \dim_set_eq:NN \l_tmpc_dim \pgf@x
+ \int_compare:nNnTF \l_@@_first_col_int = \l_tmpa_tl
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } }
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x + 0.5 \arrayrulewidth } }
\@@_qpoint:n { col - \@@_succ:n \l_tmpb_tl }
+ \dim_set:Nn \l_tmpd_dim { \pgf@x + 0.5 \arrayrulewidth }
\pgfpathrectanglecorners
{ \pgfpoint \l_tmpc_dim \l_tmpa_dim }
- { \pgfpoint \pgf@x \l_tmpb_dim }
+ { \pgfpoint \l_tmpd_dim \l_tmpb_dim }
}
\pgfusepathqfill
\endpgfpicture
@@ -8281,16 +8790,16 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% Here an example : |\@@_cellcolor:nn {red!15}{2-3,3-4,4-5,5-6}|
+% Here an example : |\@@_cellcolor[rgb]{0.5,0.5,0}{2-3,3-4,4-5,5-6}|
% \begin{macrocode}
-\cs_new_protected:Npn \@@_cellcolor:nn #1 #2
+\NewDocumentCommand \@@_cellcolor { O { } m m }
{
- \tl_if_blank:nF { #1 }
+ \tl_if_blank:nF { #2 }
{
\pgfpicture
\pgf@relevantforpicturesizefalse
- \pgfsetfillcolor { #1 }
- \clist_map_inline:nn { #2 }
+ \tl_if_empty:nTF { #1 } \color { \color [ #1 ] } { #2 }
+ \clist_map_inline:nn { #3 }
{
\@@_cut_on_hyphen:w ##1 \q_stop
\@@_qpoint:n { row - \l_tmpa_tl }
@@ -8298,13 +8807,15 @@ version 2005/12/01 or later.
{ \int_compare_p:n { \l_tmpa_tl <= \c@iRow } }
{ \int_compare_p:n { \l_tmpb_tl <= \c@jCol } }
{
- \dim_set_eq:NN \l_tmpb_dim \pgf@y
+ \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth }
\@@_qpoint:n { row - \@@_succ:n \l_tmpa_tl }
- \dim_set_eq:NN \l_tmpa_dim \pgf@y
+ \dim_set:Nn \l_tmpa_dim { \pgf@y + 0.5 \arrayrulewidth }
\@@_qpoint:n { col - \l_tmpb_tl }
- \dim_set_eq:NN \l_tmpc_dim \pgf@x
+ \int_compare:nNnTF \l_@@_first_col_int = \l_tmpb_tl
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } }
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x + 0.5 \arrayrulewidth } }
\@@_qpoint:n { col - \@@_succ:n \l_tmpb_tl }
- \dim_set_eq:NN \l_tmpd_dim \pgf@x
+ \dim_set:Nn \l_tmpd_dim { \pgf@x + 0.5 \arrayrulewidth }
\pgfpathrectanglecorners
{ \pgfpoint \l_tmpc_dim \l_tmpb_dim }
{ \pgfpoint \l_tmpd_dim \l_tmpa_dim }
@@ -8312,38 +8823,40 @@ version 2005/12/01 or later.
}
\pgfusepathqfill
\endpgfpicture
- }
+ }
}
% \end{macrocode}
%
% \bigskip
-% Here an example : |\@@_rectanglecolor:nn {red!15}{2-3}{5-6}|
+% Here an example : |\@@_rectanglecolor{red!15}{2-3}{5-6}|
% \begin{macrocode}
-\cs_new_protected:Npn \@@_rectanglecolor:nnn #1 #2 #3
+\NewDocumentCommand \@@_rectanglecolor { O { } m m m }
{
- \tl_if_blank:nF { #1 }
+ \tl_if_blank:nF { #2 }
{
\pgfpicture
\pgf@relevantforpicturesizefalse
- \pgfsetfillcolor { #1 }
- \@@_cut_on_hyphen:w #2 \q_stop
+ \tl_if_empty:nTF { #1 } \color { \color [ #1 ] } { #2 }
+ \@@_cut_on_hyphen:w #3 \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_eq:NN \l_tmpb_dim \pgf@y
+ \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \arrayrulewidth }
\@@_qpoint:n { col - \l_tmpb_tl }
- \@@_cut_on_hyphen:w #3 \q_stop
+ \int_compare:nNnTF \l_@@_first_col_int = \l_tmpb_tl
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x - 0.5 \arrayrulewidth } }
+ { \dim_set:Nn \l_tmpc_dim { \pgf@x + 0.5 \arrayrulewidth } }
+ \@@_cut_on_hyphen:w #4 \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 } }
- \dim_set_eq:NN \l_tmpc_dim \pgf@x
\@@_qpoint:n { row - \@@_succ:n \l_tmpa_tl }
- \dim_set_eq:NN \l_tmpa_dim \pgf@y
+ \dim_set:Nn \l_tmpa_dim { \pgf@y + 0.5 \arrayrulewidth }
\@@_qpoint:n { col - \@@_succ:n \l_tmpb_tl }
- \dim_set_eq:NN \l_tmpd_dim \pgf@x
+ \dim_set:Nn \l_tmpd_dim { \pgf@x + 0.5 \arrayrulewidth }
\pgfpathrectanglecorners
{ \pgfpoint \l_tmpc_dim \l_tmpb_dim }
{ \pgfpoint \l_tmpd_dim \l_tmpa_dim }
@@ -8361,30 +8874,32 @@ version 2005/12/01 or later.
% However, the command |\rowcolors| of \pkg{nicematrix} has \emph{not} the
% optional argument of the command |\rowcolors| of \pkg{xcolor}.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_rowcolors:nnn #1 #2 #3
+\NewDocumentCommand \@@_rowcolors { O { } m m m }
{
- \int_step_inline:nnn { #1 } { \int_use:N \c@iRow }
+ \int_step_inline:nnn { #2 } { \int_use:N \c@iRow }
{
\int_if_odd:nTF { ##1 }
- { \@@_rowcolor:nn { #2 } { ##1 } }
- { \@@_rowcolor:nn { #3 } { ##1 } }
- }
+ { \@@_rowcolor [ #1 ] { #3 } }
+ { \@@_rowcolor [ #1 ] { #4 } }
+ { ##1 }
+ }
}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
-\cs_new_protected:Npn \@@_chessboardcolors:nn #1 #2
+\NewDocumentCommand \@@_chessboardcolors { O { } m m }
{
\int_step_inline:nn { \int_use:N \c@iRow }
{
\int_step_inline:nn { \int_use:N \c@jCol }
{
\int_if_even:nTF { ####1 + ##1 }
- { \@@_cellcolor:nn { #1 } { ####1 - ##1 } }
- { \@@_cellcolor:nn { #2 } { ####1 - ##1 } }
+ { \@@_cellcolor [ #1 ] { #2 } }
+ { \@@_cellcolor [ #1 ] { #3 } }
+ { ##1 - ####1 }
}
- }
+ }
}
% \end{macrocode}
%
@@ -8500,10 +9015,8 @@ version 2005/12/01 or later.
% \begin{macrocode}
\@@_qpoint:n { row - 1 }
\dim_set_eq:NN \l_tmpa_dim \pgf@y
- \pgfusepathqfill
\@@_qpoint:n { row - \@@_succ:n \c@iRow }
\dim_sub:Nn \l_tmpa_dim \pgf@y
- \pgfusepathqfill
% \end{macrocode}
% We translate vertically to take into account the potential ``last row''.
% \begin{macrocode}
@@ -8516,7 +9029,7 @@ version 2005/12/01 or later.
% We adjust the value of |\l_tmpa_dim| by the width of the horizontal rule just
% before the ``last row''.
% \begin{macrocode}
- \@@_qpoint:n { row - \@@_succ:n\c@iRow }
+ \@@_qpoint:n { row - \@@_succ:n \c@iRow }
\dim_add:Nn \l_tmpa_dim \pgf@y
\@@_qpoint:n { row - \@@_succ:n \g_@@_row_total_int }
\dim_sub:Nn \l_tmpa_dim \pgf@y
@@ -8546,6 +9059,223 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+%%
+% \subsection*{The key hvlines}
+%
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_draw_hlines:
+ {
+ \pgfpicture
+ \CT@arc@
+ \pgfrememberpicturepositiononpagetrue
+ \pgf@relevantforpicturesizefalse
+ \pgfsetlinewidth \arrayrulewidth
+ \int_step_inline:nnn
+ { \bool_if:NTF \l_@@_NiceArray_bool 1 2 }
+ { \bool_if:NTF \l_@@_NiceArray_bool { \@@_succ:n \c@iRow } \c@iRow }
+ {
+ \@@_qpoint:n { row - ##1 }
+ \dim_set_eq:NN \l_tmpa_dim \pgf@y
+ \pgfpathmoveto { \pgfpoint \pgf@x \pgf@y }
+ \@@_qpoint:n { col - \@@_succ:n { \c@jCol } }
+ \dim_set:Nn \l_tmpb_dim { \pgf@x + 0.5 \arrayrulewidth }
+ \pgfpathlineto { \pgfpoint \l_tmpb_dim \l_tmpa_dim }
+ }
+ \pgfusepathqstroke
+ \endpgfpicture
+ }
+% \end{macrocode}
+%
+% \bigskip
+% Since version 4.1, the key |hvlines| is no longer a mere alias for
+% the conjonction of |hlines| and |vlines|. Indeed, with |hvlines|, the vertical
+% and horizontal rules are \emph{not} drawn within the blocks (created by
+% |\Block|) nor within the ``virtual blocks'' (corresponding to the dotted lines
+% drawn by |\Cdots|, |\Vdots|, etc.).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_draw_hvlines:
+ {
+ \bool_lazy_and:nnTF
+ { \seq_if_empty_p:N \g_@@_pos_of_blocks_seq }
+ { \seq_if_empty_p:N \g_@@_pos_of_xdots_seq }
+ \@@_draw_hvlines_i:
+ \@@_draw_hvlines_ii:
+ }
+% \end{macrocode}
+%
+% \bigskip
+% This version is only for efficiency. The general case (in
+% |\@@_draw_hvlines_ii:|) does the job in all case (but slower).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_draw_hvlines_i:
+ {
+ \@@_draw_hlines:
+ \@@_draw_vlines:
+ }
+% \end{macrocode}
+%
+% \bigskip
+% Now, the general case, where there are blocks or dots in the array.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_draw_hvlines_ii:
+ {
+ \group_begin:
+ \CT@arc@
+% \end{macrocode}
+%
+% First, the exterior rectangle of the array (only in |{NiceArray}| and
+% |{NiceTabular}|).
+% \begin{macrocode}
+ \bool_if:NT \l_@@_NiceArray_bool
+ {
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgf@relevantforpicturesizefalse
+ \pgfsetlinewidth \arrayrulewidth
+ \pgfsetrectcap
+ \@@_qpoint:n { col - 1 }
+ \dim_set_eq:NN \l_tmpa_dim \pgf@x
+ \@@_qpoint:n { row -1 }
+ \dim_set_eq:NN \l_tmpb_dim \pgf@y
+ \@@_qpoint:n { col - \@@_succ:n \c@jCol }
+ \dim_set_eq:NN \l_tmpc_dim \pgf@x
+ \@@_qpoint:n { row - \@@_succ:n \c@iRow }
+ \pgfpathrectanglecorners
+ { \pgfpoint \l_tmpa_dim \l_tmpb_dim }
+ { \pgfpoint \l_tmpc_dim \pgf@y }
+ \pgfusepathqstroke
+ \endpgfpicture
+ }
+% \end{macrocode}
+%
+% First, the horizontal rules in the interior of the array.
+% \begin{macrocode}
+ \int_step_variable:nnNn 2 \c@iRow \l_tmpa_tl
+ {
+ \int_step_variable:nNn \c@jCol \l_tmpb_tl
+ {
+% \end{macrocode}
+% The boolean |\g_tmpa_bool| indicates whether the small horizontal rule will be
+% drawn. If we find that it is in a block (a real block, created by |\Block| or
+% a virtual block corresponding to a dotted line, created by |\Cdots|, |\Vdots|,
+% etc.), we will set |\g_tmpa_bool| to |false| and the small horizontal rule
+% won't be drawn.
+% \begin{macrocode}
+ \bool_gset_true:N \g_tmpa_bool
+ \seq_map_inline:Nn \g_@@_pos_of_blocks_seq
+ { \@@_test_if_hline_in_block:nnnn ##1 }
+ \seq_map_inline:Nn \g_@@_pos_of_xdots_seq
+ { \@@_test_if_hline_in_block:nnnn ##1 }
+ \bool_if:NT \g_tmpa_bool
+ {
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgf@relevantforpicturesizefalse
+ \pgfsetlinewidth \arrayrulewidth
+ \pgfsetrectcap
+ \@@_qpoint:n { row - \l_tmpa_tl }
+ \dim_set_eq:NN \l_tmpb_dim \pgf@y
+ \@@_qpoint:n { col - \l_tmpb_tl }
+ \dim_set_eq:NN \l_tmpa_dim \pgf@x
+ \@@_qpoint:n { col - \@@_succ:n \l_tmpb_tl }
+ \dim_set_eq:NN \l_tmpc_dim \pgf@x
+ \pgfpathmoveto { \pgfpoint \l_tmpa_dim \l_tmpb_dim }
+ \pgfpathlineto { \pgfpoint \l_tmpc_dim \l_tmpb_dim }
+ \pgfusepathqstroke
+ \endpgfpicture
+ }
+ }
+ }
+% \end{macrocode}
+% Now, the vertical rules in the interior of the array.
+% \begin{macrocode}
+ \int_step_variable:nNn \c@iRow \l_tmpa_tl
+ {
+ \int_step_variable:nnNn 2 \c@jCol \l_tmpb_tl
+ {
+% \end{macrocode}
+% The boolean |\g_tmpa_bool| indicates whether the small vertial rule will be
+% drawn. If we find that it is in a block (a real block, created by |\Block| or
+% a virtual block corresponding to a dotted line, created by |\Cdots|, |\Vdots|,
+% etc.), we will set |\g_tmpa_bool| to |false| and the small vertial rule won't
+% be drawn.
+% \begin{macrocode}
+ \bool_gset_true:N \g_tmpa_bool
+ \seq_map_inline:Nn \g_@@_pos_of_blocks_seq
+ { \@@_test_if_vline_in_block:nnnn ##1 }
+ \seq_map_inline:Nn \g_@@_pos_of_xdots_seq
+ { \@@_test_if_vline_in_block:nnnn ##1 }
+ \bool_if:NT \g_tmpa_bool
+ {
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgf@relevantforpicturesizefalse
+ \pgfsetlinewidth \arrayrulewidth
+ \pgfsetrectcap
+ \@@_qpoint:n { row - \l_tmpa_tl }
+ \dim_set_eq:NN \l_tmpb_dim \pgf@y
+ \@@_qpoint:n { col - \l_tmpb_tl }
+ \dim_set_eq:NN \l_tmpa_dim \pgf@x
+ \@@_qpoint:n { row - \@@_succ:n \l_tmpa_tl }
+ \dim_set_eq:NN \l_tmpc_dim \pgf@y
+ \pgfpathmoveto { \pgfpoint \l_tmpa_dim \l_tmpb_dim }
+ \pgfpathlineto { \pgfpoint \l_tmpa_dim \l_tmpc_dim }
+ \pgfusepathqstroke
+ \endpgfpicture
+ }
+ }
+ }
+% \end{macrocode}
+% The group was for the color of the rules.
+% \begin{macrocode}
+ \group_end:
+ \seq_gclear:N \g_@@_pos_of_xdots_seq
+ }
+% \end{macrocode}
+%
+% The following command tests wether the current position in the array (given by
+% |\l_tmpa_tl| for the row and |\l_tmpb_tl| for the col) would provide an
+% horizontal rule towards the right in the block delimited by the four arguments
+% |#1|, |#2|, |#3| and |#4|. If this rule would be in the block (it must not be
+% drawn), the boolean |\l_tmpa_bool| is set to |false|.
+% \begin{macrocode}
+\cs_set_protected:Npn \@@_test_if_hline_in_block:nnnn #1 #2 #3 #4
+ {
+ \int_compare:nNnT \l_tmpa_tl > { #1 }
+ {
+ \int_compare:nNnT \l_tmpa_tl < { #3 + 1 }
+ {
+ \int_compare:nNnT \l_tmpb_tl > { #2 - 1 }
+ {
+ \int_compare:nNnT \l_tmpb_tl < { #4 + 1 }
+ { \bool_gset_false:N \g_tmpa_bool }
+ }
+ }
+ }
+ }
+% \end{macrocode}
+%
+% The same for vertical rules.
+% \begin{macrocode}
+\cs_set_protected:Npn \@@_test_if_vline_in_block:nnnn #1 #2 #3 #4
+ {
+ \int_compare:nNnT \l_tmpa_tl > { #1 - 1 }
+ {
+ \int_compare:nNnT \l_tmpa_tl < { #3 + 1 }
+ {
+ \int_compare:nNnT \l_tmpb_tl > { #2 }
+ {
+ \int_compare:nNnT \l_tmpb_tl < { #4 + 1 }
+ { \bool_gset_false:N \g_tmpa_bool }
+ }
+ }
+ }
+ }
+% \end{macrocode}
+%
+%
+%
%
% \bigskip
% \subsection*{The commands to draw dotted lines to separate columns and rows}
@@ -9211,54 +9941,63 @@ version 2005/12/01 or later.
\cs_new_protected:Npn \@@_Block_ii:nnnnn #1 #2 #3 #4 #5
{
% \end{macrocode}
-% We write an instruction in the |code-after|. We write the instruction in the
-% beginning of the |code-after| (the |left| in |\tl_gput_left:Nx|) because we
-% want the Tikz nodes corresponding of the block created \emph{before} potential
-% instructions written by the user in the |code-after| (these instructions may
-% use the Tikz node of the created block).
+%
+% \medskip
% \begin{macrocode}
- \tl_gput_left:Nx \g_@@_internal_code_after_tl
+ \tl_set:Nx \l_tmpa_tl
{
- \@@_Block_iii: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 } }
- { #3 }
- \exp_not:n { { #4 $ #5 $ } }
- }
+ }
% \end{macrocode}
-% It's not allowed to use the command |\Block| twice in the same cell of the
-% array. That's why, at the first use, we link the command |\Block|
-% to a special version. The scope of this link is the cell of the array.
+% Now, |\l_tmpa_tl| constains a ``object'' corresponding to the position of the
+% block whith four components surrounded by brackets:
+%
+% |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}|.
+%
+% We store this information in the sequence |\g_@@_pos_of_blocks_seq|.
% \begin{macrocode}
- \cs_set_eq:NN \Block \@@_Block_error:nn
- }
+ \seq_gput_left:NV \g_@@_pos_of_blocks_seq \l_tmpa_tl
% \end{macrocode}
+% We also store a complete description of the block in the sequence
+% |\g_@@_blocks_seq|. Of course, the sequences |\g_@@_pos_of_blocks_seq| and
+% |\g_@@_blocks_seq| are redundant, but it's for efficiency. In
+% |\g_@@_blocks_seq|, each block is represented by an ``objet'' with six
+% components:
%
+% |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}{|\textsl{options}|}{|\textsl{contents}|}|.
% \begin{macrocode}
-\cs_new:Npn \@@_Block_error:nn #1 #2
- {
- \@@_error:n { Second~Block }
- \cs_set_eq:NN \Block \use:nn
+ \seq_gput_left:Nx \g_@@_blocks_seq
+ {
+ \l_tmpa_tl
+ { #3 }
+ \exp_not:n { { #4 \@@_math_toggle_token: #5 \@@_math_toggle_token: } }
+ }
}
% \end{macrocode}
+%
%
-% \medskip
+% \bigskip
+% The key |tikz| is for Tikz options used when the \textsc{pgf} node of the
+% block is created.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / Block }
{
tikz .tl_set:N = \l_@@_tikz_tl ,
tikz .value_required:n = true ,
- white .bool_set:N = \l_@@_white_bool ,
- white .default:n = true ,
- white .value_forbidden:n = true ,
}
% \end{macrocode}
%
+% \bigskip
+% The command |\@@_draw_blocks:| will draw all the blocks. This command is used
+% after the construction of the array.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_draw_blocks:
+ { \seq_map_inline:Nn \g_@@_blocks_seq { \@@_Block_iii:nnnnnn ##1 } }
+% \end{macrocode}
%
-% \medskip
-% The following command |\@@_Block_iii:nnnnnn| will be used in the |code-after|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_Block_iii:nnnnnn #1 #2 #3 #4 #5 #6
{
@@ -9270,11 +10009,9 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \begin{macrocode}
- \bool_if:nTF
- {
- \int_compare_p:nNn { #3 } > \c@iRow
- || \int_compare_p:nNn { #4 } > \c@jCol
- }
+ \bool_lazy_or:nnTF
+ { \int_compare_p:nNn { #3 } > \c@iRow }
+ { \int_compare_p:nNn { #4 } > \c@jCol }
{ \msg_error:nnnn { nicematrix } { Block~too~large } { #1 } { #2 } }
{
% \end{macrocode}
@@ -9299,33 +10036,6 @@ version 2005/12/01 or later.
\@@_qpoint:n { col - \@@_succ:n { #4 } }
\dim_set_eq:NN \l_tmpd_dim \pgf@x
% \end{macrocode}
-%
-% \medskip
-% The following code doesn't work for the first vertical rule. You should allow
-% the option |white| if and only if the option |vlines| and |hlines| has been used.
-% \begin{macrocode}
- \bool_if:NT \l_@@_white_bool
- {
- \begin { pgfscope }
- \pgfsetfillcolor { white }
-% \end{macrocode}
-%
-% \begin{macrocode}
- \pgfpathrectanglecorners
- {
- \pgfpoint
- { \l_tmpb_dim + 0.5 \arrayrulewidth }
- { \l_tmpa_dim - 0.5 \arrayrulewidth }
- }
- {
- \pgfpoint
- { \l_tmpd_dim - 0.5 \arrayrulewidth }
- { \l_tmpc_dim + 0.5 \arrayrulewidth }
- }
- \pgfusepathqfill
- \end { pgfscope }
- }
-% \end{macrocode}
%
% We construct the node for the block with the name |(#1-#2-block)|.
%
@@ -9510,7 +10220,9 @@ version 2005/12/01 or later.
% case of use of |\dotfill| ``internally'' in the cell (e.g. |\hbox to 1cm {\dotfill}|).
% \begin{macrocode}
\@@_dotfill
- \group_insert_after:N \@@_dotfill_i:
+ \bool_if:NT \l_@@_NiceTabular_bool
+ { \group_insert_after:N \@@_dotfill_ii: }
+ { \group_insert_after:N \@@_dotfill_i: }
}
\cs_new_protected:Npn \@@_dotfill_i: { \group_insert_after:N \@@_dotfill_ii: }
\cs_new_protected:Npn \@@_dotfill_ii: { \group_insert_after:N \@@_dotfill_iii: }
@@ -9518,32 +10230,32 @@ version 2005/12/01 or later.
% Now, if the box if not empty (unfornately, we can't actually test whether the
% box is empty and that's why we only consider it's width), we insert
% |\@@_dotfill| (which is the saved version of |\dotfill|) in the cell of the
-% array, and it will extends, since it's no longer in |\l_@@_cell_box|.
+% array, and it will extend, since it is no longer in |\l_@@_cell_box|.
% \begin{macrocode}
\cs_new_protected:Npn \@@_dotfill_iii:
{ \dim_compare:nNnT { \box_wd:N \l_@@_cell_box } = \c_zero_dim \@@_dotfill }
% \end{macrocode}
%
-% \subsection*{The command \textbackslash slashbox}
+% \subsection*{The command \textbackslash diagbox}
%
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_slashbox:nn #1 #2
+\cs_new_protected:Npn \@@_diagbox:nn #1 #2
{
\tl_gput_right:Nx \g_@@_internal_code_after_tl
{
- \@@_actually_slashbox:nnnn
+ \@@_actually_diagbox:nnnn
{ \int_use:N \c@iRow } { \int_use:N \c@jCol } { #1 } { #2 }
}
}
% \end{macrocode}
%
% \medskip
-% The two arguments of |\@@_actually_slashbox:nn| are the number of row and the
+% The two arguments of |\@@_actually_diagbox:nn| are the number of row and the
% number of column of the cell to slash. The two other are the elements to draw
% below and above the diagonal line.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_actually_slashbox:nnnn #1 #2 #3 #4
+\cs_new_protected:Npn \@@_actually_diagbox:nnnn #1 #2 #3 #4
{
\pgfpicture
\pgf@relevantforpicturesizefalse
@@ -9571,10 +10283,12 @@ version 2005/12/01 or later.
\pgfset { inner~sep = 1 pt }
\pgfscope
\pgftransformshift { \pgfpoint \l_tmpb_dim \l_tmpc_dim }
- \pgfnode { rectangle } { south~west } { $ #3 $ } { } { }
+ \pgfnode { rectangle } { south~west }
+ { \@@_math_toggle_token: #3 \@@_math_toggle_token: } { } { }
\endpgfscope
\pgftransformshift { \pgfpoint \l_tmpd_dim \l_tmpa_dim }
- \pgfnode { rectangle } { north~east } { $ #4 $ } { } { }
+ \pgfnode { rectangle } { north~east }
+ { \@@_math_toggle_token: #4 \@@_math_toggle_token: } { } { }
\endpgfpicture
}
% \end{macrocode}
@@ -9621,21 +10335,12 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+%
%
% \bigskip
-% \subsection*{We process the options}
+% \subsection*{We process the options at package loading}
%
%
-% \begin{macrocode}
-\@@_msg_new:nn { obsolete~environments }
- {
- The~obsolete~environments~(eg.~{pNiceArrayC})~have~been~deleted~
- from~the~package~nicematrix.\\
- However,~if~you~still~want~to~use~them,~you~will~find~the~code~for~
- those~environments~at~the~end~of~the~file~'nicematrix.sty',~after~
- a~command~'\token_to_str:N\file_input_stop:'.
- }
-% \end{macrocode}
%
% We process the options when the package is loaded (with |\usepackage|) but we
% recommend to use |\NiceMatrixOptions| instead.
@@ -9655,11 +10360,6 @@ version 2005/12/01 or later.
renew-matrix .value_forbidden:n = true ,
transparent .meta:n = { renew-dots , renew-matrix } ,
transparent .value_forbidden:n = true,
- obsolete-environments .code:n = \@@_fatal:n { obsolete~environments },
- starred-commands .code:n =
- \@@_msg_redirect_name:nn { starred~commands } { none } ,
- starred-commands .value_forbidden:n = true ,
-
}
\ProcessKeysOptions { NiceMatrix / Package }
% \end{macrocode}
@@ -9798,6 +10498,7 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+%
% \begin{macrocode}
\@@_msg_new:nn { option~S~without~siunitx }
{
@@ -9841,16 +10542,14 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
-% \begin{macrocode}
-\@@_msg_new:nn { starred~commands }
+% \begin{macrocode}
+\@@_msg_new:nn { standard-cline~in~document }
{
- The~starred~versions~of~\token_to_str:N \Cdots,~\token_to_str:N \Ldots,~
- \token_to_str:N \Vdots,~\token_to_str:N\Ddots\ and~\token_to_str:N\Iddots\
- are~deprecated.~However,~you~can~go~on~for~this~time.~If~you~don't~want~to~
- see~this~error~we~should~load~'nicematrix'~with~the~option~
- 'starred-commands'.
+ The~key~'standard-cline'~is~available~only~in~the~preamble.\\
+ If~you~go~on~this~command~will~be~ignored.
}
% \end{macrocode}
+%
%
% \begin{macrocode}
\@@_msg_new:nn { bad~value~for~baseline }
@@ -9862,14 +10561,6 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
-%
-% \begin{macrocode}
-\@@_msg_new:nn { Second~Block }
- {
- You~can't~use~\token_to_str:N \Block\ twice~in~the~same~cell~of~the~array.\\
- If~you~go~on,~this~command~(and~the~other)~will~be~ignored.
- }
-% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { empty~environment }
@@ -9896,6 +10587,7 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+%
% \begin{macrocode}
\@@_msg_new:nn { last-col~non~empty~for~NiceMatrixOptions }
{
@@ -9961,7 +10653,7 @@ version 2005/12/01 or later.
The~key~'\tl_use:N\l_keys_key_str'~is~unknown~for~the~command~
\token_to_str:N \NiceMatrixOptions. \\
If~you~go~on,~it~will~be~ignored. \\
- For~a~list~of~the~available~keys,~type~H~<return>.
+ For~a~list~of~the~*principal*~available~keys,~type~H~<return>.
}
{
The~available~options~are~(in~alphabetic~order):~
@@ -9976,7 +10668,6 @@ version 2005/12/01 or later.
create-medium-nodes,~
create-large-nodes,~
end-of-row,~
- exterior-arraycolsep,~
first-col,~
first-row,~
hlines,~
@@ -9987,7 +10678,6 @@ version 2005/12/01 or later.
letter-for-dotted-lines,~
light-syntax,~
nullify-dots,~
- parallelize-diags,~
renew-dots,~
renew-matrix,~
right-margin,~
@@ -10006,7 +10696,7 @@ version 2005/12/01 or later.
The~option~'\tl_use:N\l_keys_key_str'~is~unknown~for~the~environment~
\{NiceArray\}. \\
If~you~go~on,~it~will~be~ignored. \\
- For~a~list~of~the~available~options,~type~H~<return>.
+ For~a~list~of~the~*principal*~available~options,~type~H~<return>.
}
{
The~available~options~are~(in~alphabetic~order):~
@@ -10024,7 +10714,6 @@ version 2005/12/01 or later.
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
- end-of-row,~
extra-left-margin,~
extra-right-margin,~
first-col,~
@@ -10037,9 +10726,10 @@ version 2005/12/01 or later.
light-syntax,~
name,~
nullify-dots,~
- parallelize-diags,~
renew-dots,~
right-margin,~
+ rules/color,~
+ rules/width,~
small,~
t,~
vlines,~
@@ -10059,7 +10749,7 @@ version 2005/12/01 or later.
The~option~'\tl_use:N\l_keys_key_str'~is~unknown~for~the~
\@@_full_name_env:. \\
If~you~go~on,~it~will~be~ignored. \\
- For~a~list~of~the~available~options,~type~H~<return>.
+ For~a~list~of~the~*principal*~available~options,~type~H~<return>.
}
{
The~available~options~are~(in~alphabetic~order):~
@@ -10077,7 +10767,6 @@ version 2005/12/01 or later.
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
- end-of-row,~
extra-left-margin,~
extra-right-margin,~
first-col,~
@@ -10091,10 +10780,11 @@ version 2005/12/01 or later.
light-syntax,~
name,~
nullify-dots,~
- parallelize-diags,~
r~(=R),~
renew-dots,~
right-margin,~
+ rules/color,~
+ rules/width,~
S,~
small,~
t,~
@@ -10111,7 +10801,7 @@ version 2005/12/01 or later.
The~option~'\tl_use:N\l_keys_key_str'~is~unknown~for~the~environment~
\{NiceTabular\}. \\
If~you~go~on,~it~will~be~ignored. \\
- For~a~list~of~the~available~options,~type~H~<return>.
+ For~a~list~of~the~*principal*~available~options,~type~H~<return>.
}
{
The~available~options~are~(in~alphabetic~order):~
@@ -10129,7 +10819,6 @@ version 2005/12/01 or later.
create-extra-nodes,~
create-medium-nodes,~
create-large-nodes,~
- end-of-row,~
extra-left-margin,~
extra-right-margin,~
first-col,~
@@ -10142,9 +10831,10 @@ version 2005/12/01 or later.
light-syntax,~
name,~
nullify-dots,~
- parallelize-diags,~
renew-dots,~
right-margin,~
+ rules/color,~
+ rules/width,~
t,~
vlines,~
xdots/color,~
@@ -10187,97 +10877,6 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
-%
-% \bigskip
-% \subsection*{Obsolete environments}
-%
-% The following environments are loaded only when the package \pkg{nicematrix}
-% has been loaded with the option |obsolete-environments|. However, they will be
-% completly deleted in a future version.
-%
-% \begin{macrocode}
-\file_input_stop:
-\NewDocumentEnvironment { pNiceArrayC } { }
- {
- \int_zero:N \l_@@_last_col_int
- \pNiceArray
- }
- { \endpNiceArray }
- \NewDocumentEnvironment { bNiceArrayC } { }
- {
- \int_zero:N \l_@@_last_col_int
- \bNiceArray
- }
- { \endbNiceArray }
-\NewDocumentEnvironment { BNiceArrayC } { }
- {
- \int_zero:N \l_@@_last_col_int
- \BNiceArray
- }
- { \endBNiceArray }
-\NewDocumentEnvironment { vNiceArrayC } { }
- {
- \int_zero:N \l_@@_last_col_int
- \vNiceArray
- }
- { \endvNiceArray }
-\NewDocumentEnvironment { VNiceArrayC } { }
- {
- \int_zero:N \l_@@_last_col_int
- \VNiceArray
- }
- { \endVNiceArray }
-\NewDocumentEnvironment { pNiceArrayRC } { }
- {
- \int_zero:N \l_@@_last_col_int
- \int_zero:N \l_@@_first_row_int
- \pNiceArray
- }
- { \endpNiceArray }
-\NewDocumentEnvironment { bNiceArrayRC } { }
- {
- \int_zero:N \l_@@_last_col_int
- \int_zero:N \l_@@_first_row_int
- \bNiceArray
- }
- { \endbNiceArray }
-\NewDocumentEnvironment { BNiceArrayRC } { }
- {
- \int_zero:N \l_@@_last_col_int
- \int_zero:N \l_@@_first_row_int
- \BNiceArray
- }
- { \endBNiceArray }
-\NewDocumentEnvironment { vNiceArrayRC } { }
- {
- \int_zero:N \l_@@_last_col_int
- \int_zero:N \l_@@_first_row_int
- \vNiceArray
- }
- { \endvNiceArray }
-\NewDocumentEnvironment { VNiceArrayRC } { }
- {
- \int_zero:N \l_@@_last_col_int
- \int_zero:N \l_@@_first_row_int
- \VNiceArray
- }
- { \endVNiceArray }
-\NewDocumentEnvironment { NiceArrayCwithDelims } { }
- {
- \int_zero:N \l_@@_last_col_int
- \NiceArrayWithDelims
- }
- { \endNiceArrayWithDelims }
-\NewDocumentEnvironment { NiceArrayRCwithDelims } { }
- {
- \int_zero:N \l_@@_last_col_int
- \int_zero:N \l_@@_first_row_int
- \NiceArrayWithDelims
- }
- { \endNiceArrayWithDelims }
-% \end{macrocode}
-%
-%
%
% \vspace{1cm}
% \section{History}
@@ -10576,6 +11175,14 @@ version 2005/12/01 or later.
%
% Commands to color cells, row and columns with a perfect result in the \textsc{pdf}.
%
+% \subsection*{Changes between versions 4.0 and 4.1}
+%
+% New keys |cell-space-top-limit| and |cell-space-bottom-limit|
+%
+% New command |\diagbox|
+%
+% The key |hvline| don't draw rules in the blocks (commands |\Block|) and in the
+% virtual blocks corresponding to the dotted lines.
%
% \PrintIndex
%