diff options
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/README.md | 5 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf | bin | 378455 -> 387098 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx | 3977 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | 2546 |
4 files changed, 3752 insertions, 2776 deletions
diff --git a/Master/texmf-dist/doc/latex/nicematrix/README.md b/Master/texmf-dist/doc/latex/nicematrix/README.md index 39cc99c2853..aadca62b15f 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/README.md +++ b/Master/texmf-dist/doc/latex/nicematrix/README.md @@ -1,10 +1,13 @@ # Readme for the package nicematrix +Author : F. Pantigny (`fpantigny@wanadoo.fr`). + +CTAN page : `https://ctan.org/pkg/nicematrix` + ## License The LaTeX extension `nicematrix` is distributed under the LPPL 1.3 license. ## Presentation -This extension has been written by F. Pantigny (`fpantigny@wanadoo.fr`). The LaTeX package `nicematrix` provides new environments similar to the classical environments `{array}` and `{matrix}` but with some additional features. Among these features are the diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf Binary files differindex 5d6e1f65e26..908368d1d6e 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx index f21c03b01e8..618964b20c9 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{2.1.4} -\def\myfiledate{2019/01/28} +\def\myfileversion{2.1.5} +\def\myfiledate{2019/05/27} % % %<*batchfile> @@ -44,7 +44,7 @@ version 2005/12/01 or later. \endgroup %</batchfile> % -%<@@=nicem> +%<@@=nm> %<*driver> \documentclass[dvipsnames]{l3doc}% dvipsnames is for xcolor (loaded by Tikz, loaded by nicematrix) \VerbatimFootnotes @@ -80,8 +80,9 @@ version 2005/12/01 or later. % \maketitle % % \begin{abstract} -% The LaTeX package \pkg{nicematrix} provides new environments similar to the classical environments |{array}| and -% |{matrix}| but with some additional features. Among these features are the possibilities to fix the width of the +% The LaTeX package \pkg{nicematrix} provides new environments similar to the +% classical environments |{array}| and |{matrix}| but with some additional +% features. Among these features are the possibilities to fix the width of the % columns and to draw continuous ellipsis dots between the cells of the array. % \end{abstract} % @@ -89,20 +90,22 @@ version 2005/12/01 or later. % \section{Presentation} % % -% This package can be used with |xelatex|, |lualatex|, |pdflatex| but also by the classical workflow -% |latex|-|dvips|-|ps2pdf| (or Adobe Distiller). Two or three compilations may be necessary. This package requires -% and loads the packages \pkg{expl3}, \pkg{l3keys2e}, \pkg{xparse}, \pkg{array}, \pkg{amsmath} and \pkg{tikz}. It -% also loads the Tikz library \pkg{fit}. +% This package can be used with |xelatex|, |lualatex|, |pdflatex| but also by +% the classical workflow |latex|-|dvips|-|ps2pdf| (or Adobe Distiller). Two or +% three compilations may be necessary. This package requires and loads the +% packages \pkg{expl3}, \pkg{l3keys2e}, \pkg{xparse}, \pkg{array}, \pkg{amsmath} +% and \pkg{tikz}. It also loads the Tikz library \pkg{fit}. % % % % \medskip % \begin{savenotes} % \begin{minipage}{0.6\linewidth} -% This package provides some new tools to draw mathematical matrices. The main features are the following: +% This package provides some new tools to draw mathematical matrices. The main +% features are the following: % -% \textbullet\ continuous dotted lines\footnote{If the class option |draft| is used, these dotted lines will not be -% drawn for a faster compilation.}; +% \textbullet\ continuous dotted lines\footnote{If the class option |draft| is +% used, these dotted lines will not be drawn for a faster compilation.}; % % \textbullet\ a first row and a last column for labels; % @@ -123,8 +126,8 @@ version 2005/12/01 or later. % }$ % % \medskip -% A command |\NiceMatrixOptions| is provided to fix the options (the scope of the options fixed by this command is -% the current TeX group). +% A command |\NiceMatrixOptions| is provided to fix the options (the scope of +% the options fixed by this command is the current TeX group). % % % \bigskip @@ -132,7 +135,8 @@ version 2005/12/01 or later. % % \medskip % \begin{minipage}{10cm} -% For example, consider the following code which uses an environment |{pmatrix}| of \pkg{amsmath}. +% For example, consider the following code which uses an environment |{pmatrix}| +% of \pkg{amsmath}. % % \smallskip % \begin{BVerbatim} @@ -159,8 +163,8 @@ version 2005/12/01 or later. % \begin{scope} % \NiceMatrixOptions{transparent} % \begin{minipage}{10cm} -% Now, if we use the package \pkg{nicematrix} with the option |transparent|, the same code will give the -% result on the right. +% Now, if we use the package \pkg{nicematrix} with the option |transparent|, the +% same code will give the result on the right. % \end{minipage}\hspace{1cm} % $A = \begin{pmatrix} % 1 & \cdots & \cdots & 1 \\ @@ -190,45 +194,55 @@ version 2005/12/01 or later. % % % \medskip -% By default, the environments |{NiceMatrix}|, |{pNiceMatrix}|, |{bNiceMatrix}|, |{BNiceMatrix}|, |{vNiceMatrix}| -% and |{VNiceMatrix}| behave almost exactly as the corresponding environments of \pkg{amsmath}: -% |{matrix}|, |{pmatrix}|, |{bmatrix}|, |{Bmatrix}|, |{vmatrix}| and |{Vmatrix}|. +% By default, the environments |{NiceMatrix}|, |{pNiceMatrix}|, |{bNiceMatrix}|, +% |{BNiceMatrix}|, |{vNiceMatrix}| and |{VNiceMatrix}| behave almost exactly as +% the corresponding environments of \pkg{amsmath}: |{matrix}|, |{pmatrix}|, +% |{bmatrix}|, |{Bmatrix}|, |{vmatrix}| and |{Vmatrix}|. % % % \medskip -% The environment |{NiceArray}| is similar to the environment |{array}| of the package |{array}|. However, for -% technical reasons, in the preamble of the environment |{NiceArray}|, the user must use the letters |L|, |C| -% and~|R| instead of |l|, |c| and |r|. It's possible to use the constructions \verb|w{...}{...}|, -% \verb|W{...}{...}|, \verb+|+, |>{...}|, |<{...}|, |@{...}|, |!{...}| and |*{n}{...}| but the letters |p|, |m| and -% |b| should not be used. See p.~\pageref{NiceArray} the section relating to |{NiceArray}|. +% The environment |{NiceArray}| is similar to the environment |{array}| of the +% package |{array}|. However, for technical reasons, in the preamble of the +% environment |{NiceArray}|, the user must use the letters |L|, |C| and~|R| +% instead of |l|, |c| and |r|. It's possible to use the constructions +% \verb|w{...}{...}|, \verb|W{...}{...}|, \verb+|+, |>{...}|, |<{...}|, +% |@{...}|, |!{...}| and |*{n}{...}| but the letters |p|, |m| and |b| should not +% be used. See p.~\pageref{NiceArray} the section relating to |{NiceArray}|. % % \medskip -% The environments with |C| at the end of their name, |{pNiceArrayC}|, |{bNiceArrayC}|, |{BNiceArrayC}|, -% |{vNiceArrayC}| and |{VNiceArrayC}| are similar to the environment |{NiceArray}| (especially the special letters -% |L|, |C| and |R|) but create an exterior column (on the right of the closing delimiter). See -% p.~\pageref{pNiceArrayC} the section relating to |{pNiceArrayC}|. +% The environments with |C| at the end of their name, |{pNiceArrayC}|, +% |{bNiceArrayC}|, |{BNiceArrayC}|, |{vNiceArrayC}| and |{VNiceArrayC}| are +% similar to the environment |{NiceArray}| (especially the special letters |L|, +% |C| and |R|) but create an exterior column (on the right of the closing +% delimiter). See p.~\pageref{pNiceArrayC} the section relating to +% |{pNiceArrayC}|. % % \medskip -% The environments with |RC|, |{pNiceArrayRC}|, |{bNiceArrayRC}|, |{BNiceArrayRC}|, |{vNiceArrayRC}|, -% |{VNiceArrayRC}| are similar to the environment |{NiceArray}| but create an exterior row (above the main matrix) -% and an exterior column. See p.~\pageref{pNiceArrayRC} the section relating to |{pNiceArrayRC}|. +% The environments with |RC|, |{pNiceArrayRC}|, |{bNiceArrayRC}|, +% |{BNiceArrayRC}|, |{vNiceArrayRC}|, |{VNiceArrayRC}| are similar to the +% environment |{NiceArray}| but create an exterior row (above the main matrix) +% and an exterior column. See p.~\pageref{pNiceArrayRC} the section relating to +% |{pNiceArrayRC}|. % % % % \section{The continuous dotted lines} % -% Inside the environments of the extension \pkg{nicematrix}, new commands are defined: |\Ldots|, |\Cdots|, -% |\Vdots|, |\Ddots|, and |\Iddots|. These commands are intended to be used in place of |\dots|, |\cdots|, -% |\vdots|, |\ddots| and |\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. -% It corresponds to the command |\adots| of \pkg{unicode-math}.} +% Inside the environments of the extension \pkg{nicematrix}, new commands are +% defined: |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, and |\Iddots|. These commands +% are intended to be used in place of |\dots|, |\cdots|, |\vdots|, |\ddots| and +% |\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. It corresponds to the command +% |\adots| of \pkg{unicode-math}.} % % \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 -% cells\footnote{The precise definition of a ``non-empty cell'' is given below (cf. p.~\pageref{empty-cells}).} on -% both sides of the current cell. Of course, for |\Ldots| and |\Cdots|, it's an horizontal line; for |\Vdots|, it's -% a vertical line and for |\Ddots| and |\Iddots| diagonal ones.\par\nobreak -% \bigskip +% Each of them must be used alone in the cell of the array and it draws a dotted +% line between the first non-empty cells\footnote{The precise definition of a +% ``non-empty cell'' is given below (cf. p.~\pageref{empty-cells}).} on both +% sides of the current cell. Of course, for |\Ldots| and |\Cdots|, it's an +% horizontal line; for |\Vdots|, it's a vertical line and for |\Ddots| and +% |\Iddots| diagonal ones.\par\nobreak \bigskip % \begin{BVerbatim}[baseline=c,boxwidth=10cm] % \begin{bNiceMatrix} % a_1 & \Cdots & & & a_1 \\ @@ -247,8 +261,8 @@ version 2005/12/01 or later. % \end{bNiceMatrix}$ % % \interitem -% In order to represent the null matrix, one can use the following codage:\par\nobreak -% \bigskip +% In order to represent the null matrix, one can use the following +% codage:\par\nobreak \bigskip % \begin{BVerbatim}[baseline=c,boxwidth=10cm] % \begin{bNiceMatrix} % 0 & \Cdots & 0 \\ @@ -263,9 +277,9 @@ version 2005/12/01 or later. % \end{bNiceMatrix}$ % % \bigskip -% However, one may want a larger matrix. Usually, in such a case, the users of LaTeX add a new row and a new -% column. It's possible to use the same method with \pkg{nicematrix}:\par\nobreak -% \bigskip +% However, one may want a larger matrix. Usually, in such a case, the users of +% LaTeX add a new row and a new column. It's possible to use the same method +% with \pkg{nicematrix}:\par\nobreak \bigskip % \begin{BVerbatim}[baseline=c,boxwidth=10cm] % \begin{bNiceMatrix} % 0 & \Cdots & \Cdots & 0 \\ @@ -282,15 +296,19 @@ version 2005/12/01 or later. % \end{bNiceMatrix}$ % % \bigskip -% In the first column of this exemple, there are two instructions |\Vdots| but only one dotted line is drawn (there -% is no overlapping graphic objects in the resulting \textsc{pdf}\footnote{And it's not possible to draw a |\Ldots| -% and a |\Cdots| line between the same cells.}). -% -% However, useless computations are performed by TeX before detecting that both instructions would eventually yield -% the same dotted line. That's why the package \pkg{nicematrix} provides starred versions of |\Ldots|, |\Cdots|, -% etc.: |\Ldots*|, |\Cdots*|, etc. These versions are simply equivalent to |\hphantom{\ldots}|, -% |\hphantom{\cdots}|, etc. The user should use these starred versions whenever a classical version has already -% been used for the same dotted line.\par\nobreak +% In the first column of this exemple, there are two instructions |\Vdots| but +% only one dotted line is drawn (there is no overlapping graphic objects in the +% resulting \textsc{pdf}\footnote{And it's not possible to draw a |\Ldots| and a +% |\Cdots| line between the same cells.}). +% +% However, useless computations are performed by TeX before detecting that both +% instructions would eventually yield the same dotted line. That's why the +% package \pkg{nicematrix} provides starred versions of |\Ldots|, |\Cdots|, +% etc.: |\Ldots*|, |\Cdots*|, etc. These versions are simply equivalent to +% |\hphantom{\ldots}|, |\hphantom{\cdots}|, etc. The user should use these +% starred versions whenever a classical version has already been used for the +% same dotted line.\par\nobreak +% % \bigskip % \begin{BVerbatim}[baseline=c,boxwidth=10cm] % \begin{bNiceMatrix} @@ -308,8 +326,8 @@ version 2005/12/01 or later. % \end{bNiceMatrix}$ % % \bigskip -% In fact, in this example, it would be possible to draw the same matrix without starred commands with the -% following code:\par\nobreak +% In fact, in this example, it would be possible to draw the same matrix without +% starred commands with the following code:\par\nobreak % \bigskip % \begin{BVerbatim}[baseline=c,boxwidth=10cm] % \begin{bNiceMatrix} @@ -327,14 +345,16 @@ version 2005/12/01 or later. % \end{bNiceMatrix}$ % % \bigskip -% There are also other means to change the size of the matrix. Someone might want to use the optional argument of -% the command~|\\| for the vertical dimension and a command~|\hspace*| in a cell for the horizontal -% dimension.\footnote{Nevertheless, the best way to fix the width of a column is to use the environment -% |{NiceArray}| with a column of type~|w| (or |W|).} -% -% However, a command~|\hspace*| might interfer with the construction of the dotted lines. That's why the package -% \pkg{nicematrix} provides a command~|\Hspace| which is a variant of |\hspace| transparent for the dotted lines of -% \pkg{nicematrix}.\par\nobreak +% There are also other means to change the size of the matrix. Someone might +% want to use the optional argument of the command~|\\| for the vertical +% dimension and a command~|\hspace*| in a cell for the horizontal +% dimension.\footnote{Nevertheless, the best way to fix the width of a column is +% to use the environment |{NiceArray}| with a column of type~|w| (or |W|).} +% +% However, a command~|\hspace*| might interfer with the construction of the +% dotted lines. That's why the package \pkg{nicematrix} provides a +% command~|\Hspace| which is a variant of |\hspace| transparent for the dotted +% lines of \pkg{nicematrix}.\par\nobreak % \bigskip % \begin{BVerbatim}[baseline=c,boxwidth=10cm] % \begin{bNiceMatrix} @@ -351,7 +371,9 @@ version 2005/12/01 or later. % % \subsection{The option nullify-dots} % -% Consider the following matrix composed classicaly with the environment |{pmatrix}|.\par\nobreak +% Consider the following matrix composed classicaly with the environment +% |{pmatrix}|.\par\nobreak +% % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=8cm] % $A = \begin{pmatrix} @@ -374,7 +396,8 @@ version 2005/12/01 or later. % % % \bigskip -% If we add |\vdots| instructions in the second column, the geometry of the matrix is modified.\par\nobreak +% If we add |\vdots| instructions in the second column, the geometry of the +% matrix is modified.\par\nobreak % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=8cm] % $B = \begin{pmatrix} @@ -396,8 +419,9 @@ version 2005/12/01 or later. % \end{pmatrix}$ % % \bigskip -% By default, with \pkg{nicematrix}, if we replace |{pmatrix}| by |{pNiceMatrix}| and |\vdots| by -% |\Vdots| (or |\Vdots*| for efficiency), the geometry of the matrix is not changed.\par\nobreak +% By default, with \pkg{nicematrix}, if we replace |{pmatrix}| by +% |{pNiceMatrix}| and |\vdots| by |\Vdots| (or |\Vdots*| for efficiency), the +% geometry of the matrix is not changed.\par\nobreak % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=8cm] % $C = \begin{pNiceMatrix} @@ -419,9 +443,10 @@ version 2005/12/01 or later. % \end{pNiceMatrix}$ % % \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 |nullify-dots| (and only one instruction |\Vdots| is -% necessary).\par\nobreak +% 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 |nullify-dots| (and only one instruction |\Vdots| is +% necessary).\par\nobreak % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=8cm] % $D = \begin{pNiceMatrix}[~emphase#nullify-dots@] @@ -443,19 +468,23 @@ version 2005/12/01 or later. % \end{pNiceMatrix}$ % % \medskip -% The option |nullify-dots| 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. % % \medskip -% \textbf{There must be no space before the opening bracket (|[|) of the options of the environment.} +% \textbf{There must be no space before the opening bracket (|[|) of the options +% of the environment.} % % \subsection{The command Hdotsfor} % -% Some people commonly use the command |\hdotsfor| of \pkg{amsmath} in order to draw horizontal dotted lines in a -% matrix. In the environments of \pkg{nicematrix}, one should use instead |\Hdotsfor| in order to draw dotted lines similar -% to the other dotted lines drawn by the package \pkg{nicematrix}. +% Some people commonly use the command |\hdotsfor| of \pkg{amsmath} in order to +% draw horizontal dotted lines in a matrix. In the environments of +% \pkg{nicematrix}, one should use instead |\Hdotsfor| in order to draw dotted +% lines similar to the other dotted lines drawn by the package \pkg{nicematrix}. % -% As with the other commands of \pkg{nicematrix} (like |\Cdots|, |\Ldots|, |\Vdots|, etc.), the dotted line drawn -% with |\Hdotsfor| extends until the contents of the cells on both sides. +% As with the other commands of \pkg{nicematrix} (like |\Cdots|, |\Ldots|, +% |\Vdots|, etc.), the dotted line drawn with |\Hdotsfor| extends until the +% contents of the cells on both sides. % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=7cm] @@ -474,8 +503,8 @@ version 2005/12/01 or later. % \end{pNiceMatrix}$ % % \bigskip -% However, if these cells are empty, the dotted line extends only in the cells specified by the argument of -% |\Hdotsfor| (by design). +% However, if these cells are empty, the dotted line extends only in the cells +% specified by the argument of |\Hdotsfor| (by design). % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=7cm] @@ -494,39 +523,44 @@ version 2005/12/01 or later. % \end{pNiceMatrix}$ % % \bigskip -% The command |\hdotsfor| of \pkg{amsmath} takes an optional argument (between square brackets) which is -% used for fine tuning of the space beetween two consecutive dots. For homogeneity, |\Hdotsfor| has -% also an optional argument but this argument is discarded silently. +% The command |\hdotsfor| of \pkg{amsmath} takes an optional argument (between +% square brackets) which is used for fine tuning of the space beetween two +% consecutive dots. For homogeneity, |\Hdotsfor| has also an optional argument +% but this argument is discarded silently. % -% Remark: Unlike the command |\hdotsfor| of \pkg{amsmath}, the command |\Hdotsfor| is compatible with the extension -% \pkg{colortbl}. +% Remark: Unlike the command |\hdotsfor| of \pkg{amsmath}, the command +% |\Hdotsfor| is compatible with the extension \pkg{colortbl}. % % \subsection{How to generate the continuous dotted lines transparently} % -% 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|. +% 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: |renew-dots| and |renew-matrix|. +% In fact, this option is an alias for the conjonction of two options: +% |renew-dots| and |renew-matrix|. % % \smallskip % % \begin{itemize} % \item The option |renew-dots|\par\nobreak -% With this option, the commands |\ldots|, |\cdots|, |\vdots|, |\ddots|, |\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.} and |\hdotsfor| are redefined within the environments provided by \pkg{nicematrix} -% and behave like |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, |\Iddots| and |\Hdotsfor|; the command |\dots| (``automatic -% dots'' of |amsmath|) is also redefined to behave like |\Ldots|. -% -% \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. +% With this option, the commands |\ldots|, |\cdots|, |\vdots|, |\ddots|, +% |\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.} and |\hdotsfor| are redefined within the environments +% provided by \pkg{nicematrix} and behave like |\Ldots|, |\Cdots|, |\Vdots|, +% |\Ddots|, |\Iddots| and |\Hdotsfor|; the command |\dots| (``automatic dots'' +% of |amsmath|) is also redefined to behave like |\Ldots|. +% +% \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{scope} % \NiceMatrixOptions{transparent} @@ -549,11 +583,13 @@ version 2005/12/01 or later. % % \section{The Tikz nodes created by nicematrix} % -% The package \pkg{nicematrix} creates a Tikz node for each cell of the considered array. These nodes are used to -% draw the dotted lines between the cells of the matrix. However, the user may wish to use directly these nodes. -% It's possible. First, the user have to give a name to the array (with the key called |name|). Then, the nodes are -% accessible through the names ``\textsl{name}-$i$-$j$'' where \textsl{name} is the name given to the array and -% $i$ and $j$ the numbers of the row and the column of the considered cell. +% The package \pkg{nicematrix} creates a Tikz node for each cell of the +% considered array. These nodes are used to draw the dotted lines between the +% cells of the matrix. However, the user may wish to use directly these nodes. +% It's possible. First, the user have to give a name to the array (with the key +% called |name|). Then, the nodes are accessible through the names +% ``\textsl{name}-$i$-$j$'' where \textsl{name} is the name given to the array +% and $i$ and $j$ the numbers of the row and the column of the considered cell. % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=11cm] @@ -589,12 +625,15 @@ version 2005/12/01 or later. % % % \bigskip -% In fact, the package \pkg{nicematrix} can create ``extra nodes''. These new nodes are created if the option -% |create-extra-nodes| is used. There are two series of extra nodes: the ``medium nodes'' and the ``large nodes''. +% In fact, the package \pkg{nicematrix} can create ``extra nodes''. These new +% nodes are created if the option |create-extra-nodes| is used. There are two +% series of extra nodes: the ``medium nodes'' and the ``large nodes''. % % \medskip -% The names of the ``medium nodes'' are constructed by adding the suffix ``|-medium|'' to the names of the ``normal -% nodes''. In the following example, we have underlined the ``medium nodes''. We consider that this example is self-explanatory. +% The names of the ``medium nodes'' are constructed by adding the suffix +% ``|-medium|'' to the names of the ``normal nodes''. In the following example, +% we have underlined the ``medium nodes''. We consider that this example is +% self-explanatory. % \[\begin{pNiceMatrix}[ % create-extra-nodes, % code-after = {\begin{tikzpicture} @@ -616,13 +655,15 @@ version 2005/12/01 or later. % a & a & a + b \\ % a & a & a % \end{pNiceMatrix}\] -% +% % % \medskip -% The names of the ``large nodes'' are constructed by adding the suffix ``|-large|'' to the names of the ``normal -% nodes''. In the following example, we have underlined the ``large nodes''. We consider that this example is -% self-explanatory.\footnote{In the environments like |{pNiceArrayC}| and |{pNiceArrayRC}|, there is not ``large -% nodes'' created in the exterior row and column.} +% The names of the ``large nodes'' are constructed by adding the suffix +% ``|-large|'' to the names of the ``normal nodes''. In the following example, +% we have underlined the ``large nodes''. We consider that this example is +% self-explanatory.\footnote{In the environments like |{pNiceArrayC}| and +% |{pNiceArrayRC}|, there is not ``large nodes'' created in the exterior row and +% column.} % % \[\begin{pNiceMatrix}[ % create-extra-nodes, @@ -647,11 +688,13 @@ version 2005/12/01 or later. % % % \medskip -% The ``large nodes'' of the first column and last column may appear too small for some usage. That's why it's -% possible to use the options |left-margin| and |right-margin| to add space on both sides of the array and also -% space in the ``large nodes'' of the first column and last column. In the following example, we have used the -% options |left-margin| and |right-margin|.\footnote{The options |left-margin| and |right-margin| take dimensions -% as values but, if no value is given, the default value is used, which is |\arraycolsep|.} +% The ``large nodes'' of the first column and last column may appear too small +% for some usage. That's why it's possible to use the options |left-margin| and +% |right-margin| to add space on both sides of the array and also space in the +% ``large nodes'' of the first column and last column. In the following example, +% we have used the options |left-margin| and |right-margin|.\footnote{The +% options |left-margin| and |right-margin| take dimensions as values but, if no +% value is given, the default value is used, which is |\arraycolsep|.} % \[\begin{pNiceMatrix}[ % create-extra-nodes,left-margin,right-margin, % code-after = {\begin{tikzpicture} @@ -674,9 +717,10 @@ version 2005/12/01 or later. % \end{pNiceMatrix}\] % % \medskip -% It's also possible to add more space on both side of the array with the options |extra-left-margin| and -% |extra-right-margin|. These margins are not incorporated in the ``large nodes''. In the following example, we -% have used |extra-left-margin| and |extra-right-margin| with the value $3$~pt. +% It's also possible to add more space on both side of the array with the +% options |extra-left-margin| and |extra-right-margin|. These margins are not +% incorporated in the ``large nodes''. In the following example, we have used +% |extra-left-margin| and |extra-right-margin| with the value $3$~pt. % \[\begin{pNiceMatrix}[ % create-extra-nodes,left-margin,right-margin,extra-right-margin=3pt,extra-left-margin=3pt, % code-after = {\begin{tikzpicture} @@ -699,7 +743,8 @@ version 2005/12/01 or later. % \end{pNiceMatrix}\] % % \medskip -% In this case, if we want a control over the height of the rows, we can add a |\strut| in each row of the array. +% In this case, if we want a control over the height of the rows, we can add a +% |\strut| in each row of the array. % \[\begin{pNiceMatrix}[ % create-extra-nodes,left-margin,right-margin,extra-right-margin=3pt,extra-left-margin=3pt, % code-after = {\begin{tikzpicture} @@ -726,13 +771,15 @@ version 2005/12/01 or later. % % \section{The code-after} % -% The option |code-after| may be used to give some code that will be excuted after the construction of the matrix -% (and, hence, after the construction of all the Tikz nodes). +% The option |code-after| may be used to give some code that will be excuted +% after the construction of the matrix (and, hence, after the construction of +% all the Tikz nodes). % -% In the |code-after|, the Tikz nodes should be accessed by a name of the form $i$-$j$ (without the prefix of the -% name of the environment). +% In the |code-after|, the Tikz nodes should be accessed by a name of the form +% $i$-$j$ (without the prefix of the name of the environment). % -% Moreover, a special command, called |\line| is available to draw directly dotted lines between nodes. +% Moreover, a special command, called |\line| is available to draw directly +% dotted lines between nodes. % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=12cm] @@ -752,17 +799,21 @@ version 2005/12/01 or later. % \section{The environment \{NiceArray\}} % \label{NiceArray} % -% The environment |{NiceArray}| is similar to the environment |{array}|. As for |{array}|, the mandatory argument -% is the preamble of the array. However, for technical reasons, in this preamble, the user must use the letters -% |L|, |C| and~|R|\footnote{The column types |L|, |C| and |R| are defined locally inside |{NiceArray}| with -% |\newcolumntype| of \pkg{array}. This definition overrides an eventual previous definition.} instead of |l|, |c| -% and |r|. It's possible to use the constructions \verb|w{...}{...}|, \verb|W{...}{...}|, \verb+|+, |>{...}|, -% |<{...}|, |@{...}|, |!{...}| and |*{n}{...}| but the letters |p|, |m| and |b| should not be used.\footnote{In a -% command |\multicolumn|, one should also use the letters |L|, |C|, |R|.} +% The environment |{NiceArray}| is similar to the environment |{array}|. As for +% |{array}|, the mandatory argument is the preamble of the array. However, for +% technical reasons, in this preamble, the user must use the letters |L|, |C| +% and~|R|\footnote{The column types |L|, |C| and |R| are defined locally inside +% |{NiceArray}| with |\newcolumntype| of \pkg{array}. This definition overrides +% an eventual previous definition.} instead of |l|, |c| and |r|. It's possible +% to use the constructions \verb|w{...}{...}|, \verb|W{...}{...}|, \verb+|+, +% |>{...}|, |<{...}|, |@{...}|, |!{...}| and |*{n}{...}| but the letters |p|, +% |m| and |b| should not be used.\footnote{In a command |\multicolumn|, one +% should also use the letters |L|, |C|, |R|.} % % \medskip -% The environment |{NiceArray}| accepts the classical options |t|, |c| and |b| of |{array}| but also other options -% defined by \pkg{nicematrix} (|renew-dots|, |columns-width|, etc.). +% The environment |{NiceArray}| accepts the classical options |t|, |c| and |b| +% of |{array}| but also other options defined by \pkg{nicematrix} (|renew-dots|, +% |columns-width|, etc.). % % % \vspace{1cm} @@ -785,7 +836,8 @@ version 2005/12/01 or later. % \end{NiceArray}\right]$ % % \vspace{1cm} -% An example where we use |{NiceArray}| because we want to use the types |L| and |R| for the columns: +% An example where we use |{NiceArray}| because we want to use the types |L| and +% |R| for the columns: % % \bigskip % \begin{BVerbatim}[baseline=c,boxwidth=10cm] @@ -811,12 +863,14 @@ version 2005/12/01 or later. % % The environment |{pNiceArrayC}| composes a matrix with an exterior column. % -% 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}|. \textbf{However, no specification must be -% given for the last column.} It will automatically (and necessarily) be a |L|~column. +% 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}|. \textbf{However, no specification must be given for +% the last column.} It will automatically (and necessarily) be a |L|~column. % -% A special option, called |code-for-last-col|, specifies tokens that will be inserted before each cell of the last -% column. The option |columns-width| doesn't apply to this external column. +% A special option, called |code-for-last-col|, specifies tokens that will be +% inserted before each cell of the last column. The option |columns-width| +% doesn't apply to this external column. % % \bigskip % @@ -842,10 +896,11 @@ version 2005/12/01 or later. % % % \bigskip -% In fact, the environment |{pNiceArrayC}| and its variants are based upon a more general environment, called -% |{NiceArrayCwithDelims}|. The first two mandatory arguments of this environment are the left and right delimiters -% used in the construction of the matrix. It's possible to use |{NiceArrayCwithDelims}| if we want to use atypical -% delimiters. +% In fact, the environment |{pNiceArrayC}| and its variants are based upon a +% more general environment, called |{NiceArrayCwithDelims}|. The first two +% mandatory arguments of this environment are the left and right delimiters used +% in the construction of the matrix. It's possible to use +% |{NiceArrayCwithDelims}| if we want to use atypical delimiters. % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=11cm] @@ -867,14 +922,16 @@ version 2005/12/01 or later. % \section{The environment \{pNiceArrayRC\} and its variants} % \label{pNiceArrayRC} % -% The environment |{pNiceArrayRC}| composes a matrix with an exterior row and an exterior column. +% The environment |{pNiceArrayRC}| composes a matrix with an exterior row and an +% exterior column. % -% This environment |{pNiceArrayRC}| takes a mandatory argument which is the preamble of the array. As for the -% environment |{pNiceArrayC}|, no specification must be given for the last column (it will automatically be a |L| -% column). +% This environment |{pNiceArrayRC}| takes a mandatory argument which is the +% preamble of the array. As for the environment |{pNiceArrayC}|, no +% specification must be given for the last column (it will automatically be a +% |L| column). % -% A special option, called |code-for-first-row|, specifies tokens that will be inserted before each cell of the -% first row. +% A special option, called |code-for-first-row|, specifies tokens that will be +% inserted before each cell of the first row. % % \bigskip % \begin{BVerbatim}[baseline=c,boxwidth=11cm] @@ -899,17 +956,19 @@ version 2005/12/01 or later. % % % \bigskip -% The first row of an environment |{pNiceArrayRC}| has the number $0$, and not $1$. This number is used for the -% names of the Tikz nodes (the names of these nodes are used, for example, by the command |\line| in |code-after|). +% The first row of an environment |{pNiceArrayRC}| has the number $0$, and not +% $1$. This number is used for the names of the Tikz nodes (the names of these +% nodes are used, for example, by the command |\line| in |code-after|). % -% For technical reasons, it's not possible to use the option of the command |\\| after the first row (the placement -% of the delimiters would be wrong). +% For technical reasons, it's not possible to use the option of the command |\\| +% after the first row (the placement of the delimiters would be wrong). % % \bigskip -% In fact, the environment |{pNiceArrayRC}| and its variants are based upon an more general environment, called -% |{NiceArrayRCwithDelims}|. The first two mandatory arguments of this environment are the left and right delimiters -% used in the construction of the matrix. It's possible to use |{NiceArrayRCwithDelims}| if we want to use atypical -% delimiters. +% In fact, the environment |{pNiceArrayRC}| and its variants are based upon an +% more general environment, called |{NiceArrayRCwithDelims}|. The first two +% mandatory arguments of this environment are the left and right delimiters used +% in the construction of the matrix. It's possible to use +% |{NiceArrayRCwithDelims}| if we want to use atypical delimiters. % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=11cm] @@ -931,7 +990,8 @@ version 2005/12/01 or later. % % % \bigskip -% If we want to write a linear system, we can use the following code, with a preamble \verb+CCC|C+: +% If we want to write a linear system, we can use the following code, with a +% preamble \verb+CCC|C+: % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=11cm] @@ -950,8 +1010,9 @@ version 2005/12/01 or later. % \end{pNiceArrayRC}$ % % \medskip -% The resultat may seem disappointing. It's possible to suppress the vertical rule in the first row with the -% command |\multicolumn| in order to ``reconstruct'' the cell. +% The resultat may seem disappointing. It's possible to suppress the vertical +% rule in the first row with the command |\multicolumn| in order to +% ``reconstruct'' the cell. % % % \bigskip @@ -971,8 +1032,9 @@ version 2005/12/01 or later. % \end{pNiceArrayRC}$ % % \bigskip -% On the other side, we may remark that an horizontal line (with |\hline| or |\hdashline| of \pkg{arydshln}) -% doesn't extend in the ``exterior column'' of an environment like |{pNiceArrayC}| or |{pNiceArrayRC}|. +% On the other side, we may remark that an horizontal line (with |\hline| or +% |\hdashline| of \pkg{arydshln}) doesn't extend in the ``exterior column'' of +% an environment like |{pNiceArrayC}| or |{pNiceArrayRC}|. % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=11cm] @@ -1015,8 +1077,8 @@ version 2005/12/01 or later. % % % \bigskip -% It's also possible to fix the width of all the columns of a matrix directly with the option |columns-width| (in -% all the environments of \pkg{nicematrix}). +% It's also possible to fix the width of all the columns of a matrix directly +% with the option |columns-width| (in all the environments of \pkg{nicematrix}). % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=10cm] @@ -1033,11 +1095,13 @@ version 2005/12/01 or later. % \end{pNiceMatrix}$ % % \medskip -% Note that the space inserted between two columns (equal to 2 |\arraycolsep|) is not suppressed. +% Note that the space inserted between two columns (equal to 2 |\arraycolsep|) +% is not suppressed. % % \bigskip -% It's possible to give the 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. \textbf{Two or three compilations may be necessary.}\par\nobreak +% It's possible to give the 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. +% \textbf{Two or three compilations may be necessary.}\par\nobreak % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=10cm] % $\begin{pNiceMatrix}[~emphase#columns-width = auto@] @@ -1053,8 +1117,8 @@ version 2005/12/01 or later. % \end{pNiceMatrix}$ % % \bigskip -% It's possible to fix the width of the columns of all the matrices of a current scope with the command -% |\NiceMatrixOptions|.\par\nobreak +% It's possible to fix the width of the columns of all the matrices of a current +% scope with the command |\NiceMatrixOptions|.\par\nobreak % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=8.5cm] % ~emphase#\NiceMatrixOptions{columns-width=10mm}@ @@ -1081,10 +1145,11 @@ version 2005/12/01 or later. % % % \bigskip -% But it's also possible to fix a zone where all the matrices will have their columns of the same width, equal to -% the widest cell of all the matrices. This construction uses the environment |{NiceMatrixBlock}| with the option -% |auto-columns-width|.\footnote{At this time, this is the only usage of the environment |{NiceMatrixBlock}| but -% it may have other usages in the future.} +% But it's also possible to fix a zone where all the matrices will have their +% columns of the same width, equal to the widest cell of all the matrices. This +% construction uses the environment |{NiceMatrixBlock}| with the option +% |auto-columns-width|.\footnote{At this time, this is the only usage of the +% environment |{NiceMatrixBlock}| but it may have other usages in the future.} % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=8.5cm] @@ -1113,11 +1178,13 @@ version 2005/12/01 or later. % % \subsection{Diagonal lines} % -% 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 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 array can have a marked -% effect on the final result. +% 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 +% 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 array can have a marked effect on the +% final result. % % \medskip % In the following examples, the first |\Ddots| instruction is written in color: @@ -1162,7 +1229,8 @@ version 2005/12/01 or later. % \end{pNiceMatrix}$ % % \bigskip -% It's possible to turn off the parallelization with the option |parallelize-diags| 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{parallelize-diags=false}% @@ -1182,9 +1250,11 @@ version 2005/12/01 or later. % \subsection{The ``empty'' cells} % % \label{empty-cells} -% An instruction like |\Ldots|, |\Cdots|, etc. tries to determine the first non-empty cells on both sides. 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. +% An instruction like |\Ldots|, |\Cdots|, etc. tries to determine the first +% non-empty cells on both sides. 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. % % \interitem % For \pkg{nicematrix}, the precise rules are as follow. @@ -1205,35 +1275,43 @@ version 2005/12/01 or later. % \item Each cell whose TeX ouput has a width less than 0.5~pt is empty. % % \medskip -% \item A cell which contains a command |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots| or |\Iddots| and their starred -% versions is empty. We recall that these commands should be used alone in a cell. +% \item A cell which contains a command |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots| +% or |\Iddots| and their starred versions is empty. We recall that these +% commands should be used alone in a cell. % % \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 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}. +% \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 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} % % % \subsection{The option exterior-arraycolsep} % -% The environment |{array}| inserts an 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 -% 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).} It's possible to suppress -% these spaces for a given environment |{array}| with a construction like |\begin{array}{@{}ccccc@{}}|.} +% The environment |{array}| inserts an 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 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).} 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} prefer to delete -% these spaces with explicit instructions |\hskip -\arraycolsep| and |{NiceArray}| does likewise. +% The environment |{matrix}| and its variants (|{pmatrix}|, |{vmatrix}|, etc.) +% of \pkg{amsmath} 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| of the command -% |\NiceMatrixOptions|. With this option, |{NiceArray}| will insert the same horizontal spaces as the environment -% |{array}|. +% However, the user can change this behaviour with the boolean option +% |exterior-arraycolsep| of the command |\NiceMatrixOptions|. With this option, +% |{NiceArray}| will insert the same horizontal spaces as the environment +% |{array}|. % -% This option is only for ``compatibility'' since the package \pkg{nicematrix} provides a more precise control with -% the options |left-margin|, |right-margin|, |extra-left-margin| and |extra-right-margin|. +% This option is only for ``compatibility'' since the package \pkg{nicematrix} +% provides a more precise control with the options |left-margin|, +% |right-margin|, |extra-left-margin| and |extra-right-margin|. % % % \subsection{The class option draft} @@ -1309,16 +1387,6 @@ version 2005/12/01 or later. % \end{pNiceMatrix}$ % % -% \subsection{A remark concerning a bug of Tikz} -% -% Due to a bug in Tikz, the construction |-- cycle| in a Tikz path is incompatible with the use of |name prefix| -% and |name suffix|.\footnote{cf. |tex.stackexchange.com/questions/327007/tikz-fill-not-being-drawn-using-named-coordinates|} -% -% \bigskip -% Since |name prefix| is implicitly used in the |code-after| of \pkg{nicematrix}, it's not -% possible to use |-- cycle| in |code-after|. -% -% % \subsection{Compatibility with the extension dcolumn} % % \label{dcolumn} @@ -1895,7 +1963,7 @@ version 2005/12/01 or later. % \begin{macrocode} \RequirePackage{tikz} \usetikzlibrary{fit} -\RequirePackage{expl3}[2018-01-01] +\RequirePackage{expl3}[2019/02/15] % \end{macrocode} % % We give the traditionnal declaration of a package written with |expl3|: @@ -1913,52 +1981,74 @@ version 2005/12/01 or later. % won't draw the dotted lines if the option |draft| is used. % \begin{macrocode} \bool_new:N \c_@@_draft_bool -\DeclareOption {draft} {\bool_set_true:N \c_@@_draft_bool} -\DeclareOption* {} +\DeclareOption { draft } { \bool_set_true:N \c_@@_draft_bool } +\DeclareOption* { } \ProcessOptions \relax % \end{macrocode} % -% The command for the treatment of the options of |\usepackage| is at the end of this package for technical reasons. +% The command for the treatment of the options of |\usepackage| is at the end of +% this package for technical reasons. % % \bigskip % We load \pkg{array} and \pkg{amsmath}. % \begin{macrocode} -\RequirePackage{array} -\RequirePackage{amsmath} -\RequirePackage{xparse}[2018-10-17] +\RequirePackage { array } +\RequirePackage { amsmath } +\RequirePackage { xparse } [ 2018-10-17 ] % \end{macrocode} % % \subsection{Technical definitions} % +% We test wether the current class is \cls{revtex4-1} or \cls{revtex4-2}. % \begin{macrocode} -\cs_new_protected:Nn \@@_error:n - {\msg_error:nn {nicematrix} {#1}} -\cs_new_protected:Nn \@@_error:nn - {\msg_error:nn {nicematrix} {#1} {#2}} +\bool_new:N \c_@@_revtex_bool +\@ifclassloaded { revtex4-1 } + { \bool_set_true:N \c_@@_revtex_bool } + { } +\@ifclassloaded { revtex4-2 } + { \bool_set_true:N \c_@@_revtex_bool } + { } % \end{macrocode} % -% \medskip +% % \begin{macrocode} -\cs_new_protected:Nn \@@_bool_new:N - {\bool_if_exist:NTF #1 - {\bool_set_false:N #1} - {\bool_new:N #1}} +\cs_new_protected:Nn \@@_error:n { \msg_error:nn { nicematrix } { #1 } } % \end{macrocode} -% +% +% \begin{macrocode} +\cs_new_protected:Nn \@@_error:nn { \msg_error:nn { nicematrix } { #1 } { #2 } } +% \end{macrocode} +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_msg_new:nn { \msg_new:nnn { nicematrix } } +% \end{macrocode} +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_msg_new:nnn { \msg_new:nnnn { nicematrix } } +% \end{macrocode} +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_msg_redirect_name:nn + { \msg_redirect_name:nnn { nicematrix } } +% \end{macrocode} +% +% \bigskip % First, we define a command |\iddots| similar to |\ddots| ($\ddots$) but with dots going forward ($\iddots$). We % use |\ProvideDocumentCommand| of \pkg{xparse}, and so, if the command |\iddots| has already been defined (for % example by the package \pkg{mathdots}), we don't define it again. % % \begin{macrocode} -\ProvideDocumentCommand \iddots {} - {\mathinner{\mkern 1mu - \raise \p@ \hbox{.} - \mkern 2mu - \raise 4\p@ \hbox{.} - \mkern 2mu - \raise 7\p@ \vbox{\kern 7pt - \hbox{.}} - \mkern 1mu}} +\ProvideDocumentCommand \iddots { } + { + \mathinner + { \mkern 1 mu + \raise \p@ \hbox { . } + \mkern 2 mu + \raise 4 \p@ \hbox { . } + \mkern 2 mu + \raise 7 \p@ \vbox { \kern 7 pt \hbox { . } } \mkern 1 mu + } + } % \end{macrocode} % % This definition is a variant of the standard definition of |\ddots|. @@ -1979,103 +2069,127 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% The sequence |\g_@@_names_seq| will be the list of all the names of environments used (via the option |name|) in -% the document: two environments must not have the same name. +% The sequence |\g_@@_names_seq| will be the list of all the names of +% environments used (via the option |name|) in the document: two environments +% must not have the same name. However, it's possible to use the option +% |allow-duplicate-names|. % \begin{macrocode} \seq_new:N \g_@@_names_seq % \end{macrocode} % % \bigskip -% The integer |\l_@@_nb_first_row_int| is the number of the first row of the array. The default value is $1$, but, -% in the environments like |{pNiceArrayRC}|, the value will be~$0$. +% The integer |\l_@@_nb_first_row_int| is the number of the first row of the +% array. The default value is $1$, but, in the environments like +% |{pNiceArrayRC}|, the value will be~$0$. % \begin{macrocode} \int_new:N \l_@@_nb_first_row_int \int_set:Nn \l_@@_nb_first_row_int 1 % \end{macrocode} % % \bigskip -% The flag |\l_@@_exterior_column_bool| will indicate if we are in an environment of the type of |{pNiceArrayC}| or -% |{pNiceArrayRC}|. It will be used for the creation of the ``large nodes''. +% The flag |\l_@@_exterior_column_bool| will indicate if we are in an +% environment of the type of |{pNiceArrayC}| or |{pNiceArrayRC}|. It will be +% used for the creation of the ``large nodes''. % \begin{macrocode} \bool_new:N \l_@@_exterior_column_bool % \end{macrocode} % +% +% \bigskip +% We want to known if we are in a environment |{NiceArray}| because we want to +% raise an error if the user tries to use nested environments |{NiceArray}|. +% \begin{macrocode} +\bool_new:N \l_@@_in_NiceArray_bool +% \end{macrocode} +% % \bigskip % \subsection{The options} % -% The token list |\l_@@_pos_env_tl| will contain one of the three values |t|, |c| or |b| and will indicate the -% position of the environment as in the option of the environment |{array}|. For the environment |{pNiceMatrix}|, -% |{pNiceArrayC}|, |{pNiceArrayRC}| and their variants, the value will programmatically be fixed to |c|. For the -% environment |{NiceArray}|, however, the three values |t|, |c| and |b| are possible. +% The token list |\l_@@_pos_env_str| will contain one of the three values |t|, +% |c| or |b| and will indicate the position of the environment as in the option +% of the environment |{array}|. For the environment |{pNiceMatrix}|, +% |{pNiceArrayC}|, |{pNiceArrayRC}| and their 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 +\str_new:N \l_@@_pos_env_str +\str_set:Nn \l_@@_pos_env_str c % \end{macrocode} % % \bigskip -% The flag |\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 neither for -% |{NiceMatrix}|, |{pNiceArrayC}|, |{pNiceArrayRC}| and their variants even if these environments rely upon |{NiceArray}|). +% The flag |\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 neither for +% |{NiceMatrix}|, |{pNiceArrayC}|, |{pNiceArrayRC}| and their variants even if +% these environments rely upon |{NiceArray}|). % \begin{macrocode} \bool_new:N \l_@@_exterior_arraycolsep_bool % \end{macrocode} % % \bigskip -% The flag |\l_@@_parallelize_diags_bool| controls wether the diagonals are parallelized. The initial value -% is~|true|. +% The flag |\l_@@_parallelize_diags_bool| controls wether the diagonals are +% parallelized. The initial value is~|true|. % \begin{macrocode} \bool_new:N \l_@@_parallelize_diags_bool \bool_set_true:N \l_@@_parallelize_diags_bool % \end{macrocode} % % \bigskip -% 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.) +% 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} \bool_new:N \l_@@_nullify_dots_bool % \end{macrocode} % % % \bigskip -% The following flag will be used when the current options specify that all the columns of the array must have the -% same width equal to the largest width of a cell of the array (except the cell of the ``exterior column'' of an -% environment of the kind of |{pNiceArrayC}|). +% The following flag will be used when the current options specify that all the +% columns of the array must have the same width equal to the largest width of a +% cell of the array (except the cell of the ``exterior column'' of an +% environment of the kind of |{pNiceArrayC}|). % \begin{macrocode} \bool_new:N \l_@@_auto_columns_width_bool % \end{macrocode} % % \bigskip -% The token list |\l_@@_code_for_last_col_tl| will contain code inserted at the beginning of each cell of the last -% column in the environment |{pNiceArrayC}| (and its variants). It corresponds to the option |code-for-last-col|. +% The token list |\l_@@_code_for_last_col_tl| will contain code inserted at the +% beginning of each cell 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 don't want to patch any existing code. That's why some code must be executed in a |\group_insert_after:N|. That's why -% the parameters used in that code must be transfered outside the current group. To do this, we copy those -% quantities in global variables just before the |\group_insert_after:N|. Therefore, for those quantities, we have two -% parameters, one local and one global. For example, we have |\l_@@_name_tl| and |\g_@@_name_tl|. +% We don't want to patch any existing code. That's why some code must be +% executed in a |\group_insert_after:N|. That's why the parameters used in that +% code must be transfered outside the current group. To do this, we copy those +% quantities in global variables just before the |\group_insert_after:N|. +% Therefore, for those quantities, we have two parameters, one local and one +% global. For example, we have |\l_@@_name_str| and |\g_@@_name_str|. % % \bigskip -% The token list |\l_@@_name_tl| will contain the optional name of the environment: this name can be used to -% access to the Tikz nodes created in the array from outside the environment. +% The token list |\l_@@_name_str| will contain the optional name of the +% environment: this name can be used to access to the Tikz nodes created in the +% array from outside the environment. % \begin{macrocode} -\tl_new:N \g_@@_name_tl -\tl_new:N \l_@@_name_tl +\str_new:N \g_@@_name_str +\str_new:N \l_@@_name_str % \end{macrocode} % % \bigskip -% The boolean |\l_@@_extra_nodes_bool| will be used to indicate wether the ``medium nodes'' and ``large nodes'' are -% created in the array. +% The boolean |\l_@@_extra_nodes_bool| will be used to indicate wether the +% ``medium nodes'' and ``large nodes'' are created in the array. % \begin{macrocode} \bool_new:N \l_@@_extra_nodes_bool \bool_new:N \g_@@_extra_nodes_bool % \end{macrocode} % % \bigskip -% The dimensions |\l_@@_left_margin_dim| and |\l_@@_right_margin_dim| correspond to the options |left-margin| and |right-margin|. +% The dimensions |\l_@@_left_margin_dim| and |\l_@@_right_margin_dim| correspond +% to the options |left-margin| and |right-margin|. % \begin{macrocode} \dim_new:N \l_@@_left_margin_dim \dim_new:N \l_@@_right_margin_dim @@ -2084,8 +2198,9 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% The dimensions |\l_@@_extra_left_margin_dim| and |\l_@@_extra_right_margin_dim| correspond to the options -% |extra-left-margin| and |extra-right-margin|. +% The dimensions |\l_@@_extra_left_margin_dim| and +% |\l_@@_extra_right_margin_dim| correspond to the options |extra-left-margin| +% and |extra-right-margin|. % \begin{macrocode} \dim_new:N \l_@@_extra_left_margin_dim \dim_new:N \l_@@_extra_right_margin_dim @@ -2094,746 +2209,900 @@ version 2005/12/01 or later. % % % \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 ``camel-case 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.} +% First, we define a set of keys ``|NiceMatrix / Global|'' which will be used +% (with the mechanism of |.inherit:n| by other keys of set). % \begin{macrocode} -\keys_define:nn {NiceMatrix/NiceMatrixOptions} - {parallelize-diags .bool_set:N = \l_@@_parallelize_diags_bool, - parallelize-diags .default:n = true, - ParallelizeDiagonals .meta:n = parallelize-diags, +\keys_define:nn { NiceMatrix / Global } + { + parallelize-diags .bool_set:N = \l_@@_parallelize_diags_bool , + parallelize-diags .default:n = true , % \end{macrocode} % % \bigskip -% With the option |renew-dots|, the command |\cdots|, |\ldots|, |\vdots| and |\ddots| are redefined and behave like the -% commands |\Cdots|, |\Ldots|, |\Vdots| and |\Ddots|. +% 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} - renew-dots .bool_set:N = \l_@@_renew_dots_bool, - renew-dots .default:n = true, - RenewDots .meta:n = renew-dots, + 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 , % \end{macrocode} % % \bigskip -% 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} - renew-matrix .code:n = \@@_renew_matrix:, - 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, +% An option to test wether the extra nodes will be created (these nodes are the +% ``medium nodes'' and ``large nodes''). In some circonstancies, the extra nodes +% are created automatically, for example when a dotted line has an ``open'' +% extremity. +% \begin{macrocode} + create-extra-nodes .bool_set:N = \l_@@_extra_nodes_bool , + create-extra-nodes .default:n = true, + left-margin .dim_set:N = \l_@@_left_margin_dim , + left-margin .default:n = \arraycolsep , + right-margin .dim_set:N = \l_@@_right_margin_dim , + right-margin .default:n = \arraycolsep , + extra-left-margin .dim_set:N = \l_@@_extra_left_margin_dim , + extra-right-margin .dim_set:N = \l_@@_extra_right_margin_dim + } % \end{macrocode} % % \bigskip -% 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} - nullify-dots .bool_set:N = \l_@@_nullify_dots_bool , - nullify-dots .default:n = true, - NullifyDots .meta:n = nullify-dots, +% We define a set of keys used by the environments (and not by the command +% |\NiceMatrixOptions|). +% \begin{macrocode} +\keys_define:nn { NiceMatrix / Env } + { + columns-width .code:n = + \str_if_eq:nnTF { #1 } { auto } + { \bool_set_true:N \l_@@_auto_columns_width_bool } + { \dim_set:Nn \l_@@_columns_width_dim { #1 } } , + columns-width .value_required:n = true , + name .code:n = + \seq_if_in:NnTF \g_@@_names_seq { #1 } + { \@@_error:nn { Duplicate~name } { #1 } } + { \seq_gput_left:Nn \g_@@_names_seq { #1 } } + \str_set:Nn \l_@@_name_str { #1 } , + name .value_required:n = true , + code-after .tl_set:N = \l_@@_code_after_tl , + code-after .initial:n = \c_empty_tl , + code-after .value_required:n = true , + } % \end{macrocode} -% % % \bigskip -% The following option is only for the environment |{pNiceArrayC}| and its variants. It will contain code inserted -% at the beginning of each cell of the last column.\footnote{In an environment |{pNiceArrayC}|, the last column is +% We begin the construction of the major sets of keys (used by the differents +% user commands and environments). +% \begin{macrocode} +\keys_define:nn { NiceMatrix } + { + NiceMatrixOptions .inherit:n = NiceMatrix / Global , + NiceMatrix .inherit:n = + { + NiceMatrix / Global , + NiceMatrix / Env + } , + NiceArray .inherit:n = + { + NiceMatrix / Global , + NiceMatrix / Env + } , + NiceArrayC .inherit:n = + { + NiceMatrix / Global , + NiceMatrix / Env + } , + NiceArrayRC .inherit:n = + { + NiceMatrix / Global , + NiceMatrix / Env + } + } +% \end{macrocode} +% +% +% \bigskip +% We finalise the definition of the set of keys +% ``|NiceMatrix / NiceMatrixOptions|'' with the options specific to +% |\NiceMatrixOptions|. +% \begin{macrocode} +\keys_define:nn { NiceMatrix / NiceMatrixOptions } + { +% \end{macrocode} +% +% 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} + renew-matrix .code:n = \@@_renew_matrix: , + 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 +% The following option is only for the environment |{pNiceArrayC}| and its +% variants. It will contain 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} + code-for-last-col .tl_set:N = \l_@@_code_for_last_col_tl , + code-for-last-col .value_required:n = true , +% \end{macrocode} % % \bigskip % Idem for the first row in environments like |{pNiceArrayRC}|. % \begin{macrocode} - code-for-first-row .tl_set:N = \l_@@_code_for_first_row_tl, - code-for-first-row .value_required:n = true, + code-for-first-row .tl_set:N = \l_@@_code_for_first_row_tl , + code-for-first-row .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}|. +% 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, + exterior-arraycolsep .bool_set:N = \l_@@_exterior_arraycolsep_bool , + exterior-arraycolsep .default:n = true , % \end{macrocode} % % \bigskip -% If the option |columns-width| is used, all the columns will have the same width. +% If the option |columns-width| is used, all the columns will have the same +% width. % % In |\NiceMatrixOptions|, the special value |auto| is not available. % \begin{macrocode} - columns-width .code:n = \str_if_eq:nnTF {#1} {auto} - {\@@_error:n {Option~auto~for~columns-width}} - {\dim_set:Nn \l_@@_columns_width_dim {#1}}, + columns-width .code:n = + \str_if_eq:nnTF { #1 } { auto } + { \@@_error:n { Option~auto~for~columns-width } } + { \dim_set:Nn \l_@@_columns_width_dim { #1 } } , % \end{macrocode} % % \bigskip % \begin{macrocode} - create-extra-nodes .bool_set:N = \l_@@_extra_nodes_bool, - create-extra-nodes .default:n = true, + allow-duplicate-names .code:n = + \@@_msg_redirect_name:nn { Duplicate~name } {none} , + allow-duplicate-names .value_forbidden:n = true , % \end{macrocode} % -% % \bigskip % \begin{macrocode} - left-margin .dim_set:N = \l_@@_left_margin_dim, - left-margin .default:n = \arraycolsep, - right-margin .dim_set:N = \l_@@_right_margin_dim, - right-margin .default:n = \arraycolsep, + unknown .code:n = \@@_error:n { Unknown~key~for~NiceMatrixOptions } } % \end{macrocode} % % \bigskip % \begin{macrocode} - unknown .code:n = \@@_error:n {Unknown~key~for~NiceMatrixOptions}} -% \end{macrocode} -% \begin{macrocode} -\msg_new:nnnn {nicematrix} - {Unknown~key~for~NiceMatrixOptions} - {The~key~"\tl_use:N\l_keys_key_tl"~is~unknown~for~the~command~ - \token_to_str:N \NiceMatrixOptions.\\ - If~you~go~on,~it~will~be~ignored.\\ - For~a~list~of~the~available~keys,~type~H~<return>.} - {The~available~keys~are~(in~alphabetic~order):~ - code-for-last-col,~ - exterior-arraycolsep,~ - left-margin,~ - nullify-dots,~ - parallelize-diags,~ - renew-dots,~ - renew-matrix,~ - right-margin,~ - and~transparent} +\@@_msg_new:nnn { Unknown~key~for~NiceMatrixOptions } + { + The~key~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~command~ + \token_to_str:N \NiceMatrixOptions. \\ + If~you~go~on,~it~will~be~ignored. \\ + For~a~list~of~the~available~keys,~type~H~<return>. + } + { + The~available~keys~are~(in~alphabetic~order):~ + allow-duplicate-names,~ + code-for-last-col,~ + exterior-arraycolsep,~ + left-margin,~ + nullify-dots,~ + parallelize-diags,~ + renew-dots,~ + renew-matrix,~ + right-margin,~ + and~transparent + } % \end{macrocode} % % \begin{macrocode} -\msg_new:nnn {nicematrix} - {Option~auto~for~columns-width} - {You~can't~give~the~value~"auto"~to~the~option~"columns-width"~here.~ - If~you~go~on,~the~option~will~be~ignored.} +\@@_msg_new:nn { Option~auto~for~columns-width } + { + You~can't~give~the~value~'auto'~to~the~option~'columns-width'~here.~ + If~you~go~on,~the~option~will~be~ignored. + } % \end{macrocode} % % \bigskip -% |\NiceMatrixOptions| is the command of the \pkg{nicematrix} package to fix options at the document level. The -% scope of these specifications is the current TeX group. +% |\NiceMatrixOptions| is the command of the \pkg{nicematrix} package to fix +% options at the document level. The scope of these specifications is the +% current TeX group. % \begin{macrocode} -\NewDocumentCommand \NiceMatrixOptions {m} - {\keys_set:nn {NiceMatrix/NiceMatrixOptions} {#1}} +\NewDocumentCommand \NiceMatrixOptions { m } + { \keys_set:nn { NiceMatrix / NiceMatrixOptions } { #1 } } % \end{macrocode} % -% +% % \bigskip +% We finalise the definition of the set of keys +% ``|NiceMatrix / NiceMatrix|'' with the options specific to |{NiceMatrix}|. +% % \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, -% \end{macrocode} -% The option |columns-width| is the width of the columns if we want the same width for all the columns of the -% array. A value of 0~pt means that the width of the column will be the natural width of the column. -% \begin{macrocode} - columns-width .code:n = \str_if_eq:nnTF {#1} {auto} - {\bool_set_true:N - \l_@@_auto_columns_width_bool} - {\dim_set:Nn \l_@@_columns_width_dim {#1}}, - name .code:n = {\seq_if_in:NnTF \g_@@_names_seq {#1} - {\@@_error:nn {Duplicate~name} {#1}} - {\seq_gput_left:Nn \g_@@_names_seq {#1}} - \tl_set:Nn \l_@@_name_tl {#1}}, - name .value_required:n = true, - code-after .tl_set:N = \l_@@_code_after_tl, - code-after .initial:n = \c_empty_tl, - code-after .value_required:n = true, -% \end{macrocode} -% -% The key |create-extra-nodes| indicates wether the ``medium nodes'' and ``large nodes'' will be created for each -% cell of the array. -% \begin{macrocode} - create-extra-nodes .bool_set:N = \l_@@_extra_nodes_bool, - create-extra-nodes .default:n = true, -% \end{macrocode} -% -% \begin{macrocode} - left-margin .dim_set:N = \l_@@_left_margin_dim, - left-margin .default:n = \arraycolsep, - right-margin .dim_set:N = \l_@@_right_margin_dim, - right-margin .default:n = \arraycolsep, - extra-left-margin .dim_set:N = \l_@@_extra_left_margin_dim, - extra-right-margin .dim_set:N = \l_@@_extra_right_margin_dim, - unknown .code:n = \@@_error:n {Unknown~option~for~NiceMatrix}} -% \end{macrocode} -% -% \begin{macrocode} -\msg_new:nnnn {nicematrix} - {Unknown~option~for~NiceMatrix} - {The~option~"\tl_use:N\l_keys_key_tl"~is~unknown~for~the~environment~ - \{NiceMatrix\}~and~its~variants.\\ - If~you~go~on,~it~will~be~ignored.\\ - For~a~list~of~the~available~options,~type~H~<return>.} - {The~available~options~are~(in~alphabetic~order):~ - code-after,~ - columns-width,~ - create-extra-nodes,~ - extra-left-margin,~ - extra-right-margin,~ - left-margin,~ - name,~ - nullify-dots,~ - parallelize-diags,~ - renew-dots~ - and~right-margin.} +\keys_define:nn { NiceMatrix / NiceMatrix } + { unknown .code:n = \@@_error:n { Unknown~option~for~NiceMatrix } } +% \end{macrocode} +% +% \begin{macrocode} +\@@_msg_new:nnn { Unknown~option~for~NiceMatrix } + { + The~option~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~environment~ + \{NiceMatrix\}~and~its~variants. \\ + If~you~go~on,~it~will~be~ignored. \\ + For~a~list~of~the~available~options,~type~H~<return>. + } + { + The~available~options~are~(in~alphabetic~order):~ + code-after,~ + columns-width,~ + create-extra-nodes,~ + extra-left-margin,~ + extra-right-margin,~ + left-margin,~ + name,~ + nullify-dots,~ + parallelize-diags,~ + renew-dots~ + and~right-margin. + } % \end{macrocode} % % \bigskip % \begin{macrocode} -\msg_new:nnnn {nicematrix} - {Duplicate~name} - {The~name~"#1"~is~already~used~and~you~shouldn't~use~ - the~same~environment~name~twice.~You~can~go~on,~but,~ - maybe,~you~will~have~incorrect~results~especially~ - if~you~use~"columns-width=auto".\\ - For~a~list~of~the~names~already~used,~type~H~<return>.} - {The~names~already~defined~in~this~document~are:~ - \seq_use:Nnnn~\g_@@_names_seq~{,~} {,~} {~and~}.} +\@@_msg_new:nnn { Duplicate~name } + { + The~name~'\l_keys_value_tl'~is~already~used~and~you~shouldn't~use~ + the~same~environment~name~twice.~You~can~go~on,~but,~ + maybe,~you~will~have~incorrect~results~especially~ + if~you~use~'columns-width=auto'. \\ + For~a~list~of~the~names~already~used,~type~H~<return>. \\ + If~you~don't~want~to~see~this~message~again,~use~the~option~ + 'allow-duplicate-names'. + } + { + The~names~already~defined~in~this~document~are:~ + \seq_use:Nnnn \g_@@_names_seq { ,~ } { ,~ } { ~and~ }. + } % \end{macrocode} % % \bigskip +% +% \bigskip +% We finalise the definition of the set of keys +% ``|NiceMatrix / NiceArray|'' with the options specific to |{NiceArray}|. +% % \begin{macrocode} -\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, - columns-width .code:n = \str_if_eq:nnTF {#1} {auto} - {\bool_set_true:N \l_@@_auto_columns_width_bool} - {\dim_set:Nn \l_@@_columns_width_dim {#1}}, - columns-width .value_required:n = true, - name .code:n = {\seq_if_in:NnTF \g_@@_names_seq {#1} - {\@@_error:nn {Duplicate~name} {#1}} - {\seq_gput_left:Nn \g_@@_names_seq {#1}} - \tl_set:Nn \l_@@_name_tl {#1}}, - name .value_required:n = true, +\keys_define:nn { NiceMatrix / NiceArray } + { % \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, - code-after .tl_set:N = \l_@@_code_after_tl, - code-after .initial:n = \c_empty_tl, - code-after .value_required:n = true, - create-extra-nodes .bool_set:N = \l_@@_extra_nodes_bool, - create-extra-nodes .default:n = true, - left-margin .dim_set:N = \l_@@_left_margin_dim, - left-margin .default:n = \arraycolsep, - right-margin .dim_set:N = \l_@@_right_margin_dim, - right-margin .default:n = \arraycolsep, - extra-left-margin .dim_set:N = \l_@@_extra_left_margin_dim, - extra-right-margin .dim_set:N = \l_@@_extra_right_margin_dim, - unknown .code:n = \@@_error:n {Unknown~option~for~NiceArray}} -% \end{macrocode} -% -% \begin{macrocode} -\msg_new:nnnn {nicematrix} - {Unknown~option~for~NiceArray} - {The~option~"\tl_use:N\l_keys_key_tl"~is~unknown~for~the~environment~ - \{NiceArray\}.\\ - If~you~go~on,~it~will~be~ignored.\\ - For~a~list~of~the~available~options,~type~H~<return>.} - {The~available~options~are~(in~alphabetic~order):~ - b,~ - c,~ - code-after,~ - create-extra-nodes,~ - columns-width,~ - extra-left-margin,~ - extra-right-margin,~ - left-margin,~ - name,~ - nullify-dots,~ - parallelize-diags,~ - renew-dots,~ - right-margin,~ - and~t.} +% 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 = \str_set:Nn \l_@@_pos_env_str c , + t .code:n = \str_set:Nn \l_@@_pos_env_str t , + b .code:n = \str_set:Nn \l_@@_pos_env_str b , + unknown .code:n = \@@_error:n { Unknown~option~for~NiceArray } + } +% \end{macrocode} +% +% \begin{macrocode} +\@@_msg_new:nnn { Unknown~option~for~NiceArray } + { + The~option~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~environment~ + \{NiceArray\}. \\ + If~you~go~on,~it~will~be~ignored. \\ + For~a~list~of~the~available~options,~type~H~<return>. + } + { + The~available~options~are~(in~alphabetic~order):~ + b,~ + c,~ + code-after,~ + create-extra-nodes,~ + columns-width,~ + extra-left-margin,~ + extra-right-margin,~ + left-margin,~ + name,~ + nullify-dots,~ + parallelize-diags,~ + renew-dots,~ + right-margin,~ + and~t. + } % \end{macrocode} % % \subsection{The environments \{NiceArray\} and \{NiceMatrix\}} % -% The pseudo-environment |\@@_Cell:|--|\@@_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}|). +% The pseudo-environment |\@@_Cell:|--|\@@_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}|). % % \begin{macrocode} \cs_new_protected:Nn \@@_Cell: - { + { % \end{macrocode} % We increment |\g_@@_column_int|, which is the counter of the columns. % \begin{macrocode} \int_gincr:N \g_@@_column_int % \end{macrocode} -% Now, we increment the counter of the rows. We don't do this incrementation in the |\everycr| because some -% packages, like \pkg{arydshln}, create special rows in the |\halign| that we don't want to take into account. +% Now, we increment the counter of the rows. We don't do this incrementation in +% the |\everycr| because some packages, like \pkg{arydshln}, create special rows +% in the |\halign| that we don't want to take into account. % \begin{macrocode} - \int_compare:nNnT \g_@@_column_int = 1 - {\int_gincr:N \g_@@_row_int} + \int_compare:nNnT \g_@@_column_int = \c_one_int + { \int_gincr:N \g_@@_row_int } \int_gset:Nn \g_@@_column_total_int - {\int_max:nn \g_@@_column_total_int \g_@@_column_int} + { \int_max:nn \g_@@_column_total_int \g_@@_column_int } \hbox_set:Nw \l_tmpa_box $ % $ - \int_compare:nNnT \g_@@_row_int = 0 - \l_@@_code_for_first_row_tl} + \int_compare:nNnT \g_@@_row_int = \c_zero_int + \l_@@_code_for_first_row_tl + } % \end{macrocode} % % \begin{macrocode} \cs_new_protected:Nn \@@_end_Cell: - {$ % $ + { $ % $ \hbox_set_end: % \end{macrocode} % -% We want to compute in |\l_@@_max_cell_width_dim| the width of the widest cell of the array (except the cells of -% the last column of an environment of the kind of |{pNiceArrayC}|). +% We want to compute in |\l_@@_max_cell_width_dim| the width of the widest cell +% of the array (except the cells of the last column of an environment of the +% kind of |{pNiceArrayC}|). % \begin{macrocode} \dim_gset:Nn \g_@@_max_cell_width_dim - {\dim_max:nn \g_@@_max_cell_width_dim {\box_wd:N \l_tmpa_box}} + { \dim_max:nn \g_@@_max_cell_width_dim { \box_wd:N \l_tmpa_box } } % \end{macrocode} % % % \begin{macrocode} - \int_compare:nNnT \g_@@_row_int = 0 - {\dim_gset:Nn \g_@@_max_dp_row_zero_dim - {\dim_max:nn \g_@@_max_dp_row_zero_dim {\box_dp:N \l_tmpa_box}} + \int_compare:nNnT \g_@@_row_int = \c_zero_int + { + \dim_gset:Nn \g_@@_max_dp_row_zero_dim + { \dim_max:nn \g_@@_max_dp_row_zero_dim { \box_dp:N \l_tmpa_box } } \dim_gset:Nn \g_@@_max_ht_row_zero_dim - {\dim_max:nn \g_@@_max_ht_row_zero_dim {\box_ht:N \l_tmpa_box}}} - \int_compare:nNnT \g_@@_row_int = 1 - {\dim_gset:Nn \g_@@_max_ht_row_one_dim - {\dim_max:nn \g_@@_max_ht_row_one_dim {\box_ht:N \l_tmpa_box}}} + { \dim_max:nn \g_@@_max_ht_row_zero_dim { \box_ht:N \l_tmpa_box } } + } + \int_compare:nNnT \g_@@_row_int = \c_one_int + { + \dim_gset:Nn \g_@@_max_ht_row_one_dim + { \dim_max:nn \g_@@_max_ht_row_one_dim { \box_ht:N \l_tmpa_box } } + } % \end{macrocode} % % Now, we can create the Tikz node of the cell. % \begin{macrocode} - \tikz[remember~picture, inner~sep = 0pt, minimum~width = 0pt, baseline] - \node [anchor = base, - name = nm-\int_use:N \g_@@_env_int- - \int_use:N \g_@@_row_int- - \int_use:N \g_@@_column_int, - alias = \tl_if_empty:NF \l_@@_name_tl - {\tl_use:N \l_@@_name_tl- - \int_use:N \g_@@_row_int- - \int_use:N \g_@@_column_int} ] - \bgroup - \box_use:N \l_tmpa_box - \egroup ;} + \tikz + [ + remember~picture , + inner~sep = \c_zero_dim , + minimum~width = \c_zero_dim , + baseline + ] + \node + [ + anchor = base , + name = nm - \int_use:N \g_@@_env_int - + \int_use:N \g_@@_row_int - + \int_use:N \g_@@_column_int , + alias = + \str_if_empty:NF \l_@@_name_str + { + \l_@@_name_str - + \int_use:N \g_@@_row_int - + \int_use:N \g_@@_column_int + } + ] + \bgroup + \box_use:N \l_tmpa_box + \egroup ; + } % \end{macrocode} % % % \interitem -% The environment |{NiceArray}| is the main environment of the extension \pkg{nicematrix}. +% The environment |{NiceArray}| is the main environment of the extension +% \pkg{nicematrix}. In order to clarify the explanations, we will first give the +% definition of the environment |{NiceMatrix}|. % -% 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 |renew-matrix|). Hence, this second part is the following: +% Our environment |{NiceMatrix}| must have the same second part as the +% environment |{matrix}| of \pkg{amsmath} (because of the programmation of the +% option |renew-matrix|). Hence, this second part is the following: % % \begin{Verbatim} % \endarray % \skip_horizontal:n {-\arraycolsep} % \end{Verbatim} % -% That's why, in the definition of |{NiceMatrix}|, we must use |\NiceArray| and not |\begin{NiceArray}| -% (and, in the definition of |{NiceArray}|, we will have to use |\array|, and not |\begin{array}|: see below). +% That's why, in the definition of |{NiceMatrix}|, we must use |\NiceArray| and +% not |\begin{NiceArray}| (and, in the definition of |{NiceArray}|, we will have +% to use |\array|, and not |\begin{array}|: see below). % % \medskip % Here's the definition of |{NiceMatrix}|: % \begin{macrocode} -\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} - \skip_horizontal:n {\g_@@_right_margin_dim + \g_@@_extra_right_margin_dim}} +\NewDocumentEnvironment { NiceMatrix } { ! O { } } + { + \keys_set:nn { NiceMatrix / NiceMatrix } { #1 } + \str_set:Nn \l_@@_pos_env_str c + \bool_set_false:N \l_@@_exterior_arraycolsep_bool + \NiceArray { * \c@MaxMatrixCols C } + } + { + \endarray + \skip_horizontal:n + { \g_@@_right_margin_dim + \g_@@_extra_right_margin_dim - \arraycolsep } + } % \end{macrocode} % % \interitem -% For the definition of |{NiceArray}| (just below), we have the following constraints: +% For the definition of |{NiceArray}| (just below), we have the following +% constraints: % \begin{itemize} -% \item we must use |\array| in the first part of |{NiceArray}| and, therefore, |\endarray| in the second part; -% \item we have to put a |\group_insert_after:N \@@_after_array:| in the first part of |{NiceArray}| so that |\@@_draw_lines| -% will be executed at the end of the current environment (either |{NiceArray}| or |{NiceMatrix}|). +% \item we must use |\array| in the first part of |{NiceArray}| and, therefore, +% |\endarray| in the second part; +% \item we have to put a |\group_insert_after:N \@@_after_array:| in the first +% part of |{NiceArray}| so that |\@@_draw_lines| will be executed at the end of +% the current environment (either |{NiceArray}| or |{NiceMatrix}|). % \end{itemize} % % \begin{macrocode} -\cs_generate_variant:Nn \dim_set:Nn {Nx} +\cs_generate_variant:Nn \dim_set:Nn { N x } % \end{macrocode} % % % \bigskip % \begin{macrocode} -\msg_new:nnn {nicematrix} - {We~are~yet~in~an~environment~NiceArray} - {Environments~\{NiceArray\}~(or~\{NiceMatrix\},~etc.)~can't~be~ - nested.~We~can~go~on,~but,~maybe,~you~will~have~errors~or~an~incorrect~ - result.} +\@@_msg_new:nn { Yet~in~NiceArray } + { + Environments~\{NiceArray\}~(or~\{NiceMatrix\},~etc.)~can't~be~ + nested.~We~can~go~on,~but,~maybe,~you~will~have~errors~or~an~incorrect~ + result. + } % \end{macrocode} % % % \bigskip -% The command |\@@_define_dots:| will be used in the environment |{NiceArray}| to define the commands |\Ldots|, -% |\Cdots|, etc. +% The command |\@@_define_dots:| will be used in the environment |{NiceArray}| +% to define the commands |\Ldots|, |\Cdots|, etc. % \begin{macrocode} \cs_new_protected:Npn \@@_define_dots: - {\cs_set_eq:NN \Ldots \@@_Ldots - \cs_set_eq:NN \Cdots \@@_Cdots - \cs_set_eq:NN \Vdots \@@_Vdots - \cs_set_eq:NN \Ddots \@@_Ddots - \cs_set_eq:NN \Iddots \@@_Iddots - \bool_if:NT \l_@@_renew_dots_bool - {\cs_set_eq:NN \ldots \@@_Ldots - \cs_set_eq:NN \cdots \@@_Cdots - \cs_set_eq:NN \vdots \@@_Vdots - \cs_set_eq:NN \ddots \@@_Ddots - \cs_set_eq:NN \iddots \@@_Iddots - \cs_set_eq:NN \dots \@@_Ldots - \cs_set_eq:NN \hdotsfor \@@_Hdotsfor}} + { + \cs_set_eq:NN \Ldots \@@_Ldots + \cs_set_eq:NN \Cdots \@@_Cdots + \cs_set_eq:NN \Vdots \@@_Vdots + \cs_set_eq:NN \Ddots \@@_Ddots + \cs_set_eq:NN \Iddots \@@_Iddots + \bool_if:NT \l_@@_renew_dots_bool + { + \cs_set_eq:NN \ldots \@@_Ldots + \cs_set_eq:NN \cdots \@@_Cdots + \cs_set_eq:NN \vdots \@@_Vdots + \cs_set_eq:NN \ddots \@@_Ddots + \cs_set_eq:NN \iddots \@@_Iddots + \cs_set_eq:NN \dots \@@_Ldots + \cs_set_eq:NN \hdotsfor \@@_Hdotsfor + } + } % \end{macrocode} % % \bigskip -% With |\@@_define_dots_to_nil:|, the commands like |\Ldots|, |\Cdots|, are defined, but with no effect. This -% command will be used if the class option |draft| is used. +% With |\@@_define_dots_to_nil:|, the commands like |\Ldots|, |\Cdots|, are +% defined, but with no effect. This command will be used if the class option +% |draft| is used. % \begin{macrocode} \cs_new_protected:Npn \@@_define_dots_to_nil: - {\cs_set_eq:NN \Ldots \prg_do_nothing: - \cs_set_eq:NN \Cdots \prg_do_nothing: - \cs_set_eq:NN \Vdots \prg_do_nothing: - \cs_set_eq:NN \Ddots \prg_do_nothing: - \cs_set_eq:NN \Iddots \prg_do_nothing: - \bool_if:NT \l_@@_renew_dots_bool - {\cs_set_eq:NN \ldots \prg_do_nothing: - \cs_set_eq:NN \cdots \prg_do_nothing: - \cs_set_eq:NN \vdots \prg_do_nothing: - \cs_set_eq:NN \ddots \prg_do_nothing: - \cs_set_eq:NN \iddots \prg_do_nothing: - \cs_set_eq:NN \dots \prg_do_nothing: - \cs_set_eq:NN \hdotsfor \@@_Hdotsfor}} -% \end{macrocode} -% + { + \cs_set_eq:NN \Ldots \prg_do_nothing: + \cs_set_eq:NN \Cdots \prg_do_nothing: + \cs_set_eq:NN \Vdots \prg_do_nothing: + \cs_set_eq:NN \Ddots \prg_do_nothing: + \cs_set_eq:NN \Iddots \prg_do_nothing: + \bool_if:NT \l_@@_renew_dots_bool + { + \cs_set_eq:NN \ldots \prg_do_nothing: + \cs_set_eq:NN \cdots \prg_do_nothing: + \cs_set_eq:NN \vdots \prg_do_nothing: + \cs_set_eq:NN \ddots \prg_do_nothing: + \cs_set_eq:NN \iddots \prg_do_nothing: + \cs_set_eq:NN \dots \prg_do_nothing: + \cs_set_eq:NN \hdotsfor \@@_Hdotsfor + } + } +% \end{macrocode} +% % % \bigskip -% First, we test if we are yet in an environment |{NiceArray}| (nested environment are forbidden). It's easy to -% test whether we are in an environment |{NiceArray}| : a special command |\@@_in_NiceArray:| is defined. +% First, we test if we are yet in an environment |{NiceArray}| (nested +% environments are forbidden). % \begin{macrocode} -\NewDocumentEnvironment {NiceArray} {O{} m !O{}} - {\cs_if_exist:NT \@@_in_NiceArray: - {\@@_error:n {We~are~yet~in~an~environment~NiceArray}} +\NewDocumentEnvironment { NiceArray } { O { } m ! O { } } + { + \bool_if:NT \l_@@_in_NiceArray_bool + { \@@_error:n { Yet~in~NiceArray } } % \end{macrocode} -% We deactivate Tikz externalization (since we use Tikz pictures with the options |overlay| and -% |remember picture|, there would be errors). +% +% We deactivate Tikz externalization (since we use Tikz pictures with the +% options |overlay| and |remember picture|, there would be errors). % \begin{macrocode} - \cs_if_exist:NT \tikz@library@external@loaded - {\tikzset{external/export = false}} - \cs_set:Npn \@@_in_NiceArray: {--Void--} - \group_insert_after:N \@@_after_array: - \tl_gclear_new:N \g_@@_lines_to_draw_tl + \cs_if_exist:NT \tikz@library@external@loaded + { \tikzset { external / export = false } } + \bool_set_true:N \l_@@_in_NiceArray_bool + \group_insert_after:N \@@_after_array: + \tl_gclear_new:N \g_@@_lines_to_draw_tl % \end{macrocode} % -% We increment the counter |\g_@@_env_int| which counts the environments |{NiceArray}|. +% We increment the counter |\g_@@_env_int| which counts the environments +% |{NiceArray}|. % \begin{macrocode} - \int_gincr:N \g_@@_env_int - \bool_if:NF \l_@@_block_auto_columns_width_bool - {\dim_gzero_new:N \g_@@_max_cell_width_dim} + \int_gincr:N \g_@@_env_int + \bool_if:NF \l_@@_block_auto_columns_width_bool + { \dim_gzero_new:N \g_@@_max_cell_width_dim } % \end{macrocode} % -% For the following variables, maybe we should create it only if we use the environment |{pNiceArrayRC}| or its variants. +% For the following variables, maybe we should create it only if we use the +% environment |{pNiceArrayRC}| or its variants. % \begin{macrocode} - \dim_gzero_new:N \g_@@_max_dp_row_zero_dim - \dim_gzero_new:N \g_@@_max_ht_row_zero_dim - \dim_gzero_new:N \g_@@_max_ht_row_one_dim + \dim_gzero_new:N \g_@@_max_dp_row_zero_dim + \dim_gzero_new:N \g_@@_max_ht_row_zero_dim + \dim_gzero_new:N \g_@@_max_ht_row_one_dim % \end{macrocode} % % \begin{macrocode} - \keys_set:nn {NiceMatrix/NiceArray} {#1,#3} + \keys_set:nn { NiceMatrix / NiceArray } { #1 , #3 } % \end{macrocode} % -% If the user requires all the columns to have a width equal to the widest cell of the array, we read this length in -% the file |.aux| (of, course, this is possible only on the second run of LaTeX : on the first run, the dimension -% |\l_@@_columns_width_dim| will be set to zero --- and the columns will have their natural width). +% If the user requires all the columns to have a width equal to the widest cell +% of the array, we read this length in the file |.aux| (of, course, this is +% possible only on the second run of LaTeX : on the first run, the dimension +% |\l_@@_columns_width_dim| will be set to zero --- and the columns will have +% their natural width). % \begin{macrocode} - \bool_if:NT \l_@@_auto_columns_width_bool - {\group_insert_after:N \@@_write_max_cell_width: - \cs_if_free:cTF {_@@_max_cell_width_\int_use:N \g_@@_env_int} - {\dim_set:Nn \l_@@_columns_width_dim \c_zero_dim} - {\dim_set:Nx \l_@@_columns_width_dim - {\use:c {_@@_max_cell_width_\int_use:N \g_@@_env_int}}} -% \end{macrocode} -% If the environment has a name, we read the value of the maximal value of the columns from -% |_@@_name_cell_width|{\ttfamily\slshape name} (the value will be the correct value even if the number of the -% environment has changed (for example because the user has created or deleted an environment before the current one). -% \begin{macrocode} - \tl_if_empty:NF \l_@@_name_tl - {\cs_if_free:cF {_@@_max_cell_width_\l_@@_name_tl} - {\dim_set:Nx \l_@@_columns_width_dim - {\use:c {_@@_max_cell_width_\l_@@_name_tl}}}} - } + \bool_if:NT \l_@@_auto_columns_width_bool + { + \group_insert_after:N \@@_write_max_cell_width: + \cs_if_free:cTF { _@@_max_cell_width_ \int_use:N \g_@@_env_int } + { \dim_set:Nn \l_@@_columns_width_dim \c_zero_dim } + { + \dim_set:Nx \l_@@_columns_width_dim + { \use:c { _@@_max_cell_width _ \int_use:N \g_@@_env_int } } + } % \end{macrocode} -% We don't want to patch any code and that's why some code is excuted in a |\group_insert_after:N|. In particular, in this -% |\group_insert_after:N|, we will have to know the value of some parameters like |\l_@@_extra_nodes_bool|. That's why we transit via a global -% version for some variables. +% If the environment has a name, we read the value of the maximal value of the +% columns from |_@@_name_cell_width|{\ttfamily\slshape name} (the value will be +% the correct value even if the number of the environment has changed (for +% example because the user has created or deleted an environment before the +% current one). % \begin{macrocode} - \bool_gset_eq:NN \g_@@_extra_nodes_bool \l_@@_extra_nodes_bool - \dim_gset_eq:NN \g_@@_left_margin_dim \l_@@_left_margin_dim - \dim_gset_eq:NN \g_@@_right_margin_dim \l_@@_right_margin_dim - \dim_gset_eq:NN \g_@@_extra_right_margin_dim \l_@@_extra_right_margin_dim - \tl_gset_eq:NN \g_@@_code_after_tl \l_@@_code_after_tl - \tl_gset_eq:NN \g_@@_name_tl \l_@@_name_tl + \str_if_empty:NF \l_@@_name_str + { + \cs_if_free:cF { _@@_max_cell_width_ \l_@@_name_str } + { + \dim_set:Nx \l_@@_columns_width_dim + { \use:c { _@@_max_cell_width_ \l_@@_name_str } } + } + } + } % \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. -% 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_gzero:N \g_@@_column_int}} - \tabskip = \c_zero_skip - \cs_set:Npn \ialign {\everycr{} - \tabskip = \c_zero_skip - \halign} - \halign} +% We don't want to patch any code and that's why some code is excuted in a +% |\group_insert_after:N|. In particular, in this |\group_insert_after:N|, we +% will have to know the value of some parameters like |\l_@@_extra_nodes_bool|. +% That's why we transit via a global version for some variables. +% \begin{macrocode} + \bool_gset_eq:NN \g_@@_extra_nodes_bool \l_@@_extra_nodes_bool + \dim_gset_eq:NN \g_@@_left_margin_dim \l_@@_left_margin_dim + \dim_gset_eq:NN \g_@@_right_margin_dim \l_@@_right_margin_dim + \dim_gset_eq:NN \g_@@_extra_right_margin_dim \l_@@_extra_right_margin_dim + \tl_gset_eq:NN \g_@@_code_after_tl \l_@@_code_after_tl + \tl_gset_eq:NN \g_@@_name_str \l_@@_name_str +% \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. 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_gzero:N \g_@@_column_int } } + \tabskip = \c_zero_skip + \cs_set:Npn \ialign + { + \everycr { } + \tabskip = \c_zero_skip + \halign + } + \halign + } % \end{macrocode} -% -% We define the new column types |L|, |C| and |R| that must be used instead of |l|, |c| and |r| in the preamble of -% |{NiceArray}|. +% +% We define the new column types |L|, |C| and |R| that must be used instead of +% |l|, |c| and |r| in the preamble of |{NiceArray}|. % \begin{macrocode} - \dim_compare:nNnTF \l_@@_columns_width_dim = \c_zero_dim - {\newcolumntype{L}{>{\@@_Cell:}l<{\@@_end_Cell:}} - \newcolumntype{C}{>{\@@_Cell:}c<{\@@_end_Cell:}} - \newcolumntype{R}{>{\@@_Cell:}r<{\@@_end_Cell:}}} + \dim_compare:nNnTF \l_@@_columns_width_dim = \c_zero_dim + { + \newcolumntype L { > \@@_Cell: l < \@@_end_Cell: } + \newcolumntype C { > \@@_Cell: c < \@@_end_Cell: } + \newcolumntype R { > \@@_Cell: r < \@@_end_Cell: } + } % \end{macrocode} -% If there is an option that specify that all the columns must have the same width, the column types~|L|, |C| -% and~|R| are in fact defined upon the column type~|w| of array which is, in fact, redefined below. +% If there is an option that specify that all the columns must have the same +% width, the column types~|L|, |C| and~|R| are in fact defined upon the column +% type~|w| of \pkg{array} which is, in fact, redefined below. % \begin{macrocode} - {\newcolumntype{L}{wl{\dim_use:N \l_@@_columns_width_dim}} - \newcolumntype{C}{wc{\dim_use:N \l_@@_columns_width_dim}} - \newcolumntype{R}{wr{\dim_use:N \l_@@_columns_width_dim}}} + { + \newcolumntype L { w l { \dim_use:N \l_@@_columns_width_dim } } + \newcolumntype C { w c { \dim_use:N \l_@@_columns_width_dim } } + \newcolumntype R { w r { \dim_use:N \l_@@_columns_width_dim } } + } % \end{macrocode} % -% We nullify the definitions of the column types |w| and |W| because we want to avoid a warning in the log file -% for a redefinition of a column type. +% We nullify the definitions of the column types |w| and |W| because we want to +% avoid a warning in the log file for a redefinition of a column type. We must +% put |\relax| and not |\prg_do_nothing:|. % \begin{macrocode} - \cs_set_eq:NN \NC@find@w \relax - \cs_set_eq:NN \NC@find@W \relax + \cs_set_eq:NN \NC@find@w \relax + \cs_set_eq:NN \NC@find@W \relax % \end{macrocode} % % We redefine the column types |w| and |W| of the package \pkg{array}. % \begin{macrocode} - \newcolumntype{w}[2] - {>{\hbox_set:Nw \l_tmpa_box - \@@_Cell:} - c - <{\@@_end_Cell: - \hbox_set_end: - \makebox[##2][##1]{\box_use:N \l_tmpa_box}}} - \newcolumntype{W}[2] - {>{\hbox_set:Nw \l_tmpa_box - \@@_Cell:} + \newcolumntype w [ 2 ] + { + > { + \hbox_set:Nw \l_tmpa_box + \@@_Cell:} c - <{\@@_end_Cell: - \hbox_set_end: - \cs_set_eq:NN \hss \hfil - \makebox[##2][##1]{\box_use:N \l_tmpa_box}}} + < { + \@@_end_Cell: + \hbox_set_end: + \makebox [ ##2 ] [ ##1 ] { \box_use:N \l_tmpa_box } + } + } + \newcolumntype W [ 2 ] + { + > { + \hbox_set:Nw \l_tmpa_box + \@@_Cell: + } + c + < { + \@@_end_Cell: + \hbox_set_end: + \cs_set_eq:NN \hss \hfil + \makebox [ ##2 ] [ ##1 ] { \box_use:N \l_tmpa_box } + } + } % \end{macrocode} % -% The commands |\Ldots|, |\Cdots|, etc. will be defined only in the environment |{NiceArray}|. If the class option -% |draft| is used, these commands will be defined to be no-op (the dotted lines are not drawn). +% The commands |\Ldots|, |\Cdots|, etc. will be defined only in the environment +% |{NiceArray}|. If the class option |draft| is used, these commands will be +% defined to be no-op (the dotted lines are not drawn). % \begin{macrocode} - \bool_if:NTF \c_@@_draft_bool - \@@_define_dots_to_nil: - \@@_define_dots: - \cs_set_eq:NN \Hspace \@@_Hspace: - \cs_set_eq:NN \Hdotsfor \@@_Hdotsfor - \cs_set_eq:NN \multicolumn \@@_multicolumn:nnn + \bool_if:NTF \c_@@_draft_bool + \@@_define_dots_to_nil: + \@@_define_dots: + \cs_set_eq:NN \Hspace \@@_Hspace: + \cs_set_eq:NN \Hdotsfor \@@_Hdotsfor + \cs_set_eq:NN \multicolumn \@@_multicolumn:nnn % \end{macrocode} % % -% The sequence |\g_@@_empty_cells_seq| will contain a list of ``empty'' cells (not all the empty cells of the -% 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. +% The sequence |\g_@@_empty_cells_seq| will contain a list of ``empty'' cells +% (not all the empty cells of the 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 sequence |\g_@@_multicolumn_cells_seq| will contain the list of the cells of the array where a command -% |\multicolumn{|$n$|}{...}{...}| with $n>1$ is issued. In |\g_@@_multicolumn_sizes_seq|, the ``sizes'' (that is to say -% the values of $n$) correspondant will be stored. These lists will be used for the creation of the ``medium nodes'' -% (if they are created). +% 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 +% issued. In |\g_@@_multicolumn_sizes_seq|, the ``sizes'' (that is to say the +% values of $n$) correspondant will be stored. These lists will be used for the +% creation of the ``medium nodes'' (if they are created). % \begin{macrocode} - \seq_gclear_new:N \g_@@_multicolumn_cells_seq - \seq_gclear_new:N \g_@@_multicolumn_sizes_seq + \seq_gclear_new:N \g_@@_multicolumn_cells_seq + \seq_gclear_new:N \g_@@_multicolumn_sizes_seq % \end{macrocode} % % -% The counter |\g_@@_row_int| will be used to count the rows of the array (its incrementation will be in -% the first cell of the row). At the end of the environment |{array}|, this counter will give the total number of -% rows of the matrix. +% The counter |\g_@@_row_int| will be used to count the rows of the array (its +% incrementation will be in the first cell of the row). 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_@@_row_int - \int_gset:Nn \g_@@_row_int {\l_@@_nb_first_row_int - 1} + \int_gzero_new:N \g_@@_row_int + \int_gset:Nn \g_@@_row_int { \l_@@_nb_first_row_int - 1 } % \end{macrocode} % -% The counter |\g_@@_column_int| will be used to count the columns of the array. Since we want to -% know the total number of columns of the matrix, we also create a counter |\g_@@_column_total_int|. -% These counters are updated in the command |\@@_Cell:| executed at the beginning of each cell. +% The counter |\g_@@_column_int| will be used to count the columns of the array. +% Since we want to know the total number of columns of the matrix, we also +% create a counter |\g_@@_column_total_int|. These counters are updated in the +% command |\@@_Cell:| executed at the beginning of each cell. % \begin{macrocode} - \int_gzero_new:N \g_@@_column_int - \int_gzero_new:N \g_@@_column_total_int - \cs_set_eq:NN \@ifnextchar \new@ifnextchar + \int_gzero_new:N \g_@@_column_int + \int_gzero_new:N \g_@@_column_total_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 -% 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. +% 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 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 - {\skip_horizontal:n {-\arraycolsep}} + \bool_if:NF \l_@@_exterior_arraycolsep_bool + { \skip_horizontal:n { - \arraycolsep } } % \end{macrocode} % % \begin{macrocode} - \skip_horizontal:n {\l_@@_left_margin_dim + \l_@@_extra_left_margin_dim} + \skip_horizontal:n { \l_@@_left_margin_dim + \l_@@_extra_left_margin_dim } % \end{macrocode} % % -% 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|. +% Eventually, the environment |{NiceArray}| is defined upon the environment +% |{array}|. However, if the class used is \cls{revtex4-1} or \cls{revtex4-2}, +% we have to do some tuning and use the command |\@array@array| instead of +% |\array| because these classes do a redefinition of |\array| incompatible with +% our use of |\array|. % \begin{macrocode} - \array[\l_@@_pos_env_tl]{#2}} + \bool_if:NTF \c_@@_revtex_bool + { + \cs_set_eq:NN \@acoll \@arrayacol + \cs_set_eq:NN \@acolr \@arrayacol + \cs_set_eq:NN \@acol \@arrayacol + \cs_set:Npn \@halignto { } + \@array@array + } + \array +% \end{macrocode} +% The token list |\l_@@_pos_env_str|, which is the argument of |\array| (or +% |\@array@array|) will contain one of the values |t|, |c| or |b|. +% \begin{macrocode} + [ \l_@@_pos_env_str ] { #2 } + } % \end{macrocode} % % \bigskip % \begin{macrocode} - {\endarray + { \endarray \bool_if:NF \l_@@_exterior_arraycolsep_bool - {\skip_horizontal:n {-\arraycolsep}} - \skip_horizontal:n {\g_@@_right_margin_dim + \g_@@_extra_right_margin_dim}} + { \skip_horizontal:n { - \arraycolsep } } + \skip_horizontal:n + { \g_@@_right_margin_dim + \g_@@_extra_right_margin_dim } + } % \end{macrocode} % % % \interitem % We create the variants of the environment |{NiceMatrix}|. % \begin{macrocode} -\NewDocumentEnvironment {pNiceMatrix} {} - {\left(\begin{NiceMatrix}} - {\end{NiceMatrix}\right)} +\NewDocumentEnvironment { pNiceMatrix } { } + { \left( \begin{NiceMatrix} } + { \end{NiceMatrix} \right) } % \end{macrocode} % % \begin{macrocode} -\NewDocumentEnvironment {bNiceMatrix} {} - {\left[\begin{NiceMatrix}} - {\end{NiceMatrix}\right]} +\NewDocumentEnvironment { bNiceMatrix } { } + { \left[ \begin{NiceMatrix} } + { \end{NiceMatrix} \right] } % \end{macrocode} % % \begin{macrocode} -\NewDocumentEnvironment {BNiceMatrix} {} - {\left\{\begin{NiceMatrix}} - {\end{NiceMatrix}\right\}} +\NewDocumentEnvironment { BNiceMatrix } { } + { \left\{ \begin{NiceMatrix} } + { \end{NiceMatrix} \right\} } % \end{macrocode} % % \begin{macrocode} -\NewDocumentEnvironment {vNiceMatrix} {} - {\left\lvert\begin{NiceMatrix}} - {\end{NiceMatrix}\right\rvert} +\NewDocumentEnvironment { vNiceMatrix } { } + { \left\lvert \begin{NiceMatrix} } + { \end{NiceMatrix} \right\rvert } % \end{macrocode} % % \begin{macrocode} -\NewDocumentEnvironment {VNiceMatrix} {} - {\left\lVert\begin{NiceMatrix}} - {\end{NiceMatrix}\right\rVert} +\NewDocumentEnvironment { VNiceMatrix } {} + { \left\lVert \begin{NiceMatrix} } + { \end{NiceMatrix} \right\rVert } % \end{macrocode} % % \interitem -% For the option \verb|columns-width=auto| (or the option |auto-columns-width| of the environment -% |{NiceMatrixBlock}|), we want to know the maximal width of the cells of the array (except -% the cells of the ``exterior'' column of an environment of the kind of |{pNiceAccayC}|). This length can be known -% only after the end of the construction of the array (or at the end of the environment |{NiceMatrixBlock}|). -% That's why we store this value in the main |.aux| file and it will be available in the next run. We write a -% dedicated command for this because it will be called in a~|\group_insert_after:N|. +% For the option \verb|columns-width=auto| (or the option |auto-columns-width| +% of the environment |{NiceMatrixBlock}|), we want to know the maximal width of +% the cells of the array (except the cells of the ``exterior'' column of an +% environment of the kind of |{pNiceAccayC}|). This length can be known only +% after the end of the construction of the array (or at the end of the +% environment |{NiceMatrixBlock}|). That's why we store this value in the main +% |.aux| file and it will be available in the next run. We write a dedicated +% command for this because it will be called in a~|\group_insert_after:N|. % \begin{macrocode} \cs_new_protected:Nn \@@_write_max_cell_width: - {\bool_if:NF \l_@@_block_auto_columns_width_bool - {\iow_now:Nn \@mainaux {\ExplSyntaxOn} - \iow_now:Nx \@mainaux {\cs_gset:cpn - {@@_max_cell_width_\int_use:N \g_@@_env_int} - {\dim_use:N \g_@@_max_cell_width_dim} } + { + \bool_if:NF \l_@@_block_auto_columns_width_bool + { + \iow_now:Nn \@mainaux \ExplSyntaxOn + \iow_now:Nx \@mainaux + { + \cs_gset:cpn { @@_max_cell_width_ \int_use:N \g_@@_env_int } + { \dim_use:N \g_@@_max_cell_width_dim } + } % \end{macrocode} -% If the environment has a name, we also create an alias named |\@@_max_cell_width_|{\ttfamily\slshape name}. +% If the environment has a name, we also create an alias named +% |\@@_max_cell_width_|{\ttfamily\slshape name}. % \begin{macrocode} - \iow_now:Nx \@mainaux {\cs_gset:cpn {@@_max_cell_width_\g_@@_name_tl} - {\dim_use:N \g_@@_max_cell_width_dim} } - \iow_now:Nn \@mainaux {\ExplSyntaxOff}}} + \iow_now:Nx \@mainaux + { + \cs_gset:cpn { @@_max_cell_width_ \g_@@_name_str } + { \dim_use:N \g_@@_max_cell_width_dim } + } + \iow_now:Nn \@mainaux \ExplSyntaxOff + } + } % \end{macrocode} % % \interitem -% The conditionnal |\@@_if_not_empty_cell:nnT| tests wether a cell is empty. The first two arguments must be LaTeX3 -% counters for the row and the column of the considered cell. +% The conditionnal |\@@_if_not_empty_cell:nnT| tests wether a cell is empty. The +% first two arguments must be LaTeX3 counters for the row and the column of the +% considered cell. % \begin{macrocode} -\prg_set_conditional:Npnn \@@_if_not_empty_cell:nn #1#2 {T,TF} +\prg_set_conditional:Npnn \@@_if_not_empty_cell:nn #1 #2 { T , TF } % \end{macrocode} -% If the cell is an implicit cell (that is after the symbol |\\| of end of row), the cell must, of course, be -% considered as empty. It's easy to check wether we are in this situation considering the correspondant Tikz node. +% If the cell is an implicit cell (that is after the symbol |\\| of end of row), +% the cell must, of course, be considered as empty. It's easy to check wether we +% are in this situation considering the correspondant Tikz node. % \begin{macrocode} - {\cs_if_exist:cTF {pgf@sh@ns@nm-\int_use:N \g_@@_env_int- - \int_use:N #1- - \int_use:N #2} + { + \cs_if_free:cTF + { pgf@sh@ns@nm -\int_use:N \g_@@_env_int - \int_use:N #1 - \int_use:N #2 } + \prg_return_false: % \end{macrocode} -% We manage a list of ``empty cells'' called |\g_@@_empty_cells_seq|. In fact, this list is not a list of all the -% empty cells of the array but only those explicitely declared empty for some reason. It's easy to check if the -% current cell is in this list. +% We manage a list of ``empty cells'' called |\g_@@_empty_cells_seq|. In fact, +% this list is not a list of all the empty cells of the array but only those +% explicitely declared empty for some reason. It's easy to check if the current +% cell is in this list. % \begin{macrocode} - {\seq_if_in:NxTF \g_@@_empty_cells_seq - {\int_use:N #1-\int_use:N #2} - {\prg_return_false:} + { + \seq_if_in:NxTF \g_@@_empty_cells_seq { \int_use:N #1 - \int_use:N #2 } + \prg_return_false: % \end{macrocode} -% In the general case, we consider the width of the Tikz node corresponding to the cell. In order to compute this -% width, we have to extract the coordinate of the west and east anchors of the node. This extraction needs a -% command environment |{pgfpicture}| but, in fact, nothing is drawn. +% In the general case, we consider the width of the Tikz node corresponding to +% the cell. In order to compute this width, we have to extract the coordinate of +% the west and east anchors of the node. This extraction needs a command +% environment |{pgfpicture}| but, in fact, nothing is drawn. % \begin{macrocode} - {\begin{pgfpicture} + { + \begin { pgfpicture } % \end{macrocode} % We store the name of the node corresponding to the cell in |\l_tmpa_tl|. % \begin{macrocode} - \tl_set:Nx \l_tmpa_tl {nm-\int_use:N \g_@@_env_int- - \int_use:N #1- - \int_use:N #2} - \pgfpointanchor \l_tmpa_tl {east} - \dim_gset:Nn \g_tmpa_dim \pgf@x - \pgfpointanchor \l_tmpa_tl {west} - \dim_gset:Nn \g_tmpb_dim \pgf@x - \end{pgfpicture} - \dim_compare:nNnTF {\dim_abs:n {\g_tmpb_dim-\g_tmpa_dim}} < {0.5 pt} - \prg_return_false: - \prg_return_true: - }} - \prg_return_false: - } + \tl_set:Nx \l_tmpa_tl + { nm - \int_use:N \g_@@_env_int - \int_use:N #1 - \int_use:N #2 } + \pgfpointanchor \l_tmpa_tl { east } + \dim_gset:Nn \g_tmpa_dim \pgf@x + \pgfpointanchor \l_tmpa_tl { west } + \dim_gset:Nn \g_tmpb_dim \pgf@x + \end { pgfpicture } + \dim_compare:nTF + { \dim_abs:n { \g_tmpb_dim - \g_tmpa_dim } < 0.5 pt } + \prg_return_false: + \prg_return_true: + } + } + } % \end{macrocode} % % \interitem -% The argument of the following command |\@@_instruction_of_type:n| is the type of the instruction (|Cdots|, -% |Vdots|, |Ddots|, etc.). This command writes in |\g_@@_lines_to_draw_tl| the instruction that will really draw -% the line after the construction of the matrix. +% The argument of the following command |\@@_instruction_of_type:n| is the type +% of the instruction (|Cdots|, |Vdots|, |Ddots|, etc.). This command writes in +% |\g_@@_lines_to_draw_tl| the instruction that will really draw the line after +% the construction of the matrix. % % \medskip % For example, for the following matrix, @@ -2863,103 +3132,130 @@ version 2005/12/01 or later. % % \begin{macrocode} \cs_new_protected:Nn \@@_instruction_of_type:n - {\tl_gput_right:Nx \g_@@_lines_to_draw_tl - {\exp_not:c {@@_draw_#1:nn} - {\int_use:N \g_@@_row_int} - {\int_use:N \g_@@_column_int}}} + { + \tl_gput_right:Nx \g_@@_lines_to_draw_tl + { + \exp_not:c { @@ _ draw _ #1 : nn } + { \int_use:N \g_@@_row_int } + { \int_use:N \g_@@_column_int } + } + } % \end{macrocode} % % % \subsection{After the construction of the array} % -% First, we deactivate Tikz externalization (since we use Tikz pictures with the options |overlay| and -% |remember picture|, there would be errors). +% First, we deactivate Tikz externalization (since we use Tikz pictures with the +% options |overlay| and |remember picture|, there would be errors). % \begin{macrocode} \cs_new_protected:Nn \@@_after_array: - {\group_begin: - \cs_if_exist:NT \tikz@library@external@loaded - {\tikzset{external/export = false}} + { + \group_begin: + \cs_if_exist:NT \tikz@library@external@loaded + { \tikzset { external / export = false } } % \end{macrocode} -% Now, the definition of the counters |\g_@@_column_int| and |\g_@@_column_total_int| change: |\g_@@_column_int| -% will be the number of columns without the exterior column (in an environment like |{pNiceArrayC}|) and -% |\g_@@_column_total_int| will be the number of columns with this exterior column. +% Now, the definition of the counters |\g_@@_column_int| and +% |\g_@@_column_total_int| change: |\g_@@_column_int| will be the number of +% columns without the exterior column (in an environment like |{pNiceArrayC}|) +% and |\g_@@_column_total_int| will be the number of columns with this exterior +% column. % \begin{macrocode} - \int_gset_eq:NN \g_@@_column_int \g_@@_column_total_int - \bool_if:NT \l_@@_exterior_column_bool {\int_gdecr:N \g_@@_column_int} + \int_gset_eq:NN \g_@@_column_int \g_@@_column_total_int + \bool_if:NT \l_@@_exterior_column_bool { \int_gdecr:N \g_@@_column_int } % \end{macrocode} % -% The sequence |\g_@@_yet_drawn_seq| contains a list of lines which have been drawn previously in the matrix. We -% maintain this sequence because we don't want to draw two overlapping lines. +% The sequence |\g_@@_yet_drawn_seq| contains a list of lines which have been +% drawn previously in the matrix. We maintain this sequence because we don't +% want to draw two overlapping lines. % \begin{macrocode} - \seq_gclear_new:N \g_@@_yet_drawn_seq + \seq_gclear_new:N \g_@@_yet_drawn_seq % \end{macrocode} % -% By default, the diagonal lines will be parallelized\footnote{It's possible to use the option -% |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 know wether a diagonal is the -% first of its type in the current |{NiceArray}| environment. +% By default, the diagonal lines will be parallelized\footnote{It's possible to +% use the option |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 know wether a diagonal is +% the first of its type in the current |{NiceArray}| environment. % \begin{macrocode} - \bool_if:NT \l_@@_parallelize_diags_bool - {\int_zero_new:N \l_@@_ddots_int - \int_zero_new:N \l_@@_iddots_int -% \end{macrocode} -% -% The dimensions |\l_@@_delta_x_one_dim| and |\l_@@_delta_y_one_dim| will contain the $\Delta_x$ and $\Delta_y$ of the -% first |\Ddots| diagonal. We have to store these values in order to draw the others |\Ddots| diagonals parallel to -% the first one. Similarly |\l_@@_delta_x_two_dim| and |\l_@@_delta_y_two_dim| are the $\Delta_x$ and $\Delta_y$ of -% the first |\Iddots| diagonal. -% \begin{macrocode} - \dim_zero_new:N \l_@@_delta_x_one_dim - \dim_zero_new:N \l_@@_delta_y_one_dim - \dim_zero_new:N \l_@@_delta_x_two_dim - \dim_zero_new:N \l_@@_delta_y_two_dim} + \bool_if:NT \l_@@_parallelize_diags_bool + { + \int_zero_new:N \l_@@_ddots_int + \int_zero_new:N \l_@@_iddots_int +% \end{macrocode} +% +% The dimensions |\l_@@_delta_x_one_dim| and |\l_@@_delta_y_one_dim| will +% contain the $\Delta_x$ and $\Delta_y$ of the first |\Ddots| diagonal. We have +% to store these values in order to draw the others |\Ddots| diagonals parallel +% to the first one. Similarly |\l_@@_delta_x_two_dim| and +% |\l_@@_delta_y_two_dim| are the $\Delta_x$ and $\Delta_y$ of the first +% |\Iddots| diagonal. +% \begin{macrocode} + \dim_zero_new:N \l_@@_delta_x_one_dim + \dim_zero_new:N \l_@@_delta_y_one_dim + \dim_zero_new:N \l_@@_delta_x_two_dim + \dim_zero_new:N \l_@@_delta_y_two_dim + } % \end{macrocode} % -% If the user has used the option |create-extra-nodes|, the ``medium nodes'' and ``large nodes'' are created. We -% recall that the command |\@@_create_extra_nodes:|, when used once, becomes no-op (in the current TeX group). +% If the user has used the option |create-extra-nodes|, the ``medium nodes'' and +% ``large nodes'' are created. We recall that the command +% |\@@_create_extra_nodes:|, when used once, becomes no-op (in the current TeX +% group). % \begin{macrocode} - \bool_if:NT \g_@@_extra_nodes_bool \@@_create_extra_nodes: + \bool_if:NT \g_@@_extra_nodes_bool \@@_create_extra_nodes: % \end{macrocode} % % \bigskip -% Now, we really draw the lines. The code to draw the lines has been constructed in the token list |\g_@@_lines_to_draw_tl|. -% \begin{macrocode} - \tl_if_empty:NF \g_@@_lines_to_draw_tl - {\int_zero_new:N \l_@@_initial_i_int - \int_zero_new:N \l_@@_initial_j_int - \int_zero_new:N \l_@@_final_i_int - \int_zero_new:N \l_@@_final_j_int - \@@_bool_new:N \l_@@_initial_open_bool - \@@_bool_new:N \l_@@_final_open_bool - \g_@@_lines_to_draw_tl} - \tl_gclear:N \g_@@_lines_to_draw_tl +% Now, we really draw the lines. The code to draw the lines has been constructed +% in the token list |\g_@@_lines_to_draw_tl|. +% \begin{macrocode} + \tl_if_empty:NF \g_@@_lines_to_draw_tl + { + \int_zero_new:N \l_@@_initial_i_int + \int_zero_new:N \l_@@_initial_j_int + \int_zero_new:N \l_@@_final_i_int + \int_zero_new:N \l_@@_final_j_int + \bool_set_false:N \l_@@_initial_open_bool + \bool_set_false:N \l_@@_final_open_bool + \g_@@_lines_to_draw_tl + } + \tl_gclear:N \g_@@_lines_to_draw_tl % \end{macrocode} % % \bigskip % Now, the |code-after|. % \begin{macrocode} - \tikzset{every~picture/.style = {overlay, - remember~picture, - name~prefix = nm-\int_use:N \g_@@_env_int-}} - \cs_set_eq:NN \line \@@_line:nn - \g_@@_code_after_tl - \group_end:} + \tikzset + { + every~picture / .style = + { + overlay , + remember~picture , + name~prefix = nm - \int_use:N \g_@@_env_int - + } + } + \cs_set_eq:NN \line \@@_line:nn + \g_@@_code_after_tl + \group_end: + } % \end{macrocode} % % \bigskip -% A dotted line will be said \emph{open} in one of its extremities when it stops on the edge of the matrix and \emph{closed} -% otherwise. In the following matrix, the dotted line is closed on its left extremity and open on its right. +% A dotted line will be said \emph{open} in one of its extremities when it stops +% on the edge of the matrix and \emph{closed} otherwise. In the following +% matrix, the dotted line is closed on its left extremity and open on its right. % \[ \begin{pNiceMatrix} % a+b+c & a+b & a\\ % a & \Cdots \\ % a & a+b & a+b+c % \end{pNiceMatrix}\] -% For a closed extremity, we use the normal node and for a open one, we use the ``medium node'' (the medium and -% large nodes are created with |\@@_create_extra_nodes:| if they have not been created yet). +% For a closed extremity, we use the normal node and for a open one, we use the +% ``medium node'' (the medium and large nodes are created with +% |\@@_create_extra_nodes:| if they have not been created yet). % \[ \begin{pNiceMatrix}[create-extra-nodes, % code-after = {\begin{tikzpicture} % \node [highlight, fit={(2-1)}] {} ; -% \node [highlight, fit={(2-3-medium)}] {} ; +% \node [highlight, fit={(2-3-medium)}] {}; % \end{tikzpicture} % }] % a+b+c & a+b & a\\ @@ -2973,321 +3269,434 @@ version 2005/12/01 or later. % % \begin{itemize} % \item the first argument is the row of the cell where the command was issued; -% \item the second argument is the column of the cell where the command was issued; -% \item the third argument is the $x$-value of the orientation vector of the line; +% \item the second argument is the column of the cell where the command was +% issued; +% \item the third argument is the $x$-value of the orientation vector of the +% line; % \item the fourth argument is the $y$-value the orientation vector of the line; % \end{itemize} % % This command computes: % % \begin{itemize} -% \item |\l_@@_initial_i_int| and |\l_@@_initial_j_int| which are the coordinates of one extremity of the line; -% \item |\l_@@_final_i_int| and |\l_@@_final_j_int| which are the coordinates of the other extremity of the line; -% \item |\l_@@_initial_open_bool| and |\l_@@_final_open_bool| to indicate wether the extremities are open or not. +% \item |\l_@@_initial_i_int| and |\l_@@_initial_j_int| which are the +% coordinates of one extremity of the line; +% \item |\l_@@_final_i_int| and |\l_@@_final_j_int| which are the coordinates of +% the other extremity of the line; +% \item |\l_@@_initial_open_bool| and |\l_@@_final_open_bool| to indicate wether +% the extremities are open or not. % \end{itemize} % % \begin{macrocode} \cs_new_protected:Nn \@@_find_extremities_of_line:nnnn - {\int_set:Nn \l_@@_initial_i_int {#1} - \int_set:Nn \l_@@_initial_j_int {#2} - \int_set:Nn \l_@@_final_i_int {#1} - \int_set:Nn \l_@@_final_j_int {#2} - \bool_set_false:N \l_@@_initial_open_bool - \bool_set_false:N \l_@@_final_open_bool -% \end{macrocode} -% We will do two loops: one when determinating the initial cell and the other when determinating the final cell. -% The boolean |\l_@@_stop_loop_bool| will be used to control these loops. -% \begin{macrocode} - \@@_bool_new:N \l_@@_stop_loop_bool - \bool_do_until:Nn \l_@@_stop_loop_bool - {\int_add:Nn \l_@@_final_i_int {#3} - \int_add:Nn \l_@@_final_j_int {#4} + { + \int_set:Nn \l_@@_initial_i_int { #1 } + \int_set:Nn \l_@@_initial_j_int { #2 } + \int_set:Nn \l_@@_final_i_int { #1 } + \int_set:Nn \l_@@_final_j_int { #2 } + \bool_set_false:N \l_@@_initial_open_bool + \bool_set_false:N \l_@@_final_open_bool +% \end{macrocode} +% We will do two loops: one when determinating the initial cell and the other +% when determinating the final cell. The boolean |\l_@@_stop_loop_bool| will be +% used to control these loops. +% \begin{macrocode} + \bool_set_false:N \l_@@_stop_loop_bool + \bool_do_until:Nn \l_@@_stop_loop_bool + { + \int_add:Nn \l_@@_final_i_int { #3 } + \int_add:Nn \l_@@_final_j_int { #4 } % \end{macrocode} % We test if we are still in the matrix. % \begin{macrocode} - \bool_if:nTF { \int_compare_p:nNn - \l_@@_final_i_int < {\l_@@_nb_first_row_int - 1} - || \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_total_int + \bool_if:nTF + { + \int_compare_p:nNn + \l_@@_final_i_int < { \l_@@_nb_first_row_int - 1 } + || \int_compare_p:nNn \l_@@_final_i_int > \g_@@_row_int + || \int_compare_p:nNn \l_@@_final_j_int < \c_one_int + || \int_compare_p:nNn \l_@@_final_j_int > \g_@@_column_total_int % \end{macrocode} -% If you arrive in the column |C| of an environment with such columns (like |{pNiceArrayC}|), you must consider that -% we are \emph{outside} the matrix except if we are drawing a vertical line (included in the column |C|). +% If you arrive in the column |C| of an environment with such columns (like +% |{pNiceArrayC}|), you must consider that we are \emph{outside} the matrix +% except if we are drawing a vertical line (included in the column |C|). % \begin{macrocode} - || \int_compare_p:nNn - \l_@@_final_j_int > \g_@@_column_int - && \int_compare_p:nNn {#4} > 0 } + || \int_compare_p:nNn \l_@@_final_j_int > \g_@@_column_int + && \int_compare_p:nNn { #4 } > \c_zero_int + } % \end{macrocode} -% If we are outside the matrix, we have found the extremity of the dotted line and it's a \emph{open} extremity. +% If we are outside the matrix, we have found the extremity of the dotted line +% and it's a \emph{open} extremity. % \begin{macrocode} - {\bool_set_true:N \l_@@_final_open_bool + { + \bool_set_true:N \l_@@_final_open_bool % \end{macrocode} -% We do a step backwards because we will draw the dotted line upon the last cell in the matrix (we will use the -% ``medium node'' of this cell). +% We do a step backwards because we will draw the dotted line upon the last cell +% in the matrix (we will use the ``medium node'' of this cell). % \begin{macrocode} - \int_sub:Nn \l_@@_final_i_int {#3} - \int_sub:Nn \l_@@_final_j_int {#4} - \bool_set_true:N \l_@@_stop_loop_bool} + \int_sub:Nn \l_@@_final_i_int { #3 } + \int_sub:Nn \l_@@_final_j_int { #4 } + \bool_set_true:N \l_@@_stop_loop_bool + } % \end{macrocode} -% If we are in the matrix, we test if the cell is empty. If it's not the case, we stop the loop because we have -% found the correct values for |\l_@@_final_i_int| and |\l_@@_final_j_int|. +% If we are in the matrix, we test if the cell is empty. If it's not the case, +% we stop the loop because we have found the correct values for +% |\l_@@_final_i_int| and |\l_@@_final_j_int|. % \begin{macrocode} - {\@@_if_not_empty_cell:nnT - \l_@@_final_i_int - \l_@@_final_j_int - {\bool_set_true:N \l_@@_stop_loop_bool}} - } + { + \@@_if_not_empty_cell:nnT \l_@@_final_i_int \l_@@_final_j_int + { \bool_set_true:N \l_@@_stop_loop_bool } + } + } % \end{macrocode} % % \interitem -% For |\l_@@_initial_i_int| and |\l_@@_initial_j_int| the programmation is similar to the previous one. -% \begin{macrocode} - \bool_set_false:N \l_@@_stop_loop_bool - \bool_do_until:Nn \l_@@_stop_loop_bool - {\int_sub:Nn \l_@@_initial_i_int {#3} - \int_sub:Nn \l_@@_initial_j_int {#4} - \bool_if:nTF - { \int_compare_p:nNn - \l_@@_initial_i_int < \l_@@_nb_first_row_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_total_int} - {\bool_set_true:N \l_@@_initial_open_bool - \int_add:Nn \l_@@_initial_i_int {#3} - \int_add:Nn \l_@@_initial_j_int {#4} - \bool_set_true:N \l_@@_stop_loop_bool} - {\@@_if_not_empty_cell:nnT - \l_@@_initial_i_int - \l_@@_initial_j_int - {\bool_set_true:N \l_@@_stop_loop_bool}} - } +% For |\l_@@_initial_i_int| and |\l_@@_initial_j_int| the programmation is +% similar to the previous one. +% \begin{macrocode} + \bool_set_false:N \l_@@_stop_loop_bool + \bool_do_until:Nn \l_@@_stop_loop_bool + { + \int_sub:Nn \l_@@_initial_i_int { #3 } + \int_sub:Nn \l_@@_initial_j_int { #4 } + \bool_if:nTF + { + \int_compare_p:nNn \l_@@_initial_i_int < \l_@@_nb_first_row_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_total_int + } + { + \bool_set_true:N \l_@@_initial_open_bool + \int_add:Nn \l_@@_initial_i_int { #3 } + \int_add:Nn \l_@@_initial_j_int { #4 } + \bool_set_true:N \l_@@_stop_loop_bool + } + { + \@@_if_not_empty_cell:nnT + \l_@@_initial_i_int \l_@@_initial_j_int + { \bool_set_true:N \l_@@_stop_loop_bool } + } + } % \end{macrocode} -% If we have at least one open extremity, we create the ``medium nodes'' in the matrix (in the case of an open -% extremity, the dotted line uses the ``medium node'' of the last empty cell). We remind that, when used once, the -% command |\@@_create_extra_nodes:| becomes no-op in the current TeX group. +% If we have at least one open extremity, we create the ``medium nodes'' in the +% matrix (in the case of an open extremity, the dotted line uses the ``medium +% node'' of the last empty cell). We remind that, when used once, the command +% |\@@_create_extra_nodes:| becomes no-op in the current TeX group. % \begin{macrocode} - \bool_if:nT {\l_@@_initial_open_bool || \l_@@_final_open_bool} - \@@_create_extra_nodes: } + \bool_if:nT { \l_@@_initial_open_bool || \l_@@_final_open_bool } + \@@_create_extra_nodes: + } % \end{macrocode} % % \interitem -% If the dotted line to draw is in the list of the previously drawn lines (|\g_@@_yet_drawn_seq|), we don't draw -% (so, we won't have overlapping lines in the \textsc{pdf}). The token list |\l_tmpa_tl| is the $4$-uplet -% characteristic of the line. -% \begin{macrocode} -\prg_set_conditional:Npnn \@@_if_yet_drawn: {F} - {\tl_set:Nx \l_tmpa_tl {\int_use:N \l_@@_initial_i_int- - \int_use:N \l_@@_initial_j_int- - \int_use:N \l_@@_final_i_int- - \int_use:N \l_@@_final_j_int} - \seq_if_in:NVTF \g_@@_yet_drawn_seq \l_tmpa_tl +% If the dotted line to draw is in the list of the previously drawn lines +% (|\g_@@_yet_drawn_seq|), we don't draw (so, we won't have overlapping lines in +% the \textsc{pdf}). The token list |\l_tmpa_tl| is the $4$-uplet characteristic +% of the line. +% \begin{macrocode} +\prg_set_conditional:Npnn \@@_if_yet_drawn: { F } + { + \tl_set:Nx \l_tmpa_tl + { + \int_use:N \l_@@_initial_i_int - + \int_use:N \l_@@_initial_j_int - + \int_use:N \l_@@_final_i_int - + \int_use:N \l_@@_final_j_int + } + \seq_if_in:NVTF \g_@@_yet_drawn_seq \l_tmpa_tl % \end{macrocode} % -% If the dotted line to draw is not in the list, we add it to the list |\g_@@_yet_drawn_seq|. +% If the dotted line to draw is not in the list, we add it to the list +% |\g_@@_yet_drawn_seq|. % \begin{macrocode} - {\prg_return_true:} - {\seq_gput_left:NV \g_@@_yet_drawn_seq \l_tmpa_tl - \prg_return_false:}} + \prg_return_true: + { + \seq_gput_left:NV \g_@@_yet_drawn_seq \l_tmpa_tl + \prg_return_false: + } + } % \end{macrocode} % % % \interitem -% The command |\@@_retrieve_coords:nn| retrieves the Tikz coordinates of the two extremities of the dotted line we -% will have to draw \footnote{In fact, with diagonal lines, or vertical lines in columns of type |L| or |R|, an -% adjustment of one of the coordinates may be done.}. This command has four implicit arguments which are -% |\l_@@_initial_i_int|, |\l_@@_initial_j_int|, |\l_@@_final_i_int| and |\l_@@_final_j_int|. +% The command |\@@_retrieve_coords:nn| retrieves the Tikz coordinates of the two +% extremities of the dotted line we will have to draw \footnote{In fact, with +% diagonal lines, or vertical lines in columns of type |L| or |R|, an adjustment +% of one of the coordinates may be done.}. This command has four implicit +% arguments which are |\l_@@_initial_i_int|, |\l_@@_initial_j_int|, +% |\l_@@_final_i_int| and |\l_@@_final_j_int|. % -% The two arguments of the command |\@@_retrieve_coords:nn| are the prefix and the anchor that must be used for the -% two nodes. +% The two arguments of the command |\@@_retrieve_coords:nn| are the prefix and +% the anchor that must be used for the two nodes. % -% The coordinates are stored in |\g_@@_x_initial_dim|, |\g_@@_y_initial_dim|, |\g_@@_x_final_dim|, -% |\g_@@_y_final_dim|. These variables are global for technical reasons: we have to do an affectation in an -% environment |{tikzpicture}|. +% The coordinates are stored in |\g_@@_x_initial_dim|, |\g_@@_y_initial_dim|, +% |\g_@@_x_final_dim|, |\g_@@_y_final_dim|. These variables are global for +% technical reasons: we have to do an affectation in an environment +% |{tikzpicture}|. % \begin{macrocode} \cs_new_protected:Nn \@@_retrieve_coords:nn - {\dim_gzero_new:N \g_@@_x_initial_dim - \dim_gzero_new:N \g_@@_y_initial_dim - \dim_gzero_new:N \g_@@_x_final_dim - \dim_gzero_new:N \g_@@_y_final_dim - \begin{tikzpicture}[remember~picture] + { + \dim_gzero_new:N \g_@@_x_initial_dim + \dim_gzero_new:N \g_@@_y_initial_dim + \dim_gzero_new:N \g_@@_x_final_dim + \dim_gzero_new:N \g_@@_y_final_dim + \begin { tikzpicture } [ remember~picture ] \tikz@parse@node\pgfutil@firstofone - (nm-\int_use:N \g_@@_env_int- - \int_use:N \l_@@_initial_i_int- - \int_use:N \l_@@_initial_j_int #1) + ( nm - \int_use:N \g_@@_env_int - + \int_use:N \l_@@_initial_i_int - + \int_use:N \l_@@_initial_j_int #1 ) \dim_gset:Nn \g_@@_x_initial_dim \pgf@x \dim_gset:Nn \g_@@_y_initial_dim \pgf@y \tikz@parse@node\pgfutil@firstofone - (nm-\int_use:N \g_@@_env_int- - \int_use:N \l_@@_final_i_int- - \int_use:N \l_@@_final_j_int #2) + ( nm - \int_use:N \g_@@_env_int - + \int_use:N \l_@@_final_i_int - + \int_use:N \l_@@_final_j_int #2 ) \dim_gset:Nn \g_@@_x_final_dim \pgf@x \dim_gset:Nn \g_@@_y_final_dim \pgf@y - \end{tikzpicture} } -\cs_generate_variant:Nn \@@_retrieve_coords:nn {xx} + \end { tikzpicture } + } +\cs_generate_variant:Nn \@@_retrieve_coords:nn { x x } % \end{macrocode} % % \interitem % \begin{macrocode} \cs_new_protected:Nn \@@_draw_Ldots:nn - {\@@_find_extremities_of_line:nnnn {#1} {#2} 0 1 - \@@_if_yet_drawn:F \@@_actually_draw_Ldots:} + { + \@@_find_extremities_of_line:nnnn { #1 } { #2 } \c_zero_int \c_one_int + \@@_if_yet_drawn:F \@@_actually_draw_Ldots: + } % \end{macrocode} % % \medskip -% The command |\@@_actually_draw_Ldots:| actually draws the |Ldots| line using |\l_@@_initial_i_int|, -% |\l_@@_initial_j_int|, |\l_@@_initial_open_bool|, |\l_@@_final_i_int|, |\l_@@_final_j_int| and -% |\l_@@_final_open_bool|. We have a dedicated command because if is used also by |\Hdotsfor|. +% The command |\@@_actually_draw_Ldots:| actually draws the |Ldots| line using +% |\l_@@_initial_i_int|, |\l_@@_initial_j_int|, |\l_@@_initial_open_bool|, +% |\l_@@_final_i_int|, |\l_@@_final_j_int| and |\l_@@_final_open_bool|. We have +% a dedicated command because if is used also by |\Hdotsfor|. % \begin{macrocode} \cs_new_protected:Nn \@@_actually_draw_Ldots: - {\@@_retrieve_coords:xx {\bool_if:NTF \l_@@_initial_open_bool - {-medium.base~west} - {.base~east}} - {\bool_if:NTF \l_@@_final_open_bool - {-medium.base~east} - {.base~west}} - \bool_if:NT \l_@@_initial_open_bool - {\dim_gset_eq:NN \g_@@_y_initial_dim \g_@@_y_final_dim } - \bool_if:NT \l_@@_final_open_bool - {\dim_gset_eq:NN \g_@@_y_final_dim \g_@@_y_initial_dim } + { + \@@_retrieve_coords:xx + { + \bool_if:NTF \l_@@_initial_open_bool + { - medium.base~west } + { .base~east } + } + { + \bool_if:NTF \l_@@_final_open_bool + { - medium.base~east } + { . base~west } + } + \bool_if:NT \l_@@_initial_open_bool + { \dim_gset_eq:NN \g_@@_y_initial_dim \g_@@_y_final_dim } + \bool_if:NT \l_@@_final_open_bool + { \dim_gset_eq:NN \g_@@_y_final_dim \g_@@_y_initial_dim } % \end{macrocode} -% We raise the line of a quantity equal to the radius of the dots because we want the dots really ``on'' the line -% of texte. +% We raise the line of a quantity equal to the radius of the dots because we +% want the dots really ``on'' the line of texte. % \begin{macrocode} - \dim_gadd:Nn \g_@@_y_initial_dim {0.53pt} - \dim_gadd:Nn \g_@@_y_final_dim {0.53pt} - \@@_draw_tikz_line:} + \dim_gadd:Nn \g_@@_y_initial_dim { 0.53 pt } + \dim_gadd:Nn \g_@@_y_final_dim { 0.53 pt } + \@@_draw_tikz_line: + } % \end{macrocode} % % \bigskip % \begin{macrocode} \cs_new_protected:Nn \@@_draw_Cdots:nn - {\@@_find_extremities_of_line:nnnn {#1} {#2} 0 1 - \@@_if_yet_drawn:F - {\@@_retrieve_coords:xx {\bool_if:NTF \l_@@_initial_open_bool - {-medium.mid~west} - {.mid~east}} - {\bool_if:NTF \l_@@_final_open_bool - {-medium.mid~east} - {.mid~west}} - \bool_if:NT \l_@@_initial_open_bool - {\dim_gset_eq:NN \g_@@_y_initial_dim \g_@@_y_final_dim } - \bool_if:NT \l_@@_final_open_bool - {\dim_gset_eq:NN \g_@@_y_final_dim \g_@@_y_initial_dim } - \@@_draw_tikz_line:}} + { + \@@_find_extremities_of_line:nnnn { #1 } { #2 } \c_zero_int \c_one_int + \@@_if_yet_drawn:F + { + \@@_retrieve_coords:xx + { + \bool_if:NTF \l_@@_initial_open_bool + { - medium.mid~west } + { .mid~east } + } + { + \bool_if:NTF \l_@@_final_open_bool + { - medium.mid~east } + { .mid~west } + } + \bool_if:NT \l_@@_initial_open_bool + { \dim_gset_eq:NN \g_@@_y_initial_dim \g_@@_y_final_dim } + \bool_if:NT \l_@@_final_open_bool + { \dim_gset_eq:NN \g_@@_y_final_dim \g_@@_y_initial_dim } + \@@_draw_tikz_line: + } + } % \end{macrocode} % % \bigskip -% For the vertical dots, we have to distinguish different instances because we want really vertical lines. Be -% careful: it's not possible to insert the command |\@@_retrieve_coords:nn| in the arguments |T| and |F| of the -% \pkg{expl3} commands (why?). +% For the vertical dots, we have to distinguish different instances because we +% want really vertical lines. Be careful: it's not possible to insert the +% command |\@@_retrieve_coords:nn| in the arguments |T| and |F| of the +% \pkg{expl3} commands (why?). % \begin{macrocode} \cs_new_protected:Nn \@@_draw_Vdots:nn - {\@@_find_extremities_of_line:nnnn {#1} {#2} 1 0 - \@@_if_yet_drawn:F - {\@@_retrieve_coords:xx {\bool_if:NTF \l_@@_initial_open_bool - {-medium.north~west} - {.south~west}} - {\bool_if:NTF \l_@@_final_open_bool - {-medium.south~west} - {.north~west}} -% \end{macrocode} -% The boolean |\l_tmpa_bool| indicates wether the column is of type |l| (|L| of |{NiceArray}|) or may be considered -% as if. + { + \@@_find_extremities_of_line:nnnn { #1 } { #2 } \c_one_int \c_zero_int + \@@_if_yet_drawn:F + { \@@_retrieve_coords:xx + { + \bool_if:NTF \l_@@_initial_open_bool + { - medium.north~west } + { .south~west } + } + { + \bool_if:NTF \l_@@_final_open_bool + { - medium.south~west } + { .north~west } + } +% \end{macrocode} +% The boolean |\l_tmpa_bool| indicates wether the column is of type |l| (|L| of +% |{NiceArray}|) or may be considered as if. % \begin{macrocode} - \bool_set:Nn \l_tmpa_bool - {\dim_compare_p:nNn \g_@@_x_initial_dim = \g_@@_x_final_dim} - \@@_retrieve_coords:xx {\bool_if:NTF \l_@@_initial_open_bool - {-medium.north} - {.south}} - {\bool_if:NTF \l_@@_final_open_bool - {-medium.south} - {.north}} -% \end{macrocode} -% The boolean |\l_tmpb_bool| indicates wether the column is of type |c| (|C| of |{NiceArray}|) or may be considered -% as if. + \bool_set:Nn \l_tmpa_bool + { \dim_compare_p:nNn \g_@@_x_initial_dim = \g_@@_x_final_dim } + \@@_retrieve_coords:xx + { + \bool_if:NTF \l_@@_initial_open_bool + { - medium.north } + { .south } + } + { + \bool_if:NTF \l_@@_final_open_bool + { - medium.south } + { .north } + } +% \end{macrocode} +% The boolean |\l_tmpb_bool| indicates wether the column is of type |c| (|C| of +% |{NiceArray}|) or may be considered as if. % \begin{macrocode} - \bool_set:Nn \l_tmpb_bool - {\dim_compare_p:nNn \g_@@_x_initial_dim = \g_@@_x_final_dim} - \bool_if:NF \l_tmpb_bool - {\dim_gset:Nn \g_@@_x_initial_dim - {\bool_if:NTF \l_tmpa_bool \dim_min:nn \dim_max:nn - \g_@@_x_initial_dim \g_@@_x_final_dim} - \dim_gset_eq:NN \g_@@_x_final_dim \g_@@_x_initial_dim} - \@@_draw_tikz_line:}} + \bool_set:Nn \l_tmpb_bool + { \dim_compare_p:nNn \g_@@_x_initial_dim = \g_@@_x_final_dim } + \bool_if:NF \l_tmpb_bool + { + \dim_gset:Nn \g_@@_x_initial_dim + { + \bool_if:NTF \l_tmpa_bool \dim_min:nn \dim_max:nn + \g_@@_x_initial_dim \g_@@_x_final_dim + } + \dim_gset_eq:NN \g_@@_x_final_dim \g_@@_x_initial_dim + } + \@@_draw_tikz_line: + } + } % \end{macrocode} % % \interitem -% For the diagonal lines, the situation is a bit more complicated because, by default, we parallelize the diagonals -% lines. The first diagonal line is drawn and then, all the other diagonal lines are drawn parallel to the first -% one. +% For the diagonal lines, the situation is a bit more complicated because, by +% default, we parallelize the diagonals lines. The first diagonal line is drawn +% and then, all the other diagonal lines are drawn parallel to the first one. % \begin{macrocode} \cs_new_protected:Nn \@@_draw_Ddots:nn - {\@@_find_extremities_of_line:nnnn {#1} {#2} 1 1 + { + \@@_find_extremities_of_line:nnnn { #1 } { #2 } \c_one_int \c_one_int \@@_if_yet_drawn:F - {\@@_retrieve_coords:xx {\bool_if:NTF \l_@@_initial_open_bool - {-medium.north~west} - {.south~east}} - {\bool_if:NTF \l_@@_final_open_bool - {-medium.south~east} - {.north~west}} + { + \@@_retrieve_coords:xx + { + \bool_if:NTF \l_@@_initial_open_bool + { - medium.north~west } + { .south~east } + } + { + \bool_if:NTF \l_@@_final_open_bool + { - medium.south~east } + { .north~west } + } % \end{macrocode} -% We have retrieved the coordinates in the usual way (they are stored in |\g_@@_x_initial_dim|, etc.). -% If the parallelization of the diagonals is set, we will have (maybe) to adjust the fourth coordinate. +% We have retrieved the coordinates in the usual way (they are stored in +% |\g_@@_x_initial_dim|, etc.). If the parallelization of the diagonals is set, +% we will have (maybe) to adjust the fourth coordinate. % \begin{macrocode} - \bool_if:NT \l_@@_parallelize_diags_bool - {\int_incr:N \l_@@_ddots_int + \bool_if:NT \l_@@_parallelize_diags_bool + { + \int_incr:N \l_@@_ddots_int % \end{macrocode} -% We test if the diagonal line is the first one (the counter |\l_@@_ddots_int| is created for this usage). +% We test if the diagonal line is the first one (the counter |\l_@@_ddots_int| +% is created for this usage). % \begin{macrocode} - \int_compare:nNnTF \l_@@_ddots_int = 1 + \int_compare:nNnTF \l_@@_ddots_int = \c_one_int % \end{macrocode} -% If the diagonal line is the first one, we have no adjustment of the line to do but we store the $\Delta_x$ and the -% $\Delta_y$ of the line because these values will be used to draw the others diagonal lines parallels to the first one. +% If the diagonal line is the first one, we have no adjustment of the line to do +% but we store the $\Delta_x$ and the $\Delta_y$ of the line because these +% values will be used to draw the others diagonal lines parallels to the first +% one. % \begin{macrocode} - {\dim_set:Nn \l_@@_delta_x_one_dim {\g_@@_x_final_dim - \g_@@_x_initial_dim } - \dim_set:Nn \l_@@_delta_y_one_dim {\g_@@_y_final_dim - \g_@@_y_initial_dim }} + { + \dim_set:Nn \l_@@_delta_x_one_dim + { \g_@@_x_final_dim - \g_@@_x_initial_dim } + \dim_set:Nn \l_@@_delta_y_one_dim + { \g_@@_y_final_dim - \g_@@_y_initial_dim } + } % \end{macrocode} -% If the diagonal line is not the first one, we have to adjust the second extremity of the line by modifying -% the coordinate |\g_@@_y_initial_dim|. +% If the diagonal line is not the first one, we have to adjust the second +% extremity of the line by modifying the coordinate |\g_@@_y_initial_dim|. % \begin{macrocode} - {\dim_gset:Nn \g_@@_y_final_dim - {\g_@@_y_initial_dim + - (\g_@@_x_final_dim - \g_@@_x_initial_dim) - * \dim_ratio:nn \l_@@_delta_y_one_dim \l_@@_delta_x_one_dim }}} + { + \dim_gset:Nn \g_@@_y_final_dim + { + \g_@@_y_initial_dim + + ( \g_@@_x_final_dim - \g_@@_x_initial_dim ) * + \dim_ratio:nn \l_@@_delta_y_one_dim \l_@@_delta_x_one_dim + } + } + } % \end{macrocode} -% Now, we can draw the dotted line (after a possible change of |\g_@@_y_initial_dim|). +% Now, we can draw the dotted line (after a possible change of +% |\g_@@_y_initial_dim|). % \begin{macrocode} - \@@_draw_tikz_line:}} + \@@_draw_tikz_line: + } + } % \end{macrocode} % % \bigskip % We draw the |\Iddots| diagonals in the same way. % \begin{macrocode} \cs_new_protected:Nn \@@_draw_Iddots:nn - {\@@_find_extremities_of_line:nnnn {#1} {#2} 1 {-1} + { + \@@_find_extremities_of_line:nnnn { #1 } { #2 } 1 { -1 } \@@_if_yet_drawn:F - {\@@_retrieve_coords:xx {\bool_if:NTF \l_@@_initial_open_bool - {-medium.north~east} - {.south~west}} - {\bool_if:NTF \l_@@_final_open_bool - {-medium.south~west} - {.north~east}} - \bool_if:NT \l_@@_parallelize_diags_bool - {\int_incr:N \l_@@_iddots_int - \int_compare:nNnTF \l_@@_iddots_int = 1 - {\dim_set:Nn \l_@@_delta_x_two_dim {\g_@@_x_final_dim - \g_@@_x_initial_dim} - \dim_set:Nn \l_@@_delta_y_two_dim {\g_@@_y_final_dim - \g_@@_y_initial_dim}} - {\dim_gset:Nn \g_@@_y_final_dim - {\g_@@_y_initial_dim + - (\g_@@_x_final_dim - \g_@@_x_initial_dim) - * \dim_ratio:nn \l_@@_delta_y_two_dim \l_@@_delta_x_two_dim }}} - \@@_draw_tikz_line:}} + { \@@_retrieve_coords:xx + { + \bool_if:NTF \l_@@_initial_open_bool + { - medium.north~east } + { .south~west } + } + { + \bool_if:NTF \l_@@_final_open_bool + { - medium.south~west } + { .north~east } + } + \bool_if:NT \l_@@_parallelize_diags_bool + { + \int_incr:N \l_@@_iddots_int + \int_compare:nNnTF \l_@@_iddots_int = \c_one_int + { + \dim_set:Nn \l_@@_delta_x_two_dim + { \g_@@_x_final_dim - \g_@@_x_initial_dim } + \dim_set:Nn \l_@@_delta_y_two_dim + { \g_@@_y_final_dim - \g_@@_y_initial_dim } + } + { + \dim_gset:Nn \g_@@_y_final_dim + { + \g_@@_y_initial_dim + + ( \g_@@_x_final_dim - \g_@@_x_initial_dim ) * + \dim_ratio:nn \l_@@_delta_y_two_dim \l_@@_delta_x_two_dim + } + } + } + \@@_draw_tikz_line: + } + } % \end{macrocode} % % \bigskip @@ -3300,92 +3709,131 @@ version 2005/12/01 or later. % % \begin{macrocode} \cs_new_protected:Nn \@@_draw_tikz_line: - { + { +% \end{macrocode} +% The dimension |\l_@@_l_dim| is the length $\ell$ of the line to draw. We use +% the floating point reals of \pkg{expl3} to compute this length. +% \begin{macrocode} + \dim_zero_new:N \l_@@_l_dim + \dim_set:Nn \l_@@_l_dim + { + \fp_to_dim:n + { + sqrt + ( ( \dim_use:N \g_@@_x_final_dim + - \dim_use:N \g_@@_x_initial_dim + ) ^ 2 + + + ( \dim_use:N \g_@@_y_final_dim + - \dim_use:N \g_@@_y_initial_dim + ) ^ 2 + ) + } + } % \end{macrocode} -% The dimension |\l_@@_l_dim| is the length $\ell$ of the line to draw. We use the floating point reals of -% \pkg{expl3} to compute this length. +% We draw only if the length is not equel to zero (in fact, in the first +% compilation, the length may be equal to zero). % \begin{macrocode} - \dim_zero_new:N \l_@@_l_dim - \dim_set:Nn \l_@@_l_dim - { \fp_to_dim:n - { sqrt( ( \dim_use:N \g_@@_x_final_dim - -\dim_use:N \g_@@_x_initial_dim) ^2 - +( \dim_use:N \g_@@_y_final_dim - -\dim_use:N \g_@@_y_initial_dim) ^2 )} - } + \dim_compare:nNnF \l_@@_l_dim = \c_zero_dim % \end{macrocode} -% We draw only if the length is not equel to zero (in fact, in the first compilation, the length may be equal to -% zero). +% The integer |\l_tmpa_int| is the number of dots of the dotted line. % \begin{macrocode} - \dim_compare:nNnF \l_@@_l_dim = \c_zero_dim + { + \bool_if:NTF \l_@@_initial_open_bool + { + \bool_if:NTF \l_@@_final_open_bool + { + \int_set:Nn \l_tmpa_int + { \dim_ratio:nn \l_@@_l_dim { 0.45 em } } + } + { + \int_set:Nn \l_tmpa_int + { \dim_ratio:nn { \l_@@_l_dim - 0.3 em } { 0.45 em } } + } + } + { + \bool_if:NTF \l_@@_final_open_bool + { + \int_set:Nn \l_tmpa_int + { \dim_ratio:nn { \l_@@_l_dim - 0.3 em } { 0.45 em } } + } + { \int_set:Nn \l_tmpa_int + { \dim_ratio:nn { \l_@@_l_dim - 0.6 em } { 0.45 em }} + } + } % \end{macrocode} -% The integer |\l_tmpa_int| is the number of dots of the dotted line. +% The dimensions |\l_tmpa_dim| and |\l_tmpb_dim| are the coordinates of the +% vector between two dots in the dotted line. % \begin{macrocode} - {\bool_if:NTF \l_@@_initial_open_bool - {\bool_if:NTF \l_@@_final_open_bool - {\int_set:Nn \l_tmpa_int - {\dim_ratio:nn {\l_@@_l_dim} {0.45em}}} - {\int_set:Nn \l_tmpa_int - {\dim_ratio:nn {\l_@@_l_dim - 0.3em} {0.45em}}}} - {\bool_if:NTF \l_@@_final_open_bool - {\int_set:Nn \l_tmpa_int - {\dim_ratio:nn {\l_@@_l_dim - 0.3em} {0.45em}}} - {\int_set:Nn \l_tmpa_int - {\dim_ratio:nn {\l_@@_l_dim - 0.6em} {0.45em}}}} -% \end{macrocode} -% The dimensions |\l_tmpa_dim| and |\l_tmpb_dim| are the coordinates of the vector between two dots in the -% dotted line. -% \begin{macrocode} - \dim_set:Nn \l_tmpa_dim {(\g_@@_x_final_dim - \g_@@_x_initial_dim) - * \dim_ratio:nn {0.45em} \l_@@_l_dim} - \dim_set:Nn \l_tmpb_dim {(\g_@@_y_final_dim - \g_@@_y_initial_dim) - * \dim_ratio:nn {0.45em} \l_@@_l_dim} -% \end{macrocode} -% -% The length $\ell$ is the length of the dotted line. We note $\Delta$ the length between two dots and $n$ the -% number of intervals between dots. We note $\delta = \frac12(\ell - n \Delta)$. -% The distance between the initial extremity of the line and the first dot will be equal to $k\cdot\delta$ where + \dim_set:Nn \l_tmpa_dim + { + ( \g_@@_x_final_dim - \g_@@_x_initial_dim ) * + \dim_ratio:nn { 0.45 em } \l_@@_l_dim + } + \dim_set:Nn \l_tmpb_dim + { + ( \g_@@_y_final_dim - \g_@@_y_initial_dim ) * + \dim_ratio:nn { 0.45 em } \l_@@_l_dim + } +% \end{macrocode} +% +% The length $\ell$ is the length of the dotted line. We note $\Delta$ the +% length between two dots and $n$ the number of intervals between dots. We note +% $\delta = \frac12(\ell - n \Delta)$. The distance between the initial +% extremity of the line and the first dot will be equal to $k\cdot\delta$ where % $k=0$, $1$ or $2$. We first compute this number $k$ in |\l_tmpb_int|. % \begin{macrocode} - \int_set:Nn \l_tmpb_int - {\bool_if:NTF \l_@@_initial_open_bool - {\bool_if:NTF \l_@@_final_open_bool 1 0} - {\bool_if:NTF \l_@@_final_open_bool 2 1}} + \int_set:Nn \l_tmpb_int + { + \bool_if:NTF \l_@@_initial_open_bool + { \bool_if:NTF \l_@@_final_open_bool 1 0 } + { \bool_if:NTF \l_@@_final_open_bool 2 1 } + } % \end{macrocode} -% In the loop over the dots (|\int_step_inline:nnnn|), the dimensions |\g_@@_x_initial_dim| and -% |\g_@@_y_initial_dim| will be used for the coordinates of the dots. But, before the loop, we must move until the +% In the loop over the dots (|\int_step_inline:nnnn|), the dimensions +% |\g_@@_x_initial_dim| and |\g_@@_y_initial_dim| will be used for the +% coordinates of the dots. But, before the loop, we must move until the % first dot. % % \begin{macrocode} - \dim_gadd:Nn \g_@@_x_initial_dim - { (\g_@@_x_final_dim - \g_@@_x_initial_dim) - * \dim_ratio:nn {\l_@@_l_dim - 0.45 em * \l_tmpa_int} - {\l_@@_l_dim * 2} - * \l_tmpb_int} + \dim_gadd:Nn \g_@@_x_initial_dim + { + ( \g_@@_x_final_dim - \g_@@_x_initial_dim ) * + \dim_ratio:nn + { \l_@@_l_dim - 0.45 em * \l_tmpa_int } { \l_@@_l_dim * 2 } * + \l_tmpb_int + } % \end{macrocode} -% (In a multiplication of a dimension and an integer, the integer must always be put in second position.) +% (In a multiplication of a dimension and an integer, the integer must always be +% put in second position.) % \begin{macrocode} - \dim_gadd:Nn \g_@@_y_initial_dim - { (\g_@@_y_final_dim - \g_@@_y_initial_dim) - * \dim_ratio:nn {\l_@@_l_dim - 0.45 em * \l_tmpa_int} - {\l_@@_l_dim * 2} - * \l_tmpb_int} - \begin{tikzpicture}[overlay] - \int_step_inline:nnnn 0 1 \l_tmpa_int - { \pgfpathcircle{\pgfpoint{\g_@@_x_initial_dim} - {\g_@@_y_initial_dim}} - {0.53pt} - \pgfusepath{fill} - \dim_gadd:Nn \g_@@_x_initial_dim \l_tmpa_dim - \dim_gadd:Nn \g_@@_y_initial_dim \l_tmpb_dim } - \end{tikzpicture}} -} + \dim_gadd:Nn \g_@@_y_initial_dim + { + ( \g_@@_y_final_dim - \g_@@_y_initial_dim ) * + \dim_ratio:nn + { \l_@@_l_dim - 0.45 em * \l_tmpa_int } + { \l_@@_l_dim * 2 } * + \l_tmpb_int + } + \begin { tikzpicture } [ overlay ] + \int_step_inline:nnnn 0 1 \l_tmpa_int + { + \pgfpathcircle + { \pgfpoint { \g_@@_x_initial_dim } { \g_@@_y_initial_dim } } + { 0.53 pt } + \pgfusepath { fill } + \dim_gadd:Nn \g_@@_x_initial_dim \l_tmpa_dim + \dim_gadd:Nn \g_@@_y_initial_dim \l_tmpb_dim + } + \end { tikzpicture } + } + } % \end{macrocode} % % \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 |renew-dots| is used). +% We give new names for the commands |\ldots|, |\cdots|, |\vdots| and |\ddots| +% because these commands will be redefined (if the option |renew-dots| is used). % \begin{macrocode} \cs_set_eq:NN \@@_ldots \ldots \cs_set_eq:NN \@@_cdots \cdots @@ -3395,56 +3843,70 @@ version 2005/12/01 or later. % \end{macrocode} % % \interitem -% The command |\@@_add_to_empty_cells:| adds the current cell to |\g_@@_empty_cells_seq| which is the list of the -% empty cells (the cells explicitly declared ``empty'': there may be, of course, other empty cells in the matrix). +% The command |\@@_add_to_empty_cells:| adds the current cell to +% |\g_@@_empty_cells_seq| which is the list of the empty cells (the cells +% explicitly declared ``empty'': there may be, of course, other empty cells in +% the matrix). % \begin{macrocode} \cs_new_protected:Nn \@@_add_to_empty_cells: - {\seq_gput_right:Nx \g_@@_empty_cells_seq - {\int_use:N \g_@@_row_int- - \int_use:N \g_@@_column_int}} + { + \seq_gput_right:Nx \g_@@_empty_cells_seq + { \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}| (the other environments of -% \pkg{nicematrix} rely upon |{NiceArray}|). -% \begin{macrocode} -\NewDocumentCommand \@@_Ldots {s} - {\bool_if:nF {#1} {\@@_instruction_of_type:n {Ldots}} - \bool_if:NF \l_@@_nullify_dots_bool {\phantom \@@_ldots} - \@@_add_to_empty_cells:} +% The commands |\@@_Ldots|, |\@@_Cdots|, |\@@_Vdots|, |\@@_Ddots| and +% |\@@_Iddots| will be linked to |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots| and +% |\Iddots| in the environments |{NiceArray}| (the other environments of +% \pkg{nicematrix} rely upon |{NiceArray}|). +% \begin{macrocode} +\NewDocumentCommand \@@_Ldots { s } + { + \bool_if:nF { #1 } { \@@_instruction_of_type:n { Ldots } } + \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_ldots } + \@@_add_to_empty_cells: + } % \end{macrocode} % % \bigskip % \begin{macrocode} -\NewDocumentCommand \@@_Cdots {s} - {\bool_if:nF {#1} {\@@_instruction_of_type:n {Cdots}} - \bool_if:NF \l_@@_nullify_dots_bool {\phantom \@@_cdots} - \@@_add_to_empty_cells:} +\NewDocumentCommand \@@_Cdots { s } + { + \bool_if:nF { #1 } { \@@_instruction_of_type:n { Cdots } } + \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_cdots } + \@@_add_to_empty_cells: + } % \end{macrocode} % % \bigskip % \begin{macrocode} -\NewDocumentCommand \@@_Vdots {s} - {\bool_if:nF {#1} {\@@_instruction_of_type:n {Vdots}} - \bool_if:NF \l_@@_nullify_dots_bool {\phantom \@@_vdots} - \@@_add_to_empty_cells:} +\NewDocumentCommand \@@_Vdots { s } + { + \bool_if:nF { #1 } { \@@_instruction_of_type:n { Vdots } } + \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_vdots } + \@@_add_to_empty_cells: + } % \end{macrocode} % % \bigskip % \begin{macrocode} -\NewDocumentCommand \@@_Ddots {s} - {\bool_if:nF {#1} {\@@_instruction_of_type:n {Ddots}} - \bool_if:NF \l_@@_nullify_dots_bool {\phantom \@@_ddots} - \@@_add_to_empty_cells:} +\NewDocumentCommand \@@_Ddots { s } + { + \bool_if:nF { #1 } { \@@_instruction_of_type:n { Ddots } } + \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_ddots } + \@@_add_to_empty_cells: + } % \end{macrocode} % % \bigskip % \begin{macrocode} -\NewDocumentCommand \@@_Iddots {s} - {\bool_if:nF {#1} {\@@_instruction_of_type:n {Iddots}} - \bool_if:NF \l_@@_nullify_dots_bool {\phantom \@@_iddots} - \@@_add_to_empty_cells:} +\NewDocumentCommand \@@_Iddots { s } + { + \bool_if:nF { #1 } { \@@_instruction_of_type:n { Iddots } } + \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_iddots } + \@@_add_to_empty_cells: + } % \end{macrocode} % % @@ -3452,145 +3914,189 @@ version 2005/12/01 or later. % The command |\@@_Hspace:| will be linked to |\hspace| in |{NiceArray}|. % \begin{macrocode} \cs_new_protected:Nn \@@_Hspace: - {\@@_add_to_empty_cells: - \hspace} + { + \@@_add_to_empty_cells: + \hspace + } % \end{macrocode} % % % \bigskip -% In the environment |{NiceArray}|, the command |\multicolumn| will be linked to the following command -% |\@@_multicolumn:nnn|. +% In the environment |{NiceArray}|, the command |\multicolumn| will be linked to +% the following command |\@@_multicolumn:nnn|. % \begin{macrocode} \cs_set_eq:NN \@@_old_multicolumn \multicolumn \cs_new:Nn \@@_multicolumn:nnn - {\@@_old_multicolumn{#1}{#2}{#3} - \int_compare:nNnT #1 > 1 - {\seq_gput_left:Nx \g_@@_multicolumn_cells_seq - {\int_eval:n \g_@@_row_int - - \int_use:N \g_@@_column_int} - \seq_gput_left:Nn \g_@@_multicolumn_sizes_seq {#1}} - \int_gadd:Nn \g_@@_column_int {#1-1}} + { + \@@_old_multicolumn { #1 } { #2 } { #3 } + \int_compare:nNnT #1 > 1 + { + \seq_gput_left:Nx \g_@@_multicolumn_cells_seq + { \int_eval:n \g_@@_row_int - \int_use:N \g_@@_column_int } + \seq_gput_left:Nn \g_@@_multicolumn_sizes_seq { #1 } + } + \int_gadd:Nn \g_@@_column_int { #1 - 1 } + } % \end{macrocode} % % % \bigskip -% The command |\@@_Hdotsfor| will be linked to |\Hdotsfor| in |{NiceArray}|. This command uses an optional -% argument like |\hdotsfor| but this argument is discarded (in |\hdotsfor|, this argument is used for fine tuning -% of the space beetween two consecutive dots). -% Tikz nodes are created for all the cells of the array, even the implicit cells of the |\Hdotsfor|. -% \begin{macrocode} -\NewDocumentCommand {\@@_Hdotsfor} {O{} m} - {\tl_gput_right:Nx \g_@@_lines_to_draw_tl - {\exp_not:N \@@_draw_Hdotsfor:nnn - {\int_use:N \g_@@_row_int} - {\int_use:N \g_@@_column_int} - {#2}} - \prg_replicate:nn {#2-1} {&}} +% The command |\@@_Hdotsfor| will be linked to |\Hdotsfor| in |{NiceArray}|. +% This command uses an optional argument like |\hdotsfor| but this argument is +% discarded (in |\hdotsfor|, this argument is used for fine tuning of the space +% beetween two consecutive dots). Tikz nodes are created for all the cells of +% the array, even the implicit cells of the |\Hdotsfor|. +% \begin{macrocode} +\NewDocumentCommand \@@_Hdotsfor { O { } m } + { + \tl_gput_right:Nx \g_@@_lines_to_draw_tl + { + \exp_not:N \@@_draw_Hdotsfor:nnn + { \int_use:N \g_@@_row_int } + { \int_use:N \g_@@_column_int } + { #2 } + } + \prg_replicate:nn { #2 - 1 } { & } + } % \end{macrocode} % % \medskip % \begin{macrocode} \cs_new_protected:Nn \@@_draw_Hdotsfor:nnn - {\bool_set_false:N \l_@@_initial_open_bool - \bool_set_false:N \l_@@_final_open_bool + { + \bool_set_false:N \l_@@_initial_open_bool + \bool_set_false:N \l_@@_final_open_bool % \end{macrocode} % For the row, it's easy. % \begin{macrocode} - \int_set:Nn \l_@@_initial_i_int {#1} - \int_set:Nn \l_@@_final_i_int {#1} + \int_set:Nn \l_@@_initial_i_int { #1 } + \int_set:Nn \l_@@_final_i_int { #1 } % \end{macrocode} % For the column, it's a bit more complicated. % \begin{macrocode} - \int_compare:nNnTF #2 = 1 - {\int_set:Nn \l_@@_initial_j_int 1 - \bool_set_true:N \l_@@_initial_open_bool} - {\int_set:Nn \l_tmpa_int {#2-1} - \@@_if_not_empty_cell:nnTF \l_@@_initial_i_int \l_tmpa_int - {\int_set:Nn \l_@@_initial_j_int {#2-1}} - {\int_set:Nn \l_@@_initial_j_int {#2} - \bool_set_true:N \l_@@_initial_open_bool}} - \int_compare:nNnTF {#2+#3-1} = \g_@@_column_int - {\int_set:Nn \l_@@_final_j_int {#2+#3-1} - \bool_set_true:N \l_@@_final_open_bool} - {\int_set:Nn \l_tmpa_int {#2+#3} - \@@_if_not_empty_cell:nnTF \l_@@_final_i_int \l_tmpa_int - {\int_set:Nn \l_@@_final_j_int {#2+#3}} - {\int_set:Nn \l_@@_final_j_int {#2+#3-1} - \bool_set_true:N \l_@@_final_open_bool}} - \bool_if:nT {\l_@@_initial_open_bool || \l_@@_final_open_bool} - \@@_create_extra_nodes: - \@@_actually_draw_Ldots:} + \int_compare:nNnTF #2 = 1 + { + \int_set:Nn \l_@@_initial_j_int 1 + \bool_set_true:N \l_@@_initial_open_bool + } + { + \int_set:Nn \l_tmpa_int { #2 - 1 } + \@@_if_not_empty_cell:nnTF \l_@@_initial_i_int \l_tmpa_int + { \int_set:Nn \l_@@_initial_j_int { #2 - 1 } } + { + \int_set:Nn \l_@@_initial_j_int {#2} + \bool_set_true:N \l_@@_initial_open_bool + } + } + \int_compare:nNnTF { #2 + #3 -1 } = \g_@@_column_int + { + \int_set:Nn \l_@@_final_j_int { #2 + #3 - 1 } + \bool_set_true:N \l_@@_final_open_bool + } + { + \int_set:Nn \l_tmpa_int { #2 + #3 } + \@@_if_not_empty_cell:nnTF \l_@@_final_i_int \l_tmpa_int + { \int_set:Nn \l_@@_final_j_int { #2 + #3 } } + { + \int_set:Nn \l_@@_final_j_int { #2 + #3 - 1 } + \bool_set_true:N \l_@@_final_open_bool + } + } + \bool_if:nT { \l_@@_initial_open_bool || \l_@@_final_open_bool } + \@@_create_extra_nodes: + \@@_actually_draw_Ldots: + } % \end{macrocode} % % % % \subsection{The command \textbackslash line accessible in code-after} % -% In the |code-after|, the command |\@@_line:nn| will be linked to |\line|. This command takes two arguments which -% are the specification of two cells in the array (in the format $i$-$j$) and draws a dotted line between these cells. +% In the |code-after|, the command |\@@_line:nn| will be linked to |\line|. This +% command takes two arguments which are the specification of two cells in the +% array (in the format $i$-$j$) and draws a dotted line between these cells. % \begin{macrocode} \cs_new_protected:Nn \@@_line:nn - {\dim_zero_new:N \g_@@_x_initial_dim - \dim_zero_new:N \g_@@_y_initial_dim - \dim_zero_new:N \g_@@_x_final_dim - \dim_zero_new:N \g_@@_y_final_dim - \@@_bool_new:N \l_@@_initial_open_bool - \@@_bool_new:N \l_@@_final_open_bool - \begin{tikzpicture} - \path~(#1)~--~(#2)~node[at~start]~(i)~{}~node[at~end]~(f)~{} ; - \tikz@parse@node\pgfutil@firstofone (i) - \dim_gset:Nn \g_@@_x_initial_dim \pgf@x - \dim_gset:Nn \g_@@_y_initial_dim \pgf@y - \tikz@parse@node\pgfutil@firstofone (f) - \dim_gset:Nn \g_@@_x_final_dim \pgf@x - \dim_gset:Nn \g_@@_y_final_dim \pgf@y - \end{tikzpicture} - \@@_draw_tikz_line:} + { + \dim_zero_new:N \g_@@_x_initial_dim + \dim_zero_new:N \g_@@_y_initial_dim + \dim_zero_new:N \g_@@_x_final_dim + \dim_zero_new:N \g_@@_y_final_dim + \bool_set_false:N \l_@@_initial_open_bool + \bool_set_false:N \l_@@_final_open_bool + \begin { tikzpicture } + \path~(#1)~--~(#2)~node[at~start]~(i)~{}~node[at~end]~(f)~{} ; + \tikz@parse@node \pgfutil@firstofone ( i ) + \dim_gset:Nn \g_@@_x_initial_dim \pgf@x + \dim_gset:Nn \g_@@_y_initial_dim \pgf@y + \tikz@parse@node \pgfutil@firstofone ( f ) + \dim_gset:Nn \g_@@_x_final_dim \pgf@x + \dim_gset:Nn \g_@@_y_final_dim \pgf@y + \end { tikzpicture } + \@@_draw_tikz_line: + } % \end{macrocode} % -% The commands |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, |\Iddots| don't use this command because they have to do -% other settings (for example, the diagonal lines must be parallelized). +% The commands |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, |\Iddots| don't use this +% command because they have to do other settings (for example, the diagonal +% lines must be parallelized). % % % % \subsection{The environment \{NiceMatrixBlock\}} % -% The following flag will be raised when all the columns of the environments of the block must have the same width -% in ``auto'' mode. +% The following flag will be raised when all the columns of the environments of +% the block must have the same width in ``auto'' mode. % \begin{macrocode} \bool_new:N \l_@@_block_auto_columns_width_bool % \end{macrocode} % % \bigskip -% As of now, there is only one option available for the environment |{NiceMatrixBlock}|. -% \begin{macrocode} -\keys_define:nn {NiceMatrix/NiceMatrixBlock} - {auto-columns-width .code:n = - {\bool_set_true:N \l_@@_block_auto_columns_width_bool - \dim_gzero_new:N \g_@@_max_cell_width_dim - \bool_set_true:N \l_@@_auto_columns_width_bool}} +% As of now, there is only one option available for the environment +% |{NiceMatrixBlock}|. +% \begin{macrocode} +\keys_define:nn { NiceMatrix / NiceMatrixBlock } + { + auto-columns-width .code:n = + { + \bool_set_true:N \l_@@_block_auto_columns_width_bool + \dim_gzero_new:N \g_@@_max_cell_width_dim + \bool_set_true:N \l_@@_auto_columns_width_bool + } + } % \end{macrocode} % % \bigskip % \begin{macrocode} -\NewDocumentEnvironment {NiceMatrixBlock} {!O{}} - {\keys_set:nn {NiceMatrix/NiceMatrixBlock} {#1} - \int_zero_new:N \l_@@_first_env_block_int - \int_set:Nn \l_@@_first_env_block_int {\g_@@_env_int + 1}} +\NewDocumentEnvironment { NiceMatrixBlock } { ! O { } } + { + \keys_set:nn { NiceMatrix / NiceMatrixBlock } { #1 } + \int_zero_new:N \l_@@_first_env_block_int + \int_set:Nn \l_@@_first_env_block_int { \g_@@_env_int + 1 } + } % \end{macrocode} % % \medskip -% 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|). -% \begin{macrocode} - {\bool_if:NT \l_@@_block_auto_columns_width_bool - {\iow_now:Nn \@mainaux \ExplSyntaxOn - \int_step_inline:nnnn \l_@@_first_env_block_int 1 \g_@@_env_int - {\iow_now:Nx \@mainaux - {\cs_gset:cpn {@@_max_cell_width_##1} - {\dim_use:N \g_@@_max_cell_width_dim}}} - \iow_now:Nn \@mainaux \ExplSyntaxOff}} +% 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|). +% \begin{macrocode} + { + \bool_if:NT \l_@@_block_auto_columns_width_bool + { + \iow_now:Nn \@mainaux \ExplSyntaxOn + \int_step_inline:nnnn \l_@@_first_env_block_int 1 \g_@@_env_int + { + \iow_now:Nx \@mainaux + { + \cs_gset:cpn { @@ _ max _ cell _ width _ ##1 } + { \dim_use:N \g_@@_max_cell_width_dim } + } + } + \iow_now:Nn \@mainaux \ExplSyntaxOff + } + } % \end{macrocode} % % \subsection{The environment \{pNiceArrayC\} and its variants} @@ -3598,175 +4104,190 @@ version 2005/12/01 or later. % 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, - columns-width .code:n = \str_if_eq:nnTF {#1} {auto} - {\bool_set_true:N - \l_@@_auto_columns_width_bool} - {\dim_set:Nn \l_@@_columns_width_dim {#1}}, - columns-width .value_required:n = true, - name .code:n = {\seq_if_in:NnTF \g_@@_names_seq {#1} - {\@@_error:nn {Duplicate~name} {#1}} - {\seq_gput_left:Nn \g_@@_names_seq {#1}} - \tl_set:Nn \l_@@_name_tl {#1}}, - name .value_required:n = true, - code-after .tl_set:N = \l_@@_code_after_tl, - code-after .initial:n = \c_empty_tl, - code-after .value_required:n = true, - create-extra-nodes .bool_set:N = \l_@@_extra_nodes_bool, - create-extra-nodes .default:n = true, - left-margin .dim_set:N = \l_@@_left_margin_dim, - left-margin .default:n = \arraycolsep, - right-margin .dim_set:N = \l_@@_right_margin_dim, - right-margin .default:n = \arraycolsep, - extra-left-margin .dim_set:N = \l_@@_extra_left_margin_dim, - extra-right-margin .dim_set:N = \l_@@_extra_right_margin_dim, - unknown .code:n = \@@_error:n {Unknown~option~for~NiceArrayC}} -% \end{macrocode} -% -% \begin{macrocode} -\msg_new:nnnn {nicematrix} - {Unknown~option~for~NiceArrayC} - {The~option~"\tl_use:N\l_keys_key_tl"~is~unknown~for~the~environment~ - \{\@currenvir\}.\\ - If~you~go~on,~it~will~be~ignored.\\ - For~a~list~of~the~available~options,~type~H~<return>.} - {The~available~options~are~(in~alphabetic~order):~ - code-after,~ - code-for-last-col,~ - columns-width,~ - create-extra-nodes,~ - extra-left-margin,~ - extra-right-margin,~ - left-margin,~ - name,~ - nullify-dots,~ - parallelize-diags~ - renew-dots~ - and~right-margin.} +% 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 } + { + code-for-last-col .tl_set:N = \l_@@_code_for_last_col_tl , + code-for-last-col .value_required:n = true , + unknown .code:n = \@@_error:n { Unknown~option~for~NiceArrayC } + } +% \end{macrocode} +% +% \begin{macrocode} +\@@_msg_new:nnn { Unknown~option~for~NiceArrayC } + { + The~option~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~environment~ + \{\@currenvir\}. \\ + If~you~go~on,~it~will~be~ignored. \\ + For~a~list~of~the~available~options,~type~H~<return>. + } + { + The~available~options~are~(in~alphabetic~order):~ + code-after,~ + code-for-last-col,~ + columns-width,~ + create-extra-nodes,~ + extra-left-margin,~ + extra-right-margin,~ + left-margin,~ + name,~ + nullify-dots,~ + parallelize-diags~ + renew-dots~ + and~right-margin. + } % \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. +% 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:n| will be used in |{NiceArrayCwithDelims}| but also in the environment -% |{NiceArrayRCwithDelims}|. +% The command |\@@_NiceArrayC:n| will be used in |{NiceArrayCwithDelims}| but +% also in the environment |{NiceArrayRCwithDelims}|. % \begin{macrocode} \cs_new_protected:Nn \@@_NiceArrayC:n - {\bool_set_true:N \l_@@_exterior_column_bool - \begin{NiceArray} + { + \bool_set_true:N \l_@@_exterior_column_bool + \begin { NiceArray } % \end{macrocode} -% The beginning of the preamble is the argument of the environment |{pNiceArrayC}|. +% The beginning of the preamble is the argument of the environment +% |{pNiceArrayC}|. % \begin{macrocode} - {#1 + { #1 % \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:|. +% 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} - >{\int_gincr:N \g_@@_column_int - \int_gset:Nn \g_@@_column_total_int - {\int_max:nn \g_@@_column_total_int \g_@@_column_int} - \hbox_set:Nw \l_tmpa_box $ % $ - \l_@@_code_for_last_col_tl - } - l + > + { + \int_gincr:N \g_@@_column_int + \int_gset:Nn \g_@@_column_total_int + { \int_max:nn \g_@@_column_total_int \g_@@_column_int } + \hbox_set:Nw \l_tmpa_box $ % $ + \l_@@_code_for_last_col_tl + } + l % \end{macrocode} % -% We actualize the value of |\g_@@_with_last_col_dim| which, at the end of the array, will contain the maximal width -% of the cells of the last column (thus, it will be equal to the width of the last column). +% We actualize the value of |\g_@@_with_last_col_dim| which, at the end of the +% array, will contain the maximal width of the cells of the last column (thus, +% it will be equal to the width of the last column). % \begin{macrocode} - <{ $ % $ - \hbox_set_end: - \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} + < { $ % $ + \hbox_set_end: + \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 an overlapping position. % \begin{macrocode} - \hbox_overlap_right:n - {\skip_horizontal:n - { 2\arraycolsep + \l_@@_right_margin_dim - + \l_@@_extra_right_margin_dim} - \tikz[remember~picture, inner~sep=0pt, minimum~width=0pt, baseline] - \node [anchor=base, - name = nm-\int_use:N \g_@@_env_int- - \int_use:N \g_@@_row_int- - \int_use:N \g_@@_column_int, - alias = \tl_if_empty:NF \l_@@_name_tl - {\l_@@_name_tl- - \int_use:N \g_@@_row_int- - \int_use:N \g_@@_column_int}] - {\box_use:N \l_tmpa_box} ; } }}} -% \end{macrocode} -% This ends the preamble of the array that will be constructed (a rather long preamble, indeed). + \hbox_overlap_right:n + { + \skip_horizontal:n + { + 2 \arraycolsep + + \l_@@_right_margin_dim + + \l_@@_extra_right_margin_dim + } + \tikz + [ + remember~picture , + inner~sep = \c_zero_dim , + minimum~width = \c_zero_dim , + baseline + ] + \node + [ + anchor = base , + name = + nm - + \int_use:N \g_@@_env_int - + \int_use:N \g_@@_row_int - + \int_use:N \g_@@_column_int , + alias = + \str_if_empty:NF \l_@@_name_str + { + \l_@@_name_str - + \int_use:N \g_@@_row_int - + \int_use:N \g_@@_column_int + } + ] + { \box_use:N \l_tmpa_box } ; + } + } + } + } +% \end{macrocode} % % \bigskip -% The environments of the type of |{pNiceArrayC}| will be constructed over |{NiceArrayCwithDelims}|. The first -% two arguments of this environment are the left and the right delimiter. -% \begin{macrocode} -\NewDocumentEnvironment{NiceArrayCwithDelims} {mm O{} m !O{}} - {\dim_gzero_new:N \g_@@_width_last_col_dim - \keys_set:nn {NiceMatrix/NiceArrayC} {#3,#5} - \bool_set_false:N \l_@@_exterior_arraycolsep_bool - \tl_set:Nn \l_@@_pos_env_tl c - \left#1 - \@@_NiceArrayC:n {#4}} - {\end{NiceArray} - \right#2 - \skip_horizontal:n \g_@@_width_last_col_dim - } +% The environments of the type of |{pNiceArrayC}| will be constructed over +% |{NiceArrayCwithDelims}|. The first two arguments of this environment are the +% left and the right delimiter. +% \begin{macrocode} +\NewDocumentEnvironment { NiceArrayCwithDelims } { m m O { } m ! O { } } + { + \dim_gzero_new:N \g_@@_width_last_col_dim + \keys_set:nn { NiceMatrix / NiceArrayC } { #3 , #5 } + \bool_set_false:N \l_@@_exterior_arraycolsep_bool + \str_set:Nn \l_@@_pos_env_str c + \left #1 + \@@_NiceArrayC:n { #4 } + } + { + \end { NiceArray } + \right #2 + \skip_horizontal:n \g_@@_width_last_col_dim + } % \end{macrocode} % % % \bigskip -% In the following environments, we don't use the form with |\begin{...}| and |\end{...}| because we use -% |\@currenvir| in the error message for an unknown option. +% In the following environments, we don't use the form with |\begin{...}| and +% |\end{...}| because we use |\@currenvir| in the error message for an unknown +% option. % \begin{macrocode} -\NewDocumentEnvironment {pNiceArrayC} {} - {\NiceArrayCwithDelims{(}{)}} - {\endNiceArrayCwithDelims} +\NewDocumentEnvironment { pNiceArrayC } { } + { \NiceArrayCwithDelims ( ) } + { \endNiceArrayCwithDelims } % \end{macrocode} % % \begin{macrocode} -\NewDocumentEnvironment {vNiceArrayC} {} - {\NiceArrayCwithDelims{|}{|}} - {\endNiceArrayCwithDelims} +\NewDocumentEnvironment { vNiceArrayC } { } + { \NiceArrayCwithDelims | | } + { \endNiceArrayCwithDelims } % \end{macrocode} % % \begin{macrocode} -\NewDocumentEnvironment {VNiceArrayC} {} - {\NiceArrayCwithDelims{\|}{\|}} - {\endNiceArrayCwithDelims} +\NewDocumentEnvironment { VNiceArrayC } { } + { \NiceArrayCwithDelims \| \| } + { \endNiceArrayCwithDelims } % \end{macrocode} % % \begin{macrocode} -\NewDocumentEnvironment {bNiceArrayC} {} - {\NiceArrayCwithDelims{[}{]}} - {\endNiceArrayCwithDelims} +\NewDocumentEnvironment { bNiceArrayC } { } + { \NiceArrayCwithDelims [ ] } + { \endNiceArrayCwithDelims } % \end{macrocode} % % \begin{macrocode} -\NewDocumentEnvironment {BNiceArrayC} {} - {\NiceArrayCwithDelims{\{}{\}}} - {\endNiceArrayCwithDelims} +\NewDocumentEnvironment { BNiceArrayC } { } + { \NiceArrayCwithDelims \{ \} } + { \endNiceArrayCwithDelims } % \end{macrocode} % % @@ -3777,129 +4298,124 @@ version 2005/12/01 or later. % % \bigskip % \begin{macrocode} -\keys_define:nn {NiceMatrix/NiceArrayRC} - {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-first-row .tl_set:N = \l_@@_code_for_first_row_tl, - code-for-first-row .value_required:n = true, - code-for-last-col .tl_set:N = \l_@@_code_for_last_col_tl, - code-for-last-col .value_required:n = true, - columns-width .code:n = \str_if_eq:nnTF {#1} {auto} - {\bool_set_true:N - \l_@@_auto_columns_width_bool} - {\dim_set:Nn \l_@@_columns_width_dim {#1}}, - columns-width .value_required:n = true, - name .code:n = {\seq_if_in:NnTF \g_@@_names_seq {#1} - {\@@_error:nn {Duplicate~name} {#1}} - {\seq_gput_left:Nn \g_@@_names_seq {#1}} - \tl_set:Nn \l_@@_name_tl {#1}}, - code-after .tl_set:N = \l_@@_code_after_tl, - create-extra-nodes .bool_set:N = \l_@@_extra_nodes_bool, - create-extra-nodes .default:n = true, - left-margin .dim_set:N = \l_@@_left_margin_dim, - left-margin .default:n = \arraycolsep, - right-margin .dim_set:N = \l_@@_right_margin_dim, - right-margin .default:n = \arraycolsep, - extra-left-margin .dim_set:N = \l_@@_extra_left_margin_dim, - extra-right-margin .dim_set:N = \l_@@_extra_right_margin_dim, - unknown .code:n = \@@_error:n {Unknown~option~for~NiceArrayRC}} -% \end{macrocode} -% -% \begin{macrocode} -\msg_new:nnnn {nicematrix} - {Unknown~option~for~NiceArrayRC} - {The~option~"\tl_use:N\l_keys_key_tl"~is~unknown~for~the~environment~ - \{\@currenvir\}.\\ - If~you~go~on,~it~will~be~ignored.\\ - For~a~list~of~the~available~options,~type~H~<return>.} - {The~available~options~are~(in~alphabetic~order):~ - code-after,~ - code-for-last-col,~ - code-for-first-row,~ - columns-width,~ - create-extra-nodes,~ - extra-left-margin,~ - extra-right-margin,~ - left-margin,~ - name,~ - nullify-dots,~ - parallelize-diags,~ - renew-dots~ - and~right-margin.} -% \end{macrocode} -% -% -% The first and the second argument of the environment |{NiceArrayRCwithDelims}| are the delimiters which will be -% used in the array. Usually, the final user will not use directly this environment |{NiceArrayRCwithDelims}| -% because he will use one of the variants |{pNiceArrayRC}|, |{vNiceArrayRC}|, etc. -% -% \begin{macrocode} -\NewDocumentEnvironment {NiceArrayRCwithDelims} {mm O{} m !O{}} - {\int_zero:N \l_@@_nb_first_row_int - \dim_gzero_new:N \g_@@_width_last_col_dim - \keys_set:nn {NiceMatrix/NiceArrayRC} {#3,#5} - \bool_set_false:N \l_@@_exterior_arraycolsep_bool - \tl_set:Nn \l_@@_pos_env_tl c - \box_clear_new:N \l_@@_the_array_box - \hbox_set:Nw \l_@@_the_array_box - $ % $ - \@@_NiceArrayC:n {#4}} - { \end{NiceArray} - $ % $ - \hbox_set_end: - \dim_set:Nn \l_tmpa_dim - { ( \dim_max:nn {12pt} - {\g_@@_max_ht_row_one_dim + \g_@@_max_dp_row_zero_dim}) - + \g_@@_max_ht_row_zero_dim - - \g_@@_max_ht_row_one_dim } - \hbox_set:Nn \l_tmpa_box - {$ % $ - \left#1 - \vcenter {\skip_vertical:n {- \l_tmpa_dim} - \box_use_drop:N \l_@@_the_array_box} - \right#2 - $ % $ - \skip_horizontal:n \g_@@_width_last_col_dim} - \box_set_ht:Nn \l_tmpa_box {\box_ht:N \l_tmpa_box + \l_tmpa_dim} - \box_use_drop:N \l_tmpa_box +\keys_define:nn { NiceMatrix / NiceArrayRC } + { + code-for-first-row .tl_set:N = \l_@@_code_for_first_row_tl , + code-for-first-row .value_required: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 = \@@_error:n { Unknown~option~for~NiceArrayRC } + } +% \end{macrocode} +% +% \begin{macrocode} +\@@_msg_new:nnn { Unknown~option~for~NiceArrayRC } + { + The~option~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~environment~ + \{ \@currenvir \}. \\ + If~you~go~on,~it~will~be~ignored. \\ + For~a~list~of~the~available~options,~type~H~<return>. + } + { + The~available~options~are~(in~alphabetic~order):~ + code-after,~ + code-for-last-col,~ + code-for-first-row,~ + columns-width,~ + create-extra-nodes,~ + extra-left-margin,~ + extra-right-margin,~ + left-margin,~ + name,~ + nullify-dots,~ + parallelize-diags,~ + renew-dots~ + and~right-margin. + } +% \end{macrocode} +% +% +% The first and the second argument of the environment |{NiceArrayRCwithDelims}| +% are the delimiters which will be used in the array. Usually, the final user +% will not use directly this environment |{NiceArrayRCwithDelims}| because he +% will use one of the variants |{pNiceArrayRC}|, |{vNiceArrayRC}|, etc. +% +% \begin{macrocode} +\NewDocumentEnvironment { NiceArrayRCwithDelims } { m m O { } m ! O { } } + { + \int_zero:N \l_@@_nb_first_row_int + \dim_gzero_new:N \g_@@_width_last_col_dim + \keys_set:nn { NiceMatrix / NiceArrayRC } { #3 , #5 } + \bool_set_false:N \l_@@_exterior_arraycolsep_bool + \str_set:Nn \l_@@_pos_env_str c + \box_clear_new:N \l_@@_the_array_box + \hbox_set:Nw \l_@@_the_array_box + $ % $ + \@@_NiceArrayC:n { #4 } + } + { + \end { NiceArray } + $ % $ + \hbox_set_end: + \dim_set:Nn \l_tmpa_dim + { + ( + \dim_max:nn + { 12 pt } + { \g_@@_max_ht_row_one_dim + \g_@@_max_dp_row_zero_dim } + ) + + \g_@@_max_ht_row_zero_dim - \g_@@_max_ht_row_one_dim + } + \hbox_set:Nn \l_tmpa_box + { + $ % $ + \left #1 + \vcenter + { + \skip_vertical:n { - \l_tmpa_dim } + \box_use_drop:N \l_@@_the_array_box + } + \right #2 + $ % $ + \skip_horizontal:n \g_@@_width_last_col_dim + } + \box_set_ht:Nn \l_tmpa_box { \box_ht:N \l_tmpa_box + \l_tmpa_dim } + \box_use_drop:N \l_tmpa_box } % \end{macrocode} % % \bigskip -% In the following environments, we don't use the form with |\begin{...}| and |\end{...}| because we use -% |\@currenvir| in the error message for an unknown option. +% In the following environments, we don't use the form with |\begin{...}| and +% |\end{...}| because we use |\@currenvir| in the error message for an unknown +% option. % \begin{macrocode} -\NewDocumentEnvironment {pNiceArrayRC} {} - {\NiceArrayRCwithDelims{(}{)}} - {\endNiceArrayRCwithDelims} +\NewDocumentEnvironment { pNiceArrayRC } { } + { \NiceArrayRCwithDelims ( ) } + { \endNiceArrayRCwithDelims } % \end{macrocode} % % \begin{macrocode} -\NewDocumentEnvironment {bNiceArrayRC} {} - {\NiceArrayRCwithDelims{[}{]}} - {\endNiceArrayRCwithDelims} +\NewDocumentEnvironment { bNiceArrayRC } { } + { \NiceArrayRCwithDelims [ ] } + { \endNiceArrayRCwithDelims } % \end{macrocode} % % \begin{macrocode} -\NewDocumentEnvironment {vNiceArrayRC} {} - {\NiceArrayRCwithDelims{|}{|}} - {\endNiceArrayRCwithDelims} +\NewDocumentEnvironment { vNiceArrayRC } { } + { \NiceArrayRCwithDelims | | } + { \endNiceArrayRCwithDelims } % \end{macrocode} % % \begin{macrocode} -\NewDocumentEnvironment {VNiceArrayRC} {} - {\NiceArrayRCwithDelims{\|}{\|}} - {\endNiceArrayRCwithDelims} +\NewDocumentEnvironment { VNiceArrayRC } { } + { \NiceArrayRCwithDelims \| \| } + { \endNiceArrayRCwithDelims } % \end{macrocode} % % \begin{macrocode} -\NewDocumentEnvironment {BNiceArrayRC} {} - {\NiceArrayRCwithDelims{\{}{\}}} - {\endNiceArrayRCwithDelims} +\NewDocumentEnvironment { BNiceArrayRC } { } + { \NiceArrayRCwithDelims \{ \} } + { \endNiceArrayRCwithDelims } % \end{macrocode} % % @@ -3907,246 +4423,327 @@ version 2005/12/01 or later. % % First, two variants of the functions |\dim_min:nn| and |\dim_max:nn|. % \begin{macrocode} -\cs_generate_variant:Nn \dim_min:nn {vn} -\cs_generate_variant:Nn \dim_max:nn {vn} +\cs_generate_variant:Nn \dim_min:nn { v n } +\cs_generate_variant:Nn \dim_max:nn { v n } % \end{macrocode} % % % % \bigskip -% For each row $i$, we compute two dimensions \texttt{l_@@_row_\textsl{i}_min_dim} and -% \texttt{l_@@_row_\textsl{i}_max_dim}. The dimension \texttt{l_@@_row_\textsl{i}_min_dim} is the minimal -% $y$-value of all the cells of the row~$i$. The dimension \texttt{l_@@_row_\textsl{i}_max_dim} is the maximal -% $y$-value of all the cells of the row~$i$. -% -% Similarly, for each column $j$, we compute two dimensions \texttt{l_@@_column_\textsl{j}_min_dim} and -% \texttt{l_@@_column_\textsl{j}_max_dim}. The dimension \texttt{l_@@_column_\textsl{j}_min_dim} is the minimal -% $x$-value of all the cells of the column~$j$. The dimension \texttt{l_@@_column_\textsl{j}_max_dim} is the maximal -% $x$-value of all the cells of the column~$j$. -% -% Since these dimensions will be computed as maximum or minimum, we initialize them to |\c_max_dim| or |-\c_max_dim|. +% For each row $i$, we compute two dimensions +% \texttt{l_@@_row_\textsl{i}_min_dim} and \texttt{l_@@_row_\textsl{i}_max_dim}. +% The dimension \texttt{l_@@_row_\textsl{i}_min_dim} is the minimal +% $y$-value of all the cells of the row~$i$. The dimension +% \texttt{l_@@_row_\textsl{i}_max_dim} is the maximal $y$-value of all the cells +% of the row~$i$. +% +% Similarly, for each column $j$, we compute two dimensions +% \texttt{l_@@_column_\textsl{j}_min_dim} and +% \texttt{l_@@_column_\textsl{j}_max_dim}. The dimension +% \texttt{l_@@_column_\textsl{j}_min_dim} is the minimal $x$-value of all the +% cells of the column~$j$. The dimension \texttt{l_@@_column_\textsl{j}_max_dim} +% is the maximal $x$-value of all the cells of the column~$j$. +% +% Since these dimensions will be computed as maximum or minimum, we initialize +% them to |\c_max_dim| or |-\c_max_dim|. % \begin{macrocode} \cs_new_protected:Nn \@@_create_extra_nodes: - {\begin{tikzpicture}[remember~picture,overlay] + { + \begin { tikzpicture } [ remember~picture , overlay ] \int_step_variable:nnnNn \l_@@_nb_first_row_int 1 \g_@@_row_int \@@_i - {\dim_zero_new:c {l_@@_row_\@@_i _min_dim} - \dim_set_eq:cN {l_@@_row_\@@_i _min_dim} \c_max_dim - \dim_zero_new:c {l_@@_row_\@@_i _max_dim} - \dim_set:cn {l_@@_row_\@@_i _max_dim} {-\c_max_dim}} + { + \dim_zero_new:c { l_@@_row_\@@_i _min_dim } + \dim_set_eq:cN { l_@@_row_\@@_i _min_dim } \c_max_dim + \dim_zero_new:c { l_@@_row_\@@_i _max_dim } + \dim_set:cn { l_@@_row_\@@_i _max_dim } { - \c_max_dim } + } \int_step_variable:nnnNn 1 1 \g_@@_column_total_int \@@_j - {\dim_zero_new:c {l_@@_column_\@@_j _min_dim} - \dim_set_eq:cN {l_@@_column_\@@_j _min_dim} \c_max_dim - \dim_zero_new:c {l_@@_column_\@@_j _max_dim} - \dim_set:cn {l_@@_column_\@@_j _max_dim} {-\c_max_dim}} + { + \dim_zero_new:c { l_@@_column_\@@_j _min_dim } + \dim_set_eq:cN { l_@@_column_\@@_j _min_dim } \c_max_dim + \dim_zero_new:c { l_@@_column_\@@_j _max_dim } + \dim_set:cn { l_@@_column_\@@_j _max_dim } { - \c_max_dim } + } % \end{macrocode} % We begin the two nested loops over the rows and the columns of the array. % \begin{macrocode} - \int_step_variable:nnnNn \l_@@_nb_first_row_int 1 \g_@@_row_int \@@_i - {\int_step_variable:nnnNn 1 1 \g_@@_column_total_int \@@_j -% \end{macrocode} -% Maybe the cell ($i$-$j$) is an implicit cell (that is to say a cell after implicit ampersands |&|). In this case, -% of course, we don't update the dimensions we want to compute. -% \begin{macrocode} - {\cs_if_exist:cT {pgf@sh@ns@nm-\int_use:N \g_@@_env_int-\@@_i-\@@_j} -% \end{macrocode} -% We retrieve the coordinates of the anchor |south west| of the (normal) node of the cell ($i$-$j$). They will be -% stored in |\pgf@x| and |\pgf@y|. -% \begin{macrocode} - {\tikz@parse@node \pgfutil@firstofone - (nm-\int_use:N \g_@@_env_int-\@@_i-\@@_j.south~west) - \dim_set:cn {l_@@_row_\@@_i _min_dim} - {\dim_min:vn {l_@@_row_\@@_i _min_dim} \pgf@y} - \seq_if_in:NxF \g_@@_multicolumn_cells_seq {\@@_i-\@@_j} - {\dim_set:cn {l_@@_column_\@@_j _min_dim} - {\dim_min:vn {l_@@_column_\@@_j _min_dim} \pgf@x}} -% \end{macrocode} -% We retrieve the coordinates of the anchor |north east| of the (normal) node of the cell ($i$-$j$). They will be -% stored in |\pgf@x| and |\pgf@y|. -% \begin{macrocode} - \tikz@parse@node \pgfutil@firstofone - (nm-\int_use:N \g_@@_env_int-\@@_i-\@@_j.north~east) - \dim_set:cn {l_@@_row_\@@_i _max_dim} - {\dim_max:vn {l_@@_row_\@@_i _max_dim} \pgf@y} - \seq_if_in:NxF \g_@@_multicolumn_cells_seq {\@@_i-\@@_j} - {\dim_set:cn {l_@@_column_\@@_j _max_dim} - {\dim_max:vn {l_@@_column_\@@_j _max_dim} \pgf@x}}} - }} -% \end{macrocode} -% Now, we can create the ``medium nodes''. We use a command |\@@_create_nodes:| because this command will also be used -% for the creation of the ``large nodes'' (after changing the value of |name-suffix|). + \int_step_variable:nnNn \l_@@_nb_first_row_int \g_@@_row_int \@@_i + { + \int_step_variable:nNn \g_@@_column_total_int \@@_j +% \end{macrocode} +% Maybe the cell ($i$-$j$) is an implicit cell (that is to say a cell after +% implicit ampersands |&|). In this case, of course, we don't update the +% dimensions we want to compute. +% \begin{macrocode} + { \cs_if_exist:cT + { pgf@sh@ns@nm - \int_use:N \g_@@_env_int - \@@_i- \@@_j } +% \end{macrocode} +% We retrieve the coordinates of the anchor |south west| of the (normal) node of +% the cell ($i$-$j$). They will be stored in |\pgf@x| and |\pgf@y|. +% \begin{macrocode} + { + \tikz@parse@node \pgfutil@firstofone + ( nm - \int_use:N \g_@@_env_int + - \@@_i - \@@_j .south~west ) + \dim_set:cn { l_@@_row_\@@_i _min_dim} + { \dim_min:vn { l_@@_row _ \@@_i _min_dim } \pgf@y } + \seq_if_in:NxF \g_@@_multicolumn_cells_seq { \@@_i - \@@_j } + { + \dim_set:cn { l_@@_column _ \@@_j _ min_dim} + { \dim_min:vn { l_@@_column _ \@@_j _min_dim } \pgf@x } + } +% \end{macrocode} +% We retrieve the coordinates of the anchor |north east| of the (normal) node of +% the cell ($i$-$j$). They will be stored in |\pgf@x| and |\pgf@y|. +% \begin{macrocode} + \tikz@parse@node \pgfutil@firstofone + ( nm - \int_use:N \g_@@_env_int - \@@_i - \@@_j .north~east ) + \dim_set:cn { l_@@_row _ \@@_i _ max_dim } + { \dim_max:vn { l_@@_row _ \@@_i _ max_dim } \pgf@y } + \seq_if_in:NxF \g_@@_multicolumn_cells_seq { \@@_i - \@@_j } + { + \dim_set:cn { l_@@_column _ \@@_j _ max_dim } + { \dim_max:vn { l_@@_column _ \@@_j _max_dim } \pgf@x } + } + } + } + } +% \end{macrocode} +% Now, we can create the ``medium nodes''. We use a command |\@@_create_nodes:| +% because this command will also be used for the creation of the ``large nodes'' +% (after changing the value of |name-suffix|). % \begin{macrocode} - \tikzset{name~suffix = -medium} + \tikzset { name~suffix = -medium } \@@_create_nodes: % \end{macrocode} % % \bigskip -% For ``large nodes'', the eventual ``first row'' and ``last column'' (in environments like |{pNiceArrayRC}|) don't -% interfer. That's why the loop over the rows will start at 1 and the loop over the columns will stop at -% $|\g_@@_column_int|$ (and not |\g_@@_column_total_int|).\footnote{We recall that |\g_@@_column_total_int| is -% equal to |\g_@@_column_int| except if there is an exterior column. In this case, |\g_@@_column_total_int| is equal -% to |\g_@@_column_int|${}+1$.} +% For ``large nodes'', the eventual ``first row'' and ``last column'' (in +% environments like |{pNiceArrayRC}|) don't interfer. That's why the loop over +% the rows will start at 1 and the loop over the columns will stop at +% $|\g_@@_column_int|$ (and not |\g_@@_column_total_int|).\footnote{We recall +% that |\g_@@_column_total_int| is equal to |\g_@@_column_int| except if there +% is an exterior column. In this case, |\g_@@_column_total_int| is equal to +% |\g_@@_column_int|${}+1$.} % \begin{macrocode} \int_set:Nn \l_@@_nb_first_row_int 1 % \end{macrocode} -% We have to change the values of all the dimensions \texttt{l_@@_row_\textsl{i}_min_dim}, -% \texttt{l_@@_row_\textsl{i}_max_dim}, \texttt{l_@@_column_\textsl{j}_min_dim} and -% \texttt{l_@@_column_\textsl{j}_max_dim}. +% We have to change the values of all the dimensions +% \texttt{l_@@_row_\textsl{i}_min_dim}, \texttt{l_@@_row_\textsl{i}_max_dim}, +% \texttt{l_@@_column_\textsl{j}_min_dim} and +% \texttt{l_@@_column_\textsl{j}_max_dim}. % \begin{macrocode} - \int_step_variable:nnnNn 1 1 {\g_@@_row_int-1} \@@_i - {\dim_set:cn {l_@@_row_\@@_i _min_dim} - {( \dim_use:c {l_@@_row_\@@_i _min_dim} - + \dim_use:c {l_@@_row_\int_eval:n{\@@_i+1}_max_dim}) / 2} - \dim_set_eq:cc {l_@@_row_\int_eval:n{\@@_i+1}_max_dim} - {l_@@_row_\@@_i _min_dim} } - \int_step_variable:nnnNn 1 1 {\g_@@_column_int-1} \@@_j - {\dim_set:cn {l_@@_column_\@@_j _max_dim} - {( \dim_use:c {l_@@_column_\@@_j _max_dim} - + \dim_use:c {l_@@_column_\int_eval:n{\@@_j+1}_min_dim}) / 2} - \dim_set_eq:cc {l_@@_column_\int_eval:n{\@@_j+1}_min_dim} - {l_@@_column_\@@_j _max_dim} } - \dim_sub:cn {l_@@_column_1_min_dim} \g_@@_left_margin_dim - \dim_add:cn {l_@@_column_\int_use:N \g_@@_column_int _max_dim} - \g_@@_right_margin_dim + \int_step_variable:nnnNn 1 1 { \g_@@_row_int - 1 } \@@_i + { + \dim_set:cn { l_@@_row _ \@@_i _ min _ dim } + { + ( + \dim_use:c { l_@@_row _ \@@_i _ min _ dim } + + \dim_use:c { l_@@_row _ \int_eval:n { \@@_i + 1 } _ max _ dim } + ) + / 2 + } + \dim_set_eq:cc { l_@@_row _ \int_eval:n { \@@_i + 1 } _ max _ dim } + { l_@@_row_\@@_i _min_dim } + } + \int_step_variable:nnnNn 1 1 { \g_@@_column_int - 1 } \@@_j + { + \dim_set:cn { l_@@_column _ \@@_j _ max _ dim } + { + ( + \dim_use:c + { l_@@_column _ \@@_j _ max _ dim } + + \dim_use:c + { l_@@_column _ \int_eval:n { \@@_j + 1 } _ min _ dim } + ) + / 2 + } + \dim_set_eq:cc { l_@@_column _ \int_eval:n { \@@_j + 1 } _ min _ dim } + { l_@@_column _ \@@_j _ max _ dim } + } + \dim_sub:cn + { l_@@_column _ 1 _ min _ dim } + \g_@@_left_margin_dim + \dim_add:cn + { l_@@_column _ \int_use:N \g_@@_column_int _ max _ dim } + \g_@@_right_margin_dim % \end{macrocode} % Now, we can actually create the ``large nodes''. % \begin{macrocode} - \tikzset{name~suffix = -large} + \tikzset { name~suffix = -large } \@@_create_nodes: \end{tikzpicture} % \end{macrocode} % % \medskip -% When used once, the command |\@@_create_extra_nodes:| must become no-op (in the current TeX group). That's why we -% put a nullification of the command. +% When used once, the command |\@@_create_extra_nodes:| must become no-op (in +% the current TeX group). That's why we put a nullification of the command. % \begin{macrocode} - \cs_set:Nn \@@_create_extra_nodes: {}} + \cs_set:Nn \@@_create_extra_nodes: { } + } % \end{macrocode} % % % \bigskip -% The control sequence |\@@_create_nodes:| is used twice: for the construction of the ``medium nodes'' and for the -% construction of the ``large nodes''. The nodes are constructed with the value of all the dimensions -% \texttt{l_@@_row_\textsl{i}_min_dim}, \texttt{l_@@_row_\textsl{i}_max_dim}, -% \texttt{l_@@_column_\textsl{j}_min_dim} and \texttt{l_@@_column_\textsl{j}_max_dim}. Between the -% construction of the ``medium nodes'' and the ``large nodes'', the values of these dimensions are changed. +% The control sequence |\@@_create_nodes:| is used twice: for the construction +% of the ``medium nodes'' and for the construction of the ``large nodes''. The +% nodes are constructed with the value of all the dimensions +% \texttt{l_@@_row_\textsl{i}_min_dim}, \texttt{l_@@_row_\textsl{i}_max_dim}, +% \texttt{l_@@_column_\textsl{j}_min_dim} and +% \texttt{l_@@_column_\textsl{j}_max_dim}. Between the construction of the +% ``medium nodes'' and the ``large nodes'', the values of these dimensions are +% changed. % \begin{macrocode} \cs_new_protected:Nn \@@_create_nodes: - {\int_step_variable:nnnNn \l_@@_nb_first_row_int 1 \g_@@_row_int \@@_i - {\int_step_variable:nnnNn 1 1 \g_@@_column_total_int \@@_j -% \end{macrocode} -% We create two ponctual nodes for the extremities of a diagonal of the rectangular node we want to create. These -% nodes |(@@~south~west)| and |(@@~north~east)| are not available for the user of \pkg{nicematrix}. That's why -% their names are independent of the row and the column. In the two nested loops, they will be overwritten until the -% last cell. -% \begin{macrocode} - {\coordinate (@@~south~west) - at (\dim_use:c {l_@@_column_\@@_j _min_dim}, - \dim_use:c {l_@@_row_\@@_i _min_dim}) ; - \coordinate (@@~north~east) - at (\dim_use:c {l_@@_column_\@@_j _max_dim}, - \dim_use:c {l_@@_row_\@@_i _max_dim}) ; -% \end{macrocode} -% We can eventually draw the rectangular node for the cell (|\@@_i|-|\@@_j|). This node is created with the Tikz library -% \pkg{fit}. Don't forget that the Tikz option |name suffix| has been set to |-medium| or |-large|. -% \begin{macrocode} - \draw node [fit = {(@@~south~west) (@@~north~east)}, - inner~sep=0pt, - name = nm-\int_use:N \g_@@_env_int-\@@_i-\@@_j, - alias = \tl_if_empty:NF \g_@@_name_tl - {\tl_use:N \g_@@_name_tl-\@@_i-\@@_j}] - {} ; - } + { + \int_step_variable:nnnNn \l_@@_nb_first_row_int 1 \g_@@_row_int \@@_i + { + \int_step_variable:nnnNn 1 1 \g_@@_column_total_int \@@_j +% \end{macrocode} +% We create two ponctual nodes for the extremities of a diagonal of the +% rectangular node we want to create. These nodes |(@@~south~west)| and +% |(@@~north~east)| are not available for the user of \pkg{nicematrix}. That's +% why their names are independent of the row and the column. In the two nested +% loops, they will be overwritten until the last cell. +% \begin{macrocode} + { + \coordinate ( @@~south~west ) + at ( \dim_use:c { l_@@_column_ \@@_j _min_dim } , + \dim_use:c { l_@@_row_ \@@_i _min_dim } ) ; + \coordinate ( @@~north~east ) + at ( \dim_use:c { l_@@_column_ \@@_j _max_dim }, + \dim_use:c { l_@@_row_ \@@_i _max_dim } ) ; +% \end{macrocode} +% We can eventually draw the rectangular node for the cell (|\@@_i|-|\@@_j|). +% This node is created with the Tikz library \pkg{fit}. Don't forget that the +% Tikz option |name suffix| has been set to |-medium| or |-large|. +% \begin{macrocode} + \node + [ + node~contents = { } , + fit = ( @@~south~west ) ( @@~north~east ) , + inner~sep = \c_zero_dim , + name = nm - \int_use:N \g_@@_env_int - \@@_i - \@@_j , + alias = + \str_if_empty:NF \g_@@_name_str + { \g_@@_name_str - \@@_i - \@@_j } + ] + ; } + } % \end{macrocode} -% Now, we create the nodes for the cells of the |\multicolumn|. We recall that we have stored in -% |\g_@@_multicolumn_cells_seq| the list of the cells where a |\multicolumn{|$n$|}{...}{...}| with $n$>1 was issued -% and in |\g_@@_multicolumn_sizes_seq| the correspondant values of $n$. +% Now, we create the nodes for the cells of the |\multicolumn|. We recall that +% we have stored in |\g_@@_multicolumn_cells_seq| the list of the cells where a +% |\multicolumn{|$n$|}{...}{...}| with $n$>1 was issued and in +% |\g_@@_multicolumn_sizes_seq| the correspondant values of $n$. % \begin{macrocode} - \@@_seq_mapthread_function:NNN \g_@@_multicolumn_cells_seq - \g_@@_multicolumn_sizes_seq - \@@_node_for_multicolumn:nn - } + \@@_seq_mapthread_function:NNN + \g_@@_multicolumn_cells_seq + \g_@@_multicolumn_sizes_seq + \@@_node_for_multicolumn:nn + } % \end{macrocode} % % % % \begin{macrocode} -\cs_set:Npn \@@_extract_coords: #1-#2\q_stop{\cs_set:Npn \@@_i {#1} - \cs_set:Npn \@@_j {#2}} +\cs_new_protected:Npn \@@_extract_coords: #1 - #2 \q_stop + { + \cs_set:Npn \@@_i { #1 } + \cs_set:Npn \@@_j { #2 } + } % \end{macrocode} % -% The command |\@@_node_for_multicolumn:nn| takes two arguments. The first is the position of the cell where the -% command |\multicolumn{|$n$|}{...}{...}| was issued in the format $i$|-|$j$ and the second is the value of~$n$ (the -% length of the ``multi-cell''). +% The command |\@@_node_for_multicolumn:nn| takes two arguments. The first is +% the position of the cell where the command |\multicolumn{|$n$|}{...}{...}| was +% issued in the format $i$|-|$j$ and the second is the value of~$n$ (the length +% of the ``multi-cell''). % \begin{macrocode} \cs_new_protected:Nn \@@_node_for_multicolumn:nn - {\@@_extract_coords: #1\q_stop - \coordinate (@@~south~west) - at (\dim_use:c {l_@@_column_\@@_j _min_dim}, - \dim_use:c {l_@@_row_\@@_i _min_dim}) ; - \coordinate (@@~north~east) - at (\dim_use:c {l_@@_column_\int_eval:n{\@@_j+#2-1}_max_dim}, - \dim_use:c {l_@@_row_\@@_i _max_dim}) ; - \draw node [fit = {(@@~south~west) (@@~north~east)}, - inner~sep=0pt, - name = nm-\int_use:N \g_@@_env_int-\@@_i-\@@_j, - alias = \tl_if_empty:NF \g_@@_name_tl - {\tl_use:N \g_@@_name_tl-\@@_i-\@@_j}] - {} ; - } + { + \@@_extract_coords: #1 \q_stop + \coordinate ( @@~south~west ) at + ( + \dim_use:c { l_@@_column _ \@@_j _ min _ dim } , + \dim_use:c { l_@@_row _ \@@_i _ min _ dim } + ) ; + \coordinate ( @@~north~east ) at + ( + \dim_use:c { l_@@_column _ \int_eval:n { \@@_j + #2 - 1 } _ max _ dim} , + \dim_use:c { l_@@_row _ \@@_i _ max _ dim } + ) ; + \node + [ + node~contents = { } , + fit = ( @@~south~west ) ( @@~north~east ) , + inner~sep = \c_zero_dim , + name = nm - \int_use:N \g_@@_env_int - \@@_i - \@@_j , + alias = + \str_if_empty:NF \g_@@_name_str { \g_@@_name_str - \@@_i - \@@_j } + ] + ; + } % \end{macrocode} % % % \subsection{We process the options} % -% We process the options when the package is loaded (with |\usepackage|) but we recommend to use -% |\NiceMatrixOptions| instead. +% We process the options when the package is loaded (with |\usepackage|) but we +% recommend to use |\NiceMatrixOptions| instead. % -% We must process these options after the definition of the environment |{NiceMatrix}| because the option -% |renew-matrix| execute the code |\cs_set_eq:NN \env@matrix \NiceMatrix|. +% We must process these options after the definition of the environment +% |{NiceMatrix}| because the option |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. +% Of course, the command |\NiceMatrix| must be defined before such an +% instruction is executed. % \begin{macrocode} \ProcessKeysOptions {NiceMatrix} % \end{macrocode} % % \subsection{Code for \texttt{seq_mapthread_function:NNN}} % -% In |\@@_create_nodes:| (used twice in |\@@_create_extra_nodes:| to create the ``medium nodes'' and ``large -% nodes''), we want to use |\seq_mapthread_function:NNN| which is in \pkg{l3candidates}). For security, we define a -% function |\@@_seq_mapthread_function:NNN|. We will delete the following code when |\seq_mapthread_function:NNN| -% will be in \pkg{l3seq}. +% In |\@@_create_nodes:| (used twice in |\@@_create_extra_nodes:| to create the +% ``medium nodes'' and ``large nodes''), we want to use +% |\seq_mapthread_function:NNN| which is in \pkg{l3candidates}). For security, +% we define a function |\@@_seq_mapthread_function:NNN|. We will delete the +% following code when |\seq_mapthread_function:NNN| will be in \pkg{l3seq}. % \begin{macrocode} -\cs_new:Npn \@@_seq_mapthread_function:NNN #1#2#3 - {\group_begin: +\cs_new:Npn \@@_seq_mapthread_function:NNN #1 #2 #3 + { + \group_begin: % \end{macrocode} % In the group, we can use |\seq_pop:NN| safely. % \begin{macrocode} - \int_step_inline:nnnn 1 1 {\seq_count:N #1} - {\seq_pop:NN #1 \l_tmpa_tl - \seq_pop:NN #2 \l_tmpb_tl - \exp_args:NVV #3 \l_tmpa_tl \l_tmpb_tl} + \int_step_inline:nnnn 1 1 { \seq_count:N #1 } + { + \seq_pop:NN #1 \l_tmpa_tl + \seq_pop:NN #2 \l_tmpb_tl + \exp_args:NVV #3 \l_tmpa_tl \l_tmpb_tl + } \group_end: } % \end{macrocode} % % \begin{macrocode} -\cs_set:Nn \@@_renew_matrix: - {\RenewDocumentEnvironment {pmatrix} {} - {\begin{pNiceMatrix}} - {\end{pNiceMatrix}} - \RenewDocumentEnvironment {vmatrix} {} - {\begin{vNiceMatrix}} - {\end{vNiceMatrix}} - \RenewDocumentEnvironment {Vmatrix} {} - {\begin{VNiceMatrix}} - {\end{VNiceMatrix}} - \RenewDocumentEnvironment {bmatrix} {} - {\begin{bNiceMatrix}} - {\end{bNiceMatrix}} - \RenewDocumentEnvironment {Bmatrix} {} - {\begin{BNiceMatrix}} - {\end{BNiceMatrix}}} +\cs_set_protected:Npn \@@_renew_matrix: + { + \RenewDocumentEnvironment { pmatrix } { } + { \pNiceMatrix } + { \endpNiceMatrix } + \RenewDocumentEnvironment { vmatrix } { } + { \vNiceMatrix } + { \endvNiceMatrix } + \RenewDocumentEnvironment { Vmatrix } { } + { \VNiceMatrix } + { \endVNiceMatrix } + \RenewDocumentEnvironment { bmatrix } { } + { \bNiceMatrix } + { \endbNiceMatrix } + \RenewDocumentEnvironment { Bmatrix } { } + { \BNiceMatrix } + { \endBNiceMatrix } + } % \end{macrocode} % % @@ -4154,7 +4751,8 @@ version 2005/12/01 or later. % % \subsection{Changes between versions 1.0 and 1.1} % -% The dotted lines are no longer drawn with Tikz nodes but with Tikz circles (for efficiency). +% The dotted lines are no longer drawn with Tikz nodes but with Tikz circles +% (for efficiency). % % Modification of the code which is now twice faster. % @@ -4166,56 +4764,65 @@ version 2005/12/01 or later. % % New environment |{pNiceArrayC}| and its variants. % -% Correction of a bug in the definition of |{BNiceMatrix}|, |{vNiceMatrix}| and |{VNiceMatrix}| (in fact, it was a -% typo). +% 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). +% 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). % % % \subsection{Changes between version 1.3 and 1.4} % -% The column types |w| and |W| can now be used in the environments |{NiceArray}|, |{pNiceArrayC}| and its variants -% with the same meaning as in the package \pkg{array}. +% The column types |w| and |W| can now be used in the environments +% |{NiceArray}|, |{pNiceArrayC}| and its variants with the same meaning as in +% the package \pkg{array}. % -% New option |columns-width| to fix the same width for all the columns of the array. +% New option |columns-width| to fix the same width for all the columns of the +% array. % % % \subsection{Changes between version 1.4 and 2.0} % -% The versions 1.0 to 1.4 of \pkg{nicematrix} were focused on the continuous dotted lines whereas the version 2.0 of -% \pkg{nicematrix} provides different features to improve the typesetting of mathematical matrices. +% The versions 1.0 to 1.4 of \pkg{nicematrix} were focused on the continuous +% dotted lines whereas the version 2.0 of \pkg{nicematrix} provides different +% features to improve the typesetting of mathematical matrices. % % \subsection{Changes between version 2.0 and 2.1} % -% New implementation of the environment |{pNiceArrayRC}|. With this new implementation, there is no restriction on -% the width of the columns. +% New implementation of the environment |{pNiceArrayRC}|. With this new +% implementation, there is no restriction on the width of the columns. % -% The package \pkg{nicematrix} no longer loads \pkg{mathtools} but only \pkg{amsmath}. +% The package \pkg{nicematrix} no longer loads \pkg{mathtools} but only +% \pkg{amsmath}. % % Creation of ``medium nodes'' and ``large nodes''. % % \subsection{Changes between version 2.1 and 2.1.1} % -% Small corrections: for example, the option |code-for-first-row| is now available in the command |\NiceMatrixOptions|. +% Small corrections: for example, the option |code-for-first-row| is now +% available in the command |\NiceMatrixOptions|. % % Following a discussion on -% TeX StackExchange\footnote{cf. |tex.stackexchange.com/questions/450841/tikz-externalize-and-nicematrix-package|}, +% TeX StackExchange\footnote{cf. +% |tex.stackexchange.com/questions/450841/tikz-externalize-and-nicematrix-package|}, % Tikz externalization is now deactivated in the environments of the -% extension \pkg{nicematrix}.\footnote{Before this version, there was an error when using \pkg{nicematrix} with -% Tikz externalization. In any case, it's not possible to externalize the Tikz elements constructed by -% \pkg{nicematrix} because they use the options |overlay| and |remember picture|.} +% extension \pkg{nicematrix}.\footnote{Before this version, there was an error +% when using \pkg{nicematrix} with Tikz externalization. In any case, it's not +% possible to externalize the Tikz elements constructed by \pkg{nicematrix} +% because they use the options |overlay| and |remember picture|.} % % \subsection{Changes between version 2.1 and 2.1.2} % Option |draft|: with this option, the dotted lines are not drawn (quicker). % % \subsection{Changes between version 2.1.2 and 2.1.3} % -% When searching the end of a dotted line from a command like |\Cdots| issued in the ``main matrix'' (not in the -% column |C|), the cells in the column |C| are considered as outside the matrix. That means that it's possible to -% do the following matrix with only a |\Cdots| command (and a single |\Vdots|). +% When searching the end of a dotted line from a command like |\Cdots| issued in +% the ``main matrix'' (not in the column |C|), the cells in the column |C| are +% considered as outside the matrix. That means that it's possible to do the +% following matrix with only a |\Cdots| command (and a single |\Vdots|). % \[\begin{pNiceArrayRC}{wc{5mm}Cwc{5mm}} % & C_j & \\ % \mbox{\Large $0$} & \Vdots & \mbox{\Large $0$} \\ @@ -4225,13 +4832,21 @@ version 2005/12/01 or later. % % \subsection{Changes between version 2.1.3 and 2.1.4} % -% Replacement of some options |O{}| in commands and environments defined with \pkg{xparse} by |!O{}| (because a -% recent version of \pkg{xparse} introduced the specifier |!| and modified the default behaviour of the last -% optional arguments). +% Replacement of some options |O { }| in commands and environments defined with +% \pkg{xparse} by |! O { }| (because a recent version of \pkg{xparse} introduced +% the specifier |!| and modified the default behaviour of the last optional +% arguments). % % See |https://www.texdev.net/2018/04/21/xparse-optional-arguments-at-the-end| % +% \subsection{Changes between version 2.1.4 and 2.1.5} +% +% Compatibility with the classes \cls{revtex4-1} and \cls{revtex4-2}. +% +% Option |allow-duplicate-names|. +% % \endinput % Local Variables: % TeX-fold-mode: nil +% fill-column: 80 % End: diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index d681eeb9ac4..dea687e5f4a 100644 --- a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty +++ b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty @@ -18,1123 +18,1481 @@ %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% -\def\myfileversion{2.1.4} -\def\myfiledate{2019/01/28} +\def\myfileversion{2.1.5} +\def\myfiledate{2019/05/27} \RequirePackage{tikz} \usetikzlibrary{fit} -\RequirePackage{expl3}[2018-01-01] +\RequirePackage{expl3}[2019/02/15] \RequirePackage{l3keys2e} \ProvidesExplPackage {nicematrix} {\myfiledate} {\myfileversion} {Several features to improve the typesetting of mathematical matrices with TikZ} -\bool_new:N \c__nicem_draft_bool -\DeclareOption {draft} {\bool_set_true:N \c__nicem_draft_bool} -\DeclareOption* {} +\bool_new:N \c__nm_draft_bool +\DeclareOption { draft } { \bool_set_true:N \c__nm_draft_bool } +\DeclareOption* { } \ProcessOptions \relax -\RequirePackage{array} -\RequirePackage{amsmath} -\RequirePackage{xparse}[2018-10-17] -\cs_new_protected:Nn \__nicem_error:n - {\msg_error:nn {nicematrix} {#1}} -\cs_new_protected:Nn \__nicem_error:nn - {\msg_error:nn {nicematrix} {#1} {#2}} -\cs_new_protected:Nn \__nicem_bool_new:N - {\bool_if_exist:NTF #1 - {\bool_set_false:N #1} - {\bool_new:N #1}} -\ProvideDocumentCommand \iddots {} - {\mathinner{\mkern 1mu - \raise \p@ \hbox{.} - \mkern 2mu - \raise 4\p@ \hbox{.} - \mkern 2mu - \raise 7\p@ \vbox{\kern 7pt - \hbox{.}} - \mkern 1mu}} -\int_new:N \g__nicem_env_int -\dim_new:N \l__nicem_columns_width_dim -\seq_new:N \g__nicem_names_seq -\int_new:N \l__nicem_nb_first_row_int -\int_set:Nn \l__nicem_nb_first_row_int 1 -\bool_new:N \l__nicem_exterior_column_bool -\tl_new:N \l__nicem_pos_env_tl -\tl_set:Nn \l__nicem_pos_env_tl c -\bool_new:N \l__nicem_exterior_arraycolsep_bool -\bool_new:N \l__nicem_parallelize_diags_bool -\bool_set_true:N \l__nicem_parallelize_diags_bool -\bool_new:N \l__nicem_nullify_dots_bool -\bool_new:N \l__nicem_auto_columns_width_bool -\tl_new:N \l__nicem_code_for_last_col_tl -\tl_new:N \g__nicem_name_tl -\tl_new:N \l__nicem_name_tl -\bool_new:N \l__nicem_extra_nodes_bool -\bool_new:N \g__nicem_extra_nodes_bool -\dim_new:N \l__nicem_left_margin_dim -\dim_new:N \l__nicem_right_margin_dim -\dim_new:N \g__nicem_left_margin_dim -\dim_new:N \g__nicem_right_margin_dim -\dim_new:N \l__nicem_extra_left_margin_dim -\dim_new:N \l__nicem_extra_right_margin_dim -\dim_new:N \g__nicem_extra_right_margin_dim -\keys_define:nn {NiceMatrix/NiceMatrixOptions} - {parallelize-diags .bool_set:N = \l__nicem_parallelize_diags_bool, - parallelize-diags .default:n = true, - ParallelizeDiagonals .meta:n = parallelize-diags, - renew-dots .bool_set:N = \l__nicem_renew_dots_bool, - renew-dots .default:n = true, - RenewDots .meta:n = renew-dots, - renew-matrix .code:n = \__nicem_renew_matrix:, - 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__nicem_nullify_dots_bool , - nullify-dots .default:n = true, - NullifyDots .meta:n = nullify-dots, - code-for-last-col .tl_set:N = \l__nicem_code_for_last_col_tl, - code-for-last-col .value_required:n = true, - code-for-first-row .tl_set:N = \l__nicem_code_for_first_row_tl, - code-for-first-row .value_required:n = true, - exterior-arraycolsep .bool_set:N = \l__nicem_exterior_arraycolsep_bool , - exterior-arraycolsep .default:n = true, - columns-width .code:n = \str_if_eq:nnTF {#1} {auto} - {\__nicem_error:n {Option~auto~for~columns-width}} - {\dim_set:Nn \l__nicem_columns_width_dim {#1}}, - create-extra-nodes .bool_set:N = \l__nicem_extra_nodes_bool, - create-extra-nodes .default:n = true, - left-margin .dim_set:N = \l__nicem_left_margin_dim, - left-margin .default:n = \arraycolsep, - right-margin .dim_set:N = \l__nicem_right_margin_dim, - right-margin .default:n = \arraycolsep, - unknown .code:n = \__nicem_error:n {Unknown~key~for~NiceMatrixOptions}} -\msg_new:nnnn {nicematrix} - {Unknown~key~for~NiceMatrixOptions} - {The~key~"\tl_use:N\l_keys_key_tl"~is~unknown~for~the~command~ - \token_to_str:N \NiceMatrixOptions.\\ - If~you~go~on,~it~will~be~ignored.\\ - For~a~list~of~the~available~keys,~type~H~<return>.} - {The~available~keys~are~(in~alphabetic~order):~ - code-for-last-col,~ - exterior-arraycolsep,~ - left-margin,~ - nullify-dots,~ - parallelize-diags,~ - renew-dots,~ - renew-matrix,~ - right-margin,~ - and~transparent} -\msg_new:nnn {nicematrix} - {Option~auto~for~columns-width} - {You~can't~give~the~value~"auto"~to~the~option~"columns-width"~here.~ - If~you~go~on,~the~option~will~be~ignored.} -\NewDocumentCommand \NiceMatrixOptions {m} - {\keys_set:nn {NiceMatrix/NiceMatrixOptions} {#1}} -\keys_define:nn {NiceMatrix/NiceMatrix} - {parallelize-diags .bool_set:N = \l__nicem_parallelize_diags_bool, - parallelize-diags .default:n = true, - renew-dots .bool_set:N = \l__nicem_renew_dots_bool, - renew-dots .default:n = true, - nullify-dots .bool_set:N = \l__nicem_nullify_dots_bool , - nullify-dots .default:n = true, - columns-width .code:n = \str_if_eq:nnTF {#1} {auto} - {\bool_set_true:N - \l__nicem_auto_columns_width_bool} - {\dim_set:Nn \l__nicem_columns_width_dim {#1}}, - name .code:n = {\seq_if_in:NnTF \g__nicem_names_seq {#1} - {\__nicem_error:nn {Duplicate~name} {#1}} - {\seq_gput_left:Nn \g__nicem_names_seq {#1}} - \tl_set:Nn \l__nicem_name_tl {#1}}, - name .value_required:n = true, - code-after .tl_set:N = \l__nicem_code_after_tl, - code-after .initial:n = \c_empty_tl, - code-after .value_required:n = true, - create-extra-nodes .bool_set:N = \l__nicem_extra_nodes_bool, - create-extra-nodes .default:n = true, - left-margin .dim_set:N = \l__nicem_left_margin_dim, - left-margin .default:n = \arraycolsep, - right-margin .dim_set:N = \l__nicem_right_margin_dim, - right-margin .default:n = \arraycolsep, - extra-left-margin .dim_set:N = \l__nicem_extra_left_margin_dim, - extra-right-margin .dim_set:N = \l__nicem_extra_right_margin_dim, - unknown .code:n = \__nicem_error:n {Unknown~option~for~NiceMatrix}} -\msg_new:nnnn {nicematrix} - {Unknown~option~for~NiceMatrix} - {The~option~"\tl_use:N\l_keys_key_tl"~is~unknown~for~the~environment~ - \{NiceMatrix\}~and~its~variants.\\ - If~you~go~on,~it~will~be~ignored.\\ - For~a~list~of~the~available~options,~type~H~<return>.} - {The~available~options~are~(in~alphabetic~order):~ - code-after,~ - columns-width,~ - create-extra-nodes,~ - extra-left-margin,~ - extra-right-margin,~ - left-margin,~ - name,~ - nullify-dots,~ - parallelize-diags,~ - renew-dots~ - and~right-margin.} -\msg_new:nnnn {nicematrix} - {Duplicate~name} - {The~name~"#1"~is~already~used~and~you~shouldn't~use~ - the~same~environment~name~twice.~You~can~go~on,~but,~ - maybe,~you~will~have~incorrect~results~especially~ - if~you~use~"columns-width=auto".\\ - For~a~list~of~the~names~already~used,~type~H~<return>.} - {The~names~already~defined~in~this~document~are:~ - \seq_use:Nnnn~\g__nicem_names_seq~{,~} {,~} {~and~}.} -\keys_define:nn {NiceMatrix/NiceArray} - {parallelize-diags .bool_set:N = \l__nicem_parallelize_diags_bool, - parallelize-diags .default:n = true, - renew-dots .bool_set:N = \l__nicem_renew_dots_bool, - renew-dots .default:n = true, - nullify-dots .bool_set:N = \l__nicem_nullify_dots_bool , - nullify-dots .default:n = true, - columns-width .code:n = \str_if_eq:nnTF {#1} {auto} - {\bool_set_true:N \l__nicem_auto_columns_width_bool} - {\dim_set:Nn \l__nicem_columns_width_dim {#1}}, - columns-width .value_required:n = true, - name .code:n = {\seq_if_in:NnTF \g__nicem_names_seq {#1} - {\__nicem_error:nn {Duplicate~name} {#1}} - {\seq_gput_left:Nn \g__nicem_names_seq {#1}} - \tl_set:Nn \l__nicem_name_tl {#1}}, - name .value_required:n = true, - c .code:n = \tl_set:Nn \l__nicem_pos_env_tl c, - t .code:n = \tl_set:Nn \l__nicem_pos_env_tl t, - b .code:n = \tl_set:Nn \l__nicem_pos_env_tl b, - code-after .tl_set:N = \l__nicem_code_after_tl, - code-after .initial:n = \c_empty_tl, - code-after .value_required:n = true, - create-extra-nodes .bool_set:N = \l__nicem_extra_nodes_bool, - create-extra-nodes .default:n = true, - left-margin .dim_set:N = \l__nicem_left_margin_dim, - left-margin .default:n = \arraycolsep, - right-margin .dim_set:N = \l__nicem_right_margin_dim, - right-margin .default:n = \arraycolsep, - extra-left-margin .dim_set:N = \l__nicem_extra_left_margin_dim, - extra-right-margin .dim_set:N = \l__nicem_extra_right_margin_dim, - unknown .code:n = \__nicem_error:n {Unknown~option~for~NiceArray}} -\msg_new:nnnn {nicematrix} - {Unknown~option~for~NiceArray} - {The~option~"\tl_use:N\l_keys_key_tl"~is~unknown~for~the~environment~ - \{NiceArray\}.\\ - If~you~go~on,~it~will~be~ignored.\\ - For~a~list~of~the~available~options,~type~H~<return>.} - {The~available~options~are~(in~alphabetic~order):~ - b,~ - c,~ - code-after,~ - create-extra-nodes,~ - columns-width,~ - extra-left-margin,~ - extra-right-margin,~ - left-margin,~ - name,~ - nullify-dots,~ - parallelize-diags,~ - renew-dots,~ - right-margin,~ - and~t.} -\cs_new_protected:Nn \__nicem_Cell: - { - \int_gincr:N \g__nicem_column_int - \int_compare:nNnT \g__nicem_column_int = 1 - {\int_gincr:N \g__nicem_row_int} - \int_gset:Nn \g__nicem_column_total_int - {\int_max:nn \g__nicem_column_total_int \g__nicem_column_int} +\RequirePackage { array } +\RequirePackage { amsmath } +\RequirePackage { xparse } [ 2018-10-17 ] +\bool_new:N \c__nm_revtex_bool +\@ifclassloaded { revtex4-1 } + { \bool_set_true:N \c__nm_revtex_bool } + { } +\@ifclassloaded { revtex4-2 } + { \bool_set_true:N \c__nm_revtex_bool } + { } +\cs_new_protected:Nn \__nm_error:n { \msg_error:nn { nicematrix } { #1 } } +\cs_new_protected:Nn \__nm_error:nn { \msg_error:nn { nicematrix } { #1 } { #2 } } +\cs_new_protected:Npn \__nm_msg_new:nn { \msg_new:nnn { nicematrix } } +\cs_new_protected:Npn \__nm_msg_new:nnn { \msg_new:nnnn { nicematrix } } +\cs_new_protected:Npn \__nm_msg_redirect_name:nn + { \msg_redirect_name:nnn { nicematrix } } +\ProvideDocumentCommand \iddots { } + { + \mathinner + { \mkern 1 mu + \raise \p@ \hbox { . } + \mkern 2 mu + \raise 4 \p@ \hbox { . } + \mkern 2 mu + \raise 7 \p@ \vbox { \kern 7 pt \hbox { . } } \mkern 1 mu + } + } +\int_new:N \g__nm_env_int +\dim_new:N \l__nm_columns_width_dim +\seq_new:N \g__nm_names_seq +\int_new:N \l__nm_nb_first_row_int +\int_set:Nn \l__nm_nb_first_row_int 1 +\bool_new:N \l__nm_exterior_column_bool +\bool_new:N \l__nm_in_NiceArray_bool +\str_new:N \l__nm_pos_env_str +\str_set:Nn \l__nm_pos_env_str 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_auto_columns_width_bool +\tl_new:N \l__nm_code_for_last_col_tl +\str_new:N \g__nm_name_str +\str_new:N \l__nm_name_str +\bool_new:N \l__nm_extra_nodes_bool +\bool_new:N \g__nm_extra_nodes_bool +\dim_new:N \l__nm_left_margin_dim +\dim_new:N \l__nm_right_margin_dim +\dim_new:N \g__nm_left_margin_dim +\dim_new:N \g__nm_right_margin_dim +\dim_new:N \l__nm_extra_left_margin_dim +\dim_new:N \l__nm_extra_right_margin_dim +\dim_new:N \g__nm_extra_right_margin_dim +\keys_define:nn { NiceMatrix / Global } + { + 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 , + create-extra-nodes .bool_set:N = \l__nm_extra_nodes_bool , + create-extra-nodes .default:n = true, + left-margin .dim_set:N = \l__nm_left_margin_dim , + left-margin .default:n = \arraycolsep , + right-margin .dim_set:N = \l__nm_right_margin_dim , + right-margin .default:n = \arraycolsep , + extra-left-margin .dim_set:N = \l__nm_extra_left_margin_dim , + extra-right-margin .dim_set:N = \l__nm_extra_right_margin_dim + } +\keys_define:nn { NiceMatrix / Env } + { + columns-width .code:n = + \str_if_eq:nnTF { #1 } { auto } + { \bool_set_true:N \l__nm_auto_columns_width_bool } + { \dim_set:Nn \l__nm_columns_width_dim { #1 } } , + columns-width .value_required:n = true , + name .code:n = + \seq_if_in:NnTF \g__nm_names_seq { #1 } + { \__nm_error:nn { Duplicate~name } { #1 } } + { \seq_gput_left:Nn \g__nm_names_seq { #1 } } + \str_set:Nn \l__nm_name_str { #1 } , + name .value_required:n = true , + code-after .tl_set:N = \l__nm_code_after_tl , + code-after .initial:n = \c_empty_tl , + code-after .value_required:n = true , + } +\keys_define:nn { NiceMatrix } + { + NiceMatrixOptions .inherit:n = NiceMatrix / Global , + NiceMatrix .inherit:n = + { + NiceMatrix / Global , + NiceMatrix / Env + } , + NiceArray .inherit:n = + { + NiceMatrix / Global , + NiceMatrix / Env + } , + NiceArrayC .inherit:n = + { + NiceMatrix / Global , + NiceMatrix / Env + } , + NiceArrayRC .inherit:n = + { + NiceMatrix / Global , + NiceMatrix / Env + } + } +\keys_define:nn { NiceMatrix / NiceMatrixOptions } + { + renew-matrix .code:n = \__nm_renew_matrix: , + 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, + code-for-last-col .tl_set:N = \l__nm_code_for_last_col_tl , + code-for-last-col .value_required:n = true , + code-for-first-row .tl_set:N = \l__nm_code_for_first_row_tl , + code-for-first-row .value_required:n = true , + exterior-arraycolsep .bool_set:N = \l__nm_exterior_arraycolsep_bool , + exterior-arraycolsep .default:n = true , + columns-width .code:n = + \str_if_eq:nnTF { #1 } { auto } + { \__nm_error:n { Option~auto~for~columns-width } } + { \dim_set:Nn \l__nm_columns_width_dim { #1 } } , + allow-duplicate-names .code:n = + \__nm_msg_redirect_name:nn { Duplicate~name } {none} , + allow-duplicate-names .value_forbidden:n = true , + unknown .code:n = \__nm_error:n { Unknown~key~for~NiceMatrixOptions } } +\__nm_msg_new:nnn { Unknown~key~for~NiceMatrixOptions } + { + The~key~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~command~ + \token_to_str:N \NiceMatrixOptions. \\ + If~you~go~on,~it~will~be~ignored. \\ + For~a~list~of~the~available~keys,~type~H~<return>. + } + { + The~available~keys~are~(in~alphabetic~order):~ + allow-duplicate-names,~ + code-for-last-col,~ + exterior-arraycolsep,~ + left-margin,~ + nullify-dots,~ + parallelize-diags,~ + renew-dots,~ + renew-matrix,~ + right-margin,~ + and~transparent + } +\__nm_msg_new:nn { Option~auto~for~columns-width } + { + You~can't~give~the~value~'auto'~to~the~option~'columns-width'~here.~ + If~you~go~on,~the~option~will~be~ignored. + } +\NewDocumentCommand \NiceMatrixOptions { m } + { \keys_set:nn { NiceMatrix / NiceMatrixOptions } { #1 } } +\keys_define:nn { NiceMatrix / NiceMatrix } + { unknown .code:n = \__nm_error:n { Unknown~option~for~NiceMatrix } } +\__nm_msg_new:nnn { Unknown~option~for~NiceMatrix } + { + The~option~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~environment~ + \{NiceMatrix\}~and~its~variants. \\ + If~you~go~on,~it~will~be~ignored. \\ + For~a~list~of~the~available~options,~type~H~<return>. + } + { + The~available~options~are~(in~alphabetic~order):~ + code-after,~ + columns-width,~ + create-extra-nodes,~ + extra-left-margin,~ + extra-right-margin,~ + left-margin,~ + name,~ + nullify-dots,~ + parallelize-diags,~ + renew-dots~ + and~right-margin. + } +\__nm_msg_new:nnn { Duplicate~name } + { + The~name~'\l_keys_value_tl'~is~already~used~and~you~shouldn't~use~ + the~same~environment~name~twice.~You~can~go~on,~but,~ + maybe,~you~will~have~incorrect~results~especially~ + if~you~use~'columns-width=auto'. \\ + For~a~list~of~the~names~already~used,~type~H~<return>. \\ + If~you~don't~want~to~see~this~message~again,~use~the~option~ + 'allow-duplicate-names'. + } + { + The~names~already~defined~in~this~document~are:~ + \seq_use:Nnnn \g__nm_names_seq { ,~ } { ,~ } { ~and~ }. + } +\keys_define:nn { NiceMatrix / NiceArray } + { + c .code:n = \str_set:Nn \l__nm_pos_env_str c , + t .code:n = \str_set:Nn \l__nm_pos_env_str t , + b .code:n = \str_set:Nn \l__nm_pos_env_str b , + unknown .code:n = \__nm_error:n { Unknown~option~for~NiceArray } + } +\__nm_msg_new:nnn { Unknown~option~for~NiceArray } + { + The~option~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~environment~ + \{NiceArray\}. \\ + If~you~go~on,~it~will~be~ignored. \\ + For~a~list~of~the~available~options,~type~H~<return>. + } + { + The~available~options~are~(in~alphabetic~order):~ + b,~ + c,~ + code-after,~ + create-extra-nodes,~ + columns-width,~ + extra-left-margin,~ + extra-right-margin,~ + left-margin,~ + name,~ + nullify-dots,~ + parallelize-diags,~ + renew-dots,~ + right-margin,~ + and~t. + } +\cs_new_protected:Nn \__nm_Cell: + { + \int_gincr:N \g__nm_column_int + \int_compare:nNnT \g__nm_column_int = \c_one_int + { \int_gincr:N \g__nm_row_int } + \int_gset:Nn \g__nm_column_total_int + { \int_max:nn \g__nm_column_total_int \g__nm_column_int } \hbox_set:Nw \l_tmpa_box $ % $ - \int_compare:nNnT \g__nicem_row_int = 0 - \l__nicem_code_for_first_row_tl} -\cs_new_protected:Nn \__nicem_end_Cell: - {$ % $ + \int_compare:nNnT \g__nm_row_int = \c_zero_int + \l__nm_code_for_first_row_tl + } +\cs_new_protected:Nn \__nm_end_Cell: + { $ % $ \hbox_set_end: - \dim_gset:Nn \g__nicem_max_cell_width_dim - {\dim_max:nn \g__nicem_max_cell_width_dim {\box_wd:N \l_tmpa_box}} - \int_compare:nNnT \g__nicem_row_int = 0 - {\dim_gset:Nn \g__nicem_max_dp_row_zero_dim - {\dim_max:nn \g__nicem_max_dp_row_zero_dim {\box_dp:N \l_tmpa_box}} - \dim_gset:Nn \g__nicem_max_ht_row_zero_dim - {\dim_max:nn \g__nicem_max_ht_row_zero_dim {\box_ht:N \l_tmpa_box}}} - \int_compare:nNnT \g__nicem_row_int = 1 - {\dim_gset:Nn \g__nicem_max_ht_row_one_dim - {\dim_max:nn \g__nicem_max_ht_row_one_dim {\box_ht:N \l_tmpa_box}}} - \tikz[remember~picture, inner~sep = 0pt, minimum~width = 0pt, baseline] - \node [anchor = base, - name = nm-\int_use:N \g__nicem_env_int- - \int_use:N \g__nicem_row_int- - \int_use:N \g__nicem_column_int, - alias = \tl_if_empty:NF \l__nicem_name_tl - {\tl_use:N \l__nicem_name_tl- - \int_use:N \g__nicem_row_int- - \int_use:N \g__nicem_column_int} ] - \bgroup - \box_use:N \l_tmpa_box - \egroup ;} -\NewDocumentEnvironment {NiceMatrix} {!O{}} - {\keys_set:nn {NiceMatrix/NiceMatrix} {#1} - \tl_set:Nn \l__nicem_pos_env_tl c - \bool_set_false:N \l__nicem_exterior_arraycolsep_bool - \NiceArray{*\c@MaxMatrixCols{C}} + \dim_gset:Nn \g__nm_max_cell_width_dim + { \dim_max:nn \g__nm_max_cell_width_dim { \box_wd:N \l_tmpa_box } } + \int_compare:nNnT \g__nm_row_int = \c_zero_int + { + \dim_gset:Nn \g__nm_max_dp_row_zero_dim + { \dim_max:nn \g__nm_max_dp_row_zero_dim { \box_dp:N \l_tmpa_box } } + \dim_gset:Nn \g__nm_max_ht_row_zero_dim + { \dim_max:nn \g__nm_max_ht_row_zero_dim { \box_ht:N \l_tmpa_box } } } - {\endarray - \skip_horizontal:n {-\arraycolsep} - \skip_horizontal:n {\g__nicem_right_margin_dim + \g__nicem_extra_right_margin_dim}} -\cs_generate_variant:Nn \dim_set:Nn {Nx} -\msg_new:nnn {nicematrix} - {We~are~yet~in~an~environment~NiceArray} - {Environments~\{NiceArray\}~(or~\{NiceMatrix\},~etc.)~can't~be~ - nested.~We~can~go~on,~but,~maybe,~you~will~have~errors~or~an~incorrect~ - result.} -\cs_new_protected:Npn \__nicem_define_dots: - {\cs_set_eq:NN \Ldots \__nicem_Ldots - \cs_set_eq:NN \Cdots \__nicem_Cdots - \cs_set_eq:NN \Vdots \__nicem_Vdots - \cs_set_eq:NN \Ddots \__nicem_Ddots - \cs_set_eq:NN \Iddots \__nicem_Iddots - \bool_if:NT \l__nicem_renew_dots_bool - {\cs_set_eq:NN \ldots \__nicem_Ldots - \cs_set_eq:NN \cdots \__nicem_Cdots - \cs_set_eq:NN \vdots \__nicem_Vdots - \cs_set_eq:NN \ddots \__nicem_Ddots - \cs_set_eq:NN \iddots \__nicem_Iddots - \cs_set_eq:NN \dots \__nicem_Ldots - \cs_set_eq:NN \hdotsfor \__nicem_Hdotsfor}} -\cs_new_protected:Npn \__nicem_define_dots_to_nil: - {\cs_set_eq:NN \Ldots \prg_do_nothing: - \cs_set_eq:NN \Cdots \prg_do_nothing: - \cs_set_eq:NN \Vdots \prg_do_nothing: - \cs_set_eq:NN \Ddots \prg_do_nothing: - \cs_set_eq:NN \Iddots \prg_do_nothing: - \bool_if:NT \l__nicem_renew_dots_bool - {\cs_set_eq:NN \ldots \prg_do_nothing: - \cs_set_eq:NN \cdots \prg_do_nothing: - \cs_set_eq:NN \vdots \prg_do_nothing: - \cs_set_eq:NN \ddots \prg_do_nothing: - \cs_set_eq:NN \iddots \prg_do_nothing: - \cs_set_eq:NN \dots \prg_do_nothing: - \cs_set_eq:NN \hdotsfor \__nicem_Hdotsfor}} -\NewDocumentEnvironment {NiceArray} {O{} m !O{}} - {\cs_if_exist:NT \__nicem_in_NiceArray: - {\__nicem_error:n {We~are~yet~in~an~environment~NiceArray}} - \cs_if_exist:NT \tikz@library@external@loaded - {\tikzset{external/export = false}} - \cs_set:Npn \__nicem_in_NiceArray: {--Void--} - \group_insert_after:N \__nicem_after_array: - \tl_gclear_new:N \g__nicem_lines_to_draw_tl - \int_gincr:N \g__nicem_env_int - \bool_if:NF \l__nicem_block_auto_columns_width_bool - {\dim_gzero_new:N \g__nicem_max_cell_width_dim} - \dim_gzero_new:N \g__nicem_max_dp_row_zero_dim - \dim_gzero_new:N \g__nicem_max_ht_row_zero_dim - \dim_gzero_new:N \g__nicem_max_ht_row_one_dim - \keys_set:nn {NiceMatrix/NiceArray} {#1,#3} - \bool_if:NT \l__nicem_auto_columns_width_bool - {\group_insert_after:N \__nicem_write_max_cell_width: - \cs_if_free:cTF {__nicem_max_cell_width_\int_use:N \g__nicem_env_int} - {\dim_set:Nn \l__nicem_columns_width_dim \c_zero_dim} - {\dim_set:Nx \l__nicem_columns_width_dim - {\use:c {__nicem_max_cell_width_\int_use:N \g__nicem_env_int}}} - \tl_if_empty:NF \l__nicem_name_tl - {\cs_if_free:cF {__nicem_max_cell_width_\l__nicem_name_tl} - {\dim_set:Nx \l__nicem_columns_width_dim - {\use:c {__nicem_max_cell_width_\l__nicem_name_tl}}}} - } - \bool_gset_eq:NN \g__nicem_extra_nodes_bool \l__nicem_extra_nodes_bool - \dim_gset_eq:NN \g__nicem_left_margin_dim \l__nicem_left_margin_dim - \dim_gset_eq:NN \g__nicem_right_margin_dim \l__nicem_right_margin_dim - \dim_gset_eq:NN \g__nicem_extra_right_margin_dim \l__nicem_extra_right_margin_dim - \tl_gset_eq:NN \g__nicem_code_after_tl \l__nicem_code_after_tl - \tl_gset_eq:NN \g__nicem_name_tl \l__nicem_name_tl - \cs_set:Npn \ialign - {\everycr{\noalign{\int_gzero:N \g__nicem_column_int}} - \tabskip = \c_zero_skip - \cs_set:Npn \ialign {\everycr{} - \tabskip = \c_zero_skip - \halign} - \halign} - \dim_compare:nNnTF \l__nicem_columns_width_dim = \c_zero_dim - {\newcolumntype{L}{>{\__nicem_Cell:}l<{\__nicem_end_Cell:}} - \newcolumntype{C}{>{\__nicem_Cell:}c<{\__nicem_end_Cell:}} - \newcolumntype{R}{>{\__nicem_Cell:}r<{\__nicem_end_Cell:}}} - {\newcolumntype{L}{wl{\dim_use:N \l__nicem_columns_width_dim}} - \newcolumntype{C}{wc{\dim_use:N \l__nicem_columns_width_dim}} - \newcolumntype{R}{wr{\dim_use:N \l__nicem_columns_width_dim}}} - \cs_set_eq:NN \NC@find@w \relax - \cs_set_eq:NN \NC@find@W \relax - \newcolumntype{w}[2] - {>{\hbox_set:Nw \l_tmpa_box - \__nicem_Cell:} - c - <{\__nicem_end_Cell: - \hbox_set_end: - \makebox[##2][##1]{\box_use:N \l_tmpa_box}}} - \newcolumntype{W}[2] - {>{\hbox_set:Nw \l_tmpa_box - \__nicem_Cell:} + \int_compare:nNnT \g__nm_row_int = \c_one_int + { + \dim_gset:Nn \g__nm_max_ht_row_one_dim + { \dim_max:nn \g__nm_max_ht_row_one_dim { \box_ht:N \l_tmpa_box } } + } + \tikz + [ + remember~picture , + inner~sep = \c_zero_dim , + minimum~width = \c_zero_dim , + baseline + ] + \node + [ + anchor = base , + name = nm - \int_use:N \g__nm_env_int - + \int_use:N \g__nm_row_int - + \int_use:N \g__nm_column_int , + alias = + \str_if_empty:NF \l__nm_name_str + { + \l__nm_name_str - + \int_use:N \g__nm_row_int - + \int_use:N \g__nm_column_int + } + ] + \bgroup + \box_use:N \l_tmpa_box + \egroup ; + } +\NewDocumentEnvironment { NiceMatrix } { ! O { } } + { + \keys_set:nn { NiceMatrix / NiceMatrix } { #1 } + \str_set:Nn \l__nm_pos_env_str c + \bool_set_false:N \l__nm_exterior_arraycolsep_bool + \NiceArray { * \c@MaxMatrixCols C } + } + { + \endarray + \skip_horizontal:n + { \g__nm_right_margin_dim + \g__nm_extra_right_margin_dim - \arraycolsep } + } +\cs_generate_variant:Nn \dim_set:Nn { N x } +\__nm_msg_new:nn { Yet~in~NiceArray } + { + Environments~\{NiceArray\}~(or~\{NiceMatrix\},~etc.)~can't~be~ + nested.~We~can~go~on,~but,~maybe,~you~will~have~errors~or~an~incorrect~ + result. + } +\cs_new_protected:Npn \__nm_define_dots: + { + \cs_set_eq:NN \Ldots \__nm_Ldots + \cs_set_eq:NN \Cdots \__nm_Cdots + \cs_set_eq:NN \Vdots \__nm_Vdots + \cs_set_eq:NN \Ddots \__nm_Ddots + \cs_set_eq:NN \Iddots \__nm_Iddots + \bool_if:NT \l__nm_renew_dots_bool + { + \cs_set_eq:NN \ldots \__nm_Ldots + \cs_set_eq:NN \cdots \__nm_Cdots + \cs_set_eq:NN \vdots \__nm_Vdots + \cs_set_eq:NN \ddots \__nm_Ddots + \cs_set_eq:NN \iddots \__nm_Iddots + \cs_set_eq:NN \dots \__nm_Ldots + \cs_set_eq:NN \hdotsfor \__nm_Hdotsfor + } + } +\cs_new_protected:Npn \__nm_define_dots_to_nil: + { + \cs_set_eq:NN \Ldots \prg_do_nothing: + \cs_set_eq:NN \Cdots \prg_do_nothing: + \cs_set_eq:NN \Vdots \prg_do_nothing: + \cs_set_eq:NN \Ddots \prg_do_nothing: + \cs_set_eq:NN \Iddots \prg_do_nothing: + \bool_if:NT \l__nm_renew_dots_bool + { + \cs_set_eq:NN \ldots \prg_do_nothing: + \cs_set_eq:NN \cdots \prg_do_nothing: + \cs_set_eq:NN \vdots \prg_do_nothing: + \cs_set_eq:NN \ddots \prg_do_nothing: + \cs_set_eq:NN \iddots \prg_do_nothing: + \cs_set_eq:NN \dots \prg_do_nothing: + \cs_set_eq:NN \hdotsfor \__nm_Hdotsfor + } + } +\NewDocumentEnvironment { NiceArray } { O { } m ! O { } } + { + \bool_if:NT \l__nm_in_NiceArray_bool + { \__nm_error:n { Yet~in~NiceArray } } + \cs_if_exist:NT \tikz@library@external@loaded + { \tikzset { external / export = false } } + \bool_set_true:N \l__nm_in_NiceArray_bool + \group_insert_after:N \__nm_after_array: + \tl_gclear_new:N \g__nm_lines_to_draw_tl + \int_gincr:N \g__nm_env_int + \bool_if:NF \l__nm_block_auto_columns_width_bool + { \dim_gzero_new:N \g__nm_max_cell_width_dim } + \dim_gzero_new:N \g__nm_max_dp_row_zero_dim + \dim_gzero_new:N \g__nm_max_ht_row_zero_dim + \dim_gzero_new:N \g__nm_max_ht_row_one_dim + \keys_set:nn { NiceMatrix / NiceArray } { #1 , #3 } + \bool_if:NT \l__nm_auto_columns_width_bool + { + \group_insert_after:N \__nm_write_max_cell_width: + \cs_if_free:cTF { __nm_max_cell_width_ \int_use:N \g__nm_env_int } + { \dim_set:Nn \l__nm_columns_width_dim \c_zero_dim } + { + \dim_set:Nx \l__nm_columns_width_dim + { \use:c { __nm_max_cell_width _ \int_use:N \g__nm_env_int } } + } + \str_if_empty:NF \l__nm_name_str + { + \cs_if_free:cF { __nm_max_cell_width_ \l__nm_name_str } + { + \dim_set:Nx \l__nm_columns_width_dim + { \use:c { __nm_max_cell_width_ \l__nm_name_str } } + } + } + } + \bool_gset_eq:NN \g__nm_extra_nodes_bool \l__nm_extra_nodes_bool + \dim_gset_eq:NN \g__nm_left_margin_dim \l__nm_left_margin_dim + \dim_gset_eq:NN \g__nm_right_margin_dim \l__nm_right_margin_dim + \dim_gset_eq:NN \g__nm_extra_right_margin_dim \l__nm_extra_right_margin_dim + \tl_gset_eq:NN \g__nm_code_after_tl \l__nm_code_after_tl + \tl_gset_eq:NN \g__nm_name_str \l__nm_name_str + \cs_set:Npn \ialign + { + \everycr { \noalign { \int_gzero:N \g__nm_column_int } } + \tabskip = \c_zero_skip + \cs_set:Npn \ialign + { + \everycr { } + \tabskip = \c_zero_skip + \halign + } + \halign + } + \dim_compare:nNnTF \l__nm_columns_width_dim = \c_zero_dim + { + \newcolumntype L { > \__nm_Cell: l < \__nm_end_Cell: } + \newcolumntype C { > \__nm_Cell: c < \__nm_end_Cell: } + \newcolumntype R { > \__nm_Cell: r < \__nm_end_Cell: } + } + { + \newcolumntype L { w l { \dim_use:N \l__nm_columns_width_dim } } + \newcolumntype C { w c { \dim_use:N \l__nm_columns_width_dim } } + \newcolumntype R { w r { \dim_use:N \l__nm_columns_width_dim } } + } + \cs_set_eq:NN \NC@find@w \relax + \cs_set_eq:NN \NC@find@W \relax + \newcolumntype w [ 2 ] + { + > { + \hbox_set:Nw \l_tmpa_box + \__nm_Cell:} c - <{\__nicem_end_Cell: - \hbox_set_end: - \cs_set_eq:NN \hss \hfil - \makebox[##2][##1]{\box_use:N \l_tmpa_box}}} - \bool_if:NTF \c__nicem_draft_bool - \__nicem_define_dots_to_nil: - \__nicem_define_dots: - \cs_set_eq:NN \Hspace \__nicem_Hspace: - \cs_set_eq:NN \Hdotsfor \__nicem_Hdotsfor - \cs_set_eq:NN \multicolumn \__nicem_multicolumn:nnn - \seq_gclear_new:N \g__nicem_empty_cells_seq - \seq_gclear_new:N \g__nicem_multicolumn_cells_seq - \seq_gclear_new:N \g__nicem_multicolumn_sizes_seq - \int_gzero_new:N \g__nicem_row_int - \int_gset:Nn \g__nicem_row_int {\l__nicem_nb_first_row_int - 1} - \int_gzero_new:N \g__nicem_column_int - \int_gzero_new:N \g__nicem_column_total_int - \cs_set_eq:NN \@ifnextchar \new@ifnextchar - \bool_if:NF \l__nicem_exterior_arraycolsep_bool - {\skip_horizontal:n {-\arraycolsep}} - \skip_horizontal:n {\l__nicem_left_margin_dim + \l__nicem_extra_left_margin_dim} - \array[\l__nicem_pos_env_tl]{#2}} - {\endarray - \bool_if:NF \l__nicem_exterior_arraycolsep_bool - {\skip_horizontal:n {-\arraycolsep}} - \skip_horizontal:n {\g__nicem_right_margin_dim + \g__nicem_extra_right_margin_dim}} -\NewDocumentEnvironment {pNiceMatrix} {} - {\left(\begin{NiceMatrix}} - {\end{NiceMatrix}\right)} -\NewDocumentEnvironment {bNiceMatrix} {} - {\left[\begin{NiceMatrix}} - {\end{NiceMatrix}\right]} -\NewDocumentEnvironment {BNiceMatrix} {} - {\left\{\begin{NiceMatrix}} - {\end{NiceMatrix}\right\}} -\NewDocumentEnvironment {vNiceMatrix} {} - {\left\lvert\begin{NiceMatrix}} - {\end{NiceMatrix}\right\rvert} -\NewDocumentEnvironment {VNiceMatrix} {} - {\left\lVert\begin{NiceMatrix}} - {\end{NiceMatrix}\right\rVert} -\cs_new_protected:Nn \__nicem_write_max_cell_width: - {\bool_if:NF \l__nicem_block_auto_columns_width_bool - {\iow_now:Nn \@mainaux {\ExplSyntaxOn} - \iow_now:Nx \@mainaux {\cs_gset:cpn - {__nicem_max_cell_width_\int_use:N \g__nicem_env_int} - {\dim_use:N \g__nicem_max_cell_width_dim} } - \iow_now:Nx \@mainaux {\cs_gset:cpn {__nicem_max_cell_width_\g__nicem_name_tl} - {\dim_use:N \g__nicem_max_cell_width_dim} } - \iow_now:Nn \@mainaux {\ExplSyntaxOff}}} -\prg_set_conditional:Npnn \__nicem_if_not_empty_cell:nn #1#2 {T,TF} - {\cs_if_exist:cTF {pgf@sh@ns@nm-\int_use:N \g__nicem_env_int- - \int_use:N #1- - \int_use:N #2} - {\seq_if_in:NxTF \g__nicem_empty_cells_seq - {\int_use:N #1-\int_use:N #2} - {\prg_return_false:} - {\begin{pgfpicture} - \tl_set:Nx \l_tmpa_tl {nm-\int_use:N \g__nicem_env_int- - \int_use:N #1- - \int_use:N #2} - \pgfpointanchor \l_tmpa_tl {east} - \dim_gset:Nn \g_tmpa_dim \pgf@x - \pgfpointanchor \l_tmpa_tl {west} - \dim_gset:Nn \g_tmpb_dim \pgf@x - \end{pgfpicture} - \dim_compare:nNnTF {\dim_abs:n {\g_tmpb_dim-\g_tmpa_dim}} < {0.5 pt} - \prg_return_false: - \prg_return_true: - }} - \prg_return_false: + < { + \__nm_end_Cell: + \hbox_set_end: + \makebox [ ##2 ] [ ##1 ] { \box_use:N \l_tmpa_box } + } + } + \newcolumntype W [ 2 ] + { + > { + \hbox_set:Nw \l_tmpa_box + \__nm_Cell: + } + c + < { + \__nm_end_Cell: + \hbox_set_end: + \cs_set_eq:NN \hss \hfil + \makebox [ ##2 ] [ ##1 ] { \box_use:N \l_tmpa_box } + } + } + \bool_if:NTF \c__nm_draft_bool + \__nm_define_dots_to_nil: + \__nm_define_dots: + \cs_set_eq:NN \Hspace \__nm_Hspace: + \cs_set_eq:NN \Hdotsfor \__nm_Hdotsfor + \cs_set_eq:NN \multicolumn \__nm_multicolumn:nnn + \seq_gclear_new:N \g__nm_empty_cells_seq + \seq_gclear_new:N \g__nm_multicolumn_cells_seq + \seq_gclear_new:N \g__nm_multicolumn_sizes_seq + \int_gzero_new:N \g__nm_row_int + \int_gset:Nn \g__nm_row_int { \l__nm_nb_first_row_int - 1 } + \int_gzero_new:N \g__nm_column_int + \int_gzero_new:N \g__nm_column_total_int + \cs_set_eq:NN \@ifnextchar \new@ifnextchar + \bool_if:NF \l__nm_exterior_arraycolsep_bool + { \skip_horizontal:n { - \arraycolsep } } + \skip_horizontal:n { \l__nm_left_margin_dim + \l__nm_extra_left_margin_dim } + \bool_if:NTF \c__nm_revtex_bool + { + \cs_set_eq:NN \@acoll \@arrayacol + \cs_set_eq:NN \@acolr \@arrayacol + \cs_set_eq:NN \@acol \@arrayacol + \cs_set:Npn \@halignto { } + \@array@array } -\cs_new_protected:Nn \__nicem_instruction_of_type:n - {\tl_gput_right:Nx \g__nicem_lines_to_draw_tl - {\exp_not:c {__nicem_draw_#1:nn} - {\int_use:N \g__nicem_row_int} - {\int_use:N \g__nicem_column_int}}} -\cs_new_protected:Nn \__nicem_after_array: - {\group_begin: - \cs_if_exist:NT \tikz@library@external@loaded - {\tikzset{external/export = false}} - \int_gset_eq:NN \g__nicem_column_int \g__nicem_column_total_int - \bool_if:NT \l__nicem_exterior_column_bool {\int_gdecr:N \g__nicem_column_int} - \seq_gclear_new:N \g__nicem_yet_drawn_seq - \bool_if:NT \l__nicem_parallelize_diags_bool - {\int_zero_new:N \l__nicem_ddots_int - \int_zero_new:N \l__nicem_iddots_int - \dim_zero_new:N \l__nicem_delta_x_one_dim - \dim_zero_new:N \l__nicem_delta_y_one_dim - \dim_zero_new:N \l__nicem_delta_x_two_dim - \dim_zero_new:N \l__nicem_delta_y_two_dim} - \bool_if:NT \g__nicem_extra_nodes_bool \__nicem_create_extra_nodes: - \tl_if_empty:NF \g__nicem_lines_to_draw_tl - {\int_zero_new:N \l__nicem_initial_i_int - \int_zero_new:N \l__nicem_initial_j_int - \int_zero_new:N \l__nicem_final_i_int - \int_zero_new:N \l__nicem_final_j_int - \__nicem_bool_new:N \l__nicem_initial_open_bool - \__nicem_bool_new:N \l__nicem_final_open_bool - \g__nicem_lines_to_draw_tl} - \tl_gclear:N \g__nicem_lines_to_draw_tl - \tikzset{every~picture/.style = {overlay, - remember~picture, - name~prefix = nm-\int_use:N \g__nicem_env_int-}} - \cs_set_eq:NN \line \__nicem_line:nn - \g__nicem_code_after_tl - \group_end:} -\cs_new_protected:Nn \__nicem_find_extremities_of_line:nnnn - {\int_set:Nn \l__nicem_initial_i_int {#1} - \int_set:Nn \l__nicem_initial_j_int {#2} - \int_set:Nn \l__nicem_final_i_int {#1} - \int_set:Nn \l__nicem_final_j_int {#2} - \bool_set_false:N \l__nicem_initial_open_bool - \bool_set_false:N \l__nicem_final_open_bool - \__nicem_bool_new:N \l__nicem_stop_loop_bool - \bool_do_until:Nn \l__nicem_stop_loop_bool - {\int_add:Nn \l__nicem_final_i_int {#3} - \int_add:Nn \l__nicem_final_j_int {#4} - \bool_if:nTF { \int_compare_p:nNn - \l__nicem_final_i_int < {\l__nicem_nb_first_row_int - 1} - || \int_compare_p:nNn - \l__nicem_final_i_int > \g__nicem_row_int - || \int_compare_p:nNn - \l__nicem_final_j_int < 1 - || \int_compare_p:nNn - \l__nicem_final_j_int > \g__nicem_column_total_int - || \int_compare_p:nNn - \l__nicem_final_j_int > \g__nicem_column_int - && \int_compare_p:nNn {#4} > 0 } - {\bool_set_true:N \l__nicem_final_open_bool - \int_sub:Nn \l__nicem_final_i_int {#3} - \int_sub:Nn \l__nicem_final_j_int {#4} - \bool_set_true:N \l__nicem_stop_loop_bool} - {\__nicem_if_not_empty_cell:nnT - \l__nicem_final_i_int - \l__nicem_final_j_int - {\bool_set_true:N \l__nicem_stop_loop_bool}} - } - \bool_set_false:N \l__nicem_stop_loop_bool - \bool_do_until:Nn \l__nicem_stop_loop_bool - {\int_sub:Nn \l__nicem_initial_i_int {#3} - \int_sub:Nn \l__nicem_initial_j_int {#4} - \bool_if:nTF - { \int_compare_p:nNn - \l__nicem_initial_i_int < \l__nicem_nb_first_row_int - || \int_compare_p:nNn - \l__nicem_initial_i_int > \g__nicem_row_int - || \int_compare_p:nNn - \l__nicem_initial_j_int < 1 - || \int_compare_p:nNn - \l__nicem_initial_j_int > \g__nicem_column_total_int} - {\bool_set_true:N \l__nicem_initial_open_bool - \int_add:Nn \l__nicem_initial_i_int {#3} - \int_add:Nn \l__nicem_initial_j_int {#4} - \bool_set_true:N \l__nicem_stop_loop_bool} - {\__nicem_if_not_empty_cell:nnT - \l__nicem_initial_i_int - \l__nicem_initial_j_int - {\bool_set_true:N \l__nicem_stop_loop_bool}} - } - \bool_if:nT {\l__nicem_initial_open_bool || \l__nicem_final_open_bool} - \__nicem_create_extra_nodes: } -\prg_set_conditional:Npnn \__nicem_if_yet_drawn: {F} - {\tl_set:Nx \l_tmpa_tl {\int_use:N \l__nicem_initial_i_int- - \int_use:N \l__nicem_initial_j_int- - \int_use:N \l__nicem_final_i_int- - \int_use:N \l__nicem_final_j_int} - \seq_if_in:NVTF \g__nicem_yet_drawn_seq \l_tmpa_tl - {\prg_return_true:} - {\seq_gput_left:NV \g__nicem_yet_drawn_seq \l_tmpa_tl - \prg_return_false:}} -\cs_new_protected:Nn \__nicem_retrieve_coords:nn - {\dim_gzero_new:N \g__nicem_x_initial_dim - \dim_gzero_new:N \g__nicem_y_initial_dim - \dim_gzero_new:N \g__nicem_x_final_dim - \dim_gzero_new:N \g__nicem_y_final_dim - \begin{tikzpicture}[remember~picture] + \array + [ \l__nm_pos_env_str ] { #2 } + } + { \endarray + \bool_if:NF \l__nm_exterior_arraycolsep_bool + { \skip_horizontal:n { - \arraycolsep } } + \skip_horizontal:n + { \g__nm_right_margin_dim + \g__nm_extra_right_margin_dim } + } +\NewDocumentEnvironment { pNiceMatrix } { } + { \left( \begin{NiceMatrix} } + { \end{NiceMatrix} \right) } +\NewDocumentEnvironment { bNiceMatrix } { } + { \left[ \begin{NiceMatrix} } + { \end{NiceMatrix} \right] } +\NewDocumentEnvironment { BNiceMatrix } { } + { \left\{ \begin{NiceMatrix} } + { \end{NiceMatrix} \right\} } +\NewDocumentEnvironment { vNiceMatrix } { } + { \left\lvert \begin{NiceMatrix} } + { \end{NiceMatrix} \right\rvert } +\NewDocumentEnvironment { VNiceMatrix } {} + { \left\lVert \begin{NiceMatrix} } + { \end{NiceMatrix} \right\rVert } +\cs_new_protected:Nn \__nm_write_max_cell_width: + { + \bool_if:NF \l__nm_block_auto_columns_width_bool + { + \iow_now:Nn \@mainaux \ExplSyntaxOn + \iow_now:Nx \@mainaux + { + \cs_gset:cpn { __nm_max_cell_width_ \int_use:N \g__nm_env_int } + { \dim_use:N \g__nm_max_cell_width_dim } + } + \iow_now:Nx \@mainaux + { + \cs_gset:cpn { __nm_max_cell_width_ \g__nm_name_str } + { \dim_use:N \g__nm_max_cell_width_dim } + } + \iow_now:Nn \@mainaux \ExplSyntaxOff + } + } +\prg_set_conditional:Npnn \__nm_if_not_empty_cell:nn #1 #2 { T , TF } + { + \cs_if_free:cTF + { pgf@sh@ns@nm -\int_use:N \g__nm_env_int - \int_use:N #1 - \int_use:N #2 } + \prg_return_false: + { + \seq_if_in:NxTF \g__nm_empty_cells_seq { \int_use:N #1 - \int_use:N #2 } + \prg_return_false: + { + \begin { pgfpicture } + \tl_set:Nx \l_tmpa_tl + { nm - \int_use:N \g__nm_env_int - \int_use:N #1 - \int_use:N #2 } + \pgfpointanchor \l_tmpa_tl { east } + \dim_gset:Nn \g_tmpa_dim \pgf@x + \pgfpointanchor \l_tmpa_tl { west } + \dim_gset:Nn \g_tmpb_dim \pgf@x + \end { pgfpicture } + \dim_compare:nTF + { \dim_abs:n { \g_tmpb_dim - \g_tmpa_dim } < 0.5 pt } + \prg_return_false: + \prg_return_true: + } + } + } +\cs_new_protected:Nn \__nm_instruction_of_type:n + { + \tl_gput_right:Nx \g__nm_lines_to_draw_tl + { + \exp_not:c { __nm _ draw _ #1 : nn } + { \int_use:N \g__nm_row_int } + { \int_use:N \g__nm_column_int } + } + } +\cs_new_protected:Nn \__nm_after_array: + { + \group_begin: + \cs_if_exist:NT \tikz@library@external@loaded + { \tikzset { external / export = false } } + \int_gset_eq:NN \g__nm_column_int \g__nm_column_total_int + \bool_if:NT \l__nm_exterior_column_bool { \int_gdecr:N \g__nm_column_int } + \seq_gclear_new:N \g__nm_yet_drawn_seq + \bool_if:NT \l__nm_parallelize_diags_bool + { + \int_zero_new:N \l__nm_ddots_int + \int_zero_new:N \l__nm_iddots_int + \dim_zero_new:N \l__nm_delta_x_one_dim + \dim_zero_new:N \l__nm_delta_y_one_dim + \dim_zero_new:N \l__nm_delta_x_two_dim + \dim_zero_new:N \l__nm_delta_y_two_dim + } + \bool_if:NT \g__nm_extra_nodes_bool \__nm_create_extra_nodes: + \tl_if_empty:NF \g__nm_lines_to_draw_tl + { + \int_zero_new:N \l__nm_initial_i_int + \int_zero_new:N \l__nm_initial_j_int + \int_zero_new:N \l__nm_final_i_int + \int_zero_new:N \l__nm_final_j_int + \bool_set_false:N \l__nm_initial_open_bool + \bool_set_false:N \l__nm_final_open_bool + \g__nm_lines_to_draw_tl + } + \tl_gclear:N \g__nm_lines_to_draw_tl + \tikzset + { + every~picture / .style = + { + overlay , + remember~picture , + name~prefix = nm - \int_use:N \g__nm_env_int - + } + } + \cs_set_eq:NN \line \__nm_line:nn + \g__nm_code_after_tl + \group_end: + } +\cs_new_protected:Nn \__nm_find_extremities_of_line:nnnn + { + \int_set:Nn \l__nm_initial_i_int { #1 } + \int_set:Nn \l__nm_initial_j_int { #2 } + \int_set:Nn \l__nm_final_i_int { #1 } + \int_set:Nn \l__nm_final_j_int { #2 } + \bool_set_false:N \l__nm_initial_open_bool + \bool_set_false:N \l__nm_final_open_bool + \bool_set_false:N \l__nm_stop_loop_bool + \bool_do_until:Nn \l__nm_stop_loop_bool + { + \int_add:Nn \l__nm_final_i_int { #3 } + \int_add:Nn \l__nm_final_j_int { #4 } + \bool_if:nTF + { + \int_compare_p:nNn + \l__nm_final_i_int < { \l__nm_nb_first_row_int - 1 } + || \int_compare_p:nNn \l__nm_final_i_int > \g__nm_row_int + || \int_compare_p:nNn \l__nm_final_j_int < \c_one_int + || \int_compare_p:nNn \l__nm_final_j_int > \g__nm_column_total_int + || \int_compare_p:nNn \l__nm_final_j_int > \g__nm_column_int + && \int_compare_p:nNn { #4 } > \c_zero_int + } + { + \bool_set_true:N \l__nm_final_open_bool + \int_sub:Nn \l__nm_final_i_int { #3 } + \int_sub:Nn \l__nm_final_j_int { #4 } + \bool_set_true:N \l__nm_stop_loop_bool + } + { + \__nm_if_not_empty_cell:nnT \l__nm_final_i_int \l__nm_final_j_int + { \bool_set_true:N \l__nm_stop_loop_bool } + } + } + \bool_set_false:N \l__nm_stop_loop_bool + \bool_do_until:Nn \l__nm_stop_loop_bool + { + \int_sub:Nn \l__nm_initial_i_int { #3 } + \int_sub:Nn \l__nm_initial_j_int { #4 } + \bool_if:nTF + { + \int_compare_p:nNn \l__nm_initial_i_int < \l__nm_nb_first_row_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_total_int + } + { + \bool_set_true:N \l__nm_initial_open_bool + \int_add:Nn \l__nm_initial_i_int { #3 } + \int_add:Nn \l__nm_initial_j_int { #4 } + \bool_set_true:N \l__nm_stop_loop_bool + } + { + \__nm_if_not_empty_cell:nnT + \l__nm_initial_i_int \l__nm_initial_j_int + { \bool_set_true:N \l__nm_stop_loop_bool } + } + } + \bool_if:nT { \l__nm_initial_open_bool || \l__nm_final_open_bool } + \__nm_create_extra_nodes: + } +\prg_set_conditional:Npnn \__nm_if_yet_drawn: { F } + { + \tl_set:Nx \l_tmpa_tl + { + \int_use:N \l__nm_initial_i_int - + \int_use:N \l__nm_initial_j_int - + \int_use:N \l__nm_final_i_int - + \int_use:N \l__nm_final_j_int + } + \seq_if_in:NVTF \g__nm_yet_drawn_seq \l_tmpa_tl + \prg_return_true: + { + \seq_gput_left:NV \g__nm_yet_drawn_seq \l_tmpa_tl + \prg_return_false: + } + } +\cs_new_protected:Nn \__nm_retrieve_coords:nn + { + \dim_gzero_new:N \g__nm_x_initial_dim + \dim_gzero_new:N \g__nm_y_initial_dim + \dim_gzero_new:N \g__nm_x_final_dim + \dim_gzero_new:N \g__nm_y_final_dim + \begin { tikzpicture } [ remember~picture ] \tikz@parse@node\pgfutil@firstofone - (nm-\int_use:N \g__nicem_env_int- - \int_use:N \l__nicem_initial_i_int- - \int_use:N \l__nicem_initial_j_int #1) - \dim_gset:Nn \g__nicem_x_initial_dim \pgf@x - \dim_gset:Nn \g__nicem_y_initial_dim \pgf@y + ( nm - \int_use:N \g__nm_env_int - + \int_use:N \l__nm_initial_i_int - + \int_use:N \l__nm_initial_j_int #1 ) + \dim_gset:Nn \g__nm_x_initial_dim \pgf@x + \dim_gset:Nn \g__nm_y_initial_dim \pgf@y \tikz@parse@node\pgfutil@firstofone - (nm-\int_use:N \g__nicem_env_int- - \int_use:N \l__nicem_final_i_int- - \int_use:N \l__nicem_final_j_int #2) - \dim_gset:Nn \g__nicem_x_final_dim \pgf@x - \dim_gset:Nn \g__nicem_y_final_dim \pgf@y - \end{tikzpicture} } -\cs_generate_variant:Nn \__nicem_retrieve_coords:nn {xx} -\cs_new_protected:Nn \__nicem_draw_Ldots:nn - {\__nicem_find_extremities_of_line:nnnn {#1} {#2} 0 1 - \__nicem_if_yet_drawn:F \__nicem_actually_draw_Ldots:} -\cs_new_protected:Nn \__nicem_actually_draw_Ldots: - {\__nicem_retrieve_coords:xx {\bool_if:NTF \l__nicem_initial_open_bool - {-medium.base~west} - {.base~east}} - {\bool_if:NTF \l__nicem_final_open_bool - {-medium.base~east} - {.base~west}} - \bool_if:NT \l__nicem_initial_open_bool - {\dim_gset_eq:NN \g__nicem_y_initial_dim \g__nicem_y_final_dim } - \bool_if:NT \l__nicem_final_open_bool - {\dim_gset_eq:NN \g__nicem_y_final_dim \g__nicem_y_initial_dim } - \dim_gadd:Nn \g__nicem_y_initial_dim {0.53pt} - \dim_gadd:Nn \g__nicem_y_final_dim {0.53pt} - \__nicem_draw_tikz_line:} -\cs_new_protected:Nn \__nicem_draw_Cdots:nn - {\__nicem_find_extremities_of_line:nnnn {#1} {#2} 0 1 - \__nicem_if_yet_drawn:F - {\__nicem_retrieve_coords:xx {\bool_if:NTF \l__nicem_initial_open_bool - {-medium.mid~west} - {.mid~east}} - {\bool_if:NTF \l__nicem_final_open_bool - {-medium.mid~east} - {.mid~west}} - \bool_if:NT \l__nicem_initial_open_bool - {\dim_gset_eq:NN \g__nicem_y_initial_dim \g__nicem_y_final_dim } - \bool_if:NT \l__nicem_final_open_bool - {\dim_gset_eq:NN \g__nicem_y_final_dim \g__nicem_y_initial_dim } - \__nicem_draw_tikz_line:}} -\cs_new_protected:Nn \__nicem_draw_Vdots:nn - {\__nicem_find_extremities_of_line:nnnn {#1} {#2} 1 0 - \__nicem_if_yet_drawn:F - {\__nicem_retrieve_coords:xx {\bool_if:NTF \l__nicem_initial_open_bool - {-medium.north~west} - {.south~west}} - {\bool_if:NTF \l__nicem_final_open_bool - {-medium.south~west} - {.north~west}} - \bool_set:Nn \l_tmpa_bool - {\dim_compare_p:nNn \g__nicem_x_initial_dim = \g__nicem_x_final_dim} - \__nicem_retrieve_coords:xx {\bool_if:NTF \l__nicem_initial_open_bool - {-medium.north} - {.south}} - {\bool_if:NTF \l__nicem_final_open_bool - {-medium.south} - {.north}} - \bool_set:Nn \l_tmpb_bool - {\dim_compare_p:nNn \g__nicem_x_initial_dim = \g__nicem_x_final_dim} - \bool_if:NF \l_tmpb_bool - {\dim_gset:Nn \g__nicem_x_initial_dim - {\bool_if:NTF \l_tmpa_bool \dim_min:nn \dim_max:nn - \g__nicem_x_initial_dim \g__nicem_x_final_dim} - \dim_gset_eq:NN \g__nicem_x_final_dim \g__nicem_x_initial_dim} - \__nicem_draw_tikz_line:}} -\cs_new_protected:Nn \__nicem_draw_Ddots:nn - {\__nicem_find_extremities_of_line:nnnn {#1} {#2} 1 1 - \__nicem_if_yet_drawn:F - {\__nicem_retrieve_coords:xx {\bool_if:NTF \l__nicem_initial_open_bool - {-medium.north~west} - {.south~east}} - {\bool_if:NTF \l__nicem_final_open_bool - {-medium.south~east} - {.north~west}} - \bool_if:NT \l__nicem_parallelize_diags_bool - {\int_incr:N \l__nicem_ddots_int - \int_compare:nNnTF \l__nicem_ddots_int = 1 - {\dim_set:Nn \l__nicem_delta_x_one_dim {\g__nicem_x_final_dim - \g__nicem_x_initial_dim } - \dim_set:Nn \l__nicem_delta_y_one_dim {\g__nicem_y_final_dim - \g__nicem_y_initial_dim }} - {\dim_gset:Nn \g__nicem_y_final_dim - {\g__nicem_y_initial_dim + - (\g__nicem_x_final_dim - \g__nicem_x_initial_dim) - * \dim_ratio:nn \l__nicem_delta_y_one_dim \l__nicem_delta_x_one_dim }}} - \__nicem_draw_tikz_line:}} -\cs_new_protected:Nn \__nicem_draw_Iddots:nn - {\__nicem_find_extremities_of_line:nnnn {#1} {#2} 1 {-1} - \__nicem_if_yet_drawn:F - {\__nicem_retrieve_coords:xx {\bool_if:NTF \l__nicem_initial_open_bool - {-medium.north~east} - {.south~west}} - {\bool_if:NTF \l__nicem_final_open_bool - {-medium.south~west} - {.north~east}} - \bool_if:NT \l__nicem_parallelize_diags_bool - {\int_incr:N \l__nicem_iddots_int - \int_compare:nNnTF \l__nicem_iddots_int = 1 - {\dim_set:Nn \l__nicem_delta_x_two_dim {\g__nicem_x_final_dim - \g__nicem_x_initial_dim} - \dim_set:Nn \l__nicem_delta_y_two_dim {\g__nicem_y_final_dim - \g__nicem_y_initial_dim}} - {\dim_gset:Nn \g__nicem_y_final_dim - {\g__nicem_y_initial_dim + - (\g__nicem_x_final_dim - \g__nicem_x_initial_dim) - * \dim_ratio:nn \l__nicem_delta_y_two_dim \l__nicem_delta_x_two_dim }}} - \__nicem_draw_tikz_line:}} -\cs_new_protected:Nn \__nicem_draw_tikz_line: - { - \dim_zero_new:N \l__nicem_l_dim - \dim_set:Nn \l__nicem_l_dim - { \fp_to_dim:n - { sqrt( ( \dim_use:N \g__nicem_x_final_dim - -\dim_use:N \g__nicem_x_initial_dim) ^2 - +( \dim_use:N \g__nicem_y_final_dim - -\dim_use:N \g__nicem_y_initial_dim) ^2 )} - } - \dim_compare:nNnF \l__nicem_l_dim = \c_zero_dim - {\bool_if:NTF \l__nicem_initial_open_bool - {\bool_if:NTF \l__nicem_final_open_bool - {\int_set:Nn \l_tmpa_int - {\dim_ratio:nn {\l__nicem_l_dim} {0.45em}}} - {\int_set:Nn \l_tmpa_int - {\dim_ratio:nn {\l__nicem_l_dim - 0.3em} {0.45em}}}} - {\bool_if:NTF \l__nicem_final_open_bool - {\int_set:Nn \l_tmpa_int - {\dim_ratio:nn {\l__nicem_l_dim - 0.3em} {0.45em}}} - {\int_set:Nn \l_tmpa_int - {\dim_ratio:nn {\l__nicem_l_dim - 0.6em} {0.45em}}}} - \dim_set:Nn \l_tmpa_dim {(\g__nicem_x_final_dim - \g__nicem_x_initial_dim) - * \dim_ratio:nn {0.45em} \l__nicem_l_dim} - \dim_set:Nn \l_tmpb_dim {(\g__nicem_y_final_dim - \g__nicem_y_initial_dim) - * \dim_ratio:nn {0.45em} \l__nicem_l_dim} - \int_set:Nn \l_tmpb_int - {\bool_if:NTF \l__nicem_initial_open_bool - {\bool_if:NTF \l__nicem_final_open_bool 1 0} - {\bool_if:NTF \l__nicem_final_open_bool 2 1}} - \dim_gadd:Nn \g__nicem_x_initial_dim - { (\g__nicem_x_final_dim - \g__nicem_x_initial_dim) - * \dim_ratio:nn {\l__nicem_l_dim - 0.45 em * \l_tmpa_int} - {\l__nicem_l_dim * 2} - * \l_tmpb_int} - \dim_gadd:Nn \g__nicem_y_initial_dim - { (\g__nicem_y_final_dim - \g__nicem_y_initial_dim) - * \dim_ratio:nn {\l__nicem_l_dim - 0.45 em * \l_tmpa_int} - {\l__nicem_l_dim * 2} - * \l_tmpb_int} - \begin{tikzpicture}[overlay] - \int_step_inline:nnnn 0 1 \l_tmpa_int - { \pgfpathcircle{\pgfpoint{\g__nicem_x_initial_dim} - {\g__nicem_y_initial_dim}} - {0.53pt} - \pgfusepath{fill} - \dim_gadd:Nn \g__nicem_x_initial_dim \l_tmpa_dim - \dim_gadd:Nn \g__nicem_y_initial_dim \l_tmpb_dim } - \end{tikzpicture}} -} -\cs_set_eq:NN \__nicem_ldots \ldots -\cs_set_eq:NN \__nicem_cdots \cdots -\cs_set_eq:NN \__nicem_vdots \vdots -\cs_set_eq:NN \__nicem_ddots \ddots -\cs_set_eq:NN \__nicem_iddots \iddots -\cs_new_protected:Nn \__nicem_add_to_empty_cells: - {\seq_gput_right:Nx \g__nicem_empty_cells_seq - {\int_use:N \g__nicem_row_int- - \int_use:N \g__nicem_column_int}} -\NewDocumentCommand \__nicem_Ldots {s} - {\bool_if:nF {#1} {\__nicem_instruction_of_type:n {Ldots}} - \bool_if:NF \l__nicem_nullify_dots_bool {\phantom \__nicem_ldots} - \__nicem_add_to_empty_cells:} -\NewDocumentCommand \__nicem_Cdots {s} - {\bool_if:nF {#1} {\__nicem_instruction_of_type:n {Cdots}} - \bool_if:NF \l__nicem_nullify_dots_bool {\phantom \__nicem_cdots} - \__nicem_add_to_empty_cells:} -\NewDocumentCommand \__nicem_Vdots {s} - {\bool_if:nF {#1} {\__nicem_instruction_of_type:n {Vdots}} - \bool_if:NF \l__nicem_nullify_dots_bool {\phantom \__nicem_vdots} - \__nicem_add_to_empty_cells:} -\NewDocumentCommand \__nicem_Ddots {s} - {\bool_if:nF {#1} {\__nicem_instruction_of_type:n {Ddots}} - \bool_if:NF \l__nicem_nullify_dots_bool {\phantom \__nicem_ddots} - \__nicem_add_to_empty_cells:} -\NewDocumentCommand \__nicem_Iddots {s} - {\bool_if:nF {#1} {\__nicem_instruction_of_type:n {Iddots}} - \bool_if:NF \l__nicem_nullify_dots_bool {\phantom \__nicem_iddots} - \__nicem_add_to_empty_cells:} -\cs_new_protected:Nn \__nicem_Hspace: - {\__nicem_add_to_empty_cells: - \hspace} -\cs_set_eq:NN \__nicem_old_multicolumn \multicolumn -\cs_new:Nn \__nicem_multicolumn:nnn - {\__nicem_old_multicolumn{#1}{#2}{#3} - \int_compare:nNnT #1 > 1 - {\seq_gput_left:Nx \g__nicem_multicolumn_cells_seq - {\int_eval:n \g__nicem_row_int - - \int_use:N \g__nicem_column_int} - \seq_gput_left:Nn \g__nicem_multicolumn_sizes_seq {#1}} - \int_gadd:Nn \g__nicem_column_int {#1-1}} -\NewDocumentCommand {\__nicem_Hdotsfor} {O{} m} - {\tl_gput_right:Nx \g__nicem_lines_to_draw_tl - {\exp_not:N \__nicem_draw_Hdotsfor:nnn - {\int_use:N \g__nicem_row_int} - {\int_use:N \g__nicem_column_int} - {#2}} - \prg_replicate:nn {#2-1} {&}} -\cs_new_protected:Nn \__nicem_draw_Hdotsfor:nnn - {\bool_set_false:N \l__nicem_initial_open_bool - \bool_set_false:N \l__nicem_final_open_bool - \int_set:Nn \l__nicem_initial_i_int {#1} - \int_set:Nn \l__nicem_final_i_int {#1} - \int_compare:nNnTF #2 = 1 - {\int_set:Nn \l__nicem_initial_j_int 1 - \bool_set_true:N \l__nicem_initial_open_bool} - {\int_set:Nn \l_tmpa_int {#2-1} - \__nicem_if_not_empty_cell:nnTF \l__nicem_initial_i_int \l_tmpa_int - {\int_set:Nn \l__nicem_initial_j_int {#2-1}} - {\int_set:Nn \l__nicem_initial_j_int {#2} - \bool_set_true:N \l__nicem_initial_open_bool}} - \int_compare:nNnTF {#2+#3-1} = \g__nicem_column_int - {\int_set:Nn \l__nicem_final_j_int {#2+#3-1} - \bool_set_true:N \l__nicem_final_open_bool} - {\int_set:Nn \l_tmpa_int {#2+#3} - \__nicem_if_not_empty_cell:nnTF \l__nicem_final_i_int \l_tmpa_int - {\int_set:Nn \l__nicem_final_j_int {#2+#3}} - {\int_set:Nn \l__nicem_final_j_int {#2+#3-1} - \bool_set_true:N \l__nicem_final_open_bool}} - \bool_if:nT {\l__nicem_initial_open_bool || \l__nicem_final_open_bool} - \__nicem_create_extra_nodes: - \__nicem_actually_draw_Ldots:} -\cs_new_protected:Nn \__nicem_line:nn - {\dim_zero_new:N \g__nicem_x_initial_dim - \dim_zero_new:N \g__nicem_y_initial_dim - \dim_zero_new:N \g__nicem_x_final_dim - \dim_zero_new:N \g__nicem_y_final_dim - \__nicem_bool_new:N \l__nicem_initial_open_bool - \__nicem_bool_new:N \l__nicem_final_open_bool - \begin{tikzpicture} - \path~(#1)~--~(#2)~node[at~start]~(i)~{}~node[at~end]~(f)~{} ; - \tikz@parse@node\pgfutil@firstofone (i) - \dim_gset:Nn \g__nicem_x_initial_dim \pgf@x - \dim_gset:Nn \g__nicem_y_initial_dim \pgf@y - \tikz@parse@node\pgfutil@firstofone (f) - \dim_gset:Nn \g__nicem_x_final_dim \pgf@x - \dim_gset:Nn \g__nicem_y_final_dim \pgf@y - \end{tikzpicture} - \__nicem_draw_tikz_line:} -\bool_new:N \l__nicem_block_auto_columns_width_bool -\keys_define:nn {NiceMatrix/NiceMatrixBlock} - {auto-columns-width .code:n = - {\bool_set_true:N \l__nicem_block_auto_columns_width_bool - \dim_gzero_new:N \g__nicem_max_cell_width_dim - \bool_set_true:N \l__nicem_auto_columns_width_bool}} -\NewDocumentEnvironment {NiceMatrixBlock} {!O{}} - {\keys_set:nn {NiceMatrix/NiceMatrixBlock} {#1} - \int_zero_new:N \l__nicem_first_env_block_int - \int_set:Nn \l__nicem_first_env_block_int {\g__nicem_env_int + 1}} - {\bool_if:NT \l__nicem_block_auto_columns_width_bool - {\iow_now:Nn \@mainaux \ExplSyntaxOn - \int_step_inline:nnnn \l__nicem_first_env_block_int 1 \g__nicem_env_int - {\iow_now:Nx \@mainaux - {\cs_gset:cpn {__nicem_max_cell_width_##1} - {\dim_use:N \g__nicem_max_cell_width_dim}}} - \iow_now:Nn \@mainaux \ExplSyntaxOff}} -\keys_define:nn {NiceMatrix/NiceArrayC} - {parallelize-diags .bool_set:N = \l__nicem_parallelize_diags_bool, - parallelize-diags .default:n = true, - renew-dots .bool_set:N = \l__nicem_renew_dots_bool, - renew-dots .default:n = true, - nullify-dots .bool_set:N = \l__nicem_nullify_dots_bool , - nullify-dots .default:n = true, - code-for-last-col .tl_set:N = \l__nicem_code_for_last_col_tl, - code-for-last-col .value_required:n = true, - columns-width .code:n = \str_if_eq:nnTF {#1} {auto} - {\bool_set_true:N - \l__nicem_auto_columns_width_bool} - {\dim_set:Nn \l__nicem_columns_width_dim {#1}}, - columns-width .value_required:n = true, - name .code:n = {\seq_if_in:NnTF \g__nicem_names_seq {#1} - {\__nicem_error:nn {Duplicate~name} {#1}} - {\seq_gput_left:Nn \g__nicem_names_seq {#1}} - \tl_set:Nn \l__nicem_name_tl {#1}}, - name .value_required:n = true, - code-after .tl_set:N = \l__nicem_code_after_tl, - code-after .initial:n = \c_empty_tl, - code-after .value_required:n = true, - create-extra-nodes .bool_set:N = \l__nicem_extra_nodes_bool, - create-extra-nodes .default:n = true, - left-margin .dim_set:N = \l__nicem_left_margin_dim, - left-margin .default:n = \arraycolsep, - right-margin .dim_set:N = \l__nicem_right_margin_dim, - right-margin .default:n = \arraycolsep, - extra-left-margin .dim_set:N = \l__nicem_extra_left_margin_dim, - extra-right-margin .dim_set:N = \l__nicem_extra_right_margin_dim, - unknown .code:n = \__nicem_error:n {Unknown~option~for~NiceArrayC}} -\msg_new:nnnn {nicematrix} - {Unknown~option~for~NiceArrayC} - {The~option~"\tl_use:N\l_keys_key_tl"~is~unknown~for~the~environment~ - \{\@currenvir\}.\\ - If~you~go~on,~it~will~be~ignored.\\ - For~a~list~of~the~available~options,~type~H~<return>.} - {The~available~options~are~(in~alphabetic~order):~ - code-after,~ - code-for-last-col,~ - columns-width,~ - create-extra-nodes,~ - extra-left-margin,~ - extra-right-margin,~ - left-margin,~ - name,~ - nullify-dots,~ - parallelize-diags~ - renew-dots~ - and~right-margin.} -\cs_new_protected:Nn \__nicem_NiceArrayC:n - {\bool_set_true:N \l__nicem_exterior_column_bool - \begin{NiceArray} - {#1 - >{\int_gincr:N \g__nicem_column_int - \int_gset:Nn \g__nicem_column_total_int - {\int_max:nn \g__nicem_column_total_int \g__nicem_column_int} - \hbox_set:Nw \l_tmpa_box $ % $ - \l__nicem_code_for_last_col_tl - } - l - <{ $ % $ - \hbox_set_end: - \dim_gset:Nn \g__nicem_width_last_col_dim - {\dim_max:nn \g__nicem_width_last_col_dim - {\box_wd:N \l_tmpa_box}} - \skip_horizontal:n {-2\arraycolsep} - \hbox_overlap_right:n - {\skip_horizontal:n - { 2\arraycolsep + \l__nicem_right_margin_dim - + \l__nicem_extra_right_margin_dim} - \tikz[remember~picture, inner~sep=0pt, minimum~width=0pt, baseline] - \node [anchor=base, - name = nm-\int_use:N \g__nicem_env_int- - \int_use:N \g__nicem_row_int- - \int_use:N \g__nicem_column_int, - alias = \tl_if_empty:NF \l__nicem_name_tl - {\l__nicem_name_tl- - \int_use:N \g__nicem_row_int- - \int_use:N \g__nicem_column_int}] - {\box_use:N \l_tmpa_box} ; } }}} -\NewDocumentEnvironment{NiceArrayCwithDelims} {mm O{} m !O{}} - {\dim_gzero_new:N \g__nicem_width_last_col_dim - \keys_set:nn {NiceMatrix/NiceArrayC} {#3,#5} - \bool_set_false:N \l__nicem_exterior_arraycolsep_bool - \tl_set:Nn \l__nicem_pos_env_tl c - \left#1 - \__nicem_NiceArrayC:n {#4}} - {\end{NiceArray} - \right#2 - \skip_horizontal:n \g__nicem_width_last_col_dim - } -\NewDocumentEnvironment {pNiceArrayC} {} - {\NiceArrayCwithDelims{(}{)}} - {\endNiceArrayCwithDelims} -\NewDocumentEnvironment {vNiceArrayC} {} - {\NiceArrayCwithDelims{|}{|}} - {\endNiceArrayCwithDelims} -\NewDocumentEnvironment {VNiceArrayC} {} - {\NiceArrayCwithDelims{\|}{\|}} - {\endNiceArrayCwithDelims} -\NewDocumentEnvironment {bNiceArrayC} {} - {\NiceArrayCwithDelims{[}{]}} - {\endNiceArrayCwithDelims} -\NewDocumentEnvironment {BNiceArrayC} {} - {\NiceArrayCwithDelims{\{}{\}}} - {\endNiceArrayCwithDelims} -\keys_define:nn {NiceMatrix/NiceArrayRC} - {parallelize-diags .bool_set:N = \l__nicem_parallelize_diags_bool, - parallelize-diags .default:n = true, - renew-dots .bool_set:N = \l__nicem_renew_dots_bool, - renew-dots .default:n = true, - nullify-dots .bool_set:N = \l__nicem_nullify_dots_bool , - nullify-dots .default:n = true, - code-for-first-row .tl_set:N = \l__nicem_code_for_first_row_tl, - code-for-first-row .value_required:n = true, - code-for-last-col .tl_set:N = \l__nicem_code_for_last_col_tl, - code-for-last-col .value_required:n = true, - columns-width .code:n = \str_if_eq:nnTF {#1} {auto} - {\bool_set_true:N - \l__nicem_auto_columns_width_bool} - {\dim_set:Nn \l__nicem_columns_width_dim {#1}}, - columns-width .value_required:n = true, - name .code:n = {\seq_if_in:NnTF \g__nicem_names_seq {#1} - {\__nicem_error:nn {Duplicate~name} {#1}} - {\seq_gput_left:Nn \g__nicem_names_seq {#1}} - \tl_set:Nn \l__nicem_name_tl {#1}}, - code-after .tl_set:N = \l__nicem_code_after_tl, - create-extra-nodes .bool_set:N = \l__nicem_extra_nodes_bool, - create-extra-nodes .default:n = true, - left-margin .dim_set:N = \l__nicem_left_margin_dim, - left-margin .default:n = \arraycolsep, - right-margin .dim_set:N = \l__nicem_right_margin_dim, - right-margin .default:n = \arraycolsep, - extra-left-margin .dim_set:N = \l__nicem_extra_left_margin_dim, - extra-right-margin .dim_set:N = \l__nicem_extra_right_margin_dim, - unknown .code:n = \__nicem_error:n {Unknown~option~for~NiceArrayRC}} -\msg_new:nnnn {nicematrix} - {Unknown~option~for~NiceArrayRC} - {The~option~"\tl_use:N\l_keys_key_tl"~is~unknown~for~the~environment~ - \{\@currenvir\}.\\ - If~you~go~on,~it~will~be~ignored.\\ - For~a~list~of~the~available~options,~type~H~<return>.} - {The~available~options~are~(in~alphabetic~order):~ - code-after,~ - code-for-last-col,~ - code-for-first-row,~ - columns-width,~ - create-extra-nodes,~ - extra-left-margin,~ - extra-right-margin,~ - left-margin,~ - name,~ - nullify-dots,~ - parallelize-diags,~ - renew-dots~ - and~right-margin.} -\NewDocumentEnvironment {NiceArrayRCwithDelims} {mm O{} m !O{}} - {\int_zero:N \l__nicem_nb_first_row_int - \dim_gzero_new:N \g__nicem_width_last_col_dim - \keys_set:nn {NiceMatrix/NiceArrayRC} {#3,#5} - \bool_set_false:N \l__nicem_exterior_arraycolsep_bool - \tl_set:Nn \l__nicem_pos_env_tl c - \box_clear_new:N \l__nicem_the_array_box - \hbox_set:Nw \l__nicem_the_array_box - $ % $ - \__nicem_NiceArrayC:n {#4}} - { \end{NiceArray} - $ % $ - \hbox_set_end: - \dim_set:Nn \l_tmpa_dim - { ( \dim_max:nn {12pt} - {\g__nicem_max_ht_row_one_dim + \g__nicem_max_dp_row_zero_dim}) - + \g__nicem_max_ht_row_zero_dim - - \g__nicem_max_ht_row_one_dim } - \hbox_set:Nn \l_tmpa_box - {$ % $ - \left#1 - \vcenter {\skip_vertical:n {- \l_tmpa_dim} - \box_use_drop:N \l__nicem_the_array_box} - \right#2 - $ % $ - \skip_horizontal:n \g__nicem_width_last_col_dim} - \box_set_ht:Nn \l_tmpa_box {\box_ht:N \l_tmpa_box + \l_tmpa_dim} - \box_use_drop:N \l_tmpa_box - } -\NewDocumentEnvironment {pNiceArrayRC} {} - {\NiceArrayRCwithDelims{(}{)}} - {\endNiceArrayRCwithDelims} -\NewDocumentEnvironment {bNiceArrayRC} {} - {\NiceArrayRCwithDelims{[}{]}} - {\endNiceArrayRCwithDelims} -\NewDocumentEnvironment {vNiceArrayRC} {} - {\NiceArrayRCwithDelims{|}{|}} - {\endNiceArrayRCwithDelims} -\NewDocumentEnvironment {VNiceArrayRC} {} - {\NiceArrayRCwithDelims{\|}{\|}} - {\endNiceArrayRCwithDelims} -\NewDocumentEnvironment {BNiceArrayRC} {} - {\NiceArrayRCwithDelims{\{}{\}}} - {\endNiceArrayRCwithDelims} -\cs_generate_variant:Nn \dim_min:nn {vn} -\cs_generate_variant:Nn \dim_max:nn {vn} -\cs_new_protected:Nn \__nicem_create_extra_nodes: - {\begin{tikzpicture}[remember~picture,overlay] - \int_step_variable:nnnNn \l__nicem_nb_first_row_int 1 \g__nicem_row_int \__nicem_i - {\dim_zero_new:c {l__nicem_row_\__nicem_i _min_dim} - \dim_set_eq:cN {l__nicem_row_\__nicem_i _min_dim} \c_max_dim - \dim_zero_new:c {l__nicem_row_\__nicem_i _max_dim} - \dim_set:cn {l__nicem_row_\__nicem_i _max_dim} {-\c_max_dim}} - \int_step_variable:nnnNn 1 1 \g__nicem_column_total_int \__nicem_j - {\dim_zero_new:c {l__nicem_column_\__nicem_j _min_dim} - \dim_set_eq:cN {l__nicem_column_\__nicem_j _min_dim} \c_max_dim - \dim_zero_new:c {l__nicem_column_\__nicem_j _max_dim} - \dim_set:cn {l__nicem_column_\__nicem_j _max_dim} {-\c_max_dim}} - \int_step_variable:nnnNn \l__nicem_nb_first_row_int 1 \g__nicem_row_int \__nicem_i - {\int_step_variable:nnnNn 1 1 \g__nicem_column_total_int \__nicem_j - {\cs_if_exist:cT {pgf@sh@ns@nm-\int_use:N \g__nicem_env_int-\__nicem_i-\__nicem_j} - {\tikz@parse@node \pgfutil@firstofone - (nm-\int_use:N \g__nicem_env_int-\__nicem_i-\__nicem_j.south~west) - \dim_set:cn {l__nicem_row_\__nicem_i _min_dim} - {\dim_min:vn {l__nicem_row_\__nicem_i _min_dim} \pgf@y} - \seq_if_in:NxF \g__nicem_multicolumn_cells_seq {\__nicem_i-\__nicem_j} - {\dim_set:cn {l__nicem_column_\__nicem_j _min_dim} - {\dim_min:vn {l__nicem_column_\__nicem_j _min_dim} \pgf@x}} - \tikz@parse@node \pgfutil@firstofone - (nm-\int_use:N \g__nicem_env_int-\__nicem_i-\__nicem_j.north~east) - \dim_set:cn {l__nicem_row_\__nicem_i _max_dim} - {\dim_max:vn {l__nicem_row_\__nicem_i _max_dim} \pgf@y} - \seq_if_in:NxF \g__nicem_multicolumn_cells_seq {\__nicem_i-\__nicem_j} - {\dim_set:cn {l__nicem_column_\__nicem_j _max_dim} - {\dim_max:vn {l__nicem_column_\__nicem_j _max_dim} \pgf@x}}} - }} - \tikzset{name~suffix = -medium} - \__nicem_create_nodes: - \int_set:Nn \l__nicem_nb_first_row_int 1 - \int_step_variable:nnnNn 1 1 {\g__nicem_row_int-1} \__nicem_i - {\dim_set:cn {l__nicem_row_\__nicem_i _min_dim} - {( \dim_use:c {l__nicem_row_\__nicem_i _min_dim} - + \dim_use:c {l__nicem_row_\int_eval:n{\__nicem_i+1}_max_dim}) / 2} - \dim_set_eq:cc {l__nicem_row_\int_eval:n{\__nicem_i+1}_max_dim} - {l__nicem_row_\__nicem_i _min_dim} } - \int_step_variable:nnnNn 1 1 {\g__nicem_column_int-1} \__nicem_j - {\dim_set:cn {l__nicem_column_\__nicem_j _max_dim} - {( \dim_use:c {l__nicem_column_\__nicem_j _max_dim} - + \dim_use:c {l__nicem_column_\int_eval:n{\__nicem_j+1}_min_dim}) / 2} - \dim_set_eq:cc {l__nicem_column_\int_eval:n{\__nicem_j+1}_min_dim} - {l__nicem_column_\__nicem_j _max_dim} } - \dim_sub:cn {l__nicem_column_1_min_dim} \g__nicem_left_margin_dim - \dim_add:cn {l__nicem_column_\int_use:N \g__nicem_column_int _max_dim} - \g__nicem_right_margin_dim - \tikzset{name~suffix = -large} - \__nicem_create_nodes: - \end{tikzpicture} - \cs_set:Nn \__nicem_create_extra_nodes: {}} -\cs_new_protected:Nn \__nicem_create_nodes: - {\int_step_variable:nnnNn \l__nicem_nb_first_row_int 1 \g__nicem_row_int \__nicem_i - {\int_step_variable:nnnNn 1 1 \g__nicem_column_total_int \__nicem_j - {\coordinate (__nicem~south~west) - at (\dim_use:c {l__nicem_column_\__nicem_j _min_dim}, - \dim_use:c {l__nicem_row_\__nicem_i _min_dim}) ; - \coordinate (__nicem~north~east) - at (\dim_use:c {l__nicem_column_\__nicem_j _max_dim}, - \dim_use:c {l__nicem_row_\__nicem_i _max_dim}) ; - \draw node [fit = {(__nicem~south~west) (__nicem~north~east)}, - inner~sep=0pt, - name = nm-\int_use:N \g__nicem_env_int-\__nicem_i-\__nicem_j, - alias = \tl_if_empty:NF \g__nicem_name_tl - {\tl_use:N \g__nicem_name_tl-\__nicem_i-\__nicem_j}] - {} ; + ( nm - \int_use:N \g__nm_env_int - + \int_use:N \l__nm_final_i_int - + \int_use:N \l__nm_final_j_int #2 ) + \dim_gset:Nn \g__nm_x_final_dim \pgf@x + \dim_gset:Nn \g__nm_y_final_dim \pgf@y + \end { tikzpicture } + } +\cs_generate_variant:Nn \__nm_retrieve_coords:nn { x x } +\cs_new_protected:Nn \__nm_draw_Ldots:nn + { + \__nm_find_extremities_of_line:nnnn { #1 } { #2 } \c_zero_int \c_one_int + \__nm_if_yet_drawn:F \__nm_actually_draw_Ldots: + } +\cs_new_protected:Nn \__nm_actually_draw_Ldots: + { + \__nm_retrieve_coords:xx + { + \bool_if:NTF \l__nm_initial_open_bool + { - medium.base~west } + { .base~east } + } + { + \bool_if:NTF \l__nm_final_open_bool + { - medium.base~east } + { . base~west } + } + \bool_if:NT \l__nm_initial_open_bool + { \dim_gset_eq:NN \g__nm_y_initial_dim \g__nm_y_final_dim } + \bool_if:NT \l__nm_final_open_bool + { \dim_gset_eq:NN \g__nm_y_final_dim \g__nm_y_initial_dim } + \dim_gadd:Nn \g__nm_y_initial_dim { 0.53 pt } + \dim_gadd:Nn \g__nm_y_final_dim { 0.53 pt } + \__nm_draw_tikz_line: + } +\cs_new_protected:Nn \__nm_draw_Cdots:nn + { + \__nm_find_extremities_of_line:nnnn { #1 } { #2 } \c_zero_int \c_one_int + \__nm_if_yet_drawn:F + { + \__nm_retrieve_coords:xx + { + \bool_if:NTF \l__nm_initial_open_bool + { - medium.mid~west } + { .mid~east } + } + { + \bool_if:NTF \l__nm_final_open_bool + { - medium.mid~east } + { .mid~west } + } + \bool_if:NT \l__nm_initial_open_bool + { \dim_gset_eq:NN \g__nm_y_initial_dim \g__nm_y_final_dim } + \bool_if:NT \l__nm_final_open_bool + { \dim_gset_eq:NN \g__nm_y_final_dim \g__nm_y_initial_dim } + \__nm_draw_tikz_line: + } + } +\cs_new_protected:Nn \__nm_draw_Vdots:nn + { + \__nm_find_extremities_of_line:nnnn { #1 } { #2 } \c_one_int \c_zero_int + \__nm_if_yet_drawn:F + { \__nm_retrieve_coords:xx + { + \bool_if:NTF \l__nm_initial_open_bool + { - medium.north~west } + { .south~west } + } + { + \bool_if:NTF \l__nm_final_open_bool + { - medium.south~west } + { .north~west } + } + \bool_set:Nn \l_tmpa_bool + { \dim_compare_p:nNn \g__nm_x_initial_dim = \g__nm_x_final_dim } + \__nm_retrieve_coords:xx + { + \bool_if:NTF \l__nm_initial_open_bool + { - medium.north } + { .south } + } + { + \bool_if:NTF \l__nm_final_open_bool + { - medium.south } + { .north } + } + \bool_set:Nn \l_tmpb_bool + { \dim_compare_p:nNn \g__nm_x_initial_dim = \g__nm_x_final_dim } + \bool_if:NF \l_tmpb_bool + { + \dim_gset:Nn \g__nm_x_initial_dim + { + \bool_if:NTF \l_tmpa_bool \dim_min:nn \dim_max:nn + \g__nm_x_initial_dim \g__nm_x_final_dim } + \dim_gset_eq:NN \g__nm_x_final_dim \g__nm_x_initial_dim } - \__nicem_seq_mapthread_function:NNN \g__nicem_multicolumn_cells_seq - \g__nicem_multicolumn_sizes_seq - \__nicem_node_for_multicolumn:nn + \__nm_draw_tikz_line: } -\cs_set:Npn \__nicem_extract_coords: #1-#2\q_stop{\cs_set:Npn \__nicem_i {#1} - \cs_set:Npn \__nicem_j {#2}} -\cs_new_protected:Nn \__nicem_node_for_multicolumn:nn - {\__nicem_extract_coords: #1\q_stop - \coordinate (__nicem~south~west) - at (\dim_use:c {l__nicem_column_\__nicem_j _min_dim}, - \dim_use:c {l__nicem_row_\__nicem_i _min_dim}) ; - \coordinate (__nicem~north~east) - at (\dim_use:c {l__nicem_column_\int_eval:n{\__nicem_j+#2-1}_max_dim}, - \dim_use:c {l__nicem_row_\__nicem_i _max_dim}) ; - \draw node [fit = {(__nicem~south~west) (__nicem~north~east)}, - inner~sep=0pt, - name = nm-\int_use:N \g__nicem_env_int-\__nicem_i-\__nicem_j, - alias = \tl_if_empty:NF \g__nicem_name_tl - {\tl_use:N \g__nicem_name_tl-\__nicem_i-\__nicem_j}] - {} ; + } +\cs_new_protected:Nn \__nm_draw_Ddots:nn + { + \__nm_find_extremities_of_line:nnnn { #1 } { #2 } \c_one_int \c_one_int + \__nm_if_yet_drawn:F + { + \__nm_retrieve_coords:xx + { + \bool_if:NTF \l__nm_initial_open_bool + { - medium.north~west } + { .south~east } + } + { + \bool_if:NTF \l__nm_final_open_bool + { - medium.south~east } + { .north~west } + } + \bool_if:NT \l__nm_parallelize_diags_bool + { + \int_incr:N \l__nm_ddots_int + \int_compare:nNnTF \l__nm_ddots_int = \c_one_int + { + \dim_set:Nn \l__nm_delta_x_one_dim + { \g__nm_x_final_dim - \g__nm_x_initial_dim } + \dim_set:Nn \l__nm_delta_y_one_dim + { \g__nm_y_final_dim - \g__nm_y_initial_dim } + } + { + \dim_gset:Nn \g__nm_y_final_dim + { + \g__nm_y_initial_dim + + ( \g__nm_x_final_dim - \g__nm_x_initial_dim ) * + \dim_ratio:nn \l__nm_delta_y_one_dim \l__nm_delta_x_one_dim + } + } + } + \__nm_draw_tikz_line: + } + } +\cs_new_protected:Nn \__nm_draw_Iddots:nn + { + \__nm_find_extremities_of_line:nnnn { #1 } { #2 } 1 { -1 } + \__nm_if_yet_drawn:F + { \__nm_retrieve_coords:xx + { + \bool_if:NTF \l__nm_initial_open_bool + { - medium.north~east } + { .south~west } + } + { + \bool_if:NTF \l__nm_final_open_bool + { - medium.south~west } + { .north~east } + } + \bool_if:NT \l__nm_parallelize_diags_bool + { + \int_incr:N \l__nm_iddots_int + \int_compare:nNnTF \l__nm_iddots_int = \c_one_int + { + \dim_set:Nn \l__nm_delta_x_two_dim + { \g__nm_x_final_dim - \g__nm_x_initial_dim } + \dim_set:Nn \l__nm_delta_y_two_dim + { \g__nm_y_final_dim - \g__nm_y_initial_dim } + } + { + \dim_gset:Nn \g__nm_y_final_dim + { + \g__nm_y_initial_dim + + ( \g__nm_x_final_dim - \g__nm_x_initial_dim ) * + \dim_ratio:nn \l__nm_delta_y_two_dim \l__nm_delta_x_two_dim + } + } + } + \__nm_draw_tikz_line: + } + } +\cs_new_protected:Nn \__nm_draw_tikz_line: + { + \dim_zero_new:N \l__nm_l_dim + \dim_set:Nn \l__nm_l_dim + { + \fp_to_dim:n + { + sqrt + ( ( \dim_use:N \g__nm_x_final_dim + - \dim_use:N \g__nm_x_initial_dim + ) ^ 2 + + + ( \dim_use:N \g__nm_y_final_dim + - \dim_use:N \g__nm_y_initial_dim + ) ^ 2 + ) + } + } + \dim_compare:nNnF \l__nm_l_dim = \c_zero_dim + { + \bool_if:NTF \l__nm_initial_open_bool + { + \bool_if:NTF \l__nm_final_open_bool + { + \int_set:Nn \l_tmpa_int + { \dim_ratio:nn \l__nm_l_dim { 0.45 em } } + } + { + \int_set:Nn \l_tmpa_int + { \dim_ratio:nn { \l__nm_l_dim - 0.3 em } { 0.45 em } } + } + } + { + \bool_if:NTF \l__nm_final_open_bool + { + \int_set:Nn \l_tmpa_int + { \dim_ratio:nn { \l__nm_l_dim - 0.3 em } { 0.45 em } } + } + { \int_set:Nn \l_tmpa_int + { \dim_ratio:nn { \l__nm_l_dim - 0.6 em } { 0.45 em }} + } + } + \dim_set:Nn \l_tmpa_dim + { + ( \g__nm_x_final_dim - \g__nm_x_initial_dim ) * + \dim_ratio:nn { 0.45 em } \l__nm_l_dim + } + \dim_set:Nn \l_tmpb_dim + { + ( \g__nm_y_final_dim - \g__nm_y_initial_dim ) * + \dim_ratio:nn { 0.45 em } \l__nm_l_dim + } + \int_set:Nn \l_tmpb_int + { + \bool_if:NTF \l__nm_initial_open_bool + { \bool_if:NTF \l__nm_final_open_bool 1 0 } + { \bool_if:NTF \l__nm_final_open_bool 2 1 } + } + \dim_gadd:Nn \g__nm_x_initial_dim + { + ( \g__nm_x_final_dim - \g__nm_x_initial_dim ) * + \dim_ratio:nn + { \l__nm_l_dim - 0.45 em * \l_tmpa_int } { \l__nm_l_dim * 2 } * + \l_tmpb_int + } + \dim_gadd:Nn \g__nm_y_initial_dim + { + ( \g__nm_y_final_dim - \g__nm_y_initial_dim ) * + \dim_ratio:nn + { \l__nm_l_dim - 0.45 em * \l_tmpa_int } + { \l__nm_l_dim * 2 } * + \l_tmpb_int + } + \begin { tikzpicture } [ overlay ] + \int_step_inline:nnnn 0 1 \l_tmpa_int + { + \pgfpathcircle + { \pgfpoint { \g__nm_x_initial_dim } { \g__nm_y_initial_dim } } + { 0.53 pt } + \pgfusepath { fill } + \dim_gadd:Nn \g__nm_x_initial_dim \l_tmpa_dim + \dim_gadd:Nn \g__nm_y_initial_dim \l_tmpb_dim + } + \end { tikzpicture } + } + } +\cs_set_eq:NN \__nm_ldots \ldots +\cs_set_eq:NN \__nm_cdots \cdots +\cs_set_eq:NN \__nm_vdots \vdots +\cs_set_eq:NN \__nm_ddots \ddots +\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_row_int - \int_use:N \g__nm_column_int } + } +\NewDocumentCommand \__nm_Ldots { s } + { + \bool_if:nF { #1 } { \__nm_instruction_of_type:n { Ldots } } + \bool_if:NF \l__nm_nullify_dots_bool { \phantom \__nm_ldots } + \__nm_add_to_empty_cells: + } +\NewDocumentCommand \__nm_Cdots { s } + { + \bool_if:nF { #1 } { \__nm_instruction_of_type:n { Cdots } } + \bool_if:NF \l__nm_nullify_dots_bool { \phantom \__nm_cdots } + \__nm_add_to_empty_cells: + } +\NewDocumentCommand \__nm_Vdots { s } + { + \bool_if:nF { #1 } { \__nm_instruction_of_type:n { Vdots } } + \bool_if:NF \l__nm_nullify_dots_bool { \phantom \__nm_vdots } + \__nm_add_to_empty_cells: + } +\NewDocumentCommand \__nm_Ddots { s } + { + \bool_if:nF { #1 } { \__nm_instruction_of_type:n { Ddots } } + \bool_if:NF \l__nm_nullify_dots_bool { \phantom \__nm_ddots } + \__nm_add_to_empty_cells: + } +\NewDocumentCommand \__nm_Iddots { s } + { + \bool_if:nF { #1 } { \__nm_instruction_of_type:n { Iddots } } + \bool_if:NF \l__nm_nullify_dots_bool { \phantom \__nm_iddots } + \__nm_add_to_empty_cells: + } +\cs_new_protected:Nn \__nm_Hspace: + { + \__nm_add_to_empty_cells: + \hspace + } +\cs_set_eq:NN \__nm_old_multicolumn \multicolumn +\cs_new:Nn \__nm_multicolumn:nnn + { + \__nm_old_multicolumn { #1 } { #2 } { #3 } + \int_compare:nNnT #1 > 1 + { + \seq_gput_left:Nx \g__nm_multicolumn_cells_seq + { \int_eval:n \g__nm_row_int - \int_use:N \g__nm_column_int } + \seq_gput_left:Nn \g__nm_multicolumn_sizes_seq { #1 } + } + \int_gadd:Nn \g__nm_column_int { #1 - 1 } + } +\NewDocumentCommand \__nm_Hdotsfor { O { } m } + { + \tl_gput_right:Nx \g__nm_lines_to_draw_tl + { + \exp_not:N \__nm_draw_Hdotsfor:nnn + { \int_use:N \g__nm_row_int } + { \int_use:N \g__nm_column_int } + { #2 } + } + \prg_replicate:nn { #2 - 1 } { & } + } +\cs_new_protected:Nn \__nm_draw_Hdotsfor:nnn + { + \bool_set_false:N \l__nm_initial_open_bool + \bool_set_false:N \l__nm_final_open_bool + \int_set:Nn \l__nm_initial_i_int { #1 } + \int_set:Nn \l__nm_final_i_int { #1 } + \int_compare:nNnTF #2 = 1 + { + \int_set:Nn \l__nm_initial_j_int 1 + \bool_set_true:N \l__nm_initial_open_bool + } + { + \int_set:Nn \l_tmpa_int { #2 - 1 } + \__nm_if_not_empty_cell:nnTF \l__nm_initial_i_int \l_tmpa_int + { \int_set:Nn \l__nm_initial_j_int { #2 - 1 } } + { + \int_set:Nn \l__nm_initial_j_int {#2} + \bool_set_true:N \l__nm_initial_open_bool + } + } + \int_compare:nNnTF { #2 + #3 -1 } = \g__nm_column_int + { + \int_set:Nn \l__nm_final_j_int { #2 + #3 - 1 } + \bool_set_true:N \l__nm_final_open_bool + } + { + \int_set:Nn \l_tmpa_int { #2 + #3 } + \__nm_if_not_empty_cell:nnTF \l__nm_final_i_int \l_tmpa_int + { \int_set:Nn \l__nm_final_j_int { #2 + #3 } } + { + \int_set:Nn \l__nm_final_j_int { #2 + #3 - 1 } + \bool_set_true:N \l__nm_final_open_bool + } + } + \bool_if:nT { \l__nm_initial_open_bool || \l__nm_final_open_bool } + \__nm_create_extra_nodes: + \__nm_actually_draw_Ldots: + } +\cs_new_protected:Nn \__nm_line:nn + { + \dim_zero_new:N \g__nm_x_initial_dim + \dim_zero_new:N \g__nm_y_initial_dim + \dim_zero_new:N \g__nm_x_final_dim + \dim_zero_new:N \g__nm_y_final_dim + \bool_set_false:N \l__nm_initial_open_bool + \bool_set_false:N \l__nm_final_open_bool + \begin { tikzpicture } + \path~(#1)~--~(#2)~node[at~start]~(i)~{}~node[at~end]~(f)~{} ; + \tikz@parse@node \pgfutil@firstofone ( i ) + \dim_gset:Nn \g__nm_x_initial_dim \pgf@x + \dim_gset:Nn \g__nm_y_initial_dim \pgf@y + \tikz@parse@node \pgfutil@firstofone ( f ) + \dim_gset:Nn \g__nm_x_final_dim \pgf@x + \dim_gset:Nn \g__nm_y_final_dim \pgf@y + \end { tikzpicture } + \__nm_draw_tikz_line: + } +\bool_new:N \l__nm_block_auto_columns_width_bool +\keys_define:nn { NiceMatrix / NiceMatrixBlock } + { + auto-columns-width .code:n = + { + \bool_set_true:N \l__nm_block_auto_columns_width_bool + \dim_gzero_new:N \g__nm_max_cell_width_dim + \bool_set_true:N \l__nm_auto_columns_width_bool + } + } +\NewDocumentEnvironment { NiceMatrixBlock } { ! O { } } + { + \keys_set:nn { NiceMatrix / NiceMatrixBlock } { #1 } + \int_zero_new:N \l__nm_first_env_block_int + \int_set:Nn \l__nm_first_env_block_int { \g__nm_env_int + 1 } + } + { + \bool_if:NT \l__nm_block_auto_columns_width_bool + { + \iow_now:Nn \@mainaux \ExplSyntaxOn + \int_step_inline:nnnn \l__nm_first_env_block_int 1 \g__nm_env_int + { + \iow_now:Nx \@mainaux + { + \cs_gset:cpn { __nm _ max _ cell _ width _ ##1 } + { \dim_use:N \g__nm_max_cell_width_dim } + } + } + \iow_now:Nn \@mainaux \ExplSyntaxOff + } + } +\keys_define:nn { NiceMatrix / NiceArrayC } + { + 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 = \__nm_error:n { Unknown~option~for~NiceArrayC } + } +\__nm_msg_new:nnn { Unknown~option~for~NiceArrayC } + { + The~option~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~environment~ + \{\@currenvir\}. \\ + If~you~go~on,~it~will~be~ignored. \\ + For~a~list~of~the~available~options,~type~H~<return>. + } + { + The~available~options~are~(in~alphabetic~order):~ + code-after,~ + code-for-last-col,~ + columns-width,~ + create-extra-nodes,~ + extra-left-margin,~ + extra-right-margin,~ + left-margin,~ + name,~ + nullify-dots,~ + parallelize-diags~ + renew-dots~ + and~right-margin. + } +\cs_new_protected:Nn \__nm_NiceArrayC:n + { + \bool_set_true:N \l__nm_exterior_column_bool + \begin { NiceArray } + { #1 + > + { + \int_gincr:N \g__nm_column_int + \int_gset:Nn \g__nm_column_total_int + { \int_max:nn \g__nm_column_total_int \g__nm_column_int } + \hbox_set:Nw \l_tmpa_box $ % $ + \l__nm_code_for_last_col_tl + } + l + < { $ % $ + \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 + + \l__nm_right_margin_dim + + \l__nm_extra_right_margin_dim + } + \tikz + [ + remember~picture , + inner~sep = \c_zero_dim , + minimum~width = \c_zero_dim , + baseline + ] + \node + [ + anchor = base , + name = + nm - + \int_use:N \g__nm_env_int - + \int_use:N \g__nm_row_int - + \int_use:N \g__nm_column_int , + alias = + \str_if_empty:NF \l__nm_name_str + { + \l__nm_name_str - + \int_use:N \g__nm_row_int - + \int_use:N \g__nm_column_int + } + ] + { \box_use:N \l_tmpa_box } ; + } + } + } + } +\NewDocumentEnvironment { NiceArrayCwithDelims } { m m O { } m ! O { } } + { + \dim_gzero_new:N \g__nm_width_last_col_dim + \keys_set:nn { NiceMatrix / NiceArrayC } { #3 , #5 } + \bool_set_false:N \l__nm_exterior_arraycolsep_bool + \str_set:Nn \l__nm_pos_env_str c + \left #1 + \__nm_NiceArrayC:n { #4 } + } + { + \end { NiceArray } + \right #2 + \skip_horizontal:n \g__nm_width_last_col_dim + } +\NewDocumentEnvironment { pNiceArrayC } { } + { \NiceArrayCwithDelims ( ) } + { \endNiceArrayCwithDelims } +\NewDocumentEnvironment { vNiceArrayC } { } + { \NiceArrayCwithDelims | | } + { \endNiceArrayCwithDelims } +\NewDocumentEnvironment { VNiceArrayC } { } + { \NiceArrayCwithDelims \| \| } + { \endNiceArrayCwithDelims } +\NewDocumentEnvironment { bNiceArrayC } { } + { \NiceArrayCwithDelims [ ] } + { \endNiceArrayCwithDelims } +\NewDocumentEnvironment { BNiceArrayC } { } + { \NiceArrayCwithDelims \{ \} } + { \endNiceArrayCwithDelims } +\keys_define:nn { NiceMatrix / NiceArrayRC } + { + code-for-first-row .tl_set:N = \l__nm_code_for_first_row_tl , + code-for-first-row .value_required: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 = \__nm_error:n { Unknown~option~for~NiceArrayRC } + } +\__nm_msg_new:nnn { Unknown~option~for~NiceArrayRC } + { + The~option~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~environment~ + \{ \@currenvir \}. \\ + If~you~go~on,~it~will~be~ignored. \\ + For~a~list~of~the~available~options,~type~H~<return>. + } + { + The~available~options~are~(in~alphabetic~order):~ + code-after,~ + code-for-last-col,~ + code-for-first-row,~ + columns-width,~ + create-extra-nodes,~ + extra-left-margin,~ + extra-right-margin,~ + left-margin,~ + name,~ + nullify-dots,~ + parallelize-diags,~ + renew-dots~ + and~right-margin. + } +\NewDocumentEnvironment { NiceArrayRCwithDelims } { m m O { } m ! O { } } + { + \int_zero:N \l__nm_nb_first_row_int + \dim_gzero_new:N \g__nm_width_last_col_dim + \keys_set:nn { NiceMatrix / NiceArrayRC } { #3 , #5 } + \bool_set_false:N \l__nm_exterior_arraycolsep_bool + \str_set:Nn \l__nm_pos_env_str c + \box_clear_new:N \l__nm_the_array_box + \hbox_set:Nw \l__nm_the_array_box + $ % $ + \__nm_NiceArrayC:n { #4 } + } + { + \end { NiceArray } + $ % $ + \hbox_set_end: + \dim_set:Nn \l_tmpa_dim + { + ( + \dim_max:nn + { 12 pt } + { \g__nm_max_ht_row_one_dim + \g__nm_max_dp_row_zero_dim } + ) + + \g__nm_max_ht_row_zero_dim - \g__nm_max_ht_row_one_dim + } + \hbox_set:Nn \l_tmpa_box + { + $ % $ + \left #1 + \vcenter + { + \skip_vertical:n { - \l_tmpa_dim } + \box_use_drop:N \l__nm_the_array_box + } + \right #2 + $ % $ + \skip_horizontal:n \g__nm_width_last_col_dim + } + \box_set_ht:Nn \l_tmpa_box { \box_ht:N \l_tmpa_box + \l_tmpa_dim } + \box_use_drop:N \l_tmpa_box + } +\NewDocumentEnvironment { pNiceArrayRC } { } + { \NiceArrayRCwithDelims ( ) } + { \endNiceArrayRCwithDelims } +\NewDocumentEnvironment { bNiceArrayRC } { } + { \NiceArrayRCwithDelims [ ] } + { \endNiceArrayRCwithDelims } +\NewDocumentEnvironment { vNiceArrayRC } { } + { \NiceArrayRCwithDelims | | } + { \endNiceArrayRCwithDelims } +\NewDocumentEnvironment { VNiceArrayRC } { } + { \NiceArrayRCwithDelims \| \| } + { \endNiceArrayRCwithDelims } +\NewDocumentEnvironment { BNiceArrayRC } { } + { \NiceArrayRCwithDelims \{ \} } + { \endNiceArrayRCwithDelims } +\cs_generate_variant:Nn \dim_min:nn { v n } +\cs_generate_variant:Nn \dim_max:nn { v n } +\cs_new_protected:Nn \__nm_create_extra_nodes: + { + \begin { tikzpicture } [ remember~picture , overlay ] + \int_step_variable:nnnNn \l__nm_nb_first_row_int 1 \g__nm_row_int \__nm_i + { + \dim_zero_new:c { l__nm_row_\__nm_i _min_dim } + \dim_set_eq:cN { l__nm_row_\__nm_i _min_dim } \c_max_dim + \dim_zero_new:c { l__nm_row_\__nm_i _max_dim } + \dim_set:cn { l__nm_row_\__nm_i _max_dim } { - \c_max_dim } + } + \int_step_variable:nnnNn 1 1 \g__nm_column_total_int \__nm_j + { + \dim_zero_new:c { l__nm_column_\__nm_j _min_dim } + \dim_set_eq:cN { l__nm_column_\__nm_j _min_dim } \c_max_dim + \dim_zero_new:c { l__nm_column_\__nm_j _max_dim } + \dim_set:cn { l__nm_column_\__nm_j _max_dim } { - \c_max_dim } + } + \int_step_variable:nnNn \l__nm_nb_first_row_int \g__nm_row_int \__nm_i + { + \int_step_variable:nNn \g__nm_column_total_int \__nm_j + { \cs_if_exist:cT + { pgf@sh@ns@nm - \int_use:N \g__nm_env_int - \__nm_i- \__nm_j } + { + \tikz@parse@node \pgfutil@firstofone + ( nm - \int_use:N \g__nm_env_int + - \__nm_i - \__nm_j .south~west ) + \dim_set:cn { l__nm_row_\__nm_i _min_dim} + { \dim_min:vn { l__nm_row _ \__nm_i _min_dim } \pgf@y } + \seq_if_in:NxF \g__nm_multicolumn_cells_seq { \__nm_i - \__nm_j } + { + \dim_set:cn { l__nm_column _ \__nm_j _ min_dim} + { \dim_min:vn { l__nm_column _ \__nm_j _min_dim } \pgf@x } + } + \tikz@parse@node \pgfutil@firstofone + ( nm - \int_use:N \g__nm_env_int - \__nm_i - \__nm_j .north~east ) + \dim_set:cn { l__nm_row _ \__nm_i _ max_dim } + { \dim_max:vn { l__nm_row _ \__nm_i _ max_dim } \pgf@y } + \seq_if_in:NxF \g__nm_multicolumn_cells_seq { \__nm_i - \__nm_j } + { + \dim_set:cn { l__nm_column _ \__nm_j _ max_dim } + { \dim_max:vn { l__nm_column _ \__nm_j _max_dim } \pgf@x } + } + } + } } + \tikzset { name~suffix = -medium } + \__nm_create_nodes: + \int_set:Nn \l__nm_nb_first_row_int 1 + \int_step_variable:nnnNn 1 1 { \g__nm_row_int - 1 } \__nm_i + { + \dim_set:cn { l__nm_row _ \__nm_i _ min _ dim } + { + ( + \dim_use:c { l__nm_row _ \__nm_i _ min _ dim } + + \dim_use:c { l__nm_row _ \int_eval:n { \__nm_i + 1 } _ max _ dim } + ) + / 2 + } + \dim_set_eq:cc { l__nm_row _ \int_eval:n { \__nm_i + 1 } _ max _ dim } + { l__nm_row_\__nm_i _min_dim } + } + \int_step_variable:nnnNn 1 1 { \g__nm_column_int - 1 } \__nm_j + { + \dim_set:cn { l__nm_column _ \__nm_j _ max _ dim } + { + ( + \dim_use:c + { l__nm_column _ \__nm_j _ max _ dim } + + \dim_use:c + { l__nm_column _ \int_eval:n { \__nm_j + 1 } _ min _ dim } + ) + / 2 + } + \dim_set_eq:cc { l__nm_column _ \int_eval:n { \__nm_j + 1 } _ min _ dim } + { l__nm_column _ \__nm_j _ max _ dim } + } + \dim_sub:cn + { l__nm_column _ 1 _ min _ dim } + \g__nm_left_margin_dim + \dim_add:cn + { l__nm_column _ \int_use:N \g__nm_column_int _ max _ dim } + \g__nm_right_margin_dim + \tikzset { name~suffix = -large } + \__nm_create_nodes: + \end{tikzpicture} + \cs_set:Nn \__nm_create_extra_nodes: { } + } +\cs_new_protected:Nn \__nm_create_nodes: + { + \int_step_variable:nnnNn \l__nm_nb_first_row_int 1 \g__nm_row_int \__nm_i + { + \int_step_variable:nnnNn 1 1 \g__nm_column_total_int \__nm_j + { + \coordinate ( __nm~south~west ) + at ( \dim_use:c { l__nm_column_ \__nm_j _min_dim } , + \dim_use:c { l__nm_row_ \__nm_i _min_dim } ) ; + \coordinate ( __nm~north~east ) + at ( \dim_use:c { l__nm_column_ \__nm_j _max_dim }, + \dim_use:c { l__nm_row_ \__nm_i _max_dim } ) ; + \node + [ + node~contents = { } , + fit = ( __nm~south~west ) ( __nm~north~east ) , + inner~sep = \c_zero_dim , + name = nm - \int_use:N \g__nm_env_int - \__nm_i - \__nm_j , + alias = + \str_if_empty:NF \g__nm_name_str + { \g__nm_name_str - \__nm_i - \__nm_j } + ] + ; + } + } + \__nm_seq_mapthread_function:NNN + \g__nm_multicolumn_cells_seq + \g__nm_multicolumn_sizes_seq + \__nm_node_for_multicolumn:nn + } +\cs_new_protected:Npn \__nm_extract_coords: #1 - #2 \q_stop + { + \cs_set:Npn \__nm_i { #1 } + \cs_set:Npn \__nm_j { #2 } + } +\cs_new_protected:Nn \__nm_node_for_multicolumn:nn + { + \__nm_extract_coords: #1 \q_stop + \coordinate ( __nm~south~west ) at + ( + \dim_use:c { l__nm_column _ \__nm_j _ min _ dim } , + \dim_use:c { l__nm_row _ \__nm_i _ min _ dim } + ) ; + \coordinate ( __nm~north~east ) at + ( + \dim_use:c { l__nm_column _ \int_eval:n { \__nm_j + #2 - 1 } _ max _ dim} , + \dim_use:c { l__nm_row _ \__nm_i _ max _ dim } + ) ; + \node + [ + node~contents = { } , + fit = ( __nm~south~west ) ( __nm~north~east ) , + inner~sep = \c_zero_dim , + name = nm - \int_use:N \g__nm_env_int - \__nm_i - \__nm_j , + alias = + \str_if_empty:NF \g__nm_name_str { \g__nm_name_str - \__nm_i - \__nm_j } + ] + ; + } \ProcessKeysOptions {NiceMatrix} -\cs_new:Npn \__nicem_seq_mapthread_function:NNN #1#2#3 - {\group_begin: - \int_step_inline:nnnn 1 1 {\seq_count:N #1} - {\seq_pop:NN #1 \l_tmpa_tl - \seq_pop:NN #2 \l_tmpb_tl - \exp_args:NVV #3 \l_tmpa_tl \l_tmpb_tl} +\cs_new:Npn \__nm_seq_mapthread_function:NNN #1 #2 #3 + { + \group_begin: + \int_step_inline:nnnn 1 1 { \seq_count:N #1 } + { + \seq_pop:NN #1 \l_tmpa_tl + \seq_pop:NN #2 \l_tmpb_tl + \exp_args:NVV #3 \l_tmpa_tl \l_tmpb_tl + } \group_end: } -\cs_set:Nn \__nicem_renew_matrix: - {\RenewDocumentEnvironment {pmatrix} {} - {\begin{pNiceMatrix}} - {\end{pNiceMatrix}} - \RenewDocumentEnvironment {vmatrix} {} - {\begin{vNiceMatrix}} - {\end{vNiceMatrix}} - \RenewDocumentEnvironment {Vmatrix} {} - {\begin{VNiceMatrix}} - {\end{VNiceMatrix}} - \RenewDocumentEnvironment {bmatrix} {} - {\begin{bNiceMatrix}} - {\end{bNiceMatrix}} - \RenewDocumentEnvironment {Bmatrix} {} - {\begin{BNiceMatrix}} - {\end{BNiceMatrix}}} +\cs_set_protected:Npn \__nm_renew_matrix: + { + \RenewDocumentEnvironment { pmatrix } { } + { \pNiceMatrix } + { \endpNiceMatrix } + \RenewDocumentEnvironment { vmatrix } { } + { \vNiceMatrix } + { \endvNiceMatrix } + \RenewDocumentEnvironment { Vmatrix } { } + { \VNiceMatrix } + { \endVNiceMatrix } + \RenewDocumentEnvironment { bmatrix } { } + { \bNiceMatrix } + { \endbNiceMatrix } + \RenewDocumentEnvironment { Bmatrix } { } + { \BNiceMatrix } + { \endBNiceMatrix } + } \endinput %% %% End of file `nicematrix.sty'. |