diff options
Diffstat (limited to 'Master/texmf-dist/source/latex')
-rw-r--r-- | Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx | 1145 |
1 files changed, 982 insertions, 163 deletions
diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx index c6f1a06f31a..3b7f4d278ec 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.9} -\def\myfiledate{2021/01/08} +\def\myfileversion{5.10} +\def\myfiledate{2021/02/05} % % %<*batchfile> @@ -581,11 +581,11 @@ version 2005/12/01 or later. % \end{NiceTabular} % \end{center} % -% \colorbox{yellow!30}{New 5.7}\enskip As we can see on this example, it's -% possible to fill the block by using the key |fill| and to draw the frame with -% the key |draw|\footnote{If the key |draw| is used without value, the default -% color the rules of the tabulars is used}. It's also possible to change the -% width (thickness) of that rules with the key |line-width|. +% As we can see on this example, it's possible to fill the block by using the +% key |fill| and to draw the frame with the key |draw|\footnote{If the key +% |draw| is used without value, the default color the rules of the tabulars is +% used}. It's also possible to change the width (thickness) of that rules with +% the key |line-width|. % % \subsection{The mono-column blocks} % @@ -666,7 +666,7 @@ version 2005/12/01 or later. % \begin{BVerbatim}[baseline=c,boxwidth=10cm] % \begin{NiceTabular}{cc} % \toprule -% Write & ~emphase#\Block[l]{}{year\\ of birth}@ \\ +% Writer & ~emphase#\Block[l]{}{year\\ of birth}@ \\ % \midrule % Hugo & 1802 \\ % Balzac & 1799 \\ @@ -675,7 +675,7 @@ version 2005/12/01 or later. % \end{BVerbatim} % \begin{NiceTabular}{cc} % \toprule -% Write & \Block[l]{}{year\\ of birth} \\ +% Writer & \Block[l]{}{year\\ of birth} \\ % \midrule % Hugo & 1802 \\ % Balzac & 1799 \\ @@ -1105,7 +1105,8 @@ version 2005/12/01 or later. % \bigskip % 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|. +% |\NiceMatrixOptions|. Thus released, the letter ``|:|'' can be used otherwise +% (for example by the package \pkg{arydshln}). % % \bigskip % \emph{Remark} : In the package \pkg{array} (on which the package @@ -1287,7 +1288,7 @@ version 2005/12/01 or later. % tow colors (provided in second and third argument), beginning % with the row whose number is given in first (mandatory) argument. % -% \colorbox{yellow!50}{\textbf{New 5.8}}\enskip In fact, the first (mandatory) +% \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, @@ -1300,10 +1301,10 @@ 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!50}{\textbf{New 5.8}}\enskip The key |cols| describes a +% \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!50}{\textbf{New 5.8}}\enskip With the key |restart|, +% \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.} @@ -2126,7 +2127,7 @@ version 2005/12/01 or later. % \subsection{The labels of the dotted lines} % % The commands |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, |\Iddots| and |\Hdotsfor| -% (and the command |\line| in the |code-after| which is described +% (and the command |\line| in the |\CodeAfter| which is described % p.~\pageref{line-in-code-after}) accept two optional arguments specified % by the tokens |_| and |^| for labels positionned below and above the line. The % arguments are composed in math mode with |\scriptstyle|. @@ -2148,7 +2149,7 @@ version 2005/12/01 or later. % % \label{customization} % The dotted lines drawn by |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, |\Iddots| -% and |\Hdotsfor| (and by the command |\line| in the |code-after| which is described +% 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 % between square brackets after the command): % \begin{itemize} @@ -2269,47 +2270,189 @@ version 2005/12/01 or later. % % % -% \section{The code-after} +% \section{The \textbackslash CodeAfter} % % \label{code-after} % The option |code-after| may be used to give some code that will be executed % after the construction of the matrix.\footnote{There is also a key % |code-before| described p.~\pageref{code-before}.} % -% A special command, called |\line|, is available to draw 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} +% \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|. +% +% \medskip +% 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} % % \medskip % \begin{BVerbatim}[baseline=c,boxwidth=11cm] % \NiceMatrixOptions{xdots/shorten = 0.6 em} -% \begin{pNiceMatrix}[~emphase#code-after=\line{2-2}{3-3}@] +% \begin{pNiceMatrix} % I & 0 & \Cdots &0 \\ % 0 & I & \Ddots &\Vdots\\ % \Vdots &\Ddots & I &0 \\ % 0 &\Cdots & 0 &I +% ~emphase#\CodeAfter \line{2-2}{3-3}@ % \end{pNiceMatrix} % \end{BVerbatim} % \begin{scope} % \NiceMatrixOptions{xdots/shorten = 0.6 em} -% $\begin{pNiceMatrix}[code-after=\line{2-2}{3-3}] +% $\begin{pNiceMatrix} % I & 0 & \Cdots &0 \\ % 0 & I & \Ddots &\Vdots\\ % \Vdots &\Ddots & I &0 \\ % 0 &\Cdots & 0 &I +% \CodeAfter \line{2-2}{3-3} % \end{pNiceMatrix}$ % \end{scope} % +% +% \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 +% of the array considered as a submatrix. The command |\SubMatrix| takes in five +% arguments: +% \begin{itemize} +% \item the first argument is the left delimiter, which may be any extensible delimiter +% provided by LaTeX : |(|, |[|, |\{|, |\langle|, |\lgroup|, |\lfloor|, etc. but also +% the null delimiter |.|; +% \item the second argument is the upper-left corner of the submatrix with the +% syntax $i$|-|$j$ where $i$ the number of row and $j$ the number of column; +% \item the third argument is the lower-right corner with the same syntax; +% \item the fourth argument is the right delimiter; +% \item the last argument, which is optional, is a list of key-value pairs. +% \end{itemize} +% +% One should remark that the command |\SubMatrix| draws the delimiters after the +% construction of the array: no space is inserted by the command |\SubMatrix| +% itself. That's why, in the following example, we have used the key |margin| +% and you have added by hand some space between the third and fourth column with +% |@{\hspace{1.5em}}| in the preamble of the array. +% % \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| (for an example, cf. -% p.~\pageref{example-CodeAfter}). +% \begin{scope} +% \fvset{commandchars=\~\#\+}% +% \begin{BVerbatim}[boxwidth=11cm,baseline=c] +% \[\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 +% \CodeAfter +% ~emphase#\SubMatrix({1-1}{3-3})+ +% ~emphase#\SubMatrix({1-4}{3-4})+ +% \end{NiceArray}\] +% \end{BVerbatim} +% \end{scope} +% $\begin{NiceArray}{ccc@{\hspace{1.5em}}c}[cell-space-limits=2pt,margin] +% 1 & 1 & 1 & x \\ +% \dfrac{1}{4} & \dfrac{1}{2} & \dfrac{1}{4} & y \\ +% 1 & 2 & 3 & z +% \CodeAfter +% \SubMatrix({1-1}{3-3}) +% \SubMatrix({1-4}{3-4}) +% \end{NiceArray}$ % +% \bigskip +% The options of the command |\SubMatrix| are as follows: +% \begin{itemize} +% \item |left-xshift| and |right-shift| 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 +% 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 +% 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 +% \begin{scope} +% \fvset{commandchars=\~\#\!}% +% \begin{BVerbatim}[baseline=c,boxwidth=11cm] +% $\begin{NiceArray}{cc@{\hspace{5mm}}l}% +% [cell-space-limits=2pt] +% & & \frac12 \\ +% & & \frac14 \\[1mm] +% a & b & \frac12a+\frac14b \\ +% c & d & \frac12c+\frac14d \\ +% \CodeAfter +% \SubMatrix({1-3}{2-3}) +% \SubMatrix({3-1}{4-2}) +% \SubMatrix({3-3}{4-3}) +% \end{NiceArray}$ +% \end{BVerbatim} +% \end{scope} +% $\begin{NiceArray}{cc@{\hspace{5mm}}l}[cell-space-limits=2pt] +% & & \frac12 \\ +% & & \frac14 \\[1mm] +% a & b & \frac12a+\frac14b \\ +% c & d & \frac12c+\frac14d \\ +% \CodeAfter +% \SubMatrix({1-3}{2-3}) +% \SubMatrix({3-1}{4-2}) +% \SubMatrix({3-3}{4-3}) +% \end{NiceArray}$ +% +% \medskip +% Here is the same example with the key |slim| used for one of the submatrices. +% +% \medskip +% \begin{scope} +% \fvset{commandchars=\~\#\!}% +% \begin{BVerbatim}[baseline=c,boxwidth=11cm] +% $\begin{NiceArray}{cc@{\hspace{5mm}}l}% +% [cell-space-limits=2pt] +% & & \frac12 \\ +% & & \frac14 \\[1mm] +% a & b & \frac12a+\frac14b \\ +% c & d & \frac12c+\frac14d \\ +% \CodeAfter +% \SubMatrix({1-3}{2-3})[~emphase#slim!] +% \SubMatrix({3-1}{4-2}) +% \SubMatrix({3-3}{4-3}) +% \end{NiceArray}$ +% \end{BVerbatim} +% \end{scope} +% $\begin{NiceArray}{cc@{\hspace{5mm}}l}[cell-space-limits=2pt] +% & & \frac12 \\ +% & & \frac14 \\[1mm] +% a & b & \frac12a+\frac14b \\ +% c & d & \frac12c+\frac14d \\ +% \CodeAfter +% \SubMatrix({1-3}{2-3})[slim] +% \SubMatrix({3-1}{4-2}) +% \SubMatrix({3-3}{4-3}) +% \end{NiceArray}$ +% +% +% \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 +% p.~\pageref{node-sub-matrix}. +% % \section{The notes in the tabulars} % % \label{s:notes} @@ -2812,7 +2955,7 @@ version 2005/12/01 or later. % exists) has also the number~$0$.}. Of course, the user must not change the % value of these counters which are used internally by \pkg{nicematrix}. % -% In the |code-before| (cf. p. \pageref{code-before}) and in the |code-after| +% In the |code-before| (cf. p. \pageref{code-before}) and in the |\CodeAfter| % (cf. p. \pageref{code-after}), |iRow| represents the total number of rows % (excepted the potential exterior rows) and |jCol| represents the total number % of columns (excepted the potential exterior columns). @@ -3019,7 +3162,7 @@ version 2005/12/01 or later. % Don't forget the options |remember picture| and |overlay|. % % \bigskip -% In the |code-after|, the things are easier : one must refer to the nodes with +% In the |\CodeAfter|, the things are easier : one must refer to the nodes with % the form $i$-$j$ (we don't have to indicate the environment which is of % course the current environment). % @@ -3281,7 +3424,7 @@ version 2005/12/01 or later. % 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 |code-after|. +% 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 \\ @@ -3306,7 +3449,7 @@ version 2005/12/01 or later. % % \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 |code-after|) to the +% 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$|)|. % @@ -3350,6 +3493,44 @@ version 2005/12/01 or later. % 1 & 8 & 28 & 56 & 70 & 56 & 28 & 8 & 1 % \end{NiceMatrix}\] % +% \subsection{The nodes corresponding to the command \textbackslash SubMatrix} +% +% \label{node-sub-matrix} +% +% The command |\SubMatrix| available in the |\CodeAfter| has been described +% p.~\pageref{sub-matrix}. +% +% \smallskip +% If a command |\SubMatrix| has been used with the key |name| with an expression +% such as |name=|\textsl{\ttfamily MyName} three PGF/Tikz nodes are created +% with the names \textsl{\ttfamily MyName}|-left|, \textsl{\ttfamily MyName} and +% \textsl{\ttfamily MyName}|-right|. +% +% \smallskip +% The nodes \textsl{\ttfamily MyName}|-left| and \textsl{\ttfamily +% MyName}|-right| correspond to the delimiters left and right and the node +% \textsl{\ttfamily MyName} correspond to the submatrix itself. +% +% \medskip +% In the following example, we have highlighted these nodes (the submatrix itself has +% been created with |\SubMatrix\{{2-2}{3-3}\}|). +% +% \[\begin{pNiceMatrix} +% 121 & 23 & 345 & 345\\ +% 45 & 346 & 863 & 444\\ +% 3462 & 38458 & 34 & 294 \\ +% 34 & 7 & 78 & 309 \\ +% \CodeAfter +% \SubMatrix\{{2-2}{3-3}\}[name=A] +% \begin{tikzpicture} +% [every node/.style = {blend mode = multiply, +% inner sep = 0 pt}] +% \node [fit = (A),fill = red!15] {} ; +% \node [fit = (A-left),fill = blue!15] {} ; +% \node [fit = (A-right),fill = blue!15] {} ; +% \end{tikzpicture} +% \end{pNiceMatrix}\] +% % \section{API for the developpers} % % The package \pkg{nicematrix} provides two variables which are internal but @@ -3643,6 +3824,17 @@ version 2005/12/01 or later. % The package \pkg{nicematrix} is not fully compatible with the package % \pkg{arydshln} (because this package redefines many internal of \pkg{array}). % +% Anyway, in order to use \pkg{arydshln}, one must first free the letter ``|:|'' +% by giving a new letter for the vertical dotted rules of \pkg{nicematrix}: +% +% \begin{Verbatim} +% \NiceMatrixOptions{letter-for-dotted-lines=;} +% \end{Verbatim} +% +% \bigskip +% As of 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. % % \section{Examples} % @@ -4459,7 +4651,6 @@ version 2005/12/01 or later. % \begin{macrocode} \RequirePackage { array } \RequirePackage { amsmath } -\RequirePackage { xparse } % \end{macrocode} % % \bigskip @@ -4482,6 +4673,8 @@ version 2005/12/01 or later. % \bigskip % \subsection*{Technical definitions} % +% +% \medskip % \begin{macrocode} \bool_new:N \c_@@_in_preamble_bool \bool_set_true:N \c_@@_in_preamble_bool @@ -4489,11 +4682,15 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} +\bool_new:N \c_@@_arydshln_loaded_bool \bool_new:N \c_@@_booktabs_loaded_bool \bool_new:N \c_@@_enumitem_loaded_bool \bool_new:N \c_@@_tikz_loaded_bool \AtBeginDocument { + \@ifpackageloaded { arydshln } + { \bool_set_true:N \c_@@_arydshln_loaded_bool } + { } \@ifpackageloaded { booktabs } { \bool_set_true:N \c_@@_booktabs_loaded_bool } { } @@ -4526,9 +4723,11 @@ version 2005/12/01 or later. } % \end{macrocode} % -% We test whether the current class is \cls{revtex4-1} or \cls{revtex4-2} -% because these classes redefines |\array| (of \pkg{array}) in a way -% incompatible with our programmation. +% 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 +% version \cls{revtex4-2} is 4.2e (compatible with \pkg{booktabs}). +% % \begin{macrocode} \bool_new:N \c_@@_revtex_bool \@ifclassloaded { revtex4-1 } @@ -4538,8 +4737,17 @@ version 2005/12/01 or later. { \bool_set_true:N \c_@@_revtex_bool } { } % \end{macrocode} +% Maybe one of the previous classes will be loaded inside another class... We +% try to detect that situation. +% \begin{macrocode} +\cs_if_exist:NT \rvtx@ifformat@geq { \bool_set_true:N \c_@@_revtex_bool } +% \end{macrocode} % % +% \begin{macrocode} +\cs_generate_variant:Nn \tl_if_single_token_p:n { V } +% \end{macrocode} +% % \bigskip % We define a command |\iddots| similar to |\ddots| ($\ddots$) but with dots % going forward ($\iddots$). We use |\ProvideDocumentCommand| and so, if the @@ -5185,8 +5393,8 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% \pkg{expl3} provides scratch dimension |\l_tmpa_dim| and |\l_tmpd_dim|. We -% creates two other in the same spirit (if they don't exist yet : that's why we +% \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 % use |\dim_zero_new:N|). % \begin{macrocode} \dim_zero_new:N \l_tmpc_dim @@ -5195,7 +5403,7 @@ version 2005/12/01 or later. % % \bigskip % Some cells will be declared as ``empty'' (for example a cell with an -% instrution |\Cdots|). +% instruction |\Cdots|). % \begin{macrocode} \bool_new:N \g_@@_empty_cell_bool % \end{macrocode} @@ -5263,6 +5471,14 @@ version 2005/12/01 or later. % % % \medskip +% The list of the names of the potential |\SubMatrix| in the |code-after| 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 % exterior columns). @@ -5702,8 +5918,10 @@ version 2005/12/01 or later. % initial value is 0.45~em but it will be changed if the option |small| is used. % \begin{macrocode} \dim_new:N \l_@@_inter_dots_dim -\dim_set:Nn \l_@@_inter_dots_dim { 0.45 em } +\AtBeginDocument { \dim_set:Nn \l_@@_inter_dots_dim { 0.45 em } } % \end{macrocode} +% The |\AtBeginDocument| is only a security in case \cls{revtex4-1} is used +% (even though it is obsolete). % % \bigskip % The following dimension is the minimal distance between a node (in fact an @@ -5712,8 +5930,10 @@ version 2005/12/01 or later. % distance may vary a little). % \begin{macrocode} \dim_new:N \l_@@_xdots_shorten_dim -\dim_set:Nn \l_@@_xdots_shorten_dim { 0.3 em } +\AtBeginDocument { \dim_set:Nn \l_@@_xdots_shorten_dim { 0.3 em } } % \end{macrocode} +% The |\AtBeginDocument| is only a security in case \cls{revtex4-1} is used +% (even though it is obsolete). % % \bigskip % The following dimension is the radius of the dots for the dotted lines (when @@ -5721,8 +5941,11 @@ version 2005/12/01 or later. % value is 0.53~pt but it will be changed if the option |small| is used. % \begin{macrocode} \dim_new:N \l_@@_radius_dim -\dim_set:Nn \l_@@_radius_dim { 0.53 pt } +\AtBeginDocument { \dim_set:Nn \l_@@_radius_dim { 0.53 pt } } % \end{macrocode} +% The |\AtBeginDocument| is only a security in case \cls{revtex4-1} is used +% (even if it is obsolete). +% % % \bigskip % The token list |\l_@@_xdots_line_style_tl| corresponds to the option |tikz| of the @@ -5795,8 +6018,10 @@ version 2005/12/01 or later. % % \begin{macrocode} \dim_new:N \l_@@_notes_above_space_dim -\dim_set:Nn \l_@@_notes_above_space_dim { 1 mm } +\AtBeginDocument { \dim_set:Nn \l_@@_notes_above_space_dim { 1 mm } } % \end{macrocode} +% The |\AtBeginDocument| is only a security in case \cls{revtex4-1} is used +% (even if it is obsolete). % % \bigskip % The flag |\l_@@_nullify_dots_bool| corresponds to the option |nullify-dots|. @@ -5955,10 +6180,10 @@ version 2005/12/01 or later. cell-space-top-limit .value_required:n = true , cell-space-bottom-limit .dim_set:N = \l_@@_cell_space_bottom_limit_dim , cell-space-bottom-limit .value_required:n = true , - cell-space-limits .code:n = + cell-space-limits .meta:n = { - \dim_set:Nn \l_@@_cell_space_bottom_limit_dim { #1 } - \dim_set:Nn \l_@@_cell_space_top_limit_dim { #1 } + cell-space-top-limit = #1 , + cell-space-bottom-limit = #1 , } , cell-spaces-limits .value_required:n = true , xdots .code:n = \keys_set:nn { NiceMatrix / xdots } { #1 } , @@ -6143,6 +6368,8 @@ version 2005/12/01 or later. NiceMatrixOptions / xdots .inherit:n = NiceMatrix / xdots , NiceMatrixOptions / rules .inherit:n = NiceMatrix / rules , NiceMatrixOptions / notes .inherit:n = NiceMatrix / notes , + NiceMatrixOptions / sub-matrix .inherit:n = NiceMatrix / sub-matrix , + CodeAfter / xdots .inherit:n = NiceMatrix / xdots , NiceMatrix .inherit:n = { NiceMatrix / Global , @@ -6200,7 +6427,12 @@ version 2005/12/01 or later. % \end{macrocode} % The key |transparent| is now considered as obsolete (because its name is ambiguous). % \begin{macrocode} - transparent .meta:n = { renew-dots , renew-matrix } , + transparent .code:n = + { + \@@_renew_matrix: + \bool_set_true:N \l_@@_renew_dots_bool + \@@_error:n { Key~transparent } + } , transparent .value_forbidden:n = true, % \end{macrocode} % @@ -6251,6 +6483,9 @@ version 2005/12/01 or later. letter-for-dotted-lines .value_required:n = true , notes .code:n = \keys_set:nn { NiceMatrix / notes } { #1 } , notes .value_required:n = true , + sub-matrix .code:n = + \keys_set:nn { NiceMatrix / sub-matrix } { #1 } , + sub-matrix .value_required:n = true , unknown .code:n = \@@_error:n { Unknown~key~for~NiceMatrixOptions } } % \end{macrocode} @@ -6953,11 +7188,11 @@ version 2005/12/01 or later. % |\Cdots|, etc. give the same spacing (except when the option |nullify-dots| is % used). % \begin{macrocode} - \cs_set_eq:NN \@@_old_ldots \ldots - \cs_set_eq:NN \@@_old_cdots \cdots - \cs_set_eq:NN \@@_old_vdots \vdots - \cs_set_eq:NN \@@_old_ddots \ddots - \cs_set_eq:NN \@@_old_iddots \iddots + \cs_set_eq:NN \@@_old_ldots \ldots + \cs_set_eq:NN \@@_old_cdots \cdots + \cs_set_eq:NN \@@_old_vdots \vdots + \cs_set_eq:NN \@@_old_ddots \ddots + \cs_set_eq:NN \@@_old_iddots \iddots \bool_if:NTF \l_@@_standard_cline_bool { \cs_set_eq:NN \cline \@@_standard_cline } { \cs_set_eq:NN \cline \@@_cline } @@ -7065,8 +7300,19 @@ version 2005/12/01 or later. % a mathematical formula. % \begin{macrocode} \bgroup +% \end{macrocode} +% +% \bigskip +% \begin{macrocode} \tl_set:Nn \l_@@_left_delim_tl { #1 } \tl_set:Nn \l_@@_right_delim_tl { #2 } + \tl_gset:Nn \g_@@_preamble_tl { #4 } +% \end{macrocode} +% +% +% \bigskip +% +% \begin{macrocode} \int_gzero:N \g_@@_block_box_int \dim_zero:N \g_@@_width_last_col_dim \dim_zero:N \g_@@_width_first_col_dim @@ -7321,7 +7567,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \medskip -% We compute the width of the two delimiters. +% We compute the width of both delimiters. % \begin{macrocode} \dim_zero_new:N \l_@@_left_delim_dim \dim_zero_new:N \l_@@_right_delim_dim @@ -7334,9 +7580,9 @@ version 2005/12/01 or later. % \end{macrocode} % The command |\bBigg@| is a command of \pkg{amsmath}. % \begin{macrocode} - \hbox_set:Nn \l_tmpa_box { $ \bBigg@ 5 #1 $ } + \hbox_set:Nn \l_tmpa_box { $ \bBigg@ 5 \l_@@_left_delim_tl $ } \dim_set:Nn \l_@@_left_delim_dim { \box_wd:N \l_tmpa_box } - \hbox_set:Nn \l_tmpa_box { $ \bBigg@ 5 #2 $ } + \hbox_set:Nn \l_tmpa_box { $ \bBigg@ 5 \l_@@_right_delim_tl $ } \dim_set:Nn \l_@@_right_delim_dim { \box_wd:N \l_tmpa_box } } % \end{macrocode} @@ -7360,7 +7606,7 @@ version 2005/12/01 or later. % \bigskip % The preamble will be constructed in |\g_@@_preamble_tl|. % \begin{macrocode} - \@@_construct_preamble:n { #4 } + \@@_construct_preamble: % \end{macrocode} % % Now, the preamble is constructed in |\g_@@_preamble_tl| @@ -7505,7 +7751,7 @@ version 2005/12/01 or later. \c_math_toggle_token \tl_if_empty:NF \l_@@_delimiters_color_tl { \color { \l_@@_delimiters_color_tl } } - \left #1 + \exp_after:wN \left \l_@@_left_delim_tl \vcenter { % \end{macrocode} @@ -7513,7 +7759,6 @@ version 2005/12/01 or later. % height in |\l_tmpa_dim|). The |\hbox:n| (or |\hbox|) is necessary here. % \begin{macrocode} \skip_vertical:N -\l_tmpa_dim - \skip_vertical:N -\arrayrulewidth \hbox { \bool_if:NTF \l_@@_NiceTabular_bool @@ -7529,9 +7774,8 @@ version 2005/12/01 or later. % height in |\l_tmpb_dim|). % \begin{macrocode} \skip_vertical:N -\l_tmpb_dim - \skip_vertical:N \arrayrulewidth } - \right #2 + \exp_after:wN \right \l_@@_right_delim_tl \c_math_toggle_token } % \end{macrocode} @@ -7583,12 +7827,11 @@ version 2005/12/01 or later. % The transformation of the preamble is an operation in several steps. % % \bigskip -% The argument of |\@@_construct_preamble:n| is the preamble as given by the -% final user to the environement |{NiceTabular}| (or a variant). The preamble -% will be constructed in |\g_@@_preamble_tl|. -% +% The preamble given by the final use is in |\g_@@_preamble_tl| and the modified +% version will be stored in |\g_@@_preamble_tl| also. +% % \begin{macrocode} -\cs_new_protected:Npn \@@_construct_preamble:n #1 +\cs_new_protected:Npn \@@_construct_preamble: { % \end{macrocode} % First, we will do an ``expansion'' of the preamble with the tools of the @@ -7616,8 +7859,7 @@ version 2005/12/01 or later. % (excepted the treatment on both sides of the preamble which will be done at % the end). % \begin{macrocode} - \bool_if:NTF \l_@@_Matrix_bool - { \tl_gset:Nn \g_@@_preamble_tl { #1 } } + \bool_if:NF \l_@@_Matrix_bool { \@@_newcolumntype w [ 2 ] { \@@_w: { ##1 } { ##2 } } \@@_newcolumntype W [ 2 ] { \@@_W: { ##1 } { ##2 } } @@ -7626,7 +7868,7 @@ version 2005/12/01 or later. % First, we have to store our preamble in the token register |\@temptokena| % (those ``token registers'' are not supported by \pkg{expl3}). % \begin{macrocode} - \@temptokena { #1 } + \exp_args:NV \@temptokena \g_@@_preamble_tl % \end{macrocode} % Initialisation of a flag used by \pkg{array} to detect the end of the expansion. % \begin{macrocode} @@ -7638,6 +7880,7 @@ version 2005/12/01 or later. \@whilesw \if@tempswa \fi { \@tempswafalse \the \NC@list } % \end{macrocode} % +% % \bigskip % Now, we have to ``patch'' that preamble by transforming some columns. % We will insert in the TeX flow the preamble in its actual form (that is to say @@ -7656,7 +7899,7 @@ version 2005/12/01 or later. { \tl_gclear:N \g_@@_preamble_tl } % \end{macrocode} % The counter |\l_tmpa_int| will count the number of consecutive occurrences -% of the symbole \verb+|+. +% of the symbol \verb+|+. % \begin{macrocode} \int_zero:N \l_tmpa_int % \end{macrocode} @@ -7747,15 +7990,30 @@ version 2005/12/01 or later. \@@_w: { \@@_patch_preamble_v:nnnn { } #1 } \@@_W: { \@@_patch_preamble_v:nnnn { \cs_set_eq:NN \hss \hfil } #1 } \@@_true_c: { \@@_patch_preamble_vi:n #1 } - C { \@@_error:nn { old~column~type } C } - L { \@@_error:nn { old~column~type } L } - R { \@@_error:nn { old~column~type } R } + ( { \@@_patch_preamble_vii:n #1 } + [ { \@@_patch_preamble_vii:n #1 } + \{ { \@@_patch_preamble_vii:n #1 } + ) { \@@_patch_preamble_viii:n #1 } + ] { \@@_patch_preamble_viii:n #1 } + \} { \@@_patch_preamble_viii:n #1 } + C { \@@_error:nn { old~column~type } #1 } + L { \@@_error:nn { old~column~type } #1 } + R { \@@_error:nn { old~column~type } #1 } \q_stop { } } { \str_if_eq:VnTF \l_@@_letter_for_dotted_lines_str { #1 } - { \@@_patch_preamble_vii:n #1 } - { \@@_fatal:nn { unknown~column~type } { #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 { : } + \@@_patch_preamble:n + } + { \@@_fatal:nn { unknown~column~type } { #1 } } + } } } % \end{macrocode} @@ -7772,14 +8030,13 @@ version 2005/12/01 or later. < \@@_end_Cell: } % \end{macrocode} -% We increment the counter of columns. +% +% We increment the counter of columns and then we test for the presence of a |<|. % \begin{macrocode} \int_gincr:N \c@jCol - \@@_patch_preamble_viii:n + \@@_patch_preamble_x:n } % \end{macrocode} -% -% % % \medskip % For |>|, |!| and |@| @@ -7852,10 +8109,10 @@ version 2005/12/01 or later. < { \box_use:N \@arstrutbox \end { minipage } \@@_end_Cell: } } % \end{macrocode} -% We increment the counter of columns. +% We increment the counter of columns, and then we test for the presence of a |<|. % \begin{macrocode} \int_gincr:N \c@jCol - \@@_patch_preamble_viii:n + \@@_patch_preamble_x:n } % \end{macrocode} % @@ -7882,10 +8139,10 @@ version 2005/12/01 or later. } } % \end{macrocode} -% We increment the counter of columns. +% We increment the counter of columns and then we test for the presence of a |<|. % \begin{macrocode} \int_gincr:N \c@jCol - \@@_patch_preamble_viii:n + \@@_patch_preamble_x:n } % \end{macrocode} % @@ -7897,15 +8154,67 @@ version 2005/12/01 or later. { \tl_gput_right:Nn \g_@@_preamble_tl { c } % \end{macrocode} -% We increment the counter of columns. +% We increment the counter of columns and then we test for the presence of a |<|. % \begin{macrocode} \int_gincr:N \c@jCol - \@@_patch_preamble_viii:n + \@@_patch_preamble_x:n + } +% \end{macrocode} +% +% \medskip +% For |(|, |[| and |\{|. +% \begin{macrocode} +\cs_new_protected:Npn \@@_patch_preamble_vii:n #1 + { + \bool_if:NT \l_@@_small_bool + { \@@_fatal:n { Delimiter~with~small } } +% \end{macrocode} +% If we are before the column 1, we reserve space for the left delimiter. +% \begin{macrocode} + \int_compare:nNnT \c@jCol = \c_zero_int + { \tl_gput_right:Nx \g_@@_preamble_tl { ! { \enskip } } } + \tl_gput_right:Nx \g_@@_internal_code_after_tl + { \@@_delimiter:nnn #1 { \@@_succ:n \c@jCol } \c_true_bool } + \@@_patch_preamble:n + } +% \end{macrocode} +% +% \bigskip +% For |)|, |]| and |\}|. +% \begin{macrocode} +\cs_new_protected:Npn \@@_patch_preamble_viii:n #1 + { + \bool_if:NT \l_@@_small_bool + { \@@_fatal:n { Delimiter~with~small } } + \tl_gput_right:Nx \g_@@_internal_code_after_tl + { \@@_delimiter:nnn #1 { \int_use:N \c@jCol } \c_false_bool } +% \end{macrocode} +% After this closing delimiter, we have to test whether there is a opening +% delimiter (we consider that there can't be a second closing delimiter) in +% order to add an horizontal space (equal to 0.5 em). +% \begin{macrocode} + \@@_patch_preamble_viii_i:n + } +% \end{macrocode} +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_patch_preamble_viii_i:n #1 + { + \bool_lazy_any:nT + { + { \str_if_eq_p:nn { #1 } ( } + { \str_if_eq_p:nn { #1 } [ } + { \str_if_eq_p:nn { #1 } \{ } + { \str_if_eq_p:nn { #1 } \q_stop } + } + { \tl_gput_right:Nn \g_@@_preamble_tl { ! { \enskip } } } + \@@_patch_preamble:n #1 } % \end{macrocode} % +% % \begin{macrocode} -\cs_new_protected:Npn \@@_patch_preamble_vii:n #1 +\cs_new_protected:Npn \@@_patch_preamble_xi:n #1 { \tl_gput_right:Nn \g_@@_preamble_tl { ! { \skip_horizontal:N 2\l_@@_radius_dim } } @@ -7923,7 +8232,7 @@ version 2005/12/01 or later. % |<{..}| because, after those potential |<{...}|, we have to insert % |!{\skip_horizontal:N ...}| when the key |vlines| is used. % \begin{macrocode} -\cs_new_protected:Npn \@@_patch_preamble_viii:n #1 +\cs_new_protected:Npn \@@_patch_preamble_x:n #1 { \str_if_eq:nnTF { #1 } { < } \@@_patch_preamble_ix:n @@ -7942,10 +8251,11 @@ version 2005/12/01 or later. \cs_new_protected:Npn \@@_patch_preamble_ix:n #1 { \tl_gput_right:Nn \g_@@_preamble_tl { < { #1 } } - \@@_patch_preamble_viii:n + \@@_patch_preamble_x:n } % \end{macrocode} % +% % % \bigskip % The command |\@@_put_box_in_flow:| puts the box |\l_tmpa_box| (which contains @@ -8105,7 +8415,7 @@ version 2005/12/01 or later. % \begin{macrocode} { \CT@arc@ \hrule height \heavyrulewidth } } - { \@@_error:n { bottomule~without~booktabs } } + { \@@_error:n { bottomrule~without~booktabs } } } \l_@@_notes_code_after_tl \seq_gclear:N \g_@@_tabularnotes_seq @@ -8315,7 +8625,7 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Npn \@@_light_syntax_i #1\CodeAfter #2\q_stop { - \tl_gput_right:Nn \g_nicematrix_code_after_tl { #2 } + \tl_gput_right:Nn \g_nicematrix_code_after_tl { #2 } % \end{macrocode} % The body of the array, which is stored in the argument |#1|, is now % splitted into items (and \emph{not} tokens). @@ -9068,6 +9378,7 @@ version 2005/12/01 or later. } } \cs_set_eq:NN \line \@@_line + \cs_set_eq:NN \SubMatrix \@@_SubMatrix % \end{macrocode} % When |light-syntax| is used, we insert systematically a |\CodeAfter| in the % flow. Thus, it's possible to have two instructions |\CodeAfter| and the second @@ -9076,9 +9387,18 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_set_eq:NN \CodeAfter \prg_do_nothing: % \end{macrocode} -% And here's the |code-after|: +% +% 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). % \begin{macrocode} - \g_nicematrix_code_after_tl + \seq_gclear:N \g_@@_submatrix_names_seq +% \end{macrocode} +% And here's the |code-after|. Since the |code-after| 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} + \exp_last_unbraced:NV \@@_CodeAfter_keys: \g_nicematrix_code_after_tl + \scan_stop: \tl_gclear:N \g_nicematrix_code_after_tl \group_end: % \end{macrocode} @@ -9128,6 +9448,15 @@ version 2005/12/01 or later. } % \end{macrocode} % +% \bigskip +% The following command will extract the potential options (between square +% brackets) at the beginning of the |code-after| (that is to say, when +% |\CodeAfter| is used, the options of that ``command'' |\CodeAfter|). +% \begin{macrocode} +\NewDocumentCommand \@@_CodeAfter_keys: { O { } } + { \keys_set:nn { NiceMatrix / CodeAfter } { #1 } } +% \end{macrocode} +% % % \bigskip % We remind that the first mandatory argument of the command |\Block| is the @@ -9970,9 +10299,69 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Npn \@@_draw_line: { + \pgfrememberpicturepositiononpagetrue + \pgf@relevantforpicturesizefalse + \tl_if_eq:NNTF \l_@@_xdots_line_style_tl \c_@@_standard_tl + \@@_draw_standard_dotted_line: + \@@_draw_non_standard_dotted_line: + } +% \end{macrocode} +% +% \medskip +% We have to do a special construction with |\exp_args:NV| to be able to put in +% the list of options in the correct place in the Tikz instruction. +% \begin{macrocode} +\cs_new_protected:Npn \@@_draw_non_standard_dotted_line: + { + \begin { scope } + \exp_args:No \@@_draw_non_standard_dotted_line:n + { \l_@@_xdots_line_style_tl , \l_@@_xdots_color_tl } + } +% \end{macrocode} +% We have used the fact that, in \textsc{pgf}, un color name can be put directly +% in a list of options (that's why we have put diredtly |\l_@@_xdots_color_tl|). +% +% \smallskip +% The argument of |\@@_draw_non_standard_dotted_line:n| is, in fact, the list of options. +% \begin{macrocode} +\cs_new_protected:Npn \@@_draw_non_standard_dotted_line:n #1 + { + \@@_draw_non_standard_dotted_line:nVV + { #1 } + \l_@@_xdots_up_tl + \l_@@_xdots_down_tl + } % \end{macrocode} -% First, we put the labels. +% % \begin{macrocode} +\cs_new_protected:Npn \@@_draw_non_standard_dotted_line:nnn #1 #2 #3 + { + \draw + [ + #1 , + shorten~> = \l_@@_xdots_shorten_dim , + shorten~< = \l_@@_xdots_shorten_dim , + ] + ( \l_@@_x_initial_dim , \l_@@_y_initial_dim ) +% \end{macrocode} +% Be careful: We can't put |\c_math_toggle_token| instead of |$| in the +% following lines because we are in the contents of Tikz nodes (and they will be +% \emph{rescanned} if the Tikz library \pkg{babel} is loaded). +% \begin{macrocode} + -- node [ sloped , above ] { $ \scriptstyle #2 $ } + node [ sloped , below ] { $ \scriptstyle #3 $ } + ( \l_@@_x_final_dim , \l_@@_y_final_dim ) ; + \end { scope } + } +\cs_generate_variant:Nn \@@_draw_non_standard_dotted_line:nnn { n V V } +% \end{macrocode} +% +% \bigskip +% The command |\@@_draw_standard_dotted_line:| draws the line with our system of points +% (which gives a dotted line with real round points). +% \begin{macrocode} +\cs_new_protected:Npn \@@_draw_standard_dotted_line: + { \bool_lazy_and:nnF { \tl_if_empty_p:N \l_@@_xdots_up_tl } { \tl_if_empty_p:N \l_@@_xdots_down_tl } @@ -10017,52 +10406,6 @@ version 2005/12/01 or later. { \pgfusepath { } } \endpgfscope } - \pgfrememberpicturepositiononpagetrue - \pgf@relevantforpicturesizefalse - \tl_if_eq:NNTF \l_@@_xdots_line_style_tl \c_@@_standard_tl - \@@_draw_standard_dotted_line: - \@@_draw_non_standard_dotted_line: - } -% \end{macrocode} -% -% \medskip -% We have to do a special construction with |\exp_args:NV| to be able to put in -% the list of options in the correct place in the Tikz instruction. -% \begin{macrocode} -\cs_new_protected:Npn \@@_draw_non_standard_dotted_line: - { - \begin { scope } - \exp_args:No \@@_draw_non_standard_dotted_line:n - { \l_@@_xdots_line_style_tl , \l_@@_xdots_color_tl } - } -% \end{macrocode} -% We have used the fact that, in \textsc{pgf}, un color name can be put directly -% in a list of options (that's why we have put diredtly |\l_@@_xdots_color_tl|). -% -% \smallskip -% The argument of |\@@_draw_non_standard_dotted_line:n| is, in fact, the list of options. -% \begin{macrocode} -\cs_new_protected:Npn \@@_draw_non_standard_dotted_line:n #1 - { - \draw - [ - #1 , - shorten~> = \l_@@_xdots_shorten_dim , - shorten~< = \l_@@_xdots_shorten_dim , - ] - ( \l_@@_x_initial_dim , \l_@@_y_initial_dim ) - -- - ( \l_@@_x_final_dim , \l_@@_y_final_dim ) ; - \end { scope } - } -% \end{macrocode} -% -% \bigskip -% The command |\@@_draw_standard_dotted_line:| draws the line with our system of points -% (which give a dotted line with real round points). -% \begin{macrocode} -\cs_new_protected:Npn \@@_draw_standard_dotted_line: - { \group_begin: % \end{macrocode} % The dimension |\l_@@_l_dim| is the length $\ell$ of the line to draw. We use @@ -10132,7 +10475,7 @@ version 2005/12/01 or later. \l_@@_inter_dots_dim } } - { + { \int_set:Nn \l_tmpa_int { \dim_ratio:nn @@ -10244,7 +10587,8 @@ version 2005/12/01 or later. { #1 , down = #2 , up = #3 } } } - \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_ldots } + \bool_if:NF \l_@@_nullify_dots_bool + { \phantom { \ensuremath { \@@_old_ldots } } } \bool_gset_true:N \g_@@_empty_cell_bool } % \end{macrocode} @@ -10263,7 +10607,8 @@ version 2005/12/01 or later. { #1 , down = #2 , up = #3 } } } - \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_cdots } + \bool_if:NF \l_@@_nullify_dots_bool + { \phantom { \ensuremath { \@@_old_cdots } } } \bool_gset_true:N \g_@@_empty_cell_bool } % \end{macrocode} @@ -10282,7 +10627,8 @@ version 2005/12/01 or later. { #1 , down = #2 , up = #3 } } } - \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_vdots } + \bool_if:NF \l_@@_nullify_dots_bool + { \phantom { \ensuremath { \@@_old_vdots } } } \bool_gset_true:N \g_@@_empty_cell_bool } % \end{macrocode} @@ -10310,7 +10656,8 @@ version 2005/12/01 or later. } } - \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_ddots } + \bool_if:NF \l_@@_nullify_dots_bool + { \phantom { \ensuremath { \@@_old_ddots } } } \bool_gset_true:N \g_@@_empty_cell_bool } % \end{macrocode} @@ -10335,9 +10682,9 @@ version 2005/12/01 or later. \@@_instruction_of_type:nnn \l_@@_draw_first_bool { Iddots } { #1 , down = #2 , up = #3 } } - } - \bool_if:NF \l_@@_nullify_dots_bool { \phantom \@@_old_iddots } + \bool_if:NF \l_@@_nullify_dots_bool + { \phantom { \ensuremath { \@@_old_iddots } } } \bool_gset_true:N \g_@@_empty_cell_bool } } @@ -10375,9 +10722,9 @@ version 2005/12/01 or later. \cs_set_eq:NN \@@_old_multicolumn \multicolumn \cs_new:Npn \@@_multicolumn:nnn #1 #2 #3 { -% \begin{macrocode} +% \end{macrocode} % We have to act in an expandable way since it will begin by a |\multicolumn|. -% \end{macrocode +% \begin{macrocode} \exp_args:NNe \@@_old_multicolumn { #1 } @@ -13412,6 +13759,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip +% % \subsection*{How to draw the dotted lines transparently} % \begin{macrocode} \cs_set_protected:Npn \@@_renew_matrix: @@ -13630,15 +13978,33 @@ version 2005/12/01 or later. % \bigskip % \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. +% \begin{macrocode} +\keys_define:nn { NiceMatrix / CodeAfter } + { + 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 , + unknown .code:n = \@@_error:n { Unknown~key~for~CodeAfter } + } +% \end{macrocode} +% +% \medskip % In fact, in this subsection, we define the user command |\CodeAfter| for the % case of the ``normal syntax''. For the case of ``light-syntax'', see the % definition of the environment |{@@-light-syntax}| on % p.~\pageref{code-light-syntax}. % +% % \medskip -% In the environments of \pkg{nicematrix}, |\CodeAfter| will be linked to the -% following command |\@@_CodeAfter:|. That macro must \emph{not} be protected -% since it begins with |\omit|. +% In the environments of \pkg{nicematrix}, |\CodeAfter| will be linked to +% |\@@_CodeAfter:|. That macro must \emph{not} be protected since it begins with +% |\omit|. % \begin{macrocode} \cs_new:Npn \@@_CodeAfter: { \omit \@@_CodeAfter_i:n } % \end{macrocode} @@ -13683,8 +14049,363 @@ version 2005/12/01 or later. % \end{macrocode} % % +% \subsection*{The delimiters in the preamble} +% +% The command |\@@_delimiter:nnn| will be used to draw delimiters inside the +% matrix when delimiters are specified in the preamble of the array. It does +% \emph{not} concern the exterior delimiters added by |{NiceArrayWithDelims}| +% (and |{pNiceArray}|, |{pNiceMatrix}|, etc.). +% +% A delimiter in the preamble of the array will write an instruction +% |\@@_delimiter:nnn| in the |\g_@@_internal_code_after_tl| (and also +% potentially add instructions in the preamble provided to |\array| in order to +% add spaces between columns). +% +% \smallskip +% The first argument is the type of delimiter (|(|, |[|, |\{|, |)|, |]| ou +% |\}|). The second argument is the number of colummn. The third argument is a +% boolean equal to |\c_true_bool| (resp. |\c_false_true|) when the delimiter +% must be put on the left (resp. right) side. +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_delimiter:nnn #1 #2 #3 + { + \pgfpicture + \pgfrememberpicturepositiononpagetrue + \pgf@relevantforpicturesizefalse +% \end{macrocode} +% +% \medskip +% |\l_@@_y_initial_dim| and |\l_@@_y_final_dim| will be the $y$-values of the +% extremities of the delimiter we will have to construct. +% \begin{macrocode} + \@@_qpoint:n { row - 1 } + \dim_set_eq:NN \l_@@_y_initial_dim \pgf@y + \@@_qpoint:n { row - \@@_succ:n \c@iRow } + \dim_set_eq:NN \l_@@_y_final_dim \pgf@y +% \end{macrocode} +% +% \medskip +% We will compute in |\l_tmpa_dim| the $x$-value where we will have to put our +% delimiter (on the left side or on the right side). +% \begin{macrocode} + \bool_if:nTF { #3 } + { \dim_set_eq:NN \l_tmpa_dim \c_max_dim } + { \dim_set:Nn \l_tmpa_dim { - \c_max_dim } } + \int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int + { + \cs_if_exist:cT + { pgf @ sh @ ns @ \@@_env: - ##1 - #2 } + { + \pgfpointanchor + { \@@_env: - ##1 - #2 } + { \bool_if:nTF { #3 } { west } { east } } + \dim_set:Nn \l_tmpa_dim + { \bool_if:nTF { #3 } \dim_min:nn \dim_max:nn \l_tmpa_dim \pgf@x } + } + } +% \end{macrocode} +% +% +% Now we can put the delimiter with a node of \textsc{pgf}. +% \begin{macrocode} + \pgfset { inner~sep = \c_zero_dim } + \dim_zero:N \nulldelimiterspace + \pgftransformshift + { + \pgfpoint + { \l_tmpa_dim } + { ( \l_@@_y_initial_dim + \l_@@_y_final_dim + \arrayrulewidth ) / 2 } + } + \pgfnode + { rectangle } + { \bool_if:nTF { #3 } { east } { west } } + { +% \end{macrocode} +% Here is the content of the \textsc{pgf} node, that is to say the delimiter, +% constructed with its right size. +% \begin{macrocode} + \nullfont + \c_math_toggle_token + \tl_if_empty:NF \l_@@_delimiters_color_tl + { \color { \l_@@_delimiters_color_tl } } + \bool_if:nTF { #3 } { \left #1 } { \left . } + \vcenter + { + \nullfont + \hrule \@height + \dim_eval:n { \l_@@_y_initial_dim - \l_@@_y_final_dim } + \@depth \c_zero_dim + \@width \c_zero_dim + } + \bool_if:nTF { #3 } { \right . } { \right #1 } + \c_math_toggle_token + } + { } + { } + \endpgfpicture + } +% \end{macrocode} +% +% \subsection*{The command SubMatrix} +% +% +% \begin{macrocode} +\keys_define:nn { NiceMatrix / sub-matrix } + { + extra-height .dim_set:N = \l_@@_submatrix_extra_height_dim , + extra-height .value_required:n = true , + left-xshift .dim_set:N = \l_@@_submatrix_left_xshift_dim , + left-xshift .value_required:n = true , + right-xshift .dim_set:N = \l_@@_submatrix_right_xshift_dim , + 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 , + 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 + } +% \end{macrocode} +% +% \medskip +% The following keys set is for the command |\SubMatrix| itself (not the tuning +% of |\SubMatrix| that can be done elsewhere). +% \begin{macrocode} +\keys_define:nn { NiceMatrix / SubMatrix } + { + name .code:n = + \tl_if_empty:nTF { #1 } + { \@@_error:n { Invalid~name~format } } + { + \regex_match:nnTF { \A[A-Za-z][A-Za-z0-9]*\Z } { #1 } + { + \seq_if_in:NnTF \g_@@_submatrix_names_seq { #1 } + { \@@_error:nn { Duplicate~name~for~SubMatrix } { #1 } } + { + \str_set:Nn \l_@@_submatrix_name_str { #1 } + \seq_gput_right:Nn \g_@@_submatrix_names_seq { #1 } + } + } + { \@@_error:n { Invalid~name~format } } + } , + name .value_required:n = true , + unknown .code:n = \@@_error:n { Unknown~key~for~SubMatrix } + } +% \end{macrocode} % % \bigskip +% In the |code-after|, the following command |\@@_SubMatrix| will be linked to +% |\SubMatrix|. +% \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 |#4| is the right delimiter; +% \item |#5| is the list of options of the command. +% \end{itemize} +% \begin{macrocode} +\NewDocumentCommand \@@_SubMatrix { m m m m ! O { } } + { + \group_begin: +% \end{macrocode} +% The command |\@@_cut_on_hyphen:w| cuts on the hyphen an argument of the form +% $i$-$j$. The value of $i$ is stored in |\l_tmpa_tl| and the value of $j$ is +% stored in |\l_tmpb_tl|. +% \begin{macrocode} + \@@_cut_on_hyphen:w #3 \q_stop + \tl_clear_new:N \l_tmpc_tl + \tl_clear_new:N \l_tmpd_tl + \tl_set_eq:NN \l_tmpc_tl \l_tmpa_tl + \tl_set_eq:NN \l_tmpd_tl \l_tmpb_tl + \@@_cut_on_hyphen:w #2 \q_stop + \bool_lazy_or:nnTF + { \int_compare_p:nNn \l_tmpc_tl > \g_@@_row_total_int } + { \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 + \pgfrememberpicturepositiononpagetrue + \pgf@relevantforpicturesizefalse + \pgfset { inner~sep = \c_zero_dim } + \dim_set_eq:NN \l_@@_x_initial_dim \c_max_dim + \dim_set:Nn \l_@@_x_final_dim { - \c_max_dim } +% \end{macrocode} +% The last value of |\int_step_inline:nnn| is provided by currifycation. +% \begin{macrocode} + \bool_if:NTF \l_@@_submatrix_slim_bool + { \int_step_inline:nnn \l_tmpa_tl \l_tmpc_tl } + { \int_step_inline:nnn \l_@@_first_row_int \g_@@_row_total_int } + { + \cs_if_exist:cT + { pgf @ sh @ ns @ \@@_env: - ##1 - \l_tmpb_tl } + { + \pgfpointanchor { \@@_env: - ##1 - \l_tmpb_tl } { west } + \dim_set:Nn \l_@@_x_initial_dim + { \dim_min:nn \l_@@_x_initial_dim \pgf@x } + } + \cs_if_exist:cT + { pgf @ sh @ ns @ \@@_env: - ##1 - \l_tmpd_tl } + { + \pgfpointanchor { \@@_env: - ##1 - \l_tmpd_tl } { east } + \dim_set:Nn \l_@@_x_final_dim + { \dim_max:nn \l_@@_x_final_dim \pgf@x } + } + } + \@@_qpoint:n { row - \l_tmpa_tl - base } + \dim_set:Nn \l_@@_y_initial_dim + { \pgf@y + ( \box_ht:N \strutbox + \extrarowheight ) * \arraystretch } + \@@_qpoint:n { row - \l_tmpc_tl - base } + \dim_set:Nn \l_@@_y_final_dim + { \pgf@y - ( \box_dp:N \strutbox ) * \arraystretch } + \int_step_inline:nnn \l_@@_first_col_int \g_@@_col_total_int + { + \cs_if_exist:cT + { pgf @ sh @ ns @ \@@_env: - \l_tmpa_tl - ##1 } + { + \pgfpointanchor { \@@_env: - \l_tmpa_tl - ##1 } { north } + \dim_set:Nn \l_@@_y_initial_dim + { \dim_max:nn \l_@@_y_initial_dim \pgf@y } + } + \cs_if_exist:cT + { pgf @ sh @ ns @ \@@_env: - \l_tmpc_tl - ##1 } + { + \pgfpointanchor { \@@_env: - \l_tmpc_tl - ##1 } { south } + \dim_set:Nn \l_@@_y_final_dim + { \dim_min:nn \l_@@_y_final_dim \pgf@y } + } + } + \dim_set:Nn \l_tmpa_dim + { + \l_@@_y_initial_dim - \l_@@_y_final_dim + + \l_@@_submatrix_extra_height_dim - \arrayrulewidth + } + \dim_set_eq:NN \nulldelimiterspace \c_zero_dim +% \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 +% the delimiters that we will put after). +% \begin{macrocode} + \str_if_empty:NF \l_@@_submatrix_name_str + { + \@@_pgf_rect_node:nnnnn \l_@@_submatrix_name_str + \l_@@_x_initial_dim \l_@@_y_initial_dim + \l_@@_x_final_dim \l_@@_y_final_dim + } +% \end{macrocode} +% +% \medskip +% Now, we deal with the left delimiter. Of course, the environment +% |{pgfscope}| is for the |\pgftransformshift|. +% \begin{macrocode} + \begin { pgfscope } + \pgftransformshift + { + \pgfpoint + { \l_@@_x_initial_dim - \l_@@_submatrix_left_xshift_dim } + { ( \l_@@_y_initial_dim + \l_@@_y_final_dim ) / 2 } + } + \str_if_empty:NTF \l_@@_submatrix_name_str + { \@@_node_left:nn #1 { } } + { \@@_node_left:nn #1 { \@@_env: - \l_@@_submatrix_name_str - left } } + \end { pgfscope } +% \end{macrocode} +% +% \medskip +% Now, we deal with the right delimiter. +% \begin{macrocode} + \pgftransformshift + { + \pgfpoint + { \l_@@_x_final_dim + \l_@@_submatrix_right_xshift_dim } + { ( \l_@@_y_initial_dim + \l_@@_y_final_dim ) / 2 } + } + \str_if_empty:NTF \l_@@_submatrix_name_str + { \@@_node_right:nn #4 { } } + { + \@@_node_right:nn #4 { \@@_env: - \l_@@_submatrix_name_str - right } + } + \endpgfpicture + } + \group_end: + } +% \end{macrocode} +% +% \medskip +% The command |\@@_node_left:nn| puts the left delimiter with the correct size. +% The argument |#1| is the delimiter to put. The argument |#2| is the name we +% will give to this PGF node (if the key |name| has been used in |\SubMatrix|). +% \begin{macrocode} +\cs_new_protected:Npn \@@_node_left:nn #1 #2 + { + \pgfnode + { rectangle } + { east } + { + \nullfont + \c_math_toggle_token + \tl_if_empty:NF \l_@@_delimiters_color_tl + { \color { \l_@@_delimiters_color_tl } } + \left #1 + \vcenter + { + \nullfont + \hrule \@height \l_tmpa_dim + \@depth \c_zero_dim + \@width \c_zero_dim + } + \right . + \c_math_toggle_token + } + { #2 } + { } + } +% \end{macrocode} +% +% \medskip +% The command |\@@_node_right:nn| puts the right delimiter with the correct size. +% The argument |#1| is the delimiter to put. The argument |#2| is the name we +% will give to this PGF node (if the key |name| has been used in |\SubMatrix|). +% \begin{macrocode} +\cs_new_protected:Npn \@@_node_right:nn #1 #2 + { + \pgfnode + { rectangle } + { west } + { + \nullfont + \c_math_toggle_token + \tl_if_empty:NF \l_@@_delimiters_color_tl + { \color { \l_@@_delimiters_color_tl } } + \left . + \vcenter + { + \nullfont + \hrule \@height \l_tmpa_dim + \@depth \c_zero_dim + \@width \c_zero_dim + } + \right #1 + \c_math_toggle_token + } + { #2 } + { } + } +% \end{macrocode} +% +% \bigskip % \subsection*{We process the options at package loading} % % @@ -13726,12 +14447,19 @@ version 2005/12/01 or later. define-L-C-R,~ footnote,~ footnotehyper,~ - renew-dots,~ - renew-matrix~and~ - transparent. + renew-dots,~and + renew-matrix. } % \end{macrocode} % +% \begin{macrocode} +\@@_msg_new:nn { Key~transparent } + { + The~key~'transparent'~is~now~obsolete~(because~it's~name~ + is~not~clear).~You~should~use~the~conjonction~of~'renew-dots'~ + and~'renew-matrix'.~However,~you~can~go~on. + } +% \end{macrocode} % % \begin{macrocode} \keys_define:nn { NiceMatrix / Package } @@ -13742,7 +14470,12 @@ version 2005/12/01 or later. renew-dots .value_forbidden:n = true , renew-matrix .code:n = \@@_renew_matrix: , renew-matrix .value_forbidden:n = true , - transparent .meta:n = { renew-dots , renew-matrix } , + transparent .code:n = + { + \@@_renew_matrix: + \bool_set_true:N \l_@@_renew_dots_bool + \@@_error:n { Key~transparent } + } , transparent .value_forbidden:n = true, footnote .bool_set:N = \c_@@_footnote_bool , footnotehyper .bool_set:N = \c_@@_footnotehyper_bool , @@ -13780,8 +14513,12 @@ version 2005/12/01 or later. % \begin{macrocode} \bool_if:NT \c_@@_footnote_bool { +% \end{macrocode} +% The class \cls{beamer} has its own system to extract footnotes and that's why +% we have nothing to do if \cls{beamer} is used. +% \begin{macrocode} \@ifclassloaded { beamer } - { \msg_info:nn { nicematrix } { Option~incompatible~with~Beamer } } + { \bool_set_false:N \c_@@_footnote_bool } { \@ifpackageloaded { footnotehyper } { \@@_error:n { footnote~with~footnotehyper~package } } @@ -13793,8 +14530,12 @@ version 2005/12/01 or later. % \begin{macrocode} \bool_if:NT \c_@@_footnotehyper_bool { +% \end{macrocode} +% The class \cls{beamer} has its own system to extract footnotes and that's why +% we have nothing to do if \cls{beamer} is used. +% \begin{macrocode} \@ifclassloaded { beamer } - { \@@_info:n { Option~incompatible~with~Beamer } } + { \bool_set_false:N \c_@@_footnote_bool } { \@ifpackageloaded { footnote } { \@@_error:n { footnotehyper~with~footnote~package } } @@ -13987,6 +14728,15 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} +\@@_msg_new:nn { SubMatrix~too~large } + { + Your~command~\token_to_str:N \SubMatrix\ + can't~be~drawn~because~your~matrix~is~too~small.\\ + If~you~go~on,~this~command~will~be~ignored. + } +% \end{macrocode} +% +% \begin{macrocode} \@@_msg_new:nn { double-backslash~in~light-syntax } { You~can't~use~\token_to_str:N \\~to~separate~rows~because~you~have~used~ @@ -14023,6 +14773,15 @@ version 2005/12/01 or later. } % \end{macrocode} % +% \begin{macrocode} +\@@_msg_new:nn { Invalid~name~format } + { + You~can't~give~the~name~'\l_keys_value_tl'~to~a~\token_to_str:N + \SubMatrix.\\ + A~name~must~be~accepted~by~the~regular~expression~[A-Za-z][A-Za-z0-9]*.\\ + If~you~go~on,~this~key~will~be~ignored. + } +% \end{macrocode} % % \begin{macrocode} \@@_msg_new:nn { empty~environment } @@ -14030,6 +14789,15 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} +\@@_msg_new:nn { Delimiter~with~small } + { + You~can't~put~a~delimiter~in~the~preamble~of~your~\@@_full_name_env:\ + because~the~key~'small'~is~in~force.\\ + This~error~is~fatal. + } +% \end{macrocode} +% +% \begin{macrocode} \@@_msg_new:nn { unknown~cell~for~line~in~code-after } { Your~command~\token_to_str:N\line\{#1\}\{#2\}~in~the~'code-after'~ @@ -14038,6 +14806,21 @@ version 2005/12/01 or later. } % \end{macrocode} % +% +% \begin{macrocode} +\@@_msg_new:nnn { Duplicate~name~for~SubMatrix } + { + The~name~'#1'~is~already~used~for~a~\token_to_str:N \SubMatrix\ + in~this~\@@_full_name_env:.\\ + If~you~go~on,~this~key~will~be~ignored.\\ + For~a~list~of~the~names~already~used,~type~H~<return>. + } + { + The~names~already~defined~in~this~\@@_full_name_env:\ are:~ + \seq_use:Nnnn \g_@@_submatrix_names_seq { ~and~ } { ,~ } { ~and~ }. + } +% \end{macrocode} +% % \begin{macrocode} \@@_msg_new:nn { Hdotsfor~in~col~0 } { @@ -14066,7 +14849,7 @@ version 2005/12/01 or later. } % \end{macrocode} % -% +% % \begin{macrocode} \@@_msg_new:nn { last-col~non~empty~for~NiceMatrixOptions } { @@ -14120,7 +14903,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} -\@@_msg_new:nn { bottomule~without~booktabs } +\@@_msg_new:nn { bottomrule~without~booktabs } { You~can't~use~the~key~'tabular/bottomrule'~because~you~haven't~ loaded~'booktabs'.\\ @@ -14184,8 +14967,35 @@ version 2005/12/01 or later. line-width~and~r. } % \end{macrocode} +% +% \begin{macrocode} +\@@_msg_new:nnn { Unknown~key~for~CodeAfter } + { + The~key~'\l_keys_key_str'~is~unknown.\\ + If~you~go~on,~it~will~be~ignored. \\ + For~a~list~of~the~available~keys~in~\token_to_str:N + \CodeAfter,~type~H~<return>. + } + { + The~available~keys~are~(in~alphabetic~order):~ + delimiters-color,~ + sub-matrix~(several~subkeys)~ + and~xdots~(several~subkeys).~ + The~latter~is~for~the~command~\token_to_str:N \line. + } +% \end{macrocode} % % \begin{macrocode} +\@@_msg_new:nn { 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. \\ + } +% \end{macrocode} +% +% \begin{macrocode} \@@_msg_new:nnn { Unknown~key~for~notes } { The~key~'\l_keys_key_str'~is~unknown.\\ @@ -14239,17 +15049,15 @@ version 2005/12/01 or later. left-margin,~ letter-for-dotted-lines,~ light-syntax,~ - notes~(several subkeys),~ + notes~(several~subkeys),~ nullify-dots,~ renew-dots,~ renew-matrix,~ right-margin,~ small,~ - transparent,~ + sub-matrix~(several~subkeys), vlines,~ - xdots/color,~ - xdots/shorten~and~ - xdots/line-style. + xdots~(several~subkeys). } % \end{macrocode} % @@ -14434,7 +15242,7 @@ version 2005/12/01 or later. } { The~names~already~defined~in~this~document~are:~ - \seq_use:Nnnn \g_@@_names_seq { ,~ } { ,~ } { ~and~ }. + \seq_use:Nnnn \g_@@_names_seq { ~and~ } { ,~ } { ~and~ }. } % \end{macrocode} % @@ -14447,6 +15255,7 @@ version 2005/12/01 or later. % \end{macrocode} % % +% % \vspace{1cm} % \section{History} % @@ -14861,6 +15670,15 @@ version 2005/12/01 or later. % % New key |cell-space-limits|. % +% \subsection*{Changes between versions 5.9 and 5.10} +% +% New command |\SubMatrix| available in the |\CodeAfter|. +% +% It's possible to provide options (between brackets) to the command |\CodeAfter|. +% +% A (non fatal) error is raised when the key |transparent|, which is +% deprecated, is used. +% % \PrintIndex % % \tableofcontents @@ -14873,3 +15691,4 @@ version 2005/12/01 or later. % fill-column: 80 % End: + |