From 1d7a1c697696d66a97b64894f8553a61717928d9 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Tue, 7 Apr 2020 03:02:57 +0000 Subject: CTAN sync 202004070302 --- .../latex/contrib/nicematrix/nicematrix-french.pdf | Bin 343652 -> 343415 bytes .../latex/contrib/nicematrix/nicematrix-french.tex | 621 ++++++----- macros/latex/contrib/nicematrix/nicematrix.dtx | 1155 ++++++++++++-------- macros/latex/contrib/nicematrix/nicematrix.pdf | Bin 793498 -> 814877 bytes 4 files changed, 1030 insertions(+), 746 deletions(-) (limited to 'macros/latex/contrib/nicematrix') diff --git a/macros/latex/contrib/nicematrix/nicematrix-french.pdf b/macros/latex/contrib/nicematrix/nicematrix-french.pdf index 3b5ff88070..26f4bdf64a 100644 Binary files a/macros/latex/contrib/nicematrix/nicematrix-french.pdf and b/macros/latex/contrib/nicematrix/nicematrix-french.pdf differ diff --git a/macros/latex/contrib/nicematrix/nicematrix-french.tex b/macros/latex/contrib/nicematrix/nicematrix-french.tex index 2d157cce4f..27ec881c96 100644 --- a/macros/latex/contrib/nicematrix/nicematrix-french.tex +++ b/macros/latex/contrib/nicematrix/nicematrix-french.tex @@ -469,10 +469,6 @@ $\begin{pNiceMatrix} 1 & 2 & 3 & 4 & 5 \end{pNiceMatrix}$ -\bigskip -La commande |\hdotsfor| de \pkg{amsmath} prend un argument optionnel (entre crochets) qui est utilisé pour un -réglage fin de l'espace entre deux points consécutifs. Par homogénéité, |\Hdotsfor| prend aussi un argument -optionnel mais cet argument est écarté silencieusement. Remarque : Contrairement à la commande |\hdotsfor| de \pkg{amsmath}, la commande |\Hdotsfor| est utilisable lorsque l'extension \pkg{colortbl} est chargée (mais vous risquez d'avoir des problèmes si vous utilisez |\rowcolor| sur la @@ -528,11 +524,31 @@ $\begin{pmatrix} \end{scope} +\subsection{Les labels des lignes en pointillés} + +Les commandes |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, |\Iddots| et |\Hdotsfor| (ainsi que la commande |\line| dans +le |code-after| décrite p.~\pageref{line-in-code-after}) peuvent en fait prendre deux arguments optionnels +spécifiés par les caractères |_| et |^| pour des labels situés au-dessous et au-dessus de la ligne. Les arguments +sont composés en mode mathématique avec |\scriptstyle|. + +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +$\begin{bNiceMatrix} +1 & \hspace*{1cm} & 0 \\[8mm] + & ~emphase#\Ddots^{n \text{ times}}@ & \\ +0 & & 1 \\ +\end{bNiceMatrix}$ +\end{BVerbatim} +$\begin{bNiceMatrix} +1 & \hspace*{1cm} & 0 \\[8mm] + & \Ddots^{n \text{ times}} & \\ +0 & & 1 \\ +\end{bNiceMatrix}$ + \subsection{Personnalisation des lignes en pointillés} \label{customization} -Les lignes pointillées tracées par |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, |\Idots| et |\Hdotsfor| (ainsi que par la +Les lignes pointillées tracées par |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, |\Iddots| et |\Hdotsfor| (ainsi que par la commande |\line| dans le |code-after| décrite p.~\pageref{line-in-code-after}) peuvent être paramétrées par trois options (que l'on met entre crochets après la commande) : % @@ -542,7 +558,7 @@ paramétrées par trois options (que l'on met entre crochets après la commande) \item |line-style|. \end{itemize} -Ces options peuvent aussi être fixées avec |\NiceMatrixOption| ou bien au niveau d'un environnement mais elles +Ces options peuvent aussi être fixées avec |\NiceMatrixOptions| ou bien au niveau d'un environnement mais elles doivent alors être préfixées par |xdots|, ce qui fait que leurs noms deviennent : % \begin{itemize} @@ -659,24 +675,29 @@ Ne pas oublier les options |remember picture| et |overlay|. \bigskip Dans l'exemple suivant, nous avons surligné toutes les cases de la matrice. -\[\begin{pNiceMatrix}[ - code-after = {\begin{tikzpicture} - [every node/.style = {blend mode = multiply, - inner sep = 0 pt , - fill = red!15}] - \node [fit = (1-1)] {} ; - \node [fit = (1-3)] {} ; - \node [fit = (2-2)] {} ; - \node [fit = (3-1)] {} ; - \node [fit = (3-3)] {} ; - \node [fit = (1-2)] {} ; - \node [fit = (2-1)] {} ; - \node [fit = (2-3)] {} ; - \node [fit = (3-2)] {} ; - \end{tikzpicture}}] +\[\begin{pNiceMatrix} a & a + b & a + b + c \\ a & a & a + b \\ a & a & a +\CodeAfter +\begin{tikzpicture}[ + every node/.style = + { + blend mode = multiply, + inner sep = 0 pt , + fill = red!15 + } + ] +\node [fit = (1-1)] {} ; +\node [fit = (1-3)] {} ; +\node [fit = (2-2)] {} ; +\node [fit = (3-1)] {} ; +\node [fit = (3-3)] {} ; +\node [fit = (1-2)] {} ; +\node [fit = (2-1)] {} ; +\node [fit = (2-3)] {} ; +\node [fit = (3-2)] {} ; +\end{tikzpicture} \end{pNiceMatrix}\] @@ -836,24 +857,60 @@ avec des instructions Tikz classiques. Les nœuds devront être désignés sous correspondant au nom de l'environnement). De plus, une commande spéciale, nommée |\line| est disponible pour tracer directement des lignes en pointillés -entre les nœuds). +entre les nœuds). Elle peut par exemple être utilisée pour tracer une ligne entre deux cases adjacentes comme dans +l'exemple suivant. \label{line-in-code-after} \medskip -\begin{BVerbatim}[baseline=c,boxwidth=13cm] -$\begin{pNiceMatrix}[~emphase#code-after = {\line{1-1}{3-3}[color=blue]}@] -0 & 0 & 0 \\ -0 & & 0 \\ -0 & 0 & 0 +\begin{BVerbatim}[baseline=c,boxwidth=11cm] +\NiceMatrixOptions{xdots/shorten = 0.6 em} +\begin{pNiceMatrix}[~emphase#code-after=\line{2-2}{3-3}@] +I & 0 & \Cdots &0 \\ +0 & I & \Ddots &\Vdots\\ +\Vdots &\Ddots & I &0 \\ +0 &\Cdots & 0 &I +\end{pNiceMatrix} +\end{BVerbatim} +\begin{scope} +\NiceMatrixOptions{xdots/shorten = 0.6 em} +$\begin{pNiceMatrix}[code-after=\line{2-2}{3-3}] +I & 0 & \Cdots &0 \\ +0 & I & \Ddots &\Vdots\\ +\Vdots &\Ddots & I &0 \\ +0 &\Cdots & 0 &I \end{pNiceMatrix}$ +\end{scope} + +\medskip +Pour améliorer la lisibilité du code, une syntaxe alternative est proposée : on peut spécifier les instructions du +|code-after| à la fin de l'environnement, après le mot-clé |\CodeAfter|. + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=11cm] +\NiceMatrixOptions{xdots/shorten = 0.6 em} +\begin{pNiceMatrix} +I & 0 & \Cdots &0 \\ +0 & I & \Ddots &\Vdots\\ +\Vdots &\Ddots & I &0 \\ +0 &\Cdots & 0 &I +~emphase#\CodeAfter@ +~emphase#\line{2-2}{3-3}@ +\end{pNiceMatrix} \end{BVerbatim} -$\begin{pNiceMatrix}[code-after = {\line{1-1}{3-3}[color=blue]}] -0 & 0 & 0 \\ -0 & & 0 \\ -0 & 0 & 0 +\begin{scope} +\NiceMatrixOptions{xdots/shorten = 0.6 em} +$\begin{pNiceMatrix} +I & 0 & \Cdots &0 \\ +0 & I & \Ddots &\Vdots\\ +\Vdots &\Ddots & I &0 \\ +0 &\Cdots & 0 &I +\CodeAfter +\line{2-2}{3-3} \end{pNiceMatrix}$ +\end{scope} + -\section{L'environnement \{NiceArray\}} +\section{L'environnement \{NiceArray\} et ses variantes} \label{NiceArray} L'environnement |{NiceArray}| est similaire à l'environnement |{array}|. Comme pour |{array}|, l'argument @@ -866,38 +923,102 @@ Il est possible d'utiliser les constructions |w{...}{...}|, |W{...}{...}|, \verb |!{...}| et |*{n}{...}| mais les lettres |p|, |m| et |b| ne doivent pas être employées.\footnote{Dans une commande |\multicolumn|, on doit également utiliser les lettres |L|, |C| et |R|.} -\medskip -En plus des options proposées pour |{pNiceMatrix}| et ses variantes, l'environnement |{NiceArray}| propose une -option |baseline| qui prend en argument un entier qui indique le numéro de rangée dont la ligne de base servira de -ligne de base pour l'environnement |{NiceArray}|. +\bigskip +Sans surprise, l'extension \pkg{nicematrix} fournit également les variantes |{pNiceArray}|, |{vNiceArray}|, +|{VNiceArray}|, |{bNiceArray}| et |{BNiceArray}|. + +\interitem +L'un des intérêts de |{pNiceArray}| par rapport à |{pNiceMatrix}| est la possibilité de tracer des filets verticaux +: + +\bigskip +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +$\left[\begin{NiceArray}{CCCC|C} +a_1 & ? & \Cdots & ? & ? \\ +0 & & \Ddots & \Vdots & \Vdots\\ +\Vdots & \Ddots & \Ddots & ? \\ +0 & \Cdots & 0 & a_n & ? +\end{NiceArray}\right]$ +\end{BVerbatim} +$\left[\begin{NiceArray}{CCCC|C} +a_1 & ? & \Cdots & ? & ? \\ +0 & & \Ddots & \Vdots & \Vdots\\ +\Vdots & \Ddots & \Ddots & ? \\ +0 & \Cdots & 0 & a_n & ? +\end{NiceArray}\right]$ + +\interitem +Un autre intérêt est la possibilité d'utiliser plusieurs types d'alignement de colonnes. + +\bigskip +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +$\begin{pNiceArray}{LCR} +a_{11} & \Cdots & a_{1n} \\ +a_{21} & & a_{2n} \\ +\Vdots & & \Vdots \\ +a_{n-1,1} & \Cdots & a_{n-1,n} +\end{pNiceArray}$ +\end{BVerbatim} +$\begin{pNiceArray}{LCR} +a_{11} & \Cdots & a_{1n} \\ +a_{21} & & a_{2n} \\ +\Vdots & & \Vdots \\ +a_{n-1,1} & \Cdots & a_{n-1,n} +\end{pNiceArray}$ + + + +\interitem +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 ou asymétriques. \medskip \begin{BVerbatim}[baseline=c,boxwidth=11cm] -$A = -\begin{NiceArray}{CCCC}[hvlines,~emphase#baseline=2@] -1 & 2 & 3 & 4 \\ -1 & 2 & 3 & 4 \\ -1 & 2 & 3 & 4 \\ -\end{NiceArray}$ +$\begin{~emphase#NiceArrayWithDelims@} + {\downarrow}{\uparrow}{CCC}[margin] +1 & 2 & 3 \\ +4 & 5 & 6 \\ +7 & 8 & 9 \\ +\end{~emphase#NiceArrayWithDelims@}$ \end{BVerbatim} -% -$A = -\begin{NiceArray}{CCCC}[hvlines,baseline=2] -1 & 2 & 3 & 4 \\ -1 & 2 & 3 & 4 \\ -1 & 2 & 3 & 4 \\ -\end{NiceArray}$ +$\begin{NiceArrayWithDelims} + {\downarrow}{\uparrow}{CCC}[margin] +1 & 2 & 3 \\ +4 & 5 & 6 \\ +7 & 8 & 9 \\ +\end{NiceArrayWithDelims}$ -\smallskip -L'option |hvlines| utilisée dans cet exemple est présentée plus loin (cf. p. \pageref{hvlines}). +\bigskip +\subsection{Le positionnement vertical des matrices} + +L'extension \pkg{nicematrix} propose aussi une option |baseline| par la position verticale des matrices. Cette +option |baseline| prend comme valeur un entier qui indique le numéro de rangée dont la ligne de base servira de +ligne de base pour l'environnement |{NiceArray}|. \medskip +\begin{BVerbatim}[baseline=c,boxwidth=9cm] +$A = \begin{pNiceMatrix}[baseline=2] +\frac{1}{\sqrt{1+p^2}} & p & 1-p \\ +1 & 1 & 1 \\ +1 & p & 1+p +\end{pNiceMatrix}$ +\end{BVerbatim} +$A = \begin{pNiceMatrix}[baseline=2] +\frac{1}{\sqrt{1+p^2}} & p & 1-p \\ +1 & 1 & 1 \\ +1 & p & 1+p +\end{pNiceMatrix}$ + + +\interitem L'option |baseline| peut aussi prendre les trois valeurs spéciales |t|, |c| et |b|. Ces trois lettres peuvent aussi être utilisées de manière absolue comme pour l'option de l'environnement |{array}| de \pkg{array}. La valeur initiale de |baseline| est~|c|. -\medskip +\bigskip Dans l'exemple suivant, on utilise l'option |t| (synonyme de |baseline=t|) immédiatement après un |\item| de liste. On remarquera que la présence d'un |\hline| initial n'empêche pas l'alignement sur la ligne de base de la première rangée (avec |{array}| de {array}, il faut utiliser |\firsthline|\footnote{On peut aussi utiliser |\firsthline| @@ -933,7 +1054,7 @@ u_n & 1 & 2 & 4 & 8 & 16 & 32 \\ \end{minipage} -\medskip +\bigskip Il est également possible d'utiliser les outils de \pkg{booktabs}: |\toprule|, |\bottomrule| et |\midrule|.\par\nobreak @@ -970,76 +1091,6 @@ u_n & 1 & 2 & 4 & 8 & 16 & 32 \\ -\vspace{1cm} -L'utilisation de |{NiceArray}| permet de tracer des filets verticaux :\par\nobreak - -\bigskip -\begin{BVerbatim}[baseline=c,boxwidth=10cm] -$\left[\begin{NiceArray}{CCCC|C} -a_1 & ? & \Cdots & ? & ? \\ -0 & & \Ddots & \Vdots & \Vdots\\ -\Vdots & \Ddots & \Ddots & ? \\ -0 & \Cdots & 0 & a_n & ? -\end{NiceArray}\right]$ -\end{BVerbatim} -$\left[\begin{NiceArray}{CCCC|C} -a_1 & ? & \Cdots & ? & ? \\ -0 & & \Ddots & \Vdots & \Vdots\\ -\Vdots & \Ddots & \Ddots & ? \\ -0 & \Cdots & 0 & a_n & ? -\end{NiceArray}\right]$ - -\vspace{1cm} -Il existe également des variantes pour l'environnement |{NiceArray}| : |{pNiceArray}|, |{bNiceArray}|, -|{BNiceArray}|, |{vNiceArray}| et |{VNiceArray}|. La clé |baseline| n'est \emph{pas} disponible pour ces -environnements. - - -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 -\begin{BVerbatim}[baseline=c,boxwidth=10cm] -$\begin{pNiceArray}{LCR} -a_{11} & \Cdots & a_{1n} \\ -a_{21} & & a_{2n} \\ -\Vdots & & \Vdots \\ -a_{n-1,1} & \Cdots & a_{n-1,n} -\end{pNiceArray}$ -\end{BVerbatim} -$\begin{pNiceArray}{LCR} -a_{11} & \Cdots & a_{1n} \\ -a_{21} & & a_{2n} \\ -\Vdots & & \Vdots \\ -a_{n-1,1} & \Cdots & a_{n-1,n} -\end{pNiceArray}$ - - -\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 ou asymétriques. - -\medskip -\begin{BVerbatim}[baseline=c,boxwidth=11cm] -$\begin{~emphase#NiceArrayWithDelims@} - {\downarrow}{\uparrow}{CCC}[margin] -1 & 2 & 3 \\ -4 & 5 & 6 \\ -7 & 8 & 9 \\ -\end{~emphase#NiceArrayWithDelims@}$ -\end{BVerbatim} -$\begin{NiceArrayWithDelims} - {\downarrow}{\uparrow}{CCC}[margin] -1 & 2 & 3 \\ -4 & 5 & 6 \\ -7 & 8 & 9 \\ -\end{NiceArrayWithDelims}$ - - \bigskip \section{Les rangées et colonnes extérieures} @@ -1431,7 +1482,7 @@ Dans les exemples qui suivent, on utilise la commande |\arrayrulecolor| de \pkg{ \medskip \begin{BVerbatim}[baseline=c,boxwidth=10.6cm] -\arrayrulecolor{cyan} +\arrayrulecolor{blue} $\begin{bNiceArray}{CCC|C}[margin] ~emphase#\Block{3-3}{A}@ & & & 0 \\ & \hspace*{1cm} & & \Vdots \\ @@ -1442,7 +1493,7 @@ $\begin{bNiceArray}{CCC|C}[margin] \arrayrulecolor{black} \end{BVerbatim} \begin{scope} -\arrayrulecolor{cyan} +\arrayrulecolor{blue} $\begin{bNiceArray}{CCC|C}[margin] \Block{3-3}{A} & & & 0 \\ & \hspace*{1cm} & & \Vdots \\ @@ -1461,7 +1512,7 @@ pourquoi une option à mettre entre chevrons est proposée par |\Block| pour sp \medskip \begin{BVerbatim}[baseline=c,boxwidth=10.6cm] -\arrayrulecolor{cyan} +\arrayrulecolor{blue} $\begin{bNiceArray}{CCC|C}[margin] \Block{3-3}~emphase#<\Large>@{A} & & & 0 \\ & \hspace*{1cm} & & \Vdots \\ @@ -1472,7 +1523,7 @@ $\begin{bNiceArray}{CCC|C}[margin] \arrayrulecolor{black} \end{BVerbatim} \begin{scope} -\arrayrulecolor{cyan} +\arrayrulecolor{blue} $\begin{bNiceArray}{CCC|C}[margin] \Block{3-3}<\Large>{A} & & & 0 \\ & \hspace*{1cm} & & \Vdots \\ @@ -1683,15 +1734,15 @@ Dans les environnements de \pkg{nicematrix}, on peut bien entendu ajouter des fi avec la commande~|\hline| et des filets verticaux avec le spécificateur ``\verb+|+'' dans le préambule de l'environnement. Par souci de commodité, l'extension \pkg{nicematrix} fournit aussi l'option |hlines| (resp. |vlines|) qui impose directement que tous les filets horizontaux (resp. verticaux) soient tracés (à l'exception, -très naturelle, des filets extérieurs aux rangées et colonnes extérieures). L'option |lines| est la conjonction des -options |hlines| et |vlines|. +très naturelle, des filets extérieurs aux rangées et colonnes extérieures). L'option |hvlines| est la conjonction +des options |hlines| et |vlines|. \medskip Dans l'exemple suivant, on utilise la commande |\arrayrulecolor| de \pkg{colortbl}. \medskip \begin{BVerbatim}[baseline=c,boxwidth=11cm] -\arrayrulecolor{cyan} +\arrayrulecolor{blue} $\begin{NiceArray}{CCCC}% [~emphase#hvlines@,first-row,first-col] & e & a & b & c \\ @@ -1703,7 +1754,7 @@ c & c & b & a & e \arrayrulecolor{black} \end{BVerbatim} % -\arrayrulecolor{cyan} +\arrayrulecolor{blue} $\begin{NiceArray}{CCCC}[hvlines,first-row,first-col] & e & a & b & c \\ e & e & a & b & c \\ @@ -1833,6 +1884,9 @@ En revanche, les colonnes |d| de l'extension \pkg{dcolumn} ne sont pas prises en \section{Remarques techniques} +Première remarque : l'extension \pkg{nicematrix} doit être chargée après l'extension \pkg{underscore}. Si ce n'est +pas le cas, une erreur est levée. + \subsection{Pour définir de nouveaux types de colonnes} \label{OnlyMainNiceMatrix} @@ -1874,40 +1928,6 @@ Le spécificateur |?| ainsi créé est aussi utilisable dans les environnements cas, |\OnlyMainNiceMatrix| est sans effet. -\subsection{Intersection des lignes pointillées} - -Depuis la version 3.1 de \pkg{nicematrix}, les lignes en pointillées créées par |\Cdots|, |\Ldots|, |\Vdots|, etc. -ne peuvent pas se croiser entre elles.\footnote{En revanche, les lignes créées par |\hdottedline|, la lettre - ``|:|'' dans le préambule de la matrice et la commande |\line| dans le |code-after| peuvent croiser une autre - ligne en pointillés.} - -Cela signifie qu'une ligne en pointillés créée par l'une des ces commandes s'arrête automatiquement quand elle -arrive à une autre ligne pointillée déjà tracée par l'une de ces commandes. Par conséquent, l'ordre dans lequel les -lignes sont tracées a son importance pour le résultat final. Voici cet ordre (c'est à dessein qu'il a été choisi -ainsi) : |\Hdotsfor|, |\Vdots|, |\Ddots|, |\Iddots|, |\Cdots| et |\Ldots|. - -\medskip -De ce fait, on peut tracer la matrice suivante :\par\nobreak - -\smallskip -\begin{BVerbatim}[baseline = c, boxwidth = 10.5cm] -$\begin{pNiceMatrix}[nullify-dots] -1 & 2 & 3 & \Cdots & n \\ -1 & 2 & 3 & \Cdots & n \\ -\Vdots & \Cdots & & \Hspace*{15mm} & \Vdots \\ -& \Cdots & & & \\ -& \Cdots & & & \\ -& \Cdots & & & \\ -\end{pNiceMatrix}$ -\end{BVerbatim} -$\begin{pNiceMatrix}[nullify-dots] -1 & 2 & 3 & \Cdots & n \\ -1 & 2 & 3 & \Cdots & n \\ -\Vdots & \Cdots & & \Hspace*{15mm} & \Vdots \\ -& \Cdots & & & \\ -& \Cdots & & & \\ -& \Cdots & & & \\ -\end{pNiceMatrix}$ @@ -2273,12 +2293,12 @@ a_p & &&a_0 & & &b_1 \\ \end{scope} \vspace{2cm} -Un exemple avec un système linéaire (le trait vertical a été tracé en cyan avec les outils de +Un exemple avec un système linéaire (le trait vertical a été tracé en bleu avec les outils de \pkg{colortbl}):\par\nobreak \begin{Verbatim} -\arrayrulecolor{cyan} -$\begin{pNiceArray}{*6C|C}[nullify-dots,last-col,code-for-last-col={\scriptstyle}] +\arrayrulecolor{blue} +$\begin{pNiceArray}{*6C|C}[nullify-dots,last-col,code-for-last-col=\scriptstyle] 1 & 1 & 1 &\Cdots & & 1 & 0 & \\ 0 & 1 & 0 &\Cdots & & 0 & & L_2 \gets L_2-L_1 \\ 0 & 0 & 1 &\Ddots & & \Vdots & & L_3 \gets L_3-L_1 \\ @@ -2289,8 +2309,8 @@ $\begin{pNiceArray}{*6C|C}[nullify-dots,last-col,code-for-last-col={\scriptstyle \arrayrulecolor{black} \end{Verbatim} -\arrayrulecolor{cyan} -\[\begin{pNiceArray}{*6C|C}[nullify-dots,last-col,code-for-last-col={\scriptstyle}] +\arrayrulecolor{blue} +\[\begin{pNiceArray}{*6C|C}[nullify-dots,last-col,code-for-last-col=\scriptstyle] 1 & 1 & 1 &\Cdots & & 1 & 0 & \\ 0 & 1 & 0 &\Cdots & & 0 & & L_2 \gets L_2-L_1 \\ 0 & 0 & 1 &\Ddots & & \Vdots & & L_3 \gets L_3-L_1 \\ @@ -2301,6 +2321,42 @@ $\begin{pNiceArray}{*6C|C}[nullify-dots,last-col,code-for-last-col={\scriptstyle \arrayrulecolor{black} +\subsection{Des lignes pointillées qui ne sont plus pointillées} + + +L'option |line-style| permet de changer le style des lignes tracées par |\Ldots|, |\Cdots|, etc. On peut de ce fait +tracer des lignes qui ne sont plus pointillées. + +\begin{Verbatim} +\NiceMatrixOptions + {nullify-dots,code-for-first-col = \color{blue},code-for-first-col=\color{blue}} +$\begin{pNiceMatrix}[first-row,first-col] + & & \Ldots[line-style={solid,<->},shorten=0pt]^{n \text{ columns}} \\ + & 1 & 1 & 1 & \Ldots & 1 \\ + & 1 & 1 & 1 & & 1 \\ +\Vdots[line-style={solid,<->}]_{n \text{ rows}} + & 1 & 1 & 1 & & 1 \\ + & 1 & 1 & 1 & & 1 \\ + & 1 & 1 & 1 & \Ldots & 1 \\ +\end{pNiceMatrix}$ +\end{Verbatim} + + +\begin{scope} +\NiceMatrixOptions + {nullify-dots,code-for-first-col = \color{blue},code-for-first-row=\color{blue}} +\[\begin{pNiceMatrix}[first-row,first-col] + & & \Ldots[line-style={solid,<->},shorten=0pt]^{n \text{ columns}} \\ + & 1 & 1 & 1 & \Ldots & 1 \\ + & 1 & 1 & 1 & & 1 \\ +\Vdots[line-style={solid,<->}]_{n \text{ rows}} & 1 & 1 & 1 & & 1 \\ + & 1 & 1 & 1 & & 1 \\ + & 1 & 1 & 1 & \Ldots & 1 \\ +\end{pNiceMatrix}\] +\end{scope} + + + \subsection{Largeur des colonnes} \medskip @@ -2310,13 +2366,20 @@ voulons la même largeur (automatique) pour toutes les colonnes. \bigskip \begin{BVerbatim} ~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@ -\NiceMatrixOptions{code-for-last-col = \color{blue}\scriptstyle} +\NiceMatrixOptions{code-for-last-col = \color{blue}\scriptstyle,light-syntax} \setlength{\extrarowheight}{1mm} $\begin{pNiceArray}{CCCC:C}[last-col] -1&1&1&1&1&\\ -2&4&8&16&9&\\ -3&9&27&81&36&\\ -4&16&64&256&100& + 1 1 1 1 1 ; + 2 4 8 16 9 ; + 3 9 27 81 36 ; + 4 16 64 256 100 +\end{pNiceArray}$ +\medskip +$\begin{pNiceArray}{CCCC:C}[last-col] + 1 1 1 1 1 ; + 0 2 6 14 7 { L_2 \gets -2 L_1 + L_2 } ; + 0 6 24 78 33 { L_3 \gets -3 L_1 + L_3 } ; + 0 12 60 252 96 { L_4 \gets -4 L_1 + L_4 } \end{pNiceArray}$ ... ~emphase#\end{NiceMatrixBlock}@ @@ -2326,59 +2389,59 @@ $\begin{pNiceArray}{CCCC:C}[last-col] \begin{multicols}{2} \begin{NiceMatrixBlock}[auto-columns-width] -\NiceMatrixOptions{code-for-last-col = \color{blue}\scriptstyle} +\NiceMatrixOptions{code-for-last-col = \color{blue}\scriptstyle,light-syntax} \setlength{\extrarowheight}{1mm} \enskip $\begin{pNiceArray}{CCCC:C}[last-col] -1&1&1&1&1&\\ -2&4&8&16&9&\\ -3&9&27&81&36&\\ -4&16&64&256&100& +1 1 1 1 1 ; +2 4 8 16 9 ; +3 9 27 81 36 ; +4 16 64 256 100 \end{pNiceArray}$ \medskip \enskip $\begin{pNiceArray}{CCCC:C}[last-col] -1&1&1&1&1&\\ -0&2&6&14&7&L_2\gets-2L_1+L_2 \\ -0&6&24&78&33&L_3\gets-3L_1+L_3 \\ -0&12&60&252&96&L_4\gets-4L_1+L_4 +1 1 1 1 1 ; +0 2 6 14 7 { L_2 \gets -2 L_1 + L_2 } ; +0 6 24 78 33 { L_3 \gets -3 L_1 + L_3 } ; +0 12 60 252 96 { L_4 \gets -4 L_1 + L_4 } \end{pNiceArray}$ \medskip \enskip $\begin{pNiceArray}{CCCC:C}[last-col] -1&1&1&1&1&\\ -0&1&3&7&\frac72&L_2\gets\frac12L_2\\ -0&3&12&39&\frac{33}2&L_3\gets\frac12L_3 \\ -0&1&5&21&8&L_4\gets\frac1{12}L_4 +1 1 1 1 1 ; +0 1 3 7 \frac72 { L_2 \gets \frac12 L_2 } ; +0 3 12 39 \frac{33}2 { L_3 \gets \frac12 L_3 } ; +0 1 5 21 8 { L_4 \gets \frac1{12} L_4 } \end{pNiceArray}$ \medskip \enskip $\begin{pNiceArray}{CCCC:C}[last-col] -1&1&1&1&1&\\ -0&1&3&7&\frac72&\\ -0&0&3&18&6&L_3 \gets -3L_2+L_3 \\ -0&0&-2&-14&-\frac92&L_4 \gets L_2-L_4 +1 1 1 1 1 ; +0 1 3 7 \frac72 ; +0 0 3 18 6 { L_3 \gets -3 L_2 + L_3 } ; +0 0 -2 -14 -\frac92 { L_4 \gets L_2 - L_4 } \end{pNiceArray}$ \medskip \enskip $\begin{pNiceArray}{CCCC:C}[last-col] -1&1&1&1&1&\\ -0&1&3&7&\frac72&\\ -0&0&1&6&2&L_3 \gets \frac13L_3\\ -0&0&-2&-14&-\frac92& +1 1 1 1 1 ; +0 1 3 7 \frac72 ; +0 0 1 6 2 { L_3 \gets \frac13 L_3 } ; +0 0 -2 -14 -\frac92 \end{pNiceArray}$ \medskip \enskip $\begin{pNiceArray}{CCCC:C}[last-col] -1&1&1&1&1&\\ -0&1&3&7&\frac72&\\ -0&0&1&6&2& \\ -0&0&0&-2&-\frac12 & L_4 \gets 2L_3+L_4 +1 1 1 1 1 ; +0 1 3 7 \frac72 ; +0 0 1 6 2 ; +0 0 0 -2 -\frac12 { L_4 \gets L_3 + L_4 } \end{pNiceArray}$ \end{NiceMatrixBlock} \end{multicols} @@ -2409,41 +2472,37 @@ voulons recréer des nœuds identiques aux premiers, nous devons fixer |inner se pas cela, les nouveaux nœuds seront plus grands que les nœuds d'origine créés par \pkg{nicematrix}). \begin{Verbatim} -$\begin{pNiceArray}{>{\strut}CCCC}% - [create-large-nodes,margin,extra-margin=2pt, - code-after = {\begin{tikzpicture} - [~emphase#name suffix = -large@, - every node/.style = {draw, - ~emphase#inner sep = 0pt@}] - \node [fit = (1-1)] {} ; - \node [fit = (2-2)] {} ; - \node [fit = (3-3)] {} ; - \node [fit = (4-4)] {} ; - \end{tikzpicture}}] -a_{11} & a_{12} & a_{13} & a_{14} \\ -a_{21} & a_{22} & a_{23} & a_{24} \\ -a_{31} & a_{32} & a_{33} & a_{34} \\ -a_{41} & a_{42} & a_{43} & a_{44} +$\begin{pNiceArray}{>{\strut}CCCC}[create-large-nodes,margin,extra-margin = 2pt] + a_{11} & a_{12} & a_{13} & a_{14} \\ + a_{21} & a_{22} & a_{23} & a_{24} \\ + a_{31} & a_{32} & a_{33} & a_{34} \\ + a_{41} & a_{42} & a_{43} & a_{44} +\CodeAfter + \begin{tikzpicture}[~emphase#name suffix = -large@, + every node/.style = {draw,~emphase#inner sep = 0 pt@}] + \node [fit = (1-1)] {} ; + \node [fit = (2-2)] {} ; + \node [fit = (3-3)] {} ; + \node [fit = (4-4)] {} ; + \end{tikzpicture} \end{pNiceArray}$ \end{Verbatim} - - -\[\begin{pNiceArray}{>{\strut}CCCC}[ - create-large-nodes,margin,extra-margin=2pt, - code-after = {\begin{tikzpicture}[name suffix = -large, - every node/.style = {draw, - inner sep = 0pt}] - \node [fit = (1-1)] {} ; - \node [fit = (2-2)] {} ; - \node [fit = (3-3)] {} ; - \node [fit = (4-4)] {} ; - \end{tikzpicture}}] +% +\[\begin{pNiceArray}{>{\strut}CCCC}[create-large-nodes,margin,extra-margin = 2pt] a_{11} & a_{12} & a_{13} & a_{14} \\ a_{21} & a_{22} & a_{23} & a_{24} \\ a_{31} & a_{32} & a_{33} & a_{34} \\ a_{41} & a_{42} & a_{43} & a_{44} +\CodeAfter +\begin{tikzpicture}[name suffix = -large, + every node/.style = {draw,inner sep = 0 pt}] + \node [fit = (1-1)] {} ; + \node [fit = (2-2)] {} ; + \node [fit = (3-3)] {} ; + \node [fit = (4-4)] {} ; +\end{tikzpicture} \end{pNiceArray}\] -% + On remarquera que les traits que l'on vient de tracer sont dessinés \emph{après} la matrice sans modifier la position des composantes de celle-ci. En revanche, les traits tracés par |\hline|, le spécificateur «\verb+|+» ou les options |hlines| et |vlines| «écartent» les composantes de la matrice (quand l'extension \pkg{array} est @@ -2520,34 +2579,23 @@ la case en haut à gauche (où a été utilisée la commande |\Block|). Si on a alors un nœud de ce type est aussi créé pour ce bloc avec un nom suffixé par |-medium|. \medskip -\begin{BVerbatim}[baseline=c,boxwidth=11.6cm] -$\begin{pNiceMatrix}% - [ - margin, - create-medium-nodes, - code-after = - { \tikz \node [~emphase#highlight = (1-1-block-medium)@] {} ; } - ] -\Block{3-3}<\Large>{A} & & & 0 \\ -& \hspace*{1cm} & & \Vdots \\ -& & & 0 \\ -0 & \Cdots& 0 & 0 -\end{pNiceMatrix}$ -\end{BVerbatim} -$\begin{pNiceMatrix}% - [ - margin, - create-medium-nodes, - code-after = - { \tikz \node [highlight = (1-1-block-medium)] {} ; } - ] -\Block{3-3}<\Large>{A} & & & 0 \\ -& \hspace*{1cm} & & \Vdots \\ -& & & 0 \\ -0 & \Cdots& 0 & 0 -\end{pNiceMatrix}$ - - +% $\begin{pNiceMatrix}[margin,create-medium-nodes] +% \Block{3-3}<\Large>{A} & & & 0 \\ +% & \hspace*{1cm} & & \Vdots \\ +% & & & 0 \\ +% 0 & \Cdots& 0 & 0 +% \CodeAfter +% \tikz \node [~emphase#highlight = (1-1-block-medium)@] {} ; +% \end{pNiceMatrix}$ +% \end{BVerbatim} +% $\begin{pNiceMatrix}[margin,create-medium-nodes] +% \Block{3-3}<\Large>{A} & & & 0 \\ +% & \hspace*{1cm} & & \Vdots \\ +% & & & 0 \\ +% 0 & \Cdots& 0 & 0 +% \CodeAfter +% \tikz \node [highlight = (1-1-block-medium)] {} ; +% \end{pNiceMatrix}$ @@ -2654,40 +2702,37 @@ a & a & a & L_3 Dans l'exemple suivant, on utilise les «nœuds larges» pour surligner une zone de la matrice.\par\nobreak \begin{Verbatim} -\left(\,\begin{NiceArray}{>{\strut}CCCC}% - [create-large-nodes,left-margin,right-margin, - code-after = {\tikz \path [~emphase#name suffix = -large@, - fill = red!15, - blend mode = multiply] - (1-1.north west) - |- (2-2.north west) - |- (3-3.north west) - |- (4-4.north west) - |- (4-4.south east) - |- (1-1.north west) ; } ] -A_{11} & A_{12} & A_{13} & A_{14} \\ -A_{21} & A_{22} & A_{23} & A_{24} \\ -A_{31} & A_{32} & A_{33} & A_{34} \\ -A_{41} & A_{42} & A_{43} & A_{44} -\end{NiceArray}\,\right) +\begin{pNiceArray}{>{\strut}CCCC}[create-large-nodes,margin,extra-margin=2pt] + A_{11} & A_{12} & A_{13} & A_{14} \\ + A_{21} & A_{22} & A_{23} & A_{24} \\ + A_{31} & A_{32} & A_{33} & A_{34} \\ + A_{41} & A_{42} & A_{43} & A_{44} +\CodeAfter + \tikz \path [~emphase#name suffix = -large@,fill = red!15, blend mode = multiply] + (1-1.north west) + |- (2-2.north west) + |- (3-3.north west) + |- (4-4.north west) + |- (4-4.south east) + |- (1-1.north west) ; +\end{pNiceArray} \end{Verbatim} -\[\left(\,\begin{NiceArray}{>{\strut}CCCC}[ - create-large-nodes,left-margin,right-margin, - code-after = {\tikz \path [name suffix = -large, - fill = red!15, - blend mode = multiply] - (1-1.north west) - |- (2-2.north west) - |- (3-3.north west) - |- (4-4.north west) - |- (4-4.south east) - |- (1-1.north west) ; } ] -A_{11} & A_{12} & A_{13} & A_{14} \\ -A_{21} & A_{22} & A_{23} & A_{24} \\ -A_{31} & A_{32} & A_{33} & A_{34} \\ -A_{41} & A_{42} & A_{43} & A_{44} -\end{NiceArray}\,\right)\] + +\[\begin{pNiceArray}{>{\strut}CCCC}[create-large-nodes,margin,extra-margin=2pt] + A_{11} & A_{12} & A_{13} & A_{14} \\ + A_{21} & A_{22} & A_{23} & A_{24} \\ + A_{31} & A_{32} & A_{33} & A_{34} \\ + A_{41} & A_{42} & A_{43} & A_{44} +\CodeAfter + \tikz \path [name suffix = -large,fill = red!15, blend mode = multiply] + (1-1.north west) + |- (2-2.north west) + |- (3-3.north west) + |- (4-4.north west) + |- (4-4.south east) + |- (1-1.north west) ; +\end{pNiceArray}\] \subsection{Utilisation directe des nœuds Tikz} diff --git a/macros/latex/contrib/nicematrix/nicematrix.dtx b/macros/latex/contrib/nicematrix/nicematrix.dtx index 04dd13a9dd..2bd6e5ed43 100644 --- a/macros/latex/contrib/nicematrix/nicematrix.dtx +++ b/macros/latex/contrib/nicematrix/nicematrix.dtx @@ -15,8 +15,8 @@ % % \fi % \iffalse -\def\myfileversion{3.14} -\def\myfiledate{2020/03/23} +\def\myfileversion{3.15} +\def\myfiledate{2020/04/06} % % %<*batchfile> @@ -85,8 +85,8 @@ version 2005/12/01 or later. % { % pdfinfo = % { -% Title = The extension 'nicematrix' , -% Subject = A LaTeX extension , +% Title = The package 'nicematrix' , +% Subject = A LaTeX package , % Author = F. Pantigny % } % } @@ -108,10 +108,10 @@ version 2005/12/01 or later. % This package can be used with |xelatex|, |lualatex|, |pdflatex| but also by % the classical workflow |latex|-|dvips|-|ps2pdf| (or Adobe Distiller). Two or % three compilations may be necessary. This package requires and \textbf{loads} -% the packages \pkg{expl3}, \pkg{l3keys2e}, \pkg{xparse}, \pkg{array}, -% \pkg{amsmath}, \pkg{pgfcore} and the module \pkg{shapes} of \textsc{pgf} -% (\pkg{tikz} is \emph{not} loaded). The final user only has to load the -% extension with |\usepackage{nicematrix}|. +% the packages \pkg{l3keys2e}, \pkg{xparse}, \pkg{array}, \pkg{amsmath}, +% \pkg{pgfcore} and the module \pkg{shapes} of \textsc{pgf} (\pkg{tikz} is +% \emph{not} loaded). The final user only has to load the package with +% |\usepackage{nicematrix}|. % % % \medskip @@ -189,9 +189,9 @@ version 2005/12/01 or later. % \end{scope} % % -% \section{The environments of this extension} +% \section{The environments of this package} % -% The extension \pkg{nicematrix} defines the following new environments. +% The package \pkg{nicematrix} defines the following new environments. % % \medskip % \begin{ttfamily} @@ -229,7 +229,7 @@ version 2005/12/01 or later. % % \section{The continuous dotted lines} % -% Inside the environments of the extension \pkg{nicematrix}, new commands are +% Inside the environments of the package \pkg{nicematrix}, new commands are % defined: |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, and |\Iddots|. These commands % are intended to be used in place of |\dots|, |\cdots|, |\vdots|, |\ddots| and % |\iddots|.\footnote{The command |\iddots|, defined in \pkg{nicematrix}, is a @@ -488,14 +488,9 @@ version 2005/12/01 or later. % 1 & 2 & 3 & 4 & 5 % \end{pNiceMatrix}$ % -% \bigskip -% The command |\hdotsfor| of \pkg{amsmath} takes an optional argument (between -% square brackets) which is used for fine tuning of the space between two -% consecutive dots. For homogeneity, |\Hdotsfor| has also an optional argument -% but this argument is discarded silently. % % Remark: Unlike the command |\hdotsfor| of \pkg{amsmath}, the command -% |\Hdotsfor| may be used when the extension \pkg{colortbl} is loaded (but you +% |\Hdotsfor| may be used when the package \pkg{colortbl} is loaded (but you % might have problem if you use |\rowcolor| on the same row as |\Hdotsfor|). % % \subsection{How to generate the continuous dotted lines transparently} @@ -551,12 +546,33 @@ version 2005/12/01 or later. % \end{pmatrix}$ % \end{scope} % +% \subsection{The labels of the dotted lines} +% +% The commands |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, |\Iddots| and |\Hdotsfor| +% (and the command |\line| in the |code-after| which is described +% p.~\pageref{line-in-code-after}) accept two optional arguments specified +% by the tokens |_| and |^| for labels positionned below and above the line. The +% arguments are composed in math mode with |\scriptstyle|. +% +% \begin{BVerbatim}[baseline=c,boxwidth=10cm] +% $\begin{bNiceMatrix} +% 1 & \hspace*{1cm} & 0 \\[8mm] +% & ~emphase#\Ddots^{n \text{ times}}@ & \\ +% 0 & & 1 \\ +% \end{bNiceMatrix}$ +% \end{BVerbatim} +% $\begin{bNiceMatrix} +% 1 & \hspace*{1cm} & 0 \\[8mm] +% & \Ddots^{n \text{ times}} & \\ +% 0 & & 1 \\ +% \end{bNiceMatrix}$ +% % \subsection{Customization of the dotted lines} % % \label{customization} % The dotted lines drawn by |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, |\Iddots| % and |\Hdotsfor| (and by the command |\line| in the |code-after| which is described -% in p.~\pageref{line-in-code-after}) may be customized by three options (specified +% p.~\pageref{line-in-code-after}) may be customized by three options (specified % between square brackets after the command): % \begin{itemize} % \item |color|; @@ -613,7 +629,7 @@ version 2005/12/01 or later. % % \medskip % In order to provide lines with rounded dots in the style of those provided by -% |\ldots| (at least with the \emph{Computer Modern} fonts), the extension +% |\ldots| (at least with the \emph{Computer Modern} fonts), the package % \pkg{nicematrix} embeds its own system to draw a dotted line (and this system % uses \textsc{pgf} and not Tikz). This style is called |standard| and that's % the initial value of the parameter |xdots/line-style|. @@ -876,24 +892,59 @@ version 2005/12/01 or later. % corresponding to the name of the environment). % % Moreover, a special command, called |\line|, is available to draw directly -% dotted lines between nodes. \label{line-in-code-after} +% dotted lines between nodes. It may be used, for example, to draw a dotted line +% between two adjacents cells. \label{line-in-code-after} % % \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=13cm] -% $\begin{pNiceMatrix}[~emphase#code-after = {\line{1-1}{3-3}[color=blue]}@] -% 0 & 0 & 0 \\ -% 0 & & 0 \\ -% 0 & 0 & 0 -% \end{pNiceMatrix}$ +% \begin{BVerbatim}[baseline=c,boxwidth=11cm] +% \NiceMatrixOptions{xdots/shorten = 0.6 em} +% \begin{pNiceMatrix}[~emphase#code-after=\line{2-2}{3-3}@] +% I & 0 & \Cdots &0 \\ +% 0 & I & \Ddots &\Vdots\\ +% \Vdots &\Ddots & I &0 \\ +% 0 &\Cdots & 0 &I +% \end{pNiceMatrix} % \end{BVerbatim} -% $\begin{pNiceMatrix}[code-after = {\line{1-1}{3-3}[color=blue]}] -% 0 & 0 & 0 \\ -% 0 & & 0 \\ -% 0 & 0 & 0 +% \begin{scope} +% \NiceMatrixOptions{xdots/shorten = 0.6 em} +% $\begin{pNiceMatrix}[code-after=\line{2-2}{3-3}] +% I & 0 & \Cdots &0 \\ +% 0 & I & \Ddots &\Vdots\\ +% \Vdots &\Ddots & I &0 \\ +% 0 &\Cdots & 0 &I % \end{pNiceMatrix}$ +% \end{scope} +% +% \medskip +% For the readability of the code, an alternative syntax is provided: it's +% possible to give the instructions of the |\code-after| at the end of the +% environment, after the keyword |\CodeAfter|. % +% \medskip +% \begin{BVerbatim}[baseline=c,boxwidth=11cm] +% \NiceMatrixOptions{xdots/shorten = 0.6 em} +% \begin{pNiceMatrix} +% I & 0 & \Cdots &0 \\ +% 0 & I & \Ddots &\Vdots\\ +% \Vdots &\Ddots & I &0 \\ +% 0 &\Cdots & 0 &I +% ~emphase#\CodeAfter@ +% ~emphase#\line{2-2}{3-3}@ +% \end{pNiceMatrix} +% \end{BVerbatim} +% \begin{scope} +% \NiceMatrixOptions{xdots/shorten = 0.6 em} +% $\begin{pNiceMatrix} +% I & 0 & \Cdots &0 \\ +% 0 & I & \Ddots &\Vdots\\ +% \Vdots &\Ddots & I &0 \\ +% 0 &\Cdots & 0 &I +% \CodeAfter +% \line{2-2}{3-3} +% \end{pNiceMatrix}$ +% \end{scope} % -% \section{The environment \{NiceArray\}} +% \section{The environment \{NiceArray\} and its variants} % \label{NiceArray} % % The environment |{NiceArray}| is similar to the environment |{array}|. As for @@ -908,30 +959,95 @@ version 2005/12/01 or later. % should not be used.\footnote{In a command |\multicolumn|, one should also use % the letters |L|, |C|, |R|.} % -% \medskip -% The environment |{NiceArray}| accepts the options available for -% |{pNiceMatrix}| and its variants but also a option |baseline| whose value is -% an integer which indicates the number of the row whose baseline is used -% as baseline for the environment |{NiceArray}|. +% \bigskip +% The package \pkg{nicematrix} provides also the variants |{pNiceArray}|, +%|{vNiceArray}|, |{VNiceArray}|, |{bNiceArray}| and |{BNiceArray}|. +% +% \bigskip +% Of course, one of the benefits of |{pNiceArray}| over |{pNiceMatrix}| is the +% possibility of drawing vertical rules: +% +%\bigskip +% \begin{BVerbatim}[baseline=c,boxwidth=10cm] +% $\left[\begin{NiceArray}{CCCC|C} +% a_1 & ? & \Cdots & ? & ? \\ +% 0 & & \Ddots & \Vdots & \Vdots\\ +% \Vdots & \Ddots & \Ddots & ? \\ +% 0 & \Cdots & 0 & a_n & ? +% \end{NiceArray}\right]$ +% \end{BVerbatim} +% $\left[\begin{NiceArray}{CCCC|C} +% a_1 & ? & \Cdots & ? & ? \\ +% 0 & & \Ddots & \Vdots & \Vdots\\ +% \Vdots & \Ddots & \Ddots & ? \\ +% 0 & \Cdots & 0 & a_n & ? +% \end{NiceArray}\right]$ +% +% \bigskip +% Another benefit is the possibility of using different alignments of columns. +% +% \bigskip +% \begin{BVerbatim}[baseline=c,boxwidth=10cm] +% $\begin{pNiceArray}{LCR} +% a_{11} & \Cdots & a_{1n} \\ +% a_{21} & & a_{2n} \\ +% \Vdots & & \Vdots \\ +% a_{n-1,1} & \Cdots & a_{n-1,n} +% \end{pNiceArray}$ +% \end{BVerbatim} +% $\begin{pNiceArray}{LCR} +% a_{11} & \Cdots & a_{1n} \\ +% a_{21} & & a_{2n} \\ +% \Vdots & & \Vdots \\ +% a_{n-1,1} & \Cdots & a_{n-1,n} +% \end{pNiceArray}$ +% +% +% \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 or asymetrical delimiters. % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=11cm] -% $A = -% \begin{NiceArray}{CCCC}[hvlines,~emphase#baseline=2@] -% 1 & 2 & 3 & 4 \\ -% 1 & 2 & 3 & 4 \\ -% 1 & 2 & 3 & 4 \\ -% \end{NiceArray}$ +% $\begin{~emphase#NiceArrayWithDelims@} +% {\downarrow}{\uparrow}{CCC}[margin] +% 1 & 2 & 3 \\ +% 4 & 5 & 6 \\ +% 7 & 8 & 9 \\ +% \end{~emphase#NiceArrayWithDelims@}$ % \end{BVerbatim} -% $A = -% \begin{NiceArray}{CCCC}[hvlines,baseline=2] -% 1 & 2 & 3 & 4 \\ -% 1 & 2 & 3 & 4 \\ -% 1 & 2 & 3 & 4 \\ -% \end{NiceArray}$ +% $\begin{NiceArrayWithDelims} +% {\downarrow}{\uparrow}{CCC}[margin] +% 1 & 2 & 3 \\ +% 4 & 5 & 6 \\ +% 7 & 8 & 9 \\ +% \end{NiceArrayWithDelims}$ +% +% +% \bigskip +% \section{The vertical position of the arrays} +% +% The package \pkg{nicematrix} provides a option |baseline| for the vertical +% position of the arrays. This option takes as value an integer which is the +% number of the row on which the array will be aligned. +% +% \medskip +% \begin{BVerbatim}[baseline=c,boxwidth=9cm] +% $A = \begin{pNiceMatrix}[baseline=2] +% \frac{1}{\sqrt{1+p^2}} & p & 1-p \\ +% 1 & 1 & 1 \\ +% 1 & p & 1+p +% \end{pNiceMatrix}$ +% \end{BVerbatim} +% $A = \begin{pNiceMatrix}[baseline=2] +% \frac{1}{\sqrt{1+p^2}} & p & 1-p \\ +% 1 & 1 & 1 \\ +% 1 & p & 1+p +% \end{pNiceMatrix}$ % -% \small -% (The option |hvlines| is presented further: cf. p. \pageref{hvlines}.) % % \medskip % It's also possible to use the option |baseline| with one of the special values @@ -1010,75 +1126,6 @@ version 2005/12/01 or later. % \end{minipage} % % -% \vspace{1cm} -% With |{NiceArray}|, it's possible to draw vertical rules:\par\nobreak -% -% \bigskip -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% $\left[\begin{NiceArray}{CCCC|C} -% a_1 & ? & \Cdots & ? & ? \\ -% 0 & & \Ddots & \Vdots & \Vdots\\ -% \Vdots & \Ddots & \Ddots & ? \\ -% 0 & \Cdots & 0 & a_n & ? -% \end{NiceArray}\right]$ -% \end{BVerbatim} -% $\left[\begin{NiceArray}{CCCC|C} -% a_1 & ? & \Cdots & ? & ? \\ -% 0 & & \Ddots & \Vdots & \Vdots\\ -% \Vdots & \Ddots & \Ddots & ? \\ -% 0 & \Cdots & 0 & a_n & ? -% \end{NiceArray}\right]$ -% -% \bigskip -% In fact, there is also variants for the environment |{NiceArray}|: -% |{pNiceArray}|, |{bNiceArray}|, |{BNiceArray}|, |{vNiceArray}| and -% |{VNiceArray}|. The key |baseline| is not available for these environments. -% -% In the following example, we use an environment |{pNiceArray}| (we don't use -% |{pNiceMatrix}| because we want to use the types |L| and |R| -% --- in |{pNiceMatrix}|, all the columns are of type |C|). -% -% \bigskip -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% $\begin{pNiceArray}{LCR} -% a_{11} & \Cdots & a_{1n} \\ -% a_{21} & & a_{2n} \\ -% \Vdots & & \Vdots \\ -% a_{n-1,1} & \Cdots & a_{n-1,n} -% \end{pNiceArray}$ -% \end{BVerbatim} -% $\begin{pNiceArray}{LCR} -% a_{11} & \Cdots & a_{1n} \\ -% a_{21} & & a_{2n} \\ -% \Vdots & & \Vdots \\ -% a_{n-1,1} & \Cdots & a_{n-1,n} -% \end{pNiceArray}$ -% -% -% \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 or asymetrical delimiters. -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=11cm] -% $\begin{~emphase#NiceArrayWithDelims@} -% {\downarrow}{\uparrow}{CCC}[margin] -% 1 & 2 & 3 \\ -% 4 & 5 & 6 \\ -% 7 & 8 & 9 \\ -% \end{~emphase#NiceArrayWithDelims@}$ -% \end{BVerbatim} -% $\begin{NiceArrayWithDelims} -% {\downarrow}{\uparrow}{CCC}[margin] -% 1 & 2 & 3 \\ -% 4 & 5 & 6 \\ -% 7 & 8 & 9 \\ -% \end{NiceArrayWithDelims}$ -% -% % \bigskip % \section{The exterior rows and columns} % The options |first-row|, |last-row|, |first-col| and |last-col| allow the @@ -1192,7 +1239,7 @@ version 2005/12/01 or later. % \item As shown in the previous example, an horizontal rule (drawn by |\hline|) % doesn't extend in the exterior columns and a vertical rule (specified by a % ``\verb+|+'' in the preamble of the array) doesn't extend in the exterior -% rows.\footnote{The latter is not true when the extension \pkg{arydshln} is +% rows.\footnote{The latter is not true when the package \pkg{arydshln} is % loaded besides \pkg{nicematrix}. In fact, \pkg{nicematrix} and \pkg{arydhsln} % are not totally compatible because \pkg{arydshln} redefines many internals of % \pkg{array}. On another hand, if one really wants a vertical rule running in @@ -1221,7 +1268,7 @@ version 2005/12/01 or later. % \section{The dotted lines to separate rows or columns} % % -% In the environments of the extension \pkg{nicematrix}, it's possible to use +% In the environments of the package \pkg{nicematrix}, it's possible to use % the command |\hdottedline| (provided by \pkg{nicematrix}) which is a % counterpart of the classical commands |\hline| and |\hdashline| (the latter is % a command of \pkg{arydshln}). @@ -1297,7 +1344,7 @@ version 2005/12/01 or later. % It's possible to change in \pkg{nicematrix} the letter used to specify a % vertical dotted line with the option |letter-for-dotted-lines| available in % |\NiceMatrixOptions|. For example, in this document, we have loaded the -% extension \pkg{arydshln} which uses the letter ``|:|'' to specify a vertical +% package \pkg{arydshln} which uses the letter ``|:|'' to specify a vertical % dashed line. Thus, by using |letter-for-dotted-lines|, we can use the % vertical lines of both \pkg{arydshln} and \pkg{nicematrix}. % @@ -1328,7 +1375,7 @@ version 2005/12/01 or later. % the three rules. % % \bigskip -% \emph{Remark} : In the extension \pkg{array} (on which the extension +% \emph{Remark} : In the package \pkg{array} (on which the package % \pkg{nicematrix} relies), horizontal and vertical rules make the array larger % or wider by a quantity equal to the width of the rule\footnote{In fact, this % is true only for |\hline| and ``"|"'' but not for |\cline|.}. In @@ -1496,7 +1543,7 @@ version 2005/12/01 or later. % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=10.6cm] -% \arrayrulecolor{cyan} +% \arrayrulecolor{blue} % $\begin{bNiceArray}{CCC|C}[margin] % ~emphase#\Block{3-3}{A}@ & & & 0 \\ % & \hspace*{1cm} & & \Vdots \\ @@ -1507,7 +1554,7 @@ version 2005/12/01 or later. % \arrayrulecolor{black} % \end{BVerbatim} % \begin{scope} -% \arrayrulecolor{cyan} +% \arrayrulecolor{blue} % $\begin{bNiceArray}{CCC|C}[margin] % \Block{3-3}{A} & & & 0 \\ % & \hspace*{1cm} & & \Vdots \\ @@ -1528,7 +1575,7 @@ version 2005/12/01 or later. % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=10.6cm] -% \arrayrulecolor{cyan} +% \arrayrulecolor{blue} % $\begin{bNiceArray}{CCC|C}[margin] % \Block{3-3}~emphase#<\Large>@{A} & & & 0 \\ % & \hspace*{1cm} & & \Vdots \\ @@ -1539,7 +1586,7 @@ version 2005/12/01 or later. % \arrayrulecolor{black} % \end{BVerbatim} % \begin{scope} -% \arrayrulecolor{cyan} +% \arrayrulecolor{blue} % $\begin{bNiceArray}{CCC|C}[margin] % \Block{3-3}<\Large>{A} & & & 0 \\ % & \hspace*{1cm} & & \Vdots \\ @@ -1647,10 +1694,10 @@ version 2005/12/01 or later. % % \label{small} % -% With the option |small|, the environments of the extension \pkg{nicematrix} +% With the option |small|, the environments of the package \pkg{nicematrix} % are composed in a way similar to the environment |{smallmatrix}| of the -% extension \pkg{amsmath} (and the environments |{psmallmatrix}|, -% |{bsmallmatrix}|, etc. of the extension \pkg{mathtools}). +% package \pkg{amsmath} (and the environments |{psmallmatrix}|, +% |{bsmallmatrix}|, etc. of the package \pkg{mathtools}). % % \bigskip % \begin{Verbatim} @@ -1678,7 +1725,7 @@ version 2005/12/01 or later. % One should note that the environment |{NiceMatrix}| with the option |small| is % not composed \emph{exactly} as the environment |{smallmatrix}|. Indeed, all % the environments of \pkg{nicematrix} are constructed upon |{array}| (of the -% extension \pkg{array}) whereas the environment |{smallmatrix}| is constructed +% package \pkg{array}) whereas the environment |{smallmatrix}| is constructed % directly with an |\halign| of TeX. % % \medskip @@ -1728,11 +1775,11 @@ version 2005/12/01 or later. % % \medskip % If LaTeX counters called |iRow| and |jCol| are defined in the document by -% extensions other than \pkg{nicematrix} (or by the user), they are shadowed in +% packages other than \pkg{nicematrix} (or by the user), they are shadowed in % the environments of \pkg{nicematrix}. % % \bigskip -% The extension \pkg{nicematrix} also provides commands in order to compose +% The package \pkg{nicematrix} also provides commands in order to compose % automatically matrices from a general pattern. These commands are % |\pAutoNiceMatrix|, |\bAutoNiceMatrix|, |\vAutoNiceMatrix|, % |\VAutoNiceMatrix| and |\BAutoNiceMatrix|. @@ -1756,7 +1803,7 @@ version 2005/12/01 or later. % \label{hvlines} % You can add horizontal rules between rows in the environments of % \pkg{nicematrix} with the usual command |\hline| and you can use the specifier -% ``"|"'' to add vertical rules. However, by convenience, the extension +% ``"|"'' to add vertical rules. However, by convenience, the package % \pkg{nicematrix} also provides the option |hlines| (resp. |vlines|) which will % draw all the horizontal (resp. vertical) rules (excepted, of course, the % exterior rules corresponding to the exterior rows and columns). The key @@ -1768,7 +1815,7 @@ version 2005/12/01 or later. % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=11cm] -% \arrayrulecolor{cyan} +% \arrayrulecolor{blue} % $\begin{NiceArray}{CCCC}% % [~emphase#hvlines@,first-row,first-col] % % & e & a & b & c \\ @@ -1779,7 +1826,7 @@ version 2005/12/01 or later. % \end{NiceArray}$ % \arrayrulecolor{black} % \end{BVerbatim} -% \arrayrulecolor{cyan} +% \arrayrulecolor{blue} % $\begin{NiceArray}{CCCC}[hvlines,first-row,first-col] % & e & a & b & c \\ % e & e & a & b & c \\ @@ -1838,7 +1885,7 @@ version 2005/12/01 or later. % \subsection{The option light-syntax} % % \label{light-syntax} -% The option |light-syntax|\footnote{This option is inspired by the extension +% The option |light-syntax|\footnote{This option is inspired by the package % \pkg{spalign} of Joseph Rabinoff.} allows the user to compose the arrays with a % lighter syntax, which gives a more readable TeX source. % @@ -1917,7 +1964,7 @@ version 2005/12/01 or later. % % \label{OnlyMainNiceMatrix} % -% The extension \pkg{nicematrix} provides the command |\OnlyMainNiceMatrix| +% The package \pkg{nicematrix} provides the command |\OnlyMainNiceMatrix| % which is meant to be used in definitions of new column types. Its argument is % evaluated if and only if we are in the main part of the array, that is to say % not in an eventual exterior row. @@ -1957,41 +2004,6 @@ version 2005/12/01 or later. % no-op. % % -% \subsection{Intersections of dotted lines} -% -% Since the version 3.1 of \pkg{nicematrix}, the dotted lines created by -% |\Cdots|, |\Ldots|, |\Vdots|, etc. can't intersect.\footnote{On the contrary, -% dotted lines created by |\hdottedline|, the letter ``|:|'' in the preamble -% of the array and the command |\line| in the |code-after| can have -% intersections with other dotted lines.} -% -% That means that a dotted line created by one these commands automatically -% stops when it arrives on a dotted line already drawn. Therefore, the order in -% which dotted lines are drawn is important. Here's that order (by design) : -% |\Hdotsfor|, |\Vdots|, |\Ddots|, |\Iddots|, |\Cdots| and |\Ldots|. -% -% With this structure, it's possible to draw the following matrix. -% -% \medskip -% \begin{BVerbatim}[baseline = c, boxwidth = 10.5cm] -% $\begin{pNiceMatrix}[nullify-dots] -% 1 & 2 & 3 & \Cdots & n \\ -% 1 & 2 & 3 & \Cdots & n \\ -% \Vdots & \Cdots & & \Hspace*{15mm} & \Vdots \\ -% & \Cdots & & & \\ -% & \Cdots & & & \\ -% & \Cdots & & & \\ -% \end{pNiceMatrix}$ -% \end{BVerbatim} -% % $\begin{pNiceMatrix}[nullify-dots] -% 1 & 2 & 3 & \Cdots & n \\ -% 1 & 2 & 3 & \Cdots & n \\ -% \Vdots & \Cdots & & \Hspace*{15mm} & \Vdots \\ -% & \Cdots & & & \\ -% & \Cdots & & & \\ -% & \Cdots & & & \\ -% \end{pNiceMatrix}$ -% % \subsection{The names of the PGF nodes created by nicematrix} % % We have said that, when a name is given to an environment of \pkg{nicematrix}, @@ -2134,7 +2146,7 @@ version 2005/12/01 or later. % |\hskip -\arraycolsep|\footnote{And not by inserting |@{}| on both sides of the % preamble of the array. As a consequence, the length of the |\hline| is not % modified and may appear too long, in particular when using square brackets}. -% The extension \pkg{nicematrix} does the same in all its environments, +% The package \pkg{nicematrix} does the same in all its environments, % |{NiceArray}| included. However, if the user wants the environment % |{NiceArray}| behaving by default like the environment |{array}| of % \pkg{array} (for example, when adapting an existing document) it's possible to @@ -2372,12 +2384,12 @@ version 2005/12/01 or later. % \end{scope} % % \vspace{2cm} -% An example for a linear system (the vertical rule has been drawn in cyan with +% An example for a linear system (the vertical rule has been drawn in blue with % the tools of \pkg{colortbl}):\par\nobreak % % \begin{Verbatim} -% \arrayrulecolor{cyan} -% $\begin{pNiceArray}{*6C|C}[nullify-dots,last-col,code-for-last-col={\scriptstyle}] +% \arrayrulecolor{blue} +% $\begin{pNiceArray}{*6C|C}[nullify-dots,last-col,code-for-last-col=\scriptstyle] % 1 & 1 & 1 &\Cdots & & 1 & 0 & \\ % 0 & 1 & 0 &\Cdots & & 0 & & L_2 \gets L_2-L_1 \\ % 0 & 0 & 1 &\Ddots & & \Vdots & & L_3 \gets L_3-L_1 \\ @@ -2388,9 +2400,8 @@ version 2005/12/01 or later. % \arrayrulecolor{black} % \end{Verbatim} % -% \arrayrulecolor{cyan} -% \[\begin{pNiceArray}{*6C|C}[nullify-dots,last-col, -% code-for-last-col={\scriptstyle}] +% \arrayrulecolor{blue} +% \[\begin{pNiceArray}{*6C|C}[nullify-dots,last-col,code-for-last-col=\scriptstyle] % 1 & 1 & 1 &\Cdots & & 1 & 0 & \\ % 0 & 1 & 0 &\Cdots & & 0 & & L_2 \gets L_2-L_1 \\ % 0 & 0 & 1 &\Ddots & & \Vdots & & L_3 \gets L_3-L_1 \\ @@ -2401,6 +2412,40 @@ version 2005/12/01 or later. % \arrayrulecolor{black} % % +% +% \subsection{Dotted lines which are no longer dotted} +% +% The option |line-style| controls the style of the lines drawn by |\Ldots|, +% |\Cdots|, etc. Thus, it's possible with these commands to draw lines which are +% not longer dotted. +% +% \begin{Verbatim} +% \NiceMatrixOptions +% {nullify-dots,code-for-first-col = \color{blue},code-for-first-col=\color{blue}} +% $\begin{pNiceMatrix}[first-row,first-col] +% & & \Ldots[line-style={solid,<->},shorten=0pt]^{n \text{ columns}} \\ +% & 1 & 1 & 1 & \Ldots & 1 \\ +% & 1 & 1 & 1 & & 1 \\ +% \Vdots[line-style={solid,<->}]_{n \text{ rows}} & 1 & 1 & 1 & & 1 \\ +% & 1 & 1 & 1 & & 1 \\ +% & 1 & 1 & 1 & \Ldots & 1 \\ +% \end{pNiceMatrix}$ +% \end{Verbatim} +% +% +% \begin{scope} +% \NiceMatrixOptions +% {nullify-dots,code-for-first-col = \color{blue},code-for-first-row=\color{blue}} +% \[\begin{pNiceMatrix}[first-row,first-col] +% & & \Ldots[line-style={solid,<->},shorten=0pt]^{n \text{ columns}} \\ +% & 1 & 1 & 1 & \Ldots & 1 \\ +% & 1 & 1 & 1 & & 1 \\ +% \Vdots[line-style={solid,<->}]_{n \text{ rows}} & 1 & 1 & 1 & & 1 \\ +% & 1 & 1 & 1 & & 1 \\ +% & 1 & 1 & 1 & \Ldots & 1 \\ +% \end{pNiceMatrix}\] +% \end{scope} +% % \subsection{Width of the columns} % % @@ -2412,13 +2457,20 @@ version 2005/12/01 or later. % \bigskip % \begin{BVerbatim} % ~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@ -% \NiceMatrixOptions{code-for-last-col = \color{blue}\scriptstyle} +% \NiceMatrixOptions{code-for-last-col = \color{blue}\scriptstyle,light-syntax} % \setlength{\extrarowheight}{1mm} -% \quad $\begin{pNiceArray}{CCCC:C}[last-col] -% 1&1&1&1&1&\\ -% 2&4&8&16&9&\\ -% 3&9&27&81&36&\\ -% 4&16&64&256&100& +% $\begin{pNiceArray}{CCCC:C}[last-col] +% 1 1 1 1 1 ; +% 2 4 8 16 9 ; +% 3 9 27 81 36 ; +% 4 16 64 256 100 +% \end{pNiceArray}$ +% \medskip +% $\begin{pNiceArray}{CCCC:C}[last-col] +% 1 1 1 1 1 ; +% 0 2 6 14 7 { L_2 \gets -2 L_1 + L_2 } ; +% 0 6 24 78 33 { L_3 \gets -3 L_1 + L_3 } ; +% 0 12 60 252 96 { L_4 \gets -4 L_1 + L_4 } % \end{pNiceArray}$ % ... % ~emphase#\end{NiceMatrixBlock}@ @@ -2426,65 +2478,65 @@ version 2005/12/01 or later. % % \bigskip % -% \begin{multicols}{2} +% % \begin{multicols}{2} % \begin{NiceMatrixBlock}[auto-columns-width] -% \NiceMatrixOptions{code-for-last-col = \color{blue}\scriptstyle} +% \NiceMatrixOptions{code-for-last-col = \color{blue}\scriptstyle,light-syntax} % \setlength{\extrarowheight}{1mm} % % \enskip $\begin{pNiceArray}{CCCC:C}[last-col] -% 1&1&1&1&1&\\ -% 2&4&8&16&9&\\ -% 3&9&27&81&36&\\ -% 4&16&64&256&100& +% 1 1 1 1 1 ; +% 2 4 8 16 9 ; +% 3 9 27 81 36 ; +% 4 16 64 256 100 % \end{pNiceArray}$ % % \medskip % % \enskip $\begin{pNiceArray}{CCCC:C}[last-col] -% 1&1&1&1&1&\\ -% 0&2&6&14&7&L_2\gets-2L_1+L_2 \\ -% 0&6&24&78&33&L_3\gets-3L_1+L_3 \\ -% 0&12&60&252&96&L_4\gets-4L_1+L_4 +% 1 1 1 1 1 ; +% 0 2 6 14 7 { L_2 \gets -2 L_1 + L_2 } ; +% 0 6 24 78 33 { L_3 \gets -3 L_1 + L_3 } ; +% 0 12 60 252 96 { L_4 \gets -4 L_1 + L_4 } % \end{pNiceArray}$ % % \medskip % % \enskip $\begin{pNiceArray}{CCCC:C}[last-col] -% 1&1&1&1&1&\\ -% 0&1&3&7&\frac72&L_2\gets\frac12L_2\\ -% 0&3&12&39&\frac{33}2&L_3\gets\frac12L_3 \\ -% 0&1&5&21&8&L_4\gets\frac1{12}L_4 +% 1 1 1 1 1 ; +% 0 1 3 7 \frac72 { L_2 \gets \frac12 L_2 } ; +% 0 3 12 39 \frac{33}2 { L_3 \gets \frac12 L_3 } ; +% 0 1 5 21 8 { L_4 \gets \frac1{12} L_4 } % \end{pNiceArray}$ % % \medskip % % \enskip $\begin{pNiceArray}{CCCC:C}[last-col] -% 1&1&1&1&1&\\ -% 0&1&3&7&\frac72&\\ -% 0&0&3&18&6&L_3 \gets -3L_2+L_3 \\ -% 0&0&-2&-14&-\frac92&L_4 \gets L_2-L_4 +% 1 1 1 1 1 ; +% 0 1 3 7 \frac72 ; +% 0 0 3 18 6 { L_3 \gets -3 L_2 + L_3 } ; +% 0 0 -2 -14 -\frac92 { L_4 \gets L_2 - L_4 } % \end{pNiceArray}$ % % \medskip % % \enskip $\begin{pNiceArray}{CCCC:C}[last-col] -% 1&1&1&1&1&\\ -% 0&1&3&7&\frac72&\\ -% 0&0&1&6&2&L_3 \gets \frac13L_3\\ -% 0&0&-2&-14&-\frac92& +% 1 1 1 1 1 ; +% 0 1 3 7 \frac72 ; +% 0 0 1 6 2 { L_3 \gets \frac13 L_3 } ; +% 0 0 -2 -14 -\frac92 % \end{pNiceArray}$ % % \medskip % % \enskip $\begin{pNiceArray}{CCCC:C}[last-col] -% 1&1&1&1&1&\\ -% 0&1&3&7&\frac72&\\ -% 0&0&1&6&2& \\ -% 0&0&0&-2&-\frac12 & L_4 \gets 2L_3+L_4 +% 1 1 1 1 1 ; +% 0 1 3 7 \frac72 ; +% 0 0 1 6 2 ; +% 0 0 0 -2 -\frac12 { L_4 \gets L_3 + L_4 } % \end{pNiceArray}$ % \end{NiceMatrixBlock} % \end{multicols} -% +% % % \subsection{How to highlight cells of the matrix} % @@ -2511,40 +2563,37 @@ version 2005/12/01 or later. % \pkg{nicematrix}). % % \begin{Verbatim} -% $\begin{pNiceArray}{>{\strut}CCCC}% -% [create-large-nodes,margin,extra-margin = 2pt , -% code-after = {\begin{tikzpicture} -% [~emphase#name suffix = -large@, -% every node/.style = {draw, -% ~emphase#inner sep = 0 pt@}] -% \node [fit = (1-1)] {} ; -% \node [fit = (2-2)] {} ; -% \node [fit = (3-3)] {} ; -% \node [fit = (4-4)] {} ; -% \end{tikzpicture}}] -% a_{11} & a_{12} & a_{13} & a_{14} \\ -% a_{21} & a_{22} & a_{23} & a_{24} \\ -% a_{31} & a_{32} & a_{33} & a_{34} \\ -% a_{41} & a_{42} & a_{43} & a_{44} +% $\begin{pNiceArray}{>{\strut}CCCC}[create-large-nodes,margin,extra-margin = 2pt] +% a_{11} & a_{12} & a_{13} & a_{14} \\ +% a_{21} & a_{22} & a_{23} & a_{24} \\ +% a_{31} & a_{32} & a_{33} & a_{34} \\ +% a_{41} & a_{42} & a_{43} & a_{44} +% \CodeAfter +% \begin{tikzpicture}[~emphase#name suffix = -large@, +% every node/.style = {draw,~emphase#inner sep = 0 pt@}] +% \node [fit = (1-1)] {} ; +% \node [fit = (2-2)] {} ; +% \node [fit = (3-3)] {} ; +% \node [fit = (4-4)] {} ; +% \end{tikzpicture} % \end{pNiceArray}$ % \end{Verbatim} % -% -% \[\begin{pNiceArray}{>{\strut}CCCC}[ -% create-large-nodes,margin,extra-margin = 2pt, -% code-after = {\begin{tikzpicture}[name suffix = -large, -% every node/.style = {draw, -% inner sep = 0 pt}] -% \node [fit = (1-1)] {} ; -% \node [fit = (2-2)] {} ; -% \node [fit = (3-3)] {} ; -% \node [fit = (4-4)] {} ; -% \end{tikzpicture}}] -% a_{11} & a_{12} & a_{13} & a_{14} \\ -% a_{21} & a_{22} & a_{23} & a_{24} \\ -% a_{31} & a_{32} & a_{33} & a_{34} \\ -% a_{41} & a_{42} & a_{43} & a_{44} +% \[\begin{pNiceArray}{>{\strut}CCCC}[create-large-nodes,margin,extra-margin = 2pt] +% a_{11} & a_{12} & a_{13} & a_{14} \\ +% a_{21} & a_{22} & a_{23} & a_{24} \\ +% a_{31} & a_{32} & a_{33} & a_{34} \\ +% a_{41} & a_{42} & a_{43} & a_{44} +% \CodeAfter +% \begin{tikzpicture}[name suffix = -large, +% every node/.style = {draw,inner sep = 0 pt}] +% \node [fit = (1-1)] {} ; +% \node [fit = (2-2)] {} ; +% \node [fit = (3-3)] {} ; +% \node [fit = (4-4)] {} ; +% \end{tikzpicture} % \end{pNiceArray}\] +% % % We should remark that the rules we have drawn are drawn \emph{after} the % construction of the array and thus, they don't spread the cells of the @@ -2628,30 +2677,24 @@ version 2005/12/01 or later. % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=11.6cm] -% $\begin{pNiceMatrix}% -% [ -% margin, -% create-medium-nodes, -% code-after = -% { \tikz \node [~emphase#highlight = (1-1-block-medium)@] {} ; } -% ] -% \Block{3-3}<\Large>{A} & & & 0 \\ -% & \hspace*{1cm} & & \Vdots \\ -% & & & 0 \\ -% 0 & \Cdots& 0 & 0 +% $\begin{pNiceMatrix}[margin,create-medium-nodes] +% \Block{3-3}<\Large>{A} & & & 0 \\ +% & \hspace*{1cm} & & \Vdots \\ +% & & & 0 \\ +% 0 & \Cdots& 0 & 0 +% \CodeAfter +% \tikz \node [~emphase#highlight = (1-1-block-medium)@] {} ; % \end{pNiceMatrix}$ % \end{BVerbatim} -% $\begin{pNiceMatrix}[ -% margin, -% create-medium-nodes, -% code-after = -% { \tikz \node [highlight = (1-1-block-medium)] {} ; } -% ] +% $\begin{pNiceMatrix}[margin,create-medium-nodes] % \Block{3-3}<\Large>{A} & & & 0 \\ % & \hspace*{1cm} & & \Vdots \\ % & & & 0 \\ % 0 & \Cdots& 0 & 0 +% \CodeAfter +% \tikz \node [highlight = (1-1-block-medium)] {} ; % \end{pNiceMatrix}$ +% % % \vspace{1cm} % Consider now the following matrix which we have named |example|. @@ -2759,41 +2802,37 @@ version 2005/12/01 or later. % In the following example, we use the ``large nodes'' to highlight a zone of % the matrix.\par\nobreak % \begin{Verbatim} -% \begin{pNiceArray}{>{\strut}CCCC}% -% [create-large-nodes,margin,extra-margin=2pt, -% code-after = {\tikz \path [~emphase#name suffix = -large@, -% fill = red!15, -% blend mode = multiply] -% (1-1.north west) -% |- (2-2.north west) -% |- (3-3.north west) -% |- (4-4.north west) -% |- (4-4.south east) -% |- (1-1.north west) ; } ] -% A_{11} & A_{12} & A_{13} & A_{14} \\ -% A_{21} & A_{22} & A_{23} & A_{24} \\ -% A_{31} & A_{32} & A_{33} & A_{34} \\ -% A_{41} & A_{42} & A_{43} & A_{44} +% \begin{pNiceArray}{>{\strut}CCCC}[create-large-nodes,margin,extra-margin=2pt] +% A_{11} & A_{12} & A_{13} & A_{14} \\ +% A_{21} & A_{22} & A_{23} & A_{24} \\ +% A_{31} & A_{32} & A_{33} & A_{34} \\ +% A_{41} & A_{42} & A_{43} & A_{44} +% \CodeAfter +% \tikz \path [~emphase#name suffix = -large@,fill = red!15, blend mode = multiply] +% (1-1.north west) +% |- (2-2.north west) +% |- (3-3.north west) +% |- (4-4.north west) +% |- (4-4.south east) +% |- (1-1.north west) ; % \end{pNiceArray} % \end{Verbatim} % -% \[ \begin{pNiceArray}{>{\strut}CCCC}[ -% create-large-nodes,margin,extra-margin=2pt, -% code-after = {\tikz \path [name suffix = -large, -% fill = red!15, -% blend mode = multiply] -% (1-1.north west) -% |- (2-2.north west) -% |- (3-3.north west) -% |- (4-4.north west) -% |- (4-4.south east) -% |- (1-1.north west) ; } ] -% A_{11} & A_{12} & A_{13} & A_{14} \\ -% A_{21} & A_{22} & A_{23} & A_{24} \\ -% A_{31} & A_{32} & A_{33} & A_{34} \\ -% A_{41} & A_{42} & A_{43} & A_{44} -% \end{pNiceArray}\] % +% \[\begin{pNiceArray}{>{\strut}CCCC}[create-large-nodes,margin,extra-margin=2pt] +% A_{11} & A_{12} & A_{13} & A_{14} \\ +% A_{21} & A_{22} & A_{23} & A_{24} \\ +% A_{31} & A_{32} & A_{33} & A_{34} \\ +% A_{41} & A_{42} & A_{43} & A_{44} +% \CodeAfter +% \tikz \path [name suffix = -large,fill = red!15, blend mode = multiply] +% (1-1.north west) +% |- (2-2.north west) +% |- (3-3.north west) +% |- (4-4.north west) +% |- (4-4.south east) +% |- (1-1.north west) ; +% \end{pNiceArray}\] % % \subsection{Direct use of the Tikz nodes} % @@ -2930,10 +2969,10 @@ version 2005/12/01 or later. % % % \bigskip -% \subsection*{Declaration of the package and extensions loaded} +% \subsection*{Declaration of the package and packages loaded} % % -% The prefix |nicematrix| has been registred for this extension. +% The prefix |nicematrix| has been registred for this package. % % See: |http://mirrors.ctan.org/macros/latex/contrib/l3kernel/l3prefixes.pdf| % @@ -2945,7 +2984,6 @@ version 2005/12/01 or later. % \begin{macrocode} \RequirePackage{pgfcore} \usepgfmodule{shapes} -\RequirePackage{expl3}[2020/02/08] % \end{macrocode} % % @@ -2998,7 +3036,7 @@ version 2005/12/01 or later. % \begin{macrocode} \RequirePackage { array } \RequirePackage { amsmath } -\RequirePackage { xparse } [ 2018-07-01 ] +\RequirePackage { xparse } % \end{macrocode} % % \bigskip @@ -3030,12 +3068,13 @@ version 2005/12/01 or later. % \end{macrocode} % In some constructions, we will have to use a |{pgfpicture}| which \emph{must} % be replaced by a |{tikzpicture}| if Tikz is loaded. However, this switch -% between |{pgfpicture}| |{tikzpicture}| can't be done dynamically with a -% conditional because, when the |external| Tikz library, the pair -% |\tikzpicture|-|\endtikpicture| (or |\begin{tikzpicture}-\end{tikzpicture}| -% must be statically ``visible'' (even when extenalization is not activated). +% between |{pgfpicture}| and |{tikzpicture}| can't be done dynamically with a +% conditional because, when the Tikz library |external| is loaded by the user, +% the pair |\tikzpicture|-|\endtikpicture| (or +% |\begin{tikzpicture}-\end{tikzpicture}| must be statically ``visible'' (even +% when extenalization is not activated). % -% That's why we create these token lists |\c_@@_pgfortikzpicture_tl| and +% That's why we create |\c_@@_pgfortikzpicture_tl| and % |\c_@@_endpgfortikzpicture_tl| which will be used to construct in a % |\AtBeginDocument| the correct version of some commands. % \begin{macrocode} @@ -3604,12 +3643,10 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% The token list |\l_@@_baseline_str| will contain one of the three values |t|, -% |c| or |b| and will indicate the position of the environment as in the option -% of the environment |{array}|. For the environment |{pNiceMatrix}|, -% |{pNiceArray}| and their variants, the value will programmatically be fixed to -% |c|. For the environment |{NiceArray}|, however, the three values |t|, |c| and -% |b| are possible. +% The token list |\l_@@_baseline_str| may contain one of the three values |t|, +% |c| or |b| as in the option of the environment |{array}|. However, it may also +% contain an integer (which represents the number of the row to which align the +% array). % \begin{macrocode} \str_new:N \l_@@_baseline_str \str_set:Nn \l_@@_baseline_str c @@ -3758,6 +3795,12 @@ version 2005/12/01 or later. color .value_required:n = true , shorten .dim_set:N = \l_@@_xdots_shorten_dim , shorten .value_required:n = true , +% \end{macrocode} +% The options |down| and |up| are not documented for the final user because he +% should use the syntax with |^| and |_|. +% \begin{macrocode} + down .tl_set:N = \l_@@_xdots_down_tl , + up .tl_set:N = \l_@@_xdots_up_tl , unknown .code:n = \@@_error:n { Unknown~option~for~xdots } } % \end{macrocode} @@ -3825,6 +3868,16 @@ version 2005/12/01 or later. % \begin{macrocode} \keys_define:nn { NiceMatrix / Env } { +% \end{macrocode} +% \bigskip +% The options |c|, |t| and |b| of the environment |{NiceArray}| have the same +% meaning as the option of the classical environment |{array}|. +% \begin{macrocode} + c .code:n = \str_set:Nn \l_@@_baseline_str c , + t .code:n = \str_set:Nn \l_@@_baseline_str t , + b .code:n = \str_set:Nn \l_@@_baseline_str b , + baseline .tl_set:N = \l_@@_baseline_str , + baseline .value_required:n = true , columns-width .code:n = \str_if_eq:nnTF { #1 } { auto } { \bool_set_true:N \l_@@_auto_columns_width_bool } @@ -3834,7 +3887,7 @@ version 2005/12/01 or later. % \end{macrocode} % We test whether we are in the measuring phase of an environment of % \pkg{amsmath} (always loaded by \pkg{nicematrix}) because we want to avoid a -% fallaicous message of duplicate name in this case. +% fallacious message of duplicate name in this case. % \begin{macrocode} \legacy_if:nF { measuring@ } { @@ -4003,20 +4056,9 @@ version 2005/12/01 or later. { % \end{macrocode} % -% \bigskip -% The options |c|, |t| and |b| of the environment |{NiceArray}| have the same -% meaning as the option of the classical environment |{array}|. -% \begin{macrocode} - c .code:n = \str_set:Nn \l_@@_baseline_str c , - t .code:n = \str_set:Nn \l_@@_baseline_str t , - b .code:n = \str_set:Nn \l_@@_baseline_str b , - baseline .tl_set:N = \l_@@_baseline_str , - baseline .value_required:n = true , -% \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. +% be used without value because the number of columns of the array is read +% from the preamble of the array. % \begin{macrocode} last-col .code:n = \tl_if_empty:nF { #1 } { \@@_error:n { last-col~non~empty~for~NiceArray } } @@ -4299,10 +4341,7 @@ version 2005/12/01 or later. \use:c { @@ _ draw _ #1 : nnn } { \int_use:N \c@iRow } { \int_use:N \c@jCol } -% \end{macrocode} -% Maybe we should prevent the expansion of the list of key-value. -% \begin{macrocode} - { #2 } + { \exp_not:n { #2 } } } } } @@ -4513,6 +4552,7 @@ version 2005/12/01 or later. \cs_set_eq:NN \Block \@@_Block: \cs_set_eq:NN \rotate \@@_rotate: \cs_set_eq:NN \OnlyMainNiceMatrix \@@_OnlyMainNiceMatrix:n + \cs_set_eq:NN \CodeAfter \@@_CodeAfter:n \bool_if:NT \l_@@_renew_dots_bool { \cs_set_eq:NN \ldots \@@_Ldots @@ -4610,7 +4650,7 @@ version 2005/12/01 or later. % \bigskip % By default, the letter used to specify a dotted line in the preamble of an % environment of \pkg{nicematrix} (for example in |{pNiceArray}|) is the letter -% |:|. However, this letter is used by some extensions, for example +% |:|. However, this letter is used by some packages, for example % \pkg{arydshln}. That's why it's possible to change the letter used by % \pkg{nicematrix} with the option |letter-for-dotted-lines| which changes the % value of |\l_@@_letter_for_dotted_lines_str|. We rescan this string (which is @@ -4719,7 +4759,7 @@ version 2005/12/01 or later. % \end{macrocode} % % We increment the counter |\g_@@_env_int| which counts the environments -% of the extension. +% of the package. % \begin{macrocode} \int_gincr:N \g_@@_env_int \bool_if:NF \l_@@_block_auto_columns_width_bool @@ -4789,11 +4829,9 @@ version 2005/12/01 or later. % % % A value of $-1$ for the counter |\l_@@_last_col_int| means that the user has -% used the option |last-col| without value (it's possible in an environment -% without preamble like |{NiceMatrix}| or |{pNiceMatrix}|), that is to say -% without specifying the number of that last column. In this case, we try to -% read that value from the |aux| file (if it has been written on a previous -% run). +% used the option |last-col| without value, that is to say without specifying +% the number of that last column. In this case, we try to read that value from +% the |aux| file (if it has been written on a previous run). % \begin{macrocode} \int_compare:nNnT \l_@@_last_col_int = { -1 } { @@ -4875,7 +4913,7 @@ version 2005/12/01 or later. } { \tl_put_right:Nn \l_tmpa_tl { @ { } } } } - \tl_put_right:Nn \l_tmpa_tl { > { \@@_error_too_much_cols: } l } + \tl_put_right:Nn \l_tmpa_tl { > { \@@_error_too_much_cols: } L } % \end{macrocode} % Here is the beginning of the box which will contain the array. The % |\hbox_set_end:| corresponding to this |\hbox_set:Nw| will be in the second @@ -5024,9 +5062,6 @@ version 2005/12/01 or later. \@@_error:n { bad~value~for~baseline } \int_set:Nn \l_tmpa_int 1 } -% \end{macrocode} -% We use a |{pgfpicture}| to extract coordinates (nothing is drawn). -% \begin{macrocode} \pgfpicture \@@_qpoint: { row - 1 } \dim_gset_eq:NN \g_tmpa_dim \pgf@y @@ -5062,8 +5097,8 @@ version 2005/12/01 or later. % below the array (when the key |last-row| is used). A value of $-2$ for % |\l_@@_last_row_int| means that there is no ``last row''.\footnote{A value of % $-1$ for |\l_@@_last_row_int| means that there is a ``last row'' but the -% number of that row is unknown (the user have not set the value with the option -% |last row|).} +% the user have not set the value with the option |last row| (and we are in the +% first compilation).} % \begin{macrocode} \int_compare:nNnTF \l_@@_last_row_int > { -2 } { @@ -5139,6 +5174,55 @@ version 2005/12/01 or later. { \box_set_ht:Nn \l_tmpa_box { \box_ht:N \l_tmpa_box + \l_tmpa_dim } \box_set_dp:Nn \l_tmpa_box { \box_dp:N \l_tmpa_box + \l_tmpb_dim } + \str_if_eq:VnTF \l_@@_baseline_str { c } + { \box_use_drop:N \l_tmpa_box } + \@@_put_box_in_flow_i: + } +% \end{macrocode} +% +% \medskip +% The command |\@@_put_box_in_flow_i:| is used when the value of +% |\l_@@_baseline_str| is different of |c| (which is the initial value and the +% most used). +% \begin{macrocode} +\cs_new_protected:Npn \@@_put_box_in_flow_i: + { + \str_case:VnF \l_@@_baseline_str + { + { t } { \int_set:Nn \l_tmpa_int 1 } + { b } { \int_set_eq:NN \l_tmpa_int \c@iRow } + } + { \int_set:Nn \l_tmpa_int \l_@@_baseline_str } + \bool_if:nT + { + \int_compare_p:nNn \l_tmpa_int < \l_@@_first_row_int + || \int_compare_p:nNn \l_tmpa_int > \g_@@_row_total_int + } + { + \@@_error:n { bad~value~for~baseline } + \int_set:Nn \l_tmpa_int 1 + } + \pgfpicture + \@@_qpoint: { row - 1 } + \dim_gset_eq:NN \g_tmpa_dim \pgf@y + \@@_qpoint: { row - \@@_succ:n \c@iRow } + \dim_gadd:Nn \g_tmpa_dim \pgf@y + \dim_gset:Nn \g_tmpa_dim { 0.5 \g_tmpa_dim } +% \end{macrocode} +% Now, |\g_tmpa_dim| contains the $y$-value of the center of the array (the +% delimiters are centered in relation with this value). +% \begin{macrocode} + \@@_qpoint: { row - \int_use:N \l_tmpa_int - base } + \dim_gsub:Nn \g_tmpa_dim \pgf@y +% \end{macrocode} +% We take into account the position of the mathematical axis. +% \begin{macrocode} + \dim_gsub:Nn \g_tmpa_dim { \fontdimen22 \textfont2 } +% \end{macrocode} +% Now, |\g_tmpa_dim| contains the value of the $y$ translation we have to to. +% \begin{macrocode} + \endpgfpicture + \box_move_up:nn \g_tmpa_dim { \box_use_drop:N \l_tmpa_box } \box_use_drop:N \l_tmpa_box } % \end{macrocode} @@ -5334,7 +5418,18 @@ version 2005/12/01 or later. { \crcr \int_compare:nNnT \c@iRow = 0 { \@@_fatal:n { Zero~row } } - \int_compare:nNnT \l_@@_first_col_int = 0 { \omit & } + \int_compare:nNnT \l_@@_first_col_int = 0 + { + \omit + \skip_horizontal:N -2\arraycolsep + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgfcoordinate { \@@_env: - col - 0 } \pgfpointorigin + \str_if_empty:NF \l_@@_name_str + { \pgfnodealias { \@@_env: - col - 0 } { \l_@@_name_str - col - 0 } } + \endpgfpicture + & + } \omit % \end{macrocode} % The following instruction must be put after the instruction |\omit|. @@ -5414,6 +5509,22 @@ version 2005/12/01 or later. } \endpgfpicture } + \bool_if:NT \g_@@_last_col_found_bool + { + \skip_horizontal:N 2\arraycolsep + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgfcoordinate { \@@_env: - col - \@@_succ:n \g_@@_col_total_int } + \pgfpointorigin + \str_if_empty:NF \l_@@_name_str + { + \pgfnodealias + { \@@_env: - col - \@@_succ:n \g_@@_col_total_int } + { \l_@@_name_str - col - \@@_succ:n \g_@@_col_total_int } + } + \endpgfpicture + \skip_horizontal:N -2\arraycolsep + } \cr } % \end{macrocode} @@ -5922,7 +6033,7 @@ version 2005/12/01 or later. % \item the third argument is the $x$-value of the orientation vector of the % line; % \item the fourth argument is the $y$-value of the orientation vector of the -% line; +% line. % \end{itemize} % % This command computes: @@ -5954,7 +6065,8 @@ version 2005/12/01 or later. % \end{macrocode} % We will do two loops: one when determinating the initial cell and the other % when determinating the final cell. The boolean |\l_@@_stop_loop_bool| will be -% used to control these loops. +% used to control these loops. In the first loop, we search the ``final'' +% extremity of the line. % \begin{macrocode} \bool_set_false:N \l_@@_stop_loop_bool \bool_do_until:Nn \l_@@_stop_loop_bool @@ -5967,8 +6079,12 @@ version 2005/12/01 or later. \bool_set_false:N \l_@@_final_open_bool \int_compare:nNnTF \l_@@_final_i_int > \c@iRow { - \int_compare:nNnT { #3 } = 1 + \int_compare:nNnTF { #3 } = 1 { \bool_set_true:N \l_@@_final_open_bool } + { + \int_compare:nNnT \l_@@_final_j_int > \c@jCol + { \bool_set_true:N \l_@@_final_open_bool } + } } { \int_compare:nNnTF \l_@@_final_j_int < 1 @@ -6058,8 +6174,12 @@ version 2005/12/01 or later. \bool_set_false:N \l_@@_initial_open_bool \int_compare:nNnTF \l_@@_initial_i_int < 1 { - \int_compare:nNnT { #3 } = 1 + \int_compare:nNnTF { #3 } = 1 { \bool_set_true:N \l_@@_initial_open_bool } + { + \int_compare:nNnT \l_@@_initial_j_int = 0 + { \bool_set_true:N \l_@@_initial_open_bool } + } } { \int_compare:nNnTF \l_@@_initial_j_int < 1 @@ -6220,13 +6340,6 @@ version 2005/12/01 or later. \dim_add:Nn \l_@@_y_initial_dim \l_@@_radius_dim \dim_add:Nn \l_@@_y_final_dim \l_@@_radius_dim \@@_draw_line: -% \end{macrocode} -% The values of |\l_@@_x_initial_dim|, |\l_@@_y_initial_dim|, |\l_@@_x_final_dim|, -% |\l_@@_y_final_dim|, -% -% |\l_@@_initial_open_bool| and |\l_@@_final_open_bool| are still available -% after the |\@@_draw_line:|. -% \begin{macrocode} } % \end{macrocode} % @@ -6309,13 +6422,6 @@ version 2005/12/01 or later. { \dim_set_eq:NN \l_@@_y_final_dim \l_@@_y_initial_dim } } \@@_draw_line: -% \end{macrocode} -% The values of |\l_@@_x_initial_dim|, |\l_@@_y_initial_dim|, |\l_@@_x_final_dim|, -% |\l_@@_y_final_dim|, -% -% |\l_@@_initial_open_bool| and |\l_@@_final_open_bool| are still available -% after the |\@@_draw_line:|. -% \begin{macrocode} } % \end{macrocode} % @@ -6422,13 +6528,6 @@ version 2005/12/01 or later. } } \@@_draw_line: -% \end{macrocode} -% The values of |\l_@@_x_initial_dim|, |\l_@@_y_initial_dim|, |\l_@@_x_final_dim|, -% |\l_@@_y_final_dim|, -% -% |\l_@@_initial_open_bool| and |\l_@@_final_open_bool| are -% still available after the |\@@_draw_line:|. -% \begin{macrocode} } % \end{macrocode} % @@ -6528,13 +6627,6 @@ version 2005/12/01 or later. } } \@@_draw_line: -% \end{macrocode} -% The values of |\l_@@_x_initial_dim|, |\l_@@_y_initial_dim|, |\l_@@_x_final_dim|, -% |\l_@@_y_final_dim|, -% -% |\l_@@_initial_open_bool| and |\l_@@_final_open_bool| are still available -% after the |\@@_draw_line:|. -% \begin{macrocode} } % \end{macrocode} % @@ -6613,13 +6705,6 @@ version 2005/12/01 or later. } } \@@_draw_line: -% \end{macrocode} -% The values of |\l_@@_x_initial_dim|, |\l_@@_y_initial_dim|, |\l_@@_x_final_dim|, -% |\l_@@_y_final_dim|, -% -% |\l_@@_initial_open_bool| and |\l_@@_final_open_bool| are still available -% after the |\@@_draw_line:|. -% \begin{macrocode} } % \end{macrocode} % @@ -6689,7 +6774,15 @@ version 2005/12/01 or later. shorten~< = \l_@@_xdots_shorten_dim , ] ( \l_@@_x_initial_dim , \l_@@_y_initial_dim ) - -- ( \l_@@_x_final_dim , \l_@@_y_final_dim ) ; + -- node [ sloped , above ] + { \c_math_toggle_token \scriptstyle \l_@@_xdots_up_tl \c_math_toggle_token } + node [ sloped , below ] + { + \c_math_toggle_token + \scriptstyle \l_@@_xdots_down_tl + \c_math_toggle_token + } + ( \l_@@_x_final_dim , \l_@@_y_final_dim ) ; \end { scope } } % \end{macrocode} @@ -6700,6 +6793,53 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Npn \@@_draw_standard_dotted_line: { +% \end{macrocode} +% First, we put the labels. +% \begin{macrocode} + \bool_lazy_and:nnF + { \tl_if_empty_p:N \l_@@_xdots_up_tl } + { \tl_if_empty_p:N \l_@@_xdots_down_tl } + { + \pgfscope + \pgftransformshift + { + \pgfpointlineattime { 0.5 } + { \pgfpoint \l_@@_x_initial_dim \l_@@_y_initial_dim } + { \pgfpoint \l_@@_x_final_dim \l_@@_y_final_dim } + } + \pgftransformrotate + { + \fp_eval:n + { + atand + ( + \l_@@_y_final_dim - \l_@@_y_initial_dim , + \l_@@_x_final_dim - \l_@@_x_initial_dim + ) + } + } + \pgfnode + { rectangle } + { south } + { + \c_math_toggle_token + \scriptstyle \l_@@_xdots_up_tl + \c_math_toggle_token + } + { } + { \pgfusepath { } } + \pgfnode + { rectangle } + { north } + { + \c_math_toggle_token + \scriptstyle \l_@@_xdots_down_tl + \c_math_toggle_token + } + { } + { \pgfusepath { } } + \endpgfscope + } \pgfrememberpicturepositiononpagetrue \pgf@relevantforpicturesizefalse \group_begin: @@ -6730,7 +6870,7 @@ version 2005/12/01 or later. \bool_lazy_or:nnF { \dim_compare_p:nNn { \dim_abs:n \l_@@_l_dim } > \c_@@_max_l_dim } { \dim_compare_p:nNn \l_@@_l_dim = \c_zero_dim } - \@@_actually_draw_line: + \@@_draw_standard_dotted_line_i: \group_end: } % \end{macrocode} @@ -6740,7 +6880,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} -\cs_new_protected:Npn \@@_actually_draw_line: +\cs_new_protected:Npn \@@_draw_standard_dotted_line_i: { % \end{macrocode} % The integer |\l_tmpa_int| is the number of dots of the dotted line. @@ -6855,64 +6995,82 @@ version 2005/12/01 or later. % % The starred versions of these commands are deprecated since version~3.1 but, % as for now, they are still available with an error. +% +% +% \medskip +% The syntax of these commands uses the character |_| as embellishment and +% thats' why we have to insert a character |_| in the \emph{arg spec} of these +% commands. However, we don't know the future catcode of |_| in the main +% document (maybe the user will use \pkg{underscore}, and, in that case, the +% catcode is $13$ because \pkg{underscore} activates |_|). That's why these +% commands will be defined in a |\AtBeginDocument| and the \emph{arg spec} will +% be rescanned. +% % \begin{macrocode} -\NewDocumentCommand \@@_Ldots { s O { } } - { - \bool_if:nTF { #1 } - { \@@_error:n { starred~commands } } - { \@@_instruction_of_type:nn { Ldots } { #2 } } - \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_ldots } - \bool_gset_true:N \g_@@_empty_cell_bool - } +\AtBeginDocument + { + \tl_set:Nn \l_@@_argspec_tl { s O { } E { _ ^ } { { } { } } } + \tl_set_rescan:Nno \l_@@_argspec_tl { } \l_@@_argspec_tl + \exp_args:NNV \NewDocumentCommand \@@_Ldots \l_@@_argspec_tl + { + \bool_if:nTF { #1 } + { \@@_error:n { starred~commands } } + { \@@_instruction_of_type:nn { Ldots } { #2 , down = #3 , up = #4 } } + \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_ldots } + \bool_gset_true:N \g_@@_empty_cell_bool + } % \end{macrocode} % % \bigskip % \begin{macrocode} -\NewDocumentCommand \@@_Cdots { s O { } } - { - \bool_if:nTF { #1 } - { \@@_error:n { starred~commands } } - { \@@_instruction_of_type:nn { Cdots } { #2 } } - \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_cdots } - \bool_gset_true:N \g_@@_empty_cell_bool - } + \exp_args:NNV \NewDocumentCommand \@@_Cdots \l_@@_argspec_tl + { + \bool_if:nTF { #1 } + { \@@_error:n { starred~commands } } + { \@@_instruction_of_type:nn { Cdots } { #2 , down = #3 , up = #4 } } + \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_cdots } + \bool_gset_true:N \g_@@_empty_cell_bool + } % \end{macrocode} % % \bigskip % \begin{macrocode} -\NewDocumentCommand \@@_Vdots { s O { } } - { - \bool_if:nTF { #1 } - { \@@_error:n { starred~commands } } - { \@@_instruction_of_type:nn { Vdots } { #2 } } - \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_vdots } - \bool_gset_true:N \g_@@_empty_cell_bool - } + \exp_args:NNV \NewDocumentCommand \@@_Vdots \l_@@_argspec_tl + { + \bool_if:nTF { #1 } + { \@@_error:n { starred~commands } } + { \@@_instruction_of_type:nn { Vdots } { #2 , down = #3 , up = #4 } } + \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_vdots } + \bool_gset_true:N \g_@@_empty_cell_bool + } % \end{macrocode} % % \bigskip % \begin{macrocode} -\NewDocumentCommand \@@_Ddots { s O { } } - { - \bool_if:nTF { #1 } - { \@@_error:n { starred~commands } } - { \@@_instruction_of_type:nn { Ddots } { #2 } } - \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_ddots } - \bool_gset_true:N \g_@@_empty_cell_bool - } + \exp_args:NNV \NewDocumentCommand \@@_Ddots \l_@@_argspec_tl + { + \bool_if:nTF { #1 } + { \@@_error:n { starred~commands } } + { \@@_instruction_of_type:nn { Ddots } { #2 , down = #3 , up = #4 } } + \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_ddots } + \bool_gset_true:N \g_@@_empty_cell_bool + } % \end{macrocode} % % \bigskip % \begin{macrocode} -\NewDocumentCommand \@@_Iddots { s O { } } - { - \bool_if:nTF { #1 } - { \@@_error:n { starred~commands } } - { \@@_instruction_of_type:nn { Iddots } { #2 } } - \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_iddots } - \bool_gset_true:N \g_@@_empty_cell_bool + \exp_args:NNV \NewDocumentCommand \@@_Iddots \l_@@_argspec_tl + { + \bool_if:nTF { #1 } + { \@@_error:n { starred~commands } } + { \@@_instruction_of_type:nn { Iddots } { #2 , down = #3 , up = #4 } } + \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_iddots } + \bool_gset_true:N \g_@@_empty_cell_bool + } } % \end{macrocode} +% End of the |\AtBeginDocument|. +% % % % \bigskip @@ -6963,35 +7121,48 @@ version 2005/12/01 or later. } % \end{macrocode} % +% \begin{macrocode} +\ExplSyntaxOff +\def \@tempa { O { } m O { } E { _ ^ } { { } { } } } +\ExplSyntaxOn +\tl_set_eq:NN \l_@@_a_signature_tl \@tempa +% \end{macrocode} +% % The command |\@@_Hdotsfor_i| is defined with the tools of \pkg{xparse} because % it has an optional argument. Note that such a command defined by % |\NewDocumentCommand| is protected and that's why we have put the % |\multicolumn| before (in the definition of |\@@_Hdotsfor:|). % \begin{macrocode} -\bool_if:NTF \c_@@_draft_bool +\AtBeginDocument { + \tl_set:Nn \l_@@_argspec_tl { O { } m O { } E { _ ^ } { { } { } } } + \tl_set_rescan:Nno \l_@@_argspec_tl { } \l_@@_argspec_tl + \bool_if:NTF \c_@@_draft_bool + { % \end{macrocode} % We don't put |!| before the last optionnal argument for homogeneity with % |\Cdots|, etc. which have only one optional argument. % \begin{macrocode} - \NewDocumentCommand \@@_Hdotsfor_i { O { } m O { } } - { \prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { C } { } } } - } - { - \NewDocumentCommand \@@_Hdotsfor_i { O { } m O { } } + \exp_args:NNV \NewDocumentCommand \@@_Hdotsfor_i \l_@@_argspec_tl + { \prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { C } { } } } + } { - \tl_gput_right:Nx \g_@@_Hdotsfor_lines_tl + \exp_args:NNV \NewDocumentCommand \@@_Hdotsfor_i \l_@@_argspec_tl { - \@@_Hdotsfor:nnnn - { \int_use:N \c@iRow } - { \int_use:N \c@jCol } - { #2 } - { #3 } - } - \prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { C } { } } + \tl_gput_right:Nx \g_@@_Hdotsfor_lines_tl + { + \@@_Hdotsfor:nnnn + { \int_use:N \c@iRow } + { \int_use:N \c@jCol } + { #2 } + { #1 , #3 , down = #4 , up = #5 } + } + \prg_replicate:nn { #2 - 1 } { & \multicolumn { 1 } { C } { } } + } } } % \end{macrocode} +% Enf of |\AtBeginDocument|. % % \medskip % \begin{macrocode} @@ -7126,24 +7297,36 @@ version 2005/12/01 or later. { \int_eval:n { #1 } - \int_eval:n { #2 } } % \end{macrocode} % +% \begin{macrocode} +\ExplSyntaxOff +\def \@tempa { O { } m m ! O { } E { _ ^ } { { } { } } } +\ExplSyntaxOn +\tl_set_eq:NN \l_@@_a_signature_tl \@tempa +% \end{macrocode} +% % \medskip % With the following construction, the command |\@@_double_int_eval:n| is % applied to both arguments before the application of |\@@_line_i:nn| (the % construction uses the fact the |\@@_line_i:nn| is protected and that % |\@@_double_int_eval:n| is fully expandable). % \begin{macrocode} -\NewDocumentCommand \@@_line { O { } m m ! O { } } +\AtBeginDocument { - \group_begin: - \keys_set:nn { NiceMatrix / xdots } { #1 , #4 } - \tl_if_empty:VF \l_@@_xdots_color_tl { \color { \l_@@_xdots_color_tl } } - \use:x - { - \@@_line_i:nn - { \@@_double_int_eval:n #2 \q_stop } - { \@@_double_int_eval:n #3 \q_stop } - } - \group_end: + \tl_set:Nn \l_@@_argspec_tl { O { } m m ! O { } E { _ ^ } { { } { } } } + \tl_set_rescan:Nno \l_@@_argspec_tl { } \l_@@_argspec_tl + \exp_args:NNV \NewDocumentCommand \@@_line \l_@@_argspec_tl + { + \group_begin: + \keys_set:nn { NiceMatrix / xdots } { #1 , #4 , down = #5 , up = #6 } + \tl_if_empty:VF \l_@@_xdots_color_tl { \color { \l_@@_xdots_color_tl } } + \use:x + { + \@@_line_i:nn + { \@@_double_int_eval:n #2 \q_stop } + { \@@_double_int_eval:n #3 \q_stop } + } + \group_end: + } } % \end{macrocode} % @@ -7188,8 +7371,8 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% The following command \emph{must} be protected since it's used in the -% construction of |\@@_draw_line_ii:nn|. +% The following command \emph{must} be protected (it's used in the +% construction of |\@@_draw_line_ii:nn|). % \begin{macrocode} \cs_new_protected:Npn \@@_draw_line_iii:nn #1 #2 { @@ -7209,7 +7392,6 @@ version 2005/12/01 or later. % this command because they have to do other settings (for example, the diagonal % lines must be parallelized). % -% % \bigskip % \subsection*{The vertical rules} % @@ -7845,11 +8027,11 @@ version 2005/12/01 or later. % % \medskip % The command |\@@_create_large_nodes:| must be used when we want to create only -% the ``large nodes'' and not the medium ones (if we want to create both, we -% have to use |\@@_create_medium_and_large_nodes:|). However, the +% the ``large nodes'' and not the medium ones\footnote{If we want to create +% both, we have to use |\@@_create_medium_and_large_nodes:|}. However, the % computation of the mathematical coordinates of the ``large nodes'' needs the -% computation of the mathematical coordinates of the ``medium nodes''. Hence, -% we use first |\@@_computations_for_medium_nodes:| and then the command +% computation of the mathematical coordinates of the ``medium nodes''. Hence, we +% use first |\@@_computations_for_medium_nodes:| and then the command % |\@@_computations_for_large_nodes:|. % \begin{macrocode} \cs_new_protected:Npn \@@_create_large_nodes: @@ -8179,6 +8361,7 @@ version 2005/12/01 or later. % \end{macrocode} % % We construct the node for the block with the name |(#1-#2-block)|. +% % The function |\@@_pgf_rect_node:nnnnn| takes as arguments the name of the node % and the four coordinates of two opposite corner points of the rectangle. % \begin{macrocode} @@ -8337,6 +8520,43 @@ version 2005/12/01 or later. \@@_define_com:nnn B \{ \} % \end{macrocode} % +% \subsection*{The command \textbackslash CodeAfter} +% +% The command |\CodeAfter| catches everything until the end of the current +% environment (of \pkg{nicematrix}). +% +% First, we go until the next command |\end|. +% \begin{macrocode} +\cs_new_protected:Npn \@@_CodeAfter:n #1 \end + { + \tl_gput_right:Nn \g_@@_code_after_tl { #1 } + \@@_CodeAfter_i:n + } +% \end{macrocode} +% +% We catch the argument of the command |\end| (in |#1|). +% \begin{macrocode} +\cs_new_protected:Npn \@@_CodeAfter_i:n #1 + { +% \end{macrocode} +% If this is really the end of the current environment (of \pkg{nicematrix}), we +% put back the command |\end| and its argument in the TeX flow. +% \begin{macrocode} + \bool_if:NTF { \str_if_eq_p:Vn \g_@@_name_env_str { #1 } } + { \end { #1 } } +% \end{macrocode} +% It this is not the |\end| we are looking for, we put those tokens in +% |\g_@@_code_after_tl| and we go on searching for the next command |\end| with +% a recursive call to the command |\@@_CodeAfter:n|. +% \begin{macrocode} + { + \tl_gput_right:Nn \g_@@_code_after_tl { \end { #1 } } + \@@_CodeAfter:n + } + } +% \end{macrocode} +% +% % \bigskip % \subsection*{We process the options} % @@ -8415,9 +8635,12 @@ version 2005/12/01 or later. { \seq_if_in:NVTF \c_@@_types_of_matrix_seq \g_@@_name_env_str { - \int_compare:nNnTF \l_@@_last_col_int = { -1 } + \int_compare:nNnTF \l_@@_last_col_int = { -2 } { \@@_fatal:n { too~much~cols~for~matrix } } - { \@@_fatal:n { too~much~cols~for~matrix~with~last~col } } + { + \bool_if:NF \l_@@_last_col_without_value_bool + { \@@_fatal:n { too~much~cols~for~matrix~with~last~col } } + } } { \@@_fatal:n { too~much~cols~for~array } } } @@ -8428,7 +8651,7 @@ version 2005/12/01 or later. \cs_new:Npn \@@_message_hdotsfor: { \tl_if_empty:VF \g_@@_Hdotsfor_lines_tl - { ~Maybe~your~use~of~\token_to_str:N \Hdotsfor\ is~incorrect.} + { ~Maybe~your~use~of~\token_to_str:N \Hdotsfor\ is~incorrect.} } % \end{macrocode} % @@ -8708,6 +8931,9 @@ version 2005/12/01 or later. } { The~available~options~are~(in~alphabetic~order):~ + b,~ + baseline,~ + c,~ code-after,~ code-for-first-col,~ code-for-first-row,~ @@ -8736,6 +8962,7 @@ version 2005/12/01 or later. renew-dots,~ right-margin,~ small,~ + t,~ vlines,~ xdots/color,~ xdots/shorten~and~ @@ -8932,7 +9159,7 @@ version 2005/12/01 or later. % TeX StackExchange\footnote{cf. % |tex.stackexchange.com/questions/450841/tikz-externalize-and-nicematrix-package|}, % Tikz externalization is now deactivated in the environments of the -% extension \pkg{nicematrix}.\footnote{Before this version, there was an error +% package \pkg{nicematrix}.\footnote{Before this version, there was an error % when using \pkg{nicematrix} with Tikz externalization. In any case, it's not % possible to externalize the Tikz elements constructed by \pkg{nicematrix} % because they use the options |overlay| and |remember picture|.} @@ -9148,13 +9375,24 @@ version 2005/12/01 or later. % The code of \pkg{nicematrix} no longer uses Tikz but only \textsc{pgf}. By % default, Tikz is \emph{not} loaded by \pkg{nicematrix}. % -% \subsection*{Changes between versions 3.12 and 3.13} +% \subsection*{Changes between versions 3.13 and 3.14} % -% Correction of a bug (question 60761504 on |stakoverflow|). +% Correction of a bug (question 60761504 on |stackoverflow|). % -% Best error messages when the user uses |&| or |\\| when |light-syntax| is in +% Better error messages when the user uses |&| or |\\| when |light-syntax| is in % force. % +% \subsection*{Changes between versions 3.14 and 3.15} +% +% It's possible to put labels on the dotted lines drawn by |\Ldots|, |\Cdots|, +% |\Vdots|, |\Ddots|, |\Iddots|, |\Hdotsfor| and the command |\line| in the +% |code-after| with the tokens |_| and |^|. +% +% The option |baseline| is now available in all the environments of +% \pkg{nicematrix}. Before, it was available only in |{NiceArray}|. +% +% New command |\CodeAfter| (in the environments of \pkg{nicematrix}). +% % \PrintIndex % % \tableofcontents @@ -9163,6 +9401,7 @@ version 2005/12/01 or later. % Local Variables: % TeX-fold-mode: t % TeX-fold-preserve-comments: nil +% flyspell-mode: nil % fill-column: 80 % End: diff --git a/macros/latex/contrib/nicematrix/nicematrix.pdf b/macros/latex/contrib/nicematrix/nicematrix.pdf index 8cddffc1b2..8507028d22 100644 Binary files a/macros/latex/contrib/nicematrix/nicematrix.pdf and b/macros/latex/contrib/nicematrix/nicematrix.pdf differ -- cgit v1.2.3