summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-04-01 22:31:00 +0000
committerKarl Berry <karl@freefriends.org>2018-04-01 22:31:00 +0000
commit04258ec87cd14f39ad99958a35b2a23d01260808 (patch)
treed7ea6721ad1e061c95760d0a2f93dcb6e5625320
parent51aa219e9db9d1e481c3b74c818a7f005b3266c6 (diff)
nicematrix (31mar18)
git-svn-id: svn://tug.org/texlive/trunk@47232 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdfbin226936 -> 241359 bytes
-rw-r--r--Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx758
-rw-r--r--Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty218
3 files changed, 674 insertions, 302 deletions
diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf
index 74de874af74..f3ec61447c7 100644
--- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf
+++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx
index 257e1e03a69..c6f81ecfd46 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{1.2}
-\def\myfiledate{2018/03/11}
+\def\myfileversion{1.3}
+\def\myfiledate{2018/03/31}
%
%
%<*batchfile>
@@ -69,15 +69,14 @@ version 2005/12/01 or later.
% \maketitle
%
% \begin{abstract}
-% The LaTeX package \pkg{nicematrix} provides environments |{NiceArray}| and |{NiceMatrix}| similar to the
-% classical environments |{array}| and |{matrix}| but with the possibility to draw continuous ellipsis dots between
-% the cells of the array.
+% The LaTeX package \pkg{nicematrix} provides new environments similar to the classical environments |{array}| and
+% |{matrix}| but with some additional features. Among these features is the possibility to draw continuous ellipsis
+% dots between the cells of the array.
% \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 compilations may be necessary. This package requires the
@@ -108,11 +107,11 @@ version 2005/12/01 or later.
% \end{Verbatim}
%
% \medskip
-% If we load the package \pkg{nicematrix} with the option |Transparent|, the same code will give the
+% If we load the package \pkg{nicematrix} with the option |transparent|, the same code will give the
% following result:
%
% \begin{scope}
-% \NiceMatrixOptions{Transparent}
+% \NiceMatrixOptions{transparent}
% \[A = \begin{pmatrix}
% 1 & \cdots & \cdots & 1 \\
% 0 & \ddots & & \vdots \\
@@ -123,33 +122,26 @@ version 2005/12/01 or later.
%
% \medskip
% The dotted lines are drawn with Tikz. Two compilations may be necessary.
+%
+% \medskip
+% A command |\NiceMatrixOptions| is provided to fix the options (the scope of the options fixed by this command is
+% the current TeX group).
%
%
-% \section{How to use nicematrix for new code}
-%
-% \subsection{The environments NiceArray, NiceMatrix and their variants}
-%
-% The package \pkg{nicematrix} provides new environments |{NiceArray}|, |{NiceMatrix}|, |{pNiceMatrix}|,
-% |{bNiceMatrix}|, |{BNiceMatrix}|, |{vNiceMatrix}| and |{VNiceMatrix}|.
-%
-% The environment |{NiceArray}| is similar to the environment |{array}| defined in LaTeX and redefined in the package
-% \pkg{array}. The environments |{NiceMatrix}|, |{pNiceMatrix}|, etc. are similar to the environments |{matrix}|,
-% |{pmatrix}|, etc. of \pkg{amsmath} (and \pkg{mathtools}).
+% \section{How to use \{NiceMatrix\} for new code}
%
-% The environment |{NiceMatrix}| has the same syntax that the environment |{matrix}| (idem for the variants).
-% However, for the environment |{NiceArray}|, there is a difference: in the preamble of |{NiceArray}|, 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|. It's possible to use the constructions \verb+|+, |>{...}|, |<{...}|, |@{...}|,
-% |!{...}| and |*{n}{...}| but the letters |p|, |m| and |b| should not be used.
+% \subsection{The environment \{NiceMatrix\} and its variants}
%
+% The package \pkg{nicematrix} provides new environments |{NiceMatrix}|, |{pNiceMatrix}|, |{bNiceMatrix}|,
+% |{BNiceMatrix}|, |{vNiceMatrix}| and |{VNiceMatrix}|. By default, these environments behave almost exactly as the
+% corresponding environments of \pkg{amsmath} (and \pkg{mathtools}): |{matrix}|, |{pmatrix}|, |{bmatrix}|,
+% |{Bmatrix}|, |{vmatrix}| and |{Vmatrix}|.
+%
% \smallskip
-% Inside the new environments defined by the package \pkg{nicematrix}, five commands are defined: |\Ldots|,
-% |\Cdots|, |\Vdots|, |\Ddots| and |\Iddots|. These commands are intended to be used in place of |\dots|, |\cdots|,
-% |\vdots|, |\ddots| and |\iddots|.\footnote{The command |\iddots|, defined in \pkg{nicematrix}, is a variant of
-% |\ddots| with dots going forward: \smash{$\iddots$}. If the command |\iddots| is already defined (for example if
-% \pkg{mathdots} is loaded), the previous definition is not overwritten. Note that the package \pkg{yhmath}
-% provides a command |\adots| similar to |\iddots|.}
+% Inside these environments, five 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
+% |\iddots|.\footnote{The command |\iddots|, defined in \pkg{nicematrix}, is a variant of
+% |\ddots| with dots going forward: \smash{$\iddots$}. If |mathdots| is loaded, the version of |mathdots| is used.}
%
% \smallskip
% Each of them must be used alone in the cell of the array and it draws a dotted line between the first non-empty
@@ -274,7 +266,7 @@ version 2005/12/01 or later.
% \end{bNiceMatrix}$
%
% \vskip1cm
-% \subsection{The option NullifyDots}
+% \subsection{The option nullify-dots}
%
% Consider the following matrix composed classicaly with the environment |{pmatrix}|.\par\nobreak
% \medskip
@@ -345,12 +337,11 @@ version 2005/12/01 or later.
%
% \bigskip
% However, one may prefer the geometry of the first matrix $A$ and would like to have such a geometry with a dotted
-% line in the second column. It's possible by using the option |NullifyDots| (and only one instruction |\Vdots| is
+% line in the second column. It's possible by using the option |nullify-dots| (and only one instruction |\Vdots| is
% necessary).\par\nobreak
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=7cm]
-% ~emphase#\NiceMatrixOptions{NullifyDots}@
-% $D = \begin{pNiceMatrix}
+% $D = \begin{pNiceMatrix}[~emphase#nullify-dots@]
% a_0 & b \\
% a_1 & \Vdots \\
% a_2 & \\
@@ -359,48 +350,47 @@ version 2005/12/01 or later.
% a_5 & b
% \end{pNiceMatrix}$
% \end{BVerbatim}
-% {\NiceMatrixOptions{NullifyDots}
-% $D = \begin{pNiceMatrix}
+% $D = \begin{pNiceMatrix}[nullify-dots]
% a_0 & b \\
% a_1 & \Vdots \\
% a_2 & \\
% a_3 & \\
% a_4 & \\
% a_5 & b
-% \end{pNiceMatrix}$}
+% \end{pNiceMatrix}$
%
% \medskip
-% The option |NullifyDots| smashes the instructions |\Ldots| (and the variants) vertically but also horizontally.
+% The option |nullify-dots| smashes the instructions |\Ldots| (and the variants) vertically but also horizontally.
%
% \section{How to use nicematrix for existing code}
%
-% The package \pkg{nicematrix} provides an option called |Transparent| for using existing code transparently in the
-% environments |{matrix}| (not in the environments |{array}|). This option can be set as option of |\usepackage| or
-% with the dedicated command called |\NiceMatrixOptions|.
+% The package \pkg{nicematrix} provides an option called |transparent| for using existing code transparently in the
+% environments |{matrix}|. This option can be set as option of |\usepackage| or with the command
+% |\NiceMatrixOptions|.
%
%
-% In fact, this option is an alias for the conjonction of two options: |RenewDots| and |RenewMatrix|.
+% In fact, this option is an alias for the conjonction of two options: |renew-dots| and |renew-matrix|.
%
% \smallskip
%
% \begin{itemize}
-% \item The option |RenewDots|\par\nobreak
+% \item The option |renew-dots|\par\nobreak
% With this option, the commands |\ldots|, |\cdots|, |\vdots|, |\ddots| and |\iddots|\footnote{The command
% |\iddots| is not a command of LaTeX but is defined by the package \pkg{nicematrix}. If |mathdots| is loaded, the
-% version of |mathdots| is used.} are redefined within the environments |{NiceArray}|, |{NiceMatrix}| and its
-% variants and behave like |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots| and |\Iddots|; the command |\dots| (``automatic
+% version of |mathdots| is used.} are redefined within the environments provided by \pkg{nicematrix}
+% and behave like |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots| and |\Iddots|; the command |\dots| (``automatic
% dots'' of |amsmath| --- and |mathtools|) is also redefined to behave like |\Ldots|.
%
-% \item The option |RenewMatrix|\par\nobreak
+% \item The option |renew-matrix|\par\nobreak
% With this option, the environment |{matrix}| is redefined and behave like |{NiceMatrix}|, and so on for the five
% variants.
% \end{itemize}
%
% \bigskip
-% Therefore, with the option |Transparent|, a classical code gives directly the ouput of \pkg{nicematrix}.\par\nobreak
+% Therefore, with the option |transparent|, a classical code gives directly the ouput of \pkg{nicematrix}.\par\nobreak
% \bigskip
% \begin{BVerbatim}[baseline=c]
-% ~emphase#\NiceMatrixOptions{Transparent}@
+% ~emphase#\NiceMatrixOptions{transparent}@
% \begin{pmatrix}
% 1 & \cdots & \cdots & 1 \\
% 0 & \ddots & & \vdots \\
@@ -410,7 +400,7 @@ version 2005/12/01 or later.
% \end{BVerbatim}
% \hspace{2cm}
% \begin{scope}
-% \NiceMatrixOptions{Transparent}
+% \NiceMatrixOptions{transparent}
% $\begin{pmatrix}
% 1 & \cdots & \cdots & 1 \\
% 0 & \ddots & & \vdots \\
@@ -419,14 +409,141 @@ version 2005/12/01 or later.
% \end{pmatrix}$
% \end{scope}
%
+%
+% \section{The environment \{NiceArray\}}
+%
+% In fact, the environment |{NiceMatrix}| relies upon an environment |{NiceArray}| defined in the package
+% \pkg{nicematrix}.
+%
+% \medskip
+% This environment |{NiceArray}| itself relies upon the environment |{array}| of the package \pkg{array}.\footnote{The
+% environment |{array}| is defined in standard LaTeX but is redefined in the package \pkg{array} (loaded by
+% \pkg{nicematrix}).}
+%
+% \medskip
+% The differences between |{NiceArray}| and |{array}| are as follow.
+% \begin{itemize}
+% \item The commands |\Cdots| and its variants are available in the environment |{NiceArray}|.
+% \item The environment |{NiceArray}| accepts (between brackets) the options |t|, |c| and |b| as the classical
+% |{array}| but also the following options defined by \pkg{nicematrix}: |renew-dots|, |nullify-dots|,
+% |exterior-arraycolsep| and |parallelize-diags| (these last two options are technical options described further).
+% \item For technical reasons, in the preamble of |{NiceArray}|, 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|. It's possible to use the constructions \verb+|+, |>{...}|, |<{...}|, |@{...}|,
+% |!{...}| and |*{n}{...}| but the letters |p|, |m| and |b| should not be used.
+% \end{itemize}
+%
+%
+% \vspace{1cm}
+% An example with a linear system (we need |{NiceArray}| for the vertical rule):
+%
+% \bigskip
+% \begin{BVerbatim}[baseline=c]
+% $\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}
+% \hspace{2.5cm}
+% $\left[\begin{NiceArray}{CCCC|C}
+% a_1 & ? & \Cdots & ? & ? \\
+% 0 & & \Ddots & \Vdots & \Vdots\\
+% \Vdots & \Ddots & \Ddots & ? \\
+% 0 & \Cdots & 0 & a_n & ? \\
+% \end{NiceArray}\right]$
+%
+% \vspace{1cm}
+% An example where we use |{NiceArray}| because we want to use the types |L| and |R| for the columns:
+%
+% \bigskip
+% \begin{BVerbatim}[baseline=c]
+% $\left(\begin{NiceArray}{LCR}
+% a_{11} & \Cdots & a_{1n} \\
+% a_{21} & & a_{2n} \\
+% \Vdots & & \Vdots \\
+% a_{n-1,1} & \Cdots & a_{n-1,n} \\
+% \end{NiceArray}\right)$
+% \end{BVerbatim}
+% \hspace{4cm}
+% $\left(\begin{NiceArray}{LCR}
+% a_{11} & \Cdots & a_{1n} \\
+% a_{21} & & a_{2n} \\
+% \Vdots & & \Vdots \\
+% a_{n-1,1} & \Cdots & a_{n-1,n} \\
+% \end{NiceArray}\right)$
+%
+%
+% \section{The environment \{pNiceArrayC\} and its variants}
+%
+% The package \pkg{nicematrix} provides also environments to compose matrices with an exterior column, that is to
+% say on the right of the closing delimiter. These environments are |{pNiceArrayC}|, |{vNiceArrayC}|,
+% |{VNiceArrayC}|, |{bNiceArrayC}| and |{BNiceArrayC}| (there is no environment |{NiceArrayC}| since such an
+% environment would logically be equivalent to |{NiceArray}|).
+%
+% All these environments have the same characteristics even if, for sake of simplicity, we will speak only of
+% |{pNiceArrayC}|.
+%
+% \medskip
+% \begin{itemize}
+% \item The command |\Cdots| and its variants are available in |{pNiceArrayC}|.
+% \item The environment |{pNiceArrayC}| takes a mandatory argument which is the preamble of the array. The types
+% of columns available are the same as for the environment |{NiceArray}|. \emph{However, no specification must be
+% given for the last column:} it will automatically (and necessarily) be a column~|L|.
+% \item The options available are |renew-dots|, |nullify-dots|, |parallelize-diags| (this technical option is
+% described further) and |code-for-last-col|. This last option specifies tokens that will be inserted before each
+% cell of the last column, \emph{before} the symbol |$| of the math mode.
+% \end{itemize}
+%
+%
+% \bigskip
+% \begin{BVerbatim}[baseline=c]
+% \begin{pNiceArrayC}{RRRR|R}[~emphase#code-for-last-col={\small\color{blue}}@]
+% 1& 2& 2& 3& -2 \\
+% 0& 0& -1& 5& -5 & L_2 \gets 2L_1-L_2 \\
+% 0& -1& -3& 3& -7 & L_3 \gets L_1-L_3
+% \end{pNiceArrayC}
+% \end{BVerbatim}
+%
+% \smallskip
+% \[\begin{pNiceArrayC}{RRRR|R}[code-for-last-col={\small\color{blue}}]
+% 1& 2& 2& 3& -2 \\
+% 0& 0& -1& 5& -5 & L_2 \gets 2L_1-L_2 \\
+% 0& -1& -3& 3& -7 & L_3 \gets L_1-L_3
+% \end{pNiceArrayC}\]
+%
+% \bigskip
+%
+% \begin{Verbatim}
+% $\begin{pNiceArrayC}{*6C|C}[nullify-dots,code-for-last-col={\small}]
+% 1 & 1 & 1 &\Cdots & & 1 & 0 & \\
+% 0 & 1 & 0 &\Cdots & & 0 & & L_2 \gets L_2-L_1 \\
+% 0 & 0 & 1 &\Ddots & & \Vdots & & L_3 \gets L_3-L_1 \\
+% & & &\Ddots & & & \Vdots & \Vdots \\
+% \Vdots & & &\Ddots & & 0 & \\
+% 0 & & &\Cdots & 0 & 1 & 0 & L_n \gets L_n-L_1
+% \end{pNiceArrayC}$
+% \end{Verbatim}
+%
+% \[\begin{pNiceArrayC}{*6C|C}[nullify-dots,code-for-last-col={\small}]
+% 1 & 1 & 1 &\Cdots & & 1 & 0 & \\
+% 0 & 1 & 0 &\Cdots & & 0 & & L_2 \gets L_2-L_1 \\
+% 0 & 0 & 1 &\Ddots & & \Vdots & & L_3 \gets L_3-L_1 \\
+% & & &\Ddots & & & \Vdots & \Vdots \\
+% \Vdots & & &\Ddots & & 0 & \\
+% 0 & & &\Cdots & 0 & 1 & 0 & L_n \gets L_n-L_1
+% \end{pNiceArrayC}\]
+%
%
% \section{Technical remarks}
%
% \subsection{Diagonal lines}
%
-% By default, all the diagonal lines of a same matrix are ``parallelized''. That means that the first diagonal line
+% By default, all the diagonal lines 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 of the instructions |\Ddots| in the matrix can have a marked
+% extremity of the line). That's why the position of the instructions |\Ddots| in the array can have a marked
% effect on the final result.
%
% \medskip
@@ -453,7 +570,7 @@ version 2005/12/01 or later.
% \end{pNiceMatrix}$
%
% \bigskip
-% \NiceMatrixOptions{ParallelizeDiagonals=true}%
+% \NiceMatrixOptions{parallelize-diags=true}%
% \begin{minipage}{9.5cm}
% % \begin{Verbatim}
% $A = \begin{pNiceMatrix}
@@ -472,13 +589,12 @@ version 2005/12/01 or later.
% \end{pNiceMatrix}$
%
% \bigskip
-% It's possible to turn off the parallelization with the option |ParallelizeDiagonals| set to |false|: \par\nobreak
+% It's possible to turn off the parallelization with the option |parallelize-diags| set to |false|: \par\nobreak
%
% \medskip
-% \NiceMatrixOptions{ParallelizeDiagonals=false}%
+% \NiceMatrixOptions{parallelize-diags=false}%
% \begin{minipage}{9.5cm}
-% The same example without parallelization:\\
-% |\NiceMatrixOptions{ParallelizeDiagonals=false}|.
+% The same example without parallelization:
% \end{minipage}
% $A = \begin{pNiceMatrix}
% 1 & \Cdots & & 1 \\
@@ -495,7 +611,7 @@ version 2005/12/01 or later.
%
% An instruction like |\Ldots|, |\Cdots|, etc. tries to determine the first non-empty cell on both
% sides\footnote{If \pkg{nicematrix} can't find theses cells, an error |Imposible instruction| is raised. Nevertheless,
-% with the option |Silent|, these instructions are discarded silently.}. However, a empty cell is not necessarily a
+% with the option |silent|, these instructions are discarded silently.}. However, a empty cell is not necessarily a
% cell with no TeX content (that is to say a cell with no token between the two ampersands~|&|). Indeed, a cell
% with contents |\hspace*{1cm}| may be considered as empty.
%
@@ -523,32 +639,32 @@ version 2005/12/01 or later.
%
% \medskip
% \item A cell with a command |\Hspace| (or |\Hspace*|) is empty. This command |\Hspace| is a command defined by
-% the package \pkg{nicematrix} with the same meaning that |\hspace| except that the cell where it is used is
+% the package \pkg{nicematrix} with the same meaning as |\hspace| except that the cell where it is used is
% considered as empty. This command can be used to fix the width of some columns of the matrix without interfering
% with \pkg{nicematrix}.
% % \end{itemize}
%
% \interitem
% A dotted line must be delimited by two non-empty cells. If it's not possible to find one of these cells whitin
-% the boudaries of the matrix, an error is issued and the instruction is ignored.
+% the boundaries of the matrix, an error is issued and the instruction is ignored.
%
% \vspace{1cm}
% \subsection{The option exterior-arraycolsep}
%
% The environment |{array}| inserts un horizontal space equal to |\arraycolsep| before and after each column. In
% particular, there is a space equal to |\arraycolsep| before and after the array. This feature of the environment
-% |{array}| was probably not a good idea.\footnote{In the documentation of |{amsmath}|, we can read: \itshape The
+% |{array}| was probably not a good idea.\footnote{In the documentation of |{amsmath}|, we can read: {\itshape The
% extra space of |\arraycolsep| that \pkg{array} adds on each side is a waste so we remove it [in |{matrix}|]
-% (perhaps we should instead remove it from array in general, but that's a harder task).}
+% (perhaps we should instead remove it from array in general, but that's a harder task).} It's possible to suppress
+% these spaces for a given environment |{array}| with a construction like |\begin{array}{@{}ccccc@{}}|.}
%
% The environment |{matrix}| and its variants (|{pmatrix}|, |{vmatrix}|, etc.) of \pkg{amsmath} and \pkg{mathtools}
% prefer to delete these spaces with explicit instructions |\hskip -\arraycolsep| and |{NiceArray}| does likewise.
%
-% However, the user can change this behaviour with the boolean option |exterior-arraycolsep|. With this option
-% \footnote{The option |exterior-arraycolsep| can be set globally with |\NiceMatrixOptions| but also locally as an
-% option of a given environment |{NiceArray}|. In this case, it's also possible to give the traditionnal option
-% |t|, |c| or |b| of a environment |{array}|: |\begin{NiceArray}[exterior-arraycolsep,t]...|}, the environment
-% |{NiceArray}| will insert the sames horizontal spaces as the environment |{array}| of LaTeX and \pkg{array}.
+% However, the user can change this behaviour with the boolean option |exterior-arraycolsep|. With this option,
+% |{NiceArray}| will insert the same horizontal spaces as the environment |{array}|. This
+% option can be set as an option of an environment |{NiceArray}| (between square brackets) or with the command
+% |\NiceMatrixOptions|.
%
%
% \section{Examples}
@@ -558,8 +674,7 @@ version 2005/12/01 or later.
%
% \bigskip
% \begin{BVerbatim}[baseline=c]
-% \NiceMatrixOptions{NullifyDots}
-% $\begin{pNiceMatrix}
+% $\begin{pNiceMatrix}[nullify-dots]
% a & b & 0 & & \Cdots & 0 \\
% b & a & b & \Ddots & & \Vdots \\
% 0 & b & a & \Ddots & & \\
@@ -569,9 +684,7 @@ version 2005/12/01 or later.
% \end{pNiceMatrix}$
% \end{BVerbatim}
% \hspace{1.5cm}
-% \begin{scope}
-% \NiceMatrixOptions{NullifyDots}
-% $\begin{pNiceMatrix}
+% $\begin{pNiceMatrix}[nullify-dots]
% a & b & 0 & & \Cdots & 0 \\
% b & a & b & \Ddots & & \Vdots \\
% 0 & b & a & \Ddots & & \\
@@ -579,7 +692,6 @@ version 2005/12/01 or later.
% \Vdots & & & & & b \\
% 0 & \Cdots & & 0 & b & a
% \end{pNiceMatrix}$
-% \end{scope}
%
% \vspace{2cm}
%
@@ -628,87 +740,27 @@ version 2005/12/01 or later.
% \end{pNiceMatrix}$
%
%
-%
-%
-% \vspace{2cm}
-% An example with a linear system (we need |{NiceArray}| for the vertical line):
-%
-% \bigskip
-% \begin{BVerbatim}[baseline=c]
-% $\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}
-% \hspace{2.5cm}
-% $\left[\begin{NiceArray}{CCCC|C}
-% a_1 & ? & \Cdots & ? & ? \\
-% 0 & & \Ddots & \Vdots & \Vdots\\
-% \Vdots & \Ddots & \Ddots & ? \\
-% 0 & \Cdots & 0 & a_n & ? \\
-% \end{NiceArray}\right]$
-%
-% \vspace{2cm}
-% An example where we use |{NiceArray}| because we want to use the types |L| and |R| for the columns:
-%
-% \bigskip
-% \begin{BVerbatim}[baseline=c]
-% $\left(\begin{NiceArray}{LCR}
-% a_{11} & \Cdots & a_{1n} \\
-% a_{21} & & a_{2n} \\
-% \Vdots & & \Vdots \\
-% a_{n-1,1} & \Cdots & a_{n-1,n} \\
-% \end{NiceArray}\right)$
-% \end{BVerbatim}
-% \hspace{4cm}
-% $\left(\begin{NiceArray}{LCR}
-% a_{11} & \Cdots & a_{1n} \\
-% a_{21} & & a_{2n} \\
-% \Vdots & & \Vdots \\
-% a_{n-1,1} & \Cdots & a_{n-1,n} \\
-% \end{NiceArray}\right)$
-%
-%
-% \vspace{2cm}
-%
-% Another example with |{NiceArray}|:
%
-% \begin{Verbatim}
-% \left(\begin{~emphase#NiceArray@}{*4{C}|*4{C}}
-% 1 &\Cdots& &1 &2 &\Cdots& &2 \\
-% \Vdots& & & & & & &\Vdots\\
-% & & &\Vdots&\Vdots& & & \\
-% 1 & &\Cdots&1 & & & & \\
-% \cline{1-4}
-% 0 &\Cdots& &0 & & & & \\
-% \Vdots& & & & & & & \\
-% & & &\Vdots&\Vdots& & & \\
-% 0 & &\Cdots&0 &2 & &\Cdots&2
-% \end{~emphase#NiceArray@}\right)
-% \end{Verbatim}
-%
%
-%\[A=\left(\begin{NiceArray}{*4{C}|*4{C}}
-% 1 &\Cdots& &1 &2 &\Cdots& &2 \\
-% \Vdots& & & & & & &\Vdots\\
-% & & &\Vdots&\Vdots& & & \\
-% 1 & &\Cdots&1 & & & & \\
-% \cline{1-4}
-% 0 &\Cdots& &0 & & & & \\
-% \Vdots& & & & & & & \\
-% & & &\Vdots&\Vdots& & & \\
-% 0 & &\Cdots&0 &2 & &\Cdots&2
-% \end{NiceArray}\right)\]
+% \vspace{1cm}
%
+% \section{Implementation}
%
+% By default, the package \pkg{nicematrix} doesn't patch any existing code.
%
-%
-%
-% \vspace{1cm}
+% \smallskip
+% However, when the option |renew-dots| is used, the commands |\cdots|, |\ldots|, |\dots|, |\vdots|, |\ddots| and
+% |\iddots| are redefined in the environments provided by \pkg{nicematrix} as explained previously. In the same way,
+% if the option |renew-matrix| is used, the environment |{matrix}| of \pkg{amsmath} (and \pkg{mathtools}) is
+% redefined.
%
-% \section{Implementation}
+% \smallskip
+% On the other hand, the environnement |{array}| is never redefined.
+%
+% \smallskip
+% Of course, the package \pkg{nicematrix} uses the features of the package \pkg{array}. It tries to be independant of its
+% implementation. Unfortunately, it was not possible to be strictly independant: the package \pkg{nicematrix} relies upon the
+% fact that the package |{array}| uses |\ialign| to begin the |\halign|.
%
% \subsection{Declaration of the package and extensions loaded}
%
@@ -763,12 +815,12 @@ version 2005/12/01 or later.
%
% \bigskip
% In the environment |{NiceMatrix}|, the command |\multicolumn| will be linked to the following command
-% |\@@_multicolumn:| but only if the option |RenewMatrix| is not set. Indeed, if the option |RenewMatrix| is used,
+% |\@@_multicolumn:| but only if the option |renew-matrix| is not set. Indeed, if the option |renew-matrix| is used,
% we want to let the possibility to the user to use |\multicolumn| (or |\hdotsfor| of \pkg{amsmath}) in some
% matrices without dotted lines and to have the automatic dotted lines of \pkg{nicematrix} in other matrices.
% \begin{macrocode}
\cs_new_protected:Nn \@@_multicolumn:nn
- {\msg_error:nn {nicematrix} {multicolumn~forbidden}}
+ {\msg_error:nn {nicematrix} {Multicolumn~forbidden}}
% \end{macrocode}
% This command |\@@_multicolumn:nn| takes two arguments, and therefore, the first two arguments of |\column| will
% be gobbled.
@@ -783,9 +835,18 @@ version 2005/12/01 or later.
% \bigskip
% \subsection{The options}
%
+% The token list |\l_@@_pos_env_tl| will contains one of the three values |t|, |c| or |b| and will indicate to
+% position of the environment as in the option of the environment |{array}|. For the environment |{NiceMatrix}|
+% (and its variants) and |{pNiceArrayC}| (and its variants), the value will programmatically be fixed to |c|. For the
+% environment |{NiceArray}|, however, the three values |t|, |c| and |b| are possible.
+% \begin{macrocode}
+\tl_new:N \l_@@_pos_env_tl
+\tl_set:Nn \l_@@_pos_env_tl c
+% \end{macrocode}
+%
% The boolean |\l_@@_exterior_arraycolsep_bool| corresponds to the option |exterior-arraycolsep|. If this option is
-% set, a space equal to |\arraycolsep| will be put on both sides of an environment |{NiceArray}| (but not for
-% |{NiceMatrix}| and its variants).
+% set, a space equal to |\arraycolsep| will be put on both sides of an environment |{NiceArray}| (but neither for
+% |{NiceMatrix}| and its variants nor |{pNiceArrayC}| and its variants even if these environments relies upon |{NiceArray}|).
% \begin{macrocode}
\bool_new:N \l_@@_exterior_arraycolsep_bool
% \end{macrocode}
@@ -799,7 +860,7 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% The flag |\l_@@_nullify_dots_bool| corresponds to the option |NullifyDots|. When the flag is down, the
+% The flag |\l_@@_nullify_dots_bool| corresponds to the option |nullify-dots|. When the flag is down, the
% instructions like |\vdots| are inserted within a |\hphantom| (and so the constructed matrix has exactly the same
% size as a matrix constructed with the classical |{matrix}| and |\ldots|, |\vdots|, etc.)
% \begin{macrocode}
@@ -807,76 +868,140 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% The flag |\l_@@_renew_matrix_bool| will be raised if the option |RenewMatrix| is used.
+% The flag |\l_@@_renew_matrix_bool| will be raised if the option |renew-matrix| is used.
% \begin{macrocode}
\bool_new:N \l_@@_renew_matrix_bool
% \end{macrocode}
%
% \bigskip
-% We define a set of options which will be used with the command |NiceMatrixOptions|.
+% The token list |\l_@@_code_for_last_col_tl| will contains code inserted at the beginning of each cell\footnote{At
+% the beginning of each cell but before the character |$| of the mathematical mode.} of the last
+% column in the environment |{pNiceArrayC}| (and its variants). It corresponds to the option |code-for-last-col|.
+% \begin{macrocode}
+\tl_new:N \l_@@_code_for_last_col_tl
+% \end{macrocode}
+%
+% \bigskip
+% We define a set of options which will be used with the command |NiceMatrixOptions|.\footnote{Before the version
+% 1.3, the names of the options were in ``caml style'' (like |ParallelizeDiagonals|) which was not a good idea. In
+% version 1.4, the names are converted in lowercase with hyphens (like |parallelize-diags|). For compatibility, the
+% old names are conversed.}
% \begin{macrocode}
-\keys_define:nn {NiceMatrix}
- {ParallelizeDiagonals .bool_set:N = \l_@@_parallelize_diags_bool,
- ParallelizeDiagonals .default:n = true,
+\keys_define:nn {NiceMatrix/NiceMatrixOptions}
+ {parallelize-diags .bool_set:N = \l_@@_parallelize_diags_bool,
+ parallelize-diags .default:n = true,
+ ParallelizeDiagonals .meta:n = parallelize-diags,
% \end{macrocode}
%
% \bigskip
-% With the option |RenewDots|, the command |\cdots|, |\ldots|, |\vdots| and |\ddots| are redefined and behave like the
+% With the option |renew-dots|, the command |\cdots|, |\ldots|, |\vdots| and |\ddots| are redefined and behave like the
% commands |\Cdots|, |\Ldots|, |\Vdots| and |\Ddots|.
% \begin{macrocode}
- RenewDots .bool_set:N = \l_@@_renew_dots_bool,
- RenewDots .default:n = true,
+ renew-dots .bool_set:N = \l_@@_renew_dots_bool,
+ renew-dots .default:n = true,
+ RenewDots .meta:n = renew-dots,
% \end{macrocode}
%
% \bigskip
-% With the option |RenewMatrix|, the environment |{matrix}| of \pkg{amsmath} and its variants are redefined to
+% With the option |renew-matrix|, the environment |{matrix}| of \pkg{amsmath} and its variants are redefined to
% behave like the environment |{NiceMatrix}| and its variants.
% \begin{macrocode}
- RenewMatrix .code:n = {\cs_set_eq:NN \env@matrix \NiceMatrix
- \bool_set_true:N \l_@@_renew_matrix_bool},
- RenewMatrix .default:n = true,
- Transparent .meta:n = {RenewDots,RenewMatrix},
- Transparent .value_forbidden:n = true,
+ renew-matrix .code:n = {\cs_set_eq:NN \env@matrix \NiceMatrix
+ \bool_set_true:N \l_@@_renew_matrix_bool},
+ renew-matrix .value_forbidden:n = true,
+ RenewMatrix .meta:n = renew-matrix,
+ transparent .meta:n = {renew-dots,renew-matrix},
+ transparent .value_forbidden:n = true,
+ Transparent .meta:n = transparent,
% \end{macrocode}
%
% \bigskip
-% Without the option |NullifyDots|, the instructions like |\vdots| are inserted within a
+% Without the option |nullify-dots|, the instructions like |\vdots| are inserted within a
% |\hphantom| (and so the constructed matrix has exactly the same size as a matrix constructed with the
% classical |{matrix}| and |\ldots|, |\vdots|, etc.). This option is set by default.
% \begin{macrocode}
- NullifyDots .bool_set:N = \l_@@_nullify_dots_bool ,
- NullifyDots .default:n = true,
+ nullify-dots .bool_set:N = \l_@@_nullify_dots_bool ,
+ nullify-dots .default:n = true,
+ NullifyDots .meta:n = nullify-dots,
% \end{macrocode}
%
% \bigskip
-% With the option |Silent|, no error is generated for the impossible instructions. This option can be useful when
+% With the option |silent|, no error is generated for the impossible instructions. This option can be useful when
% adapting an existing code.
% \begin{macrocode}
- Silent .code:n = {\msg_redirect_name:nnn {nicematrix}
- {Impossible~instruction}
- {none}} ,
- Silent .value_forbidden:n = true}
+ silent .code:n = {\msg_redirect_name:nnn {nicematrix}
+ {Impossible~instruction}
+ {none}} ,
+ silent .value_forbidden:n = true,
+ Silent .meta:n = silent,
+% \end{macrocode}
+%
+% \bigskip
+% The following option is only for the environment |{pNiceArrayC}| and its variants. It will contains code inserted
+% at the beginning of each cell of the last column.\footnote{In an environment |{pNiceArrayC}|, the last column is
+% composed outside the parentheses of the array.}
+% \begin{macrocode}
+ code-for-last-col .tl_set:N = \l_@@_code_for_last_col_tl,
+ code-for-last-col .value_required:n = true,
+% \end{macrocode}
+%
+% \bigskip
+% The option |exterior-arraycolsep| will have effect only in |{NiceArray}| for those who want to have for
+% |{NiceArray}| the same behaviour as |{array}|.
+% \begin{macrocode}
+ exterior-arraycolsep .bool_set:N = \l_@@_exterior_arraycolsep_bool ,
+ exterior-arraycolsep .default:n = true,
+ unknown .code:n = \msg_error:nn {nicematrix} {Option~unknown}}
% \end{macrocode}
%
% \bigskip
% |\NiceMatrixOptions| is the command of the \pkg{nicematrix} package to fix options at the document level. The
-% scope of these specification is the current TeX group.
+% scope of these specifications is the current TeX group.
% \begin{macrocode}
\NewDocumentCommand \NiceMatrixOptions {m}
- {\keys_set:nn {NiceMatrix} {#1}}
+ {\keys_set:nn {NiceMatrix/NiceMatrixOptions} {#1}}
% \end{macrocode}
%
+%
+% \bigskip
+% \begin{macrocode}
+\keys_define:nn {NiceMatrix/NiceMatrix}
+ {parallelize-diags .bool_set:N = \l_@@_parallelize_diags_bool,
+ parallelize-diags .default:n = true,
+ renew-dots .bool_set:N = \l_@@_renew_dots_bool,
+ renew-dots .default:n = true,
+ nullify-dots .bool_set:N = \l_@@_nullify_dots_bool ,
+ nullify-dots .default:n = true,
+ unknown .code:n = \msg_error:nn {nicematrix} {Option~unknown}}
+% \end{macrocode}
+%
% \bigskip
-% \subsection{The environments NiceArray and NiceMatrix}
-%
-% First, we define a set of keys named |{NiceArray}|.
% \begin{macrocode}
-\keys_define:nn {NiceArray}
- {exterior-arraycolsep .bool_set:N = \l_@@_exterior_arraycolsep_bool ,
- exterior-arraycolsep .default:n = true}
+\keys_define:nn {NiceMatrix/NiceArray}
+ {parallelize-diags .bool_set:N = \l_@@_parallelize_diags_bool,
+ parallelize-diags .default:n = true,
+ renew-dots .bool_set:N = \l_@@_renew_dots_bool,
+ renew-dots .default:n = true,
+ nullify-dots .bool_set:N = \l_@@_nullify_dots_bool ,
+ nullify-dots .default:n = true,
+ exterior-arraycolsep .bool_set:N = \l_@@_exterior_arraycolsep_bool ,
+ exterior-arraycolsep .default:n = true,
+% \end{macrocode}
+%
+% \bigskip
+% The options |c|, |t| and |b| of the environment |{NiceArray}| have the same meaning as the option of the classical
+% environment |{array}|.
+% \begin{macrocode}
+ c .code:n = \tl_set:Nn \l_@@_pos_env_tl c,
+ t .code:n = \tl_set:Nn \l_@@_pos_env_tl t,
+ b .code:n = \tl_set:Nn \l_@@_pos_env_tl b,
+ unknown .code:n = \msg_error:nn {nicematrix} {Option~unknown}}
% \end{macrocode}
%
+%
% \bigskip
+% \subsection{The environments \{NiceArray\} and \{NiceMatrix\}}
+%
% The pseudo-environment |\@@_Cell:n|--|\@@_end_Cell:| will be used to format the cells of the array. In the code,
% the affectations are global because this pseudo-environment will be used in the cells of a |\halign| (via an
% environment |{array}|).
@@ -897,7 +1022,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\tikz[remember~picture, inner~sep = 0pt, minimum~width = 0pt, baseline]
\node [anchor=base] (nm-\int_use:N \g_@@_env_int-
- \int_use:N \g_@@_line_int-
+ \int_use:N \g_@@_row_int-
\int_use:N \g_@@_column_int)
\bgroup $} % $
% \end{macrocode}
@@ -913,7 +1038,7 @@ version 2005/12/01 or later.
% In order to clarify the explanations, we will first give the definition of the environment |{NiceMatrix}|.
%
% Our environment |{NiceMatrix}| must have the same second part as the environment |{matrix}| of \pkg{amsmath}
-% (because of the programmation of the option |RenewMatrix|). Hence, this second part is the following:
+% (because of the programmation of the option |renew-matrix|). Hence, this second part is the following:
%
% \begin{Verbatim}
% \endarray
@@ -926,8 +1051,10 @@ version 2005/12/01 or later.
% \medskip
% Here's the definition of |{NiceMatrix}|:
% \begin{macrocode}
-\NewDocumentEnvironment {NiceMatrix} {}
- {\bool_set_false:N \l_@@_exterior_arraycolsep_bool
+\NewDocumentEnvironment {NiceMatrix} {O{}}
+ {\keys_set:nn {NiceMatrix/NiceMatrix} {#1}
+ \tl_set:Nn \l_@@_pos_env_tl c
+ \bool_set_false:N \l_@@_exterior_arraycolsep_bool
\NiceArray{*\c@MaxMatrixCols{C}}}
{\endarray
\skip_horizontal:n {-\arraycolsep}}
@@ -942,28 +1069,24 @@ version 2005/12/01 or later.
% \end{itemize}
%
% \begin{macrocode}
-\NewDocumentEnvironment {NiceArray} {O{} m}
+\NewDocumentEnvironment {NiceArray} {O{} m O{}}
{\aftergroup \@@_draw_lines:
-% \end{macrocode}
-% First, we test wether there is the option |exterior-arraycolsep|. The other options (|t|, |c| or |b|) will be
-% stored in |\l_tmpa_tl| and passed to |\array| (see below).
-% \begin{macrocode}
- \keys_set_known:nnN {NiceArray} {#1} \l_tmpa_tl
+ \keys_set:nn {NiceMatrix/NiceArray} {#1,#3}
% \end{macrocode}
% The environment |{array}| uses internally the command |\ialign| and, in particular, this command |\ialign| sets
-% |\everycr| to |{}|. However, we want to use |\everycr| in our array (in particular to increment |\g_@@_line_int|).
+% |\everycr| to |{}|. However, we want to use |\everycr| in our array (in particular to increment |\g_@@_row_int|).
% The solution is to give to |\ialign| a new definition (giving to |\everycr| the value we want)
% that will revert automatically to its default definition after the first utilisation.\footnote{With this programmation, we will
% have, in the cells of the array, a clean version of |\ialign|. That's necessary: the user will probably not employ directly
% |\ialign| in the array... but more likely environments that utilize |\ialign| internally (e.g.: |{substack}|)}
% \begin{macrocode}
\cs_set:Npn \ialign
- {\everycr{\noalign{\int_gincr:N \g_@@_line_int
+ {\everycr{\noalign{\int_gincr:N \g_@@_row_int
\int_gzero:N \g_@@_column_int
% \end{macrocode}
-% We want to have the preamble of the array in |\g_@@_preamble_tl| at the end of the array. However, some lines of the array
-% may be shorter (that is to say without all the ampersands) and it's not possible to known which line will be the
-% longest. That's why, during the construction of a line, we retrieve the corresponding preamble in
+% We want to have the preamble of the array in |\g_@@_preamble_tl| at the end of the array. However, some rows of the array
+% may be shorter (that is to say without all the ampersands) and it's not possible to known which row will be the
+% longest. That's why, during the construction of a row, we retrieve the corresponding preamble in
% |\g_@@_preamble_aux_tl|. At the end of the array, we are sure that the longest value will be the real preamble of
% the array (stored in |\g_@@_preamble_tl|).
% \begin{macrocode}
@@ -1005,64 +1128,63 @@ version 2005/12/01 or later.
%
% We increment the counter |\g_@@_env_int| which counts the environments |{NiceArray}|.
% \begin{macrocode}
- \int_gincr:N \g_@@_env_int
+ \int_gincr:N \g_@@_env_int
% \end{macrocode}
%
% We have to remind the types of the columns (|l|, |c| or |r|) because we will use this information when we will
% draw the vertical dotted lines. That's why we store the types of the columns in |\g_@@_preamble_tl| (for example,
-% if the preamble of |{NiceArray}| is |L*4{C}R|, the final value of |\g_@@_preamble_tl| will be |lccccr|).
+% if the preamble of |{NiceArray}| is |L*4{C}R|, the final value of |\g_@@_preamble_tl| will be |lccccr| if the
+% user really uses the six columns).
% \begin{macrocode}
\tl_clear_new:N \g_@@_preamble_tl
\tl_clear_new:N \g_@@_preamble_aux_tl
% \end{macrocode}
%
% The sequence |\g_@@_empty_cells_seq| will contains a list of ``empty'' cells (not all the empty cells of the
-% matrix). If we want to indicate that the cell in line~$i$ and line~$j$ must be considered as empty, the token
+% matrix). If we want to indicate that the cell in row~$i$ and column~$j$ must be considered as empty, the token
% list ``|i-j|'' will be put in this sequence.
% \begin{macrocode}
- \seq_gclear_new:N \g_@@_empty_cells_seq
+ \seq_gclear_new:N \g_@@_empty_cells_seq
% \end{macrocode}
%
% The counter |\g_@@_instruction_int| will count the instructions (|\Cdots|, |\Vdots|, |\Ddots|, etc.) in the matrix.
% \begin{macrocode}
- \int_gzero_new:N \g_@@_instruction_int
+ \int_gzero_new:N \g_@@_instruction_int
% \end{macrocode}
%
-% The counter |\g_@@_line_int| will be used to count the lines of the array (its incrementation will be in
-% |\everycr|). At the end of the environment |{array}|, this counter will give the total number of lines of the matrix.
+% The counter |\g_@@_row_int| will be used to count the rows of the array (its incrementation will be in
+% |\everycr|). At the end of the environment |{array}|, this counter will give the total number of rows of the matrix.
% \begin{macrocode}
- \int_gzero_new:N \g_@@_line_int
+ \int_gzero_new:N \g_@@_row_int
% \end{macrocode}
%
% The counter |\g_@@_column_int| will be used to count the columns of the array (it will be set to zero in
% |\everycr|). This counter is updated in the command |\@@_Cell:n| executed at the beginning of each cell. At the
% end of the array (in the beginning of |\@@_draw_lines:|), it will be set to the total number of columns of the array.
% \begin{macrocode}
- \int_gzero_new:N \g_@@_column_int
- \cs_set_eq:NN \@ifnextchar \new@ifnextchar
+ \int_gzero_new:N \g_@@_column_int
+ \cs_set_eq:NN \@ifnextchar \new@ifnextchar
% \end{macrocode}
%
% The extra horizontal spaces on both sides of an environment |{array}| should be considered as a bad idea of
% standard LaTeX. In the environment |{matrix}| the package \pkg{amsmath} prefers to suppress these spaces with
-% intructions ``|\hskip -\arraycolsep|''. In the same way, we decide to suppress them in |{NiceArray}|. However, for better
+% instructions ``|\hskip -\arraycolsep|''. In the same way, we decide to suppress them in |{NiceArray}|. However, for better
% compatibility, we give an option |exterior-arraycolsep| to control this feature.
% \begin{macrocode}
- \bool_if:NF \l_@@_exterior_arraycolsep_bool
+ \bool_if:NF \l_@@_exterior_arraycolsep_bool
{\skip_horizontal:n {-\arraycolsep}}
% \end{macrocode}
%
-% Eventually, the environment |{NiceArray}| is defined upon the environment |{array}|. As said previously, we must
-% use |\array| and not |\begin{array}|. The token list |\l_tmpa_tl| contains the options given to the environment
-% |{NiceArray}| that have not been catched by the set of keys |NiceArray| (|\l_tmpa_tl| should be equal to |t|,
-% |c|, |b| or the empty list).
+% Eventually, the environment |{NiceArray}| is defined upon the environment |{array}|. The token list |l_@@_pos_tl|
+% will contain one of the values |t|, |c| or |b|.
% \begin{macrocode}
- \array[\l_tmpa_tl]{#2}}
+ \array[\l_@@_pos_env_tl]{#2}}
% \end{macrocode}
%
% \bigskip
% \begin{macrocode}
- {\endarray
- \bool_if:NF \l_@@_exterior_arraycolsep_bool
+ {\endarray
+ \bool_if:NF \l_@@_exterior_arraycolsep_bool
{\skip_horizontal:n {-\arraycolsep}}}
% \end{macrocode}
%
@@ -1084,19 +1206,19 @@ version 2005/12/01 or later.
% \begin{macrocode}
\NewDocumentEnvironment {BNiceMatrix} {}
{\left\{\begin{NiceMatrix}}
- {\end{BNiceMatrix}\right\}}
+ {\end{NiceMatrix}\right\}}
% \end{macrocode}
%
% \begin{macrocode}
\NewDocumentEnvironment {vNiceMatrix} {}
{\left\lvert\begin{NiceMatrix}}
- {\end{BNiceMatrix}\right\rvert}
+ {\end{NiceMatrix}\right\rvert}
% \end{macrocode}
%
% \begin{macrocode}
\NewDocumentEnvironment {VNiceMatrix} {}
{\left\lVert\begin{NiceMatrix}}
- {\end{BNiceMatrix}\right\rVert}
+ {\end{NiceMatrix}\right\rVert}
% \end{macrocode}
%
% \interitem
@@ -1149,7 +1271,7 @@ version 2005/12/01 or later.
% informations corresponding to the instruction. Such an property list will have three fields:
% \begin{itemize}
% \item a field ``type'' with the type of the instruction (|cdots|, |vdots|, |ddots|, etc.);
-% \item a field ``line'' with the number of the line of the matrix where the instruction appeared;
+% \item a field ``row'' with the number of the row of the matrix where the instruction appeared;
% \item a field ``column'' with the number of the column of the matrix where the instruction appeared.
% \end{itemize}
%
@@ -1164,7 +1286,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
{\int_gincr:N \g_@@_instruction_int
\prop_put:Nnn \l_tmpa_prop {type} {#1}
- \prop_put:NnV \l_tmpa_prop {line} \g_@@_line_int
+ \prop_put:NnV \l_tmpa_prop {row} \g_@@_row_int
\prop_put:NnV \l_tmpa_prop {column} \g_@@_column_int
% \end{macrocode}
% The property list has been created in a local variable for convenience. Now, it will be stored in a
@@ -1184,9 +1306,12 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Nn \@@_draw_lines:
- {\int_compare:nNnT {\tl_count:N \g_@@_preamble_aux_tl}
- > {\tl_count:N \g_@@_preamble_tl}
- {\tl_set_eq:NN \g_@@_preamble_tl \g_@@_preamble_aux_tl}
+ {
+% \end{macrocode}
+% The last |\cr| in the array has incremented the counter |\g_@@_row_int|. That's why we decrement it to have the
+% real number of rows.
+% \begin{macrocode}
+ \int_decr:N \g_@@_row_int
% \end{macrocode}
% The counter |\g_@@_column_int| will now be the total number of columns in the array.
% \begin{macrocode}
@@ -1203,14 +1328,14 @@ version 2005/12/01 or later.
% The following variables will be used further.
% \begin{macrocode}
\int_zero_new:N \l_@@_type_int
- \int_zero_new:N \l_@@_line_int
+ \int_zero_new:N \l_@@_row_int
\int_zero_new:N \l_@@_column_int
\int_zero_new:N \l_@@_di_int
\int_zero_new:N \l_@@_dj_int
% \end{macrocode}
%
% By befault, the diagonal lines will be parallelized\footnote{It's possible to use the option
-% |ParallelizeDiagonals| to disable this parallelization.}. There are two types of diagonals lines: the $|\Ddots|$
+% |parallelize-diags| to disable this parallelization.}. There are two types of diagonals lines: the $|\Ddots|$
% diagonals and the |\Iddots| diagonals. We have to count both types in order to known wether a diagonal is the
% first of its type in the current |{NiceArray}| environment.
% \begin{macrocode}
@@ -1245,7 +1370,7 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \interitem
-% We extract from the property list of the current instruction the fields ``type'', ``line'' and ``column'' and we
+% We extract from the property list of the current instruction the fields ``type'', ``row'' and ``column'' and we
% store these values. We have to do a conversion because the components of a property list are token lists (and not
% integers).
% \begin{macrocode}
@@ -1253,8 +1378,8 @@ version 2005/12/01 or later.
{type} \l_tmpa_tl
\int_set:Nn \l_@@_type_int {\l_tmpa_tl}
\prop_get:cnN {g_@@_instruction_\int_use:N \l_@@_instruction_int _prop}
- {line} \l_tmpa_tl
- \int_set:Nn \l_@@_line_int {\l_tmpa_tl}
+ {row} \l_tmpa_tl
+ \int_set:Nn \l_@@_row_int {\l_tmpa_tl}
\prop_get:cnN {g_@@_instruction_\int_use:N \l_@@_instruction_int _prop}
{column} \l_tmpa_tl
\int_set:Nn \l_@@_column_int {\l_tmpa_tl}
@@ -1293,7 +1418,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\int_zero_new:N \l_@@_final_i_int
\int_zero_new:N \l_@@_final_j_int
- \int_set:Nn \l_@@_final_i_int \l_@@_line_int
+ \int_set:Nn \l_@@_final_i_int \l_@@_row_int
\int_set:Nn \l_@@_final_j_int \l_@@_column_int
\bool_if_exist:NTF \l_@@_stop_loop_bool
{\bool_set_false:N \l_@@_stop_loop_bool}
@@ -1305,7 +1430,7 @@ version 2005/12/01 or later.
% We test if we are still in the matrix.
% \begin{macrocode}
\bool_if:nTF { \int_compare_p:nNn \l_@@_final_i_int < 1
- || \int_compare_p:nNn \l_@@_final_i_int > \g_@@_line_int
+ || \int_compare_p:nNn \l_@@_final_i_int > \g_@@_row_int
|| \int_compare_p:nNn \l_@@_final_j_int < 1
|| \int_compare_p:nNn \l_@@_final_j_int > \g_@@_column_int}
% \end{macrocode}
@@ -1328,10 +1453,10 @@ version 2005/12/01 or later.
% \begin{macrocode}
\int_zero_new:N \l_@@_initial_i_int
\int_zero_new:N \l_@@_initial_j_int
- \int_set:Nn \l_@@_initial_i_int \l_@@_line_int
+ \int_set:Nn \l_@@_initial_i_int \l_@@_row_int
\int_set:Nn \l_@@_initial_j_int \l_@@_column_int
% \end{macrocode}
-% If we known that the instruction is impossible (because it was not possible to found the correct value for
+% If we know that the instruction is impossible (because it was not possible to found the correct value for
% |\l_@@_final_i_int| and |\l_@@_final_j_int|), we don't do this loop.
% \begin{macrocode}
\bool_set_eq:NN \l_@@_stop_loop_bool \l_@@_impossible_instruction_bool
@@ -1340,7 +1465,7 @@ version 2005/12/01 or later.
\int_sub:Nn \l_@@_initial_j_int \l_@@_dj_int
\bool_if:nTF
{ \int_compare_p:nNn \l_@@_initial_i_int < 1
- || \int_compare_p:nNn \l_@@_initial_i_int > \g_@@_line_int
+ || \int_compare_p:nNn \l_@@_initial_i_int > \g_@@_row_int
|| \int_compare_p:nNn \l_@@_initial_j_int < 1
|| \int_compare_p:nNn \l_@@_initial_j_int > \g_@@_column_int}
{\bool_set_true:N \l_@@_impossible_instruction_bool
@@ -1599,10 +1724,10 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% \subsection{User commands available in environments {NiceArray} and {NiceMatrix}}
+% \subsection{User commands available in the new environments}
%
% We give new names for the commands |\ldots|, |\cdots|, |\vdots| and |\ddots| because these commands will be
-% redefined (if the option |RenewDots| is used).
+% redefined (if the option |renew-dots| is used).
% \begin{macrocode}
\cs_set_eq:NN \@@_ldots \ldots
\cs_set_eq:NN \@@_cdots \cdots
@@ -1617,13 +1742,14 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Nn \@@_add_to_empty_cells:
{\seq_gput_right:Nx \g_@@_empty_cells_seq
- {\int_use:N \g_@@_line_int-
+ {\int_use:N \g_@@_row_int-
\int_use:N \g_@@_column_int}}
% \end{macrocode}
%
% \interitem
% The commands |\@@_Ldots|, |\@@_Cdots|, |\@@_Vdots|, |\@@_Ddots| and |\@@_Iddots| will be linked to |\Ldots|,
-% |\Cdots|, |\Vdots|, |\Ddots| and |\Iddots| in the environments |{NiceArray}|.
+% |\Cdots|, |\Vdots|, |\Ddots| and |\Iddots| in the environments |{NiceArray}| (the other environments of
+% \pkg{nicematrix} rely upon |{NiceArray}|).
% \begin{macrocode}
\NewDocumentCommand \@@_Ldots {s}
{\IfBooleanF {#1} {\@@_instruction_of_type:n 0}
@@ -1665,7 +1791,7 @@ version 2005/12/01 or later.
%
%
% \bigskip
-% The command |\@@_Hspace:| will be linked to |\hspace| in the environments |{NiceArray}|.
+% The command |\@@_Hspace:| will be linked to |\hspace| in |{NiceArray}|.
% \begin{macrocode}
\cs_new_protected:Nn \@@_Hspace:
{\@@_add_to_empty_cells:
@@ -1673,7 +1799,7 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% The command |\@@_NiceMatrixEndPoint:| will be linked to |\NiceMatrixEndPoint| in the environments |{NiceArray}|.
+% The command |\@@_NiceMatrixEndPoint:| will be linked to |\NiceMatrixEndPoint| in |{NiceArray}|.
% \begin{macrocode}
\cs_new_protected:Nn \@@_NiceMatrixEndPoint:
{\kern 0.5pt}
@@ -1686,7 +1812,7 @@ version 2005/12/01 or later.
% |\NiceMatrixOptions| instead.
%
% We must process these options after the definition of the environment |{NiceMatrix}| because the option
-% |RenewMatrix| execute the code |\cs_set_eq:NN \env@matrix \NiceMatrix|.
+% |renew-matrix| execute the code |\cs_set_eq:NN \env@matrix \NiceMatrix|.
%
% Of course, the command |\NiceMatrix| must be defined before such an instruction is executed.
% \begin{macrocode}
@@ -1704,18 +1830,18 @@ version 2005/12/01 or later.
{0 {\token_to_str:N \Ldots}
1 {\token_to_str:N \Cdots}
2 {\token_to_str:N \Vdots}
- 3 {\token_to_str:N \Ddots}}~in~the~line~\int_use:N\l_@@_line_int\
+ 3 {\token_to_str:N \Ddots}}~in~the~row~\int_use:N\l_@@_row_int\
~and~the~column~\int_use:N\l_@@_column_int\space of~the~matrix~
because~it's~impossible~to~find~one~of~its~extremities~
(both~extremities~must~be~non~empty~cells~of~the~matrix).~
If~you~go~on,~the~instruction~will~be~ignored.}
- {You~can~specify~a~end~of~line~on~a~empty~cell~
+ {You~can~specify~an~end~of~line~on~a~empty~cell~
with~\token_to_str:N \NiceMatrixEndPoint.}
% \end{macrocode}
%
% \begin{macrocode}
\msg_new:nnn {nicematrix}
- {multicolumn~forbidden}
+ {Multicolumn~forbidden}
{The~command~\token_to_str:N \multicolumn\
is~forbidden~in~the~environment~\{NiceMatrix\}~
and~its~variants.~The~command~\token_to_str:N \hdotsfor\
@@ -1724,12 +1850,139 @@ version 2005/12/01 or later.
probably~be~wrong.}
% \end{macrocode}
%
+% \begin{macrocode}
+\msg_new:nnn {nicematrix}
+ {Option~unknown}
+ {The~option~"\tl_use:N\l_keys_key_tl"~is~unknown~or~
+ meaningless~in~the~context.~If~you~go~on,~it~will~be~ignored.}
+% \end{macrocode}
+%
+% \bigskip
+% \subsection{The environment \{pNiceArrayC\} and its variants}
+%
+% The code in this section can be removed without affecting the previous code.
%
+% \medskip
+% First, we define a set of options for the environment |{pNiceArrayC}| and its variants. This set of keys is named
+% |NiceMatrix/NiceArrayC| even though there is no environment called |{NiceArrayC}|.
+%
+% \begin{macrocode}
+\keys_define:nn {NiceMatrix/NiceArrayC}
+ {parallelize-diags .bool_set:N = \l_@@_parallelize_diags_bool,
+ parallelize-diags .default:n = true,
+ renew-dots .bool_set:N = \l_@@_renew_dots_bool,
+ renew-dots .default:n = true,
+ nullify-dots .bool_set:N = \l_@@_nullify_dots_bool ,
+ nullify-dots .default:n = true,
+ code-for-last-col .tl_set:N = \l_@@_code_for_last_col_tl,
+ code-for-last-col .value_required:n = true,
+ unknown .code:n = \msg_error:nn {nicematrix} {Option~unknown}}
+% \end{macrocode}
+%
+% \bigskip
+% In the environment |{pNiceArrayC}| (and its variants), the last column is composed with instructions
+% |\hbox_overlap_right:n| (this instruction may be seen as the \pkg{expl3} equivalent of the classical command
+% |\rlap|). After the composition of the array, an horizontal skip is inserted to compensate for these
+% overlapping boxes.
+%
+% \medskip
+% The command |\@@_NiceArrayC:nn| will be used in the environment |{pNiceArrayC}| and its variants.
+% \begin{macrocode}
+\cs_new_protected:Nn \@@_NiceArrayC:nn
+ {\dim_gzero_new:N \g_@@_width_last_col_dim
+ \keys_set:nn {NiceMatrix/NiceArrayC} {#1}
+ \bool_set_false:N \l_@@_exterior_arraycolsep_bool
+ \tl_set:Nn \l_@@_pos_env_tl c
+ \begin{NiceArray}
+% \end{macrocode}
+% The beginning of the preamble is the argument of the environment |{pNiceArrayC}|.
+% \begin{macrocode}
+ {#2
+% \end{macrocode}
+%
+% However, we add a last column with its own specification. For a cell in this last column, the first operation is
+% to store the content of the cell in the box |\l_tmpa_box|. This is allowed in \pkg{expl3} with the construction
+% |\hbox_set:Nw \l_tmpa_box| ... |\hbox_set_end:|.
+% \begin{macrocode}
+ >{\hbox_set:Nw \l_tmpa_box
+ \l_@@_code_for_last_col_tl
+ \@@_Cell:n l}
+ l
+ <{\@@_end_Cell:
+ \hbox_set_end:
+% \end{macrocode}
+%
+% We actualize the value of |\g_@@with_last_col_dim| which, at the end of the array, will contains the maximal width
+% of the cells of the last column (thus, it will be equal to the width of the last column).
+% \begin{macrocode}
+ \dim_gset:Nn \g_@@_width_last_col_dim
+ {\dim_max:nn \g_@@_width_last_col_dim
+ {\box_wd:N \l_tmpa_box}}
+ \skip_horizontal:n {-2\arraycolsep}
+% \end{macrocode}
+% The content of the cell is inserted in a overlapping position.
+% \begin{macrocode}
+ \hbox_overlap_right:n
+ {\skip_horizontal:n {2\arraycolsep}
+ \box_use:N \l_tmpa_box}}}}
+% \end{macrocode}
+% This ends the preamble of the array that will be constructed (a rather long preamble, indeed).
+%
+% \bigskip
+% The command |\@@_after_last_col:| will be used to insert, after the construction of the array (and after the
+% insertion of the right parenthesis, brace, bracket, etc.), an horizontal space in order to compensate for the
+% overlapping boxes.
+% \begin{macrocode}
+\cs_new:Nn \@@_after_last_col:
+ {\dim_compare:nNnF \g_@@_width_last_col_dim = \c_zero_dim
+ {\skip_horizontal:n {\g_@@_width_last_col_dim}{}}}
+% \end{macrocode}
+%
+% \bigskip
+% \begin{macrocode}
+\NewDocumentEnvironment {pNiceArrayC} {O{} m O{}}
+ {\left(
+ \@@_NiceArrayC:nn {#1,#3} {#2}}
+ {\end{NiceArray}
+ \right)
+ \@@_after_last_col:}
+
+\NewDocumentEnvironment {vNiceArrayC} {O{} m O{}}
+ {\left|
+ \@@_NiceArrayC:nn {#1,#3} {#2}}
+ {\end{NiceArray}
+ \right|
+ \@@_after_last_col:}
+
+\NewDocumentEnvironment {VNiceArrayC} {O{} m O{}}
+ {\left\|
+ \@@_NiceArrayC:nn {#1,#3} {#2}}
+ {\end{NiceArray}
+ \right\|
+ \@@_after_last_col:}
+
+\NewDocumentEnvironment {bNiceArrayC} {O{} m O{}}
+ {\left[
+ \@@_NiceArrayC:nn {#1,#3} {#2}}
+ {\end{NiceArray}
+ \right]
+ \@@_after_last_col:}
+
+\NewDocumentEnvironment {BNiceArrayC} {O{} m O{}}
+ {\left\{
+ \@@_NiceArrayC:nn {#1,#3} {#2}}
+ {\end{NiceArray}
+ \right\}
+ \@@_after_last_col:}
+% \end{macrocode}
+%
+%
+%
% \section{History}
%
% \subsection{Changes between versions 1.0 and 1.1}
%
-% Option |Silent| (with this option, the impossible instructions are discarded silently).
+% Option |silent| (with this option, the impossible instructions are discarded silently).
%
% The dotted lines are no longer drawn with Tikz nodes but with Tikz circles (for efficiency).
%
@@ -1739,6 +1992,21 @@ version 2005/12/01 or later.
%
% New environment |{NiceArray}| with column types |L|, |C| and |R|.
%
+% \subsection{Changes between version 1.2 and 1.3}
+%
+% New environment |{pNiceArrayC}| and its variants.
+%
+% We decrement |\g_@@_row_int| in |\@@_draw_arrows:| to have the exact number of rows.
+%
+% Correction of a bug in the definition of |{BNiceMatrix}|, |{vNiceMatrix}| and |{VNiceMatrix}| (in fact, it was a
+% typo).
+%
+% Options are now available locally in |{pNiceMatrix}| and its variants.
+%
+% The names of the options are changed. The old names were names in ``camel style''. New names are in lowercase and
+% hyphens (but backward compatibility is kept).
+%
+%
% \endinput
% Local Variables:
% TeX-fold-mode: nil
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
index e51cb549e77..fa0c20dbd66 100644
--- a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
+++ b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
@@ -18,8 +18,8 @@
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%%
-\def\myfileversion{1.2}
-\def\myfiledate{2018/03/11}
+\def\myfileversion{1.3}
+\def\myfiledate{2018/03/31}
\RequirePackage{l3keys2e}
\ProvidesExplPackage
{nicematrix}
@@ -40,54 +40,88 @@
\hbox{.}}
\mkern 1mu}}
\cs_new_protected:Nn \__nm_multicolumn:nn
- {\msg_error:nn {nicematrix} {multicolumn~forbidden}}
+ {\msg_error:nn {nicematrix} {Multicolumn~forbidden}}
\int_new:N \g__nm_env_int
+\tl_new:N \l__nm_pos_env_tl
+\tl_set:Nn \l__nm_pos_env_tl c
\bool_new:N \l__nm_exterior_arraycolsep_bool
\bool_new:N \l__nm_parallelize_diags_bool
\bool_set_true:N \l__nm_parallelize_diags_bool
\bool_new:N \l__nm_nullify_dots_bool
\bool_new:N \l__nm_renew_matrix_bool
-\keys_define:nn {NiceMatrix}
- {ParallelizeDiagonals .bool_set:N = \l__nm_parallelize_diags_bool,
- ParallelizeDiagonals .default:n = true,
- RenewDots .bool_set:N = \l__nm_renew_dots_bool,
- RenewDots .default:n = true,
- RenewMatrix .code:n = {\cs_set_eq:NN \env@matrix \NiceMatrix
- \bool_set_true:N \l__nm_renew_matrix_bool},
- RenewMatrix .default:n = true,
- Transparent .meta:n = {RenewDots,RenewMatrix},
- Transparent .value_forbidden:n = true,
- NullifyDots .bool_set:N = \l__nm_nullify_dots_bool ,
- NullifyDots .default:n = true,
- Silent .code:n = {\msg_redirect_name:nnn {nicematrix}
- {Impossible~instruction}
- {none}} ,
- Silent .value_forbidden:n = true}
+\tl_new:N \l__nm_code_for_last_col_tl
+\keys_define:nn {NiceMatrix/NiceMatrixOptions}
+ {parallelize-diags .bool_set:N = \l__nm_parallelize_diags_bool,
+ parallelize-diags .default:n = true,
+ ParallelizeDiagonals .meta:n = parallelize-diags,
+ renew-dots .bool_set:N = \l__nm_renew_dots_bool,
+ renew-dots .default:n = true,
+ RenewDots .meta:n = renew-dots,
+ renew-matrix .code:n = {\cs_set_eq:NN \env@matrix \NiceMatrix
+ \bool_set_true:N \l__nm_renew_matrix_bool},
+ renew-matrix .value_forbidden:n = true,
+ RenewMatrix .meta:n = renew-matrix,
+ transparent .meta:n = {renew-dots,renew-matrix},
+ transparent .value_forbidden:n = true,
+ Transparent .meta:n = transparent,
+ nullify-dots .bool_set:N = \l__nm_nullify_dots_bool ,
+ nullify-dots .default:n = true,
+ NullifyDots .meta:n = nullify-dots,
+ silent .code:n = {\msg_redirect_name:nnn {nicematrix}
+ {Impossible~instruction}
+ {none}} ,
+ silent .value_forbidden:n = true,
+ Silent .meta:n = silent,
+ code-for-last-col .tl_set:N = \l__nm_code_for_last_col_tl,
+ code-for-last-col .value_required:n = true,
+ exterior-arraycolsep .bool_set:N = \l__nm_exterior_arraycolsep_bool ,
+ exterior-arraycolsep .default:n = true,
+ unknown .code:n = \msg_error:nn {nicematrix} {Option~unknown}}
\NewDocumentCommand \NiceMatrixOptions {m}
- {\keys_set:nn {NiceMatrix} {#1}}
-\keys_define:nn {NiceArray}
- {exterior-arraycolsep .bool_set:N = \l__nm_exterior_arraycolsep_bool ,
- exterior-arraycolsep .default:n = true}
+ {\keys_set:nn {NiceMatrix/NiceMatrixOptions} {#1}}
+\keys_define:nn {NiceMatrix/NiceMatrix}
+ {parallelize-diags .bool_set:N = \l__nm_parallelize_diags_bool,
+ parallelize-diags .default:n = true,
+ renew-dots .bool_set:N = \l__nm_renew_dots_bool,
+ renew-dots .default:n = true,
+ nullify-dots .bool_set:N = \l__nm_nullify_dots_bool ,
+ nullify-dots .default:n = true,
+ unknown .code:n = \msg_error:nn {nicematrix} {Option~unknown}}
+\keys_define:nn {NiceMatrix/NiceArray}
+ {parallelize-diags .bool_set:N = \l__nm_parallelize_diags_bool,
+ parallelize-diags .default:n = true,
+ renew-dots .bool_set:N = \l__nm_renew_dots_bool,
+ renew-dots .default:n = true,
+ nullify-dots .bool_set:N = \l__nm_nullify_dots_bool ,
+ nullify-dots .default:n = true,
+ exterior-arraycolsep .bool_set:N = \l__nm_exterior_arraycolsep_bool ,
+ exterior-arraycolsep .default:n = true,
+ c .code:n = \tl_set:Nn \l__nm_pos_env_tl c,
+ t .code:n = \tl_set:Nn \l__nm_pos_env_tl t,
+ b .code:n = \tl_set:Nn \l__nm_pos_env_tl b,
+ unknown .code:n = \msg_error:nn {nicematrix} {Option~unknown}}
\cs_new_protected:Nn \__nm_Cell:n
{ \tl_gput_right:Nn \g__nm_preamble_aux_tl {#1}
\int_gincr:N \g__nm_column_int
\tikz[remember~picture, inner~sep = 0pt, minimum~width = 0pt, baseline]
\node [anchor=base] (nm-\int_use:N \g__nm_env_int-
- \int_use:N \g__nm_line_int-
+ \int_use:N \g__nm_row_int-
\int_use:N \g__nm_column_int)
\bgroup $} % $
\cs_new_protected:Nn \__nm_end_Cell:
{$\egroup ;} % $
-\NewDocumentEnvironment {NiceMatrix} {}
- {\bool_set_false:N \l__nm_exterior_arraycolsep_bool
+\NewDocumentEnvironment {NiceMatrix} {O{}}
+ {\keys_set:nn {NiceMatrix/NiceMatrix} {#1}
+ \tl_set:Nn \l__nm_pos_env_tl c
+ \bool_set_false:N \l__nm_exterior_arraycolsep_bool
\NiceArray{*\c@MaxMatrixCols{C}}}
{\endarray
\skip_horizontal:n {-\arraycolsep}}
-\NewDocumentEnvironment {NiceArray} {O{} m}
+\NewDocumentEnvironment {NiceArray} {O{} m O{}}
{\aftergroup \__nm_draw_lines:
- \keys_set_known:nnN {NiceArray} {#1} \l_tmpa_tl
+ \keys_set:nn {NiceMatrix/NiceArray} {#1,#3}
\cs_set:Npn \ialign
- {\everycr{\noalign{\int_gincr:N \g__nm_line_int
+ {\everycr{\noalign{\int_gincr:N \g__nm_row_int
\int_gzero:N \g__nm_column_int
\int_compare:nNnT {\tl_count:N \g__nm_preamble_aux_tl}
> {\tl_count:N \g__nm_preamble_tl}
@@ -116,19 +150,19 @@
\cs_set_eq:NN \iddots \__nm_Iddots}
\bool_if:NF \l__nm_renew_matrix_bool
{\cs_set_eq:NN \multicolumn \__nm_multicolumn:nn}
- \int_gincr:N \g__nm_env_int
+ \int_gincr:N \g__nm_env_int
\tl_clear_new:N \g__nm_preamble_tl
\tl_clear_new:N \g__nm_preamble_aux_tl
- \seq_gclear_new:N \g__nm_empty_cells_seq
- \int_gzero_new:N \g__nm_instruction_int
- \int_gzero_new:N \g__nm_line_int
- \int_gzero_new:N \g__nm_column_int
- \cs_set_eq:NN \@ifnextchar \new@ifnextchar
- \bool_if:NF \l__nm_exterior_arraycolsep_bool
+ \seq_gclear_new:N \g__nm_empty_cells_seq
+ \int_gzero_new:N \g__nm_instruction_int
+ \int_gzero_new:N \g__nm_row_int
+ \int_gzero_new:N \g__nm_column_int
+ \cs_set_eq:NN \@ifnextchar \new@ifnextchar
+ \bool_if:NF \l__nm_exterior_arraycolsep_bool
{\skip_horizontal:n {-\arraycolsep}}
- \array[\l_tmpa_tl]{#2}}
- {\endarray
- \bool_if:NF \l__nm_exterior_arraycolsep_bool
+ \array[\l__nm_pos_env_tl]{#2}}
+ {\endarray
+ \bool_if:NF \l__nm_exterior_arraycolsep_bool
{\skip_horizontal:n {-\arraycolsep}}}
\NewDocumentEnvironment {pNiceMatrix} {}
{\left(\begin{NiceMatrix}}
@@ -138,13 +172,13 @@
{\end{NiceMatrix}\right]}
\NewDocumentEnvironment {BNiceMatrix} {}
{\left\{\begin{NiceMatrix}}
- {\end{BNiceMatrix}\right\}}
+ {\end{NiceMatrix}\right\}}
\NewDocumentEnvironment {vNiceMatrix} {}
{\left\lvert\begin{NiceMatrix}}
- {\end{BNiceMatrix}\right\rvert}
+ {\end{NiceMatrix}\right\rvert}
\NewDocumentEnvironment {VNiceMatrix} {}
{\left\lVert\begin{NiceMatrix}}
- {\end{BNiceMatrix}\right\rVert}
+ {\end{NiceMatrix}\right\rVert}
\prg_set_conditional:Npnn \__nm_if_not_empty_cell:nn #1#2 {T}
{\cs_if_exist:cTF {pgf@sh@ns@nm-\int_use:N \g__nm_env_int-
\int_use:N #1-
@@ -170,7 +204,7 @@
\cs_new_protected:Nn \__nm_instruction_of_type:n
{\int_gincr:N \g__nm_instruction_int
\prop_put:Nnn \l_tmpa_prop {type} {#1}
- \prop_put:NnV \l_tmpa_prop {line} \g__nm_line_int
+ \prop_put:NnV \l_tmpa_prop {row} \g__nm_row_int
\prop_put:NnV \l_tmpa_prop {column} \g__nm_column_int
\prop_gclear_new:c
{g__nm_instruction_\int_use:N\g__nm_instruction_int _prop}
@@ -180,13 +214,12 @@
}
\cs_new_protected:Nn \__nm_draw_lines:
- {\int_compare:nNnT {\tl_count:N \g__nm_preamble_aux_tl}
- > {\tl_count:N \g__nm_preamble_tl}
- {\tl_set_eq:NN \g__nm_preamble_tl \g__nm_preamble_aux_tl}
+ {
+ \int_decr:N \g__nm_row_int
\int_set:Nn \g__nm_column_int {\tl_count:N \g__nm_preamble_tl}
\seq_clear_new:N \l__nm_yet_drawn_seq
\int_zero_new:N \l__nm_type_int
- \int_zero_new:N \l__nm_line_int
+ \int_zero_new:N \l__nm_row_int
\int_zero_new:N \l__nm_column_int
\int_zero_new:N \l__nm_di_int
\int_zero_new:N \l__nm_dj_int
@@ -205,8 +238,8 @@
{type} \l_tmpa_tl
\int_set:Nn \l__nm_type_int {\l_tmpa_tl}
\prop_get:cnN {g__nm_instruction_\int_use:N \l__nm_instruction_int _prop}
- {line} \l_tmpa_tl
- \int_set:Nn \l__nm_line_int {\l_tmpa_tl}
+ {row} \l_tmpa_tl
+ \int_set:Nn \l__nm_row_int {\l_tmpa_tl}
\prop_get:cnN {g__nm_instruction_\int_use:N \l__nm_instruction_int _prop}
{column} \l_tmpa_tl
\int_set:Nn \l__nm_column_int {\l_tmpa_tl}
@@ -226,7 +259,7 @@
{\bool_new:N \l__nm_impossible_instruction_bool}
\int_zero_new:N \l__nm_final_i_int
\int_zero_new:N \l__nm_final_j_int
- \int_set:Nn \l__nm_final_i_int \l__nm_line_int
+ \int_set:Nn \l__nm_final_i_int \l__nm_row_int
\int_set:Nn \l__nm_final_j_int \l__nm_column_int
\bool_if_exist:NTF \l__nm_stop_loop_bool
{\bool_set_false:N \l__nm_stop_loop_bool}
@@ -235,7 +268,7 @@
{\int_add:Nn \l__nm_final_i_int \l__nm_di_int
\int_add:Nn \l__nm_final_j_int \l__nm_dj_int
\bool_if:nTF { \int_compare_p:nNn \l__nm_final_i_int < 1
- || \int_compare_p:nNn \l__nm_final_i_int > \g__nm_line_int
+ || \int_compare_p:nNn \l__nm_final_i_int > \g__nm_row_int
|| \int_compare_p:nNn \l__nm_final_j_int < 1
|| \int_compare_p:nNn \l__nm_final_j_int > \g__nm_column_int}
{\bool_set_true:N \l__nm_impossible_instruction_bool
@@ -245,7 +278,7 @@
}
\int_zero_new:N \l__nm_initial_i_int
\int_zero_new:N \l__nm_initial_j_int
- \int_set:Nn \l__nm_initial_i_int \l__nm_line_int
+ \int_set:Nn \l__nm_initial_i_int \l__nm_row_int
\int_set:Nn \l__nm_initial_j_int \l__nm_column_int
\bool_set_eq:NN \l__nm_stop_loop_bool \l__nm_impossible_instruction_bool
\bool_do_until:Nn \l__nm_stop_loop_bool
@@ -253,7 +286,7 @@
\int_sub:Nn \l__nm_initial_j_int \l__nm_dj_int
\bool_if:nTF
{ \int_compare_p:nNn \l__nm_initial_i_int < 1
- || \int_compare_p:nNn \l__nm_initial_i_int > \g__nm_line_int
+ || \int_compare_p:nNn \l__nm_initial_i_int > \g__nm_row_int
|| \int_compare_p:nNn \l__nm_initial_j_int < 1
|| \int_compare_p:nNn \l__nm_initial_j_int > \g__nm_column_int}
{\bool_set_true:N \l__nm_impossible_instruction_bool
@@ -382,7 +415,7 @@
\cs_set_eq:NN \__nm_iddots \iddots
\cs_new_protected:Nn \__nm_add_to_empty_cells:
{\seq_gput_right:Nx \g__nm_empty_cells_seq
- {\int_use:N \g__nm_line_int-
+ {\int_use:N \g__nm_row_int-
\int_use:N \g__nm_column_int}}
\NewDocumentCommand \__nm_Ldots {s}
{\IfBooleanF {#1} {\__nm_instruction_of_type:n 0}
@@ -417,21 +450,92 @@
{0 {\token_to_str:N \Ldots}
1 {\token_to_str:N \Cdots}
2 {\token_to_str:N \Vdots}
- 3 {\token_to_str:N \Ddots}}~in~the~line~\int_use:N\l__nm_line_int\
+ 3 {\token_to_str:N \Ddots}}~in~the~row~\int_use:N\l__nm_row_int\
~and~the~column~\int_use:N\l__nm_column_int\space of~the~matrix~
because~it's~impossible~to~find~one~of~its~extremities~
(both~extremities~must~be~non~empty~cells~of~the~matrix).~
If~you~go~on,~the~instruction~will~be~ignored.}
- {You~can~specify~a~end~of~line~on~a~empty~cell~
+ {You~can~specify~an~end~of~line~on~a~empty~cell~
with~\token_to_str:N \NiceMatrixEndPoint.}
\msg_new:nnn {nicematrix}
- {multicolumn~forbidden}
+ {Multicolumn~forbidden}
{The~command~\token_to_str:N \multicolumn\
is~forbidden~in~the~environment~\{NiceMatrix\}~
and~its~variants.~The~command~\token_to_str:N \hdotsfor\
of~amsmath~is~also~forbidden~since~it~uses~
\token_to_str:N \multicolumn.~You~can~go~on~but~your~line~will~
probably~be~wrong.}
+\msg_new:nnn {nicematrix}
+ {Option~unknown}
+ {The~option~"\tl_use:N\l_keys_key_tl"~is~unknown~or~
+ meaningless~in~the~context.~If~you~go~on,~it~will~be~ignored.}
+\keys_define:nn {NiceMatrix/NiceArrayC}
+ {parallelize-diags .bool_set:N = \l__nm_parallelize_diags_bool,
+ parallelize-diags .default:n = true,
+ renew-dots .bool_set:N = \l__nm_renew_dots_bool,
+ renew-dots .default:n = true,
+ nullify-dots .bool_set:N = \l__nm_nullify_dots_bool ,
+ nullify-dots .default:n = true,
+ code-for-last-col .tl_set:N = \l__nm_code_for_last_col_tl,
+ code-for-last-col .value_required:n = true,
+ unknown .code:n = \msg_error:nn {nicematrix} {Option~unknown}}
+\cs_new_protected:Nn \__nm_NiceArrayC:nn
+ {\dim_gzero_new:N \g__nm_width_last_col_dim
+ \keys_set:nn {NiceMatrix/NiceArrayC} {#1}
+ \bool_set_false:N \l__nm_exterior_arraycolsep_bool
+ \tl_set:Nn \l__nm_pos_env_tl c
+ \begin{NiceArray}
+ {#2
+ >{\hbox_set:Nw \l_tmpa_box
+ \l__nm_code_for_last_col_tl
+ \__nm_Cell:n l}
+ l
+ <{\__nm_end_Cell:
+ \hbox_set_end:
+ \dim_gset:Nn \g__nm_width_last_col_dim
+ {\dim_max:nn \g__nm_width_last_col_dim
+ {\box_wd:N \l_tmpa_box}}
+ \skip_horizontal:n {-2\arraycolsep}
+ \hbox_overlap_right:n
+ {\skip_horizontal:n {2\arraycolsep}
+ \box_use:N \l_tmpa_box}}}}
+\cs_new:Nn \__nm_after_last_col:
+ {\dim_compare:nNnF \g__nm_width_last_col_dim = \c_zero_dim
+ {\skip_horizontal:n {\g__nm_width_last_col_dim}{}}}
+\NewDocumentEnvironment {pNiceArrayC} {O{} m O{}}
+ {\left(
+ \__nm_NiceArrayC:nn {#1,#3} {#2}}
+ {\end{NiceArray}
+ \right)
+ \__nm_after_last_col:}
+
+\NewDocumentEnvironment {vNiceArrayC} {O{} m O{}}
+ {\left|
+ \__nm_NiceArrayC:nn {#1,#3} {#2}}
+ {\end{NiceArray}
+ \right|
+ \__nm_after_last_col:}
+
+\NewDocumentEnvironment {VNiceArrayC} {O{} m O{}}
+ {\left\|
+ \__nm_NiceArrayC:nn {#1,#3} {#2}}
+ {\end{NiceArray}
+ \right\|
+ \__nm_after_last_col:}
+
+\NewDocumentEnvironment {bNiceArrayC} {O{} m O{}}
+ {\left[
+ \__nm_NiceArrayC:nn {#1,#3} {#2}}
+ {\end{NiceArray}
+ \right]
+ \__nm_after_last_col:}
+
+\NewDocumentEnvironment {BNiceArrayC} {O{} m O{}}
+ {\left\{
+ \__nm_NiceArrayC:nn {#1,#3} {#2}}
+ {\end{NiceArray}
+ \right\}
+ \__nm_after_last_col:}
\endinput
%%
%% End of file `nicematrix.sty'.