summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-03-11 20:24:29 +0000
committerKarl Berry <karl@freefriends.org>2018-03-11 20:24:29 +0000
commit6e3fb8c5153de44e35c1bb1a7feb772026a4910f (patch)
tree7c6613562baa846fdaad16f94f1c935fa0396f82
parentea9e4ccd8121bca75c0f89743fc8099617e26d15 (diff)
nicematrix (11mar18)
git-svn-id: svn://tug.org/texlive/trunk@46920 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdfbin187641 -> 226936 bytes
-rw-r--r--Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx469
-rw-r--r--Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty117
3 files changed, 420 insertions, 166 deletions
diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf
index 2a2f43c97ab..74de874af74 100644
--- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf
+++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx
index bfb21ac8785..257e1e03a69 100644
--- a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx
+++ b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx
@@ -15,8 +15,8 @@
%
% \fi
% \iffalse
-\def\myfileversion{1.1}
-\def\myfiledate{2018/02/26}
+\def\myfileversion{1.2}
+\def\myfiledate{2018/03/11}
%
%
%<*batchfile>
@@ -69,13 +69,16 @@ version 2005/12/01 or later.
% \maketitle
%
% \begin{abstract}
-% The LaTeX package \pkg{nicematrix} gives an environment |{NiceMatrix}| which is similar to the environment
-% |{matrix}| but gives the possibility to draw ellipis dots between the cells of the matrix.
+% The LaTeX package \pkg{nicematrix} provides environments |{NiceArray}| and |{NiceMatrix}| similar to the
+% classical environments |{array}| and |{matrix}| but with the possibility to draw continuous ellipsis dots between
+% the cells of the array.
% \end{abstract}
%
% \vspace{1cm}
% \section{Presentation}
%
+%
+%
% This package can be used with |xelatex|, |lualatex|, |pdflatex| but also by the classical workflow
% |latex|-|dvips|-|ps2pdf| (or Adobe Distiller). Two compilations may be necessary. This package requires the
% packages \pkg{expl3}, \pkg{l3keys2e}, \pkg{xparse}, \pkg{array}, \pkg{mathtools} and \pkg{tikz}.
@@ -84,7 +87,7 @@ version 2005/12/01 or later.
% The package \pkg{nicematrix} aims to draw beautiful matrices in a way almost transparent for the user.
%
% \medskip
-% Consider, for exemple, the matrix\enskip
+% Consider, for example, the matrix\enskip
% $A = \begin{pmatrix}
% 1 &\cdots &\cdots &1 \\
% 0 &\ddots & &\vdots \\
@@ -124,20 +127,29 @@ version 2005/12/01 or later.
%
% \section{How to use nicematrix for new code}
%
-% \subsection{The environment NiceMatrix and its variants}
+% \subsection{The environments NiceArray, NiceMatrix and their variants}
+%
+% The package \pkg{nicematrix} provides new environments |{NiceArray}|, |{NiceMatrix}|, |{pNiceMatrix}|,
+% |{bNiceMatrix}|, |{BNiceMatrix}|, |{vNiceMatrix}| and |{VNiceMatrix}|.
%
-% The package \pkg{nicematrix} gives six new environments |{NiceMatrix}|, |{pNiceMatrix}|, |{bNiceMatrix}|,
-% |{BNiceMatrix}|, |{vNiceMatrix}| and |{VNiceMatrix}|. By default, these environments behave almost exactly as the
-% corresponding environments of \pkg{amsmath} (and \pkg{mathtools}): |{matrix}|, |{pmatrix}|, |{bmatrix}|,
-% |{Bmatrix}|, |{vmatrix}| and |{Vmatrix}|.
+% The environment |{NiceArray}| is similar to the environment |{array}| defined in LaTeX and redefined in the package
+% \pkg{array}. The environments |{NiceMatrix}|, |{pNiceMatrix}|, etc. are similar to the environments |{matrix}|,
+% |{pmatrix}|, etc. of \pkg{amsmath} (and \pkg{mathtools}).
%
+% The environment |{NiceMatrix}| has the same syntax that the environment |{matrix}| (idem for the variants).
+% However, for the environment |{NiceArray}|, there is a difference: in the preamble of |{NiceArray}|, the user
+% must use the letters |L|, |C| and |R|\footnote{The column types |L|, |C| and |R| are defined locally inside
+% |{NiceArray}| with |\newcolumntype| of \pkg{array}. This definition overrides an eventual previous definition.}
+% instead of |l|, |c| and |r|. It's possible to use the constructions \verb+|+, |>{...}|, |<{...}|, |@{...}|,
+% |!{...}| and |*{n}{...}| but the letters |p|, |m| and |b| should not be used.
+%
% \smallskip
-% Inside these environments, five new commands are defined: |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots| and |\Iddots|.
-% These commands are intended to be used in place of |\dots|, |\cdots|, |\vdots|, |\ddots| and
-% |\iddots|.\footnote{The command |\iddots|, defined in \pkg{nicematrix}, is a variant of
+% Inside the new environments defined by the package \pkg{nicematrix}, five commands are defined: |\Ldots|,
+% |\Cdots|, |\Vdots|, |\Ddots| and |\Iddots|. These commands are intended to be used in place of |\dots|, |\cdots|,
+% |\vdots|, |\ddots| and |\iddots|.\footnote{The command |\iddots|, defined in \pkg{nicematrix}, is a variant of
% |\ddots| with dots going forward: \smash{$\iddots$}. If the command |\iddots| is already defined (for example if
-% \pkg{mathdots} is loaded), the previous definition is not overwritten. Note that the package \pkg{yhmath} provides a
-% command |\adots| similar to |\iddots|.}
+% \pkg{mathdots} is loaded), the previous definition is not overwritten. Note that the package \pkg{yhmath}
+% provides a command |\adots| similar to |\iddots|.}
%
% \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
@@ -362,11 +374,12 @@ version 2005/12/01 or later.
%
% \section{How to use nicematrix for existing code}
%
-% The package \pkg{nicematrix} provides an option called |Transparent| for using existing code transparently (this
-% option --- and the others --- can be set with the |\usepackage| command but \pkg{nicematrix} provides also a
-% dedicated command called |\NiceMatrixOptions|).
+% The package \pkg{nicematrix} provides an option called |Transparent| for using existing code transparently in the
+% environments |{matrix}| (not in the environments |{array}|). This option can be set as option of |\usepackage| or
+% with the dedicated command called |\NiceMatrixOptions|.
+%
%
-% In fact, this option is an alias for the conjonction of two options : |RenewDots| and |RenewMatrix|.
+% In fact, this option is an alias for the conjonction of two options: |RenewDots| and |RenewMatrix|.
%
% \smallskip
%
@@ -374,9 +387,9 @@ version 2005/12/01 or later.
% \item The option |RenewDots|\par\nobreak
% With this option, the commands |\ldots|, |\cdots|, |\vdots|, |\ddots| and |\iddots|\footnote{The command
% |\iddots| is not a command of LaTeX but is defined by the package \pkg{nicematrix}. If |mathdots| is loaded, the
-% version of |mathdots| is used.} are redefined within the environments |{NiceMatrix}| and behave like |\Ldots|,
-% |\Cdots|, |\Vdots|, |\Ddots| and |\Iddots|; the command |\dots| (``automatic dots'' of |amsmath| --- and
-% |mathtools|) is also redefined to behave like |\Ldots|.
+% version of |mathdots| is used.} are redefined within the environments |{NiceArray}|, |{NiceMatrix}| and its
+% variants and behave like |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots| and |\Iddots|; the command |\dots| (``automatic
+% dots'' of |amsmath| --- and |mathtools|) is also redefined to behave like |\Ldots|.
%
% \item The option |RenewMatrix|\par\nobreak
% With this option, the environment |{matrix}| is redefined and behave like |{NiceMatrix}|, and so on for the five
@@ -519,13 +532,29 @@ version 2005/12/01 or later.
% A dotted line must be delimited by two non-empty cells. If it's not possible to find one of these cells whitin
% the boudaries of the matrix, an error is issued and the instruction is ignored.
%
+% \vspace{1cm}
+% \subsection{The option exterior-arraycolsep}
+%
+% The environment |{array}| inserts un horizontal space equal to |\arraycolsep| before and after each column. In
+% particular, there is a space equal to |\arraycolsep| before and after the array. This feature of the environment
+% |{array}| was probably not a good idea.\footnote{In the documentation of |{amsmath}|, we can read: \itshape The
+% 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).}
%
+% The environment |{matrix}| and its variants (|{pmatrix}|, |{vmatrix}|, etc.) of \pkg{amsmath} and \pkg{mathtools}
+% prefer to delete these spaces with explicit instructions |\hskip -\arraycolsep| and |{NiceArray}| does likewise.
+%
+% However, the user can change this behaviour with the boolean option |exterior-arraycolsep|. With this option
+% \footnote{The option |exterior-arraycolsep| can be set globally with |\NiceMatrixOptions| but also locally as an
+% option of a given environment |{NiceArray}|. In this case, it's also possible to give the traditionnal option
+% |t|, |c| or |b| of a environment |{array}|: |\begin{NiceArray}[exterior-arraycolsep,t]...|}, the environment
+% |{NiceArray}| will insert the sames horizontal spaces as the environment |{array}| of LaTeX and \pkg{array}.
%
-% \section{Examples}
%
+% \section{Examples}
%
% \bigskip
-% A tridiagonal matrix :
+% A tridiagonal matrix:
%
% \bigskip
% \begin{BVerbatim}[baseline=c]
@@ -554,7 +583,7 @@ version 2005/12/01 or later.
%
% \vspace{2cm}
%
-% A permutation matrix :
+% A permutation matrix:
%
% \bigskip
% \begin{BVerbatim}[baseline=c]
@@ -600,6 +629,83 @@ version 2005/12/01 or later.
%
%
%
+%
+% \vspace{2cm}
+% An example with a linear system (we need |{NiceArray}| for the vertical line):
+%
+% \bigskip
+% \begin{BVerbatim}[baseline=c]
+% $\left[\begin{NiceArray}{CCCC|C}
+% a_1 & ? & \Cdots & ? & ? \\
+% 0 & & \Ddots & \Vdots & \Vdots\\
+% \Vdots & \Ddots & \Ddots & ? \\
+% 0 & \Cdots & 0 & a_n & ? \\
+% \end{NiceArray}\right]$
+% \end{BVerbatim}
+% \hspace{2.5cm}
+% $\left[\begin{NiceArray}{CCCC|C}
+% a_1 & ? & \Cdots & ? & ? \\
+% 0 & & \Ddots & \Vdots & \Vdots\\
+% \Vdots & \Ddots & \Ddots & ? \\
+% 0 & \Cdots & 0 & a_n & ? \\
+% \end{NiceArray}\right]$
+%
+% \vspace{2cm}
+% An example where we use |{NiceArray}| because we want to use the types |L| and |R| for the columns:
+%
+% \bigskip
+% \begin{BVerbatim}[baseline=c]
+% $\left(\begin{NiceArray}{LCR}
+% a_{11} & \Cdots & a_{1n} \\
+% a_{21} & & a_{2n} \\
+% \Vdots & & \Vdots \\
+% a_{n-1,1} & \Cdots & a_{n-1,n} \\
+% \end{NiceArray}\right)$
+% \end{BVerbatim}
+% \hspace{4cm}
+% $\left(\begin{NiceArray}{LCR}
+% a_{11} & \Cdots & a_{1n} \\
+% a_{21} & & a_{2n} \\
+% \Vdots & & \Vdots \\
+% a_{n-1,1} & \Cdots & a_{n-1,n} \\
+% \end{NiceArray}\right)$
+%
+%
+% \vspace{2cm}
+%
+% Another example with |{NiceArray}|:
+%
+% \begin{Verbatim}
+% \left(\begin{~emphase#NiceArray@}{*4{C}|*4{C}}
+% 1 &\Cdots& &1 &2 &\Cdots& &2 \\
+% \Vdots& & & & & & &\Vdots\\
+% & & &\Vdots&\Vdots& & & \\
+% 1 & &\Cdots&1 & & & & \\
+% \cline{1-4}
+% 0 &\Cdots& &0 & & & & \\
+% \Vdots& & & & & & & \\
+% & & &\Vdots&\Vdots& & & \\
+% 0 & &\Cdots&0 &2 & &\Cdots&2
+% \end{~emphase#NiceArray@}\right)
+% \end{Verbatim}
+%
+%
+%\[A=\left(\begin{NiceArray}{*4{C}|*4{C}}
+% 1 &\Cdots& &1 &2 &\Cdots& &2 \\
+% \Vdots& & & & & & &\Vdots\\
+% & & &\Vdots&\Vdots& & & \\
+% 1 & &\Cdots&1 & & & & \\
+% \cline{1-4}
+% 0 &\Cdots& &0 & & & & \\
+% \Vdots& & & & & & & \\
+% & & &\Vdots&\Vdots& & & \\
+% 0 & &\Cdots&0 &2 & &\Cdots&2
+% \end{NiceArray}\right)\]
+%
+%
+%
+%
+%
% \vspace{1cm}
%
% \section{Implementation}
@@ -620,7 +726,7 @@ version 2005/12/01 or later.
% 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{mathtools} (\pkg{mathtools} may be considered as the successor of \pkg{amsmath}) and \pkg{tikz}.
+% We load \pkg{array}, \pkg{mathtools} (\pkg{mathtools} may be considered as the successor of \pkg{amsmath}) and \pkg{tikz}.
% \begin{macrocode}
\RequirePackage{array}
\RequirePackage{mathtools}
@@ -668,15 +774,23 @@ version 2005/12/01 or later.
% be gobbled.
%
% \bigskip
-% The following counter will count the environments |{NiceMatrix}|. The value of this counter will be used to
-% prefix the names of the Tikz nodes created in the matrix.
+% The following counter will count the environments |{NiceArray}|. The value of this counter will be used to
+% prefix the names of the Tikz nodes created in the array.
% \begin{macrocode}
\int_new:N \g_@@_env_int
% \end{macrocode}
-%
+%
% \bigskip
% \subsection{The options}
%
+% The boolean |\l_@@_exterior_arraycolsep_bool| corresponds to the option |exterior-arraycolsep|. If this option is
+% set, a space equal to |\arraycolsep| will be put on both sides of an environment |{NiceArray}| (but not for
+% |{NiceMatrix}| and its variants).
+% \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 default
% is~|true|.
% \begin{macrocode}
@@ -738,10 +852,10 @@ version 2005/12/01 or later.
% With the option |Silent|, no error is generated for the impossible instructions. This option can be useful when
% adapting an existing code.
% \begin{macrocode}
- Silent .code:n = {\msg_redirect_name:nnn {nicematrix}
+ Silent .code:n = {\msg_redirect_name:nnn {nicematrix}
{Impossible~instruction}
{none}} ,
- Silent .value_forbidden:n = true}
+ Silent .value_forbidden:n = true}
% \end{macrocode}
%
% \bigskip
@@ -753,24 +867,32 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% \subsection{The main functions}
+% \subsection{The environments NiceArray and NiceMatrix}
%
-% The pseudo-environment |\@@_Cell:|--|\@@_end_Cell:| is used to format the cells of the array (except the cells of
-% the first column: see below).
+% First, we define a set of keys named |{NiceArray}|.
% \begin{macrocode}
-\cs_new_protected:Nn \@@_Cell:
- {
+\keys_define:nn {NiceArray}
+ {exterior-arraycolsep .bool_set:N = \l_@@_exterior_arraycolsep_bool ,
+ exterior-arraycolsep .default:n = true}
% \end{macrocode}
-% We increment |\g_@@_column_int|, which is the counter of the columns. We need a global affectation because this
-% command will be used in the cell of a |\halign| (via an environment |{array}|).
+%
+% \bigskip
+% The pseudo-environment |\@@_Cell:n|--|\@@_end_Cell:| will be used to format the cells of the array. In the code,
+% the affectations are global because this pseudo-environment will be used in the cells of a |\halign| (via an
+% environment |{array}|).
+%
+% The argument of |\@@_Cell:n| is a letter |l|, |c| or |r| that describes the type of column: we store this letter
+% at the end of |\g_@@_preamble_aux_tl| (see the redefinition of |\ialign| in the environment |{NiceArray}| for
+% explanations).
% \begin{macrocode}
- \int_gincr:N \g_@@_column_int
+\cs_new_protected:Nn \@@_Cell:n
+ { \tl_gput_right:Nn \g_@@_preamble_aux_tl {#1}
% \end{macrocode}
-% At the end of the array, the counter |\g_@@_nb_column_int| will contain the total number of columns of the array
-% (even if all the lines don't have the same number of ampersands).
+% We increment |\g_@@_column_int|, which is the counter of the columns.
% \begin{macrocode}
- \int_gset:Nn \g_@@_nb_column_int {\int_max:nn \g_@@_nb_column_int \g_@@_column_int}
+ \int_gincr:N \g_@@_column_int
% \end{macrocode}
+%
% We create a Tikz node for the current cell of the array.
% \begin{macrocode}
\tikz[remember~picture, inner~sep = 0pt, minimum~width = 0pt, baseline]
@@ -785,62 +907,115 @@ version 2005/12/01 or later.
{$\egroup ;} % $
% \end{macrocode}
%
-% \interitem
-% The pseudo-environment |\@@_Cell_First_Column:|--|\@@_end_Cell:| is used to format the cells of the first column
-% of the array. For such a column, we have to increment the counter of the lines (|\g_@@_line_int|) and to
-% initialize the counter of the columns (|\g_@@_column_int|).
-% \begin{macrocode}
-\cs_new_protected:Nn \@@_Cell_First_Column:
- {\int_gincr:N \g_@@_line_int
- \int_gset:Nn \g_@@_column_int 0
- \@@_Cell:}
-% \end{macrocode}
+% \interitem
+% 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}|.
%
-% \interitem
-% The environment |{NiceMatrix}| is the main environment of the package |nicematrix|. This environment creates an
-% array similar to the array created by the environment |{matrix}| of \pkg{amsmath} but with Tikz nodes for each
-% cell of the matrix.
+% Our environment |{NiceMatrix}| must have the same second part as the environment |{matrix}| of \pkg{amsmath}
+% (because of the programmation of the option |RenewMatrix|). Hence, this second part is the following:
+%
+% \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).
+%
+% \medskip
+% Here's the definition of |{NiceMatrix}|:
% \begin{macrocode}
\NewDocumentEnvironment {NiceMatrix} {}
- {
-% \end{macrocode}
-% We use a |\aftergroup| to execute |\@@_draw_lines| at the end of the environment (all the LaTeX environments are
-% TeX groups). With this technic, the second part of the environment is the same that the second part of the
-% environment |{matrix}| of \pkg{amsmath}. Therefore, it's easier to redefine the environment |{matrix}| (when the
-% option |RenewMatrix| is used).
-% \begin{macrocode}
- \aftergroup \@@_draw_lines:
+ {\bool_set_false:N \l_@@_exterior_arraycolsep_bool
+ \NiceArray{*\c@MaxMatrixCols{C}}}
+ {\endarray
+ \skip_horizontal:n {-\arraycolsep}}
% \end{macrocode}
%
-% The commands |\Ldots|, |\Cdots|, etc. will be defined only within the environment |{NiceMatrix}|.
-% \begin{macrocode}
- \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 \Hspace \@@_Hspace:
- \cs_set_eq:NN \NiceMatrixEndPoint \@@_NiceMatrixEndPoint:
- \bool_if:NF \l_@@_renew_matrix_bool
- {\cs_set_eq:NN \multicolumn \@@_multicolumn:nn}
+% \interitem
+% 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 |\aftergroup \@@_draw_lines:| 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}
+\NewDocumentEnvironment {NiceArray} {O{} m}
+ {\aftergroup \@@_draw_lines:
+% \end{macrocode}
+% First, we test wether there is the option |exterior-arraycolsep|. The other options (|t|, |c| or |b|) will be
+% stored in |\l_tmpa_tl| and passed to |\array| (see below).
+% \begin{macrocode}
+ \keys_set_known:nnN {NiceArray} {#1} \l_tmpa_tl
+% \end{macrocode}
+% The environment |{array}| uses internally the command |\ialign| and, in particular, this command |\ialign| sets
+% |\everycr| to |{}|. However, we want to use |\everycr| in our array (in particular to increment |\g_@@_line_int|).
+% The solution is to give to |\ialign| a new definition (giving to |\everycr| the value we want)
+% that will revert automatically to its default definition after the first utilisation.\footnote{With this programmation, we will
+% have, in the cells of the array, a clean version of |\ialign|. That's necessary: the user will probably not employ directly
+% |\ialign| in the array... but more likely environments that utilize |\ialign| internally (e.g.: |{substack}|)}
+% \begin{macrocode}
+ \cs_set:Npn \ialign
+ {\everycr{\noalign{\int_gincr:N \g_@@_line_int
+ \int_gzero:N \g_@@_column_int
+% \end{macrocode}
+% We want to have the preamble of the array in |\g_@@_preamble_tl| at the end of the array. However, some lines of the array
+% may be shorter (that is to say without all the ampersands) and it's not possible to known which line will be the
+% longest. That's why, during the construction of a line, we retrieve the corresponding preamble in
+% |\g_@@_preamble_aux_tl|. At the end of the array, we are sure that the longest value will be the real preamble of
+% the array (stored in |\g_@@_preamble_tl|).
+% \begin{macrocode}
+ \int_compare:nNnT {\tl_count:N \g_@@_preamble_aux_tl}
+ > {\tl_count:N \g_@@_preamble_tl}
+ {\tl_gset_eq:NN \g_@@_preamble_tl \g_@@_preamble_aux_tl}
+ \tl_gclear:N \g_@@_preamble_aux_tl}}
+ \skip_zero:N \tabskip
+ \cs_set:Npn \ialign {\everycr{}
+ \skip_zero:N \tabskip
+ \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}|.
+% \begin{macrocode}
+ \newcolumntype{L}{>{\@@_Cell:n l}l<{\@@_end_Cell:}}
+ \newcolumntype{C}{>{\@@_Cell:n c}c<{\@@_end_Cell:}}
+ \newcolumntype{R}{>{\@@_Cell:n r}r<{\@@_end_Cell:}}
+% \end{macrocode}
+% The commands |\Ldots|, |\Cdots|, etc. will be defined only in the environment |{NiceArray}|.
+% \begin{macrocode}
+ \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 \Hspace \@@_Hspace:
+ \cs_set_eq:NN \NiceMatrixEndPoint \@@_NiceMatrixEndPoint:
+ \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}
+ \bool_if:NF \l_@@_renew_matrix_bool
+ {\cs_set_eq:NN \multicolumn \@@_multicolumn:nn}
% \end{macrocode}
-% If the option |RenewDots| is used, we redefine the commands |\ldots|, |\cdots|, etc.
+%
+% We increment the counter |\g_@@_env_int| which counts the environments |{NiceArray}|.
% \begin{macrocode}
- \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}
+ \int_gincr:N \g_@@_env_int
% \end{macrocode}
%
-% We increment the counter |\g_@@_env_int| which counts the environments |{NiceMatrix}|.
+% We have to remind the types of the columns (|l|, |c| or |r|) because we will use this information when we will
+% draw the vertical dotted lines. That's why we store the types of the columns in |\g_@@_preamble_tl| (for example,
+% if the preamble of |{NiceArray}| is |L*4{C}R|, the final value of |\g_@@_preamble_tl| will be |lccccr|).
% \begin{macrocode}
- \int_gincr:N \g_@@_env_int
+ \tl_clear_new:N \g_@@_preamble_tl
+ \tl_clear_new:N \g_@@_preamble_aux_tl
% \end{macrocode}
-%
+%
% The sequence |\g_@@_empty_cells_seq| will contains a list of ``empty'' cells (not all the empty cells of the
% matrix). If we want to indicate that the cell in line~$i$ and line~$j$ must be considered as empty, the token
% list ``|i-j|'' will be put in this sequence.
@@ -852,41 +1027,46 @@ version 2005/12/01 or later.
% \begin{macrocode}
\int_gzero_new:N \g_@@_instruction_int
% \end{macrocode}
-% The counter |\g_@@_line_int| will be used to count the lines of the array. At the end of the environment
-% |{array}|, this counter will give the total number of lines of the matrix.
+%
+% The counter |\g_@@_line_int| will be used to count the lines of the array (its incrementation will be in
+% |\everycr|). At the end of the environment |{array}|, this counter will give the total number of lines of the matrix.
% \begin{macrocode}
\int_gzero_new:N \g_@@_line_int
% \end{macrocode}
-% The counter |\g_@@_column_int| will be used to count the colums of the array. Since we want to known the total
-% number of columns of the matrix, we also create a counter |\g_@@_nb_column_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 (it will be set to zero in
+% |\everycr|). This counter is updated in the command |\@@_Cell:n| executed at the beginning of each cell. At the
+% end of the array (in the beginning of |\@@_draw_lines:|), it will be set to the total number of columns of the array.
% \begin{macrocode}
\int_gzero_new:N \g_@@_column_int
- \int_gzero_new:N \g_@@_nb_column_int
+ \cs_set_eq:NN \@ifnextchar \new@ifnextchar
% \end{macrocode}
-% The next two lines are the same as in the command |\env@matrix| of \pkg{amsmath} on which all the matrix
-% constructions are built.
+%
+% The extra horizontal spaces on both sides of an environment |{array}| should be considered as a bad idea of
+% standard LaTeX. In the environment |{matrix}| the package \pkg{amsmath} prefers to suppress these spaces with
+% intructions ``|\hskip -\arraycolsep|''. In the same way, we decide to suppress them in |{NiceArray}|. However, for better
+% compatibility, we give an option |exterior-arraycolsep| to control this feature.
% \begin{macrocode}
- \hskip -\arraycolsep
- \cs_set_eq:NN \@ifnextchar \new@ifnextchar
+ \bool_if:NF \l_@@_exterior_arraycolsep_bool
+ {\skip_horizontal:n {-\arraycolsep}}
% \end{macrocode}
-% Eventually, the environment |{NiceMatrix}| is defined upon the environment |{array}|. We maintain the
-% signification of the counter |\c@MaxMatrixCols| of \pkg{amsmath}.
+%
+% Eventually, the environment |{NiceArray}| is defined upon the environment |{array}|. As said previously, we must
+% use |\array| and not |\begin{array}|. The token list |\l_tmpa_tl| contains the options given to the environment
+% |{NiceArray}| that have not been catched by the set of keys |NiceArray| (|\l_tmpa_tl| should be equal to |t|,
+% |c|, |b| or the empty list).
% \begin{macrocode}
- \int_set:Nn \l_tmpa_int {\c@MaxMatrixCols - 1}
- \array{>{\@@_Cell_First_Column:}c<{\@@_end_Cell:}
- *\l_tmpa_int{>{\@@_Cell:}c<{\@@_end_Cell:}}}}
+ \array[\l_tmpa_tl]{#2}}
% \end{macrocode}
+%
% \bigskip
-% The second part of the environment |{NiceMatrix}| is the same as the second part of the environment |{matrix}| of
-% \pkg{amsmath}. However, at the end of the environment, the instruction |\@@_draw_lines:| will
-% be executed because we have put a ``|\aftergroup \@@_draw_lines:|'' in the beginning of the environment
-% (therefore, it's possible to implement the option |RenewMatrix| with |\cs_set_eq:NN \env@matrix \NiceMatrix|).
% \begin{macrocode}
- {\endarray
- \hskip -\arraycolsep}
+ {\endarray
+ \bool_if:NF \l_@@_exterior_arraycolsep_bool
+ {\skip_horizontal:n {-\arraycolsep}}}
% \end{macrocode}
%
+%
% \interitem
% We create the variants of the environment |{NiceMatrix}|.
% \begin{macrocode}
@@ -1004,7 +1184,13 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Nn \@@_draw_lines:
- {
+ {\int_compare:nNnT {\tl_count:N \g_@@_preamble_aux_tl}
+ > {\tl_count:N \g_@@_preamble_tl}
+ {\tl_set_eq:NN \g_@@_preamble_tl \g_@@_preamble_aux_tl}
+% \end{macrocode}
+% The counter |\g_@@_column_int| will now be the total number of columns in the array.
+% \begin{macrocode}
+ \int_set:Nn \g_@@_column_int {\tl_count:N \g_@@_preamble_tl}
% \end{macrocode}
%
% The sequence |\l_@@_yet_drawn_seq| contains a list of lines which have been drawn previously in the matrix. We
@@ -1025,8 +1211,8 @@ version 2005/12/01 or later.
%
% By befault, the diagonal lines will be parallelized\footnote{It's possible to use the option
% |ParallelizeDiagonals| to disable this parallelization.}. There are two types of diagonals lines: the $|\Ddots|$
-% diagonals and the |\Iddots| diagonals. We have to count the both types in order to known wether a diagonal is the
-% first of its type in the current |{NiceMatrix}| environment.
+% diagonals and the |\Iddots| diagonals. We have to count both types in order to known wether a diagonal is the
+% first of its type in the current |{NiceArray}| environment.
% \begin{macrocode}
\bool_if:NT \l_@@_parallelize_diags_bool
{\int_zero_new:N \l_@@_ddots_int
@@ -1059,7 +1245,7 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \interitem
-% We extract from the property list of the current instruction the fields ``type'', ``line'' and ``column''and we
+% We extract from the property list of the current instruction the fields ``type'', ``line'' and ``column'' and we
% store these values. We have to do a conversion because the components of a property list are token lists (and not
% integers).
% \begin{macrocode}
@@ -1121,7 +1307,7 @@ version 2005/12/01 or later.
\bool_if:nTF { \int_compare_p:nNn \l_@@_final_i_int < 1
|| \int_compare_p:nNn \l_@@_final_i_int > \g_@@_line_int
|| \int_compare_p:nNn \l_@@_final_j_int < 1
- || \int_compare_p:nNn \l_@@_final_j_int > \g_@@_nb_column_int}
+ || \int_compare_p:nNn \l_@@_final_j_int > \g_@@_column_int}
% \end{macrocode}
% If we are outside the matrix, the instruction is impossible and, of course, we stop the loop.
% \begin{macrocode}
@@ -1156,7 +1342,7 @@ version 2005/12/01 or later.
{ \int_compare_p:nNn \l_@@_initial_i_int < 1
|| \int_compare_p:nNn \l_@@_initial_i_int > \g_@@_line_int
|| \int_compare_p:nNn \l_@@_initial_j_int < 1
- || \int_compare_p:nNn \l_@@_initial_j_int > \g_@@_nb_column_int}
+ || \int_compare_p:nNn \l_@@_initial_j_int > \g_@@_column_int}
{\bool_set_true:N \l_@@_impossible_instruction_bool
\bool_set_true:N \l_@@_stop_loop_bool}
{\@@_if_not_empty_cell:nnT \l_@@_initial_i_int \l_@@_initial_j_int
@@ -1220,9 +1406,9 @@ version 2005/12/01 or later.
%
% \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 diagonals lines, a 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|.
+% will have to draw \footnote{In fact, with diagonals lines, or vertical lines in columns of type |L| or |R|, a
+% 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 anchors that must be used for the two nodes.
%
@@ -1239,9 +1425,9 @@ version 2005/12/01 or later.
\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} }
@@ -1262,9 +1448,39 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
+% For the vertical dotted lines, there is a problem because we want really vertical lines. If the type of the
+% column is |c| (from a type |C| in |{NiceArray}|), all the Tikz nodes of the column have the same $x$-value for the
+% anchors |south| and |north|. However, if the type of the column is |l| or |r| (from a type |L| or |R| in
+% |{NiceArray}|), the geometric line from the anchors |south| and |north| would probably not be really vertical.
+% That's why we need to known the type of the column and that's why we have constructed a token list
+% |\g_@@_preamble_tl| to store the types (|l|, |c| or |r|) of all the columns.
% \begin{macrocode}
\cs_new_protected:Nn \@@_draw_vdots_line:
{\@@_retrieve_coords:nn {south} {north}
+% \end{macrocode}
+% We store in |\t_tmpa_tl| the type of the column (|l|, |c| or |r|).
+% \begin{macrocode}
+ \tl_set:Nx \l_tmpa_tl {\tl_item:Nn \g_@@_preamble_tl \l_@@_initial_j_int}
+% \end{macrocode}
+% If the column is of type |l|, we will draw the dotted on the left-most abscissa.
+% \begin{macrocode}
+ \tl_set:Nn \l_tmpb_tl {l}
+ \tl_if_eq:NNT \l_tmpa_tl \l_tmpb_tl
+ {\dim_set:Nn \l_tmpa_dim {\dim_min:nn \g_@@_x_initial_dim \g_@@_x_final_dim}
+ \dim_set_eq:NN \g_@@_x_initial_dim \l_tmpa_dim
+ \dim_set_eq:NN \g_@@_x_final_dim \l_tmpa_dim}
+% \end{macrocode}
+% If the column is of type |r|, we will draw the dotted on the right-most abscissa.
+% \begin{macrocode}
+ \tl_set:Nn \l_tmpb_tl {r}
+ \tl_if_eq:NNT \l_tmpa_tl \l_tmpb_tl
+ {\dim_set:Nn \l_tmpa_dim {\dim_max:nn \g_@@_x_initial_dim \g_@@_x_final_dim}
+ \dim_set_eq:NN \g_@@_x_initial_dim \l_tmpa_dim
+ \dim_set_eq:NN \g_@@_x_final_dim \l_tmpa_dim}
+% \end{macrocode}
+% Now, the coordinates of the line to draw are computed in |\g_@@_x_initial_dim|, |\g_@@_y_initial_dim|,
+% |\g_@@_x_final_dim| and |\g_@@_y_final_dim|. We can draw the line with |\l_@@_draw_tikz_line:| as usual.
+% \begin{macrocode}
\@@_draw_tikz_line:}
% \end{macrocode}
%
@@ -1383,7 +1599,7 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% \subsection{User commands available in environments {NiceMatrix}}
+% \subsection{User commands available in environments {NiceArray} and {NiceMatrix}}
%
% We give new names for the commands |\ldots|, |\cdots|, |\vdots| and |\ddots| because these commands will be
% redefined (if the option |RenewDots| is used).
@@ -1407,7 +1623,7 @@ version 2005/12/01 or later.
%
% \interitem
% The commands |\@@_Ldots|, |\@@_Cdots|, |\@@_Vdots|, |\@@_Ddots| and |\@@_Iddots| will be linked to |\Ldots|,
-% |\Cdots|, |\Vdots|, |\Ddots| and |\Iddots| in the environment |{NiceMatrix}|.
+% |\Cdots|, |\Vdots|, |\Ddots| and |\Iddots| in the environments |{NiceArray}|.
% \begin{macrocode}
\NewDocumentCommand \@@_Ldots {s}
{\IfBooleanF {#1} {\@@_instruction_of_type:n 0}
@@ -1449,7 +1665,7 @@ version 2005/12/01 or later.
%
%
% \bigskip
-% The command |\@@_Hspace:| will be linked to |\hspace| in the environment |{NiceMatrix}|.
+% The command |\@@_Hspace:| will be linked to |\hspace| in the environments |{NiceArray}|.
% \begin{macrocode}
\cs_new_protected:Nn \@@_Hspace:
{\@@_add_to_empty_cells:
@@ -1457,7 +1673,7 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
-% The command |\@@_NiceMatrixEndPoint:| will be linked to |\NiceMatrixEndPoint| in the environment |{NiceMatrix}|.
+% The command |\@@_NiceMatrixEndPoint:| will be linked to |\NiceMatrixEndPoint| in the environments |{NiceArray}|.
% \begin{macrocode}
\cs_new_protected:Nn \@@_NiceMatrixEndPoint:
{\kern 0.5pt}
@@ -1508,7 +1724,7 @@ version 2005/12/01 or later.
probably~be~wrong.}
% \end{macrocode}
%
-%
+%
% \section{History}
%
% \subsection{Changes between versions 1.0 and 1.1}
@@ -1518,6 +1734,11 @@ version 2005/12/01 or later.
% 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.
+%
+% \subsection{Changes between versions 1.1 and 1.2}
+%
+% New environment |{NiceArray}| with column types |L|, |C| and |R|.
+%
% \endinput
% Local Variables:
% TeX-fold-mode: nil
diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
index a11a958ad7b..e51cb549e77 100644
--- a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
+++ b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty
@@ -18,8 +18,8 @@
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
%%
-\def\myfileversion{1.1}
-\def\myfiledate{2018/02/26}
+\def\myfileversion{1.2}
+\def\myfiledate{2018/03/11}
\RequirePackage{l3keys2e}
\ProvidesExplPackage
{nicematrix}
@@ -42,6 +42,7 @@
\cs_new_protected:Nn \__nm_multicolumn:nn
{\msg_error:nn {nicematrix} {multicolumn~forbidden}}
\int_new:N \g__nm_env_int
+\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
@@ -58,16 +59,18 @@
Transparent .value_forbidden:n = true,
NullifyDots .bool_set:N = \l__nm_nullify_dots_bool ,
NullifyDots .default:n = true,
- Silent .code:n = {\msg_redirect_name:nnn {nicematrix}
+ Silent .code:n = {\msg_redirect_name:nnn {nicematrix}
{Impossible~instruction}
{none}} ,
- Silent .value_forbidden:n = true}
+ Silent .value_forbidden:n = true}
\NewDocumentCommand \NiceMatrixOptions {m}
{\keys_set:nn {NiceMatrix} {#1}}
-\cs_new_protected:Nn \__nm_Cell:
- {
+\keys_define:nn {NiceArray}
+ {exterior-arraycolsep .bool_set:N = \l__nm_exterior_arraycolsep_bool ,
+ exterior-arraycolsep .default:n = true}
+\cs_new_protected:Nn \__nm_Cell:n
+ { \tl_gput_right:Nn \g__nm_preamble_aux_tl {#1}
\int_gincr:N \g__nm_column_int
- \int_gset:Nn \g__nm_nb_column_int {\int_max:nn \g__nm_nb_column_int \g__nm_column_int}
\tikz[remember~picture, inner~sep = 0pt, minimum~width = 0pt, baseline]
\node [anchor=base] (nm-\int_use:N \g__nm_env_int-
\int_use:N \g__nm_line_int-
@@ -75,42 +78,58 @@
\bgroup $} % $
\cs_new_protected:Nn \__nm_end_Cell:
{$\egroup ;} % $
-\cs_new_protected:Nn \__nm_Cell_First_Column:
- {\int_gincr:N \g__nm_line_int
- \int_gset:Nn \g__nm_column_int 0
- \__nm_Cell:}
\NewDocumentEnvironment {NiceMatrix} {}
- {
- \aftergroup \__nm_draw_lines:
- \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 \Hspace \__nm_Hspace:
- \cs_set_eq:NN \NiceMatrixEndPoint \__nm_NiceMatrixEndPoint:
- \bool_if:NF \l__nm_renew_matrix_bool
- {\cs_set_eq:NN \multicolumn \__nm_multicolumn:nn}
- \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}
+ {\bool_set_false:N \l__nm_exterior_arraycolsep_bool
+ \NiceArray{*\c@MaxMatrixCols{C}}}
+ {\endarray
+ \skip_horizontal:n {-\arraycolsep}}
+\NewDocumentEnvironment {NiceArray} {O{} m}
+ {\aftergroup \__nm_draw_lines:
+ \keys_set_known:nnN {NiceArray} {#1} \l_tmpa_tl
+ \cs_set:Npn \ialign
+ {\everycr{\noalign{\int_gincr:N \g__nm_line_int
+ \int_gzero:N \g__nm_column_int
+ \int_compare:nNnT {\tl_count:N \g__nm_preamble_aux_tl}
+ > {\tl_count:N \g__nm_preamble_tl}
+ {\tl_gset_eq:NN \g__nm_preamble_tl \g__nm_preamble_aux_tl}
+ \tl_gclear:N \g__nm_preamble_aux_tl}}
+ \skip_zero:N \tabskip
+ \cs_set:Npn \ialign {\everycr{}
+ \skip_zero:N \tabskip
+ \halign}
+ \halign}
+ \newcolumntype{L}{>{\__nm_Cell:n l}l<{\__nm_end_Cell:}}
+ \newcolumntype{C}{>{\__nm_Cell:n c}c<{\__nm_end_Cell:}}
+ \newcolumntype{R}{>{\__nm_Cell:n r}r<{\__nm_end_Cell:}}
+ \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 \Hspace \__nm_Hspace:
+ \cs_set_eq:NN \NiceMatrixEndPoint \__nm_NiceMatrixEndPoint:
+ \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}
+ \bool_if:NF \l__nm_renew_matrix_bool
+ {\cs_set_eq:NN \multicolumn \__nm_multicolumn:nn}
\int_gincr:N \g__nm_env_int
+ \tl_clear_new:N \g__nm_preamble_tl
+ \tl_clear_new:N \g__nm_preamble_aux_tl
\seq_gclear_new:N \g__nm_empty_cells_seq
\int_gzero_new:N \g__nm_instruction_int
\int_gzero_new:N \g__nm_line_int
\int_gzero_new:N \g__nm_column_int
- \int_gzero_new:N \g__nm_nb_column_int
- \hskip -\arraycolsep
\cs_set_eq:NN \@ifnextchar \new@ifnextchar
- \int_set:Nn \l_tmpa_int {\c@MaxMatrixCols - 1}
- \array{>{\__nm_Cell_First_Column:}c<{\__nm_end_Cell:}
- *\l_tmpa_int{>{\__nm_Cell:}c<{\__nm_end_Cell:}}}}
- {\endarray
- \hskip -\arraycolsep}
+ \bool_if:NF \l__nm_exterior_arraycolsep_bool
+ {\skip_horizontal:n {-\arraycolsep}}
+ \array[\l_tmpa_tl]{#2}}
+ {\endarray
+ \bool_if:NF \l__nm_exterior_arraycolsep_bool
+ {\skip_horizontal:n {-\arraycolsep}}}
\NewDocumentEnvironment {pNiceMatrix} {}
{\left(\begin{NiceMatrix}}
{\end{NiceMatrix}\right)}
@@ -161,7 +180,10 @@
}
\cs_new_protected:Nn \__nm_draw_lines:
- {
+ {\int_compare:nNnT {\tl_count:N \g__nm_preamble_aux_tl}
+ > {\tl_count:N \g__nm_preamble_tl}
+ {\tl_set_eq:NN \g__nm_preamble_tl \g__nm_preamble_aux_tl}
+ \int_set:Nn \g__nm_column_int {\tl_count:N \g__nm_preamble_tl}
\seq_clear_new:N \l__nm_yet_drawn_seq
\int_zero_new:N \l__nm_type_int
\int_zero_new:N \l__nm_line_int
@@ -215,7 +237,7 @@
\bool_if:nTF { \int_compare_p:nNn \l__nm_final_i_int < 1
|| \int_compare_p:nNn \l__nm_final_i_int > \g__nm_line_int
|| \int_compare_p:nNn \l__nm_final_j_int < 1
- || \int_compare_p:nNn \l__nm_final_j_int > \g__nm_nb_column_int}
+ || \int_compare_p:nNn \l__nm_final_j_int > \g__nm_column_int}
{\bool_set_true:N \l__nm_impossible_instruction_bool
\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
@@ -233,7 +255,7 @@
{ \int_compare_p:nNn \l__nm_initial_i_int < 1
|| \int_compare_p:nNn \l__nm_initial_i_int > \g__nm_line_int
|| \int_compare_p:nNn \l__nm_initial_j_int < 1
- || \int_compare_p:nNn \l__nm_initial_j_int > \g__nm_nb_column_int}
+ || \int_compare_p:nNn \l__nm_initial_j_int > \g__nm_column_int}
{\bool_set_true:N \l__nm_impossible_instruction_bool
\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
@@ -269,9 +291,9 @@
\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__nm_env_int-
- \int_use:N \l__nm_final_i_int-
- \int_use:N \l__nm_final_j_int.#2)
+ (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} }
@@ -283,6 +305,17 @@
\__nm_draw_tikz_line:}
\cs_new_protected:Nn \__nm_draw_vdots_line:
{\__nm_retrieve_coords:nn {south} {north}
+ \tl_set:Nx \l_tmpa_tl {\tl_item:Nn \g__nm_preamble_tl \l__nm_initial_j_int}
+ \tl_set:Nn \l_tmpb_tl {l}
+ \tl_if_eq:NNT \l_tmpa_tl \l_tmpb_tl
+ {\dim_set:Nn \l_tmpa_dim {\dim_min:nn \g__nm_x_initial_dim \g__nm_x_final_dim}
+ \dim_set_eq:NN \g__nm_x_initial_dim \l_tmpa_dim
+ \dim_set_eq:NN \g__nm_x_final_dim \l_tmpa_dim}
+ \tl_set:Nn \l_tmpb_tl {r}
+ \tl_if_eq:NNT \l_tmpa_tl \l_tmpb_tl
+ {\dim_set:Nn \l_tmpa_dim {\dim_max:nn \g__nm_x_initial_dim \g__nm_x_final_dim}
+ \dim_set_eq:NN \g__nm_x_initial_dim \l_tmpa_dim
+ \dim_set_eq:NN \g__nm_x_final_dim \l_tmpa_dim}
\__nm_draw_tikz_line:}
\cs_new_protected:Nn \__nm_draw_ddots_line:
{\__nm_retrieve_coords:nn {south~east} {north~west}