summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-07-19 20:42:46 +0000
committerKarl Berry <karl@freefriends.org>2019-07-19 20:42:46 +0000
commit0770d0964f61096883b1a75524e16c31da08b9a4 (patch)
tree0c2477a566d7b068ad490c114121f39163784f39 /Master/texmf-dist/source
parent5abfca443b064af0c3d64883243452ef36ab2483 (diff)
nicematrix (19jul19)
git-svn-id: svn://tug.org/texlive/trunk@51680 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r--Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx904
1 files changed, 571 insertions, 333 deletions
diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx b/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx
index 095ec34bfdc..90140a6ec28 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{2.2.1}
-\def\myfiledate{2019/07/02}
+\def\myfileversion{2.3}
+\def\myfiledate{2019/07/18}
%
%
%<*batchfile>
@@ -49,8 +49,9 @@ version 2005/12/01 or later.
\documentclass[dvipsnames]{l3doc}% dvipsnames is for xcolor (loaded by Tikz, loaded by nicematrix)
\VerbatimFootnotes
\usepackage{xltxtra}
-\usepackage{geometry}
+\usepackage[xetex]{geometry}
\geometry{left=2.8cm,right=2.8cm,top=2.5cm,bottom=2.5cm,papersize={21cm,29.7cm}}
+\usepackage{siunitx}
\usepackage{nicematrix}
\NewDocumentEnvironment {scope} {} {} {}
\def\interitem{\vskip 7mm plus 2 mm minus 3mm}
@@ -66,7 +67,7 @@ version 2005/12/01 or later.
\usepackage{footnotehyper}
\parindent 0pt
-\DisableCrossrefs
+\EnableCrossrefs
\begin{document}
\DocInput{nicematrix.dtx}
\end{document}
@@ -112,8 +113,7 @@ version 2005/12/01 or later.
% \end{minipage}
% \end{savenotes}
% \hspace{1.4cm}
-% $\vcenter{
-% \begin{bNiceArrayRC}{CCCC}[code-for-last-col=\color{blue}\scriptstyle,
+% $\begin{bNiceArrayRC}{CCCC}[code-for-last-col=\color{blue}\scriptstyle,
% code-for-first-row=\color{blue}\scriptstyle,
% columns-width = auto]
% C_1 & C_2 & \Cdots & C_n \\
@@ -122,7 +122,7 @@ version 2005/12/01 or later.
% \Vdots & \Vdots & \Ddots & \Vdots & \Vdots \\
% a_{n1} & a_{n2} & \Cdots & a_{nn} & L_n
% \end{bNiceArrayRC}
-% }$
+% $
%
% \medskip
% A command |\NiceMatrixOptions| is provided to fix the options (the scope of
@@ -204,7 +204,7 @@ version 2005/12/01 or later.
% package |{array}|. However, for technical reasons, in the preamble of the
% environment |{NiceArray}|, the user must use the letters |L|, |C| and~|R|
% instead of |l|, |c| and |r|. It's possible to use the constructions
-% \verb|w{...}{...}|, \verb|W{...}{...}|, \verb+|+, |>{...}|, |<{...}|,
+% |w{...}{...}|, |W{...}{...}|, "|", |>{...}|, |<{...}|,
% |@{...}|, |!{...}| and |*{n}{...}| but the letters |p|, |m| and |b| should not
% be used. See p.~\pageref{NiceArray} the section relating to |{NiceArray}|.
%
@@ -371,7 +371,7 @@ version 2005/12/01 or later.
% \subsection{The option nullify-dots}
%
% Consider the following matrix composed classicaly with the environment
-% |{pmatrix}|.\par\nobreak
+% |{pmatrix}| of \pkg{amsmath}.\par\nobreak
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=8cm]
@@ -474,7 +474,7 @@ version 2005/12/01 or later.
% \textbf{There must be no space before the opening bracket (|[|) of the options
% of the environment.}
%
-% \subsection{The command Hdotsfor}
+% \subsection{The command \textbackslash Hdotsfor}
%
% Some people commonly use the command |\hdotsfor| of \pkg{amsmath} in order to
% draw horizontal dotted lines in a matrix. In the environments of
@@ -769,7 +769,7 @@ version 2005/12/01 or later.
% \end{pNiceMatrix}\]
%
% \bigskip
-% We explain below how to fill the nodes created by \pkg{nicematrix}.
+% We explain below how to fill the nodes created by \pkg{nicematrix} (cf. p. \pageref{highlight}).
%
% \section{The code-after}
%
@@ -808,10 +808,10 @@ version 2005/12/01 or later.
% |{NiceArray}| with |\newcolumntype| of \pkg{array}. This definition overrides
% an eventual previous definition. In fact, the column types |w| and |W| are
% also redefined.} instead of |l|, |c| and |r|. It's possible
-% to use the constructions \verb|w{...}{...}|, \verb|W{...}{...}|, \verb+|+,
-% |>{...}|, |<{...}|, |@{...}|, |!{...}| and |*{n}{...}| but the letters |p|,
-% |m| and |b| should not be used.\footnote{In a command |\multicolumn|, one
-% should also use the letters |L|, |C|, |R|.}
+% to use the constructions |w{...}{...}|, |W{...}{...}|, "|", |>{...}|,
+% |<{...}|, |@{...}|, |!{...}| and |*{n}{...}| but the letters |p|, |m| and |b|
+% should not be used.\footnote{In a command |\multicolumn|, one should also use
+% the letters |L|, |C|, |R|.}
%
% \medskip
% The environment |{NiceArray}| accepts the classical options |t|, |c| and |b|
@@ -899,6 +899,28 @@ version 2005/12/01 or later.
%
%
% \bigskip
+% Note that an horizontal line drawn with |\hline| does \emph{not} extend in
+% the last column.\par\nobreak
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
+% $\begin{pNiceArrayC}
+% a_{11} & a_{12} & a_{13} \\
+% a_{21} & a_{22} & a_{23} \\
+% a_{31} & a_{32} & a_{33} \\
+% ~emphase#\hline@
+% S_1 & S_2 & S_3
+% \end{pNiceArrayC}$
+% \end{BVerbatim}
+% $\begin{pNiceArrayC}{CCC}
+% a_{11} & a_{12} & a_{13} & L_1 \\
+% a_{21} & a_{22} & a_{23} & L_2 \\
+% a_{31} & a_{32} & a_{33} & L_3 \\
+% \hline
+% S_1 & S_2 & S_3
+% \end{pNiceArrayC}$
+%
+% \bigskip
% In fact, the environment |{pNiceArrayC}| and its variants are based upon a
% more general environment, called |{NiceArrayCwithDelims}|. The first two
% mandatory arguments of this environment are the left and right delimiters used
@@ -966,35 +988,11 @@ version 2005/12/01 or later.
% For technical reasons, it's not possible to use the option of the command |\\|
% after the first row (the placement of the delimiters would be wrong).
%
-% \bigskip
-% In fact, the environment |{pNiceArrayRC}| and its variants are based upon an
-% more general environment, called |{NiceArrayRCwithDelims}|. The first two
-% mandatory arguments of this environment are the left and right delimiters used
-% in the construction of the matrix. It's possible to use
-% |{NiceArrayRCwithDelims}| if we want to use atypical delimiters.
-%
-% \medskip
-% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
-% $\begin{NiceArrayRCwithDelims}
-% {\downarrow}{\downarrow}{CCC}[columns-width=auto]
-% C_1 & C_2 & C_3 \\
-% 1 & 2 & 3 \\
-% 4 & 5 & 6 \\
-% 7 & 8 & 9
-% \end{NiceArrayRCwithDelims}$
-% \end{BVerbatim}
-% $\begin{NiceArrayRCwithDelims}
-% {\downarrow}{\downarrow}{CCC}[columns-width=auto]
-% C_1 & C_2 & C_3 \\
-% 1 & 2 & 3 \\
-% 4 & 5 & 6 \\
-% 7 & 8 & 9
-% \end{NiceArrayRCwithDelims}$
%
%
% \bigskip
% If we want to write a linear system, we can use the following code, with a
-% preamble \verb+CCC|C+:
+% preamble "CCC|C":\par\nobreak
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
@@ -1006,65 +1004,54 @@ version 2005/12/01 or later.
% \end{pNiceArrayRC}$
% \end{BVerbatim}
% $\begin{pNiceArrayRC}{CCC|C}
-% C_1 & \Cdots & C_n \\
+% C_1 & \Cdots & \multicolumn1C{C_n} \\
% a_{11} & \Cdots & a_{1n} & b_1 \\
% \Vdots & & \Vdots & \Vdots \\
% a_{n1} & \Cdots & a_{nn} & b_n \\
% \end{pNiceArrayRC}$
%
% \medskip
-% The resultat may seem disappointing. It's possible to suppress the vertical
-% rule in the first row with the command |\multicolumn| in order to
-% ``reconstruct'' the cell.
+% We remark that the vertical rule doesn't extend in the first
+% row.\footnote{This is a feature of the version 2.2.1 of \pkg{nicematrix}. Before
+% that version, the vrule extended in the first row. We must remark that, if the
+% extension \pkg{arydshln} is loaded, the line will extend even if any
+% functionnality of \pkg{arydshln} is used in the array (that's because
+% \pkg{arydshln} redefine many internals of \pkg{array}).}
+%
%
-%
-% \bigskip
-% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
-% $\begin{pNiceArrayRC}{CCC|C}
-% C_1 & \Cdots & ~emphase#\multicolumn{1}{C}{C_n}@ \\
-% a_{11} & \Cdots & a_{1n} & b_1 \\
-% \Vdots & & \Vdots & \Vdots \\
-% a_{n1} & \Cdots & a_{nn} & b_n \\
-% \end{pNiceArrayRC}$
-% \end{BVerbatim}
-% $\begin{pNiceArrayRC}{CCC|C}
-% C_1 & \Cdots & \multicolumn{1}{C}{C_n} \\
-% a_{11} & \Cdots & a_{1n} & b_1 \\
-% \Vdots & & \Vdots & \Vdots \\
-% a_{n1} & \Cdots & a_{nn} & b_n
-% \end{pNiceArrayRC}$
-%
% \bigskip
-% On the other side, we may remark that an horizontal line (with |\hline| or
-% |\hdashline| of \pkg{arydshln}) doesn't extend in the ``exterior column'' of
-% an environment like |{pNiceArrayC}| or |{pNiceArrayRC}|.
+% In fact, the environment |{pNiceArrayRC}| and its variants are based upon an
+% more general environment, called |{NiceArrayRCwithDelims}|. The first two
+% mandatory arguments of this environment are the left and right delimiters used
+% in the construction of the matrix. It's possible to use
+% |{NiceArrayRCwithDelims}| if we want to use atypical delimiters.
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=11cm]
-% $\begin{pNiceArrayC}{CCC}
-% a_{11} & \Cdots & a_{1n} & L_1 \\
-% \Vdots & & \Vdots & \Vdots \\
-% a_{n1} & \Cdots & a_{nn} & L_n \\
-% ~emphase#\hdashline@
-% S_1 & \Cdots & S_n \\
-% \end{pNiceArrayC}$
+% $\begin{NiceArrayRCwithDelims}
+% {\downarrow}{\downarrow}{CCC}[columns-width=auto]
+% C_1 & C_2 & C_3 \\
+% 1 & 2 & 3 \\
+% 4 & 5 & 6 \\
+% 7 & 8 & 9
+% \end{NiceArrayRCwithDelims}$
% \end{BVerbatim}
-% $\begin{pNiceArrayC}{CCC}
-% a_{11} & \Cdots & a_{1n} & L_1 \\
-% \Vdots & & \Vdots & \Vdots \\
-% a_{n1} & \Cdots & a_{nn} & L_n \\
-% \hdashline
-% S_1 & \Cdots & S_n \\
-% \end{pNiceArrayC}$
-%
+% $\begin{NiceArrayRCwithDelims}
+% {\downarrow}{\downarrow}{CCC}[columns-width=auto]
+% C_1 & C_2 & C_3 \\
+% 1 & 2 & 3 \\
+% 4 & 5 & 6 \\
+% 7 & 8 & 9
+% \end{NiceArrayRCwithDelims}$
%
%
% \section{The dotted lines to separate rows or columns}
%
%
% In the environments of the extension \pkg{nicematrix}, it's possible to use
-% the command |\hdottedline| which is a counterpart of the classical commands
-% |\hline| and |\hdashline| (of \pkg{arydshln}).
+% the command |\hdottedline| (provided by \pkg{nicematrix}) which is a
+% counterpart of the classical commands |\hline| and |\hdashline| (of
+% \pkg{arydshln}).
%
% \medskip
% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm]
@@ -1196,7 +1183,8 @@ version 2005/12/01 or later.
%
% \medskip
% Note that the space inserted between two columns (equal to 2 |\arraycolsep|)
-% is not suppressed.
+% is not suppressed (of course, it's possible to suppress this space by setting
+% |\arraycolsep| equal to $0$~pt).
%
% \bigskip
% It's possible to give the value |auto| to the option |columns-width|: all the
@@ -1274,8 +1262,57 @@ version 2005/12/01 or later.
% \end{NiceMatrixBlock}
%
%
+% \section{The option hlines}
+%
+% Of course, you can add horizontal rules between rows in the environments of
+% \pkg{nicematrix} with the command |\hline|. But you can also specify that all
+% horizontal lines must be drawn with the option |hlines|.
+%
+% \medskip
+% \begin{BVerbatim}[baseline=c,boxwidth=8.5cm]
+%$\begin{NiceArray}{|*{4}{C|}}[~emphase#hlines@]
+% e & a & b & c \\
+% a & e & c & b \\
+% b & c & e & a \\
+% c & b & a & e
+% \end{NiceArray}$
+% \end{BVerbatim}
+%$\begin{NiceArray}{|*{4}{C|}}[hlines]
+% e & a & b & c \\
+% a & e & c & b \\
+% b & c & e & a \\
+% c & b & a & e
+% \end{NiceArray}$
+%
+%
+%
+% \section{Utilisation of the column type S of siunitx}
%
+% If the package \pkg{siunitx} is loaded (before or after \pkg{nicematrix}),
+% it's possible to use the |S| column type of \pkg{siunitx} in the environments
+% of \pkg{nicematrix}. The implementation doesn't use explicitly any private
+% macro of \pkg{siunitx}.
%
+%
+% \medskip
+% \begin{BVerbatim}[baseline = c, boxwidth = 10.5cm]
+% $\begin{pNiceArrayRC}{~emphase#S@Cwc{1cm}C}[nullify-dots]
+% {C_1} & \Cdots & & C_n \\
+% 2.3 & 0 & \Cdots & 0 \\
+% 12.4 & \Vdots & & \Vdots \\
+% 1.45 \\
+% 7.2 & 0 & \Cdots & 0
+% \end{pNiceArrayRC}$
+% \end{BVerbatim}
+% $\begin{pNiceArrayRC}{SCwc{1cm}C}[nullify-dots]
+% {C_1} & \Cdots & & C_n \\
+% 2.3 & 0 & \Cdots & 0 \\
+% 12.4 & \Vdots & & \Vdots \\
+% 1.45 \\
+% 7.2 & 0 & \Cdots & 0
+% \end{pNiceArrayRC}$
+%
+%
% \section{Technical remarks}
%
% \subsection{Diagonal lines}
@@ -1353,7 +1390,7 @@ version 2005/12/01 or later.
%
% \label{empty-cells}
% An instruction like |\Ldots|, |\Cdots|, etc. tries to determine the first
-% non-empty cells on both sides. However, a empty cell is not necessarily a cell
+% non-empty cells on both sides. However, an empty cell is not necessarily a cell
% with no TeX content (that is to say a cell with no token between the two
% ampersands~|&|). Indeed, a cell with contents |\hspace*{1cm}| may be
% considered as empty.
@@ -1493,29 +1530,6 @@ version 2005/12/01 or later.
% \end{pNiceMatrix}$
%
%
-% \subsection{Compatibility with the extension dcolumn}
-%
-% \label{dcolumn}
-% If we want to make \pkg{nicematrix} compatible with \pkg{dcolumn}, it's
-% necessary to patch the commands |\DC@endcentre| and |\DC@endright| as follow.
-%
-% \bigskip
-%
-% \begin{scope}
-% \fvset{commandchars=\~\#\+}
-% \begin{Verbatim}
-% \def\DC@endcentre{$\egroup
-% \ifdim \wd\z@>\wd\tw@
-% \setbox\tw@=\hbox to\wd\z@{\unhbox\tw@\hfill}%
-% \else
-% \setbox\z@=\hbox to\wd\tw@{\hfill\unhbox\z@}\fi
-% ~emphase#\@@_Cell:+\box\z@\box\tw@ ~emphase#\@@_end_Cell:+}
-% \end{Verbatim}
-%
-% \begin{Verbatim}
-% \def\DC@endright{$\hfil\egroup ~emphase#\@@_Cell:+\box\z@\box\tw@ ~emphase#\@@_end_Cell:+}
-% \end{Verbatim}
-% \end{scope}
%
%
%
@@ -1754,11 +1768,15 @@ version 2005/12/01 or later.
%
% \subsection{How to highlight cells of the matrix}
%
+% \label{highlight}
% \medskip
-% In order to highlight a cell of a matrix, it's possible to ``draw'' one of the correspond nodes (the ``normal
-% node'', the ``medium node'' or the ``large node''). In the following example, we use the ``large nodes'' of the
-% diagonal of the matrix (with the Tikz key ``|name suffix|'', it's easy to use the ``large nodes''). In order to
-% have the continuity of the lines, we have to set |inner sep = -\pgflinewidth/2|.
+% In order to highlight a cell of a matrix, it's possible to ``draw'' one of the
+% correspondant nodes (the ``normal node'', the ``medium node'' or the ``large
+% node''). In the following example, we use the ``large nodes'' of the diagonal
+% of the matrix (with the Tikz key ``|name suffix|'', it's easy to use the
+% ``large nodes'').
+%
+% In order to have the continuity of the lines, we have to set |inner sep = -\pgflinewidth/2|.
%
% \begin{Verbatim}
% $\left(\,\begin{NiceArray}{>{\strut}CCCC}%
@@ -2043,8 +2061,7 @@ version 2005/12/01 or later.
%
% \section{Implementation}
%
-% By default, the package \pkg{nicematrix} doesn't patch any existing code.\footnote{If we want \pkg{nicematrix}
-% compatible with \pkg{dcolumn}, we have to patch \pkg{dcolumn}: cf. p.~\pageref{dcolumn}.}
+% By default, the package \pkg{nicematrix} doesn't patch any existing code.
%
% \smallskip
% However, when the option |renew-dots| is used, the commands |\cdots|, |\ldots|, |\dots|, |\vdots|, |\ddots| and
@@ -2095,6 +2112,8 @@ version 2005/12/01 or later.
\ProcessOptions \relax
% \end{macrocode}
%
+%
+%
% The command for the treatment of the options of |\usepackage| is at the end of
% this package for technical reasons.
%
@@ -2106,6 +2125,29 @@ version 2005/12/01 or later.
\RequirePackage { xparse } [ 2018-10-17 ]
% \end{macrocode}
%
+% \bigskip
+% \begin{macrocode}
+\cs_new_protected:Nn \@@_error:n { \msg_error:nn { nicematrix } { #1 } }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new_protected:Nn \@@_error:nn { \msg_error:nn { nicematrix } { #1 } { #2 } }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_msg_new:nn { \msg_new:nnn { nicematrix } }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_msg_new:nnn { \msg_new:nnnn { nicematrix } }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_msg_redirect_name:nn
+ { \msg_redirect_name:nnn { nicematrix } }
+% \end{macrocode}
+%
+%
% \subsection{Technical definitions}
%
% We test whether the current class is \cls{revtex4-1} or \cls{revtex4-2}.
@@ -2119,30 +2161,43 @@ version 2005/12/01 or later.
{ }
% \end{macrocode}
%
-%
-% \begin{macrocode}
-\cs_new_protected:Nn \@@_error:n { \msg_error:nn { nicematrix } { #1 } }
-% \end{macrocode}
+%
%
% \begin{macrocode}
-\cs_new_protected:Nn \@@_error:nn { \msg_error:nn { nicematrix } { #1 } { #2 } }
+\@@_msg_new:nn { Draft~mode }
+ { The~compilation~is~in~draft~mode:~the~dotted~lines~won't~be~drawn. }
% \end{macrocode}
%
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_msg_new:nn { \msg_new:nnn { nicematrix } }
-% \end{macrocode}
%
% \begin{macrocode}
-\cs_new_protected:Npn \@@_msg_new:nnn { \msg_new:nnnn { nicematrix } }
+\bool_if:NT \c_@@_draft_bool
+ { \msg_warning:nn { nicematrix } { Draft~mode } }
% \end{macrocode}
%
+% \medskip
+% We create booleans in order to know if some packages are loaded.
+% for the package \pkg{siunitx}, the boolean is called
+% |\c_@@_siunitx_loaded_bool|.\footnote{It's not possible to use
+% |\@ifpackageloaded| in the core of the functions because |\@ifpackageloaded|
+% is available only in the preamble.}
% \begin{macrocode}
-\cs_new_protected:Npn \@@_msg_redirect_name:nn
- { \msg_redirect_name:nnn { nicematrix } }
+\AtBeginDocument
+ {
+ \clist_map_inline:nn
+ {
+ siunitx
+ }
+ {
+ \bool_new:c { c_@@_#1_loaded_bool }
+ \@ifpackageloaded { #1 }
+ { \bool_set_true:c { c_@@_#1_loaded_bool } }
+ { }
+ }
+ }
% \end{macrocode}
-%
+%
% \bigskip
-% First, we define a command |\iddots| similar to |\ddots| ($\ddots$) but with dots going forward ($\iddots$). We
+% We define a command |\iddots| similar to |\ddots| ($\ddots$) but with dots going forward ($\iddots$). We
% use |\ProvideDocumentCommand| of \pkg{xparse}, and so, if the command |\iddots| has already been defined (for
% example by the package \pkg{mathdots}), we don't define it again.
%
@@ -2150,12 +2205,13 @@ version 2005/12/01 or later.
\ProvideDocumentCommand \iddots { }
{
\mathinner
- { \mkern 1 mu
- \raise \p@ \hbox { . }
+ {
+ \mkern 1 mu
+ \raise \p@ \hbox:n { . }
\mkern 2 mu
- \raise 4 \p@ \hbox { . }
+ \raise 4 \p@ \hbox:n { . }
\mkern 2 mu
- \raise 7 \p@ \vbox { \kern 7 pt \hbox { . } } \mkern 1 mu
+ \raise 7 \p@ \vbox { \kern 7 pt \hbox:n { . } } \mkern 1 mu
}
}
% \end{macrocode}
@@ -2228,25 +2284,126 @@ version 2005/12/01 or later.
\bool_new:N \l_@@_in_NiceArray_bool
% \end{macrocode}
%
+% \subsection{The column S of siunitx}
+%
+% The command |\NC@rewrite@S| is a LaTeX command created by \pkg{siunitx} in
+% connection with the |S| column. In the code of \pkg{siunitx}, this command is
+% defined by:
+% \begin{Verbatim}[commandchars=\~\!\+, formatcom = \small]
+% \renewcommand*{\NC@rewrite@S}[1][]
+% {
+% \@temptokena \exp_after:wN
+% {
+% \tex_the:D \@temptokena
+% > { \__siunitx_table_collect_begin: S {#1} }
+% c
+% < { \__siunitx_table_print: }
+% }
+% \NC@find
+% }
+% \end{Verbatim}
+% We want to patch this command (in the environments of \pkg{nicematrix}) in
+% order to have:
+% \begin{Verbatim}[commandchars=\~\!\+, formatcom = \small]
+% \renewcommand*{\NC@rewrite@S}[1][]
+% {
+% \@temptokena \exp_after:wN
+% {
+% \tex_the:D \@temptokena
+% > { ~emphase!\@@_Cell:+ \__siunitx_table_collect_begin: S {#1} }
+% c
+% < { \__siunitx_table_print: ~emphase!\@@_end_Cell:+ }
+% }
+% \NC@find
+% }
+% \end{Verbatim}
+% However, we don't want do use explicitly any private command of \pkg{siunitx}. That's why we
+% will extract the name of the two |\__siunitx...| commands by their position in
+% the code of |\NC@rewrite@S|.
+%
+% Since the command |\NC@rewrite@S| appends some tokens to the \emph{toks} list
+% |\@temptokena|, we use the LaTeX command |\NC@rewrite@S| in a group
+% (|\group_begin:|--|\group_end:|) and we extract the two command names which
+% are in the toks |\@temptokena|. However, this extraction can be done only
+% when \pkg{siunitx} is loaded (and it may be loaded after \pkg{nicematrix})
+% and, in fact, after the beginning of the document --- because some instructions of
+% \pkg{siunitx} are executed in a |\AtBeginDocument|). That's why this
+% extraction will be done only at the first utilisation of an environment of
+% \pkg{nicematrix} with the command |\@@_adapt_S_column:|. This command becomes
+% globally no-op when used once.
+% \begin{macrocode}
+\cs_set_protected:Npn \@@_adapt_S_column:
+ {
+ \bool_if:NT \c_@@_siunitx_loaded_bool
+ {
+ \group_begin:
+ \@temptokena = { }
+% \end{macrocode}
+% We protect |\NC@find| which is at the end of |\NC@rewrite@S|.
+% \begin{macrocode}
+ \cs_set_eq:NN \NC@find \prg_do_nothing:
+ \NC@rewrite@S { }
+% \end{macrocode}
+% Conversion of the \emph{toks} |\@temptokena| in a token list of \pkg{expl3}
+% (the toks are not supported by \pkg{expl3} and that's why we use
+% |\tex_the:D|). The conversion is global (|gset|) because we have to exit the group.
+% \begin{macrocode}
+ \exp_args:NNo \tl_gset:Nn \g_tmpa_tl { \tex_the:D \@temptokena }
+ \group_end:
+ \tl_new:N \c_@@_table_collect_begin_tl
+ \tl_set:Nx \l_tmpa_tl { \tl_item:Nn \g_tmpa_tl 2 }
+ \tl_gset:Nx \c_@@_table_collect_begin_tl { \tl_item:Nn \l_tmpa_tl 1 }
+ \tl_new:N \c_@@_table_print_tl
+ \tl_gset:Nx \c_@@_table_print_tl { \tl_item:Nn \g_tmpa_tl { -1 } }
+ }
+% \end{macrocode}
+% When, used once, the command |\@@_adapt_S_column:| becomes no-op (globally).
+% \begin{macrocode}
+ \cs_gset_eq:NN \@@_adapt_S_column: \prg_do_nothing:
+ }
+% \end{macrocode}
+% The token lists |\c_@@_table_collect_begin_tl| and |\c_@@_table_print_tl| contain
+% now the two commands of \pkg{siunitx}.
%
% \bigskip
-% A list of names of environments of the extension \pkg{nicematrix} which have a
-% preamble as argument. This list is used to parameter some erros messages.
+% The command |\@@_renew_NC@rewrite@S:| will be used in each environment of
+% \pkg{nicematrix} in order to ``rewrite'' the |S| column in each environment
+% (only if the boolean |\c_@@_siunitx_loaded_bool| is raised, of course).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_renew_NC@rewrite@S:
+ {
+ \renewcommand*{\NC@rewrite@S}[1][]
+ {
+ \@temptokena \exp_after:wN
+ {
+ \tex_the:D \@temptokena
+ > { \@@_Cell: \c_@@_table_collect_begin_tl S {##1} }
+ c
+ < { \c_@@_table_print_tl \@@_end_Cell: }
+ }
+ \NC@find
+ }
+ }
+% \end{macrocode}
+%
+% \bigskip
+% \subsection{The options}
%
+%
% \begin{macrocode}
-\seq_new:N \c_@@_env_with_preamble_seq
-\seq_set_from_clist:Nn \c_@@_env_with_preamble_seq
+\@@_msg_new:nn { Option~Transparent~suppressed }
+ {
+ The~option~'Transparent'~has~been~renamed~'transparent'.\\
+ However,~you~can~go~on~for~this~time.
+ }
+\@@_msg_new:nn { Option~RenewMatrix~suppressed }
{
- NiceArray , NiceArrayCwithDelims , pNiceArrayC , vNiceArrayC , VNiceArrayC ,
- bNiceArrayC , BNiceArrayC , NiceArrayRCwithDelims , pNiceArrayRC ,
- vNiceArrayRC , VNiceArrayRC , bNiceArrayRC , BNiceArrayRC
+ The~option~'RenewMatrix~has~been~renamed~'renew-matrix'.\\
+ However,~you~can~go~on~for~this~time.
}
% \end{macrocode}
%
%
-% \bigskip
-% \subsection{The options}
-%
% The token list |\l_@@_pos_env_str| will contain one of the three values |t|,
% |c| or |b| and will indicate the position of the environment as in the option
% of the environment |{array}|. For the environment |{pNiceMatrix}|,
@@ -2277,6 +2434,12 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \bigskip
+% The flag |\l_@@_hlines_bool| correspond to the option |\hlines|.
+% \begin{macrocode}
+\bool_new:N \l_@@_hlines_bool
+% \end{macrocode}
+%
+% \bigskip
% The flag |\l_@@_nullify_dots_bool| corresponds to the option |nullify-dots|.
% When the flag is down, the instructions like |\vdots| are inserted within a
% |\hphantom| (and so the constructed matrix has exactly the same size as a
@@ -2356,6 +2519,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\keys_define:nn { NiceMatrix / Global }
{
+ hlines .bool_set:N = \l_@@_hlines_bool ,
parallelize-diags .bool_set:N = \l_@@_parallelize_diags_bool ,
parallelize-diags .default:n = true ,
% \end{macrocode}
@@ -2457,10 +2621,13 @@ version 2005/12/01 or later.
% \begin{macrocode}
renew-matrix .code:n = \@@_renew_matrix: ,
renew-matrix .value_forbidden:n = true ,
- RenewMatrix .meta:n = renew-matrix ,
+ RenewMatrix .code:n = \@@_error:n { Option~RenewMatrix~suppressed }
+ \@@_renew_matrix: ,
transparent .meta:n = { renew-dots , renew-matrix } ,
transparent .value_forbidden:n = true,
- Transparent .meta:n = transparent,
+ Transparent .code:n = \@@_error:n { Option~Transparent~suppressed }
+ \@@_renew_matrix:
+ \bool_set_true:N \l_@@_renew_dots_bool ,
% \end{macrocode}
%
% \bigskip
@@ -2541,6 +2708,7 @@ version 2005/12/01 or later.
allow-duplicate-names,~
code-for-last-col,~
exterior-arraycolsep,~
+ hlines,~
left-margin,~
letter-for-dotted-lines,~
nullify-dots,~
@@ -2594,6 +2762,7 @@ version 2005/12/01 or later.
create-extra-nodes,~
extra-left-margin,~
extra-right-margin,~
+ hlines,~
left-margin,~
name,~
nullify-dots,~
@@ -2660,6 +2829,7 @@ version 2005/12/01 or later.
columns-width,~
extra-left-margin,~
extra-right-margin,~
+ hlines,~
left-margin,~
name,~
nullify-dots,~
@@ -2692,7 +2862,8 @@ version 2005/12/01 or later.
\int_compare:nNnT \g_@@_column_int = 1 { \int_gincr:N \g_@@_row_int }
\int_gset:Nn \g_@@_column_total_int
{ \int_max:nn \g_@@_column_total_int \g_@@_column_int }
- \hbox_set:Nw \l_tmpa_box $ % $
+ \hbox_set:Nw \l_tmpa_box
+ \c_math_toggle_token
\int_compare:nNnT \g_@@_row_int = \c_zero_int
\l_@@_code_for_first_row_tl
}
@@ -2700,7 +2871,8 @@ version 2005/12/01 or later.
%
% \begin{macrocode}
\cs_new_protected:Nn \@@_end_Cell:
- { $ % $
+ {
+ \c_math_toggle_token
\hbox_set_end:
% \end{macrocode}
%
@@ -2819,55 +2991,16 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
-%
-% \bigskip
-% The command |\@@_define_dots:| will be used in the environment |{NiceArray}|
-% to define the commands |\Ldots|, |\Cdots|, etc.
% \begin{macrocode}
-\cs_new_protected:Npn \@@_define_dots:
- {
- \cs_set_eq:NN \Ldots \@@_Ldots
- \cs_set_eq:NN \Cdots \@@_Cdots
- \cs_set_eq:NN \Vdots \@@_Vdots
- \cs_set_eq:NN \Ddots \@@_Ddots
- \cs_set_eq:NN \Iddots \@@_Iddots
- \bool_if:NT \l_@@_renew_dots_bool
- {
- \cs_set_eq:NN \ldots \@@_Ldots
- \cs_set_eq:NN \cdots \@@_Cdots
- \cs_set_eq:NN \vdots \@@_Vdots
- \cs_set_eq:NN \ddots \@@_Ddots
- \cs_set_eq:NN \iddots \@@_Iddots
- \cs_set_eq:NN \dots \@@_Ldots
- \cs_set_eq:NN \hdotsfor \@@_Hdotsfor
- }
+\@@_msg_new:nn { Outside~math~mode }
+ {
+ The~environment~\{\@currenvir\}~can~be~used~only~in~math~mode~
+ (and~not~in~\token_to_str:N \vcenter).\_
+ If~you~go~on,~you~will~have~other~errors.
}
% \end{macrocode}
+%
%
-% \bigskip
-% With |\@@_define_dots_to_nil:|, the commands like |\Ldots|, |\Cdots|, are
-% defined, but with no effect. This command will be used if the class option
-% |draft| is used.
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_define_dots_to_nil:
- {
- \cs_set_eq:NN \Ldots \prg_do_nothing:
- \cs_set_eq:NN \Cdots \prg_do_nothing:
- \cs_set_eq:NN \Vdots \prg_do_nothing:
- \cs_set_eq:NN \Ddots \prg_do_nothing:
- \cs_set_eq:NN \Iddots \prg_do_nothing:
- \bool_if:NT \l_@@_renew_dots_bool
- {
- \cs_set_eq:NN \ldots \prg_do_nothing:
- \cs_set_eq:NN \cdots \prg_do_nothing:
- \cs_set_eq:NN \vdots \prg_do_nothing:
- \cs_set_eq:NN \ddots \prg_do_nothing:
- \cs_set_eq:NN \iddots \prg_do_nothing:
- \cs_set_eq:NN \dots \prg_do_nothing:
- \cs_set_eq:NN \hdotsfor \@@_Hdotsfor
- }
- }
-% \end{macrocode}
%
% \bigskip
% In the environment |{NiceArray}|, we will have to redefine the column types
@@ -2897,7 +3030,8 @@ version 2005/12/01 or later.
\box_move_down:nn \l_tmpa_dim
{
\vbox:n
- { \hbox_to_wd:nn { \box_wd:N \l_tmpb_box }
+ {
+ \hbox_to_wd:nn { \box_wd:N \l_tmpb_box }
{
\hfil
\tikz [ remember~picture , overlay ]
@@ -2941,14 +3075,26 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_test_if_math_mode:
+ {
+ \ifmmode \else
+ \@@_error:n { Outside~math~mode }
+ \fi
+ }
+% \end{macrocode}
+%
% \bigskip
% First, we test if we are yet in an environment |{NiceArray}| (nested
% environments are forbidden).
% \begin{macrocode}
\NewDocumentEnvironment { NiceArray } { O { } m ! O { } }
{
+ \@@_adapt_S_column:
+ \@@_test_if_math_mode:
\bool_if:NT \l_@@_in_NiceArray_bool
{ \@@_error:n { Yet~in~NiceArray } }
+ \bool_set_true:N \l_@@_in_NiceArray_bool
% \end{macrocode}
%
% We deactivate Tikz externalization (since we use Tikz pictures with the
@@ -2956,7 +3102,6 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_if_exist:NT \tikz@library@external@loaded
{ \tikzset { external / export = false } }
- \bool_set_true:N \l_@@_in_NiceArray_bool
\group_insert_after:N \@@_after_array:
\tl_gclear_new:N \g_@@_lines_to_draw_tl
% \end{macrocode}
@@ -2991,7 +3136,7 @@ version 2005/12/01 or later.
{
\group_insert_after:N \@@_write_max_cell_width:
\cs_if_free:cTF { _@@_max_cell_width_ \int_use:N \g_@@_env_int }
- { \dim_set:Nn \l_@@_columns_width_dim \c_zero_dim }
+ { \dim_zero:N \l_@@_columns_width_dim }
{
\dim_set:Nx \l_@@_columns_width_dim
{ \use:c { _@@_max_cell_width _ \int_use:N \g_@@_env_int } }
@@ -3036,7 +3181,21 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_set:Npn \ialign
{
- \everycr { \noalign { \int_gzero:N \g_@@_column_int } }
+ \everycr
+ {
+ \noalign
+ {
+ \int_gzero:N \g_@@_column_int
+ \bool_if:NT \l_@@_hlines_bool
+ {
+ \int_compare:nNnT \g_@@_row_int > { -1 }
+ {
+ \hrule \@height \arrayrulewidth
+ \skip_vertical:n { - \arrayrulewidth }
+ }
+ }
+ }
+ }
\tabskip = \c_zero_skip
\cs_set:Npn \ialign
{
@@ -3124,30 +3283,40 @@ version 2005/12/01 or later.
{
\int_gset_eq:NN \g_@@_last_vdotted_col_int \g_@@_column_int
\tl_gput_right:Nx \g_@@_code_after_tl
- {
- \exp_not:N \@@_vdottedline:n
- \exp_not:N {
- \int_use:N \g_@@_column_int
- \exp_not:N }
- }
+% \end{macrocode}
+% The command |\@@_vdottedline:n| is protected, and, therefore, won't be expanded
+% before writing on |\g_@@_code_after_tl|.
+% \begin{macrocode}
+ { \@@_vdottedline:n { \int_use:N \g_@@_column_int } }
}
}
}
% \end{macrocode}
%
-%
%
% The commands |\Ldots|, |\Cdots|, etc. will be defined only in the environment
-% |{NiceArray}|. If the class option |draft| is used, these commands will be
-% defined to be no-op (the dotted lines are not drawn).
+% |{NiceArray}|.
% \begin{macrocode}
- \bool_if:NTF \c_@@_draft_bool
- \@@_define_dots_to_nil:
- \@@_define_dots:
+ \cs_set_eq:NN \Ldots \@@_Ldots
+ \cs_set_eq:NN \Cdots \@@_Cdots
+ \cs_set_eq:NN \Vdots \@@_Vdots
+ \cs_set_eq:NN \Ddots \@@_Ddots
+ \cs_set_eq:NN \Iddots \@@_Iddots
\cs_set_eq:NN \hdottedline \@@_hdottedline:
\cs_set_eq:NN \Hspace \@@_Hspace:
\cs_set_eq:NN \Hdotsfor \@@_Hdotsfor
\cs_set_eq:NN \multicolumn \@@_multicolumn:nnn
+ \bool_if:NT \l_@@_renew_dots_bool
+ {
+ \cs_set_eq:NN \ldots \@@_Ldots
+ \cs_set_eq:NN \cdots \@@_Cdots
+ \cs_set_eq:NN \vdots \@@_Vdots
+ \cs_set_eq:NN \ddots \@@_Ddots
+ \cs_set_eq:NN \iddots \@@_Iddots
+ \cs_set_eq:NN \dots \@@_Ldots
+ \cs_set_eq:NN \hdotsfor \@@_Hdotsfor
+ }
+ \bool_if:NT \c_@@_siunitx_loaded_bool \@@_renew_NC@rewrite@S:
% \end{macrocode}
%
%
@@ -3206,7 +3375,8 @@ version 2005/12/01 or later.
% \end{macrocode}
%
% \begin{macrocode}
- \skip_horizontal:n { \l_@@_left_margin_dim + \l_@@_extra_left_margin_dim }
+ \skip_horizontal:n \l_@@_left_margin_dim
+ \skip_horizontal:n \l_@@_extra_left_margin_dim
% \end{macrocode}
%
%
@@ -3238,8 +3408,8 @@ version 2005/12/01 or later.
{ \endarray
\bool_if:NF \l_@@_exterior_arraycolsep_bool
{ \skip_horizontal:n { - \arraycolsep } }
- \skip_horizontal:n
- { \g_@@_right_margin_dim + \g_@@_extra_right_margin_dim }
+ \skip_horizontal:n \g_@@_right_margin_dim
+ \skip_horizontal:n \g_@@_extra_right_margin_dim
}
% \end{macrocode}
%
@@ -3248,31 +3418,46 @@ version 2005/12/01 or later.
% We create the variants of the environment |{NiceMatrix}|.
% \begin{macrocode}
\NewDocumentEnvironment { pNiceMatrix } { }
- { \left( \begin{NiceMatrix} }
+ {
+ \@@_test_if_math_mode:
+ \left( \begin{NiceMatrix}
+ }
{ \end{NiceMatrix} \right) }
% \end{macrocode}
%
% \begin{macrocode}
\NewDocumentEnvironment { bNiceMatrix } { }
- { \left[ \begin{NiceMatrix} }
+ {
+ \@@_test_if_math_mode:
+ \left[ \begin{NiceMatrix}
+ }
{ \end{NiceMatrix} \right] }
% \end{macrocode}
%
% \begin{macrocode}
\NewDocumentEnvironment { BNiceMatrix } { }
- { \left\{ \begin{NiceMatrix} }
+ {
+ \@@_test_if_math_mode:
+ \left\{ \begin{NiceMatrix}
+ }
{ \end{NiceMatrix} \right\} }
% \end{macrocode}
%
% \begin{macrocode}
\NewDocumentEnvironment { vNiceMatrix } { }
- { \left\lvert \begin{NiceMatrix} }
+ {
+ \@@_test_if_math_mode:
+ \left\lvert \begin{NiceMatrix}
+ }
{ \end{NiceMatrix} \right\rvert }
% \end{macrocode}
%
% \begin{macrocode}
\NewDocumentEnvironment { VNiceMatrix } {}
- { \left\lVert \begin{NiceMatrix} }
+ {
+ \@@_test_if_math_mode:
+ \left\lVert \begin{NiceMatrix}
+ }
{ \end{NiceMatrix} \right\rVert }
% \end{macrocode}
%
@@ -3300,10 +3485,13 @@ version 2005/12/01 or later.
% If the environment has a name, we also create an alias named
% |\@@_max_cell_width_|{\ttfamily\slshape name}.
% \begin{macrocode}
- \iow_now:Nx \@mainaux
+ \str_if_empty:NF \g_@@_name_str
{
- \cs_gset:cpn { @@_max_cell_width_ \g_@@_name_str }
- { \dim_use:N \g_@@_max_cell_width_dim }
+ \iow_now:Nx \@mainaux
+ {
+ \cs_gset:cpn { @@_max_cell_width_ \g_@@_name_str }
+ { \dim_use:N \g_@@_max_cell_width_dim }
+ }
}
\iow_now:Nn \@mainaux \ExplSyntaxOff
}
@@ -3328,7 +3516,7 @@ version 2005/12/01 or later.
% \end{macrocode}
% We manage a list of ``empty cells'' called |\g_@@_empty_cells_seq|. In fact,
% this list is not a list of all the empty cells of the array but only those
-% explicitely declared empty for some reason. It's easy to check if the current
+% explicitly declared empty for some reason. It's easy to check if the current
% cell is in this list.
% \begin{macrocode}
{
@@ -3352,8 +3540,8 @@ version 2005/12/01 or later.
\pgfpointanchor \l_tmpa_tl { west }
\dim_gset:Nn \g_tmpb_dim \pgf@x
\end { pgfpicture }
- \dim_compare:nTF
- { \dim_abs:n { \g_tmpb_dim - \g_tmpa_dim } < 0.5 pt }
+ \dim_compare:nNnTF
+ { \dim_abs:n { \g_tmpb_dim - \g_tmpa_dim } } < { 0.5 pt }
\prg_return_false:
\prg_return_true:
}
@@ -3394,14 +3582,18 @@ version 2005/12/01 or later.
% \end{scope}
%
% \begin{macrocode}
-\cs_new_protected:Nn \@@_instruction_of_type:n
- {
- \tl_gput_right:Nx \g_@@_lines_to_draw_tl
+\bool_if:NTF \c_@@_draft_bool
+ { \cs_set_protected:Npn \@@_instruction_of_type:n #1 { } }
+ {
+ \cs_new_protected:Npn \@@_instruction_of_type:n #1
{
- \exp_not:c { @@ _ draw _ #1 : nn }
- { \int_use:N \g_@@_row_int }
- { \int_use:N \g_@@_column_int }
- }
+ \tl_gput_right:Nx \g_@@_lines_to_draw_tl
+ {
+ \exp_not:c { @@ _ draw _ #1 : nn }
+ { \int_use:N \g_@@_row_int }
+ { \int_use:N \g_@@_column_int }
+ }
+ }
}
% \end{macrocode}
%
@@ -3411,7 +3603,7 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Nn \@@_after_array:
{
- \int_compare:nNnTF \g_@@_row_int > 0
+ \int_compare:nNnTF \g_@@_row_int > \c_zero_int
\@@_after_array_i:
{ \@@_error:n { Zero~row } }
}
@@ -3420,8 +3612,9 @@ version 2005/12/01 or later.
% \begin{macrocode}
\@@_msg_new:nn { Zero~row }
{
- There~is~a~problem.~Maybe~your~environment~is~empty.~Maybe~you~have~used~L,~
- ~C~and~R~instead~of~l,~c~and~r~in~the~preamble~of~your~environment.\\
+ There~is~a~problem.~Maybe~your~environment~\{\@currenvir\}~is~empty.~
+ Maybe~you~have~used~L,~C~and~R~instead~of~l,~c~and~r~in~the~preamble~
+ of~your~environment. \\
If~you~go~on,~the~result~may~be~incorrect.
}
% \end{macrocode}
@@ -3679,7 +3872,7 @@ version 2005/12/01 or later.
% \interitem
% If the dotted line to draw is in the list of the previously drawn lines
% (|\g_@@_yet_drawn_seq|), we don't draw (so, we won't have overlapping lines in
-% the \textsc{pdf}). The token list |\l_tmpa_tl| is the $4$-uplet characteristic
+% the \textsc{pdf}). The token list |\l_tmpa_tl| is the $4$-list characteristic
% of the line.
% \begin{macrocode}
\prg_set_conditional:Npnn \@@_if_yet_drawn: { F }
@@ -4211,7 +4404,7 @@ version 2005/12/01 or later.
% the following command |\@@_multicolumn:nnn|.
% \begin{macrocode}
\cs_set_eq:NN \@@_old_multicolumn \multicolumn
-\cs_new:Nn \@@_multicolumn:nnn
+\cs_new:Npn \@@_multicolumn:nnn #1 #2 #3
{
\@@_old_multicolumn { #1 } { #2 } { #3 }
\int_compare:nNnT #1 > 1
@@ -4232,16 +4425,23 @@ version 2005/12/01 or later.
% beetween two consecutive dots). Tikz nodes are created for all the cells of
% the array, even the implicit cells of the |\Hdotsfor|.
% \begin{macrocode}
-\NewDocumentCommand \@@_Hdotsfor { O { } m }
- {
- \tl_gput_right:Nx \g_@@_lines_to_draw_tl
+\bool_if:NTF \c_@@_draft_bool
+ {
+ \NewDocumentCommand \@@_Hdotsfor { O { } m }
+ { \prg_replicate:nn { #2 - 1 } { & } }
+ }
+ {
+ \NewDocumentCommand \@@_Hdotsfor { O { } m }
{
- \exp_not:N \@@_draw_Hdotsfor:nnn
- { \int_use:N \g_@@_row_int }
- { \int_use:N \g_@@_column_int }
- { #2 }
- }
- \prg_replicate:nn { #2 - 1 } { & }
+ \tl_gput_right:Nx \g_@@_lines_to_draw_tl
+ {
+ \@@_draw_Hdotsfor:nnn
+ { \int_use:N \g_@@_row_int }
+ { \int_use:N \g_@@_column_int }
+ { #2 }
+ }
+ \prg_replicate:nn { #2 - 1 } { & }
+ }
}
% \end{macrocode}
%
@@ -4347,23 +4547,25 @@ version 2005/12/01 or later.
\cs_generate_variant:Nn \dim_set:Nn { N v }
% \end{macrocode}
%
-% \medskip
-% The command |\@@_hdottedline:| (which is linked to |\hdottedline| in the
-% environment |{NiceArray}|) begins with a |\noalign| which contains a
-% vertical skip which is part of the construction of the ``false row''.
%
% \medskip
-% Some extension, like the extension \pkg{doc} do a redefinition of the command
+% Some extension, like the extension \pkg{doc}, do a redefinition of the command
% |\dotfill| of LaTeX. That's why we define a command |\@@_dotfill:| as we wish.
% \begin{macrocode}
-\cs_set:Npn \@@_dotfill:
- { \cleaders \hbox_to_wd:nn {.44em} {\hss .\hss } \hfill \kern \c_zero_dim }
+\bool_if:NTF \c_@@_draft_bool
+ { \cs_set_eq:NN \@@_dotfill: \prg_do_nothing: }
+ {
+ \cs_set:Npn \@@_dotfill:
+ {
+ \cleaders \hbox_to_wd:nn { .44 em } { \hss .\hss } \hfill
+ \skip_horizontal:n \c_zero_dim
+ }
+ }
% \end{macrocode}
%
-
% This command must \emph{not} be protected because it starts with |\noalign|.
% \begin{macrocode}
-\cs_new:Nn \@@_hdottedline:
+\cs_new:Npn \@@_hdottedline:
{
\noalign
{
@@ -4385,23 +4587,6 @@ version 2005/12/01 or later.
%
%
%
-% \begin{macrocode}
-\@@_msg_new:nn { Use~of~hdottedline~in~first~position }
- {
- You~can't~use~the~command~\token_to_str:N\hdottedline\ in~the~first~row~
- of~the~environment~\{\@currenvir\}.~But~maybe~you~have~used~l,~c~and~r~
- instead~of~L,~C,~R~in~the~preamble~of~the~array.\\
- If~you~go~on,~this~dotted~line~will~be~ignored.
- }
-\@@_msg_new:nn { Use~of~hdottedline~in~first~position~bis }
- {
- You~can't~use~the~command~\token_to_str:N\hdottedline\ in~the~first~row~
- of~the~environment~\{\@currenvir\}. \\
- If~you~go~on,~this~dotted~line~will~be~ignored.
- }
-% \end{macrocode}
-%
-%
% \bigskip
% \begin{macrocode}
\cs_new_protected:Nn \@@_vdottedline:n
@@ -4567,6 +4752,7 @@ version 2005/12/01 or later.
create-extra-nodes,~
extra-left-margin,~
extra-right-margin,~
+ hlines,~
left-margin,~
name,~
nullify-dots,~
@@ -4610,7 +4796,7 @@ version 2005/12/01 or later.
\int_gincr:N \g_@@_column_int
\int_gset:Nn \g_@@_column_total_int
{ \int_max:nn \g_@@_column_total_int \g_@@_column_int }
- \hbox_set:Nw \l_tmpa_box $ % $
+ \hbox_set:Nw \l_tmpa_box \c_math_toggle_token
\l_@@_code_for_last_col_tl
}
l
@@ -4620,7 +4806,7 @@ version 2005/12/01 or later.
% array, will contain the maximal width of the cells of the last column (thus,
% it will be equal to the width of the last column).
% \begin{macrocode}
- < { $ % $
+ < { \c_math_toggle_token
\hbox_set_end:
\dim_gset:Nn \g_@@_width_last_col_dim
{
@@ -4676,7 +4862,8 @@ version 2005/12/01 or later.
% left and the right delimiter.
% \begin{macrocode}
\NewDocumentEnvironment { NiceArrayCwithDelims } { m m O { } m ! O { } }
- {
+ {
+ \@@_test_if_math_mode:
\dim_gzero_new:N \g_@@_width_last_col_dim
\keys_set:nn { NiceMatrix / NiceArrayC } { #3 , #5 }
\bool_set_false:N \l_@@_exterior_arraycolsep_bool
@@ -4761,6 +4948,7 @@ version 2005/12/01 or later.
create-extra-nodes,~
extra-left-margin,~
extra-right-margin,~
+ hlines,~
left-margin,~
name,~
nullify-dots,~
@@ -4770,15 +4958,52 @@ version 2005/12/01 or later.
}
% \end{macrocode}
%
-%
+% \bigskip
% The first and the second argument of the environment |{NiceArrayRCwithDelims}|
% are the delimiters which will be used in the array. Usually, the final user
% will not use directly this environment |{NiceArrayRCwithDelims}| because he
% will use one of the variants |{pNiceArrayRC}|, |{vNiceArrayRC}|, etc.
%
+%
+% \medskip
+% We don't want that a vertical rule drawn by this specifier extends in the
+% first row of the array (since this first row is for the labels and is
+% ``outside'' the matrix).
+%
+% The natural way to do that would be to redefine the specifier ``"|"''
+% with |\newcolumntype|:
+% \begin{Verbatim}[commandchars=\~\#\+]
+% \newcolumntype { | }
+% { ! { \int_compare:nNnF \g_@@_row_int = \c_zero_int \vline } }
+% \end{Verbatim}
+%
+% However, this code fails is the user uses "\DefineShortVerb{\|}" of
+% \pkg{fancyvrb}. Moreover, it would not be able to deal correctly with two
+% consecutive specifier ``"|"'' (in a preambule like "ccc||ccc").
+%
+% That's why we will do a redefinition of the macro |\@arrayrule| of \pkg{array}
+% and this redefinition will add |\@@_vline:| instead of |\vline| to the
+% preamble.
+%
+% Here is the definition of |\@@_vline:|. This definition \emph{must} be
+% protected because you don't want that macro expanded during the construction of
+% the preamble (the test must be effective in each row and not once when the
+% preamble is constructed).
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_vline:
+ {
+ \int_compare:nNnTF \g_@@_column_int = \c_zero_int
+ { \int_compare:nNnF \g_@@_row_int < \c_zero_int \vline }
+ { \int_compare:nNnF \g_@@_row_int < \c_one_int \vline }
+ }
+% \end{macrocode}
+%
+% \bigskip
% \begin{macrocode}
\NewDocumentEnvironment { NiceArrayRCwithDelims } { m m O { } m ! O { } }
{
+ \@@_test_if_math_mode:
+ \cs_set_protected:Npn \@arrayrule { \@addtopreamble \@@_vline: }
\int_zero:N \l_@@_nb_first_row_int
\dim_gzero_new:N \g_@@_width_last_col_dim
\keys_set:nn { NiceMatrix / NiceArrayRC } { #3 , #5 }
@@ -4786,25 +5011,25 @@ version 2005/12/01 or later.
\str_set:Nn \l_@@_pos_env_str c
\box_clear_new:N \l_@@_the_array_box
\hbox_set:Nw \l_@@_the_array_box
- $ % $
+ \c_math_toggle_token
\@@_NiceArrayC:n { #4 }
}
{
\end { NiceArray }
- $ % $
+ \c_math_toggle_token
\hbox_set_end:
\dim_set:Nn \l_tmpa_dim
{
(
\dim_max:nn
- { 12 pt }
- { \g_@@_max_ht_row_one_dim + \g_@@_max_dp_row_zero_dim }
+ { 12 pt }
+ { \g_@@_max_ht_row_one_dim + \g_@@_max_dp_row_zero_dim }
)
+ \g_@@_max_ht_row_zero_dim - \g_@@_max_ht_row_one_dim
}
\hbox_set:Nn \l_tmpa_box
{
- $ % $
+ \c_math_toggle_token
\left #1
\vcenter
{
@@ -4812,7 +5037,7 @@ version 2005/12/01 or later.
\box_use_drop:N \l_@@_the_array_box
}
\right #2
- $ % $
+ \c_math_toggle_token
\skip_horizontal:n \g_@@_width_last_col_dim
}
\box_set_ht:Nn \l_tmpa_box { \box_ht:N \l_tmpa_box + \l_tmpa_dim }
@@ -4867,7 +5092,7 @@ version 2005/12/01 or later.
%
% \bigskip
% For each row $i$, we compute two dimensions
-% \texttt{l_@@_row_\textsl{i}_min_dim} and \texttt{l_@@_row_\textsl{i}_max_dim}.
+% "l_@@_row_\textsl{i}_min_dim" and \texttt{l_@@_row_\textsl{i}_max_dim}.
% The dimension \texttt{l_@@_row_\textsl{i}_min_dim} is the minimal
% $y$-value of all the cells of the row~$i$. The dimension
% \texttt{l_@@_row_\textsl{i}_max_dim} is the maximal $y$-value of all the cells
@@ -4886,33 +5111,33 @@ version 2005/12/01 or later.
\cs_new_protected:Nn \@@_create_extra_nodes:
{
\begin { tikzpicture } [ remember~picture , overlay ]
- \int_step_variable:nnnNn \l_@@_nb_first_row_int 1 \g_@@_row_int \@@_i
+ \int_step_variable:nnnNn \l_@@_nb_first_row_int 1 \g_@@_row_int \@@_i:
{
- \dim_zero_new:c { l_@@_row_\@@_i _min_dim }
- \dim_set_eq:cN { l_@@_row_\@@_i _min_dim } \c_max_dim
- \dim_zero_new:c { l_@@_row_\@@_i _max_dim }
- \dim_set:cn { l_@@_row_\@@_i _max_dim } { - \c_max_dim }
+ \dim_zero_new:c { l_@@_row_\@@_i: _min_dim }
+ \dim_set_eq:cN { l_@@_row_\@@_i: _min_dim } \c_max_dim
+ \dim_zero_new:c { l_@@_row_\@@_i: _max_dim }
+ \dim_set:cn { l_@@_row_\@@_i: _max_dim } { - \c_max_dim }
}
- \int_step_variable:nNn \g_@@_column_total_int \@@_j
+ \int_step_variable:nNn \g_@@_column_total_int \@@_j:
{
- \dim_zero_new:c { l_@@_column_\@@_j _min_dim }
- \dim_set_eq:cN { l_@@_column_\@@_j _min_dim } \c_max_dim
- \dim_zero_new:c { l_@@_column_\@@_j _max_dim }
- \dim_set:cn { l_@@_column_\@@_j _max_dim } { - \c_max_dim }
+ \dim_zero_new:c { l_@@_column_\@@_j: _min_dim }
+ \dim_set_eq:cN { l_@@_column_\@@_j: _min_dim } \c_max_dim
+ \dim_zero_new:c { l_@@_column_\@@_j: _max_dim }
+ \dim_set:cn { l_@@_column_\@@_j: _max_dim } { - \c_max_dim }
}
% \end{macrocode}
% We begin the two nested loops over the rows and the columns of the array.
% \begin{macrocode}
- \int_step_variable:nnNn \l_@@_nb_first_row_int \g_@@_row_int \@@_i
+ \int_step_variable:nnNn \l_@@_nb_first_row_int \g_@@_row_int \@@_i:
{
- \int_step_variable:nNn \g_@@_column_total_int \@@_j
+ \int_step_variable:nNn \g_@@_column_total_int \@@_j:
% \end{macrocode}
% Maybe the cell ($i$-$j$) is an implicit cell (that is to say a cell after
% implicit ampersands |&|). In this case, of course, we don't update the
% dimensions we want to compute.
% \begin{macrocode}
{ \cs_if_exist:cT
- { pgf@sh@ns@nm - \int_use:N \g_@@_env_int - \@@_i- \@@_j }
+ { pgf@sh@ns@nm - \int_use:N \g_@@_env_int - \@@_i: - \@@_j: }
% \end{macrocode}
% We retrieve the coordinates of the anchor |south west| of the (normal) node of
% the cell ($i$-$j$). They will be stored in |\pgf@x| and |\pgf@y|.
@@ -4920,26 +5145,26 @@ version 2005/12/01 or later.
{
\tikz@parse@node \pgfutil@firstofone
( nm - \int_use:N \g_@@_env_int
- - \@@_i - \@@_j .south~west )
- \dim_set:cn { l_@@_row_\@@_i _min_dim}
- { \dim_min:vn { l_@@_row _ \@@_i _min_dim } \pgf@y }
- \seq_if_in:NxF \g_@@_multicolumn_cells_seq { \@@_i - \@@_j }
+ - \@@_i: - \@@_j: .south~west )
+ \dim_set:cn { l_@@_row_\@@_i: _min_dim}
+ { \dim_min:vn { l_@@_row _ \@@_i: _min_dim } \pgf@y }
+ \seq_if_in:NxF \g_@@_multicolumn_cells_seq { \@@_i: - \@@_j: }
{
- \dim_set:cn { l_@@_column _ \@@_j _ min_dim}
- { \dim_min:vn { l_@@_column _ \@@_j _min_dim } \pgf@x }
+ \dim_set:cn { l_@@_column _ \@@_j: _min_dim}
+ { \dim_min:vn { l_@@_column _ \@@_j: _min_dim } \pgf@x }
}
% \end{macrocode}
% We retrieve the coordinates of the anchor |north east| of the (normal) node of
% the cell ($i$-$j$). They will be stored in |\pgf@x| and |\pgf@y|.
% \begin{macrocode}
\tikz@parse@node \pgfutil@firstofone
- ( nm - \int_use:N \g_@@_env_int - \@@_i - \@@_j .north~east )
- \dim_set:cn { l_@@_row _ \@@_i _ max_dim }
- { \dim_max:vn { l_@@_row _ \@@_i _ max_dim } \pgf@y }
- \seq_if_in:NxF \g_@@_multicolumn_cells_seq { \@@_i - \@@_j }
+ ( nm - \int_use:N \g_@@_env_int - \@@_i: - \@@_j: .north~east )
+ \dim_set:cn { l_@@_row _ \@@_i: _ max_dim }
+ { \dim_max:vn { l_@@_row _ \@@_i: _ max_dim } \pgf@y }
+ \seq_if_in:NxF \g_@@_multicolumn_cells_seq { \@@_i: - \@@_j: }
{
- \dim_set:cn { l_@@_column _ \@@_j _ max_dim }
- { \dim_max:vn { l_@@_column _ \@@_j _max_dim } \pgf@x }
+ \dim_set:cn { l_@@_column _ \@@_j: _ max_dim }
+ { \dim_max:vn { l_@@_column _ \@@_j: _max_dim } \pgf@x }
}
}
}
@@ -4969,33 +5194,33 @@ version 2005/12/01 or later.
% \texttt{l_@@_column_\textsl{j}_min_dim} and
% \texttt{l_@@_column_\textsl{j}_max_dim}.
% \begin{macrocode}
- \int_step_variable:nNn { \g_@@_row_int - 1 } \@@_i
+ \int_step_variable:nNn { \g_@@_row_int - 1 } \@@_i:
{
- \dim_set:cn { l_@@_row _ \@@_i _ min _ dim }
+ \dim_set:cn { l_@@_row _ \@@_i: _ min _ dim }
{
(
- \dim_use:c { l_@@_row _ \@@_i _ min _ dim } +
- \dim_use:c { l_@@_row _ \int_eval:n { \@@_i + 1 } _ max _ dim }
+ \dim_use:c { l_@@_row _ \@@_i: _ min _ dim } +
+ \dim_use:c { l_@@_row _ \int_eval:n { \@@_i: + 1 } _ max _ dim }
)
/ 2
}
- \dim_set_eq:cc { l_@@_row _ \int_eval:n { \@@_i + 1 } _ max _ dim }
- { l_@@_row_\@@_i _min_dim }
+ \dim_set_eq:cc { l_@@_row _ \int_eval:n { \@@_i: + 1 } _ max _ dim }
+ { l_@@_row_\@@_i: _min_dim }
}
- \int_step_variable:nNn { \g_@@_column_int - 1 } \@@_j
+ \int_step_variable:nNn { \g_@@_column_int - 1 } \@@_j:
{
- \dim_set:cn { l_@@_column _ \@@_j _ max _ dim }
+ \dim_set:cn { l_@@_column _ \@@_j: _ max _ dim }
{
(
\dim_use:c
- { l_@@_column _ \@@_j _ max _ dim } +
+ { l_@@_column _ \@@_j: _ max _ dim } +
\dim_use:c
- { l_@@_column _ \int_eval:n { \@@_j + 1 } _ min _ dim }
+ { l_@@_column _ \int_eval:n { \@@_j: + 1 } _ min _ dim }
)
/ 2
}
- \dim_set_eq:cc { l_@@_column _ \int_eval:n { \@@_j + 1 } _ min _ dim }
- { l_@@_column _ \@@_j _ max _ dim }
+ \dim_set_eq:cc { l_@@_column _ \int_eval:n { \@@_j: + 1 } _ min _ dim }
+ { l_@@_column _ \@@_j: _ max _ dim }
}
\dim_sub:cn
{ l_@@_column _ 1 _ min _ dim }
@@ -5015,7 +5240,7 @@ version 2005/12/01 or later.
% When used once, the command |\@@_create_extra_nodes:| must become no-op (in
% the current TeX group). That's why we put a nullification of the command.
% \begin{macrocode}
- \cs_set:Nn \@@_create_extra_nodes: { }
+ \cs_set:Npn \@@_create_extra_nodes: { }
% \end{macrocode}
%
% \medskip
@@ -5053,9 +5278,9 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Nn \@@_create_nodes:
{
- \int_step_variable:nnnNn \l_@@_nb_first_row_int 1 \g_@@_row_int \@@_i
+ \int_step_variable:nnNn \l_@@_nb_first_row_int \g_@@_row_int \@@_i:
{
- \int_step_variable:nnnNn 1 1 \g_@@_column_total_int \@@_j
+ \int_step_variable:nNn \g_@@_column_total_int \@@_j:
% \end{macrocode}
% We create two ponctual nodes for the extremities of a diagonal of the
% rectangular node we want to create. These nodes |(@@~south~west)| and
@@ -5065,11 +5290,11 @@ version 2005/12/01 or later.
% \begin{macrocode}
{
\coordinate ( @@~south~west )
- at ( \dim_use:c { l_@@_column_ \@@_j _min_dim } ,
- \dim_use:c { l_@@_row_ \@@_i _min_dim } ) ;
+ at ( \dim_use:c { l_@@_column_ \@@_j: _min_dim } ,
+ \dim_use:c { l_@@_row_ \@@_i: _min_dim } ) ;
\coordinate ( @@~north~east )
- at ( \dim_use:c { l_@@_column_ \@@_j _max_dim },
- \dim_use:c { l_@@_row_ \@@_i _max_dim } ) ;
+ at ( \dim_use:c { l_@@_column_ \@@_j: _max_dim },
+ \dim_use:c { l_@@_row_ \@@_i: _max_dim } ) ;
% \end{macrocode}
% We can eventually draw the rectangular node for the cell (|\@@_i|-|\@@_j|).
% This node is created with the Tikz library \pkg{fit}. Don't forget that the
@@ -5080,10 +5305,10 @@ version 2005/12/01 or later.
node~contents = { } ,
fit = ( @@~south~west ) ( @@~north~east ) ,
inner~sep = \c_zero_dim ,
- name = nm - \int_use:N \g_@@_env_int - \@@_i - \@@_j ,
+ name = nm - \int_use:N \g_@@_env_int - \@@_i: - \@@_j: ,
alias =
\str_if_empty:NF \g_@@_name_str
- { \g_@@_name_str - \@@_i - \@@_j }
+ { \g_@@_name_str - \@@_i: - \@@_j: }
]
;
}
@@ -5106,8 +5331,8 @@ version 2005/12/01 or later.
% \begin{macrocode}
\cs_new_protected:Npn \@@_extract_coords: #1 - #2 \q_stop
{
- \cs_set:Npn \@@_i { #1 }
- \cs_set:Npn \@@_j { #2 }
+ \cs_set:Npn \@@_i: { #1 }
+ \cs_set:Npn \@@_j: { #2 }
}
% \end{macrocode}
%
@@ -5121,22 +5346,22 @@ version 2005/12/01 or later.
\@@_extract_coords: #1 \q_stop
\coordinate ( @@~south~west ) at
(
- \dim_use:c { l_@@_column _ \@@_j _ min _ dim } ,
- \dim_use:c { l_@@_row _ \@@_i _ min _ dim }
+ \dim_use:c { l_@@_column _ \@@_j: _ min _ dim } ,
+ \dim_use:c { l_@@_row _ \@@_i: _ min _ dim }
) ;
\coordinate ( @@~north~east ) at
(
- \dim_use:c { l_@@_column _ \int_eval:n { \@@_j + #2 - 1 } _ max _ dim} ,
- \dim_use:c { l_@@_row _ \@@_i _ max _ dim }
+ \dim_use:c { l_@@_column _ \int_eval:n { \@@_j: + #2 - 1 } _ max _ dim} ,
+ \dim_use:c { l_@@_row _ \@@_i: _ max _ dim }
) ;
\node
[
node~contents = { } ,
fit = ( @@~south~west ) ( @@~north~east ) ,
inner~sep = \c_zero_dim ,
- name = nm - \int_use:N \g_@@_env_int - \@@_i - \@@_j ,
+ name = nm - \int_use:N \g_@@_env_int - \@@_i: - \@@_j: ,
alias =
- \str_if_empty:NF \g_@@_name_str { \g_@@_name_str - \@@_i - \@@_j }
+ \str_if_empty:NF \g_@@_name_str { \g_@@_name_str - \@@_i: - \@@_j: }
]
;
}
@@ -5155,10 +5380,11 @@ version 2005/12/01 or later.
% Of course, the command |\NiceMatrix| must be defined before such an
% instruction is executed.
% \begin{macrocode}
-\ProcessKeysOptions {NiceMatrix}
+\ProcessKeysOptions { NiceMatrix }
% \end{macrocode}
%
-% \subsection{Code for \texttt{seq_mapthread_function:NNN}}
+%
+% \subsection{Code for \textbackslash seq_mapthread_function:NNN}
%
% In |\@@_create_nodes:| (used twice in |\@@_create_extra_nodes:| to create the
% ``medium nodes'' and ``large nodes''), we want to use
@@ -5310,7 +5536,7 @@ version 2005/12/01 or later.
%
% Possibility to draw vertical dotted lines to separate columns with the
% specifier ``|:|'' in the preamble (similar to the classical specifier
-% ``\verb+|+'' and the specifier ``|:|'' of \pkg{arydshln}).
+% ``"|"'' and the specifier ``|:|'' of \pkg{arydshln}).
%
% \subsection{Changes between version 2.2 and 2.2.1}
%
@@ -5319,6 +5545,18 @@ version 2005/12/01 or later.
%
% Modification of the position of the dotted lines drawn by |\hdottedline|.
%
+% \subsection{Changes between version 2.2.1 and 2.3}
+%
+% Compatibility with the column type |S| of \pkg{siunitx}.
+%
+% Option |hlines|.
+%
+% A warning is issued when the |draft| mode is used. In this case, the dotted
+% lines are not drawn.
+%
+% \PrintIndex
+%
+% \tableofcontents
% \endinput
% Local Variables:
% TeX-fold-mode: nil