diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx | 426 |
1 files changed, 283 insertions, 143 deletions
diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx index 3e91e797955..6c750cab7f0 100644 --- a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx +++ b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx @@ -1,4 +1,4 @@ -% \iffalse meta-comment +% \iffalse meta-comment % % Copyright (C) 2018-2019 by F. Pantigny % ----------------------------------- @@ -15,8 +15,8 @@ % % \fi % \iffalse -\def\myfileversion{3.1} -\def\myfiledate{2019/09/04} +\def\myfileversion{3.2} +\def\myfiledate{2019/09/19} % % %<*batchfile> @@ -112,10 +112,10 @@ c & c & b & a & e % % 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 +% three compilations may be necessary. This package requires and \textbf{loads} the % packages \pkg{expl3}, \pkg{l3keys2e}, \pkg{xparse}, \pkg{array}, \pkg{amsmath} -% and \pkg{tikz}. It also loads the Tikz library \pkg{fit}. -% +% and \pkg{tikz}. It also loads the Tikz library \pkg{fit}. The final user only +% has to load the extension with |\usepackage{nicematrix}|. % % % \medskip @@ -123,13 +123,12 @@ c & c & b & a & e % \begin{minipage}{0.6\linewidth} % 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 +% \begin{itemize}\setlength{\itemsep}{0pt} +% \item continuous dotted lines\footnote{If the class option |draft| is % used, these dotted lines will not be drawn for a faster compilation.}; -% -% \textbullet\ exterior row and columns for labels; -% -% \textbullet\ a control of the width of the columns. +% \item exterior rows and columns for labels; +% \item a control of the width of the columns. +% \end{itemize} % \end{minipage} % \end{savenotes} % \hspace{1.4cm} @@ -144,9 +143,9 @@ c & c & b & a & e % L_n & a_{n1} & a_{n2} & \Cdots & a_{nn} % \end{bNiceArray}$ % -% \medskip -% A command |\NiceMatrixOptions| is provided to fix the options (the scope of -% the options fixed by this command is the current TeX group). +% \medskip +% A command |\NiceMatrixOptions| is provided to fix the options (the +% scope of the options fixed by this command is the current TeX group). % % % \bigskip @@ -182,8 +181,8 @@ c & c & b & a & e % \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 \\ @@ -210,7 +209,7 @@ c & c & b & a & e % \{VNiceMatrix\} & & \{NiceArrayWithDelims\} \\ % \end{tabular} % \end{ttfamily} -% +%b % % \medskip % By default, the environments |{NiceMatrix}|, |{pNiceMatrix}|, |{bNiceMatrix}|, @@ -251,7 +250,9 @@ c & c & b & a & e % ``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 +% |\Iddots| diagonal ones.\par\nobreak +% +% \bigskip % \begin{BVerbatim}[baseline=c,boxwidth=10cm] % \begin{bNiceMatrix} % a_1 & \Cdots & & & a_1 \\ @@ -269,9 +270,11 @@ c & c & b & a & e % a_1 & a_2 & & & a_n % \end{bNiceMatrix}$ % -% \interitem +% \interitem % In order to represent the null matrix, one can use the following -% codage:\par\nobreak \bigskip +% codage:\par\nobreak +% +% \bigskip % \begin{BVerbatim}[baseline=c,boxwidth=10cm] % \begin{bNiceMatrix} % 0 & \Cdots & 0 \\ @@ -288,7 +291,9 @@ c & c & b & a & e % \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 +% with \pkg{nicematrix}:\par\nobreak +% +% \bigskip % \begin{BVerbatim}[baseline=c,boxwidth=10cm] % \begin{bNiceMatrix} % 0 & \Cdots & \Cdots & 0 \\ @@ -313,6 +318,7 @@ c & c & b & a & e % \bigskip % In fact, in this example, it would be possible to draw the same matrix more % easily with the following code:\par\nobreak +% % \bigskip % \begin{BVerbatim}[baseline=c,boxwidth=10cm] % \begin{bNiceMatrix} @@ -341,6 +347,7 @@ c & c & b & a & e % 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} @@ -384,6 +391,7 @@ c & c & b & a & e % \bigskip % 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} @@ -408,6 +416,7 @@ c & c & b & a & e % By default, with \pkg{nicematrix}, if we replace |{pmatrix}| by % |{pNiceMatrix}| and |\vdots| by |\Vdots|, the geometry of the matrix is not % changed.\par\nobreak +% % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=8cm] % $C = \begin{pNiceMatrix} @@ -433,6 +442,7 @@ c & c & b & a & e % 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@] @@ -511,7 +521,7 @@ c & c & b & a & e % % \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 +% square brackets) which is used for fine tuning of the space between two % consecutive dots. For homogeneity, |\Hdotsfor| has also an optional argument % but this argument is discarded silently. % @@ -533,6 +543,7 @@ c & c & b & a & e % % \begin{itemize} % \item The option |renew-dots|\par\nobreak +% % With this option, the commands |\ldots|, |\cdots|, |\vdots|, |\ddots|, % |\iddots|\footnotemark[\thefniddots] and |\hdotsfor| are redefined within the environments % provided by \pkg{nicematrix} and behave like |\Ldots|, |\Cdots|, |\Vdots|, @@ -540,6 +551,7 @@ c & c & b & a & e % 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} @@ -547,6 +559,7 @@ c & c & b & a & e % \bigskip % Therefore, with the option |transparent|, a classical code gives directly the % ouput of \pkg{nicematrix}.\par\nobreak +% % \bigskip % \begin{scope} % \NiceMatrixOptions{transparent} @@ -1133,6 +1146,7 @@ c & c & b & a & e % 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@] @@ -1150,6 +1164,7 @@ c & c & b & a & e % \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 +% % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=8.5cm] % ~emphase#\NiceMatrixOptions{columns-width=10mm}@ @@ -1244,7 +1259,7 @@ c & c & b & a & e % One may wish raise the size of the ``$A$'' placed in the block of the previous % example. Since this element is composed in math mode, it's not possible to use % directly a command like |\large|, |\Large| and |\LARGE|. That's why the command -% |\Block| provides an option beetween angle brackets to specificy some TeX code +% |\Block| provides an option between angle brackets to specificy some TeX code % which will be inserted before the beginning of the math mode. % % \medskip @@ -1276,6 +1291,51 @@ c & c & b & a & e % write |\Block{|$i$|-|$j$|}<>{<}| with the expected result. % % +% +% \section{The option small} +% +% With the option |small|, the environments of the extension \pkg{nicematrix} +% are composed in a way similar to the environment |{smallmatrix}| of the +% extension \pkg{amsmath} (and the environments |{psmallmatrix}|, +% |{bsmallmatrix}|, etc. of the extension \pkg{mathtools}). +% +% \bigskip +% \begin{Verbatim} +% $\begin{bNiceArray}{CCCC|C}[~emphase#small@, +% last-col, +% code-for-last-col = \scriptscriptstyle, +% columns-width = 3mm ] +% 1 & -2 & 3 & 4 & 5 \\ +% 0 & 3 & 2 & 1 & 2 & L_2 \gets 2 L_1 - L_2 \\ +% 0 & 1 & 1 & 2 & 3 & L_3 \gets L_1 + L_3 \\ +% \end{bNiceArray}$ +% \end{Verbatim} +% % +% \[\begin{bNiceArray}{CCCC|C}[small, last-col, +% code-for-last-col = \scriptscriptstyle, columns-width=3mm] +% 1 & -2 & 3 & 4 & 5 \\ +% 0 & 3 & 2 & 1 & 2 & L_2 \gets 2 L_1 - L_2 \\ +% 0 & 1 & 1 & 2 & 3 & L_3 \gets L_1 + L_3 \\ +% \end{bNiceArray}\] +% +% +% +% \bigskip +% One should note that the environment |{NiceMatrix}| with the option |small| is +% not composed \emph{exactly} as the environment |{smallmatrix}|. Indeed, all the +% environments of \pkg{nicematrix} are constructed upon |{array}| (of the +% extension \pkg{array}) whereas the environment |{smallmatrix}| is constructed +% directly with an |\halign| of TeX. +% +% \medskip +% In fact, the option |small| corresponds to the following tuning: +% \begin{itemize} +% \item the cells of the array are composed with \verb|\scriptstyle| ; +% \item \verb|\arraystretch| is set to $0.47$ ; +% \item \verb|\arraycolsep| is set to $1.45$~pt ; +% \item the characteristics of the dotted lines are also modified. +% \end{itemize} +% % \section{The option hlines} % % You can add horizontal rules between rows in the environments of @@ -1656,6 +1716,7 @@ c & c & b & a & e % \vspace{2cm} % % An example with |\Iddots|: \par\nobreak +% % \bigskip % \begin{BVerbatim}[baseline=c] % $\begin{pNiceMatrix} @@ -1676,6 +1737,7 @@ c & c & b & a & e % % \vspace{2cm} % An example with |\multicolumn|:\par\nobreak +% % \bigskip % \begin{BVerbatim} % \begin{BNiceMatrix}[nullify-dots] @@ -1696,6 +1758,7 @@ c & c & b & a & e % % \vspace{2cm} % An example with |\Hdotsfor|:\par\nobreak +% % \bigskip % \begin{BVerbatim}[baseline=c,boxwidth=11cm] % \begin{pNiceMatrix}[nullify-dots] @@ -1720,6 +1783,7 @@ c & c & b & a & e % % \vspace{2cm} % An example for the resultant of two polynoms:\par\nobreak +% % \bigskip % \begin{BVerbatim} % \setlength{\extrarowheight}{1mm} @@ -2451,6 +2515,27 @@ c & c & b & a & e % \end{macrocode} % % \bigskip +% The length |\l_@@_inter_dots_dim| is the distance between two dots for the +% dotted lines. The default value is 0.45~em but it will be changed if the +% option |small| is used. +% \begin{macrocode} +\dim_new:N \l_@@_inter_dots_dim +\dim_set:Nn \l_@@_inter_dots_dim { 0.45 em } +% \end{macrocode} +% The length |\l_@@_radius_dim| is the radius of the dots for the dotted lines. +% The default value is 0.34~pt but it will changed if the option |small| is used. +% \begin{macrocode} +\dim_new:N \l_@@_radius_dim +\dim_set:Nn \l_@@_radius_dim { 0.53 pt } +% \end{macrocode} +% +% \bigskip +% The name of the current environment (will be used only in the error messages). +% \begin{macrocode} +\str_new:N \g_@@_type_env_str +% \end{macrocode} +% +% \bigskip % \subsubsection{Variables for the exterior rows and columns} % % The keys for the exterior rows and columns are |first-row|, |first-col|, @@ -2487,7 +2572,7 @@ c & c & b & a & e % as specified by the key |last-row|. A value of $-2$ means that there is no % ``last row''. A value of $-1$ means that there is a ``last row'' but we don't % know the number of that row (the key |last-row| has been used without value -% and has not still been read in the |aux|). +% and the actual value has not still been read in the |aux| file). % \begin{macrocode} \int_new:N \l_@@_last_row_int \int_set:Nn \l_@@_last_row_int { -2 } @@ -2768,16 +2853,15 @@ c & c & b & a & e % % % -% % \bigskip % First, we define a set of keys ``|NiceMatrix / Global|'' which will be used % (with the mechanism of |.inherit:n|) by other sets of keys. % \begin{macrocode} \keys_define:nn { NiceMatrix / Global } { + small .bool_set:N = \l_@@_small_bool , hlines .bool_set:N = \l_@@_hlines_bool , parallelize-diags .bool_set:N = \l_@@_parallelize_diags_bool , - parallelize-diags .default:n = true , % \end{macrocode} % % \bigskip @@ -2786,9 +2870,7 @@ c & c & b & a & e % |\Vdots| and |\Ddots|. % \begin{macrocode} 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 @@ -2799,7 +2881,6 @@ c & c & b & a & e % the |w|~node is used instead of the ``medium'' node.} % \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 , @@ -2815,7 +2896,7 @@ c & c & b & a & e % % \bigskip % The following set of keys concerns the options to \emph{customize} the -% exterior columns, that is to say the options |code-for-first-row|, etc. +% exterior rows and columns, that is to say the options |code-for-first-row|, etc. % \begin{macrocode} \keys_define:nn { NiceMatrix / Code } { @@ -2916,7 +2997,6 @@ c & c & b & a & e % 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 , % \end{macrocode} % % \bigskip @@ -3061,6 +3141,7 @@ c & c & b & a & e % \begin{macrocode} \hbox_set:Nw \l_tmpa_box \c_math_toggle_token + \bool_if:NT \l_@@_small_bool \scriptstyle \int_compare:nNnTF \g_@@_row_int = \c_zero_int \l_@@_code_for_first_row_tl { @@ -3366,6 +3447,18 @@ c & c & b & a & e \cs_new_protected:Npn \@@_pre_array: { % \end{macrocode} +% If the option |small| is used, we have to do some tuning. In particular, we +% change the value of |\arraystretch| (this parameter is used in the +% construction of |\@arstrutbox| in the beginning of |{array}|). +% \begin{macrocode} + \bool_if:NT \l_@@_small_bool + { +% \end{macrocode} +% \begin{macrocode} + \cs_set:Npn \arraystretch { 0.47 } + \dim_set:Nn \arraycolsep { 1.45 pt } + } +% \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 @@ -3417,16 +3510,11 @@ c & c & b & a & e \bool_gset_eq:NN \g_@@_NiceArray_bool \l_@@_NiceArray_bool \bool_gset_eq:NN \g_@@_last_row_without_value_bool \l_@@_last_row_without_value_bool + \bool_gset_eq:NN \g_@@_small_bool \l_@@_small_bool % \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}|)} +% The environment |{array}| uses internally the command |\ialign|. We change the +% definition of |\ialign| for several reasons. In particular, |\ialign| sets +% |\everycr| to |{ }|. However, we have to change the value of |\everycr|. % \begin{macrocode} \cs_set:Npn \ialign { @@ -3440,6 +3528,37 @@ c & c & b & a & e } { \everycr { \@@_everycr: } } \tabskip = \c_zero_skip +% \end{macrocode} +% The box |\@arstrutbox| is a box constructed in the beginning of the +% environment |{array}|. The construction of that box takes into account the +% current values of |\arraystretch|\footnote{The option |small| of +% \pkg{nicematrix} changes (among other) the value of |\arraystretch|. This is +% done, of course, before the call of |{array}|.} and |\extrarowheight| (of +% \pkg{array}). That box is inserted (via |\@arstrut|) in the beginning of each +% row of the array. That's why we use the dimensions of that box to initialize +% the variables which will be the dimensions of the potential first and last row +% of the environment. This initialization must be done after the creation of +% |\@arstrutbox| and that's why we do it in the |\ialign|. +% \begin{macrocode} + \dim_gzero_new:N \g_@@_dp_row_zero_dim + \dim_gset:Nn \g_@@_dp_row_zero_dim { \box_dp:N \@arstrutbox } + \dim_gzero_new:N \g_@@_ht_row_zero_dim + \dim_gset:Nn \g_@@_ht_row_zero_dim { \box_ht:N \@arstrutbox } + \dim_gzero_new:N \g_@@_ht_row_one_dim + \dim_gset:Nn \g_@@_ht_row_one_dim { \box_ht:N \@arstrutbox } + \dim_gzero_new:N \g_@@_dp_ante_last_row_dim + \dim_gset:Nn \g_@@_dp_ante_last_row_dim { \box_dp:N \@arstrutbox } + \dim_gzero_new:N \g_@@_ht_last_row_dim + \dim_gset:Nn \g_@@_ht_last_row_dim { \box_ht:N \@arstrutbox } + \dim_gzero_new:N \g_@@_dp_last_row_dim + \dim_gset:Nn \g_@@_dp_last_row_dim { \box_dp:N \@arstrutbox } +% \end{macrocode} +% After its first utilisation, the definition of |\ialign| will revert +% automatically to its default definition. With this programmation, we will +% have, in the cells of the array, a clean version of |\ialign|.\footnote{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 { } @@ -3542,12 +3661,6 @@ c & c & b & a & e \cs_set_eq:NN \NC@find@W \relax \@@_renewcolumntype:nn w { } \@@_renewcolumntype:nn W { \cs_set_eq:NN \hss \hfil } - \dim_gzero_new:N \g_@@_dp_row_zero_dim - \dim_gzero_new:N \g_@@_ht_row_zero_dim - \dim_gzero_new:N \g_@@_ht_row_one_dim - \dim_gzero_new:N \g_@@_dp_ante_last_row_dim - \dim_gzero_new:N \g_@@_ht_last_row_dim - \dim_gzero_new:N \g_@@_dp_last_row_dim % \end{macrocode} % % \bigskip @@ -3629,6 +3742,8 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { NiceArrayWithDelims } { m m O { } m ! O { } } { + \str_if_empty:NT \g_@@_type_env_str + { \str_gset:Nn \g_@@_type_env_str { NiceArrayWithDelims } } \@@_adapt_S_column: \@@_test_if_math_mode: \bool_if:NT \l_@@_in_env_bool { \@@_fatal:n { Yet~in~env } } @@ -3686,7 +3801,7 @@ c & c & b & a & e { \bool_set_true:N \l_@@_last_row_without_value_bool % \end{macrocode} -% A value based the name is more reliable than a value based on the number of +% A value based on the name is more reliable than a value based on the number of % the environment. % \begin{macrocode} \str_if_empty:NTF \g_@@_name_str @@ -3786,7 +3901,7 @@ c & c & b & a & e \c_math_toggle_token % \end{macrocode} % Here is the call to |\array| (we have a dedicated macro |\@@_array:| because -% of compatibility with \cls{revtex4-1} and \cls{revtex4-2}). +% of compatibility with the classes \cls{revtex4-1} and \cls{revtex4-2}). % \begin{macrocode} \exp_args:NV \@@_array: \l_tmpa_tl } @@ -3824,20 +3939,12 @@ c & c & b & a & e % row'' above the array (when the key |first-row| is used). % \begin{macrocode} \int_compare:nNnTF \l_@@_first_row_int = \c_zero_int - { - \dim_compare:nNnTF - { \g_@@_ht_row_one_dim + \g_@@_dp_row_zero_dim + \lineskiplimit } - > \baselineskip + { + \dim_set:Nn \l_tmpa_dim { - \dim_set:Nn \l_tmpa_dim - { - \g_@@_ht_row_one_dim + \g_@@_dp_row_zero_dim + \lineskip - + \g_@@_ht_row_zero_dim - \g_@@_ht_row_one_dim - } - } - { - \dim_set:Nn \l_tmpa_dim - { \baselineskip + \g_@@_ht_row_zero_dim - \g_@@_ht_row_one_dim } + \g_@@_ht_row_one_dim + \g_@@_dp_row_zero_dim + + \lineskip + + \g_@@_ht_row_zero_dim - \g_@@_ht_row_one_dim } } { \dim_zero:N \l_tmpa_dim } @@ -3851,25 +3958,11 @@ c & c & b & a & e % \begin{macrocode} \int_compare:nNnTF \l_@@_last_row_int > { -2 } { - \dim_compare:nNnTF + \dim_set:Nn \l_tmpb_dim { - \g_@@_ht_last_row_dim + \g_@@_dp_ante_last_row_dim + \lineskiplimit - } - > - \baselineskip - { - \dim_set:Nn \l_tmpb_dim - { - \g_@@_ht_last_row_dim + \g_@@_dp_ante_last_row_dim + \lineskip - + \g_@@_dp_last_row_dim - \g_@@_dp_ante_last_row_dim - } - } - { - \dim_set:Nn \l_tmpb_dim - { - \baselineskip - + \g_@@_dp_last_row_dim - \g_@@_dp_ante_last_row_dim - } + \g_@@_ht_last_row_dim + \g_@@_dp_ante_last_row_dim + + \lineskip + + \g_@@_dp_last_row_dim - \g_@@_dp_ante_last_row_dim } } { \dim_zero:N \l_tmpb_dim } @@ -3981,6 +4074,7 @@ c & c & b & a & e % \begin{macrocode} \hbox_set:Nw \l_tmpa_box \c_math_toggle_token + \bool_if:NT \l_@@_small_bool \scriptstyle \l_@@_code_for_first_col_tl } l @@ -4062,6 +4156,7 @@ c & c & b & a & e % \begin{macrocode} \hbox_set:Nw \l_tmpa_box \c_math_toggle_token + \bool_if:NT \l_@@_small_bool \scriptstyle \l_@@_code_for_last_col_tl } l @@ -4131,6 +4226,8 @@ c & c & b & a & e \NewDocumentEnvironment { NiceArray } { } { \bool_set_true:N \l_@@_NiceArray_bool + \str_if_empty:NT \g_@@_type_env_str + { \str_gset:Nn \g_@@_type_env_str { NiceArray } } % \end{macrocode} % We put . and . for the delimiters but, in fact, that doesn't matter because % these arguments won't be used in |{NiceArrayWithDelims}| (because the flag @@ -4149,6 +4246,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { pNiceArray } { } { + \str_gset:Nn \g_@@_type_env_str { pNiceArray } \@@_test_if_math_mode: \NiceArrayWithDelims ( ) } @@ -4158,6 +4256,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { bNiceArray } { } { + \str_gset:Nn \g_@@_type_env_str { bNiceArray } \@@_test_if_math_mode: \NiceArrayWithDelims [ ] } @@ -4167,6 +4266,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { BNiceArray } { } { + \str_gset:Nn \g_@@_type_env_str { BNiceArray } \@@_test_if_math_mode: \NiceArrayWithDelims \{ \} } @@ -4176,6 +4276,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { vNiceArray } { } { + \str_gset:Nn \g_@@_type_env_str { vNiceArray } \@@_test_if_math_mode: \NiceArrayWithDelims | | } @@ -4185,6 +4286,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { VNiceArray } { } { + \str_gset:Nn \g_@@_type_env_str { VNiceArray } \@@_test_if_math_mode: \NiceArrayWithDelims \| \| } @@ -4205,8 +4307,8 @@ c & c & b & a & e % % That's why in the definition of |{NiceMatrix}|, we have to use |\array| and % not |\begin{array}|. This command |\array| is in |\@@_array:| (we have written -% this command because of the redefinition of |\array| done in \cls{revtex4-1} -% and \cls{revtex4-2}). +% this command because of the redefinition of |\array| done in the classes +% \cls{revtex4-1} and \cls{revtex4-2}). % % In order to execute code after the array, we use a command % |\group_insert_after:N|. @@ -4216,6 +4318,8 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { NiceMatrix } { ! O { } } { + \str_if_empty:NT \g_@@_type_env_str + { \str_gset:Nn \g_@@_type_env_str { NiceMatrix } } \@@_test_if_math_mode: \bool_if:NT \l_@@_in_env_bool { \@@_fatal:n { Yet~in~env } } \bool_set_true:N \l_@@_in_env_bool @@ -4264,47 +4368,52 @@ c & c & b & a & e % We create the variants of the environment |{NiceMatrix}|. % \begin{macrocode} \NewDocumentEnvironment { pNiceMatrix } { } - { - \@@_test_if_math_mode: - \left( \begin{NiceMatrix} - } - { \end{NiceMatrix} \right) } + { + \str_gset:Nn \g_@@_type_env_str { pNiceMatrix } + \@@_test_if_math_mode: + \left( \begin{NiceMatrix} + } + { \end{NiceMatrix} \right) } % \end{macrocode} % % \begin{macrocode} \NewDocumentEnvironment { bNiceMatrix } { } - { - \@@_test_if_math_mode: - \left[ \begin{NiceMatrix} - } - { \end{NiceMatrix} \right] } + { + \str_gset:Nn \g_@@_type_env_str { bNiceMatrix } + \@@_test_if_math_mode: + \left[ \begin{NiceMatrix} + } + { \end{NiceMatrix} \right] } % \end{macrocode} % % \begin{macrocode} \NewDocumentEnvironment { BNiceMatrix } { } - { - \@@_test_if_math_mode: - \left\{ \begin{NiceMatrix} - } - { \end{NiceMatrix} \right\} } + { + \str_gset:Nn \g_@@_type_env_str { BNiceMatrix } + \@@_test_if_math_mode: + \left\{ \begin{NiceMatrix} + } + { \end{NiceMatrix} \right\} } % \end{macrocode} % % \begin{macrocode} \NewDocumentEnvironment { vNiceMatrix } { } - { - \@@_test_if_math_mode: - \left\lvert \begin{NiceMatrix} - } - { \end{NiceMatrix} \right\rvert } + { + \str_gset:Nn \g_@@_type_env_str { vNiceMatrix } + \@@_test_if_math_mode: + \left\lvert \begin{NiceMatrix} + } + { \end{NiceMatrix} \right\rvert } % \end{macrocode} % % \begin{macrocode} \NewDocumentEnvironment { VNiceMatrix } { } - { - \@@_test_if_math_mode: - \left\lVert \begin{NiceMatrix} - } - { \end{NiceMatrix} \right\rVert } + { + \str_gset:Nn \g_@@_type_env_str { VNiceMatrix } + \@@_test_if_math_mode: + \left\lVert \begin{NiceMatrix} + } + { \end{NiceMatrix} \right\rVert } % \end{macrocode} % % @@ -4450,9 +4559,8 @@ c & c & b & a & e % % \subsection{After the construction of the array} % -% The macro |\@@_after_array:| is called (via -% |\group_insert_after:N|) in |{NiceArrayWithDelims}| and -% |{NiceMatrix}|. +% The macro |\@@_after_array:| is called (via |\group_insert_after:N|) in +% |{NiceArrayWithDelims}| and |{NiceMatrix}|. % % \begin{macrocode} \cs_new_protected:Nn \@@_after_array: @@ -4561,6 +4669,16 @@ c & c & b & a & e \bool_set_false:N \l_@@_final_open_bool % \end{macrocode} % +% If the option |small| is used, the values |\l_@@_radius_dim| and +% |\l_@@_inter_dots_dim| (used to draw the dotted lines) are changed. +% \begin{macrocode} + \bool_if:NT \g_@@_small_bool + { + \dim_set:Nn \l_@@_radius_dim { 0.37 pt } + \dim_set:Nn \l_@@_inter_dots_dim { 0.25 em } + } +% \end{macrocode} +% % \bigskip % Now, we really draw the lines. The code to draw the lines has been constructed % in the token lists |\g_@@_Vdots_lines_tl|, etc. @@ -4589,6 +4707,7 @@ c & c & b & a & e \g_@@_code_after_tl \tl_gclear:N \g_@@_code_after_tl \group_end: + \str_gclear:N \g_@@_type_env_str } % \end{macrocode} % @@ -4649,7 +4768,7 @@ c & c & b & a & e % \begin{macrocode} \cs_set:cpn { @@ _ dotted _ #1 - #2 } { } % \end{macrocode} -% Initialisation of variables. +% Initialization of variables. % \begin{macrocode} \int_set:Nn \l_@@_initial_i_int { #1 } \int_set:Nn \l_@@_initial_j_int { #2 } @@ -5226,22 +5345,22 @@ c & c & b & a & e \bool_if:NTF \l_@@_final_open_bool { \int_set:Nn \l_tmpa_int - { \dim_ratio:nn \l_@@_l_dim { 0.45 em } } + { \dim_ratio:nn \l_@@_l_dim \l_@@_inter_dots_dim } } { \int_set:Nn \l_tmpa_int - { \dim_ratio:nn { \l_@@_l_dim - 0.3 em } { 0.45 em } } + { \dim_ratio:nn { \l_@@_l_dim - 0.3 em } \l_@@_inter_dots_dim } } } { \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 } } + { \dim_ratio:nn { \l_@@_l_dim - 0.3 em } \l_@@_inter_dots_dim } } { \int_set:Nn \l_tmpa_int - { \dim_ratio:nn { \l_@@_l_dim - 0.6 em } { 0.45 em }} + { \dim_ratio:nn { \l_@@_l_dim - 0.6 em } \l_@@_inter_dots_dim} } } % \end{macrocode} @@ -5251,12 +5370,12 @@ c & c & b & a & e \dim_set:Nn \l_tmpa_dim { ( \g_@@_x_final_dim - \g_@@_x_initial_dim ) * - \dim_ratio:nn { 0.45 em } \l_@@_l_dim + \dim_ratio:nn \l_@@_inter_dots_dim \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 + \dim_ratio:nn \l_@@_inter_dots_dim \l_@@_l_dim } % \end{macrocode} % @@ -5283,7 +5402,7 @@ c & c & b & a & e { ( \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_@@_l_dim - \l_@@_inter_dots_dim * \l_tmpa_int } { \l_@@_l_dim * 2 } * \l_tmpb_int } % \end{macrocode} @@ -5294,7 +5413,7 @@ c & c & b & a & e { ( \g_@@_y_final_dim - \g_@@_y_initial_dim ) * \dim_ratio:nn - { \l_@@_l_dim - 0.45 em * \l_tmpa_int } + { \l_@@_l_dim - \l_@@_inter_dots_dim * \l_tmpa_int } { \l_@@_l_dim * 2 } * \l_tmpb_int } @@ -5303,7 +5422,7 @@ c & c & b & a & e { \pgfpathcircle { \pgfpoint { \g_@@_x_initial_dim } { \g_@@_y_initial_dim } } - { 0.53 pt } + { \l_@@_radius_dim } \pgfusepath { fill } \dim_gadd:Nn \g_@@_x_initial_dim \l_tmpa_dim \dim_gadd:Nn \g_@@_y_initial_dim \l_tmpb_dim @@ -5431,7 +5550,7 @@ c & c & b & a & e % 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 +% between two consecutive dots). Tikz nodes are created for all the cells of % the array, even the implicit cells of the |\Hdotsfor|. % % \medskip @@ -5591,7 +5710,24 @@ c & c & b & a & e { \cs_set:Npn \@@_dotfill: { - \cleaders \hbox_to_wd:nn { .44 em } { \hss . \hss } \hfill +% \end{macrocode} +% If the option |small| is used, we change the space between two dots (we can't +% use |\l_@@_inter_dots_dim| which will be set after the construction of the +% array). We can't put the |\bool_if:NT| in the first argument of +% |\hbox_to_wd:nn| because |\cleaders| is a special TeX primitive. +% \begin{macrocode} + \bool_if:NT \l_@@_small_bool + { \dim_set:Nn \l_@@_inter_dots_dim { 0.25 em } } + \cleaders + \hbox_to_wd:nn + { \l_@@_inter_dots_dim } + { + \c_math_toggle_token + \bool_if:NT \l_@@_small_bool \scriptstyle + \hss . \hss + \c_math_toggle_token + } + \hfill \skip_horizontal:n \c_zero_dim } } @@ -6287,10 +6423,10 @@ c & c & b & a & e \@@_msg_new:nn { Wrong~last~row } { You~have~used~'last-row=\int_use:N \g_@@_last_row_int'~but~your~environment~ - \{\@currenvir\}~seems~to~have~\int_use:N \g_@@_row_int\ - rows~(remark~that~you~can~use~'last-row'~without~value).~If~you~go~on, - ~the~value~of~\int_use:N \g_@@_row_int\ - will~be~used~for~last~row. + \{\g_@@_type_env_str\}~seems~to~have~\int_use:N \g_@@_row_int\ + rows.~If~you~go~on,~the~value~of~\int_use:N \g_@@_row_int\ + will~be~used~for~last~row.~You~can~avoid~this~problem~by~using~'last-row'~ + without~value~(more~compilations~might~be~necessary). } % \end{macrocode} % @@ -6311,7 +6447,7 @@ c & c & b & a & e % \begin{macrocode} \@@_msg_new:nn { Outside~math~mode } { - The~environment~\{\@currenvir\}~can~be~used~only~in~math~mode~ + The~environment~\{\g_@@_type_env_str\}~can~be~used~only~in~math~mode~ (and~not~in~\token_to_str:N \vcenter).\\ This~error~is~fatal. } @@ -6348,7 +6484,7 @@ c & c & b & a & e For~a~list~of~the~available~keys,~type~H~<return>. } { - The~available~keys~are~(in~alphabetic~order):~ + The~available~options~are~(in~alphabetic~order):~ allow-duplicate-names,~ code-for-first-col,~ code-for-first-row,~ @@ -6363,6 +6499,7 @@ c & c & b & a & e renew-dots,~ renew-matrix,~ right-margin,~ + small,~ and~transparent } % \end{macrocode} @@ -6395,6 +6532,7 @@ c & c & b & a & e parallelize-diags,~ renew-dots,~ right-margin,~ + small,~ and~t. } % \end{macrocode} @@ -6420,8 +6558,9 @@ c & c & b & a & e name,~ nullify-dots,~ parallelize-diags,~ - renew-dots~ - and~right-margin. + renew-dots,~ + right-margin~ + and~small. } % \end{macrocode} % @@ -6432,7 +6571,7 @@ c & c & b & a & e \@@_msg_new:nnn { Unknown~option~for~pNiceArray } { The~option~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~environment~ - \{\@currenvir\}. \\ + \{\g_@@_type_env_str\}. \\ If~you~go~on,~it~will~be~ignored. \\ For~a~list~of~the~available~options,~type~H~<return>. } @@ -6457,7 +6596,8 @@ c & c & b & a & e nullify-dots,~ parallelize-diags,~ renew-dots,~ - and~right-margin. + right-margin~ + and~small. } % \end{macrocode} % @@ -6467,10 +6607,10 @@ c & c & b & a & e 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'. \\ + if~you~use~'columns-width=auto'.~If~you~use~nicematrix~inside~some~ + environments~of~amsmath,~this~error~may~be~an~artefact.~In~this~case, + use~the~option~'allow-duplicate-names'.\\ 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:~ @@ -6489,7 +6629,7 @@ c & c & b & a & e % \begin{macrocode} \@@_msg_new:nn { Zero~row } { - There~is~a~problem.~Maybe~your~environment~\{\@currenvir\}~is~empty.~ + There~is~a~problem.~Maybe~your~environment~\{\g_@@_type_env_str\}~is~empty.~ Maybe~you~have~used~l,~c~and~r~instead~of~L,~C~and~R~in~the~preamble~ of~your~environment. \\ If~you~go~on,~the~result~may~be~incorrect. @@ -6500,7 +6640,7 @@ c & c & b & a & e \@@_msg_new:nn { Use~of~:~in~first~position } { You~can't~use~the~column~specifier~'\l_@@_letter_for_dotted_lines_str'~in~the~ - first~position~of~the~preamble~of~the~environment~\{\@currenvir\}. \\ + first~position~of~the~preamble~of~the~environment~\{\g_@@_type_env_str\}. \\ If~you~go~on,~this~dotted~line~will~be~ignored. } % \end{macrocode} @@ -6694,9 +6834,7 @@ c & c & b & a & e % 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). -% +% style''. % % \subsection*{Changes between version 1.3 and 1.4} % @@ -6761,7 +6899,7 @@ c & c & b & a & e % 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| +% See |www.texdev.net/2018/04/21/xparse-optional-arguments-at-the-end| % % \subsection*{Changes between version 2.1.4 and 2.1.5} % @@ -6819,7 +6957,7 @@ c & c & b & a & e % with the new implementation, they become pointless. These starred versions % are no longer documented. % -% The vertical rules in the matrices (drawn by \verb+|+) are now compatible with +% The vertical rules in the matrices (drawn by "|") are now compatible with % the color fixed by \pkg{colortbl}. % % Correction of a bug: it was not possible to use the colon |:| in the preamble @@ -6830,7 +6968,9 @@ c & c & b & a & e % % \tableofcontents % \endinput +% % Local Variables: -% TeX-fold-mode: nil +% TeX-fold-mode: t +% TeX-fold-preserve-comments: nil % fill-column: 80 % End: |