summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/nicematrix/nicematrix.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-04-01 03:01:11 +0000
committerNorbert Preining <norbert@preining.info>2023-04-01 03:01:11 +0000
commit1c004b8b1b82512ea320e5d1e16e364d54878e6a (patch)
tree61c1c3e5f18f20f7d7df8c91164e7b0de75220d0 /macros/latex/contrib/nicematrix/nicematrix.dtx
parentff15e9aea45682289b6f31fa687c1b51f543d09e (diff)
CTAN sync 202304010301
Diffstat (limited to 'macros/latex/contrib/nicematrix/nicematrix.dtx')
-rw-r--r--macros/latex/contrib/nicematrix/nicematrix.dtx501
1 files changed, 346 insertions, 155 deletions
diff --git a/macros/latex/contrib/nicematrix/nicematrix.dtx b/macros/latex/contrib/nicematrix/nicematrix.dtx
index 6ef8d2a7f7..3620cc0f4b 100644
--- a/macros/latex/contrib/nicematrix/nicematrix.dtx
+++ b/macros/latex/contrib/nicematrix/nicematrix.dtx
@@ -3,7 +3,7 @@
% This file should be compiled with $xelatex$.
%
% Copyright (C) 2018-2023 by F. Pantigny
-% -----------------------------------
+% ------------------------------------------
%
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
@@ -17,8 +17,8 @@
%
% \fi
% \iffalse
-\def\myfileversion{6.16}
-\def\myfiledate{2023/03/06}
+\def\myfileversion{6.17}
+\def\myfiledate{2023/03/31}
%
%
%<*batchfile>
@@ -61,6 +61,7 @@ version 2005/12/01 or later.
\usepackage{caption}
\usepackage{varwidth}
\usepackage{tcolorbox}
+\usepackage{adjustbox}
\usepackage[auto-lang=false]{lipsum}
\NewDocumentEnvironment {scope} {} {} {}
@@ -556,9 +557,8 @@ version 2005/12/01 or later.
% block;\footnote{However, the rules are not drawn in the sub-blocks of the
% block, as always with \pkg{nicematrix}: the rules are not drawn in the blocks
% (cf. section~\ref{rules} p.~\pageref{rules}).}
-% \item the key \Definition{line-width} is the width of the rules (this key
-% is meaningful only when one of the keys |draw|, |hvlines|, |vlines| and
-% |hlines| is used);
+% \item the key \Definition{line-width} is the width of the rules (is relevant
+% only when one of the keys |draw|, |hvlines|, |vlines| and |hlines| is used);
% \item the key \Definition{rounded-corners} requires rounded corners (for the
% frame drawn by |draw| and the shape drawn by |fill|) with a radius equal to
% the value of that key (the default value is 4~pt\footnote{This value is the
@@ -582,7 +582,7 @@ version 2005/12/01 or later.
% the form |tikz={|\textsl{list}|}| where \textsl{list} is a list of couples
% \textsl{key=value} of Tikz specifying the graphical characteristics of the
% lines that will be drawn (for an example, see p.~\pageref{dashed}).
-% \item \colorbox{yellow!50}{\textbf{Nouveau 6.15}}\par\nobreak
+% \item \colorbox{yellow!50}{\textbf{New 6.15}}\par\nobreak
% By default, the rules are not drawn in the blocks (see the section about the
% rules: section~\ref{rules} p.~\pageref{rules}). However, if the key
% \Definition{transparent} is used, the rules are drawn. For an example, see
@@ -590,7 +590,7 @@ version 2005/12/01 or later.
% \end{itemize}
%
% There is also keys for the horizontal and vertical positions of the content of
-% the block: cf.~\ref{horizontal-block} p.~\pageref{horizontal-block}).
+% the block: cf.~\ref{horizontal-block} p.~\pageref{horizontal-block}.
%
% \interitem
% {\bfseries One must remark that, by default, the commands |\Blocks| don't create space}.
@@ -599,11 +599,11 @@ version 2005/12/01 or later.
%
% \medskip
% In the following example, we have had to enlarge by hand the columns 2 and 3
-% (with the construction |wc{...}| of \pkg{array}).
+% (with the construction |w{c}{...}| of \pkg{array}).
%
% \bigskip
% \begin{BVerbatim}
-% \begin{NiceTabular}{cwc{2cm}wc{3cm}c}
+% \begin{NiceTabular}{cw{c}{2cm}w{c}{3cm}c}
% rose & tulip & daisy & dahlia \\
% violet
% & ~emphase#\Block[draw=red,fill=[RGB]{204,204,255},rounded-corners]{2-2}@
@@ -616,7 +616,7 @@ version 2005/12/01 or later.
%
% \medskip
% \begin{center}
-% \begin{NiceTabular}{cwc{2cm}wc{3cm}c}
+% \begin{NiceTabular}{cw{c}{2cm}w{c}{3cm}c}
% rose & tulip & daisy & dahlia \\
% violet & \Block[draw=red,fill=[RGB]{204,204,255},rounded-corners]{2-2}
% {\LARGE Some beautiful flowers} & & marigold \\
@@ -633,9 +633,9 @@ version 2005/12/01 or later.
% \item The natural width of the contents of these blocks is taken into account
% for the width of the current column.
%
-% In the columns with a fixed width (columns |w{...}{...}|, |p{...}|, |b{...}|,
-% |m{...}| and |X|), the content of the block is formatted as a paragraph of
-% that width.
+% In the columns with a fixed width (columns |w{...}{...}|, |W{...}{...}|,
+% |p{...}|, |b{...}|, |m{...}|, |V| and |X|), the content of the block is
+% formatted as a paragraph of that width.
%
% \item The specification of the horizontal position provided by the type of
% column (|c|, |r| or |l|) is taken into account for the blocks (but the
@@ -764,7 +764,7 @@ version 2005/12/01 or later.
% \end{bNiceArray}$
%
%
-%
+% \medskip
% By default, the horizontal position of the content of a block is computed
% by using the positions of the \emph{contents} of the columns implied in that
% block. That's why, in the following example, the header ``First group'' is
@@ -852,7 +852,7 @@ version 2005/12/01 or later.
%
% \colorbox{yellow!50}{\textbf{New 6.14}}
%
-% For the vertical position, the commands |\Blocks| accepts the keys
+% For the vertical position, the command |\Blocks| accepts the keys
% |v-center|\footnote{That key could not have been named |c| since the key |c|
% is used for the horizontal alignement.},
% |t|, |b|, |T| and |B|.
@@ -1389,7 +1389,7 @@ version 2005/12/01 or later.
% will be created by \pkg{nicematrix} and that will be available for the final
% user in order to draw horizontal rules (similarly to |\hline|);
%
-% \item the key |cccommand| is the name (without the backslash) of a command
+% \item the key |ccommand| is the name (without the backslash) of a command
% that will be created by \pkg{nicematrix} and that will be available for the
% final user to order to draw partial horizontal rules (similarly to |\cline|,
% hence the name |ccommand|): the argument of that command is a list of
@@ -2180,7 +2180,7 @@ version 2005/12/01 or later.
% color of the text.\footnote{The key |color| uses the command
% |\color| but inserts also an instruction |\leavevmode| before. This
% instruction prevents a extra vertical space in the cells which belong to
-% columns of type |p|, |b|, |m| and |X| (which start in
+% columns of type |p|, |b|, |m|, |X| and |V| (which start in
% vertical mode).}
% \item The key |bold| enforces
% bold characters for the cells of the row, both in math and text mode.
@@ -2220,13 +2220,13 @@ version 2005/12/01 or later.
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=9cm]
-% \begin{NiceTabular}{~emphase#Wc{2cm}@cc}[hvlines]
+% \begin{NiceTabular}{~emphase#W{c}{2cm}@cc}[hvlines]
% Paris & New York & Madrid \\
% Berlin & London & Roma \\
% Rio & Tokyo & Oslo
% \end{NiceTabular}
% \end{BVerbatim}
-% \begin{NiceTabular}{Wc{2cm}cc}[hvlines]
+% \begin{NiceTabular}{W{c}{2cm}cc}[hvlines]
% Paris & New York & Madrid \\
% Berlin & London & Roma \\
% Rio & Tokyo & Oslo
@@ -2342,6 +2342,60 @@ version 2005/12/01 or later.
% \end{array}$
% \end{NiceMatrixBlock}
%
+% \subsection{The columns X}
+%
+% \label{X-columns}
+%
+% The environment |{NiceTabular}| provides |X| columns similar to those provided
+% by the environment |{tabularx}| of the eponymous package.
+%
+% The required width of the tabular may be specified with the key |width| (in
+% |{NiceTabular}| or in |\NiceMatrixOptions|). The initial value of this
+% parameter is |\linewidth| (and not |\textwidth|).
+%
+% For sake of similarity with the environment |{tabularx}|, \pkg{nicematrix}
+% also provides an environment |{NiceTabularX}| with a syntax similar to the
+% syntax of |{tabularx}|, that is to say with a first mandatory argument
+% which is the width of the tabular.\footnote{If \pkg{tabularx} is loaded, one
+% must use |{NiceTabularX}| (and not |{NiceTabular}|) in order to use the
+% columns |X| (this point comes from a conflict in the definitions of the
+% specifier |X|).}
+%
+% As with the packages \pkg{tabu}\footnote{The extension \pkg{tabu} is now
+% considered as deprecated.} and \pkg{tabularray}, the specifier |X| takes
+% in an optional argument (between square brackets) which is a list of keys.
+% \begin{itemize}
+% \item It's possible to give a weight for the column by providing a positive
+% integer directly as argument of the specifier |X|. For example, a column
+% |X[2]| will have a width double of the width of a column~|X| (which has a
+% weight equal to $1$).\footnote{The negative values of the weight, as provided
+% by \pkg{tabu} (which is now obsolete), are \emph{not} supported by \pkg{nicematrix}.
+% If such a value is used, an error will be raised.}
+% \item It's possible to specify an horizontal alignment with one of the
+% letters |l|, |c| and |r| (which insert respectively |\raggedright|,
+% |\centering| and |\raggedleft| followed by |\arraybackslash|).
+% \item It's possible to specify a vertical alignment with one of the keys
+% |t| (alias |p|), |m| and |b| (which construct respectively columns of type
+% |p|, |m| and |b|). The default value is |t|.
+% \end{itemize}
+%
+% \begin{Verbatim}
+% \begin{NiceTabular}~emphase#[width=9cm]{X[2,l]X[l]}@[hvlines]
+% a rather long text which fits on several lines
+% & a rather long text which fits on several lines \\
+% a shorter text & a shorter text
+% \end{NiceTabular}
+% \end{Verbatim}
+%
+% \begin{center}
+% \begin{NiceTabular}[width=9cm]{X[2,l]X[l]}[hvlines]
+% a rather long text which fits on several lines
+% & a rather long text which fits on several lines \\
+% a shorter text & a shorter text
+% \end{NiceTabular}
+% \end{center}
+%
+%
% \subsection{The columns V of varwidth}
%
% \label{varwidth}
@@ -2423,66 +2477,18 @@ version 2005/12/01 or later.
% interests of this type of columns is that, for a cell of a column of type~|V|,
% the PGF/Tikz node created by \pkg{nicematrix} for the content of that cell has
% a width adjusted to the content of the cell : cf. p.~\pageref{node-V}.
-
+%
+%
+% \bigskip
+% The columns |V| of \pkg{nicematrix} supports the keys |t|, |p|, |m|, |b|, |l|,
+% |c| and |r| also supported by the columns |X|: see their description in the
+% section~\ref{X-columns}, p.~\pageref{X-columns}.
+%
% \bigskip
% One should remark that the extension \pkg{varwidth} (at least in its version
% 0.92) has some problems: for instance, with LuaLaTeX, it does not work when
% the content begins with |\color|.
%
-%
-% \subsection{The columns X}
-%
-% \label{X-columns}
-%
-% The environment |{NiceTabular}| provides |X| columns similar to those provided
-% by the environment |{tabularx}| of the eponymous package.
-%
-% The required width of the tabular may be specified with the key |width| (in
-% |{NiceTabular}| or in |\NiceMatrixOptions|). The initial value of this
-% parameter is |\linewidth| (and not |\textwidth|).
-%
-% For sake of similarity with the environment |{tabularx}|, \pkg{nicematrix}
-% also provides an environment |{NiceTabularX}| with a syntax similar to the
-% syntax of |{tabularx}|, that is to say with a first mandatory argument
-% which is the width of the tabular.\footnote{If \pkg{tabularx} is loaded, one
-% must use |{NiceTabularX}| (and not |{NiceTabular}|) in order to use the
-% columns |X| (this point comes from a conflict in the definitions of the
-% specifier |X|).}
-%
-% As with the packages \pkg{tabu}\footnote{The extension \pkg{tabu} is now
-% considered as deprecated.} and \pkg{tabularray}, the specifier |X| takes
-% in an optional argument (between square brackets) which is a list of keys.
-% \begin{itemize}
-% \item It's possible to give a weight for the column by providing a positive
-% integer directly as argument of the specifier |X|. For example, a column
-% |X[2]| will have a width double of the width of a column~|X| (which has a
-% weight equal to $1$).\footnote{The negative values of the weight, as provided
-% by \pkg{tabu} (which is now obsolete), are \emph{not} supported by \pkg{nicematrix}.
-% If such a value is used, an error will be raised.}
-% \item It's possible to specify an horizontal alignment with one of the
-% letters |l|, |c| and |r| (which insert respectively |\raggedright|,
-% |\centering| and |\raggedleft| followed by |\arraybackslash|).
-% \item It's possible to specify a vertical alignment with one of the keys
-% |t| (alias |p|), |m| and |b| (which construct respectively columns of type
-% |p|, |m| and |b|). The default value is |t|.
-% \end{itemize}
-%
-% \begin{Verbatim}
-% \begin{NiceTabular}~emphase#[width=9cm]{X[2,l]X[l]}@[hvlines]
-% a rather long text which fits on several lines
-% & a rather long text which fits on several lines \\
-% a shorter text & a shorter text
-% \end{NiceTabular}
-% \end{Verbatim}
-%
-% \begin{center}
-% \begin{NiceTabular}[width=9cm]{X[2,l]X[l]}[hvlines]
-% a rather long text which fits on several lines
-% & a rather long text which fits on several lines \\
-% a shorter text & a shorter text
-% \end{NiceTabular}
-% \end{center}
-%
% \bigskip
% \section{The exterior rows and columns}
%
@@ -3313,7 +3319,7 @@ version 2005/12/01 or later.
%
%
% \subsection{The command \textbackslash SubMatrix in the \textbackslash
-% CodeAfter (and also the \textbackslash CodeBefore)}
+% CodeAfter (and the \textbackslash CodeBefore)}
%
% \label{sub-matrix}
%
@@ -3419,26 +3425,27 @@ version 2005/12/01 or later.
% \bigskip
% The options of the command |\SubMatrix| are as follows:
% \begin{itemize}
-% \item |left-xshift| and |right-xshift| shift horizontally the delimiters (there
-% 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 \Definition{left-xshift} and \Definition{right-xshift} shift
+% horizontally the delimiters (there exists also the key \Definition{xshift}
+% which fixes both parameters);
+% \item \Definition{extra-height} adds a quantity to the total height of the
+% delimiters (height |\ht| + depth |\dp|);
+% \item \Definition{delimiters/color} fixes the color of the delimiters (also
% available in |\NiceMatrixOptions|, in the environments with delimiters and as
% option of the keyword |\CodeAfter|);
-% \item |slim| is a boolean key: when that key is in force, the horizontal
+% \item \Definition{slim} is a boolean key: when that key is in force, the horizontal
% 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). ;
-% \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;
-% \item |code| insert code, especially TikZ code, after the construcion of the
-% submatrix. That key is detailed below.
+% \item \Definition{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 \Definition{hlines} is similar to |vlines| but for the horizontal rules;
+% \item \Definition{hvlines}, which must be used without value, draws all the
+% vertical and horizontal rules;
+% \item \Definition{code} insert code, especially TikZ code, after the
+% construcion of the submatrix. That key is detailed below.
% \end{itemize}
% One should remark that the keys add their rules after the construction of
% the main matrix: no space is added between the rows and the columns of the
@@ -3561,7 +3568,8 @@ version 2005/12/01 or later.
% submatrix. It's meant to be used to insert TikZ instructions because, in the
% TikZ instructions inserted by that code, the nodes of the form |i-j| and
% \verb+i-|j+ are interpreted with |i| and |j| as numbers of row and columns
-% \emph{relative to the submatrix}.
+% \emph{relative to the submatrix}.\footnote{Be careful: the syntax
+% \verb+j|-i+ is not allowed.}
%
% \medskip
% \begin{scope}
@@ -4433,7 +4441,11 @@ version 2005/12/01 or later.
%
% \subsection{The nodes corresponding to the contents of the cells}
%
-% The package \pkg{nicematrix} creates a PGF/Tikz node for each (non-empty) cell
+% The package \pkg{nicematrix} creates a PGF/Tikz node\footnote{We recall that Tikz
+% is a layer over PGF. The extension \pkg{nicematrix} loads PGF but does not
+% load Tikz. We speak of PGF/Tikz nodes to emphase the fact that the PGF nodes
+% created by \pkg{nicematrix} may be used with PGF but also with Tikz. The final
+% user will probably prefer to use Tikz rather than PGF.} for each (non-empty) cell
% of the considered array. These nodes are used to draw the dotted lines between
% the cells of the matrix (inter alia).
%
@@ -4518,36 +4530,65 @@ version 2005/12/01 or later.
% \tikz \draw (2-2) circle (2mm) ;
% \end{pNiceMatrix}$
%
+% \medskip
+% The nodes of the last column (excepted the potential «last column» specified
+% by |last-col|\footnote{For the exterior columns, cf. part~\ref{exterior},
+% p.~\pageref{exterior}.}) may also be indicated by $i$-|last|. Similarly, the
+% nodes of the last row may be indicated by |last|-$j$.
%
% \bigskip
-% In the following example, we have underlined all the nodes of the matrix (we
-% explain below the technic used : cf. p. \pageref{highlight}).
+% In the following example, we have underlined all the nodes of the matrix.
%
-%
-% \[\begin{pNiceMatrix}
-% \CodeBefore [create-cell-nodes]
-% \begin{tikzpicture}%
-% [every node/.style = { inner sep = 0 pt , fill = red!15 }]
-% \node [fit = (1-1)] {} ;
-% \node [fit = (1-3)] {} ;
-% \node [fit = (2-2)] {} ;
-% \node [fit = (3-1)] {} ;
-% \node [fit = (3-3)] {} ;
-% \node [fit = (1-2)] {} ;
-% \node [fit = (2-1)] {} ;
-% \node [fit = (2-3)] {} ;
-% \node [fit = (3-2)] {} ;
-% \end{tikzpicture}
-% \Body
+% \[
+% \NiceMatrixOptions
+% {
+% pgf-node-code =
+% {
+% \pgfsetfillcolor{red!15}%
+% \pgfusepathqfill
+% }
+% }
+% \begin{pNiceMatrix}
% a & a + b & a + b + c \\
% a & a & a + b \\
-% a & a & a
+% a & a & a
% \end{pNiceMatrix}\]
%
%
-% The nodes of the last column (excepted the potential «last column» specified
-% by |last-col|) may also be indicated by $i$-|last|. Similarly, the nodes of
-% the last row may be indicated by |last|-$j$.
+% \bigskip
+% \colorbox{yellow!50}{\textbf{New 6.17}}\enskip Since those nodes are PGF
+% nodes, one won't be surprised to learn that they are drawn by using a specific
+% PGF style. That style is called |nicematrix/cell-node| and its definition in
+% the source file |nicematrix.sty| is as follows:
+%
+% \begin{Verbatim}
+% \pgfset
+% {
+% ~emphase#nicematrix / cell-node@ /.style =
+% {
+% inner sep = 0 pt ,
+% minimum width = 0 pt
+% }
+% }
+% \end{Verbatim}
+%
+% The final user may modify that style by changing the values of the keys |text/rotate|,
+% |inner xsep|, |inner ysep|, |inner sep|, |outer xsep|, |outer ysep|, |outer sep|,
+% |minimum width|, |minimum height| and |minimum size|.
+%
+% \medskip
+% For an example of utilisation, see part~\ref{triangular}, p.~\pageref{triangular}.
+%
+%
+% \subsubsection{The key pgf-node-code}
+%
+% \colorbox{yellow!50}{\textbf{New 6.17}}\enskip \textbf{For the experienced
+% users}, \pkg{nicematrix} provides the key |pgf-node-code| which corresponds to
+% some PGF node that will be executed at the creation, by PGF, of the nodes
+% corresponding to the cells of the array. More pricisely, the value given to
+% the key |pgf-node-code| will be passed in the fifth argument of the command
+% |\pgfnode|. That value should contain at least an instruction such as
+% |\pgfusepath|, |\pgfusepathqstroke|, |\pgfusepathqfill|, etc.
%
% \subsubsection{The columns V of varwidth}
%
@@ -5086,7 +5127,8 @@ version 2005/12/01 or later.
%
% \section{Technical remarks}
%
-% First remark: the package \pkg{underscore} must be loaded before \pkg{nicematrix}.
+% First remark: the package \pkg{underscore} must be loaded before
+% \pkg{nicematrix}. If it is loaded after, an error will be raised.
%
% \subsection{Diagonal lines}
%
@@ -5215,7 +5257,7 @@ version 2005/12/01 or later.
% before and after each column. In particular, there is a space equal to
% |\arraycolsep| before and after the array. This feature of the environment
% |{array}| was probably not a good idea\footnote{In the documentation of
-% |{amsmath}|, we can read: {\itshape The extra space of |\arraycolsep| that
+% \pkg{amsmath}, we can read: {\itshape The extra space of |\arraycolsep| that
% \pkg{array} adds on each side is a waste so we remove it [in |{matrix}|]
% (perhaps we should instead remove it from array in general, but that's a
% harder task).}}. The environment |{matrix}| of
@@ -6219,7 +6261,9 @@ version 2005/12/01 or later.
% a & a & a & L_3
% \end{pNiceArray}\]
%
-%
+%
+
+%
% \subsection{Utilisation of \textbackslash SubMatrix in the \textbackslash CodeBefore}
%
% \label{submatrix-in-codebefore}
@@ -6299,6 +6343,69 @@ version 2005/12/01 or later.
% \end{NiceArray}\]
% \end{Verbatim}
%
+%
+%
+% \subsection{A triangular tabular}
+%
+% \label{triangular}
+%
+% In the following example, we use the style PGF/TikZ |nicematrix/cell-node|
+% to rotate the contents of the cells (and, then, we compensate that rotation by
+% a rotation of the whole tabular with the command |\adjustbox| of the eponymous
+% package, which must be loaded previously).
+%
+%
+% \medskip
+% \begin{Verbatim}
+% \pgfset
+% {
+% ~emphase#nicematrix/cell-node@/.append style =
+% { text/rotate = 45, minimum size = 6 mm }
+% }
+%
+% \setlength{\tabcolsep}{0pt}
+%
+% ~emphase#\adjustbox@{rotate = -45, set depth = 6mm + 1.414 \arrayrulewidth}
+% {\begin{NiceTabular} [ hvlines, corners=SE, baseline = line-9 ] { cccccccc }
+% \CodeBefore
+% \chessboardcolors{red!15}{blue!15}
+% \Body
+% 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
+% 1 & 2 & 3 & 4 & 5 & 6 & 7 \\
+% 1 & 3 & 6 & 10 & 15 & 21 \\
+% 1 & 4 & 10 & 20 & 35 \\
+% 1 & 5 & 15 & 35 \\
+% 1 & 6 & 21 \\
+% 1 & 7 \\
+% 1
+% \end{NiceTabular}}
+% \end{Verbatim}
+%
+%
+% \begin{center}
+% \pgfset
+% {
+% nicematrix/cell-node/.append style =
+% { text/rotate = 45, minimum size = 6 mm }
+% }%
+% \setlength{\tabcolsep}{0pt}%
+% \adjustbox{rotate = -45, set depth = 6mm + 1.414 \arrayrulewidth}
+% {\begin{NiceTabular} [ hvlines, corners=SE, baseline = line-9 ] { cccccccc }
+% \CodeBefore
+% \chessboardcolors{red!15}{blue!15}
+% \Body
+% 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\
+% 1 & 2 & 3 & 4 & 5 & 6 & 7 \\
+% 1 & 3 & 6 & 10 & 15 & 21 \\
+% 1 & 4 & 10 & 20 & 35 \\
+% 1 & 5 & 15 & 35 \\
+% 1 & 6 & 21 \\
+% 1 & 7 \\
+% 1
+% \end{NiceTabular}}
+% \end{center}
+%
+%
%
% \section{Implementation}
%
@@ -6578,7 +6685,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. At the date January 2022, the current
+% way incompatible with our programmation. At the date March 2023, the current
% version \cls{revtex4-2} is 4.2e (compatible with \pkg{booktabs}).
%
% \begin{macrocode}
@@ -7251,6 +7358,13 @@ version 2005/12/01 or later.
% \begin{macrocode}
\tl_new:N \l_@@_code_tl
% \end{macrocode}
+%
+% \bigskip
+% For the key |pgf-node-code|. That code will be used when the nodes of the
+% cells (that is to say the nodes of the form |i-j|) will be created.
+% \begin{macrocode}
+\tl_new:N \l_@@_pgf_node_code_tl
+% \end{macrocode}
%
% \bigskip
% The following token list has a function similar to
@@ -7313,10 +7427,6 @@ version 2005/12/01 or later.
\dim_new:N \l_@@_X_columns_dim
% \end{macrocode}
%
-% \medskip
-% \begin{macrocode}
-\bool_new:N \l_@@_X_V_bool
-% \end{macrocode}
%
% \bigskip
% This boolean will be used only to detect in an expandable way whether we are
@@ -7508,7 +7618,7 @@ version 2005/12/01 or later.
% The following sequence will be used when the command |\SubMatrix| is used in
% the |\CodeBefore| (and not in the |\CodeAfter|). It will contain the position of
% all the sub-matrices specified in the |\CodeBefore|. Each sub-matrix is
-% represented by an ``object'' of the forme |{|$i$|}{|$j$|}{|$k$|}{|$l$|}|
+% represented by an ``object'' of the form |{|$i$|}{|$j$|}{|$k$|}{|$l$|}|
% where $i$ and $j$ are the number of row and column of the upper-left cell and
% $k$ and $l$ the number of row and column of the lower-right cell.
% \begin{macrocode}
@@ -8064,7 +8174,7 @@ version 2005/12/01 or later.
\begin { pgfscope }
\pgfset
{
- outer~sep = \c_zero_dim ,
+ % outer~sep = \c_zero_dim ,
inner~sep = \c_zero_dim ,
minimum~size = \c_zero_dim
}
@@ -8096,7 +8206,7 @@ version 2005/12/01 or later.
\begin { pgfscope }
\pgfset
{
- outer~sep = \c_zero_dim ,
+ % outer~sep = \c_zero_dim ,
inner~sep = \c_zero_dim ,
minimum~size = \c_zero_dim
}
@@ -8545,7 +8655,9 @@ version 2005/12/01 or later.
{ extra-left-margin = #1 , extra-right-margin = #1 } ,
extra-margin .value_required:n = true ,
respect-arraystretch .bool_set:N = \l_@@_respect_arraystretch_bool ,
- respect-arraystretch .default:n = true
+ respect-arraystretch .default:n = true ,
+ pgf-node-code .tl_set:N = \l_@@_pgf_node_code_tl ,
+ pgf-node-code .value_required:n = true
}
% \end{macrocode}
%
@@ -9078,6 +9190,13 @@ version 2005/12/01 or later.
{
\@@_math_toggle_token:
\hbox_set_end:
+ \@@_cell_end_i:
+ }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_cell_end_i:
+ {
% \end{macrocode}
% The token list |\g_@@_cell_after_hook_tl| is (potentially) set during the
% composition of the box |\l_@@_cell_box| and is used now \emph{after} the
@@ -9136,13 +9255,13 @@ version 2005/12/01 or later.
% \end{itemize}
% \begin{macrocode}
\bool_if:NTF \g_@@_empty_cell_bool
- { \box_use_drop:N \l_@@_cell_box }
+ { \box_use_drop:N \l_@@_cell_box }
{
\bool_lazy_or:nnTF
\g_@@_not_empty_cell_bool
{ \dim_compare_p:nNn { \box_wd:N \l_@@_cell_box } > \c_zero_dim }
\@@_node_for_cell:
- { \box_use_drop:N \l_@@_cell_box }
+ { \box_use_drop:N \l_@@_cell_box }
}
\int_gset:Nn \g_@@_col_total_int { \int_max:nn \g_@@_col_total_int \c@jCol }
\bool_gset_false:N \g_@@_empty_cell_bool
@@ -9150,20 +9269,46 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
-% \medskip
+% \bigskip
+% The following variant of |\@@_cell_end:| is only for the columns of type
+% |w{s}{...}| or |W{s}{...}| (which use the horizontal alignement key |s| of
+% |\makebox|).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_cell_end_for_w_s:
+ {
+ \@@_math_toggle_token:
+ \hbox_set_end:
+ \bool_if:NF \g_@@_rotate_bool
+ {
+ \hbox_set:Nn \l_@@_cell_box
+ {
+ \makebox [ \l_@@_col_width_dim ] [ s ]
+ { \hbox_unpack_drop:N \l_@@_cell_box }
+ }
+ }
+ \@@_cell_end_i:
+ }
+% \end{macrocode}
+%
+%
+% \bigskip
% The following command creates the \textsc{pgf} name of the node with, of
% course, |\l_@@_cell_box| as the content.
% \begin{macrocode}
+\pgfset
+ {
+ nicematrix / cell-node /.style =
+ {
+ inner~sep = \c_zero_dim ,
+ minimum~width = \c_zero_dim
+ }
+ }
\cs_new_protected:Npn \@@_node_for_cell:
{
\pgfpicture
\pgfsetbaseline \c_zero_dim
\pgfrememberpicturepositiononpagetrue
- \pgfset
- {
- inner~sep = \c_zero_dim ,
- minimum~width = \c_zero_dim
- }
+ \pgfset { nicematrix / cell-node }
\pgfnode
{ rectangle }
{ base }
@@ -9176,7 +9321,7 @@ version 2005/12/01 or later.
\box_use_drop:N \l_@@_cell_box
}
{ \@@_env: - \int_use:N \c@iRow - \int_use:N \c@jCol }
- { }
+ { \l_@@_pgf_node_code_tl }
\str_if_empty:NF \l_@@_name_str
{
\pgfnodealias
@@ -11302,9 +11447,62 @@ version 2005/12/01 or later.
%
% \medskip
% For |w| and |W|
+%
+% |#1| is a special argument: empty for |w| and equal to |\@@_special_W:| for |W|;
+%
+% |#2| is the type of column (|w| or |W|);
+%
+% |#3| is the type of horizontal alignment (|c|, |l|, |r| or |s|);
+%
+% |#4| is the width of the column.
+%
% \begin{macrocode}
\cs_new_protected:Npn \@@_patch_preamble_vi:nnnn #1 #2 #3 #4
{
+ \str_if_eq:nnTF { #3 } { s }
+ { \@@_patch_preamble_vi_i:nnnn { #1 } { #4 } }
+ { \@@_patch_preamble_vi_ii:nnnn { #1 } { #2 } { #3 } { #4 } }
+ }
+% \end{macrocode}
+%
+% \bigskip
+% First, the case of an horizontal alignment equal to |s| (for \emph{stretch}).
+%
+% |#1| is a special argument: empty for |w| and equal to |\@@_special_W:| for
+% |W|;
+%
+% |#2| is the width of the column.
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_preamble_vi_i:nnnn #1 #2
+ {
+ \tl_gput_right:NV \g_@@_preamble_tl \g_@@_pre_cell_tl
+ \tl_gclear:N \g_@@_pre_cell_tl
+ \tl_gput_right:Nn \g_@@_preamble_tl
+ {
+ > {
+ \dim_set:Nn \l_@@_col_width_dim { #2 }
+ \@@_cell_begin:w
+ \str_set:Nn \l_@@_hpos_cell_str { c }
+ }
+ c
+ < {
+ \@@_cell_end_for_w_s:
+ #1
+ \@@_adjust_size_box:
+ \box_use_drop:N \l_@@_cell_box
+ }
+ }
+ \int_gincr:N \c@jCol
+ \@@_patch_preamble_xi:n
+ }
+% \end{macrocode}
+%
+% \bigskip
+% Then, the most important version, for the horizontal alignments types of |c|,
+% |l| and |r| (and not |s|).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_patch_preamble_vi_ii:nnnn #1 #2 #3 #4
+ {
\tl_gput_right:NV \g_@@_preamble_tl \g_@@_pre_cell_tl
\tl_gclear:N \g_@@_pre_cell_tl
\tl_gput_right:Nn \g_@@_preamble_tl
@@ -11324,10 +11522,11 @@ version 2005/12/01 or later.
< {
\@@_cell_end:
\hbox_set_end:
- \bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box:
+ % The following line is probably pointless
+ % \bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box:
#1
\@@_adjust_size_box:
- \makebox [ #4 ] [ #3 ] { \box_use_drop:N \l_@@_cell_box }
+ \makebox [ #4 ] [ #3 ] { \box_use_drop:N \l_@@_cell_box }
}
}
% \end{macrocode}
@@ -11342,10 +11541,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_special_W:
{
- \dim_compare:nNnT
- { \box_wd:N \l_@@_cell_box }
- >
- \l_@@_col_width_dim
+ \dim_compare:nNnT { \box_wd:N \l_@@_cell_box } > \l_@@_col_width_dim
{ \@@_warning:n { W~warning } }
}
% \end{macrocode}
@@ -11537,10 +11733,7 @@ version 2005/12/01 or later.
% of keys will be used to retrieve that value (in the counter |\l_@@_weight_int|).
% \begin{macrocode}
\keys_define:nn { WithArrows / X-column }
- {
- v .bool_set:N = \l_@@_X_V_bool ,
- unknown .code:n = \int_set:Nn \l_@@_weight_int { \l_keys_key_str }
- }
+ { unknown .code:n = \int_set:Nn \l_@@_weight_int { \l_keys_key_str } }
% \end{macrocode}
%
%
@@ -11574,7 +11767,6 @@ version 2005/12/01 or later.
\tl_set:Nn \l_tmpa_tl { #1 }
\tl_replace_all:Nnn \l_tmpa_tl { \@@_S: } { S }
\@@_keys_p_column:V \l_tmpa_tl
- \bool_set_false:N \l_@@_X_V_bool
\keys_set:nV { WithArrows / X-column } \l_tmpa_tl
\int_compare:nNnT \l_@@_weight_int < 0
{
@@ -11593,11 +11785,7 @@ version 2005/12/01 or later.
\exp_args:Nnx
\@@_patch_preamble_iv_iv:nn
{ \l_@@_weight_int \l_@@_X_columns_dim }
- {
- \bool_if:NTF \l_@@_X_V_bool
- { varwidth }
- { minipage }
- }
+ { minipage }
}
{
\tl_gput_right:Nn \g_@@_preamble_tl
@@ -11931,7 +12119,7 @@ version 2005/12/01 or later.
\bool_if:NT \g_@@_rotate_bool \@@_rotate_cell_box:
#1
\@@_adjust_size_box:
- \makebox [ #4 ] [ #3 ] { \box_use_drop:N \l_@@_cell_box }
+ \makebox [ #4 ] [ #3 ] { \box_use_drop:N \l_@@_cell_box }
}
}
% \end{macrocode}
@@ -12887,7 +13075,7 @@ version 2005/12/01 or later.
{
\dim_compare:nNnTF { \box_wd:N \l_@@_cell_box } > \c_zero_dim
\@@_node_for_cell:
- { \box_use_drop:N \l_@@_cell_box }
+ { \box_use_drop:N \l_@@_cell_box }
\skip_horizontal:N \l_@@_left_delim_dim
\skip_horizontal:N \l_@@_left_margin_dim
\skip_horizontal:N \l_@@_extra_left_margin_dim
@@ -21688,6 +21876,7 @@ version 2005/12/01 or later.
matrix/columns-type,~
notes~(several~subkeys),~
nullify-dots,~
+ pgf-node-code,~
renew-dots,~
renew-matrix,~
respect-arraystretch,~
@@ -21743,13 +21932,13 @@ version 2005/12/01 or later.
light-syntax,~
name,~
nullify-dots,~
+ pgf-node-code,~
renew-dots,~
respect-arraystretch,~
right-margin,~
rules~(with~the~subkeys~'color'~and~'width'),~
small,~
t,~
- tabularnote,~
vlines,~
xdots/color,~
xdots/shorten-start,~
@@ -21806,6 +21995,7 @@ version 2005/12/01 or later.
light-syntax,~
name,~
nullify-dots,~
+ pgf-node-code,~
r,~
renew-dots,~
respect-arraystretch,~
@@ -21867,6 +22057,7 @@ version 2005/12/01 or later.
name,~
notes~(several~subkeys),~
nullify-dots,~
+ pgf-node-code,~
renew-dots,~
respect-arraystretch,~
right-margin,~
@@ -21928,7 +22119,7 @@ version 2005/12/01 or later.
% \subsection*{Changes between version 6.15 and 6.16}
%
% It's now possible to put any LaTeX extensible delimiter (|\lgroup|, |\langle|,
-% etc.) in the preamble of an environment with pramble (such as |{NiceArray}|)
+% etc.) in the preamble of an environment with preamble (such as |{NiceArray}|)
% by prefixing them by |\left| and |\right|.
%
% New key |code| for the command |\SubMatrix| in the |\CodeAfter|.