diff options
Diffstat (limited to 'Master')
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/README.md | 2 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf | bin | 316720 -> 313809 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex | 133 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf | bin | 671681 -> 654887 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx | 958 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | 507 |
6 files changed, 750 insertions, 850 deletions
diff --git a/Master/texmf-dist/doc/latex/nicematrix/README.md b/Master/texmf-dist/doc/latex/nicematrix/README.md index aadca62b15f..056f0d84a4a 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/README.md +++ b/Master/texmf-dist/doc/latex/nicematrix/README.md @@ -12,7 +12,7 @@ The LaTeX extension `nicematrix` is distributed under the LPPL 1.3 license. The LaTeX package `nicematrix` provides new environments similar to the classical environments `{array}` and `{matrix}` but with some additional features. Among these features are the possibilities to fix the width of the columns, to draw continuous ellipsis dots between the cells -of the array and to add an exterior line and an exterior column. +of the array and to add exterior rows and columns (so called 'border matrices'). ## Installation diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf Binary files differindex 735084e1e56..8829f14771d 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex index 5d6e573f66d..fa07724b594 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex @@ -1,4 +1,4 @@ -\documentclass[dvipsnames]{article}% dvipsnames is for xcolor (loaded by Tikz, loaded by nicematrix) +\documentclass[dvipsnames]{article}% dvipsnames is for xcolor (loaded by Tikz, loaded by nicematrix) \usepackage{xltxtra} \usepackage[french]{babel} @@ -212,8 +212,7 @@ des raisons techniques, dans le préambule de l'environnement |{NiceArray}|, l'u |W{...}{...}|\footnote{Pour les colonnes de type |w| et |W|, les cases sont composées en mode mathématique (dans les environnements de \pkg{nicematrix}) alors que dans |{array}| de \pkg{array}, elles sont composées en mode texte.}, \verb+|+, |>{...}|, |<{...}|, |@{...}|, |!{...}| et |*{n}{...}| mais les lettres |p|, |m| et |b| ne -doivent pas être employées. L'environnement |{NiceArray}| et ses variantes fournissent des options qui permettent -de tracer des rangées et colonnes extérieures. Voir p.~\pageref{NiceArray} la partie concernant |{NiceArray}|. +doivent pas être employées. Voir p.~\pageref{NiceArray} la partie concernant |{NiceArray}|. \section{Les lignes en pointillés continues} @@ -316,7 +315,8 @@ $\begin{bNiceMatrix} \bigskip Il y a aussi d'autres moyens de changer la taille d'une matrice. On pourrait vouloir utiliser l'argument optionnel de la commande~|\\| pour l'espacement vertical et la commande~|\hspace*| dans une case pour l'espacement -horizontal.\footnote{On peut aussi régler la largeur des colonnes en utilisant l'environnement |{NiceArray}| (ou +horizontal.\footnote{Dans \pkg{nicematrix}, il faut utiliser |\hspace*| et non |\hspace| car \pkg{nicematrix} + utilise \pkg{array}. Remarquons aussi que l'on peut également régler la largeur des colonnes en utilisant l'environnement |{NiceArray}| (ou une de ses variantes) avec une colonne de type~|w| ou |W|: cf. p.~\pageref{width}} Toutefois, une commande~|\hspace*| pourrait interférer dans la construction des lignes en pointillés. C'est @@ -501,10 +501,11 @@ même rangée que |\Hdotsfor|). \subsection{Comment créer les lignes en pointillés de manière transparente} L'extension \pkg{nicematrix} fournit une option appelée |transparent| qui permet d'utiliser du code existant de -manière transparente dans les environnements |{matrix}|. Cette option peut être passée en option du |\usepackage| -ou bien être fixée avec la commande |\NiceMatrixOptions|. - -En fait, cette option est un alias pour la conjonction de deux options : |renew-dots| et |renew-matrix|. +manière transparente dans les environnements de l'\pkg{amsmath} : |{matrix}|, |{pmatrix}|, |{bmatrix}|, etc. En +fait, cette option est un alias pour la conjonction de deux options : |renew-dots| et +|renew-matrix|.\footnote{Comme toutes les autres options, les options |renew-dots|, |renew-matrix| et |transparent| + peuvent être fixées avec la commande |\NiceMatrixOptions|, mais elles peuvent aussi être passées en options du + |\usepackage| (ce sont les trois seules).} \smallskip @@ -800,8 +801,8 @@ Il existe également des variantes pour l'environnement |{NiceArray}| : |{pNiceA |{BNiceArray}|, |{vNiceArray}| et |{VNiceArray}|. -Dans l'exemple suivant, on utilise un environnment |{pNiceArray}| (on n'utilise pas |{pNiceMatrix}| car on souhaite -utiliser les types de colonne |L| et |R| --- avec |{pNiceMatrix}|, toutes les colonnes sont de type |C|). +Dans l'exemple suivant, on utilise un environnement |{pNiceArray}| (on n'utilise pas |{pNiceMatrix}| car on +souhaite utiliser les types de colonne |L| et |R| --- avec |{pNiceMatrix}|, toutes les colonnes sont de type |C|). \bigskip @@ -820,42 +821,81 @@ a_{21} & & a_{2n} \\ a_{n-1,1} & \Cdots & a_{n-1,n} \end{pNiceArray}$ -\vspace{1cm} -L'environnement |{NiceArray}| et ses variantes permettent de composer des rangées et des colonnes «extérieures» grâce aux options + +\bigskip +\bigskip +En fait, l'environnement |{pNiceArray}| et ses variantes sont fondés sur un environnement plus général, appelé +|{NiceArrayWithDelims}|. Les deux premiers arguments obligatoires de cet environnement sont les délimiteurs gauche +et droit qui seront utilisés dans la construction de la matrice. Il est possible d'utiliser |{NiceArrayWithDelims}| +si on a besoin de délimiteurs atypiques. + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=11cm] +$\begin{~emphase#NiceArrayWithDelims@} + {\downarrow}{\downarrow}{CCC} +1 & 2 & 3 \\ +4 & 5 & 6 \\ +7 & 8 & 9 \\ +\end{~emphase#NiceArrayWithDelims@}$ +\end{BVerbatim} +$\begin{NiceArrayWithDelims} + {\downarrow}{\downarrow}{CCC} +1 & 2 & 3 \\ +4 & 5 & 6 \\ +7 & 8 & 9 \\ +\end{NiceArrayWithDelims}$ + + + +\bigskip +\section{Les rangées et colonnes extérieures} +Les environnements de \pkg{nicematrix} permettent de composer des rangées et des colonnes «extérieures» grâce aux options |first-row|, |last-row|, |first-col| et |last-col|. \label{exterior} -Il n'y a pas de spécification de colonne à fournir pour l'éventuelle «première colonne» (qui sera automatiquement -une colonne de type |R|) ou pour l'éventuelle «dernière colonne» (qui sera automatiquement de type |L|). - +Si elle est présente, la première rangée est numérotée par $0$ (et non $1$). Il en est de même pour la première +colonne. Dans le cas général, on doit spécifier le numéro de la dernière rangée et de la dernière colonne (si elles +sont présentes). \begin{Verbatim} -$\begin{pNiceArray}{CCCC}[~emphase#first-row,last-row,first-col,last-col@] +$\begin{pNiceMatrix}[~emphase#first-row,last-row=5,first-col,last-col=5@] & C_1 & C_2 & C_3 & C_4 & \\ L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\ L_2 & a_{21} & a_{22} & a_{23} & a_{24} & L_2 \\ L_3 & a_{31} & a_{32} & a_{33} & a_{34} & L_3 \\ L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\ & C_1 & C_2 & C_3 & C_4 & -\end{pNiceArray}$ +\end{pNiceMatrix}$ \end{Verbatim} % -\[\begin{pNiceArray}{CCCC}[first-row,last-row,first-col,last-col] +\[\begin{pNiceMatrix}[first-row,last-row=5,first-col,last-col=5] & C_1 & C_2 & C_3 & C_4 & \\ L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\ L_2 & a_{21} & a_{22} & a_{23} & a_{24} & L_2 \\ L_3 & a_{31} & a_{32} & a_{33} & a_{34} & L_3 \\ L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\ & C_1 & C_2 & C_3 & C_4 & -\end{pNiceArray}\] +\end{pNiceMatrix}\] \bigskip -Néanmoins, il y a une particularité avec l'option |last-row| : quand LaTeX compose un tableau |{array}| (via une -commande |\halign| de TeX), il le compose rangée par rangée et il n'y a pas de moyen direct de savoir que l'on est -arrivé à la dernière rangée avant la composition de celle-ci. Pour remédier à ce problème, \pkg{nicematrix} écrit -dans le fichier |aux| le nombre de rangées du tableau pour pouvoir l'utiliser à la compilation suivante. Il est -néanmoins également possible de passer directement le nombre de rangées en argument de l'option |last-row| et, -ainsi, \pkg{nicematrix} le connaîtra dès la première compilation. +Il y a plusieurs remarques à formuler. +% +\begin{itemize} +\item Si on utilise un environnement avec préambule explicite (c'est-à-dire |{NiceArray}| ou l'une de ses +variantes), on ne doit pas mettre de spécification de colonne pour les éventuelles première et dernière colonne : +la première colonne sera automatiquement (et nécessairement) de type |R| et la dernière de type |L|). + +\item Si on utilise un environnement avec préambule explicite et une dernière colonne, on doit utiliser l'option +|last-col| \emph{sans} valeur. En effet le numéro de la dernière colonne est, dans ce cas, déduit du préambule (qui +contient nécessairement l'information du nombre de colonnes non extérieures). + +\item Pour une dernière rangée, l'option |last-row| peut en fait être utilisée sans préciser de valeur. Dans ce +cas, \pkg{nicematrix} détermine, lors de la première compilation, le nombre de rangées rencontrées dans le tableau +et l'écrit dans le fichier |.aux| pour la prochaine compilation. Dans l'exemple qui suit, l'option |last-row| sera +utilisée sans valeur explicite. +\end{itemize} + + \bigskip On peut contrôler l'apparence de ces rangées et colonnes avec les options |code-for-first-row|, @@ -867,7 +907,7 @@ insérées au début de chaque case de la rangée ou de la colonne considérée. ~emphase#code-for-first-col@ = \color{blue}, ~emphase#code-for-last-row@ = \color{green}, ~emphase#code-for-last-col@ = \color{magenta}} -$\begin{pNiceArray}{CC|CC}[first-row,last-row=5,first-col,last-col] +$\begin{pNiceArray}{CC|CC}[first-row,last-row,first-col,last-col] & C_1 & C_2 & C_3 & C_4 & \\ L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\ L_2 & a_{21} & a_{22} & a_{23} & a_{24} & L_2 \\ @@ -884,7 +924,7 @@ L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\ code-for-last-row = \color{green}, code-for-last-col = \color{magenta}} \begin{displaymath} -\begin{pNiceArray}{CC|CC}[first-row,last-row=5,first-col,last-col] +\begin{pNiceArray}{CC|CC}[first-row,last-row,first-col,last-col] & C_1 & \multicolumn1C{C_2} & C_3 & C_4 & \\ L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\ L_2 & a_{21} & a_{22} & a_{23} & a_{24} & L_2 \\ @@ -907,9 +947,6 @@ tableau) ne s'étend pas dans les rangées extérieures.\footnote{Ce dernier poi sont pas parfaitement compatibles car \pkg{arydshln} redéfinit beaucoup de structures internes à \pkg{array}. Par ailleurs, si on veut vraiment un filet qui s'étende dans la première et la dernière rangée, on peut utiliser |!{\vline}| dans le préambule à la place de \verb+|+.} -\item La «première rangée» d'un environnement |{pNiceArray}| porte le numéro $0$, et non $1$ (de même pour la -«première colonne»). Ce numéro est utilisé, par exemple, pour les noms des nœuds Tikz (les noms de ces nœuds sont -utilisés, par exemple, par la commande |\line| dans le |code-after|). \item Sans surprise, une éventuelle option |columns-width| (décrite p.~\pageref{width}) ne s'applique pas à la «première colonne» ni à la «dernière colonne». \item Pour des raisons techniques, il n'est pas possible d'utiliser l'option de la commande |\\| après la @@ -917,28 +954,6 @@ utilisés, par exemple, par la commande |\line| dans le |code-after|). \end{itemize} -\bigskip -En fait, l'environnement |{pNiceArray}| et ses variantes sont fondés sur un environnement plus général, appelé -|{NiceArrayWithDelims}|. Les deux premiers arguments obligatoires de cet environnement sont les délimiteurs gauche -et droit qui seront utilisés dans la construction de la matrice. Il est possible d'utiliser |{NiceArrayWithDelims}| -si on a besoin de délimiteurs atypiques. - -\medskip -\begin{BVerbatim}[baseline=c,boxwidth=11cm] -$\begin{~emphase#NiceArrayWithDelims@} - {\downarrow}{\downarrow}{CCC}[last-col] -1 & 2 & 3 & L_1 \\ -4 & 5 & 6 & L_2 \\ -7 & 8 & 9 & L_3 -\end{~emphase#NiceArrayWithDelims@}$ -\end{BVerbatim} -$\begin{NiceArrayWithDelims} - {\downarrow}{\downarrow}{CCC}[last-col] -1 & 2 & 3 & L_1 \\ -4 & 5 & 6 & L_2 \\ -7 & 8 & 9 & L_3 -\end{NiceArrayWithDelims}$ - @@ -1065,8 +1080,8 @@ $\begin{pNiceArray}{Wc{1cm}CC} \bigskip -Avec \pkg{nicematrix}, il est aussi possible de fixer la largeur de toutes les colonnes de la matrice directement -avec l'option |columns-width| (disponible dans tous les environnements de \pkg{nicematrix}). +Dans les environnements de \pkg{nicematrix}, il est aussi possible de fixer la largeur de toutes les colonnes de la +matrice directement avec l'option |columns-width|. \medskip \begin{BVerbatim}[baseline=c,boxwidth=10cm] @@ -1088,8 +1103,9 @@ possible de le supprimer en mettant |\arraycolsep| à~$0$). \bigskip Il est possible de donner la valeur |auto| à l'option |columns-width| : toutes les colonnes du tableau -auront alors une largeur égale à la largeur de la case la plus large du tableau. \textbf{Deux ou trois - compilations successives peuvent être nécessaires.}\par\nobreak +auront alors une largeur égale à la largeur de la case la plus large du tableau.\footnote{Le résultat est atteint +dès la première compilation (mais Tikz écrivant des informations dans le fichier |.aux|, un message demandant une +deuxième compilation apparaîtra).}\par\nobreak \medskip \begin{BVerbatim}[baseline=c,boxwidth=10cm] @@ -1159,9 +1175,12 @@ $\begin{pNiceMatrix} = \begin{pNiceMatrix} 1 & 1245 \\ 345 & 2 - \end{pNiceMatrix}$ +\end{pNiceMatrix}$ \end{NiceMatrixBlock} +\medskip +\textbf{Plusieurs compilations peuvent être nécessaires pour obtenir le résultat désiré.} + \section{Les matrices par blocs} Dans les environnements de \pkg{nicematrix}, on peut utiliser la commande |\Block| pour placer un élément au centre diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf Binary files differindex 690f05bce7a..b635371dec3 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx index 684b34c5b46..44a38c9a0bd 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{3.2a} -\def\myfiledate{2019/09/21} +\def\myfileversion{3.3} +\def\myfiledate{2019/10/01} % % %<*batchfile> @@ -211,7 +211,7 @@ c & c & b & a & e % \{VNiceMatrix\} & & \{NiceArrayWithDelims\} \\ % \end{tabular} % \end{ttfamily} -%b +% % % \medskip % By default, the environments |{NiceMatrix}|, |{pNiceMatrix}|, |{bNiceMatrix}|, @@ -229,9 +229,8 @@ c & c & b & a & e % |W|, the cells are composed in math mode (in the environments of % \pkg{nicematrix}) whereas in |{array}| of \pkg{array}, they are composed in text mode.}, "|", % |>{...}|, |<{...}|, |@{...}|, |!{...}| and |*{n}{...}| but the letters |p|, -% |m| and |b| should not be used. The environment |{NiceArray}| and its variants -% provide also options to draw exterior rows and columns. See p.~\pageref{NiceArray} -% the section relating to |{NiceArray}| +% |m| and |b| should not be used. See p.~\pageref{NiceArray} the section +% relating to |{NiceArray}|. % % % \section{The continuous dotted lines} @@ -337,13 +336,15 @@ c & c & b & a & e % 0 & & \Cdots & 0 % \end{bNiceMatrix}$ % -% \bigskip e +% \bigskip % There are also other means to change the size of the matrix. Someone might % want to use the optional argument of the command~|\\| for the vertical % dimension and a command~|\hspace*| in a cell for the horizontal -% dimension.\footnote{It's also possible to fix the width of a column -% by using the environment |{NiceArray}| (or one of its variants) with a column of -% type~|w| or~|W|: see p.~\pageref{width}} +% dimension.\footnote{In \pkg{nicematrix}, one should use |\hspace*| and not +% |\hspace| for such an usage because \pkg{nicematrix} loads \pkg{array}. One +% may also remark that it's possible to fix the width of a column by using the +% environment |{NiceArray}| (or one of its variants) with a column of type~|w| +% or~|W|: see p.~\pageref{width}} % % However, a command~|\hspace*| might interfer with the construction of the % dotted lines. That's why the package \pkg{nicematrix} provides a @@ -534,12 +535,14 @@ c & c & b & a & e % \subsection{How to generate the continuous dotted lines transparently} % % The package \pkg{nicematrix} provides an option called |transparent| for using -% existing code transparently in the environments |{matrix}|. This option can be -% set as option of |\usepackage| or with the command |\NiceMatrixOptions|. -% -% -% In fact, this option is an alias for the conjonction of two options: -% |renew-dots| and |renew-matrix|. +% existing code transparently in the environments of the \pkg{amsmath} : +% |{matrix}|, |{pmatrix}|, |{bmatrix}|, etc. In fact, this +% option is an alias for the conjonction of two options: +% |renew-dots| and |renew-matrix|.\footnote{The options |renew-dots|, +% |renew-matrix| and |transparent| can be fixed with the command +% |\NiceMatrixOptiosn| like the other options. However, they can also be fixed +% as options of the command |\usepackage| (it's an exception for these three +% specific options.)} % % \smallskip % @@ -869,46 +872,78 @@ c & c & b & a & e % \end{pNiceArray}$ % % -% \vspace{1cm} -% With the environment |{NiceArray}| and its the variants, it's possible to -% compose exterior rows and columns with the options |first-row|, |last-row|, -% |first-col| and |last-col|. +% \bigskip +% In fact, the environment |{pNiceArray}| and its variants are based upon a +% more general environment, called |{NiceArrayWithDelims}|. The first two +% mandatory arguments of this environment are the left and right delimiters used +% in the construction of the matrix. It's possible to use +% |{NiceArrayWithDelims}| if we want to use atypical delimiters. +% +% \medskip +% \begin{BVerbatim}[baseline=c,boxwidth=11cm] +% $\begin{~emphase#NiceArrayWithDelims@} +% {\downarrow}{\downarrow}{CCC} +% 1 & 2 & 3 \\ +% 4 & 5 & 6 \\ +% 7 & 8 & 9 \\ +% \end{~emphase#NiceArrayWithDelims@}$ +% \end{BVerbatim} +% $\begin{NiceArrayWithDelims} +% {\downarrow}{\downarrow}{CCC} +% 1 & 2 & 3 \\ +% 4 & 5 & 6 \\ +% 7 & 8 & 9 \\ +% \end{NiceArrayWithDelims}$ +% +% +% \bigskip +% \section{The exterior row and columns} +% The options |first-row|, |last-row|, |first-col| and |last-col| allow the +% composition of exterior rows and columns in the environments of \pkg{nicematrix}. % \label{exterior} % -% There is no specification of column to provide for the potential ``first -% column'' (it will automatically be a |R| column) and for the potential ``last -% column'' (it will automatically be a |L| column). +% A potential first row has the number $0$ (and not $1$). Idem for the potential +% first column. In general cases, one must specify the number of the last row +% and the number of the last column as values of |last-row| and |last-col|. % % \begin{Verbatim} -% $\begin{pNiceArray}{CCCC}[~emphase#first-row,last-row,first-col,last-col@] +% $\begin{pNiceMatrix}[~emphase#first-row,last-row=5,first-col,last-col=5@] % & C_1 & C_2 & C_3 & C_4 & \\ % L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\ % L_2 & a_{21} & a_{22} & a_{23} & a_{24} & L_2 \\ % L_3 & a_{31} & a_{32} & a_{33} & a_{34} & L_3 \\ % L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\ % & C_1 & C_2 & C_3 & C_4 & -% \end{pNiceArray}$ +% \end{pNiceMatrix}$ % \end{Verbatim} % -% \[\begin{pNiceArray}{CCCC}[first-row,last-row,first-col,last-col] +% \[\begin{pNiceMatrix}[first-row,last-row=5,first-col,last-col=5] % & C_1 & C_2 & C_3 & C_4 & \\ % L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\ % L_2 & a_{21} & a_{22} & a_{23} & a_{24} & L_2 \\ % L_3 & a_{31} & a_{32} & a_{33} & a_{34} & L_3 \\ % L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\ % & C_1 & C_2 & C_3 & C_4 & -% \end{pNiceArray}\] +% \end{pNiceMatrix}\] % % \bigskip -% However, there is a particularity for the option |last-row|: when LaTeX -% composes an array (with the TeX command |\halign|) it composes it row by row -% and there is no direct way to know if we are at the last row before the -% composition of that row. That's why \pkg{nicematrix} writes in the |aux| file -% the number of rows of the array in order to use it at the next run. -% Nevertheless, it's possible to give directly the number of rows as the value -% of the key |last-row|. It that way, \pkg{nicematrix} will know the correct -% value by the first compilation. -% +% We have several remarks to do. +% \begin{itemize} +% \item For the environments with an explicit preamble (i.e. |{NiceArray}| and +% its variants), no letter must be given in the preamble for the potential first +% column and the potential last column: the first column will be automatically +% (and necessarily) of type |R| and the last column will be automatically of +% type |L|). +% \item In an environment with an explicit preamble, the option |last-col| must +% be used \emph{without} value: the number of columns will be automatically +% computed from the preamble of the array. +% \item For the potential last row, the option |last-row| may, in fact, be used +% without value. In this case, \pkg{nicematrix} computes, during the first +% compilation, the number of row of the array and writes that information in the +% |.aux| file for the second run. In the following example, the option +% |last-row| will be used without value. +% \end{itemize} +% % \bigskip % It's possible to control the appearance of these rows and columns with options % |code-for-first-row|, |code-for-last-row|, |code-for-first-col| and @@ -961,10 +996,6 @@ c & c & b & a & e % \pkg{array}. On another note, if one really wants a vertical rule running in % the first and in the last row, he should use |!{\vline}| instead of \verb+|+ % in the preamble of the array.} -% \item The ``first row'' of an environment |{pNiceArray}| has the number $0$, and not -% $1$. Idem for the ``first column''. This number is used for the names of the Tikz -% nodes (the names of these nodes are used, for example, by the command |\line| -% in |code-after|). % \item Logically, the potential option |columns-width| (described % p.~\pageref{width}) doesn't apply to the ``first column'' and ``last column''. % \item For technical reasons, it's not possible to use the option of the command |\\| @@ -975,30 +1006,6 @@ c & c & b & a & e % % % -% \bigskip -% In fact, the environment |{pNiceArray}| and its variants are based upon a -% more general environment, called |{NiceArrayWithDelims}|. The first two -% mandatory arguments of this environment are the left and right delimiters used -% in the construction of the matrix. It's possible to use -% |{NiceArrayWithDelims}| if we want to use atypical delimiters. -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=11cm] -% $\begin{~emphase#NiceArrayWithDelims@} -% {\downarrow}{\downarrow}{CCC}[last-col] -% 1 & 2 & 3 & L_1 \\ -% 4 & 5 & 6 & L_2 \\ -% 7 & 8 & 9 & L_3 -% \end{~emphase#NiceArrayWithDelims@}$ -% \end{BVerbatim} -% $\begin{NiceArrayWithDelims} -% {\downarrow}{\downarrow}{CCC}[last-col] -% 1 & 2 & 3 & L_1 \\ -% 4 & 5 & 6 & L_2 \\ -% 7 & 8 & 9 & L_3 -% \end{NiceArrayWithDelims}$ -% -% % % \section{The dotted lines to separate rows or columns} % @@ -1122,8 +1129,8 @@ c & c & b & a & e % % % \bigskip -% It's also possible to fix the width of all the columns of a matrix directly -% with the option |columns-width| (in all the environments of \pkg{nicematrix}). +% In the environments of \pkg{nicematrix}, it's also possible to fix the width +% of all the columns of a matrix directly with the option |columns-width|. % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=10cm] @@ -1146,8 +1153,10 @@ c & c & b & a & e % % \bigskip % It's possible to give the value |auto| to the option |columns-width|: all the -% columns of the array will have a width equal to the widest cell of the array. -% \textbf{Two or three compilations may be necessary.}\par\nobreak +% columns of the array will have a width equal to the widest cell of the +% array.\footnote{The result is achieved with only one compilation (but Tikz +% will have written informations in the |.aux| file and a message requiring a +% second compilation will appear).}\par\nobreak % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=10cm] @@ -1221,6 +1230,10 @@ c & c & b & a & e % \end{pNiceMatrix}$ % \end{NiceMatrixBlock} % +% \medskip +% \textbf{Several compilations may be necessary to achieve the job.} +% +% % \section{Block matrices} % % In the environments of \pkg{nicematrix}, it's possible to use the command @@ -1258,11 +1271,12 @@ c & c & b & a & e % \end{scope} % % \bigskip -% 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 between angle brackets to specificy some TeX code -% which will be inserted before the beginning of the math mode. +% One may wish to 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 between angle brackets to +% specificy some TeX code which will be inserted before the beginning of the +% math mode. % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=10.6cm] @@ -2429,8 +2443,16 @@ c & c & b & a & e % \end{macrocode} % % \bigskip +% We also define a counter to count the environments |{NiceMatrixBlock}|. +% \begin{macrocode} +\int_new:N \g_@@_NiceMatrixBlock_int +% \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. +% that all the columns must have the same width (but, if the key |columns-width| +% is used with the special value |auto|, the boolean +% |l_@@_auto_columns_width_bool| will be raised). % \begin{macrocode} \dim_new:N \l_@@_columns_width_dim % \end{macrocode} @@ -2461,7 +2483,6 @@ c & c & b & a & e % position (|t|, |b| or |c|). % \begin{macrocode} \bool_new:N \l_@@_NiceArray_bool -\bool_new:N \g_@@_NiceArray_bool % \end{macrocode} % % @@ -2536,6 +2557,10 @@ c & c & b & a & e % \begin{macrocode} \str_new:N \g_@@_type_env_str % \end{macrocode} +% +% \begin{macrocode} +\tl_new:N \g_@@_code_after_tl +% \end{macrocode} % % \bigskip % \subsubsection{Variables for the exterior rows and columns} @@ -2554,7 +2579,6 @@ c & c & b & a & e % \begin{macrocode} \int_new:N \l_@@_first_row_int \int_set:Nn \l_@@_first_row_int 1 -\int_new:N \g_@@_first_row_int % \end{macrocode} % % \medskip @@ -2565,7 +2589,6 @@ c & c & b & a & e % \begin{macrocode} \int_new:N \l_@@_first_col_int \int_set:Nn \l_@@_first_col_int 1 -\int_new:N \g_@@_first_col_int % \end{macrocode} % % \medskip @@ -2578,7 +2601,6 @@ c & c & b & a & e % \begin{macrocode} \int_new:N \l_@@_last_row_int \int_set:Nn \l_@@_last_row_int { -2 } -\int_new:N \g_@@_last_row_int % \end{macrocode} % % \smallskip @@ -2590,18 +2612,19 @@ c & c & b & a & e % value from the |aux| file, the value of the counter won't be $-1$ any longer.} % \begin{macrocode} \bool_new:N \l_@@_last_row_without_value_bool -\bool_new:N \g_@@_last_row_without_value_bool % \end{macrocode} % % \medskip % \item \textbf{Last column}\par\nobreak % -% For the eventual ``last column'', we have a boolean an not an integer. +% For the eventual ``last column'', we use an integer. A value of $-1$ means +% that there is no last column. % \begin{macrocode} -\bool_new:N \l_@@_last_col_bool +\int_new:N \l_@@_last_col_int +\int_set:Nn \l_@@_last_col_int { -1 } % \end{macrocode} % -% However, we have also another boolean. Consider the following code: +% However, we have also a boolean. Consider the following code: % \begin{center} % \begin{BVerbatim} % \begin{pNiceArray}{CC}[last-col] @@ -2807,20 +2830,11 @@ c & c & b & a & e % % % \bigskip -% We don't want to patch any existing code. That's why some code must be -% executed in a |\group_insert_after:N|. That's why the parameters used in that -% code must be transfered outside the current group. To do this, we copy those -% quantities in global variables just before the |\group_insert_after:N|. -% Therefore, for those quantities, we have two parameters, one local and one -% global. For example, we have |\l_@@_name_str| and |\g_@@_name_str|. -% -% \bigskip % The token list |\l_@@_name_str| will contain the optional name of the % environment: this name can be used to access to the Tikz nodes created in the % array from outside the environment. % \begin{macrocode} \str_new:N \l_@@_name_str -\str_new:N \g_@@_name_str % \end{macrocode} % % \bigskip @@ -2837,8 +2851,6 @@ c & c & b & a & e % \begin{macrocode} \dim_new:N \l_@@_left_margin_dim \dim_new:N \l_@@_right_margin_dim -\dim_new:N \g_@@_left_margin_dim -\dim_new:N \g_@@_right_margin_dim \dim_new:N \g_@@_width_last_col_dim \dim_new:N \g_@@_width_first_col_dim % \end{macrocode} @@ -2850,7 +2862,6 @@ c & c & b & a & e % \begin{macrocode} \dim_new:N \l_@@_extra_left_margin_dim \dim_new:N \l_@@_extra_right_margin_dim -\dim_new:N \g_@@_extra_right_margin_dim % \end{macrocode} % % @@ -2861,6 +2872,14 @@ c & c & b & a & e % \begin{macrocode} \keys_define:nn { NiceMatrix / Global } { + code-for-first-col .tl_set:N = \l_@@_code_for_first_col_tl , + code-for-first-col .value_required:n = true , + code-for-last-col .tl_set:N = \l_@@_code_for_last_col_tl , + code-for-last-col .value_required:n = true , + code-for-first-row .tl_set:N = \l_@@_code_for_first_row_tl , + code-for-first-row .value_required:n = true , + code-for-last-row .tl_set:N = \l_@@_code_for_last_row_tl , + code-for-last-row .value_required:n = true , small .bool_set:N = \l_@@_small_bool , hlines .bool_set:N = \l_@@_hlines_bool , parallelize-diags .bool_set:N = \l_@@_parallelize_diags_bool , @@ -2872,6 +2891,7 @@ c & c & b & a & e % |\Vdots| and |\Ddots|. % \begin{macrocode} renew-dots .bool_set:N = \l_@@_renew_dots_bool , + renew-dots .value_forbidden:n = true , nullify-dots .bool_set:N = \l_@@_nullify_dots_bool , % \end{macrocode} % @@ -2897,23 +2917,6 @@ c & c & b & a & e % \end{macrocode} % % \bigskip -% The following set of keys concerns the options to \emph{customize} the -% exterior rows and columns, that is to say the options |code-for-first-row|, etc. -% \begin{macrocode} -\keys_define:nn { NiceMatrix / Code } - { - code-for-first-col .tl_set:N = \l_@@_code_for_first_col_tl , - code-for-first-col .value_required:n = true , - code-for-last-col .tl_set:N = \l_@@_code_for_last_col_tl , - code-for-last-col .value_required:n = true , - code-for-first-row .tl_set:N = \l_@@_code_for_first_row_tl , - code-for-first-row .value_required:n = true , - code-for-last-row .tl_set:N = \l_@@_code_for_last_row_tl , - code-for-last-row .value_required:n = true , - } -% \end{macrocode} -% -% \bigskip % We define a set of keys used by the environments of \pkg{nicematrix} (but not % by the command |\NiceMatrixOptions|). % \begin{macrocode} @@ -2932,8 +2935,11 @@ c & c & b & a & e \str_set_eq:NN \l_@@_name_str \l_tmpa_str , name .value_required:n = true , code-after .tl_gset:N = \g_@@_code_after_tl , - code-after .initial:n = \c_empty_tl , code-after .value_required:n = true , + first-col .code:n = \int_zero:N \l_@@_first_col_int , + first-row .code:n = \int_zero:N \l_@@_first_row_int , + last-row .int_set:N = \l_@@_last_row_int , + last-row .default:n = -1 , } % \end{macrocode} % @@ -2946,7 +2952,6 @@ c & c & b & a & e NiceMatrixOptions .inherit:n = { NiceMatrix / Global , - NiceMatrix / Code } , NiceMatrix .inherit:n = { @@ -2957,13 +2962,11 @@ c & c & b & a & e { NiceMatrix / Global , NiceMatrix / Env , - NiceMatrix / Code } , pNiceArray .inherit:n = { NiceMatrix / Global , NiceMatrix / Env , - NiceMatrix / Code } } % \end{macrocode} @@ -3038,7 +3041,6 @@ c & c & b & a & e { \@@_error:n { Bad~value~for~letter~for~dotted~lines } } } , letter-for-dotted-lines .value_required:n = true , - letter-for-dotted-lines .initial:n = \c_colon_str , % \end{macrocode} % % \bigskip @@ -3047,7 +3049,11 @@ c & c & b & a & e } % \end{macrocode} % -% +% \begin{macrocode} +\str_new:N \l_@@_letter_for_dotted_lines_str +\str_set_eq:NN \l_@@_letter_for_dotted_lines_str \c_colon_str +% \end{macrocode} +% % \bigskip % |\NiceMatrixOptions| is the command of the \pkg{nicematrix} package to fix % options at the document level. The scope of these specifications is the @@ -3064,15 +3070,19 @@ c & c & b & a & e % % \begin{macrocode} \keys_define:nn { NiceMatrix / NiceMatrix } - { unknown .code:n = \@@_error:n { Unknown~option~for~NiceMatrix } } + { + last-col .code:n = \tl_if_empty:nTF {#1} + { \@@_error:n { last-col~empty~for~NiceMatrix } } + { \int_set:Nn \l_@@_last_col_int { #1 } } , + unknown .code:n = \@@_error:n { Unknown~option~for~NiceMatrix } + } % \end{macrocode} % % -% \bigskip % % \bigskip -% We finalise the definition of the set of keys -% ``|NiceMatrix / NiceArray|'' with the options specific to |{NiceArray}|. +% We finalise the definition of the set of keys ``|NiceMatrix / NiceArray|'' +% with the options specific to |{NiceArray}|. % % \begin{macrocode} \keys_define:nn { NiceMatrix / NiceArray } @@ -3086,11 +3096,15 @@ c & c & b & a & e c .code:n = \str_set:Nn \l_@@_pos_env_str c , t .code:n = \str_set:Nn \l_@@_pos_env_str t , b .code:n = \str_set:Nn \l_@@_pos_env_str b , - first-col .code:n = \int_zero:N \l_@@_first_col_int , - last-col .bool_set:N = \l_@@_last_col_bool , - first-row .code:n = \int_zero:N \l_@@_first_row_int , - last-row .int_set:N = \l_@@_last_row_int , - last-row .default:n = -1 , +% \end{macrocode} +% +% In the environments |{NiceArray}| and its variants, the option |last-col| must +% be used without value because the number of columns of the array can be read +% in the preamble of the array. +% \begin{macrocode} + last-col .code:n = \tl_if_empty:nF {#1} + { \@@_error:n { last-col~non~empty~for~NiceArray } } + \int_zero:N \l_@@_last_col_int , unknown .code:n = \@@_error:n { Unknown~option~for~NiceArray } } % \end{macrocode} @@ -3101,16 +3115,18 @@ c & c & b & a & e \keys_define:nn { NiceMatrix / pNiceArray } { first-col .code:n = \int_zero:N \l_@@_first_col_int , - last-col .bool_set:N = \l_@@_last_col_bool , + last-col .code:n = \tl_if_empty:nF {#1} + { \@@_error:n { last-col~non~empty~for~NiceArray } } + \int_zero:N \l_@@_last_col_int , first-row .code:n = \int_zero:N \l_@@_first_row_int , last-row .int_set:N = \l_@@_last_row_int , last-row .default:n = -1 , - unknown .code:n = \@@_error:n { Unknown~option~for~pNiceArray } + unknown .code:n = \@@_error:n { Unknown~option~for~NiceMatrix } } % \end{macrocode} % % -% \subsection{Code common to \{NiceArrayWithDelims\} and \{NiceMatrix\}} +% \subsection{Important code used by \{NiceArrayWithDelims\} } % % The pseudo-environment |\@@_Cell:|--|\@@_end_Cell:| will be used to format the % cells of the array. In the code, the affectations are global because this @@ -3327,8 +3343,8 @@ c & c & b & a & e % \interitem % The argument of the following command |\@@_instruction_of_type:n| defined % below is the type of the instruction (|Cdots|, |Vdots|, |Ddots|, etc.). This -% command writes in the correspondint |\g_@@_|\textsl{type}|_lines_tl| the -% instruction that will really draw the line after the construction of the +% command writes in the corresponding |\g_@@_|\textsl{type}|_lines_tl| the +% instruction which will really draw the line after the construction of the % matrix. % % \medskip @@ -3348,8 +3364,10 @@ c & c & b & a & e % 7 & \Cdots \\ % \end{pNiceMatrix}$ % +% \smallskip % the content of |\g_@@_Cdots_lines_tl| will be: % +% \smallskip % \begin{scope} % \color{gray} % \verb|\@@_draw_Cdots:nn {2}{2}| @@ -3430,7 +3448,7 @@ c & c & b & a & e % \begin{macrocode} \int_compare:nNnT \g_@@_row_int > { -1 } { - \int_compare:nNnF \g_@@_row_int = \g_@@_last_row_int + \int_compare:nNnF \g_@@_row_int = \l_@@_last_row_int { \hrule \@height \arrayrulewidth \skip_vertical:n { - \arrayrulewidth } @@ -3441,14 +3459,14 @@ c & c & b & a & e % \end{macrocode} % % \bigskip -% The following code |\@@_pre_array:| is used in |{NiceArray}| and in -% |{NiceMatrix}|. It contains code that will be executed \emph{before} the -% construction of the array. +% The following code |\@@_pre_array:| is used in |{NiceArrayWithDelims}|. It +% exists as a standalone macro only for lisibility. % \label{prearray} % % \begin{macrocode} \cs_new_protected:Npn \@@_pre_array: - { + { + \tl_clear:N \g_@@_code_after_tl % \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 @@ -3463,61 +3481,20 @@ c & c & b & a & e } % \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). Remark that, even if the environment has a name (see -% just below) we have to write in the |aux| file the information with the number -% of environment because of |auto-columns-width| of |{NiceMatrixBlock}|. -% \begin{macrocode} - \bool_if:NT \l_@@_auto_columns_width_bool - { - \group_insert_after:N \@@_write_max_cell_width: - \cs_if_free:cTF { _@@_max_cell_width_ \int_use:N \g_@@_env_int } - { \dim_zero:N \l_@@_columns_width_dim } - { - \dim_set:Nx \l_@@_columns_width_dim - { \use:c { _@@_max_cell_width _ \int_use:N \g_@@_env_int } } - } -% \end{macrocode} -% If the environment has a name, we read the value of the maximal value of the -% columns from |_@@_name_cell_width|{\ttfamily\slshape name} (the value will be -% the correct value even if the number of the environment has changed (for -% example because the user has created or deleted an environment before the -% current one)). -% \begin{macrocode} - \str_if_empty:NF \l_@@_name_str - { - \cs_if_free:cF { _@@_max_cell_width_ \l_@@_name_str } - { - \dim_set:Nx \l_@@_columns_width_dim - { \use:c { _@@_max_cell_width_ \l_@@_name_str } } - } - } - } -% \end{macrocode} -% We don't want to patch any code and that's why some code is executed in a -% |\group_insert_after:N|. In particular, in this |\group_insert_after:N|, we -% will have to know the value of some parameters like |\l_@@_extra_nodes_bool|. -% That's why we transit via a global version for some variables. +% +% \medskip +% We switch to a global version of the boolean |\g_@@_extra_nodes_bool|, +% because, in some circonstancies, the boolean will be raised from inside a +% cell of the |\halign| (in particular in a column of type |w|). +% % \begin{macrocode} \bool_gset_eq:NN \g_@@_extra_nodes_bool \l_@@_extra_nodes_bool - \dim_gset_eq:NN \g_@@_left_margin_dim \l_@@_left_margin_dim - \dim_gset_eq:NN \g_@@_right_margin_dim \l_@@_right_margin_dim - \dim_gset_eq:NN \g_@@_extra_right_margin_dim \l_@@_extra_right_margin_dim - \int_gset_eq:NN \g_@@_last_row_int \l_@@_last_row_int - \tl_gset_eq:NN \g_@@_name_str \l_@@_name_str - \int_gset_eq:NN \g_@@_first_row_int \l_@@_first_row_int - \int_gset_eq:NN \g_@@_first_col_int \l_@@_first_col_int - \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} +% +% \bigskip % 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|. +% |\everycr| to |{ }| and we \emph{need} to have to change the value of |\everycr|. % \begin{macrocode} \cs_set:Npn \ialign { @@ -3532,6 +3509,7 @@ 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 @@ -3575,24 +3553,10 @@ c & c & b & a & e % We define the new column types |L|, |C| and |R| that must be used instead of % |l|, |c| and |r| in the preamble of |{NiceArray}|. % \begin{macrocode} - \dim_compare:nNnTF \l_@@_columns_width_dim = \c_zero_dim - { - \newcolumntype L { > \@@_Cell: l < \@@_end_Cell: } - \newcolumntype C { > \@@_Cell: c < \@@_end_Cell: } - \newcolumntype R { > \@@_Cell: r < \@@_end_Cell: } - } -% \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 \pkg{array} which is, in fact, redefined below. -% \begin{macrocode} - { - \newcolumntype L { w l { \dim_use:N \l_@@_columns_width_dim } } - \newcolumntype C { w c { \dim_use:N \l_@@_columns_width_dim } } - \newcolumntype R { w r { \dim_use:N \l_@@_columns_width_dim } } - } -% \end{macrocode} -% + \newcolumntype L { > \@@_Cell: l < \@@_end_Cell: } + \newcolumntype C { > \@@_Cell: c < \@@_end_Cell: } + \newcolumntype R { > \@@_Cell: r < \@@_end_Cell: } +% \end{macrocode} % % \begin{macrocode} \cs_set_eq:NN \Ldots \@@_Ldots @@ -3759,14 +3723,6 @@ c & c & b & a & e \cs_if_exist:NT \tikz@library@external@loaded { \tikzset { external / export = false } } % \end{macrocode} -% In |{NiceArrayWithDelims}|, it would have been possible to avoid the -% |\group_insert_after:N| and to put |\@@_after_array| in the second -% part of the environment |{NiceArrayWithDelims}|. However, it's not possible to -% do that in |{NiceMatrix}| (because of the option |renew-matrix|) and that's -% why we use this technique in |{NiceArrayWithDelims}| and in |{NiceMatrix}|. -% \begin{macrocode} - \group_insert_after:N \@@_after_array: -% \end{macrocode} % % We increment the counter |\g_@@_env_int| which counts the environments % of the extension. @@ -3807,7 +3763,7 @@ c & c & b & a & e % 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 + \str_if_empty:NTF \l_@@_name_str { \cs_if_exist:cT { @@_last_row_ \int_use:N \g_@@_env_int } { @@ -3816,10 +3772,10 @@ c & c & b & a & e } } { - \cs_if_exist:cT { @@_last_row_ \g_@@_name_str } + \cs_if_exist:cT { @@_last_row_ \l_@@_name_str } { \int_set:Nn \l_@@_last_row_int - { \use:c { @@_last_row_ \g_@@_name_str } } + { \use:c { @@_last_row_ \l_@@_name_str } } } } } @@ -3833,8 +3789,8 @@ c & c & b & a & e % \medskip % We compute the width of the two delimiters. % \begin{macrocode} - \dim_zero_new:N \g_@@_left_delim_dim - \dim_zero_new:N \g_@@_right_delim_dim + \dim_gzero_new:N \g_@@_left_delim_dim + \dim_gzero_new:N \g_@@_right_delim_dim \bool_if:NTF \l_@@_NiceArray_bool { \dim_gset:Nn \g_@@_left_delim_dim { 2 \arraycolsep } @@ -3884,7 +3840,7 @@ c & c & b & a & e { \tl_put_left:Nn \l_tmpa_tl { @ { } } } } } - \bool_if:NTF \l_@@_last_col_bool + \int_compare:nNnTF \l_@@_last_col_int > { -1 } { \tl_put_right:NV \l_tmpa_tl \c_@@_preamble_last_col_tl } { \bool_if:NT \l_@@_NiceArray_bool @@ -3911,27 +3867,99 @@ c & c & b & a & e % \end{macrocode} % % \bigskip -% We begin the second part of the environment |{NiceArrayWithDelims}|. +% We begin the second part of the environment |{NiceArrayWithDelims}|. If all +% the columns must have the same width (if the user has used the option +% |columns-width| or the option |auto-column-width| of the environment +% |{NiceMatrixBlock}|), we add a row in the array to fix the width of the +% columns and construct the ``|col|'' nodes |nm-|\textsl{a}|-col-|\textsl{j} (these +% nodes will be used by the horizontal open dotted lines and by the potential +% commands |\@@_vdottedline:n|). +% % \begin{macrocode} { + \bool_if:nT + { + ( \l_@@_auto_columns_width_bool && ! \l_@@_block_auto_columns_width_bool) + || \dim_compare_p:nNn \l_@@_columns_width_dim > \c_zero_dim + } + { + \crcr + \int_compare:nNnT \l_@@_first_col_int = 0 { \omit & } + \omit +% \end{macrocode} +% First, we put a ``|col|'' node on the left of the first column (of course, we +% have to do that \emph{after} the |\omit|). +% \begin{macrocode} + \tikz [ remember~picture , overlay ] + \coordinate [ name = nm - \int_use:N \g_@@_env_int - col - 0 ] ; +% \end{macrocode} +% We compute in |\g_tmpa_dim| the common width of the columns. We use a global +% variable because we are in a cell of an |\halign| and that we have to use this +% variable in other cells (of the same row). The affectation of |\g_tmpa_dim|, +% like all the affectations, must be done after the |\omit| of the cell. +% \begin{macrocode} + \bool_if:nTF + { + \l_@@_auto_columns_width_bool + && ! \l_@@_block_auto_columns_width_bool + } + { + \dim_gset:Nn \g_tmpa_dim + { \g_@@_max_cell_width_dim + 2 \arraycolsep } + } + { + \dim_gset:Nn \g_tmpa_dim + { \l_@@_columns_width_dim + 2 \arraycolsep } + } + \skip_horizontal:N \g_tmpa_dim +% \end{macrocode} +% We begin a loop over the columns. The integer |\g_tmpa_int| will be the +% number of columns of the current cell. This integer is not used to fix the +% width of the column (since all the columns have the same width equal to +% |\g_@@_tmpa_dim|) but for the Tikz nodes. +% \begin{macrocode} + \int_gset:Nn \g_tmpa_int 1 + \bool_if:nTF \g_@@_last_col_found_bool + { \prg_replicate:nn { \g_@@_col_total_int - 2 } } + { \prg_replicate:nn { \g_@@_col_total_int - 1 } } + { + & + \omit +% \end{marocode} +% The incrementation of the counter |\g_tmpa_int| must be done after the |\omit| +% of the cell. +% \begin{macrocode} + \int_gincr:N \g_tmpa_int + \skip_horizontal:N \g_tmpa_dim +% \end{macrocode} +% We create a ``|col|'' node on the right of the current column. +% \begin{macrocode} + \tikz [ remember~picture , overlay ] + \coordinate + [ + name = nm - \int_use:N \g_@@_env_int - + col - \int_use:N \g_tmpa_int + ] ; + } + } \endarray \c_math_toggle_token - \skip_horizontal:n \g_@@_right_margin_dim - \skip_horizontal:n \g_@@_extra_right_margin_dim + \skip_horizontal:n \l_@@_right_margin_dim + \skip_horizontal:n \l_@@_extra_right_margin_dim \hbox_set_end: % \end{macrocode} % % \bigskip % % \begin{macrocode} - \int_compare:nNnT \g_@@_last_row_int > { -2 } + \int_compare:nNnT \l_@@_last_row_int > { -2 } { - \bool_if:NF \g_@@_last_row_without_value_bool + \bool_if:NF \l_@@_last_row_without_value_bool { - \int_compare:nNnF \g_@@_last_row_int = \g_@@_row_int + \int_compare:nNnF \l_@@_last_row_int = \g_@@_row_int { \@@_error:n { Wrong~last~row } - \int_gset_eq:NN \g_@@_last_row_int \g_@@_row_int + \int_gset_eq:NN \l_@@_last_row_int \g_@@_row_int } } } @@ -3977,7 +4005,7 @@ c & c & b & a & e % column'' has been constructed in an overlapping position and that we have computed % its width in |\g_@@_width_first_col_dim|: see p.~\pageref{overlap-left}). % \begin{macrocode} - \int_compare:nNnT \g_@@_first_col_int = \c_zero_int + \int_compare:nNnT \l_@@_first_col_int = \c_zero_int { \skip_horizontal:n \arraycolsep \skip_horizontal:n \g_@@_width_first_col_dim @@ -3989,9 +4017,9 @@ c & c & b & a & e % into account the option of position (|t|, |c| or |b|). We begin with % |{NiceArray}|. % \begin{macrocode} - \bool_if:NTF \g_@@_NiceArray_bool + \bool_if:NTF \l_@@_NiceArray_bool { - \int_compare:nNnT \g_@@_first_row_int = \c_zero_int + \int_compare:nNnT \l_@@_first_row_int = \c_zero_int { \str_if_eq:VnTF \l_@@_pos_env_str { t } { @@ -4000,7 +4028,7 @@ c & c & b & a & e } } { - \bool_if:NT \g_@@_last_row_int + \int_compare:nNnT \l_@@_last_row_int > 0 { \str_if_eq:VnT \l_@@_pos_env_str { b } { @@ -4059,10 +4087,12 @@ c & c & b & a & e \skip_horizontal:n \g_@@_width_last_col_dim \skip_horizontal:n \arraycolsep } + \@@_after_array: } % \end{macrocode} % This is the end of the environment |{NiceArrayWithDelims}|. % +% % \interitem % Here is the preamble for the ``first column'' (if the user uses the key |first-col|) % \begin{macrocode} @@ -4249,7 +4279,8 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { pNiceArray } { } { - \str_gset:Nn \g_@@_type_env_str { pNiceArray } + \str_if_empty:NT \g_@@_type_env_str + { \str_gset:Nn \g_@@_type_env_str { pNiceArray } } \@@_test_if_math_mode: \NiceArrayWithDelims ( ) } @@ -4259,7 +4290,8 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { bNiceArray } { } { - \str_gset:Nn \g_@@_type_env_str { bNiceArray } + \str_if_empty:NT \g_@@_type_env_str + { \str_gset:Nn \g_@@_type_env_str { NiceArray } } \@@_test_if_math_mode: \NiceArrayWithDelims [ ] } @@ -4269,7 +4301,8 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { BNiceArray } { } { - \str_gset:Nn \g_@@_type_env_str { BNiceArray } + \str_if_empty:NT \g_@@_type_env_str + { \str_gset:Nn \g_@@_type_env_str { BNiceArray } } \@@_test_if_math_mode: \NiceArrayWithDelims \{ \} } @@ -4279,7 +4312,8 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { vNiceArray } { } { - \str_gset:Nn \g_@@_type_env_str { vNiceArray } + \str_if_empty:NT \g_@@_type_env_str + { \str_gset:Nn \g_@@_type_env_str { vNiceArray } } \@@_test_if_math_mode: \NiceArrayWithDelims | | } @@ -4289,7 +4323,8 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { VNiceArray } { } { - \str_gset:Nn \g_@@_type_env_str { VNiceArray } + \str_if_empty:NT \g_@@_type_env_str + { \str_gset:Nn \g_@@_type_env_str { VNiceArray } } \@@_test_if_math_mode: \NiceArrayWithDelims \| \| } @@ -4299,165 +4334,41 @@ c & c & b & a & e % \bigskip % \subsection{The environment \{NiceMatrix\} and its variants} % -% Our environment |{NiceMatrix}| must have the same second part as the -% environment |{matrix}| of \pkg{amsmath} (because of the programmation of the -% option |renew-matrix|). Hence, this second part is the following: -% -% \begin{Verbatim} -% \endarray -% \skip_horizontal:n { - \arraycolsep } -% \end{Verbatim} -% -% That's why in the definition of |{NiceMatrix}|, we 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 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|. -% -% \medskip -% Here's the definition of |{NiceMatrix}|: -% \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 -% \end{macrocode} -% We have to deactivate the potential externalisation of Tikz because -% \pkg{nicematrix} uses Tikz with |remember picture|. -% \begin{macrocode} - \cs_if_exist:NT \tikz@library@external@loaded - { \tikzset { external / export = false } } -% \end{macrocode} -% The instruction for actual drawing of the dotted lines must be in a -% |\group_insert_after:N| because the second part of the environment must be the -% same as in |{array}| (for the option |renew-matrix|). % \begin{macrocode} - \group_insert_after:N \@@_after_array: - \int_gincr:N \g_@@_env_int - \bool_if:NF \l_@@_block_auto_columns_width_bool - { \dim_gzero_new:N \g_@@_max_cell_width_dim } - \keys_set:nn { NiceMatrix / NiceMatrix } { #1 } -% \end{macrocode} -% The macro |\@@_pre_array:| is defined above (see p.~\pageref{prearray}). It -% is also used in |{NiceArrayWithDelims}|. -% \begin{macrocode} - \@@_pre_array: - \skip_horizontal:n { - \arraycolsep } - \skip_horizontal:n \l_@@_left_margin_dim - \skip_horizontal:n \l_@@_extra_left_margin_dim - \str_set:Nn \l_@@_pos_env_str c - \bool_set_false:N \l_@@_exterior_arraycolsep_bool - \@@_array: { * \c@MaxMatrixCols C } - } - { - \endarray - \skip_horizontal:n { - \arraycolsep } -% \end{macrocode} -% The two following lines are, of course, not in the second part of |{array}|, -% but that doesn't matter because, when |renew-matrix| is used, -% |\g_@@_right_margin_dim| and |\g_@@_extra_right_margin_dim| will be equal to $0$~pt. -% \begin{macrocode} - \skip_horizontal:n \g_@@_right_margin_dim - \skip_horizontal:n \g_@@_extra_right_margin_dim - } -% \end{macrocode} -% -% \interitem -% We create the variants of the environment |{NiceMatrix}|. -% \begin{macrocode} -\NewDocumentEnvironment { pNiceMatrix } { } - { - \str_gset:Nn \g_@@_type_env_str { pNiceMatrix } - \@@_test_if_math_mode: - \left( \begin{NiceMatrix} - } - { \end{NiceMatrix} \right) } -% \end{macrocode} -% -% \begin{macrocode} -\NewDocumentEnvironment { bNiceMatrix } { } - { - \str_gset:Nn \g_@@_type_env_str { bNiceMatrix } - \@@_test_if_math_mode: - \left[ \begin{NiceMatrix} - } - { \end{NiceMatrix} \right] } -% \end{macrocode} -% -% \begin{macrocode} -\NewDocumentEnvironment { BNiceMatrix } { } - { - \str_gset:Nn \g_@@_type_env_str { BNiceMatrix } - \@@_test_if_math_mode: - \left\{ \begin{NiceMatrix} - } - { \end{NiceMatrix} \right\} } -% \end{macrocode} -% -% \begin{macrocode} -\NewDocumentEnvironment { vNiceMatrix } { } - { - \str_gset:Nn \g_@@_type_env_str { vNiceMatrix } - \@@_test_if_math_mode: - \left\lvert \begin{NiceMatrix} +\cs_new_protected:Npn \@@_define_env:n #1 + { + \NewDocumentEnvironment { #1 NiceMatrix } { ! O { } } + { + \str_gset:Nn \g_@@_type_env_str { #1 NiceMatrix } + \keys_set:nn { NiceMatrix / NiceMatrix } { ##1 } + \begin { #1 NiceArray } + { + * + { + \int_compare:nNnTF \l_@@_last_col_int = { -1 } + \c@MaxMatrixCols + { \int_eval:n { \l_@@_last_col_int - 1 } } + } + C + } + } + { \end { #1 NiceArray } } } - { \end{NiceMatrix} \right\rvert } % \end{macrocode} % % \begin{macrocode} -\NewDocumentEnvironment { VNiceMatrix } { } - { - \str_gset:Nn \g_@@_type_env_str { VNiceMatrix } - \@@_test_if_math_mode: - \left\lVert \begin{NiceMatrix} - } - { \end{NiceMatrix} \right\rVert } +\@@_define_env:n { } +\@@_define_env:n p +\@@_define_env:n b +\@@_define_env:n B +\@@_define_env:n v +\@@_define_env:n V % \end{macrocode} % % % \bigskip % \subsection{Automatic width of the cells} % -% For the option |columns-width=auto| (or the option |auto-columns-width| -% of the environment |{NiceMatrixBlock}|), we want to know the maximal width of -% the cells of the array (except the cells of the ``exterior'' column of an -% environment of the kind of |{pNiceAccayC}|). This length can be known only -% after the end of the construction of the array (or at the end of the -% environment |{NiceMatrixBlock}|). That's why we store this value in the main -% |.aux| file and it will be available in the next run. We write a dedicated -% command for this because it will be called in a~|\group_insert_after:N|. -% \begin{macrocode} -\cs_new_protected:Nn \@@_write_max_cell_width: - { - \bool_if:NF \l_@@_block_auto_columns_width_bool - { - \iow_now:Nn \@mainaux \ExplSyntaxOn - \iow_now:Nx \@mainaux - { - \cs_gset:cpn { @@_max_cell_width_ \int_use:N \g_@@_env_int } - { \dim_use:N \g_@@_max_cell_width_dim } - } -% \end{macrocode} -% If the environment has a name, we also create an alias named -% |\@@_max_cell_width_|{\ttfamily\slshape name}. -% \begin{macrocode} - \str_if_empty:NF \g_@@_name_str - { - \iow_now:Nx \@mainaux - { - \cs_gset:cpn { @@_max_cell_width_ \g_@@_name_str } - { \dim_use:N \g_@@_max_cell_width_dim } - } - } - \iow_now:Nn \@mainaux \ExplSyntaxOff - } - } -% \end{macrocode} % % \bigskip % \subsection{How to know whether a cell is ``empty''} @@ -4599,14 +4510,14 @@ c & c & b & a & e % same principle. % \begin{macrocode} \int_gset_eq:NN \g_@@_row_total_int \g_@@_row_int - \int_compare:nNnT \g_@@_last_row_int > { -1 } + \int_compare:nNnT \l_@@_last_row_int > { -1 } { \int_gsub:Nn \g_@@_row_int \c_one_int } % \end{macrocode} % % In the user has used the option |last-row| without value, we write in the % |aux| file the number of that last row for the next run. % \begin{macrocode} - \bool_if:NT \g_@@_last_row_without_value_bool + \bool_if:NT \l_@@_last_row_without_value_bool { \iow_now:Nn \@mainaux \ExplSyntaxOn \iow_now:Nx \@mainaux @@ -4619,11 +4530,11 @@ c & c & b & a & e % because it's more reliable than a value based on the number of the % environment. % \begin{macrocode} - \str_if_empty:NF \g_@@_name_str + \str_if_empty:NF \l_@@_name_str { \iow_now:Nx \@mainaux { - \cs_gset:cpn { @@_last_row_ \g_@@_name_str } + \cs_gset:cpn { @@_last_row_ \l_@@_name_str } { \int_use:N \g_@@_row_total_int } } } @@ -4675,7 +4586,7 @@ c & c & b & a & e % 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 + \bool_if:NT \l_@@_small_bool { \dim_set:Nn \l_@@_radius_dim { 0.37 pt } \dim_set:Nn \l_@@_inter_dots_dim { 0.25 em } @@ -5025,8 +4936,7 @@ c & c & b & a & e \bool_if:NTF \l_@@_initial_open_bool { % \end{macrocode} -% If a |w| node exists (created when the key |columns-width| is used), we use -% the |w| node for the extremity. +% If a |w| node exists we use the |w| node for the extremity. % \begin{macrocode} \cs_if_exist:cTF { @@ -5405,8 +5315,9 @@ c & c & b & a & e { ( \g_@@_x_final_dim - \g_@@_x_initial_dim ) * \dim_ratio:nn - { \l_@@_l_dim - \l_@@_inter_dots_dim * \l_tmpa_int } { \l_@@_l_dim * 2 } * - \l_tmpb_int + { \l_@@_l_dim - \l_@@_inter_dots_dim * \l_tmpa_int } + { \l_@@_l_dim * 2 } + * \l_tmpb_int } % \end{macrocode} % (In a multiplication of a dimension and an integer, the integer must always be @@ -5714,7 +5625,7 @@ c & c & b & a & e \cs_set:Npn \@@_dotfill: { % \end{macrocode} -% If the option |small| is used, we change the space between two dots (we can't +% If the option |small| is used, we change the space between 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. @@ -5751,7 +5662,7 @@ c & c & b & a & e \hbox_to_wd:nn { \l_tmpa_dim + 2 \arraycolsep - - \l_@@_left_margin_dim - \g_@@_right_margin_dim + - \l_@@_left_margin_dim - \l_@@_right_margin_dim } \@@_dotfill: } @@ -5759,8 +5670,6 @@ c & c & b & a & e } % \end{macrocode} % -% -% % \bigskip % \begin{macrocode} \cs_new_protected:Nn \@@_vdottedline:n @@ -5795,14 +5704,8 @@ c & c & b & a & e \dim_gset:Nn \g_@@_y_final_dim \pgf@y \end { tikzpicture } % \end{macrocode} -% However, if the |w|-nodes are created in the previous column (that is if the -% previous column was constructed explicitly or implicitly\footnote{A column is -% constructed implicitly with the letter |w| if the option |columns-width| is -% used or if the environment |{NiceMatrixBlock}| is used with the option -% |auto-columns-width|.} with a letter |w|), we use the |w|-nodes to change the -% $x$-value of the nodes in order to have the dotted lines perfectly aligned -% when we use the environment |{NiceMatrixBlock}| with the option -% |auto-columns-width|. +% However, if the previous column was constructed with a letter |w|, we use the +% |w|-nodes to change the $x$-value of the nodes. % \begin{macrocode} \cs_if_exist:cT { pgf@sh@ns@nm -\int_use:N \g_@@_env_int - 1 - #1 - w } @@ -5818,6 +5721,20 @@ c & c & b & a & e \dim_gadd:Nn \g_@@_x_initial_dim \arraycolsep \dim_gadd:Nn \g_@@_x_final_dim \arraycolsep } +% \end{macrocode} +% However, if a node of column exists (if the array has been constructed with a +% fixed width of column), we use it. +% \begin{macrocode} + \cs_if_exist:cT + { pgf@sh@ns@nm -\int_use:N \g_@@_env_int - col - #1 } + { + \begin { tikzpicture } [ remember~picture ] + \tikz@parse@node\pgfutil@firstofone + ( col - #1 ) + \dim_gset:Nn \g_@@_x_initial_dim \pgf@x + \dim_gset:Nn \g_@@_x_final_dim \pgf@x + \end { tikzpicture } + } \@@_draw_tikz_line: } } @@ -5938,9 +5855,17 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { NiceMatrixBlock } { ! O { } } { + \int_gincr:N \g_@@_NiceMatrixBlock_int + \dim_zero:N \l_@@_columns_width_dim \keys_set:nn { NiceMatrix / NiceMatrixBlock } { #1 } - \int_zero_new:N \l_@@_first_env_block_int - \int_set:Nn \l_@@_first_env_block_int { \g_@@_env_int + 1 } + \bool_if:NT \l_@@_block_auto_columns_width_bool + { + \cs_if_exist:cT { @@_max_cell_width_ \int_use:N \g_@@_NiceMatrixBlock_int } + { + \dim_set:Nx \l_@@_columns_width_dim + { \use:c { @@_max_cell_width _ \int_use:N \g_@@_NiceMatrixBlock_int } } + } + } } % \end{macrocode} % @@ -5954,13 +5879,11 @@ c & c & b & a & e \bool_if:NT \l_@@_block_auto_columns_width_bool { \iow_now:Nn \@mainaux \ExplSyntaxOn - \int_step_inline:nnnn \l_@@_first_env_block_int 1 \g_@@_env_int + \iow_now:Nx \@mainaux { - \iow_now:Nx \@mainaux - { - \cs_gset:cpn { @@ _ max _ cell _ width _ ##1 } - { \dim_use:N \g_@@_max_cell_width_dim } - } + \cs_gset:cpn + { @@ _ max _ cell _ width _ \int_use:N \g_@@_NiceMatrixBlock_int } + { \dim_use:N \g_@@_max_cell_width_dim } } \iow_now:Nn \@mainaux \ExplSyntaxOff } @@ -6002,14 +5925,14 @@ c & c & b & a & e \cs_new_protected:Nn \@@_create_extra_nodes: { \begin { tikzpicture } [ remember~picture , overlay ] - \int_step_variable:nnNn \g_@@_first_row_int \g_@@_row_total_int \@@_i: + \int_step_variable:nnNn \l_@@_first_row_int \g_@@_row_total_int \@@_i: { \dim_zero_new:c { l_@@_row_\@@_i: _min_dim } \dim_set_eq:cN { l_@@_row_\@@_i: _min_dim } \c_max_dim \dim_zero_new:c { l_@@_row_\@@_i: _max_dim } \dim_set:cn { l_@@_row_\@@_i: _max_dim } { - \c_max_dim } } - \int_step_variable:nnNn \g_@@_first_col_int \g_@@_col_total_int \@@_j: + \int_step_variable:nnNn \l_@@_first_col_int \g_@@_col_total_int \@@_j: { \dim_zero_new:c { l_@@_column_\@@_j: _min_dim } \dim_set_eq:cN { l_@@_column_\@@_j: _min_dim } \c_max_dim @@ -6019,10 +5942,10 @@ c & c & b & a & e % \end{macrocode} % We begin the two nested loops over the rows and the columns of the array. % \begin{macrocode} - \int_step_variable:nnNn \g_@@_first_row_int \g_@@_row_total_int \@@_i: + \int_step_variable:nnNn \l_@@_first_row_int \g_@@_row_total_int \@@_i: { \int_step_variable:nnNn - \g_@@_first_col_int \g_@@_col_total_int \@@_j: + \l_@@_first_col_int \g_@@_col_total_int \@@_j: % \end{macrocode} % Maybe the cell ($i$-$j$) is an implicit cell (that is to say a cell after % implicit ampersands |&|). In this case, of course, we don't update the @@ -6075,8 +5998,8 @@ c & c & b & a & e % That's why the loop over the rows will start at 1 and the loop over the columns % will stop at $|\g_@@_col_int|$ (and not |\g_@@_col_total_int|). Idem for the rows. % \begin{macrocode} - \int_set:Nn \g_@@_first_row_int 1 - \int_set:Nn \g_@@_first_col_int 1 + \int_set:Nn \l_@@_first_row_int 1 + \int_set:Nn \l_@@_first_col_int 1 % \end{macrocode} % We have to change the values of all the dimensions % \texttt{l_@@_row_\textsl{i}_min_dim}, \texttt{l_@@_row_\textsl{i}_max_dim}, @@ -6113,10 +6036,10 @@ c & c & b & a & e } \dim_sub:cn { l_@@_column _ 1 _ min _ dim } - \g_@@_left_margin_dim + \l_@@_left_margin_dim \dim_add:cn { l_@@_column _ \int_use:N \g_@@_col_int _ max _ dim } - \g_@@_right_margin_dim + \l_@@_right_margin_dim % \end{macrocode} % Now, we can actually create the ``large nodes''. % \begin{macrocode} @@ -6167,9 +6090,9 @@ c & c & b & a & e % \begin{macrocode} \cs_new_protected:Nn \@@_create_nodes: { - \int_step_variable:nnNn \g_@@_first_row_int \g_@@_row_total_int \@@_i: + \int_step_variable:nnNn \l_@@_first_row_int \g_@@_row_total_int \@@_i: { - \int_step_variable:nnNn \g_@@_first_col_int \g_@@_col_total_int \@@_j: + \int_step_variable:nnNn \l_@@_first_col_int \g_@@_col_total_int \@@_j: % \end{macrocode} % We create two ponctual nodes for the extremities of a diagonal of the % rectangular node we want to create. These nodes |(@@~south~west)| and @@ -6196,8 +6119,8 @@ c & c & b & a & e inner~sep = \c_zero_dim , name = nm - \int_use:N \g_@@_env_int - \@@_i: - \@@_j: , alias = - \str_if_empty:NF \g_@@_name_str - { \g_@@_name_str - \@@_i: - \@@_j: } + \str_if_empty:NF \l_@@_name_str + { \l_@@_name_str - \@@_i: - \@@_j: } ] ; } @@ -6208,7 +6131,7 @@ c & c & b & a & e % |\multicolumn{|$n$|}{...}{...}| with $n$>1 was issued and in % |\g_@@_multicolumn_sizes_seq| the correspondant values of $n$. % \begin{macrocode} - \@@_seq_mapthread_function:NNN + \seq_mapthread_function:NNN \g_@@_multicolumn_cells_seq \g_@@_multicolumn_sizes_seq \@@_node_for_multicolumn:nn @@ -6249,7 +6172,7 @@ c & c & b & a & e inner~sep = \c_zero_dim , name = nm - \int_use:N \g_@@_env_int - \@@_i: - \@@_j: , alias = - \str_if_empty:NF \g_@@_name_str { \g_@@_name_str - \@@_i: - \@@_j: } + \str_if_empty:NF \l_@@_name_str { \l_@@_name_str - \@@_i: - \@@_j: } ] ; } @@ -6385,6 +6308,29 @@ c & c & b & a & e } % \end{macrocode} % +% % \subsection{How to draw the dotted lines transparently} +% \begin{macrocode} +\cs_set_protected:Npn \@@_renew_matrix: + { + \RenewDocumentEnvironment { pmatrix } { } + { \pNiceMatrix } + { \endpNiceMatrix } + \RenewDocumentEnvironment { vmatrix } { } + { \vNiceMatrix } + { \endvNiceMatrix } + \RenewDocumentEnvironment { Vmatrix } { } + { \VNiceMatrix } + { \endVNiceMatrix } + \RenewDocumentEnvironment { bmatrix } { } + { \bNiceMatrix } + { \endbNiceMatrix } + \RenewDocumentEnvironment { Bmatrix } { } + { \BNiceMatrix } + { \endBNiceMatrix } + } +% \end{macrocode} +% +% % % \subsection{We process the options} % @@ -6398,12 +6344,41 @@ c & c & b & a & e % Of course, the command |\NiceMatrix| must be defined before such an % instruction is executed. % \begin{macrocode} -\ProcessKeysOptions { NiceMatrix } +\keys_define:nn { NiceMatrix / Package } + { + renew-dots .bool_set:N = \l_@@_renew_dots_bool , + renew-dots .value_forbidden:n = true , + renew-matrix .code:n = \@@_renew_matrix: , + renew-matrix .value_forbidden:n = true , + transparent .meta:n = { renew-dots , renew-matrix } , + transparent .value_forbidden:n = true, + } +\ProcessKeysOptions { NiceMatrix / Package } % \end{macrocode} % % \subsection{Error messages of the package} % % \begin{macrocode} +\@@_msg_new:nn { last-col~non~empty~for~NiceArray } + { + In~the~environment~\{\g_@@_type_env_str\},~you~must~use~the~option~ + 'last-col'~without~value~(the~number~of~columns~is~known~by~the~ + preamble~of~the~environment).\\ + However,~you~can~go~on~for~this~time~ + (the~value~'\l_keys_value_tl'~will~be~ignored). + } +% \end{macrocode} +% +% \begin{macrocode} +\@@_msg_new:nn { last-col~empty~for~NiceMatrix } + { + In~the~environment~\{\g_@@_type_env_str\}~you~can't~use~the~option~ + 'last-col'~without~value.~You~must~give~the~number~of~that~last~column.\\ + If~you~go~on~this~option~will~be~ignored. + } +% \end{macrocode} +% +% \begin{macrocode} \@@_msg_new:nn { Block~too~large } { You~try~to~draw~a~block~in~the~cell~#1-#2~of~your~matrix~but~the~matrix~is~ @@ -6425,7 +6400,7 @@ c & c & b & a & e % \begin{macrocode} \@@_msg_new:nn { Wrong~last~row } { - You~have~used~'last-row=\int_use:N \g_@@_last_row_int'~but~your~environment~ + You~have~used~'last-row=\int_use:N \l_@@_last_row_int'~but~your~environment~ \{\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'~ @@ -6502,7 +6477,7 @@ c & c & b & a & e renew-dots,~ renew-matrix,~ right-margin,~ - small,~ + small~ and~transparent } % \end{macrocode} @@ -6528,50 +6503,28 @@ c & c & b & a & e create-extra-nodes,~ extra-left-margin,~ extra-right-margin,~ + first-col,~ + first-row,~ hlines,~ + last-col,~ + last-row,~ left-margin,~ name,~ nullify-dots,~ parallelize-diags,~ renew-dots,~ right-margin,~ - small,~ + small~ and~t. } % \end{macrocode} % -% -% \begin{macrocode} -\@@_msg_new:nnn { Unknown~option~for~NiceMatrix } - { - The~option~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~environment~ - \{NiceMatrix\}~and~its~variants. \\ - If~you~go~on,~it~will~be~ignored. \\ - For~a~list~of~the~available~options,~type~H~<return>. - } - { - The~available~options~are~(in~alphabetic~order):~ - code-after,~ - columns-width,~ - create-extra-nodes,~ - extra-left-margin,~ - extra-right-margin,~ - hlines,~ - left-margin,~ - name,~ - nullify-dots,~ - parallelize-diags,~ - renew-dots,~ - right-margin~ - and~small. - } -% \end{macrocode} -% % \medskip -% Despite its name, the following set of keys will be used for |{pNiceArray}| -% but also |{vNiceArray}|, |{VNiceArray}|, etc. but not for |{NiceArray}|. +% This error message is used for the set of keys |NiceMatrix/NiceMatrix| and +% |NiceMatrix/pNiceArray| (but not by |NiceMatrix/NiceArray| (because, for this +% set of keys, there is also the options |t|, |c| and~|b|). % \begin{macrocode} -\@@_msg_new:nnn { Unknown~option~for~pNiceArray } +\@@_msg_new:nnn { Unknown~option~for~NiceMatrix } { The~option~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~environment~ \{\g_@@_type_env_str\}. \\ @@ -6591,9 +6544,9 @@ c & c & b & a & e extra-right-margin,~ first-col,~ first-row,~ + hlines,~ last-col,~ last-row,~ - hlines,~ left-margin,~ name,~ nullify-dots,~ @@ -6646,54 +6599,7 @@ c & c & b & a & e first~position~of~the~preamble~of~the~environment~\{\g_@@_type_env_str\}. \\ If~you~go~on,~this~dotted~line~will~be~ignored. } -% \end{macrocode} -% -% -% \subsection{Code for \textbackslash seq_mapthread_function:NNN} -% -% In |\@@_create_nodes:| (used twice in |\@@_create_extra_nodes:| to create the -% ``medium nodes'' and ``large nodes''), we want to use -% |\seq_mapthread_function:NNN| which is in \pkg{l3candidates}). For security, -% we define a function |\@@_seq_mapthread_function:NNN|. We will delete the -% following code when |\seq_mapthread_function:NNN| will be in \pkg{l3seq}. -% \begin{macrocode} -\cs_new:Npn \@@_seq_mapthread_function:NNN #1 #2 #3 - { - \group_begin: -% \end{macrocode} -% In the group, we can use |\seq_pop:NN| safely. -% \begin{macrocode} - \int_step_inline:nn { \seq_count:N #1 } - { - \seq_pop:NN #1 \l_tmpa_tl - \seq_pop:NN #2 \l_tmpb_tl - \exp_args:NVV #3 \l_tmpa_tl \l_tmpb_tl - } - \group_end: - } -% \end{macrocode} -% -% \begin{macrocode} -\cs_set_protected:Npn \@@_renew_matrix: - { - \RenewDocumentEnvironment { pmatrix } { } - { \pNiceMatrix } - { \endpNiceMatrix } - \RenewDocumentEnvironment { vmatrix } { } - { \vNiceMatrix } - { \endvNiceMatrix } - \RenewDocumentEnvironment { Vmatrix } { } - { \VNiceMatrix } - { \endVNiceMatrix } - \RenewDocumentEnvironment { bmatrix } { } - { \bNiceMatrix } - { \endbNiceMatrix } - \RenewDocumentEnvironment { Bmatrix } { } - { \BNiceMatrix } - { \endBNiceMatrix } - } -% \end{macrocode} -% +% \end{macrocode} % % % \subsection{Obsolete environments} @@ -6701,7 +6607,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { pNiceArrayC } { } { - \bool_set_true:N \l_@@_last_col_bool + \int_set:Nn \l_@@_last_col_int \c_zero_dim \pNiceArray } { \endpNiceArray } @@ -6710,7 +6616,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { bNiceArrayC } { } { - \bool_set_true:N \l_@@_last_col_bool + \int_set:Nn \l_@@_last_col_int \c_zero_dim \bNiceArray } { \endbNiceArray } @@ -6719,7 +6625,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { BNiceArrayC } { } { - \bool_set_true:N \l_@@_last_col_bool + \int_set:Nn \l_@@_last_col_int \c_zero_dim \BNiceArray } { \endBNiceArray } @@ -6728,7 +6634,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { vNiceArrayC } { } { - \bool_set_true:N \l_@@_last_col_bool + \int_set:Nn \l_@@_last_col_int \c_zero_dim \vNiceArray } { \endvNiceArray } @@ -6737,7 +6643,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { VNiceArrayC } { } { - \bool_set_true:N \l_@@_last_col_bool + \int_set:Nn \l_@@_last_col_int \c_zero_dim \VNiceArray } { \endVNiceArray } @@ -6746,7 +6652,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { pNiceArrayRC } { } { - \bool_set_true:N \l_@@_last_col_bool + \int_set:Nn \l_@@_last_col_int \c_zero_dim \int_set:Nn \l_@@_first_row_int \c_zero_int \pNiceArray } @@ -6756,7 +6662,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { bNiceArrayRC } { } { - \bool_set_true:N \l_@@_last_col_bool + \int_set:Nn \l_@@_last_col_int \c_zero_dim \int_set:Nn \l_@@_first_row_int \c_zero_int \bNiceArray } @@ -6766,7 +6672,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { BNiceArrayRC } { } { - \bool_set_true:N \l_@@_last_col_bool + \int_set:Nn \l_@@_last_col_int \c_zero_dim \int_set:Nn \l_@@_first_row_int \c_zero_int \BNiceArray } @@ -6786,7 +6692,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { VNiceArrayRC } { } { - \bool_set_true:N \l_@@_last_col_bool + \int_set:Nn \l_@@_last_col_int \c_zero_dim \int_set:Nn \l_@@_first_row_int \c_zero_int \VNiceArray } @@ -6796,7 +6702,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { NiceArrayCwithDelims } { } { - \bool_set_true:N \l_@@_last_col_bool + \int_set:Nn \l_@@_last_col_int \c_zero_dim \NiceArrayWithDelims } { \endNiceArrayWithDelims } @@ -6805,7 +6711,7 @@ c & c & b & a & e % \begin{macrocode} \NewDocumentEnvironment { NiceArrayRCwithDelims } { } { - \bool_set_true:N \l_@@_last_col_bool + \int_set:Nn \l_@@_last_col_int \c_zero_dim \int_set:Nn \l_@@_first_row_int \c_zero_int \NiceArrayWithDelims } @@ -6972,7 +6878,20 @@ c & c & b & a & e % % Option |small|. % +% \subsection*{Changes between version 3.2 and 3.3} +% +% The options |first-row|, |last-row|, |first-col| and |last-col| are now +% available in the environments |{NiceMatrix}|, |{pNiceMatrix}|, +% |{bNiceMatrix}|, etc. +% +% The option |columns-width=auto| doesn't need any more a second compilation. +% +% The options |renew-dots|, |renew-matrix| and |transparent| are now available +% as package options (as said in the documentation). % +% The previous version of \pkg{nicematrix} was incompatible with a recent +% version of \pkg{expl3} (released 2019/09/30). This version is compatible. +% % \PrintIndex % % \tableofcontents @@ -6983,3 +6902,4 @@ c & c & b & a & e % TeX-fold-preserve-comments: nil % fill-column: 80 % End: + diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index 60dba930365..58aae5cd837 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{3.2a} -\def\myfiledate{2019/09/21} +\def\myfileversion{3.3} +\def\myfiledate{2019/10/01} \RequirePackage{tikz} \usetikzlibrary{fit} \RequirePackage{expl3}[2019/02/15] @@ -67,12 +67,12 @@ } } \int_new:N \g__nm_env_int +\int_new:N \g__nm_NiceMatrixBlock_int \dim_new:N \l__nm_columns_width_dim \seq_new:N \g__nm_names_seq \bool_new:N \l__nm_in_env_bool \bool_new:N \l__nm_NiceArray_bool -\bool_new:N \g__nm_NiceArray_bool \cs_new_protected:Npn \__nm_test_if_math_mode: { \if_mode_math: \else: @@ -95,18 +95,16 @@ \dim_new:N \l__nm_radius_dim \dim_set:Nn \l__nm_radius_dim { 0.53 pt } \str_new:N \g__nm_type_env_str +\tl_new:N \g__nm_code_after_tl \int_new:N \l__nm_first_row_int \int_set:Nn \l__nm_first_row_int 1 -\int_new:N \g__nm_first_row_int \int_new:N \l__nm_first_col_int \int_set:Nn \l__nm_first_col_int 1 -\int_new:N \g__nm_first_col_int \int_new:N \l__nm_last_row_int \int_set:Nn \l__nm_last_row_int { -2 } -\int_new:N \g__nm_last_row_int \bool_new:N \l__nm_last_row_without_value_bool -\bool_new:N \g__nm_last_row_without_value_bool -\bool_new:N \l__nm_last_col_bool +\int_new:N \l__nm_last_col_int +\int_set:Nn \l__nm_last_col_int { -1 } \bool_new:N \g__nm_last_col_found_bool \bool_new:N \c__nm_siunitx_loaded_bool \AtBeginDocument @@ -156,24 +154,29 @@ \bool_new:N \l__nm_nullify_dots_bool \bool_new:N \l__nm_auto_columns_width_bool \str_new:N \l__nm_name_str -\str_new:N \g__nm_name_str \bool_new:N \l__nm_extra_nodes_bool \bool_new:N \g__nm_extra_nodes_bool \dim_new:N \l__nm_left_margin_dim \dim_new:N \l__nm_right_margin_dim -\dim_new:N \g__nm_left_margin_dim -\dim_new:N \g__nm_right_margin_dim \dim_new:N \g__nm_width_last_col_dim \dim_new:N \g__nm_width_first_col_dim \dim_new:N \l__nm_extra_left_margin_dim \dim_new:N \l__nm_extra_right_margin_dim -\dim_new:N \g__nm_extra_right_margin_dim \keys_define:nn { NiceMatrix / Global } { + code-for-first-col .tl_set:N = \l__nm_code_for_first_col_tl , + code-for-first-col .value_required:n = true , + code-for-last-col .tl_set:N = \l__nm_code_for_last_col_tl , + code-for-last-col .value_required:n = true , + code-for-first-row .tl_set:N = \l__nm_code_for_first_row_tl , + code-for-first-row .value_required:n = true , + code-for-last-row .tl_set:N = \l__nm_code_for_last_row_tl , + code-for-last-row .value_required:n = true , small .bool_set:N = \l__nm_small_bool , hlines .bool_set:N = \l__nm_hlines_bool , parallelize-diags .bool_set:N = \l__nm_parallelize_diags_bool , renew-dots .bool_set:N = \l__nm_renew_dots_bool , + renew-dots .value_forbidden:n = true , nullify-dots .bool_set:N = \l__nm_nullify_dots_bool , create-extra-nodes .bool_set:N = \l__nm_extra_nodes_bool , left-margin .dim_set:N = \l__nm_left_margin_dim , @@ -187,17 +190,6 @@ extra-margin .meta:n = { extra-left-margin = #1 , extra-right-margin = #1 } , } -\keys_define:nn { NiceMatrix / Code } - { - code-for-first-col .tl_set:N = \l__nm_code_for_first_col_tl , - code-for-first-col .value_required:n = true , - code-for-last-col .tl_set:N = \l__nm_code_for_last_col_tl , - code-for-last-col .value_required:n = true , - code-for-first-row .tl_set:N = \l__nm_code_for_first_row_tl , - code-for-first-row .value_required:n = true , - code-for-last-row .tl_set:N = \l__nm_code_for_last_row_tl , - code-for-last-row .value_required:n = true , - } \keys_define:nn { NiceMatrix / Env } { columns-width .code:n = @@ -213,15 +205,17 @@ \str_set_eq:NN \l__nm_name_str \l_tmpa_str , name .value_required:n = true , code-after .tl_gset:N = \g__nm_code_after_tl , - code-after .initial:n = \c_empty_tl , code-after .value_required:n = true , + first-col .code:n = \int_zero:N \l__nm_first_col_int , + first-row .code:n = \int_zero:N \l__nm_first_row_int , + last-row .int_set:N = \l__nm_last_row_int , + last-row .default:n = -1 , } \keys_define:nn { NiceMatrix } { NiceMatrixOptions .inherit:n = { NiceMatrix / Global , - NiceMatrix / Code } , NiceMatrix .inherit:n = { @@ -232,13 +226,11 @@ { NiceMatrix / Global , NiceMatrix / Env , - NiceMatrix / Code } , pNiceArray .inherit:n = { NiceMatrix / Global , NiceMatrix / Env , - NiceMatrix / Code } } \keys_define:nn { NiceMatrix / NiceMatrixOptions } @@ -267,33 +259,39 @@ { \__nm_error:n { Bad~value~for~letter~for~dotted~lines } } } , letter-for-dotted-lines .value_required:n = true , - letter-for-dotted-lines .initial:n = \c_colon_str , unknown .code:n = \__nm_error:n { Unknown~key~for~NiceMatrixOptions } } +\str_new:N \l__nm_letter_for_dotted_lines_str +\str_set_eq:NN \l__nm_letter_for_dotted_lines_str \c_colon_str \NewDocumentCommand \NiceMatrixOptions { m } { \keys_set:nn { NiceMatrix / NiceMatrixOptions } { #1 } } \keys_define:nn { NiceMatrix / NiceMatrix } - { unknown .code:n = \__nm_error:n { Unknown~option~for~NiceMatrix } } + { + last-col .code:n = \tl_if_empty:nTF {#1} + { \__nm_error:n { last-col~empty~for~NiceMatrix } } + { \int_set:Nn \l__nm_last_col_int { #1 } } , + unknown .code:n = \__nm_error:n { Unknown~option~for~NiceMatrix } + } \keys_define:nn { NiceMatrix / NiceArray } { c .code:n = \str_set:Nn \l__nm_pos_env_str c , t .code:n = \str_set:Nn \l__nm_pos_env_str t , b .code:n = \str_set:Nn \l__nm_pos_env_str b , - first-col .code:n = \int_zero:N \l__nm_first_col_int , - last-col .bool_set:N = \l__nm_last_col_bool , - first-row .code:n = \int_zero:N \l__nm_first_row_int , - last-row .int_set:N = \l__nm_last_row_int , - last-row .default:n = -1 , + last-col .code:n = \tl_if_empty:nF {#1} + { \__nm_error:n { last-col~non~empty~for~NiceArray } } + \int_zero:N \l__nm_last_col_int , unknown .code:n = \__nm_error:n { Unknown~option~for~NiceArray } } \keys_define:nn { NiceMatrix / pNiceArray } { first-col .code:n = \int_zero:N \l__nm_first_col_int , - last-col .bool_set:N = \l__nm_last_col_bool , + last-col .code:n = \tl_if_empty:nF {#1} + { \__nm_error:n { last-col~non~empty~for~NiceArray } } + \int_zero:N \l__nm_last_col_int , first-row .code:n = \int_zero:N \l__nm_first_row_int , last-row .int_set:N = \l__nm_last_row_int , last-row .default:n = -1 , - unknown .code:n = \__nm_error:n { Unknown~option~for~pNiceArray } + unknown .code:n = \__nm_error:n { Unknown~option~for~NiceMatrix } } \cs_new_protected:Nn \__nm_Cell: { @@ -465,7 +463,7 @@ { \int_compare:nNnT \g__nm_row_int > { -1 } { - \int_compare:nNnF \g__nm_row_int = \g__nm_last_row_int + \int_compare:nNnF \g__nm_row_int = \l__nm_last_row_int { \hrule \@height \arrayrulewidth \skip_vertical:n { - \arrayrulewidth } @@ -475,41 +473,13 @@ } \cs_new_protected:Npn \__nm_pre_array: { + \tl_clear:N \g__nm_code_after_tl \bool_if:NT \l__nm_small_bool { \cs_set:Npn \arraystretch { 0.47 } \dim_set:Nn \arraycolsep { 1.45 pt } } - \bool_if:NT \l__nm_auto_columns_width_bool - { - \group_insert_after:N \__nm_write_max_cell_width: - \cs_if_free:cTF { __nm_max_cell_width_ \int_use:N \g__nm_env_int } - { \dim_zero:N \l__nm_columns_width_dim } - { - \dim_set:Nx \l__nm_columns_width_dim - { \use:c { __nm_max_cell_width _ \int_use:N \g__nm_env_int } } - } - \str_if_empty:NF \l__nm_name_str - { - \cs_if_free:cF { __nm_max_cell_width_ \l__nm_name_str } - { - \dim_set:Nx \l__nm_columns_width_dim - { \use:c { __nm_max_cell_width_ \l__nm_name_str } } - } - } - } \bool_gset_eq:NN \g__nm_extra_nodes_bool \l__nm_extra_nodes_bool - \dim_gset_eq:NN \g__nm_left_margin_dim \l__nm_left_margin_dim - \dim_gset_eq:NN \g__nm_right_margin_dim \l__nm_right_margin_dim - \dim_gset_eq:NN \g__nm_extra_right_margin_dim \l__nm_extra_right_margin_dim - \int_gset_eq:NN \g__nm_last_row_int \l__nm_last_row_int - \tl_gset_eq:NN \g__nm_name_str \l__nm_name_str - \int_gset_eq:NN \g__nm_first_row_int \l__nm_first_row_int - \int_gset_eq:NN \g__nm_first_col_int \l__nm_first_col_int - \bool_gset_eq:NN \g__nm_NiceArray_bool \l__nm_NiceArray_bool - \bool_gset_eq:NN \g__nm_last_row_without_value_bool - \l__nm_last_row_without_value_bool - \bool_gset_eq:NN \g__nm_small_bool \l__nm_small_bool \cs_set:Npn \ialign { \bool_if:NTF \c__nm_colortbl_loaded_bool @@ -542,17 +512,9 @@ } \halign } - \dim_compare:nNnTF \l__nm_columns_width_dim = \c_zero_dim - { - \newcolumntype L { > \__nm_Cell: l < \__nm_end_Cell: } - \newcolumntype C { > \__nm_Cell: c < \__nm_end_Cell: } - \newcolumntype R { > \__nm_Cell: r < \__nm_end_Cell: } - } - { - \newcolumntype L { w l { \dim_use:N \l__nm_columns_width_dim } } - \newcolumntype C { w c { \dim_use:N \l__nm_columns_width_dim } } - \newcolumntype R { w r { \dim_use:N \l__nm_columns_width_dim } } - } + \newcolumntype L { > \__nm_Cell: l < \__nm_end_Cell: } + \newcolumntype C { > \__nm_Cell: c < \__nm_end_Cell: } + \newcolumntype R { > \__nm_Cell: 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 @@ -622,7 +584,6 @@ \bool_set_true:N \l__nm_in_env_bool \cs_if_exist:NT \tikz@library@external@loaded { \tikzset { external / export = false } } - \group_insert_after:N \__nm_after_array: \int_gincr:N \g__nm_env_int \bool_if:NF \l__nm_block_auto_columns_width_bool { \dim_gzero_new:N \g__nm_max_cell_width_dim } @@ -634,7 +595,7 @@ \int_compare:nNnT \l__nm_last_row_int = { -1 } { \bool_set_true:N \l__nm_last_row_without_value_bool - \str_if_empty:NTF \g__nm_name_str + \str_if_empty:NTF \l__nm_name_str { \cs_if_exist:cT { __nm_last_row_ \int_use:N \g__nm_env_int } { @@ -643,16 +604,16 @@ } } { - \cs_if_exist:cT { __nm_last_row_ \g__nm_name_str } + \cs_if_exist:cT { __nm_last_row_ \l__nm_name_str } { \int_set:Nn \l__nm_last_row_int - { \use:c { __nm_last_row_ \g__nm_name_str } } + { \use:c { __nm_last_row_ \l__nm_name_str } } } } } \__nm_pre_array: - \dim_zero_new:N \g__nm_left_delim_dim - \dim_zero_new:N \g__nm_right_delim_dim + \dim_gzero_new:N \g__nm_left_delim_dim + \dim_gzero_new:N \g__nm_right_delim_dim \bool_if:NTF \l__nm_NiceArray_bool { \dim_gset:Nn \g__nm_left_delim_dim { 2 \arraycolsep } @@ -690,7 +651,7 @@ { \tl_put_left:Nn \l_tmpa_tl { @ { } } } } } - \bool_if:NTF \l__nm_last_col_bool + \int_compare:nNnTF \l__nm_last_col_int > { -1 } { \tl_put_right:NV \l_tmpa_tl \c__nm_preamble_last_col_tl } { \bool_if:NT \l__nm_NiceArray_bool @@ -706,19 +667,61 @@ \exp_args:NV \__nm_array: \l_tmpa_tl } { + \bool_if:nT + { + ( \l__nm_auto_columns_width_bool && ! \l__nm_block_auto_columns_width_bool) + || \dim_compare_p:nNn \l__nm_columns_width_dim > \c_zero_dim + } + { + \crcr + \int_compare:nNnT \l__nm_first_col_int = 0 { \omit & } + \omit + \tikz [ remember~picture , overlay ] + \coordinate [ name = nm - \int_use:N \g__nm_env_int - col - 0 ] ; + \bool_if:nTF + { + \l__nm_auto_columns_width_bool + && ! \l__nm_block_auto_columns_width_bool + } + { + \dim_gset:Nn \g_tmpa_dim + { \g__nm_max_cell_width_dim + 2 \arraycolsep } + } + { + \dim_gset:Nn \g_tmpa_dim + { \l__nm_columns_width_dim + 2 \arraycolsep } + } + \skip_horizontal:N \g_tmpa_dim + \int_gset:Nn \g_tmpa_int 1 + \bool_if:nTF \g__nm_last_col_found_bool + { \prg_replicate:nn { \g__nm_col_total_int - 2 } } + { \prg_replicate:nn { \g__nm_col_total_int - 1 } } + { + & + \omit + \int_gincr:N \g_tmpa_int + \skip_horizontal:N \g_tmpa_dim + \tikz [ remember~picture , overlay ] + \coordinate + [ + name = nm - \int_use:N \g__nm_env_int - + col - \int_use:N \g_tmpa_int + ] ; + } + } \endarray \c_math_toggle_token - \skip_horizontal:n \g__nm_right_margin_dim - \skip_horizontal:n \g__nm_extra_right_margin_dim + \skip_horizontal:n \l__nm_right_margin_dim + \skip_horizontal:n \l__nm_extra_right_margin_dim \hbox_set_end: - \int_compare:nNnT \g__nm_last_row_int > { -2 } + \int_compare:nNnT \l__nm_last_row_int > { -2 } { - \bool_if:NF \g__nm_last_row_without_value_bool + \bool_if:NF \l__nm_last_row_without_value_bool { - \int_compare:nNnF \g__nm_last_row_int = \g__nm_row_int + \int_compare:nNnF \l__nm_last_row_int = \g__nm_row_int { \__nm_error:n { Wrong~last~row } - \int_gset_eq:NN \g__nm_last_row_int \g__nm_row_int + \int_gset_eq:NN \l__nm_last_row_int \g__nm_row_int } } } @@ -742,14 +745,14 @@ } } { \dim_zero:N \l_tmpb_dim } - \int_compare:nNnT \g__nm_first_col_int = \c_zero_int + \int_compare:nNnT \l__nm_first_col_int = \c_zero_int { \skip_horizontal:n \arraycolsep \skip_horizontal:n \g__nm_width_first_col_dim } - \bool_if:NTF \g__nm_NiceArray_bool + \bool_if:NTF \l__nm_NiceArray_bool { - \int_compare:nNnT \g__nm_first_row_int = \c_zero_int + \int_compare:nNnT \l__nm_first_row_int = \c_zero_int { \str_if_eq:VnTF \l__nm_pos_env_str { t } { @@ -758,7 +761,7 @@ } } { - \bool_if:NT \g__nm_last_row_int + \int_compare:nNnT \l__nm_last_row_int > 0 { \str_if_eq:VnT \l__nm_pos_env_str { b } { @@ -800,6 +803,7 @@ \skip_horizontal:n \g__nm_width_last_col_dim \skip_horizontal:n \arraycolsep } + \__nm_after_array: } \tl_const:Nn \c__nm_preamble_first_col_tl { @@ -930,123 +934,69 @@ { \endNiceArrayWithDelims } \NewDocumentEnvironment { pNiceArray } { } { - \str_gset:Nn \g__nm_type_env_str { pNiceArray } + \str_if_empty:NT \g__nm_type_env_str + { \str_gset:Nn \g__nm_type_env_str { pNiceArray } } \__nm_test_if_math_mode: \NiceArrayWithDelims ( ) } { \endNiceArrayWithDelims } \NewDocumentEnvironment { bNiceArray } { } { - \str_gset:Nn \g__nm_type_env_str { bNiceArray } + \str_if_empty:NT \g__nm_type_env_str + { \str_gset:Nn \g__nm_type_env_str { NiceArray } } \__nm_test_if_math_mode: \NiceArrayWithDelims [ ] } { \endNiceArrayWithDelims } \NewDocumentEnvironment { BNiceArray } { } { - \str_gset:Nn \g__nm_type_env_str { BNiceArray } + \str_if_empty:NT \g__nm_type_env_str + { \str_gset:Nn \g__nm_type_env_str { BNiceArray } } \__nm_test_if_math_mode: \NiceArrayWithDelims \{ \} } { \endNiceArrayWithDelims } \NewDocumentEnvironment { vNiceArray } { } { - \str_gset:Nn \g__nm_type_env_str { vNiceArray } + \str_if_empty:NT \g__nm_type_env_str + { \str_gset:Nn \g__nm_type_env_str { vNiceArray } } \__nm_test_if_math_mode: \NiceArrayWithDelims | | } { \endNiceArrayWithDelims } \NewDocumentEnvironment { VNiceArray } { } { - \str_gset:Nn \g__nm_type_env_str { VNiceArray } + \str_if_empty:NT \g__nm_type_env_str + { \str_gset:Nn \g__nm_type_env_str { VNiceArray } } \__nm_test_if_math_mode: \NiceArrayWithDelims \| \| } { \endNiceArrayWithDelims } -\NewDocumentEnvironment { NiceMatrix } { ! O { } } +\cs_new_protected:Npn \__nm_define_env:n #1 { - \str_if_empty:NT \g__nm_type_env_str - { \str_gset:Nn \g__nm_type_env_str { NiceMatrix } } - \__nm_test_if_math_mode: - \bool_if:NT \l__nm_in_env_bool { \__nm_fatal:n { Yet~in~env } } - \bool_set_true:N \l__nm_in_env_bool - \cs_if_exist:NT \tikz@library@external@loaded - { \tikzset { external / export = false } } - \group_insert_after:N \__nm_after_array: - \int_gincr:N \g__nm_env_int - \bool_if:NF \l__nm_block_auto_columns_width_bool - { \dim_gzero_new:N \g__nm_max_cell_width_dim } - \keys_set:nn { NiceMatrix / NiceMatrix } { #1 } - \__nm_pre_array: - \skip_horizontal:n { - \arraycolsep } - \skip_horizontal:n \l__nm_left_margin_dim - \skip_horizontal:n \l__nm_extra_left_margin_dim - \str_set:Nn \l__nm_pos_env_str c - \bool_set_false:N \l__nm_exterior_arraycolsep_bool - \__nm_array: { * \c@MaxMatrixCols C } - } - { - \endarray - \skip_horizontal:n { - \arraycolsep } - \skip_horizontal:n \g__nm_right_margin_dim - \skip_horizontal:n \g__nm_extra_right_margin_dim - } -\NewDocumentEnvironment { pNiceMatrix } { } - { - \str_gset:Nn \g__nm_type_env_str { pNiceMatrix } - \__nm_test_if_math_mode: - \left( \begin{NiceMatrix} - } - { \end{NiceMatrix} \right) } -\NewDocumentEnvironment { bNiceMatrix } { } - { - \str_gset:Nn \g__nm_type_env_str { bNiceMatrix } - \__nm_test_if_math_mode: - \left[ \begin{NiceMatrix} - } - { \end{NiceMatrix} \right] } -\NewDocumentEnvironment { BNiceMatrix } { } - { - \str_gset:Nn \g__nm_type_env_str { BNiceMatrix } - \__nm_test_if_math_mode: - \left\{ \begin{NiceMatrix} - } - { \end{NiceMatrix} \right\} } -\NewDocumentEnvironment { vNiceMatrix } { } - { - \str_gset:Nn \g__nm_type_env_str { vNiceMatrix } - \__nm_test_if_math_mode: - \left\lvert \begin{NiceMatrix} - } - { \end{NiceMatrix} \right\rvert } -\NewDocumentEnvironment { VNiceMatrix } { } - { - \str_gset:Nn \g__nm_type_env_str { VNiceMatrix } - \__nm_test_if_math_mode: - \left\lVert \begin{NiceMatrix} - } - { \end{NiceMatrix} \right\rVert } -\cs_new_protected:Nn \__nm_write_max_cell_width: - { - \bool_if:NF \l__nm_block_auto_columns_width_bool + \NewDocumentEnvironment { #1 NiceMatrix } { ! O { } } { - \iow_now:Nn \@mainaux \ExplSyntaxOn - \iow_now:Nx \@mainaux + \str_gset:Nn \g__nm_type_env_str { #1 NiceMatrix } + \keys_set:nn { NiceMatrix / NiceMatrix } { ##1 } + \begin { #1 NiceArray } { - \cs_gset:cpn { __nm_max_cell_width_ \int_use:N \g__nm_env_int } - { \dim_use:N \g__nm_max_cell_width_dim } - } - \str_if_empty:NF \g__nm_name_str - { - \iow_now:Nx \@mainaux + * { - \cs_gset:cpn { __nm_max_cell_width_ \g__nm_name_str } - { \dim_use:N \g__nm_max_cell_width_dim } + \int_compare:nNnTF \l__nm_last_col_int = { -1 } + \c@MaxMatrixCols + { \int_eval:n { \l__nm_last_col_int - 1 } } } + C } - \iow_now:Nn \@mainaux \ExplSyntaxOff } + { \end { #1 NiceArray } } } +\__nm_define_env:n { } +\__nm_define_env:n p +\__nm_define_env:n b +\__nm_define_env:n B +\__nm_define_env:n v +\__nm_define_env:n V \prg_set_conditional:Npnn \__nm_if_not_empty_cell:nn #1 #2 { T , TF } { \bool_set_false:N \l_tmpa_bool @@ -1111,9 +1061,9 @@ \int_gset_eq:NN \g__nm_col_int \g__nm_col_total_int \bool_if:nT \g__nm_last_col_found_bool { \int_gdecr:N \g__nm_col_int } \int_gset_eq:NN \g__nm_row_total_int \g__nm_row_int - \int_compare:nNnT \g__nm_last_row_int > { -1 } + \int_compare:nNnT \l__nm_last_row_int > { -1 } { \int_gsub:Nn \g__nm_row_int \c_one_int } - \bool_if:NT \g__nm_last_row_without_value_bool + \bool_if:NT \l__nm_last_row_without_value_bool { \iow_now:Nn \@mainaux \ExplSyntaxOn \iow_now:Nx \@mainaux @@ -1121,11 +1071,11 @@ \cs_gset:cpn { __nm_last_row_ \int_use:N \g__nm_env_int } { \int_use:N \g__nm_row_total_int } } - \str_if_empty:NF \g__nm_name_str + \str_if_empty:NF \l__nm_name_str { \iow_now:Nx \@mainaux { - \cs_gset:cpn { __nm_last_row_ \g__nm_name_str } + \cs_gset:cpn { __nm_last_row_ \l__nm_name_str } { \int_use:N \g__nm_row_total_int } } } @@ -1147,7 +1097,7 @@ \int_zero_new:N \l__nm_final_j_int \bool_set_false:N \l__nm_initial_open_bool \bool_set_false:N \l__nm_final_open_bool - \bool_if:NT \g__nm_small_bool + \bool_if:NT \l__nm_small_bool { \dim_set:Nn \l__nm_radius_dim { 0.37 pt } \dim_set:Nn \l__nm_inter_dots_dim { 0.25 em } @@ -1618,8 +1568,9 @@ { ( \g__nm_x_final_dim - \g__nm_x_initial_dim ) * \dim_ratio:nn - { \l__nm_l_dim - \l__nm_inter_dots_dim * \l_tmpa_int } { \l__nm_l_dim * 2 } * - \l_tmpb_int + { \l__nm_l_dim - \l__nm_inter_dots_dim * \l_tmpa_int } + { \l__nm_l_dim * 2 } + * \l_tmpb_int } \dim_gadd:Nn \g__nm_y_initial_dim { @@ -1816,7 +1767,7 @@ \hbox_to_wd:nn { \l_tmpa_dim + 2 \arraycolsep - - \l__nm_left_margin_dim - \g__nm_right_margin_dim + - \l__nm_left_margin_dim - \l__nm_right_margin_dim } \__nm_dotfill: } @@ -1860,6 +1811,16 @@ \dim_gadd:Nn \g__nm_x_initial_dim \arraycolsep \dim_gadd:Nn \g__nm_x_final_dim \arraycolsep } + \cs_if_exist:cT + { pgf@sh@ns@nm -\int_use:N \g__nm_env_int - col - #1 } + { + \begin { tikzpicture } [ remember~picture ] + \tikz@parse@node\pgfutil@firstofone + ( col - #1 ) + \dim_gset:Nn \g__nm_x_initial_dim \pgf@x + \dim_gset:Nn \g__nm_x_final_dim \pgf@x + \end { tikzpicture } + } \__nm_draw_tikz_line: } } @@ -1925,21 +1886,27 @@ } \NewDocumentEnvironment { NiceMatrixBlock } { ! O { } } { + \int_gincr:N \g__nm_NiceMatrixBlock_int + \dim_zero:N \l__nm_columns_width_dim \keys_set:nn { NiceMatrix / NiceMatrixBlock } { #1 } - \int_zero_new:N \l__nm_first_env_block_int - \int_set:Nn \l__nm_first_env_block_int { \g__nm_env_int + 1 } + \bool_if:NT \l__nm_block_auto_columns_width_bool + { + \cs_if_exist:cT { __nm_max_cell_width_ \int_use:N \g__nm_NiceMatrixBlock_int } + { + \dim_set:Nx \l__nm_columns_width_dim + { \use:c { __nm_max_cell_width _ \int_use:N \g__nm_NiceMatrixBlock_int } } + } + } } { \bool_if:NT \l__nm_block_auto_columns_width_bool { \iow_now:Nn \@mainaux \ExplSyntaxOn - \int_step_inline:nnnn \l__nm_first_env_block_int 1 \g__nm_env_int + \iow_now:Nx \@mainaux { - \iow_now:Nx \@mainaux - { - \cs_gset:cpn { __nm _ max _ cell _ width _ ##1 } - { \dim_use:N \g__nm_max_cell_width_dim } - } + \cs_gset:cpn + { __nm _ max _ cell _ width _ \int_use:N \g__nm_NiceMatrixBlock_int } + { \dim_use:N \g__nm_max_cell_width_dim } } \iow_now:Nn \@mainaux \ExplSyntaxOff } @@ -1949,24 +1916,24 @@ \cs_new_protected:Nn \__nm_create_extra_nodes: { \begin { tikzpicture } [ remember~picture , overlay ] - \int_step_variable:nnNn \g__nm_first_row_int \g__nm_row_total_int \__nm_i: + \int_step_variable:nnNn \l__nm_first_row_int \g__nm_row_total_int \__nm_i: { \dim_zero_new:c { l__nm_row_\__nm_i: _min_dim } \dim_set_eq:cN { l__nm_row_\__nm_i: _min_dim } \c_max_dim \dim_zero_new:c { l__nm_row_\__nm_i: _max_dim } \dim_set:cn { l__nm_row_\__nm_i: _max_dim } { - \c_max_dim } } - \int_step_variable:nnNn \g__nm_first_col_int \g__nm_col_total_int \__nm_j: + \int_step_variable:nnNn \l__nm_first_col_int \g__nm_col_total_int \__nm_j: { \dim_zero_new:c { l__nm_column_\__nm_j: _min_dim } \dim_set_eq:cN { l__nm_column_\__nm_j: _min_dim } \c_max_dim \dim_zero_new:c { l__nm_column_\__nm_j: _max_dim } \dim_set:cn { l__nm_column_\__nm_j: _max_dim } { - \c_max_dim } } - \int_step_variable:nnNn \g__nm_first_row_int \g__nm_row_total_int \__nm_i: + \int_step_variable:nnNn \l__nm_first_row_int \g__nm_row_total_int \__nm_i: { \int_step_variable:nnNn - \g__nm_first_col_int \g__nm_col_total_int \__nm_j: + \l__nm_first_col_int \g__nm_col_total_int \__nm_j: { \cs_if_exist:cT { pgf@sh@ns@nm - \int_use:N \g__nm_env_int - \__nm_i: - \__nm_j: } { @@ -1994,8 +1961,8 @@ } \tikzset { name~suffix = -medium } \__nm_create_nodes: - \int_set:Nn \g__nm_first_row_int 1 - \int_set:Nn \g__nm_first_col_int 1 + \int_set:Nn \l__nm_first_row_int 1 + \int_set:Nn \l__nm_first_col_int 1 \int_step_variable:nNn { \g__nm_row_int - 1 } \__nm_i: { \dim_set:cn { l__nm_row _ \__nm_i: _ min _ dim } @@ -2026,10 +1993,10 @@ } \dim_sub:cn { l__nm_column _ 1 _ min _ dim } - \g__nm_left_margin_dim + \l__nm_left_margin_dim \dim_add:cn { l__nm_column _ \int_use:N \g__nm_col_int _ max _ dim } - \g__nm_right_margin_dim + \l__nm_right_margin_dim \tikzset { name~suffix = -large } \__nm_create_nodes: \end{tikzpicture} @@ -2053,9 +2020,9 @@ } \cs_new_protected:Nn \__nm_create_nodes: { - \int_step_variable:nnNn \g__nm_first_row_int \g__nm_row_total_int \__nm_i: + \int_step_variable:nnNn \l__nm_first_row_int \g__nm_row_total_int \__nm_i: { - \int_step_variable:nnNn \g__nm_first_col_int \g__nm_col_total_int \__nm_j: + \int_step_variable:nnNn \l__nm_first_col_int \g__nm_col_total_int \__nm_j: { \coordinate ( __nm~south~west ) at ( \dim_use:c { l__nm_column_ \__nm_j: _min_dim } , @@ -2070,13 +2037,13 @@ inner~sep = \c_zero_dim , name = nm - \int_use:N \g__nm_env_int - \__nm_i: - \__nm_j: , alias = - \str_if_empty:NF \g__nm_name_str - { \g__nm_name_str - \__nm_i: - \__nm_j: } + \str_if_empty:NF \l__nm_name_str + { \l__nm_name_str - \__nm_i: - \__nm_j: } ] ; } } - \__nm_seq_mapthread_function:NNN + \seq_mapthread_function:NNN \g__nm_multicolumn_cells_seq \g__nm_multicolumn_sizes_seq \__nm_node_for_multicolumn:nn @@ -2106,7 +2073,7 @@ inner~sep = \c_zero_dim , name = nm - \int_use:N \g__nm_env_int - \__nm_i: - \__nm_j: , alias = - \str_if_empty:NF \g__nm_name_str { \g__nm_name_str - \__nm_i: - \__nm_j: } + \str_if_empty:NF \l__nm_name_str { \l__nm_name_str - \__nm_i: - \__nm_j: } ] ; } @@ -2172,7 +2139,48 @@ \end{tikzpicture} } } -\ProcessKeysOptions { NiceMatrix } +\cs_set_protected:Npn \__nm_renew_matrix: + { + \RenewDocumentEnvironment { pmatrix } { } + { \pNiceMatrix } + { \endpNiceMatrix } + \RenewDocumentEnvironment { vmatrix } { } + { \vNiceMatrix } + { \endvNiceMatrix } + \RenewDocumentEnvironment { Vmatrix } { } + { \VNiceMatrix } + { \endVNiceMatrix } + \RenewDocumentEnvironment { bmatrix } { } + { \bNiceMatrix } + { \endbNiceMatrix } + \RenewDocumentEnvironment { Bmatrix } { } + { \BNiceMatrix } + { \endBNiceMatrix } + } +\keys_define:nn { NiceMatrix / Package } + { + renew-dots .bool_set:N = \l__nm_renew_dots_bool , + renew-dots .value_forbidden:n = true , + renew-matrix .code:n = \__nm_renew_matrix: , + renew-matrix .value_forbidden:n = true , + transparent .meta:n = { renew-dots , renew-matrix } , + transparent .value_forbidden:n = true, + } +\ProcessKeysOptions { NiceMatrix / Package } +\__nm_msg_new:nn { last-col~non~empty~for~NiceArray } + { + In~the~environment~\{\g__nm_type_env_str\},~you~must~use~the~option~ + 'last-col'~without~value~(the~number~of~columns~is~known~by~the~ + preamble~of~the~environment).\\ + However,~you~can~go~on~for~this~time~ + (the~value~'\l_keys_value_tl'~will~be~ignored). + } +\__nm_msg_new:nn { last-col~empty~for~NiceMatrix } + { + In~the~environment~\{\g__nm_type_env_str\}~you~can't~use~the~option~ + 'last-col'~without~value.~You~must~give~the~number~of~that~last~column.\\ + If~you~go~on~this~option~will~be~ignored. + } \__nm_msg_new:nn { Block~too~large } { You~try~to~draw~a~block~in~the~cell~#1-#2~of~your~matrix~but~the~matrix~is~ @@ -2187,7 +2195,7 @@ } \__nm_msg_new:nn { Wrong~last~row } { - You~have~used~'last-row=\int_use:N \g__nm_last_row_int'~but~your~environment~ + You~have~used~'last-row=\int_use:N \l__nm_last_row_int'~but~your~environment~ \{\g__nm_type_env_str\}~seems~to~have~\int_use:N \g__nm_row_int\ rows.~If~you~go~on,~the~value~of~\int_use:N \g__nm_row_int\ will~be~used~for~last~row.~You~can~avoid~this~problem~by~using~'last-row'~ @@ -2245,7 +2253,7 @@ renew-dots,~ renew-matrix,~ right-margin,~ - small,~ + small~ and~transparent } \__nm_msg_new:nnn { Unknown~option~for~NiceArray } @@ -2268,42 +2276,23 @@ create-extra-nodes,~ extra-left-margin,~ extra-right-margin,~ + first-col,~ + first-row,~ hlines,~ + last-col,~ + last-row,~ left-margin,~ name,~ nullify-dots,~ parallelize-diags,~ renew-dots,~ right-margin,~ - small,~ + small~ and~t. } \__nm_msg_new:nnn { Unknown~option~for~NiceMatrix } { The~option~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~environment~ - \{NiceMatrix\}~and~its~variants. \\ - If~you~go~on,~it~will~be~ignored. \\ - For~a~list~of~the~available~options,~type~H~<return>. - } - { - The~available~options~are~(in~alphabetic~order):~ - code-after,~ - columns-width,~ - create-extra-nodes,~ - extra-left-margin,~ - extra-right-margin,~ - hlines,~ - left-margin,~ - name,~ - nullify-dots,~ - parallelize-diags,~ - renew-dots,~ - right-margin~ - and~small. - } -\__nm_msg_new:nnn { Unknown~option~for~pNiceArray } - { - The~option~'\tl_use:N\l_keys_key_tl'~is~unknown~for~the~environment~ \{\g__nm_type_env_str\}. \\ If~you~go~on,~it~will~be~ignored. \\ For~a~list~of~the~available~options,~type~H~<return>. @@ -2321,9 +2310,9 @@ extra-right-margin,~ first-col,~ first-row,~ + hlines,~ last-col,~ last-row,~ - hlines,~ left-margin,~ name,~ nullify-dots,~ @@ -2364,82 +2353,53 @@ first~position~of~the~preamble~of~the~environment~\{\g__nm_type_env_str\}. \\ If~you~go~on,~this~dotted~line~will~be~ignored. } -\cs_new:Npn \__nm_seq_mapthread_function:NNN #1 #2 #3 - { - \group_begin: - \int_step_inline:nn { \seq_count:N #1 } - { - \seq_pop:NN #1 \l_tmpa_tl - \seq_pop:NN #2 \l_tmpb_tl - \exp_args:NVV #3 \l_tmpa_tl \l_tmpb_tl - } - \group_end: - } -\cs_set_protected:Npn \__nm_renew_matrix: - { - \RenewDocumentEnvironment { pmatrix } { } - { \pNiceMatrix } - { \endpNiceMatrix } - \RenewDocumentEnvironment { vmatrix } { } - { \vNiceMatrix } - { \endvNiceMatrix } - \RenewDocumentEnvironment { Vmatrix } { } - { \VNiceMatrix } - { \endVNiceMatrix } - \RenewDocumentEnvironment { bmatrix } { } - { \bNiceMatrix } - { \endbNiceMatrix } - \RenewDocumentEnvironment { Bmatrix } { } - { \BNiceMatrix } - { \endBNiceMatrix } - } \NewDocumentEnvironment { pNiceArrayC } { } { - \bool_set_true:N \l__nm_last_col_bool + \int_set:Nn \l__nm_last_col_int \c_zero_dim \pNiceArray } { \endpNiceArray } \NewDocumentEnvironment { bNiceArrayC } { } { - \bool_set_true:N \l__nm_last_col_bool + \int_set:Nn \l__nm_last_col_int \c_zero_dim \bNiceArray } { \endbNiceArray } \NewDocumentEnvironment { BNiceArrayC } { } { - \bool_set_true:N \l__nm_last_col_bool + \int_set:Nn \l__nm_last_col_int \c_zero_dim \BNiceArray } { \endBNiceArray } \NewDocumentEnvironment { vNiceArrayC } { } { - \bool_set_true:N \l__nm_last_col_bool + \int_set:Nn \l__nm_last_col_int \c_zero_dim \vNiceArray } { \endvNiceArray } \NewDocumentEnvironment { VNiceArrayC } { } { - \bool_set_true:N \l__nm_last_col_bool + \int_set:Nn \l__nm_last_col_int \c_zero_dim \VNiceArray } { \endVNiceArray } \NewDocumentEnvironment { pNiceArrayRC } { } { - \bool_set_true:N \l__nm_last_col_bool + \int_set:Nn \l__nm_last_col_int \c_zero_dim \int_set:Nn \l__nm_first_row_int \c_zero_int \pNiceArray } { \endpNiceArray } \NewDocumentEnvironment { bNiceArrayRC } { } { - \bool_set_true:N \l__nm_last_col_bool + \int_set:Nn \l__nm_last_col_int \c_zero_dim \int_set:Nn \l__nm_first_row_int \c_zero_int \bNiceArray } { \endbNiceArray } \NewDocumentEnvironment { BNiceArrayRC } { } { - \bool_set_true:N \l__nm_last_col_bool + \int_set:Nn \l__nm_last_col_int \c_zero_dim \int_set:Nn \l__nm_first_row_int \c_zero_int \BNiceArray } @@ -2453,24 +2413,25 @@ { \endvNiceArray } \NewDocumentEnvironment { VNiceArrayRC } { } { - \bool_set_true:N \l__nm_last_col_bool + \int_set:Nn \l__nm_last_col_int \c_zero_dim \int_set:Nn \l__nm_first_row_int \c_zero_int \VNiceArray } { \endVNiceArray } \NewDocumentEnvironment { NiceArrayCwithDelims } { } { - \bool_set_true:N \l__nm_last_col_bool + \int_set:Nn \l__nm_last_col_int \c_zero_dim \NiceArrayWithDelims } { \endNiceArrayWithDelims } \NewDocumentEnvironment { NiceArrayRCwithDelims } { } { - \bool_set_true:N \l__nm_last_col_bool + \int_set:Nn \l__nm_last_col_int \c_zero_dim \int_set:Nn \l__nm_first_row_int \c_zero_int \NiceArrayWithDelims } { \endNiceArrayWithDelims } + \endinput %% %% End of file `nicematrix.sty'. |