summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-03-23 22:29:11 +0000
committerKarl Berry <karl@freefriends.org>2021-03-23 22:29:11 +0000
commit02d9d13fd85bb113f1506ff9c25d8624229ce155 (patch)
treeee0de6ef6468d14a0c89280e1d81326686d8cf2f /Master/texmf-dist/source
parent038bb9e27529993bc413ba08aba815278fab7373 (diff)
nicematrix (23mar21)
git-svn-id: svn://tug.org/texlive/trunk@58667 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r--Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx531
1 files changed, 424 insertions, 107 deletions
diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx
index a84069b7c80..38269b145ca 100644
--- a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx
+++ b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx
@@ -15,8 +15,8 @@
%
% \fi
% \iffalse
-\def\myfileversion{5.12}
-\def\myfiledate{2021/03/10}
+\def\myfileversion{5.13}
+\def\myfiledate{2021/03/23}
%
%
%<*batchfile>
@@ -346,7 +346,7 @@ version 2005/12/01 or later.
% immediately after an |\item| of list. One should remark that the presence of a
% |\hline| at the beginning of the array doesn't prevent the alignment of the
% baseline with the baseline of the first row (with |{tabular}| or |{array}| of
-% \pkg{array}, one must use |\firsthline|.
+% \pkg{array}, one must use |\firsthline|).
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
@@ -566,6 +566,10 @@ version 2005/12/01 or later.
% |fill|) with a radius equal to the value of that key (the default value is
% 4~pt\footnote{This value is the initial value of the \emph{rounded corners} of
% Tikz.}).
+% \item \colorbox{yellow!50}{\textbf{New 5.13}}\enskip the key |borders| provides
+% the ability to draw only some borders of the blocks; the value of that key is
+% a (comma-separated) list of elements covered by |left|, |right|, |top| and
+% |bottom|.
% \end{itemize}
%
% \interitem
@@ -780,7 +784,8 @@ version 2005/12/01 or later.
%
%
% \bigskip
-% However, the vertical rules are not drawn in the blocks.
+% However, the vertical rules are not drawn in the blocks (created by |\Block|:
+% cf.~p.~\pageref{Block}).
%
% \bigskip
% If you use \pkg{booktabs} (which provides |\toprule|, |\midrule|,
@@ -920,6 +925,18 @@ version 2005/12/01 or later.
% he should consider the command |\OnlyMainNiceMatrix| described on
% page~\pageref{OnlyMainNiceMatrix}.
%
+%
+% \subsection{The command \textbackslash Hline}
+%
+% We have said that the vertical rules specified by a symbol ``\verb+|+'' in the
+% preamble (for the environments with preamble, of course) are not drawn in the
+% blocks.\footnote{Those blocks are those created by the commands \verb|\Block|
+% and |\multicolumn| but also those implicitely determined by the continuous
+% dotted lines (created by \verb|\Cdots|, etc.).}
+%
+% \smallskip
+% \colorbox{yellow!50}{\textbf{New 5.13}}\enskip In order to have horizontal
+% rules with the same behaviour, \pkg{nicematrix} provides the command |\Hline|.
%
%
% \subsection{The keys hlines and vlines}
@@ -928,7 +945,7 @@ version 2005/12/01 or later.
% the vertical rules excepted in the blocks, created by |\Block| and the virtual
% blocks determined by dotted lines: |\Cdots|, |\Vdots|, etc.. In fact, in the
% environments with delimiters (as |{pNiceMatrix}| or |{bNiceArray}|) the
-% exteriors rules are not drawn (as expected).
+% exterior rules are not drawn (as expected).
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm]
@@ -945,6 +962,11 @@ version 2005/12/01 or later.
% \end{pNiceMatrix}$
%
%
+% \bigskip
+% \colorbox{yellow!50}{\textbf{New 5.13}}\enskip It's possible to provide to the
+% key |vlines| a (comma-separated) list of numbers, which are the numbers of the
+% vertical rules to draw. The key |hlines| has a similar behaviour.
+%
%
% \subsection{The key hvlines}
% \label{hvlines}
@@ -978,6 +1000,8 @@ version 2005/12/01 or later.
%
% \subsection{The key hvlines-except-corners}
%
+% \label{except-corners}
+%
% The key |hvlines-except-corners| draws all the horizontal and vertical rules,
% excepted in the blocks (and the virtual blocks determined by dotted lines) and
% excepted in the empty corners.
@@ -1041,6 +1065,10 @@ version 2005/12/01 or later.
% 1&5&10&10&5&1
% \end{NiceTabular}
%
+% \bigskip
+% $\triangleright$ The concept of corner is also used by the command
+% |\arraycolor| in the |\CodeBefore| which takes in as option a key
+% |except-corners|: cf.~p.~\pageref{arraycolor}.
%
% \subsection{The command \textbackslash diagbox}
%
@@ -1119,14 +1147,16 @@ 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|. Thus released, the letter ``|:|'' can be used otherwise
-% (for example by the package \pkg{arydshln}).
+% (for example by the package \pkg{arydshln}\footnote{However, one should remark
+% that the package \pkg{arydshln} is not fully compatible with
+% \pkg{nicematrix}.}).
%
% \bigskip
-% \emph{Remark} : In the package \pkg{array} (on which the package
+% \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|: cf
-% p.~\pageref{remark-cline}}. In \pkg{nicematrix}, the dotted lines drawn by
+% or wider by a quantity equal to the width of the rule\footnote{In fact, with
+% \pkg{array}, this is true only for |\hline| and ``"|"'' but not for |\cline|:
+% cf p.~\pageref{remark-cline}}. In \pkg{nicematrix}, the dotted lines drawn by
% |\hdottedline| and ``|:|'' do likewise.
%
%
@@ -1147,7 +1177,7 @@ version 2005/12/01 or later.
% However, there is two drawbacks:
% \begin{itemize}
% \item The package \pkg{colortbl} patches \pkg{array}, leading to some
-% incompatibilities (for example with the command |\hdotsfor|).
+% incompatibilities (for instance with the command |\hdotsfor|).
%
% \item The package \pkg{colortbl} constructs the array row by row, alterning
% colored rectangles, rules and contents of the cells. The resulting
@@ -1171,7 +1201,7 @@ version 2005/12/01 or later.
% The package \pkg{nicematrix} provides tools to avoid those problems.
% \end{itemize}
%
-% \subsection{The tools of nicematrix in the code-before}
+% \subsection{The tools of nicematrix in the \textbackslash CodeBefore}
%
% The package \pkg{nicematrix} provides some tools (independent of
% \pkg{colortbl}) to draw the colored panels first, and, then, the content
@@ -1198,10 +1228,11 @@ version 2005/12/01 or later.
% \end{Verbatim}
%
% New commands are available in that |\CodeBefore|: |\cellcolor|,
-% |\rectanglecolor|, |\rowcolor|, |\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}.}
+% |\rectanglecolor|, |\rowcolor|, |\columncolor|, |\rowcolors|,
+% |\chessboardcolors| and |arraycolor|.\footnote{Remark that, in the
+% \verb|\CodeBefore|, PGF/Tikz nodes of the form ``\verb+(i-|j)+'' are also
+% available to indicate the position to the potential rules:
+% cf.~p.~\pageref{nodes-i}.}
% \label{code-before}
%
% \medskip
@@ -1224,7 +1255,7 @@ version 2005/12/01 or later.
% \begin{BVerbatim}[boxwidth=10cm,baseline=c]
% \begin{NiceTabular}{|c|c|c|}
% \CodeBefore
-% ~emphase#\cellcolor{red!15}{3-1,2-2,1-3}@
+% ~emphase#\cellcolor[HTML]{FFFF88}{3-1,2-2,1-3}@
% \Body
% \hline
% a & b & c \\ \hline
@@ -1234,7 +1265,7 @@ version 2005/12/01 or later.
% \end{BVerbatim}
% \begin{NiceTabular}{|c|c|c|}
% \CodeBefore
-% \cellcolor{red!15}{3-1,2-2,1-3}
+% \cellcolor[HTML]{FFFF88}{3-1,2-2,1-3}
% \Body
% \hline
% a & b & c \\ \hline
@@ -1436,7 +1467,7 @@ version 2005/12/01 or later.
% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
% $\begin{pNiceMatrix}[r,margin]
% \CodeBefore
-% ~emphase#code-before=\chessboardcolors{red!15}{blue!15}@
+% ~emphase#\chessboardcolors{red!15}{blue!15}@
% \Body
% 1 & -1 & 1 \\
% -1 & 1 & -1 \\
@@ -1454,7 +1485,47 @@ version 2005/12/01 or later.
% \end{scope}
%
% \medskip
-% We have used the key |r| which aligns all the columns rightwards (cf. p.~\pageref{key-R}).
+% We have used the key |r| which aligns all the columns rightwards (cf.
+% p.~\pageref{key-R}).
+%
+%
+% \item \colorbox{yellow!50}{\textbf{New 5.13}}\enskip
+% The command |\arraycolor| takes in as mandatory argument a color and color
+% the whole tabular with that color (excepted the potential exterior rows and
+% columns: cf.~p.~\pageref{exterior}). This command is useful thanks to its key
+% |except-corners| (in the third argument, which is a optional argument between
+% square brackets). The definition of these ``corners'' has been given
+% p.~\pageref{except-corners} when we have presented the key
+% |hvlines-except-corners|.
+%
+% \label{arraycolor}
+%
+%
+% \medskip
+% \begin{BVerbatim}[boxwidth=10cm,baseline=c]
+% \begin{NiceTabular}{*{6}{c}}[cell-space-top-limit=3pt]
+% \CodeBefore
+% ~emphase#\arraycolor{blue!10}[except-corners=NE]@
+% \Body
+% 1\\
+% 1&1\\
+% 1&2&1\\
+% 1&3&3&1\\
+% 1&4&6&4&1\\
+% 1&5&10&10&5&1
+% \end{NiceTabular}
+% \end{BVerbatim}
+% \begin{NiceTabular}{*{6}{c}}[cell-space-top-limit=3pt]
+% \CodeBefore
+% \arraycolor{blue!10}[except-corners=NE]
+% \Body
+% 1\\
+% 1&1\\
+% 1&2&1\\
+% 1&3&3&1\\
+% 1&4&6&4&1\\
+% 1&5&10&10&5&1
+% \end{NiceTabular}
% \end{itemize}
%
%
@@ -1695,10 +1766,6 @@ version 2005/12/01 or later.
% \end{array}$
% \end{NiceMatrixBlock}
%
-% \medskip
-% \textbf{Several compilations may be necessary to achieve the job.}
-%
-%
%
% \bigskip
% \section{The exterior rows and columns}
@@ -2405,7 +2472,6 @@ version 2005/12/01 or later.
%
% \label{sub-matrix}
%
-% \colorbox{yellow!30}{New 5.10}\enskip
% 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:
@@ -2469,33 +2535,24 @@ version 2005/12/01 or later.
% position of the delimiters is computed by using only the contents of the cells
% of the submatrix whereas, in the general case, the position is computed by
% taking into account the cells of the whole columns implied in the submatrix
-% (see example below).
-% \end{itemize}
-%
-% These keys are also available in |\NiceMatrixOptions|, at the level of the
-% environments of \pkg{nicematrix} or as option of the command |\CodeAfter| with
-% the prefix |sub-matrix| which means that their names are therefore
-% |sub-matrix/left-xshift|, |sub-matrix/right-xshift|, |sub-matrix/xshift|, etc.
-%
-% \bigskip
-% \medskip
-% \colorbox{yellow!50}{\textbf{New 5.12}}\enskip There is also the following
-% keys, which are available only for an individual command |\SubMatrix|:
-%
-% \begin{itemize}
+% (see example below). ;
% \item |vlines| contents a list of numbers of vertical rules that will be drawn in
% the sub-matrix (if this key is used without value, all the vertical rules of
% the sub-matrix are drawn);
-%
% \item |hlines| is similar to |vlines| but for the horizontal rules;
-%
% \item |hvlines|, which must be used without value, draws all the vertical and
% horizontal rules.
% \end{itemize}
% One should remark that these keys add their rules after the construction of
% the main matrix: no space is added between the rows and the columns of the
% array for theses rules.
-%
+%
+% \bigskip
+% All these keys are also available in |\NiceMatrixOptions|, at the level of the
+% environments of \pkg{nicematrix} or as option of the command |\CodeAfter| with
+% the prefix |sub-matrix| which means that their names are therefore
+% |sub-matrix/left-xshift|, |sub-matrix/right-xshift|, |sub-matrix/xshift|, etc.
+%
% \bigskip
% \begin{scope}
% \hfuzz=12cm
@@ -3538,6 +3595,9 @@ version 2005/12/01 or later.
% 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|.
+%
+% \colorbox{yellow!50}{\textbf{New 5.13}}\enskip The last node has also an alias called
+% |last|.
% \begin{center}
% \begin{NiceTabular}{ccc}[hvlines,rules/width=1pt,rules/color=gray]
% rose & tulipe & lys \\
@@ -3599,7 +3659,6 @@ version 2005/12/01 or later.
%
% \label{node-sub-matrix}
%
-% \colorbox{yellow!30}{New 5.10}\enskip
% The command |\SubMatrix| available in the |\CodeAfter| has been described
% p.~\pageref{sub-matrix}.
%
@@ -3892,7 +3951,7 @@ version 2005/12/01 or later.
% \pkg{amsmath} prefer to delete these spaces with explicit instructions
% |\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}.
+% modified and may appear too long, in particular when using square brackets.}.
% 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
@@ -4349,11 +4408,11 @@ version 2005/12/01 or later.
% 0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm]
% 12 & -8 &7 &5 & 3 \\
% 0 & 64 &-41 & 1 & 19 \\
-% ~emphase#\CodeAfter@
-% ~emphase# \SubMatrix({1-1}{4-5})[vlines=4]@
-% ~emphase# \SubMatrix({5-1}{8-5})[vlines=4]@
-% ~emphase# \SubMatrix({9-1}{11-5})[vlines=4]@
-% ~emphase# \SubMatrix({12-1}{13-5})[vlines=4]@
+% ~emphase#\CodeAfter [sub-matrix/vlines=4]@
+% ~emphase# \SubMatrix({1-1}{4-5})@
+% ~emphase# \SubMatrix({5-1}{8-5})@
+% ~emphase# \SubMatrix({9-1}{11-5})@
+% ~emphase# \SubMatrix({12-1}{13-5})@
% \end{NiceMatrix}\]
% \end{Verbatim}
%
@@ -4374,11 +4433,11 @@ version 2005/12/01 or later.
% 0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm]
% 12 & -8 &7 &5 & 3 \\
% 0 & 64 &-41 & 1 & 19 \\
-% \CodeAfter
-% \SubMatrix({1-1}{4-5})[vlines=4]
-% \SubMatrix({5-1}{8-5})[vlines=4]
-% \SubMatrix({9-1}{11-5})[vlines=4]
-% \SubMatrix({12-1}{13-5})[vlines=4]
+% \CodeAfter [sub-matrix/vlines=4]
+% \SubMatrix({1-1}{4-5})
+% \SubMatrix({5-1}{8-5})
+% \SubMatrix({9-1}{11-5})
+% \SubMatrix({12-1}{13-5})
% \end{NiceMatrix}\]
% \end{scope}
%
@@ -5606,11 +5665,12 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \medskip
-% The following parameters correspond to the keys |fill|, |draw| and
+% The following parameters correspond to the keys |fill|, |draw|, |borders| and
% |rounded-corners| of the command |\Block|.
% \begin{macrocode}
\tl_new:N \l_@@_fill_tl
\tl_new:N \l_@@_draw_tl
+\clist_new:N \l_@@_borders_clist
\dim_new:N \l_@@_rounded_corners_dim
% \end{macrocode}
%
@@ -5659,6 +5719,8 @@ version 2005/12/01 or later.
\dim_new:N \l_@@_submatrix_right_xshift_dim
\clist_new:N \l_@@_hlines_clist
\clist_new:N \l_@@_vlines_clist
+\clist_new:N \l_@@_submatrix_hlines_clist
+\clist_new:N \l_@@_submatrix_vlines_clist
% \end{macrocode}
%
%
@@ -7497,7 +7559,8 @@ version 2005/12/01 or later.
}
\endpgfpicture
% \end{macrocode}
-% Now, you create the diagonal nodes by using the |row| nodes and the |col| nodes.
+% Now, you create the diagonal nodes by using the |row| nodes and the |col|
+% nodes. If the engine is |xetex| or |luatex| we also create the ``½ nodes''.
% \begin{macrocode}
\@@_create_diag_nodes:
% \end{macrocode}
@@ -7519,6 +7582,7 @@ version 2005/12/01 or later.
\cs_set_eq:NN \roundedrectanglecolor \@@_roundedrectanglecolor
\cs_set_eq:NN \rowcolor \@@_rowcolor
\cs_set_eq:NN \rowcolors \@@_rowcolors
+ \cs_set_eq:NN \arraycolor \@@_arraycolor
\cs_set_eq:NN \columncolor \@@_columncolor
\cs_set_eq:NN \chessboardcolors \@@_chessboardcolors
\cs_set_eq:NN \SubMatrix \@@_SubMatrix_in_code_before
@@ -7527,7 +7591,7 @@ version 2005/12/01 or later.
% by the user between instructions in the |code-before|.
% \begin{macrocode}
\bool_if:NT \l_@@_NiceTabular_bool \c_math_toggle_token
- \seq_clear_new:N \l_@@_colors_seq
+ \seq_gclear_new:N \g_@@_colors_seq
% \end{macrocode}
% Here is the |\CodeBefore|. As of now, the keys that may be provided to the
% keyword |\CodeBefore| are the same as keys that may be provided to
@@ -7699,9 +7763,10 @@ version 2005/12/01 or later.
% |\CodeBefore|). By definition, the |\CodeBefore| must be executed before the
% body of the array...
% \begin{macrocode}
- \@@_pre_array:
+ \@@_pre_array:
}
% \end{macrocode}
+%
%
% \bigskip
% \subsection*{The environment \{NiceArrayWithDelims\}}
@@ -9511,15 +9576,10 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \medskip
+% Now, you create the diagonal nodes by using the |row| nodes and the |col|
+% nodes. If the engine is |xetex| or |luatex| we also create the ``½ nodes''.
% \begin{macrocode}
- \@@_create_diag_nodes:
- \str_if_empty:NF \l_@@_name_str
- {
- \pgfpicture
- \pgfrememberpicturepositiononpagetrue
- \pgfnodealias { \l_@@_name_str - ##1 } { \@@_env: - ##1 }
- \endpgfpicture
- }
+ \@@_create_diag_nodes:
% \end{macrocode}
%
% By default, the diagonal lines will be parallelized\footnote{It's possible to
@@ -9584,7 +9644,9 @@ version 2005/12/01 or later.
%
% \bigskip
% The following computes the ``corners'' (made up of empty cells) but if there
-% is no corner to compute, it will do nothing.
+% is no corner to compute, it will do nothing. The corners are computed
+% in |\l_@@_empty_corner_cells_seq| which will contain all the empty cells (and
+% not in a block) considered in the corners of the array.
% \begin{macrocode}
\@@_compute_corners:
% \end{macrocode}
@@ -9804,18 +9866,50 @@ 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:
{
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
\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 }
+ }
+ \pgfnodealias
+ { \@@_env: - last }
+ { \@@_env: - \int_eval:n { \int_max:nn \c@iRow \c@jCol + 1 } }
+ \endpgfpicture
+ }
+% \end{macrocode}
+%
+% \bigskip
+% As for now, the ½ nodes are not documented and they are created only in the
+% native \textsc{utf8} engines, that is to say XeLaTeX and LuaLaTeX.
+% \begin{macrocode}
+\bool_if:nT
+ { \sys_if_engine_xetex_p: || \sys_if_engine_luatex_p: }
+ { \tl_put_right:Nn \@@_create_diag_nodes: \@@_create_half_nodes: }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_create_half_nodes:
+ {
+ \int_step_inline:nn { \int_max:nn \c@iRow \c@jCol }
+ {
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgfcoordinate { \@@_env: - ##1 ½ }
+ {
+ \pgfpointscale { 0.5 }
+ {
+ \pgfpointadd
+ { \@@_qpoint:n { ##1 } }
+ { \@@_qpoint:n { \int_eval:n { ##1 + 1 } } }
+ }
+ }
\endpgfpicture
}
}
@@ -11564,13 +11658,13 @@ version 2005/12/01 or later.
% the execution of the |code-before|) don't directly draw the corresponding
% rectangles. Instead, they store their instructions color by color:
% \begin{itemize}
-% \item A sequence |\l_@@_colors_seq| will be built containing all the colors
+% \item A sequence |\g_@@_colors_seq| will be built containing all the colors
% used by at least one of these instructions. Each \emph{color} may be prefixed
% by it color model (eg: |[gray]{0.5}|).
-% \item For the color whose index in |\l_@@_colors_seq| is equal to~$i$, a list of
+% \item For the color whose index in |\g_@@_colors_seq| is equal to~$i$, a list of
% instructions which use that color will be constructed in the token list
-% |\l_@@_color_|$i$|_tl|. In that token list, the instructions will
-% |\@@_rowcolor:n|, |\@@_columncolor:n| and |\@@_rectanglecolor:nn|
+% |\g_@@_color_|$i$|_tl|. In that token list, the instructions will be written
+% using |\@@_rowcolor:n|, |\@@_columncolor:n| and |\@@_rectanglecolor:nn|
% (corresponding of |\@@_rowcolor|, |\@@_columncolor| and |\@@_rectanglecolor|).
% \end{itemize}
%
@@ -11578,8 +11672,11 @@ version 2005/12/01 or later.
% bigskip
% |#1| is the color and |#2| is an instruction using that color. Despite its
% name, the command |\@@_add_to_color_seq| doesn't only add a color to
-% |\l_@@_colors_seq|: it also updates the corresponding token list
-% |\l_@@_color_|$i$|_tl|.
+% |\g_@@_colors_seq|: it also updates the corresponding token list
+% |\g_@@_color_|$i$|_tl|. We add in a global way because the final user may use
+% the instructions such as |\cellcolor| in a loop of \pkg{pgffor} in the
+% |\CodeBefore| (and we recall that a loop of \pkg{pgffor} is encapsulated in a
+% group).
% \begin{macrocode}
\cs_new_protected:Npn \@@_add_to_colors_seq:nn #1 #2
{
@@ -11589,21 +11686,21 @@ version 2005/12/01 or later.
% |\l_tmpa_int| will remain equal to $0$.
% \begin{macrocode}
\int_zero:N \l_tmpa_int
- \seq_map_indexed_inline:Nn \l_@@_colors_seq
+ \seq_map_indexed_inline:Nn \g_@@_colors_seq
{ \tl_if_eq:nnT { #1 } { ##2 } { \int_set:Nn \l_tmpa_int { ##1 } } }
\int_compare:nNnTF \l_tmpa_int = \c_zero_int
% \end{macrocode}
% First, the case where the color is a \emph{new} color (not in the sequence).
% \begin{macrocode}
{
- \seq_put_right:Nn \l_@@_colors_seq { #1 }
- \tl_set:cn { l_@@_color _ \seq_count:N \l_@@_colors_seq _ tl } { #2 }
+ \seq_gput_right:Nn \g_@@_colors_seq { #1 }
+ \tl_gset:cx { g_@@_color _ \seq_count:N \g_@@_colors_seq _ tl } { #2 }
}
% \end{macrocode}
% Now, the case where the color is \emph{not} a new color (the color is in the
% sequence at the position |\l_tmpa_int|).
% \begin{macrocode}
- { \tl_put_right:cn { l_@@_color _ \int_use:N \l_tmpa_int _tl } { #2 } }
+ { \tl_gput_right:cx { g_@@_color _ \int_use:N \l_tmpa_int _tl } { #2 } }
}
% \end{macrocode}
%
@@ -11620,10 +11717,11 @@ version 2005/12/01 or later.
{
\pgfpicture
\pgf@relevantforpicturesizefalse
- \seq_map_indexed_inline:Nn \l_@@_colors_seq
+ \seq_map_indexed_inline:Nn \g_@@_colors_seq
{
\color ##2
- \use:c { l_@@_color _ ##1 _tl }
+ \use:c { g_@@_color _ ##1 _tl }
+ \tl_gclear:c { g_@@_color _ ##1 _tl }
\pgfusepath { fill }
}
\endpgfpicture
@@ -11771,7 +11869,87 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+% \bigskip
+% \begin{macrocode}
+\keys_define:nn { NiceMatrix / arraycolor }
+ {
+ except-corners .clist_set:N = \l_tmpa_clist ,
+ except-corners .default:n = { NW , SW , NE , SE }
+ }
+% \end{macrocode}
+%
+% \bigskip
+% The command |\@@_arraycolor| (linked to |\arraycolor| at the beginning of
+% the |\CodeBefore|) will color the whole tabular (excepted the potential
+% exterior rows and columns). The third argument is a optional argument which a
+% list of pairs key-value. As for now, there is only one key: |except-corners|.
+% When that key is used, the cells in the corners are not colored.
+% \begin{macrocode}
+\NewDocumentCommand \@@_arraycolor { O { } m O { } }
+ {
+ \keys_set:nn { NiceMatrix / arraycolor } { #3 }
+% \end{macrocode}
+% If the key |except-corners| is not used, it's easy: we only have a rectangle
+% fo fill.
+% \begin{macrocode}
+ \clist_if_empty:NTF \l_tmpa_clist
+ {
+ \@@_rectanglecolor [ #1 ] { #2 }
+ { 1 - 1 } { \int_use:N \c@iRow - \int_use:N \c@jCol }
+ }
+% \end{macrocode}
+% The interesting case is when the key |except-corners| is used. In that case,
+% we can't fill now the tabular because we don't know the list of the cells
+% of the corners. That's why we postpone the treatment in the |\CodeAfter|.
+% \begin{macrocode}
+ {
+ \tl_gput_left:Nx \g_@@_internal_code_after_tl
+ {
+ \@@_arraycolor_code_after:nnn
+ { #1 }
+ { \exp_not:n { #2 } }
+ { \l_tmpa_clist }
+ }
+ }
+ }
+% \end{macrocode}
+%
+% \bigskip
+% The following command will be used in the |\CodeAfter|. |#1| is the color
+% model, |#2| the color and |#3| the value of the key |except-corners| (a
+% sublist of |{NW,NE,SW,SE}|).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_arraycolor_code_after:nnn #1 #2 #3
+ {
+ \group_begin:
+% \end{macrocode}
+% First, we compute the corners.
+% \begin{macrocode}
+ \clist_set:Nn \l_@@_except_corners_clist { #3 }
+ \@@_compute_corners:
+% \end{macrocode}
+% Now, for each cell of the array (excepted the potential exterior rows and
+% columns) we check whether we have to fill that cell. When we have to fill the
+% cell, we do the job by writing an instruction in the |\CodeBefore| (in fact,
+% the ``|\CodeBefore|'' which will be written on the |aux| file for the next
+% run).
+% \begin{macrocode}
+ \int_step_inline:nn \c@iRow
+ {
+ \int_step_inline:nn \c@jCol
+ {
+ \seq_if_in:NnF \l_@@_empty_corner_cells_seq { ##1 - ####1 }
+ {
+ \tl_gput_left:Nx \g_nicematrix_code_before_tl
+ { \@@_cellcolor [ #1 ] { \exp_not:n { #2 } } { ##1 - ####1 } }
+ }
+ }
+ }
+ \group_end:
+ }
+% \end{macrocode}
%
+%
% \bigskip
% \begin{macrocode}
\keys_define:nn { NiceMatrix / rowcolors }
@@ -13755,6 +13933,8 @@ version 2005/12/01 or later.
rounded-corners .default:n = 4 pt ,
color .code:n = \color { #1 } \tl_set:Nn \l_@@_draw_tl { #1 } ,
color .value_required:n = true ,
+ borders .clist_set:N = \l_@@_borders_clist ,
+ borders .value_required:n = true ,
line-width .dim_set:N = \l_@@_line_width_dim ,
line-width .value_required:n = true ,
l .code:n = \tl_set:Nn \l_@@_pos_of_block_tl l ,
@@ -13843,11 +14023,8 @@ version 2005/12/01 or later.
\keys_set:nn { NiceMatrix / Block / SecondPass } { #5 }
% \end{macrocode}
%
-%
% \begin{macrocode}
- \bool_lazy_or:nnT
- { ! \tl_if_empty_p:N \l_@@_draw_tl }
- { \dim_compare_p:nNn \l_@@_line_width_dim > \c_zero_dim }
+ \tl_if_empty:NF \l_@@_draw_tl
{
\tl_gput_right:Nx \g_nicematrix_code_after_tl
{
@@ -13862,6 +14039,19 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \begin{macrocode}
+ \clist_if_empty:NF \l_@@_borders_clist
+ {
+ \tl_gput_right:Nx \g_nicematrix_code_after_tl
+ {
+ \@@_stroke_borders_block:nnn
+ { \exp_not:n { #5 } }
+ { #1 - #2 }
+ { \int_use:N \l_@@_last_row_int - \int_use:N \l_@@_last_col_int }
+ }
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
\tl_if_empty:NF \l_@@_fill_tl
{
\tl_gput_right:Nx \g_nicematrix_code_before_tl
@@ -14153,7 +14343,7 @@ version 2005/12/01 or later.
% % \bigskip
% The first argument of |\@@_stroke_block:nnn| is a list of options for the
% rectangle that you will stroke. The second argument is the upper-left cell of
-% the block (with, as usual, the syntex $i$|-|$j$) and the third is the last
+% the block (with, as usual, the syntax $i$|-|$j$) and the third is the last
% cell of the block (with the same syntax).
% \begin{macrocode}
\cs_new_protected:Npn \@@_stroke_block:nnn #1 #2 #3
@@ -14204,7 +14394,7 @@ version 2005/12/01 or later.
{ \pgfpoint \l_tmpd_dim \l_tmpa_dim }
\pgfsetlinewidth { 1.1 \l_@@_line_width_dim }
% \end{macrocode}
-% We can't use |\pgfusepathqtroke| because of the key |rounded-corners|.
+% We can't use |\pgfusepathqstroke| because of the key |rounded-corners|.
% \begin{macrocode}
\pgfusepath { stroke }
}
@@ -14217,10 +14407,6 @@ version 2005/12/01 or later.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / BlockStroke }
{
-% \end{macrocode}
-% We will uncomment the following line when we will give to the key |color| of
-% the command |\Block| its new definition.
-% \begin{macrocode}
color .tl_set:N = \l_@@_draw_tl ,
draw .tl_set:N = \l_@@_draw_tl ,
draw .default:n = default ,
@@ -14231,6 +14417,94 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
+% The first argument of |\@@_stroke_borders_block:nnn| is a list of options for
+% the borders that you will stroke. The second argument is the upper-left cell
+% of the block (with, as usual, the syntax $i$|-|$j$) and the third is the last
+% cell of the block (with the same syntax).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_stroke_borders_block:nnn #1 #2 #3
+ {
+ \dim_set_eq:NN \l_@@_line_width_dim \arrayrulewidth
+ \keys_set_known:nn { NiceMatrix / BlockBorders } { #1 }
+ \dim_compare:nNnTF \l_@@_rounded_corners_dim > \c_zero_dim
+ { \@@_error:n { borders~forbidden } }
+ {
+ \clist_map_inline:Nn \l_@@_borders_clist
+ {
+ \clist_if_in:nnF { top , bottom , left , right } { ##1 }
+ { \@@_error:nn { bad~border } { ##1 } }
+ }
+ \@@_cut_on_hyphen:w #2 \q_stop
+ \tl_set_eq:NN \l_tmpc_tl \l_tmpa_tl
+ \tl_set_eq:NN \l_tmpd_tl \l_tmpb_tl
+ \@@_cut_on_hyphen:w #3 \q_stop
+ \tl_set:Nx \l_tmpa_tl { \int_eval:n { \l_tmpa_tl + 1 } }
+ \tl_set:Nx \l_tmpb_tl { \int_eval:n { \l_tmpb_tl + 1 } }
+ \pgfpicture
+ \pgfrememberpicturepositiononpagetrue
+ \pgf@relevantforpicturesizefalse
+ \CT@arc@
+ \pgfsetlinewidth { 1.1 \l_@@_line_width_dim }
+ \clist_if_in:NnT \l_@@_borders_clist { right }
+ { \@@_stroke_vertical:n \l_tmpb_tl }
+ \clist_if_in:NnT \l_@@_borders_clist { left }
+ { \@@_stroke_vertical:n \l_tmpd_tl }
+ \clist_if_in:NnT \l_@@_borders_clist { bottom }
+ { \@@_stroke_horizontal:n \l_tmpa_tl }
+ \clist_if_in:NnT \l_@@_borders_clist { top }
+ { \@@_stroke_horizontal:n \l_tmpc_tl }
+ \endpgfpicture
+ }
+ }
+% \end{macrocode}
+%
+% \medskip
+% The following command is used to stroke the left border and the right border.
+% The argument |#1| is the number of column (in the sense of the |col| node).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_stroke_vertical:n #1
+ {
+ \@@_qpoint:n \l_tmpc_tl
+ \dim_set:Nn \l_tmpb_dim { \pgf@y + 0.5 \l_@@_line_width_dim }
+ \@@_qpoint:n \l_tmpa_tl
+ \dim_set:Nn \l_tmpc_dim { \pgf@y + 0.5 \l_@@_line_width_dim }
+ \@@_qpoint:n { #1 }
+ \pgfpathmoveto { \pgfpoint \pgf@x \l_tmpb_dim }
+ \pgfpathlineto { \pgfpoint \pgf@x \l_tmpc_dim }
+ \pgfusepathqstroke
+ }
+% \end{macrocode}
+%
+% \medskip
+% The following command is used to stroke the top border and the bottom border.
+% The argument |#1| is the number of row (in the sense of the |row| node).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_stroke_horizontal:n #1
+ {
+ \@@_qpoint:n \l_tmpd_tl
+ \clist_if_in:NnTF \l_@@_borders_clist { left }
+ { \dim_set:Nn \l_tmpa_dim { \pgf@x - 0.5 \l_@@_line_width_dim } }
+ { \dim_set:Nn \l_tmpa_dim { \pgf@x + 0.5 \l_@@_line_width_dim } }
+ \@@_qpoint:n \l_tmpb_tl
+ \dim_set:Nn \l_tmpb_dim { \pgf@x + 0.5 \l_@@_line_width_dim }
+ \@@_qpoint:n { #1 }
+ \pgfpathmoveto { \pgfpoint \l_tmpa_dim \pgf@y }
+ \pgfpathlineto { \pgfpoint \l_tmpb_dim \pgf@y }
+ \pgfusepathqstroke
+ }
+% \end{macrocode}
+%
+% \bigskip
+% Here is the set of keys for the command |\@@_stroke_borders_block:nnn|.
+% \begin{macrocode}
+\keys_define:nn { NiceMatrix / BlockBorders }
+ {
+ borders .clist_set:N = \l_@@_borders_clist ,
+ rounded-corners .dim_set:N = \l_@@_rounded_corners_dim ,
+ rounded-corners .default:n = 4 pt ,
+ line-width .dim_set:N = \l_@@_line_width_dim
+ }
+% \end{macrocode}
%
% \subsection*{How to draw the dotted lines transparently}
% \begin{macrocode}
@@ -14456,7 +14730,10 @@ version 2005/12/01 or later.
% square brackets. Here is the corresponding set of keys.
% \begin{macrocode}
\keys_define:nn { NiceMatrix }
- { CodeAfter / rules .inherit:n = NiceMatrix / rules }
+ {
+ CodeAfter / rules .inherit:n = NiceMatrix / rules ,
+ CodeAfter / sub-matrix .inherit:n = NiceMatrix / sub-matrix
+ }
\keys_define:nn { NiceMatrix / CodeAfter }
{
sub-matrix .code:n = \keys_set:nn { NiceMatrix / sub-matrix } { #1 } ,
@@ -14639,11 +14916,21 @@ version 2005/12/01 or later.
delimiters / color .value_required:n = true ,
slim .bool_set:N = \l_@@_submatrix_slim_bool ,
slim .default:n = true ,
+ hlines .clist_set:N = \l_@@_submatrix_hlines_clist ,
+ hlines .default:n = all ,
+ vlines .clist_set:N = \l_@@_submatrix_vlines_clist ,
+ vlines .default:n = all ,
+ hvlines .meta:n = { hlines, vlines } ,
+ hvlines .value_forbidden:n = true ,
}
\keys_define:nn { NiceMatrix }
{
SubMatrix .inherit:n = NiceMatrix / sub-matrix ,
CodeAfter / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,
+ NiceMatrix / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,
+ NiceArray / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,
+ pNiceArray / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,
+ NiceMatrixOptions / sub-matrix .inherit:n = NiceMatrix / sub-matrix ,
}
% \end{macrocode}
%
@@ -14653,9 +14940,9 @@ version 2005/12/01 or later.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / SubMatrix }
{
- hlines .clist_set:N = \l_@@_hlines_clist ,
+ hlines .clist_set:N = \l_@@_submatrix_hlines_clist ,
hlines .default:n = all ,
- vlines .clist_set:N = \l_@@_vlines_clist ,
+ vlines .clist_set:N = \l_@@_submatrix_vlines_clist ,
vlines .default:n = all ,
hvlines .meta:n = { hlines, vlines } ,
hvlines .value_forbidden:n = true ,
@@ -14738,8 +15025,6 @@ version 2005/12/01 or later.
{ \@@_error:n { SubMatrix~too~large } }
{
\str_clear_new:N \l_@@_submatrix_name_str
- \clist_clear:N \l_@@_hlines_clist
- \clist_clear:N \l_@@_vlines_clist
\keys_set:nn { NiceMatrix / SubMatrix } { #5 }
\pgfpicture
\pgfrememberpicturepositiononpagetrue
@@ -14837,9 +15122,9 @@ version 2005/12/01 or later.
% The last argument of |\int_step_inline:nn| or |\clist_map_inline:Nn| is given
% by curryfication.
% \begin{macrocode}
- \tl_if_eq:NnTF \l_@@_vlines_clist { all }
+ \tl_if_eq:NnTF \l_@@_submatrix_vlines_clist { all }
{ \int_step_inline:nn { \l_@@_last_j_tl - \l_@@_first_j_tl } }
- { \clist_map_inline:Nn \l_@@_vlines_clist }
+ { \clist_map_inline:Nn \l_@@_submatrix_vlines_clist }
{
\bool_lazy_and:nnTF
{ \int_compare_p:nNn { ##1 } > 0 }
@@ -14862,9 +15147,9 @@ version 2005/12/01 or later.
% The last argument of |\int_step_inline:nn| or |\clist_map_inline:Nn| is given
% by curryfication.
% \begin{macrocode}
- \tl_if_eq:NnTF \l_@@_hlines_clist { all }
+ \tl_if_eq:NnTF \l_@@_submatrix_hlines_clist { all }
{ \int_step_inline:nn { \l_@@_last_i_tl - \l_@@_first_i_tl } }
- { \clist_map_inline:Nn \l_@@_hlines_clist }
+ { \clist_map_inline:Nn \l_@@_submatrix_hlines_clist }
{
\bool_lazy_and:nnTF
{ \int_compare_p:nNn { ##1 } > 0 }
@@ -14910,8 +15195,8 @@ version 2005/12/01 or later.
%
% \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
-% the delimiters that we will put after).
+% node with that name for the submatrix (this node does not encompass the
+% delimiters that we will put after).
% \begin{macrocode}
\str_if_empty:NF \l_@@_submatrix_name_str
{
@@ -15577,6 +15862,16 @@ version 2005/12/01 or later.
If~you~go~on,~this~specification~of~corner~will~be~ignored.
}
% \end{macrocode}
+%
+% \begin{macrocode}
+\@@_msg_new:nn { bad~border }
+ {
+ #1~is~an~incorrect~specification~for~a~border~(in~the~key~
+ 'borders'~of~the~command~\token_to_str:N \Block).~The~available~
+ values~are:~left,~right,~top~and~bottom.\\
+ If~you~go~on,~this~specification~of~border~will~be~ignored.
+ }
+% \end{macrocode}
%
% \begin{macrocode}
\@@_msg_new:nn { last-col~non~empty~for~NiceArray }
@@ -15642,6 +15937,16 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \begin{macrocode}
+\@@_msg_new:nn { borders~forbidden }
+ {
+ You~can't~use~the~key~'borders'~of~the~command~\token_to_str:N \Block\
+ because~the~option~'rounded-corners'~
+ is~in~force~with~a~non-zero~value.\\
+ If~you~go~on,~this~key~will~be~ignored.
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
\@@_msg_new:nn { bottomrule~without~booktabs }
{
You~can't~use~the~key~'tabular/bottomrule'~because~you~haven't~
@@ -15702,7 +16007,7 @@ version 2005/12/01 or later.
For~a~list~of~the~available~keys,~type~H~<return>.
}
{
- The~available~keys~are~(in~alphabetic~order):~c,~draw,~fill,~l,~
+ The~available~keys~are~(in~alphabetic~order):~borders,~c,~draw,~fill,~l,~
line-width,~rounded-corners~and~r.
}
% \end{macrocode}
@@ -16426,7 +16731,7 @@ version 2005/12/01 or later.
%
% New command |\SubMatrix| available in the |\CodeAfter|.
%
-% It's possible to provide options (between brackets) to the command |\CodeAfter|.
+% It's possible to provide options (between brackets) to the keyword |\CodeAfter|.
%
% A (non fatal) error is raised when the key |transparent|, which is
% deprecated, is used.
@@ -16434,10 +16739,10 @@ version 2005/12/01 or later.
% \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)
+% 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$.
%
-% % \subsection*{Changes between versions 5.11 and 5.12}
+% \subsection*{Changes between versions 5.11 and 5.12}
%
% Keywords |\CodeBefore| and |\Body| (alternative syntax to the key
% |code-before|).
@@ -16448,6 +16753,18 @@ version 2005/12/01 or later.
% |\CodeAfter|.
%
% New key |rounded-corners| for the command |\Block|.
+%
+% \subsection*{Changes between versions 5.12 and 5.13}
+%
+% New command |\arraycolor| in the |\CodeBefore| (with its key
+% |except-corners|).
+%
+% New key |borders| for the command |\Block|.
+%
+% New command |\Hline| (for horizontal rules not drawn in the blocks).
+%
+% The keys |vlines| and |hlines| takes in as value a (comma-separated) list of
+% numbers (for the rules to draw).
%
% \PrintIndex
%