diff options
Diffstat (limited to 'macros/latex/contrib/nicematrix/nicematrix.dtx')
-rw-r--r-- | macros/latex/contrib/nicematrix/nicematrix.dtx | 998 |
1 files changed, 592 insertions, 406 deletions
diff --git a/macros/latex/contrib/nicematrix/nicematrix.dtx b/macros/latex/contrib/nicematrix/nicematrix.dtx index 3b7f4d278e..24732c133c 100644 --- a/macros/latex/contrib/nicematrix/nicematrix.dtx +++ b/macros/latex/contrib/nicematrix/nicematrix.dtx @@ -15,8 +15,8 @@ % % \fi % \iffalse -\def\myfileversion{5.10} -\def\myfiledate{2021/02/05} +\def\myfileversion{5.11} +\def\myfiledate{2021/02/22} % % %<*batchfile> @@ -95,7 +95,8 @@ version 2005/12/01 or later. \cs_set_protected:Npn} \DoNotIndex{\bool_if:NTF,\bool_new:N,\bool_set_false:N,\bool_set_true:N,\l_tmpa_bool} \DoNotIndex{\group_begin:,\group_end:,\c_math_toggle_token} -\DoNotIndex{\tl_set:Nn,\l_tmpa_tl} +\DoNotIndex{\tl_set:Nn,\l_tmpa_tl,\l_tmpb_tl} +\DoNotIndex{\tl_gput_left:Nn,\tl_gput_right:Nn} \ExplSyntaxOff \makeatother @@ -160,6 +161,16 @@ version 2005/12/01 or later. % distribution as MiKTeX or TeXlive. % % \bigskip +% \emph{Remark}: If you use LaTeX via Internet with, for example, Overleaf, you +% can upload the file |nicematrix.sty| in the repertory of your +% project in order to take full advantage of the latest version de +% \pkg{nicematrix}.\footnote{The latest version of the file +% \verb|nicematrix.sty| may be downloaded from the \textsc{svn} server of +% TeXLive:\newline +% \small +% \url{https:www.tug.org/svn/texlive/trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty}} +% +% \bigskip % This package can be used with |xelatex|, |lualatex|, |pdflatex| but also by % the classical workflow |latex|-|dvips|-|ps2pdf| (or Adobe Distiller). % \textsl{However, the file nicematrix.dtx of the present documentation should @@ -191,19 +202,6 @@ version 2005/12/01 or later. % semi-global). % % -% \bigskip -% {\bfseries \color{red} Important -% -% Since the version 5.0 of \pkg{nicematrix}, one must use the letters |l|, |c| and -% |r| in the preambles of the environments and no longer the letters |L|, |C| and -% |R|. -% -% For sake of compatibility with the previous versions, there exists an option -% |define-L-C-R| which must be used when loading \pkg{nicematrix}. -% \begin{Verbatim} -% \usepackage[define-L-C-R]{nicematrix} -% \end{Verbatim} -% } % % \newpage % @@ -281,8 +279,8 @@ version 2005/12/01 or later. % |cell-space-bottom-limit| similar to the parameters |\cellspacetoplimit| and % |\cellspacebottomlimit| of \pkg{cellspace}. % -% \colorbox{yellow!50}{\bfseries{New 5.9}}\enskip -% There is also a key |cell-space-limits| to set both parameters at once. +% \colorbox{yellow!30}{New 5.9}\enskip There is also a key |cell-space-limits| +% to set both parameters at once. % % The initial value of these parameters is $0$~pt in order to have for the % environments of \pkg{nicematrix} the same behaviour as those of \pkg{array} @@ -747,9 +745,7 @@ version 2005/12/01 or later. % In the environments of \pkg{nicematrix}, the vertical rules specified by % \verb+|+ in the preambles of the environments are never broken, even by an % incomplete row or by a double horizontal rule specified by |\hline\hline| -% (there is no need to use \pkg{hhline}). \footnote{This is the behaviour since -% the version 5.1 of \pkg{nicematrix}. Prior to that version, the behaviour was -% the standard behaviour of \pkg{array}.} +% (there is no need to use \pkg{hhline}). % % \bigskip % \begin{BVerbatim}[baseline=c,boxwidth=10cm] @@ -1170,7 +1166,9 @@ version 2005/12/01 or later. % The extension \pkg{nicematrix} provides a key |code-before| for some code that % will be executed before the drawing of the tabular. In this |code-before|, new % commands are available: |\cellcolor|, |\rectanglecolor|, |\rowcolor|, -% |\columncolor|, |\rowcolors| and |\chessboardcolors|. +% |\columncolor|, |\rowcolors| and |\chessboardcolors|.\footnote{Remark that, in +% the \verb|code-before|, some PGF/Tikz nodes corresponding to the position to +% the potential rules are available: cf.~p.~\pageref{nodes-i}.} % \label{code-before} % % \medskip @@ -1183,8 +1181,8 @@ version 2005/12/01 or later. % \pkg{colortbl}. % % This command takes in as mandatory arguments a color and a list of cells, each -% of which with the format $i$-$j$ where $i$ is the number of row and $j$ the -% number of colummn of the cell. +% of which with the format $i$-$j$ where $i$ is the number of the row and $j$ the +% number of the colummn of the cell. % % % \medskip @@ -1282,17 +1280,17 @@ version 2005/12/01 or later. % \bigskip % \item The command |\rowcolors| (with a \emph{s}) takes its name from the % command |\rowcolors| of \pkg{xcolor}\footnote{The command |\rowcolors| of -% \pkg{xcolor} is available when \pkg{xcolor} is loaded with the -% option~|table|.}. The \emph{s} emphasizes the fact that there is \emph{two} -% colors. This command colors alternately the rows of the tabular with the -% tow colors (provided in second and third argument), beginning -% with the row whose number is given in first (mandatory) argument. +% \pkg{xcolor} is available when \pkg{xcolor} is loaded with the option~|table|. +% That option also loads the package \pkg{colortbl}.}. The \emph{s} emphasizes +% the fact that there is \emph{two} colors. This command colors alternately the +% rows of the tabular with the tow colors (provided in second and third +% argument), beginning with the row whose number is given in first (mandatory) +% argument. % -% \colorbox{yellow!30}{New 5.8}\enskip In fact, the first (mandatory) -% argument is, more generally, a comma separated list of intervals describing -% the rows involved in the action of |\rowcolors| (an interval of the form -% $i$|-| describes in fact the interval of all the rows of the tabular, -% beginning with the row~$i$). +% In fact, the first (mandatory) argument is, more generally, a comma separated +% list of intervals describing the rows involved in the action of |\rowcolors| +% (an interval of the form $i$|-| describes in fact the interval of all the rows +% of the tabular, beginning with the row~$i$). % % % @@ -1301,15 +1299,15 @@ version 2005/12/01 or later. % optional argument in the first position corresponds to the colorimetric % space). The available keys are |cols|, |restart| and |respect-blocks|. % \begin{itemize} -% \item \colorbox{yellow!30}{New 5.8}\enskip The key |cols| describes a -% set of columns. The command |\rowcolors| will color only the cells of these -% columns. The value is a comma-separated list of intervals of the form $i$-$j$. -% \item \colorbox{yellow!30}{New 5.8}\enskip With the key |restart|, -% each interval of rows (specified by the first mandatory argument) begins with -% the same color.\footnote{Otherwise, the color of a given row relies only upon the -% parity of its number.} +% \item The key |cols| describes a set of columns. The command |\rowcolors| will +% color only the cells of these columns. The value is a comma-separated list of +% intervals of the form $i$-$j$. +% \item With the key |restart|, each interval of rows (specified by the first +% mandatory argument) begins with the same color.\footnote{Otherwise, the color +% of a given row relies only upon the parity of its number.} % \item With the key |respect-blocks| the ``rows'' alternately colored may extend over -% several rows if they have to incorporate blocks (created with the command |\Block|). +% several rows if they have to incorporate blocks (created with the command +% |\Block|: cf.~p.~\pageref{Block}). % \end{itemize} % % \medskip @@ -1402,7 +1400,8 @@ version 2005/12/01 or later. % % \bigskip % One should remark that these commands are compatible with the commands of -% \pkg{booktabs} (|\toprule|, |\midrule|, |\bottomrule|, etc). +% \pkg{booktabs} (|\toprule|, |\midrule|, |\bottomrule|, etc). However, +% \pkg{booktabs} is not loaded by \pkg{nicematrix}. % % \medskip % \begin{scope} @@ -1451,7 +1450,7 @@ version 2005/12/01 or later. % % It's possible to access the preceding tools with a syntax close to the syntax % of \pkg{colortbl}. For that, one must use the key |colortbl-like| in the -% current environment.\footnote{As of now, this key is not available in |\NiceMatrixOptions|.} +% current environment.\footnote{As for now, this key is \emph{not} available in |\NiceMatrixOptions|.} % % There are three commands available (they are inspired by \pkg{colortbl} but % are \emph{independent} of \pkg{colortbl}): @@ -1463,7 +1462,7 @@ version 2005/12/01 or later. % with the same syntax as the corresponding command of % \pkg{colortbl} (however, unlike the command |\columncolor| of \pkg{colortbl}, % this command |\columncolor| can appear within another command, itself used in the -% preamble). +% preamble of the array). % \end{itemize} % % \medskip @@ -1673,10 +1672,13 @@ version 2005/12/01 or later. % \bigskip % We have several remarks to do. % \begin{itemize}[beginpenalty=10000] -% \item For the environments with an explicit preamble (i.e. |{NiceArray}| and -% its variants), no letter must be given in that preamble for the potential -% first column and the potential last column: they will automatically (and -% necessarily) be of type |r| for the first column and |l| for the last one. +% \item For the environments with an explicit preamble (i.e. |{NiceTabular}|, +% |{NiceArray}| and its variants), no letter must be given in that preamble for +% the potential first column and the potential last column: they will +% automatically (and necessarily) be of type |r| for the first column and |l| +% for the last one.\footnote{The users wishing exteriors columns with another +% type of alignment should consider the command |\SubMatrix| available in the +% |\CodeAfter| (cf.~p.~\pageref{sub-matrix}).} % \item One may wonder how \pkg{nicematrix} determines the number of rows and % columns which are needed for the composition of the ``last row'' and ``last % column''. @@ -1705,9 +1707,8 @@ version 2005/12/01 or later. % \bigskip % It's possible to control the appearance of these rows and columns with options % |code-for-first-row|, |code-for-last-row|, |code-for-first-col| and -% |code-for-last-col|. These options -% specify tokens that will be inserted before each cell of the corresponding row -% or column. +% |code-for-last-col|. These options specify tokens that will be inserted before +% each cell of the corresponding row or column. % % % \begin{Verbatim} @@ -1761,9 +1762,12 @@ version 2005/12/01 or later. % % \item Logically, the potential option |columns-width| (described % p.~\pageref{width}) doesn't apply to the ``first column'' and ``last column''. +% % \item For technical reasons, it's not possible to use the option of the -% command |\\| after the ``first row'' or before the ``last row'' (the placement -% of the delimiters would be wrong). +% command |\\| after the ``first row'' or before the ``last row''. The placement +% of the delimiters would be wrong. If you are looking for a workaround, +% consider the command |\SubMatrix| in the |\CodeAfter| described +% p.~\pageref{sub-matrix}. % \end{itemize} % % @@ -1793,7 +1797,7 @@ version 2005/12/01 or later. % with the option |color|.\footnote{It's also possible to change the color of % all theses dotted lines with the option |xdots/color| (\textsl{xdots} to % remind that it works for |\Cdots|, |\Ldots|, |\Vdots|, etc.): cf. p. -% \pageref{customization}.}\par\nobreak +% \pageref{customisation}.}\par\nobreak % % \bigskip % \begin{BVerbatim}[baseline=c,boxwidth=10cm] @@ -2028,10 +2032,12 @@ version 2005/12/01 or later. % 1 & 2 & 3 & 4 & 5 % \end{pNiceMatrix}$ % -% +% \medskip % Remark: Unlike the command |\hdotsfor| of \pkg{amsmath}, the command -% |\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|). +% |\Hdotsfor| may be used even when the package \pkg{colortbl}\footnote{We +% recall that when \pkg{xcolor} is loaded with the option \verb|table|, the +% package \pkg{colortbl} is loaded.} is loaded (but you might have problem if +% you use |\rowcolor| on the same row as |\Hdotsfor|). % % \bigskip % The package \pkg{nicematrix} also provides a command |\Vdotsfor| similar to @@ -2145,9 +2151,9 @@ version 2005/12/01 or later. % 0 & & 1 % \end{bNiceMatrix}$ % -% \subsection{Customization of the dotted lines} +% \subsection{Customisation of the dotted lines} % -% \label{customization} +% \label{customisation} % The dotted lines drawn by |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, |\Iddots| % and |\Hdotsfor| (and by the command |\line| in the |\CodeAfter| which is described % p.~\pageref{line-in-code-after}) may be customized by three options (specified @@ -2158,9 +2164,9 @@ version 2005/12/01 or later. % \item |line-style|. % \end{itemize} % -% These options may also be fixed with |\NiceMatrixOptions| or at the level of a -% given environment but, in those cases, they must be prefixed by |xdots|, and, -% thus have for names: +% These options may also be fixed with |\NiceMatrixOptions|, as options of +% |\CodeAfter| or at the level of a given environment but, in those cases, they +% must be prefixed by |xdots|, and, thus have for names: % \begin{itemize} % \item |xdots/color|; % \item |xdots/shorten|; @@ -2280,18 +2286,27 @@ version 2005/12/01 or later. % \medskip % For the legibility 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|. +% environment, after the keyword |\CodeAfter|. Although |\CodeAfter| is a +% keyword, it takes in an optional argument (between square brackets). The keys +% accepted form a subset of the keys of the command |\WithArrowsOptions|. % +% +% \medskip +% The experienced users may use, for instance, the PGF/Tikz nodes created by +% \pkg{nicematrix} in the |\CodeAfter|. These nodes are described further +% beginning on p.~\pageref{PGF-nodes}. +% % \medskip -% Two special commands are available in the |\CodeAfter|: |line| and +% Moreover, two special commands are available in the |\CodeAfter|: |line| and % |\SubMatrix|. % % \subsection{The command \textbackslash line in the \textbackslash CodeAfter} % -% The command |\line|draws directly dotted lines between nodes. It takes two -% arguments for the two cells to rely, both of the form $i$-$j$ where is the -% number of row and $j$ is the number of column. It may be used, for example, to -% draw a dotted line between two adjacent cells. \label{line-in-code-after} +% The command |\line| draws directly dotted lines between nodes. It takes in two +% arguments for the two cells to link, both of the form $i$-$j$ where is the +% number of the row and $j$ is the number of the column. It may be used, for +% example, to draw a dotted line between two adjacent +% cells. \label{line-in-code-after} % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=11cm] @@ -2315,13 +2330,18 @@ version 2005/12/01 or later. % \end{pNiceMatrix}$ % \end{scope} % +% \medskip +% The options available for the customisation of the dotted lines created by +% |\Cdots|, |\Vdots|, etc. are also available for this command (cf. +% p.~\pageref{customisation}). +% % % \subsection{The command \textbackslash SubMatrix in the \textbackslash CodeAfter} % % \label{sub-matrix} % % \colorbox{yellow!50}{\textbf{New 5.10}}\enskip -% The command |\SubMatrix| provides a way to put delimiters on an portion +% The command |\SubMatrix| provides a way to put delimiters on a portion % of the array considered as a submatrix. The command |\SubMatrix| takes in five % arguments: % \begin{itemize} @@ -2343,10 +2363,10 @@ version 2005/12/01 or later. % % \medskip % \begin{scope} +% \hfuzz=15cm % \fvset{commandchars=\~\#\+}% % \begin{BVerbatim}[boxwidth=11cm,baseline=c] -% \[\begin{NiceArray}{ccc~emphase#@{\hspace{1.5em}}+c}% -% [cell-space-limits=2pt,~emphase#margin+] +% \[\begin{NiceArray}{ccc~emphase#@{\hspace{1.5em}}+c}[cell-space-limits=2pt,~emphase#margin+] % 1 & 1 & 1 & x \\ % \dfrac{1}{4} & \dfrac{1}{2} & \dfrac{1}{4} & y \\ % 1 & 2 & 3 & z @@ -2372,7 +2392,7 @@ version 2005/12/01 or later. % exists also the key |xshift| which fixes both parameters); % \item |extra-height| adds a quantity to the total height of the delimiters % (height |\ht| + depth |\dp|); -% \item |delimiters-color| fixes the color of the delimiters (also +% \item |delimiters/color| fixes the color of the delimiters (also % available in |\NiceMatrixOptions|, in the environments with delimiters and as % option of the command |\CodeAfter|); % \item |slim| is a boolean key: when that key is in force, the horizontal @@ -2390,10 +2410,10 @@ version 2005/12/01 or later. % % \bigskip % \begin{scope} +% \hfuzz=12cm % \fvset{commandchars=\~\#\!}% % \begin{BVerbatim}[baseline=c,boxwidth=11cm] -% $\begin{NiceArray}{cc@{\hspace{5mm}}l}% -% [cell-space-limits=2pt] +% $\begin{NiceArray}{cc@{\hspace{5mm}}l}[cell-space-limits=2pt] % & & \frac12 \\ % & & \frac14 \\[1mm] % a & b & \frac12a+\frac14b \\ @@ -2421,10 +2441,10 @@ version 2005/12/01 or later. % % \medskip % \begin{scope} +% \hfuzz=12cm % \fvset{commandchars=\~\#\!}% % \begin{BVerbatim}[baseline=c,boxwidth=11cm] -% $\begin{NiceArray}{cc@{\hspace{5mm}}l}% -% [cell-space-limits=2pt] +% $\begin{NiceArray}{cc@{\hspace{5mm}}l}[cell-space-limits=2pt] % & & \frac12 \\ % & & \frac14 \\[1mm] % a & b & \frac12a+\frac14b \\ @@ -2450,7 +2470,7 @@ version 2005/12/01 or later. % % \bigskip % There is also a key |name| which gives a name to the submatrix created by -% |\SubMatrix|. That name is used to created PGF/Tiks nodes: cf +% |\SubMatrix|. That name is used to created PGF/Tikz nodes: cf % p.~\pageref{node-sub-matrix}. % % \section{The notes in the tabulars} @@ -2570,7 +2590,7 @@ version 2005/12/01 or later. % % \begin{center} % \fvset{commandchars=\~\#\!} -% \begin{BVerbatim}[formatcom=\small\color{gray}] +% \begin{Verbatim}[formatcom=\small\color{gray}] % \begin{table} % \setlength{\belowcaptionskip}{1ex} % \centering @@ -2592,11 +2612,11 @@ version 2005/12/01 or later. % \bottomrule % \end{NiceTabular} % \end{table} -% \end{BVerbatim} +% \end{Verbatim} % \end{center} % % -% \begin{table} +% \begin{table}[hb] % \setlength{\belowcaptionskip}{1ex} % \centering % \caption{Use of \texttt{\textbackslash tabularnote}\tabularnote{It's possible @@ -2745,7 +2765,7 @@ version 2005/12/01 or later. % Initial value:\quad |afterlabel = \nobreak, itemjoin = \quad| % % -% \item The key |notes/code-before| est une token list inserted by \pkg{nicematrix} +% \item The key |notes/code-before| is a token list inserted by \pkg{nicematrix} % just before the composition of the notes at the end of the tabular. % % Initial value: \textsl{empty} @@ -2762,7 +2782,7 @@ version 2005/12/01 or later. % % % \bigskip -% For an example of customization of the tabular notes, see p.~\pageref{ex:notes}. +% For an example of customisation of the tabular notes, see p.~\pageref{ex:notes}. % % % \subsection{Use of \{NiceTabular\} with threeparttable} @@ -3055,16 +3075,17 @@ version 2005/12/01 or later. % % For the environements with delimiters (|{pNiceArray}|, |{pNiceMatrix}|, etc.), % it's possible to change the color of the delimiters with the key -% |delimiters-color|. +% |delimiters/color|.\footnote{\verb|delimiters-color| is a synonymous +% (deprecated) for |delimiters/color|.} % % \medskip % \begin{BVerbatim}[boxwidth=12cm,baseline=c] -% $\begin{bNiceMatrix}[delimiters-color=red] +% $\begin{bNiceMatrix}[delimiters/color=red] % 1 & 2 \\ % 3 & 4 % \end{bNiceMatrix}$ % \end{BVerbatim} -% $\begin{bNiceMatrix}[delimiters-color=red] +% $\begin{bNiceMatrix}[delimiters/color=red] % 1 & 2 \\ % 3 & 4 % \end{bNiceMatrix}$ @@ -3098,7 +3119,8 @@ version 2005/12/01 or later. % % \section{Use of Tikz with nicematrix} % -% \label{name} +% \label{name}\label{PGF-nodes} +% % \subsection{The nodes corresponding to the contents of the cells} % % The package \pkg{nicematrix} creates a PGF/Tikz node for each (non-empty) cell @@ -3419,12 +3441,15 @@ version 2005/12/01 or later. % % % -% \subsection{The ``row-nodes'' and the ``col-nodes''} +% \subsection{The nodes which indicate the position of the rules} % -% The package \pkg{nicematrix} creates a PGF/Tikz node indicating the potential -% position of each horizontal rule (with the names |row-|$i$) and each vertical -% rule (with the names |col-|$j$), as described in the following figure. These -% nodes are available in the |code-before| and the |\CodeAfter|. +% \label{nodes-i} +% \colorbox{yellow!50}{\textbf{New 5.11}}\enskip The package \pkg{nicematrix} +% creates a PGF/Tikz node merely called $i$ (with the classical prefix) at the +% intersection of the horizontal rule of number~$i$ and the vertical rule of +% number~$j$ (more specifically the potential position of those rules because +% maybe there are not actually drawn). These nodes are available in the +% |code-before| and the |\CodeAfter|. % \begin{center} % \begin{NiceTabular}{ccc}[hvlines,rules/width=1pt,rules/color=gray] % rose & tulipe & lys \\ @@ -3435,23 +3460,18 @@ version 2005/12/01 or later. % \begin{tikzpicture} % \foreach \i in {1,2,3,4} % { -% \fill [red] (row-\i) circle (0.5mm) ; -% \node [red,anchor=east] at (row-\i) {row-\i} ; -% } -% \foreach \j in {1,2,3,4} -% { -% \fill [blue] (col-\j) circle (0.5mm) ; -% \node [blue,anchor=north] at (col-\j) {col-\j} ; +% \fill [red] (\i) circle (0.5mm) ; +% \node [red,above right] at (\i) {\i} ; % } % \end{tikzpicture} % \end{NiceTabular} % \end{center} % % \bigskip -% If we use Tikz (we remind that \pkg{nicematrix} does not load Tikz by -% default), we can access (in the |code-before| and the |\CodeAfter|) to the -% intersection of the horizontal rule~$i$ and the vertical rule~$j$ with the -% syntax |(row-|$i$\verb+-|col-+$j$|)|. +% If we use Tikz (we remind that \pkg{nicematrix} does not load Tikz by default, +% by only \textsc{pgf}, which is a sub-layer of Tikz), we can access, in the +% |\CodeAfter| but also in the |code-before|) to the intersection of the horizontal +% rule~$i$ and the vertical rule~$j$ with the syntax |(|$i$\verb+-|+$j$|)|. % % \medskip % \begin{Verbatim} @@ -3459,8 +3479,7 @@ version 2005/12/01 or later. % code-before = % { % ~emphase# \tikz \draw [fill = red!15] @ -% ~emphase# (row-7-|col-4) -- (row-8-|col-4) -- (row-8-|col-5) -- @ -% ~emphase# (row-9-|col-5) -- (row-9-|col-6) |- cycle ; @ +% ~emphase# (7-|4) -- (8-|4) -- (8-|5) -- (9-|5) -- (9-|6) |- cycle ; @ % } % ] % 1 \\ @@ -3478,8 +3497,7 @@ version 2005/12/01 or later. % code-before = % { % \tikz \draw [fill = red!15] -% (row-7-|col-4) -- (row-8-|col-4) -- (row-8-|col-5) -- -% (row-9-|col-5) -- (row-9-|col-6) |- cycle ; +% (7-|4) -- (8-|4) -- (8-|5) -- (9-|5) -- (9-|6) |- cycle ; % } % ] % 1 \\ @@ -3497,8 +3515,9 @@ version 2005/12/01 or later. % % \label{node-sub-matrix} % +% \colorbox{yellow!50}{\textbf{New 5.10}}\enskip % The command |\SubMatrix| available in the |\CodeAfter| has been described -% p.~\pageref{sub-matrix}. +% p.~\pageref{sub-matrix}. % % \smallskip % If a command |\SubMatrix| has been used with the key |name| with an expression @@ -3567,51 +3586,37 @@ version 2005/12/01 or later. % \fvset{commandchars=\§\¤\μ} % \begin{Verbatim} %\ExplSyntaxOn -% \cs_new_protected:Nn \__pantigny_hatchcell:nnn +% \cs_new_protected:Nn \__pantigny_hatch:nnn % { % \begin { tikzpicture } % \fill [ pattern = north~west~lines , pattern~color = #3 ] -% ( row - #1 -| col - #2) -% rectangle -% ( row - \int_eval:n { #1 + 1 } -| col - \int_eval:n { #2 + 1 } ) ; +% ( #1 -| #2) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ; % \end { tikzpicture } % } % % \NewDocumentCommand \hatchcell { ! O { black } } % { % \tl_gput_right:Nx §emphase¤\g_nicematrix_code_before_tlμ -% { -% \__pantigny_hatchcell:nnn -% { \int_use:c { c@iRow } } -% { \int_use:c { c@jCol } } -% { #1 } -% } +% { \__pantigny_hatch:nnn { \arabic { iRow } } { \arabic { jCol } } { #1 } } % } % \ExplSyntaxOff % \end{Verbatim} % \end{scope} % % -%\ExplSyntaxOn -% \cs_new_protected:Nn \__pantigny_hatchcell:nnn +% \ExplSyntaxOn +% \cs_new_protected:Nn \__pantigny_hatch:nnn % { % \begin { tikzpicture } % \fill [ pattern = north~west~lines , pattern~color = #3 ] -% ( row - #1 -| col - #2) -% rectangle -% ( row - \int_eval:n { #1 + 1 } -| col - \int_eval:n { #2 + 1 } ) ; +% ( #1 -| #2 ) rectangle ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ; % \end { tikzpicture } % } % % \NewDocumentCommand \hatchcell { ! O { black } } % { % \tl_gput_right:Nx \g_nicematrix_code_before_tl -% { -% \__pantigny_hatchcell:nnn -% { \int_use:c { c@iRow } } -% { \int_use:c { c@jCol } } -% { #1 } -% } +% { \__pantigny_hatch:nnn { \arabic { iRow } } { \arabic { jCol } } { #1 } } % } % \ExplSyntaxOff % @@ -3623,7 +3628,7 @@ version 2005/12/01 or later. % \begin{BVerbatim}[baseline=c,boxwidth=9cm] % \begin{NiceTabular}{ccc}[hvlines] % Tokyo & Paris & London \\ -% Roma & ~emphase#\hatchcell[blue!30]@Oslo & Miami \\ +% Lima & ~emphase#\hatchcell[blue!30]@Oslo & Miami \\ % Los Angeles & Madrid & Roma % \end{NiceTabular} % \end{BVerbatim} @@ -3643,7 +3648,7 @@ version 2005/12/01 or later. % 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 potential exterior row. +% not in a potential exterior row. % % For example, one may wish to define a new column type |?| in order to draw a % (black) heavy rule of width 1~pt. The following definition will do the @@ -3832,7 +3837,7 @@ version 2005/12/01 or later. % \end{Verbatim} % % \bigskip -% As of now, the package \pkg{nicematrix} is not compatible with +% As for now, the package \pkg{nicematrix} is not compatible with % \cls{aastex63}. If you want to use \pkg{nicematrix} with \cls{aastex63}, send % me an email and I will try to solve the incompatibilies. % @@ -3942,103 +3947,7 @@ version 2005/12/01 or later. % % \subsection{Dotted lines} % -% -% A permutation matrix (as an example, we have raised the value of -% |xdots/shorten|). -% -% \label{permutation} -% \bigskip -% \begin{BVerbatim}[baseline=c] -% $\begin{pNiceMatrix}[~emphase#xdots/shorten=0.6em@] -% 0 & 1 & 0 & & \Cdots & 0 \\ -% \Vdots & & & \Ddots & & \Vdots \\ -% & & & \Ddots & & \\ -% & & & \Ddots & & 0 \\ -% 0 & 0 & & & & 1 \\ -% 1 & 0 & & \Cdots & & 0 -% \end{pNiceMatrix}$ -% \end{BVerbatim} -% \hspace{2.5cm} -% $\begin{pNiceMatrix}[xdots/shorten=0.6em] -% 0 & 1 & 0 & & \Cdots & 0 \\ -% \Vdots & & & \Ddots & & \Vdots \\ -% & & & \Ddots & & \\ -% & & & \Ddots & & 0 \\ -% 0 & 0 & & & & 1 \\ -% 1 & 0 & & \Cdots & & 0 -% \end{pNiceMatrix}$ -% -% \vspace{2cm} -% -% An example with |\Iddots| (we have raised again the value of -% |xdots/shorten|).\par\nobreak -% -% \bigskip -% \begin{BVerbatim}[baseline=c] -% $\begin{pNiceMatrix}[xdots/shorten=0.9em] -% 1 & \Cdots & & 1 \\ -% \Vdots & & & 0 \\ -% & ~emphase#\Iddots@ & ~emphase#\Iddots@ & \Vdots \\ -% 1 & 0 & \Cdots & 0 -% \end{pNiceMatrix}$ -% \end{BVerbatim} -% \hspace{4cm} -% $\begin{pNiceMatrix}[xdots/shorten=0.9em] -% 1 & \Cdots & & 1 \\ -% \Vdots & & & 0 \\ -% & \Iddots & \Iddots & \Vdots \\ -% 1 & 0 & \Cdots & 0 -% \end{pNiceMatrix}$ -% -% -% \vspace{2cm} -% An example with |\multicolumn|:\par\nobreak -% -% \bigskip -% \begin{BVerbatim} -% \begin{BNiceMatrix}[nullify-dots] -% 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10\\ -% 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10\\ -% \Cdots & & ~emphase#\multicolumn{6}{C}{10 \text{ other rows}}@ & \Cdots \\ -% 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 -% \end{BNiceMatrix} -% \end{BVerbatim} -% -% \bigskip -% \[\begin{BNiceMatrix}[nullify-dots] -% 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10\\ -% 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10\\ -% \Cdots & & \multicolumn{6}{c}{10 \text{ other rows}} & \Cdots \\ -% 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 -% \end{BNiceMatrix}\] -% -% \vspace{2cm} -% An example with |\Hdotsfor|:\par\nobreak -% -% \bigskip -% \begin{BVerbatim}[baseline=c,boxwidth=11cm] -% \begin{pNiceMatrix}[nullify-dots] -% 0 & 1 & 1 & 1 & 1 & 0 \\ -% 0 & 1 & 1 & 1 & 1 & 0 \\ -% \Vdots & ~emphase#\Hdotsfor{4}@ & \Vdots \\ -% & ~emphase#\Hdotsfor{4}@ & \\ -% & ~emphase#\Hdotsfor{4}@ & \\ -% & ~emphase#\Hdotsfor{4}@ & \\ -% 0 & 1 & 1 & 1 & 1 & 0 -% \end{pNiceMatrix} -% \end{BVerbatim} -% $\begin{pNiceMatrix}[nullify-dots] -% 0 & 1 & 1 & 1 & 1 & 0 \\ -% 0 & 1 & 1 & 1 & 1 & 0 \\ -% \Vdots & \Hdotsfor{4} & \Vdots \\ -% & \Hdotsfor{4} & \\ -% & \Hdotsfor{4} & \\ -% & \Hdotsfor{4} & \\ -% 0 & 1 & 1 & 1 & 1 & 0 -% \end{pNiceMatrix}$ -% -% \vspace{2cm} -% An example for the resultant of two polynoms:\par\nobreak +% An example with the resultant of two polynoms:\par\nobreak % % \bigskip % \begin{BVerbatim} @@ -4100,6 +4009,54 @@ version 2005/12/01 or later. % 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}[formatcom=\small\color{gray}] +% \NiceMatrixOptions{code-for-first-row = \scriptstyle,code-for-first-col = \scriptstyle } +% \setcounter{MaxMatrixCols}{12} +% \newcommand{\blue}{\color{blue}} +% \[\begin{pNiceMatrix}[last-row,last-col,nullify-dots,xdots/line-style={dashed,blue}] +% 1& & & \Vdots & & & & \Vdots \\ +% & \Ddots[line-style=standard] \\ +% & & 1 \\ +% \Cdots[color=blue,line-style=dashed]& & & \blue 0 & +% \Cdots & & & \blue 1 & & & \Cdots & \blue \leftarrow i \\ +% & & & & 1 \\ +% & & &\Vdots & & \Ddots[line-style=standard] & & \Vdots \\ +% & & & & & & 1 \\ +% \Cdots & & & \blue 1 & \Cdots & & \Cdots & \blue 0 & & & \Cdots & \blue \leftarrow j \\ +% & & & & & & & & 1 \\ +% & & & & & & & & & \Ddots[line-style=standard] \\ +% & & & \Vdots & & & & \Vdots & & & 1 \\ +% & & & \blue \overset{\uparrow}{i} & & & & \blue \overset{\uparrow}{j} \\ +% \end{pNiceMatrix}\] +% \end{Verbatim} +% +% +% \begin{scope} +% \NiceMatrixOptions{code-for-first-row = \scriptstyle,code-for-first-col = \scriptstyle } +% \setcounter{MaxMatrixCols}{12} +% \newcommand{\blue}{\color{blue}} +% \[\begin{pNiceMatrix}[last-row,last-col,nullify-dots,xdots/line-style={dashed,blue}] +% 1& & & \Vdots & & & & \Vdots \\ +% & \Ddots[line-style=standard] \\ +% & & 1 \\ +% \Cdots[color=blue,line-style=dashed]& & & \blue 0 & +% \Cdots & & & \blue 1 & & & \Cdots & \blue \leftarrow i \\ +% & & & & 1 \\ +% & & &\Vdots & & \Ddots[line-style=standard] & & \Vdots \\ +% & & & & & & 1 \\ +% \Cdots & & & \blue 1 & \Cdots & & \Cdots & \blue 0 & & & \Cdots & \blue \leftarrow j \\ +% & & & & & & & & 1 \\ +% & & & & & & & & & \Ddots[line-style=standard] \\ +% & & & \Vdots & & & & \Vdots & & & 1 \\ +% & & & \blue \overset{\uparrow}{i} & & & & \blue \overset{\uparrow}{j} \\ +% \end{pNiceMatrix}\] +% \end{scope} +% +% \interitem +% In fact, it's even possible to draw solid lines with the commands |\Cdots|, +% |\Vdots|, etc. % % \begin{Verbatim} % \NiceMatrixOptions @@ -4260,7 +4217,29 @@ version 2005/12/01 or later. % % \vspace{1cm} % It's possible to color a row with |\rowcolor| in the |code-before| (or with -% |\rowcolor| in the first cell of the row if the key |colortbl-like| is used). +% |\rowcolor| in the first cell of the row if the key |colortbl-like| is +% used−even when \pkg{colortbl} is not loaded). +% +% \medskip +% \begin{Verbatim} +% \begin{pNiceArray}{>{\strut}cccc}[margin, extra-margin=2pt,colortbl-like] +% ~emphase#\rowcolor{red!15}@A_{11} & A_{12} & A_{13} & A_{14} \\ +% A_{21} & ~emphase#\rowcolor{red!15}@A_{22} & A_{23} & A_{24} \\ +% A_{31} & A_{32} & ~emphase#\rowcolor{red!15}@A_{33} & A_{34} \\ +% A_{41} & A_{42} & A_{43} & ~emphase#\rowcolor{red!15}@A_{44} +% \end{pNiceArray} +% \end{Verbatim} +% +% +% +% \[\begin{pNiceArray}{>{\strut}cccc}[margin, extra-margin=2pt,colortbl-like] +% \rowcolor{red!15}A_{11} & A_{12} & A_{13} & A_{14} \\ +% A_{21} & \rowcolor{red!15}A_{22} & A_{23} & A_{24} \\ +% A_{31} & A_{32} & \rowcolor{red!15}A_{33} & A_{34} \\ +% A_{41} & A_{42} & A_{43} & \rowcolor{red!15}A_{44} +% \end{pNiceArray}\] +% +% \bigskip % However, it's not possible to do a fine tuning. That's why we describe now a % method to highlight a row of the matrix. We create a rectangular Tikz node % which encompasses the nodes of the second row with the Tikz library \pkg{fit}. @@ -4268,11 +4247,16 @@ version 2005/12/01 or later. % the text \emph{under} this node, we have to use transparency with the % |blend mode| equal to |multiply|. % +% \medskip +% \textbf{Caution} : Some \textsc{pdf} readers are not able to show +% transparency.\footnote{In Overleaf, the ``built-in'' \textsc{pdf} viewer does +% not show transparency. You can switch to the ``native'' viewer in that case.} +% % % \medskip % That example and the following ones require Tikz (by default, \pkg{nicematrix} -% only loads \textsc{pgf}) and the Tikz library |fit|. The following lines in -% the preamble of your document do the job: +% only loads \textsc{pgf}, which is a sub-layer of Tikz) and the Tikz library +% |fit|. The following lines in the preamble of your document do the job: % \begin{verbatim} % \usepackage{tikz} % \usetikzlibrary{fit} @@ -4439,44 +4423,6 @@ version 2005/12/01 or later. % a & a & a & L_3 % \end{pNiceArray}\] % -% -% -% \vspace{1cm} -% -% 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] -% 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] -% 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} % @@ -4607,9 +4553,9 @@ version 2005/12/01 or later. % \smallskip % Of course, the package \pkg{nicematrix} uses the features of the package % \pkg{array}. It tries to be independent of its implementation. Unfortunately, -% it was not possible to be strictly independent: the package \pkg{nicematrix} -% relies upon the fact that the package |{array}| uses |\ialign| to begin the -% |\halign|. +% it was not possible to be strictly independent. For example, the package +% \pkg{nicematrix} relies upon the fact that the package |{array}| uses +% |\ialign| to begin the |\halign|. % % % \bigskip @@ -4647,8 +4593,9 @@ version 2005/12/01 or later. % this package for technical reasons. % % \bigskip -% We load some packages. +% We load some packages. The package \pkg{xparse} is still loaded for use on Overleaf. % \begin{macrocode} +\RequirePackage { xparse } \RequirePackage { array } \RequirePackage { amsmath } % \end{macrocode} @@ -4725,7 +4672,7 @@ version 2005/12/01 or later. % % We test whether the current class is \cls{revtex4-1} (deprecated) or % \cls{revtex4-2} because these classes redefines |\array| (of \pkg{array}) in a -% way incompatible with our programmation. As of january 2021, the current +% way incompatible with our programmation. At the date January 2021, the current % version \cls{revtex4-2} is 4.2e (compatible with \pkg{booktabs}). % % \begin{macrocode} @@ -4792,7 +4739,7 @@ version 2005/12/01 or later. \cs_set_eq:NN \@@_old_pgfutil@check@rerun \pgfutil@check@rerun % \end{macrocode} % The new version of |\pgfutil@check@rerun| will not check the PGF nodes whose -% names start with |nm-| (which is the prefix for the nodes creates by +% names start with |nm-| (which is the prefix for the nodes created by % \pkg{nicematrix}). % \begin{macrocode} \cs_set_protected:Npn \pgfutil@check@rerun ##1 ##2 @@ -4816,7 +4763,7 @@ version 2005/12/01 or later. % \end{macrocode} % The command |\CT@arc@| is a command of \pkg{colortbl} which sets the color of % the rules in the array. We will use it to store the instruction of color for -% the rules even if \pkg{colortbl} is not loaded. Idem for +% the rules even if \pkg{colortbl} is not loaded. % \begin{macrocode} \cs_set_protected:Npn \CT@arc@ { } \cs_set:Npn \arrayrulecolor #1 # { \CT@arc { #1 } } @@ -5092,7 +5039,7 @@ version 2005/12/01 or later. % |\pgfsyspdfmark| in the |aux| file. If he changes its mind and no longer loads % \pkg{nicematrix}, an error may occur at the next compilation because of % remanent instructions |\pgfsyspdfmark| in the |aux| file. With the following -% code, we avoid that situation. +% code, we try to avoid that situation. % \begin{macrocode} \cs_new_protected:Npn \@@_provide_pgfsyspdfmark: { @@ -5109,10 +5056,10 @@ version 2005/12/01 or later. % % \subsection*{Parameters} % -% \bigskip +% \bigskip % For compatibility with versions prior to 5.0, we provide a load-time option -% |define_L_C_R|. With this option, it's possible the letters |L|, |C| and |R| -% instead of |l|, |c| and |r| in the preamble of the environments of +% |define_L_C_R|. With this option, it's possible to use the letters |L|, |C| +% and |R| instead of |l|, |c| and |r| in the preamble of the environments of % \pkg{nicematrix} as it was mandatory before version~5.0. % \begin{macrocode} \bool_new:N \c_@@_define_L_C_R_bool @@ -5198,7 +5145,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% Idem pour the blocks mono-row. +% Idem pour the mono-row blocks. % \begin{macrocode} \dim_new:N \g_@@_blocks_ht_dim \dim_new:N \g_@@_blocks_dp_dim @@ -5214,7 +5161,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% We want to know if we are in an environment of \pkg{nicematrix} because we +% We want to know whether we are in an environment of \pkg{nicematrix} because we % will raise an error if the user tries to use nested environments. % \begin{macrocode} \bool_new:N \l_@@_in_env_bool @@ -5265,9 +5212,22 @@ version 2005/12/01 or later. } % \end{macrocode} % +% \bigskip +% The letter used for the vlines which will be drawn only in the sub-matrices. +% |vlism| stands for \emph{vertical lines in sub-matrices}. +% \begin{macrocode} +\tl_new:N \l_@@_letter_vlism_tl +% \end{macrocode} +% +% The list of the columns where vertical lines in sub-matrices (vlism) must be +% drawn. Of course, the actual value of this sequence will be known after the +% analyse of the preamble of the array. +% \begin{macrocode} +\seq_new:N \g_@@_cols_vlism_seq +% \end{macrocode} % % \bigskip -% The following colors will be used to memorize le color of the potential ``first +% The following colors will be used to memorize the color of the potential ``first % col'' and the potential ``first row''. % \begin{macrocode} \colorlet { nicematrix-last-col } { . } @@ -5315,7 +5275,7 @@ version 2005/12/01 or later. % |\g_nicematrix_code_after_tl| but it is used internally by \pkg{nicematrix}. % In fact, we have to distinguish between |\g_nicematrix_code_after_tl| and % |\g_@@_internal_code_after_tl| because we must take care of the order in which -% instructions stored in that paremeters are executed. +% instructions stored in that parameters are executed. % \begin{macrocode} \tl_new:N \g_@@_internal_code_after_tl % \end{macrocode} @@ -5394,7 +5354,7 @@ version 2005/12/01 or later. % % \bigskip % \pkg{expl3} provides scratch dimensions |\l_tmpa_dim| and |\l_tmpb_dim|. We -% creates two other in the same spirit (if they don't exist yet: that's why we +% creates two more in the same spirit (if they don't exist yet: that's why we % use |\dim_zero_new:N|). % \begin{macrocode} \dim_zero_new:N \l_tmpc_dim @@ -5408,12 +5368,6 @@ version 2005/12/01 or later. \bool_new:N \g_@@_empty_cell_bool % \end{macrocode} % -% \bigskip -% The following dimension will be used to save the current value of -% |\arraycolsep|. -% \begin{macrocode} -\dim_new:N \@@_old_arraycolsep_dim -% \end{macrocode} % % \bigskip % The following dimensions will be used internally to compute the width of the @@ -5426,7 +5380,7 @@ version 2005/12/01 or later. % \bigskip % The following sequence will contain the characteristics of the blocks of the % array, specified by the command |\Block|. Each block is represented by 6 -% components surrounded by braces: +% components surrounded by curly braces: % % |{|\textsl{imin}|}{|\textsl{jmin}|}{|\textsl{imax}|}{|\textsl{jmax}|}{|\textsl{options}|}{|\textsl{contents}|}|. % @@ -5461,7 +5415,7 @@ version 2005/12/01 or later. % % \medskip % The final user may decide to ``stroke'' a block (using, for example, the key -% |color=red!15| when using the command |\Block|). In that case, the rules +% |draw=red!15| when using the command |\Block|). In that case, the rules % specified, for instance, by |hvlines| must not be drawn around the block. % That's why we keep the information of all that stroken blocks in the following % sequence. @@ -5471,13 +5425,14 @@ version 2005/12/01 or later. % % % \medskip -% The list of the names of the potential |\SubMatrix| in the |code-after| of an +% The list of the names of the potential |\SubMatrix| in the |\CodeAfter| of an % environment. Unfortunately, that list has to be global (we have to use it % inside the group for the options of a given |\SubMatrix|). % \begin{macrocode} \seq_new:N \g_@@_submatrix_names_seq % \end{macrocode} -% +% +% % \medskip % We are able to determine the number of columns specified in the preamble (for % the environments with explicit preamble, of course and without the potential @@ -5531,6 +5486,17 @@ version 2005/12/01 or later. % \begin{macrocode} \int_new:N \g_@@_block_box_int % \end{macrocode} +% +% \medskip +% \begin{macrocode} +\dim_new:N \l_@@_submatrix_extra_height_dim +\dim_new:N \l_@@_submatrix_left_xshift_dim +\dim_new:N \l_@@_submatrix_right_xshift_dim +\clist_new:N \l_@@_submatrix_hlines_clist +\clist_new:N \l_@@_submatrix_vlines_clist +% \end{macrocode} +% +% % % \bigskip % \textbf{Variables for the exterior rows and columns}\par\nobreak @@ -5853,7 +5819,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \medskip -% The command |\@@_pgf_rect_node:nnn| is a variant of |\@@_pgr_rect_node:nnnn|: +% The command |\@@_pgf_rect_node:nnn| is a variant of |\@@_pgf_rect_node:nnnn|: % it takes two \textsc{pgf} points as arguments instead of the four dimensions % which are the coordinates. % \begin{macrocode} @@ -6097,7 +6063,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% The following token list corresponds to the key |delimiters-color|. +% The following token list corresponds to the key |delimiters/color|. % \begin{macrocode} \tl_new:N \l_@@_delimiters_color_tl % \end{macrocode} @@ -6150,7 +6116,7 @@ version 2005/12/01 or later. % construction of the array and not when we draw the dotted lines). % \begin{macrocode} draw-first .code:n = \prg_do_nothing: , - unknown .code:n = \@@_error:n { Unknown~option~for~xdots } + unknown .code:n = \@@_error:n { Unknown~key~for~xdots } } % \end{macrocode} % @@ -6174,6 +6140,8 @@ version 2005/12/01 or later. % \begin{macrocode} \keys_define:nn { NiceMatrix / Global } { + rules .code:n = \keys_set:nn { NiceMatrix / rules } { #1 } , + rules .value_required:n = true , standard-cline .bool_set:N = \l_@@_standard_cline_bool , standard-cline .default:n = true , cell-space-top-limit .dim_set:N = \l_@@_cell_space_top_limit_dim , @@ -6206,6 +6174,13 @@ version 2005/12/01 or later. code-for-last-row .value_required:n = true , hlines .bool_set:N = \l_@@_hlines_bool , vlines .bool_set:N = \l_@@_vlines_bool , + vlines-in-sub-matrix .code:n = + { + \tl_if_single_token:nTF { #1 } + { \tl_set:Nn \l_@@_letter_vlism_tl { #1 } } + { \@@_error:n { One~letter~allowed } } + } , + vlines-in-sub-matrix .value_required:n = true , hvlines .code:n = { \bool_set_true:N \l_@@_vlines_bool @@ -6369,6 +6344,7 @@ version 2005/12/01 or later. NiceMatrixOptions / rules .inherit:n = NiceMatrix / rules , NiceMatrixOptions / notes .inherit:n = NiceMatrix / notes , NiceMatrixOptions / sub-matrix .inherit:n = NiceMatrix / sub-matrix , + SubMatrix / rules .inherit:n = NiceMatrix / rules , CodeAfter / xdots .inherit:n = NiceMatrix / xdots , NiceMatrix .inherit:n = { @@ -6409,6 +6385,8 @@ version 2005/12/01 or later. % \begin{macrocode} \keys_define:nn { NiceMatrix / NiceMatrixOptions } { + delimiters / color .tl_set:N = \l_@@_delimiters_color_tl , + delimiters / color .value_required:n = true , delimiters-color .tl_set:N = \l_@@_delimiters_color_tl , delimiters-color .value_required:n = true , last-col .code:n = \tl_if_empty:nF { #1 } @@ -6478,7 +6456,7 @@ version 2005/12/01 or later. { \tl_if_single_token:nTF { #1 } { \str_set:Nx \l_@@_letter_for_dotted_lines_str { #1 } } - { \@@_error:n { Bad~value~for~letter~for~dotted~lines } } + { \@@_error:n { One~letter~allowed } } } , letter-for-dotted-lines .value_required:n = true , notes .code:n = \keys_set:nn { NiceMatrix / notes } { #1 } , @@ -6523,6 +6501,8 @@ version 2005/12/01 or later. r .code:n = \tl_set:Nn \l_@@_type_of_col_tl r , small .bool_set:N = \l_@@_small_bool , small .value_forbidden:n = true , + delimiters / color .tl_set:N = \l_@@_delimiters_color_tl , + delimiters / color .value_required:n = true , delimiters-color .tl_set:N = \l_@@_delimiters_color_tl , delimiters-color .value_required:n = true , unknown .code:n = \@@_error:n { Unknown~option~for~NiceMatrix } @@ -6557,6 +6537,8 @@ version 2005/12/01 or later. tabularnote .value_required:n = true , delimiters-color .tl_set:N = \l_@@_delimiters_color_tl , delimiters-color .value_required:n = true , + delimiters / color .tl_set:N = \l_@@_delimiters_color_tl , + delimiters / color .value_required:n = true , unknown .code:n = \@@_error:n { Unknown~option~for~NiceArray } } % \end{macrocode} @@ -6795,7 +6777,7 @@ version 2005/12/01 or later. % \item we test the existence of these nodes in order to determine whether a % cell is empty when we search the extremities of a dotted line. % \end{itemize} -% However, it's very difficult to determine whether a cell is empty. As of now, +% However, it's very difficult to determine whether a cell is empty. As for now, % we use the following technic: % \begin{itemize} % \item if the width of the box |\l_@@_cell_box| (created with the content of @@ -6805,7 +6787,7 @@ version 2005/12/01 or later. % \item the cells with a command |\Ldots| or |\Cdots|, |\Vdots|, etc., % should also be considered as empty; if |nullify-dots| is in force, there would % be nothing to do (in this case the previous commands only write an instruction -% in a kind of |code-after|); however, if |nullify-dots| is not in force, a +% in a kind of |\CodeAfter|); however, if |nullify-dots| is not in force, a % phantom of |\ldots|, |\cdots|, |\vdots| is inserted and its width is not equal % to zero; that's why these commands raise a boolean |\g_@@_empty_cell_bool| and % we begin by testing this boolean. @@ -6897,11 +6879,6 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Npn \@@_instruction_of_type:nnn #1 #2 #3 { -% \end{macrocode} -% It's important to use a |\tl_gput_right:cx| and not a |\tl_gput_left:cx| -% because we want the |\Ddots| lines to be drawn in the order of appearance -% in the array (for parallelisation). -% \begin{macrocode} \bool_if:nTF { #1 } \tl_gput_left:cx \tl_gput_right:cx { g_@@_ #2 _ lines _ tl } { @@ -7414,7 +7391,7 @@ version 2005/12/01 or later. { % \end{macrocode} % First, we give values to the LaTeX counters |iRow| and |jCol|. We remind that, -% in the |code-before| (and in the |code-after|) they represent the numbers of +% in the |code-before| (and in the |\CodeAfter|) they represent the numbers of % rows and columns of the array (without the potential last row and last column). % \begin{macrocode} \int_zero_new:N \c@iRow @@ -7464,6 +7441,15 @@ version 2005/12/01 or later. { \pgfpointdiff \@@_picture_position: \@@_node_position: } } \endpgfpicture +% \end{macrocode} +% Now, you create the diagonal nodes by using the |row| nodes and the |col| nodes. +% \begin{macrocode} + \@@_create_diag_nodes: +% \end{macrocode} +% +% \medskip +% Now, yet another settings before the executation of the |code-before|. +% \begin{macrocode} \group_begin: \bool_if:NT \c_@@_tikz_loaded_bool { @@ -7898,6 +7884,12 @@ version 2005/12/01 or later. } { \tl_gclear:N \g_@@_preamble_tl } % \end{macrocode} +% The sequence |\g_@@_cols_vlsim_seq| will contain the numbers of the columns +% where you will to have to draw vertical lines in the potential sub-matrices +% (hence the name |vlism|). +% \begin{macrocode} + \seq_clear:N \g_@@_cols_vlism_seq +% \end{macrocode} % The counter |\l_tmpa_int| will count the number of consecutive occurrences % of the symbol \verb+|+. % \begin{macrocode} @@ -7957,8 +7949,7 @@ version 2005/12/01 or later. % \begin{macrocode} \dim_compare:nNnT \l_@@_tabular_width_dim = \c_zero_dim { - \tl_gput_right:Nn - \g_@@_preamble_tl + \tl_gput_right:Nn \g_@@_preamble_tl { > { \@@_error_too_much_cols: } l } } % \end{macrocode} @@ -8004,15 +7995,25 @@ version 2005/12/01 or later. { \str_if_eq:VnTF \l_@@_letter_for_dotted_lines_str { #1 } { \@@_patch_preamble_xi:n #1 } - { - \bool_lazy_and:nnTF - { \str_if_eq_p:nn { : } { #1 } } - \c_@@_arydshln_loaded_bool - { - \tl_gput_right:Nn \g_@@_preamble_tl { : } + { + \str_if_eq:VnTF \l_@@_letter_vlism_tl { #1 } + { + \seq_gput_right:Nx \g_@@_cols_vlism_seq + { \int_eval:n { \c@jCol + 1 } } + \tl_gput_right:Nx \g_@@_preamble_tl + { \exp_not:N ! { \skip_horizontal:N \arrayrulewidth } } \@@_patch_preamble:n } - { \@@_fatal:nn { unknown~column~type } { #1 } } + { + \bool_lazy_and:nnTF + { \str_if_eq_p:nn { : } { #1 } } + \c_@@_arydshln_loaded_bool + { + \tl_gput_right:Nn \g_@@_preamble_tl { : } + \@@_patch_preamble:n + } + { \@@_fatal:nn { unknown~column~type } { #1 } } + } } } } @@ -8102,11 +8103,15 @@ version 2005/12/01 or later. \@@_Cell: \begin { minipage } [ #1 ] { #3 } \mode_leave_vertical: - \arraybackslash % added in the version 5.8 - \box_use:N \@arstrutbox + \arraybackslash + \vrule height \box_ht:N \@arstrutbox depth 0 pt width 0 pt % v. 5.11 } c - < { \box_use:N \@arstrutbox \end { minipage } \@@_end_Cell: } + < { + \vrule height 0 pt depth \box_dp:N \@arstrutbox width 0 pt % v. 5.11 + \end { minipage } + \@@_end_Cell: + } } % \end{macrocode} % We increment the counter of columns, and then we test for the presence of a |<|. @@ -8603,7 +8608,7 @@ version 2005/12/01 or later. { \@@_fatal:n { double-backslash~in~light-syntax } } } % \end{macrocode} -% Now, you extract the |code-after| of the body of the environment. Maybe, there +% Now, you extract the |\CodeAfter| of the body of the environment. Maybe, there % is no command |\CodeAfter| in the body. That's why you put a marker % |\CodeAfter| after |#1|. If there is yet a |\CodeAfter| in |#1|, this second % (or third...) |\CodeAfter| will be catched in the value of @@ -8884,6 +8889,12 @@ version 2005/12/01 or later. { > { +% \end{macrocode} +% At the beginning of the cell, we link |\CodeAfter| to a command which do +% \emph{not} begin with |\omit| (whereas the standard version of |\CodeAfter| +% begins with |\omit|). +% \begin{macrocode} + \cs_set_eq:NN \CodeAfter \@@_CodeAfter_i:n \bool_gset_true:N \g_@@_after_col_zero_bool \@@_begin_of_row: % \end{macrocode} @@ -8955,6 +8966,12 @@ version 2005/12/01 or later. > { % \end{macrocode} +% At the beginning of the cell, we link |\CodeAfter| to a command which do +% \emph{not} begin with |\omit| (whereas the standard version of |\CodeAfter| +% begins with |\omit|). +% \begin{macrocode} + \cs_set_eq:NN \CodeAfter \@@_CodeAfter_i:n +% \end{macrocode} % With the flag |\g_@@_last_col_found_bool|, we will know that the ``last % column'' is really used. % \begin{macrocode} @@ -9259,7 +9276,17 @@ version 2005/12/01 or later. } % \end{macrocode} % -% +% \medskip +% \begin{macrocode} + \@@_create_diag_nodes: + \str_if_empty:NF \l_@@_name_str + { + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgfnodealias { \l_@@_name_str - ##1 } { \@@_env: - ##1 } + \endpgfpicture + } +% \end{macrocode} % % By default, the diagonal lines will be parallelized\footnote{It's possible to % use the option |parallelize-diags| to disable this parallelization.}. There @@ -9363,7 +9390,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% Now, the |code-after|. +% Now, the |\CodeAfter|. % \begin{macrocode} \bool_if:NT \c_@@_tikz_loaded_bool { @@ -9389,11 +9416,11 @@ version 2005/12/01 or later. % \end{macrocode} % % We clear the list of the names of the potential |\SubMatrix| that will appear -% in the |code-after| (unfortunately, that list has to be global). +% in the |\CodeAfter| (unfortunately, that list has to be global). % \begin{macrocode} \seq_gclear:N \g_@@_submatrix_names_seq % \end{macrocode} -% And here's the |code-after|. Since the |code-after| may begin with an +% And here's the |\CodeAfter|. Since the |\CodeAfter| may begin with an % ``argument'' between square brackets of the options, we extract and treat that % potential ``argument'' with the command |\@@_CodeAfter_keys:|. % \begin{macrocode} @@ -9450,7 +9477,7 @@ version 2005/12/01 or later. % % \bigskip % The following command will extract the potential options (between square -% brackets) at the beginning of the |code-after| (that is to say, when +% brackets) at the beginning of the |\CodeAfter| (that is to say, when % |\CodeAfter| is used, the options of that ``command'' |\CodeAfter|). % \begin{macrocode} \NewDocumentCommand \@@_CodeAfter_keys: { O { } } @@ -9541,6 +9568,26 @@ version 2005/12/01 or later. % % % \bigskip +% The following command creates the diagonal nodes (in fact, if the matrix is +% not a square matrix, not all the nodes are on the diagonal). +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_create_diag_nodes: + { + \int_step_inline:nn { \int_max:nn \c@iRow \c@jCol + 1 } + { + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \@@_qpoint:n { row - \int_min:nn { ##1 } { \c@iRow + 1 } } + \dim_set_eq:NN \l_tmpa_dim \pgf@y + \@@_qpoint:n { col - \int_min:nn { ##1 } { \c@jCol + 1 } } + \pgfcoordinate { \@@_env: - ##1 } { \pgfpoint \pgf@x \l_tmpa_dim } + \endpgfpicture + } + } +% \end{macrocode} +% +% \bigskip % \subsection*{We draw the dotted lines} % % A dotted line will be said \emph{open} in one of its extremities when it stops @@ -11025,7 +11072,7 @@ version 2005/12/01 or later. % \bigskip % \subsection*{The command \textbackslash line accessible in code-after} % -% In the |code-after|, the command |\@@_line:nn| will be linked to |\line|. This +% In the |\CodeAfter|, the command |\@@_line:nn| will be linked to |\line|. This % command takes two arguments which are the specifications of two cells in the % array (in the format $i$-$j$) and draws a dotted line between these cells. % @@ -11033,7 +11080,7 @@ version 2005/12/01 or later. % First, we write a command with an argument of the format $i$-$j$ and applies % the command |\int_eval:n| to $i$ and~$j$ ; this must \emph{not} be protected % (and is, of course fully expandable).\footnote{Indeed, we want that the user -% may use the command |\line| in |code-after| with LaTeX counters in the +% may use the command |\line| in |\CodeAfter| with LaTeX counters in the % arguments --- with the command |\value|.} % \begin{macrocode} \cs_new:Npn \@@_double_int_eval:n #1-#2 \q_stop @@ -11079,7 +11126,7 @@ version 2005/12/01 or later. \cs_if_free_p:c { pgf @ sh @ ns @ \@@_env: - #2 } } { - \@@_error:nnn { unknown~cell~for~line~in~code-after } { #1 } { #2 } + \@@_error:nnn { unknown~cell~for~line~in~CodeAfter } { #1 } { #2 } } { \@@_draw_line_ii:nn { #1 } { #2 } } } @@ -11341,7 +11388,7 @@ version 2005/12/01 or later. cols .tl_set:N = \l_@@_cols_tl , restart .bool_set:N = \l_@@_rowcolors_restart_bool , restart .default:n = true , - unknown .code:n = \@@_error:n { Unknown~option~for~rowcolors } + unknown .code:n = \@@_error:n { Unknown~key~for~rowcolors } } % \end{macrocode} % @@ -11655,7 +11702,7 @@ version 2005/12/01 or later. } % \end{macrocode} % This definition may seem complicated by we must remind that the number of row -% |\c@iRow| is incremented in the first cell of the row, \emph{after} an +% |\c@iRow| is incremented in the first cell of the row, \emph{after} a % potential vertical rule on the left side of the first cell. % % \smallskip @@ -11675,8 +11722,8 @@ version 2005/12/01 or later. % % \bigskip % The following command will be executed in the |internal-code-after|. The rule -% will be drawn \emph{before} the column |#1|. |#2| is the number of consecutive -% occurrences of \verb+|+. +% will be drawn \emph{before} the column |#1| (that is to say on the left side). +% |#2| is the number of consecutive occurrences of \verb+|+. % \begin{macrocode} \cs_new_protected:Npn \@@_vline:nn #1 #2 { @@ -11715,11 +11762,11 @@ version 2005/12/01 or later. % \begin{macrocode} \bool_gset_true:N \g_tmpa_bool \seq_map_inline:Nn \g_@@_pos_of_blocks_seq - { \@@_test_if_vline_in_block:nnnn ##1 } + { \@@_test_vline_in_block:nnnn ##1 } \seq_map_inline:Nn \g_@@_pos_of_xdots_seq - { \@@_test_if_vline_in_block:nnnn ##1 } + { \@@_test_vline_in_block:nnnn ##1 } \seq_map_inline:Nn \g_@@_pos_of_stroken_blocks_seq - { \@@_test_if_vline_in_stroken_block:nnnn ##1 } + { \@@_test_vline_in_stroken_block:nnnn ##1 } \clist_if_empty:NF \l_@@_except_corners_clist \@@_test_in_corner_v: \bool_if:NTF \g_tmpa_bool @@ -11785,7 +11832,7 @@ version 2005/12/01 or later. % % \bigskip % |#1| is the number of the column; |#2| is the number of vertical rules to -% draw (with potentially a color between); |#3| and |#4| are the number of the +% draw (with potentially a color between); |#3| and |#4| are the numbers of the % rows between which the rule has to be drawn. % \begin{macrocode} \cs_new_protected:Npn \@@_vline_ii:nnnn #1 #2 #3 #4 @@ -11831,8 +11878,8 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% The following draws a complete vertical rule in the column |#1| (|#2| is the -% number of consecutive rules specified by the number of \verb+|+ in the +% The following command draws a complete vertical rule in the column |#1| (|#2| +% is the number of consecutive rules specified by the number of \verb+|+ in the % preamble). This command will be used if there is no block in the array (and % the key |except-corners| is not used). % \begin{macrocode} @@ -11875,7 +11922,7 @@ version 2005/12/01 or later. \cs_new_protected:Npn \@@_hline_i:nn #1 #2 { % \end{macrocode} -% |\l_tmpa_tl| is the number of row and |\l_tmpb_tl| the number of column. Whe, +% |\l_tmpa_tl| is the number of row and |\l_tmpb_tl| the number of column. When % we have found a column corresponding to a rule to draw, we note its number in % |\l_tmpc_tl|. % \begin{macrocode} @@ -11892,11 +11939,11 @@ version 2005/12/01 or later. % \begin{macrocode} \bool_gset_true:N \g_tmpa_bool \seq_map_inline:Nn \g_@@_pos_of_blocks_seq - { \@@_test_if_hline_in_block:nnnn ##1 } + { \@@_test_hline_in_block:nnnn ##1 } \seq_map_inline:Nn \g_@@_pos_of_xdots_seq - { \@@_test_if_hline_in_block:nnnn ##1 } + { \@@_test_hline_in_block:nnnn ##1 } \seq_map_inline:Nn \g_@@_pos_of_stroken_blocks_seq - { \@@_test_if_hline_in_stroken_block:nnnn ##1 } + { \@@_test_hline_in_stroken_block:nnnn ##1 } \clist_if_empty:NF \l_@@_except_corners_clist \@@_test_in_corner_h: \bool_if:NTF \g_tmpa_bool { @@ -12064,13 +12111,13 @@ version 2005/12/01 or later. % \subsection*{The key hvlines} % % -% The following command tests wether the current position in the array (given by -% |\l_tmpa_tl| for the row and |\l_tmpb_tl| for the col) would provide an +% The following command tests whether the current position in the array (given by +% |\l_tmpa_tl| for the row and |\l_tmpb_tl| for the column) would provide an % horizontal rule towards the right in the block delimited by the four arguments % |#1|, |#2|, |#3| and |#4|. If this rule would be in the block (it must not be % drawn), the boolean |\l_tmpa_bool| is set to |false|. % \begin{macrocode} -\cs_new_protected:Npn \@@_test_if_hline_in_block:nnnn #1 #2 #3 #4 +\cs_new_protected:Npn \@@_test_hline_in_block:nnnn #1 #2 #3 #4 { \bool_lazy_all:nT { @@ -12085,7 +12132,7 @@ version 2005/12/01 or later. % % The same for vertical rules. % \begin{macrocode} -\cs_new_protected:Npn \@@_test_if_vline_in_block:nnnn #1 #2 #3 #4 +\cs_new_protected:Npn \@@_test_vline_in_block:nnnn #1 #2 #3 #4 { \bool_lazy_all:nT { @@ -12099,7 +12146,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} -\cs_new_protected:Npn \@@_test_if_hline_in_stroken_block:nnnn #1 #2 #3 #4 +\cs_new_protected:Npn \@@_test_hline_in_stroken_block:nnnn #1 #2 #3 #4 { \bool_lazy_all:nT { @@ -12113,7 +12160,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} -\cs_new_protected:Npn \@@_test_if_vline_in_stroken_block:nnnn #1 #2 #3 #4 +\cs_new_protected:Npn \@@_test_vline_in_stroken_block:nnnn #1 #2 #3 #4 { \bool_lazy_all:nT { @@ -12332,7 +12379,7 @@ version 2005/12/01 or later. % % % \medskip -% The command |\@@_hdottedline:n| is the command written in the |code-after| +% The command |\@@_hdottedline:n| is the command written in the |\CodeAfter| % that will actually draw the dotted line. Its argument is the number of the row % \emph{before} which we will draw the row. % \begin{macrocode} @@ -12446,16 +12493,14 @@ version 2005/12/01 or later. % bracket. The correction by |0.5 \l_@@_inter_dots_dim| is \emph{ad hoc} for a % better result. % \begin{macrocode} - \tl_set:Nn \l_tmpa_tl { ( } - \tl_if_eq:NNF \l_@@_left_delim_tl \l_tmpa_tl + \tl_if_eq:NnF \l_@@_left_delim_tl ( { \dim_gadd:Nn \l_@@_x_initial_dim { 0.5 \l_@@_inter_dots_dim } } - \tl_set:Nn \l_tmpa_tl { ) } - \tl_if_eq:NNF \l_@@_right_delim_tl \l_tmpa_tl + \tl_if_eq:NnF \l_@@_right_delim_tl ) { \dim_gsub:Nn \l_@@_x_final_dim { 0.5 \l_@@_inter_dots_dim } } % \end{macrocode} % % \medskip -% As of now, we have no option to control the style of the lines drawn by +% As for now, we have no option to control the style of the lines drawn by % |\hdottedline| and the specifier ``|:|'' in the preamble. That's why we impose % the style |standard|. % \begin{macrocode} @@ -12523,7 +12568,7 @@ version 2005/12/01 or later. \@@_qpoint:n { row - \@@_succ:n \c@iRow } \dim_set:Nn \l_@@_y_final_dim { \pgf@y + 0.5 \l_@@_inter_dots_dim } % \end{macrocode} -% As of now, we have no option to control the style of the lines drawn by +% As for now, we have no option to control the style of the lines drawn by % |\hdottedline| and the specifier ``|:|'' in the preamble. That's why we impose % the style |standard|. % \begin{macrocode} @@ -12544,7 +12589,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% As of now, there is only one option available for the environment +% As for now, there is only one option available for the environment % |{NiceMatrixBlock}|. % \begin{macrocode} \keys_define:nn { NiceMatrix / NiceMatrixBlock } @@ -13293,7 +13338,7 @@ version 2005/12/01 or later. % replaced by the line which is commented. % \begin{macrocode} color .code:n = - \@@_error:n { Key~color~for~Block } + \@@_fatal:n { Key~color~for~Block } \tl_set:Nn \l_@@_fill_tl { #1 } , % color .code:n = \color { #1 } \tl_set:Nn \l_@@_draw_tl { #1 } , color .value_required:n = true , @@ -13347,10 +13392,8 @@ version 2005/12/01 or later. \int_compare:nNnTF { #4 } > { 99 } { \int_set_eq:NN \l_@@_last_col_int \c@jCol } { \int_set:Nn \l_@@_last_col_int { #4 } } - \bool_lazy_or:nnTF - { \int_compare_p:nNn \l_@@_last_row_int > \g_@@_row_total_int } - { \int_compare_p:nNn \l_@@_last_col_int > \g_@@_col_total_int } - { + \int_compare:nNnTF \l_@@_last_col_int > \g_@@_col_total_int + { \int_compare:nTF { \l_@@_last_col_int <= \g_@@_static_num_of_col_int } { @@ -13361,9 +13404,13 @@ version 2005/12/01 or later. \@@_msg_redirect_name:nn { columns~not~used } { none } \group_end: } + { \msg_error:nnnn { nicematrix } { Block~too~large~1 } { #1 } { #2 } } + } + { + \int_compare:nNnTF \l_@@_last_row_int > \g_@@_row_total_int { \msg_error:nnnn { nicematrix } { Block~too~large~1 } { #1 } { #2 } } + { \@@_Block_v:nnnnnn { #1 } { #2 } { #3 } { #4 } { #5 } { #6 } } } - { \@@_Block_v:nnnnnn { #1 } { #2 } { #3 } { #4 } { #5 } { #6 } } } % \end{macrocode} % @@ -13979,17 +14026,20 @@ version 2005/12/01 or later. % \subsection*{The keyword \textbackslash CodeAfter} % % -% The |code-after| (inserted with the key |code-after| or after the keyword -% |\CodeAfter| can always begin with a list of pairs \emph{key-value} between -% square brackets). Here the corresponding set of keys. +% The |\CodeAfter| (inserted with the key |code-after| or after the keyword +% |\CodeAfter|) may always begin with a list of pairs \emph{key-value} between +% square brackets. Here is the corresponding set of keys. % \begin{macrocode} +\keys_define:nn { NiceMatrix } + { CodeAfter / rules .inherit:n = NiceMatrix / rules } \keys_define:nn { NiceMatrix / CodeAfter } { - sub-matrix .code:n = - \keys_set:nn { NiceMatrix / sub-matrix } { #1 } , + sub-matrix .code:n = \keys_set:nn { NiceMatrix / sub-matrix } { #1 } , sub-matrix .value_required:n = true , - delimiters-color .tl_set:N = \l_@@_delimiters_color_tl , - delimiters-color .value_required:n = true , + delimiters / color .tl_set:N = \l_@@_delimiters_color_tl , + delimiters / color .value_required:n = true , + rules .code:n = \keys_set:nn { NiceMatrix / rules } { #1 } , + rules .value_required:n = true , unknown .code:n = \@@_error:n { Unknown~key~for~CodeAfter } } % \end{macrocode} @@ -14034,8 +14084,7 @@ version 2005/12/01 or later. % 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} - \str_if_eq:eeTF \@currenvir { #1 } - { \end { #1 } } + \str_if_eq:eeTF \@currenvir { #1 } { \end { #1 } } % \end{macrocode} % If this is not the |\end| we are looking for, we put those tokens in % |\g_nicematrix_code_after_tl| and we go on searching for the next command @@ -14147,7 +14196,7 @@ version 2005/12/01 or later. } % \end{macrocode} % -% \subsection*{The command SubMatrix} +% \subsection*{The command \textbackslash SubMatrix} % % % \begin{macrocode} @@ -14161,15 +14210,15 @@ version 2005/12/01 or later. right-xshift .value_required:n = true , xshift .meta:n = { left-xshift = #1, right-xshift = #1 } , xshift .value_required:n = true , - delimiters-color .tl_set:N = \l_@@_delimiters_color_tl , - delimiters-color .value_required:n = true , + delimiters / color .tl_set:N = \l_@@_delimiters_color_tl , + delimiters / color .value_required:n = true , slim .bool_set:N = \l_@@_submatrix_slim_bool , slim .default:n = true , } \keys_define:nn { NiceMatrix } { - SubMatrix .inherit:n = NiceMatrix /sub-matrix , - CodeAfter / sub-matrix .inherit:n = NiceMatrix / sub-matrix + SubMatrix .inherit:n = NiceMatrix / sub-matrix , + CodeAfter / sub-matrix .inherit:n = NiceMatrix / sub-matrix , } % \end{macrocode} % @@ -14179,6 +14228,10 @@ version 2005/12/01 or later. % \begin{macrocode} \keys_define:nn { NiceMatrix / SubMatrix } { + hlines .clist_set:N = \l_@@_submatrix_hlines_clist , + hlines .default:n = all , + vlines .clist_set:N = \l_@@_submatrix_vlines_clist , + vlines .default:n = all , name .code:n = \tl_if_empty:nTF { #1 } { \@@_error:n { Invalid~name~format } } @@ -14194,6 +14247,8 @@ version 2005/12/01 or later. } { \@@_error:n { Invalid~name~format } } } , + rules .code:n = \keys_set:nn { NiceMatrix / rules } { #1 } , + rules .value_required:n = true , name .value_required:n = true , unknown .code:n = \@@_error:n { Unknown~key~for~SubMatrix } } @@ -14205,7 +14260,7 @@ version 2005/12/01 or later. % \begin{itemize} % \item |#1| is the left delimiter; % \item |#2| is the upper-left cell of the matrix with the format $i$-$j$; -% \item |#2| is the lower-right cell of the matrix with the format $i$-$j$; +% \item |#3| is the lower-right cell of the matrix with the format $i$-$j$; % \item |#4| is the right delimiter; % \item |#5| is the list of options of the command. % \end{itemize} @@ -14229,9 +14284,6 @@ version 2005/12/01 or later. { \int_compare_p:nNn \l_tmpd_tl > \g_@@_col_total_int } { \@@_error:n { SubMatrix~too~large } } { - \dim_zero_new:N \l_@@_submatrix_extra_height_dim - \dim_zero_new:N \l_@@_submatrix_left_xshift_dim - \dim_zero_new:N \l_@@_submatrix_right_xshift_dim \str_clear_new:N \l_@@_submatrix_name_str \keys_set:nn { NiceMatrix / SubMatrix } { #5 } \pgfpicture @@ -14293,6 +14345,109 @@ version 2005/12/01 or later. \dim_set_eq:NN \nulldelimiterspace \c_zero_dim % \end{macrocode} % +% \bigskip +% We will draw the rules in the |\SubMatrix|. +% \begin{macrocode} + \group_begin: + \pgfsetlinewidth { 1.1 \arrayrulewidth } + \tl_if_empty:NF \l_@@_rules_color_tl + { \exp_after:wN \@@_set_CT@arc@: \l_@@_rules_color_tl \q_stop } + \CT@arc@ +% \end{macrocode} +% Now, we draw the potential vertical rules specified in the preamble of the +% environments with the letter fixed with the key |vlines-in-sub-matrix|. The +% list of the columns where there is such rule to draw is in |\g_@@_cols_vlism_seq|. +% \begin{macrocode} + \seq_map_inline:Nn \g_@@_cols_vlism_seq + { + \int_compare:nNnT \l_tmpb_tl < { ##1 } + { + \int_compare:nNnT { ##1 } < { \int_eval:n { \l_tmpd_tl + 1 } } + { +% \end{macrocode} +% First, we extract the value of the abscissa of the rule we have to draw. +% \begin{macrocode} + \@@_qpoint:n { col - ##1 } + \pgfpathmoveto { \pgfpoint \pgf@x \l_@@_y_initial_dim } + \pgfpathlineto { \pgfpoint \pgf@x \l_@@_y_final_dim } + \pgfusepathqstroke + } + } + } +% \end{macrocode} +% +% \medskip +% Now, we draw the vertical rules specified in the key |vlines| of |\SubMatrix|. +% The last argument of |\int_step_inline:nn| or |\clist_map_inline:Nn| is given +% by curryfication. +% \begin{macrocode} + \tl_if_eq:NnTF \l_@@_submatrix_vlines_clist { all } + { \int_step_inline:nn { \l_tmpd_tl - \l_tmpb_tl } } + { \clist_map_inline:Nn \l_@@_submatrix_vlines_clist } + { + \bool_lazy_and:nnTF + { \int_compare_p:nNn { ##1 } > 0 } + { \int_compare_p:nNn { ##1 } < { \l_tmpd_tl - \l_tmpb_tl + 1 } } + { + \@@_qpoint:n { col - \int_eval:n { ##1 + \l_tmpb_tl } } + \pgfpathmoveto { \pgfpoint \pgf@x \l_@@_y_initial_dim } + \pgfpathlineto { \pgfpoint \pgf@x \l_@@_y_final_dim } + \pgfusepathqstroke + } + { \@@_error:nnn { Wrong~line~in~SubMatrix } { vertical } { ##1 } } + } +% \end{macrocode} +% +% \medskip +% Now, we draw the horizontal rules specified in the key |hlines| of +% |\SubMatrix|. +% The last argument of |\int_step_inline:nn| or |\clist_map_inline:Nn| is given +% by curryfication. +% \begin{macrocode} + \tl_if_eq:NnTF \l_@@_submatrix_hlines_clist { all } + { \int_step_inline:nn { \l_tmpc_tl - \l_tmpa_tl } } + { \clist_map_inline:Nn \l_@@_submatrix_hlines_clist } + { + \bool_lazy_and:nnTF + { \int_compare_p:nNn { ##1 } > 0 } + { \int_compare_p:nNn { ##1 } < { \l_tmpc_tl - \l_tmpa_tl + 1 } } + { + \@@_qpoint:n { row - \int_eval:n { ##1 + \l_tmpa_tl } } +% \end{macrocode} +% We use a group to protect |\l_tmpa_dim| and |\l_tmpb_dim|. +% \begin{macrocode} + \group_begin: +% \end{macrocode} +% We compute in |\l_tmpa_dim| the $x$-value of the left end of the rule. +% \begin{macrocode} + \dim_set:Nn \l_tmpa_dim + { \l_@@_x_initial_dim - \l_@@_submatrix_left_xshift_dim } + \str_case:nn { #1 } + { + ( { \dim_sub:Nn \l_tmpa_dim { 0.9 mm } } + [ { \dim_sub:Nn \l_tmpa_dim { 0.2 mm } } + \{ { \dim_sub:Nn \l_tmpa_dim { 0.9 mm } } + } + \pgfpathmoveto { \pgfpoint \l_tmpa_dim \pgf@y } +% \end{macrocode} +% We compute in |\l_tmpb_dim| the $x$-value of the right end of the rule. +% \begin{macrocode} + \dim_set:Nn \l_tmpb_dim + { \l_@@_x_final_dim + \l_@@_submatrix_right_xshift_dim } + \str_case:nn { #4 } + { + ) { \dim_add:Nn \l_tmpb_dim { 0.9 mm } } + ] { \dim_add:Nn \l_tmpb_dim { 0.2 mm } } + \} { \dim_add:Nn \l_tmpb_dim { 0.9 mm } } + } + \pgfpathlineto { \pgfpoint \l_tmpb_dim \pgf@y } + \pgfusepathqstroke + \group_end: + } + { \@@_error:nnn { Wrong~line~in~SubMatrix } { horizontal } { ##1 } } + } +% \end{macrocode} +% % \medskip % If the key |name| has been used for the command |\SubMatrix|, we create a PGF % node with that name for the submatrix (this node does not take into account @@ -14304,7 +14459,9 @@ version 2005/12/01 or later. \l_@@_x_initial_dim \l_@@_y_initial_dim \l_@@_x_final_dim \l_@@_y_final_dim } + \group_end: % \end{macrocode} +% The group was for |\CT@arc@| (the color of the rules). % % \medskip % Now, we deal with the left delimiter. Of course, the environment @@ -14405,6 +14562,9 @@ version 2005/12/01 or later. } % \end{macrocode} % +% +% +% % \bigskip % \subsection*{We process the options at package loading} % @@ -14420,7 +14580,6 @@ version 2005/12/01 or later. % instruction is executed. % % \medskip -%% \medskip % The boolean |\g_@@_footnotehyper_bool| will indicate if the option % |footnotehyper| is used. % \begin{macrocode} @@ -14692,18 +14851,18 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} -\@@_msg_new:nn { Unknown~option~for~xdots } +\@@_msg_new:nn { Unknown~key~for~xdots } { - As~for~now~there~is~only~three~key~available~here:~'color',~'line-style'~ + As~for~now,~there~is~only~three~key~available~here:~'color',~'line-style'~ and~'shorten'~(and~you~try~to~use~'\l_keys_key_str').~If~you~go~on,~ this~key~will~be~ignored. } % \end{macrocode} % % \begin{macrocode} -\@@_msg_new:nn { Unknown~option~for~rowcolors } +\@@_msg_new:nn { Unknown~key~for~rowcolors } { - As~for~now~there~is~only~two~keys~available~here:~'cols'~and~'respect-blocks'~ + As~for~now,~there~is~only~two~keys~available~here:~'cols'~and~'respect-blocks'~ (and~you~try~to~use~'\l_keys_key_str').~If~you~go~on,~ this~key~will~be~ignored. } @@ -14714,8 +14873,8 @@ version 2005/12/01 or later. { The~key~'color'~for~the~command~\token_to_str:N \Block\ is~deprecated:~you~should~use~'fill'~instead.\\ - You~can~go~on~for~this~time~but~remember~that~that~key~ - will~be~deleted~in~a~future~version. + This~error~is~fatal. + } % \end{macrocode} % @@ -14782,6 +14941,15 @@ version 2005/12/01 or later. If~you~go~on,~this~key~will~be~ignored. } % \end{macrocode} +% +% \begin{macrocode} +\@@_msg_new:nn { Wrong~line~in~SubMatrix } + { + You~try~to~draw~a~#1~line~of~number~'#2'~in~a~ + \token_to_str:N \SubMatrix\ of~your~\@@_full_name_env:\ but~that~ + number~is~not~valid.~If~you~go~on,~it~will~be~ignored. + } +% \end{macrocode} % % \begin{macrocode} \@@_msg_new:nn { empty~environment } @@ -14798,7 +14966,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} -\@@_msg_new:nn { unknown~cell~for~line~in~code-after } +\@@_msg_new:nn { unknown~cell~for~line~in~CodeAfter } { Your~command~\token_to_str:N\line\{#1\}\{#2\}~in~the~'code-after'~ can't~be~executed~because~a~cell~doesn't~exist.\\ @@ -14947,7 +15115,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} -\@@_msg_new:nn { Bad~value~for~letter~for~dotted~lines } +\@@_msg_new:nn { One~letter~allowed } { The~value~of~key~'\l_keys_key_str'~must~be~of~length~1.\\ If~you~go~on,~it~will~be~ignored. @@ -14978,7 +15146,8 @@ version 2005/12/01 or later. } { The~available~keys~are~(in~alphabetic~order):~ - delimiters-color,~ + delimiters/color,~ + rules~(with~the~subkeys~'color'~and~'width'),~ sub-matrix~(several~subkeys)~ and~xdots~(several~subkeys).~ The~latter~is~for~the~command~\token_to_str:N \line. @@ -14986,12 +15155,25 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} -\@@_msg_new:nn { Unknown~key~for~SubMatrix } +\@@_msg_new:nnn { Unknown~key~for~SubMatrix } { The~key~'\l_keys_key_str'~is~unknown.\\ - The~only~keys~available~here~are~'delimiters-color',~'extra-height',~ - 'left-xshift',~'name',~'right-xshift',~'slim'~and~'xshift'.\\ If~you~go~on,~this~key~will~be~ignored. \\ + For~a~list~of~the~available~keys~in~\token_to_str:N + \SubMatrix,~type~H~<return>. + } + { + The~available~keys~are~(in~alphabetic~order):~ + 'delimiters/color',~ + 'extra-height',~ + 'hlines',~ + 'left-xshift',~ + 'name',~ + 'right-xshift',~ + 'rules'~(with~the~subkeys~'color'~and~'width'),~ + 'slim',~ + 'vlines'~and~'xshift'~(which~set~both~'left-xshift'~ + and~'right-xshift').\\ } % \end{macrocode} % @@ -15037,7 +15219,7 @@ version 2005/12/01 or later. create-extra-nodes,~ create-medium-nodes,~ create-large-nodes,~ - delimiters-color,~ + delimiters/color,~ end-of-row,~ first-col,~ first-row,~ @@ -15054,6 +15236,7 @@ version 2005/12/01 or later. renew-dots,~ renew-matrix,~ right-margin,~ + rules~(with~the~subkeys~'color'~and~'width'),~ small,~ sub-matrix~(several~subkeys), vlines,~ @@ -15087,7 +15270,7 @@ version 2005/12/01 or later. create-extra-nodes,~ create-medium-nodes,~ create-large-nodes,~ - delimiters-color,~ + delimiters/color,~ extra-left-margin,~ extra-right-margin,~ first-col,~ @@ -15105,8 +15288,7 @@ version 2005/12/01 or later. nullify-dots,~ renew-dots,~ right-margin,~ - rules/color,~ - rules/width,~ + rules~(with~the~subkeys~'color'~and~'width'),~ small,~ t,~ vlines,~ @@ -15146,7 +15328,7 @@ version 2005/12/01 or later. create-extra-nodes,~ create-medium-nodes,~ create-large-nodes,~ - delimiters-color,~ + delimiters/color,~ extra-left-margin,~ extra-right-margin,~ first-col,~ @@ -15164,8 +15346,7 @@ version 2005/12/01 or later. r,~ renew-dots,~ right-margin,~ - rules/color,~ - rules/width,~ + rules~(with~the~subkeys~'color'~and~'width'),~ small,~ t,~ vlines,~ @@ -15218,8 +15399,7 @@ version 2005/12/01 or later. nullify-dots,~ renew-dots,~ right-margin,~ - rules/color,~ - rules/width,~ + rules~(with~the~subkeys~'color'~and~'width'),~ t,~ vlines,~ xdots/color,~ @@ -15523,7 +15703,7 @@ version 2005/12/01 or later. % % The option |dotted-lines-margin| has been renamed in |xdots/shorten| and the % options |xdots/color| and |xdots/line-style| have been added for a complete -% customization of the dotted lines. +% customisation of the dotted lines. % % In the environments without preamble (|{NiceMatrix}|, |{pNiceMatrix}|, etc.), % it's possible to use the options |l| (=|L|) or |r| (=|R|) to specify the type @@ -15615,8 +15795,8 @@ version 2005/12/01 or later. % % The variable |\g_nicematrix_code_before_tl| is now public. % -% The key |baseline| can take in as value of the form \textsl{line-i} to align -% the |\hline| in the row \textsl{i}. +% The key |baseline| may take in as value an expression of the form +% \textsl{line-i} to align the |\hline| in the row \textsl{i}. % % The key |hvlines-except-corners| may take in as value a list of corners (eg: NW,SE). % @@ -15679,6 +15859,12 @@ version 2005/12/01 or later. % A (non fatal) error is raised when the key |transparent|, which is % deprecated, is used. % +% \subsection*{Changes between versions 5.10 and 5.11} +% +% It's now possible, in the |code-before| and in the |\CodeAfter|, to use the +% syntax \verb+|(i-|j)+ for the Tikz node at the intersection of the (potential) +% horizontal rule number~$i$ and the (potential) vertical rule number~$j$. +% % \PrintIndex % % \tableofcontents |