From 78510518401cc9b3aced4cf291ecb7730591091d Mon Sep 17 00:00:00 2001
From: Norbert Preining <norbert@preining.info>
Date: Wed, 11 Aug 2021 03:00:54 +0000
Subject: CTAN sync 202108110300

---
 macros/latex/contrib/nicematrix/nicematrix.dtx | 1105 ++++++++++++++++--------
 1 file changed, 746 insertions(+), 359 deletions(-)

(limited to 'macros/latex/contrib/nicematrix/nicematrix.dtx')

diff --git a/macros/latex/contrib/nicematrix/nicematrix.dtx b/macros/latex/contrib/nicematrix/nicematrix.dtx
index 095a776390..f2ecb695bc 100644
--- a/macros/latex/contrib/nicematrix/nicematrix.dtx
+++ b/macros/latex/contrib/nicematrix/nicematrix.dtx
@@ -15,8 +15,8 @@
 %
 % \fi
 % \iffalse
-\def\myfileversion{5.19}
-\def\myfiledate{2021/07/23}
+\def\myfileversion{6.0}
+\def\myfiledate{2021/08/10}
 %
 %
 %<*batchfile>
@@ -188,7 +188,7 @@ version 2005/12/01 or later.
 % 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
+% 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}.\footnote{If you use Overleaf, Overleaf will do automatically
 % the right number of compilations.}
@@ -250,18 +250,6 @@ version 2005/12/01 or later.
 % brackets, an optional list of \textsl{key=value} pairs. \textbf{There must be
 % no space before the opening bracket (|[|) of this list of options.}
 %
-%\bigskip
-% \textbf{Important}\par\nobreak
-%
-% Before the version 5.0, it was mandatory to use, for technical reasons, the 
-% letters |L|, |C| et |R| instead of |l|, |c| et |r| in the preambles of the
-% environments of \pkg{nicematrix}. If we want to be able to go on using these
-% letters, \pkg{nicematrix} must be loaded with the option |define-L-C-R|.
-% \begin{Verbatim}
-% \usepackage[define-L-C-R]{nicematrix}
-% \end{Verbatim}
-% \textbf{This key will probably be deleted in a future version of
-% \pkg{nicematrix}.} 
 %
 % \section{The vertical space between the rows}
 %
@@ -633,6 +621,10 @@ version 2005/12/01 or later.
 % \item The natural width of the contents of these blocks is taken into account
 % for the width of the current column.
 %
+% \colorbox{yellow!50}{\textbf{New 6.0}}\enskip In the columns with a fixed
+% width (columns |w{...}{...}|, |p{...}|, |b{...}|, |m{...}| and |X|), the
+% content of the block is formatted as a paragraph of that width.
+%
 % \item The specification of the horizontal position provided by the type of
 % column (|c|, |r| or |l|) is taken into account for the blocks.
 %
@@ -1313,9 +1305,9 @@ version 2005/12/01 or later.
 %
 % New commands are available in that |\CodeBefore|: |\cellcolor|,
 % |\rectanglecolor|, |\rowcolor|, |\columncolor|, |\rowcolors|,
-% |\chessboardcolors| and |arraycolor|.\footnote{Remark that, in the
-% \verb|\CodeBefore|, PGF/Tikz nodes of the form ``\verb+(i-|j)+'' are also
-% available to indicate the position to the potential rules:
+% |\rowlistcolors|, |\chessboardcolors| and |arraycolor|.\footnote{Remark that,
+% in the \verb|\CodeBefore|, PGF/Tikz nodes of the form ``\verb+(i-|j)+'' are
+% also available to indicate the position to the potential rules:
 % cf.~p.~\pageref{nodes-i}.}
 % \label{code-before}
 %
@@ -1582,19 +1574,58 @@ version 2005/12/01 or later.
 % \end{scope}
 %
 %
+%
+%
+% \bigskip
+% \item \colorbox{yellow!50}{\textbf{New 6.0}}\enskip The extension
+% \pkg{nicematrix} provides also a command |\rowlistcolors|. This command
+% generalises the command |\rowcolors|: instead of two successive arguments for
+% the colors, this command takes in an argument which is a (comma-separated)
+% list of colors. In that list, the symbol |=| represent a color identical to
+% the previous one.
+% \end{itemize}
+%
+% \smallskip
+% \begin{BVerbatim}[boxwidth=10cm,baseline=c]
+% \begin{NiceTabular}{c}
+% \CodeBefore
+%   ~emphase#\rowlistcolors{1}{red!15,blue!15,green!15}@
+% \Body
+% Peter \\
+% James \\
+% Abigail \\
+% Elisabeth \\
+% Claudius \\
+% Jane \\
+% Alexandra \\
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \begin{NiceTabular}{c}
+% \CodeBefore
+%   \rowlistcolors{1}{red!15,blue!15,green!15}
+% \Body
+% Peter \\
+% James \\
+% Abigail \\
+% Elisabeth \\
+% Claudius \\
+% Jane \\
+% Alexandra \\
+% \end{NiceTabular}
+%
+%
 % \medskip
 % We recall that all the color commands we have described don't color the cells
 % which are in the ``corners''. In the following example, we use the key
 % |corners| to require the determination of the corner \emph{north east} (NE).
 %
-%
 %\medskip
 % \begin{scope}
 % \hfuzz=11cm
 % \begin{BVerbatim}[boxwidth=9cm,baseline=c]
 % \begin{NiceTabular}{cccccc}[~emphase#corners=NE@,margin,hvlines,first-row,first-col]
 % \CodeBefore
-%   ~emphase#\rowcolors{1}{blue!15}{}@
+%   ~emphase#\rowlistcolors{1}{blue!15, }@
 % \Body
 %   & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\
 % 0 & 1 \\
@@ -1608,7 +1639,7 @@ version 2005/12/01 or later.
 % \end{BVerbatim}
 % \begin{NiceTabular}{ccccccc}[corners=NE,margin,hvlines,first-row,first-col]
 % \CodeBefore
-%   \rowcolors{1}{blue!15}{}
+%   \rowlistcolors{1}{blue!15, }
 % \Body
 %   & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\
 % 0 & 1 \\
@@ -1621,8 +1652,6 @@ version 2005/12/01 or later.
 % \end{NiceTabular}
 % \end{scope}
 %
-% \end{itemize}
-%
 %
 % \bigskip
 % One should remark that all the previous commands are compatible with the
@@ -1765,9 +1794,11 @@ version 2005/12/01 or later.
 % \section{The width of the columns}
 % \label{width}
 %
+% \subsection{Basic tools}
+%
 % 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}. 
+% the standard letters |w|, |W|, |p|, |b| and |m| of the package \pkg{array}. 
 % 
 % \medskip
 % \begin{BVerbatim}[baseline=c,boxwidth=9cm]
@@ -1786,7 +1817,8 @@ version 2005/12/01 or later.
 %
 % \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|.
+% width of all the columns (excepted the potential exterior columns: cf. p.~\pageref{exterior}) directly
+% with the key |columns-width|. 
 % 
 % \medskip
 % \begin{BVerbatim}[baseline=c,boxwidth=10cm]
@@ -1812,7 +1844,7 @@ version 2005/12/01 or later.
 % 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 PGF/Tikz
-% will have written informations in the |.aux| file and a message requiring a
+% will have written informations in the |aux| file and a message requiring a
 % second compilation will appear).}\par\nobreak
 %
 % \medskip
@@ -1831,7 +1863,7 @@ version 2005/12/01 or later.
 % 
 % \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
+% the arrays of a current scope with the command
 % |\NiceMatrixOptions|.\par\nobreak
 %
 % \medskip
@@ -1892,13 +1924,57 @@ version 2005/12/01 or later.
 % \end{array}$
 % \end{NiceMatrixBlock}
 %
+% \subsection{The columns X}
+%
+% \colorbox{yellow!50}{\textbf{New 6.0}}
+%
+% The environment |{NiceTabular}| provides |X| columns similar to those provided
+% by the environment |{tabularx}| of the eponymous package.
+%
+% The required width of the tabular may be specified with the key |width|. The
+% initial value of this parameter is |\linewidth|.
+%
+% For sake of similarity with the environment |{tabularx}|, \pkg{nicematrix}
+% also provides an environment |{NiceTabularX}| with a first mandatory argument
+% which is the width of the tabular.
+%
+% As with the packages \pkg{tabu} and \pkg{tabularray}, the specifier |X| takes
+% in an optional argument (between square brackets) which is a list of keys.
+% \begin{itemize}
+% \item It's possible to give a weight for the column by providing an integer
+% directly as argument of the specifier |X|. For example, a column |X[2]| will
+% have a width double of the width of a column |X| (which has a weight equal to $1$).
+% \item It's possible to specify an horizontal alignment with one of the
+% letters |l|, |c| and |r| (which inserts respectively |\raggedright|,
+% |\centering| and |\raggedleft| followed by |\arraybackslash|).
+% \item It's possible to specify a vertical alignement with one of the keys
+% |t| (alias |p|), |m| and |b| (which construct respectively columns of type
+% |p|, |m| and |b|). The default value is |t|.
+% \end{itemize}
+% 
+% \begin{Verbatim}
+% \begin{NiceTabular}~emphase#[width=9cm]{X[2,l]X[l]}@[hvlines]
+% a rather long text which fits on several lines 
+% & a rather long text which fits on several lines \\
+% a shorter text & a shorter text
+% \end{NiceTabular}
+% \end{Verbatim}
+% 
+% \begin{center}
+% \begin{NiceTabular}[width=9cm]{X[2,l]X[l]}[hvlines]
+% a rather long text which fits on several lines 
+% & a rather long text which fits on several lines \\
+% a shorter text & a shorter text
+% \end{NiceTabular}
+% \end{center}
 % 
 % \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}. 
+% \pkg{nicematrix}. It's particularly interesting for the (methematical)
+% matrices. 
 % \label{exterior}
 %
 % A potential ``first row'' (exterior) has the number $0$ (and not $1$). Idem
@@ -2007,7 +2083,7 @@ version 2005/12/01 or later.
 % \emph{Remarks}
 % \begin{itemize}[beginpenalty=10000]
 % \item As shown in the previous example, the horizontal and vertical rules
-% doesn't extend in the exterior rows and columns.
+% don'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
@@ -2015,7 +2091,7 @@ version 2005/12/01 or later.
 % 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
+% a dotted line drawn in that 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
@@ -2053,7 +2129,7 @@ version 2005/12/01 or later.
 % horizontal line; for |\Vdots|, it's a vertical line and for |\Ddots| and
 % |\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
+% all these dotted lines with the option |xdots/color| (\textsl{xdots} to
 % remind that it works for |\Cdots|, |\Ldots|, |\Vdots|, etc.): cf. p.
 % \pageref{customisation}.}\par\nobreak  
 %
@@ -2513,10 +2589,11 @@ version 2005/12/01 or later.
 % 
 % The dotted lines determine virtual blocks which have the same behaviour
 % regarding the rules (the rules specified by the specifier \verb+|+ in the
-% preamble, by the command |\Hline| and by the keys |hlines|, |vlines| and
-% |hvlines| are not drawn within the blocks).\footnote{On the other side, the
-% command \verb|\line| in the \verb|\CodeAfter|
-% (cf.~p.~\pageref{line-in-code-after}) does \emph{not} create block.}
+% preamble, by the command |\Hline| and by the keys |hlines|, |vlines|,
+% |hvlines| and |hvlines-except-borders| are not drawn within the
+% blocks).\footnote{On the other side, the command \verb|\line| in the
+% \verb|\CodeAfter| (cf.~p.~\pageref{line-in-code-after}) does \emph{not} create
+% block.}
 %
 % \medskip
 % \begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
@@ -3140,14 +3217,14 @@ version 2005/12/01 or later.
 % \subsection{Use of \{NiceTabular\} with threeparttable}
 %
 %
-% If you wish to use the environment |{NiceTabular}| or |{NiceTabular*}| in an
-% environment |{threeparttable}| of the eponymous package, you have to patch the
-% environment |{threeparttable}| with the following code (with a version of
-% LaTeX at least 2020/10/01).
+% If you wish to use the environment |{NiceTabular}|, |{NiceTabular*}|
+% |{NiceTabularX}|in an environment |{threeparttable}| of the eponymous package,
+% you have to patch the environment |{threeparttable}| with the following code
+% (with a version of LaTeX at least 2020/10/01).
 % \begin{Verbatim}[commandchars=\~\#\!]
 % \makeatletter
 % \AddToHook{env/threeparttable/begin}
-%   {\TPT@hookin{NiceTabular}\TPT@hookin{NiceTabular*}}
+%   {\TPT@hookin{NiceTabular}\TPT@hookin{NiceTabular*}\TPT@hookin{NiceTabularX}}
 % \makeatother
 % \end{Verbatim}
 %
@@ -3373,8 +3450,7 @@ version 2005/12/01 or later.
 % These commands take in two mandatory arguments. The first is the format of the
 % matrix, with the syntax $n$-$p$ where $n$ is the number of rows and $p$ the
 % number of columns. The second argument is the pattern (it's a list of tokens
-% which are inserted in each cell of the constructed matrix, excepted in the
-% cells of the potential exterior rows and columns).
+% which are inserted in each cell of the constructed matrix).
 %
 % \medskip
 % \begin{Verbatim}
@@ -3953,9 +4029,11 @@ version 2005/12/01 or later.
 %
 % \medskip
 % These variables contain the code of what we have called the ``|code-before|''
-% and the ``|code-after|''. The developper can use them to add code from a cell
-% of the array (the affectation must be global, allowing to exit the cell, which
-% is a TeX group).
+% (usually specified at the beginning of the environment with the syntax using
+% the keywords |\CodeBefore| and |\Body|) and the ``|code-after|'' (usually
+% specified at the end of the environment after the keyword |\CodeAfter|). The
+% developper can use them to add code from a cell of the array (the affectation
+% must be global, allowing to exit the cell, which is a TeX group).
 %
 % \medskip
 % One should remark that the use of |\g_nicematrix_code_before_tl| needs one
@@ -3963,27 +4041,34 @@ version 2005/12/01 or later.
 % used during the next run).
 %
 % \bigskip
-% \emph{Example} : We want to write a command |\hatchcell| to hatch the current
-% cell (with an optional argument between brackets for the color). It's possible
-% to program such command |\hatchcell| as follows, explicitely using the public
-% variable |\g_nicematrix_code_before_tl| (this code requires the Tikz library
-% \pkg{patterns}: |\usetikzlibrary{patterns}|).
+% \emph{Example} : We want to write a command |\crossbox| to draw a cross in the
+% current cell. This command will take in an optional argument between square
+% brackets for a list of pairs \textsl{key}-\textsl{value} which will be given to
+% Tikz before the drawing.
 %
+% It's possible to program such command |\crossbox| as follows, explicitely
+% using the public variable |\g_nicematrix_code_after_tl|.
 %
 % \begin{scope}
 % \fvset{commandchars=\§\¤\μ}
 % \begin{Verbatim}
-%\ExplSyntaxOn
-% \cs_new_protected:Nn \__pantigny_hatch:nnn
+% \ExplSyntaxOn
+% \cs_new_protected:Nn \__pantigny_crossbox:nnn
 %   {
-%     \tikz \fill [ pattern = north~west~lines , pattern~color = #3 ]
-%        ( #1 -| #2) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ;
+%     \tikz \draw [ #3 ] 
+%           ( #1 -| \int_eval:n { #2 + 1 } ) -- ( \int_eval:n { #1 + 1 } -| #2 ) 
+%           ( #1 -| #2 ) -- ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ; 
 %   }
 %
-% \NewDocumentCommand \hatchcell { ! O { black } }
+% \NewDocumentCommand \crossbox { ! O { } }
 %   {
-%     \tl_gput_right:Nx §emphase¤\g_nicematrix_code_before_tlμ
-%       { \__pantigny_hatch:nnn { \arabic { iRow } } { \arabic { jCol } } { #1 } }
+%     \tl_gput_right:Nx §emphase¤\g_nicematrix_code_after_tlμ
+%       { 
+%         \__pantigny_crossbox:nnn 
+%           { \int_use:c { c@iRow } } 
+%           { \int_use:c { c@jCol } }
+%           { \exp_not:n { #1 } }
+%       }
 %   }
 % \ExplSyntaxOff
 % \end{Verbatim}
@@ -3991,38 +4076,45 @@ version 2005/12/01 or later.
 %
 %
 % \ExplSyntaxOn
-% \cs_new_protected:Nn \__pantigny_hatch:nnn
+% \cs_new_protected:Nn \__pantigny_crossbox:nnn
 %   {
-%     \tikz \fill [ pattern = north~west~lines , pattern~color = #3 ]
-%        ( #1 -| #2 ) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ;
+%     \tikz \draw [ #3 ] 
+%           ( #1 -| \int_eval:n { #2 + 1 } ) -- ( \int_eval:n { #1 + 1 } -| #2 ) 
+%           ( #1 -| #2 ) -- ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ; 
 %   }
 %
-% \NewDocumentCommand \hatchcell { ! O { black } }
+%
+% \NewDocumentCommand \crossbox { ! O { } }
 %   {
-%     \tl_gput_right:Nx \g_nicematrix_code_before_tl
-%       { \__pantigny_hatch:nnn { \arabic { iRow } } { \arabic { jCol } } { #1 } }
+%     \tl_gput_right:Nx \g_nicematrix_code_after_tl
+%       { 
+%         \__pantigny_crossbox:nnn 
+%           { \int_use:c { c@iRow } } 
+%           { \int_use:c { c@jCol } }
+%           { \exp_not:n { #1 } }
+%       }
 %   }
 % \ExplSyntaxOff
 %
-%
 % \bigskip
-% Here is an example of use:
+% Here is an example of utilisation:
 %
 % \medskip
 % \begin{BVerbatim}[baseline=c,boxwidth=9cm]
 % \begin{NiceTabular}{ccc}[hvlines]
-% Tokyo & Paris & London \\
-% Lima & ~emphase#\hatchcell[blue!30]@Oslo & Miami \\
-% Los Angeles & Madrid & Roma
+% merlan & requin & cabillaud \\
+% baleine & ~emphase#\crossbox[red]@ & morue \\
+% mante & raie & poule 
 % \end{NiceTabular}
 % \end{BVerbatim}
 % \begin{NiceTabular}{ccc}[hvlines]
-% Tokyo & Paris & London \\
-% Lima & \hatchcell[blue!30]Oslo & Miami \\
-% Los Angeles & Madrid & Roma
+% merlan & requin & cabillaud \\
+% baleine & \crossbox[red] & morue \\
+% mante & raie & poule 
 % \end{NiceTabular}
 %
 %
+%
 % \section{Technical remarks}
 % 
 % \subsection{Definition of new column types}
@@ -4076,7 +4168,7 @@ version 2005/12/01 or later.
 %
 % \label{parallelization}
 % By default, all the diagonal lines\footnote{We speak of the lines created by
-% |\Ddots| and not the lines created by a command |\line| in |code-after|.} of a
+% |\Ddots| and not the lines created by a command |\line| in the |\CodeAfter|.} of a
 % same array are ``parallelized''. That means that the first diagonal line is
 % drawn and, then, the other lines are drawn parallel to the first one (by
 % rotation around the left-most extremity of the line). That's why the position
@@ -4233,7 +4325,7 @@ version 2005/12/01 or later.
 % 
 %
 % \bigskip
-% the package \pkg{nicematrix} is not compatible with the class \cls{ieeeaccess}
+% The package \pkg{nicematrix} is not compatible with the class \cls{ieeeaccess}
 % (because that class is not compatible with PGF/Tikz).
 % 
 % \section{Examples}
@@ -4767,10 +4859,10 @@ 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 commands |\hline| and |\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}.}
+% We recall that, on the other side, the commands |\hline| and |\Hline|, the
+% specifier ``"|"'' and the options |hlines|, |vlines|, |hvlines| and
+% |hvlines-except-borders| spread the cells.\footnote{For the command |\cline|,
+% see the remark p.~\pageref{remark-cline}.}
 % 
 %
 % \vspace{1cm}
@@ -5255,9 +5347,7 @@ version 2005/12/01 or later.
 \AtBeginDocument 
   { 
     \@ifpackageloaded { colortbl }
-      { 
-        \bool_set_true:N \c_@@_colortbl_loaded_bool 
-      }
+      { \bool_set_true:N \c_@@_colortbl_loaded_bool }
       { 
 %    \end{macrocode}
 % The command |\CT@arc@| is a command of \pkg{colortbl} which sets the color of
@@ -5294,7 +5384,17 @@ version 2005/12/01 or later.
   } 
 %    \end{macrocode}
 % 
-%
+% \bigskip
+% We will use |\AtBeginEnvironment|. For version of LaTeX posterior to
+% 2020-10-01, the command is available in the LaTeX kernel (\pkg{l3hooks}). For
+% older versions, we load \pkg{etoolbox}.
+%    \begin{macrocode}
+\cs_if_exist:NF \AtBeginEnvironment { \RequirePackage { etoolbox } }
+%    \end{macrocode}
+% The command |\AtBeginDocument| will be used to patch |{tabular}| in order to
+% come back to the original versions of |\multicolumn| in the |{tabular}| nested
+% in the environments of \pkg{nicematrix}.
+% 
 % \bigskip 
 % We have to redefine |\cline| for several reasons. The command |\@@_cline| will
 % be linked to |\cline| in the beginning of |{NiceArrayWithDelims}|. The
@@ -5515,26 +5615,6 @@ version 2005/12/01 or later.
 % \subsection*{Parameters}
 %
 % \bigskip 
-% For compatibility with versions prior to 5.0, we provide a load-time option
-% |define_L_C_R|. With this option, it's possible to use the letters |L|, |C|
-% and |R| instead of |l|, |c| and |r| in the preamble of the environments of
-% \pkg{nicematrix} as it was mandatory before version~5.0. This key will
-% probably be deleted in a future version.
-%    \begin{macrocode}
-\bool_new:N \c_@@_define_L_C_R_bool
-%    \end{macrocode}
-%
-% 
-%    \begin{macrocode}
-\cs_new_protected:Npn \@@_define_L_C_R:
-  {
-    \newcolumntype L l
-    \newcolumntype C c
-    \newcolumntype R r
-  }
-%    \end{macrocode}
-% 
-% \bigskip 
 % The following counter will count the environments |{NiceArray}|. The value of
 % this counter will be used to prefix the names of the Tikz nodes created in the
 % array. 
@@ -5586,6 +5666,19 @@ version 2005/12/01 or later.
 %    \end{macrocode}
 %
 % \bigskip
+% The dimension |\l_@@_col_width_dim| will be available in each cell which
+% belongs to a column of fixed width: |w{...}{...}|, |W{...}{...}|, |p{}|,
+% |m{}|, |b{}| but also |X| (when the actual width of that column is known, that
+% is to say after the first compilation). It's the width of that column. It will
+% be used by some commands |\Block|. A non positive value means that the column
+% has no fixed width (it's a column of type |c|, |r|, |l|, etc.).
+%    \begin{macrocode}
+\dim_new:N \l_@@_col_width_dim 
+\dim_set:Nn \l_@@_col_width_dim { -1 cm }
+%    \end{macrocode}
+% 
+% 
+% \bigskip
 % The following counters will be used to count the numbers of rows and columns
 % of the array.
 %    \begin{macrocode}
@@ -5594,11 +5687,13 @@ version 2005/12/01 or later.
 %    \end{macrocode}
 % 
 % \bigskip
-% The following token list will contain the type of the current cell (|l|, |c|
-% or |r|). It will be used by the blocks.
+% The following token list will contain the type of horizontal alignment of the
+% current cell as provided by the corresponding column. The possible values are
+% |r|, |l|, |c|. For exemple, a column |p[l]{3cm}| will provide the value |l|
+% for all the cells of the column.
 %    \begin{macrocode}
-\tl_new:N \l_@@_cell_type_tl
-\tl_set:Nn \l_@@_cell_type_tl { c }
+\str_new:N \l_@@_hpos_cell_str
+\str_set:Nn \l_@@_hpos_cell_str { c }
 %    \end{macrocode}
 % 
 % \bigskip
@@ -5672,6 +5767,13 @@ version 2005/12/01 or later.
 %    \end{macrocode}
 %
 % \bigskip
+% In a cell, it will be possible to know whether we are in a cell of a column of
+% type |X| thanks to that flag.
+%    \begin{macrocode}
+\bool_new:N \l_@@_X_column_bool 
+%    \end{macrocode}
+% 
+% \bigskip
 % We will write in |\g_@@_aux_tl| all the instructions that we have to write on
 % the |aux| file for the current environment. The contain of that token list
 % will be written on the |aux| file at the end of the environment (in an
@@ -5786,16 +5888,19 @@ version 2005/12/01 or later.
 %    \end{macrocode}
 %
 % \bigskip
-% The number of letters |X| in the preamble of the array.
+% The sum of the weights of all the |X|-columns in the preamble. The weight of a
+% |X|-column is given as optional argument between square brackets. The default
+% value, of course, is $1$.
 %    \begin{macrocode}
-\int_new:N \g_@@_nb_of_X_int
+\int_new:N \g_@@_total_X_weight_int
 %    \end{macrocode}
 % 
 % If there is at least one |X|-column in the preamble of the array, the
 % following flag will be raised via the |aux| file. The length
-% |l_@@_x_columns_dim| will be the width of the |X|-columns. That value is
-% computed after the contruction of the array during the first compilation in
-% order to be used in the following run.
+% |l_@@_x_columns_dim| will be the width of |X|-columns of weight $1$ (the width
+% of a column of weigth $n$ will be that dimension multiplied by~$n$). That
+% value is computed after the construction of the array during the first
+% compilation in order to be used in the following run.
 %    \begin{macrocode}
 \bool_new:N \l_@@_X_columns_aux_bool
 \dim_new:N \l_@@_X_columns_dim
@@ -5947,7 +6052,14 @@ version 2005/12/01 or later.
 %    \begin{macrocode}
 \seq_new:N \g_@@_submatrix_names_seq
 %    \end{macrocode}
-%
+% 
+% \medskip
+% The following flag will be raised if the key |width| has been raised. You use
+% it to raise an error when this key is used while no column |X| is used.
+%    \begin{macrocode}
+\bool_new:N \l_@@_width_used_bool
+%    \end{macrocode}
+% 
 % \medskip
 % The sequence |\g_@@_multicolumn_cells_seq| will contain the list of the cells
 % of the array where a command |\multicolumn{|$n$|}{...}{...}| with $n>1$ is
@@ -6024,8 +6136,8 @@ version 2005/12/01 or later.
 % |\l_@@_hpos_of_block_cap_bool| will be raised (in the second pass of the
 % analyze of the keys of the command |\Block|).
 %    \begin{macrocode}
-\tl_new:N \l_@@_hpos_of_block_tl
-\tl_set:Nn \l_@@_hpos_of_block_tl { c }
+\str_new:N \l_@@_hpos_block_str
+\str_set:Nn \l_@@_hpos_block_str { c }
 \bool_new:N \l_@@_hpos_of_block_cap_bool
 %    \end{macrocode}
 %
@@ -6801,9 +6913,9 @@ version 2005/12/01 or later.
 %    \begin{macrocode}
 \keys_define:nn { NiceMatrix / Env } 
   { 
-    
 %    \end{macrocode}
-% The key |hvlines-except-corners| is now deprecated.
+% The key |hvlines-except-corners| is now deprecated (use |hvlines| and
+% |corners| instead).
 %    \begin{macrocode}
     hvlines-except-corners .code:n = 
       { 
@@ -7157,6 +7269,12 @@ version 2005/12/01 or later.
 %    \begin{macrocode}
 \keys_define:nn { NiceMatrix / NiceTabular }
   {
+%    \end{macrocode}
+%  The dimension |width| will be used if at least a column of type |X| is used.
+%    \begin{macrocode}
+    width .code:n = \dim_set:Nn \l_@@_width_dim { #1 } 
+                    \bool_set_true:N \l_@@_width_used_bool ,
+    width .value_required:n = true ,
     notes / para .bool_set:N = \l_@@_notes_para_bool ,
     notes / para .default:n = true ,
     notes / bottomrule .bool_set:N = \l_@@_notes_bottomrule_bool ,
@@ -7184,12 +7302,12 @@ version 2005/12/01 or later.
 \cs_new_protected:Npn \@@_Cell:
   { 
 %    \end{macrocode}
-% The token list |\g_@@_post_treatment_cell_tl| will be set during the
+% The token list |\g_@@_post_action_cell_tl| will be set during the
 % composition of the box |\l_@@_cell_box| and will be used \emph{after} the
 % composition in order to modify that box (that's why it's called a
-% \emph{post-treatment}). 
+% \emph{post-action}). 
 %    \begin{macrocode}
-    \tl_gclear:N \g_@@_post_treatment_cell_tl
+    \tl_gclear:N \g_@@_post_action_cell_tl
 %    \end{macrocode}
 % At the beginning of the cell, we link |\CodeAfter| to a command which do
 % \emph{not} begin with |\omit| (whereas the standard version of |\CodeAfter|
@@ -7349,11 +7467,11 @@ version 2005/12/01 or later.
     \@@_math_toggle_token: 
     \hbox_set_end:
 %    \end{macrocode}
-% The token list |\g_@@_post_treatment_cell_tl| is (potentially) set during the 
+% The token list |\g_@@_post_action_cell_tl| is (potentially) set during the 
 % composition of the box |\l_@@_cell_box| and is used now \emph{after} the
 % composition in order to modify that box.
 %    \begin{macrocode}
-    \g_@@_post_treatment_cell_tl
+    \g_@@_post_action_cell_tl
     \bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box:
     \@@_adjust_size_box:
 %    \end{macrocode}
@@ -7856,7 +7974,6 @@ version 2005/12/01 or later.
     \cs_set_eq:NN \Hspace \@@_Hspace:
     \cs_set_eq:NN \Hdotsfor \@@_Hdotsfor:
     \cs_set_eq:NN \Vdotsfor \@@_Vdotsfor:
-    \cs_set_eq:NN \multicolumn \@@_multicolumn:nnn
     \cs_set_eq:NN \Block \@@_Block:
     \cs_set_eq:NN \rotate \@@_rotate:
     \cs_set_eq:NN \OnlyMainNiceMatrix \@@_OnlyMainNiceMatrix:n
@@ -7868,6 +7985,18 @@ version 2005/12/01 or later.
     \bool_if:NT \l_@@_colortbl_like_bool \@@_colortbl_like:
     \bool_if:NT \l_@@_renew_dots_bool \@@_renew_dots:
 %    \end{macrocode}
+% We redefine |\multicolumn| and, since we want |\multicolumn| to be available
+% in the potential environments |{tabular}| nested in the environments of
+% \pkg{nicematrix}, we patch |{tabular}| to go back to the original definition.
+% The command |\AtBeginEnvironment| is the command of \pkg{l3hooks} and, if this
+% command is not available (versions of LaTeX prior to 2020-10-01),
+% \pkg{etoolbox} is loaded and the command |\AtBeginDocument| of \pkg{etoolbox}
+% is used.
+%    \begin{macrocode}
+    \cs_set_eq:NN \multicolumn \@@_multicolumn:nnn
+    \AtBeginEnvironment { tabular } 
+      { \cs_set_eq:NN \multicolumn \@@_old_multicolumn }
+%    \end{macrocode}
 % 
 %
 % The sequence |\g_@@_multicolumn_cells_seq| will contain the list of the cells
@@ -8029,14 +8158,6 @@ version 2005/12/01 or later.
     \box_clear_new:N \l_@@_the_array_box
 %    \end{macrocode}
 %
-% \bigskip
-% If the user has loaded |nicematrix| with the option |define-L-C-R|, he will be
-% able to use |L|, |C| and |R| instead of |l|, |c| and |r| in the preambles of
-% the environments of \pkg{nicematrix} (it's a compatibility mode since |L|, |C|
-% and |R| were mandatory before version 5.0).
-%    \begin{macrocode}
-    \bool_if:NT \c_@@_define_L_C_R_bool \@@_define_L_C_R:
-%    \end{macrocode}
 %
 % \bigskip
 % The preamble will be constructed in |\g_@@_preamble_tl|. 
@@ -8112,7 +8233,7 @@ version 2005/12/01 or later.
       { 
         \tl_gput_right:Nn \g_@@_row_style_tl
           {
-            \tl_gput_right:Nn \g_@@_post_treatment_cell_tl 
+            \tl_gput_right:Nn \g_@@_post_action_cell_tl 
               { \dim_set:Nn \l_@@_cell_space_top_limit_dim { #1 } }
           }
       } ,
@@ -8121,7 +8242,7 @@ version 2005/12/01 or later.
       { 
         \tl_gput_right:Nn \g_@@_row_style_tl
           {
-            \tl_gput_right:Nn \g_@@_post_treatment_cell_tl 
+            \tl_gput_right:Nn \g_@@_post_action_cell_tl 
               { \dim_set:Nn \l_@@_cell_space_bottom_limit_dim { #1 } }
           }
       } ,
@@ -8223,6 +8344,7 @@ version 2005/12/01 or later.
     \cs_set_eq:NN \roundedrectanglecolor \@@_roundedrectanglecolor
     \cs_set_eq:NN \rowcolor \@@_rowcolor
     \cs_set_eq:NN \rowcolors \@@_rowcolors
+    \cs_set_eq:NN \rowlistcolors \@@_rowlistcolors
     \cs_set_eq:NN \arraycolor \@@_arraycolor
     \cs_set_eq:NN \columncolor \@@_columncolor
     \cs_set_eq:NN \chessboardcolors \@@_chessboardcolors
@@ -8351,6 +8473,9 @@ version 2005/12/01 or later.
 \NewDocumentEnvironment { NiceArrayWithDelims } 
   { m m O { } m ! O { } t \CodeBefore }
   { 
+%    \end{macrocode}
+%
+%    \begin{macrocode}
     \@@_provide_pgfsyspdfmark:
     \bool_if:NT \c_@@_footnote_bool \savenotes 
 %    \end{macrocode}
@@ -8507,18 +8632,31 @@ version 2005/12/01 or later.
 % End of the construction of the array (in the box |\l_@@_the_array_box|).
 %
 % \bigskip
+% If the user has used the key |width| without any column |X|, we raise an error.
+%    \begin{macrocode}
+    \bool_if:NT \l_@@_width_used_bool
+      {
+        \int_compare:nNnT \g_@@_total_X_weight_int = 0 
+          { \@@_error:n { width~without~X~columns } }
+      }
+%    \end{macrocode}
+%
+% \bigskip
 % Now, if there is at least one |X|-column in the environment, we compute the
-% width that those columns will have (in the next compilation).
+% width that those columns will have (in the next compilation). In fact,
+% |l_@@_X_columns_dim| will the the width of a column of weight $1$. For a
+% |X|-column of weight~$n$, the width will be |l_@@_X_columns_dim| multiplied
+% by~$n$. 
 %    \begin{macrocode}
-    \int_compare:nNnT \g_@@_nb_of_X_int > 0 
+    \int_compare:nNnT \g_@@_total_X_weight_int > 0 
       { 
         \bool_if:NTF \l_@@_X_columns_aux_bool 
           { \dim_set_eq:NN \l_tmpa_dim \l_@@_X_columns_dim }
           {
             \dim_set:Nn \l_tmpa_dim 
               { 
-                ( \textwidth - \box_wd:N \l_@@_the_array_box ) 
-                / \int_use:N \g_@@_nb_of_X_int 
+                ( \l_@@_width_dim - \box_wd:N \l_@@_the_array_box ) 
+                / \int_use:N \g_@@_total_X_weight_int 
               } 
           }
         \tl_gput_right:Nx \g_@@_aux_tl
@@ -8823,7 +8961,7 @@ version 2005/12/01 or later.
 %    \end{macrocode}
 % The number of letters |X| in the preamble of the array.
 %    \begin{macrocode}
-        \int_gzero:N \g_@@_nb_of_X_int
+        \int_gzero:N \g_@@_total_X_weight_int
 %    \end{macrocode}
 % The sequence |\g_@@_cols_vlsim_seq| will contain the numbers of the columns
 % where you will to have to draw vertical lines in the potential sub-matrices
@@ -8932,9 +9070,9 @@ version 2005/12/01 or later.
         ! { \@@_patch_preamble_ii:nn #1 }
         @ { \@@_patch_preamble_ii:nn #1 }
         | { \@@_patch_preamble_iii:n #1 }
-        p { \@@_patch_preamble_iv:nnn t #1 }
-        b { \@@_patch_preamble_iv:nnn b #1 }
-        m { \@@_patch_preamble_iv:nnn b #1 }
+        p { \@@_patch_preamble_iv:n #1 }
+        b { \@@_patch_preamble_iv:n #1 }
+        m { \@@_patch_preamble_iv:n #1 }
         \@@_w: { \@@_patch_preamble_v:nnnn { }                          #1 } 
         \@@_W: { \@@_patch_preamble_v:nnnn { \cs_set_eq:NN \hss \hfil } #1 } 
         \@@_true_c: { \@@_patch_preamble_vi:n #1 }
@@ -8944,10 +9082,7 @@ version 2005/12/01 or later.
         )  { \@@_patch_preamble_viii:nn #1 }       
         ]  { \@@_patch_preamble_viii:nn #1 }       
         \} { \@@_patch_preamble_viii:nn #1 }       
-        X  { \@@_patch_preamble_xii: }
-        C { \@@_error:nn { old~column~type } #1 }
-        L { \@@_error:nn { old~column~type } #1 }
-        R { \@@_error:nn { old~column~type } #1 }
+        X  { \@@_patch_preamble_ix:n }
         \q_stop { }
       }
       { 
@@ -8984,7 +9119,7 @@ version 2005/12/01 or later.
   { 
     \tl_gput_right:Nn \g_@@_preamble_tl 
       { 
-        > { \@@_Cell: \tl_set:Nn \l_@@_cell_type_tl { #1 } } 
+        > { \@@_Cell: \str_set:Nn \l_@@_hpos_cell_str { #1 } } 
         #1 
         < \@@_end_Cell:
       }  
@@ -9055,16 +9190,143 @@ version 2005/12/01 or later.
 \bool_new:N \l_@@_bar_at_end_of_pream_bool
 %    \end{macrocode}
 % 
+% \bigskip
+% The specifier |p| (and also the specifiers |m| and |b|) have an optional
+% argument between square brackets for a list of \emph{key}-\emph{value} pairs.
+% Here are the corresponding keys. This set of keys will also be used by the |X|
+% columns. 
+%    \begin{macrocode}
+\keys_define:nn { WithArrows / p-column }
+  {
+    r .code:n = \str_set:Nn \l_@@_hpos_col_str { r } ,
+    r .value_forbidden:n = true ,
+    c .code:n = \str_set:Nn \l_@@_hpos_col_str { c } ,
+    c .value_forbidden:n = true ,
+    l .code:n = \str_set:Nn \l_@@_hpos_col_str { l } ,
+    l .value_forbidden:n = true ,
+    p .code:n = \str_set:Nn \l_@@_vpos_col_str { p } ,
+    p .value_forbidden:n = true ,
+    t .meta:n = p ,
+    m .code:n = \str_set:Nn \l_@@_vpos_col_str { m } ,
+    m .value_forbidden:n = true ,
+    b .code:n = \str_set:Nn \l_@@_vpos_col_str { b } ,
+    b .value_forbidden:n = true 
+  }
+%    \end{macrocode}
+% 
+% 
+% \medskip
+% For |p|, |b| and |m|. The argument |#1| is that value : |p|, |b| or |m|.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_preamble_iv:n #1
+  { 
+    \str_set:Nn \l_@@_vpos_col_str { #1 }
+%    \end{macrocode}
+% Now, you look for a potential character |[| after the letter of the specifier
+% (for the options).
+%    \begin{macrocode}
+    \@@_patch_preamble_iv_i:n 
+  }
+%    \end{macrocode}
+% 
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_preamble_iv_i:n #1
+  {
+    \str_if_eq:nnTF { #1 } { [ }
+      { \@@_patch_preamble_iv_ii:w [ }
+      { \@@_patch_preamble_iv_ii:w [ ] { #1 } }
+  }
+%    \end{macrocode}
+% 
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_preamble_iv_ii:w [ #1 ]
+  { \@@_patch_preamble_iv_iii:nn { #1 } }
+%    \end{macrocode}
+% 
 % \medskip
-% For |p| and |b|
+% |#1| is the optional argument of the specifier (a list of
+% \emph{key}-\emph{value} pairs).
+%
+% |#2| is the mandatory argument of the specifier: the width of the column.
 %    \begin{macrocode}  
-\cs_new_protected:Npn \@@_patch_preamble_iv:nnn #1 #2 #3
+\cs_new_protected:Npn \@@_patch_preamble_iv_iii:nn #1 #2 
   {  
+%    \end{macrocode}
+% The possible values of |\l_@@_hpos_col_str| are |j| (for \emph{justified} which is
+% the initial value), |l|, |c| and |r| (when the user has used the corresponding
+% key in the optional argument of the specifier).
+%    \begin{macrocode}
+    \str_set:Nn \l_@@_hpos_col_str { j }
+    \keys_set:nn { WithArrows / p-column } { #1 }
+    \@@_patch_preamble_iv_iv:n { #2 }
+  }
+%    \end{macrocode}
+% 
+% \medskip
+% The argument is the width of the column.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_preamble_iv_iv:n #1 
+  {
+    \use:x 
+      { 
+        \@@_patch_preamble_iv_v:nnnn
+          { \str_if_eq:VnTF \l_@@_vpos_col_str { p } { t } { b } }
+          { \dim_eval:n { #1 } }
+          {
+%    \end{macrocode}
+% The parameter |\l_@@_hpos_col_str| (as |\l_@@_vpos_col_str|) exists only
+% during the contruction of the preamble. During the composition of the array
+% itself, you will have, in each cell, the parameter |\l_@@_hpos_cell_str| which
+% will provide 
+%    \begin{macrocode}
+            \str_if_eq:VnTF \l_@@_hpos_col_str j 
+              { \str_set:Nn \exp_not:N \l_@@_hpos_cell_str { c } }
+              { \str_set:Nn \exp_not:N \l_@@_hpos_cell_str \l_@@_hpos_col_str }  
+            \str_case:Vn \l_@@_hpos_col_str 
+              {
+                c { \exp_not:N \centering }
+                l { \exp_not:N \raggedright }
+                r { \exp_not:N \raggedleft }
+              }
+          }
+          { \str_if_eq:VnT \l_@@_vpos_col_str { m } \@@_center_cell_box: }
+      }
+%    \end{macrocode}
+%
+% We increment the counter of columns, and then we test for the presence of a |<|.
+%    \begin{macrocode}
+    \int_gincr:N \c@jCol
+    \@@_patch_preamble_x:n
+  }
+%    \end{macrocode}
+% 
+% \medskip
+% |#1| is the optional argument of |{minipage}|: |t| of |b|. Indeed, for the
+% columns of type |m|, we use the value |b| here because there is a special
+% post-action in order to center vertically the box (see |#4|).
+%
+% |#2| is the width of the |{minipage}|, that is to say also the width of the
+% column.
+% 
+% |#3| is the coding for the horizontal position of the content of the cell
+% (|\centering|, |\raggedright|, |\raggedleft| or nothing).
+%
+% |#4| is an extra-code which contains |\l_@@_center_cell_box| (when the column
+% is a |m| column) or nothing (in the other cases).
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_preamble_iv_v:nnnn #1 #2 #3 #4
+  {
     \tl_gput_right:Nn \g_@@_preamble_tl
       {
         > { 
+%    \end{macrocode}
+% The parameter |\l_@@_col_width_dim|, which is the width of the current column,
+% will be available in each cell of the column. It will be used by the
+% mono-column blocks.
+%    \begin{macrocode}
+            \dim_set:Nn \l_@@_col_width_dim { #2 }
             \@@_Cell: 
-            \begin { minipage } [ #1 ] { \dim_eval:n { #3 } }
+            \begin { minipage } [ #1 ] { #2 }
 %    \end{macrocode}
 % The following lines have been taken from |array.sty|.
 %    \begin{macrocode}
@@ -9073,7 +9335,17 @@ version 2005/12/01 or later.
                 \vrule height \box_ht:N \@arstrutbox width \c_zero_dim
                 \everypar { }
               }
-            \g_@@_row_style_tl % added the 2021-07-17
+%    \end{macrocode}
+% Now, the potential code for the horizontal position of the content of the cell
+% (|\centering|, |\raggedright|, |\raggedleft| or nothing).
+%    \begin{macrocode}
+            #3
+%    \end{macrocode}
+% The following code is to allow something like |\centering| in |\RowStyle|.
+% However, there is extra vertical space if |\color{...}| is used in
+% |\RowStyle| (we should try to add a key |color| to the command |\RowStyle|.
+%    \begin{macrocode}
+            \g_@@_row_style_tl
             \arraybackslash
           } 
         c 
@@ -9084,18 +9356,13 @@ version 2005/12/01 or later.
             \@finalstrut \@arstrutbox
             \end { minipage } 
 %    \end{macrocode}
-% If the letter in the preamble is |m|, you require a post-treatment for the box
-% |\l_@@_cell_box|.
+% If the letter in the preamble is |m|, |#3| will be equal to
+% |\@@_center_cell_box:| (see just below).
 %    \begin{macrocode}
-            \str_if_eq:nnT { #2 } m \@@_center_cell_box:
+            #4
             \@@_end_Cell: 
           } 
       }
-%    \end{macrocode}
-% We increment the counter of columns, and then we test for the presence of a |<|.
-%    \begin{macrocode}
-    \int_gincr:N \c@jCol
-    \@@_patch_preamble_x:n
   }
 %    \end{macrocode}
 % 
@@ -9104,16 +9371,16 @@ version 2005/12/01 or later.
 % vertically the box. In fact, despite its name, the command does not always
 % center the cell. Indeed, if there is only one row in the cell, it should not
 % be centered vertically. It's not possible to know the number of rows of the
-% cell. However, you consider (as in \pkg{array}) that if the height of the cell
+% cell. However, we consider (as in \pkg{array}) that if the height of the cell
 % is no more that the height of |\@arstrutbox|, there is only one row.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_center_cell_box:
   {
 %    \end{macrocode}
-% By putting instructions in |\g_@@_post_treatment_cell_tl|, we require a
-% post-treatment of the box |\l_@@_cell_box|. 
+% By putting instructions in |\g_@@_post_action_cell_tl|, we require a
+% post-action of the box |\l_@@_cell_box|.
 %    \begin{macrocode}
-    \tl_gput_right:Nn \g_@@_post_treatment_cell_tl
+    \tl_gput_right:Nn \g_@@_post_action_cell_tl
       {
         \int_compare:nNnT 
           { \box_ht:N \l_@@_cell_box } 
@@ -9143,9 +9410,15 @@ version 2005/12/01 or later.
     \tl_gput_right:Nn \g_@@_preamble_tl
       {
         > {
+%    \end{macrocode}
+% The parameter |\l_@@_col_width_dim|, which is the width of the current column,
+% will be available in each cell of the column. It will be used by the
+% mono-column blocks.
+%    \begin{macrocode}
+            \dim_set:Nn \l_@@_col_width_dim { #4 }
             \hbox_set:Nw \l_@@_cell_box
             \@@_Cell:
-            \tl_set:Nn \l_@@_cell_type_tl { #3 }
+            \str_set:Nn \l_@@_hpos_cell_str { #3 }
           }
         c
         < {
@@ -9290,6 +9563,105 @@ version 2005/12/01 or later.
   }
 %    \end{macrocode}
 % 
+% \bigskip
+% For the case of a letter |X|. This specifier may take in an optional argument
+% (between square brackets). That's why we test whether there is a |[| after the
+% letter |X|.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_preamble_ix:n #1
+  {
+    \str_if_eq:nnTF { #1 } { [ }
+      { \@@_patch_preamble_ix_i:w [ }
+      { \@@_patch_preamble_ix_i:w [ ] #1 }
+  }
+%    \end{macrocode}
+% 
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_preamble_ix_i:w [ #1 ]
+  { \@@_patch_preamble_ix_ii:n { #1 } }
+%    \end{macrocode}
+% |#1| is the optional argument of the |X| specifier (a list of
+% \emph{key}-\emph{value} pairs).
+%
+% \medskip
+% The following set of keys is for the specifier |X| in the preamble of the
+% array. Such specifier may have as key all the keys of 
+% |{ WithArrows / p-column }| but also a key as 1, 2, 3, etc. The following set
+% of keys will be used to retrieve that value (in the counter |\l_@@_weight_int|).
+%    \begin{macrocode}
+\keys_define:nn { WithArrows / X-column }
+  { unknown .code:n = \int_set:Nn \l_@@_weight_int { \l_keys_key_str } }
+%    \end{macrocode}
+% 
+% 
+% \medskip
+% In the following command, |#1| is the list of the options of the specifier |X|.
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_preamble_ix_ii:n #1
+  {
+%    \end{macrocode}
+% The possible values of |\l_@@_hpos_col_str| are |j| (for \emph{justified} which is
+% the initial value), |l|, |c| and |r| (when the user has used the corresponding
+% key in the optional argument of the specifier |X|).
+%    \begin{macrocode}
+    \str_set:Nn \l_@@_hpos_col_str { j }
+%    \end{macrocode}
+% The possible values of |\l_@@_vpos_col_str| are |p| (the initial value), |m| and |b|
+% (when the user has used the corresponding key in the optional argument of the
+% specifier |X|). 
+%    \begin{macrocode}
+    \tl_set:Nn \l_@@_vpos_col_str { p }
+%    \end{macrocode}
+%
+% The integer |\l_@@_weight_int| will be the weight of the |X| column (the
+% initial value is $1$). The user may specify a different value (such as $2$,
+% $3$, etc.) by putting that value in the optional argument of the specifier.
+% The weights of the |X| columns are used in the computation of the actual width
+% of those columns.
+%    \begin{macrocode}
+    \int_zero_new:N \l_@@_weight_int 
+    \int_set:Nn \l_@@_weight_int { 1 }
+    \keys_set_known:nnN { WithArrows / p-column } { #1 } \l_tmpa_tl 
+    \keys_set:nV { WithArrows / X-column } \l_tmpa_tl
+    \int_gadd:Nn \g_@@_total_X_weight_int \l_@@_weight_int
+%    \end{macrocode}
+%
+% We test whether we know the width of the |X|-columns by reading the |aux| file.
+% (after the first compilation, the width of the |X|-columns is computed and
+% written on the |aux| file).
+%    \begin{macrocode}
+    \bool_if:NTF \l_@@_X_columns_aux_bool
+      { \@@_patch_preamble_iv_iv:n { \l_@@_weight_int \l_@@_X_columns_dim } }
+      {
+        \tl_gput_right:Nn \g_@@_preamble_tl 
+          { 
+            > { 
+                \@@_Cell: 
+                \bool_set_true:N \l_@@_X_column_bool 
+%    \end{macrocode}
+% The following code will nullify the box of the cell.
+%    \begin{macrocode}
+                \tl_gput_right:Nn \g_@@_post_action_cell_tl 
+                  { \hbox_set:Nn \l_@@_cell_box { } }
+%    \end{macrocode}
+% We put a |{minipage}| to give to the user the ability to put a command such as
+% |\centering| in the |\RowStyle|.
+%    \begin{macrocode}
+                \begin { minipage } { 5 cm } \arraybackslash
+              } 
+            c 
+            < { 
+                \end { minipage }
+                \@@_end_Cell: 
+              }
+          }  
+        \int_gincr:N \c@jCol
+        \@@_patch_preamble_x:n
+      }
+  }
+%    \end{macrocode}
+%
+% \bigskip
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_patch_preamble_xi:n #1
   {
@@ -9305,6 +9677,7 @@ version 2005/12/01 or later.
   }
 %    \end{macrocode}
 % 
+% \bigskip
 % After a specifier of column, we have to test whether there is one or several
 % |<{..}| because, after those potential |<{...}|, we have to insert
 % |!{\skip_horizontal:N ...}| when the key |vlines| is used.
@@ -9312,7 +9685,7 @@ version 2005/12/01 or later.
 \cs_new_protected:Npn \@@_patch_preamble_x:n #1
   {
     \str_if_eq:nnTF { #1 } { < }
-      \@@_patch_preamble_ix:n 
+      \@@_patch_preamble_xii:n 
       { 
         \tl_if_eq:NnTF \l_@@_vlines_clist { all }
           { 
@@ -9333,48 +9706,13 @@ version 2005/12/01 or later.
 %    \end{macrocode}
 % 
 %    \begin{macrocode}
-\cs_new_protected:Npn \@@_patch_preamble_ix:n #1
+\cs_new_protected:Npn \@@_patch_preamble_xii:n #1
   {
     \tl_gput_right:Nn \g_@@_preamble_tl { < { #1 } }
     \@@_patch_preamble_x:n
   }
 %    \end{macrocode}
 %
-% \bigskip
-% For the case of a letter |X|
-%    \begin{macrocode}
-\cs_new_protected:Npn \@@_patch_preamble_xii:
-  {
-    \int_gincr:N \g_@@_nb_of_X_int
-%    \end{macrocode}
-% We test whether you know the width of the |X|-columns by reading the value in
-% the |aux| file (of course, this is not possible at the first compilation).
-%    \begin{macrocode}
-    \bool_if:NTF \l_@@_X_columns_aux_bool
-      { \exp_args:NNNV \@@_patch_preamble_iv:nnn t p \l_@@_X_columns_dim }
-      {
-        \tl_gput_right:Nn \g_@@_preamble_tl 
-          { 
-            > { 
-                \@@_Cell: 
-                \tl_set:Nn \l_@@_cell_type_tl { c } 
-%    \end{macrocode}
-% The following code will nullify the box of the cell.
-%    \begin{macrocode}
-                \tl_gput_right:Nn \g_@@_post_treatment_cell_tl 
-                  { \hbox_set:Nn \l_@@_cell_box { } }
-%    \end{macrocode}
-% The content of the cell is composed in |\l_tmpa_box| which will be discarded.
-%    \begin{macrocode}
-              } 
-            c 
-            < { \@@_end_Cell: }
-          }  
-        \int_gincr:N \c@jCol
-        \@@_patch_preamble_x:n
-      }
-  }
-%    \end{macrocode}
 % 
 % \bigskip
 % \subsection*{The redefinition of \textbackslash multicolumn}
@@ -9481,9 +9819,6 @@ version 2005/12/01 or later.
         \@@_w: { \@@_patch_m_preamble_v:nnnn { }                          #1 } 
         \@@_W: { \@@_patch_m_preamble_v:nnnn { \cs_set_eq:NN \hss \hfil } #1 } 
         \@@_true_c: { \@@_patch_m_preamble_vi:n #1 }
-        C { \@@_error:nn { old~column~type } #1 }
-        L { \@@_error:nn { old~column~type } #1 }
-        R { \@@_error:nn { old~column~type } #1 }
         \q_stop { }
       }
       { \@@_fatal:nn { unknown~column~type } { #1 } }
@@ -9497,7 +9832,7 @@ version 2005/12/01 or later.
   { 
     \tl_gput_right:Nn \g_@@_preamble_tl 
       { 
-        > { \@@_Cell: \tl_set:Nn \l_@@_cell_type_tl { #1 } } 
+        > { \@@_Cell: \str_set:Nn \l_@@_hpos_cell_str { #1 } } 
         #1 
         < \@@_end_Cell:
       }  
@@ -9568,7 +9903,7 @@ version 2005/12/01 or later.
         > {
             \hbox_set:Nw \l_@@_cell_box
             \@@_Cell:
-            \tl_set:Nn \l_@@_cell_type_tl { #3 }
+            \str_set:Nn \l_@@_hpos_cell_str { #3 }
           }
         c
         < {
@@ -10588,11 +10923,18 @@ version 2005/12/01 or later.
 %    \end{macrocode}
 %
 % \bigskip
-% \subsection*{The environments \{NiceTabular\}  and \{NiceTabular*\}}
+% \subsection*{\{NiceTabular\}, \{NiceTabularX\} and \{NiceTabular*\}} 
 %
 %    \begin{macrocode}
 \NewDocumentEnvironment { NiceTabular } { O { } m ! O { } }
   { 
+%    \end{macrocode}
+% The dimension |\l_@@_width_dim| will be used if at least one column of type
+% |X| is used.
+% 
+%    \begin{macrocode}
+    \dim_zero_new:N \l_@@_width_dim 
+    \dim_set_eq:NN \l_@@_width_dim \linewidth
     \str_gset:Nn \g_@@_name_env_str { NiceTabular }
     \keys_set:nn { NiceMatrix / NiceTabular } { #1 , #3 }
     \bool_set_true:N \l_@@_NiceTabular_bool 
@@ -10601,6 +10943,20 @@ version 2005/12/01 or later.
   { \endNiceArray }
 %    \end{macrocode}
 %
+% \bigskip
+%    \begin{macrocode}
+\NewDocumentEnvironment { NiceTabularX } { m O { } m ! O { } }
+  { 
+    \str_gset:Nn \g_@@_name_env_str { NiceTabularX }
+    \dim_zero_new:N \l_@@_width_dim 
+    \dim_set:Nn \l_@@_width_dim { #1 }
+    \keys_set:nn { NiceMatrix / NiceTabular } { #2 , #4 }
+    \bool_set_true:N \l_@@_NiceTabular_bool 
+    \NiceArray { #3 }
+  }
+  { \endNiceArray }
+%    \end{macrocode}
+%
 % \bigskip 
 %    \begin{macrocode}
 \NewDocumentEnvironment { NiceTabular* } { m O { } m ! O { } }
@@ -12414,6 +12770,10 @@ version 2005/12/01 or later.
   }
 %    \end{macrocode}
 %
+% \bigskip
+% In the environments of |nicematrix|, the command |\multicolumn| is redefined.
+% We will patch the environment |{tabular}| to go back to the previous value of
+% |\multicolumn|.
 %    \begin{macrocode}
 \cs_set_eq:NN \@@_old_multicolumn \multicolumn
 %    \end{macrocode}
@@ -12776,28 +13136,26 @@ version 2005/12/01 or later.
 % We want to avoid the thin white lines that are shown in some \textsc{pdf}
 % viewers (eg: with the engine MuPDF used by SumatraPDF). That's why we try to
 % draw rectangles of the same color in the same instruction |\pgfusepath { fill }|
-% (and they will be in the same instruction |fill|---coded |f|--- in the
+% (and they will be in the same instruction |fill|---coded |f|---in the
 % resulting \textsc{pdf}).
 %
-% The commands |\@@_rowcolor|, |\@@_columncolor| and |\@@_rectanglecolor|
-% (which are linked to |\rowcolor|, |\columncolor| and |\rectanglecolor| before
-% the execution of the |code-before|) don't directly draw the corresponding
-% rectangles. Instead, they store their instructions color by color:
+% The commands |\@@_rowcolor|, |\@@_columncolor|, |\@@_rectanglecolor| and
+% |\@@_rowlistcolors| don't directly draw the corresponding rectangles. Instead,
+% they store their instructions color by color:
 % \begin{itemize}
 % \item A sequence |\g_@@_colors_seq| will be built containing all the colors
 % used by at least one of these instructions. Each \emph{color} may be prefixed
-% by it color model (eg: |[gray]{0.5}|).
+% by its color model (eg: |[gray]{0.5}|).
 % \item For the color whose index in |\g_@@_colors_seq| is equal to~$i$, a list of
 % instructions which use that color will be constructed in the token list
 % |\g_@@_color_|$i$|_tl|. In that token list, the instructions will be written
-% using |\@@_rowcolor:n|, |\@@_columncolor:n| and |\@@_rectanglecolor:nn|
-% (corresponding of |\@@_rowcolor|, |\@@_columncolor| and |\@@_rectanglecolor|). 
+% using |\@@_cartesian_color:nn| and |\@@_rectanglecolor:nn|.
 % \end{itemize}
 %
 % 
-% bigskip
+% \bigskip
 % |#1| is the color and |#2| is an instruction using that color. Despite its
-% name, the command |\@@_add_to_color_seq| doesn't only add a color to
+% name, the command |\@@_add_to_colors_seq:nn| doesn't only add a color to
 % |\g_@@_colors_seq|: it also updates the corresponding token list
 % |\g_@@_color_|$i$|_tl|. We add in a global way because the final user may use
 % the instructions such as |\cellcolor| in a loop of \pkg{pgffor} in the
@@ -12832,6 +13190,7 @@ version 2005/12/01 or later.
 %
 %    \begin{macrocode}
 \cs_generate_variant:Nn \@@_add_to_colors_seq:nn { x n }
+\cs_generate_variant:Nn \@@_add_to_colors_seq:nn { x x }
 %    \end{macrocode}
 %
 % \bigskip
@@ -12862,6 +13221,14 @@ version 2005/12/01 or later.
   }
 %    \end{macrocode}
 %
+%    \begin{macrocode}
+\cs_new_protected:Npn \@@_cartesian_color:nn #1 #2
+  {
+    \tl_set:Nn \l_@@_rows_tl { #1 }
+    \tl_set:Nn \l_@@_cols_tl { #2 }
+    \@@_cartesian_path:
+  }
+%    \end{macrocode}
 % 
 % \bigskip
 % Here is an example : |\@@_rowcolor {red!15} {1,3,5-7,10-}|
@@ -12872,25 +13239,11 @@ version 2005/12/01 or later.
       {
         \@@_add_to_colors_seq:xn 
           { \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } }
-          { \@@_rowcolor:n { #3 } }
+          { \@@_cartesian_color:nn { #3 } { - } }
       }
   }
 %    \end{macrocode}
 %
-%    \begin{macrocode}
-\cs_new_protected:Npn \@@_rowcolor:n #1
-  {
-    \tl_set:Nn \l_@@_rows_tl { #1 }
-    \tl_set:Nn \l_@@_cols_tl { - }
-%    \end{macrocode}
-% The command |\@@_cartesian_path:| takes in two implicit arguments:
-% |\l_@@_cols_tl| and |\l_@@_rows_tl|.
-%    \begin{macrocode}
-     \@@_cartesian_path:
-  }
-%    \end{macrocode}
-% 
-%
 % \bigskip
 % Here an example : |\@@_columncolor:nn {red!15} {1,3,5-7,10-}|
 %    \begin{macrocode}
@@ -12900,23 +13253,10 @@ version 2005/12/01 or later.
       {
         \@@_add_to_colors_seq:xn 
           { \tl_if_blank:nF { #1 } { [ #1 ] } { #2 } }
-          { \@@_columncolor:n { #3 } }
+          { \@@_cartesian_color:nn { - } { #3 } }
       }
   }
 %    \end{macrocode}
-%    \begin{macrocode}
-\cs_new_protected:Npn \@@_columncolor:n #1
-  {
-    \tl_set:Nn \l_@@_rows_tl { - }
-    \tl_set:Nn \l_@@_cols_tl { #1 }
-%    \end{macrocode}
-% The command |\@@_cartesian_path:| takes in two implicit arguments:
-% |\l_@@_cols_tl| and |\l_@@_rows_tl|.
-%    \begin{macrocode}
-    \@@_cartesian_path:
-  }
-%    \end{macrocode}
-%
 %
 % \bigskip
 % Here is an example : |\@@_rectanglecolor{red!15}{2-3}{5-6}|
@@ -13038,24 +13378,26 @@ version 2005/12/01 or later.
 % 
 % |#1| (optional) is the color space ;
 % |#2| is a list of intervals of rows ;
-% |#3| is the first color ;
-% |#4| is the second color ;
-% |#5| is for the optional list of pairs key-value.
+% |#3| is the list of colors ;
+% |#4| is for the optional list of pairs key-value.
 %    \begin{macrocode}
-\NewDocumentCommand \@@_rowcolors { O { } m m m O { } }
+\NewDocumentCommand \@@_rowlistcolors { O { } m m O { } }
   {
 %    \end{macrocode}
-% The group is for the options.
+% The group is for the options. |\l_@@_colors_seq| will be the list of colors.
 %    \begin{macrocode}
     \group_begin:
+    \seq_clear_new:N \l_@@_colors_seq
+    \seq_set_split:Nnn \l_@@_colors_seq { , } { #3 }
     \tl_clear_new:N \l_@@_cols_tl
     \tl_set:Nn \l_@@_cols_tl { - }
-    \keys_set:nn { NiceMatrix / rowcolors } { #5 }
+    \keys_set:nn { NiceMatrix / rowcolors } { #4 }
 %    \end{macrocode}
-% The boolean |\l_tmpa_bool| will indicate whereas we are in a row of the first
-% color or of the second color.
+% The counter |\l_@@_color_int| will be the rank of the current color in the list of
+% colors (modulo the length of the list).
 %    \begin{macrocode}
-    \bool_set_true:N \l_tmpa_bool
+    \int_zero_new:N \l_@@_color_int
+    \int_set:Nn \l_@@_color_int 1 
     \bool_if:NT \l_@@_respect_blocks_bool
       {
 %    \end{macrocode}
@@ -13069,6 +13411,9 @@ version 2005/12/01 or later.
       }
     \pgfpicture
     \pgf@relevantforpicturesizefalse
+%    \end{macrocode}
+% |#2| is the list of intervals of rows.
+%    \begin{macrocode}
     \clist_map_inline:nn { #2 }
       {
         \tl_set:Nn \l_tmpa_tl { ##1 }
@@ -13076,12 +13421,14 @@ version 2005/12/01 or later.
           { \@@_cut_on_hyphen:w ##1 \q_stop }  
           { \tl_set:Nx \l_tmpb_tl { \int_use:N \c@iRow } }  
 %    \end{macrocode}
-% The counter |\l_tmpa_int| will be the index of the loop.
+% Now, |l_tmpa_tl| and |l_tmpb_tl| are the first row and the last row of the
+% interval of rows that we have to treat. The counter |\l_tmpa_int| will be the
+% index of the loop over the rows.
 %    \begin{macrocode}
         \int_set:Nn \l_tmpa_int \l_tmpa_tl
         \bool_if:NTF \l_@@_rowcolors_restart_bool
-          { \bool_set_true:N \l_tmpa_bool }
-          { \bool_set:Nn \l_tmpa_bool { \int_if_odd_p:n { \l_tmpa_tl } } }
+          { \int_set:Nn \l_@@_color_int 1 }
+          { \int_set:Nn \l_@@_color_int \l_tmpa_tl } 
         \int_zero_new:N \l_tmpc_int
         \int_set:Nn \l_tmpc_int \l_tmpb_tl
         \int_do_until:nNnn \l_tmpa_int > \l_tmpc_int
@@ -13105,39 +13452,27 @@ version 2005/12/01 or later.
               }
             \tl_set:Nx \l_@@_rows_tl 
               { \int_use:N \l_tmpa_int - \int_use:N \l_tmpb_int } 
-            \bool_if:NTF \l_tmpa_bool
-              {
-                \tl_if_blank:nF { #3 } 
-                  {
-                    \tl_if_empty:nTF { #1 } 
-                      \color 
-                      { \color [ #1 ] } 
-                      { #3 }
 %    \end{macrocode}
-% The command |\@@_cartesian_path:| takes in two implicit arguments:
-% |\l_@@_cols_tl| and |\l_@@_rows_tl|.
+% |\l_tmpc_tl| will be the color that we will use.
 %    \begin{macrocode}
-                    \@@_cartesian_path:
-                    \pgfusepath { fill }
-                  }
-                \bool_set_false:N \l_tmpa_bool
-              }
+            \tl_clear_new:N \l_@@_color_tl
+            \tl_set:Nx \l_@@_color_tl
               { 
-                \tl_if_blank:nF { #4 }
-                  {
-                    \tl_if_empty:nTF { #1 } 
-                      \color 
-                      { \color [ #1 ] } 
-                      { #4 }
-%    \end{macrocode}
-% The command |\@@_cartesian_path:| takes in two implicit arguments:
-% |\l_@@_cols_tl| and |\l_@@_row_tl|.
-%    \begin{macrocode}
-                    \@@_cartesian_path:
-                    \pgfusepath { fill }
+                \@@_color_index:n 
+                  { 
+                    \int_mod:nn 
+                      { \l_@@_color_int - 1 } 
+                      { \seq_count:N \l_@@_colors_seq } 
+                    + 1 
                   }
-                \bool_set_true:N \l_tmpa_bool
               }
+            \tl_if_empty:NF \l_@@_color_tl
+              {
+                \@@_add_to_colors_seq:xx
+                  { \tl_if_blank:nF { #1 } { [ #1 ] } { \l_@@_color_tl } }
+                  { \@@_cartesian_color:nn { \l_@@_rows_tl } { \l_@@_cols_tl } }
+              }
+            \int_incr:N \l_@@_color_int
             \int_set:Nn \l_tmpa_int { \l_tmpb_int + 1 }
           }
       }
@@ -13146,6 +13481,27 @@ version 2005/12/01 or later.
   }
 %    \end{macrocode}
 %
+% \medskip
+% The command |\@@_color_index:n| peeks in |\l_@@_colors_seq| the color at the
+% index |#1|. However, if that color is the symbol |=|, the previous one is
+% poken. This macro is recursive.
+%    \begin{macrocode}
+\cs_new:Npn \@@_color_index:n #1
+  {
+    \str_if_eq:eeTF { \seq_item:Nn \l_@@_colors_seq { #1 } } { = }
+      { \@@_color_index:n { #1 - 1 } }
+      { \seq_item:Nn \l_@@_colors_seq { #1 } }
+  }
+%    \end{macrocode}
+% 
+% \bigskip
+% The command |\rowcolors| (available in the |\CodeBefore|) is a specialisation
+% of the most general command |\rowlistcolors|.
+%    \begin{macrocode}
+\NewDocumentCommand \@@_rowcolors { O { } m m m O { } }
+  { \@@_rowlistcolors [ #1 ] { #2 } { { #3 } , { #4 } } [ #5 ] }
+%    \end{macrocode}
+% 
 % \bigskip 
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_rowcolors_i:nnnn #1 #2 #3 #4
@@ -13757,9 +14113,12 @@ version 2005/12/01 or later.
     \dim_set_eq:NN \l_tmpb_dim \pgf@y
     \@@_qpoint:n { col - \@@_succ:n { #4 } }
     \dim_set_eq:NN \l_tmpc_dim \pgf@x
-    \bool_lazy_and:nnT
-      { \int_compare_p:nNn { #2 } > 1 }
-      { ! \tl_if_blank_p:V \CT@drsc@ }
+    \bool_lazy_all:nT
+      { 
+        { \int_compare_p:nNn { #2 } > 1 }
+        { \cs_if_exist_p:N \CT@drsc@ } % condition added in version 6.0
+        { ! \tl_if_blank_p:V \CT@drsc@ }
+      }
       {
         \group_begin:
         \CT@drsc@
@@ -14385,7 +14744,7 @@ version 2005/12/01 or later.
 %    \end{macrocode}
 %
 % \medskip
-% At the end of the environment |{NiceMatrixBlock}|, we write in the main |.aux|
+% At the end of the environment |{NiceMatrixBlock}|, we write in the main |aux|
 % file instructions for the column width of all the environments of the block
 % (that's why we have stored the number of the first environment of the block in
 % the counter |\l_@@_first_env_block_int|). 
@@ -14774,21 +15133,21 @@ version 2005/12/01 or later.
 %    \begin{macrocode}
 \keys_define:nn { NiceMatrix / Block / FirstPass }
   {
-    l .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl l ,
+    l .code:n = \str_set:Nn \l_@@_hpos_block_str l ,
     l .value_forbidden:n = true ,
-    r .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl r ,
+    r .code:n = \str_set:Nn \l_@@_hpos_block_str r ,
     r .value_forbidden:n = true ,
-    c .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl c ,
+    c .code:n = \str_set:Nn \l_@@_hpos_block_str c ,
     c .value_forbidden:n = true ,
-    L .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl l ,
+    L .code:n = \str_set:Nn \l_@@_hpos_block_str l ,
     L .value_forbidden:n = true ,
-    R .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl r ,
+    R .code:n = \str_set:Nn \l_@@_hpos_block_str r ,
     R .value_forbidden:n = true ,
-    C .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl c ,
+    C .code:n = \str_set:Nn \l_@@_hpos_block_str c ,
     C .value_forbidden:n = true ,
-    t .code:n = \tl_set:Nn \l_@@_vpos_of_block_tl t ,
+    t .code:n = \str_set:Nn \l_@@_vpos_of_block_tl t ,
     t .value_forbidden:n = true ,
-    b .code:n = \tl_set:Nn \l_@@_vpos_of_block_tl b ,
+    b .code:n = \str_set:Nn \l_@@_vpos_of_block_tl b ,
     b .value_forbidden:n = true ,
     color .tl_set:N = \l_@@_color_tl ,
     color .value_required:n = true ,
@@ -14799,9 +15158,7 @@ version 2005/12/01 or later.
 % The following command |\@@_Block:| will be linked to |\Block| in the
 % environments of \pkg{nicematrix}. We define it with
 % |\NewExpandableDocumentCommand| because it has an optional argument between
-% |<| and |>| (for TeX instructions put before the math mode of the label and
-% before the beginning of the small array of the block). It's mandatory to use
-% an expandable command.
+% |<| and |>|. It's mandatory to use an expandable command.
 %
 %    \begin{macrocode}
 \NewExpandableDocumentCommand \@@_Block: { O { } m D < > { } m }
@@ -14863,13 +15220,13 @@ version 2005/12/01 or later.
 %    \begin{macrocode}
     \int_compare:nNnTF \l_tmpb_int = 1
       {
-        \tl_if_empty:NTF \l_@@_cell_type_tl
-          { \tl_set:Nn \l_@@_hpos_of_block_tl c }
-          { \tl_set_eq:NN \l_@@_hpos_of_block_tl \l_@@_cell_type_tl }
+        \str_if_empty:NTF \l_@@_hpos_cell_str
+          { \str_set:Nn \l_@@_hpos_block_str c }
+          { \str_set_eq:NN \l_@@_hpos_block_str \l_@@_hpos_cell_str }
       }
-      { \tl_set:Nn \l_@@_hpos_of_block_tl c }
+      { \str_set:Nn \l_@@_hpos_block_str c }
 %    \end{macrocode}
-% The value of |\l_@@_hpos_of_block_tl| may be modified by the keys of the
+% The value of |\l_@@_hpos_block_str| may be modified by the keys of the
 % command |\Block| that we will analyze now.
 %
 % \medskip
@@ -14905,6 +15262,16 @@ version 2005/12/01 or later.
           \int_compare_p:nNn { \l_tmpb_int } = 1  
         ) 
         && ! \tl_if_empty_p:n { #5 }
+%    \end{macrocode}
+% For the blocks mono-column, we will compose right now in a box in order to
+% compute its width and take that width into account for the width of the
+% column. However, if the column is a |X| column, we should not do that since
+% the width is determined by another way. This should be the same for the |p|,
+% |m| and |b| columns and we should modify that point. However, for the |X|
+% column, it's imperative. Otherwise, the process for the determination of the
+% widths of the columns will be wrong.
+%    \begin{macrocode}
+        && ! \l_@@_X_column_bool 
       }
       { \exp_args:Nxx \@@_Block_iv:nnnnn }
       { \exp_args:Nxx \@@_Block_v:nnnnn }
@@ -14952,8 +15319,8 @@ version 2005/12/01 or later.
           { \int_compare:nNnT { #2 } = 1 \set@color }
           { \color { \l_@@_color_tl } }
 %    \end{macrocode}
-% If the block is mono-row, we use |\g_@@_row_style_tl| even it has yet been used
-% in the beginning of the cell where the command |\Block| has been issued
+% If the block is mono-row, we use |\g_@@_row_style_tl| even if it has yet been
+% used in the beginning of the cell where the command |\Block| has been issued
 % because we want to be able to take into account a potential instruction of
 % color of the font in |\g_@@_row_style_tl|.
 %    \begin{macrocode}
@@ -14970,23 +15337,43 @@ version 2005/12/01 or later.
 % the tabular is the same as the external alignment of the tabular (that is to
 % say the position of the block in its zone of merged cells).
 %    \begin{macrocode}
-        \bool_if:NT \g_@@_rotate_bool { \tl_set:Nn \l_@@_hpos_of_block_tl c }  
+        \bool_if:NT \g_@@_rotate_bool { \str_set:Nn \l_@@_hpos_block_str c }  
         \bool_if:NTF \l_@@_NiceTabular_bool
           { 
-            \use:x 
-              { 
-                \exp_not:N \begin { tabular } [ \l_@@_vpos_of_block_tl ]
-                  { @ { } \l_@@_hpos_of_block_tl @ { } }
-              }  
-              #5 
-            \end { tabular } 
+            \bool_lazy_and:nnTF
+              { \int_compare_p:nNn { #2 } = 1 }
+              { \dim_compare_p:n { \l_@@_col_width_dim >= \c_zero_dim } }
+%    \end{macrocode}
+% When the block is mono-column in a column with a fixed width (eg |p{3cm}|).
+%    \begin{macrocode}
+              {
+                \begin { minipage } [ l_@@_vpos_of_block_tl ]
+                  { \l_@@_col_width_dim }
+                  \str_case:Vn \l_@@_hpos_block_str
+                    {
+                      c \centering
+                      r \raggedleft
+                      l \raggedright
+                    }
+                  #5
+                \end { minipage }
+              }
+              {
+                \use:x 
+                  { 
+                    \exp_not:N \begin { tabular } [ \l_@@_vpos_of_block_tl ]
+                      { @ { } \l_@@_hpos_block_str @ { } }
+                  }  
+                  #5 
+                \end { tabular } 
+              }
           } 
           { 
             \c_math_toggle_token
             \use:x 
               { 
                 \exp_not:N \begin { array } [ \l_@@_vpos_of_block_tl ]
-                { @ { } \l_@@_hpos_of_block_tl @ { } } 
+                { @ { } \l_@@_hpos_block_str @ { } } 
               }
               #5 
             \end { array } 
@@ -15048,11 +15435,11 @@ version 2005/12/01 or later.
 %    \end{macrocode}
 % In the list of options |#3|, maybe there is a key for the horizontal alignment
 % (|l|, |r| or |c|). In that case, that key has been read and stored in
-% |\l_@@_hpos_of_block_tl|. However, maybe there were no key of the horizontal
+% |\l_@@_hpos_block_str|. However, maybe there were no key of the horizontal
 % alignement and that's why we put a key corresponding to the value of
-% |\l_@@_hpos_of_block_tl|, which is fixed by the type of current column.
+% |\l_@@_hpos_block_str|, which is fixed by the type of current column.
 %    \begin{macrocode}
-        { \exp_not:n { #3 } , \l_@@_hpos_of_block_tl }
+        { \exp_not:n { #3 } , \l_@@_hpos_block_str }
         { 
           \box_use_drop:c 
             { g_@@_ block _ box _ \int_use:N \g_@@_block_box_int _ box } 
@@ -15091,11 +15478,11 @@ version 2005/12/01 or later.
 % say the position of the block in its zone of merged cells).
 %    \begin{macrocode}
                   \bool_if:NT \g_@@_rotate_bool
-                    { \tl_set:Nn \l_@@_hpos_of_block_tl c }
+                    { \str_set:Nn \l_@@_hpos_block_str c }
                   \use:x 
                     { 
                       \exp_not:N \begin { tabular } [ \l_@@_vpos_of_block_tl ] 
-                      { @ { } \l_@@_hpos_of_block_tl @ { } } 
+                      { @ { } \l_@@_hpos_block_str @ { } } 
                     }
                     #5 
                   \end { tabular } 
@@ -15107,12 +15494,12 @@ version 2005/12/01 or later.
                   \dim_set_eq:NN \extrarowheight \c_zero_dim 
                   #4 
                   \bool_if:NT \g_@@_rotate_bool
-                    { \tl_set:Nn \l_@@_hpos_of_block_tl c }
+                    { \str_set:Nn \l_@@_hpos_block_str c }
                   \c_math_toggle_token 
                   \use:x 
                     { 
                       \exp_not:N \begin { array } [ \l_@@_vpos_of_block_tl ]
-                      { @ { } \l_@@_hpos_of_block_tl @ { } }
+                      { @ { } \l_@@_hpos_block_str @ { } }
                     } 
                     #5 
                   \end { array } 
@@ -15153,24 +15540,24 @@ version 2005/12/01 or later.
     hvlines .default:n = true ,
     line-width .dim_set:N = \l_@@_line_width_dim ,
     line-width .value_required:n = true ,
-    l .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl l ,
+    l .code:n = \str_set:Nn \l_@@_hpos_block_str l ,
     l .value_forbidden:n = true ,
-    r .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl r ,
+    r .code:n = \str_set:Nn \l_@@_hpos_block_str r ,
     r .value_forbidden:n = true ,
-    c .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl c ,
+    c .code:n = \str_set:Nn \l_@@_hpos_block_str c ,
     c .value_forbidden:n = true ,
-    L .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl l 
+    L .code:n = \str_set:Nn \l_@@_hpos_block_str l 
                 \bool_set_true:N \l_@@_hpos_of_block_cap_bool ,
     L .value_forbidden:n = true ,
-    R .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl r 
+    R .code:n = \str_set:Nn \l_@@_hpos_block_str r 
                 \bool_set_true:N \l_@@_hpos_of_block_cap_bool ,
     R .value_forbidden:n = true ,
-    C .code:n = \tl_set:Nn \l_@@_hpos_of_block_tl c 
+    C .code:n = \str_set:Nn \l_@@_hpos_block_str c 
                 \bool_set_true:N \l_@@_hpos_of_block_cap_bool ,
     C .value_forbidden:n = true ,
-    t .code:n = \tl_set:Nn \l_@@_vpos_of_block_tl t ,
+    t .code:n = \str_set:Nn \l_@@_vpos_of_block_tl t ,
     t .value_forbidden:n = true ,
-    b .code:n = \tl_set:Nn \l_@@_vpos_of_block_tl b ,
+    b .code:n = \str_set:Nn \l_@@_vpos_of_block_tl b ,
     b .value_forbidden:n = true ,
     unknown .code:n = \@@_error:n { Unknown~key~for~Block }
   }
@@ -15546,7 +15933,7 @@ version 2005/12/01 or later.
             \bool_if:NF \l_@@_hpos_of_block_cap_bool { - short }
           } 
           {
-            \str_case:Vn \l_@@_hpos_of_block_tl
+            \str_case:Vn \l_@@_hpos_block_str
               {
                 c { center } 
                 l { west } 
@@ -15561,7 +15948,7 @@ version 2005/12/01 or later.
         \pgfnode 
           { rectangle } 
           {
-             \str_case:Vn \l_@@_hpos_of_block_tl
+             \str_case:Vn \l_@@_hpos_block_str
               {
                 c { base } 
                 l { base~west } 
@@ -15582,11 +15969,11 @@ version 2005/12/01 or later.
 % If we are in the first column, we must put the block as if it was with the key~|r|.
 %    \begin{macrocode}
         \int_compare:nNnT { #2 } = 0 
-          { \tl_set:Nn \l_@@_hpos_of_block_tl r }
+          { \str_set:Nn \l_@@_hpos_block_str r }
         \bool_if:nT \g_@@_last_col_found_bool 
           {
             \int_compare:nNnT { #2 } = \g_@@_col_total_int
-              { \tl_set:Nn \l_@@_hpos_of_block_tl l }
+              { \str_set:Nn \l_@@_hpos_block_str l }
           }
         \pgftransformshift
           {
@@ -15596,7 +15983,7 @@ version 2005/12/01 or later.
                 \bool_if:NF \l_@@_hpos_of_block_cap_bool { - short }
               }
               {
-                \str_case:Vn \l_@@_hpos_of_block_tl
+                \str_case:Vn \l_@@_hpos_block_str
                   {
                     c { center } 
                     l { west } 
@@ -15608,7 +15995,7 @@ version 2005/12/01 or later.
         \pgfnode 
           { rectangle } 
           {
-             \str_case:Vn \l_@@_hpos_of_block_tl
+             \str_case:Vn \l_@@_hpos_block_str
               {
                 c { center } 
                 l { west } 
@@ -15997,6 +16384,7 @@ version 2005/12/01 or later.
     \group_end:
   }
 %    \end{macrocode}
+%
 % 
 % \bigskip
 % \subsection*{The redefinition of the command \textbackslash dotfill }
@@ -16030,7 +16418,8 @@ version 2005/12/01 or later.
 % \subsection*{The command \textbackslash diagbox}
 %
 % The command |\diagbox| will be linked to |\diagbox:nn| in the environments of
-% \pkg{nicematrix}. 
+% \pkg{nicematrix}. However, there are also redefinitions of |\diagbox| in other
+% circonstancies.
 %
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_diagbox:nn #1 #2
@@ -16886,7 +17275,6 @@ version 2005/12/01 or later.
   }
   {
     The~available~keys~are~(in~alphabetic~order):~
-    define-L-C-R,~
     footnote,~
     footnotehyper,~
     renew-dots,~and
@@ -16906,20 +17294,8 @@ version 2005/12/01 or later.
 %    \end{macrocode}
 %
 %    \begin{macrocode}
-\@@_msg_new:nn { define-L-C-R }
-  {
-    You~have~used~the~key~'define-L-C-R'.~Please~note~that~this~key~
-    will~probably~be~deleted~in~a~future~version~of~'nicematrix'.\\
-    However,~you~can~go~on.
-  }
-%    \end{macrocode}
-% 
-%    \begin{macrocode}
 \keys_define:nn { NiceMatrix / Package }
   {
-    define-L-C-R .code:n = 
-      \@@_error:n { define-L-C-R }
-      \bool_set_true:N \c_@@_define_L_C_R_bool ,
     renew-dots .bool_set:N = \l_@@_renew_dots_bool ,
     renew-dots .value_forbidden:n = true ,
     renew-matrix .code:n = \@@_renew_matrix: ,
@@ -17236,15 +17612,6 @@ version 2005/12/01 or later.
   }
 %    \end{macrocode}
 % 
-%    \begin{macrocode}
-\@@_msg_new:nn { old~column~type } 
-  {
-    The~column~type~'#1'~is~no~longer~defined~in~'nicematrix'.~
-    Since~version~5.0,~you~have~to~use~'l',~'c'~and~'r'~instead~of~'L',~
-    'C'~and~'R'.~You~can~also~use~the~key~'define-L-C-R'.\\
-    This~error~is~fatal.
-  }
-%    \end{macrocode}
 % 
 %    \begin{macrocode}
 \@@_msg_new:nn { bad~value~for~baseline }
@@ -17288,6 +17655,14 @@ version 2005/12/01 or later.
 %    \end{macrocode}
 % 
 %    \begin{macrocode}
+\@@_msg_new:nn { width~without~X~columns }
+  {
+    You~have~used~the~key~'width'~but~you~have~put~no~'X'~column. \\
+    If~you~go~on,~that~key~will~be~ignored.
+  }
+%    \end{macrocode}
+%
+%    \begin{macrocode}
 \@@_msg_new:nn { empty~environment }
   { Your~\@@_full_name_env:\ is~empty.~This~error~is~fatal. }
 %    \end{macrocode}
@@ -18301,7 +18676,7 @@ version 2005/12/01 or later.
 % \subsection*{Changes between versions 5.16 and 5.17}
 % 
 % The key |define-L-C-R| (only available at load-time) now raises a (non fatal)
-% error (that key will probably be deleted in a future version of \pkg{nicematrix}).
+% error.
 %
 % Keys |L|, |C| and |R| for the command |\Block|.
 % 
@@ -18318,6 +18693,18 @@ version 2005/12/01 or later.
 % 
 % New key |tikz| for the command |\Block|.
 %
+% 
+% \subsection*{Changes between versions 5.19 and 6.0}
+% 
+% Columns |X| and environment |{NiceTabularX}|.
+%
+% Command |\rowlistcolors| available in the |\CodeBefore|.
+%
+% In columns with fixed width, the blocks are composed as paragraphs (wrapping
+% of the lines).
+% 
+% The key |define-L-C-R| has been deleted.
+%
 % \PrintIndex
 % 
 % \tableofcontents
-- 
cgit v1.2.3

