summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/nicematrix
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-05-01 17:57:18 +0000
committerKarl Berry <karl@freefriends.org>2018-05-01 17:57:18 +0000
commit08ba64265f0add4eebf9496610c9e49d0470734f (patch)
tree92b9355bf2e6cf89f8ed82269a42290cb986d9cc /Master/texmf-dist/source/latex/nicematrix
parent0f529fdea1a21b9f20b3f03d2919d8f07dfcdb4e (diff)
nicematrix (16apr18)
git-svn-id: svn://tug.org/texlive/trunk@47545 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/nicematrix')
-rw-r--r--Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx380
1 files changed, 311 insertions, 69 deletions
diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx
index c6f81ecfd46..5093c59642a 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.3}
-\def\myfiledate{2018/03/31}
+\def\myfileversion{1.4}
+\def\myfiledate{2018/04/16}
%
%
%<*batchfile>
@@ -70,8 +70,8 @@ version 2005/12/01 or later.
%
% \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 is the possibility to draw continuous ellipsis
-% dots between the cells of the array.
+% |{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}
%
% \vspace{1cm}
@@ -79,8 +79,8 @@ version 2005/12/01 or later.
%
%
% 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}.
+% |latex|-|dvips|-|ps2pdf| (or Adobe Distiller). Two or three compilations may be necessary. This package requires
+% the packages \pkg{expl3}, \pkg{l3keys2e}, \pkg{xparse}, \pkg{array}, \pkg{mathtools} and \pkg{tikz}.
%
% \medskip
% The package \pkg{nicematrix} aims to draw beautiful matrices in a way almost transparent for the user.
@@ -247,7 +247,10 @@ version 2005/12/01 or later.
%
% \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.
+% 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
@@ -362,6 +365,9 @@ version 2005/12/01 or later.
% \medskip
% The option |nullify-dots| smashes the instructions |\Ldots| (and the variants) vertically but also horizontally.
%
+%
+%
+% \vskip1cm
% \section{How to use nicematrix for existing code}
%
% The package \pkg{nicematrix} provides an option called |transparent| for using existing code transparently in the
@@ -426,12 +432,13 @@ version 2005/12/01 or later.
% \item The commands |\Cdots| and its variants are available in the environment |{NiceArray}|.
% \item The environment |{NiceArray}| accepts (between brackets) the options |t|, |c| and |b| as the classical
% |{array}| but also the following options defined by \pkg{nicematrix}: |renew-dots|, |nullify-dots|,
-% |exterior-arraycolsep| and |parallelize-diags| (these last two options are technical options described further).
-% \item For technical reasons, in the preamble of |{NiceArray}|, the user
-% must use the letters |L|, |C| and |R|\footnote{The column types |L|, |C| and |R| are defined locally inside
+% |columns-width| (explained below), |exterior-arraycolsep| and |parallelize-diags| (these last two options are
+% technical options described further).
+% \item For technical reasons, in the preamble of the environment |{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.
+% 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.
% \end{itemize}
%
%
@@ -475,6 +482,61 @@ version 2005/12/01 or later.
% a_{n-1,1} & \Cdots & a_{n-1,n} \\
% \end{NiceArray}\right)$
%
+% \vskip1cm
+% As in the environment |{array}| of the extension \pkg{array}, it's possible to fix the width of a column by using
+% the letter |w| or the letter |W| in the preamble. In the following example, the width of the third column is
+% fixed to 1~cm.\par\nobreak
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
+% $\left(\begin{NiceArray}{CC~emphase#w{c}{1cm}@}
+% 1 & 2 & 3 \\
+% 4 & 5 & 6 \\
+% 7 & 8 & 9
+% \end{NiceArray}\right)$
+% \end{BVerbatim}
+% $\left(\begin{NiceArray}{CCw{c}{1cm}}
+% 1 & 2 & 3 \\
+% 4 & 5 & 6 \\
+% 7 & 8 & 9
+% \end{NiceArray}\right)$
+%
+% \bigskip
+% However, the environment |{NiceArray}| and the other environments defined in this extension have an option called
+% |columns-width| which fixes the width of all columns of the matrix.\par\nobreak
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
+% $\begin{pNiceMatrix}[~emphase#columns-width = 1cm@]
+% 1 & 12 & -123 \\
+% 12 & 0 & 0 \\
+% 4 & 1 & 2
+% \end{pNiceMatrix}$
+% \end{BVerbatim}
+% $\begin{pNiceMatrix}[columns-width = 1cm]
+% 1 & 12 & -123 \\
+% 12 & 0 & 0 \\
+% 4 & 1 & 2
+% \end{pNiceMatrix}$
+%
+% \medskip
+% Note that the space inserted between two columns (equal to 2 |\arraycolsep|) is not suppressed.
+%
+% \bigskip
+% It's also 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. \emph{Two or three compilations may be necessary}.\par\nobreak
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=10cm]
+% $\begin{pNiceMatrix}[~emphase#columns-width = auto@]
+% 1 & 12 & -123 \\
+% 12 & 0 & 0 \\
+% 4 & 1 & 2
+% \end{pNiceMatrix}$
+% \end{BVerbatim}
+% $\left(\begin{NiceArray}[columns-width = auto]{CCC}
+% 1 & 12 & -123 \\
+% 12 & 0 & 0 \\
+% 4 & 1 & 2
+% \end{NiceArray}\right)$
+%
%
% \section{The environment \{pNiceArrayC\} and its variants}
%
@@ -492,15 +554,17 @@ version 2005/12/01 or later.
% \item The environment |{pNiceArrayC}| takes a mandatory argument which is the preamble of the array. The types
% of columns available are the same as for the environment |{NiceArray}|. \emph{However, no specification must be
% given for the last column:} it will automatically (and necessarily) be a column~|L|.
-% \item The options available are |renew-dots|, |nullify-dots|, |parallelize-diags| (this technical option is
-% described further) and |code-for-last-col|. This last option specifies tokens that will be inserted before each
+% \item The options available are |columns-width| (doesn't apply to the exterior column), |renew-dots|,
+% |nullify-dots|, |parallelize-diags| (this technical option is described further) and an option specific to these
+% environments, called |code-for-last-col|. This last option specifies tokens that will be inserted before each
% cell of the last column, \emph{before} the symbol |$| of the math mode.
% \end{itemize}
%
%
% \bigskip
% \begin{BVerbatim}[baseline=c]
-% \begin{pNiceArrayC}{RRRR|R}[~emphase#code-for-last-col={\small\color{blue}}@]
+% \begin{pNiceArrayC}{RRRR|R}[~emphase#code-for-last-col={\small\color{blue}}@,
+% columns-width=auto]
% 1& 2& 2& 3& -2 \\
% 0& 0& -1& 5& -5 & L_2 \gets 2L_1-L_2 \\
% 0& -1& -3& 3& -7 & L_3 \gets L_1-L_3
@@ -508,7 +572,8 @@ version 2005/12/01 or later.
% \end{BVerbatim}
%
% \smallskip
-% \[\begin{pNiceArrayC}{RRRR|R}[code-for-last-col={\small\color{blue}}]
+% \[\begin{pNiceArrayC}{RRRR|R}[code-for-last-col={\small\color{blue}},
+% columns-width=auto]
% 1& 2& 2& 3& -2 \\
% 0& 0& -1& 5& -5 & L_2 \gets 2L_1-L_2 \\
% 0& -1& -3& 3& -7 & L_3 \gets L_1-L_3
@@ -795,6 +860,7 @@ version 2005/12/01 or later.
% \bigskip
% \subsection{Technical definitions}
%
+%
% 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.
@@ -833,6 +899,12 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
+% The dimension |\l_@@_columns_width_dim| will be used when the options specify that all the columns must have the
+% same width.
+% \begin{macrocode}
+\dim_new:N \l_@@_columns_width_dim
+% \end{macrocode}
+% \bigskip
% \subsection{The options}
%
% The token list |\l_@@_pos_env_tl| will contains one of the three values |t|, |c| or |b| and will indicate to
@@ -874,6 +946,14 @@ version 2005/12/01 or later.
% \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}|).
+% \begin{macrocode}
+\bool_new:N \l_@@_auto_columns_width_bool
+% \end{macrocode}
+%
+% \bigskip
% The token list |\l_@@_code_for_last_col_tl| will contains code inserted at the beginning of each cell\footnote{At
% the beginning of each cell but before the character |$| of the mathematical mode.} of the last
% column in the environment |{pNiceArrayC}| (and its variants). It corresponds to the option |code-for-last-col|.
@@ -925,6 +1005,7 @@ version 2005/12/01 or later.
NullifyDots .meta:n = nullify-dots,
% \end{macrocode}
%
+%
% \bigskip
% With the option |silent|, no error is generated for the impossible instructions. This option can be useful when
% adapting an existing code.
@@ -951,7 +1032,24 @@ version 2005/12/01 or later.
% \begin{macrocode}
exterior-arraycolsep .bool_set:N = \l_@@_exterior_arraycolsep_bool ,
exterior-arraycolsep .default:n = true,
- unknown .code:n = \msg_error:nn {nicematrix} {Option~unknown}}
+ unknown .code:n = \msg_error:nn {nicematrix} {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,~
+ nullify-dots,~
+ parallelize-diags,~
+ renew-dots,~
+ renew-matrix~
+ and~transparent}
% \end{macrocode}
%
% \bigskip
@@ -966,13 +1064,35 @@ version 2005/12/01 or later.
% \bigskip
% \begin{macrocode}
\keys_define:nn {NiceMatrix/NiceMatrix}
- {parallelize-diags .bool_set:N = \l_@@_parallelize_diags_bool,
- parallelize-diags .default:n = true,
- renew-dots .bool_set:N = \l_@@_renew_dots_bool,
- renew-dots .default:n = true,
- nullify-dots .bool_set:N = \l_@@_nullify_dots_bool ,
- nullify-dots .default:n = true,
- unknown .code:n = \msg_error:nn {nicematrix} {Option~unknown}}
+ {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 it 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}},
+ unknown .code:n = \msg_error:nn {nicematrix} {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):~
+ columns-width,~
+ nullify-dots,~
+ parallelize-diags~
+ and~renew-dots.}
% \end{macrocode}
%
% \bigskip
@@ -986,6 +1106,10 @@ version 2005/12/01 or later.
nullify-dots .default:n = true,
exterior-arraycolsep .bool_set:N = \l_@@_exterior_arraycolsep_bool ,
exterior-arraycolsep .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,
% \end{macrocode}
%
% \bigskip
@@ -995,9 +1119,26 @@ version 2005/12/01 or later.
c .code:n = \tl_set:Nn \l_@@_pos_env_tl c,
t .code:n = \tl_set:Nn \l_@@_pos_env_tl t,
b .code:n = \tl_set:Nn \l_@@_pos_env_tl b,
- unknown .code:n = \msg_error:nn {nicematrix} {Option~unknown}}
+ unknown .code:n = \msg_error:nn {nicematrix} {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,~
+ columns-width,~
+ exterior-arraycolsep,~
+ nullify-dots,~
+ parallelize-diags,~
+ renew-dots~
+ and~t.}
+% \end{macrocode}
%
% \bigskip
% \subsection{The environments \{NiceArray\} and \{NiceMatrix\}}
@@ -1011,27 +1152,34 @@ version 2005/12/01 or later.
% explanations).
% \begin{macrocode}
\cs_new_protected:Nn \@@_Cell:n
- { \tl_gput_right:Nn \g_@@_preamble_aux_tl {#1}
+ {\tl_gput_right:Nn \g_@@_preamble_aux_tl {#1}
% \end{macrocode}
% We increment |\g_@@_column_int|, which is the counter of the columns.
% \begin{macrocode}
\int_gincr:N \g_@@_column_int
+ \hbox_set:Nw \l_tmpa_box $} % $
% \end{macrocode}
%
-% We create a Tikz node for the current cell of the array.
% \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}|).
+% \begin{macrocode}
+ \dim_gset:Nn \g_@@_max_cell_width_dim
+ {\dim_max:nn \g_@@_max_cell_width_dim {\box_wd:N \l_tmpa_box}}
\tikz[remember~picture, inner~sep = 0pt, minimum~width = 0pt, baseline]
\node [anchor=base] (nm-\int_use:N \g_@@_env_int-
\int_use:N \g_@@_row_int-
\int_use:N \g_@@_column_int)
- \bgroup $} % $
-% \end{macrocode}
-%
-% \begin{macrocode}
-\cs_new_protected:Nn \@@_end_Cell:
- {$\egroup ;} % $
+ \bgroup
+ \box_use:N \l_tmpa_box
+ \egroup ;}
% \end{macrocode}
%
+%
% \interitem
% The environment |{NiceArray}| is the main environment of the extension \pkg{nicematrix}.
%
@@ -1055,7 +1203,8 @@ version 2005/12/01 or later.
{\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}}}
+ \NiceArray{*\c@MaxMatrixCols{C}}
+ }
{\endarray
\skip_horizontal:n {-\arraycolsep}}
% \end{macrocode}
@@ -1069,10 +1218,29 @@ version 2005/12/01 or later.
% \end{itemize}
%
% \begin{macrocode}
+\cs_generate_variant:Nn \dim_set:Nn {Nx}
\NewDocumentEnvironment {NiceArray} {O{} m O{}}
- {\aftergroup \@@_draw_lines:
+ {\aftergroup \@@_write_max_cell_width:
+ \aftergroup \@@_draw_lines:
+% \end{macrocode}
+%
+% We increment the counter |\g_@@_env_int| which counts the environments |{NiceArray}|.
+% \begin{macrocode}
+ \int_gincr:N \g_@@_env_int
+ \dim_gzero_new:N \g_@@_max_cell_width_dim
\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).
+% \begin{macrocode}
+ \bool_if:NT \l_@@_auto_columns_width_bool
+ {\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}
% 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_@@_row_int|).
% The solution is to give to |\ialign| a new definition (giving to |\everycr| the value we want)
@@ -1085,28 +1253,64 @@ version 2005/12/01 or later.
\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 rows of the array
-% may be shorter (that is to say without all the ampersands) and it's not possible to known which row will be the
+% may be shorter (that is to say without all the ampersands) and it's not possible to know which row will be the
% longest. That's why, during the construction of a row, we retrieve the corresponding preamble in
% |\g_@@_preamble_aux_tl|. At the end of the array, we are sure that the longest value will be the real preamble of
% the array (stored in |\g_@@_preamble_tl|).
% \begin{macrocode}
- \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}}
+ \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:}}
+ \dim_compare:nNnTF \l_@@_columns_width_dim = \c_zero_dim
+ {\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}
+% 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.
+% \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}}}
+% \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.
+% \begin{macrocode}
+ \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:n ##1}
+ 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:n ##1}
+ 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}|.
% \begin{macrocode}
\cs_set_eq:NN \Ldots \@@_Ldots
@@ -1126,10 +1330,6 @@ version 2005/12/01 or later.
{\cs_set_eq:NN \multicolumn \@@_multicolumn:nn}
% \end{macrocode}
%
-% We increment the counter |\g_@@_env_int| which counts the environments |{NiceArray}|.
-% \begin{macrocode}
- \int_gincr:N \g_@@_env_int
-% \end{macrocode}
%
% We have to remind the types of the columns (|l|, |c| or |r|) because we will use this information when we will
% draw the vertical dotted lines. That's why we store the types of the columns in |\g_@@_preamble_tl| (for example,
@@ -1222,6 +1422,20 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \interitem
+% For the option \verb|columns-width=auto|, we want to known 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: that's why we store this value in the main |.aux| file and
+% it will be available in the next run.
+% \begin{macrocode}
+\cs_new:Nn \@@_write_max_cell_width:
+ {\iow_now:Nx \@mainaux
+ {\ExplSyntaxOn
+ \cs_gset:cpn {_@@_max_cell_width_\int_use:N \g_@@_env_int}
+ {\dim_use:N \g_@@_max_cell_width_dim}
+ \ExplSyntaxOff}}
+% \end{macrocode}
+%
+% \interitem
% The conditionnal |\@@_if_not_empty_cell:nnT| test 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}
@@ -1849,13 +2063,6 @@ version 2005/12/01 or later.
\token_to_str:N \multicolumn.~You~can~go~on~but~your~line~will~
probably~be~wrong.}
% \end{macrocode}
-%
-% \begin{macrocode}
-\msg_new:nnn {nicematrix}
- {Option~unknown}
- {The~option~"\tl_use:N\l_keys_key_tl"~is~unknown~or~
- meaningless~in~the~context.~If~you~go~on,~it~will~be~ignored.}
-% \end{macrocode}
%
% \bigskip
% \subsection{The environment \{pNiceArrayC\} and its variants}
@@ -1868,15 +2075,35 @@ version 2005/12/01 or later.
%
% \begin{macrocode}
\keys_define:nn {NiceMatrix/NiceArrayC}
- {parallelize-diags .bool_set:N = \l_@@_parallelize_diags_bool,
- parallelize-diags .default:n = true,
- renew-dots .bool_set:N = \l_@@_renew_dots_bool,
- renew-dots .default:n = true,
- nullify-dots .bool_set:N = \l_@@_nullify_dots_bool ,
- nullify-dots .default:n = true,
- code-for-last-col .tl_set:N = \l_@@_code_for_last_col_tl,
- code-for-last-col .value_required:n = true,
- unknown .code:n = \msg_error:nn {nicematrix} {Option~unknown}}
+ {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,
+ unknown .code:n = \msg_error:nn {nicematrix} {Unknown~option~for~pNiceArrayC}}
+% \end{macrocode}
+%
+% \begin{macrocode}
+\msg_new:nnnn {nicematrix}
+ {Unknown~option~for~pNiceArrayC}
+ {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-for-last-col,~
+ columns-width,~
+ nullify-dots,~
+ parallelize-diags~
+ and~renew-dots.}
% \end{macrocode}
%
% \bigskip
@@ -1904,20 +2131,28 @@ version 2005/12/01 or later.
% to store the content of the cell in the box |\l_tmpa_box|. This is allowed in \pkg{expl3} with the construction
% |\hbox_set:Nw \l_tmpa_box| ... |\hbox_set_end:|.
% \begin{macrocode}
- >{\hbox_set:Nw \l_tmpa_box
+ >{\int_gincr:N \g__nm_column_int
+ \hbox_set:Nw \l_tmpa_box
\l_@@_code_for_last_col_tl
- \@@_Cell:n l}
- l
- <{\@@_end_Cell:
- \hbox_set_end:
+ \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_row_int-
+ \int_use:N \g__nm_column_int)
+ \bgroup $ % $
+ }
+ l
% \end{macrocode}
%
% We actualize the value of |\g_@@with_last_col_dim| which, at the end of the array, will contains the maximal width
% of the cells of the last column (thus, it will be equal to the width of the last column).
% \begin{macrocode}
+ <{ $ % $
+ \egroup ;
+ \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}}
+ \tl_gput_right:Nn \g__nm_preamble_aux_tl {#1}
\skip_horizontal:n {-2\arraycolsep}
% \end{macrocode}
% The content of the cell is inserted in a overlapping position.
@@ -1976,7 +2211,7 @@ version 2005/12/01 or later.
\@@_after_last_col:}
% \end{macrocode}
%
-%
+%
%
% \section{History}
%
@@ -2007,6 +2242,13 @@ version 2005/12/01 or later.
% 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}.
+%
+% New option |columns-width| to fix the same width for all the columns of the array.
+%
% \endinput
% Local Variables:
% TeX-fold-mode: nil