diff options
author | Karl Berry <karl@freefriends.org> | 2023-05-16 20:22:30 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-05-16 20:22:30 +0000 |
commit | 9878b019471468462f25f79fd6a5837b9bcad076 (patch) | |
tree | 65cd04ec4a6524830f9ec0d9be55d241acf87c98 /Master/texmf-dist | |
parent | 8e9d8b027e86eefeb1788f42ec5fc0a8c76548ba (diff) |
nicematrix (16may23)
git-svn-id: svn://tug.org/texlive/trunk@67135 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/README.md | 2 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix-code.pdf | bin | 0 -> 909639 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf | bin | 553017 -> 577804 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex | 616 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf | bin | 1380299 -> 571224 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/nicematrix/nicematrix.tex | 7484 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/nicematrix/nicematrix-code.dtx (renamed from Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx) | 7609 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/nicematrix/nicematrix.ins | 2 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty | 363 |
9 files changed, 8512 insertions, 7564 deletions
diff --git a/Master/texmf-dist/doc/latex/nicematrix/README.md b/Master/texmf-dist/doc/latex/nicematrix/README.md index 5822e17e0e7..da760d43741 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/README.md +++ b/Master/texmf-dist/doc/latex/nicematrix/README.md @@ -19,7 +19,7 @@ The package `nicematrix` is present in the distributions MiKTeX, TeXLive and Mac For a manual installation: -* put the files `nicematrix.ins` and `nicematrix.dtx` in the same directory; +* put the files `nicematrix.ins` and `nicematrix-code.dtx` in the same directory; * run `latex nicematrix.ins` in that directory. The file `nicematrix.sty` will be generated. diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-code.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-code.pdf Binary files differnew file mode 100644 index 00000000000..6cc99d6835b --- /dev/null +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-code.pdf diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf Binary files differindex efad4b58efd..fcc05694fd7 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.pdf diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex index 920c1844330..1b5bf2b9df7 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix-french.tex @@ -17,6 +17,8 @@ \usepackage{siunitx} \usepackage{verbatim} \usepackage{caption} +\usepackage{tocloft} +\setlength{\cftsubsecnumwidth}{3em} % for the numbers of subsections of the TOC % On utilise \MakeShortVerb de shortvrb et pas \DefineShortVerb de fancyvrb % car on ne veut pas que le contenu des petits éléments en verbatim soit colorié @@ -42,18 +44,6 @@ \usepackage{tcolorbox} \usepackage{adjustbox} \usepackage[auto-lang=false]{lipsum} -\usepackage[hyperfootnotes = false]{hyperref} - -\hypersetup - { - pdfinfo = - { - Title = L’extension nicematrix , - Subject = Une extension LaTeX , - Author = F. Pantigny - } - } - \NewDocumentEnvironment {scope} {} {} {} @@ -67,6 +57,26 @@ \NewDocumentCommand{\Definition}{m} {{\setlength{\fboxsep}{1pt}\colorbox{gray!20}{\ttfamily \vphantom{gl}#1}}} +\usepackage{makeidx} +\makeindex + +\NewDocumentCommand{\indexcommand}{m}{\index{#1@\texttt{\textbackslash #1}}} + +\NewDocumentCommand{\indexenv}{m}{\index{#1@\texttt{\{#1\}}}} + + +\usepackage[hyperfootnotes = false]{hyperref} + +\hypersetup + { + pdfinfo = + { + Title = L’extension nicematrix , + Subject = Une extension LaTeX , + Author = F. Pantigny + } + } + \begin{document} @@ -155,7 +165,7 @@ utiliser pour développer de nouvelles fonctionnalités. Comme toujours avec pour être utilisées à la compilation suivante. C'est pourquoi l'utilisation de \pkg{nicematrix} nécessite \textbf{plusieurs compilations successives}.\footnote{Si vous utilisez Overleaf, Overleaf effectue - automatiquement le nombre de compilations nécessaire.} + automatiquement un nombre de compilations suffisant.} \medskip La plupart des fonctionnalités de \pkg{nicematrix} sont accessibles sans avoir à @@ -163,6 +173,7 @@ utiliser explicitement \textsc{pgf} ou TikZ (ce dernier n'est d'ailleurs pas chargé par défaut). \medskip +\indexcommand{NiceMatrixOptions} Une commande|\NiceMatrixOptions| est fournie pour régler les options (la portée des options fixées par cette commande est le groupe TeX courant : elles sont semi-globales). @@ -172,6 +183,23 @@ semi-globales). \section{Les environnements de cette extension} + +\indexenv{NiceTabular} +\indexenv{NiceTabular*} +\indexenv{NiceArray} +\indexenv{pNiceArray} +\indexenv{bNiceArray} +\indexenv{BNiceArray} +\indexenv{vNiceArray} +\indexenv{VNiceArray} +\indexenv{NiceMatrix} +\indexenv{pNiceMatrix} +\indexenv{bNiceMatrix} +\indexenv{BNiceMatrix} +\indexenv{vNiceMatrix} +\indexenv{VNiceMatrix} + + L'extension \pkg{nicematrix} définit les nouveaux environnements suivants : \medskip @@ -227,6 +255,9 @@ crochets, une liste optionnelle de paires de la forme \textsl{clé=valeur}. \section{L'espace vertical entre les rangées} \label{cell-space} +\index{cell-space-top-limit} +\index{cell-space-bottom-limit} +\index{cell-space-limits} Il est bien connu que certaines rangées des tableaux créés par défaut avec LaTeX sont trop proches l'une de l'autre. On en donne ci-dessous un exemple @@ -248,7 +279,7 @@ $\begin{pmatrix} En s'inspirant de l'extension \pkg{cellspace} qui traite de ce problème, l'extension \pkg{nicematrix} propose deux clés |cell-space-top-limit| et |cell-space-bottom-limit| qui sont similaires aux deux paramètres -|\cellspacetoplimit| et |\cellspacebottomlimit| proposés par \pkg{cellspace}. +|\cellspacetoplimit| et |\cellspacebottomlimit| proposés par \pkg{cellspace}.\index{cellspace@\pkg{cellspace} (extension)} Il existe aussi une clé |cell-space-limits| pour régler simultanément les deux paramètres. @@ -284,6 +315,8 @@ $\begin{pNiceMatrix} \medskip \section{La clé baseline} +\index{baseline (clé pour un environnement)} + L'extension \pkg{nicematrix} propose une option |baseline| pour la position verticale des tableaux. Cette option |baseline| prend comme valeur un entier qui indique le numéro de rangée dont la ligne de base servira de ligne de base pour @@ -420,6 +453,8 @@ $A=\begin{pNiceArray}{cc|cc}~emphase#[baseline=line-3]@ \section{Les blocs} \label{Block} +\index{Blocs@\textbf{Blocs dans les tableaux}|(} +\indexcommand{Block} \subsection{Cas général} @@ -499,52 +534,63 @@ $\begin{bNiceArray}{cw{c}{1cm}c|c}[margin] La commande |\Block| accepte en premier argument optionnel (entre crochets) une liste de couples \textsl{clé=valeur}. Les clés sont les suivantes : \begin{itemize} -\item la clé \Definition{fill} prend en argument une couleur et remplit le bloc +\item \index{fill (clé de \texttt{\textbackslash Block})} +la clé \Definition{fill} prend en argument une couleur et remplit le bloc avec cette couleur ; -\item la clé \Definition{draw} prend en argument une couleur et trace le cadre +\item \index{draw (clé de \texttt{\textbackslash Block})} +la clé \Definition{draw} prend en argument une couleur et trace le cadre avec cette couleur (la valeur par défaut de cette clé est la couleur courante des filets du tableau) ; -\item la clé \Definition{color} prend en argument une couleur et l'applique au +\item \index{color!clé de \texttt{\textbackslash Block}} +la clé \Definition{color} prend en argument une couleur et l'applique au contenu et trace également le cadre avec cette couleur ; -\item les clés \Definition{hlines}, \Definition{vlines} et \Definition{hvlines} +\item \index{vlines!clé de \texttt{\textbackslash Block}} \index{hvlines!clé de + \texttt{\textbackslash Block}} \index{hlines!clé de \texttt{\textbackslash Block}} +les clés \Definition{hlines}, \Definition{vlines} et \Definition{hvlines} tracent les filets correspondants dans le bloc\footnote{Néanmoins, les filets ne sont pas tracés dans les sous-blocs du bloc, conformément à l'esprit de \pkg{nicematrix}: les filets ne sont pas tracés dans les blocs (cf. section~\ref{rules} p.~\pageref{rules}).} ; -\item la clé \Definition{line-width} fixe la largeur utilisée pour tracer les +\item \index{line-width (clé de \texttt{\textbackslash Block})} +la clé \Definition{line-width} fixe la largeur utilisée pour tracer les filets (n'a d'intérêt que si |draw|, |hvlines|, |hlines| ou |vlines| est utilisée) ; -\item la clé \Definition{rounded-corners} impose des coins arrondis (pour le +\item \index{rounded-corners!clé de \texttt{\textbackslash Block}} \index{Coins arrondis!pour un bloc} +la clé \Definition{rounded-corners} impose des coins arrondis (pour le cadre dessiné par |draw| et le fond dessiné par |fill|) avec un rayon égal à la valeur de cette clé (la valeur par défaut est 4~pt\footnote{Cette valeur par défaut est la valeur initiale des \emph{rounded corners} de TikZ.}) ; -\item quand la clé \Definition{tikz} est utilisée, le chemin TikZ correspondant +\item \index{tikzz@tikz!clé de \texttt{\textbackslash Block}} +quand la clé \Definition{tikz} est utilisée, le chemin TikZ correspondant au rectangle délimitant le bloc est exécuté avec TikZ\footnote{TikZ doit être chargé préalablement (par défaut, \pkg{nicematrix} ne charge que \textsc{pgf}), faute de quoi, une erreur sera levée.} en utilisant comme options la valeur de cette clé |tikz| (qui doit donc être une liste de clés TikZ applicables à un chemin de TikZ). Pour des exemples d'utilisation de cette clé |tikz|, voir p.~\pageref{tikz-key-examples} ; -\item la clé \Definition{name} donne un nom au nœud TikZ rectangulaire +\item \index{name!clé de \texttt{\textbackslash Block}} +la clé \Definition{name} donne un nom au nœud TikZ rectangulaire correspondant au bloc ; on peut utiliser ce nom avec TikZ dans le |\CodeAfter| (cf.~p.~\pageref{code-after}); -\item la clé \Definition{respect-arraystretch} évite la remise à $1$ de +\item \index{respect-arraystretch (clé de \texttt{\textbackslash Block})} +la clé \Definition{respect-arraystretch} évite la remise à $1$ de |\arraystretch| en début de bloc (qui a lieu par défaut) ; -\item la clé \Definition{borders} permet de ne tracer que certaines des bordures +\item \index{borders (clé de \texttt{\textbackslash Block})} \index{tikzz@tikz!clé de «borders» de \texttt{\textbackslash Block}} +la clé \Definition{borders} permet de ne tracer que certaines des bordures du bloc : cette clé prend comme valeur une liste d'éléments parmi les suivants : |left|, |right|, |top| et |bottom| ; on peut en fait, dans la liste qui est la valeur de la clé |borders| mettre une entrée de la forme |tikz={|\textsl{liste}|}| où \textsl{liste} est une liste de couples \textsl{clé=valeur} de TikZ spécifiant les caractéristiques graphiques des traits qui seront dessinés (pour un exemple, voir p.~\pageref{tiretes}). - -\item \colorbox{yellow!50}{\textbf{Nouveau 6.15}}\par\nobreak Par défaut, les -filets ne sont pas tracés dans les blocs (voir à ce sujet la partie sur les -filets, section~\ref{rules} p.~\pageref{rules}). Néanmoins, si la clé -\Definition{transparent} est utilisée, les filets seront tracés. Pour un +\item \index{transparent (clé de \texttt{\textbackslash Block})} +Par défaut, les filets ne sont pas tracés dans les blocs (voir à ce sujet +la partie sur les filets, section~\ref{rules} p.~\pageref{rules}). Néanmoins, si +la clé \Definition{transparent} est utilisée, les filets seront tracés. Pour un example, voir la section~\ref{tikz-key-examples}, -page~\pageref{tikz-key-examples}. +page~\pageref{tikz-key-examples}. Attention : cette clé n'implique pas du tout +que le contenu du bloc sera transparent. \end{itemize} @@ -818,8 +864,10 @@ Concernant le positionnement vertical, la commande |\Block| admet les clés \texttt{c} est déjà prise pour le positionnement horizontal.}, |t|, |b|, |T| et~|B|. + \begin{itemize} -\item Avec la clé |v-center|, le contenu du bloc est centré verticalement. +\item \index{v-center (clé de \texttt{\textbackslash Block)})} +Avec la clé |v-center|, le contenu du bloc est centré verticalement. \item Avec la clé |t|, la ligne de base du contenu du bloc est alignée avec la ligne de base de la première rangée concernée par le bloc. @@ -934,10 +982,11 @@ text & text \\ \end{scope} - +\index{Blocs@\textbf{Blocs dans les tableaux}|)} \section{Les filets horizontaux et verticaux} \label{rules} +\index{Filets@\textbf{Filets dans les tableaux}|(} Les techniques habituelles pour tracer des filets peuvent être utilisées dans les environnements de \pkg{nicematrix}, à l'exception de |\vline|. Il y a @@ -980,6 +1029,7 @@ cf.~p.~\pageref{exterior}). \medskip +\index{booktabs@\pkg{booktabs} (extension)} Si vous utilisez \pkg{booktabs} (qui fournit |\toprule|, |\midrule|, |\bottomrule|, etc.) et que vous tenez absolument à mettre des filets verticaux (ce qui est contraire à l'esprit à \pkg{booktabs}), vous constaterez que les @@ -1017,6 +1067,7 @@ Il reste néanmoins possible de définir un spécificateur, nommé par exemple \subsubsection{La commande \textbackslash cline} \label{remark-cline} +\index{cline@\texttt{\textbackslash cline} (commande de LaTeX)} Les traits verticaux et horizontaux que l'on insère avec |\hline| et le spécificateur de colonne «\verb+|+» de \pkg{array} rendent le tableau plus large @@ -1048,6 +1099,7 @@ A&B&C&D \\ \end{scope} \medskip +\index{standard-cline} Dans les environnements de \pkg{nicematrix}, cette situation est corrigée (il est néanmoins possible de revenir au comportement par défaut de |\cline| avec la clé |standard-cline|). @@ -1079,6 +1131,11 @@ Dans les environnements de \pkg{nicematrix}, une instruction \subsection{L'épaisseur et la couleur des filets} +\indexcommand{arrayrulewidth} +\index{Couleur!des filets} +\index{width!sous-clé de «rules»} +\index{rules (clé pour un environnement)} + Les environnements de \pkg{nicematrix} proposent une clé |rules/width| pour fixer la largeur (on devrait plutôt dire l'épaisseur) des filets dans l'environnement. En fait, cette clé ne fait que fixer la valeur du paramètre @@ -1089,6 +1146,7 @@ On sait que \pkg{colortbl} propose la commande |\arrayrulecolor| pour spécifier la couleur de ces filets. \smallskip +\indexcommand{arrayrulecolor} Avec \pkg{nicematrix}, il est possible de spécifier une couleur même si \pkg{colortbl} n'est pas chargé. Par souci de compatibilité, la commande est nommée également |\arrayrulecolor|. Les environnements de \pkg{nicematrix} @@ -1122,13 +1180,16 @@ muguet & dahlia & souci \\ \medskip \subsection{Les outils de nicematrix pour tracer des filets} + + Les outils proposés par \pkg{nicematrix} pour tracer des filets sont les suivants : \begin{itemize} \item les clés |hlines|, |vlines|, |hvlines| et |hvlines-except-borders|; \item le spécificateur «\verb+|+» dans le préambule (pour les environnements à préambule) ; -\item la commande |\Hline|. +\item \indexcommand{Hline} +la commande |\Hline|. \end{itemize} \medskip @@ -1160,6 +1221,11 @@ de ces clés, voir |custom-line| p.~\pageref{custom-line}. \medskip \subsubsection{Les clés hlines et vlines} +\index{hlines|see{Filets}} +\index{hlines!clé pour un environnement} +\index{vlines|see{Filets}} +\index{vlines!clé pour un environnement} + \medskip Les clés |hlines| et |vlines| (qui, bien sûr, tracent des filets horizontaux et verticaux) prennent comme valeur une liste de numéros qui sont les numéros des @@ -1188,6 +1254,9 @@ $\begin{pNiceMatrix}[vlines,rules/width=0.2pt] \subsubsection{Les clés hvlines et hvlines-except-borders} \label{hvlines} +\index{hvlines|see{Filets}} +\index{hvlines!clé pour un environnement} +\index{hvlines-except-borders} La clé |hvlines|, qui ne prend pas de valeur, est la conjonction des clés |hlines| et |vlines|. @@ -1228,6 +1297,9 @@ tcolorbox» p.~\pageref{tcolorbox}. \subsubsection{Les coins (vides)} \label{corners} +\index{Coins (les --- vides)} +\index{corners (clé d'un environnement)} + Les quatre coins d'un tableau seront notés |NW|, |SW|, |NE| et |SE| (\emph{north west}, \emph{south west}, \emph{north east} et \emph{south east} en anglais). @@ -1241,6 +1313,7 @@ rectangle entièrement constitué de cases vides partant de ce coin.\footnote{Po une «case vide» est donnée plus loin (cf. p.~\pageref{empty-cells}).} \smallskip +\indexcommand{NotEmpty} On peut néanmoins imposer à une case sans contenu d'être considérée comme non vide par \pkg{nicematrix} avec la commande |\NotEmpty|. @@ -1340,6 +1413,8 @@ dans les coins (cf.~p.~\pageref{color-in-code-before}). \subsection{La commande \textbackslash diagbox} +\indexcommand{diagbox} + La commande |\diagbox| (inspirée par l'extension \pkg{diagbox}) permet, quand elle est utilisée dans une case, de couper cette case selon une diagonale descendante. @@ -1369,6 +1444,11 @@ Cette commande |\diagbox| peut aussi être utilisée dans un |\Block|. \subsection{Commandes pour filets personnalisés} \label{custom-line} +\index{command (clé de «custom-line»)} +\index{ccommand (clé de «custom-line»)} +\index{letter (clé de «custom-line»)} +\index{custom-line|(} + Il est possible de définir des commandes et des lettres pour des filets personnalisés avec la clé |custom-line|, utilisable dans |\NiceMatrixOptions| ou @@ -1411,6 +1491,9 @@ Il est possible de spécifier des filets multiples, colorés avec une couleur entre les filets (comme on peut le faire avec \pkg{colortbl} par exemple). \begin{itemize} +\index{multiplicity (clé de «custom-line»)} +\index{color!clé de «custom-line»} +\index{sep-color (clé de «custom-line»)} \item la clé |multiplicity| indique le nombre de traits successifs qui seront tracés : par exemple, une valeur de~$2$ va créer des filets doubles comme créés en standard par |\hline\hline| ou bien \verb+||+ dans le préambule d'un @@ -1458,6 +1541,9 @@ Produit C & 5 & 4 & 1 \\ \item \emph{Deuxième possibilité}\par\nobreak +\index{tikzz@tikz!clé de «custom-line»} +\index{total-width (clé de «custom-line»)} + On peut utiliser la clé |tikz| (si TikZ est chargé, \pkg{nicematrix} ne chargeant par défaut que \textsc{pgf}). Dans ce cas-là , le filet est tracé directement avec TikZ en utilisant comme paramètres la valeur de la clé |tikz| @@ -1511,6 +1597,9 @@ sept & huit & neuf \medskip \item \emph{Troisième possibilité} : la clé |dotted|\par\nobreak \label{dotted} +\index{dotted (clé de «custom-line»)} +\indexcommand{hdottedline} +\indexcommand{cdottedline} Comme on le voit dans l'exemple précédent, les pointillés tracés par la clé |dotted| de TikZ ne sont pas ronds. C'est pourquoi l'extension \pkg{nicematrix} @@ -1587,13 +1676,17 @@ $\begin{pNiceArray}{cccc:c} \end{pNiceArray}$ \end{itemize} - - +\index{custom-line|)} +\index{Filets@\textbf{Filets dans les tableaux}|)} \section{Les couleurs des rangées et des colonnes} +\index{Couleur!de fond pour les cases} + \subsection{Utilisation de colortbl} +\index{colortbl@\pkg{colortbl} (extension)} + Rappelons que l'extension \pkg{colortbl} peut être chargée directement par |\usepackage{colortbl}| ou en chargeant l'extension \pkg{xcolor} avec l'option |table| : |\usepackage[table]{xcolor}|. @@ -1637,6 +1730,9 @@ inconvénients. \subsection{Les outils de nicematrix dans le \textbackslash CodeBefore} \label{color-in-code-before} +\index{code-before!clé pour un environnement} +\index{CodeBefore@\texttt{\textbackslash CodeBefore}...\texttt{\textbackslash Body}} +\index{Body@\texttt{\textbackslash Body}|see{\texttt{\textbackslash CodeBefore}}} L'extension \pkg{nicematrix} propose des outils (indépendants de \pkg{colortbl}) pour tracer d'abord les rectangles colorés, puis le contenu des cases et les @@ -1644,8 +1740,7 @@ filets. Cette manière de faire est plus dans l'esprit du «modèle du peintre» formats PostScript et \textsc{pdf} et convient donc mieux aux lecteurs de \textsc{pdf}. L'inconvénient est qu'elle nécessite plusieurs compilations successives.\footnote{Si vous utilisez Overleaf, Overleaf effectue - automatiquement le nombre de - compilations nécessaire.} + automatiquement un nombre de compilations suffisant.} \medskip L'extension \pkg{nicematrix} fournit une clé |code-before| pour du code qui sera @@ -1666,7 +1761,7 @@ peut placer le contenu de ce |code-before| entre les mots-clés |\CodeBefore| et L'argument optionnel entre crochets est une liste de couples \textsl{clé=valeur} qui seront présentées au fur et à mesure. \footnote{Les clés disponibles sont \texttt{create-cell-nodes}, \texttt{sub-matrix} (et ses sous-clés) et - \texttt{delimiters-color}.} + \texttt{delimiters/color}.} \smallskip De nouvelles commandes sont disponibles dans ce |\CodeBefore|: |\cellcolor|, @@ -1676,6 +1771,20 @@ De nouvelles commandes sont disponibles dans ce |\CodeBefore|: |\cellcolor|, position des filets éventuels sont également accessibles : cf. p.~\pageref{nodes-i}.} \label{code-before} +\index{cellcolor@\texttt{\textbackslash cellcolor}!commande du + \texttt{\textbackslash CodeBefore}} +\index{rectanglecolor@\texttt{\textbackslash rectanglecolor} (commande du + \texttt{\textbackslash CodeBefore})} +\index{rowcolor@\texttt{\textbackslash rowcolor}!commande du \texttt{\textbackslash CodeBefore}} +\index{columncolor@\texttt{\textbackslash columncolor}!commande du + \texttt{\textbackslash CodeBefore}} +\index{rowcolors@\texttt{\textbackslash rowcolors} (commande du \texttt{\textbackslash CodeBefore})} +\index{rowlistcolor@\texttt{\textbackslash rowlistcolors} (commande du + \texttt{\textbackslash CodeBefore})} +\index{chessboardcolors@\texttt{\textbackslash chessboardcolors}!(commande + du \texttt{\textbackslash CodeBefore})} +\index{arraycolor@\texttt{\textbackslash arraycolor} (commande du \texttt{\textbackslash + CodeBefore)}} \medskip @@ -1695,7 +1804,9 @@ par une virgule) : \begin{itemize} \item le modèle colorimétrique (|RGB|, |rgb|, |HTML|, etc.) comme spécifié par l'extension \pkg{xcolor} ; -\item \colorbox{yellow!50}{\textbf{Nouveau 6.18}} +\item \index{opacity (clé des commandes comme\newline \texttt{\textbackslash + rowcolor}, etc.)} +\colorbox{yellow!50}{\textbf{Nouveau 6.18}} une spécification d'opacité selon la forme \texttt{opacity = \textsl{valeur}}. \end{itemize} @@ -1878,6 +1989,9 @@ La commande |\rowcolors| accepte une liste de couples \textsl{clé=valeur} comme argument optionnel en dernière position (l'argument optionnel en première position correspond à l'espace colorimétrique). Les clés disponibles sont |cols|, |restart| et |respect-blocks|. +\index{cols (clé de \texttt{\textbackslash rowcolors} du \texttt{\textbackslash CodeBefore})} +\index{restart (clé de \texttt{\textbackslash rowcolors} du \texttt{\textbackslash CodeBefore})} +\index{respect-blocks (clé de \texttt{\textbackslash rowcolors} du\newline \texttt{\textbackslash CodeBefore})} \begin{itemize} \item La clé |cols| décrit un ensemble de colonnes sur lesquelles portera l'effet de |\rowcolors|. Cet ensemble de colonnes est une liste d'intervalles de @@ -1888,13 +2002,11 @@ premier argument de |\rowcolors| recommence avec la même couleur.\footnote{Autrement, la couleur d'une rangée ne dépend que de la parité de son numéro absolu.} - \item Avec la clé |respect-blocks|, qui est de type booléen, les «rangées» colorées alternativement peuvent s'étendre sur plusieurs rangées réelles du tableau pour englober les blocs (créés par la commande |\Block| : cf.~p.~\pageref{Block}). \end{itemize} - \medskip \begin{scope} \hfuzz=10cm @@ -1965,11 +2077,6 @@ Henri & 14 \\ \end{NiceTabular} \end{scope} - - - - - \medskip \item L'extension \pkg{nicematrix} propose aussi une commande \Definition{\textbackslash rowlistcolors}. Cette commande généralise la commande |\rowcolors|: au lieu de @@ -2014,6 +2121,9 @@ avec |\resetcolorseries|\footnote{Pour l'initialisation, on a tableau : cf~p.~\pageref{iRow}. Cela permet un ajustement de la gradation des couleurs à la taille du tableau.}). +\index{definecolorseries@\texttt{\textbackslash definecolorseries} (commande de \pkg{xcolor})} +\index{resetcolorseries@\texttt{\textbackslash resetcolorseries} (commande de \pkg{xcolor})} + \smallskip \begin{BVerbatim}[boxwidth=12cm,baseline=c] \begin{NiceTabular}{c} @@ -2055,6 +2165,7 @@ colorient pas les cases qui sont dans les «coins». Dans l'exemple suivant, on utilise la clé |corners| pour demander de considérer le coin \emph{north east} (NE). \medskip +\index{corners (clé d'un environnement)|textit} \begin{scope} \hfuzz=11cm \begin{BVerbatim}[boxwidth=9cm,baseline=c] @@ -2087,14 +2198,13 @@ utilise la clé |corners| pour demander de considérer le coin \emph{north east} \end{NiceTabular} \end{scope} - - -\medskip +\bigskip On remarquera que ces commandes sont compatibles avec les commandes de \pkg{booktabs} (|\toprule|, |\midrule|, |\bottomrule|, etc). Néanmoins, l'extension \pkg{booktabs} n'est \emph{pas} chargée par \pkg{nicematrix}. \medskip +\index{rotate@\texttt{\textbackslash rotate}|textit} \begin{scope} \hfuzz=10cm \begin{BVerbatim}[baseline=c,boxwidth=8.5cm] @@ -2139,6 +2249,8 @@ spécial & 12 & 12 & 0.5 & 70 \\ \end{NiceTabular} \end{scope} +\index{S (les colonnes S de \pkg{siunitx})|textit} + \medskip On a utilisé le type de colonne |S| de \pkg{siunitx}. @@ -2146,6 +2258,11 @@ On a utilisé le type de colonne |S| de \pkg{siunitx}. \subsection{Outils de coloriage avec la syntaxe de colortbl} \label{colortbl-like} +\index{colortbl-like} +\index{cellcolor@\texttt{\textbackslash cellcolor}!commande en tableau} +\index{rowcolor@\texttt{\textbackslash rowcolor}!commande en tableau} +\index{columncolor@\texttt{\textbackslash columncolor}!commande dans le + préambule d'un environnement} On peut accéder aux outils de coloriage précédents avec une syntaxe proche de celle proposée par \pkg{colortbl} (même si \pkg{colortbl} n'est pas chargé). On @@ -2202,6 +2319,11 @@ Dupont & Chantal & 15 janvier 1998 \\ \section{La commande \textbackslash RowStyle} \label{RowStyle} +\indexcommand{RowStyle} +\index{cell-space-top-limit} +\index{cell-space-bottom-limit} +\index{cell-space-limits} + La commande |\RowStyle| prend en argument des instructions de mise en forme qui seront appliquées à chacune des cases restantes sur la rangée en cours. @@ -2210,20 +2332,25 @@ seront appliquées à chacune des cases restantes sur la rangée en cours. Elle prend aussi en premier argument optionnel, entre crochets, une liste de couples \textsl{clé=valeur}. \begin{itemize} -\item La clé |nb-rows| indique le nombre de rangées consécutives concernées par +\item \index{nb-rows (clé de \texttt{\textbackslash RowStyle})} +La clé |nb-rows| indique le nombre de rangées consécutives concernées par les spécifications de cette commande (une valeur |*| signifie que toutes les rangées restantes seront concernées). \item Les clés |cell-space-top-limit|, |cell-space-bottom-limit| et |cell-space-limits| sont disponibles avec le même effet que les clés globales de même nom (cf. p.~\pageref{cell-space}). -\item La clé |rowcolor| fixe la couleur de fond et la clé |color| fixe la +\item +\index{rowcolor (clé de \texttt{\textbackslash RowStyle})} +\index{color!clé de \texttt{\textbackslash RowStyle}} +La clé |rowcolor| fixe la couleur de fond et la clé |color| fixe la couleur du texte.\footnote{La clé |color| utilise la commande |\color| mais insère aussi une instruction |\leavevmode| devant. Cela évite un espace vertical parasite dans les cases qui correspondent à des colonnes de type |p|, |b|, |m|, |X| et |V| (qui débutent en mode vertical).} -\item La clé |bold| impose des caractères gras aux éléments de la rangée, qu'ils +\item \index{bold (clé de \texttt{\textbackslash RowStyle})} +La clé |bold| impose des caractères gras aux éléments de la rangée, qu'ils soient en mode texte ou bien en mode mathématique. \end{itemize} @@ -2238,6 +2365,7 @@ premier & deuxième & troisième & quatrième \\ I & II & III & IV \end{NiceTabular} \end{BVerbatim} +\index{rotate@\texttt{\textbackslash rotate}|textit} \begin{NiceTabular}{cccc} \hline \RowStyle[cell-space-limits=3pt]{\rotate} @@ -2253,6 +2381,7 @@ La commande |\rotate| est présentée p.~\pageref{rotate}. \section{La largeur des colonnes} \label{width} +\index{Largeur@\textbf{Largeur des colonnes}|(} \subsection{Techniques de base} @@ -2276,6 +2405,7 @@ Rio & Tokyo & Oslo \medskip +\index{columns-width} Dans les environnements de \pkg{nicematrix}, il est aussi possible de fixer la largeur \emph{minimale} de toutes les colonnes (à l'exception des éventuelles colonnes extérieures: cf. p.~\pageref{exterior}) directement avec l'option @@ -2353,6 +2483,8 @@ c & d \medskip +\index{NiceMatrixBlock@\texttt{\{NiceMatrixBlock\}}} +\index{auto-columns-width!(clé de \texttt{\{NiceMatrixBlock\}})} Mais il est aussi possible de fixer une zone dans laquelle toutes les matrices auront leurs colonnes de la même largeur, égale à la largeur de la case la plus large de toutes les matrices de la zone. Cette construction utilise @@ -2390,8 +2522,11 @@ $\begin{array}{c} \subsection{Les colonnes X} - \label{colonne-X} +\index{tabularx@\pkg{tabularx} (extension)} +\index{NiceTabularX@\texttt{\{NiceTabularX\}}} +\index{X (les colonnes X)} +\index{width!clé de \texttt{\{NiceTabular\}}} L'environnement |{NiceTabular}| propose aussi des colonnes |X| similaires à celles proposées par l'environnement |{tabularx}| de l'extension éponyme. @@ -2447,6 +2582,8 @@ Un texte plus court. & Un texte plus court. \subsection{Les colonnes V de varwidth} \label{varwidth} +\index{varwidth@\pkg{varwidth} (extension)} +\index{V (les colonnes V de \pkg{varwidth})} Rappelons d'abord le fonctionnement d'un environnement |{varwidth}| de l'extension éponyme \pkg{varwidth}. Un tel environnement est similaire à @@ -2537,9 +2674,16 @@ Remarquons que l'extension \pkg{varwidth} a quelques problèmes (au moins dans s version 0.92). Par exemple, avec LuaLaTeX, elle ne fonctionne pas si le contenu commence par une instruction |\color|. +\index{Largeur@\textbf{Largeur des colonnes}|)} \medskip \section{Les rangées et colonnes extérieures} + +\index{first-row} +\index{last-row} +\index{first-col} +\index{last-col} + Les environnements de \pkg{nicematrix} permettent de composer des rangées et des colonnes «extérieures» grâce aux options |first-row|, |last-row|, |first-col| et |last-col|. C'est particulièrement intéressant pour les matrices (mathématiques). @@ -2611,9 +2755,11 @@ C'est ce que nous ferons dans la suite. \end{itemize} - - \medskip +\index{code-for-first-row} +\index{code-for-first-col} +\index{code-for-last-row} +\index{code-for-last-col} On peut contrôler l'apparence de ces rangées et colonnes avec les options |code-for-first-row|, |code-for-last-row|, |code-for-first-col| et |code-for-last-col|. Ces options sont des listes de tokens qui seront insérées @@ -2678,9 +2824,19 @@ p.~\pageref{sub-matrix}). + \section{Les lignes en pointillés continues} \label{Cdots} +\index{Pointillés@\textbf{Pointillés (lignes en ---)}|(} +\index{Lignes en pointillés|see{Pointillés}} +\indexcommand{Ldots} +\indexcommand{Cdots} +\index{Ddots@\texttt{\textbackslash Ddots}|textbf} +\index{Iddots@\texttt{\textbackslash Iddots}|textbf} +\indexcommand{Vdots} +\index{mathdots@\pkg{mathdots} (extension)} +\index{xdots (et ses sous-clés)} À l'intérieur des environnements de l'extension \pkg{nicematrix}, de nouvelles commandes sont définies : |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots| et |\Iddots|. @@ -2796,6 +2952,7 @@ horizontal.\footnote{Dans \pkg{nicematrix}, il faut utiliser |\hspace*| et non |{NiceArray}| (ou une de ses variantes) avec une colonne de type~|w| ou |W|: cf. p.~\pageref{width}} +\indexcommand{Hspace} Toutefois, une commande~|\hspace*| pourrait interférer dans la construction des lignes en pointillés. C'est pourquoi l'extension \pkg{nicematrix} fournit une commande~|\Hspace| qui est une variante de |\hspace| transparente pour la @@ -2817,6 +2974,8 @@ $\begin{bNiceMatrix} \subsection{L'option nullify-dots} +\index{nullify-dots} + Considérons la matrice suivante qui a été composée classiquement avec l'environnement |{pmatrix}| de \pkg{amsmath}.\par\nobreak @@ -2891,6 +3050,9 @@ horizontalement mais aussi verticalement. \subsection{Les commandes \textbackslash Hdotsfor et \textbackslash Vdotsfor} +\indexcommand{Hdotsfor} +\indexcommand{Vdotsfor} + Certaines personnes utilisent habituellement la commande |\hdotsfor| de l'extension \pkg{amsmath} pour tracer des lignes en pointillés horizontales dans une matrice. Dans les environnements de \pkg{nicematrix}, il convient d'utiliser @@ -2985,6 +3147,9 @@ C[a_n^{(p)},a_1] & \Cdots & C[a_n^{(p)},a_n] & & C[a_n^{(p)},a_1^{(p)}] & \Cdots \subsection{Comment créer les lignes en pointillés de manière transparente} +\index{renew-matrix} +\index{renew-dots} + Si on a un document déjà tapé qui contient un grand nombre de matrices avec des points de suspension, on peut souhaiter utiliser les lignes pointillées de \pkg{nicematrix} sans avoir à modifier chaque matrice. Pour cela, @@ -3061,8 +3226,15 @@ $\begin{bNiceMatrix} \subsection{Personnalisation des lignes en pointillés} - \label{customization} +\index{color!clé pour les lignes pointillées} +\index{radius (clé pour les lignes pointillées)} +\index{inter (clé pour les lignes pointillées)} +\index{line-style (clé pour les lignes pointillées)} +\index{shorten (clé pour les lignes pointillées)} +\index{shorten-end (clé pour les lignes pointillées)} +\index{shorten-start (clé pour les lignes pointillées)} + Les lignes pointillées tracées par |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, |\Iddots|, |\Hdotsfor| et |\Vdotsfor| (ainsi que par la commande |\line| dans le |\CodeAfter| décrite p.~\pageref{line-in-code-after}) peuvent être paramétrées @@ -3217,8 +3389,12 @@ $\begin{bNiceMatrix}[margin,hvlines] 0 & \Cdots& 0 & 0 \end{bNiceMatrix}$ +\index{Pointillés@\textbf{Pointillés (lignes en ---)}|)} + \section{Délimiteurs dans le préambule de l'environnement} +\index{blkarray@\pkg{blkarray} (extension)} + \colorbox{yellow!50}{\textbf{Modifié 6.16}}\enskip Pour les environnements à préambule (|{NiceArray}|, |{pNiceArray}|, etc.), il est possible de placer des délimiteurs verticaux directement dans le préambule.\footnote{Cette syntaxe est @@ -3226,6 +3402,10 @@ délimiteurs verticaux directement dans le préambule.\footnote{Cette syntaxe es \label{delimiters-in-preamble}% \smallskip +\index{left@\texttt{\textbackslash left} : utilisé par \pkg{nicematrix}\newline pour des + délimiteurs\newline dans les préambules} +\index{right@\texttt{\textbackslash right} : utilisé par \pkg{nicematrix}\newline pour des + délimiteurs\newline dans les préambules} Les délimiteurs ouvrants doivent être précédés du mot-clé |\left| et les délimiteurs fermants du mot-clé |\right|. Les mots-clés |\left| et |\right| n'ont pas d'obligation à être utilisés par paires. @@ -3293,12 +3473,16 @@ p.~\pageref{sub-matrix}. \section{Le \textbackslash CodeAfter} +\index{CodeAfter@\texttt{\textbackslash CodeAfter}|(} +\index{code-after} + \label{code-after} On a présenté p.~\pageref{code-before} la clé |code-before|. Il existe en fait une clé similaire |code-after| qui peut être utilisée pour indiquer du code qui sera exécuté \emph{après} la construction du tableau. \medskip +\index{sub-matrix (clé de \texttt{\textbackslash CodeAfter}, avec sous-clés)} Pour améliorer la lisibilité du code, une syntaxe alternative est proposée : on peut spécifier les instructions du |code-after| à la fin de l'environnement, après le mot-clé |\CodeAfter|. Bien que ce soit un mot-clé, |\CodeAfter| accepte @@ -3322,6 +3506,7 @@ ces commandes. \subsection{La commande \textbackslash line dans le \textbackslash CodeAfter} \label{line-in-code-after} +\index{line@\texttt{\textbackslash line} (commande du \texttt{\textbackslash CodeAfter})} La commande |\line| permet de tracer directement des lignes en pointillés entre les cases. Elle prend deux arguments correspondant aux cases ou blocs à relier. Chacun de ces deux arguments peut être : @@ -3389,6 +3574,9 @@ autres lignes diagonales (par défaut, les lignes tracées par |\Ddots| sont CodeAfter (et le \textbackslash CodeBefore)} \label{sub-matrix} +\index{SubMatrix@\texttt{\textbackslash SubMatrix} (commande du +\texttt{\textbackslash CodeAfter}\newline et du +\texttt{\textbackslash CodeBefore})|textbf} La commande |\SubMatrix| permet de positionner des délimiteurs sur une partie du tableau, partie qui est considérée comme une sous-matrice. La commande @@ -3496,25 +3684,36 @@ $\begin{bNiceMatrix}[right-margin=1em] Les clés disponibles pour la commande |\SubMatrix| sont les suivantes : % \begin{itemize} -\item \Definition{left-xshift} et \Definition{right-xshift} déplacent +\item +\index{left-xshift (clé de \texttt{\textbackslash SubMatrix})} +\index{right-xshift (clé de \texttt{\textbackslash SubMatrix})} +\index{xshift (clé de \texttt{\textbackslash SubMatrix})} +\Definition{left-xshift} et \Definition{right-xshift} déplacent horizontalement les délimiteurs (il existe aussi la clé \Definition{xshift} qui permet de régler simultanément ces deux clés) ; -\item \Definition{extra-height} ajoute une quantité à la hauteur totale des +\item \index{extra-height (clé de \texttt{\textbackslash SubMatrix})} +\Definition{extra-height} ajoute une quantité à la hauteur totale des délimiteurs (hauteur~|\ht| + profondeur |\dp|) ; -\item \Definition{delimiters/color} permet de fixer la couleur des délimiteurs (cette clé +\item \index{delimiters!---/color pour \texttt{\textbackslash SubMatrix}} +\Definition{delimiters/color} permet de fixer la couleur des délimiteurs (cette clé est également disponible dans |\NiceMatrixOptions| et au niveau des environnements à délimiteurs ou comme option de |\CodeAfter|) ; -\item \Definition{slim} qui est une clé booléenne : lorsqu'elle est utilisée la position +\item \index{slim (clé de \texttt{\textbackslash SubMatrix})} +\Definition{slim} qui est une clé booléenne : lorsqu'elle est utilisée la position horizontale des délimiteurs est calculée uniquement sur le contenu des cases de la sous-matrice alors, que, dans le cas général, elle est calculée sur le contenu des cases des colonnes mises en jeu (voir exemple ci-dessous) ; -\item \Definition{vlines} contient une liste de numéros de filets verticaux à tracer dans +\item \index{vlines!clé de \texttt{\textbackslash SubMatrix}} +\Definition{vlines} contient une liste de numéros de filets verticaux à tracer dans la sous-matrice (si cette clé est utilisée sans valeur, tous les filets verticaux sont tracés) ; -\item \Definition{hlines} est similaire à |vlines| mais pour les filets horizontaux ; -\item \Definition{hvlines}, qui s'utilise sans valeur, trace tous les filets dans la +\item \index{hlines!clé de \texttt{\textbackslash SubMatrix}} +\Definition{hlines} est similaire à |vlines| mais pour les filets horizontaux ; +\item \index{hvlines!clé de \texttt{\textbackslash SubMatrix}} +\Definition{hvlines}, qui s'utilise sans valeur, trace tous les filets dans la sous-matrice ; -\item \Definition{code} permet d'insérer du code, en particulier du code TikZ, après la +\item \index{code (clé de \texttt{\textbackslash SubMatrix})} +\Definition{code} permet d'insérer du code, en particulier du code TikZ, après la construction de la matrice. Cette clé est décrite en détail plus loin. \end{itemize} On remarquera que tous les filets sont dessinés après la construction du tableau @@ -3633,13 +3832,13 @@ Part A & the first part \\ \vspace{1cm} -\colorbox{yellow!50}{\textbf{Nouveau 6.16}}\enskip La clé |code| de la commande -|\SubMatrix| permet d'insérer du code après la création de la matrice. Elle a -surtout pour vocation d'être utilisée pour insérer des instructions TikZ, -sachant que, dans les instructions TikZ insérées dans cette clé, les nœuds de la -forme |i-j| et \verb+i-|j+ sont interprétés avec |i| et |j| étant des numéros de -ligne et colonne \emph{relatifs à la sous-matrice}.\footnote{Attention : la - syntaxe \texttt{j\string|-i} n'est autorisée.} +La clé |code| de la commande |\SubMatrix| permet d'insérer du code après la +création de la matrice. Elle a surtout pour vocation d'être utilisée pour +insérer des instructions TikZ, sachant que, dans les instructions TikZ insérées +dans cette clé, les nœuds de la forme |i-j| et \verb+i-|j+ sont interprétés avec +|i| et |j| étant des numéros de ligne et colonne \emph{relatifs à la + sous-matrice}.\footnote{Attention : la syntaxe \texttt{j\string|-i} n'est + \emph{pas} autorisée.} \medskip \begin{scope} @@ -3683,6 +3882,14 @@ Comme on le voit, le tracé effectué par la commande |\MyDraw| est \emph{relati \subsection{Les commandes \textbackslash OverBrace et \textbackslash UnderBrace dans le \textbackslash CodeAfter} +\index{UncerBrace@\texttt{\textbackslash UnderBrace} (commande du +\texttt{\textbackslash CodeAfter}\newline et du +\texttt{\textbackslash CodeBefore})} +\index{OverBrace@\texttt{\textbackslash OverBrace} (commande du +\texttt{\textbackslash CodeAfter}\newline et du +\texttt{\textbackslash CodeBefore})} + + Les commandes |\OverBrace| and |\UnderBrace| permettent de placer des accolades horizontales sur une partie du tableau. Ces commandes prennent trois arguments : \begin{itemize} @@ -3716,6 +3923,18 @@ $\begin{pNiceMatrix} \end{pNiceMatrix}$ \bigskip +Attention : Aucun espace vertical n'est réservé par \pkg{nicematrix} pour ces +accolades.\footnote{Voir à ce sujet: \url{https://tex.stackexchange.com/questions/685755}} + +\bigskip +\index{color!clé de \texttt{\textbackslash OverBrace} et \texttt{\textbackslash + UnderBrace}} +\index{yshift (clé de \texttt{\textbackslash OverBrace} et \texttt{\textbackslash + UnderBrace})} +\index{left-shorten (clé de \texttt{\textbackslash OverBrace} et\newline \texttt{\textbackslash + UnderBrace})} +\index{right-shorten (clé de \texttt{\textbackslash OverBrace} et\newline \texttt{\textbackslash + UnderBrace})} Les commandes |\OverBrace| et |\UnderBrace| acceptent en fait un premier argument optionnel (entre crochets) pour une liste de couples \textsl{clé=valeur}. Les clés disponibles sont les suivantes : @@ -3751,6 +3970,7 @@ $\begin{pNiceMatrix} \OverBrace[shorten,yshift=3pt]{1-4}{2-6}{B} \end{pNiceMatrix}$ +\index{CodeAfter@\texttt{\textbackslash CodeAfter}|)} \section{Les légendes et les notes dans les tableaux} @@ -3758,6 +3978,15 @@ $\begin{pNiceMatrix} \subsection{La légendes des tableaux} +\label{s:caption} + +\index{caption (clé de \texttt{\{NiceTabular\}})} +\index{short-caption} +\index{label (clé de \texttt{\{NiceTabular\}})} +\index{caption-above} +\index{Legende@\textbf{Légende des tableaux}} + + L'environnement |{NiceTabular}| propose des clés |caption|, |short-caption| et |label| à utiliser lorsque le tableau est inséré dans un environnment flottant (typiquement un environnement |{table}|). @@ -3766,8 +3995,9 @@ L'environnement |{NiceTabular}| propose des clés |caption|, |short-caption| et L'intérêt d'utiliser cette clé |caption| plutôt que la commande classique |\caption| est que la légende, si elle est longue, est justifiée à la largeur du tableau (hors éventuelles colonnes extérieures spécifiées par |first-col| et -|last-col|). Il n'y a pas besoin d'avoir recours à l'extension -\pkg{threeparttable} ou l'extension \pkg{floatrow}. +|last-col| : cf.~\ref{exterior}, p.~\pageref{exterior}). Il n'y a pas besoin +d'avoir recours à l'extension \pkg{threeparttable} ou l'extension +\pkg{floatrow}. \smallskip Par défaut, la légende est placée au-dessous du tableau. Pour avoir la légende @@ -3779,11 +4009,19 @@ La clé |short-caption| correspond à l'argument optionnel de la commande classique |\caption| et la clé |label| correspond bien sûr à la commande |\label|. \smallskip -Voir table \ref{t:tabularnote}, p.~\pageref{t:tabularnote} un exemple +Voir table \ref{t:tabularnote}, p.~\pageref{t:tabularnote}, un exemple d'utilisation des clés |caption| et |label|. +\smallskip +Ces fonctionnalités sont compatibles avec l'extension \pkg{caption}. + \subsection{Les notes de pied de page} +\index{footnote@\pkg{footnote} (extension)} +\index{footnote (clé)} +\index{footnotehyper@\pkg{footnotehyper} (extension)} +\index{footnotehyper (clé)} + \smallskip L'extension \pkg{nicematrix} permet, en utilisant \pkg{footnote} ou bien \pkg{footnotehyper}, d'extraire les notes insérées avec |\footnote| dans un @@ -3812,16 +4050,21 @@ l'extension \pkg{xcolor} et elle n'est pas parfaitement compatible avec \subsection{Les notes de tableaux} +\index{nota@\textbf{Notes dans les tableaux}|(} + \label{tabularnote} +\index{tabularnote@\texttt{\textbackslash tabularnote}} L'extension \pkg{nicematrix} propose aussi une commande |\tabularnote| qui permet de spécifier des notes qui seront composées à la fin du tableau avec une longueur de ligne égale à la largeur du tableau (hors éventuelles colonnes -extérieures spécifiées par |first-col| et |last-col|). Sans surprise, cette -commande n'est disponible que dans |{NiceTabular}|, |{NiceTabular*}| and -|{NiceTabularX}|. +extérieures spécifiées par |first-col| et |last-col|: cf.~\ref{exterior}, +p.~\pageref{exterior}). Sans surprise, cette commande n'est disponible que dans +|{NiceTabular}|, |{NiceTabular*}| et |{NiceTabularX}|. + +\index{enumitem@\pkg{enumitem} (extension requise pour utiliser\newline \texttt{\textbackslash tabularnote})} En fait, cette commande n'est disponible que si l'extension \pkg{enumitem} a été chargée (avant ou après \pkg{nicematrix}). Les notes sont en effet composées en fin de tableau selon un type de liste défini par l'extension \pkg{enumitem}. @@ -3883,9 +4126,13 @@ colonne). \item Si la clé |notes/para| est utilisée, les notes sont composées à la fin du tableau en un seul paragraphe. -\item Il existe une clé |tabularnote| qui permet d'insérer du texte dans la zone +\item \index{tabularnote (clé de \texttt{\{NiceTabular\}})} +Il existe une clé |tabularnote| qui permet d'insérer du texte dans la zone des notes avant les notes numérotées. +\index{tabularnote@\texttt{\{TabularNote\}}} +\index{notes (clé pour paramétrer les notes de\newline tableau)} + Une syntaxe alternative est proposée : il est possible d'utiliser l'environnement |{TabularNote}| à la fin de l'environnement |{NiceTabular}| (mais \emph{avant} l'éventuel |\CodeAfter|). @@ -3903,6 +4150,12 @@ sont marqués). Il est possible de désactiver cette fonctionnalité avec la clà \item Il est possible de référencer une note de tableau (avec la commande |\label| placée après le |\tabularnote|). + +\item \colorbox{yellow!50}{\textbf{Nouveau 6.19}} La commande |\tabularnote| +admet un argument optionnel (entre crochets) qui permet de changer le symbole de +l'appel de note. + +\emph{Exemple} : |\tabularnote[$\star$]{Une note...}|. \end{itemize} % Voir sur la table \ref{t:tabularnote}, p.~\pageref{t:tabularnote}, certaines de ces @@ -3917,8 +4170,8 @@ remarques illustrées. Cette table a été composée avec le code suivant \NiceMatrixOptions{caption-above} \begin{NiceTabular}{@{}llc@{}}% [ - caption = Un tableau dont la légende a été rentrée avec la clé \texttt{caption} - ~emphase#\tabularnote{On peut mettre une note dans la légende.}! , + caption = Un tableau dont la légende a été rentrée avec la clé \texttt{caption}% + ~emphase#\tabularnote[$\star$]{On peut mettre une note dans la légende.}! , label = t:tabularnote , tabularnote = Un peu de texte avant les notes. , notes/bottomrule @@ -3944,8 +4197,8 @@ Wallis & John & 87 \\ \NiceMatrixOptions{caption-above} \begin{NiceTabular}{@{}llc@{}}% [ - caption = Un tableau dont la légende a été rentrée avec la clé \texttt{caption} - \tabularnote{On peut mettre une note dans la légende.} , + caption = Un tableau dont la légende a été rentrée avec la clé \texttt{caption}% + \tabularnote[$\star$]{On peut mettre une note dans la légende.} , label = t:tabularnote, tabularnote = Un peu de texte avant les notes. , notes/bottomrule @@ -3967,9 +4220,18 @@ Wallis & John & 87 \\ - \subsection{Personnalisation des notes de tableau} +\index{para (sous-clé de «notes»)} +\index{bottomrule (sous-clé de «notes»)} +\index{style (sous-clé de «notes»)} +\index{label-in-tabular (sous-clé de «notes»)} +\index{label-in-list (sous-clé de «notes»)} +\index{enumitem-keys (sous-clé de «notes»)} +\index{enumitem-keys-para (sous-clé de «notes»)} +\index{code-before!sous-clé de «notes»} +\index{detect-duplicates (sous-clé de «notes»)} + Les notes de tableau peuvent être personnalisées grâce à un ensemble de clés disponibles dans |\NiceMatrixOptions|. Ces clés ont un nom préfixé par |notes| : @@ -3984,7 +4246,7 @@ disponibles dans |\NiceMatrixOptions|. Ces clés ont un nom préfixé par |notes \item |notes/code-before| \item |notes/detect-duplicates| \end{itemize} -Pour la commmodité, il est aussi possible de fixer ces clés dans +Pour la commodité, il est aussi possible de fixer ces clés dans |\NiceMatrixOptions| via une clé |notes| qui prend en argument une liste de paires \textsl{clé=valeur} où le nom des clés n'a plus à être préfixé par |notes|: @@ -4121,6 +4383,7 @@ commandes |\tabularnote| avec le même argument. Valeur initiale : |true| \end{itemize} +\index{nota@\textbf{Notes dans les tableaux}|)} \medskip @@ -4129,6 +4392,7 @@ Pour un exemple de personnalisation des notes de tableau, voir p.~\pageref{ex:no \subsection{Utilisation de \{NiceTabular\} avec threeparttable} +\index{threeparttable@\pkg{threeparttable} (extension)} Si vous souhaitez utiliser les environnements |{NiceTabular}|, |{NiceTabular*}| ou |{NiceTabularX}| dans un environnement |{threeparttable}| de l'extension @@ -4141,8 +4405,9 @@ suivant (avec une version de LaTeX postérieure à 2020/10/01). \makeatother \end{Verbatim} -Néanmoins, les fonctionnalités proposées par \pkg{nicematrix} rendent peu -utile l'utilisation de \pkg{threeparttable} en conjonction avec \pkg{nicematrix}. +Néanmoins, les fonctionnalités proposées par \pkg{nicematrix} rendent peu utile +l'utilisation de \pkg{threeparttable} en conjonction avec \pkg{nicematrix} (voir +la clé |caption| à la partie \ref{s:caption}, p.~\pageref{s:caption}). \section{Autres fonctionnalités} @@ -4150,6 +4415,8 @@ utile l'utilisation de \pkg{threeparttable} en conjonction avec \pkg{nicematrix} \subsection{La clé rounded-corners de \{NiceTabular\}} \label{tabular-rounded-corners} +\index{rounded-corners!clé de \texttt{\{NiceTabular\}}} +\index{Coins arrondis!pour un tableau} \colorbox{yellow!50}{\textbf{Nouveau 6.18}}\par\nobreak @@ -4198,6 +4465,9 @@ avec des coins arrondis. \subsection{Commande \textbackslash ShowCellNames} +\index{ShowCellNames@\texttt{\textbackslash ShowCellNames} (commande du +\texttt{\textbackslash CodeAfter}\newline et du +\texttt{\textbackslash CodeBefore})} La commande |\ShowCellNames|, utilisable dans le |\CodeBefore| et le |\CodeAfter| affiche le nom (sous la forme $i$-$j$) de chaque case. Quand elle @@ -4225,6 +4495,10 @@ semi-transparent pour estomper le tableau (attention : certains lecteurs de \subsection{Utilisation du type de colonne S de siunitx} + +\index{S (les colonnes S de \pkg{siunitx})} +\index{siunitx@\pkg{siunitx} (extension)} + Si l'extension \pkg{siunitx} est chargée (avant ou après \pkg{nicematrix}), il est possible d'utiliser les colonnes de type |S| de \pkg{siunitx} dans les environnements de \pkg{nicematrix}. L'implémentation n'utilise explicitement aucune macro privée de \pkg{siunitx}. @@ -4256,6 +4530,7 @@ charge par \pkg{nicematrix}. \subsection{Type de colonne par défaut dans \{NiceMatrix\}} \label{columns-type} +\index{columns-type (clé de \texttt{\{NiceMatrix\}}, etc.)} Les environnements sans préambule (|{NiceMatrix}|, |{pNiceMatrix}|, etc.) ainsi que la commande |\pAutoNiceMatrix| et ses variantes, acceptent la clé @@ -4285,6 +4560,7 @@ de la préfixer par |matrix|, ce qui fait que son nom devient |matrix/columns-ty \subsection{La commande \textbackslash rotate} \label{rotate} +\index{rotate@\texttt{\textbackslash rotate}} Utilisée au début d'une case, la commande |\rotate| (fournie par \pkg{nicematrix}) compose le contenu après une rotation de 90° dans le sens direct. @@ -4318,6 +4594,12 @@ e_1 & e_2 & e_3 \\ \end{varwidth} \medskip +\index{first-row|textit} +\index{last-row|textit} +\index{code-for-first-row|textit} +\index{code-for-last-row|textit} +\index{last-col|textit} +\index{code-for-last-col|textit} Si la commande |\rotate| est utilisée dans la «dernière rangée» (extérieure à la matrice), les éléments qui subissent cette rotation sont alignés vers le haut. @@ -4349,6 +4631,9 @@ $A = \begin{pNiceMatrix}[last-row,last-col=4] \subsection{L'option small} \label{small} +\index{small (clé pour un environnement)} +\index{smallmatrix@\texttt{\{smallmatrix\}} (envionnement de \pkg{amsmath})} + Avec l'option |small|, les environnements de l'extension \pkg{nicematrix} sont composés d'une manière proche de ce que propose l'environnement |{smallmatrix}| @@ -4401,6 +4686,8 @@ partie \ref{delimiters-in-preamble}, p.~\pageref{delimiters-in-preamble}). \subsection{Les compteurs iRow et jCol} \label{iRow} +\index{iRow (compteur LaTeX)} +\index{jCol (compteur LaTeX)} Dans les cases du tableau, il est possible d'utiliser les compteurs LaTeX |iRow| et |jCol| qui représentent le numéro de la rangée courante et le numéro de la @@ -4444,6 +4731,12 @@ final), ces compteurs sont masqués dans les environnements de \pkg{nicematrix}. \medskip +\indexcommand{AutoNiceMatrix} +\indexcommand{pAutoNiceMatrix} +\indexcommand{bAutoNiceMatrix} +\indexcommand{vAutoNiceMatrix} +\indexcommand{VAutoNiceMatrix} +\indexcommand{BAutoNiceMatrix} L'extension \pkg{nicematrix} propose aussi des commandes pour composer automatiquement des matrices à partir d'un motif général. Ces commandes sont nommées |\AutoNiceMatrix|, |\pAutoNiceMatrix|, |\bAutoNiceMatrix|, @@ -4460,16 +4753,12 @@ simplement des tokens qui seront insérés dans chaque case de la matrice). $C = ~emphase#\pAutoNiceMatrix@{3-3}{C_{\arabic{iRow},\arabic{jCol}}}$ \end{Verbatim} - - - \[C = \pAutoNiceMatrix{3-3}{C_{\arabic{iRow},\arabic{jCol}}}\] - - \subsection{L'option light-syntax} \label{light-syntax} +\index{light-syntax} L'option |light-syntax| (inspirée de l'extension \pkg{spalign}) permet d'alléger la saisie des matrices, ainsi que leur lisibilité dans le source TeX. Lorsque @@ -4498,6 +4787,7 @@ b \cos a+\cos b { 2 \cos b } \end{bNiceMatrix}$ \medskip +\index{end-of-row (à utiliser avec light-syntax)} On peut changer le caractère utilisé pour indiquer les fins de rangées avec l'option |end-of-row|. Comme dit précédemment, la valeur initiale de ce paramètre est un point-virgule. @@ -4514,6 +4804,10 @@ dans les cases du tableau.\footnote{La raison en est que lorsque l'option |light \subsection{Couleur des délimiteurs} +\index{delimiters!---/color pour un environnement} +\index{color!pour les délimiteurs de matrices} +\index{Couleur!des délimiteurs de matrices} + Pour les environnements avec délimiteurs (|{pNiceArray}|, |{pNiceMatrix}|, etc.), il est possible de changer la couleur des délimiteurs avec la clé |delimiters/color|. @@ -4532,13 +4826,16 @@ $\begin{bNiceMatrix}[delimiters/color=red] \medskip Cette couleur s'applique aussi aux délimiteurs tracés par |\SubMatrix| -(cf.~p.~\pageref{sub-matrix}). +(cf.~p.~\pageref{sub-matrix}) et aux délimiteurs spécifiés directement dans le +préambule des environnements à préambule (cf.~p.~\pageref{delimiters-in-preamble}). \subsection{L'environnement \{NiceArrayWithDelims\}} \label{NiceArrayWithDelims} +\index{NiceArrayWithDelims@\texttt{\{NiceArrayWithDelims\}}} + En fait, l'environnement |{pNiceArray}| et ses variantes sont fondés sur un environnement plus général, appelé |{NiceArrayWithDelims}|. Les deux premiers arguments obligatoires de cet environnement sont les délimiteurs gauche et droit @@ -4566,6 +4863,8 @@ $\begin{NiceArrayWithDelims} \subsection{La commande \textbackslash OnlyMainNiceMatrix} +\indexcommand{OnlyMainNiceMatrix} + La commande |\OnlyMainNiceMatrix| n'exécute son argument que si on se trouve dans le tableau principal, c'est-à -dire que l'on n'est pas dans les rangées extérieures. Si elle est utilisée hors d'un environnement de \pkg{nicematrix}, @@ -4577,7 +4876,8 @@ Pour un exemple d'utilisation, voir \url{tex.stackexchange.com/questions/488566} \section{Utilisation de TikZ avec nicematrix} \label{name}\label{PGF-nodes} - +\index{tikza@TikZ (utilisation avec \pkg{nicematrix})} +\index{noeud@\textbf{Nœuds PGF/Tikz}|(} \subsection{Les nœuds correspondant aux contenus des cases} @@ -4609,11 +4909,13 @@ Si l'environnement concerné a le numéro $n$, alors le nœud de la rangée~$i$ de la colonne~$j$ a pour nom |nm-|$n$|-|$i$|-|$j$. \smallskip +\indexcommand{NiceMatrixLastEnv} La commande |\NiceMatrixLastEnv| donne le numéro du dernier de ces environnements (pour LaTeX, il s'agit d'une commande — complètement développable — et non d'un compteur). \smallskip +\index{name!clé pour un environnement} Il est néanmoins recommandé de passer plutôt par la clé |name|. Celle-ci permet de donner un nom à l'environnement. Une fois l'environnement nommé, les nœuds sont accessibles à travers les noms «\textsl{nom}-$i$-$j$» où \textsl{nom} est @@ -4723,6 +5025,8 @@ p.~\pageref{triangular}. \subsubsection{La clé pgf-node-code} +\index{pgf-node-code} + \colorbox{yellow!50}{\textbf{Nouveau 6.17}}\enskip \textbf{Pour les utilisateurs expérimentés}, \pkg{nicematrix} fournit la clé |pgf-node-code| qui correspond à du code PGF qui sera exécuté à la création, par PGF, des nœuds correspondants aux @@ -4734,6 +5038,9 @@ contenir au moins une instruction comme |\pgfusepath|, |\pgfusepathqstroke|, \subsubsection{Les colonnes V de varwidth} \label{node-V} +\index{V (les colonnes V de \pkg{varwidth})} +\index{varwidth@\pkg{varwidth} (extension)} + Quand l'extension \pkg{varwidth} est chargée, les colonnes de type |V| définies par \pkg{varwidth} sont prises en charge par \pkg{nicematrix}. Il peut être intéressant de préciser que, pour une case située dans une colonne de type @@ -4770,6 +5077,9 @@ peu plus loin, p.~\pageref{nodes-i}. \subsection{Les «nœuds moyens» et les «nœuds larges»} +\index{create-medium-nodes} +\index{create-large-nodes} +\index{create-extra-nodes} En fait, l'extension \pkg{nicematrix} peut créer deux séries de nœuds supplémentaires (\emph{extra nodes} en anglais) : les «nœuds moyens» @@ -4840,6 +5150,8 @@ a & a & a \medskip +\index{left-margin} +\index{right-margin} Les «nœuds larges» de la première colonne et de la dernière colonne peuvent apparaître trop petits pour certains usages. C'est pourquoi il est possible d'utiliser les options |left-margin| et |right-margin| pour ajouter de l'espace @@ -4872,6 +5184,8 @@ a & a & a \end{pNiceMatrix}\] \medskip +\index{extra-left-margin} +\index{extra-right-margin} Il est aussi possible d'ajouter de l'espace sur les côtés du tableau avec les options |extra-left-margin| et |extra-right-margin|. Ces marges ne sont pas incorporées dans les «nœuds larges». Dans l'exemple suivant, nous avons utilisé @@ -4978,6 +5292,8 @@ noix & noisette & brugnon Les nœuds que l'on vient de décrire ne sont pas accessibles par défaut dans le |\CodeBefore| (décrit p.~\pageref{code-before}). \par\nobreak + +\index{create-cell-nodes (clé de \texttt{\textbackslash CodeBefore})} On peut rendre ces nœuds accessibles dans le |\CodeBefore| en utilisant la clé |create-cell-nodes| du mot-clé |\CodeBefore| (dans ce cas-là , les nœuds sont créés une première fois avant la construction du tableau en utilisant des @@ -5124,13 +5440,19 @@ $\begin{pNiceArray}{ccc|c} \end{pNiceArray}$ -\subsection{Les nœuds correspondants aux commandes \textbackslash SubMatrix} +\subsection{Les nœuds correspondant aux commandes \textbackslash SubMatrix} \label{node-sub-matrix} La commande |\SubMatrix| disponible dans le |\CodeAfter| a été présentée p.~\pageref{sub-matrix}. +\index{SubMatrix@\texttt{\textbackslash SubMatrix} (commande du +\texttt{\textbackslash CodeAfter}\newline et du +\texttt{\textbackslash CodeBefore})} +\index{name!clé de \texttt{\textbackslash SubMatrix}} + + \smallskip Si une commande |\SubMatrix| est utilisée avec la clé |name| sous la forme |name=|\textsl{\ttfamily MonNom}, trois nœuds PGF-TikZ sont créés avec les noms @@ -5162,9 +5484,14 @@ a été créée avec |\SubMatrix\{{2-2}{3-3}\}|). \end{tikzpicture} \end{pNiceMatrix}\] +\index{noeud@\textbf{Nœuds PGF/Tikz}|)} + \section{API pour les développeurs} +\indexcommand{g\_nicematrix\_code\_before\_tl} +\indexcommand{g\_nicematrix\_code\_after\_tl} + L'extension \pkg{nicematrix} fournit deux variables internes mais publiques\footnote{Conformément aux conventions de LaTeX3, toute variable dont le nom commence par |\g_nicematrix| ou |\l_nicematrix| est publique alors que toute variable dont le nom débute par |\g__nicematrix| ou @@ -5187,9 +5514,6 @@ On remarquera que l'utilisation de |\g_nicematrix_code_before_tl| nécessite une compilation supplémentaire (car les instructions sont écrites dans le fichier |aux| pour être utilisées à la compilation suivante). - - - \medskip \emph{Exemple} : On souhaite écrire une commande |\crossbox| qui barre en croix la case courante. Cette commande prendra en argument optionnel une liste de @@ -5201,6 +5525,8 @@ On peut alors programmer cette commande |\crossbox| de la manière suivante, qui utilise explicitement la variable publique |\g_nicematrix_code_before_tl|. +\index{crossbox@\texttt{\textbackslash crossbox} (définie dans un exemple)|textit} + \begin{scope} \fvset{commandchars=\§\¤\μ} \begin{Verbatim} @@ -5283,6 +5609,9 @@ l'extension \pkg{underscore}. Si elle est chargée après, une erreur sera levé \subsection{Lignes diagonales} \label{parallelization} +\index{parallelize-diags} +\index{Ddots@\texttt{\textbackslash Ddots}} +\index{Iddots@\texttt{\textbackslash Iddots}} Par défaut, toutes les lignes diagonales\footnote{On parle des lignes créées par |\Ddots| et non des lignes créées par une commande |\line| dans le @@ -5295,8 +5624,6 @@ tableau peut avoir un effet marqué sur le résultat final. \medskip Dans les exemples suivants, la première instruction |\Ddots| est marquée en couleur : - - \medskip \begin{scope} \begin{minipage}{9.5cm} @@ -5355,6 +5682,8 @@ a+b & \Cdots & a+b & 1 \end{scope} \medskip +\index{draw-first (clé de \texttt{\textbackslash Ddots} et + \texttt{\textbackslash Iddots})} On peut choisir l'instruction |\Ddots| qui sera tracée en premier (et qui servira pour tracer les suivantes quand la parallélisation est activée) avec la clé |draw-first| : |\Ddots[draw-first]|\rlap{.} @@ -5407,6 +5736,8 @@ lignes en pointillés par \pkg{nicematrix}. \subsection{L'option exterior-arraycolsep} +\index{exterior-arraycolsep} + L'environnement |{array}| insère un espace horizontal égal à |\arraycolsep| avant et après chaque colonne. En particulier, il y a un espace égal à |\arraycolsep| avant et après le tableau. Cette caractéristique de @@ -5434,6 +5765,7 @@ environnements de l'extension \pkg{nicematrix} ne sont pas affectés). \subsection{Incompatibilités} +\index{Incompatibilités} \medskip L'extension \pkg{nicematrix} n'est pas compatible avec la classe \cls{ieeeaccess} @@ -5483,6 +5815,8 @@ on utiliser la colonne |S| de \pkg{siunitx}). \subsection{Utilisation de la clé «tikz» de la commande \textbackslash Block} +\index{tikzz@tikz!clé de \texttt{\textbackslash Block}|textit} + \label{tikz-key-examples} La clé |tikz| de la commande |\Block| n'est disponible que lorsque TikZ est @@ -5529,10 +5863,17 @@ Pour l'exemple suivant, la bibliothèque \pkg{patterns} de TikZ doit aussi être \bigskip + Dans l'exemple suivant, on utilise la clé |tikz| pour hachurer une ligne du tableau. On remarquera que l'on utilise la clé |transparent| de la commande -|\Block| pour que les filets soient tracés dans le bloc.\footnote{Par défaut, les filets ne sont pas tracés dans les blocs créés avec la commande -\texttt{\textbackslash Block} : cf.~section~\ref{rules} p.~\pageref{rules}} +|\Block| pour que les filets soient tracés dans le bloc.\footnote{Par défaut, + les filets ne sont pas tracés dans les blocs créés avec la commande + \texttt{\textbackslash Block} : cf.~section~\ref{rules} p.~\pageref{rules}} + +\index{transparent (clé de \texttt{\textbackslash Block})|textit} +\index{columncolor@\texttt{\textbackslash columncolor}!commande du + \texttt{\textbackslash CodeBefore}|textit} + \begin{Verbatim} \begin{NiceTabular}{ccc}[hvlines] @@ -5560,6 +5901,7 @@ sept & huit & neuf \subsection{Utilisation avec tcolorbox} \label{tcolorbox} +\index{tcolorbox@\pkg{tcolorbox} (extension)|textit} Voici un exemple d'utilisation de |{NiceTabular}| dans une commande |\tcbox| de \pkg{tcolorbox}. On a utilisé la clé |hvlines-except-borders| pour faire afficher @@ -5602,6 +5944,11 @@ tous les filets sauf ceux sur les bords (qui sont, bien entendu, ajoutés par } \end{BVerbatim} + +\index{hvlines-except-borders|textit} +\index{rules (clé pour un environnement)|textit} +\index{rowcolor@\texttt{\textbackslash rowcolor}!commande du \texttt{\textbackslash CodeBefore}|textit} + \medskip \begin{center} \tcbset @@ -5643,6 +5990,13 @@ tous les filets sauf ceux sur les bords (qui sont, bien entendu, ajoutés par \subsection{Notes dans les tableaux} +\index{nota@\textbf{Notes dans les tableaux}|textit} +\index{tabularnote@\texttt{\textbackslash tabularnote}|textit} +\index{notes (clé pour paramétrer les notes de\newline tableau)|textit} +\index{style (sous-clé de «notes»)|textit} +\index{enumitem-keys (sous-clé de «notes»)|textit} +\index{enumitem@\pkg{enumitem} (extension requise pour utiliser\newline \texttt{\textbackslash tabularnote})|textit} + \label{ex:notes} Les outils de \pkg{nicematrix} pour les notes dans les tableaux ont été @@ -5744,6 +6098,9 @@ Dupont & Chantal & 15 janvier 1998 \\ \subsection{Lignes en pointillés} +\index{Pointillés@\textbf{Pointillés (lignes en ---)}|textit} + + Un exemple pour le résultant de deux polynômes : \par\nobreak \medskip @@ -5760,6 +6117,9 @@ a_p & &&a_0 & & &b_1 \\ \end{vNiceArray} \end{BVerbatim} + +\index{Ddots@\texttt{\textbackslash Ddots}|textit} + \medskip \begin{scope} @@ -5778,6 +6138,9 @@ a_p & &&a_0 & & &b_1 \\ \vspace{2cm} Un exemple avec un système linéaire: +\index{last-col|textit} +\index{code-for-last-col|textit} + \begin{Verbatim} $\begin{pNiceArray}{*6c|c}[nullify-dots,last-col,code-for-last-col=\scriptstyle] 1 & 1 & 1 &\Cdots & & 1 & 0 & \\ @@ -5808,8 +6171,7 @@ L'option |line-style| permet de changer le style des lignes tracées par |\Ldots|, |\Cdots|, etc. On peut de ce fait tracer des lignes qui ne sont plus pointillées. - - +\index{line-style (clé pour les lignes pointillées)|textit} \begin{Verbatim}[formatcom=\small\color{gray}] \NiceMatrixOptions{code-for-first-row = \scriptstyle,code-for-first-col = \scriptstyle } @@ -5832,6 +6194,8 @@ pointillées. \end{pNiceMatrix}\] \end{Verbatim} +\index{code-for-first-row|textit} +\index{code-for-last-col|textit} \begin{scope} \NiceMatrixOptions{code-for-first-row = \scriptstyle,code-for-first-col = \scriptstyle } @@ -5893,6 +6257,8 @@ $\begin{pNiceMatrix}[first-row,first-col] \label{tiretes} +\index{tikzz@tikz!clé de «borders» de \texttt{\textbackslash Block}|textit} + Dans l'exemple suivant, on utilise des commandes |\Block| pour tracer des filets en tiretés. Cet exemple nécessite que TikZ soit chargé (par |\usepackage{tikz}|). @@ -5937,6 +6303,8 @@ Pour avoir les colonnes alignées les unes sous les autres, on peut imposer une largeur commune à toutes les colonnes, ce que l'on fait dans l'exemple suivant avec l'environnement |{NiceMatrixBlock}| et l'option |auto-columns-width|. +\index{NiceMatrixBlock@\texttt{\{NiceMatrixBlock\}}|textit} + \begin{Verbatim}[formatcom=\small\color{gray}] ~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@ \NiceMatrixOptions @@ -5978,6 +6346,7 @@ $\begin{pNiceArray}{rrrr|r} \end{Verbatim} \medskip +\index{auto-columns-width!(clé de \texttt{\{NiceMatrixBlock\}})|textit} \begin{NiceMatrixBlock}[auto-columns-width] \NiceMatrixOptions { @@ -6021,6 +6390,8 @@ précédentes. C'est que les parenthèses, en LaTeX, n'ont pas toutes la même largeur suivant leur taille. \medskip +\index{max-width (sous-clé de «delimiters»)} +\index{delimiters!---/max-width} Pour résoudre ce problème, on peut demander que les délimiteurs soient composés avec leur largeur maximale grâce à la clé booléenne |delimiters/max-width|. @@ -6093,6 +6464,9 @@ et placer les parenthèses avec des commandes |\SubMatrix| dans le |\CodeAfter|. Bien sûr, ce tableau ne pourra pas être coupé par un saut de page. \medskip +\index{SubMatrix@\texttt{\textbackslash SubMatrix} (commande du +\texttt{\textbackslash CodeAfter}\newline et du +\texttt{\textbackslash CodeBefore})|textit} \begin{Verbatim} \setlength{\extrarowheight}{1mm} \[\begin{NiceMatrix}% @@ -6150,6 +6524,7 @@ composition du tableau et les traits verticaux sont donc tracés sans espacer le colonnes. \medskip +\index{vlines-in-sub-matrix} En fait, on peut avec la clé |vlines-in-sub-matrix| choisir un spécificateur dans le préambule du tableau pour indiquer des filets verticaux qui seront tracés dans les |\SubMatrix| uniquement (en espaçant les colonnes). @@ -6224,6 +6599,7 @@ tracés dans les |\SubMatrix| uniquement (en espaçant les colonnes). \subsection{Comment surligner les cases d'une matrice} \label{highlight} +\index{draw (clé de \texttt{\textbackslash Block})|textit} \medskip Pour mettre en évidence une case d'une matrice, il est possible de «dessiner» @@ -6263,6 +6639,9 @@ Il est possible de colorier une rangée avec |\rowcolor| dans le |\CodeBefore| |colortbl-like| − même si \pkg{colortbl} n'est pas chargé). +\index{colortbl-like|textit} +\index{rowcolor@\texttt{\textbackslash rowcolor}!commande en tableau|textit} + \begin{Verbatim} \begin{pNiceArray}{>{\strut}cccc}[margin, extra-margin=2pt,colortbl-like] ~emphase#\rowcolor{red!15}@A_{11} & A_{12} & A_{13} & A_{14} \\ @@ -6311,6 +6690,7 @@ faut utiliser la clé |create-cell-nodes| du |\CodeBefore| pour demander leur cr fit=#1}} \medskip +\index{highlight (style TikZ défini dans\newline un exemple)|textit} \begin{Verbatim} \tikzset{highlight/.style={rectangle, fill=red!15, @@ -6328,6 +6708,9 @@ $\begin{bNiceMatrix} \end{bNiceMatrix}$ \end{Verbatim} +\index{create-cell-nodes (clé de \texttt{\textbackslash CodeBefore})|textit} +\index{CodeBefore@\texttt{\textbackslash CodeBefore}...\texttt{\textbackslash Body}|textit} + \[\begin{bNiceMatrix} \CodeBefore [create-cell-nodes] \tikz \node [highlight = (2-1) (2-3)] {} ; @@ -6376,6 +6759,9 @@ a & a & a & L_3 Le résultat peut paraître décevant. On peut l'améliorer en utilisant les «nœuds moyens» au lieu des «nœuds normaux». +\index{create-medium-nodes|textit} +\index{create-cell-nodes (clé de \texttt{\textbackslash CodeBefore})|textit} + \begin{Verbatim} \[\begin{pNiceArray}{ccc}[last-col, margin = 2pt, create-medium-nodes] \CodeBefore [create-cell-nodes] @@ -6409,6 +6795,13 @@ a & a & a & L_3 \subsection{Utilisation de \textbackslash SubMatrix dans le \textbackslash CodeBefore} +\index{SubMatrix@\texttt{\textbackslash SubMatrix} (commande du +\texttt{\textbackslash CodeAfter}\newline et du +\texttt{\textbackslash CodeBefore})|textit} +\index{CodeBefore@\texttt{\textbackslash CodeBefore}...\texttt{\textbackslash Body}|textit} +\index{CodeAfter@\texttt{\textbackslash CodeAfter}|textit} +\index{create-cell-nodes (clé de \texttt{\textbackslash CodeBefore})|textit} + \label{submatrix-in-codebefore} @@ -6493,6 +6886,11 @@ de parenthèses ont été rajoutées avec |\SubMatrix| dans le |\CodeBefore|. \subsection{Un tableau triangulaire} \label{triangular} +\index{pgf-node-code|textit} +\index{Coins (les --- vides)|textit} +\index{chessboardcolors@\texttt{\textbackslash chessboardcolors}!(commande + du \texttt{\textbackslash CodeBefore})|textit} +\index{CodeBefore@\texttt{\textbackslash CodeBefore}...\texttt{\textbackslash Body}|textit} Dans l'exemple suivant, on utilise le style PGF/Tikz |nicematrix/cell-node| pour faire tourner le contenu des cases (rotation que l'on compense ensuite en faisant @@ -6549,13 +6947,21 @@ qui doit donc être chargée préalablement). \end{NiceTabular}} \end{center} +\cleardoublepage +\phantomsection +\addcontentsline{toc}{section}{Index} + +\printindex \section*{Autre documentation} Le document |nicematrix.pdf| (fourni avec l'extension \pkg{nicematrix}) contient -une traduction anglaise de la documentation ici présente, ainsi que le code -source commenté et un historique des versions. +une traduction anglaise de la documentation ici présente ainsi qu'un historique +des versions. + +Le document |nicematrix-code.pdf| (fourni également avec l'extension \pkg{nicematrix} +contient le code LaTeX commenté (à partir du fichier |nicematrix-code.dtx|). \medskip Les versions successives du fichier |nicematrix.sty| fournies par diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf Binary files differindex 7b447a8a119..474dac2ee0f 100644 --- a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.pdf diff --git a/Master/texmf-dist/doc/latex/nicematrix/nicematrix.tex b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.tex new file mode 100644 index 00000000000..6cf322afa9e --- /dev/null +++ b/Master/texmf-dist/doc/latex/nicematrix/nicematrix.tex @@ -0,0 +1,7484 @@ +% -*- coding: utf-8 ; -*- This file should be compiled with XeLaTeX only +\documentclass[dvipsnames]{article}% dvipsnames is for xcolor (loaded by Tikz, loaded by nicematrix) +\usepackage{xltxtra} + +\usepackage{geometry} +\geometry{left=2.8cm,right=2.8cm,top=2.5cm,bottom=2.5cm,papersize={21cm,29.7cm}} + +\usepackage{nicematrix} + +\usepackage{tikz} +\usetikzlibrary{fit,patterns,arrows.meta,decorations.pathmorphing} + +\usepackage{enumitem} +\usepackage{siunitx} +\usepackage{verbatim} +\usepackage{caption} +\usepackage{tocloft} +\setlength{\cftsubsecnumwidth}{3em} % for the numbers of subsections of the TOC + +% On utilise \MakeShortVerb de shortvrb et pas \DefineShortVerb de fancyvrb +% car on ne veut pas que le contenu des petits éléments en verbatim soit colorié +% en gris +\usepackage{shortvrb} +\MakeShortVerb{\|} + +\usepackage{fancyvrb} +\fvset{commandchars=\~\#\@,formatcom=\color{gray}} + +\usepackage{titlesec} +\titlespacing*{\section}{0pt}{6.5ex plus 1ex minus .2ex}{4.3ex plus .2ex} +\titlespacing*{\subsection}{0pt}{4.5ex plus 1ex minus .2ex}{2ex plus .2ex} + +\def\LetterAt{@} + +\def\interitem{\vspace{7mm plus 2 mm minus 3mm}} +\def\emphase{\bgroup\color{RoyalPurple}\let\next=} + +\usepackage{footnote} +\usepackage{booktabs} +\usepackage{varwidth} +\usepackage{tcolorbox} +\usepackage{adjustbox} +\usepackage[auto-lang=false]{lipsum} + +\NewDocumentEnvironment {scope} {} {} {} + +\NewDocumentCommand {\pkg} {m} {\textsf{#1}} +\NewDocumentCommand {\cls} {m} {\textsf{#1}} + +\setlength{\parindent}{0pt} +\skip \footins = 2 \bigskipamount + + +\NewDocumentCommand{\Definition}{m} + {{\setlength{\fboxsep}{1pt}\colorbox{gray!20}{\ttfamily \vphantom{gl}#1}}} + +\usepackage{makeidx} +\makeindex + +\NewDocumentCommand{\indexcommand}{m}{\index{#1@\texttt{\textbackslash #1}}} + +\NewDocumentCommand{\indexenv}{m}{\index{#1@\texttt{\{#1\}}}} + +\usepackage[hyperfootnotes = false]{hyperref} + +\hypersetup + { + pdfinfo = + { + Title = The package 'nicematrix' , + Subject = A LaTeX package , + Author = F. Pantigny + } + } + + + +\begin{document} + +\VerbatimFootnotes + + +\title{The package \pkg{nicematrix}\thanks{This document corresponds to the version~\myfileversion\space of \pkg{nicematrix}, +at the date of~\myfiledate.}} \author{F. Pantigny \\ \texttt{fpantigny@wanadoo.fr}} + + +\maketitle + +\begin{abstract} +The LaTeX package \pkg{nicematrix} provides new environments similar to the +classical environments |{tabular}|, |{array}| and |{matrix}| of \pkg{array} +and \pkg{amsmath} but with extended features. +\end{abstract} + + + + +\vspace{1cm} +\hspace{1cm} +$\begin{bNiceArray}{cccc}[first-row,first-col, + code-for-first-col=\color{blue}\scriptstyle, + code-for-first-row=\color{blue}\scriptstyle, + columns-width = auto] + & C_1 & C_2 & \Cdots & C_n \\ +L_1 & a_{11} & a_{12} & \Cdots & a_{1n} \\ +L_2 & a_{21} & a_{22} & \Cdots & a_{2n} \\ +\Vdots & \Vdots & \Vdots & \Ddots & \Vdots\\ +L_n & a_{n1} & a_{n2} & \Cdots & a_{nn} +\end{bNiceArray}$\hspace{2cm} +\begin{NiceTabular}{lSSSS}[code-before = \rowcolor{red!15}{1-2} \rowcolors{3}{blue!15}{}] +\toprule +\Block{2-1}{Product} & \multicolumn{3}{c}{dimensions (cm)} & \Block{2-1}{\rotate Price} \\ +\cmidrule(rl){2-4} + & L & l & h \\ +\midrule +small & 3 & 5.5 & 1 & 30 \\ +standard & 5.5 & 8 & 1.5 & 50.5 \\ +premium & 8.5 & 10.5 & 2 & 80 \\ +extra & 8.5 & 10 & 1.5 & 85.5 \\ +special & 12 & 12 & 0.5 & 70 \\ +\bottomrule +\end{NiceTabular} + +\vspace{1cm} +The package \pkg{nicematrix} is entirely contained in the file +|nicematrix.sty|. This file may be put in the current directory or in a +|texmf| tree. However, the best is to install \pkg{nicematrix} with a TeX +distribution such as MiKTeX, TeX Live or MacTeX. + +\medskip +\emph{Remark}\par\nobreak + +If you use LaTeX via Internet with, for example, Overleaf, you +can upload the file |nicematrix.sty| in the repertory of your +project in order to take full advantage of the latest version de +\pkg{nicematrix}.\footnote{The latest version of the file +|nicematrix.sty| may be downloaded from the \textsc{svn} server of +TeXLive:\newline +\small +\url{https:www.tug.org/svn/texlive/trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty}} + +\medskip +This package can be used with |xelatex|, |lualatex|, |pdflatex| but also by +the classical workflow |latex|-|dvips|-|ps2pdf| (or Adobe Distiller). +\textsl{However, the file nicematrix.dtx of the present documentation should +be compiled with XeLaTeX.} + +\medskip +This package requires and \textbf{loads} the packages \pkg{l3keys2e}, +\pkg{array}, \pkg{amsmath}, \pkg{pgfcore} and the module \pkg{shapes} of +\textsc{pgf} (\pkg{tikz}, which is a layer over \textsc{pgf}, is \emph{not} +loaded). The final user only has to load the package with +|\usepackage{nicematrix}|. + + +\medskip +The idea of \pkg{nicematrix} is to create \textsc{pgf} nodes under the cells +and the positions of the rules of the tabular created by \pkg{array} and to +use these nodes to develop new features. As usual with \textsc{pgf}, the +coordinates of these nodes are written in the |aux| to be used on the next +compilation and that's why \pkg{nicematrix} may need \textbf{several +compilations}.\footnote{If you use Overleaf, Overleaf will do automatically +a sufficient number of compilations.} + +\medskip +Most features of \pkg{nicematrix} may be used without explicit use of +\textsc{pgf} or Tikz (which, in fact, is not loaded by default). + +\medskip +\indexcommand{NiceMatrixOptions} +A command |\NiceMatrixOptions| is provided to fix the options (the +scope of the options fixed by this command is the current TeX group: they are +semi-global). + + + +\newpage + +\section{The environments of this package} + +The package \pkg{nicematrix} defines the following new environments. + +\medskip +\begin{ttfamily} +\setlength{\tabcolsep}{3mm} +\begin{tabular}{llll} +\{NiceTabular\} & \{NiceArray\} & \{NiceMatrix\} \\ +\{NiceTabular*\} & \{pNiceArray\} & \{pNiceMatrix\} \\ +\{NiceTabularX\} & \{bNiceArray\} & \{bNiceMatrix\} \\ + & \{BNiceArray\} & \{BNiceMatrix\} \\ + & \{vNiceArray\} & \{vNiceMatrix\} \\ + & \{VNiceArray\} & \{VNiceMatrix\} +\end{tabular} +\end{ttfamily} + +% +\medskip +The environments |{NiceArray}|, |{NiceTabular}| and |{NiceTabular*}| are +similar to the environments |{array}|, |{tabular}| and |{tabular*}| of the +package \pkg{array} (which is loaded by \pkg{nicematrix}). + +\medskip +The environments |{pNiceArray}|, |{bNiceArray}|, etc. have no equivalent in +\pkg{array}. + +\medskip +The environments |{NiceMatrix}|, |{pNiceMatrix}|, etc. are similar to the +corresponding environments of \pkg{amsmath} (which is loaded by +\pkg{nicematrix}): |{matrix}|, |{pmatrix}|, etc. + +\medskip +The environment |{NiceTabularX}| is similar to the environment |{tabularx}| +from the eponymous package.\footnote{In fact, it's possible to use directly the +|X| columns in the environment |{NiceTabular}| (and the required +width for the tabular is fixed by the key |width|): cf. p.~\pageref{X-columns}}. + +\medskip +\textbf{It's recommended to use primarily the classical environments and to use the +environments of \pkg{nicematrix} only when some feature provided by these +environments is used (this will save memory).} + +\medskip +All the environments of the package \pkg{nicematrix} accept, between square +brackets, an optional list of \textsl{key=value} pairs. \textbf{There must be +no space before the opening bracket (|[|) of this list of options.} + + +\section{The vertical space between the rows} + +\label{cell-space} +\index{cell-space-top-limit} +\index{cell-space-bottom-limit} +\index{cell-space-limits} + + +It's well known that some rows of the arrays created by default with LaTeX +are, by default, too close to each other. Here is a classical example. + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=9cm] +$\begin{pmatrix} +\frac{1}{2} & -\frac{1}{2} \\ +\frac{1}{3} & \frac{1}{4} \\ +\end{pmatrix}$ +\end{BVerbatim} +$\begin{pmatrix} +\frac{1}{2} & -\frac{1}{2} \\ +\frac{1}{3} & \frac{1}{4} \\ +\end{pmatrix}$ + +\bigskip +Inspired by the package \pkg{cellspace} which deals with that problem, the +package \pkg{nicematrix} provides two keys |cell-space-top-limit| and +|cell-space-bottom-limit| similar to the parameters of \pkg{cellspace} called +|\cellspacetoplimit| and +|\cellspacebottomlimit|.\index{cellspace@\pkg{cellspace} (package)} + +There is also a key |cell-space-limits| to set both parameters at once. + +The initial value of these parameters is $0$~pt in order to have for the +environments of \pkg{nicematrix} the same behaviour as those of \pkg{array} +and \pkg{amsmath}. However, a value of $1$~pt would probably be a good choice +and we suggest to set them with |\NiceMatrixOptions|.\footnote{One should +remark that these parameters apply also to the columns of type |S| of +\pkg{siunitx} whereas the package \pkg{cellspace} is not able to act on such +columns of type~|S|.} + +\medskip +\begin{Verbatim} +\NiceMatrixOptions{~emphase#cell-space-limits = 1pt@} +\end{Verbatim} + +\begin{BVerbatim}[baseline=c,boxwidth=9cm] +$\begin{pNiceMatrix} +\frac12 & -\frac12 \\ +\frac13 & \frac14 \\ +\end{pNiceMatrix}$ +\end{BVerbatim} +\begin{scope} +\NiceMatrixOptions{cell-space-limits = 1pt} +$\begin{pNiceMatrix} +\frac12 & -\frac12 \\ +\frac13 & \frac14 \\ +\end{pNiceMatrix}$ +\end{scope} + + + + + +\bigskip +\section{The vertical position of the arrays} + +\index{baseline (key for an environment)} + +The package \pkg{nicematrix} provides a option |baseline| for the vertical +position of the arrays. This option takes in as value an integer which is the +number of the row on which the array will be aligned. + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=9cm] +$A = \begin{pNiceMatrix}[~emphase#baseline=2@] +\frac{1}{\sqrt{1+p^2}} & p & 1-p \\ +1 & 1 & 1 \\ +1 & p & 1+p +\end{pNiceMatrix}$ +\end{BVerbatim} +$A = \begin{pNiceMatrix}[baseline=2] +\frac{1}{\sqrt{1+p^2}} & p & 1-p \\ +1 & 1 & 1 \\ +1 & p & 1+p +\end{pNiceMatrix}$ + + +\medskip +It's also possible to use the option |baseline| with one of the special values +|t|, |c| or |b|. These letters may also be used absolutely like the option of +the environments |{tabular}| and |{array}| of \pkg{array}. The initial value +of |baseline| is~|c|. + + +\medskip +In the following example, we use the option |t| (equivalent to |baseline=t|) +immediately after an |\item| of list. One should remark that the presence of a +|\hline| at the beginning of the array doesn't prevent the alignment of the +baseline with the baseline of the first row (with |{tabular}| or |{array}| of +\pkg{array}, one must use |\firsthline|). + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=9cm] +\begin{enumerate} +\item an item +\smallskip +\item \renewcommand{\arraystretch}{1.2} +$\begin{NiceArray}~emphase#[t]@{lcccccc} +\hline +n & 0 & 1 & 2 & 3 & 4 & 5 \\ +u_n & 1 & 2 & 4 & 8 & 16 & 32 +\hline +\end{NiceArray}$ +\end{enumerate} +\end{BVerbatim} +\begin{minipage}{5cm} +\begin{enumerate} +\item an item +\smallskip +\item \renewcommand{\arraystretch}{1.2} +$\begin{NiceArray}[t]{lcccccc} +\hline +n & 0 & 1 & 2 & 3 & 4 & 5 \\ +u_n & 1 & 2 & 4 & 8 & 16 & 32 \\ +\hline +\end{NiceArray}$ +\end{enumerate} +\end{minipage} + +\medskip +However, it's also possible to use the tools of +\pkg{booktabs}\footnote{The extension \pkg{booktabs} is \emph{not} loaded +by \pkg{nicematrix}.}: |\toprule|, +|\bottomrule|, |\midrule|, etc.\par\nobreak + +\smallskip +\begin{BVerbatim}[baseline=c,boxwidth=9cm] +\begin{enumerate} +\item an item +\smallskip +\item +$\begin{NiceArray}[t]{lcccccc} +~emphase#\toprule@ +n & 0 & 1 & 2 & 3 & 4 & 5 \\ +~emphase#\midrule@ +u_n & 1 & 2 & 4 & 8 & 16 & 32 +~emphase#\bottomrule@ +\end{NiceArray}$ +\end{enumerate} +\end{BVerbatim} +\begin{minipage}{5cm} +\begin{enumerate} +\item an item +\smallskip +\item +$\begin{NiceArray}[t]{lcccccc} +\toprule +n & 0 & 1 & 2 & 3 & 4 & 5 \\ +\midrule +u_n & 1 & 2 & 4 & 8 & 16 & 32 \\ +\bottomrule +\end{NiceArray}$ +\end{enumerate} +\end{minipage} + +\bigskip +It's also possible to use the key |baseline| to align a matrix on an +horizontal rule (drawn by |\hline|). In this aim, one should give the value +|line-|\textsl{i} where \textsl{i} is the number of the row \emph{following} the +horizontal rule. + +\smallskip +\begin{Verbatim} +\NiceMatrixOptions{cell-space-limits=1pt} +\end{Verbatim} + +\smallskip +\begin{BVerbatim}[baseline=c,boxwidth=9cm] +$A=\begin{pNiceArray}{cc|cc}~emphase#[baseline=line-3]@ +\dfrac{1}{A} & \dfrac{1}{B} & 0 & 0 \\ +\dfrac{1}{C} & \dfrac{1}{D} & 0 & 0 \\ +\hline +0 & 0 & A & B \\ +0 & 0 & D & D \\ +\end{pNiceArray}$ +\end{BVerbatim} +\begin{scope} +\NiceMatrixOptions{cell-space-limits=1pt} +\raisebox{-5mm}{$A=\begin{pNiceArray}{cc|cc}[baseline=line-3] +\dfrac{1}{A} & \dfrac{1}{B} & 0 & 0 \\ +\dfrac{1}{C} & \dfrac{1}{D} & 0 & 0 \\ +\hline +0 & 0 & A & B \\ +0 & 0 & D & D \\ +\end{pNiceArray}$} +\end{scope} + + +\section{The blocks} +\label{Block} + +\index{Blocks@\textbf{Blocks in the tabulars}|(} +\indexcommand{Block} + + +\subsection{General case} + +In the environments of \pkg{nicematrix}, it's possible to use the command +|\Block| in order to place an element in the center of a rectangle of merged +cells of the array.\footnote{The spaces after a command |\Block| are deleted.} + +The command |\Block| must be used in the upper leftmost cell of the array with +two arguments. + +\begin{itemize} +\item The first argument is the size of the block with the syntax +$i$|-|$j$ where $i$ is the number of rows of the block and $j$ its number +of columns. + +If this argument is empty, its default +value is |1-1|. If the number of rows is not specified, or equal to |*|, the +block extends until the last row (idem for the columns). + +\item The second argument is the content of the block. It's possible to use +|\\| in that content to have a content on several lines. In |{NiceTabular}|, +|{NiceTabular*}| and |{NiceTabularX}|, the content of the block is composed in +text mode whereas, in the other environments, it is composed in math mode. +\end{itemize} + + +\interitem +Here is an example of utilisation of the command |\Block| in mathematical matrices. + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=10.6cm] +$\begin{bNiceArray}{cw{c}{1cm}c|c}[margin] +~emphase#\Block{3-3}{A}@ & & & 0 \\ +& & & \Vdots \\ +& & & 0 \\ +\hline +0 & \Cdots& 0 & 0 +\end{bNiceArray}$ +\end{BVerbatim} +$\begin{bNiceArray}{cw{c}{1cm}c|c}[margin] +\Block{3-3}{A} & & & 0 \\ +& & & \Vdots \\ +& & & 0 \\ +\hline +0 & \Cdots& 0 & 0 +\end{bNiceArray}$ + +\bigskip +One may wish to raise the size of the ``$A$'' placed in the block of the +previous example. Since this element is composed in math mode, it's not +possible to use directly a command like |\large|, |\Large| and |\LARGE|. +That's why the command |\Block| provides an option between angle brackets to +specify some TeX code which will be inserted before the beginning of the +math mode.\footnote{This argument between angular brackets may also be used to +insert a command of font such as |\bfseries| when the command |\\| is used in +the content of the block.} + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=10.6cm] +$\begin{bNiceArray}{cw{c}{1cm}c|c}[margin] +\Block{3-3}~emphase#<\Large>@{A} & & & 0 \\ +0 & & & \Vdots \\ +& & & 0 \\ +\hline +0 & \Cdots& 0 & 0 +\end{bNiceArray}$ +\end{BVerbatim} +\begin{scope} +$\begin{bNiceArray}{cw{c}{1cm}c|c}[margin] +\Block{3-3}<\Large>{A} & & & 0 \\ +& & & \Vdots \\ +& & & 0 \\ +\hline +0 & \Cdots& 0 & 0 +\end{bNiceArray}$ +\end{scope} + + + +\interitem +In fact, the command |\Block| accepts as first optional argument (between +square brackets) a list of couples \textsl{key=value}. The available keys are as +follows: +\begin{itemize} +\item \index{fill (key of \texttt{\textbackslash Block})} +the key \Definition{fill} takes in as value a color and fills the block +with that color; +\item \index{draw (key of \texttt{\textbackslash Block})} +the key \Definition{draw} takes in as value a color and strokes the +frame of the block with that color (the default value of that key is the +current color of the rules of the array); +\item \index{color!key of \texttt{\textbackslash Block}} +the key \Definition{color} takes in as value a color and apply that +color the content of the block but draws also the frame of the block with that +color; +\item \index{vlines!key of \texttt{\textbackslash Block}} +\index{hvlines!key of \texttt{\textbackslash Block}} +\index{hlines!key of \texttt{\textbackslash Block}} +the keys \Definition{hlines}, \Definition{vlines} and +\Definition{hvlines} draw all the corresponding rules in the +block;\footnote{However, the rules are not drawn in the sub-blocks of the +block, as always with \pkg{nicematrix}: the rules are not drawn in the blocks +(cf. section~\ref{rules} p.~\pageref{rules}).} +\item \index{line-width (key of \texttt{\textbackslash Block})} +the key \Definition{line-width} is the width of the rules (is relevant +only when one of the keys |draw|, |hvlines|, |vlines| and |hlines| is used); +\item \index{rounded-corners!key of \texttt{\textbackslash Block}} +\index{Corners (rounded ---)!for a block} +the key \Definition{rounded-corners} requires rounded corners (for the +frame drawn by |draw| and the shape drawn by |fill|) with a radius equal to +the value of that key (the default value is 4~pt\footnote{This value is the +initial value of the \emph{rounded corners} of Tikz.}); +\item \index{tikzz@tikz!key of \texttt{\textbackslash Block}} +when the key \Definition{tikz} is used, the Tikz path corresponding of +the rectangle which delimits the block is executed with Tikz\footnote{Tikz +should be loaded (by default, \pkg{nicematrix} only loads \textsc{pgf}) and, +if it's not, an error will be raised.} by using as options the value of that +key |tikz| (which must be a list of keys allowed for a Tikz path). For +examples, cf. p.~\pageref{tikz-key-examples}; +\item \index{name!key of \texttt{\textbackslash Block}} +the key \Definition{name} provides a name to the rectangular Tikz node +corresponding to the block; it's possible to use that name with Tikz in the +|\CodeAfter| of the environment (cf.~p.~\pageref{code-after}); +\item \index{respect-arraystretch (key of \texttt{\textbackslash Block})} +the key \Definition{respect-arraystretch} prevents the setting of +|\arraystretch| to $1$ at the beginning of the block (which is the behaviour +by default) ; +\item \index{borders (key of \texttt{\textbackslash Block})} +\index{tikzz@tikz!key of ``borders'' de \texttt{\textbackslash Block}} +the key \Definition{borders} provides the ability to draw only some +borders of the blocks; the value of that key is a (comma-separated) list of +elements covered by |left|, |right|, |top| and |bottom|; it's possible, in +fact, in the list which is the value of the key |borders|, to add an entry of +the form |tikz={|\textsl{list}|}| where \textsl{list} is a list of couples +\textsl{key=value} of Tikz specifying the graphical characteristics of the +lines that will be drawn (for an example, see p.~\pageref{dashed}). +\item \index{transparent (key of \texttt{\textbackslash Block})} +By default, the rules are not drawn in the blocks (see the section about +the rules: section~\ref{rules} p.~\pageref{rules}). However, if the key +\Definition{transparent} is used, the rules are drawn. For an example, see +section~\ref{tikz-key-examples} on page~\pageref{tikz-key-examples}. Caution: +that key does not imply that the content of the block will be transparent! +\end{itemize} + +There is also keys for the horizontal and vertical positions of the content of +the block: cf.~\ref{horizontal-block} p.~\pageref{horizontal-block}. + +\interitem +{\bfseries One must remark that, by default, the commands |\Blocks| don't create space}. +There is exception only for the blocks mono-row and the blocks mono-column as +explained just below. + +\medskip +In the following example, we have had to enlarge by hand the columns 2 and 3 +(with the construction |w{c}{...}| of \pkg{array}). + +\bigskip +\begin{BVerbatim} +\begin{NiceTabular}{cw{c}{2cm}w{c}{3cm}c} +rose & tulip & daisy & dahlia \\ +violet +& ~emphase#\Block[draw=red,fill=[RGB]{204,204,255},rounded-corners]{2-2}@ + ~emphase#{\LARGE Some beautiful flowers}@ + & & marigold \\ +iris & & & lis \\ +arum & periwinkle & forget-me-not & hyacinth +\end{NiceTabular} +\end{BVerbatim} + +\medskip +\begin{center} +\begin{NiceTabular}{cw{c}{2cm}w{c}{3cm}c} +rose & tulip & daisy & dahlia \\ +violet & \Block[draw=red,fill=[RGB]{204,204,255},rounded-corners]{2-2} + {\LARGE Some beautiful flowers} & & marigold \\ + iris & & & lis \\ + arum & periwinkle & forget-me-not & hyacinth +\end{NiceTabular} +\end{center} + +\subsection{The mono-column blocks} + +The mono-column blocks have a special behaviour. + +\begin{itemize} +\item The natural width of the contents of these blocks is taken into account +for the width of the current column. + +In the columns with a fixed width (columns |w{...}{...}|, |W{...}{...}|, +|p{...}|, |b{...}|, |m{...}|, |V| and |X|), the content of the block is +formatted as a paragraph of that width. + +\item The specification of the horizontal position provided by the type of +column (|c|, |r| or |l|) is taken into account for the blocks (but the +|\Block| may have its own specification of alignment: +cf.~\ref{horizontal-block} p.~\pageref{horizontal-block}). + +\item The specifications of font specified for the column by a construction +|>{...}| in the preamble of the array are taken into account for the +mono-column blocks of that column (this behaviour is probably expected). +\end{itemize} + + +\bigskip +\begin{scope} +\hfuzz=10cm +\begin{BVerbatim}[baseline=c,boxwidth=12cm] +\begin{NiceTabular}{~LetterAt{}>{\bfseries}lr~LetterAt{}} \hline +\Block{2-1}{John} & 12 \\ + & 13 \\ \hline +Steph & 8 \\ \hline +\Block{3-1}{Sarah} & 18 \\ + & 17 \\ + & 15 \\ \hline +Ashley & 20 \\ \hline +Henry & 14 \\ \hline +\Block{2-1}{Madison} & 15 \\ + & 19 \\ \hline +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{@{}>{\bfseries}lr@{}}[baseline=c] \hline +\Block{2-1}{John} & 12 \\ + & 13 \\ \hline +Steph & 8 \\ \hline +\Block{3-1}{Sarah} & 18 \\ + & 17 \\ + & 15 \\ \hline +Ashley & 20 \\ \hline +Henry & 14 \\ \hline +\Block{2-1}{Madison} & 15 \\ + & 19 \\ \hline +\end{NiceTabular} +\end{scope} + + +\subsection{The mono-row blocks} + +For the mono-row blocks, the natural height and depth are taken into account +for the height and depth of the current row (as does a standard |\multicolumn| +of LaTeX). + +\subsection{The mono-cell blocks} + +A mono-cell block inherits all the properties of the mono-row blocks and +mono-column blocks. + +\medskip +At first sight, one may think that there is no point using a mono-cell block. +However, there are some good reasons to use such a block. +\begin{itemize} +\item It's possible to use the command |\\| in a (mono-cell) block. + +\item It's possible to use the option of horizontal alignment of the block in +derogation of the type of column given in the preamble of the array. + +\item It's possible do draw a frame around the cell with the key |draw| of the +command |\Block| and to fill the background with rounded corners with the keys +|fill| and |rounded-corners|.\footnote{If one simply wishes to color the +background of a unique cell, there is no point using the command |\Block|: +it's possible to use the command |\cellcolor| (when the key |colortbl-like| is +used).} + +\item It's possible to draw one or several borders of the cell with the key |borders|. +\end{itemize} + +\bigskip +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +\begin{NiceTabular}{cc} +\toprule +Writer & ~emphase#\Block[l]{}{year\\ of birth}@ \\ +\midrule +Hugo & 1802 \\ +Balzac & 1799 \\ +\bottomrule +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{cc} +\toprule +Writer & \Block[l]{}{year\\ of birth} \\ +\midrule +Hugo & 1802 \\ +Balzac & 1799 \\ +\bottomrule +\end{NiceTabular} + +\medskip +We recall that if the first mandatory argument of |\Block| is left blank, the +block is mono-cell.\footnote{One may consider that the default value of the +first mandatory argument of |\Block| is |1-1|.} + + + + +\subsection{Horizontal position of the content of the block} + +\label{horizontal-block} + +The command |\Block| accepts the keys |l|, |c| and |r| for the horizontal +position of its content. + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=10.6cm] +$\begin{bNiceArray}{cw{c}{1cm}c|c}[margin] +\Block~emphase#[r]@{3-3}<\LARGE>{A} & & & 0 \\ +& & & \Vdots \\ +& & & 0 \\ +\hline +0 & \Cdots& 0 & 0 +\end{bNiceArray}$ +\end{BVerbatim} +$\begin{bNiceArray}{cw{c}{1cm}c|c}[margin] +\Block[r]{3-3}<\LARGE>{A} & & & 0 \\ +& & & \Vdots \\ +& & & 0 \\ +\hline +0 & \Cdots& 0 & 0 +\end{bNiceArray}$ + + +\medskip +By default, the horizontal position of the content of a block is computed +by using the positions of the \emph{contents} of the columns implied in that +block. That's why, in the following example, the header ``First group'' is +correctly centered despite the instruction |!{\qquad}| in the preamble which +has been used to increase the space between the columns (this +is not the behaviour of |\multicolumn|). + +\medskip +\begin{center} +\fvset{commandchars=\~\#\+} +\begin{BVerbatim} +\begin{NiceTabular}{@{}c!{\qquad}ccc~emphase#!{\qquad}+ccc@{}} +\toprule +Rank & ~emphase#\Block{1-3}{First group}+ & & & \Block{1-3}{Second group} \\ + & 1A & 1B & 1C & 2A & 2B & 2C \\ +\midrule + 1 & 0.657 & 0.913 & 0.733 & 0.830 & 0.387 & 0.893\\ + 2 & 0.343 & 0.537 & 0.655 & 0.690 & 0.471 & 0.333\\ + 3 & 0.783 & 0.885 & 0.015 & 0.306 & 0.643 & 0.263\\ + 4 & 0.161 & 0.708 & 0.386 & 0.257 & 0.074 & 0.336\\ +\bottomrule +\end{NiceTabular} +\end{BVerbatim} +\end{center} + +\bigskip +\begin{center} +\begin{NiceTabular}{@{}c!{\qquad}ccc!{\qquad}ccc@{}} +\toprule +Rank & \Block{1-3}{First group} & & & \Block{1-3}{Second group} \\ + & 1A & 1B & 1C & 2A & 2B & 2C \\ +\midrule + 1 & 0.657 & 0.913 & 0.733 & 0.830 & 0.387 & 0.893\\ + 2 & 0.343 & 0.537 & 0.655 & 0.690 & 0.471 & 0.333\\ + 3 & 0.783 & 0.885 & 0.015 & 0.306 & 0.643 & 0.263\\ + 4 & 0.161 & 0.708 & 0.386 & 0.257 & 0.074 & 0.336\\ +\bottomrule +\end{NiceTabular} +\end{center} + +\medskip +In order to have an horizontal positionning of the content of the block +computed with the limits of the columns of the LaTeX array (and not with the +contents of those columns), one may use the key |L|, |R| and |C| of the +command |\Block|. + +\medskip +Here is the same example with the key |C| for the first block. + +\medskip +\begin{center} +\fvset{commandchars=\~\#\+} +\begin{BVerbatim} +\begin{NiceTabular}{@{}c!{\qquad}ccc~emphase#!{\qquad}+ccc@{}} +\toprule +Rank & ~emphase#\Block[C]{1-3}{First group}+ & & & \Block{1-3}{Second group} \\ + & 1A & 1B & 1C & 2A & 2B & 2C \\ +\midrule + 1 & 0.657 & 0.913 & 0.733 & 0.830 & 0.387 & 0.893\\ + 2 & 0.343 & 0.537 & 0.655 & 0.690 & 0.471 & 0.333\\ + 3 & 0.783 & 0.885 & 0.015 & 0.306 & 0.643 & 0.263\\ + 4 & 0.161 & 0.708 & 0.386 & 0.257 & 0.074 & 0.336\\ +\bottomrule +\end{NiceTabular} +\end{BVerbatim} +\end{center} + +\bigskip +\begin{center} +\begin{NiceTabular}{@{}c!{\qquad}ccc!{\qquad}ccc@{}} +\toprule +Rank & \Block[C]{1-3}{First group} & & & \Block{1-3}{Second group} \\ + & 1A & 1B & 1C & 2A & 2B & 2C \\ +\midrule + 1 & 0.657 & 0.913 & 0.733 & 0.830 & 0.387 & 0.893\\ + 2 & 0.343 & 0.537 & 0.655 & 0.690 & 0.471 & 0.333\\ + 3 & 0.783 & 0.885 & 0.015 & 0.306 & 0.643 & 0.263\\ + 4 & 0.161 & 0.708 & 0.386 & 0.257 & 0.074 & 0.336\\ +\bottomrule +\end{NiceTabular} +\end{center} + + +\subsection{Vertical position of the content of the block} + + +For the vertical position, the command |\Blocks| accepts the keys +|v-center|\footnote{That key could not have been named |c| since the key |c| +is used for the horizontal alignement.}, +|t|, |b|, |T| and |B|. + + +\begin{itemize} +\item \index{v-center (key of \texttt{\textbackslash Block})} +With the key |v-center|, the content of the block is vertically centered. +\item With the key |t|, the baseline of the content of the block is aligned +With the basline of the first row concerned by the block). +\item with the key |b|, the baseline of the last row of the content of the +block (we recall that the content of a block may contains several lines +separated by |\\|) is aligned with the baseline of the last of the rows of the +array involved in the block. +\item With the key |T|, the content of the block is set upwards. + +\colorbox{yellow!50}{\textbf{Modification 6.18}}\enskip No vertical margin is +added. However, the contents of the block is (always) composed by +\pkg{nicematrix} in a |{minipage}|, a |{tabular}| or an |{array}| and, hence, +there will still remain a margin (in most cases). + +\item With the key |B|, the content of the block is set downwards. +\end{itemize} + +When no key is given, the key |v-center| applies (excepted in the mono-row blocks). + + + +\medskip +\begin{scope} +\NiceMatrixOptions{rules/color=[gray]{0.75}, hvlines} + +\begin{BVerbatim} +\NiceMatrixOptions{rules/color=[gray]{0.75}, hvlines} +\end{BVerbatim} + +\bigskip + +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +\begin{NiceTabular}{ccc} +\Block[fill=red!10,~emphase#t@,l]{4-2}{two\\lines} + & & \Huge Un\\ + & & deux \\ + & & trois \\ + & & \Huge quatre \\ +text & text \\ +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{ccc} +\Block[fill=red!10,t,l]{4-2}{two\\lines} + & & \Huge Un\\ + & & deux \\ + & & trois \\ + & & \Huge quatre \\ +text & text \\ +\end{NiceTabular} + + +\bigskip +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +\begin{NiceTabular}{ccc} +\Block[fill=red!10,~emphase#b@,r]{4-2}{two\\lines} + & & \Huge Un\\ + & & deux \\ + & & trois \\ + & & \Huge quatre \\ +text & text \\ +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{ccc} +\Block[fill=red!10,b,r]{4-2}{two\\lines} + & & \Huge Un\\ + & & deux \\ + & & trois \\ + & & \Huge quatre \\ +text & text \\ +\end{NiceTabular} + +\bigskip +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +\begin{NiceTabular}{ccc} +\Block[fill=red!10,~emphase#T@,l]{4-2}{two\\lines} + & & \Huge Un\\ + & & deux \\ + & & trois \\ + & & \Huge quatre \\ +text & text \\ +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{ccc} +\Block[fill=red!10,T,l]{4-2}{two\\lines} + & & \Huge Un\\ + & & deux \\ + & & trois \\ + & & \Huge quatre \\ +text & text \\ +\end{NiceTabular} + + +\bigskip +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +\begin{NiceTabular}{ccc} +\Block[fill=red!10,~emphase#B@,r]{4-2}{two\\lines} + & & \Huge Un\\ + & & deux \\ + & & trois \\ + & & \Huge quatre \\ +text & text \\ +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{ccc} +\Block[fill=red!10,B,r]{4-2}{two\\lines} + & & \Huge Un\\ + & & deux \\ + & & trois \\ + & & \Huge quatre \\ +text & text \\ +\end{NiceTabular} + + +\end{scope} + +\index{Blocks@\textbf{Blocks in the tabulars}|)} + + +\section{The rules} + +\label{rules} +\index{Rules@\textbf{Rules in the tabulars}|(} +\index{Lines in the tabulars|see{Rules}} + +The usual techniques for the rules may be used in the environments of +\pkg{nicematrix} (excepted |\vline|). However, there is some small differences +with the classical environments. + +\bigskip +\subsection{Some differences with the classical environments} + +\subsubsection{The vertical rules} + +In the environments of \pkg{nicematrix}, the vertical rules specified by +\verb+|+ in the preambles of the environments are never broken, even by an +incomplete row or by a double horizontal rule specified by |\hline\hline| +(there is no need to use the package~\pkg{hhline}). + +\bigskip +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +\begin{NiceTabular}{|c|c|} \hline +First & Second \\ ~emphase#\hline\hline@ +Peter \\ \hline +Mary & George\\ \hline +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{|c|c|}[c] \hline +First & Second \\ \hline\hline +Peter \\ \hline +Mary & George \\ \hline +\end{NiceTabular} + + +\bigskip +However, the vertical rules are not drawn in the blocks (created by |\Block|: +cf.~p.~\pageref{Block}) nor in the corners (created by the key |corner|: +cf.~p.~\pageref{corners}) nor in the potential exterior rows (created by the +keys |first-row| and |last-row|: cf.~p.~\pageref{exterior}). + +\bigskip +\index{booktabs@\pkg{booktabs} (package)} +If you use \pkg{booktabs} (which provides |\toprule|, |\midrule|, +|\bottomrule|, etc.) and if you really want to add vertical rules (which is +not in the spirit of \pkg{booktabs}), you should notice that the vertical rules +drawn by \pkg{nicematrix} are compatible with \pkg{booktabs}. + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=10.5cm] +$\begin{NiceArray}{~emphase#|cccc|@} \toprule +a & b & c & d \\ \midrule +1 & 2 & 3 & 4 \\ +1 & 2 & 3 & 4 \\ \bottomrule +\end{NiceArray}$ +\end{BVerbatim} +$\begin{NiceArray}{|cccc|} +\toprule +a & b & c & d \\ +\midrule +1 & 2 & 3 & 4 \\ +1 & 2 & 3 & 4 \\ +\bottomrule +\end{NiceArray}$ + +\bigskip +However, it's still possible to define a specifier (named, for instance, |I|) +to draw vertical rules with the standard behaviour of \pkg{array}. + +\begin{Verbatim} +\newcolumntype{I}{!{\vrule}} +\end{Verbatim} + + +\bigskip +\subsubsection{The command \textbackslash cline} + +\label{remark-cline} +\index{cline@\texttt{\textbackslash cline} (LaTeX command)} + +The horizontal and vertical rules drawn by |\hline| and the specifier +``\verb+|+'' make the array larger or wider by a quantity equal to the width +of the rule (with \pkg{array} and also with \pkg{nicematrix}). + +\smallskip +For historical reasons, this is not the case with the command |\cline|, as +shown by the following example. + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +\setlength{\arrayrulewidth}{2pt} +\begin{tabular}{cccc} \hline +A&B&C&D \\ ~emphase#\cline{2-2}@ +A&B&C&D \\ \hline +\end{tabular} +\end{BVerbatim} +\begin{scope} +\setlength{\arrayrulewidth}{2pt} +\begin{tabular}[c]{cccc} +\hline +A&B&C&D \\ +\cline{2-2} +A&B&C&D \\ +\hline +\end{tabular} +\end{scope} + +\medskip +\index{standard-cline} +In the environments of \pkg{nicematrix}, this situation is corrected (it's +still possible to go to the standard behaviour of |\cline| with the key |standard-cline|). + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +\setlength{\arrayrulewidth}{2pt} +\begin{NiceTabular}{cccc} \hline +A&B&C&D \\ ~emphase#\cline{2}@ +A&B&C&D \\ \hline +\end{NiceTabular} +\end{BVerbatim} +\begin{scope} +\setlength{\arrayrulewidth}{2pt} +\begin{NiceTabular}[c]{cccc} +\hline +A&B&C&D \\ +\cline{2} +A&B&C&D \\ +\hline +\end{NiceTabular} +\end{scope} + +\medskip +In the environments of \pkg{nicematrix}, an instruction |\cline{|\textsl{\texttt{i}}|}| +is equivalent to |\cline{|\textsl{\texttt{i}}|-|\textsl{\texttt{i}}|}|. + + +\subsection{The thickness and the color of the rules} + +\indexcommand{arrayrulewidth} +\index{Colour!of the rules} +\index{width!subkey of ``rules''} +\index{rules (key for an environment)} + +The environments of \pkg{nicematrix} provide a key |rules/width| to set the +width (in fact the thickness) of the rules in the current environment. In +fact, this key merely sets the value of the length |\arrayrulewidth|. + +\smallskip +It's well known that \pkg{colortbl} provides the command |\arrayrulecolor| in +order to specify the color of the rules. + +\smallskip +\indexcommand{arrayrulecolor} +With \pkg{nicematrix}, it's possible to specify the color of the rules even +when \pkg{colortbl} is not loaded. For sake of compatibility, the command is +also named |\arrayrulecolor|. The environments of \pkg{nicematrix} also +provide a key |rules/color| to fix the color of the rules in the current +environment. This key sets the value locally (whereas |\arrayrulecolor| acts +globally!). + +\medskip +\begin{scope} +\hfuzz=10cm +\begin{BVerbatim}[baseline=c,boxwidth=9.5cm] +\begin{NiceTabular}{|ccc|}[~emphase#rules/color=[gray]{0.9},rules/width=1pt@] +\hline +rose & tulipe & lys \\ +arum & iris & violette \\ +muguet & dahlia & souci \\ +\hline +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{|ccc|}[rules/color=[gray]{0.9},rules/width=1pt] +\hline +rose & tulipe & lys \\ +arum & iris & violette \\ +muguet & dahlia & souci \\ +\hline +\end{NiceTabular} +\end{scope} + + + +\subsection{The tools of nicematrix for the rules} + +Here are the tools provided by \pkg{nicematrix} for the rules. +\begin{itemize} +\item the keys |hlines|, |vlines|, |hvlines| and |hvlines-except-borders|; +\item the specifier ``\verb+|+'' in the preamble (for the environments with +preamble); +\item \indexcommand{Hline} +the command |\Hline|. +\end{itemize} + +\medskip +\textbf{All these tools don't draw the rules in the blocks nor in the +empty corners (when the key |corners| is used), nor in the exterior rows and +columns.} +\begin{itemize} +\item These blocks are: +\begin{itemize} +\item the blocks created by the command |\Block|\footnote{And also the command |\multicolumn| but +it's recommended to use instead |\Block| in the environments of +\pkg{nicematrix}.} presented +p.~\pageref{Block}; +\item the blocks implicitely delimited by the continuous dotted lines created +by |\Cdots|, |\Vdots|, etc. (cf.~p.~\pageref{Cdots}). +\end{itemize} +\item The corners are created by the key |corners| explained below (see +p.~\pageref{corners}). +\item For the exterior rows and columns, see~p.~\pageref{exterior}. +\end{itemize} + +In particular, this remark explains the difference between the standard +command |\hline| and the command |\Hline| provided by \pkg{nicematrix}. + +The key |\Hline| takes in an optional argument (between square brackets) which +is a list of \textsl{key=value} pairs. For the description of those keys, see +|custom-line| on p.~\pageref{custom-line}. + +\subsubsection{The keys hlines and vlines} + +\index{hlines|see{Rules}} +\index{hlines!key for an environment} +\index{vlines|see{Rules}} +\index{vlines!key for an environment} + +The keys |hlines| and |vlines| (which draw, of course, horizontal and vertical +rules) take in as value a list of numbers which are the numbers of the rules +to draw.\footnote{It's possible to put in that list some intervals of integers +with the syntax $i$|-|$j$.} + +In fact, for the environments with delimiters (such as |{pNiceMatrix}| or +|{bNiceArray}|), the key |vlines| don't draw the exterior rules (this is +certainly the expected behaviour). + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=10.6cm] +$\begin{pNiceMatrix}[~emphase#vlines@,rules/width=0.2pt] +1 & 2 & 3 & 4 & 5 & 6 \\ +1 & 2 & 3 & 4 & 5 & 6 \\ +1 & 2 & 3 & 4 & 5 & 6 +\end{pNiceMatrix}$ +\end{BVerbatim} +$\begin{pNiceMatrix}[vlines,rules/width=0.2pt] +1 & 2 & 3 & 4 & 5 & 6 \\ +1 & 2 & 3 & 4 & 5 & 6 \\ +1 & 2 & 3 & 4 & 5 & 6 +\end{pNiceMatrix}$ + + + +\subsubsection{The keys hvlines and hvlines-except-borders} +\label{hvlines} + +\index{hvlines|see{Rules}} +\index{hvlines!key for an environment} +\index{hvlines-except-borders} + + +The key |hvlines| (no value) is the conjonction of the keys |hlines| and |vlines|. + +\smallskip +\begin{Verbatim} +\setlength{\arrayrulewidth}{1pt} +\begin{NiceTabular}{cccc}[~emphase#hvlines@,rules/color=blue] +rose & tulipe & marguerite & dahlia \\ +violette & \Block[draw=red]{2-2}{\LARGE fleurs} & & souci \\ +pervenche & & & lys \\ +arum & iris & jacinthe & muguet +\end{NiceTabular} +\end{Verbatim} + +\begin{center} +\setlength{\arrayrulewidth}{1pt} +\begin{NiceTabular}{cccc}[hvlines,rules/color=blue] +rose & tulipe & marguerite & dahlia \\ +violette & \Block[draw=red]{2-2}{\LARGE fleurs} & & souci \\ +pervenche & & & lys \\ +arum & iris & jacinthe & muguet +\end{NiceTabular} +\end{center} + +\bigskip +It's worth noting that, when the key |rounded-corners| is used for the +environment |{NiceTabular}|, the key |hvlines| draws rounded corners for the +exterior frame of the tabular: cf. part~\ref{tabular-rounded-corners}, +p.~\pageref{tabular-rounded-corners}. + +\bigskip +The key |hvlines-except-borders| is similar to the key |hvlines| but does not +draw the rules on the horizontal and vertical borders of the array. For an +example of use of that key, see the part ``Use with tcolorbox'', +p.~\pageref{tcolorbox}. + +\subsubsection{The (empty) corners} + +\label{corners} +\index{Corners (the empty ---)} +\index{corners (key of an environment)} + +The four |corners| of an array will be designed by |NW|, |SW|, |NE| and |SE| +(\emph{north west}, \emph{south west}, \emph{north east} and \emph{south east}). + +For each of these corners, we will call \emph{empty corner} (or simply +\emph{corner}) the reunion of all the empty rectangles starting from the cell +actually in the corner of the array.\footnote{For sake of completeness, we +should also say that a cell contained in a block (even an empty cell) is not +taken into account for the determination of the corners. That behaviour is +natural. The precise definition of a ``non-empty cell'' is given below (cf. +p.~\pageref{empty-cells}).} + +However, it's possible, for a cell without content, to require \pkg{nicematrix} +to consider that cell as not empty with the key |\NotEmpty|. + +\bigskip +\begin{minipage}{9cm} +In the example on the right (where B is in the center of a block of size +$2\times2$), we have colored in blue the four (empty) corners of the array. +\end{minipage}\hspace{2cm}% +\begin{NiceTabular}{*{6}{c}}[cell-space-top-limit=3pt] +\CodeBefore + \rectanglecolor{blue!10}{1-1}{4-2} + \rectanglecolor{blue!10}{1-1}{1-4} + \rectanglecolor{blue!10}{1-6}{3-6} + \rectanglecolor{blue!10}{7-1}{9-1} + \rectanglecolor{blue!10}{7-5}{9-6} +\Body + & & & & A \\ + & & A & A & A \\ + & & & A \\ + & & A & A & A & A \\ +A & A & A & A & A & A \\ +A & A & A & A & A & A \\ + & A & A & A \\ + & \Block{2-2}{B} & & A \\ + & & & A \\ +\end{NiceTabular} + +\bigskip +When the key |corners|\footnote{The key |corners| that we describe now +has no direct link with the key |rounded-corners| described in the part +\ref{tabular-rounded-corners}, p.~\pageref{tabular-rounded-corners}} is used, +\pkg{nicematrix} computes the (empty) corners and these corners will be taken +into account by the tools for drawing the rules (the rules won't be drawn in +the corners). + +\bigskip +\begin{BVerbatim}[boxwidth=11cm,baseline=c] +\NiceMatrixOptions{cell-space-top-limit=3pt} +\begin{NiceTabular}{*{6}{c}}[~emphase#corners@,hvlines] + & & & & A \\ + & & A & A & A \\ + & & & A \\ + & & A & A & A & A \\ +A & A & A & A & A & A \\ +A & A & A & A & A & A \\ + & A & A & A \\ + & \Block{2-2}{B} & & A \\ + & & & A \\ +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{*{6}{c}}[corners,hvlines,cell-space-top-limit=3pt] + & & & & A \\ + & & A & A & A \\ + & & & A \\ + & & A & A & A & A \\ +A & A & A & A & A & A \\ +A & A & A & A & A & A \\ + & A & A & A \\ + & \Block{2-2}{B} & & A \\ + & & & A \\ +\end{NiceTabular} + + +\bigskip +It's also possible to provide to the key |corners| a (comma-separated) list of +corners (designed by |NW|, |SW|, |NE| and |SE|). + +\medskip +\begin{BVerbatim}[boxwidth=11cm,baseline=c] +\NiceMatrixOptions{cell-space-top-limit=3pt} +\begin{NiceTabular}{*{6}{c}}[~emphase#corners=NE@,hvlines] +1\\ +1&1\\ +1&2&1\\ +1&3&3&1\\ +1&4&6&4&1\\ + & & & & &1 +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{*{6}{c}}[c,corners=NE,hvlines,cell-space-top-limit=3pt] +1\\ +1&1\\ +1&2&1\\ +1&3&3&1\\ +1&4&6&4&1\\ + & & & & &1 +\end{NiceTabular} + + +\medskip +$\triangleright$ The corners are also taken into account by the tools provided +by \pkg{nicematrix} to color cells, rows and columns. These tools don't color +the cells which are in the corners (cf.~p.~\pageref{color-in-code-before}). + +\subsection{The command \textbackslash diagbox} + +\indexcommand{diagbox} + +The command |\diagbox| (inspired by the package \pkg{diagbox}), allows, when +it is used in a cell, to slash that cell diagonally downwards. + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +$\begin{NiceArray}{*{5}{c}}[hvlines] +~emphase#\diagbox{x}{y}@ & e & a & b & c \\ +e & e & a & b & c \\ +a & a & e & c & b \\ +b & b & c & e & a \\ +c & c & b & a & e +\end{NiceArray}$ +\end{BVerbatim} +$\begin{NiceArray}{*{5}{c}}[hvlines] +\diagbox{x}{y} & e & a & b & c \\ +e & e & a & b & c \\ +a & a & e & c & b \\ +b & b & c & e & a \\ +c & c & b & a & e +\end{NiceArray}$ + +\medskip +It's possible to use the command |\diagbox| in a |\Block|. + + + + +\subsection{Commands for customized rules} + +\label{custom-line} +\index{command (key of ``custom-line'')} +\index{ccommand (key of ``custom-line'')} +\index{letter (key of ``custom-line'')} +\index{custom-line|(} + + +It's also possible to define commands and letters for customized rules with +the key |custom-line| available in |\NiceMatrixOptions| and in the options of +individual environments. That key takes in as argument a list of +\textsl{key=value} pairs. First, there is three keys to define the tools which +will be used to use that new type of rule. + +\begin{itemize} +\item the key |command| is the name (without the backslash) of a command that +will be created by \pkg{nicematrix} and that will be available for the final +user in order to draw horizontal rules (similarly to |\hline|); + +\item the key |ccommand| is the name (without the backslash) of a command +that will be created by \pkg{nicematrix} and that will be available for the +final user to order to draw partial horizontal rules (similarly to |\cline|, +hence the name |ccommand|): the argument of that command is a list of +intervals of columns specified by the syntax~$i$ or $i$-$j$.\footnote{It's +recommended to use such commands only once in a row because each use will +create space between the rows corresponding to the total width of the rule.} + +\item the key |letter| takes in as argument a letter\footnote{The following +letters are forbidden: \verb+lcrpmbVX|()[]!@<>+} that the user will use in +the preamble of an environment with preamble (such as |{NiceTabular}| in order +to specify a vertical rule. +\end{itemize} + +\bigskip +We will now speak of the keys which describe the rule itself. Those keys may +also be used in the (optional) argument of an individual command |\Hline|. + +There is three possibilities. + +\begin{itemize} +\item \emph{First possibility}\par\nobreak + +It's possible to specify composite rules, with a color and a color for the +inter-rule space (as possible with \pkg{colortbl} for instance). + +\begin{itemize} +\index{multiplicity (key of ``custom-line'')} +\index{color!key of ``custom-line''} +\index{sep-color (key of ``custom-line'')} +\item the key |multiplicity| is the number of consecutive rules that will be +drawn: for instance, a value of $2$ will create double rules such those +created by |\hline\hline| or \verb+||+ in the preamble of an environment; + +\item the key |color| sets the color of the rules ; + +\item the key |sep-color| sets the color between two successive rules (should be +used only in conjonction with |multiplicity|). +\end{itemize} + +\medskip +That system may be used, in particular, for the definition of commands and +letters to draw rules with a specific color (and those rules will respect the +blocks and corners as do all the rules of \pkg{nicematrix}). + +\medskip +\begin{Verbatim} +\begin{NiceTabular}{lcIcIc}~emphase#[custom-line = {letter=I, color=blue}]@ +\hline + & \Block{1-3}{dimensions} \\ + & L & l & h \\ +\hline +Product A & 3 & 1 & 2 \\ +Product B & 1 & 3 & 4 \\ +Product C & 5 & 4 & 1 \\ +\hline +\end{NiceTabular} +\end{Verbatim} + + +\begin{center} +\begin{NiceTabular}{lcIcIc}[custom-line = {letter=I, color=blue}] +\hline + & \Block{1-3}{dimensions} \\ + & L & l & H \\ +\hline +Product A & 3 & 1 & 2 \\ +Product B & 1 & 3 & 4 \\ +Product C & 5 & 4 & 1 \\ +\hline +\end{NiceTabular} +\end{center} + + +\bigskip +\item \emph{Second possibility}\par\nobreak + +\index{tikzz@tikz!key of ``custom-line''} +\index{total-width (key of ``custom-line'')} + +It's possible to use the key |tikz| (if Tikz is loaded). In that case, the +rule is drawn directly with Tikz by using as parameters the value of the key +|tikz| which must be a list of \textsl{key=value} pairs which may be applied +to a Tikz path. + +By default, no space is reserved for the rule that will be drawn with Tikz. It +is possible to specify a reservation (horizontal for a vertical rule and +vertical for an horizontal one) with the key |total-width|. That value of that +key, is, in some ways, the width of the rule that will be drawn +(\pkg{nicematrix} does not compute that width from the characteristics of the +rule specified in |tikz|). + + + +\bigskip +Here is an example with the key |dotted| of Tikz. + +\begin{BVerbatim}[boxwidth=9cm,baseline=c] +\NiceMatrixOptions + { + custom-line = + { + letter = I , + ~emphase#tikz = dotted@ , + ~emphase#total-width = \pgflinewidth@ + } + } + +\begin{NiceTabular}{cIcIc} +one & two & three \\ +four & five & six \\ +seven & eight & nine +\end{NiceTabular} +\end{BVerbatim} +\begin{scope} +\NiceMatrixOptions + { + custom-line = + { + letter = I , + tikz = dotted , + total-width = \pgflinewidth + } + } +\begin{NiceTabular}{cIcIc} +one & two & three \\ +four & five & six \\ +seven & eight & nine +\end{NiceTabular} +\end{scope} + +\bigskip +\item \emph{Third possibility} : the key |dotted| +\label{dotted} +\index{dotted (key of ``custom-line'')} +\indexcommand{hdottedline} +\indexcommand{cdottedline} + +As one can see, the dots of a dotted line of Tikz have the shape of a square, +and not a circle. That's why the extension \pkg{nicematrix} provides in the +key |custom-line| a key |dotted| which will draw rounded dots. The initial +value of the key |total-width| is, in this case, equal to the diameter of the dots +(but the user may change the value with the key |total-width| if needed). Those +dotted rules are also used by \pkg{nicematrix} to draw continuous dotted rules +between cells of the matrix with |\Cdots|, |\Vdots|, etc. (cf. p.~\pageref{Cdots}). + +In fact, \pkg{nicematrix} defines by default the commands |\hdottedline| and +|\cdottedline |and the letter ``|:|'' for those dotted +rules.\footnote{However, it's possible to overwrite those definitions with a +|custom-line| (in order, for example, to switch to dashed lines).} + +\smallskip +\begin{BVerbatim} + +\NiceMatrixOptions % ~textsl#present in nicematrix.sty@ + { + custom-line = + { + letter = : , + command = hdottedline , + ccommand = cdottedline , + ~emphase#dotted@ + } + } +\end{BVerbatim} + +Thus, it's possible to use the commands |\hdottedline| and |\cdottedline |to +draw horizontal dotted rules. + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=9.5cm] +\begin{pNiceMatrix} +1 & 2 & 3 & 4 & 5 \\ +~emphase#\hdottedline@ +6 & 7 & 8 & 9 & 10 \\ +~emphase#\cdottedline{1,4-5}@ +11 & 12 & 13 & 14 & 15 +\end{pNiceMatrix} +\end{BVerbatim} +$\begin{pNiceMatrix} +1 & 2 & 3 & 4 & 5 \\ +\hdottedline +6 & 7 & 8 & 9 & 10 \\ +\cdottedline{1,4-5} +11 & 12 & 13 & 14 & 15 +\end{pNiceMatrix}$ + + +\bigskip +In the environments with an explicit preamble (like |{NiceTabular}|, +|{NiceArray}|, etc.), it's possible to draw a vertical dotted line with the +specifier ``|:|''. + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=9.5cm] +\left(\begin{NiceArray}{cccc~emphase#:@c} +1 & 2 & 3 & 4 & 5 \\ +6 & 7 & 8 & 9 & 10 \\ +11 & 12 & 13 & 14 & 15 +\end{NiceArray}\right) +\end{BVerbatim} +$\left(\begin{NiceArray}{cccc:c} +1 & 2 & 3 & 4 & 5 \\ +6 & 7 & 8 & 9 & 10 \\ +11 & 12 & 13 & 14 & 15 +\end{NiceArray}\right)$ + +\end{itemize} + +\index{custom-line|)} +\index{Rules@\textbf{Rules in the tabulars}|)} + + +\section{The color of the rows and columns} + +\index{Colour!of the cells} + +\subsection{Use of colortbl} + +\index{colortbl@\pkg{colortbl} (package)} + +We recall that the package \pkg{colortbl} can be loaded directly with +|\usepackage{colortbl}| or by loading \pkg{xcolor} with the key |table|: +|\usepackage[table]{xcolor}|. + +\medskip +Since the package \pkg{nicematrix} is based on \pkg{array}, it's possible to +use \pkg{colortbl} with \pkg{nicematrix}. + +\medskip +However, there is two drawbacks: +\begin{itemize} +\item The package \pkg{colortbl} patches \pkg{array}, leading to some +incompatibilities (for instance with the command |\hdotsfor|). + +\item The package \pkg{colortbl} constructs the array row by row, alterning +colored rectangles, rules and contents of the cells. The resulting +\textsc{pdf} is difficult to interpret by some \textsc{pdf} viewers and may +lead to artefacts on the screen. +\begin{itemize} +\item Some rules seem to disappear. This is because many PDF viewers give +priority to graphical element drawn posteriorly (which is in the spirit of the +``painting model'' of PostScript and PDF). Concerning this problem, MuPDF +(which is used, for instance, by SumatraPDF) gives better results than Adobe +Reader). +\item A thin white line may appear between two cells of the same color. This +phenomenon occurs when each cell is colored with its own instruction |fill| +(the PostScript operator |fill| noted |f| in PDF). This is the case with +\pkg{colortbl}: each cell is colored on its own, even when |\columncolor| or +|\rowcolor| is used. + +As for this phenomenon, Adobe Reader gives better results than MuPDF. +\end{itemize} + +The package \pkg{nicematrix} provides tools to avoid those problems. +\end{itemize} + +\subsection{The tools of nicematrix in the \textbackslash CodeBefore} + +\label{color-in-code-before} +\index{code-before!key for an environment} +\index{CodeBefore@\texttt{\textbackslash CodeBefore}...\texttt{\textbackslash Body}} +\index{Body@\texttt{\textbackslash Body}|see{\texttt{\textbackslash CodeBefore}}} + +The package \pkg{nicematrix} provides some tools (independent of \pkg{colortbl}) +to draw the colored panels first, and, then, the content of the cells and the +rules. This strategy is more conform to the ``painting model'' of the formats +PostScript and \textsc{pdf} and is more suitable for the \textsc{pdf} viewers. +However, it requires several compilations.\footnote{If you use Overleaf, + Overleaf will do automatically a sufficient number of compilations.} + +\medskip +The extension \pkg{nicematrix} provides a key |code-before| for some code that +will be executed before the drawing of the tabular. + +\medskip +An alternative syntax is provided: it's possible to put the content of that +|code-before| between the keywords |\CodeBefore| and |\Body| at the beginning +of the environment. + +\begin{Verbatim} +\begin{pNiceArray}{~textsl#preamble@} +~emphase#\CodeBefore [~textsl#options@]@ + ~textsl#instructions of the code-before@ +~emphase#\Body@ + ~textsl#contents of the environment@ +\end{pNiceArray} +\end{Verbatim} + +\smallskip +The optional argument between square brackets is a list of \textsl{key=value} +pairs which will be presented progressively in this +documentation.\footnote{The available keys are |create-cell-nodes|, +|sub-matrix| (and its subkeys) and \texttt{delimiters-color}.} + +\medskip +New commands are available in that |\CodeBefore|: |\cellcolor|, +|\rectanglecolor|, |\rowcolor|, |\columncolor|, |\rowcolors|, +|\rowlistcolors|, |\chessboardcolors| and |\arraycolor|.\footnote{Remark that, +in the |\CodeBefore|, PGF/Tikz nodes of the form ``\verb+(i-|j)+'' are +also available to indicate the position to the potential rules: +cf.~p.~\pageref{nodes-i}.} +\label{code-before} + +\index{cellcolor@\texttt{\textbackslash cellcolor}!command of + \texttt{\textbackslash CodeBefore}} +\index{rectanglecolor@\texttt{\textbackslash rectanglecolor} (command of + \texttt{\textbackslash CodeBefore})} +\index{rowcolor@\texttt{\textbackslash rowcolor}!command of \texttt{\textbackslash CodeBefore}} +\index{columncolor@\texttt{\textbackslash columncolor}!command of + \texttt{\textbackslash CodeBefore}} +\index{rowcolors@\texttt{\textbackslash rowcolors} (command of \texttt{\textbackslash CodeBefore})} +\index{rowlistcolor@\texttt{\textbackslash rowlistcolors} (command of + \texttt{\textbackslash CodeBefore})} +\index{chessboardcolors@\texttt{\textbackslash chessboardcolors}!(commande + du \texttt{\textbackslash CodeBefore})} +\index{arraycolor@\texttt{\textbackslash arraycolor} (command of \texttt{\textbackslash + CodeBefore)}} + +\medskip +These commands don't color the cells which are in the ``corners'' if the key +|corners| is used. That key has been described p.~\pageref{corners}. + +\medskip +These commands respect the rounded corners if the key |rounded-corners| +(described in the part \ref{tabular-rounded-corners} at the +page~\pageref{tabular-rounded-corners}) has been used. + +\medskip +All these commands accept an optional argument, between square brackets and +in first position. That optional argument may contain two elements (separated +by a comma) +\begin{itemize} +\item the colorimetric space (|RGB|, |rgb|, |HTML|, etc) as specified by the +the extension \pkg{xcolor}; +\item \index{opacity (key of commands such as\newline \texttt{\textbackslash rowcolor}, etc.)} +\colorbox{yellow!50}{\textbf{New 6.18}}\par\nobreak +a specification of opacity f the form \texttt{opacity = \textsl{value}}. +\end{itemize} + +\bigskip + +We describe now in detail those commands. + +\medskip +\begin{itemize} +\item The command \Definition{\textbackslash cellcolor} takes its name from +the command |\cellcolor| of \pkg{colortbl}. + +This command takes in as mandatory arguments a color and a list of cells, each +of which with the format $i$-$j$ where $i$ is the number of the row and $j$ the +number of the colummn of the cell. In fact, despite its name, this command may +be used to color a whole row (with the syntax $i$-) or a whole column (with the +syntax -$j$). + +\medskip +\begin{scope} +\hfuzz=10cm +\begin{BVerbatim}[boxwidth=10cm,baseline=c] +\begin{NiceTabular}{ccc}[hvlines] +\CodeBefore + ~emphase#\cellcolor[HTML]{FFFF88}{3-1,2-2,-3}@ +\Body +a & b & c \\ +e & f & g \\ +h & i & j \\ +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{ccc}[hvlines] +\CodeBefore + \cellcolor[HTML]{FFFF88}{3-1,2-2,-3} +\Body +a & b & c \\ +e & f & g \\ +h & i & j \\ +\end{NiceTabular} +\end{scope} + +\bigskip +\item The command \Definition{\textbackslash rectanglecolor} takes three +mandatory arguments. The first is the color. The second is the upper-left cell +of the rectangle and the third is the lower-right cell of the rectangle. + +\medskip +\begin{scope} +\hfuzz=10cm +\begin{BVerbatim}[boxwidth=10cm,baseline=c] +\begin{NiceTabular}{ccc}[hvlines] +\CodeBefore + ~emphase#\rectanglecolor{blue!15}{2-2}{3-3}@ +\Body +a & b & c \\ +e & f & g \\ +h & i & j \\ +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{ccc}[hvlines] +\CodeBefore + \rectanglecolor{blue!15}{2-2}{3-3} +\Body +a & b & c \\ +e & f & g \\ +h & i & j \\ +\end{NiceTabular} +\end{scope} + +\bigskip +\item The command \Definition{\textbackslash arraycolor} takes in as mandatory +argument a color and color the whole tabular with that color (excepted the +potential exterior rows and columns: cf.~p.~\pageref{exterior}). It's only a +particular case of |\rectanglecolor|. + + +\bigskip +\item The command \Definition{\textbackslash chessboardcolors} takes in as +mandatory arguments two colors and it colors the cells of the tabular in +quincunx with these colors. + +\medskip +\begin{scope} +\hfuzz=10cm +\begin{BVerbatim}[baseline=c,boxwidth=9cm] +$\begin{pNiceMatrix}[r,margin] +\CodeBefore + ~emphase#\chessboardcolors{red!15}{blue!15}@ +\Body +1 & -1 & 1 \\ +-1 & 1 & -1 \\ +1 & -1 & 1 +\end{pNiceMatrix}$ +\end{BVerbatim} +$\begin{pNiceMatrix}[r,baseline=1, margin] +\CodeBefore +\chessboardcolors{red!15}{blue!15} +\Body +1 & -1 & 1 \\ +-1 & 1 & -1 \\ +1 & -1 & 1 +\end{pNiceMatrix}$ +\end{scope} + +\medskip +We have used the key |r| which aligns all the columns rightwards (cf. +p.~\pageref{columns-width}). + + +\bigskip +\item The command \Definition{\textbackslash rowcolor} takes its name from the +command |\rowcolor| of \pkg{colortbl}. Its first mandatory argument is the +color and the second is a comma-separated list of rows or interval of rows +with the form $a$-$b$ (an interval of the form $a$- represent all the rows +from the row $a$ until the end). + +\medskip +\begin{scope} +\hfuzz = 10cm +\begin{BVerbatim}[boxwidth=9cm,baseline=c] +$\begin{NiceArray}{lll}[hvlines] +\CodeBefore + ~emphase#\rowcolor{red!15}{1,3-5,8-}@ +\Body +a_1 & b_1 & c_1 \\ +a_2 & b_2 & c_2 \\ +a_3 & b_3 & c_3 \\ +a_4 & b_4 & c_4 \\ +a_5 & b_5 & c_5 \\ +a_6 & b_6 & c_6 \\ +a_7 & b_7 & c_7 \\ +a_8 & b_8 & c_8 \\ +a_9 & b_9 & c_9 \\ +a_{10} & b_{10} & c_{10} \\ +\end{NiceArray}$ +\end{BVerbatim} +$\begin{NiceArray}{lll}[baseline=4,hvlines] +\CodeBefore +\rowcolor{red!15}{1,3-5,8-} +\Body +a_1 & b_1 & c_1 \\ +a_2 & b_2 & c_2 \\ +a_3 & b_3 & c_3 \\ +a_4 & b_4 & c_4 \\ +a_5 & b_5 & c_5 \\ +a_6 & b_6 & c_6 \\ +a_7 & b_7 & c_7 \\ +a_8 & b_8 & c_8 \\ +a_9 & b_9 & c_9 \\ +a_{10} & b_{10} & c_{10} \\ +\end{NiceArray}$ +\end{scope} + + +\bigskip +\item The command \Definition{\textbackslash columncolor} takes its name from +the command |\columncolor| of \pkg{colortbl}. Its syntax is similar to the +syntax of |\rowcolor|. + +\bigskip +\item The command \Definition{\textbackslash rowcolors} (with a \emph{s}) +takes its name from the command |\rowcolors| of \pkg{colortbl}. The \emph{s} +emphasizes the fact that there is \emph{two} colors. This command colors +alternately the rows of the tabular with the two colors (provided in second +and third argument), beginning with the row whose number is given in first +(mandatory) argument. + +In fact, the first (mandatory) argument is, more generally, a comma separated +list of intervals describing the rows involved in the action of |\rowcolors| +(an interval of the form $i$|-| describes in fact the interval of all the rows +of the tabular, beginning with the row~$i$). + + +\bigskip +The last argument of |\rowcolors| is an optional list of pairs +\textsl{key=value} (the optional argument in the first position corresponds to +the colorimetric space). The available keys are |cols|, |restart| and +|respect-blocks|. + +\index{cols (key of \texttt{\textbackslash rowcolors} of \texttt{\textbackslash CodeBefore})} +\index{restart (key of \texttt{\textbackslash rowcolors} of \texttt{\textbackslash CodeBefore})} +\index{respect-blocks (key of \texttt{\textbackslash rowcolors} du\newline \texttt{\textbackslash CodeBefore})} + +\begin{itemize} +\item The key |cols| describes a set of columns. The command |\rowcolors| will +color only the cells of these columns. The value is a comma-separated list of +intervals of the form $i$-$j$ (where $i$ or $j$ may be replaced by |*|). +\item With the key |restart|, each interval of rows (specified by the first +mandatory argument) begins with the same color.\footnote{Otherwise, the color +of a given row relies only upon the parity of its absolute number.} +\item With the key |respect-blocks| the ``rows'' alternately colored may extend over +several rows if they have to incorporate blocks (created with the command +|\Block|: cf.~p.~\pageref{Block}). +\end{itemize} + +\medskip +\begin{scope} +\hfuzz=10cm +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +\begin{NiceTabular}{clr}[hvlines] +\CodeBefore + ~emphase#\rowcolors[gray]{2}{0.8}{}[cols=2-3,restart]@ +\Body +\Block{1-*}{Results} \\ +John & 12 \\ +Stephen & 8 \\ +Sarah & 18 \\ +Ashley & 20 \\ +Henry & 14 \\ +Madison & 15 +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{clr}[hvlines,baseline=2] +\CodeBefore + \rowcolors[gray]{2}{0.8}{}[cols=2-3,restart] +\Body +\Block{1-*}{Results} \\ +\Block{2-1}{A}& John & 12 \\ + & Stephen & 8 \\ +\Block{4-1}{B}& Sarah & 18 \\ + & Ashley & 20 \\ + & Henry & 14 \\ + & Madison & 15 +\end{NiceTabular} +\end{scope} + +\vspace{1cm} +\begin{scope} +\hfuzz=10cm +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +\begin{NiceTabular}{lr}[hvlines] +\CodeBefore + ~emphase#\rowcolors{1}{blue!10}{}[respect-blocks]@ +\Body +\Block{2-1}{John} & 12 \\ + & 13 \\ +Steph & 8 \\ +\Block{3-1}{Sarah} & 18 \\ + & 17 \\ + & 15 \\ +Ashley & 20 \\ +Henry & 14 \\ +\Block{2-1}{Madison} & 15 \\ + & 19 +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{lr}[hvlines,baseline=c] +\CodeBefore + \rowcolors{1}{blue!10}{}[respect-blocks] +\Body +\Block{2-1}{John} & 12 \\ + & 13 \\ +Steph & 8 \\ +\Block{3-1}{Sarah} & 18 \\ + & 17 \\ + & 15 \\ +Ashley & 20 \\ +Henry & 14 \\ +\Block{2-1}{Madison} & 15 \\ + & 19 +\end{NiceTabular} +\end{scope} + + + + +\bigskip +\item The extension \pkg{nicematrix} provides also a command +\Definition{\textbackslash rowlistcolors}. This command generalises the +command |\rowcolors|: instead of two successive arguments for the colors, this +command takes in an argument which is a (comma-separated) list of colors. In +that list, the symbol |=| represent a color identical to the previous one. + +\smallskip +\begin{BVerbatim}[boxwidth=10cm,baseline=c] +\begin{NiceTabular}{c} +\CodeBefore + ~emphase#\rowlistcolors{1}{red!15,blue!15,green!15}@ +\Body +Peter \\ +James \\ +Abigail \\ +Elisabeth \\ +Claudius \\ +Jane \\ +Alexandra \\ +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{c} +\CodeBefore + \rowlistcolors{1}{red!15,blue!15,green!15} +\Body +Peter \\ +James \\ +Abigail \\ +Elisabeth \\ +Claudius \\ +Jane \\ +Alexandra \\ +\end{NiceTabular} + +\bigskip +It's also possible to use in the command |\rowlistcolors| a color series +defined by the command |\definecolorseries| of \pkg{xcolor} (and initialized +with the command |\resetcolorseries|\footnote{For the initialization, in the +following example, you have used the counter |iRow| which, when used in the +|\CodeBefore| (and in the |\CodeAfter|) corresponds to the number of rows of +the array: cf.~p~\pageref{iRow}. That leads to an adjustement of the gradation +of the colors to the size of the tabular.}). + +\index{definecolorseries@\texttt{\textbackslash definecolorseries} (command of \pkg{xcolor})} +\index{resetcolorseries@\texttt{\textbackslash resetcolorseries} (command of \pkg{xcolor})} + +\smallskip +\begin{BVerbatim}[boxwidth=12.5cm,baseline=c] +\begin{NiceTabular}{c} +\CodeBefore + ~emphase#\definecolorseries{BlueWhite}{rgb}{last}{blue}{white}@ + ~emphase#\resetcolorseries{\value{iRow}}{BlueWhite}@ + ~emphase#\rowlistcolors{1}{BlueWhite!!+}@ +\Body +Peter \\ +James \\ +Abigail \\ +Elisabeth \\ +Claudius \\ +Jane \\ +Alexandra \\ +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{c} +\CodeBefore + \definecolorseries{BlueWhite}{rgb}{last}{blue}{white} + \resetcolorseries[\value{iRow}]{BlueWhite} + \rowlistcolors{1}{BlueWhite!!+} +\Body +Peter \\ +James \\ +Abigail \\ +Elisabeth \\ +Claudius \\ +Jane \\ +Alexandra \\ +\end{NiceTabular} +\end{itemize} + +\vspace{1cm} +We recall that all the color commands we have described don't color the cells +which are in the ``corners''. In the following example, we use the key +|corners| to require the determination of the corner \emph{north east} (NE). + +\medskip +\index{corners (key of an environment)|textit} +\begin{scope} +\hfuzz=11cm +\begin{BVerbatim}[boxwidth=9cm,baseline=c] +\begin{NiceTabular}{cccccc}[~emphase#corners=NE@,margin,hvlines,first-row,first-col] +\CodeBefore + ~emphase#\rowlistcolors{1}{blue!15, }@ +\Body + & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\ +0 & 1 \\ +1 & 1 & 1 \\ +2 & 1 & 2 & 1 \\ +3 & 1 & 3 & 3 & 1 \\ +4 & 1 & 4 & 6 & 4 & 1 \\ +5 & 1 & 5 & 10 & 10 & 5 & 1 \\ +6 & 1 & 6 & 15 & 20 & 15 & 6 & 1 \\ +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{ccccccc}[corners=NE,margin,hvlines,first-row,first-col] +\CodeBefore + \rowlistcolors{1}{blue!15, } +\Body + & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\ +0 & 1 \\ +1 & 1 & 1 \\ +2 & 1 & 2 & 1 \\ +3 & 1 & 3 & 3 & 1 \\ +4 & 1 & 4 & 6 & 4 & 1 \\ +5 & 1 & 5 & 10 & 10 & 5 & 1 \\ +6 & 1 & 6 & 15 & 20 & 15 & 6 & 1 \\ +\end{NiceTabular} +\end{scope} + + +\bigskip +One should remark that all the previous commands are compatible with the +commands of \pkg{booktabs} (|\toprule|, |\midrule|, |\bottomrule|, etc). +However, \pkg{booktabs} is \emph{not} loaded by \pkg{nicematrix}. + +\medskip +\index{rotate@\texttt{\textbackslash rotate}|textit} +\begin{scope} +\hfuzz=10cm +\begin{BVerbatim}[baseline=c,boxwidth=8.5cm] +\begin{NiceTabular}[c]{lSSSS} +\CodeBefore + \rowcolor{red!15}{1-2} + \rowcolors{3}{blue!15}{} +\Body +~emphase#\toprule@ +\Block{2-1}{Product} & +\Block{1-3}{dimensions (cm)} & & & +\Block{2-1}{\rotate Price} \\ +~emphase#\cmidrule(rl){2-4}@ + & L & l & h \\ +~emphase#\midrule@ +small & 3 & 5.5 & 1 & 30 \\ +standard & 5.5 & 8 & 1.5 & 50.5 \\ +premium & 8.5 & 10.5 & 2 & 80 \\ +extra & 8.5 & 10 & 1.5 & 85.5 \\ +special & 12 & 12 & 0.5 & 70 \\ +~emphase#\bottomrule@ +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}[c]{lSSSS} +\CodeBefore + \rowcolor{red!15}{1-2} + \rowcolors{3}{blue!15}{} +\Body +\toprule +\Block{2-1}{Product} & +\Block{1-3}{dimensions (cm)} & & & +\Block{2-1}{\rotate Price} \\ +\cmidrule(rl){2-4} + & L & l & h \\ +\midrule +small & 3 & 5.5 & 1 & 30 \\ +standard & 5.5 & 8 & 1.5 & 50.5 \\ +premium & 8.5 & 10.5 & 2 & 80 \\ +extra & 8.5 & 10 & 1.5 & 85.5 \\ +special & 12 & 12 & 0.5 & 70 \\ +\bottomrule +\end{NiceTabular} +\end{scope} + +\index{S (the columns S of \pkg{siunitx})|textit} +\medskip +We have used the type of column |S| of \pkg{siunitx}. + + +\subsection{Color tools with the syntax of colortbl} + +\index{colortbl-like} +\index{cellcolor@\texttt{\textbackslash cellcolor}!command in tabular} +\index{rowcolor@\texttt{\textbackslash rowcolor}!command in tabular} +\index{columncolor@\texttt{\textbackslash columncolor}!command in the preamble + of an environment} + + +It's possible to access the preceding tools with a syntax close to the syntax +of \pkg{colortbl}. For that, one must use the key |colortbl-like| in the +current environment.\footnote{Up to now, this key is \emph{not} available in |\NiceMatrixOptions|.} + +There are three commands available (they are inspired by \pkg{colortbl} but +are \emph{independent} of \pkg{colortbl}): +\begin{itemize} +\item |\cellcolor| which colorizes a cell;\footnote{However, this command +|\cellcolor| will delete the following spaces, which does not the command +|\cellcolor| of \pkg{colortbl}.} +\item |\rowcolor| which must be used in a cell and which colorizes the end of +the row; +\item |\columncolor| which must be used in the preamble of the environment +with the same syntax as the corresponding command of +\pkg{colortbl} (however, unlike the command |\columncolor| of \pkg{colortbl}, +this command |\columncolor| can appear within another command, itself used in the +preamble of the array). +\end{itemize} + +\smallskip +\begin{Verbatim} +\NewDocumentCommand { \Blue } { } { ~emphase#\columncolor{blue!15}@ } +\begin{NiceTabular}[colortbl-like]{>{\Blue}c>{\Blue}cc} +\toprule +~emphase#\rowcolor{red!15}@ +Last name & First name & Birth day \\ +\midrule +Achard & Jacques & 5 juin 1962 \\ +Lefebvre & Mathilde & 23 mai 1988 \\ +Vanesse & Stephany & 30 octobre 1994 \\ +Dupont & Chantal & 15 janvier 1998 \\ +\bottomrule +\end{NiceTabular} +\end{Verbatim} + + +\begin{center} +\NewDocumentCommand { \Blue } { } { \columncolor{blue!15} } +\begin{NiceTabular}[colortbl-like]{>{\Blue}c>{\Blue}cc} +\toprule +\rowcolor{red!15} +Last name & First name & Birth day \\ +\midrule +Achard & Jacques & 5 juin 1962 \\ +Lefebvre & Mathilde & 23 mai 1988 \\ +Vanesse & Stephany & 30 octobre 1994 \\ +Dupont & Chantal & 15 janvier 1998 \\ +\bottomrule +\end{NiceTabular} +\end{center} + +\section{The command \textbackslash RowStyle} + +\label{RowStyle} +\indexcommand{RowStyle} +\index{cell-space-top-limit} +\index{cell-space-bottom-limit} +\index{cell-space-limits} + + +The command |\RowStyle| takes in as argument some formatting intructions that +will be applied to each cell on the rest of the current row. + +\medskip +That command also takes in as optional argument (between square brackets) +a list of \textsl{key=value} pairs. +\begin{itemize} +\item \index{nb-rows (key of \texttt{\textbackslash RowStyle})} The key |nb-rows| sets +the number of rows to which the specifications of the current command will +apply (with the special value |*|, it will apply to all the following rows). +\item The keys |cell-space-top-limit|, |cell-space-bottom-limit| and +|cell-space-limits| are available with the same meaning that the corresponding +global keys (cf. p.~\pageref{cell-space}). +\item \index{rowcolor (key of \texttt{\textbackslash RowStyle})} +\index{color!key of \texttt{\textbackslash RowStyle}} +The key |rowcolor| sets +the color of the background and the key |color| sets the +color of the text.\footnote{The key |color| uses the command +|\color| but inserts also an instruction |\leavevmode| before. This +instruction prevents a extra vertical space in the cells which belong to +columns of type |p|, |b|, |m|, |X| and |V| (which start in +vertical mode).} +\item \index{bold (key of \texttt{\textbackslash RowStyle})} The key |bold| +enforces bold characters for the cells of the row, both in math and text mode. +\end{itemize} + +\medskip +\begin{BVerbatim}[boxwidth=12cm,baseline=c] +\begin{NiceTabular}{cccc} +\hline +~emphase#\RowStyle[cell-space-limits=3pt]{\rotate}@ +first & second & third & fourth \\ +~emphase#\RowStyle[nb-rows=2,rowcolor=blue!50,color=white]{\sffamily}@ +1 & 2 & 3 & 4 \\ +I & II & III & IV +\end{NiceTabular} +\end{BVerbatim} +\index{rotate@\texttt{\textbackslash rotate}|textit} +\begin{NiceTabular}{cccc} +\hline +\RowStyle[cell-space-limits=3pt]{\rotate} +first & second & third & fourth \\ +\RowStyle[nb-rows=2,rowcolor=blue!50,color=white]{\sffamily} +1 & 2 & 3 & 4 \\ +I & II & III & IV \\ +\end{NiceTabular} + +\medskip +The command |\rotate| is described p.~\pageref{rotate}. + +\section{The width of the columns} + +\label{width} +\index{width@\textbf{Width of the columns}|(} + +\subsection{Basic tools} + +In the environments with an explicit preamble (like |{NiceTabular}|, +|{NiceArray}|, etc.), it's possible to fix the width of a given column with +the standard letters |w|, |W|, |p|, |b| and |m| of the package \pkg{array}. + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=9cm] +\begin{NiceTabular}{~emphase#W{c}{2cm}@cc}[hvlines] +Paris & New York & Madrid \\ +Berlin & London & Roma \\ +Rio & Tokyo & Oslo +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{W{c}{2cm}cc}[hvlines] +Paris & New York & Madrid \\ +Berlin & London & Roma \\ +Rio & Tokyo & Oslo +\end{NiceTabular} + + +\bigskip +\index{columns-width} +In the environments of \pkg{nicematrix}, it's also possible to fix the \emph{minimal} +width of all the columns (excepted the potential exterior columns: cf. p.~\pageref{exterior}) directly +with the key |columns-width|. + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +$\begin{pNiceMatrix}[~emphase#columns-width = 1cm@] +1 & 12 & -123 \\ +12 & 0 & 0 \\ +4 & 1 & 2 +\end{pNiceMatrix}$ +\end{BVerbatim} +$\begin{pNiceMatrix}[columns-width = 1cm] +1 & 12 & -123 \\ +12 & 0 & 0 \\ +4 & 1 & 2 +\end{pNiceMatrix}$ + +\medskip +Note that the space inserted between two columns (equal to 2 |\tabcolsep| in +|{NiceTabular}| and to 2 |\arraycolsep| in the other environments) +is not suppressed (of course, it's possible to suppress this space by setting +|\tabcolsep| or |\arraycolsep| equal to $0$~pt before the environment). + +\bigskip +It's possible to give the special value |auto| to the option |columns-width|: +all the columns of the array will have a width equal to the widest cell of the +array.\footnote{The result is achieved with only one compilation (but PGF/Tikz +will have written informations in the |aux| file and a message requiring a +second compilation will appear).}\par\nobreak + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +$\begin{pNiceMatrix}[~emphase#columns-width = auto@] +1 & 12 & -123 \\ +12 & 0 & 0 \\ +4 & 1 & 2 +\end{pNiceMatrix}$ +\end{BVerbatim} +$\begin{pNiceMatrix}[columns-width = auto] +1 & 12 & -123 \\ +12 & 0 & 0 \\ +4 & 1 & 2 +\end{pNiceMatrix}$ + +\bigskip +Without surprise, it's possible to fix the minimal width of the columns of all +the arrays of a current scope with the command +|\NiceMatrixOptions|.\par\nobreak + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=8.5cm] +~emphase#\NiceMatrixOptions{columns-width=10mm}@ +$\begin{pNiceMatrix} +a & b \\ c & d +\end{pNiceMatrix} += +\begin{pNiceMatrix} +1 & 1245 \\ 345 & 2 +\end{pNiceMatrix}$ +\end{BVerbatim} +\begin{scope} +\NiceMatrixOptions{columns-width=10mm} +$\begin{pNiceMatrix} +a & b \\ +c & d +\end{pNiceMatrix} += +\begin{pNiceMatrix} +1 & 1245 \\ +345 & 2 +\end{pNiceMatrix}$ +\end{scope} + + +\bigskip +\index{NiceMatrixBlock@\texttt{\{NiceMatrixBlock\}}} +\index{auto-columns-width!(key of \texttt{\{NiceMatrixBlock\}})} +It's also possible to fix a zone where all the matrices will have their +columns of the same width, equal to the widest cell of all the matrices. This +construction uses the environment |{NiceMatrixBlock}| with the option +|auto-columns-width|\footnote{At this time, this is the only usage of the +environment |{NiceMatrixBlock}| but it may have other usages in the future.}. +The environment |{NiceMatrixBlock}| has no direct link with the command +|\Block| presented previously in this document (cf.~p.~\pageref{Block}). + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=8.5cm] +~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@ +$\begin{array}{c} +\begin{bNiceMatrix} + 9 & 17 \\ -2 & 5 + \end{bNiceMatrix} \\ \\ +\begin{bNiceMatrix} + 1 & 1245345 \\ 345 & 2 +\end{bNiceMatrix} +\end{array}$ +~emphase#\end{NiceMatrixBlock}@ +\end{BVerbatim} +\begin{NiceMatrixBlock}[auto-columns-width] +$\begin{array}{c} +\begin{bNiceMatrix} + 9 & 17 \\ -2 & 5 + \end{bNiceMatrix} \\ \\ +\begin{bNiceMatrix} + 1 & 1245345 \\ 345 & 2 +\end{bNiceMatrix} +\end{array}$ +\end{NiceMatrixBlock} + +\subsection{The columns X} + +\label{X-columns} +\index{tabularx@\pkg{tabularx} (package)} +\index{NiceTabularX@\texttt{\{NiceTabularX\}}} +\index{X (the columns X)} +\index{width!key of \texttt{\{NiceTabular\}}} + +The environment |{NiceTabular}| provides |X| columns similar to those provided +by the environment |{tabularx}| of the eponymous package. + +The required width of the tabular may be specified with the key |width| (in +|{NiceTabular}| or in |\NiceMatrixOptions|). The initial value of this +parameter is |\linewidth| (and not |\textwidth|). + +For sake of similarity with the environment |{tabularx}|, \pkg{nicematrix} +also provides an environment |{NiceTabularX}| with a syntax similar to the +syntax of |{tabularx}|, that is to say with a first mandatory argument +which is the width of the tabular.\footnote{If \pkg{tabularx} is loaded, one +must use |{NiceTabularX}| (and not |{NiceTabular}|) in order to use the +columns |X| (this point comes from a conflict in the definitions of the +specifier |X|).} + +As with the packages \pkg{tabu}\footnote{The extension \pkg{tabu} is now +considered as deprecated.} and \pkg{tabularray}, the specifier |X| takes +in an optional argument (between square brackets) which is a list of keys. +\begin{itemize} +\item It's possible to give a weight for the column by providing a positive +integer directly as argument of the specifier |X|. For example, a column +|X[2]| will have a width double of the width of a column~|X| (which has a +weight equal to $1$).\footnote{The negative values of the weight, as provided +by \pkg{tabu} (which is now obsolete), are \emph{not} supported by \pkg{nicematrix}. +If such a value is used, an error will be raised.} +\item It's possible to specify an horizontal alignment with one of the +letters |l|, |c| and |r| (which insert respectively |\raggedright|, +|\centering| and |\raggedleft| followed by |\arraybackslash|). +\item It's possible to specify a vertical alignment with one of the keys +|t| (alias |p|), |m| and |b| (which construct respectively columns of type +|p|, |m| and |b|). The default value is |t|. +\end{itemize} + +\begin{Verbatim} +\begin{NiceTabular}~emphase#[width=9cm]{X[2,l]X[l]}@[hvlines] +a rather long text which fits on several lines +& a rather long text which fits on several lines \\ +a shorter text & a shorter text +\end{NiceTabular} +\end{Verbatim} + +\begin{center} +\begin{NiceTabular}[width=9cm]{X[2,l]X[l]}[hvlines] +a rather long text which fits on several lines +& a rather long text which fits on several lines \\ +a shorter text & a shorter text +\end{NiceTabular} +\end{center} + + +\subsection{The columns V of varwidth} + +\label{varwidth} +\index{varwidth@\pkg{varwidth} (package)} +\index{V (the columns V of \pkg{varwidth})} + + +Let's recall first the behaviour of the environment |{varwidth}| of the +eponymous package \pkg{varwidth}. That environment is similar to the classical +environment |{minipage}| but the width provided in the argument is only the +\emph{maximal} width of the created box. In the general case, the width of the +box constructed by an environment |{varwidth}| is the natural width of its +contents. + +\medskip +That point is illustrated on the following examples. + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=6cm] +\fbox{% +\begin{~emphase#varwidth@}{8cm} +\begin{itemize} +\item first item +\item second item +\end{itemize} +\end{~emphase#varwidth@}} +\end{BVerbatim} +\fbox{\begin{varwidth}{8cm} +\begin{itemize} +\item first item +\item second item +\end{itemize} +\end{varwidth}} + +\bigskip +\begin{BVerbatim}[baseline=c,boxwidth=6cm] +\fbox{% +\begin{~emphase#minipage@}{8cm} +\begin{itemize} +\item first item +\item second item +\end{itemize} +\end{~emphase#minipage@}} +\end{BVerbatim} +\fbox{\begin{minipage}{8cm} +\begin{itemize} +\item first item +\item second item +\end{itemize} +\end{minipage}} + + +\bigskip +The package \pkg{varwidth} provides also the column type |V|. A column of type +|V{|$\langle$\textsl{dim}$\rangle$|}| encapsulates all its cells in a +|{varwidth}| with the argument $\langle$\textsl{dim}$\rangle$ (and does also some tuning). + +\smallskip +When the package \pkg{varwidth} is loaded, the columns |V| of \pkg{varwidth} +are supported by \pkg{nicematrix}. + +\medskip +\begin{Verbatim} +\begin{NiceTabular}[corners=NW,hvlines]{~emphase#V{3cm}V{3cm}V{3cm}@} +& some text & some very very very long text \\ +some very very very long text \\ +some very very very long text +\end{NiceTabular} +\end{Verbatim} + +\medskip +\begin{center} +\begin{NiceTabular}[corners=NW,hvlines]{V{3cm}V{3cm}V{3cm}} +& some text & some very very very long text \\ +some very very very long text \\ +some very very very long text +\end{NiceTabular} +\end{center} + +\bigskip +Concerning \pkg{nicematrix}, one of the +interests of this type of columns is that, for a cell of a column of type~|V|, +the PGF/Tikz node created by \pkg{nicematrix} for the content of that cell has +a width adjusted to the content of the cell : cf. p.~\pageref{node-V}. + + +\bigskip +The columns |V| of \pkg{nicematrix} supports the keys |t|, |p|, |m|, |b|, |l|, +|c| and |r| also supported by the columns |X|: see their description in the +section~\ref{X-columns}, p.~\pageref{X-columns}. + +\bigskip +One should remark that the extension \pkg{varwidth} (at least in its version +0.92) has some problems: for instance, with LuaLaTeX, it does not work when +the content begins with |\color|. + +\index{width@\textbf{Width of the columns}|)} + + +\bigskip +\section{The exterior rows and columns} + +\index{first-row} +\index{last-row} +\index{first-col} +\index{last-col} + +The options |first-row|, |last-row|, |first-col| and |last-col| allow the +composition of exterior rows and columns in the environments of +\pkg{nicematrix}. It's particularly interesting for the (mathematical) +matrices. +\label{exterior} + +A potential ``first row'' (exterior) has the number $0$ (and not $1$). Idem +for the potential ``first column''. + +\begin{Verbatim} +$\begin{pNiceMatrix}[~emphase#first-row,last-row,first-col,last-col@,nullify-dots] + & C_1 & \Cdots & & C_4 & \\ +L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\ +\Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\ + & a_{31} & a_{32} & a_{33} & a_{34} & \\ +L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\ + & C_1 & \Cdots & & C_4 & +\end{pNiceMatrix}$ +\end{Verbatim} + +\[\begin{pNiceMatrix}[first-row,last-row,first-col,last-col,nullify-dots] + & C_1 & \Cdots & & C_4 & \\ +L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\ +\Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\ + & a_{31} & a_{32} & a_{33} & a_{34} & \\ +L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\ + & C_1 & \Cdots & & C_4 & +\end{pNiceMatrix}\] + +\medskip +The dotted lines have been drawn with the tools presented p.~\pageref{Cdots}. + +\bigskip +We have several remarks to do. +\begin{itemize}[beginpenalty=10000] +\item For the environments with an explicit preamble (i.e. |{NiceTabular}|, +|{NiceArray}| and its variants), no letter must be given in that preamble for +the potential first column and the potential last column: they will +automatically (and necessarily) be of type |r| for the first column and |l| +for the last one.\footnote{The users wishing exterior columns with another +type of alignment should consider the command |\SubMatrix| available in the +|\CodeAfter| (cf.~p.~\pageref{sub-matrix}).} +\item One may wonder how \pkg{nicematrix} determines the number of rows and +columns which are needed for the composition of the ``last row'' and ``last +column''. +\begin{itemize} +\item For the environments with explicit preamble, like |{NiceTabular}| and +|{pNiceArray}|, the number of columns can obviously be computed from the +preamble. + +\item When the option |light-syntax| (cf. p. \pageref{light-syntax}) is used, +\pkg{nicematrix} has, in any case, to load the whole body of the environment +(and that's why it's not possible to put verbatim material in the array with +the option |light-syntax|). The analysis of this whole body gives the number +of rows and the number of columns. + +\item In the other cases, \pkg{nicematrix} compute the number of rows and +columns during the first compilation and write the result in the |aux| file +for the next run. + +\textsl{However, it's possible to provide the number of the last row and the +number of the last column as values of the options |last-row| and |last-col|, +tending to an acceleration of the whole compilation of the document.} That's +what we will do throughout the rest of the document. +\end{itemize} +\end{itemize} + +\bigskip +\index{code-for-first-row} +\index{code-for-first-col} +\index{code-for-last-row} +\index{code-for-last-col} +It's possible to control the appearance of these rows and columns with options +|code-for-first-row|, |code-for-last-row|, |code-for-first-col| and +|code-for-last-col|. These options specify tokens that will be inserted before +each cell of the corresponding row or column. + + +\begin{Verbatim} +\NiceMatrixOptions{~emphase#code-for-first-row@ = \color{red}, + ~emphase#code-for-first-col@ = \color{blue}, + ~emphase#code-for-last-row@ = \color{green}, + ~emphase#code-for-last-col@ = \color{magenta}} +$\begin{pNiceArray}{cc|cc}[first-row,last-row=5,first-col,last-col,nullify-dots] + & C_1 & \Cdots & & C_4 & \\ +L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\ +\Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\ +\hline + & a_{31} & a_{32} & a_{33} & a_{34} & \\ +L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\ + & C_1 & \Cdots & & C_4 & +\end{pNiceArray}$ +\end{Verbatim} + +\begin{scope} +\NiceMatrixOptions{code-for-first-row = \color{red}, + code-for-first-col = \color{blue}, + code-for-last-row = \color{green}, + code-for-last-col = \color{magenta}} +\begin{displaymath} +\begin{pNiceArray}{cc|cc}[first-row,last-row=5,first-col,last-col,nullify-dots] + & C_1 & \multicolumn1c{\Cdots} & & C_4 & \\ +L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\ +\Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\ +\hline + & a_{31} & a_{32} & a_{33} & a_{34} & \\ +L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\ + & C_1 & \multicolumn1c{\Cdots} & & C_4 & +\end{pNiceArray} +\end{displaymath} +\end{scope} + + +\emph{Remarks} +\begin{itemize}[beginpenalty=10000] +\item As shown in the previous example, the horizontal and vertical rules +don't extend in the exterior rows and columns. This remark also applies to the +customized rules created by the key |custom-line| +(cf.~p.~\pageref{custom-line}). + +\item A specification of color present in |code-for-first-row| also applies to +a dotted line drawn in that exterior ``first row'' (excepted if a value has +been given to |xdots/color|). Idem for the other exterior rows and columns. + +\item Logically, the potential option |columns-width| (described +p.~\pageref{width}) doesn't apply to the ``first column'' and ``last column''. + +\item For technical reasons, it's not possible to use the option of the +command |\\| after the ``first row'' or before the ``last row''. The placement +of the delimiters would be wrong. If you are looking for a workaround, +consider the command |\SubMatrix| in the |\CodeAfter| described +p.~\pageref{sub-matrix}. +\end{itemize} + + + + + +\section{The continuous dotted lines} + +\label{Cdots} +\index{dotted@\textbf{Dotted lines}|(} +\indexcommand{Ldots} +\indexcommand{Cdots} +\index{Ddots@\texttt{\textbackslash Ddots}|textbf} +\index{Iddots@\texttt{\textbackslash Iddots}|textbf} +\indexcommand{Vdots} +\index{mathdots@\pkg{mathdots} (package)} +\index{xdots (and its subkeys)} + +Inside the environments of the package \pkg{nicematrix}, new commands are +defined: |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, and |\Iddots|. These commands +are intended to be used in place of |\dots|, |\cdots|, |\vdots|, |\ddots| and +|\iddots|.\footnote{The command |\iddots|, defined in \pkg{nicematrix}, is a +variant of |\ddots| with dots going forward. If |mathdots| is loaded, the +version of |mathdots| is used. It corresponds to the command |\adots| of +\pkg{unicode-math}.} +\newcounter{fniddots} +\setcounter{fniddots}{\thefootnote} + +\smallskip +Each of them must be used alone in the cell of the array and it draws a dotted +line between the first non-empty cells\footnote{The precise definition of a +``non-empty cell'' is given below (cf. p.~\pageref{empty-cells}).} on both +sides of the current cell. Of course, for |\Ldots| and |\Cdots|, it's an +horizontal line; for |\Vdots|, it's a vertical line and for |\Ddots| and +|\Iddots| diagonal ones. It's possible to change the color of these lines +with the option |color|.\footnote{It's also possible to change the color of +all these dotted lines with the option |xdots/color| (\textsl{xdots} to +remind that it works for |\Cdots|, |\Ldots|, |\Vdots|, etc.): cf. p. +\pageref{customisation}.}\par\nobreak + +\bigskip +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +\begin{bNiceMatrix} +a_1 & \Cdots & & & a_1 \\ +\Vdots & a_2 & \Cdots & & a_2 \\ + & \Vdots & \Ddots[color=red] \\ +\\ +a_1 & a_2 & & & a_n +\end{bNiceMatrix} +\end{BVerbatim} +$\begin{bNiceMatrix} +a_1 & \Cdots & & & a_1 \\ +\Vdots & a_2 & \Cdots & & a_2 \\ + & \Vdots & \Ddots[color=red] \\ +\\ +a_1 & a_2 & & & a_n +\end{bNiceMatrix}$ + +\interitem +In order to represent the null matrix, one can use the following +codage:\par\nobreak + +\bigskip +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +\begin{bNiceMatrix} +0 & \Cdots & 0 \\ +\Vdots & & \Vdots \\ +0 & \Cdots & 0 +\end{bNiceMatrix} +\end{BVerbatim} +$\begin{bNiceMatrix} +0 & \Cdots & 0 \\ +\Vdots & & \Vdots \\ +0 & \Cdots & 0 +\end{bNiceMatrix}$ + +\bigskip +However, one may want a larger matrix. Usually, in such a case, the users of +LaTeX add a new row and a new column. It's possible to use the same method +with \pkg{nicematrix}:\par\nobreak + +\bigskip +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +\begin{bNiceMatrix} +0 & \Cdots & \Cdots & 0 \\ +\Vdots & & & \Vdots \\ +\Vdots & & & \Vdots \\ +0 & \Cdots & \Cdots & 0 +\end{bNiceMatrix} +\end{BVerbatim} +$\begin{bNiceMatrix} +0 & \Cdots & \Cdots & 0 \\ +\Vdots & & & \Vdots \\ +\Vdots & & & \Vdots \\ +0 & \Cdots & \Cdots & 0 +\end{bNiceMatrix}$ + +\bigskip +In the first column of this example, there are two instructions |\Vdots| but, +of course, only one dotted line is drawn. + +\bigskip +In fact, in this example, it would be possible to draw the same matrix more +easily with the following code:\par\nobreak + +\bigskip +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +\begin{bNiceMatrix} +0 & \Cdots & & 0 \\ +\Vdots & & & \\ + & & & \Vdots \\ +0 & & \Cdots & 0 +\end{bNiceMatrix} +\end{BVerbatim} +$\begin{bNiceMatrix} +0 & \Cdots & & 0 \\ +\Vdots & & & \\ + & & & \Vdots \\ +0 & & \Cdots & 0 +\end{bNiceMatrix}$ + +\bigskip +There are also other means to change the size of the matrix. Someone might +want to use the optional argument of the command~|\\| for the vertical +dimension and a command~|\hspace*| in a cell for the horizontal +dimension.\footnote{In \pkg{nicematrix}, one should use |\hspace*| and not +|\hspace| for such an usage because \pkg{nicematrix} loads \pkg{array}. One +may also remark that it's possible to fix the width of a column by using the +environment |{NiceArray}| (or one of its variants) with a column of type~|w| +or~|W|: see p.~\pageref{width}} + +\indexcommand{Hspace} +However, a command~|\hspace*| might interfer with the construction of the +dotted lines. That's why the package \pkg{nicematrix} provides a +command~|\Hspace| which is a variant of |\hspace| transparent for the dotted +lines of \pkg{nicematrix}.\par\nobreak + +\bigskip +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +\begin{bNiceMatrix} +0 & \Cdots & ~emphase#\Hspace*{1cm}@ & 0 \\ +\Vdots & & & \Vdots \\~emphase#[1cm]@ +0 & \Cdots & & 0 +\end{bNiceMatrix} +\end{BVerbatim} +$\begin{bNiceMatrix} +0 & \Cdots & \Hspace*{1cm} & 0 \\ +\Vdots & & & \Vdots \\[1cm] +0 & \Cdots & & 0 +\end{bNiceMatrix}$ + +\subsection{The option nullify-dots} + +\index{nullify-dots} + +Consider the following matrix composed classicaly with the environment +|{pmatrix}| of \pkg{amsmath}.\par\nobreak + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +$A = \begin{pmatrix} +h & i & j & k & l & m \\ +x & & & & & x +\end{pmatrix}$ +\end{BVerbatim} +$A = \begin{pmatrix} +h & i & j & k & l & m \\ +x & & & & & x +\end{pmatrix}$ + + +\bigskip +If we add |\ldots| instructions in the second row, the geometry of the +matrix is modified.\par\nobreak + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +$B = \begin{pmatrix} +h & i & j & k & l & m \\ +x & \ldots & \ldots & \ldots & \ldots & x +\end{pmatrix}$ +\end{BVerbatim} +$B = \begin{pmatrix} +h & i & j & k & l & m \\ +x & \ldots & \ldots & \ldots & \ldots & x +\end{pmatrix}$ + +\bigskip +By default, with \pkg{nicematrix}, if we replace |{pmatrix}| by +|{pNiceMatrix}| and |\ldots| by |\Ldots|, the geometry of the matrix is not +changed.\par\nobreak + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +$C = \begin{pNiceMatrix} +h & i & j & k & l & m \\ +x & \Ldots & \Ldots & \Ldots & \Ldots & x +\end{pNiceMatrix}$ +\end{BVerbatim} +$C = \begin{pNiceMatrix} +h & i & j & k & l & m \\ +x & \Ldots & \Ldots & \Ldots & \Ldots & x +\end{pNiceMatrix}$ + +\bigskip +However, one may prefer the geometry of the first matrix $A$ and would like to +have such a geometry with a dotted line in the second row. It's possible by +using the option |nullify-dots| (and only one instruction |\Ldots| is +necessary).\par\nobreak + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +$D = \begin{pNiceMatrix}[~emphase#nullify-dots@] +h & i & j & k & l & m \\ +x & \Ldots & & & & x +\end{pNiceMatrix}$ +\end{BVerbatim} +$D = \begin{pNiceMatrix}[nullify-dots] +h & i & j & k & l & m \\ +x & \Ldots & & & & x +\end{pNiceMatrix}$ + +\medskip +The option |nullify-dots| smashes the instructions |\Ldots| (and the variants) +horizontally but also vertically. + + + +\subsection{The commands \textbackslash Hdotsfor and \textbackslash Vdotsfor} + +\indexcommand{Hdotsfor} +\indexcommand{Vdotsfor} + +Some people commonly use the command |\hdotsfor| of \pkg{amsmath} in order to +draw horizontal dotted lines in a matrix. In the environments of +\pkg{nicematrix}, one should use instead |\Hdotsfor| in order to draw dotted +lines similar to the other dotted lines drawn by the package \pkg{nicematrix}. + +As with the other commands of \pkg{nicematrix} (like |\Cdots|, |\Ldots|, +|\Vdots|, etc.), the dotted line drawn with |\Hdotsfor| extends until the +contents of the cells on both sides. + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=7cm] +$\begin{pNiceMatrix} +1 & 2 & 3 & 4 & 5 \\ +1 & ~emphase#\Hdotsfor{3}@ & 5 \\ +1 & 2 & 3 & 4 & 5 \\ +1 & 2 & 3 & 4 & 5 +\end{pNiceMatrix}$ +\end{BVerbatim} +$\begin{pNiceMatrix} +1 & 2 & 3 & 4 & 5 \\ +1 & \Hdotsfor{3} & 5 \\ +1 & 2 & 3 & 4 & 5 \\ +1 & 2 & 3 & 4 & 5 +\end{pNiceMatrix}$ + +\bigskip +However, if these cells are empty, the dotted line extends only in the cells +specified by the argument of |\Hdotsfor| (by design). + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=7cm] +$\begin{pNiceMatrix} +1 & 2 & 3 & 4 & 5 \\ + & ~emphase#\Hdotsfor{3}@ \\ +1 & 2 & 3 & 4 & 5 \\ +1 & 2 & 3 & 4 & 5 +\end{pNiceMatrix}$ +\end{BVerbatim} +$\begin{pNiceMatrix} +1 & 2 & 3 & 4 & 5 \\ + & \Hdotsfor{3} \\ +1 & 2 & 3 & 4 & 5 \\ +1 & 2 & 3 & 4 & 5 +\end{pNiceMatrix}$ + +\medskip +Remark: Unlike the command |\hdotsfor| of \pkg{amsmath}, the command +|\Hdotsfor| may be used even when the package \pkg{colortbl}\footnote{We +recall that when \pkg{xcolor} is loaded with the option |table|, the +package \pkg{colortbl} is loaded.} is loaded (but you might have problem if +you use |\rowcolor| on the same row as |\Hdotsfor|). + +\bigskip +The package \pkg{nicematrix} also provides a command |\Vdotsfor| similar to +|\Hdotsfor| but for the vertical dotted lines. +\bigskip +The following example uses both |\Hdotsfor| and |\Vdotsfor|: + +\begin{Verbatim}[formatcom=\small\color{gray}] +\begin{bNiceMatrix} +C[a_1,a_1] & \Cdots & C[a_1,a_n] + & \hspace*{20mm} & C[a_1,a_1^{(p)}] & \Cdots & C[a_1,a_n^{(p)}] \\ +\Vdots & \Ddots & \Vdots + & ~emphase#\Hdotsfor{1}@ & \Vdots & \Ddots & \Vdots \\ +C[a_n,a_1] & \Cdots & C[a_n,a_n] + & & C[a_n,a_1^{(p)}] & \Cdots & C[a_n,a_n^{(p)}] \\ +\rule{0pt}{15mm}\NotEmpty & ~emphase#\Vdotsfor{1}@ & & \Ddots & & ~emphase#\Vdotsfor{1}@ \\ +C[a_1^{(p)},a_1] & \Cdots & C[a_1^{(p)},a_n] + & & C[a_1^{(p)},a_1^{(p)}] & \Cdots & C[a_1^{(p)},a_n^{(p)}] \\ +\Vdots & \Ddots & \Vdots + & ~emphase#\Hdotsfor{1}@ & \Vdots & \Ddots & \Vdots \\ +C[a_n^{(p)},a_1] & \Cdots & C[a_n^{(p)},a_n] + & & C[a_n^{(p)},a_1^{(p)}] & \Cdots & C[a_n^{(p)},a_n^{(p)}] +\end{bNiceMatrix} +\end{Verbatim} + + +\[\begin{bNiceMatrix} +C[a_1,a_1] & \Cdots & C[a_1,a_n] & \hspace*{20mm} & C[a_1,a_1^{(p)}] & \Cdots & C[a_1,a_n^{(p)}] \\ +\Vdots & \Ddots & \Vdots & \Hdotsfor{1} & \Vdots & \Ddots & \Vdots \\ +C[a_n,a_1] & \Cdots & C[a_n,a_n] & & C[a_n,a_1^{(p)}] & \Cdots & C[a_n,a_n^{(p)}] \\ +\rule{0pt}{15mm}\NotEmpty & \Vdotsfor{1} & & \Ddots & & \Vdotsfor{1} \\ +C[a_1^{(p)},a_1] & \Cdots & C[a_1^{(p)},a_n] & & C[a_1^{(p)},a_1^{(p)}] & \Cdots & C[a_1^{(p)},a_n^{(p)}] \\ +\Vdots & \Ddots & \Vdots & \Hdotsfor{1} & \Vdots & \Ddots & \Vdots \\ +C[a_n^{(p)},a_1] & \Cdots & C[a_n^{(p)},a_n] & & C[a_n^{(p)},a_1^{(p)}] & \Cdots & C[a_n^{(p)},a_n^{(p)}] +\end{bNiceMatrix}\] + + + + +\subsection{How to generate the continuous dotted lines transparently} + +\index{renew-matrix} +\index{renew-dots} + +Imagine you have a document with a great number of mathematical matrices with +ellipsis. You may wish to use the dotted lines of \pkg{nicematrix} without +having to modify the code of each matrix. It's possible with the keys. +|renew-dots| and |renew-matrix|.\footnote{The options |renew-dots|, +|renew-matrix| can be fixed with the command +|\NiceMatrixOptions| like the other options. However, they can also be fixed +as options of the command |\usepackage|.} + +\smallskip + +\begin{itemize} +\item The option |renew-dots|\par\nobreak + +With this option, the commands |\ldots|, |\cdots|, |\vdots|, |\ddots|, +|\iddots|\footnotemark[\thefniddots] and |\hdotsfor| are redefined within the +environments provided by \pkg{nicematrix} and behave like |\Ldots|, |\Cdots|, +|\Vdots|, |\Ddots|, |\Iddots| and |\Hdotsfor|; the command |\dots| +(``automatic dots'' of |amsmath|) is also redefined to behave like |\Ldots|. + +\item The option |renew-matrix|\par\nobreak + +With this option, the environment |{matrix}| is redefined and behave like +|{NiceMatrix}|, and so on for the five variants. +\end{itemize} + +\bigskip +Therefore, with the keys |renew-dots| and |renew-matrix|, a classical code +gives directly the ouput of \pkg{nicematrix}.\par\nobreak + +\bigskip +\begin{scope} +\NiceMatrixOptions{renew-dots,renew-matrix} +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +~emphase#\NiceMatrixOptions{renew-dots,renew-matrix}@ +\begin{pmatrix} +1 & \cdots & \cdots & 1 \\ +0 & \ddots & & \vdots \\ +\vdots & \ddots & \ddots & \vdots \\ +0 & \cdots & 0 & 1 +\end{pmatrix} +\end{BVerbatim} +$\begin{pmatrix} +1 & \cdots & \cdots & 1 \\ +0 & \ddots & & \vdots \\ +\vdots & \ddots & \ddots & \vdots \\ +0 & \cdots & 0 & 1 +\end{pmatrix}$ +\end{scope} + +\subsection{The labels of the dotted lines} + +The commands |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, |\Iddots| and |\Hdotsfor| +(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|. + +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +$\begin{bNiceMatrix} +1 & \hspace*{1cm} & 0 \\[8mm] + & ~emphase#\Ddots^{n \text{ times}}@ & \\ +0 & & 1 +\end{bNiceMatrix}$ +\end{BVerbatim} +$\begin{bNiceMatrix} +1 & \hspace*{1cm} & 0 \\[8mm] + & \Ddots^{n \text{ times}} & \\ +0 & & 1 +\end{bNiceMatrix}$ + +\subsection{Customisation of the dotted lines} + +\label{customisation} +\index{color!key for the dotted rules} +\index{radius (key for the dotted rules)} +\index{inter (key for the dotted rules)} +\index{line-style (key for the dotted rules)} +\index{shorten (key for the dotted rules)} +\index{shorten-end (key for the dotted rules)} +\index{shorten-start (key for the dotted rules)} + +The dotted lines drawn by |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, |\Iddots|, +|\Hdotsfor| and |\Vdotsfor| (and by the command |\line| in the |\CodeAfter| +which is described p.~\pageref{line-in-code-after}) may be customized by the following +options (specified between square brackets after the command): +\begin{itemize} +\item |color|; +\item |radius|; +\item |shorten-start|, |shorten-end| and |shorten|; +\item |inter|; +\item |line-style|. +\end{itemize} + +These options may also be fixed with |\NiceMatrixOptions|, as options of +|\CodeAfter| or at the level of a given environment but, in those cases, they +must be prefixed by |xdots| (\textsl{xdots} to remind that it works for +|\Cdots|, |\Ldots|, |\Vdots|, etc.), and, thus have for names: +\begin{itemize} +\item |xdots/color|; +\item |xdots/radius|; +\item |xdots/shorten-start|, |xdots/shorten-end| and |xdots/shorten|; +\item |xdots/inter|; +\item |xdots/line-style|. +\end{itemize} + +For the clarity of the explanations, we will use those names. + +\bigskip +\textbf{The option xdots/color}\par\nobreak + +\smallskip +The option |xdots/color| fixes the color or the dotted line. However, one should +remark that the dotted lines drawn in the exterior rows and columns have a +special treatment: cf. p.~\pageref{exterior}. + +\bigskip +\textbf{The option xdots/radius}\par\nobreak + +The option |radius| fixes the radius of the dots. The initial value is 0.53~pt. + +\bigskip +\textbf{The option xdots/shorten}\par\nobreak + +\smallskip +The keys |xdots/shorten-start| and |xdots/shorten-end| fix the margin at the +extremities of the line. The key |xdots/shorten| fixes both parameters. +The initial value is 0.3~em (it is recommanded to use a unit of length +dependent of the current font). + +\bigskip +\textbf{The option xdots/inter}\par\nobreak + +\smallskip +The option |xdots/inter| fixes the length between the dots. The initial value +is 0.45~em (it is recommanded to use a unit of length dependent of the current +font). + +\bigskip +\textbf{The option xdots/line-style}\par\nobreak + +\smallskip +It should be pointed that, by default, the lines drawn by Tikz with the +parameter |dotted| are composed of square dots (and not rounded +ones).\footnote{The first reason of this behaviour is that the \textsc{pdf} +format includes a description for dashed lines. The lines specified with this +descriptor are displayed very efficiently by the \textsc{pdf} readers. It's +easy, starting from these dashed lines, +to create a line composed by square dots whereas a line of rounded dots needs +a specification of each dot in the \textsc{pdf} file. Nevertheless, you can +have a look at the following page to see how to have dotted rules with rounded +dots in Tikz:\newline \small +\url{https://tex.stackexchange.com/questions/52848/tikz-line-with-large-dots}} + +\begin{BVerbatim}[baseline=c,boxwidth=9cm] +\tikz \draw [dotted] (0,0) -- (5,0) ; +\end{BVerbatim} +\tikz \draw [dotted] (0,0) -- (5,0) ; + +\medskip +In order to provide lines with rounded dots in the style of those provided by +|\ldots| (at least with the \emph{Computer Modern} fonts), the package +\pkg{nicematrix} embeds its own system to draw a dotted line (and this system +uses \textsc{pgf} and not Tikz). This style is called |standard| and that's +the initial value of the parameter |xdots/line-style|. + +However (when Tikz is loaded) it's possible to use for |xdots/line-style| any style +provided by Tikz, that is to say any sequence of options provided by Tikz for +the Tizk pathes (with the exception of ``|color|'', ``|shorten >|'' and +``|shorten <|''). + +\medskip +Here is for example a tridiagonal matrix with the style |loosely dotted|:\par\nobreak + +\medskip +\begin{BVerbatim}[baseline=c] +$\begin{pNiceMatrix}[nullify-dots,~emphase#xdots/line-style=loosely dotted@] +a & b & 0 & & \Cdots & 0 \\ +b & a & b & \Ddots & & \Vdots \\ +0 & b & a & \Ddots & & \\ + & \Ddots & \Ddots & \Ddots & & 0 \\ +\Vdots & & & & & b \\ +0 & \Cdots & & 0 & b & a +\end{pNiceMatrix}$ +\end{BVerbatim} + + +\[\begin{pNiceMatrix}[nullify-dots,xdots/line-style=loosely dotted] +a & b & 0 & & \Cdots & 0 \\ +b & a & b & \Ddots & & \Vdots \\ +0 & b & a & \Ddots & & \\ + & \Ddots & \Ddots & \Ddots & & 0 \\ +\Vdots & & & & & b \\ +0 & \Cdots & & 0 & b & a +\end{pNiceMatrix}\] + + +\subsection{The dotted lines and the rules} + +\label{dotted-and-rules} + +The dotted lines determine virtual blocks which have the same behaviour +regarding the rules (the rules specified by the specifier \verb+|+ in the +preamble, by the command |\Hline|, by the keys |hlines|, |vlines|, +|hvlines| and |hvlines-except-borders| and by the tools created by +|custom-line| are not drawn within the +blocks).\footnote{On the other side, the command |\line| in the +|\CodeAfter| (cf.~p.~\pageref{line-in-code-after}) does \emph{not} create +block.} + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=10.6cm] +$\begin{bNiceMatrix}[margin,~emphase#hvlines@] +\Block{3-3}<\LARGE>{A} & & & 0 \\ +& \hspace*{1cm} & & \Vdots \\ +& & & 0 \\ +0 & \Cdots& 0 & 0 +\end{bNiceMatrix}$ +\end{BVerbatim} +$\begin{bNiceMatrix}[margin,hvlines] +\Block{3-3}<\LARGE>{A} & & & 0 \\ +& \hspace*{1cm} & & \Vdots \\ +& & & 0 \\ +0 & \Cdots& 0 & 0 +\end{bNiceMatrix}$ + +\index{dotted@\textbf{Dotted lines}|)} + +\section{Delimiters in the preamble of the environment} + +\index{blkarray@\pkg{blkarray} (package)} + +\label{delimiters-in-preamble} + +In the environments with preamble (|{NiceArray}|, |{pNiceArray}|, etc.), it's +possible to put vertical delimiters directly in the preamble of the +environment.\footnote{This syntax is inspired by the extension \pkg{blkarray}.} + +\smallskip +\index{left@\texttt{\textbackslash left} : used by \pkg{nicematrix} for\newline + delimiters in the preambles} +\index{right@\texttt{\textbackslash right} : used by \pkg{nicematrix} for\newline + delimiters in the preambles} +The opening delimiters should be prefixed by the keyword |\left| and the +closing delimiters by the keyword |\right|. It's not mandatory to use +|\left| and |\right| pair-wise. + +\smallskip +All the vertical extensible delimiters of LaTeX are allowed. + +\medskip +Here is a example which uses the delimiters |\lgroup| and |\rgroup|. + +\smallskip +\begin{BVerbatim} +$\begin{NiceArray}{~emphase#\left\lgroup@ ccc~emphase#\right\rgroup@ l} +1 & 2 & 3 & +4 & 1 & 6 & +7 & 8 & 9 & \scriptstyle L_3 \gets L_3 + L_1 + L_2 +\end{NiceArray}$ +\end{BVerbatim} + +\[\begin{NiceArray}{\left\lgroup ccc\right\rgroup l} +1 & 2 & 3 & \\ +4 & 1 & 6 & \\ +7 & 8 & 9 & \scriptstyle L_3 \gets L_3 + L_1 + L_2 +\end{NiceArray}\] + +\medskip +For this example, it would also have been possible to use the environment +|{NiceArrayWithDelims}| (cf. the section \ref{NiceArrayWithDelims}, +p.~\pageref{NiceArrayWithDelims}) and the key |last-col| (cf. p.~\pageref{exterior}). + +\bigskip +There is a particular case: for the delimiters |(|, |[| and |\{| (and the +corresponding closing delimiters), the prefixes |\left| et |\right| are +optional.\footnote{For the delimiters |[| and |]|, the prefixes remain mandatory +when there is a conflict of notation with the square brackets for the options +of some descriptors of columns.} + + + +\bigskip +When there are two successive delimiters (necessarily a closing one following by +an opening one for another submatrix), a space equal to |\enskip| is +automatically inserted. + +\medskip +\begin{BVerbatim} +$\begin{pNiceArray}{~emphase#(c)(c)(c)@} +a_{11} & a_{12} & a_{13} \\ +a_{21} & \displaystyle \int_0^1\dfrac{1}{x^2+1}\,dx & a_{23} \\ +a_{31} & a_{32} & a_{33} +\end{pNiceArray}$ +\end{BVerbatim} + +\[\begin{pNiceArray}{(c)(c)(c)} +a_{11} & a_{12} & a_{13} \\ +a_{21} & \displaystyle \int_0^1\dfrac{1}{x^2+1}\,dx & a_{23} \\ +a_{31} & a_{32} & a_{33} +\end{pNiceArray}\] + + +\bigskip +For more complex constructions, in particular with delimiters spanning only a +\emph{subset} of the rows of the array, one should consider the command +|\SubMatrix| available in the |\CodeAfter|. See the section~\ref{sub-matrix}, +p.~\pageref{sub-matrix}. + +\section{The \textbackslash CodeAfter} + +\index{CodeAfter@\texttt{\textbackslash CodeAfter}|(} +\index{code-after} + +\label{code-after} +The option |code-after| may be used to give some code that will be executed +\emph{after} the construction of the matrix.\footnote{There is also a key +|code-before| described p.~\pageref{code-before}.} + +\medskip +\index{sub-matrix (key of \texttt{\textbackslash CodeAfter}, with subkeys)} +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|. Although |\CodeAfter| is a +keyword, it takes in an optional argument (between square +brackets).\footnote{Here are the keys accepted in that argument: +|delimiters/color|, |rules| and its sub-keys and |sub-matrix| (linked to the +command |\SubMatrix|) and its sub-keys.} + + +\medskip +The experienced users may, for instance, use the PGF/Tikz nodes created by +\pkg{nicematrix} in the |\CodeAfter|. These nodes are described further +beginning on p.~\pageref{PGF-nodes}. + +\medskip +Moreover, several special commands are available in the |\CodeAfter|: |line|, +|\SubMatrix|, |\OverBrace| and |\UnderBrace|. We will now present these commands. + +\subsection{The command \textbackslash line in the \textbackslash CodeAfter} + +\label{line-in-code-after} +\index{line@\texttt{\textbackslash line} (command of \texttt{\textbackslash CodeAfter})} +The command |\line| draws directly dotted lines between cells or blocks. It takes in two +arguments for the cells or blocks to link. Both argument may be: +\begin{itemize} +\item a specification of cell of the form $i$-$j$ where is the +number of the row and $j$ is the number of the column; +\item the name of a block (created by the command |\Block| with the key |name| +of that command). +\end{itemize} +The options available for the customisation of the dotted lines created by +|\Cdots|, |\Vdots|, etc. are also available for this command (cf. +p.~\pageref{customisation}). + +\bigskip +This command may be used, for example, to draw a dotted line between two +adjacent cells. + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=11cm] +\NiceMatrixOptions{xdots/shorten = 0.6 em} +\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} +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} + +\bigskip +It can also be used to draw a diagonal line not parallel to the other diagonal +lines (by default, the dotted lines drawn by |\Ddots| are ``parallelized'': +cf.~p.~\pageref{parallelization}). + +\medskip +\begin{BVerbatim} +\begin{bNiceMatrix} +1 & \Cdots & & 1 & 2 & \Cdots & 2 \\ +0 & \Ddots & & \Vdots & \Vdots & \hspace*{2.5cm} & \Vdots \\ +\Vdots & \Ddots & & & & & \\ +0 & \Cdots & 0 & 1 & 2 & \Cdots & 2 +~emphase#\CodeAfter \line[shorten=6pt]{1-5}{4-7}@ +\end{bNiceMatrix} +\end{BVerbatim} +\[\begin{bNiceMatrix} +1 & \Cdots & & 1 & 2 & \Cdots & 2 \\ +0 & \Ddots & & \Vdots & \Vdots & \hspace*{2.5cm} & \Vdots \\ +\Vdots & \Ddots & & & & & \\ +0 & \Cdots & 0 & 1 & 2 & \Cdots & 2 +\CodeAfter \line[shorten=6pt]{1-5}{4-7} +\end{bNiceMatrix}\] + + + + +\subsection{The command \textbackslash SubMatrix in the \textbackslash +CodeAfter (and the \textbackslash CodeBefore)} + +\label{sub-matrix} +\index{SubMatrix@\texttt{\textbackslash SubMatrix} (command of +\texttt{\textbackslash CodeAfter}\newline and +\texttt{\textbackslash CodeBefore})|textbf} + + +The command |\SubMatrix| provides a way to put delimiters on a portion +of the array considered as a submatrix. The command |\SubMatrix| takes in five +arguments: +\begin{itemize} +\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 \textsl{key=value} +pairs.\footnote{There is no optional argument between square brackets in first +position because a square bracket just after |\SubMatrix| must be interpreted +as the first (mandatory) argument of the command |\SubMatrix|: that bracket is +the left delimiter of the sub-matrix to construct (eg.: +|\SubMatrix[{2-2}{4-7}]|).} +\end{itemize} + +One should remark that the command |\SubMatrix| draws the delimiters \emph{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 +\begin{scope} +\hfuzz=15cm +\fvset{commandchars=\~\#\+}% +\begin{BVerbatim}[boxwidth=11cm,baseline=c] +\[\begin{NiceArray}{ccc~emphase#@{\hspace{1.5em}}+c}[cell-space-limits=2pt,~emphase#margin+] + 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}$ + +\medskip +Eventually, in this example, it would probably have been easier to put the +delimiters directly in the preamble of |{NiceArray}| (see +section~\ref{delimiters-in-preamble}, p.~\pageref{delimiters-in-preamble}) +with the following construction. + +\medskip +\begin{scope} +\hfuzz=15cm +\begin{BVerbatim}[boxwidth=11cm,baseline=c] +$\begin{NiceArray}{~emphase#(ccc)(c)@}[cell-space-limits=2pt] + 1 & 1 & 1 & x \\ +\dfrac{1}{4} & \dfrac{1}{2} & \dfrac{1}{4} & y \\ + 1 & 2 & 3 & z +\end{NiceArray}$ +\end{BVerbatim} +\end{scope} +$\begin{NiceArray}{(ccc)(c)}[cell-space-limits=2pt] + 1 & 1 & 1 & x \\ +\dfrac{1}{4} & \dfrac{1}{2} & \dfrac{1}{4} & y \\ + 1 & 2 & 3 & z +\end{NiceArray}$ + +\bigskip +In fact, the command |\SubMatrix| also takes in two optional arguments +specified by the traditional symbols |^| and |_| for material in superscript +and subscript. + +\medskip +\begin{scope} +\hfuzz=15cm +\begin{BVerbatim}[boxwidth=11cm,baseline=c] +$\begin{bNiceMatrix}[right-margin=1em] +1 & 1 & 1 \\ +1 & a & b \\ +1 & c & d +\CodeAfter + ~emphase#\SubMatrix[{2-2}{3-3}]^{T}@ +\end{bNiceMatrix}$ +\end{BVerbatim} +$\begin{bNiceMatrix}[right-margin=1em] +1 & 1 & 1 \\ +1 & a & b \\ +1 & c & d +\CodeAfter + \SubMatrix[{2-2}{3-3}]^{T} +\end{bNiceMatrix}$ +\end{scope} + + +\bigskip +The options of the command |\SubMatrix| are as follows: +\begin{itemize} +\item +\index{left-xshift (key of \texttt{\textbackslash SubMatrix})} +\index{right-xshift (key of \texttt{\textbackslash SubMatrix})} +\index{xshift (key of \texttt{\textbackslash SubMatrix})} +\Definition{left-xshift} and \Definition{right-xshift} shift +horizontally the delimiters (there exists also the key \Definition{xshift} +which fixes both parameters); +\item \index{extra-height (key of \texttt{\textbackslash SubMatrix})} +\Definition{extra-height} adds a quantity to the total height of the +delimiters (height |\ht| + depth |\dp|); +\item \index{delimiters!---/color pour \texttt{\textbackslash SubMatrix}} +\Definition{delimiters/color} fixes the color of the delimiters (also +available in |\NiceMatrixOptions|, in the environments with delimiters and as +option of the keyword |\CodeAfter|); +\item \index{slim (key of \texttt{\textbackslash SubMatrix})} +\Definition{slim} is a boolean key: when that key is in force, the horizontal +position of the delimiters is computed by using only the contents of the cells +of the submatrix whereas, in the general case, the position is computed by +taking into account the cells of the whole columns implied in the submatrix +(see example below). ; +\item \index{vlines!key of \texttt{\textbackslash SubMatrix}} +\Definition{vlines} contents a list of numbers of vertical rules that +will be drawn in the sub-matrix (if this key is used without value, all the +vertical rules of the sub-matrix are drawn); +\item \index{hlines!key of \texttt{\textbackslash SubMatrix}} +\Definition{hlines} is similar to |vlines| but for the horizontal rules; +\item \index{hvlines!key of \texttt{\textbackslash SubMatrix}} +\Definition{hvlines}, which must be used without value, draws all the +vertical and horizontal rules; +\item \index{code (key of \texttt{\textbackslash SubMatrix})} +\Definition{code} insert code, especially TikZ code, after the +construcion of the submatrix. That key is detailed below. +\end{itemize} +One should remark that the keys add their rules after the construction of +the main matrix: no space is added between the rows and the columns of the +array for theses rules. + +\bigskip +All these keys are also available in |\NiceMatrixOptions|, at the level of the +environments of \pkg{nicematrix} or as option of the command |\CodeAfter| with +the prefix |sub-matrix| which means that their names are therefore +|sub-matrix/left-xshift|, |sub-matrix/right-xshift|, |sub-matrix/xshift|, etc. + +\bigskip +\begin{scope} +\hfuzz=12cm +\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} +\hfuzz=12cm +\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 create PGF/Tikz nodes: cf +p.~\pageref{node-sub-matrix}. + + +\bigskip +Despite its name, the command |\SubMatrix| may also be used within a +|{NiceTabular}|. Here is an example (which uses |\bottomrule| and +|\toprule| of \pkg{booktabs}). + +\medskip +\begin{BVerbatim}[baseline=c] +\begin{NiceTabular}{~@{}ll~@{}} +\toprule +Part A & the first part \\ +\Block{2-1}{Part B} & a first sub-part \\ + & a second sub-part \\ +\bottomrule +\CodeAfter + ~emphase#\SubMatrix{\{}{2-2}{3-2}{.}@ +\end{NiceTabular} +\end{BVerbatim} +\hspace{2cm} +\begin{NiceTabular}{@{}ll@{}} +\toprule +Part A & the first part \\ +\Block{2-1}{Part B} & a first sub-part \\ + & a second sub-part \\ +\bottomrule +\CodeAfter + \SubMatrix{\{}{2-2}{3-2}{.} +\end{NiceTabular} + +\bigskip +The command |\SubMatrix| is, in fact, also available in the |\CodeBefore|. By +using |\SubMatrix| in the |\CodeBefore|, the delimiters drawn by those +commands |\SubMatrix| are taken into account to limit the continuous dotted +lines (drawn by |\Cdots|, |\Vdots|, etc.) which have an open extremity. + +For an example, see voir \ref{submatrix-in-codebefore} +p.~\pageref{submatrix-in-codebefore}. + + +\vspace{1cm} +The key |code| of the command |\SubMatrix| allows the insertion of code after +the construction of the submatrix. It's meant to be used to insert TikZ +instructions because, in the TikZ instructions inserted by that code, the +nodes of the form |i-j| and \verb+i-|j+ are interpreted with |i| and |j| as +numbers of row and columns \emph{relative to the submatrix}.\footnote{Be +careful: the syntax \verb+j|-i+ is \emph{not} allowed.} + +\medskip +\begin{scope} +\fvset{commandchars=\~\#\!}% +\begin{Verbatim} +$\begin{NiceArray}{ccc@{}w{c}{5mm}@{}ccc} + & & && -1 & 1 & 2 \\ + & & && 0 & 3 & 4 \\ + & & && 0 & 0 & 5 \\ + 1 & 2 & 3 && -1 & 7 & 25 \\ + 0 & 4 & 5 && 0 & 12 & 41 \\ + 0 & 0 & 6 && 0 & 0 & 30 +\CodeAfter + ~emphase#\NewDocumentCommand{\MyDraw}{}{\tikz \draw [blue] (2-|1) -| (3-|2) -| (4-|3) ;}! + \SubMatrix({1-5}{3-7})[~emphase#code = \MyDraw!] + \SubMatrix({4-1}{6-3})[~emphase#code = \MyDraw!] + \SubMatrix({4-5}{6-7})[~emphase#code = \MyDraw!] +\end{NiceArray}$ +\end{Verbatim} +\end{scope} + + +\[\begin{NiceArray}{ccc@{}w{c}{5mm}@{}ccc} + & & && -1 & 1 & 2 \\ + & & && 0 & 3 & 4 \\ + & & && 0 & 0 & 5 \\ + 1 & 2 & 3 && -1 & 7 & 25 \\ + 0 & 4 & 5 && 0 & 12 & 41 \\ + 0 & 0 & 6 && 0 & 0 & 30 +\CodeAfter + \NewDocumentCommand{\MyDraw}{}{\tikz \draw [blue] (2-|1) -| (3-|2) -| (4-|3) ;} + \SubMatrix({1-5}{3-7})[code = \MyDraw ] + \SubMatrix({4-1}{6-3})[code = \MyDraw ] + \SubMatrix({4-5}{6-7})[code = \MyDraw ] +\end{NiceArray}\] + +\medskip +As we see, the drawing done by our command |\MyDraw| is \emph{relative} to the +submatrix to which it is applied. + +\subsection{The commands \textbackslash OverBrace and \textbackslash +UnderBrace in the \textbackslash CodeAfter} + +\index{UncerBrace@\texttt{\textbackslash UnderBrace} (command of +\texttt{\textbackslash CodeAfter}\newline and +\texttt{\textbackslash CodeBefore})} +\index{OverBrace@\texttt{\textbackslash OverBrace} (command of +\texttt{\textbackslash CodeAfter}\newline and +\texttt{\textbackslash CodeBefore})} + +The commands |\OverBrace| and |\UnderBrace| provide a way to put +horizontal braces on a part of the array. These commands take in three +arguments: +\begin{itemize} +\item the first 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 second argument is the lower-right corner with the same syntax; +\item the third argument is the label of the brace that will be put by +\pkg{nicematrix} (with \textsc{pgf}) above the brace (for the command +|\OverBrace|) or under the brace (for |\UnderBrace|). +\end{itemize} + +\bigskip +\begin{BVerbatim}[baseline=c,boxwidth=9cm] +\begin{pNiceMatrix} +1 & 2 & 3 & 4 & 5 & 6 \\ +11 & 12 & 13 & 14 & 15 & 16 \\ +\CodeAfter + ~emphase#\OverBrace{1-1}{2-3}{A}@ + ~emphase#\OverBrace{1-4}{2-6}{B}@ +\end{pNiceMatrix} +\end{BVerbatim} +$\begin{pNiceMatrix} +1 & 2 & 3 & 4 & 5 & 6 \\ +11 & 12 & 13 & 14 & 15 & 16 \\ +\CodeAfter + \OverBrace{1-1}{2-3}{A} + \OverBrace{1-4}{2-6}{B} +\end{pNiceMatrix}$ + +\bigskip +Caution : There is no vertical space reserved for those braces.\footnote{See: + \url{https://tex.stackexchange.com/questions/685755}} + + +\bigskip +\index{color!key of \texttt{\textbackslash OverBrace} and \texttt{\textbackslash + UnderBrace}} +\index{yshift (key of \texttt{\textbackslash OverBrace} and \texttt{\textbackslash + UnderBrace})} +\index{left-shorten (key of \texttt{\textbackslash OverBrace} and\newline \texttt{\textbackslash + UnderBrace})} +\index{right-shorten (key of \texttt{\textbackslash OverBrace} and\newline \texttt{\textbackslash + UnderBrace})} + +In fact, the commands |\OverBrace| and |\UnderBrace| take in an optional +argument (in first position and between square brackets) for a list of +\textsl{key=value} pairs. The available keys are: +\begin{itemize} +\item |left-shorten| and |right-shorten| which do not take in value; when the +key |left-shorten| is used, the abscissa of the left extremity of the brace is +computed with the contents of the cells of the involved sub-array, otherwise, +the position of the potential vertical rule is used (idem for +|right-shorten|). + +\item |shorten|, which is the conjunction of the keys |left-shorten| and +|right-shorten|; + +\item |yshift|, which shifts vertically the brace (and its label); + +\item |color|, which sets the color of the brace (and its label). +\end{itemize} + +\bigskip +\begin{BVerbatim}[baseline=c,boxwidth=9cm] +\begin{pNiceMatrix} +1 & 2 & 3 & 4 & 5 & 6 \\ +11 & 12 & 13 & 14 & 15 & 16 \\ +\CodeAfter + \OverBrace~emphase#[shorten,yshift=3pt]@{1-1}{2-3}{A} + \OverBrace~emphase#[shorten,yshift=3pt]@{1-4}{2-6}{B} +\end{pNiceMatrix} +\end{BVerbatim} +$\begin{pNiceMatrix} +1 & 2 & 3 & 4 & 5 & 6 \\ +11 & 12 & 13 & 14 & 15 & 16 \\ +\CodeAfter + \OverBrace[shorten,yshift=3pt]{1-1}{2-3}{A} + \OverBrace[shorten,yshift=3pt]{1-4}{2-6}{B} +\end{pNiceMatrix}$ + +\index{CodeAfter@\texttt{\textbackslash CodeAfter}|)} + +\section{Captions and notes in the tabulars} + +\label{s:notes} + +\subsection{Caption of a tabular} + +\label{s:caption} + +\index{caption (key of \texttt{\{NiceTabular\}})} +\index{short-caption} +\index{label (key of \texttt{\{NiceTabular\}})} +\index{caption-above} +\index{caption@\textbf{Captions of the tabulars}} + +\smallskip +The environment |{NiceTabular}| provides the keys |caption|, |short-caption| +and |label| which may be used when the tabular is inserted in a floating +environment (typically the environment |{table}|). + +\smallskip +With the key |caption|, the caption, when it is long, is wrapped at the width of +the tabular (excepted the potential exterior columns specified by |first-col| +and |last-col|: cf.~\ref{exterior}, p.~\pageref{exterior}), without the use of +the package \pkg{threeparttable} or the package \pkg{floatrow}. + +\smallskip +By default, the caption is composed below the tabular. With the key +|caption-above|, available in |\NiceMatrixOptions|, the caption will be +composed above the tabular. + +\smallskip +The key |short-caption| corresponds to the optional argument of the clasical +command |\caption| and the key |label| corresponds, of course, to the command +|\label|. + +\smallskip +See table \ref{t:tabularnote}, p.~\pageref{t:tabularnote}, for an example of +use the keys |caption| and |label|. + +\smallskip +These functionnalities are compatible with the extension \pkg{caption}. + +\subsection{The footnotes} + +\index{footnote@\pkg{footnote} (package)} +\index{footnote (key)} +\index{footnotehyper@\pkg{footnotehyper} (package)} +\index{footnotehyper (key)} + +\smallskip +The package \pkg{nicematrix} allows, by using \pkg{footnote} or +\pkg{footnotehyper}, the extraction of the notes inserted by |\footnote| in the +environments of \pkg{nicematrix} and their composition in the foot of the page +with the other notes of the document. + +\smallskip +If \pkg{nicematrix} is loaded with the option |footnote| (with +|\usepackage[footnote]{nicematrix}| or with |\PassOptionsToPackage|), the +package \pkg{footnote} is loaded (if it is not yet loaded) and it is used to +extract the footnotes. + +\smallskip +If \pkg{nicematrix} is loaded with the option |footnotehyper|, the package +\pkg{footnotehyper} is loaded (if it is not yet loaded) ant it is used to +extract footnotes. + +\smallskip +Caution: The packages \pkg{footnote} and \pkg{footnotehyper} are incompatible. +The package \pkg{footnotehyper} is the successor of the package \pkg{footnote} +and should be used preferently. The package \pkg{footnote} has some drawbacks, +in particular: it must be loaded after the package \pkg{xcolor} and it is not +perfectly compatible with \pkg{hyperref}. + + +\subsection{The notes of tabular} + +\index{nota@\textbf{Notes in the tabulars}|(} +\index{tabularnote@\texttt{\textbackslash tabularnote}} + + +The package \pkg{nicematrix} also provides a command |\tabularnote| which gives +the ability to specify notes that will be composed at the end of the array with +a width of line equal to the width of the array (excepted the potential exterior +columns specified by |first-col| and |last-col|: cf.~\ref{exterior}, +p.~\pageref{exterior}). With no surprise, that command is available only in the +environments |{NiceTabular}|, |{NiceTabular*}| and |{NiceTabularX}|. + +In fact, this command is available only if the extension \pkg{enumitem} +\index{enumitem@\pkg{enumitem} (package required to use\newline \texttt{\textbackslash tabularnote})} has +been loaded (before or after \pkg{nicematrix}). Indeed, the notes are composed +at the end of the array with a type of list provided by the package +\pkg{enumitem}. + +\begin{scope} +\fvset{commandchars=\~\#\!} +\begin{Verbatim} +\begin{NiceTabular}{@{}llr@{}} +\toprule \RowStyle{\bfseries} +Last name & First name & Birth day \\ +\midrule +Achard\tabularnote{~emphase#Achard is an old family of the Poitou.!} +& Jacques & 5 juin 1962 \\ +Lefebvre\tabularnote{~emphase#The name Lefebvre is an alteration of the name Lefebure.!} +& Mathilde & 23 mai 1988 \\ +Vanesse & Stephany & 30 octobre 1994 \\ +Dupont & Chantal & 15 janvier 1998 \\ +\bottomrule +\end{NiceTabular} +\end{Verbatim} +\end{scope} + +\begin{center} +\begin{NiceTabular}{@{}llr@{}} +\toprule \RowStyle{\bfseries} +Last name & First name & Birth day \\ +\midrule +Achard\tabularnote{Achard is an old family of the Poitou.} +& Jacques & June 5, 2005 \\ +Lefebvre\tabularnote{The name Lefebvre is an alteration of the name Lefebure.} +& Mathilde & January 23, 1975 \\ +Vanesse & Stephany & October 30, 1994 \\ +Dupont & Chantal & January 15, 1998 \\ +\bottomrule +\end{NiceTabular} +\end{center} + + +\bigskip +\begin{itemize} +\item If you have several successive commands |\tabularnote{...}| \emph{with no +space at all between them}, the labels of the corresponding notes are composed +together, separated by commas (this is similar to the option |multiple| of +\pkg{footmisc} for the footnotes). + +\item If a command |\tabularnote{...}| is exactly at the end of a cell (with +no space at all after), the label of the note is composed in an overlapping +position (towards the right). This structure may provide a better alignment of +the cells of a given column. + +\item If the key |notes/para| is used, the notes are composed at the end of +the array in a single paragraph (as with the key |para| of \pkg{threeparttable}). + +\item \index{tabularnote (key of \texttt{\{NiceTabular\}})} +There is a key |tabularnote| which provides a way to insert some text in +the zone of the notes before the numbered tabular notes. + +\index{tabularnote@\texttt{\{TabularNote\}}} +An alternative syntax is available with the environment |{TabularNote}|. That +environment should be used at the end of the environment |{NiceTabular}| (but +\emph{before} a potential instruction |\CodeAfter|). + +\item If the package \pkg{booktabs} has been loaded (before or after +\pkg{nicematrix}), the key |notes/bottomrule| draws a |\bottomrule| of +\pkg{booktabs} \emph{after} the notes. + +\item The command |\tabularnote| may be used \emph{before} +the environment of \pkg{nicematrix}. Thus, it's possible to use it on the +title inserted by |\caption| in an environment |{table}| of LaTeX (or in a +command |\captionof| of the package \pkg{caption}). It's also possible, as +expected, to use the command |\tabularnote| in the caption provided by the +\emph{key} |caption| of the environment |{NiceTabaular}|. + +If several commands |\tabularnote| are used in a tabular with the same +argument, only one note is inserted at the end of the tabular (but all the +labels are composed, of course). It's possible to control that feature with +the key |notes/detect-duplicates|.\footnote{For technical reasons, the final +user is not allowed to put several commands |\tabularnote| with exactly the +same argument in the caption of the tabular.} + +\item It's possible to create a reference to a tabular note created by |\tabularnote| +(with the usual command |\label| used after the |\tabularnote|). + +\item \colorbox{yellow!50}{\textbf{New 6.19}} The command |\tabularnote| has an +optional argument (between square brackets) to change the symbol of the +reference of the note. + +\emph{Example}: |\tabularnote[$\star$]{A footnote...}| +\end{itemize} +% +For an illustration of some of those remarks, see table +\ref{t:tabularnote}, p.~\pageref{t:tabularnote}. This table has been composed +with the following code (the package \pkg{caption} has been loaded in this document). + +\begin{center} +\fvset{commandchars=\~\#\!} +\begin{Verbatim}[formatcom=\small\color{gray}] +\begin{table} +\centering +\NiceMatrixOptions{caption-above} +\begin{NiceTabular}{@{}llc@{} + [ + caption = A tabular whose caption has been specified by the key + \texttt{caption}~emphase#\tabularnote[$\star$]{It's possible to put a tabular note in the caption}! , + label = t:tabularnote , + tabularnote = Some text before the notes. , + notes/bottomrule + ] +\toprule +Last name & First name & Length of life \\ +\midrule +Churchill & Wiston & 91\\ +Nightingale~emphase#\tabularnote{Considered as the first nurse of history}!% +~emphase#\tabularnote{Nicknamed ``the Lady with the Lamp''.}! +& Florence~emphase#\tabularnote{This note is shared by two references.}! & 90 \\ +Schoelcher & Victor & 89~emphase#\tabularnote{The label of the note is overlapping.}!\\ +Touchet & Marie~emphase#\tabularnote{This note is shared by two references.}! & 89 \\ +Wallis & John & 87 \\ +\bottomrule +\end{NiceTabular} +\end{table} +\end{Verbatim} +\end{center} + + +\begin{table}[hbt] +\centering +\NiceMatrixOptions{caption-above} +\begin{NiceTabular}{@{}llc@{}}[ + caption = A tabular whose caption has been specified by the key + \texttt{caption}\tabularnote[$\star$]{It's possible to put a tabular note in the caption} , + label = t:tabularnote , + tabularnote = Some text before the notes. , + notes/bottomrule + ] +\toprule +Last name & First name & Length of life \\ +\midrule +Churchill & Wiston & 91\\ +Nightingale\tabularnote{Considered as the first nurse of +history.}\tabularnote{Nicknamed ``the Lady with the Lamp''.} +& Florence\tabularnote{This note is shared by two references.} & 90 \\ +Schoelcher & Victor & 89\tabularnote{The label of the note is overlapping.}\\ +Touchet & Marie\tabularnote{This note is shared by two references.} & 89 \\ +Wallis & John & 87 \\ +\bottomrule +\end{NiceTabular} +\end{table} + + +\subsection{Customisation of the tabular notes} + +\index{para (subkey of ``notes'')} +\index{bottomrule (subkey of ``notes'')} +\index{style (subkey of ``notes'')} +\index{label-in-tabular (subkey of ``notes'')} +\index{label-in-list (subkey of ``notes'')} +\index{enumitem-keys (subkey of ``notes'')} +\index{enumitem-keys-para (subkey of ``notes'')} +\index{code-before!subkey of ``notes''} +\index{detect-duplicates (subkey of ``notes'')} + + +The tabular notes can be customized with a set of keys available in +|\NiceMatrixOptions|. The name of these keys is prefixed by |notes|. +\begin{itemize} +\item |notes/para| +\item |notes/bottomrule| +\item |notes/style| +\item |notes/label-in-tabular| +\item |notes/label-in-list| +\item |notes/enumitem-keys| +\item |notes/enumitem-keys-para| +\item |notes/code-before| +\end{itemize} +For sake of commodity, it is also possible to set these keys in +|\NiceMatrixOptions| via a key |notes| which takes in as value a list of +pairs \textsl{key=value} where the name of the keys need no longer be +prefixed by |notes|: +\begin{center} +\begin{BVerbatim}[formatcom = \small \color{gray}] +\NiceMatrixOptions + { + notes = + { + bottomrule , + style = ... , + label-in-tabular = ... , + enumitem-keys = + { + labelsep = ... , + align = ... , + ... + } + } + } +\end{BVerbatim} +\end{center} + + +\bigskip +We detail these keys. + +\begin{itemize}[itemsep=\medskipamount] +\item The key |notes/para| requires the composition of the notes (at the end of +the tabular) in a single paragraph. + +Initial value: |false| + +That key is also available within a given environment. + +\item The key |notes/bottomrule| adds a |\bottomrule| of \pkg{booktabs} +\emph{after} the notes. Of course, that rule is drawn only if there is really +notes in the tabular. The package \pkg{booktabs} must have been loaded (before +or after the package \pkg{nicematrix}). If it is not, an error is raised. + +Initial value: |false| + +That key is also available within a given environment. + +\item The key |notes/style| is a command whose argument is specified by |#1| +and which gives the style of numerotation of the notes. That style will be +used by |\ref| when referencing a tabular note marked with a command |\label|. +The labels formatted by that style are used, separated by commas, when the user +puts several consecutive commands |\tabularnote|. The marker |#1| is meant to +be the name of a LaTeX counter. + +Initial value: |\textit{\alph{#1}}| + +Another possible value should be a mere |\arabic{#1}| + +\item The key |notes/label-in-tabular| is a command whose argument is +specified by |#1| which is used when formatting the label of a note in the +tabular. Internally, this number of note has already been formatted by +|notes/style| before sent to that command. + +Initial value: |\textsuperscript{#1}| + +In French, it's a tradition of putting a small space before the label of note. +That tuning could be acheived by the following code: +% +\begin{Verbatim} +\NiceMatrixOptions{notes/label-in-tabular = \,\textsuperscript{~#1}} +\end{Verbatim} + + +\item The key |notes/label-in-list| is a command whose argument is specified +by |#1| which is used when formatting the label in the list of notes at the +end of the tabular. Internally, this number of note has already been formatted by +|notes/style| before sent to that command. + +Initial value: |\textsuperscript{#1}| + +In French, the labels of notes are not composed in upper position when +composing the notes. Such behaviour could be acheived by: +\begin{Verbatim} +\NiceMatrixOptions{notes/label-in-list = ~#1.\nobreak\hspace{0.25em}} +\end{Verbatim} +The command |\nobreak| is for the event that the option |para| is used. + + +\item The notes are composed at the end of the tabular by using internally a +style of list of \pkg{enumitem}. This style of list is defined as follows (with, of +course, keys of \pkg{enumitem}): + +|noitemsep , leftmargin = * , align = left , labelsep = 0pt| + +The specification |align = left| in that style requires a +composition of the label leftwards in the box affected to that label. +With that tuning, the notes are composed flush left, which is pleasant when +composing tabulars in the spirit of \pkg{booktabs} (see for example the +table \ref{t:tabularnote}, p.~\pageref{t:tabularnote}). + +\medskip +The key |notes/enumitem-keys| specifies a list of pairs +\textsl{key=value} (following the specifications of \pkg{enumitem}) to +customize that style of list (it uses internally the command |\setlist*| of +\pkg{enumitem}). + + +\item The key |notes/enumitem-keys-para| is similar to the previous one but +corresponds to the type of list used when the option |para| is in force. Of +course, when the option |para| is used, a list of type |inline| (as called by +\pkg{enumitem}) is used and the pairs \textsl{key=value} should correspond to +such a list of type |inline|. + +Initially, the style of list is defined by:\quad +|afterlabel = \nobreak, itemjoin = \quad| + + +\item The key |notes/code-before| is a token list inserted by \pkg{nicematrix} +just before the composition of the notes at the end of the tabular. + +Initial value: \textsl{empty} + +For example, if one wishes to compose all the notes in gray and |\footnotesize|, +he should use that key: +\begin{Verbatim} +\NiceMatrixOptions{notes/code-before = \footnotesize \color{gray}} +\end{Verbatim} +It's also possible to add |\raggedright| or |\RaggedRight| in that key (|\RaggedRight| +is a command of \pkg{ragged2e}). + +\item The key |notes/detect-duplicates| activates the detection of the commands +|\tabularnotes| with the same argument. + +Initial value : |true| +\end{itemize} + +\index{nota@\textbf{Notes in the tabulars}|)} + +\bigskip +For an example of customisation of the tabular notes, see p.~\pageref{ex:notes}. + + +\subsection{Use of \{NiceTabular\} with threeparttable} + +\index{threeparttable@\pkg{threeparttable} (package)} + +If you wish to use an environment |{NiceTabular}|, |{NiceTabular*}| or +|{NiceTabularX}| in an environment |{threeparttable}| of the eponymous package, +you have to patch |{threeparttable}| with the following code (with a version of +LaTeX at least 2020/10/01). +\begin{Verbatim}[commandchars=\~\#\!] +\makeatletter +\AddToHook{env/threeparttable/begin} + {\TPT@hookin{NiceTabular}\TPT@hookin{NiceTabular*}\TPT@hookin{NiceTabularX}} +\makeatother +\end{Verbatim} + +Nevertheless, the use of \pkg{threeparttable} in conjonction with +\pkg{nicematrix} seems rather point-less because of the functionalities +provided by \pkg{nicematrix} (see the key |caption| in the section +\ref{s:caption}, p.~\pageref{s:caption}). + + +\section{Other features} + +\subsection{The key rounded-corners of \{NiceTabular\}} + +\label{tabular-rounded-corners} +\index{rounded-corners!key of \texttt{\{NiceTabular\}}} +\index{Corners (rounded ---)!for a tabular} + +\colorbox{yellow!50}{\textbf{New 6.18}}\par\nobreak + +\smallskip +The key |rounded-corners| that we will describe now has no direct link with +the key |corners| (which is used to specify ``empty corners'') described in +the part~\ref{corners}, p.~\pageref{corners}. + +\smallskip +The environment |{NiceTabular}| provides a key |rounded-corners| which specify +that the tabular should have rounded corners with a radius equal to the value of +that key (the default value is 4~pt\footnote{This value is the initial value of + the \emph{rounded corners} of Tikz.}). More precisely, that key has two +effects that we describe now. +\begin{itemize} +\item All the commands for coloring the cells, columns and rows (in the +|\CodeBefore| but also directly in the array when the key |colortbl-like| is +used) will respect those rounded corners. + +\item When the key |hvlines| is used, the exterior rules will be drawn with +rounded corners. +\end{itemize} + +\bigskip +\begin{BVerbatim}[baseline=c,boxwidth=9cm] +\begin{NiceTabular} + [hvlines,~emphase#rounded-corners@] + {ccc} +\CodeBefore + \rowcolor{red!15}{1} +\Body +Last name & First name & Profession \\ +Arvy & Jacques & Physicist \\ +Jalon & Amandine & Physicist +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{ccc}[hvlines,rounded-corners] +\CodeBefore + \rowcolor{red!15}{1} +\Body +Last name & First name & Profession \\ +Arvy & Jacques & Physicist \\ +Jalon & Amandine & Physicist +\end{NiceTabular} + + +\subsection{Command \textbackslash ShowCellNames} + +\index{ShowCellNames@\texttt{\textbackslash ShowCellNames} (command of +\texttt{\textbackslash CodeAfter}\newline and +\texttt{\textbackslash CodeBefore})} + + +The command |\ShowCellNames|, which may be used in the |\CodeBefore| and in +the |\CodeAfter| displays the name (with the form $i$-$j$) of each cell. When +used in the |\CodeAfter|, that command applies a semi-transparent white +rectangle to fade the array (caution: some \textsc{pdf} readers don't support +transparency). + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=10.6cm] +\begin{NiceTabular}{ccc}[hvlines,cell-space-limits=3pt] + \Block{2-2}{} & & test \\ + & & blabla \\ + & some text & nothing +~emphase#\CodeAfter \ShowCellNames@ +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{ccc}[hvlines,cell-space-limits=3pt] + \Block{2-2}{} & & test \\ + & & blabla \\ + & some text & nothing +\CodeAfter \ShowCellNames +\end{NiceTabular} + + +\subsection{Use of the column type S of siunitx} + +\index{S (the columns S of \pkg{siunitx})} +\index{siunitx@\pkg{siunitx} (package)} + +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 = 11cm] +$\begin{pNiceArray}{~emphase#S@cW{c}{1cm}c}[nullify-dots,first-row] +{C_1} & \Cdots & & C_n \\ +2.3 & 0 & \Cdots & 0 \\ +12.4 & \Vdots & & \Vdots \\ +1.45 \\ +7.2 & 0 & \Cdots & 0 +\end{pNiceArray}$ +\end{BVerbatim} +$\begin{pNiceArray}{ScW{c}{1cm}c}[nullify-dots,first-row] +{C_1} & \Cdots & & C_n \\ +2.3 & 0 & \Cdots & 0 \\ +12.4 & \Vdots & & \Vdots \\ +1.45 \\ +7.2 & 0 & \Cdots & 0 +\end{pNiceArray}$ + +\medskip +On the other hand, the |d| columns of the package \pkg{dcolumn} are not +supported by \pkg{nicematrix}. + + +\subsection{Default column type in \{NiceMatrix\}} + +\label{columns-width} +\index{columns-type (key of \texttt{\{NiceMatrix\}}, etc.)} + +The environments without preamble (|{NiceMatrix}|, |{pNiceMatrix}|, +|{bNiceMatrix}|, etc.) and the commande |\pAutoNiceMatrix| (and its variants) +provide an option |columns-type| to specify the type of column which will be +used (the initial value is, of course, |c|). + +The keys |l| and |r| are shortcuts for |columns-type=l| and |columns-type=r|. + + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +$\begin{bNiceMatrix}[r] +\cos x & - \sin x \\ +\sin x & \cos x +\end{bNiceMatrix}$ +\end{BVerbatim} +$\begin{bNiceMatrix}[r] +\cos x & - \sin x \\ +\sin x & \cos x +\end{bNiceMatrix}$ + +\medskip +The key |columns-type| is available in |\NiceMatrixOptions| but with the +prefix |matrix|, which means that its name is, within |\NiceMatrixOptions| : +|matrix/columns-type|. + +\subsection{The command \textbackslash rotate} + +\label{rotate} +\index{rotate@\texttt{\textbackslash rotate}} + +The package \pkg{nicematrix} provides a command |\rotate|. When used in the +beginning of a cell, this command composes the contents of the cell after a +rotation of 90° in the direct sens. + +In the following command, we use that command in the +|code-for-first-row|.\footnote{It can also be used in |\RowStyle| +(cf.~p.~\pageref{RowStyle}.)} + +\bigskip + +\begin{BVerbatim}[baseline=c,boxwidth=12cm] +\NiceMatrixOptions% + {code-for-first-row = \scriptstyle ~emphase#\rotate@ \text{image of }, + code-for-last-col = \scriptstyle } +$A = \begin{pNiceMatrix}[first-row,last-col=4] +e_1 & e_2 & e_3 \\ +1 & 2 & 3 & e_1 \\ +4 & 5 & 6 & e_2 \\ +7 & 8 & 9 & e_3 +\end{pNiceMatrix}$ +\end{BVerbatim} +\begin{varwidth}{10cm} +\NiceMatrixOptions% + {code-for-first-row = \scriptstyle\rotate \text{image of }, + code-for-last-col = \scriptstyle } +$ A = \begin{pNiceMatrix}[first-row,last-col=4] +e_1 & e_2 & e_3 \\ +1 & 2 & 3 & e_1 \\ +4 & 5 & 6 & e_2 \\ +7 & 8 & 9 & e_3 +\end{pNiceMatrix}$ +\end{varwidth} + +\bigskip +If the command |\rotate| is used in the ``last row'' (exterior to the matrix), +the corresponding elements are aligned upwards as shown below. + +\bigskip +\index{first-row|textit} +\index{last-row|textit} +\index{code-for-first-row|textit} +\index{code-for-last-row|textit} +\index{last-col|textit} +\index{code-for-last-col|textit} + +\begin{BVerbatim}[baseline=c,boxwidth=12cm] +\NiceMatrixOptions% + {code-for-last-row = \scriptstyle ~emphase#\rotate@ , + code-for-last-col = \scriptstyle } +$A = \begin{pNiceMatrix}[last-row=4,last-col=4] +1 & 2 & 3 & e_1 \\ +4 & 5 & 6 & e_2 \\ +7 & 8 & 9 & e_3 \\ +\text{image of } e_1 & e_2 & e_3 +\end{pNiceMatrix}$ +\end{BVerbatim} +\begin{varwidth}{10cm} +\NiceMatrixOptions% + {code-for-last-row = \scriptstyle\rotate , + code-for-last-col = \scriptstyle }% +$A = \begin{pNiceMatrix}[last-row=4,last-col=4] +1 & 2 & 3 & e_1 \\ +4 & 5 & 6 & e_2 \\ +7 & 8 & 9 & e_3 \\ +\text{image of } e_1 & e_2 & e_3 +\end{pNiceMatrix}$ +\end{varwidth} + + + +\subsection{The option small} + +\label{small} +\index{small (key for an environment)} +\index{smallmatrix@\texttt{\{smallmatrix\}} (environment of \pkg{amsmath})} + + +With the option |small|, the environments of the package \pkg{nicematrix} +are composed in a way similar to the environment |{smallmatrix}| of the +package \pkg{amsmath} (and the environments |{psmallmatrix}|, +|{bsmallmatrix}|, etc. of the package \pkg{mathtools}). + +\bigskip +\begin{Verbatim} +$\begin{bNiceArray}{cccc|c}[~emphase#small@, + last-col, + code-for-last-col = \scriptscriptstyle, + columns-width = 3mm ] +1 & -2 & 3 & 4 & 5 \\ +0 & 3 & 2 & 1 & 2 & L_2 \gets 2 L_1 - L_2 \\ +0 & 1 & 1 & 2 & 3 & L_3 \gets L_1 + L_3 +\end{bNiceArray}$ +\end{Verbatim} +% +\[\begin{bNiceArray}{cccc|c}[small, last-col, + code-for-last-col = \scriptscriptstyle, + columns-width=3mm] +1 & -2 & 3 & 4 & 5 \\ +0 & 3 & 2 & 1 & 2 & L_2 \gets 2 L_1 - L_2 \\ +0 & 1 & 1 & 2 & 3 & L_3 \gets L_1 + L_3 +\end{bNiceArray}\] + + +\bigskip +One should note that the environment |{NiceMatrix}| with the option |small| is +not composed \emph{exactly} as the environment |{smallmatrix}|. Indeed, all +the environments of \pkg{nicematrix} are constructed upon |{array}| (of the +package \pkg{array}) whereas the environment |{smallmatrix}| is constructed +directly with an |\halign| of TeX. + +\medskip +In fact, the option |small| corresponds to the following tuning: +\begin{itemize} +\item the cells of the array are composed with |\scriptstyle|; +\item |\arraystretch| is set to $0.47$; +\item |\arraycolsep| is set to $1.45$~pt; +\item the characteristics of the dotted lines are also modified. +\end{itemize} + +\medskip +When the key |small| is in force, some functionalities of \pkg{nicematrix} are +no longer available: for example, it's no longer possible to put vertical +delimiters directly in the preamble of an environment with preamble (cf. +section \ref{delimiters-in-preamble}, p.~\pageref{delimiters-in-preamble}). + + +\subsection{The counters iRow and jCol} + +\label{iRow} +\index{iRow (LaTeX counter)} +\index{jCol (LaTeX counter)} + +In the cells of the array, it's possible to use the LaTeX counters |iRow| and +|jCol| which represent the number of the current row and the number of the +current column\footnote{We recall that the exterior ``first row'' (if it +exists) has the number~$0$ and that the exterior ``first column'' (if it +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 |\CodeBefore| (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). + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=10.6cm] +$\begin{pNiceMatrix}% don't forget the % + [first-row, + first-col, + code-for-first-row = \mathbf{~emphase#\alph{jCol}@} , + code-for-first-col = \mathbf{~emphase#\arabic{iRow}@} ] +& & & & \\ +& 1 & 2 & 3 & 4 \\ +& 5 & 6 & 7 & 8 \\ +& 9 & 10 & 11 & 12 +\end{pNiceMatrix}$ +\end{BVerbatim} +$\begin{pNiceMatrix}[first-row, + first-col, + code-for-first-row = \mathbf{\alph{jCol}} , + code-for-first-col = \mathbf{\arabic{iRow}} ] +& & & & \\ +& 1 & 2 & 3 & 4 \\ +& 5 & 6 & 7 & 8 \\ +& 9 & 10 & 11 & 12 +\end{pNiceMatrix}$ + +\medskip +If LaTeX counters called |iRow| and |jCol| are defined in the document by +packages other than \pkg{nicematrix} (or by the final user), they are shadowed +in the environments of \pkg{nicematrix}. + +\bigskip +\indexcommand{AutoNiceMatrix} +\indexcommand{pAutoNiceMatrix} +\indexcommand{bAutoNiceMatrix} +\indexcommand{vAutoNiceMatrix} +\indexcommand{VAutoNiceMatrix} +\indexcommand{BAutoNiceMatrix} +The package \pkg{nicematrix} also provides commands in order to compose +automatically matrices from a general pattern. These commands are +|\AutoNiceMatrix|, |\pAutoNiceMatrix|, |\bAutoNiceMatrix|, |\vAutoNiceMatrix|, +|\VAutoNiceMatrix| and |\BAutoNiceMatrix|. + +These commands take in two mandatory arguments. The first is the format of the +matrix, with the syntax $n$-$p$ where $n$ is the number of rows and $p$ the +number of columns. The second argument is the pattern (it's a list of tokens +which are inserted in each cell of the constructed matrix). + +\medskip +\begin{Verbatim} +$C = ~emphase#\pAutoNiceMatrix@{3-3}{C_{\arabic{iRow},\arabic{jCol}}}$ +\end{Verbatim} + + +\[C = \pAutoNiceMatrix{3-3}{C_{\arabic{iRow},\arabic{jCol}}}\] + + +\subsection{The key light-syntax} + +\label{light-syntax} +\index{light-syntax} + +The option |light-syntax| (inpired by the package \pkg{spalign}) allows the +user to compose the arrays with a lighter syntax, which gives a better +legibility of the TeX source. + +When this option is used, one should use the semicolon for the end of a row +and spaces or tabulations to separate the columns. However, as usual in the +TeX world, the spaces after a control sequence are discarded and the elements +between curly braces are considered as a whole. + + +\medskip +\begin{scope} +\begin{BVerbatim}[baseline=c,boxwidth=10cm] +$\begin{bNiceMatrix}[~emphase#light-syntax@,first-row,first-col] +{} a b ; +a 2\cos a {\cos a + \cos b} ; +b \cos a+\cos b { 2 \cos b } +\end{bNiceMatrix}$ +\end{BVerbatim} +\end{scope} +$\begin{bNiceMatrix}[light-syntax,first-row,first-col] +{} a b ; +a 2\cos a {\cos a + \cos b} ; +b \cos a+\cos b { 2 \cos b } +\end{bNiceMatrix}$ + +\medskip +\index{end-of-row (to be used with light-syntax)} +It's possible to change the character used to mark the end of rows with the +option |end-of-row|. As said before, the initial value is a semicolon. + +\medskip +When the option |light-syntax| is used, it is not possible to put verbatim +material (for example with the command |\verb|) in the cells of the +array.\footnote{The reason is that, when the option |light-syntax| is used, +the whole content of the environment is loaded as a TeX argument to be +analyzed. The environment doesn't behave in that case as a standard +environment of LaTeX which only put TeX commands before and after the content.} + + +\subsection{Color of the delimiters} + +\index{delimiters!---/color for an environment} +\index{color!for the delimiters of the matrices} +\index{Colour!of the delimiters of the matrices} + + +For the environments with delimiters (|{pNiceArray}|, |{pNiceMatrix}|, etc.), +it's possible to change the color of the delimiters with the key +|delimiters/color|. + +\medskip +\begin{BVerbatim}[boxwidth=12cm,baseline=c] +$\begin{bNiceMatrix}[delimiters/color=red] +1 & 2 \\ +3 & 4 +\end{bNiceMatrix}$ +\end{BVerbatim} +$\begin{bNiceMatrix}[delimiters/color=red] +1 & 2 \\ +3 & 4 +\end{bNiceMatrix}$ + +\medskip +This color also applies to the delimiters drawn by the command |\SubMatrix| +(cf.~p.~\pageref{sub-matrix}) and for the delimiters directly specified in the +preamble of the environments with preamble +(cf.~p.~\pageref{delimiters-in-preamble}). + +\subsection{The environment \{NiceArrayWithDelims\}} + +\label{NiceArrayWithDelims} +\index{NiceArrayWithDelims@\texttt{\{NiceArrayWithDelims\}}} + +In fact, the environment |{pNiceArray}| and its variants are based upon a +more general environment, called |{NiceArrayWithDelims}|. 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 |{NiceArrayWithDelims}| if we want to use atypical or +asymetrical delimiters. + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=11cm] +$\begin{~emphase#NiceArrayWithDelims@} + {\downarrow}{\uparrow}{ccc}[margin] +1 & 2 & 3 \\ +4 & 5 & 6 \\ +7 & 8 & 9 +\end{~emphase#NiceArrayWithDelims@}$ +\end{BVerbatim} +$\begin{NiceArrayWithDelims} + {\downarrow}{\uparrow}{ccc}[margin] +1 & 2 & 3 \\ +4 & 5 & 6 \\ +7 & 8 & 9 +\end{NiceArrayWithDelims}$ + +\subsection{The command \textbackslash OnlyMainNiceMatrix} + +\indexcommand{OnlyMainNiceMatrix} + +The command |\OnlyMainNiceMatrix| executes its argument only when it is in the +main part of the array, that is to say when it is not in one of the exterior +rows. If it is used outside an environment of \pkg{nicematrix}, that command is +no-op. + +For an example of utilisation, see \url{tex.stackexchange.com/questions/488566} + +\section{Use of Tikz with nicematrix} + +\label{name}\label{PGF-nodes} +\index{tikza@TikZ (utilisation with \pkg{nicematrix})} +\index{node@\textbf{Nodes of PGF/Tikz}|(} + +\subsection{The nodes corresponding to the contents of the cells} + +The package \pkg{nicematrix} creates a PGF/Tikz node\footnote{We recall that Tikz +is a layer over PGF. The extension \pkg{nicematrix} loads PGF but does not +load Tikz. We speak of PGF/Tikz nodes to emphase the fact that the PGF nodes +created by \pkg{nicematrix} may be used with PGF but also with Tikz. The final +user will probably prefer to use Tikz rather than PGF.} for each (non-empty) cell +of the considered array. These nodes are used to draw the dotted lines between +the cells of the matrix (inter alia). + + +\smallskip +\textbf{Caution} : By default, no node is created in a empty cell. + +\smallskip +However, it's possible to impose the creation of a node with the command +|\NotEmpty|. \footnote{One should note that, with that command, the cell is +considered as non-empty, which has consequencies for the continuous dotted +lines (cf. p.~\pageref{Cdots}) and the computation of the ``corners'' +(cf.~p.~\pageref{corners}).} + +\medskip +The nodes of a document must have distinct names. That's why the names of the +nodes created by \pkg{nicematrix} contains the number of the current +environment. Indeed, the environments of \pkg{nicematrix} are numbered by a +internal global counter. + +\smallskip +In the environment with the number $n$, the node of the row $i$ and +column~$j$ has for name |nm-|$n$|-|$i$|-|$j$. + +\smallskip +The command |\NiceMatrixLastEnv| provides the number of the last environment +of \pkg{nicematrix} (for LaTeX, it's a ``fully expandable'' command and not a +counter). + +\smallskip +\index{name!key for an environment} +However, it's advisable to use instead the key |name|. This key gives a name +to the current environment. When the environment has a name, the nodes are +accessible with the name ``\textsl{name}-$i$-$j$'' where \textsl{name} is the +name given to the array and $i$ and $j$ the numbers of row and column. It's +possible to use these nodes with \textsc{pgf} but the final user will +probably prefer to use Tikz (which is a convenient layer upon \textsc{pgf}). +However, one should remind that \pkg{nicematrix} doesn't load Tikz by default. +In the following examples, we assume that Tikz has been loaded. + +\bigskip +\begin{BVerbatim}[baseline=c,boxwidth=11cm] +$\begin{pNiceMatrix}[name=~emphase#mymatrix@] +1 & 2 & 3 \\ +4 & 5 & 6 \\ +7 & 8 & 9 +\end{pNiceMatrix}$ +\tikz[remember picture,overlay] + \draw ~emphase#(mymatrix-2-2)@ circle (2mm) ; +\end{BVerbatim} +$\begin{pNiceMatrix}[name=mymatrix] +1 & 2 & 3 \\ +4 & 5 & 6 \\ +7 & 8 & 9 +\end{pNiceMatrix}$ +\tikz[remember picture,overlay] + \draw (mymatrix-2-2) circle (2mm) ; + +\medskip +Don't forget the options |remember picture| and |overlay|. + +\bigskip +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). + + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=11cm] +$\begin{pNiceMatrix} +1 & 2 & 3 \\ +4 & 5 & 6 \\ +7 & 8 & 9 +\CodeAfter + \tikz \draw ~emphase#(2-2)@ circle (2mm) ; +\end{pNiceMatrix}$ +\end{BVerbatim} +$\begin{pNiceMatrix} +1 & 2 & 3 \\ +4 & 5 & 6 \\ +7 & 8 & 9 +\CodeAfter + \tikz \draw (2-2) circle (2mm) ; +\end{pNiceMatrix}$ + +\medskip +The nodes of the last column (excepted the potential ``last column'' specified +by |last-col|\footnote{For the exterior columns, cf. part~\ref{exterior}, +p.~\pageref{exterior}.}) may also be indicated by $i$-|last|. Similarly, the +nodes of the last row may be indicated by |last|-$j$. + +\bigskip +In the following example, we have underlined all the nodes of the matrix. + +\[ +\NiceMatrixOptions + { + pgf-node-code = + { + \pgfsetfillcolor{red!15}% + \pgfusepathqfill + } + } +\begin{pNiceMatrix} +a & a + b & a + b + c \\ +a & a & a + b \\ +a & a & a +\end{pNiceMatrix}\] + + +\bigskip +\colorbox{yellow!50}{\textbf{New 6.17}}\enskip Since those nodes are PGF +nodes, one won't be surprised to learn that they are drawn by using a specific +PGF style. That style is called |nicematrix/cell-node| and its definition in +the source file |nicematrix.sty| is as follows: + +\begin{Verbatim} +\pgfset + { + ~emphase#nicematrix / cell-node@ /.style = + { + inner sep = 0 pt , + minimum width = 0 pt + } + } +\end{Verbatim} + +The final user may modify that style by changing the values of the keys |text/rotate|, +|inner xsep|, |inner ysep|, |inner sep|, |outer xsep|, |outer ysep|, |outer sep|, +|minimum width|, |minimum height| and |minimum size|. + +\medskip +For an example of utilisation, see part~\ref{triangular}, p.~\pageref{triangular}. + + +\subsubsection{The key pgf-node-code} + +\index{pgf-node-code} + +\colorbox{yellow!50}{\textbf{New 6.17}}\enskip \textbf{For the experienced +users}, \pkg{nicematrix} provides the key |pgf-node-code| which corresponds to +some PGF node that will be executed at the creation, by PGF, of the nodes +corresponding to the cells of the array. More pricisely, the value given to +the key |pgf-node-code| will be passed in the fifth argument of the command +|\pgfnode|. That value should contain at least an instruction such as +|\pgfusepath|, |\pgfusepathqstroke|, |\pgfusepathqfill|, etc. + +\subsubsection{The columns V of varwidth} + +\label{node-V} +\index{V (the columns V of \pkg{varwidth})} +\index{varwidth@\pkg{varwidth} (package)} + +When the extension \pkg{varwidth} is loaded, the columns of the type |V| +defined by \pkg{varwidth} are supported by \pkg{nicematrix}. It may be +interessant to notice that, for a cell of a column of type |V|, the PGF/Tikz +node created by \pkg{nicematrix} for the content of that cell has a width +adjusted to the content of the cell. This is in contrast to the case of the +columns of type |p|, |m| or |b| for which the nodes have always a width equal +to the width of the column. In the following example, the command |\lipsum| is +provided by the eponymous package. + +\begin{Verbatim} +\begin{NiceTabular}{V{10cm}} +\bfseries \large +Titre \\ +\lipsum[1][1-4] +\CodeAfter + \tikz \draw [rounded corners] (1-1) -| (last-|2) -- (last-|1) |- (1-1) ; +\end{NiceTabular} +\end{Verbatim} + + +\begin{center} +\begin{NiceTabular}{V{10cm}} +\bfseries \large +Titre \\ +\lipsum[1][1-4] +\CodeAfter + \tikz \draw [rounded corners] (1-1) -| (last-|2) -- (last-|1) |- (1-1) ; +\end{NiceTabular} +\end{center} + +We have used the nodes corresponding to the position of the potential rules, +which are described below (cf. p.~\pageref{nodes-i}). + + +\subsection[The medium nodes and the large nodes]{The ``medium nodes'' and the ``large nodes''} + +\index{create-medium-nodes} +\index{create-large-nodes} +\index{create-extra-nodes} + +In fact, the package \pkg{nicematrix} can create ``extra nodes'': the ``medium +nodes'' and the ``large nodes''. The first ones +are created with the option |create-medium-nodes| and the second ones with the +option |create-large-nodes|.\footnote{There is also an option +|create-extra-nodes| which is an alias for the conjonction of +|create-medium-nodes| and |create-large-nodes|.} + +\medskip +These nodes are not used by \pkg{nicematrix} by default, and that's why they +are not created by default. + +\medskip +The names of the ``medium nodes'' are constructed by adding the suffix +``|-medium|'' to the names of the ``normal nodes''. In the following example, +we have underlined the ``medium nodes''. We consider that this example is +self-explanatory. +\[\begin{pNiceMatrix}[create-medium-nodes] +\CodeBefore [create-cell-nodes] + \begin{tikzpicture} + [every node/.style = {fill = red!15, inner sep = 0 pt}, + name suffix = -medium] + \node [fit = (1-1)] {} ; + \node [fit = (1-2)] {} ; + \node [fit = (1-3)] {} ; + \node [fit = (2-1)] {} ; + \node [fit = (2-2)] {} ; + \node [fit = (2-3)] {} ; + \node [fit = (3-1)] {} ; + \node [fit = (3-2)] {} ; + \node [fit = (3-3)] {} ; +\end{tikzpicture} +\Body +a & a + b & a + b + c \\ +a & a & a + b \\ +a & a & a +\end{pNiceMatrix}\] + + +\medskip +\index{left-margin} +\index{right-margin} +The names of the ``large nodes'' are constructed by adding the suffix +``|-large|'' to the names of the ``normal nodes''. In the following example, +we have underlined the ``large nodes''. We consider that this example is +self-explanatory.\footnote{There is no ``large nodes'' created in the exterior +rows and columns (for these rows and columns, cf. p.~\pageref{exterior}).} +\[\begin{pNiceMatrix}[create-large-nodes] +\CodeBefore [create-cell-nodes] + \begin{tikzpicture} + [every node/.style = { inner sep = 0 pt} , + name suffix = -large] + \node [fit = (1-1),fill = red!15] {} ; + \node [fit = (1-3),fill = red!15] {} ; + \node [fit = (2-2),fill = red!15] {} ; + \node [fit = (3-1),fill = red!15] {} ; + \node [fit = (3-3),fill = red!15] {} ; + \node [fit = (1-2),fill = blue!15] {} ; + \node [fit = (2-1),fill = blue!15] {} ; + \node [fit = (2-3),fill = blue!15] {} ; + \node [fit = (3-2),fill = blue!15] {} ; + \end{tikzpicture} +\Body +a & a + b & a + b + c \\ +a & a & a + b \\ +a & a & a +\end{pNiceMatrix}\] + + + +\medskip +\index{extra-left-margin} +\index{extra-right-margin} +The ``large nodes'' of the first column and last column may appear too small +for some usage. That's why it's possible to use the options |left-margin| and +|right-margin| to add space on both sides of the array and also space in the +``large nodes'' of the first column and last column. In the following example, +we have used the options |left-margin| and |right-margin|.\footnote{The +options |left-margin| and |right-margin| take dimensions as values but, if no +value is given, the default value is used, which is |\arraycolsep| (by +default: 5~pt). There is also an option |margin| to fix both |left-margin| and +|right-margin| to the same value.} +\[\begin{pNiceMatrix}[create-large-nodes,left-margin,right-margin] +\CodeBefore [create-cell-nodes] + \begin{tikzpicture} + [every node/.style = {inner sep = 0 pt}, + name suffix = -large] + \node [fit = (1-1),fill = red!15] {} ; + \node [fit = (1-3),fill = red!15] {} ; + \node [fit = (2-2),fill = red!15] {} ; + \node [fit = (3-1),fill = red!15] {} ; + \node [fit = (3-3),fill = red!15] {} ; + \node [fit = (1-2),fill = blue!15] {} ; + \node [fit = (2-1),fill = blue!15] {} ; + \node [fit = (2-3),fill = blue!15] {} ; + \node [fit = (3-2),fill = blue!15] {} ; + \end{tikzpicture} +\Body +a & a + b & a + b + c \\ +a & a & a + b \\ +a & a & a +\end{pNiceMatrix}\] + + +\medskip +It's also possible to add more space on both side of the array with the +options |extra-left-margin| and |extra-right-margin|. These margins are not +incorporated in the ``large nodes''. It's possible to fix both values with the +option |extra-margin| and, in the following example, we use |extra-margin| +with the value $3$~pt. +\[\begin{pNiceMatrix}[create-large-nodes,left-margin,right-margin,extra-right-margin=3pt,extra-left-margin=3pt] +\CodeBefore [create-cell-nodes] + \begin{tikzpicture} + [every node/.style = {inner sep = 0 pt}, + name suffix = -large] + \node [fit = (1-1),fill = red!15] {} ; + \node [fit = (1-3),fill = red!15] {} ; + \node [fit = (2-2),fill = red!15] {} ; + \node [fit = (3-1),fill = red!15] {} ; + \node [fit = (3-3),fill = red!15] {} ; + \node [fit = (1-2),fill = blue!15] {} ; + \node [fit = (2-1),fill = blue!15] {} ; + \node [fit = (2-3),fill = blue!15] {} ; + \node [fit = (3-2),fill = blue!15] {} ; + \end{tikzpicture} +\Body +a & a + b & a + b + c \\ +a & a & a + b \\ +a & a & a +\end{pNiceMatrix}\] + + + +\bigskip +\textbf{Be careful} : These nodes are reconstructed from the contents of the +contents cells of the array. Usually, they do not correspond to the cells +delimited by the rules (if we consider that these rules are drawn). + +\bigskip +\begin{minipage}[c]{7.6cm} +Here is an array composed with the following code: + +\medskip +\begin{BVerbatim} +\large +\begin{NiceTabular}{wl{2cm}ll}[hvlines] +fraise & amande & abricot \\ +prune & pêche & poire \\[1ex] +noix & noisette & brugnon +\end{NiceTabular} +\end{BVerbatim} +\end{minipage} +\hspace{0.9cm} +\begin{scope} +\large +\begin{NiceTabular}[c]{wl{2cm}ll}[hvlines] +fraise & amande & abricot \\ +prune & pêche & poire \\[1ex] +noix & noisette & brugnon +\end{NiceTabular} +\end{scope} + +\vspace{1cm} +\begin{minipage}[c]{7cm} +Here, we have colored all the cells of the array with |\chessboardcolors|. +\end{minipage} +\hspace{1.5cm} +\begin{scope} +\large +\begin{NiceTabular}[c]{wl{2cm}ll}[hvlines,code-before = \chessboardcolors{red!15}{blue!15}] +fraise & amande & abricot \\ +prune & pêche & poire \\[1ex] +noix & noisette & brugnon +\end{NiceTabular} +\end{scope} + + +\vspace{1cm} +\begin{minipage}[c]{7cm} +Here are the ``large nodes'' of this array (without use of |margin| +nor |extra-margin|). +\end{minipage} +\hspace{1.5cm} +\begin{scope} +\large +\begin{NiceTabular}[c]{w{l}{2cm}ll}[hvlines,create-large-nodes] +\CodeBefore [create-cell-nodes] + \begin{tikzpicture} + [every node/.style = {inner sep = 0 pt}, + name suffix = -large] + \node [fit = (1-1),fill = red!15] {} ; + \node [fit = (1-3),fill = red!15] {} ; + \node [fit = (2-2),fill = red!15] {} ; + \node [fit = (3-1),fill = red!15] {} ; + \node [fit = (3-3),fill = red!15] {} ; + \node [fit = (1-2),fill = blue!15] {} ; + \node [fit = (2-1),fill = blue!15] {} ; + \node [fit = (2-3),fill = blue!15] {} ; + \node [fit = (3-2),fill = blue!15] {} ; + \end{tikzpicture} +\Body +fraise & amande & abricot \\ +prune & pêche & poire \\[1ex] +noix & noisette & brugnon +\end{NiceTabular} +\end{scope} + + +\vspace{1cm} +The nodes we have described are not available by default in the |\CodeBefore| +(described p.~\pageref{code-before}).\par\nobreak + +\index{create-cell-nodes (key of \texttt{\textbackslash CodeBefore})} +It's possible to have these nodes available in the |\CodeBefore| by using the +key |create-cell-nodes| of the keyword |\CodeBefore| (in that case, the nodes +are created first before the construction of the array by using informations +written on the |aux| file and created a second time during the contruction of +the array itself). + +\bigskip +Here is an example which uses these nodes in the |\CodeAfter|. + +\begin{center} +\fvset{commandchars=\~\#\+} +\begin{Verbatim} +\begin{NiceArray}{c@{\;}c@{\;}c@{\;}c@{\;}c}[create-medium-nodes] + u_1 &-& u_0 &=& r \\ + u_2 &-& u_1 &=& r \\ + u_3 &-& u_2 &=& r \\ + u_4 &-& u_3 &=& r \\ + \phantom{u_5} & & \phantom{u_4} &\smash{\vdots} & \\ + u_n &-& u_{n-1} &=& r \\[3pt] + \hline + u_n &-& u_0 &=& nr \\ +\CodeAfter + \tikz[very thick, red, opacity=0.4, name suffix = -medium] + \draw (1-1.north west) -- (2-3.south east) + (2-1.north west) -- (3-3.south east) + (3-1.north west) -- (4-3.south east) + (4-1.north west) -- (5-3.south east) + (5-1.north west) -- (6-3.south east) ; +\end{NiceArray} +\end{Verbatim} +\end{center} + +\[\begin{NiceArray}{c@{\;}c@{\;}c@{\;}c@{\;}c}[create-medium-nodes] + u_1 &-& u_0 &=& r \\ + u_2 &-& u_1 &=& r \\ + u_3 &-& u_2 &=& r \\ + u_4 &-& u_3 &=& r \\ + \phantom{u_5} & & \phantom{u_4} &\smash{\vdots} & \\ + u_n &-& u_{n-1} &=& r \\[3pt] + \hline + u_n &-& u_0 &=& nr \\ + \CodeAfter + \tikz[very thick, red, opacity=0.4, name suffix = -medium] + \draw (1-1.north west) -- (2-3.south east) + (2-1.north west) --(3-3.south east) + (3-1.north west) -- (4-3.south east) + (4-1.north west) -- (5-3.south east) + (5-1.north west) -- (6-3.south east) ; +\end{NiceArray}\] + + + +\subsection{The nodes which indicate the position of the rules} + +\label{nodes-i} +The package \pkg{nicematrix} creates a PGF/Tikz node merely called $i$ (with +the classical prefix) at the intersection of the horizontal rule of number~$i$ +and the vertical rule of number~$i$ (more specifically the potential position +of those rules because maybe there are not actually drawn). The last node has +also an alias called |last|. There is also a node called $i$|.5| midway +between the node $i$ and the node $i+1$. + +These nodes are available in the |\CodeBefore| and the |\CodeAfter|. + +\begin{center} +\begin{NiceTabular}{ccc}[hvlines,rules/width=1pt,rules/color=gray] + & tulipe & lys \\ +arum & & violette mauve \\ +muguet & dahlia +\CodeAfter + \tiny + \begin{tikzpicture} + \foreach \i in {1,1.5,2,2.5,3,3.5,4} + { + \fill [red] (\i) circle (0.5mm) ; + \node [red,above right] at (\i) {\i} ; + } + \end{tikzpicture} +\end{NiceTabular} +\end{center} + +\bigskip +If we use Tikz (we remind that \pkg{nicematrix} does not load Tikz by default, +by only \textsc{pgf}, which is a sub-layer of Tikz), we can access, in the +|\CodeAfter| but also in the |\CodeBefore|, to the intersection of the +(potential) horizontal rule~$i$ and the (potential) vertical rule~$j$ with the +syntax |(|$i$\verb+-|+$j$|)|. + +\medskip +\begin{Verbatim} +\begin{NiceMatrix} +\CodeBefore + ~emphase#\tikz \draw [fill=red!15] (7-|4) |- (8-|5) |- (9-|6) |- cycle ;@ +\Body +1 \\ +1 & 1 \\ +1 & 2 & 1 \\ +1 & 3 & 3 & 1 \\ +1 & 4 & 6 & 4 & 1 \\ +1 & 5 & 10 & 10 & 5 & 1 \\ +1 & 6 & 15 & 20 & 15 & 6 & 1 \\ +1 & 7 & 21 & 35 & 35 & 21 & 7 & 1 \\ +1 & 8 & 28 & 56 & 70 & 56 & 28 & 8 & 1 +\end{NiceMatrix} +\end{Verbatim} +% +\[\begin{NiceMatrix} +\CodeBefore + \tikz \draw [fill=red!15] (7-|4) |- (8-|5) |- (9-|6) |- cycle ; +\Body +1 \\ +1 & 1 \\ +1 & 2 & 1 \\ +1 & 3 & 3 & 1 \\ +1 & 4 & 6 & 4 & 1 \\ +1 & 5 & 10 & 10 & 5 & 1 \\ +1 & 6 & 15 & 20 & 15 & 6 & 1 \\ +1 & 7 & 21 & 35 & 35 & 21 & 7 & 1 \\ +1 & 8 & 28 & 56 & 70 & 56 & 28 & 8 & 1 +\end{NiceMatrix}\] + + +\bigskip +The nodes of the form $i$|.5| may be used, for example to cross a row of a +matrix (if Tikz is loaded). + +\smallskip +\begin{BVerbatim}[boxwidth=11cm,baseline=c] +$\begin{pNiceArray}{ccc|c} +2 & 1 & 3 & 0 \\ +3 & 3 & 1 & 0 \\ +3 & 3 & 1 & 0 +\CodeAfter + \tikz \draw [red] (~emphase#3.5@-|1) -- (~emphase#3.5@-|last) ; +\end{pNiceArray}$ +\end{BVerbatim} +$\begin{pNiceArray}{ccc|c} +2 & 1 & 3 & 0 \\ +3 & 3 & 1 & 0 \\ +3 & 3 & 1 & 0 +\CodeAfter + \tikz \draw [red] (3.5-|1) -- (3.5-|last) ; +\end{pNiceArray}$ + +\subsection{The nodes corresponding to the command \textbackslash SubMatrix} + +\label{node-sub-matrix} +\index{SubMatrix@\texttt{\textbackslash SubMatrix} (command of +\texttt{\textbackslash CodeAfter}\newline and +\texttt{\textbackslash CodeBefore})} +\index{name!key of \texttt{\textbackslash SubMatrix}} + + +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}\] + +\index{node@\textbf{Nodes of PGF/Tikz}|)} + +\section{API for the developpers} + +The package \pkg{nicematrix} provides two variables which are internal but +public\footnote{According to the LaTeX3 conventions, +each variable with name beginning with |\g_nicematrix| ou |\l_nicematrix| is +public and each variable with name beginning with |\g__nicematrix| or +|\l__nicematrix| is private.}: +\begin{itemize} +\item |\g_nicematrix_code_before_tl| ; +\item |\g_nicematrix_code_after_tl|. +\end{itemize} + + +\medskip +These variables contain the code of what we have called the ``|code-before|'' +(usually specified at the beginning of the environment with the syntax using +the keywords |\CodeBefore| and |\Body|) and the ``|code-after|'' (usually +specified at the end of the environment after the keyword |\CodeAfter|). The +developper can use them to add code from a cell of the array (the affectation +must be global, allowing to exit the cell, which is a TeX group). + +\medskip +One should remark that the use of |\g_nicematrix_code_before_tl| needs one +compilation more (because the instructions are written on the |aux| file to be +used during the next run). + +\bigskip +\emph{Example} : We want to write a command |\crossbox| to draw a cross in the +current cell. This command will take in an optional argument between square +brackets for a list of pairs \textsl{key}-\textsl{value} which will be given to +Tikz before the drawing. + +It's possible to program such command |\crossbox| as follows, explicitely +using the public variable |\g_nicematrix_code_before_tl|. + +\index{crossbox@\texttt{\textbackslash crossbox} (defined in an example)|textit} + +\begin{scope} +\fvset{commandchars=\§\¤\μ} +\begin{Verbatim} +\ExplSyntaxOn +\cs_new_protected:Nn \__pantigny_crossbox:nnn + { + \tikz \draw [ #3 ] + ( #1 -| \int_eval:n { #2 + 1 } ) -- ( \int_eval:n { #1 + 1 } -| #2 ) + ( #1 -| #2 ) -- ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ; + } + +\NewDocumentCommand \crossbox { ! O { } } + { + \tl_gput_right:Nx §emphase¤\g_nicematrix_code_before_tlμ + { + \__pantigny_crossbox:nnn + { \int_use:c { c@iRow } } + { \int_use:c { c@jCol } } + { \exp_not:n { #1 } } + } + } +\ExplSyntaxOff +\end{Verbatim} +\end{scope} + + +\ExplSyntaxOn +\cs_new_protected:Nn \__pantigny_crossbox:nnn + { + \tikz \draw [ #3 ] + ( #1 -| \int_eval:n { #2 + 1 } ) -- ( \int_eval:n { #1 + 1 } -| #2 ) + ( #1 -| #2 ) -- ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ; + } + + +\NewDocumentCommand \crossbox { ! O { } } + { + \tl_gput_right:Nx \g_nicematrix_code_before_tl + { + \__pantigny_crossbox:nnn + { \int_use:c { c@iRow } } + { \int_use:c { c@jCol } } + { \exp_not:n { #1 } } + } + } +\ExplSyntaxOff + +\bigskip +Here is an example of utilisation: + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=9cm] +\begin{NiceTabular}{ccc}[hvlines] +\CodeBefore + \arraycolor{gray!10} +\Body +merlan & requin & cabillaud \\ +baleine & ~emphase#\crossbox[red]@ & morue \\ +mante & raie & poule +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{ccc}[hvlines] +\CodeBefore + \arraycolor{gray!10} +\Body +merlan & requin & cabillaud \\ +baleine & \crossbox[red] & morue \\ +mante & raie & poule +\end{NiceTabular} + + + +\section{Technical remarks} + +First remark: the package \pkg{underscore} must be loaded before +\pkg{nicematrix}. If it is loaded after, an error will be raised. + +\subsection{Diagonal lines} + +\label{parallelization} +\index{parallelize-diags} +\index{Ddots@\texttt{\textbackslash Ddots}} +\index{Iddots@\texttt{\textbackslash Iddots}} + +By default, all the diagonal lines\footnote{We speak of the lines created by +|\Ddots| and not the lines created by a command |\line| in the |\CodeAfter|.} of a +same array are ``parallelized''. That means that the first diagonal line is +drawn and, then, the other lines are drawn parallel to the first one (by +rotation around the left-most extremity of the line). That's why the position +of the instructions |\Ddots| in the array can have a marked effect on the +final result. + +\medskip +In the following examples, the first |\Ddots| instruction is written in color: + +% \medskip +\begin{scope} +\begin{minipage}{9.5cm} +Example with parallelization (default): +\begin{Verbatim} +$A = \begin{pNiceMatrix} +1 & \Cdots & & 1 \\ +a+b & ~emphase#\Ddots@~ & & \Vdots \\ +\Vdots & \Ddots & & \\ +a+b & \Cdots & a+b & 1 +\end{pNiceMatrix}$ +\end{Verbatim} +\end{minipage} +$A = \begin{pNiceMatrix} +1 & \Cdots & & 1 \\ +a+b & \Ddots & & \Vdots \\ +\Vdots & \Ddots & & \\ +a+b & \Cdots & a+b & 1 +\end{pNiceMatrix}$ + +\bigskip +\NiceMatrixOptions{parallelize-diags=true}% +\begin{minipage}{9.5cm} +\begin{Verbatim} +$A = \begin{pNiceMatrix} +1 & \Cdots & & 1 \\ +a+b & & & \Vdots \\ +\Vdots & ~emphase#\Ddots@~ & \Ddots & \\ +a+b & \Cdots & a+b & 1 +\end{pNiceMatrix}$ +\end{Verbatim} +\end{minipage} +$A = \begin{pNiceMatrix} +1 & \Cdots & & 1 \\ +a+b & & & \Vdots \\ +\Vdots & \Ddots & \Ddots & \\ +a+b & \Cdots & a+b & 1 +\end{pNiceMatrix}$ + +\bigskip +It's possible to turn off the parallelization with the option +|parallelize-diags| set to |false|: \par\nobreak + +\medskip +\NiceMatrixOptions{parallelize-diags=false}% +\begin{minipage}{9.5cm} +The same example without parallelization: +\end{minipage} +$A = \begin{pNiceMatrix} +1 & \Cdots & & 1 \\ +a+b & \Ddots & & \Vdots \\ +\Vdots & \Ddots & & \\ +a+b & \Cdots & a+b & 1 +\end{pNiceMatrix}$ + +\end{scope} + +It's possible to specify the instruction |\Ddots| which will be drawn first +(and which will be used to draw the other diagonal dotted lines when the +parallelization is in force) with the key |draw-first|: |\Ddots[draw-first]|. + +\subsection[The empty cells]{The ``empty'' cells} + +\label{empty-cells} +An instruction like |\Ldots|, |\Cdots|, etc. tries to determine the first +non-empty cell on both sides. When the key |corners| is used +(cf.~p.~\pageref{corners}), \pkg{nicematrix} computes corners consisting of +empty cells. 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~|&|). +The precise rules are as follow. + +\begin{itemize} +\item An implicit cell is empty. For example, in the following matrix: + +\begin{Verbatim} +\begin{pmatrix} +a & b \\ +c \\ +\end{pmatrix} +\end{Verbatim} + +the last cell (second row and second column) is empty. + +\medskip +\item For the columns of type |p|, |m|, |b|, |V|\footnote{The columns of type +|V| are provided by \pkg{varwidth}: cf.~p.~\pageref{varwidth}.} and +|X|\footnote{See p.~\pageref{X-columns}}, the cell is empty if (and only if) +its content in the TeX code is empty (there is only spaces between the +ampersands |&|). + +\medskip +\item For the columns of type |c|, |l|, |r| and |w{...}{...}|, the cell is +empty if (and only if) its TeX output has a width equal to zero. + +\medskip +\item \indexcommand{NotEmpty} +A cell containing the command |\NotEmpty| is not empty (and a PGF/Tikz +node is created in that cell). + +\medskip +\item A cell with only a command |\Hspace| (or |\Hspace*|) is empty. This +command |\Hspace| is a command defined by the package \pkg{nicematrix} with +the same meaning as |\hspace| except that the cell where it is used is +considered as empty. This command can be used to fix the width of some columns +of the matrix without interfering with \pkg{nicematrix}. +\end{itemize} + + +\subsection{The option exterior-arraycolsep} + +\index{exterior-arraycolsep} + +The environment |{array}| inserts an horizontal space equal to |\arraycolsep| +before and after each column. In particular, there is a space equal to +|\arraycolsep| before and after the array. This feature of the environment +|{array}| was probably not a good idea\footnote{In the documentation of +\pkg{amsmath}, we can read: {\itshape The extra space of |\arraycolsep| that +\pkg{array} adds on each side is a waste so we remove it [in |{matrix}|] +(perhaps we should instead remove it from array in general, but that's a +harder task).}}. The environment |{matrix}| of +\pkg{amsmath} and its variants (|{pmatrix}|, |{vmatrix}|, etc.) of +\pkg{amsmath} prefer to delete these spaces with explicit instructions +|\hskip -\arraycolsep|\footnote{And not by inserting |@{}| on both sides of the +preamble of the array. As a consequence, the length of the |\hline| is not +modified and may appear too long, in particular when using square brackets.}. +The package \pkg{nicematrix} does the same in all its environments, +|{NiceArray}| included. However, if the user wants the environment +|{NiceArray}| behaving by default like the environment |{array}| of +\pkg{array} (for example, when adapting an existing document) it's possible to +control this behaviour with the option |exterior-arraycolsep|, set by the +command |\NiceMatrixOptions|. With this option, exterior spaces of length +|\arraycolsep| will be inserted in the environments |{NiceArray}| (the other +environments of \pkg{nicematrix} are not affected). + + + + +\subsection{Incompatibilities} + +\index{Incompatibilities} + +The package \pkg{nicematrix} is not compatible with the class \cls{ieeeaccess} +(because that class is not compatible with PGF/Tikz).\footnote{See + \url{https://tex.stackexchange.com/questions/528975/error-loading-tikz-in-ieeeaccess-class}} + +\bigskip +In order to use \pkg{nicematrix} with the class \cls{aastex631} +(of the \emph{American Astronomical Society}), you have to +add the following lines in the preamble of your document : + +\begin{Verbatim} +\BeforeBegin{NiceTabular}{\let\begin\BeginEnvironment\let\end\EndEnvironment} +\BeforeBegin{NiceArray}{\let\begin\BeginEnvironment} +\BeforeBegin{NiceMatrix}{\let\begin\BeginEnvironment} +\end{Verbatim} + +\bigskip +In order to use \pkg{nicematrix} with the class \cls{sn-jnl} (of +\emph{Springer Nature}), \pkg{pgf} must +be loaded before the |\documentclass| with |\RequirePackage|: + +\begin{Verbatim} +\RequirePackage{pgf} +\documentclass{sn-jnl} +\end{Verbatim} + +\bigskip +The package \pkg{nicematrix} is not fully compatible with the packages and classes +of \LuaTeX-ja: the detection of the empty corners (cf. % p.~\pageref{corners}) +may be wrong in some circonstances. + +\bigskip +The package \pkg{nicematrix} is not fully compatible with the package +\pkg{arydshln} (because this package redefines many internals of \pkg{array}). +By any means, in the context of \pkg{nicematrix}, it's recommended to draw +dashed rules with the tools provided by \pkg{nicematrix}, by creating a +customized line style with |custom-line|: cf.~p.~\pageref{custom-line}. + +\bigskip +The columns |d| of \pkg{dcolumn} are not supported (but it's possible to use +the colums |S| of \pkg{siunitx}). + +\section{Examples} + +\subsection[{Utilisation of the key 'tikz' of the command \textbackslash +Block}]{Utilisation of the key ``tikz'' of the command \textbackslash Block} +\label{tikz-key-examples} + +\index{tikzz@tikz!key of \texttt{\textbackslash Block}|textit} + +The key |tikz| of the command |\Block| is available only when Tikz is +loaded.\footnote{By default, \pkg{nicematrix} only loads \textsc{pgf}, which is +a sub-layer of Tikz.} + +For the following example, we also need the Tikz library |patterns|. + +\begin{Verbatim} +\usetikzlibrary{patterns} +\end{Verbatim} + + +\begin{Verbatim} +\ttfamily \small +\begin{NiceTabular}{X[m]X[m]X[m]}[hvlines,cell-space-limits=3pt] + \Block[~emphase#tikz={pattern=grid,pattern color=lightgray}@]{} + {pattern = grid,\\ pattern color = lightgray} +& \Block[~emphase#tikz={pattern = north west lines,pattern color=blue}@]{} + {pattern = north west lines,\\ pattern color = blue} +& \Block[~emphase#tikz={outer color = red!50, inner color=white }@]{2-1} + {outer color = red!50,\\ inner color = white} \\ + \Block[~emphase#tikz={pattern = sixpointed stars, pattern color = blue!15}@]{} + {pattern = sixpointed stars,\\ pattern color = blue!15} +& \Block[~emphase#tikz={left color = blue!50}@]{} + {left color = blue!50} \\ +\end{NiceTabular} +\end{Verbatim} + +\begin{center} +\ttfamily \small +\begin{NiceTabular}{X[m]X[m]X[m]}[hvlines,cell-space-limits=3pt] + \Block[tikz={pattern=grid,pattern color=lightgray}]{} + {pattern = grid,\\ pattern color = lightgray} +& \Block[tikz={pattern = north west lines,pattern color=blue}]{} + {pattern = north west lines,\\ pattern color = blue} +& \Block[tikz={outer color = red!50, inner color=white }]{2-1} + {outer color = red!50,\\ inner color = white} \\ + \Block[tikz={pattern = sixpointed stars, pattern color = blue!15}]{} + {pattern = sixpointed stars,\\ pattern color = blue!15} +& \Block[tikz={left color = blue!50}]{} + {left color = blue!50} \\ +\end{NiceTabular} +\end{center} + +\bigskip +In the following example, we use the key |tikz| to hatch a row of the tabular. +Remark that you use the key |transparent| of the command |\Block| in order to +have the rules drawn in the block.\footnote{By default, the rules are not +drawn in the blocks created by the command |\Block|: cf.~section~\ref{rules} +p.~\pageref{rules}} + +\index{transparent (key of \texttt{\textbackslash Block})|textit} +\index{columncolor@\texttt{\textbackslash columncolor}!command of + \texttt{\textbackslash CodeBefore}|textit} + + +\begin{Verbatim} +\begin{NiceTabular}{ccc}[hvlines] +\CodeBefore + \columncolor[RGB]{169,208,142}{2} +\Body +one & two & three \\ +\Block[~emphase#transparent, tikz={pattern = north west lines, pattern color = gray}@]{1-*}{} +four & five & six \\ +seven & eight & nine +\end{Verbatim} + +\begin{center} +\begin{NiceTabular}{ccc}[hvlines] +\CodeBefore + \columncolor[RGB]{169,208,142}{2} +\Body +one & two & three \\ +\Block[transparent, tikz={pattern = north west lines, pattern color = gray}]{1-*}{} +four & five & six \\ +seven & eight & nine +\end{NiceTabular} +\end{center} + +\subsection{Use with tcolorbox} + +\label{tcolorbox} +\index{tcolorbox@\pkg{tcolorbox} (package)|textit} + +Here is an example of use of |{NiceTabular}| within a command |\tcbox| of +\pkg{tcolorbox}. We have used the key |hvlines-except-borders| in order all +the rules excepted on the borders (which are, of course, added by \pkg{tcolorbox}) + +\medskip +\begin{BVerbatim} +\tcbset + { + colframe = blue!50!black , + colback = white , + colupper = red!50!black , + fonttitle = \bfseries , + nobeforeafter , + center title + } + +\tcbox + [ + left = 0mm , + right = 0mm , + top = 0mm , + bottom = 0mm , + boxsep = 0mm , + toptitle = 0.5mm , + bottomtitle = 0.5mm , + title = My table + ] + { + \renewcommand{\arraystretch}{1.2}% <-- the % is mandatory here + \begin{NiceTabular}{rcl}[~emphase#hvlines-except-borders@,rules/color=blue!50!black] + \CodeBefore + \rowcolor{red!15}{1} + \Body + One & Two & Three \\ + Men & Mice & Lions \\ + Upper & Middle & Lower + \end{NiceTabular} + } +\end{BVerbatim} + + +\index{hvlines-except-borders|textit} +\index{rules (key for an environment)|textit} +\index{rowcolor@\texttt{\textbackslash rowcolor}!command of \texttt{\textbackslash CodeBefore}|textit} + +\medskip +\begin{center} +\tcbset + { + colframe = blue!50!black , + colback = white , + colupper = red!50!black , + fonttitle = \bfseries , + nobeforeafter , + center title + } + +\tcbox + [ + left = 0mm , + right = 0mm , + top = 0mm , + bottom = 0mm , + boxsep = 0mm , + toptitle = 0.5mm , + bottomtitle = 0.5mm , + title = My table + ] + { + \renewcommand{\arraystretch}{1.2}\begin{NiceTabular}{rcl}[hvlines-except-borders,rules/color=blue!50!black] + \CodeBefore + \rowcolor{red!15}{1} + \Body + One & Two & Three \\ + Men & Mice & Lions \\ + Upper & Middle & Lower + \end{NiceTabular} + } +\end{center} + + + +\vspace{1cm} +That example shows the use of \pkg{nicematrix} in conjunction with +\pkg{tcolorbox}. If one wishes a tabular with an exterior frame with rounded +corners, it's not necessary to use \pkg{tcolorbox}: it's possible to use the +command |\Block| with the key |rounded-corners|. + +\medskip +\begin{BVerbatim}[baseline=c,boxwidth=10.5cm] +\begin{NiceTabular}{rcl}[hvlines-except-borders] +\Block[draw,transparent,~emphase#rounded-corners@]{*-*}{} + One & Two & Three \\ + Men & Mice & Lions \\ + Upper & Middle & Lower +\end{NiceTabular} +\end{BVerbatim} +\begin{NiceTabular}{rcl}[hvlines-except-borders] +\Block[draw,transparent,rounded-corners]{*-*}{} + One & Two & Three \\ + Men & Mice & Lions \\ + Upper & Middle & Lower +\end{NiceTabular} + +\medskip +We have used the key |transparent| to have the rules specified by +|hvlines-except-borders| drawn in the blocks (by default, the rules are not +drawn in the blocks). + +\subsection{Notes in the tabulars} + +\index{nota@\textbf{Notes in the tabulars}|textit} +\index{tabularnote@\texttt{\textbackslash tabularnote}|textit} +\index{notes (key to customize the notes of a\newline tabular)|textit} +\index{style (subkey of ``notes'')|textit} +\index{enumitem-keys (subkey of ``notes'')|textit} +\index{enumitem@\pkg{enumitem} (package required to use\newline \texttt{\textbackslash tabularnote})|textit} + + +\label{ex:notes} + +The tools provided by \pkg{nicematrix} for the composition of the tabular +notes have been presented in the section \ref{s:notes} p.~\pageref{s:notes}. + +\medskip +Let's consider that we wish to number the notes of a tabular with +stars.\footnote{Of course, it's realistic only when there is very few notes in +the tabular.} + +\medskip +First, we write a command |\stars| similar the well-known commands +|\arabic|, |\alph|, |\Alph|, etc. which produces a number of stars equal to +its argument\footnote{In fact: the value of its argument.}. +\begin{Verbatim} +\ExplSyntaxOn +\NewDocumentCommand ~emphase#\stars@ { m } + { \prg_replicate:nn { \value { ~#1 } } { $ \star $ } } +\ExplSyntaxOff +\end{Verbatim} +% +Of course, we change the style of the labels with the key |notes/style|. +However, it would be interesting to change also some parameters in the type of +list used to compose the notes at the end of the tabular. +First, we required a composition flush right for the labels with the setting +|align=right|. +Moreover, we want the labels to be composed on a width equal to the width of +the widest label. The widest label is, of course, the label with the greatest +number of stars. We know that number: it is equal to |\value{tabularnote}| +(because |tabularnote| is the LaTeX counter used by |\tabularnote| and, +therefore, at the end of the tabular, its value is equal to the total number +of tabular notes). We use the key |widest*| of \pkg{enumitem} in order to +require a width equal to that value: |widest*=\value{tabularnote}|. +\begin{Verbatim} +\NiceMatrixOptions + { + notes = + { + ~emphase#style = \stars{~#1} , @ + ~emphase#enumitem-keys = @ + ~emphase# { @ + ~emphase# widest* = \value{tabularnote} ,@ + ~emphase# align = right @ + ~emphase# } @ + } + } +\end{Verbatim} + + + +\begin{scope} +\ExplSyntaxOn +\NewDocumentCommand \stars { m } + { \prg_replicate:nn { \value { #1 } } { $ \star $ } } +\NiceMatrixOptions + { + notes = + { + style = \stars{#1} , + enumitem-keys = + { + widest* = \value{tabularnote} , + align = right + } + } + } +\ExplSyntaxOff +\begin{Verbatim} +\begin{NiceTabular}{~@{}llr~@{}} +\toprule \RowStyle{\bfseries} +Last name & First name & Birth day \\ +\midrule +Achard\tabularnote{~emphase#Achard is an old family of the Poitou.@} +& Jacques & 5 juin 1962 \\ +Lefebvre\tabularnote{~emphase#The name Lefebvre is an alteration of the name Lefebure.@} +& Mathilde & 23 mai 1988 \\ +Vanesse & Stephany & 30 octobre 1994 \\ +Dupont & Chantal & 15 janvier 1998 \\ +\bottomrule +\end{NiceTabular} +\end{Verbatim} + +\begin{center} +\begin{NiceTabular}{@{}llr@{}} +\toprule \RowStyle{\bfseries} +Last name & First name & Birth day \\ +\midrule +Achard\tabularnote{Achard is an old family of the Poitou.} +& Jacques & June 5, 2005 \\ +Lefebvre\tabularnote{The name Lefebvre is an alteration of the name Lefebure.} +& Mathilde & January 23, 1975 \\ +Vanesse & Stephany & October 30, 1994 \\ +Dupont & Chantal & January 15, 1998 \\ +\bottomrule +\end{NiceTabular} +\end{center} +\end{scope} + + + +\subsection{Dotted lines} + +\index{dotted@\textbf{Dotted lines}|textit} + +An example with the resultant of two polynoms:\par\nobreak + +\bigskip +\begin{BVerbatim} +\setlength{\extrarowheight}{1mm} +\[\begin{vNiceArray}{cccc:ccc}[columns-width=6mm] +a_0 & && &b_0 & & \\ +a_1 &\Ddots&& &b_1 &\Ddots& \\ +\Vdots&\Ddots&& &\Vdots &\Ddots&b_0 \\ +a_p & &&a_0 & & &b_1 \\ + &\Ddots&&a_1 &b_q & &\Vdots\\ + & &&\Vdots & &\Ddots& \\ + & &&a_p & & &b_q +\end{vNiceArray}\] +\end{BVerbatim} + +\bigskip +\index{Ddots@\texttt{\textbackslash Ddots}|textit} + +\begin{scope} +\setlength{\extrarowheight}{1mm} +\[\begin{vNiceArray}{cccc:ccc}[columns-width=6mm] +a_0 & && &b_0 & & \\ +a_1 &\Ddots&& &b_1 &\Ddots& \\ +\Vdots&\Ddots&& &\Vdots &\Ddots&b_0 \\ +a_p & &&a_0 & & &b_1 \\ + &\Ddots&&a_1 &b_q & &\Vdots\\ + & &&\Vdots & &\Ddots& \\ + & &&a_p & & &b_q +\end{vNiceArray}\] +\end{scope} + +\vspace{2cm} +An example for a linear system:\par\nobreak + +\index{last-col|textit} +\index{code-for-last-col|textit} + +\begin{Verbatim} +$\begin{pNiceArray}{*6c|c}[nullify-dots,last-col,code-for-last-col=\scriptstyle] +1 & 1 & 1 &\Cdots & & 1 & 0 & \\ +0 & 1 & 0 &\Cdots & & 0 & & L_2 \gets L_2-L_1 \\ +0 & 0 & 1 &\Ddots & & \Vdots & & L_3 \gets L_3-L_1 \\ + & & &\Ddots & & & \Vdots & \Vdots \\ +\Vdots & & &\Ddots & & 0 & \\ +0 & & &\Cdots & 0 & 1 & 0 & L_n \gets L_n-L_1 +\end{pNiceArray}$ +\end{Verbatim} + + +\[\begin{pNiceArray}{*6c|c}[nullify-dots,last-col,code-for-last-col=\scriptstyle] +1 & 1 & 1 &\Cdots & & 1 & 0 & \\ +0 & 1 & 0 &\Cdots & & 0 & & L_2 \gets L_2-L_1 \\ +0 & 0 & 1 &\Ddots & & \Vdots & & L_3 \gets L_3-L_1 \\ + & & &\Ddots & & & \Vdots & \Vdots \\ +\Vdots & & &\Ddots & & 0 & \\ +0 & & &\Cdots & 0 & 1 & 0 & L_n \gets L_n-L_1 +\end{pNiceArray}\] + + + +\subsection{Dotted lines which are no longer dotted} + +The option |line-style| controls the style of the lines drawn by |\Ldots|, +|\Cdots|, etc. Thus, it's possible with these commands to draw lines which are +not longer dotted. + +\index{line-style (key for the dotted rules)|textit} + +\begin{Verbatim}[formatcom=\small\color{gray}] +\NiceMatrixOptions{code-for-first-row = \scriptstyle,code-for-first-col = \scriptstyle } +\setcounter{MaxMatrixCols}{12} +\newcommand{\blue}{\color{blue}} +\[\begin{pNiceMatrix}[last-row,last-col,nullify-dots,xdots/line-style={dashed,blue}] +1& & & \Vdots & & & & \Vdots \\ +& \Ddots[line-style=standard] \\ +& & 1 \\ +\Cdots[color=blue,line-style=dashed]& & & \blue 0 & +\Cdots & & & \blue 1 & & & \Cdots & \blue \leftarrow i \\ +& & & & 1 \\ +& & &\Vdots & & \Ddots[line-style=standard] & & \Vdots \\ +& & & & & & 1 \\ +\Cdots & & & \blue 1 & \Cdots & & \Cdots & \blue 0 & & & \Cdots & \blue \leftarrow j \\ +& & & & & & & & 1 \\ +& & & & & & & & & \Ddots[line-style=standard] \\ +& & & \Vdots & & & & \Vdots & & & 1 \\ +& & & \blue \overset{\uparrow}{i} & & & & \blue \overset{\uparrow}{j} \\ +\end{pNiceMatrix}\] +\end{Verbatim} + +\index{code-for-first-row|textit} +\index{code-for-last-col|textit} + + +\begin{scope} +\NiceMatrixOptions{code-for-first-row = \scriptstyle,code-for-first-col = \scriptstyle } +\setcounter{MaxMatrixCols}{12} +\newcommand{\blue}{\color{blue}} +\[\begin{pNiceMatrix}[last-row,last-col,nullify-dots,xdots/line-style={dashed,blue}] +1& & & \Vdots & & & & \Vdots \\ +& \Ddots[line-style=standard] \\ +& & 1 \\ +\Cdots[color=blue,line-style=dashed]& & & \blue 0 & +\Cdots & & & \blue 1 & & & \Cdots & \blue \leftarrow i \\ +& & & & 1 \\ +& & &\Vdots & & \Ddots[line-style=standard] & & \Vdots \\ +& & & & & & 1 \\ +\Cdots & & & \blue 1 & \Cdots & & \Cdots & \blue 0 & & & \Cdots & \blue \leftarrow j \\ +& & & & & & & & 1 \\ +& & & & & & & & & \Ddots[line-style=standard] \\ +& & & \Vdots & & & & \Vdots & & & 1 \\ +& & & \blue \overset{\uparrow}{i} & & & & \blue \overset{\uparrow}{j} \\ +\end{pNiceMatrix}\] +\end{scope} + +\interitem +In fact, it's even possible to draw solid lines with the commands |\Cdots|, +|\Vdots|, etc.\footnote{In this document, the Tikz library \pkg{arrows.meta} +has been loaded, which impacts the shape of the arrow tips.} + +\begin{Verbatim} +\NiceMatrixOptions + {nullify-dots,code-for-first-col = \color{blue},code-for-first-row=\color{blue}} +$\begin{pNiceMatrix}[first-row,first-col] + & & \Ldots[line-style={solid,<->},shorten=0pt]^{n \text{ columns}} \\ + & 1 & 1 & 1 & \Ldots & 1 \\ + & 1 & 1 & 1 & & 1 \\ +\Vdots[line-style={solid,<->}]_{n \text{ rows}} & 1 & 1 & 1 & & 1 \\ + & 1 & 1 & 1 & & 1 \\ + & 1 & 1 & 1 & \Ldots & 1 +\end{pNiceMatrix}$ +\end{Verbatim} + + +\begin{scope} +\NiceMatrixOptions + {nullify-dots,code-for-first-col = \color{blue},code-for-first-row=\color{blue}} +\[\begin{pNiceMatrix}[first-row,first-col] + & & \Ldots[line-style={solid,<->},shorten=0pt]^{n \text{ columns}} \\ + & 1 & 1 & 1 & \Ldots & 1 \\ + & 1 & 1 & 1 & & 1 \\ +\Vdots[line-style={solid,<->}]_{n \text{ rows}} & 1 & 1 & 1 & & 1 \\ + & 1 & 1 & 1 & & 1 \\ + & 1 & 1 & 1 & \Ldots & 1 +\end{pNiceMatrix}\] +\end{scope} + +\subsection{Dashed rules} +\label{dashed} +\index{tikzz@tikz!key of ``borders'' de \texttt{\textbackslash Block}|textit} + +In the following example, we use the command |\Block| to draw dashed rules. +For that example, Tikz should be loaded (by |\usepackage{tikz}|). + + +\begin{Verbatim} +\begin{pNiceMatrix} +~emphase#\Block[borders={bottom,right,tikz=dashed}]{2-2}{}@ +1 & 2 & 0 & 0 & 0 & 0 \\ +4 & 5 & 0 & 0 & 0 & 0 \\ +0 & 0 & ~emphase#\Block[borders={bottom,top,right,left,tikz=dashed}]{2-2}{}@ + 7 & 1 & 0 & 0 \\ +0 & 0 & -1 & 2 & 0 & 0 \\ +0 & 0 & 0 & 0 & ~emphase#\Block[borders={left,top,tikz=dashed}]{2-2}{}@ + 3 & 4 \\ +0 & 0 & 0 & 0 & 1 & 4 +\end{pNiceMatrix} +\end{Verbatim} + + +\[\begin{pNiceMatrix} +\Block[borders={bottom,right,tikz=dashed}]{2-2}{} +1 & 2 & 0 & 0 & 0 & 0 \\ +4 & 5 & 0 & 0 & 0 & 0 \\ +0 & 0 & \Block[borders={bottom,top,right,left,tikz=dashed}]{2-2}{} + 7 & 1 & 0 & 0 \\ +0 & 0 & -1 & 2 & 0 & 0 \\ +0 & 0 & 0 & 0 & \Block[borders={left,top,tikz=dashed}]{2-2}{} + 3 & 4 \\ +0 & 0 & 0 & 0 & 1 & 4 +\end{pNiceMatrix}\] + + +\subsection{Stacks of matrices} + +\index{NiceMatrixBlock@\texttt{\{NiceMatrixBlock\}}|textit} + +We often need to compose mathematical matrices on top on each other (for +example for the resolution of linear systems). + +\medskip +In order to have the columns aligned one above the other, it's possible to +fix a width for all the columns. That's what is done in the following example +with the environment |{NiceMatrixBlock}| and its option |auto-columns-width|. + +\begin{Verbatim}[formatcom=\small\color{gray}] +~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@ +\NiceMatrixOptions + { + light-syntax, + last-col, code-for-last-col = \color{blue} \scriptstyle, + } +\setlength{\extrarowheight}{1mm} + +$\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 {} ; + 3 -18 12 1 4 ; +-3 -46 29 -2 -15 ; + 9 10 -5 4 7 +\end{pNiceArray}$ + +\smallskip +$\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 ; +0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ; +0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ; +0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ; +\end{pNiceArray}$ + +\smallskip +$\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 ; +0 64 -41 1 19 ; +0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 } +\end{pNiceArray}$ + +\smallskip +$\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 {} ; +0 64 -41 1 19 ; +\end{pNiceArray}$ + +~emphase#\end{NiceMatrixBlock}@ +\end{Verbatim} + +\bigskip +\index{auto-columns-width!(key of \texttt{\{NiceMatrixBlock\}})|textit} +\begin{NiceMatrixBlock}[auto-columns-width] +\NiceMatrixOptions + { + light-syntax, + last-col, code-for-last-col = \color{blue} \scriptstyle , + } +\setlength{\extrarowheight}{1mm} + +\quad $\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 {} ; + 3 -18 12 1 4 ; +-3 -46 29 -2 -15 ; + 9 10 -5 4 7 +\end{pNiceArray}$ + +\smallskip +\quad $\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 ; +0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ; +0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ; +0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ; +\end{pNiceArray}$ + +\smallskip +\quad $\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 ; +0 64 -41 1 19 ; +0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 } +\end{pNiceArray}$\par\nobreak + +\smallskip +\quad $\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 {} ; +0 64 -41 1 19 ; +\end{pNiceArray}$ +\end{NiceMatrixBlock} + +\bigskip +However, one can see that the last matrix is not perfectly aligned with +others. That's why, in LaTeX, the parenthesis have not exactly the same width +(smaller parenthesis are a bit slimer). + +\medskip +\index{max-width (subkey of ``delimiters'')} +\index{delimiters!---/max-width} +In order the solve that problem, it's possible to require the delimiters to be +composed with the maximal width, thanks to the boolean key +|delimiters/max-width|. + +\begin{Verbatim}[formatcom=\small\color{gray}] +~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@ +\NiceMatrixOptions + { + ~emphase#delimiters/max-width@, + light-syntax, + last-col, code-for-last-col = \color{blue}\scriptstyle, + } +\setlength{\extrarowheight}{1mm} + +$\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 {} ; + 3 -18 12 1 4 ; +-3 -46 29 -2 -15 ; + 9 10 -5 4 7 +\end{pNiceArray}$ + +... +~emphase#\end{NiceMatrixBlock}@ +\end{Verbatim} + +\bigskip +\begin{NiceMatrixBlock}[auto-columns-width] +\NiceMatrixOptions + { + delimiters/max-width, + light-syntax, + last-col, code-for-last-col = \color{blue}\scriptstyle, + } +\setlength{\extrarowheight}{1mm} + +\quad $\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 {} ; + 3 -18 12 1 4 ; +-3 -46 29 -2 -15 ; + 9 10 -5 4 7 +\end{pNiceArray}$ + +\smallskip +\quad $\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 ; +0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ; +0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ; +0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ; +\end{pNiceArray}$ + +\smallskip +\quad $\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 ; +0 64 -41 1 19 ; +0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 } +\end{pNiceArray}$\par\nobreak + +\smallskip +\quad $\begin{pNiceArray}{rrrr|r} +12 -8 7 5 3 {} ; +0 64 -41 1 19 ; +\end{pNiceArray}$ + +\end{NiceMatrixBlock} + + +\interitem +If you wish an alignment of the different matrices without the same width +for all the columns, you can construct a unique array and place the +parenthesis with commands |\SubMatrix| in the |\CodeAfter|. Of course, that +array can't be broken by a page break. + +\medskip +\index{SubMatrix@\texttt{\textbackslash SubMatrix} (command of +\texttt{\textbackslash CodeAfter}\newline and +\texttt{\textbackslash CodeBefore})|textit} + +\begin{Verbatim} +\setlength{\extrarowheight}{1mm} +\[\begin{NiceMatrix}[ r, last-col=6, code-for-last-col = \scriptstyle \color{blue} ] +12 & -8 & 7 & 5 & 3 \\ + 3 & -18 & 12 & 1 & 4 \\ +-3 & -46 & 29 &-2 &-15 \\ + 9 & 10 &-5 &4 & 7 \\[1mm] +12 & -8 & 7 &5 & 3 \\ +0 & 64 &-41 & 1 & 19 & L_2 \gets L_1-4L_2 \\ +0 & -192 &123 &-3 &-57 & L_3 \gets L_1+4L_3 \\ +0 & -64 & 41 &-1 &-19 & L_4 \gets 3L_1-4L_4 \\[1mm] +12 & -8 &7 &5 & 3 \\ +0 & 64 &-41 &1 &19 \\ +0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm] +12 & -8 &7 &5 & 3 \\ +0 & 64 &-41 & 1 & 19 \\ +~emphase#\CodeAfter [sub-matrix/vlines=4]@ +~emphase# \SubMatrix({1-1}{4-5})@ +~emphase# \SubMatrix({5-1}{8-5})@ +~emphase# \SubMatrix({9-1}{11-5})@ +~emphase# \SubMatrix({12-1}{13-5})@ +\end{NiceMatrix}\] +\end{Verbatim} + +\medskip +\begin{scope} +\setlength{\extrarowheight}{1mm} +\[\begin{NiceMatrix}[ r, last-col=6, code-for-last-col = \scriptstyle \color{blue} ] +12 & -8 & 7 & 5 & 3 \\ + 3 & -18 & 12 & 1 & 4 \\ +-3 & -46 & 29 &-2 &-15 \\ + 9 & 10 &-5 &4 & 7 \\[1mm] +12 & -8 & 7 &5 & 3 \\ +0 & 64 &-41 & 1 & 19 & L_2 \gets L_1-4L_2 \\ +0 & -192 &123 &-3 &-57 & L_3 \gets L_1+4L_3 \\ +0 & -64 & 41 &-1 &-19 & L_4 \gets 3L_1-4L_4 \\[1mm] +12 & -8 &7 &5 & 3 \\ +0 & 64 &-41 &1 &19 \\ +0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm] +12 & -8 &7 &5 & 3 \\ +0 & 64 &-41 & 1 & 19 \\ +\CodeAfter [sub-matrix/vlines=4] + \SubMatrix({1-1}{4-5}) + \SubMatrix({5-1}{8-5}) + \SubMatrix({9-1}{11-5}) + \SubMatrix({12-1}{13-5}) +\end{NiceMatrix}\] +\end{scope} + +\bigskip +In this tabular, the instructions |\SubMatrix| are executed after the +composition of the tabular and, thus, the vertical rules are drawn without +adding space between the columns. + + +\bigskip +In fact, it's possible, with the key |vlines-in-sub-matrix|, to choice a +letter in the preamble of the array to specify vertical rules which will be +drawn in the |\SubMatrix| only (by adding space between the columns). + +\index{vlines-in-sub-matrix} +\medskip +\begin{Verbatim} +\setlength{\extrarowheight}{1mm} +\[\begin{NiceArray} + [ + ~emphase#vlines-in-sub-matrix=I@, + last-col, + code-for-last-col = \scriptstyle \color{blue} + ] + {rrrrIr} +12 & -8 & 7 & 5 & 3 \\ + 3 & -18 & 12 & 1 & 4 \\ +-3 & -46 & 29 &-2 &-15 \\ + 9 & 10 &-5 &4 & 7 \\[1mm] +12 & -8 & 7 &5 & 3 \\ +0 & 64 &-41 & 1 & 19 & L_2 \gets L_1-4L_2 \\ +0 & -192 &123 &-3 &-57 & L_3 \gets L_1+4L_3 \\ +0 & -64 & 41 &-1 &-19 & L_4 \gets 3L_1-4L_4 \\[1mm] +12 & -8 &7 &5 & 3 \\ +0 & 64 &-41 &1 &19 \\ +0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm] +12 & -8 &7 &5 & 3 \\ +0 & 64 &-41 & 1 & 19 \\ +\CodeAfter + \SubMatrix({1-1}{4-5}) + \SubMatrix({5-1}{8-5}) + \SubMatrix({9-1}{11-5}) + \SubMatrix({12-1}{13-5}) +\end{NiceArray}\] +\end{Verbatim} + + +\medskip +\begin{scope} +\setlength{\extrarowheight}{1mm} +\[\begin{NiceArray} + [ + vlines-in-sub-matrix=I, + last-col, + code-for-last-col = \scriptstyle \color{blue} + ] + {rrrrIr} +12 & -8 & 7 & 5 & 3 \\ + 3 & -18 & 12 & 1 & 4 \\ +-3 & -46 & 29 &-2 &-15 \\ + 9 & 10 &-5 &4 & 7 \\[1mm] +12 & -8 & 7 &5 & 3 \\ +0 & 64 &-41 & 1 & 19 & L_2 \gets L_1-4L_2 \\ +0 & -192 &123 &-3 &-57 & L_3 \gets L_1+4L_3 \\ +0 & -64 & 41 &-1 &-19 & L_4 \gets 3L_1-4L_4 \\[1mm] +12 & -8 &7 &5 & 3 \\ +0 & 64 &-41 &1 &19 \\ +0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm] +12 & -8 &7 &5 & 3 \\ +0 & 64 &-41 & 1 & 19 \\ +\CodeAfter + \SubMatrix({1-1}{4-5}) + \SubMatrix({5-1}{8-5}) + \SubMatrix({9-1}{11-5}) + \SubMatrix({12-1}{13-5}) +\end{NiceArray}\] +\end{scope} + + + + + +\subsection{How to highlight cells of a matrix} + + +\label{highlight} +\index{draw (key of \texttt{\textbackslash Block})|textit} + +\medskip +In order to highlight a cell of a matrix, it's possible to ``draw'' that cell +with the key |draw| of the command |\Block| (this is one of the uses of a +mono-cell block\footnote{We recall that, if the first mandatory argument of +the command |\Block| is left empty, that means that the block is a mono-cell block}). + +\label{example-CodeAfter} + + +\begin{Verbatim} +$\begin{pNiceArray}{>{\strut}cccc}[margin,rules/color=blue] +~emphase#\Block[draw]{}{a_{11}}@ & a_{12} & a_{13} & a_{14} \\ +a_{21} & \Block[draw]{}{a_{22}} & a_{23} & a_{24} \\ +a_{31} & a_{32} & \Block[draw]{}{a_{33}} & a_{34} \\ +a_{41} & a_{42} & a_{43} & \Block[draw]{}{a_{44}} \\ +\end{pNiceArray}$ +\end{Verbatim} +\[\begin{pNiceArray}{>{\strut}cccc}[margin,rules/color=blue] +\Block[draw]{}{a_{11}} & a_{12} & a_{13} & a_{14} \\ +a_{21} & \Block[draw]{}{a_{22}} & a_{23} & a_{24} \\ +a_{31} & a_{32} & \Block[draw]{}{a_{33}} & a_{34} \\ +a_{41} & a_{42} & a_{43} & \Block[draw]{}{a_{44}} \\ +\end{pNiceArray}\] + +We should remark that the rules we have drawn are drawn \emph{after} the +construction of the array and thus, they don't spread the cells of the array. +We recall that, on the other side, the commands |\hline| and |\Hline|, the +specifier ``\verb+|+'' and the options |hlines|, |vlines|, |hvlines| and +|hvlines-except-borders| spread the cells.\footnote{For the command |\cline|, +see the remark p.~\pageref{remark-cline}.} + + +\vspace{1cm} +It's possible to color a row with |\rowcolor| in the |code-before| (or with +|\rowcolor| in the first cell of the row if the key |colortbl-like| is +used−even when \pkg{colortbl} is not loaded). + +\index{colortbl-like|textit} +\index{rowcolor@\texttt{\textbackslash rowcolor}!command in tabular|textit} + + +\medskip +\begin{Verbatim} +\begin{pNiceArray}{>{\strut}cccc}[margin, extra-margin=2pt,colortbl-like] + ~emphase#\rowcolor{red!15}@A_{11} & A_{12} & A_{13} & A_{14} \\ + A_{21} & ~emphase#\rowcolor{red!15}@A_{22} & A_{23} & A_{24} \\ + A_{31} & A_{32} & ~emphase#\rowcolor{red!15}@A_{33} & A_{34} \\ + A_{41} & A_{42} & A_{43} & ~emphase#\rowcolor{red!15}@A_{44} +\end{pNiceArray} +\end{Verbatim} + + + +\[\begin{pNiceArray}{>{\strut}cccc}[margin, extra-margin=2pt,colortbl-like] + \rowcolor{red!15}A_{11} & A_{12} & A_{13} & A_{14} \\ + A_{21} & \rowcolor{red!15}A_{22} & A_{23} & A_{24} \\ + A_{31} & A_{32} & \rowcolor{red!15}A_{33} & A_{34} \\ + A_{41} & A_{42} & A_{43} & \rowcolor{red!15}A_{44} +\end{pNiceArray}\] + +\bigskip +However, it's not possible to do a fine tuning. That's why we describe now a +method to highlight a row of the matrix. + +\medskip +That example and the following ones require Tikz (by default, \pkg{nicematrix} +only loads \textsc{pgf}, which is a sub-layer of Tikz) and the Tikz library +|fit|. The following lines in the preamble of your document do the job: +\begin{verbatim} +\usepackage{tikz} +\usetikzlibrary{fit} +\end{verbatim} + +\medskip +We create a rectangular Tikz node which encompasses the nodes of the second +row by using the tools of the Tikz library \pkg{fit}. Those nodes are not +available by default in the |\CodeBefore| (for efficiency). We have to require +their creation with the key |create-cell-nodes| of the keyword |\CodeBefore|. + +\tikzset{highlight/.style={rectangle, + fill=red!15, + rounded corners = 0.5 mm, + inner sep=1pt, + fit = #1}} + +\medskip +\index{highlight (TikZ style defined in\newline an example)|textit} +\begin{Verbatim} +\tikzset{highlight/.style={rectangle, + fill=red!15, + rounded corners = 0.5 mm, + inner sep=1pt, + fit=~#1}} + +$\begin{bNiceMatrix} +~emphase#\CodeBefore [create-cell-nodes] @ +~emphase# \tikz \node [highlight = (2-1) (2-3)] {} ; @ +~emphase# \Body @ +0 & \Cdots & 0 \\ +1 & \Cdots & 1 \\ +0 & \Cdots & 0 \\ +\end{bNiceMatrix}$ +\end{Verbatim} +\index{create-cell-nodes (key of \texttt{\textbackslash CodeBefore})|textit} +\index{CodeBefore@\texttt{\textbackslash CodeBefore}...\texttt{\textbackslash Body}|textit} + +\[\begin{bNiceMatrix} +\CodeBefore [create-cell-nodes] + \tikz \node [highlight = (2-1) (2-3)] {} ; +\Body +0 & \Cdots & 0 \\ +1 & \Cdots & 1 \\ +0 & \Cdots & 0 \\ +\end{bNiceMatrix}\] + + +\vspace{1cm} +We consider now the following matrix. If we want to highlight each row of +this matrix, we can use the previous technique three times. + +\begin{Verbatim} +\[\begin{pNiceArray}{ccc}[last-col, margin = 2pt] +\CodeBefore [create-cell-nodes] + \begin{tikzpicture} +~emphase# \node [highlight = (1-1) (1-3)] {} ;@ +~emphase# \node [highlight = (2-1) (2-3)] {} ;@ +~emphase# \node [highlight = (3-1) (3-3)] {} ;@ + \end{tikzpicture} +\Body +a & a + b & a + b + c & L_1 \\ +a & a & a + b & L_2 \\ +a & a & a & L_3 +\end{pNiceArray}\] +\end{Verbatim} + + +\[\begin{pNiceArray}{ccc}[last-col, margin = 2pt] +\CodeBefore [create-cell-nodes] + \begin{tikzpicture} + \node [highlight = (1-1) (1-3)] {} ; + \node [highlight = (2-1) (2-3)] {} ; + \node [highlight = (3-1) (3-3)] {} ; + \end{tikzpicture} +\Body +a & a + b & a + b + c & L_1 \\ +a & a & a + b & L_2 \\ +a & a & a & L_3 +\end{pNiceArray}\] + +\medskip +The result may seem disappointing. We can improve it by using the ``medium +nodes'' instead of the ``normal nodes''. + +\index{create-medium-nodes|textit} +\index{create-cell-nodes (key of \texttt{\textbackslash CodeBefore})|textit} + + +\begin{Verbatim} +\[\begin{pNiceArray}{ccc}[last-col, margin = 2pt, create-medium-nodes] +\CodeBefore [create-cell-nodes] + \begin{tikzpicture} ~emphase#[name suffix = -medium]@ + \node [highlight = (1-1) (1-3)] {} ; + \node [highlight = (2-1) (2-3)] {} ; + \node [highlight = (3-1) (3-3)] {} ; + \end{tikzpicture} +\Body +a & a + b & a + b + c & L_1 \\ +a & a & a + b & L_2 \\ +a & a & a & L_3 +\end{pNiceArray}\] +\end{Verbatim} + + +\[\begin{pNiceArray}{ccc}[last-col, margin = 2pt, create-medium-nodes] +\CodeBefore [create-cell-nodes] + \begin{tikzpicture} [name suffix = -medium] + \node [highlight = (1-1) (1-3)] {} ; + \node [highlight = (2-1) (2-3)] {} ; + \node [highlight = (3-1) (3-3)] {} ; + \end{tikzpicture} +\Body +a & a + b & a + b + c & L_1 \\ +a & a & a + b & L_2 \\ +a & a & a & L_3 +\end{pNiceArray}\] + + + + +\subsection{Utilisation of \textbackslash SubMatrix in the \textbackslash CodeBefore} + +\label{submatrix-in-codebefore} + +\index{SubMatrix@\texttt{\textbackslash SubMatrix} (command of +\texttt{\textbackslash CodeAfter}\newline and +\texttt{\textbackslash CodeBefore})|textit} +\index{CodeBefore@\texttt{\textbackslash CodeBefore}...\texttt{\textbackslash Body}|textit} +\index{CodeAfter@\texttt{\textbackslash CodeAfter}|textit} +\index{create-cell-nodes (key of \texttt{\textbackslash CodeBefore})|textit} + + +In the following example, we illustrate the mathematical product of two +matrices. + +The whole figure is an environment |{NiceArray}| and the three pairs of +parenthesis have been added with |\SubMatrix| in the |\CodeBefore|. + +\tikzset{highlight/.style={rectangle, + fill=red!15, + rounded corners = 0.5 mm, + inner sep=1pt, + fit=#1}}% +\[\begin{NiceArray}{*{6}{c}@{\hspace{6mm}}*{5}{c}}[nullify-dots] +\CodeBefore [create-cell-nodes] + \SubMatrix({2-7}{6-last}) + \SubMatrix({7-2}{last-6}) + \SubMatrix({7-7}{last-last}) + \begin{tikzpicture} + \node [highlight = (9-2) (9-6)] { } ; + \node [highlight = (2-9) (6-9)] { } ; + \end{tikzpicture} +\Body + & & & & & & & & \color{blue}\scriptstyle C_j \\ + & & & & & & b_{11} & \Cdots & b_{1j} & \Cdots & b_{1n} \\ + & & & & & & \Vdots & & \Vdots & & \Vdots \\ + & & & & & & & & b_{kj} \\ + & & & & & & & & \Vdots \\ + & & & & & & b_{n1} & \Cdots & b_{nj} & \Cdots & b_{nn} \\[3mm] + & a_{11} & \Cdots & & & a_{1n} \\ + & \Vdots & & & & \Vdots & & & \Vdots \\ +\color{blue}\scriptstyle L_i + & a_{i1} & \Cdots & a_{ik} & \Cdots & a_{in} & \Cdots & & c_{ij} \\ + & \Vdots & & & & \Vdots \\ + & a_{n1} & \Cdots & & & a_{nn} \\ +\CodeAfter +\tikz \draw [gray,shorten > = 1mm, shorten < = 1mm] (9-4.north) to [bend left] (4-9.west) ; +\end{NiceArray}\] + + +\vspace{1cm} +\begin{Verbatim} +\tikzset{highlight/.style={rectangle, + fill=red!15, + rounded corners = 0.5 mm, + inner sep=1pt, + fit=~#1}} +\end{Verbatim} + +\begin{Verbatim}[formatcom = \small\color{gray}] +\[\begin{NiceArray}{*{6}{c}~LetterAt{\hspace{6mm}}*{5}{c}}[nullify-dots] +\CodeBefore [create-cell-nodes] + \SubMatrix({2-7}{6-last}) + \SubMatrix({7-2}{last-6}) + \SubMatrix({7-7}{last-last}) + \begin{tikzpicture} + \node [highlight = (9-2) (9-6)] { } ; + \node [highlight = (2-9) (6-9)] { } ; + \end{tikzpicture} +\Body + & & & & & & & & \color{blue}\scriptstyle C_j \\ + & & & & & & b_{11} & \Cdots & b_{1j} & \Cdots & b_{1n} \\ + & & & & & & \Vdots & & \Vdots & & \Vdots \\ + & & & & & & & & b_{kj} \\ + & & & & & & & & \Vdots \\ + & & & & & & b_{n1} & \Cdots & b_{nj} & \Cdots & b_{nn} \\[3mm] + & a_{11} & \Cdots & & & a_{1n} \\ + & \Vdots & & & & \Vdots & & & \Vdots \\ +\color{blue}\scriptstyle L_i + & a_{i1} & \Cdots & a_{ik} & \Cdots & a_{in} & \Cdots & & c_{ij} \\ + & \Vdots & & & & \Vdots \\ + & a_{n1} & \Cdots & & & a_{nn} \\ +\CodeAfter +\tikz \draw [gray,shorten > = 1mm, shorten < = 1mm] (9-4.north) to [bend left] (4-9.west) ; +\end{NiceArray}\] +\end{Verbatim} + + + +\subsection{A triangular tabular} + +\label{triangular} + +\index{pgf-node-code|textit} +\index{Corners (the empty ---)|textit} +\index{chessboardcolors@\texttt{\textbackslash chessboardcolors}!(commande + du \texttt{\textbackslash CodeBefore})|textit} +\index{CodeBefore@\texttt{\textbackslash CodeBefore}...\texttt{\textbackslash Body}|textit} + +In the following example, we use the style PGF/TikZ |nicematrix/cell-node| +to rotate the contents of the cells (and, then, we compensate that rotation by +a rotation of the whole tabular with the command |\adjustbox| of the eponymous +package, which must be loaded previously). + + +\medskip +\begin{Verbatim} +\pgfset + { + ~emphase#nicematrix/cell-node@/.append style = + { text/rotate = 45, minimum size = 6 mm } + } + +\setlength{\tabcolsep}{0pt} + +~emphase#\adjustbox@{rotate = -45, set depth = 6mm + 1.414 \arrayrulewidth} + {\begin{NiceTabular} [ hvlines, corners=SE, baseline = line-9 ] { cccccccc } + \CodeBefore + \chessboardcolors{red!15}{blue!15} + \Body + 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ + 1 & 2 & 3 & 4 & 5 & 6 & 7 \\ + 1 & 3 & 6 & 10 & 15 & 21 \\ + 1 & 4 & 10 & 20 & 35 \\ + 1 & 5 & 15 & 35 \\ + 1 & 6 & 21 \\ + 1 & 7 \\ + 1 + \end{NiceTabular}} +\end{Verbatim} + + +\begin{center} +\pgfset + { + nicematrix/cell-node/.append style = + { text/rotate = 45, minimum size = 6 mm } + }% +\setlength{\tabcolsep}{0pt}% +\adjustbox{rotate = -45, set depth = 6mm + 1.414 \arrayrulewidth} + {\begin{NiceTabular} [ hvlines, corners=SE, baseline = line-9 ] { cccccccc } + \CodeBefore + \chessboardcolors{red!15}{blue!15} + \Body + 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ + 1 & 2 & 3 & 4 & 5 & 6 & 7 \\ + 1 & 3 & 6 & 10 & 15 & 21 \\ + 1 & 4 & 10 & 20 & 35 \\ + 1 & 5 & 15 & 35 \\ + 1 & 6 & 21 \\ + 1 & 7 \\ + 1 + \end{NiceTabular}} +\end{center} + + +\newpage +\vspace{1cm} +\section{History} + +The successive versions of the file |nicematrix.sty| provided by TeXLive are available on the +\textsc{svn} server of TeXLive:\par\nobreak + +\smallskip +{ +\small +\nolinkurl{https:www.tug.org/svn/texlive/trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty} +} + +\subsection*{Changes between version 6.18 and 6.19} + +The command |\tabularnote| now supports an optional argument (between square +brackets) to change the symbol of the reference of the note. + +\subsection*{Changes between version 6.17 and 6.18} + +New key |opacity| in the commands to color cells, rows and columns. + +New key |rounded-corners| for a whole tabular. + + +\subsection*{Changes between version 6.16 and 6.17} + +New PGF/Tikz style |nicematrix/cell-node|. + +New key |pgf-node-code| + +\subsection*{Changes between version 6.15 and 6.16} + +It's now possible to put any LaTeX extensible delimiter (|\lgroup|, |\langle|, +etc.) in the preamble of an environment with preamble (such as |{NiceArray}|) +by prefixing them by |\left| and |\right|. + +New key |code| for the command |\SubMatrix| in the |\CodeAfter|. + +\subsection*{Changes between version 6.14 and 6.15} + +New key |transparent| for the command |\Block| (with that key, the rules are +drawn within the block). + +\subsection*{Changes between version 6.13 and 6.14} + +New keys for the command |\Block| for the vertical position of the content of +that block. + +\subsection*{Changes between version 6.12 and 6.13} + +New environment |{TabularNote}| in |{NiceTabular}| with the same semantic as +the key |tabularnote| (for legibility). + +The command |\Hline| nows accepts options (between square brackets). + +\subsection*{Changes between version 6.11 and 6.12} + +New keys |caption|, |short-caption| and |label| in the environment +|{NiceTabular}|. + +In |{NiceTabular}|, a caption specified by the key |caption| is wrapped to the +width of the tabular. + +Correction of a bug: it's now possible to use |\OverBrace| and |\UnderBrace| +with \pkg{unicode-math} (with XeLaTeX or LuaLaTeX). + +\subsection*{Changes between version 6.10 and 6.11} + +New key |matrix/columns-type| to specify the type of columns of the matrices. + +New key |ccommand| in |custom-line| and new command |\cdottedline|. + +\subsection*{Changes between version 6.9 and 6.10} + +New keys |xdots/shorten-start| and |xdots/shorten-end|. + +It's possible to use |\line| in the |\CodeAfter| between two blocks (and not +only two cells). + +\subsection*{Changes between version 6.8 and 6.9} + +New keys |xdots/radius| and |xdots/inter| for customisation of the continuous +dotted lines. + +New command |\ShowCellNames| available in the |\CodeBefore| and in the |\CodeAfter|. + +\subsection*{Changes between version 6.7 and 6.8} + +In the notes of a tabular (with the command |\tabularnote|), the duplicates +are now detected: when several commands |\tabularnote| are used with the same +argument, only one note is created at the end of the tabular (but all the +labels are present, of course). + +\subsection*{Changes between version 6.6 and 6.7} + +Key |color| for |\OverBrace| and |\UnderBrace| in the |\CodeAfter| + +Key |tikz| in the key |borders| of a command |\Block| + +\subsection*{Changes between version 6.5 and 6.6} + +Keys |tikz| and |width| in |custom-line|. + +\subsection*{Changes between versions 6.4 and 6.5} + +Key |custom-line| in |\NiceMatrixOptions|. + +Key |respect-arraystretch|. + +\subsection*{Changes between versions 6.3 and 6.4} + +New commands |\UnderBrace| and |\OverBrace| in the |\CodeAfter|. + +Correction of a bug of the key |baseline| (cf. question 623258 on TeX StackExchange). + +Correction of a bug with the columns |V| of \pkg{varwidth}. + +Correction of a bug: the use of |\hdottedline| and |:| in the preamble of the +array (of another letter specified by |letter-for-dotted-lines|) was +incompatible with the key |xdots/line-style|. + +\subsection*{Changes between versions 6.2 and 6.3} + +Keys |nb-rows|, |rowcolor| and |bold| for the command |\RowStyle| + +Key |name| for the command |\Block|. + +Support for the columns |V| of \pkg{varwidth}. + +\subsection*{Changes between versions 6.1 and 6.2} + +Better compatibility with the classes \cls{revtex4-1} and \cls{revtex4-2}. + +Key |vlines-in-sub-matrix|. + +\subsection*{Changes between versions 6.0 and 6.1} + +Better computation of the widths of the |X| columns. + +Key |\color| for the command |\RowStyle|. + +\subsection*{Changes between versions 5.19 and 6.0} + +Columns |X| and environment |{NiceTabularX}|. + +Command |\rowlistcolors| available in the |\CodeBefore|. + +In columns with fixed width, the blocks are composed as paragraphs (wrapping +of the lines). + +The key |define-L-C-R| has been deleted. + +\subsection*{Changes between versions 5.18 and 5.19} + +New key |tikz| for the command |\Block|. + +\subsection*{Changes between versions 5.17 and 5.18} + +New command |\RowStyle| + +\subsection*{Changes between versions 5.16 and 5.17} + +The key |define-L-C-R| (only available at load-time) now raises a (non fatal) +error. + +Keys |L|, |C| and |R| for the command |\Block|. + +Key |hvlines-except-borders|. + +It's now possible to use a key |l|, |r| or |c| with the command +|\pAutoNiceMatrix| (and the similar ones). + +\subsection*{Changes between versions 5.15 and 5.16} + +It's now possible to use the cells corresponding to the contents of the nodes +(of the form |i-j|) in the |\CodeBefore| when the key |create-cell-nodes| of +that |\CodeBefore| is used. The medium and the large nodes are also available +if the corresponding keys are used. + +\subsection*{Changes between versions 5.14 and 5.15} + +Key |hvlines| for the command |\Block|. + +The commands provided by \pkg{nicematrix} to color cells, rows and columns +don't color the cells which are in the ``corners'' (when the key |corner| is +used). + +It's now possible to specify delimiters for submatrices in the preamble of an +environment. + +The version 5.15b is compatible with the version 3.0+ of \pkg{siunitx} +(previous versions were not). + +\subsection*{Changes between versions 5.13 and 5.14} + +Nodes of the form |(1.5)|, |(2.5)|, |(3.5)|, etc. + +Keys |t| and |b| for the command |\Block|. + +Key |corners|. + +\subsection*{Changes between versions 5.12 and 5.13} + +New command |\arraycolor| in the |\CodeBefore| (with its key +|except-corners|). + +New key |borders| for the command |\Block|. + +New command |\Hline| (for horizontal rules not drawn in the blocks). + +The keys |vlines| and |hlines| takes in as value a (comma-separated) list of +numbers (for the rules to draw). + +\subsection*{Changes between versions 5.11 and 5.12} + +Keywords |\CodeBefore| and |\Body| (alternative syntax to the key +|code-before|). + +New key |delimiters/max-width|. + +New keys |hlines|, |vlines| and |hvlines| for the command |\SubMatrix| in the +|\CodeAfter|. + +New key |rounded-corners| for the command |\Block|. + +\subsection*{Changes between versions 5.10 and 5.11} + +It's now possible, in the |code-before| and in the |\CodeAfter|, to use the +syntax \verb+|(i-|j)+ for the Tikz node at the intersection of the (potential) +horizontal rule number~$i$ and the (potential) vertical rule number~$j$. + +\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 keyword |\CodeAfter|. + +\subsection*{Changes between versions 5.8 and 5.9} + +Correction of a bug: in the previous versions, it was not possible to use the +key |line-style| for the continuous dotted lines when the Tikz library |babel| +was loaded. + +New key |cell-space-limits|. + +\subsection*{Changes between versions 5.7 and 5.8} + +Keys |cols| and |restart| of the command |\rowcolors| in the |code-before|. + +Modification of the behaviour of |\\| in the columns of type |p|, |m| or |b| +(for a behaviour similar to the environments of \pkg{array}). + +Better error messages for the command |\Block|. + +\subsection*{Changes between versions 5.6 and 5.7} + +New key |delimiters-color| + +Keys |fill|, |draw| and |line-width| for the command |\Block|. + +\subsection*{Changes between versions 5.5 and 5.6} + +Different behaviour for the mono-row blocks. + +New command |\NotEmpty|. + +\subsection*{Changes between versions 5.4 and 5.5} + +The user must never put |\omit| before |\CodeAfter|. + +Correction of a bug: the tabular notes |\tabularnotes| were not composed when +present in a block (except a mono-column block). + +\subsection*{Changes between versions 5.3 and 5.4} + +Key |tabularnote|. + +Different behaviour for the mono-column blocks. + +\subsection*{Changes between versions 5.2 and 5.3} + +Keys |c|, |r| and |l| for the command |\Block|. + +It's possible to use the key |draw-first| with |\Ddots| and |\Iddots| to +specify which dotted line will be drawn first (the other lines will be drawn +parallel to that one if parallelization is activated). + +\subsection*{Changes between versions 5.1 and 5.2} + +The vertical rules specified by \verb+|+ or \verb+||+ in the preamble respect +the blocks. + +Key |respect-blocks| for |\rowcolors| (with a \emph{s}) in the |code-before|. + +The variable |\g_nicematrix_code_before_tl| is now public. + +The key |baseline| may take in as value an expression of the form +\textsl{line-i} to align the |\hline| in the row \textsl{i}. + +The key |hvlines-except-corners| may take in as value a list of corners (eg: NW,SE). + +\subsection*{Changes between versions 5.0 and 5.1} + +The vertical rules specified by \verb+|+ in the preamble are not broken by +|\hline\hline| (and other). + +Environment |{NiceTabular*}| + +Command |\Vdotsfor| similar to |\Hdotsfor| + +The variable |\g_nicematrix_code_after_tl| is now public. + +\subsection*{Changes between versions 4.4 and 5.0} + +Use of the standard column types |l|, |c| and |r| instead of |L|, |C| and |R|. + +It's now possible to use the command |\diagbox| in a |\Block|. + +Command |\tabularnote| + +\subsection*{Changes between versions 4.3 and 4.4} + +New key |hvlines-except-corners| (now deprecated). + +\subsection*{Changes between versions 4.2 and 4.3} + +The horizontal centering of the content of a |\Block| is correct even when an +instruction such as |!{\qquad}| is used in the preamble of the array. + +It's now possible to use the command |\Block| in the ``last row''. + +\subsection*{Changes between versions 4.1 and 4.2} + +It's now possible to write |\begin{pNiceMatrix}a&b\\c&d\end{pNiceMatrix}^2| +with the expected result. + +\subsection*{Changes between versions 4.0 and 4.1} + +New keys |cell-space-top-limit| and |cell-space-bottom-limit| + +New command |\diagbox| + +The key |hvline| don't draw rules in the blocks (commands |\Block|) and in the +virtual blocks corresponding to the dotted lines. + +\subsection*{Changes between versions 3.15 and 4.0} + +New environment |{NiceTabular}| + +Commands to color cells, rows and columns with a perfect result in the \textsc{pdf}. + +\subsection*{Changes between versions 3.14 and 3.15} + +It's possible to put labels on the dotted lines drawn by |\Ldots|, |\Cdots|, +|\Vdots|, |\Ddots|, |\Iddots|, |\Hdotsfor| and the command |\line| in the +|code-after| with the tokens |_| and |^|. + +The option |baseline| is now available in all the environments of +\pkg{nicematrix}. Before, it was available only in |{NiceArray}|. + +New keyword |\CodeAfter| (in the environments of \pkg{nicematrix}). + +\subsection*{Changes between versions 3.13 and 3.14} + +Correction of a bug (question 60761504 on |stackoverflow|). + +Better error messages when the user uses |&| or |\\| when |light-syntax| is in +force. + +\subsection*{Changes between versions 3.12 and 3.13} + +The behaviour of the command |\rotate| is improved when used in the ``last +row''. + +The option |dotted-lines-margin| has been renamed in |xdots/shorten| and the +options |xdots/color| and |xdots/line-style| have been added for a complete +customisation of the dotted lines. + +In the environments without preamble (|{NiceMatrix}|, |{pNiceMatrix}|, etc.), +it's possible to use the options |l| (=|L|) or |r| (=|R|) to specify the type +of the columns. + +The code of \pkg{nicematrix} no longer uses Tikz but only \textsc{pgf}. By +default, Tikz is \emph{not} loaded by \pkg{nicematrix}. + +\subsection*{Changes between versions 3.11 and 3.12} + +Command |\rotate| in the cells of the array. + +Options |vlines|, |hlines| and |hvlines|. + +Option |baseline| pour |{NiceArray}| (not for the other environments). + +The name of the Tikz nodes created by the command |\Block| has changed: when +the command has been issued in the cell $i$|-|$j$, the name is +$i$|-|$j$|-block| and, if the creation of the ``medium nodes'' is required, a +node $i$|-|$j$|-block-medium| is created. + +If the user tries to use more columns than allowed by its environment, an error +is raised by nicematrix (instead of a low-level error). + +The package must be loaded with the option |obsolete-environments| if we want +to use the deprecated environments. + +\subsection*{Changes between versions 3.10 and 3.11} + +Correction of a bug linked to |first-row| and |last-row|. + +\subsection*{Changes between version 3.9 and 3.10} + +New option |light-syntax| (and |end-of-row|). + +New option |dotted-lines-margin| for fine tuning of the dotted lines. + +\subsection*{Changes between version 3.8 and 3.9} + +New commands |\NiceMatrixLastEnv| and |\OnlyMainNiceMatrix|. + +New options |create-medium-nodes| and |create-large-nodes|. + +\subsection*{Changes between version 3.7 and 3.8} + +New programmation for the command |\Block| when the block has only one row. +With this programmation, the vertical rules drawn by the specifier +``\verb+|+'' at the end of the block is actually drawn. In previous versions, +they were not because the block of one row was constructed with +|\multicolumn|. + +An error is raised when an obsolete environment is used. + +\subsection*{Changes between version 3.6 and 3.7} + +The four ``corners'' of the matrix are correctly protected against the four +codes: |code-for-first-col|, |code-for-last-col|, |code-for-first-row| and +|code-for-last-row|. + +New command |\pAutoNiceMatrix| and its variants (suggestion of Christophe +Bal). + +\subsection*{Changes between version 3.5 and 3.6} + +LaTeX counters |iRow| and |jCol| available in the cells of the array. + +Addition of |\normalbaselines| before the construction of the array: in +environments like |{align}| of \pkg{amsmath} the value of |\baselineskip| is +changed and if the options |first-row| and |last-row| were used in an +environment of \pkg{nicematrix}, the position of the delimiters was wrong. + +A warning is written in the |.log| file if an obsolete environment is used. + +There is no longer artificial errors |Duplicate~name| in the environments of +\pkg{amsmath}. + +\subsection*{Changes between version 3.4 and 3.5} + +Correction on a bug on the two previous versions where the |code-after| was +not executed. + +\subsection*{Changes between version 3.3 and 3.4} + +Following a discussion on TeX StackExchange\footnote{cf. +|tex.stackexchange.com/questions/510841/nicematrix-and-tikz-external-optimize|}, +optimization of Tikz externalization is disabled in the environments of +\pkg{nicematrix} when the class \cls{standalone} or the package +\pkg{standalone} is used. + +\subsection*{Changes between version 3.2 and 3.3} + +The options |first-row|, |last-row|, |first-col| and |last-col| are now +available in the environments |{NiceMatrix}|, |{pNiceMatrix}|, +|{bNiceMatrix}|, etc. + +The option |columns-width=auto| doesn't need any more a second compilation. + +\subsection*{Changes between version 3.1 and 3.2 (and 3.2a)} + +Option |small|. + +\subsection*{Changes between version 3.0 and 3.1} + +Command |\Block| to draw block matrices. + +Error message when the user gives an incorrect value for |last-row|. + +The vertical rules in the matrices (drawn by ``\verb+|+'') are now compatible with +the color fixed by \pkg{colortbl}. + +Correction of a bug: it was not possible to use the colon ``|:|'' in the +preamble of an array when |pdflatex| was used with \pkg{french-babel} (because +\pkg{french-babel} activates the colon in the beginning of the document). + +\subsection*{Changes between version 2.3 and 3.0} + +Modification of |\Hdotsfor|. Now |\Hdotsfor| erases the |\vlines| (of ``\verb+|+'') +as |\hdotsfor| does. + +Composition of exterior rows and columns on the four sides of the matrix (and +not only on two sides) with the options |first-row|, |last-row|, |first-col| +and |last-col|. + +\subsection*{Changes between version 2.2.1 and 2.3} + +Compatibility with the column type |S| of \pkg{siunitx}. + +Option |hlines|. + +\subsection*{Changes between version 2.2 and 2.2.1} + +Improvment of the vertical dotted lines drawn by the specifier ``:'' in the +preamble. + +Modification of the position of the dotted lines drawn by |\hdottedline|. + +\subsection*{Changes between version 2.1.5 and 2.2} + +Possibility to draw horizontal dotted lines to separate rows with the command +|\hdottedline| (similar to the classical command |\hline| and the command +|\hdashline| of \pkg{arydshln}). + +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}). + +\subsection*{Changes between version 2.1.4 and 2.1.5} + +Compatibility with the classes \cls{revtex4-1} and \cls{revtex4-2}. + +Option |allow-duplicate-names|. + +\subsection*{Changes between version 2.1.3 and 2.1.4} + +Replacement of some options |O { }| in commands and environments defined with +\pkg{xparse} by |! O { }| (because a recent version of \pkg{xparse} introduced +the specifier |!| and modified the default behaviour of the last optional +arguments). + +See |www.texdev.net/2018/04/21/xparse-optional-arguments-at-the-end| + +\subsection*{Changes between version 2.1.2 and 2.1.3} + +When searching the end of a dotted line from a command like |\Cdots| issued in +the ``main matrix'' (not in the exterior column), the cells in the exterior +column are considered as outside the matrix. That means that it's possible to +do the following matrix with only a |\Cdots| command (and a single |\Vdots|). +\[\begin{pNiceArray}{Wc{5mm}cWc{5mm}}[first-row,last-col] +& C_j & \\ +\mbox{\Large $0$} & \Vdots & \mbox{\Large $0$} \\ +\strut & a & \Cdots & L_i \\ +\mbox{\Large $0$} & & \mbox{\Large $0$} \\ +\end{pNiceArray}\] + +\subsection*{Changes between version 2.1 and 2.1.1} + +Small corrections: for example, the option |code-for-first-row| is now +available in the command |\NiceMatrixOptions|. + +Following a discussion on +TeX StackExchange\footnote{cf. +|tex.stackexchange.com/questions/450841/tikz-externalize-and-nicematrix-package|}, +Tikz externalization is now deactivated in the environments of the +package \pkg{nicematrix}.\footnote{Before this version, there was an error +when using \pkg{nicematrix} with Tikz externalization. In any case, it's not +possible to externalize the Tikz elements constructed by \pkg{nicematrix} +because they use the options |overlay| and |remember picture|.} + +\subsection*{Changes between version 2.0 and 2.1} + +New implementation of the environment |{pNiceArrayRC}|. With this new +implementation, there is no restriction on the width of the columns. + +The package \pkg{nicematrix} no longer loads \pkg{mathtools} but only +\pkg{amsmath}. + +Creation of ``medium nodes'' and ``large nodes''. + +\subsection*{Changes between version 1.4 and 2.0} + +The versions 1.0 to 1.4 of \pkg{nicematrix} were focused on the continuous +dotted lines whereas the version 2.0 of \pkg{nicematrix} provides different +features to improve the typesetting of mathematical matrices. + +\subsection*{Changes between version 1.3 and 1.4} + +The column types |w| and |W| can now be used in the environments +|{NiceArray}|, |{pNiceArrayC}| and its variants with the same meaning as in +the package \pkg{array}. + +New option |columns-width| to fix the same width for all the columns of the +array. + +\subsection*{Changes between version 1.2 and 1.3} + +New environment |{pNiceArrayC}| and its variants. + +Correction of a bug in the definition of |{BNiceMatrix}|, |{vNiceMatrix}| and +|{VNiceMatrix}| (in fact, it was a typo). + +Options are now available locally in |{pNiceMatrix}| and its variants. + +The names of the options are changed. The old names were names in ``camel +style''. + +\subsection*{Changes between versions 1.1 and 1.2} + +New environment |{NiceArray}| with column types |L|, |C| and |R|. + +\subsection*{Changes between versions 1.0 and 1.1} + +The dotted lines are no longer drawn with Tikz nodes but with Tikz circles +(for efficiency). + +Modification of the code which is now twice faster. + + + +\cleardoublepage + +\phantomsection +\addcontentsline{toc}{section}{Index} + +\printindex + + +\newpage +\tableofcontents + +\end{document} + +% \endinput +% Local Variables: +% TeX-fold-mode: t +% TeX-fold-preserve-comments: nil +% fill-column: 80 +% End: + + diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx b/Master/texmf-dist/source/latex/nicematrix/nicematrix-code.dtx index c22ed30da11..4c28160949b 100644 --- a/Master/texmf-dist/source/latex/nicematrix/nicematrix.dtx +++ b/Master/texmf-dist/source/latex/nicematrix/nicematrix-code.dtx @@ -17,8 +17,8 @@ % % \fi % \iffalse -\def\myfileversion{6.18} -\def\myfiledate{2023/04/19} +\def\myfileversion{6.19} +\def\myfiledate{2023/05/15} % % %<*batchfile> @@ -55,72 +55,34 @@ version 2005/12/01 or later. \geometry{left=2.8cm,right=2.8cm,top=2.5cm,bottom=2.5cm,papersize={21cm,29.7cm}} \usepackage{tikz} -\usetikzlibrary{fit,patterns,arrows.meta,decorations.pathmorphing} +\usetikzlibrary{fit} \usepackage{nicematrix} -\usepackage{siunitx} -\usepackage{caption} -\usepackage{varwidth} -\usepackage{tcolorbox} -\usepackage{adjustbox} -\usepackage[auto-lang=false]{lipsum} \NewDocumentEnvironment {scope} {} {} {} \def\interitem{\vspace{7mm plus 2 mm minus 3mm}} -\def\emphase{\bgroup\color{RoyalPurple}\let\next=} + \fvset{commandchars=\~\#\@,formatcom=\color{gray}} \usepackage{titlesec} \titlespacing*{\section}{0pt}{6.5ex plus 1ex minus .2ex}{4.3ex plus .2ex} \titlespacing*{\subsection}{0pt}{4.5ex plus 1ex minus .2ex}{2ex plus .2ex} -\usepackage{footnotehyper} -\def\LetterAt{@} \parindent 0pt \skip \footins = 2 \bigskipamount -\EnableCrossrefs -\makeatletter -\ExplSyntaxOn -\DoNotIndex{\begin,\end} -\DoNotIndex{\c@iRow,\c@jCol,\theiRow,\thejCol} -\DoNotIndex{\pgfpicture,\endpgfpicture,\tikzpicture,\endtikzpicture} -\DoNotIndex{\pgfpoint,\pgfnode,\pgfnodealias,\pgfcoordinate} -\DoNotIndex{\pgf@x,\pgf@y} -\DoNotIndex{\int_add:Nn,\int_case:nnTF,\int_compare:nNnTF,\int_compare:nTF, - \int_compare_p:nNn,\int_decr:N,\int_eval:n,\int_add:Nn,\int_gdecr:N,\int_gincr:N - \int_gset:Nn,\int_gset_eq:NN,\int_gzero:N,\int_gzero_new:N,\int_if_odd:nTF, - \int_max:nn,\int_new:N,\int_set:Nn,\int_set_eq:NN,\int_step_inline:nnn, - \int_step_variable:nNn,\int_step_variable:nnNn,\int_sub:Nn,\int_use:N,\int_zero:N, - \int_zero_new:N,\g_tmpa_int,\l_tmpa_int,\l_tmpb_int} -\DoNotIndex{\dim_abs:n,\dim_add:Nn,\dim_compare:nNnTF,\dim_compare_p:nNn, -\dim_const:Nn,\dim_eval:n,\dim_gadd:Nn,\dim_gset:Nn,\dim_gset_eq:NN, -\dim_gset:Nn,\dim_gset_eq:NN,\dim_gsub:Nn,\dim_gzero_new:N,\dim_max:nn, -\dim_min:nn,\dim_new:N,\dim_ration:nn,\dim_set:Nn,\dim_set_eq:NN,\dim_sub:Nn, -\dim_use:N,\dim_zero:N,\dim_zero_new:N,\g_tmpa_dim,\l_tmpa_dim,\l_tmpb_dim, -\c_zero_dim} -\DoNotIndex{\cs_new_protected:Npn,\cs_new:Npn,\cs_set_eq:NN, -\cs_set_protected:Npn} -\DoNotIndex{\bool_if:NTF,\bool_new:N,\bool_set_false:N,\bool_set_true:N,\l_tmpa_bool} -\DoNotIndex{\group_begin:,\group_end:,\c_math_toggle_token} -\DoNotIndex{\tl_set:Nn,\l_tmpa_tl,\l_tmpb_tl} -\DoNotIndex{\tl_gput_left:Nn,\tl_gput_right:Nn} -\ExplSyntaxOff -\makeatother - - - \begin{document} -\DocInput{nicematrix.dtx} +\DocInput{nicematrix-code.dtx} \end{document} %</driver> % \fi -% \title{The package \pkg{nicematrix}\thanks{This document corresponds to the version~\myfileversion\space of \pkg{nicematrix}, -% at the date of~\myfiledate.}} \author{F. Pantigny \\ \texttt{fpantigny@wanadoo.fr}} +% \title{The code of the package \pkg{nicematrix}\thanks{This document corresponds to the version~\myfileversion\space of \pkg{nicematrix}, +% at the date of~\myfiledate.}} +% \author{F. Pantigny \\ \texttt{fpantigny@wanadoo.fr}} % % \hypersetup % { % pdfinfo = % { -% Title = The package 'nicematrix' , +% Title = The code of the package 'nicematrix' , % Subject = A LaTeX package , % Author = F. Pantigny % } @@ -130,6370 +92,21 @@ version 2005/12/01 or later. % \maketitle % % \begin{abstract} -% The LaTeX package \pkg{nicematrix} provides new environments similar to the -% classical environments |{tabular}|, |{array}| and |{matrix}| of \pkg{array} -% and \pkg{amsmath} but with extended features. +% This document is the documented code of the LaTeX package \pkg{nicematrix}. It +% is \emph{not} its user's guide. The guide of utilisation is the document +% |nicematrix.pdf| (with a French traduction: |nicematrix-french.pdf|). % \end{abstract} % % -% -% -% \vspace{1cm} -% \hspace{1cm} -% $\begin{bNiceArray}{cccc}[first-row,first-col, -% code-for-first-col=\color{blue}\scriptstyle, -% code-for-first-row=\color{blue}\scriptstyle, -% columns-width = auto] -% & C_1 & C_2 & \Cdots & C_n \\ -% L_1 & a_{11} & a_{12} & \Cdots & a_{1n} \\ -% L_2 & a_{21} & a_{22} & \Cdots & a_{2n} \\ -% \Vdots & \Vdots & \Vdots & \Ddots & \Vdots\\ -% L_n & a_{n1} & a_{n2} & \Cdots & a_{nn} -% \end{bNiceArray}$\hspace{2cm} -% \begin{NiceTabular}{lSSSS}[code-before = \rowcolor{red!15}{1-2} \rowcolors{3}{blue!15}{}] -% \toprule -% \Block{2-1}{Product} & \multicolumn{3}{c}{dimensions (cm)} & \Block{2-1}{\rotate Price} \\ -% \cmidrule(rl){2-4} -% & L & l & h \\ -% \midrule -% small & 3 & 5.5 & 1 & 30 \\ -% standard & 5.5 & 8 & 1.5 & 50.5 \\ -% premium & 8.5 & 10.5 & 2 & 80 \\ -% extra & 8.5 & 10 & 1.5 & 85.5 \\ -% special & 12 & 12 & 0.5 & 70 \\ -% \bottomrule -% \end{NiceTabular} -% -% \vspace{1cm} -% The package \pkg{nicematrix} is entirely contained in the file -% |nicematrix.sty|. This file may be put in the current directory or in a -% |texmf| tree. However, the best is to install \pkg{nicematrix} with a TeX -% distribution such as MiKTeX, TeX Live or MacTeX. -% -% \medskip -% \emph{Remark}: If you use LaTeX via Internet with, for example, Overleaf, you -% can upload the file |nicematrix.sty| in the repertory of your -% project in order to take full advantage of the latest version de -% \pkg{nicematrix}.\footnote{The latest version of the file -% |nicematrix.sty| may be downloaded from the \textsc{svn} server of -% TeXLive:\newline -% \small -% \url{https:www.tug.org/svn/texlive/trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty}} -% -% \medskip -% This package can be used with |xelatex|, |lualatex|, |pdflatex| but also by -% the classical workflow |latex|-|dvips|-|ps2pdf| (or Adobe Distiller). -% \textsl{However, the file nicematrix.dtx of the present documentation should -% be compiled with XeLaTeX.} -% -% \medskip -% This package requires and \textbf{loads} the packages \pkg{l3keys2e}, -% \pkg{array}, \pkg{amsmath}, \pkg{pgfcore} and the module \pkg{shapes} of -% \textsc{pgf} (\pkg{tikz}, which is a layer over \textsc{pgf}, is \emph{not} -% loaded). The final user only has to load the package with -% |\usepackage{nicematrix}|. -% -% -% \medskip -% The idea of \pkg{nicematrix} is to create \textsc{pgf} nodes under the cells -% and the positions of the rules of the tabular created by \pkg{array} and to -% use these nodes to develop new features. As usual with \textsc{pgf}, the -% coordinates of these nodes are written in the |aux| to be used on the next -% compilation and that's why \pkg{nicematrix} may need \textbf{several -% compilations}.\footnote{If you use Overleaf, Overleaf will do automatically -% the right number of compilations.} -% -% \medskip -% Most features of \pkg{nicematrix} may be used without explicit use of -% \textsc{pgf} or Tikz (which, in fact, is not loaded by default). -% -% \medskip -% A command |\NiceMatrixOptions| is provided to fix the options (the -% scope of the options fixed by this command is the current TeX group: they are -% semi-global). -% -% -% -% \newpage -% -% \section{The environments of this package} -% -% The package \pkg{nicematrix} defines the following new environments. -% -% \medskip -% \begin{ttfamily} -% \setlength{\tabcolsep}{3mm} -% \begin{tabular}{llll} -% \{NiceTabular\} & \{NiceArray\} & \{NiceMatrix\} \\ -% \{NiceTabular*\} & \{pNiceArray\} & \{pNiceMatrix\} \\ -% \{NiceTabularX\} & \{bNiceArray\} & \{bNiceMatrix\} \\ -% & \{BNiceArray\} & \{BNiceMatrix\} \\ -% & \{vNiceArray\} & \{vNiceMatrix\} \\ -% & \{VNiceArray\} & \{VNiceMatrix\} -% \end{tabular} -% \end{ttfamily} -% -% % -% \medskip -% The environments |{NiceArray}|, |{NiceTabular}| and |{NiceTabular*}| are -% similar to the environments |{array}|, |{tabular}| and |{tabular*}| of the -% package \pkg{array} (which is loaded by \pkg{nicematrix}). -% -% \medskip -% The environments |{pNiceArray}|, |{bNiceArray}|, etc. have no equivalent in -% \pkg{array}. -% -% \medskip -% The environments |{NiceMatrix}|, |{pNiceMatrix}|, etc. are similar to the -% corresponding environments of \pkg{amsmath} (which is loaded by -% \pkg{nicematrix}): |{matrix}|, |{pmatrix}|, etc. -% -% \medskip -% The environment |{NiceTabularX}| is similar to the environment |{tabularx}| -% from the eponymous package.\footnote{In fact, it's possible to use directly the -% |X| columns in the environment |{NiceTabular}| (and the required -% width for the tabular is fixed by the key |width|): cf. p.~\pageref{X-columns}}. -% -% \medskip -% \textbf{It's recommended to use primarily the classical environments and to use the -% environments of \pkg{nicematrix} only when some feature provided by these -% environments is used (this will save memory).} -% -% \medskip -% All the environments of the package \pkg{nicematrix} accept, between square -% brackets, an optional list of \textsl{key=value} pairs. \textbf{There must be -% no space before the opening bracket (|[|) of this list of options.} -% -% -% \section{The vertical space between the rows} -% -% \label{cell-space} -% -% It's well known that some rows of the arrays created by default with LaTeX -% are, by default, too close to each other. Here is a classical example. -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=9cm] -% $\begin{pmatrix} -% \frac{1}{2} & -\frac{1}{2} \\ -% \frac{1}{3} & \frac{1}{4} \\ -% \end{pmatrix}$ -% \end{BVerbatim} -% $\begin{pmatrix} -% \frac{1}{2} & -\frac{1}{2} \\ -% \frac{1}{3} & \frac{1}{4} \\ -% \end{pmatrix}$ -% -% \bigskip -% Inspired by the package \pkg{cellspace} which deals with that problem, the -% package \pkg{nicematrix} provides two keys |cell-space-top-limit| and -% |cell-space-bottom-limit| similar to the parameters |\cellspacetoplimit| and -% |\cellspacebottomlimit| of \pkg{cellspace}. -% -% There is also a key |cell-space-limits| to set both parameters at once. -% -% The initial value of these parameters is $0$~pt in order to have for the -% environments of \pkg{nicematrix} the same behaviour as those of \pkg{array} -% and \pkg{amsmath}. However, a value of $1$~pt would probably be a good choice -% and we suggest to set them with |\NiceMatrixOptions|.\footnote{One should -% remark that these parameters apply also to the columns of type |S| of -% \pkg{siunitx} whereas the package \pkg{cellspace} is not able to act on such -% columns of type~|S|.} -% -% \medskip -% \begin{Verbatim} -% \NiceMatrixOptions{~emphase#cell-space-limits = 1pt@} -% \end{Verbatim} -% -% \begin{BVerbatim}[baseline=c,boxwidth=9cm] -% $\begin{pNiceMatrix} -% \frac12 & -\frac12 \\ -% \frac13 & \frac14 \\ -% \end{pNiceMatrix}$ -% \end{BVerbatim} -% \begin{scope} -% \NiceMatrixOptions{cell-space-limits = 1pt} -% $\begin{pNiceMatrix} -% \frac12 & -\frac12 \\ -% \frac13 & \frac14 \\ -% \end{pNiceMatrix}$ -% \end{scope} -% -% -% -% -% -% \bigskip -% \section{The vertical position of the arrays} -% -% The package \pkg{nicematrix} provides a option |baseline| for the vertical -% position of the arrays. This option takes in as value an integer which is the -% number of the row on which the array will be aligned. -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=9cm] -% $A = \begin{pNiceMatrix}[~emphase#baseline=2@] -% \frac{1}{\sqrt{1+p^2}} & p & 1-p \\ -% 1 & 1 & 1 \\ -% 1 & p & 1+p -% \end{pNiceMatrix}$ -% \end{BVerbatim} -% $A = \begin{pNiceMatrix}[baseline=2] -% \frac{1}{\sqrt{1+p^2}} & p & 1-p \\ -% 1 & 1 & 1 \\ -% 1 & p & 1+p -% \end{pNiceMatrix}$ -% -% -% \medskip -% It's also possible to use the option |baseline| with one of the special values -% |t|, |c| or |b|. These letters may also be used absolutely like the option of -% the environments |{tabular}| and |{array}| of \pkg{array}. The initial value -% of |baseline| is~|c|. -% -% -% \medskip -% In the following example, we use the option |t| (equivalent to |baseline=t|) -% immediately after an |\item| of list. One should remark that the presence of a -% |\hline| at the beginning of the array doesn't prevent the alignment of the -% baseline with the baseline of the first row (with |{tabular}| or |{array}| of -% \pkg{array}, one must use |\firsthline|). -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=9cm] -% \begin{enumerate} -% \item an item -% \smallskip -% \item \renewcommand{\arraystretch}{1.2} -% $\begin{NiceArray}~emphase#[t]@{lcccccc} -% \hline -% n & 0 & 1 & 2 & 3 & 4 & 5 \\ -% u_n & 1 & 2 & 4 & 8 & 16 & 32 -% \hline -% \end{NiceArray}$ -% \end{enumerate} -% \end{BVerbatim} -% \begin{minipage}{5cm} -% \begin{enumerate} -% \item an item -% \smallskip -% \item \renewcommand{\arraystretch}{1.2} -% $\begin{NiceArray}[t]{lcccccc} -% \hline -% n & 0 & 1 & 2 & 3 & 4 & 5 \\ -% u_n & 1 & 2 & 4 & 8 & 16 & 32 \\ -% \hline -% \end{NiceArray}$ -% \end{enumerate} -% \end{minipage} -% -% \medskip -% However, it's also possible to use the tools of -% \pkg{booktabs}\footnote{The extension \pkg{booktabs} is \emph{not} loaded -% by \pkg{nicematrix}.}: |\toprule|, -% |\bottomrule|, |\midrule|, etc.\par\nobreak -% -% \smallskip -% \begin{BVerbatim}[baseline=c,boxwidth=9cm] -% \begin{enumerate} -% \item an item -% \smallskip -% \item -% $\begin{NiceArray}[t]{lcccccc} -% ~emphase#\toprule@ -% n & 0 & 1 & 2 & 3 & 4 & 5 \\ -% ~emphase#\midrule@ -% u_n & 1 & 2 & 4 & 8 & 16 & 32 -% ~emphase#\bottomrule@ -% \end{NiceArray}$ -% \end{enumerate} -% \end{BVerbatim} -% \begin{minipage}{5cm} -% \begin{enumerate} -% \item an item -% \smallskip -% \item -% $\begin{NiceArray}[t]{lcccccc} -% \toprule -% n & 0 & 1 & 2 & 3 & 4 & 5 \\ -% \midrule -% u_n & 1 & 2 & 4 & 8 & 16 & 32 \\ -% \bottomrule -% \end{NiceArray}$ -% \end{enumerate} -% \end{minipage} -% -% \bigskip -% It's also possible to use the key |baseline| to align a matrix on an -% horizontal rule (drawn by |\hline|). In this aim, one should give the value -% |line-|\textsl{i} where \textsl{i} is the number of the row \emph{following} the -% horizontal rule. -% -% \smallskip -% \begin{Verbatim} -% \NiceMatrixOptions{cell-space-limits=1pt} -% \end{Verbatim} -% -% \smallskip -% \begin{BVerbatim}[baseline=c,boxwidth=9cm] -% $A=\begin{pNiceArray}{cc|cc}~emphase#[baseline=line-3]@ -% \dfrac{1}{A} & \dfrac{1}{B} & 0 & 0 \\ -% \dfrac{1}{C} & \dfrac{1}{D} & 0 & 0 \\ -% \hline -% 0 & 0 & A & B \\ -% 0 & 0 & D & D \\ -% \end{pNiceArray}$ -% \end{BVerbatim} -% \begin{scope} -% \NiceMatrixOptions{cell-space-limits=1pt} -% \raisebox{-5mm}{$A=\begin{pNiceArray}{cc|cc}[baseline=line-3] -% \dfrac{1}{A} & \dfrac{1}{B} & 0 & 0 \\ -% \dfrac{1}{C} & \dfrac{1}{D} & 0 & 0 \\ -% \hline -% 0 & 0 & A & B \\ -% 0 & 0 & D & D \\ -% \end{pNiceArray}$} -% \end{scope} -% -% -% \section{The blocks} -% \label{Block} -% -% \subsection{General case} -% -% In the environments of \pkg{nicematrix}, it's possible to use the command -% |\Block| in order to place an element in the center of a rectangle of merged -% cells of the array.\footnote{The spaces after a command |\Block| are deleted.} -% -% The command |\Block| must be used in the upper leftmost cell of the array with -% two arguments. -% -% \begin{itemize} -% \item The first argument is the size of the block with the syntax -% $i$|-|$j$ where $i$ is the number of rows of the block and $j$ its number -% of columns. -% -% If this argument is empty, its default -% value is |1-1|. If the number of rows is not specified, or equal to |*|, the -% block extends until the last row (idem for the columns). -% -% \item The second argument is the content of the block. It's possible to use -% |\\| in that content to have a content on several lines. In |{NiceTabular}|, -% |{NiceTabular*}| and |{NiceTabularX}|, the content of the block is composed in -% text mode whereas, in the other environments, it is composed in math mode. -% \end{itemize} -% -% -% \interitem -% Here is an example of utilisation of the command |\Block| in mathematical matrices. -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm] -% $\begin{bNiceArray}{cw{c}{1cm}c|c}[margin] -% ~emphase#\Block{3-3}{A}@ & & & 0 \\ -% & & & \Vdots \\ -% & & & 0 \\ -% \hline -% 0 & \Cdots& 0 & 0 -% \end{bNiceArray}$ -% \end{BVerbatim} -% $\begin{bNiceArray}{cw{c}{1cm}c|c}[margin] -% \Block{3-3}{A} & & & 0 \\ -% & & & \Vdots \\ -% & & & 0 \\ -% \hline -% 0 & \Cdots& 0 & 0 -% \end{bNiceArray}$ -% -% \bigskip -% One may wish to raise the size of the ``$A$'' placed in the block of the -% previous example. Since this element is composed in math mode, it's not -% possible to use directly a command like |\large|, |\Large| and |\LARGE|. -% That's why the command |\Block| provides an option between angle brackets to -% specify some TeX code which will be inserted before the beginning of the -% math mode.\footnote{This argument between angular brackets may also be used to -% insert a command of font such as |\bfseries| when the command |\\| is used in -% the content of the block.} -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm] -% $\begin{bNiceArray}{cw{c}{1cm}c|c}[margin] -% \Block{3-3}~emphase#<\Large>@{A} & & & 0 \\ -% 0 & & & \Vdots \\ -% & & & 0 \\ -% \hline -% 0 & \Cdots& 0 & 0 -% \end{bNiceArray}$ -% \end{BVerbatim} -% \begin{scope} -% $\begin{bNiceArray}{cw{c}{1cm}c|c}[margin] -% \Block{3-3}<\Large>{A} & & & 0 \\ -% & & & \Vdots \\ -% & & & 0 \\ -% \hline -% 0 & \Cdots& 0 & 0 -% \end{bNiceArray}$ -% \end{scope} -% -% \NewDocumentCommand{\Definition}{m} -% {{\setlength{\fboxsep}{1pt}\colorbox{gray!20}{\ttfamily \vphantom{gl}#1}}} -% -% -% \interitem -% In fact, the command |\Block| accepts as first optional argument (between -% square brackets) a list of couples \textsl{key=value}. The available keys are as -% follows: -% \begin{itemize} -% \item the key \Definition{fill} takes in as value a color and fills the block -% with that color; -% \item the key \Definition{draw} takes in as value a color and strokes the -% frame of the block with that color (the default value of that key is the -% current color of the rules of the array); -% \item the key \Definition{color} takes in as value a color and apply that -% color the content of the block but draws also the frame of the block with that -% color; -% \item the keys \Definition{hlines}, \Definition{vlines} and -% \Definition{hvlines} draw all the corresponding rules in the -% block;\footnote{However, the rules are not drawn in the sub-blocks of the -% block, as always with \pkg{nicematrix}: the rules are not drawn in the blocks -% (cf. section~\ref{rules} p.~\pageref{rules}).} -% \item the key \Definition{line-width} is the width of the rules (is relevant -% only when one of the keys |draw|, |hvlines|, |vlines| and |hlines| is used); -% \item the key \Definition{rounded-corners} requires rounded corners (for the -% frame drawn by |draw| and the shape drawn by |fill|) with a radius equal to -% the value of that key (the default value is 4~pt\footnote{This value is the -% initial value of the \emph{rounded corners} of Tikz.}); -% \item when the key \Definition{tikz} is used, the Tikz path corresponding of -% the rectangle which delimits the block is executed with Tikz\footnote{Tikz -% should be loaded (by default, \pkg{nicematrix} only loads \textsc{pgf}) and, -% if it's not, an error will be raised.} by using as options the value of that -% key |tikz| (which must be a list of keys allowed for a Tikz path). For -% examples, cf. p.~\pageref{tikz-key-examples}; -% \item the key \Definition{name} provides a name to the rectangular Tikz node -% corresponding to the block; it's possible to use that name with Tikz in the -% |\CodeAfter| of the environment (cf.~p.~\pageref{code-after}); -% \item the key \Definition{respect-arraystretch} prevents the setting of -% |\arraystretch| to $1$ at the beginning of the block (which is the behaviour -% by default) ; -% \item the key \Definition{borders} provides the ability to draw only some -% borders of the blocks; the value of that key is a (comma-separated) list of -% elements covered by |left|, |right|, |top| and |bottom|; it's possible, in -% fact, in the list which is the value of the key |borders|, to add an entry of -% the form |tikz={|\textsl{list}|}| where \textsl{list} is a list of couples -% \textsl{key=value} of Tikz specifying the graphical characteristics of the -% lines that will be drawn (for an example, see p.~\pageref{dashed}). -% \item \colorbox{yellow!50}{\textbf{New 6.15}}\par\nobreak -% By default, the rules are not drawn in the blocks (see the section about the -% rules: section~\ref{rules} p.~\pageref{rules}). However, if the key -% \Definition{transparent} is used, the rules are drawn. For an example, see -% section~\ref{tikz-key-examples} on page~\pageref{tikz-key-examples}. -% \end{itemize} -% -% There is also keys for the horizontal and vertical positions of the content of -% the block: cf.~\ref{horizontal-block} p.~\pageref{horizontal-block}. -% -% \interitem -% {\bfseries One must remark that, by default, the commands |\Blocks| don't create space}. -% There is exception only for the blocks mono-row and the blocks mono-column as -% explained just below. -% -% \medskip -% In the following example, we have had to enlarge by hand the columns 2 and 3 -% (with the construction |w{c}{...}| of \pkg{array}). -% -% \bigskip -% \begin{BVerbatim} -% \begin{NiceTabular}{cw{c}{2cm}w{c}{3cm}c} -% rose & tulip & daisy & dahlia \\ -% violet -% & ~emphase#\Block[draw=red,fill=[RGB]{204,204,255},rounded-corners]{2-2}@ -% ~emphase#{\LARGE Some beautiful flowers}@ -% & & marigold \\ -% iris & & & lis \\ -% arum & periwinkle & forget-me-not & hyacinth -% \end{NiceTabular} -% \end{BVerbatim} -% -% \medskip -% \begin{center} -% \begin{NiceTabular}{cw{c}{2cm}w{c}{3cm}c} -% rose & tulip & daisy & dahlia \\ -% violet & \Block[draw=red,fill=[RGB]{204,204,255},rounded-corners]{2-2} -% {\LARGE Some beautiful flowers} & & marigold \\ -% iris & & & lis \\ -% arum & periwinkle & forget-me-not & hyacinth -% \end{NiceTabular} -% \end{center} -% -% \subsection{The mono-column blocks} -% -% The mono-column blocks have a special behaviour. -% -% \begin{itemize} -% \item The natural width of the contents of these blocks is taken into account -% for the width of the current column. -% -% In the columns with a fixed width (columns |w{...}{...}|, |W{...}{...}|, -% |p{...}|, |b{...}|, |m{...}|, |V| and |X|), the content of the block is -% formatted as a paragraph of that width. -% -% \item The specification of the horizontal position provided by the type of -% column (|c|, |r| or |l|) is taken into account for the blocks (but the -% |\Block| may have its own specification of alignment: -% cf.~\ref{horizontal-block} p.~\pageref{horizontal-block}). -% -% \item The specifications of font specified for the column by a construction -% |>{...}| in the preamble of the array are taken into account for the -% mono-column blocks of that column (this behaviour is probably expected). -% \end{itemize} -% -% -% \bigskip -% \begin{scope} -% \hfuzz=10cm -% \begin{BVerbatim}[baseline=c,boxwidth=12cm] -% \begin{NiceTabular}{~LetterAt{}>{\bfseries}lr~LetterAt{}} \hline -% \Block{2-1}{John} & 12 \\ -% & 13 \\ \hline -% Steph & 8 \\ \hline -% \Block{3-1}{Sarah} & 18 \\ -% & 17 \\ -% & 15 \\ \hline -% Ashley & 20 \\ \hline -% Henry & 14 \\ \hline -% \Block{2-1}{Madison} & 15 \\ -% & 19 \\ \hline -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}{@{}>{\bfseries}lr@{}}[baseline=c] \hline -% \Block{2-1}{John} & 12 \\ -% & 13 \\ \hline -% Steph & 8 \\ \hline -% \Block{3-1}{Sarah} & 18 \\ -% & 17 \\ -% & 15 \\ \hline -% Ashley & 20 \\ \hline -% Henry & 14 \\ \hline -% \Block{2-1}{Madison} & 15 \\ -% & 19 \\ \hline -% \end{NiceTabular} -% \end{scope} -% -% -% \subsection{The mono-row blocks} -% -% For the mono-row blocks, the natural height and depth are taken into account -% for the height and depth of the current row (as does a standard |\multicolumn| -% of LaTeX). -% -% \subsection{The mono-cell blocks} -% -% A mono-cell block inherits all the properties of the mono-row blocks and -% mono-column blocks. -% -% \medskip -% At first sight, one may think that there is no point using a mono-cell block. -% However, there are some good reasons to use such a block. -% \begin{itemize} -% \item It's possible to use the command |\\| in a (mono-cell) block. -% -% \item It's possible to use the option of horizontal alignment of the block in -% derogation of the type of column given in the preamble of the array. -% -% \item It's possible do draw a frame around the cell with the key |draw| of the -% command |\Block| and to fill the background with rounded corners with the keys -% |fill| and |rounded-corners|.\footnote{If one simply wishes to color the -% background of a unique cell, there is no point using the command |\Block|: -% it's possible to use the command |\cellcolor| (when the key |colortbl-like| is -% used).} -% -% \item It's possible to draw one or several borders of the cell with the key |borders|. -% \end{itemize} -% -% \bigskip -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% \begin{NiceTabular}{cc} -% \toprule -% Writer & ~emphase#\Block[l]{}{year\\ of birth}@ \\ -% \midrule -% Hugo & 1802 \\ -% Balzac & 1799 \\ -% \bottomrule -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}{cc} -% \toprule -% Writer & \Block[l]{}{year\\ of birth} \\ -% \midrule -% Hugo & 1802 \\ -% Balzac & 1799 \\ -% \bottomrule -% \end{NiceTabular} -% -% \medskip -% We recall that if the first mandatory argument of |\Block| is left blank, the -% block is mono-cell.\footnote{One may consider that the default value of the -% first mandatory argument of |\Block| is |1-1|.} -% -% -% -% -% \subsection{Horizontal position of the content of the block} -% -% \label{horizontal-block} -% -% The command |\Block| accepts the keys |l|, |c| and |r| for the horizontal -% position of its content. -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm] -% $\begin{bNiceArray}{cw{c}{1cm}c|c}[margin] -% \Block~emphase#[r]@{3-3}<\LARGE>{A} & & & 0 \\ -% & & & \Vdots \\ -% & & & 0 \\ -% \hline -% 0 & \Cdots& 0 & 0 -% \end{bNiceArray}$ -% \end{BVerbatim} -% $\begin{bNiceArray}{cw{c}{1cm}c|c}[margin] -% \Block[r]{3-3}<\LARGE>{A} & & & 0 \\ -% & & & \Vdots \\ -% & & & 0 \\ -% \hline -% 0 & \Cdots& 0 & 0 -% \end{bNiceArray}$ -% -% -% \medskip -% By default, the horizontal position of the content of a block is computed -% by using the positions of the \emph{contents} of the columns implied in that -% block. That's why, in the following example, the header ``First group'' is -% correctly centered despite the instruction |!{\qquad}| in the preamble which -% has been used to increase the space between the columns (this -% is not the behaviour of |\multicolumn|). -% -% \medskip -% \begin{center} -% \fvset{commandchars=\~\#\+} -% \begin{BVerbatim} -% \begin{NiceTabular}{@{}c!{\qquad}ccc~emphase#!{\qquad}+ccc@{}} -% \toprule -% Rank & ~emphase#\Block{1-3}{First group}+ & & & \Block{1-3}{Second group} \\ -% & 1A & 1B & 1C & 2A & 2B & 2C \\ -% \midrule -% 1 & 0.657 & 0.913 & 0.733 & 0.830 & 0.387 & 0.893\\ -% 2 & 0.343 & 0.537 & 0.655 & 0.690 & 0.471 & 0.333\\ -% 3 & 0.783 & 0.885 & 0.015 & 0.306 & 0.643 & 0.263\\ -% 4 & 0.161 & 0.708 & 0.386 & 0.257 & 0.074 & 0.336\\ -% \bottomrule -% \end{NiceTabular} -% \end{BVerbatim} -% \end{center} -% -% \bigskip -% \begin{center} -% \begin{NiceTabular}{@{}c!{\qquad}ccc!{\qquad}ccc@{}} -% \toprule -% Rank & \Block{1-3}{First group} & & & \Block{1-3}{Second group} \\ -% & 1A & 1B & 1C & 2A & 2B & 2C \\ -% \midrule -% 1 & 0.657 & 0.913 & 0.733 & 0.830 & 0.387 & 0.893\\ -% 2 & 0.343 & 0.537 & 0.655 & 0.690 & 0.471 & 0.333\\ -% 3 & 0.783 & 0.885 & 0.015 & 0.306 & 0.643 & 0.263\\ -% 4 & 0.161 & 0.708 & 0.386 & 0.257 & 0.074 & 0.336\\ -% \bottomrule -% \end{NiceTabular} -% \end{center} -% -% \medskip -% In order to have an horizontal positionning of the content of the block -% computed with the limits of the columns of the LaTeX array (and not with the -% contents of those columns), one may use the key |L|, |R| and |C| of the -% command |\Block|. -% -% \medskip -% Here is the same example with the key |C| for the first block. -% -% \medskip -% \begin{center} -% \fvset{commandchars=\~\#\+} -% \begin{BVerbatim} -% \begin{NiceTabular}{@{}c!{\qquad}ccc~emphase#!{\qquad}+ccc@{}} -% \toprule -% Rank & ~emphase#\Block[C]{1-3}{First group}+ & & & \Block{1-3}{Second group} \\ -% & 1A & 1B & 1C & 2A & 2B & 2C \\ -% \midrule -% 1 & 0.657 & 0.913 & 0.733 & 0.830 & 0.387 & 0.893\\ -% 2 & 0.343 & 0.537 & 0.655 & 0.690 & 0.471 & 0.333\\ -% 3 & 0.783 & 0.885 & 0.015 & 0.306 & 0.643 & 0.263\\ -% 4 & 0.161 & 0.708 & 0.386 & 0.257 & 0.074 & 0.336\\ -% \bottomrule -% \end{NiceTabular} -% \end{BVerbatim} -% \end{center} -% -% \bigskip -% \begin{center} -% \begin{NiceTabular}{@{}c!{\qquad}ccc!{\qquad}ccc@{}} -% \toprule -% Rank & \Block[C]{1-3}{First group} & & & \Block{1-3}{Second group} \\ -% & 1A & 1B & 1C & 2A & 2B & 2C \\ -% \midrule -% 1 & 0.657 & 0.913 & 0.733 & 0.830 & 0.387 & 0.893\\ -% 2 & 0.343 & 0.537 & 0.655 & 0.690 & 0.471 & 0.333\\ -% 3 & 0.783 & 0.885 & 0.015 & 0.306 & 0.643 & 0.263\\ -% 4 & 0.161 & 0.708 & 0.386 & 0.257 & 0.074 & 0.336\\ -% \bottomrule -% \end{NiceTabular} -% \end{center} -% -% -% \subsection{Vertical position of the content of the block} -% -% -% For the vertical position, the command |\Blocks| accepts the keys -% |v-center|\footnote{That key could not have been named |c| since the key |c| -% is used for the horizontal alignement.}, -% |t|, |b|, |T| and |B|. -% -% \begin{itemize} -% \item With the key |v-center|, the content of the block is vertically -% centered. -% \item With the key |t|, the baseline of the content of the block is aligned -% With the basline of the first row concerned by the block). -% \item with the key |b|, the baseline of the last row of the content of the -% block (we recall that the content of a block may contains several lines -% separated by |\\|) is aligned with the baseline of the last of the rows of the -% array involved in the block. -% \item With the key |T|, the content of the block is set upwards. -% -% \colorbox{yellow!50}{\textbf{Modification 6.18}}\enskip No vertical margin is -% added. However, the contents of the block is (always) composed by -% \pkg{nicematrix} in a |{minipage}|, a |{tabular}| or an |{array}| and, hence, -% there will still remain a margin (in most cases). -% -% \item With the key |B|, the content of the block is set downwards. -% \end{itemize} -% -% When no key is given, the key |v-center| applies (excepted in the mono-row blocks). -% -% -% -% \medskip -% \begin{scope} -% \NiceMatrixOptions{rules/color=[gray]{0.75}, hvlines} -% -% \begin{BVerbatim} -% \NiceMatrixOptions{rules/color=[gray]{0.75}, hvlines} -% \end{BVerbatim} -% -% \bigskip -% -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% \begin{NiceTabular}{ccc} -% \Block[fill=red!10,~emphase#t@,l]{4-2}{two\\lines} -% & & \Huge Un\\ -% & & deux \\ -% & & trois \\ -% & & \Huge quatre \\ -% text & text \\ -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}{ccc} -% \Block[fill=red!10,t,l]{4-2}{two\\lines} -% & & \Huge Un\\ -% & & deux \\ -% & & trois \\ -% & & \Huge quatre \\ -% text & text \\ -% \end{NiceTabular} -% -% -% \bigskip -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% \begin{NiceTabular}{ccc} -% \Block[fill=red!10,~emphase#b@,r]{4-2}{two\\lines} -% & & \Huge Un\\ -% & & deux \\ -% & & trois \\ -% & & \Huge quatre \\ -% text & text \\ -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}{ccc} -% \Block[fill=red!10,b,r]{4-2}{two\\lines} -% & & \Huge Un\\ -% & & deux \\ -% & & trois \\ -% & & \Huge quatre \\ -% text & text \\ -% \end{NiceTabular} -% -% \bigskip -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% \begin{NiceTabular}{ccc} -% \Block[fill=red!10,~emphase#T@,l]{4-2}{two\\lines} -% & & \Huge Un\\ -% & & deux \\ -% & & trois \\ -% & & \Huge quatre \\ -% text & text \\ -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}{ccc} -% \Block[fill=red!10,T,l]{4-2}{two\\lines} -% & & \Huge Un\\ -% & & deux \\ -% & & trois \\ -% & & \Huge quatre \\ -% text & text \\ -% \end{NiceTabular} -% -% -% \bigskip -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% \begin{NiceTabular}{ccc} -% \Block[fill=red!10,~emphase#B@,r]{4-2}{two\\lines} -% & & \Huge Un\\ -% & & deux \\ -% & & trois \\ -% & & \Huge quatre \\ -% text & text \\ -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}{ccc} -% \Block[fill=red!10,B,r]{4-2}{two\\lines} -% & & \Huge Un\\ -% & & deux \\ -% & & trois \\ -% & & \Huge quatre \\ -% text & text \\ -% \end{NiceTabular} -% -% -% \end{scope} -% -% -% -% -% \section{The rules} -% -% \label{rules} -% -% The usual techniques for the rules may be used in the environments of -% \pkg{nicematrix} (excepted |\vline|). However, there is some small differences -% with the classical environments. -% -% \bigskip -% \subsection{Some differences with the classical environments} -% -% \subsubsection{The vertical rules} -% -% In the environments of \pkg{nicematrix}, the vertical rules specified by -% \verb+|+ in the preambles of the environments are never broken, even by an -% incomplete row or by a double horizontal rule specified by |\hline\hline| -% (there is no need to use the package~\pkg{hhline}). -% -% \bigskip -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% \begin{NiceTabular}{|c|c|} \hline -% First & Second \\ ~emphase#\hline\hline@ -% Peter \\ \hline -% Mary & George\\ \hline -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}{|c|c|}[c] \hline -% First & Second \\ \hline\hline -% Peter \\ \hline -% Mary & George \\ \hline -% \end{NiceTabular} -% -% -% \bigskip -% However, the vertical rules are not drawn in the blocks (created by |\Block|: -% cf.~p.~\pageref{Block}) nor in the corners (created by the key |corner|: -% cf.~p.~\pageref{corners}) nor in the potential exterior rows (created by the -% keys |first-row| and |last-row|: cf.~p.~\pageref{exterior}). -% -% \bigskip -% If you use \pkg{booktabs} (which provides |\toprule|, |\midrule|, -% |\bottomrule|, etc.) and if you really want to add vertical rules (which is -% not in the spirit of \pkg{booktabs}), you should notice that the vertical rules -% drawn by \pkg{nicematrix} are compatible with \pkg{booktabs}. -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=10.5cm] -% $\begin{NiceArray}{~emphase#|cccc|@} \toprule -% a & b & c & d \\ \midrule -% 1 & 2 & 3 & 4 \\ -% 1 & 2 & 3 & 4 \\ \bottomrule -% \end{NiceArray}$ -% \end{BVerbatim} -% $\begin{NiceArray}{|cccc|} -% \toprule -% a & b & c & d \\ -% \midrule -% 1 & 2 & 3 & 4 \\ -% 1 & 2 & 3 & 4 \\ -% \bottomrule -% \end{NiceArray}$ -% -% \bigskip -% However, it's still possible to define a specifier (named, for instance, |I|) -% to draw vertical rules with the standard behaviour of \pkg{array}. -% -% \begin{Verbatim} -% \newcolumntype{I}{!{\vrule}} -% \end{Verbatim} -% -% -% \bigskip -% \subsubsection{The command \textbackslash cline} -% -%\label{remark-cline} -% -% The horizontal and vertical rules drawn by |\hline| and the specifier -% ``\verb+|+'' make the array larger or wider by a quantity equal to the width -% of the rule (with \pkg{array} and also with \pkg{nicematrix}). -% -% \smallskip -% For historical reasons, this is not the case with the command |\cline|, as -% shown by the following example. -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% \setlength{\arrayrulewidth}{2pt} -% \begin{tabular}{cccc} \hline -% A&B&C&D \\ ~emphase#\cline{2-2}@ -% A&B&C&D \\ \hline -% \end{tabular} -% \end{BVerbatim} -% \begin{scope} -% \setlength{\arrayrulewidth}{2pt} -% \begin{tabular}[c]{cccc} -% \hline -% A&B&C&D \\ -% \cline{2-2} -% A&B&C&D \\ -% \hline -% \end{tabular} -% \end{scope} -% -% \medskip -% In the environments of \pkg{nicematrix}, this situation is corrected (it's -% still possible to go to the standard behaviour of |\cline| with the key |standard-cline|). -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% \setlength{\arrayrulewidth}{2pt} -% \begin{NiceTabular}{cccc} \hline -% A&B&C&D \\ ~emphase#\cline{2}@ -% A&B&C&D \\ \hline -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{scope} -% \setlength{\arrayrulewidth}{2pt} -% \begin{NiceTabular}[c]{cccc} -% \hline -% A&B&C&D \\ -% \cline{2} -% A&B&C&D \\ -% \hline -% \end{NiceTabular} -% \end{scope} -% -% \medskip -% In the environments of \pkg{nicematrix}, an instruction |\cline{|\textsl{\texttt{i}}|}| -% is equivalent to |\cline{|\textsl{\texttt{i}}|-|\textsl{\texttt{i}}|}|. -% -% -% \subsection{The thickness and the color of the rules} -% -% The environments of \pkg{nicematrix} provide a key |rules/width| to set the -% width (in fact the thickness) of the rules in the current environment. In -% fact, this key merely sets the value of the length |\arrayrulewidth|. -% -% \smallskip -% It's well known that \pkg{colortbl} provides the command |\arrayrulecolor| in -% order to specify the color of the rules. -% -% \smallskip -% With \pkg{nicematrix}, it's possible to specify the color of the rules even -% when \pkg{colortbl} is not loaded. For sake of compatibility, the command is -% also named |\arrayrulecolor|. The environments of \pkg{nicematrix} also -% provide a key |rules/color| to fix the color of the rules in the current -% environment. This key sets the value locally (whereas |\arrayrulecolor| acts -% globally!). -% -% \medskip -% \begin{scope} -% \hfuzz=10cm -% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm] -% \begin{NiceTabular}{|ccc|}[~emphase#rules/color=[gray]{0.9},rules/width=1pt@] -% \hline -% rose & tulipe & lys \\ -% arum & iris & violette \\ -% muguet & dahlia & souci \\ -% \hline -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}{|ccc|}[rules/color=[gray]{0.9},rules/width=1pt] -% \hline -% rose & tulipe & lys \\ -% arum & iris & violette \\ -% muguet & dahlia & souci \\ -% \hline -% \end{NiceTabular} -% \end{scope} -% -% -% -% \subsection{The tools of nicematrix for the rules} -% -% Here are the tools provided by \pkg{nicematrix} for the rules. -% \begin{itemize} -% \item the keys |hlines|, |vlines|, |hvlines| and |hvlines-except-borders|; -% \item the specifier ``\verb+|+'' in the preamble (for the environments with -% preamble); -% \item the command |\Hline|. -% \end{itemize} -% -% \medskip -% \textbf{All these tools don't draw the rules in the blocks nor in the -% empty corners (when the key |corners| is used), nor in the exterior rows and -% columns.} -% \begin{itemize} -% \item These blocks are: -% \begin{itemize} -% \item the blocks created by the command |\Block|\footnote{And also the command |\multicolumn| but -% it's recommended to use instead |\Block| in the environments of -% \pkg{nicematrix}.} presented -% p.~\pageref{Block}; -% \item the blocks implicitely delimited by the continuous dotted lines created -% by |\Cdots|, |\Vdots|, etc. (cf.~p.~\pageref{Cdots}). -% \end{itemize} -% \item The corners are created by the key |corners| explained below (see -% p.~\pageref{corners}). -% \item For the exterior rows and columns, see~p.~\pageref{exterior}. -% \end{itemize} -% -% In particular, this remark explains the difference between the standard -% command |\hline| and the command |\Hline| provided by \pkg{nicematrix}. -% -% The key |\Hline| takes in an optional argument (between square brackets) which -% is a list of \textsl{key=value} pairs. For the description of those keys, see -% |custom-line| on p.~\pageref{custom-line}. -% -% \subsubsection{The keys hlines and vlines} -% -% The keys |hlines| and |vlines| (which draw, of course, horizontal and vertical -% rules) take in as value a list of numbers which are the numbers of the rules -% to draw.\footnote{It's possible to put in that list some intervals of integers -% with the syntax $i$|-|$j$.} -% -% In fact, for the environments with delimiters (such as |{pNiceMatrix}| or -% |{bNiceArray}|), the key |vlines| don't draw the exterior rules (this is -% certainly the expected behaviour). -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm] -% $\begin{pNiceMatrix}[~emphase#vlines@,rules/width=0.2pt] -% 1 & 2 & 3 & 4 & 5 & 6 \\ -% 1 & 2 & 3 & 4 & 5 & 6 \\ -% 1 & 2 & 3 & 4 & 5 & 6 -% \end{pNiceMatrix}$ -% \end{BVerbatim} -% $\begin{pNiceMatrix}[vlines,rules/width=0.2pt] -% 1 & 2 & 3 & 4 & 5 & 6 \\ -% 1 & 2 & 3 & 4 & 5 & 6 \\ -% 1 & 2 & 3 & 4 & 5 & 6 -% \end{pNiceMatrix}$ -% -% -% -% \subsubsection{The keys hvlines and hvlines-except-borders} -% \label{hvlines} -% -% The key |hvlines| (no value) is the conjonction of the keys |hlines| and |vlines|. -% -% \smallskip -% \begin{Verbatim} -% \setlength{\arrayrulewidth}{1pt} -% \begin{NiceTabular}{cccc}[~emphase#hvlines@,rules/color=blue] -% rose & tulipe & marguerite & dahlia \\ -% violette & \Block[draw=red]{2-2}{\LARGE fleurs} & & souci \\ -% pervenche & & & lys \\ -% arum & iris & jacinthe & muguet -% \end{NiceTabular} -% \end{Verbatim} -% -% \begin{center} -% \setlength{\arrayrulewidth}{1pt} -% \begin{NiceTabular}{cccc}[hvlines,rules/color=blue] -% rose & tulipe & marguerite & dahlia \\ -% violette & \Block[draw=red]{2-2}{\LARGE fleurs} & & souci \\ -% pervenche & & & lys \\ -% arum & iris & jacinthe & muguet -% \end{NiceTabular} -% \end{center} -% -% \bigskip -% It's worth noting that, when the key |rounded-corners| is used for the -% environment |{NiceTabular}|, the key |hvlines| draws rounded corners for the -% exterior frame of the tabular: cf. part~\ref{tabular-rounded-corners}, -% p.~\pageref{tabular-rounded-corners}. -% -% \bigskip -% The key |hvlines-except-borders| is similar to the key |hvlines| but does not -% draw the rules on the horizontal and vertical borders of the array. For an -% example of use of that key, see the part ``Use with tcolorbox'', -% p.~\pageref{tcolorbox}. -% -% \subsubsection{The (empty) corners} -% -% \label{corners} -% -% The four |corners| of an array will be designed by |NW|, |SW|, |NE| and |SE| -% (\emph{north west}, \emph{south west}, \emph{north east} and \emph{south east}). -% -% For each of these corners, we will call \emph{empty corner} (or simply -% \emph{corner}) the reunion of all the empty rectangles starting from the cell -% actually in the corner of the array.\footnote{For sake of completeness, we -% should also say that a cell contained in a block (even an empty cell) is not -% taken into account for the determination of the corners. That behaviour is -% natural. The precise definition of a ``non-empty cell'' is given below (cf. -% p.~\pageref{empty-cells}).} -% -% However, it's possible, for a cell without content, to require \pkg{nicematrix} -% to consider that cell as not empty with the key |\NotEmpty|. -% -%\bigskip -% \begin{minipage}{9cm} -% In the example on the right (where B is in the center of a block of size -% $2\times2$), we have colored in blue the four (empty) corners of the array. -% \end{minipage}\hspace{2cm}% -% \begin{NiceTabular}{*{6}{c}}[cell-space-top-limit=3pt] -% \CodeBefore -% \rectanglecolor{blue!10}{1-1}{4-2} -% \rectanglecolor{blue!10}{1-1}{1-4} -% \rectanglecolor{blue!10}{1-6}{3-6} -% \rectanglecolor{blue!10}{7-1}{9-1} -% \rectanglecolor{blue!10}{7-5}{9-6} -% \Body -% & & & & A \\ -% & & A & A & A \\ -% & & & A \\ -% & & A & A & A & A \\ -% A & A & A & A & A & A \\ -% A & A & A & A & A & A \\ -% & A & A & A \\ -% & \Block{2-2}{B} & & A \\ -% & & & A \\ -% \end{NiceTabular} -% -% \bigskip -% When the key |corners|\footnote{The key \texttt{corners} that we describe now -% has no direct link with the key \texttt{rounded-corners} described in the part -% \ref{tabular-rounded-corners}, p.~\pageref{tabular-rounded-corners}} is used, -% \pkg{nicematrix} computes the (empty) corners and these corners will be taken -% into account by the tools for drawing the rules (the rules won't be drawn in -% the corners). -% -% \bigskip -% \begin{BVerbatim}[boxwidth=11cm,baseline=c] -% \NiceMatrixOptions{cell-space-top-limit=3pt} -% \begin{NiceTabular}{*{6}{c}}[~emphase#corners@,hvlines] -% & & & & A \\ -% & & A & A & A \\ -% & & & A \\ -% & & A & A & A & A \\ -% A & A & A & A & A & A \\ -% A & A & A & A & A & A \\ -% & A & A & A \\ -% & \Block{2-2}{B} & & A \\ -% & & & A \\ -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}{*{6}{c}}[corners,hvlines,cell-space-top-limit=3pt] -% & & & & A \\ -% & & A & A & A \\ -% & & & A \\ -% & & A & A & A & A \\ -% A & A & A & A & A & A \\ -% A & A & A & A & A & A \\ -% & A & A & A \\ -% & \Block{2-2}{B} & & A \\ -% & & & A \\ -% \end{NiceTabular} -% -% -% \bigskip -% It's also possible to provide to the key |corners| a (comma-separated) list of -% corners (designed by |NW|, |SW|, |NE| and |SE|). -% -% \medskip -% \begin{BVerbatim}[boxwidth=11cm,baseline=c] -% \NiceMatrixOptions{cell-space-top-limit=3pt} -% \begin{NiceTabular}{*{6}{c}}[~emphase#corners=NE@,hvlines] -% 1\\ -% 1&1\\ -% 1&2&1\\ -% 1&3&3&1\\ -% 1&4&6&4&1\\ -% & & & & &1 -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}{*{6}{c}}[c,corners=NE,hvlines,cell-space-top-limit=3pt] -% 1\\ -% 1&1\\ -% 1&2&1\\ -% 1&3&3&1\\ -% 1&4&6&4&1\\ -% & & & & &1 -% \end{NiceTabular} -% -% -% \medskip -% $\triangleright$ The corners are also taken into account by the tools provided -% by \pkg{nicematrix} to color cells, rows and columns. These tools don't color -% the cells which are in the corners (cf.~p.~\pageref{color-in-code-before}). -% -% \subsection{The command \textbackslash diagbox} -% -% The command |\diagbox| (inspired by the package \pkg{diagbox}), allows, when -% it is used in a cell, to slash that cell diagonally downwards. -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% $\begin{NiceArray}{*{5}{c}}[hvlines] -% ~emphase#\diagbox{x}{y}@ & e & a & b & c \\ -% e & e & a & b & c \\ -% a & a & e & c & b \\ -% b & b & c & e & a \\ -% c & c & b & a & e -% \end{NiceArray}$ -% \end{BVerbatim} -% $\begin{NiceArray}{*{5}{c}}[hvlines] -% \diagbox{x}{y} & e & a & b & c \\ -% e & e & a & b & c \\ -% a & a & e & c & b \\ -% b & b & c & e & a \\ -% c & c & b & a & e -% \end{NiceArray}$ -% -% \medskip -% It's possible to use the command |\diagbox| in a |\Block|. -% -% -% -% -% \subsection{Commands for customized rules} -% \label{custom-line} -% -% It's also possible to define commands and letters for customized rules with -% the key |custom-line| available in |\NiceMatrixOptions| and in the options of -% individual environments. That key takes in as argument a list of -% \textsl{key=value} pairs. First, there is three keys to define the tools which -% will be used to use that new type of rule. -% -% \begin{itemize} -% \item the key |command| is the name (without the backslash) of a command that -% will be created by \pkg{nicematrix} and that will be available for the final -% user in order to draw horizontal rules (similarly to |\hline|); -% -% \item the key |ccommand| is the name (without the backslash) of a command -% that will be created by \pkg{nicematrix} and that will be available for the -% final user to order to draw partial horizontal rules (similarly to |\cline|, -% hence the name |ccommand|): the argument of that command is a list of -% intervals of columns specified by the syntax~$i$ or $i$-$j$.\footnote{It's -% recommended to use such commands only once in a row because each use will -% create space between the rows corresponding to the total width of the rule.} -% -% \item the key |letter| takes in as argument a letter\footnote{The following -% letters are forbidden: \verb+lcrpmbVX|()[]!@<>+} that the user will use in -% the preamble of an environment with preamble (such as |{NiceTabular}| in order -% to specify a vertical rule. -% \end{itemize} -% -% \bigskip -% We will now speak of the keys which describe the rule itself. Those keys may -% also be used in the (optional) argument of an individual command |\Hline|. -% -% There is three possibilities. -% -% \begin{itemize} -% \item \emph{First possibility}\par\nobreak -% -% It's possible to specify composite rules, with a color and a color for the -% inter-rule space (as possible with \pkg{colortbl} for instance). -% -% \begin{itemize} -% \item the key |multiplicity| is the number of consecutive rules that will be -% drawn: for instance, a value of $2$ will create double rules such those -% created by |\hline\hline| or \verb+||+ in the preamble of an environment; -% -% \item the key |color| sets the color of the rules ; -% -% \item the key |sep-color| sets the color between two successive rules (should be -% used only in conjonction with |multiplicity|). -% \end{itemize} -% -% \medskip -% That system may be used, in particular, for the definition of commands and -% letters to draw rules with a specific color (and those rules will respect the -% blocks and corners as do all the rules of \pkg{nicematrix}). -% -% \medskip -% \begin{Verbatim} -% \begin{NiceTabular}{lcIcIc}~emphase#[custom-line = {letter=I, color=blue}]@ -% \hline -% & \Block{1-3}{dimensions} \\ -% & L & l & h \\ -% \hline -% Product A & 3 & 1 & 2 \\ -% Product B & 1 & 3 & 4 \\ -% Product C & 5 & 4 & 1 \\ -% \hline -% \end{NiceTabular} -% \end{Verbatim} -% -% -% \bigskip -% \item \emph{Second possibility}\par\nobreak -% -% It's possible to use the key |tikz| (if Tikz is loaded). In that case, the -% rule is drawn directly with Tikz by using as parameters the value of the key -% |tikz| which must be a list of \textsl{key=value} pairs which may be applied -% to a Tikz path. -% -% By default, no space is reserved for the rule that will be drawn with Tikz. It -% is possible to specify a reservation (horizontal for a vertical rule and -% vertical for an horizontal one) with the key |total-width|. That value of that -% key, is, in some ways, the width of the rule that will be drawn -% (\pkg{nicematrix} does not compute that width from the characteristics of the -% rule specified in |tikz|). -% -% -% \begin{center} -% \begin{NiceTabular}{lcIcIc}[custom-line = {letter=I, color=blue}] -% \hline -% & \Block{1-3}{dimensions} \\ -% & L & l & H \\ -% \hline -% Product A & 3 & 1 & 2 \\ -% Product B & 1 & 3 & 4 \\ -% Product C & 5 & 4 & 1 \\ -% \hline -% \end{NiceTabular} -% \end{center} -% -% \bigskip -% Here is an example with the key |dotted| of Tikz. -% -% \begin{BVerbatim}[boxwidth=9cm,baseline=c] -% \NiceMatrixOptions -% { -% custom-line = -% { -% letter = I , -% ~emphase#tikz = dotted@ , -% ~emphase#total-width = \pgflinewidth@ -% } -% } -% -% \begin{NiceTabular}{cIcIc} -% one & two & three \\ -% four & five & six \\ -% seven & eight & nine -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{scope} -% \NiceMatrixOptions -% { -% custom-line = -% { -% letter = I , -% tikz = dotted , -% total-width = \pgflinewidth -% } -% } -% \begin{NiceTabular}{cIcIc} -% one & two & three \\ -% four & five & six \\ -% seven & eight & nine -% \end{NiceTabular} -% \end{scope} -% -% \bigskip -% \item \emph{Third possibility} : the key |dotted| -% \label{dotted} -% -% As one can see, the dots of a dotted line of Tikz have the shape of a square, -% and not a circle. That's why the extension \pkg{nicematrix} provides in the -% key |custom-line| a key |dotted| which will draw rounded dots. The initial -% value of the key |total-width| is, in this case, equal to the diameter of the dots -% (but the user may change the value with the key |total-width| if needed). Those -% dotted rules are also used by \pkg{nicematrix} to draw continuous dotted rules -% between cells of the matrix with |\Cdots|, |\Vdots|, etc. (cf. p.~\pageref{Cdots}). -% -% In fact, \pkg{nicematrix} defines by default the commands |\hdottedline| and -% |\cdottedline |and the letter ``|:|'' for those dotted -% rules.\footnote{However, it's possible to overwrite those definitions with a -% |custom-line| (in order, for example, to switch to dashed lines).} -% -%\smallskip -%\begin{BVerbatim} -% -% \NiceMatrixOptions % ~textsl#present in nicematrix.sty@ -% { -% custom-line = -% { -% letter = : , -% command = hdottedline , -% ccommand = cdottedline , -% ~emphase#dotted@ -% } -% } -% \end{BVerbatim} -% -% Thus, it's possible to use the commands |\hdottedline| and |\cdottedline |to -% draw horizontal dotted rules. -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm] -% \begin{pNiceMatrix} -% 1 & 2 & 3 & 4 & 5 \\ -% ~emphase#\hdottedline@ -% 6 & 7 & 8 & 9 & 10 \\ -% ~emphase#\cdottedline{1,4-5}@ -% 11 & 12 & 13 & 14 & 15 -% \end{pNiceMatrix} -% \end{BVerbatim} -% $\begin{pNiceMatrix} -% 1 & 2 & 3 & 4 & 5 \\ -% \hdottedline -% 6 & 7 & 8 & 9 & 10 \\ -% \cdottedline{1,4-5} -% 11 & 12 & 13 & 14 & 15 -% \end{pNiceMatrix}$ -% -% -% \bigskip -% In the environments with an explicit preamble (like |{NiceTabular}|, -% |{NiceArray}|, etc.), it's possible to draw a vertical dotted line with the -% specifier ``|:|''. -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=9.5cm] -% \left(\begin{NiceArray}{cccc~emphase#:@c} -% 1 & 2 & 3 & 4 & 5 \\ -% 6 & 7 & 8 & 9 & 10 \\ -% 11 & 12 & 13 & 14 & 15 -% \end{NiceArray}\right) -% \end{BVerbatim} -% $\left(\begin{NiceArray}{cccc:c} -% 1 & 2 & 3 & 4 & 5 \\ -% 6 & 7 & 8 & 9 & 10 \\ -% 11 & 12 & 13 & 14 & 15 -% \end{NiceArray}\right)$ -% -% \end{itemize} -% -% -% -%\section{The color of the rows and columns} -% -% \subsection{Use of colortbl} -% -% We recall that the package \pkg{colortbl} can be loaded directly with -% |\usepackage{colortbl}| or by loading \pkg{xcolor} with the key |table|: -% |\usepackage[table]{xcolor}|. -% -% \medskip -% Since the package \pkg{nicematrix} is based on \pkg{array}, it's possible to -% use \pkg{colortbl} with \pkg{nicematrix}. -% -% \medskip -% However, there is two drawbacks: -% \begin{itemize} -% \item The package \pkg{colortbl} patches \pkg{array}, leading to some -% incompatibilities (for instance with the command |\hdotsfor|). -% -% \item The package \pkg{colortbl} constructs the array row by row, alterning -% colored rectangles, rules and contents of the cells. The resulting -% \textsc{pdf} is difficult to interpret by some \textsc{pdf} viewers and may -% lead to artefacts on the screen. -% \begin{itemize} -% \item Some rules seem to disappear. This is because many PDF viewers give -% priority to graphical element drawn posteriorly (which is in the spirit of the -% ``painting model'' of PostScript and PDF). Concerning this problem, MuPDF -% (which is used, for instance, by SumatraPDF) gives better results than Adobe -% Reader). -% \item A thin white line may appear between two cells of the same color. This -% phenomenon occurs when each cell is colored with its own instruction |fill| -% (the PostScript operator |fill| noted |f| in PDF). This is the case with -% \pkg{colortbl}: each cell is colored on its own, even when |\columncolor| or -% |\rowcolor| is used. -% -% As for this phenomenon, Adobe Reader gives better results than MuPDF. -% \end{itemize} -% -% The package \pkg{nicematrix} provides tools to avoid those problems. -% \end{itemize} -% -% \subsection{The tools of nicematrix in the \textbackslash CodeBefore} -% -% \label{color-in-code-before} -% -% The package \pkg{nicematrix} provides some tools (independent of -% \pkg{colortbl}) to draw the colored panels first, and, then, the content of -% the cells and the rules. This strategy is more conform to the ``painting -% model'' of the formats PostScript and \textsc{pdf} and is more suitable for -% the \textsc{pdf} viewers. However, it requires several -% compilations.\footnote{If you use Overleaf, Overleaf will do automatically the -% right number of compilations.} -% -% \medskip -% The extension \pkg{nicematrix} provides a key |code-before| for some code that -% will be executed before the drawing of the tabular. -% -% \medskip -% An alternative syntax is provided: it's possible to put the content of that -% |code-before| between the keywords |\CodeBefore| and |\Body| at the beginning -% of the environment. -% -% \begin{Verbatim} -% \begin{pNiceArray}{~textsl#preamble@} -% ~emphase#\CodeBefore [~textsl#options@]@ -% ~textsl#instructions of the code-before@ -% ~emphase#\Body@ -% ~textsl#contents of the environment@ -% \end{pNiceArray} -% \end{Verbatim} -% -% \smallskip -% The optional argument between square brackets is a list of \textsl{key=value} -% pairs which will be presented progressively in this -% documentation.\footnote{The available keys are |create-cell-nodes|, -% |sub-matrix| (and its subkeys) and \texttt{delimiters-color}.} -% -% \medskip -% New commands are available in that |\CodeBefore|: |\cellcolor|, -% |\rectanglecolor|, |\rowcolor|, |\columncolor|, |\rowcolors|, -% |\rowlistcolors|, |\chessboardcolors| and |\arraycolor|.\footnote{Remark that, -% in the |\CodeBefore|, PGF/Tikz nodes of the form ``\verb+(i-|j)+'' are -% also available to indicate the position to the potential rules: -% cf.~p.~\pageref{nodes-i}.} -% \label{code-before} -% -% \medskip -% These commands don't color the cells which are in the ``corners'' if the key -% |corners| is used. That key has been described p.~\pageref{corners}. -% -% \medskip -% These commands respect the rounded corners if the key |rounded-corners| -% (described in the part \ref{tabular-rounded-corners} at the -% page~\pageref{tabular-rounded-corners}) has been used. -% -% \medskip -% All these commands accept an optional argument, between square brackets and -% in first position. That optional argument may contain two elements (separated -% by a comma) -% \begin{itemize} -% \item the colorimetric space (|RGB|, |rgb|, |HTML|, etc) as specified by the -% the extension \pkg{xcolor}; -% \item \colorbox{yellow!50}{\textbf{New 6.18}}\par\nobreak -% a specification of opacity f the form \texttt{opacity = \textsl{value}}. -% \end{itemize} -% -% \bigskip -% -% We describe now in detail those commands. -% -% \medskip -% \begin{itemize} -% \item The command \Definition{\textbackslash cellcolor} takes its name from -% the command |\cellcolor| of \pkg{colortbl}. -% -% This command takes in as mandatory arguments a color and a list of cells, each -% of which with the format $i$-$j$ where $i$ is the number of the row and $j$ the -% number of the colummn of the cell. In fact, despite its name, this command may -% be used to color a whole row (with the syntax $i$-) or a whole column (with the -% syntax -$j$). -% -% \medskip -% \begin{scope} -% \hfuzz=10cm -% \begin{BVerbatim}[boxwidth=10cm,baseline=c] -% \begin{NiceTabular}{ccc}[hvlines] -% \CodeBefore -% ~emphase#\cellcolor[HTML]{FFFF88}{3-1,2-2,-3}@ -% \Body -% a & b & c \\ -% e & f & g \\ -% h & i & j \\ -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}{ccc}[hvlines] -% \CodeBefore -% \cellcolor[HTML]{FFFF88}{3-1,2-2,-3} -% \Body -% a & b & c \\ -% e & f & g \\ -% h & i & j \\ -% \end{NiceTabular} -% \end{scope} -% -% \bigskip -% \item The command \Definition{\textbackslash rectanglecolor} takes three -% mandatory arguments. The first is the color. The second is the upper-left cell -% of the rectangle and the third is the lower-right cell of the rectangle. -% -% \medskip -% \begin{scope} -% \hfuzz=10cm -% \begin{BVerbatim}[boxwidth=10cm,baseline=c] -% \begin{NiceTabular}{ccc}[hvlines] -% \CodeBefore -% ~emphase#\rectanglecolor{blue!15}{2-2}{3-3}@ -% \Body -% a & b & c \\ -% e & f & g \\ -% h & i & j \\ -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}{ccc}[hvlines] -% \CodeBefore -% \rectanglecolor{blue!15}{2-2}{3-3} -% \Body -% a & b & c \\ -% e & f & g \\ -% h & i & j \\ -% \end{NiceTabular} -% \end{scope} -% -% \bigskip -% \item The command \Definition{\textbackslash arraycolor} takes in as mandatory -% argument a color and color the whole tabular with that color (excepted the -% potential exterior rows and columns: cf.~p.~\pageref{exterior}). It's only a -% particular case of |\rectanglecolor|. -% -% -% \bigskip -% \item The command \Definition{\textbackslash chessboardcolors} takes in as -% mandatory arguments two colors and it colors the cells of the tabular in -% quincunx with these colors. -% -% \medskip -% \begin{scope} -% \hfuzz=10cm -% \begin{BVerbatim}[baseline=c,boxwidth=9cm] -% $\begin{pNiceMatrix}[r,margin] -% \CodeBefore -% ~emphase#\chessboardcolors{red!15}{blue!15}@ -% \Body -% 1 & -1 & 1 \\ -% -1 & 1 & -1 \\ -% 1 & -1 & 1 -% \end{pNiceMatrix}$ -% \end{BVerbatim} -% $\begin{pNiceMatrix}[r,baseline=1, margin] -% \CodeBefore -% \chessboardcolors{red!15}{blue!15} -% \Body -% 1 & -1 & 1 \\ -% -1 & 1 & -1 \\ -% 1 & -1 & 1 -% \end{pNiceMatrix}$ -% \end{scope} -% -% \medskip -% We have used the key |r| which aligns all the columns rightwards (cf. -% p.~\pageref{columns-width}). -% -% -% \bigskip -% \item The command \Definition{\textbackslash rowcolor} takes its name from the -% command |\rowcolor| of \pkg{colortbl}. Its first mandatory argument is the -% color and the second is a comma-separated list of rows or interval of rows -% with the form $a$-$b$ (an interval of the form $a$- represent all the rows -% from the row $a$ until the end). -% -% \medskip -% \begin{scope} -% \hfuzz = 10cm -% \begin{BVerbatim}[boxwidth=9cm,baseline=c] -% $\begin{NiceArray}{lll}[hvlines] -% \CodeBefore -% ~emphase#\rowcolor{red!15}{1,3-5,8-}@ -% \Body -% a_1 & b_1 & c_1 \\ -% a_2 & b_2 & c_2 \\ -% a_3 & b_3 & c_3 \\ -% a_4 & b_4 & c_4 \\ -% a_5 & b_5 & c_5 \\ -% a_6 & b_6 & c_6 \\ -% a_7 & b_7 & c_7 \\ -% a_8 & b_8 & c_8 \\ -% a_9 & b_9 & c_9 \\ -% a_{10} & b_{10} & c_{10} \\ -% \end{NiceArray}$ -% \end{BVerbatim} -% $\begin{NiceArray}{lll}[baseline=4,hvlines] -% \CodeBefore -% \rowcolor{red!15}{1,3-5,8-} -% \Body -% a_1 & b_1 & c_1 \\ -% a_2 & b_2 & c_2 \\ -% a_3 & b_3 & c_3 \\ -% a_4 & b_4 & c_4 \\ -% a_5 & b_5 & c_5 \\ -% a_6 & b_6 & c_6 \\ -% a_7 & b_7 & c_7 \\ -% a_8 & b_8 & c_8 \\ -% a_9 & b_9 & c_9 \\ -% a_{10} & b_{10} & c_{10} \\ -% \end{NiceArray}$ -% \end{scope} -% -% -% \bigskip -% \item The command \Definition{\textbackslash columncolor} takes its name from -% the command |\columncolor| of \pkg{colortbl}. Its syntax is similar to the -% syntax of |\rowcolor|. -% -% \bigskip -% \item The command \Definition{\textbackslash rowcolors} (with a \emph{s}) -% takes its name from the command |\rowcolors| of \pkg{colortbl}. The \emph{s} -% emphasizes the fact that there is \emph{two} colors. This command colors -% alternately the rows of the tabular with the two colors (provided in second -% and third argument), beginning with the row whose number is given in first -% (mandatory) argument. -% -% In fact, the first (mandatory) argument is, more generally, a comma separated -% list of intervals describing the rows involved in the action of |\rowcolors| -% (an interval of the form $i$|-| describes in fact the interval of all the rows -% of the tabular, beginning with the row~$i$). -% -% -% \bigskip -% The last argument of |\rowcolors| is an optional list of pairs -% \textsl{key=value} (the optional argument in the first position corresponds to -% the colorimetric space). The available keys are |cols|, |restart| and -% |respect-blocks|. -% \begin{itemize} -% \item The key |cols| describes a set of columns. The command |\rowcolors| will -% color only the cells of these columns. The value is a comma-separated list of -% intervals of the form $i$-$j$ (where $i$ or $j$ may be replaced by |*|). -% \item With the key |restart|, each interval of rows (specified by the first -% mandatory argument) begins with the same color.\footnote{Otherwise, the color -% of a given row relies only upon the parity of its absolute number.} -% \item With the key |respect-blocks| the ``rows'' alternately colored may extend over -% several rows if they have to incorporate blocks (created with the command -% |\Block|: cf.~p.~\pageref{Block}). -% \end{itemize} -% -% \medskip -% \begin{scope} -% \hfuzz=10cm -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% \begin{NiceTabular}{clr}[hvlines] -% \CodeBefore -% ~emphase#\rowcolors[gray]{2}{0.8}{}[cols=2-3,restart]@ -% \Body -% \Block{1-*}{Results} \\ -% John & 12 \\ -% Stephen & 8 \\ -% Sarah & 18 \\ -% Ashley & 20 \\ -% Henry & 14 \\ -% Madison & 15 -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}{clr}[hvlines,baseline=2] -% \CodeBefore -% \rowcolors[gray]{2}{0.8}{}[cols=2-3,restart] -% \Body -% \Block{1-*}{Results} \\ -% \Block{2-1}{A}& John & 12 \\ -% & Stephen & 8 \\ -% \Block{4-1}{B}& Sarah & 18 \\ -% & Ashley & 20 \\ -% & Henry & 14 \\ -% & Madison & 15 -% \end{NiceTabular} -% \end{scope} -% -% \vspace{1cm} -% \begin{scope} -% \hfuzz=10cm -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% \begin{NiceTabular}{lr}[hvlines] -% \CodeBefore -% ~emphase#\rowcolors{1}{blue!10}{}[respect-blocks]@ -% \Body -% \Block{2-1}{John} & 12 \\ -% & 13 \\ -% Steph & 8 \\ -% \Block{3-1}{Sarah} & 18 \\ -% & 17 \\ -% & 15 \\ -% Ashley & 20 \\ -% Henry & 14 \\ -% \Block{2-1}{Madison} & 15 \\ -% & 19 -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}{lr}[hvlines,baseline=c] -% \CodeBefore -% \rowcolors{1}{blue!10}{}[respect-blocks] -% \Body -% \Block{2-1}{John} & 12 \\ -% & 13 \\ -% Steph & 8 \\ -% \Block{3-1}{Sarah} & 18 \\ -% & 17 \\ -% & 15 \\ -% Ashley & 20 \\ -% Henry & 14 \\ -% \Block{2-1}{Madison} & 15 \\ -% & 19 -% \end{NiceTabular} -% \end{scope} -% -% -% -% -% \bigskip -% \item The extension \pkg{nicematrix} provides also a command -% \Definition{\textbackslash rowlistcolors}. This command generalises the -% command |\rowcolors|: instead of two successive arguments for the colors, this -% command takes in an argument which is a (comma-separated) list of colors. In -% that list, the symbol |=| represent a color identical to the previous one. -% -% \smallskip -% \begin{BVerbatim}[boxwidth=10cm,baseline=c] -% \begin{NiceTabular}{c} -% \CodeBefore -% ~emphase#\rowlistcolors{1}{red!15,blue!15,green!15}@ -% \Body -% Peter \\ -% James \\ -% Abigail \\ -% Elisabeth \\ -% Claudius \\ -% Jane \\ -% Alexandra \\ -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}{c} -% \CodeBefore -% \rowlistcolors{1}{red!15,blue!15,green!15} -% \Body -% Peter \\ -% James \\ -% Abigail \\ -% Elisabeth \\ -% Claudius \\ -% Jane \\ -% Alexandra \\ -% \end{NiceTabular} -% -% \bigskip -% It's also possible to use in the command |\rowlistcolors| a color series -% defined by the command |\definecolorseries| of \pkg{xcolor} (and initialized -% with the command |\resetcolorseries|\footnote{For the initialization, in the -% following example, you have used the counter |iRow| which, when used in the -% |\CodeBefore| (and in the |\CodeAfter|) corresponds to the number of rows of -% the array: cf.~p~\pageref{iRow}. That leads to an adjustement of the gradation -% of the colors to the size of the tabular.}). -% -% \smallskip -% \begin{BVerbatim}[boxwidth=12.5cm,baseline=c] -% \begin{NiceTabular}{c} -% \CodeBefore -% ~emphase#\definecolorseries{BlueWhite}{rgb}{last}{blue}{white}@ -% ~emphase#\resetcolorseries{\value{iRow}}{BlueWhite}@ -% ~emphase#\rowlistcolors{1}{BlueWhite!!+}@ -% \Body -% Peter \\ -% James \\ -% Abigail \\ -% Elisabeth \\ -% Claudius \\ -% Jane \\ -% Alexandra \\ -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}{c} -% \CodeBefore -% \definecolorseries{BlueWhite}{rgb}{last}{blue}{white} -% \resetcolorseries[\value{iRow}]{BlueWhite} -% \rowlistcolors{1}{BlueWhite!!+} -% \Body -% Peter \\ -% James \\ -% Abigail \\ -% Elisabeth \\ -% Claudius \\ -% Jane \\ -% Alexandra \\ -% \end{NiceTabular} -% \end{itemize} -% -% \vspace{1cm} -% We recall that all the color commands we have described don't color the cells -% which are in the ``corners''. In the following example, we use the key -% |corners| to require the determination of the corner \emph{north east} (NE). -% -%\medskip -% \begin{scope} -% \hfuzz=11cm -% \begin{BVerbatim}[boxwidth=9cm,baseline=c] -% \begin{NiceTabular}{cccccc}[~emphase#corners=NE@,margin,hvlines,first-row,first-col] -% \CodeBefore -% ~emphase#\rowlistcolors{1}{blue!15, }@ -% \Body -% & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\ -% 0 & 1 \\ -% 1 & 1 & 1 \\ -% 2 & 1 & 2 & 1 \\ -% 3 & 1 & 3 & 3 & 1 \\ -% 4 & 1 & 4 & 6 & 4 & 1 \\ -% 5 & 1 & 5 & 10 & 10 & 5 & 1 \\ -% 6 & 1 & 6 & 15 & 20 & 15 & 6 & 1 \\ -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}{ccccccc}[corners=NE,margin,hvlines,first-row,first-col] -% \CodeBefore -% \rowlistcolors{1}{blue!15, } -% \Body -% & 0 & 1 & 2 & 3 & 4 & 5 & 6 \\ -% 0 & 1 \\ -% 1 & 1 & 1 \\ -% 2 & 1 & 2 & 1 \\ -% 3 & 1 & 3 & 3 & 1 \\ -% 4 & 1 & 4 & 6 & 4 & 1 \\ -% 5 & 1 & 5 & 10 & 10 & 5 & 1 \\ -% 6 & 1 & 6 & 15 & 20 & 15 & 6 & 1 \\ -% \end{NiceTabular} -% \end{scope} -% -% -% \bigskip -% One should remark that all the previous commands are compatible with the -% commands of \pkg{booktabs} (|\toprule|, |\midrule|, |\bottomrule|, etc). -% However, \pkg{booktabs} is \emph{not} loaded by \pkg{nicematrix}. -% -% \medskip -% \begin{scope} -% \hfuzz=10cm -% \begin{BVerbatim}[baseline=c,boxwidth=8.5cm] -% \begin{NiceTabular}[c]{lSSSS} -% \CodeBefore -% \rowcolor{red!15}{1-2} -% \rowcolors{3}{blue!15}{} -% \Body -% ~emphase#\toprule@ -% \Block{2-1}{Product} & -% \Block{1-3}{dimensions (cm)} & & & -% \Block{2-1}{\rotate Price} \\ -% ~emphase#\cmidrule(rl){2-4}@ -% & L & l & h \\ -% ~emphase#\midrule@ -% small & 3 & 5.5 & 1 & 30 \\ -% standard & 5.5 & 8 & 1.5 & 50.5 \\ -% premium & 8.5 & 10.5 & 2 & 80 \\ -% extra & 8.5 & 10 & 1.5 & 85.5 \\ -% special & 12 & 12 & 0.5 & 70 \\ -% ~emphase#\bottomrule@ -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}[c]{lSSSS} -% \CodeBefore -% \rowcolor{red!15}{1-2} -% \rowcolors{3}{blue!15}{} -% \Body -% \toprule -% \Block{2-1}{Product} & -% \Block{1-3}{dimensions (cm)} & & & -% \Block{2-1}{\rotate Price} \\ -% \cmidrule(rl){2-4} -% & L & l & h \\ -% \midrule -% small & 3 & 5.5 & 1 & 30 \\ -% standard & 5.5 & 8 & 1.5 & 50.5 \\ -% premium & 8.5 & 10.5 & 2 & 80 \\ -% extra & 8.5 & 10 & 1.5 & 85.5 \\ -% special & 12 & 12 & 0.5 & 70 \\ -% \bottomrule -% \end{NiceTabular} -% \end{scope} -% -% \medskip -% We have used the type of column |S| of \pkg{siunitx}. -% -% -% \subsection{Color tools with the syntax of colortbl} -% -% It's possible to access the preceding tools with a syntax close to the syntax -% of \pkg{colortbl}. For that, one must use the key |colortbl-like| in the -% current environment.\footnote{Up to now, this key is \emph{not} available in |\NiceMatrixOptions|.} -% -% There are three commands available (they are inspired by \pkg{colortbl} but -% are \emph{independent} of \pkg{colortbl}): -% \begin{itemize} -% \item |\cellcolor| which colorizes a cell;\footnote{However, this command -% |\cellcolor| will delete the following spaces, which does not the command -% |\cellcolor| of \pkg{colortbl}.} -% \item |\rowcolor| which must be used in a cell and which colorizes the end of -% the row; -% \item |\columncolor| which must be used in the preamble of the environment -% with the same syntax as the corresponding command of -% \pkg{colortbl} (however, unlike the command |\columncolor| of \pkg{colortbl}, -% this command |\columncolor| can appear within another command, itself used in the -% preamble of the array). -% \end{itemize} -% -% \smallskip -% \begin{Verbatim} -% \NewDocumentCommand { \Blue } { } { ~emphase#\columncolor{blue!15}@ } -% \begin{NiceTabular}[colortbl-like]{>{\Blue}c>{\Blue}cc} -% \toprule -% ~emphase#\rowcolor{red!15}@ -% Last name & First name & Birth day \\ -% \midrule -% Achard & Jacques & 5 juin 1962 \\ -% Lefebvre & Mathilde & 23 mai 1988 \\ -% Vanesse & Stephany & 30 octobre 1994 \\ -% Dupont & Chantal & 15 janvier 1998 \\ -% \bottomrule -% \end{NiceTabular} -% \end{Verbatim} -% -% -% \begin{center} -% \NewDocumentCommand { \Blue } { } { \columncolor{blue!15} } -% \begin{NiceTabular}[colortbl-like]{>{\Blue}c>{\Blue}cc} -% \toprule -% \rowcolor{red!15} -% Last name & First name & Birth day \\ -% \midrule -% Achard & Jacques & 5 juin 1962 \\ -% Lefebvre & Mathilde & 23 mai 1988 \\ -% Vanesse & Stephany & 30 octobre 1994 \\ -% Dupont & Chantal & 15 janvier 1998 \\ -% \bottomrule -% \end{NiceTabular} -% \end{center} -% -% \section{The command \textbackslash RowStyle} -% -% \label{RowStyle} -% -% The command |\RowStyle| takes in as argument some formatting intructions that -% will be applied to each cell on the rest of the current row. -% -% \medskip -% That command also takes in as optional argument (between square brackets) -% a list of \textsl{key=value} pairs. -% \begin{itemize} -% \item The key |nb-rows| sets -% the number of rows to which the specifications of the current command will -% apply (with the special value |*|, it will apply to all the following rows). -% \item The keys |cell-space-top-limit|, |cell-space-bottom-limit| and -% |cell-space-limits| are available with the same meaning that the corresponding -% global keys (cf. p.~\pageref{cell-space}). -% \item The key |rowcolor| sets -% the color of the background and the key |color| sets the -% color of the text.\footnote{The key |color| uses the command -% |\color| but inserts also an instruction |\leavevmode| before. This -% instruction prevents a extra vertical space in the cells which belong to -% columns of type |p|, |b|, |m|, |X| and |V| (which start in -% vertical mode).} -% \item The key |bold| enforces -% bold characters for the cells of the row, both in math and text mode. -% \end{itemize} -% -% \medskip -% \begin{BVerbatim}[boxwidth=12cm,baseline=c] -% \begin{NiceTabular}{cccc} -% \hline -% ~emphase#\RowStyle[cell-space-limits=3pt]{\rotate}@ -% first & second & third & fourth \\ -% ~emphase#\RowStyle[nb-rows=2,rowcolor=blue!50,color=white]{\sffamily}@ -% 1 & 2 & 3 & 4 \\ -% I & II & III & IV -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}{cccc} -% \hline -% \RowStyle[cell-space-limits=3pt]{\rotate} -% first & second & third & fourth \\ -% \RowStyle[nb-rows=2,rowcolor=blue!50,color=white]{\sffamily} -% 1 & 2 & 3 & 4 \\ -% I & II & III & IV \\ -% \end{NiceTabular} -% -% \medskip -% The command |\rotate| is described p.~\pageref{rotate}. -% -% \section{The width of the columns} -% \label{width} -% -% \subsection{Basic tools} -% -% In the environments with an explicit preamble (like |{NiceTabular}|, -% |{NiceArray}|, etc.), it's possible to fix the width of a given column with -% the standard letters |w|, |W|, |p|, |b| and |m| of the package \pkg{array}. -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=9cm] -% \begin{NiceTabular}{~emphase#W{c}{2cm}@cc}[hvlines] -% Paris & New York & Madrid \\ -% Berlin & London & Roma \\ -% Rio & Tokyo & Oslo -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}{W{c}{2cm}cc}[hvlines] -% Paris & New York & Madrid \\ -% Berlin & London & Roma \\ -% Rio & Tokyo & Oslo -% \end{NiceTabular} -% -% -% \bigskip -% In the environments of \pkg{nicematrix}, it's also possible to fix the \emph{minimal} -% width of all the columns (excepted the potential exterior columns: cf. p.~\pageref{exterior}) directly -% with the key |columns-width|. -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% $\begin{pNiceMatrix}[~emphase#columns-width = 1cm@] -% 1 & 12 & -123 \\ -% 12 & 0 & 0 \\ -% 4 & 1 & 2 -% \end{pNiceMatrix}$ -% \end{BVerbatim} -% $\begin{pNiceMatrix}[columns-width = 1cm] -% 1 & 12 & -123 \\ -% 12 & 0 & 0 \\ -% 4 & 1 & 2 -% \end{pNiceMatrix}$ -% -% \medskip -% Note that the space inserted between two columns (equal to 2 |\tabcolsep| in -% |{NiceTabular}| and to 2 |\arraycolsep| in the other environments) -% is not suppressed (of course, it's possible to suppress this space by setting -% |\tabcolsep| or |\arraycolsep| equal to $0$~pt before the environment). -% -% \bigskip -% It's possible to give the special value |auto| to the option |columns-width|: -% all the columns of the array will have a width equal to the widest cell of the -% array.\footnote{The result is achieved with only one compilation (but PGF/Tikz -% will have written informations in the |aux| file and a message requiring a -% second compilation will appear).}\par\nobreak -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% $\begin{pNiceMatrix}[~emphase#columns-width = auto@] -% 1 & 12 & -123 \\ -% 12 & 0 & 0 \\ -% 4 & 1 & 2 -% \end{pNiceMatrix}$ -% \end{BVerbatim} -% $\begin{pNiceMatrix}[columns-width = auto] -% 1 & 12 & -123 \\ -% 12 & 0 & 0 \\ -% 4 & 1 & 2 -% \end{pNiceMatrix}$ -% -% \bigskip -% Without surprise, it's possible to fix the minimal width of the columns of all -% the arrays of a current scope with the command -% |\NiceMatrixOptions|.\par\nobreak -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=8.5cm] -% ~emphase#\NiceMatrixOptions{columns-width=10mm}@ -% $\begin{pNiceMatrix} -% a & b \\ c & d -% \end{pNiceMatrix} -% = -% \begin{pNiceMatrix} -% 1 & 1245 \\ 345 & 2 -% \end{pNiceMatrix}$ -% \end{BVerbatim} -% \begin{scope} -% \NiceMatrixOptions{columns-width=10mm} -% $\begin{pNiceMatrix} -% a & b \\ -% c & d -% \end{pNiceMatrix} -% = -% \begin{pNiceMatrix} -% 1 & 1245 \\ -% 345 & 2 -% \end{pNiceMatrix}$ -% \end{scope} -% -% -% \bigskip -% But it's also possible to fix a zone where all the matrices will have their -% columns of the same width, equal to the widest cell of all the matrices. This -% construction uses the environment |{NiceMatrixBlock}| with the option -% |auto-columns-width|\footnote{At this time, this is the only usage of the -% environment |{NiceMatrixBlock}| but it may have other usages in the future.}. -% The environment |{NiceMatrixBlock}| has no direct link with the command -% |\Block| presented previously in this document (cf.~p.~\pageref{Block}). -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=8.5cm] -% ~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@ -% $\begin{array}{c} -% \begin{bNiceMatrix} -% 9 & 17 \\ -2 & 5 -% \end{bNiceMatrix} \\ \\ -% \begin{bNiceMatrix} -% 1 & 1245345 \\ 345 & 2 -% \end{bNiceMatrix} -% \end{array}$ -% ~emphase#\end{NiceMatrixBlock}@ -% \end{BVerbatim} -% \begin{NiceMatrixBlock}[auto-columns-width] -% $\begin{array}{c} -% \begin{bNiceMatrix} -% 9 & 17 \\ -2 & 5 -% \end{bNiceMatrix} \\ \\ -% \begin{bNiceMatrix} -% 1 & 1245345 \\ 345 & 2 -% \end{bNiceMatrix} -% \end{array}$ -% \end{NiceMatrixBlock} -% -% \subsection{The columns X} -% -% \label{X-columns} -% -% The environment |{NiceTabular}| provides |X| columns similar to those provided -% by the environment |{tabularx}| of the eponymous package. -% -% The required width of the tabular may be specified with the key |width| (in -% |{NiceTabular}| or in |\NiceMatrixOptions|). The initial value of this -% parameter is |\linewidth| (and not |\textwidth|). -% -% For sake of similarity with the environment |{tabularx}|, \pkg{nicematrix} -% also provides an environment |{NiceTabularX}| with a syntax similar to the -% syntax of |{tabularx}|, that is to say with a first mandatory argument -% which is the width of the tabular.\footnote{If \pkg{tabularx} is loaded, one -% must use |{NiceTabularX}| (and not |{NiceTabular}|) in order to use the -% columns |X| (this point comes from a conflict in the definitions of the -% specifier |X|).} -% -% As with the packages \pkg{tabu}\footnote{The extension \pkg{tabu} is now -% considered as deprecated.} and \pkg{tabularray}, the specifier |X| takes -% in an optional argument (between square brackets) which is a list of keys. -% \begin{itemize} -% \item It's possible to give a weight for the column by providing a positive -% integer directly as argument of the specifier |X|. For example, a column -% |X[2]| will have a width double of the width of a column~|X| (which has a -% weight equal to $1$).\footnote{The negative values of the weight, as provided -% by \pkg{tabu} (which is now obsolete), are \emph{not} supported by \pkg{nicematrix}. -% If such a value is used, an error will be raised.} -% \item It's possible to specify an horizontal alignment with one of the -% letters |l|, |c| and |r| (which insert respectively |\raggedright|, -% |\centering| and |\raggedleft| followed by |\arraybackslash|). -% \item It's possible to specify a vertical alignment with one of the keys -% |t| (alias |p|), |m| and |b| (which construct respectively columns of type -% |p|, |m| and |b|). The default value is |t|. -% \end{itemize} -% -% \begin{Verbatim} -% \begin{NiceTabular}~emphase#[width=9cm]{X[2,l]X[l]}@[hvlines] -% a rather long text which fits on several lines -% & a rather long text which fits on several lines \\ -% a shorter text & a shorter text -% \end{NiceTabular} -% \end{Verbatim} -% -% \begin{center} -% \begin{NiceTabular}[width=9cm]{X[2,l]X[l]}[hvlines] -% a rather long text which fits on several lines -% & a rather long text which fits on several lines \\ -% a shorter text & a shorter text -% \end{NiceTabular} -% \end{center} -% -% -% \subsection{The columns V of varwidth} -% -% \label{varwidth} -% -% Let's recall first the behaviour of the environment |{varwidth}| of the -% eponymous package \pkg{varwidth}. That environment is similar to the classical -% environment |{minipage}| but the width provided in the argument is only the -% \emph{maximal} width of the created box. In the general case, the width of the -% box constructed by an environment |{varwidth}| is the natural width of its -% contents. -% -% \medskip -% That point is illustrated on the following examples. -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=6cm] -% \fbox{% -% \begin{~emphase#varwidth@}{8cm} -% \begin{itemize} -% \item first item -% \item second item -% \end{itemize} -% \end{~emphase#varwidth@}} -% \end{BVerbatim} -% \fbox{\begin{varwidth}{8cm} -% \begin{itemize} -% \item first item -% \item second item -% \end{itemize} -% \end{varwidth}} -% -% \bigskip -% \begin{BVerbatim}[baseline=c,boxwidth=6cm] -% \fbox{% -% \begin{~emphase#minipage@}{8cm} -% \begin{itemize} -% \item first item -% \item second item -% \end{itemize} -% \end{~emphase#minipage@}} -% \end{BVerbatim} -% \fbox{\begin{minipage}{8cm} -% \begin{itemize} -% \item first item -% \item second item -% \end{itemize} -% \end{minipage}} -% -% -% \bigskip -% The package \pkg{varwidth} provides also the column type |V|. A column of type -% |V{|$\langle$\textsl{dim}$\rangle$|}| encapsulates all its cells in a -% |{varwidth}| with the argument $\langle$\textsl{dim}$\rangle$ (and does also some tuning). -% -% \smallskip -% When the package \pkg{varwidth} is loaded, the columns |V| of \pkg{varwidth} -% are supported by \pkg{nicematrix}. -% -% \medskip -% \begin{Verbatim} -% \begin{NiceTabular}[corners=NW,hvlines]{~emphase#V{3cm}V{3cm}V{3cm}@} -% & some text & some very very very long text \\ -% some very very very long text \\ -% some very very very long text -% \end{NiceTabular} -% \end{Verbatim} -% -% \medskip -% \begin{center} -% \begin{NiceTabular}[corners=NW,hvlines]{V{3cm}V{3cm}V{3cm}} -% & some text & some very very very long text \\ -% some very very very long text \\ -% some very very very long text -% \end{NiceTabular} -% \end{center} -% -% \bigskip -% Concerning \pkg{nicematrix}, one of the -% interests of this type of columns is that, for a cell of a column of type~|V|, -% the PGF/Tikz node created by \pkg{nicematrix} for the content of that cell has -% a width adjusted to the content of the cell : cf. p.~\pageref{node-V}. -% -% -% \bigskip -% The columns |V| of \pkg{nicematrix} supports the keys |t|, |p|, |m|, |b|, |l|, -% |c| and |r| also supported by the columns |X|: see their description in the -% section~\ref{X-columns}, p.~\pageref{X-columns}. -% -% \bigskip -% One should remark that the extension \pkg{varwidth} (at least in its version -% 0.92) has some problems: for instance, with LuaLaTeX, it does not work when -% the content begins with |\color|. -% -% \bigskip -% \section{The exterior rows and columns} -% -% The options |first-row|, |last-row|, |first-col| and |last-col| allow the -% composition of exterior rows and columns in the environments of -% \pkg{nicematrix}. It's particularly interesting for the (methematical) -% matrices. -% \label{exterior} -% -% A potential ``first row'' (exterior) has the number $0$ (and not $1$). Idem -% for the potential ``first column''. -% -% \begin{Verbatim} -% $\begin{pNiceMatrix}[~emphase#first-row,last-row,first-col,last-col@,nullify-dots] -% & C_1 & \Cdots & & C_4 & \\ -% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\ -% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\ -% & a_{31} & a_{32} & a_{33} & a_{34} & \\ -% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\ -% & C_1 & \Cdots & & C_4 & -% \end{pNiceMatrix}$ -% \end{Verbatim} -% -% \[\begin{pNiceMatrix}[first-row,last-row,first-col,last-col,nullify-dots] -% & C_1 & \Cdots & & C_4 & \\ -% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\ -% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\ -% & a_{31} & a_{32} & a_{33} & a_{34} & \\ -% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\ -% & C_1 & \Cdots & & C_4 & -% \end{pNiceMatrix}\] -% -% \medskip -% The dotted lines have been drawn with the tools presented p.~\pageref{Cdots}. -% -% \bigskip -% We have several remarks to do. -% \begin{itemize}[beginpenalty=10000] -% \item For the environments with an explicit preamble (i.e. |{NiceTabular}|, -% |{NiceArray}| and its variants), no letter must be given in that preamble for -% the potential first column and the potential last column: they will -% automatically (and necessarily) be of type |r| for the first column and |l| -% for the last one.\footnote{The users wishing exterior columns with another -% type of alignment should consider the command |\SubMatrix| available in the -% |\CodeAfter| (cf.~p.~\pageref{sub-matrix}).} -% \item One may wonder how \pkg{nicematrix} determines the number of rows and -% columns which are needed for the composition of the ``last row'' and ``last -% column''. -% \begin{itemize} -% \item For the environments with explicit preamble, like |{NiceTabular}| and -% |{pNiceArray}|, the number of columns can obviously be computed from the -% preamble. -% -% \item When the option |light-syntax| (cf. p. \pageref{light-syntax}) is used, -% \pkg{nicematrix} has, in any case, to load the whole body of the environment -% (and that's why it's not possible to put verbatim material in the array with -% the option |light-syntax|). The analysis of this whole body gives the number -% of rows and the number of columns. -% -% \item In the other cases, \pkg{nicematrix} compute the number of rows and -% columns during the first compilation and write the result in the |aux| file -% for the next run. -% -% \textsl{However, it's possible to provide the number of the last row and the -% number of the last column as values of the options |last-row| and |last-col|, -% tending to an acceleration of the whole compilation of the document.} That's -% what we will do throughout the rest of the document. -% \end{itemize} -% \end{itemize} -% -% \bigskip -% It's possible to control the appearance of these rows and columns with options -% |code-for-first-row|, |code-for-last-row|, |code-for-first-col| and -% |code-for-last-col|. These options specify tokens that will be inserted before -% each cell of the corresponding row or column. -% -% -% \begin{Verbatim} -% \NiceMatrixOptions{~emphase#code-for-first-row@ = \color{red}, -% ~emphase#code-for-first-col@ = \color{blue}, -% ~emphase#code-for-last-row@ = \color{green}, -% ~emphase#code-for-last-col@ = \color{magenta}} -% $\begin{pNiceArray}{cc|cc}[first-row,last-row=5,first-col,last-col,nullify-dots] -% & C_1 & \Cdots & & C_4 & \\ -% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\ -% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\ -% \hline -% & a_{31} & a_{32} & a_{33} & a_{34} & \\ -% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\ -% & C_1 & \Cdots & & C_4 & -% \end{pNiceArray}$ -% \end{Verbatim} -% -% \begin{scope} -% \NiceMatrixOptions{code-for-first-row = \color{red}, -% code-for-first-col = \color{blue}, -% code-for-last-row = \color{green}, -% code-for-last-col = \color{magenta}} -% \begin{displaymath} -% \begin{pNiceArray}{cc|cc}[first-row,last-row=5,first-col,last-col,nullify-dots] -% & C_1 & \multicolumn1c{\Cdots} & & C_4 & \\ -% L_1 & a_{11} & a_{12} & a_{13} & a_{14} & L_1 \\ -% \Vdots & a_{21} & a_{22} & a_{23} & a_{24} & \Vdots \\ -% \hline -% & a_{31} & a_{32} & a_{33} & a_{34} & \\ -% L_4 & a_{41} & a_{42} & a_{43} & a_{44} & L_4 \\ -% & C_1 & \multicolumn1c{\Cdots} & & C_4 & -% \end{pNiceArray} -% \end{displaymath} -% \end{scope} -% -% -% \emph{Remarks} -% \begin{itemize}[beginpenalty=10000] -% \item As shown in the previous example, the horizontal and vertical rules -% don't extend in the exterior rows and columns. This remark also applies to the -% customized rules created by the key |custom-line| -% (cf.~p.~\pageref{custom-line}). -% -% \item A specification of color present in |code-for-first-row| also applies to -% a dotted line drawn in that exterior ``first row'' (excepted if a value has -% been given to |xdots/color|). Idem for the other exterior rows and columns. -% -% \item Logically, the potential option |columns-width| (described -% p.~\pageref{width}) doesn't apply to the ``first column'' and ``last column''. -% -% \item For technical reasons, it's not possible to use the option of the -% command |\\| after the ``first row'' or before the ``last row''. The placement -% of the delimiters would be wrong. If you are looking for a workaround, -% consider the command |\SubMatrix| in the |\CodeAfter| described -% p.~\pageref{sub-matrix}. -% \end{itemize} -% -% -% -% -% -% \section{The continuous dotted lines} -% -% \label{Cdots} -% Inside the environments of the package \pkg{nicematrix}, new commands are -% defined: |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, and |\Iddots|. These commands -% are intended to be used in place of |\dots|, |\cdots|, |\vdots|, |\ddots| and -% |\iddots|.\footnote{The command |\iddots|, defined in \pkg{nicematrix}, is a -% variant of |\ddots| with dots going forward. If |mathdots| is loaded, the -% version of |mathdots| is used. It corresponds to the command |\adots| of -% \pkg{unicode-math}.} -% \newcounter{fniddots} -% \setcounter{fniddots}{\thefootnote} -% -% \smallskip -% Each of them must be used alone in the cell of the array and it draws a dotted -% line between the first non-empty cells\footnote{The precise definition of a -% ``non-empty cell'' is given below (cf. p.~\pageref{empty-cells}).} on both -% sides of the current cell. Of course, for |\Ldots| and |\Cdots|, it's an -% horizontal line; for |\Vdots|, it's a vertical line and for |\Ddots| and -% |\Iddots| diagonal ones. It's possible to change the color of these lines -% with the option |color|.\footnote{It's also possible to change the color of -% all these dotted lines with the option |xdots/color| (\textsl{xdots} to -% remind that it works for |\Cdots|, |\Ldots|, |\Vdots|, etc.): cf. p. -% \pageref{customisation}.}\par\nobreak -% -% \bigskip -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% \begin{bNiceMatrix} -% a_1 & \Cdots & & & a_1 \\ -% \Vdots & a_2 & \Cdots & & a_2 \\ -% & \Vdots & \Ddots[color=red] \\ -% \\ -% a_1 & a_2 & & & a_n -% \end{bNiceMatrix} -% \end{BVerbatim} -% $\begin{bNiceMatrix} -% a_1 & \Cdots & & & a_1 \\ -% \Vdots & a_2 & \Cdots & & a_2 \\ -% & \Vdots & \Ddots[color=red] \\ -% \\ -% a_1 & a_2 & & & a_n -% \end{bNiceMatrix}$ -% -% \interitem -% In order to represent the null matrix, one can use the following -% codage:\par\nobreak -% -% \bigskip -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% \begin{bNiceMatrix} -% 0 & \Cdots & 0 \\ -% \Vdots & & \Vdots \\ -% 0 & \Cdots & 0 -% \end{bNiceMatrix} -% \end{BVerbatim} -% $\begin{bNiceMatrix} -% 0 & \Cdots & 0 \\ -% \Vdots & & \Vdots \\ -% 0 & \Cdots & 0 -% \end{bNiceMatrix}$ -% -% \bigskip -% However, one may want a larger matrix. Usually, in such a case, the users of -% LaTeX add a new row and a new column. It's possible to use the same method -% with \pkg{nicematrix}:\par\nobreak -% -% \bigskip -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% \begin{bNiceMatrix} -% 0 & \Cdots & \Cdots & 0 \\ -% \Vdots & & & \Vdots \\ -% \Vdots & & & \Vdots \\ -% 0 & \Cdots & \Cdots & 0 -% \end{bNiceMatrix} -% \end{BVerbatim} -% $\begin{bNiceMatrix} -% 0 & \Cdots & \Cdots & 0 \\ -% \Vdots & & & \Vdots \\ -% \Vdots & & & \Vdots \\ -% 0 & \Cdots & \Cdots & 0 -% \end{bNiceMatrix}$ -% -% \bigskip -% In the first column of this example, there are two instructions |\Vdots| but, -% of course, only one dotted line is drawn. -% -% \bigskip -% In fact, in this example, it would be possible to draw the same matrix more -% easily with the following code:\par\nobreak -% -% \bigskip -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% \begin{bNiceMatrix} -% 0 & \Cdots & & 0 \\ -% \Vdots & & & \\ -% & & & \Vdots \\ -% 0 & & \Cdots & 0 -% \end{bNiceMatrix} -% \end{BVerbatim} -% $\begin{bNiceMatrix} -% 0 & \Cdots & & 0 \\ -% \Vdots & & & \\ -% & & & \Vdots \\ -% 0 & & \Cdots & 0 -% \end{bNiceMatrix}$ -% -% \bigskip -% There are also other means to change the size of the matrix. Someone might -% want to use the optional argument of the command~|\\| for the vertical -% dimension and a command~|\hspace*| in a cell for the horizontal -% dimension.\footnote{In \pkg{nicematrix}, one should use |\hspace*| and not -% |\hspace| for such an usage because \pkg{nicematrix} loads \pkg{array}. One -% may also remark that it's possible to fix the width of a column by using the -% environment |{NiceArray}| (or one of its variants) with a column of type~|w| -% or~|W|: see p.~\pageref{width}} -% -% However, a command~|\hspace*| might interfer with the construction of the -% dotted lines. That's why the package \pkg{nicematrix} provides a -% command~|\Hspace| which is a variant of |\hspace| transparent for the dotted -% lines of \pkg{nicematrix}.\par\nobreak -% -% \bigskip -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% \begin{bNiceMatrix} -% 0 & \Cdots & ~emphase#\Hspace*{1cm}@ & 0 \\ -% \Vdots & & & \Vdots \\~emphase#[1cm]@ -% 0 & \Cdots & & 0 -% \end{bNiceMatrix} -% \end{BVerbatim} -% $\begin{bNiceMatrix} -% 0 & \Cdots & \Hspace*{1cm} & 0 \\ -% \Vdots & & & \Vdots \\[1cm] -% 0 & \Cdots & & 0 -% \end{bNiceMatrix}$ -% -% \subsection{The option nullify-dots} -% -% -% Consider the following matrix composed classicaly with the environment -% |{pmatrix}| of \pkg{amsmath}.\par\nobreak -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% $A = \begin{pmatrix} -% h & i & j & k & l & m \\ -% x & & & & & x -% \end{pmatrix}$ -% \end{BVerbatim} -% $A = \begin{pmatrix} -% h & i & j & k & l & m \\ -% x & & & & & x -% \end{pmatrix}$ -% -% -% \bigskip -% If we add |\ldots| instructions in the second row, the geometry of the -% matrix is modified.\par\nobreak -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% $B = \begin{pmatrix} -% h & i & j & k & l & m \\ -% x & \ldots & \ldots & \ldots & \ldots & x -% \end{pmatrix}$ -% \end{BVerbatim} -% $B = \begin{pmatrix} -% h & i & j & k & l & m \\ -% x & \ldots & \ldots & \ldots & \ldots & x -% \end{pmatrix}$ -% -% \bigskip -% By default, with \pkg{nicematrix}, if we replace |{pmatrix}| by -% |{pNiceMatrix}| and |\ldots| by |\Ldots|, the geometry of the matrix is not -% changed.\par\nobreak -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% $C = \begin{pNiceMatrix} -% h & i & j & k & l & m \\ -% x & \Ldots & \Ldots & \Ldots & \Ldots & x -% \end{pNiceMatrix}$ -% \end{BVerbatim} -% $C = \begin{pNiceMatrix} -% h & i & j & k & l & m \\ -% x & \Ldots & \Ldots & \Ldots & \Ldots & x -% \end{pNiceMatrix}$ -% -% \bigskip -% However, one may prefer the geometry of the first matrix $A$ and would like to -% have such a geometry with a dotted line in the second row. It's possible by -% using the option |nullify-dots| (and only one instruction |\Ldots| is -% necessary).\par\nobreak -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% $D = \begin{pNiceMatrix}[~emphase#nullify-dots@] -% h & i & j & k & l & m \\ -% x & \Ldots & & & & x -% \end{pNiceMatrix}$ -% \end{BVerbatim} -% $D = \begin{pNiceMatrix}[nullify-dots] -% h & i & j & k & l & m \\ -% x & \Ldots & & & & x -% \end{pNiceMatrix}$ -% -% \medskip -% The option |nullify-dots| smashes the instructions |\Ldots| (and the variants) -% horizontally but also vertically. -% -% -% -% \subsection{The commands \textbackslash Hdotsfor and \textbackslash Vdotsfor} -% -% Some people commonly use the command |\hdotsfor| of \pkg{amsmath} in order to -% draw horizontal dotted lines in a matrix. In the environments of -% \pkg{nicematrix}, one should use instead |\Hdotsfor| in order to draw dotted -% lines similar to the other dotted lines drawn by the package \pkg{nicematrix}. -% -% As with the other commands of \pkg{nicematrix} (like |\Cdots|, |\Ldots|, -% |\Vdots|, etc.), the dotted line drawn with |\Hdotsfor| extends until the -% contents of the cells on both sides. -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=7cm] -% $\begin{pNiceMatrix} -% 1 & 2 & 3 & 4 & 5 \\ -% 1 & ~emphase#\Hdotsfor{3}@ & 5 \\ -% 1 & 2 & 3 & 4 & 5 \\ -% 1 & 2 & 3 & 4 & 5 -% \end{pNiceMatrix}$ -% \end{BVerbatim} -% $\begin{pNiceMatrix} -% 1 & 2 & 3 & 4 & 5 \\ -% 1 & \Hdotsfor{3} & 5 \\ -% 1 & 2 & 3 & 4 & 5 \\ -% 1 & 2 & 3 & 4 & 5 -% \end{pNiceMatrix}$ -% -% \bigskip -% However, if these cells are empty, the dotted line extends only in the cells -% specified by the argument of |\Hdotsfor| (by design). -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=7cm] -% $\begin{pNiceMatrix} -% 1 & 2 & 3 & 4 & 5 \\ -% & ~emphase#\Hdotsfor{3}@ \\ -% 1 & 2 & 3 & 4 & 5 \\ -% 1 & 2 & 3 & 4 & 5 -% \end{pNiceMatrix}$ -% \end{BVerbatim} -% $\begin{pNiceMatrix} -% 1 & 2 & 3 & 4 & 5 \\ -% & \Hdotsfor{3} \\ -% 1 & 2 & 3 & 4 & 5 \\ -% 1 & 2 & 3 & 4 & 5 -% \end{pNiceMatrix}$ -% -% \medskip -% Remark: Unlike the command |\hdotsfor| of \pkg{amsmath}, the command -% |\Hdotsfor| may be used even when the package \pkg{colortbl}\footnote{We -% recall that when \pkg{xcolor} is loaded with the option |table|, the -% package \pkg{colortbl} is loaded.} is loaded (but you might have problem if -% you use |\rowcolor| on the same row as |\Hdotsfor|). -% -% \bigskip -% The package \pkg{nicematrix} also provides a command |\Vdotsfor| similar to -% |\Hdotsfor| but for the vertical dotted lines. -% \bigskip -% The following example uses both |\Hdotsfor| and |\Vdotsfor|: -% -% \begin{Verbatim}[formatcom=\small\color{gray}] -% \begin{bNiceMatrix} -% C[a_1,a_1] & \Cdots & C[a_1,a_n] -% & \hspace*{20mm} & C[a_1,a_1^{(p)}] & \Cdots & C[a_1,a_n^{(p)}] \\ -% \Vdots & \Ddots & \Vdots -% & ~emphase#\Hdotsfor{1}@ & \Vdots & \Ddots & \Vdots \\ -% C[a_n,a_1] & \Cdots & C[a_n,a_n] -% & & C[a_n,a_1^{(p)}] & \Cdots & C[a_n,a_n^{(p)}] \\ -% \rule{0pt}{15mm}\NotEmpty & ~emphase#\Vdotsfor{1}@ & & \Ddots & & ~emphase#\Vdotsfor{1}@ \\ -% C[a_1^{(p)},a_1] & \Cdots & C[a_1^{(p)},a_n] -% & & C[a_1^{(p)},a_1^{(p)}] & \Cdots & C[a_1^{(p)},a_n^{(p)}] \\ -% \Vdots & \Ddots & \Vdots -% & ~emphase#\Hdotsfor{1}@ & \Vdots & \Ddots & \Vdots \\ -% C[a_n^{(p)},a_1] & \Cdots & C[a_n^{(p)},a_n] -% & & C[a_n^{(p)},a_1^{(p)}] & \Cdots & C[a_n^{(p)},a_n^{(p)}] -% \end{bNiceMatrix} -% \end{Verbatim} -% -% -% \[\begin{bNiceMatrix} -% C[a_1,a_1] & \Cdots & C[a_1,a_n] & \hspace*{20mm} & C[a_1,a_1^{(p)}] & \Cdots & C[a_1,a_n^{(p)}] \\ -% \Vdots & \Ddots & \Vdots & \Hdotsfor{1} & \Vdots & \Ddots & \Vdots \\ -% C[a_n,a_1] & \Cdots & C[a_n,a_n] & & C[a_n,a_1^{(p)}] & \Cdots & C[a_n,a_n^{(p)}] \\ -% \rule{0pt}{15mm}\NotEmpty & \Vdotsfor{1} & & \Ddots & & \Vdotsfor{1} \\ -% C[a_1^{(p)},a_1] & \Cdots & C[a_1^{(p)},a_n] & & C[a_1^{(p)},a_1^{(p)}] & \Cdots & C[a_1^{(p)},a_n^{(p)}] \\ -% \Vdots & \Ddots & \Vdots & \Hdotsfor{1} & \Vdots & \Ddots & \Vdots \\ -% C[a_n^{(p)},a_1] & \Cdots & C[a_n^{(p)},a_n] & & C[a_n^{(p)},a_1^{(p)}] & \Cdots & C[a_n^{(p)},a_n^{(p)}] -% \end{bNiceMatrix}\] -% -% -% -% -% \subsection{How to generate the continuous dotted lines transparently} -% -% Imagine you have a document with a great number of mathematical matrices with -% ellipsis. You may wish to use the dotted lines of \pkg{nicematrix} without -% having to modify the code of each matrix. It's possible with the keys. -% |renew-dots| and |renew-matrix|.\footnote{The options |renew-dots|, -% |renew-matrix| can be fixed with the command -% |\NiceMatrixOptions| like the other options. However, they can also be fixed -% as options of the command |\usepackage|.} -% -% \smallskip -% -% \begin{itemize} -% \item The option |renew-dots|\par\nobreak -% -% With this option, the commands |\ldots|, |\cdots|, |\vdots|, |\ddots|, -% |\iddots|\footnotemark[\thefniddots] and |\hdotsfor| are redefined within the -% environments provided by \pkg{nicematrix} and behave like |\Ldots|, |\Cdots|, -% |\Vdots|, |\Ddots|, |\Iddots| and |\Hdotsfor|; the command |\dots| -% (``automatic dots'' of |amsmath|) is also redefined to behave like |\Ldots|. -% -% \item The option |renew-matrix|\par\nobreak -% -% With this option, the environment |{matrix}| is redefined and behave like -% |{NiceMatrix}|, and so on for the five variants. -% \end{itemize} -% -% \bigskip -% Therefore, with the keys |renew-dots| and |renew-matrix|, a classical code -% gives directly the ouput of \pkg{nicematrix}.\par\nobreak -% -% \bigskip -% \begin{scope} -% \NiceMatrixOptions{renew-dots,renew-matrix} -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% ~emphase#\NiceMatrixOptions{renew-dots,renew-matrix}@ -% \begin{pmatrix} -% 1 & \cdots & \cdots & 1 \\ -% 0 & \ddots & & \vdots \\ -% \vdots & \ddots & \ddots & \vdots \\ -% 0 & \cdots & 0 & 1 -% \end{pmatrix} -% \end{BVerbatim} -% $\begin{pmatrix} -% 1 & \cdots & \cdots & 1 \\ -% 0 & \ddots & & \vdots \\ -% \vdots & \ddots & \ddots & \vdots \\ -% 0 & \cdots & 0 & 1 -% \end{pmatrix}$ -% \end{scope} -% -% \subsection{The labels of the dotted lines} -% -% The commands |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, |\Iddots| and |\Hdotsfor| -% (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|. -% -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% $\begin{bNiceMatrix} -% 1 & \hspace*{1cm} & 0 \\[8mm] -% & ~emphase#\Ddots^{n \text{ times}}@ & \\ -% 0 & & 1 -% \end{bNiceMatrix}$ -% \end{BVerbatim} -% $\begin{bNiceMatrix} -% 1 & \hspace*{1cm} & 0 \\[8mm] -% & \Ddots^{n \text{ times}} & \\ -% 0 & & 1 -% \end{bNiceMatrix}$ -% -% \subsection{Customisation of the dotted lines} -% -% \label{customisation} -% The dotted lines drawn by |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, |\Iddots|, -% |\Hdotsfor| and |\Vdotsfor| (and by the command |\line| in the |\CodeAfter| -% which is described p.~\pageref{line-in-code-after}) may be customized by the following -% options (specified between square brackets after the command): -% \begin{itemize} -% \item |color|; -% \item |radius|; -% \item |shorten-start|, |shorten-end| and |shorten|; -% \item |inter|; -% \item |line-style|. -% \end{itemize} -% -% These options may also be fixed with |\NiceMatrixOptions|, as options of -% |\CodeAfter| or at the level of a given environment but, in those cases, they -% must be prefixed by |xdots| (\textsl{xdots} to remind that it works for -% |\Cdots|, |\Ldots|, |\Vdots|, etc.), and, thus have for names: -% \begin{itemize} -% \item |xdots/color|; -% \item |xdots/radius|; -% \item |xdots/shorten-start|, |xdots/shorten-end| and |xdots/shorten|; -% \item |xdots/inter|; -% \item |xdots/line-style|. -% \end{itemize} -% -% For the clarity of the explanations, we will use those names. -% -% \bigskip -% \textbf{The option xdots/color}\par\nobreak -% -% \smallskip -% The option |xdots/color| fixes the color or the dotted line. However, one should -% remark that the dotted lines drawn in the exterior rows and columns have a -% special treatment: cf. p.~\pageref{exterior}. -% -% \bigskip -% \textbf{The option xdots/radius}\par\nobreak -% -% The option |radius| fixes the radius of the dots. The initial value is 0.53~pt. -% -% \bigskip -% \textbf{The option xdots/shorten}\par\nobreak -% -% \smallskip -% The keys |xdots/shorten-start| and |xdots/shorten-end| fix the margin at the -% extremities of the line. The key |xdots/shorten| fixes both parameters. -% The initial value is 0.3~em (it is recommanded to use a unit of length -% dependent of the current font). -% -% \bigskip -% \textbf{The option xdots/inter}\par\nobreak -% -% \smallskip -% The option |xdots/inter| fixes the length between the dots. The initial value -% is 0.45~em (it is recommanded to use a unit of length dependent of the current -% font). -% -% \bigskip -% \textbf{The option xdots/line-style}\par\nobreak -% -% \smallskip -% It should be pointed that, by default, the lines drawn by Tikz with the -% parameter |dotted| are composed of square dots (and not rounded -% ones).\footnote{The first reason of this behaviour is that the \textsc{pdf} -% format includes a description for dashed lines. The lines specified with this -% descriptor are displayed very efficiently by the \textsc{pdf} readers. It's -% easy, starting from these dashed lines, -% to create a line composed by square dots whereas a line of rounded dots needs -% a specification of each dot in the \textsc{pdf} file. Nevertheless, you can -% have a look at the following page to see how to have dotted rules with rounded -% dots in Tikz:\newline \small -% \url{https://tex.stackexchange.com/questions/52848/tikz-line-with-large-dots}} -% -% \begin{BVerbatim}[baseline=c,boxwidth=9cm] -% \tikz \draw [dotted] (0,0) -- (5,0) ; -% \end{BVerbatim} -% \tikz \draw [dotted] (0,0) -- (5,0) ; -% -% \medskip -% In order to provide lines with rounded dots in the style of those provided by -% |\ldots| (at least with the \emph{Computer Modern} fonts), the package -% \pkg{nicematrix} embeds its own system to draw a dotted line (and this system -% uses \textsc{pgf} and not Tikz). This style is called |standard| and that's -% the initial value of the parameter |xdots/line-style|. -% -% However (when Tikz is loaded) it's possible to use for |xdots/line-style| any style -% provided by Tikz, that is to say any sequence of options provided by Tikz for -% the Tizk pathes (with the exception of ``|color|'', ``|shorten >|'' and -% ``|shorten <|''). -% -% \medskip -% Here is for example a tridiagonal matrix with the style |loosely dotted|:\par\nobreak -% -% \medskip -% \begin{BVerbatim}[baseline=c] -% $\begin{pNiceMatrix}[nullify-dots,~emphase#xdots/line-style=loosely dotted@] -% a & b & 0 & & \Cdots & 0 \\ -% b & a & b & \Ddots & & \Vdots \\ -% 0 & b & a & \Ddots & & \\ -% & \Ddots & \Ddots & \Ddots & & 0 \\ -% \Vdots & & & & & b \\ -% 0 & \Cdots & & 0 & b & a -% \end{pNiceMatrix}$ -% \end{BVerbatim} -% -% -% \[\begin{pNiceMatrix}[nullify-dots,xdots/line-style=loosely dotted] -% a & b & 0 & & \Cdots & 0 \\ -% b & a & b & \Ddots & & \Vdots \\ -% 0 & b & a & \Ddots & & \\ -% & \Ddots & \Ddots & \Ddots & & 0 \\ -% \Vdots & & & & & b \\ -% 0 & \Cdots & & 0 & b & a -% \end{pNiceMatrix}\] -% -% -% \subsection{The dotted lines and the rules} -% -% \label{dotted-and-rules} -% -% The dotted lines determine virtual blocks which have the same behaviour -% regarding the rules (the rules specified by the specifier \verb+|+ in the -% preamble, by the command |\Hline|, by the keys |hlines|, |vlines|, -% |hvlines| and |hvlines-except-borders| and by the tools created by -% |custom-line| are not drawn within the -% blocks).\footnote{On the other side, the command |\line| in the -% |\CodeAfter| (cf.~p.~\pageref{line-in-code-after}) does \emph{not} create -% block.} -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm] -% $\begin{bNiceMatrix}[margin,~emphase#hvlines@] -% \Block{3-3}<\LARGE>{A} & & & 0 \\ -% & \hspace*{1cm} & & \Vdots \\ -% & & & 0 \\ -% 0 & \Cdots& 0 & 0 -% \end{bNiceMatrix}$ -% \end{BVerbatim} -% $\begin{bNiceMatrix}[margin,hvlines] -% \Block{3-3}<\LARGE>{A} & & & 0 \\ -% & \hspace*{1cm} & & \Vdots \\ -% & & & 0 \\ -% 0 & \Cdots& 0 & 0 -% \end{bNiceMatrix}$ -% -% -% \section{Delimiters in the preamble of the environnment} -% -% \label{delimiters-in-preamble} -% -% \colorbox{yellow!50}{\textbf{New 6.16}\enskip} -% In the environments with preamble (|{NiceArray}|, |{pNiceArray}|, etc.), it's -% possible to put vertical delimiters directly in the preamble of the -% environnment.\footnote{This syntax is inspired by the extension \pkg{blkarray}.} -% -% \smallskip -% The opening delimiters should be prefixed by the keyword |\left| and the -% closing delimiters by the keyword |\right|. It's not mandatory to use -% |\left| and |\right| pair-wise. -% -% \smallskip -% All the vertical extensible delimiters of LaTeX are allowed. -% -% \medskip -% Here is a example which uses the delimiters |\lgroup| and |\rgroup|. -% -% \smallskip -% \begin{BVerbatim} -% $\begin{NiceArray}{~emphase#\left\lgroup@ ccc~emphase#\right\rgroup@ l} -% 1 & 2 & 3 & -% 4 & 1 & 6 & -% 7 & 8 & 9 & \scriptstyle L_3 \gets L_3 + L_1 + L_2 -% \end{NiceArray}$ -% \end{BVerbatim} -% -% \[\begin{NiceArray}{\left\lgroup ccc\right\rgroup l} -% 1 & 2 & 3 & \\ -% 4 & 1 & 6 & \\ -% 7 & 8 & 9 & \scriptstyle L_3 \gets L_3 + L_1 + L_2 -% \end{NiceArray}\] -% -% \medskip -% For this example, it would also have been possible to use the environnment -% |{NiceArrayWithDelims}| (cf. the section \ref{NiceArrayWithDelims}, -% p.~\pageref{NiceArrayWithDelims}) and the key |last-col| (cf. p.~\pageref{exterior}). -% -% \bigskip -% There is a particular case: for the delimiters |(|, |[| and |\{| (and the -% corresponding closing delimiters), the prefixes |\left| et |\right| are -% optional.\footnote{For the delimiters |[| and |]|, the prefixes remain mandatory -% when there is a conflict of notation with the square brackets for the options -% of some descriptors of columns.} -% -% -% -% \bigskip -% When there are two successive delimiters (necessarily a closing one following by -% an opening one for another submatrix), a space equal to |\enskip| is -% automatically inserted. -% -% \medskip -% \begin{BVerbatim} -% $\begin{pNiceArray}{~emphase#(c)(c)(c)@} -% a_{11} & a_{12} & a_{13} \\ -% a_{21} & \displaystyle \int_0^1\dfrac{1}{x^2+1}\,dx & a_{23} \\ -% a_{31} & a_{32} & a_{33} -% \end{pNiceArray}$ -% \end{BVerbatim} -% -% \[\begin{pNiceArray}{(c)(c)(c)} -% a_{11} & a_{12} & a_{13} \\ -% a_{21} & \displaystyle \int_0^1\dfrac{1}{x^2+1}\,dx & a_{23} \\ -% a_{31} & a_{32} & a_{33} -% \end{pNiceArray}\] -% -% -% \bigskip -% For more complex constructions, in particular with delimiters spanning only a -% \emph{subset} of the rows of the array, one should consider the command -% |\SubMatrix| available in the |\CodeAfter|. See the section~\ref{sub-matrix}, -% p.~\pageref{sub-matrix}. -% -% \section{The \textbackslash CodeAfter} -% -% \label{code-after} -% The option |code-after| may be used to give some code that will be executed -% \emph{after} the construction of the matrix.\footnote{There is also a key -% |code-before| described p.~\pageref{code-before}.} -% -% \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|. Although |\CodeAfter| is a -% keyword, it takes in an optional argument (between square -% brackets).\footnote{Here are the keys accepted in that argument: -% |delimiters/color|, |rules| and its sub-keys and |sub-matrix| (linked to the -% command |\SubMatrix|) and its sub-keys.} -% -% -% \medskip -% The experienced users may, for instance, use the PGF/Tikz nodes created by -% \pkg{nicematrix} in the |\CodeAfter|. These nodes are described further -% beginning on p.~\pageref{PGF-nodes}. -% -% \medskip -% Moreover, several special commands are available in the |\CodeAfter|: |line|, -% |\SubMatrix|, |\OverBrace| and |\UnderBrace|. We will now present these commands. -% -% \subsection{The command \textbackslash line in the \textbackslash CodeAfter} -% -% \label{line-in-code-after} -% The command |\line| draws directly dotted lines between cells or blocks. It takes in two -% arguments for the cells or blocks to link. Both argument may be: -% \begin{itemize} -% \item a specification of cell of the form $i$-$j$ where is the -% number of the row and $j$ is the number of the column; -% \item the name of a block (created by the command |\Block| with the key |name| -% of that command). -% \end{itemize} -% The options available for the customisation of the dotted lines created by -% |\Cdots|, |\Vdots|, etc. are also available for this command (cf. -% p.~\pageref{customisation}). -% -% \bigskip -% This command may be used, for example, to draw a dotted line between two -% adjacent cells. -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=11cm] -% \NiceMatrixOptions{xdots/shorten = 0.6 em} -% \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} -% 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} -% -% \bigskip -% It can also be used to draw a diagonal line not parallel to the other diagonal -% lines (by default, the dotted lines drawn by |\Ddots| are ``parallelized'': -% cf.~p.~\pageref{parallelization}). -% -% \medskip -% \begin{BVerbatim} -% \begin{bNiceMatrix} -% 1 & \Cdots & & 1 & 2 & \Cdots & 2 \\ -% 0 & \Ddots & & \Vdots & \Vdots & \hspace*{2.5cm} & \Vdots \\ -% \Vdots & \Ddots & & & & & \\ -% 0 & \Cdots & 0 & 1 & 2 & \Cdots & 2 -% ~emphase#\CodeAfter \line[shorten=6pt]{1-5}{4-7}@ -% \end{bNiceMatrix} -% \end{BVerbatim} -% \[\begin{bNiceMatrix} -% 1 & \Cdots & & 1 & 2 & \Cdots & 2 \\ -% 0 & \Ddots & & \Vdots & \Vdots & \hspace*{2.5cm} & \Vdots \\ -% \Vdots & \Ddots & & & & & \\ -% 0 & \Cdots & 0 & 1 & 2 & \Cdots & 2 -% \CodeAfter \line[shorten=6pt]{1-5}{4-7} -% \end{bNiceMatrix}\] -% -% -% -% -% \subsection{The command \textbackslash SubMatrix in the \textbackslash -% CodeAfter (and the \textbackslash CodeBefore)} -% -% \label{sub-matrix} -% -% The command |\SubMatrix| provides a way to put delimiters on a portion -% of the array considered as a submatrix. The command |\SubMatrix| takes in five -% arguments: -% \begin{itemize} -% \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 \textsl{key=value} -% pairs.\footnote{There is no optional argument between square brackets in first -% position because a square bracket just after |\SubMatrix| must be interpreted -% as the first (mandatory) argument of the command |\SubMatrix|: that bracket is -% the left delimiter of the sub-matrix to construct (eg.: -% |\SubMatrix[{2-2}{4-7}]|).} -% \end{itemize} -% -% One should remark that the command |\SubMatrix| draws the delimiters \emph{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 -% \begin{scope} -% \hfuzz=15cm -% \fvset{commandchars=\~\#\+}% -% \begin{BVerbatim}[boxwidth=11cm,baseline=c] -% \[\begin{NiceArray}{ccc~emphase#@{\hspace{1.5em}}+c}[cell-space-limits=2pt,~emphase#margin+] -% 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}$ -% -% \medskip -% Eventually, in this example, it would probably have been easier to put the -% delimiters directly in the preamble of |{NiceArray}| (see -% section~\ref{delimiters-in-preamble}, p.~\pageref{delimiters-in-preamble}) -% with the following construction. -% -% \medskip -% \begin{scope} -% \hfuzz=15cm -% \begin{BVerbatim}[boxwidth=11cm,baseline=c] -% $\begin{NiceArray}{~emphase#(ccc)(c)@}[cell-space-limits=2pt] -% 1 & 1 & 1 & x \\ -% \dfrac{1}{4} & \dfrac{1}{2} & \dfrac{1}{4} & y \\ -% 1 & 2 & 3 & z -% \end{NiceArray}$ -% \end{BVerbatim} -% \end{scope} -% $\begin{NiceArray}{(ccc)(c)}[cell-space-limits=2pt] -% 1 & 1 & 1 & x \\ -% \dfrac{1}{4} & \dfrac{1}{2} & \dfrac{1}{4} & y \\ -% 1 & 2 & 3 & z -% \end{NiceArray}$ -% -% \bigskip -% In fact, the command |\SubMatrix| also takes in two optional arguments -% specified by the traditional symbols |^| and |_| for material in superscript -% and subscript. -% -% \medskip -% \begin{scope} -% \hfuzz=15cm -% \begin{BVerbatim}[boxwidth=11cm,baseline=c] -% $\begin{bNiceMatrix}[right-margin=1em] -% 1 & 1 & 1 \\ -% 1 & a & b \\ -% 1 & c & d -% \CodeAfter -% ~emphase#\SubMatrix[{2-2}{3-3}]^{T}@ -% \end{bNiceMatrix}$ -% \end{BVerbatim} -% $\begin{bNiceMatrix}[right-margin=1em] -% 1 & 1 & 1 \\ -% 1 & a & b \\ -% 1 & c & d -% \CodeAfter -% \SubMatrix[{2-2}{3-3}]^{T} -% \end{bNiceMatrix}$ -% \end{scope} -% -% -% \bigskip -% The options of the command |\SubMatrix| are as follows: -% \begin{itemize} -% \item \Definition{left-xshift} and \Definition{right-xshift} shift -% horizontally the delimiters (there exists also the key \Definition{xshift} -% which fixes both parameters); -% \item \Definition{extra-height} adds a quantity to the total height of the -% delimiters (height |\ht| + depth |\dp|); -% \item \Definition{delimiters/color} fixes the color of the delimiters (also -% available in |\NiceMatrixOptions|, in the environments with delimiters and as -% option of the keyword |\CodeAfter|); -% \item \Definition{slim} is a boolean key: when that key is in force, the horizontal -% position of the delimiters is computed by using only the contents of the cells -% of the submatrix whereas, in the general case, the position is computed by -% taking into account the cells of the whole columns implied in the submatrix -% (see example below). ; -% \item \Definition{vlines} contents a list of numbers of vertical rules that -% will be drawn in the sub-matrix (if this key is used without value, all the -% vertical rules of the sub-matrix are drawn); -% \item \Definition{hlines} is similar to |vlines| but for the horizontal rules; -% \item \Definition{hvlines}, which must be used without value, draws all the -% vertical and horizontal rules; -% \item \Definition{code} insert code, especially TikZ code, after the -% construcion of the submatrix. That key is detailed below. -% \end{itemize} -% One should remark that the keys add their rules after the construction of -% the main matrix: no space is added between the rows and the columns of the -% array for theses rules. -% -% \bigskip -% All these keys are also available in |\NiceMatrixOptions|, at the level of the -% environments of \pkg{nicematrix} or as option of the command |\CodeAfter| with -% the prefix |sub-matrix| which means that their names are therefore -% |sub-matrix/left-xshift|, |sub-matrix/right-xshift|, |sub-matrix/xshift|, etc. -% -% \bigskip -% \begin{scope} -% \hfuzz=12cm -% \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} -% \hfuzz=12cm -% \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 create PGF/Tikz nodes: cf -% p.~\pageref{node-sub-matrix}. -% -% -% \bigskip -% Despite its name, the command |\SubMatrix| may also be used within a -% |{NiceTabular}|. Here is an example (which uses |\bottomrule| and -% |\toprule| of \pkg{booktabs}). -% -% \medskip -% \begin{BVerbatim}[baseline=c] -% \begin{NiceTabular}{~@{}ll~@{}} -% \toprule -% Part A & the first part \\ -% \Block{2-1}{Part B} & a first sub-part \\ -% & a second sub-part \\ -% \bottomrule -% \CodeAfter -% ~emphase#\SubMatrix{\{}{2-2}{3-2}{.}@ -% \end{NiceTabular} -% \end{BVerbatim} -% \hspace{2cm} -% \begin{NiceTabular}{@{}ll@{}} -% \toprule -% Part A & the first part \\ -% \Block{2-1}{Part B} & a first sub-part \\ -% & a second sub-part \\ -% \bottomrule -% \CodeAfter -% \SubMatrix{\{}{2-2}{3-2}{.} -% \end{NiceTabular} -% -% \bigskip -% The command |\SubMatrix| is, in fact, also available in the |\CodeBefore|. By -% using |\SubMatrix| in the |\CodeBefore|, the delimiters drawn by those -% commands |\SubMatrix| are taken into account to limit the continuous dotted -% lines (drawn by |\Cdots|, |\Vdots|, etc.) which have an open extremity. -% -% For an example, see voir \ref{submatrix-in-codebefore} -% p.~\pageref{submatrix-in-codebefore}. -% -% -% -% \vspace{1cm} -% \colorbox{yellow!50}{\textbf{New 6.16}}\enskip The key |code| of the command -% |\SubMatrix| allows the insertion of code after the construction of the -% submatrix. It's meant to be used to insert TikZ instructions because, in the -% TikZ instructions inserted by that code, the nodes of the form |i-j| and -% \verb+i-|j+ are interpreted with |i| and |j| as numbers of row and columns -% \emph{relative to the submatrix}.\footnote{Be careful: the syntax -% \verb+j|-i+ is not allowed.} -% -% \medskip -% \begin{scope} -% \fvset{commandchars=\~\#\!}% -% \begin{Verbatim} -% $\begin{NiceArray}{ccc@{}w{c}{5mm}@{}ccc} -% & & && -1 & 1 & 2 \\ -% & & && 0 & 3 & 4 \\ -% & & && 0 & 0 & 5 \\ -% 1 & 2 & 3 && -1 & 7 & 25 \\ -% 0 & 4 & 5 && 0 & 12 & 41 \\ -% 0 & 0 & 6 && 0 & 0 & 30 -% \CodeAfter -% ~emphase#\NewDocumentCommand{\MyDraw}{}{\tikz \draw [blue] (2-|1) -| (3-|2) -| (4-|3) ;}! -% \SubMatrix({1-5}{3-7})[~emphase#code = \MyDraw!] -% \SubMatrix({4-1}{6-3})[~emphase#code = \MyDraw!] -% \SubMatrix({4-5}{6-7})[~emphase#code = \MyDraw!] -% \end{NiceArray}$ -% \end{Verbatim} -% \end{scope} -% -% -% \[\begin{NiceArray}{ccc@{}w{c}{5mm}@{}ccc} -% & & && -1 & 1 & 2 \\ -% & & && 0 & 3 & 4 \\ -% & & && 0 & 0 & 5 \\ -% 1 & 2 & 3 && -1 & 7 & 25 \\ -% 0 & 4 & 5 && 0 & 12 & 41 \\ -% 0 & 0 & 6 && 0 & 0 & 30 -% \CodeAfter -% \NewDocumentCommand{\MyDraw}{}{\tikz \draw [blue] (2-|1) -| (3-|2) -| (4-|3) ;} -% \SubMatrix({1-5}{3-7})[code = \MyDraw ] -% \SubMatrix({4-1}{6-3})[code = \MyDraw ] -% \SubMatrix({4-5}{6-7})[code = \MyDraw ] -% \end{NiceArray}\] -% -% \medskip -% As we see, the drawing done by our command |\MyDraw| is \emph{relative} to the -% submatrix to which it is applied. -% -% \subsection{The commands \textbackslash OverBrace and \textbackslash -% UnderBrace in the \textbackslash CodeAfter} -% -% The commands |\OverBrace| and |\UnderBrace| provide a way to put -% horizontal braces on a part of the array. These commands take in three -% arguments: -% \begin{itemize} -% \item the first 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 second argument is the lower-right corner with the same syntax; -% \item the third argument is the label of the brace that will be put by -% \pkg{nicematrix} (with \textsc{pgf}) above the brace (for the command -% |\OverBrace|) or under the brace (for |\UnderBrace|). -% \end{itemize} -% -% \bigskip -% \begin{BVerbatim}[baseline=c,boxwidth=9cm] -% \begin{pNiceMatrix} -% 1 & 2 & 3 & 4 & 5 & 6 \\ -% 11 & 12 & 13 & 14 & 15 & 16 \\ -% \CodeAfter -% ~emphase#\OverBrace{1-1}{2-3}{A}@ -% ~emphase#\OverBrace{1-4}{2-6}{B}@ -% \end{pNiceMatrix} -% \end{BVerbatim} -% $\begin{pNiceMatrix} -% 1 & 2 & 3 & 4 & 5 & 6 \\ -% 11 & 12 & 13 & 14 & 15 & 16 \\ -% \CodeAfter -% \OverBrace{1-1}{2-3}{A} -% \OverBrace{1-4}{2-6}{B} -% \end{pNiceMatrix}$ -% -% \bigskip -% In fact, the commands |\OverBrace| and |\UnderBrace| take in an optional -% argument (in first position and between square brackets) for a list of -% \textsl{key=value} pairs. The available keys are: -% \begin{itemize} -% \item |left-shorten| and |right-shorten| which do not take in value; when the -% key |left-shorten| is used, the abscissa of the left extremity of the brace is -% computed with the contents of the cells of the involved sub-array, otherwise, -% the position of the potential vertical rule is used (idem for -% |right-shorten|). -% -% \item |shorten|, which is the conjunction of the keys |left-shorten| and -% |right-shorten|; -% -% \item |yshift|, which shifts vertically the brace (and its label) ; -% -% \item |color|, which sets the color of the brace (and its label). -% \end{itemize} -% -% \bigskip -% \begin{BVerbatim}[baseline=c,boxwidth=9cm] -% \begin{pNiceMatrix} -% 1 & 2 & 3 & 4 & 5 & 6 \\ -% 11 & 12 & 13 & 14 & 15 & 16 \\ -% \CodeAfter -% \OverBrace~emphase#[shorten,yshift=3pt]@{1-1}{2-3}{A} -% \OverBrace~emphase#[shorten,yshift=3pt]@{1-4}{2-6}{B} -% \end{pNiceMatrix} -% \end{BVerbatim} -% $\begin{pNiceMatrix} -% 1 & 2 & 3 & 4 & 5 & 6 \\ -% 11 & 12 & 13 & 14 & 15 & 16 \\ -% \CodeAfter -% \OverBrace[shorten,yshift=3pt]{1-1}{2-3}{A} -% \OverBrace[shorten,yshift=3pt]{1-4}{2-6}{B} -% \end{pNiceMatrix}$ -% -% -% -% \section{Captions and notes in the tabulars} -% -% \label{s:notes} -% -% \subsection{Caption of a tabular} -% -% \smallskip -% The environment |{NiceTabular}| provides the keys |caption|, |short-caption| -% and |label| which may be used when the tabular is inserted in a floating -% environment (typically the environment |{table}|). -% -% \smallskip -% With the key |caption|, the caption, when it is long, is wrapped at the width -% of the tabular (excepted the potential exterior columns specified by -% |first-col| and |last-col|), without the use of the package -% \pkg{threeparttable} or the package \pkg{floatrow}. -% -% \smallskip -% By default, the caption is composed below the tabular. With the key -% |caption-above|, available in |\NiceMatrixOptions|, the caption will be -% composed above de tabular. -% -% \smallskip -% The key |short-caption| corresponds to the optional argument of the clasical -% command |\caption| and the key |label| corresponds, of course, to the command -% |\label|. -% -% \smallskip -% See table \ref{t:tabularnote}, p.~\pageref{t:tabularnote} for an example of -% use the keys |caption| and |label|. -% -% \subsection{The footnotes} -% -% \smallskip -% The package \pkg{nicematrix} allows, by using \pkg{footnote} or -% \pkg{footnotehyper}, the extraction of the notes inserted by |\footnote| in -% the environments of \pkg{nicematrix} and their composition in the footpage -% with the other notes of the document. -% -% \smallskip -% If \pkg{nicematrix} is loaded with the option |footnote| (with -% |\usepackage[footnote]{nicematrix}| or with |\PassOptionsToPackage|), the -% package \pkg{footnote} is loaded (if it is not yet loaded) and it is used to -% extract the footnotes. -% -% \smallskip -% If \pkg{nicematrix} is loaded with the option |footnotehyper|, the package -% \pkg{footnotehyper} is loaded (if it is not yet loaded) ant it is used to -% extract footnotes. -% -% \smallskip -% Caution: The packages \pkg{footnote} and \pkg{footnotehyper} are incompatible. -% The package \pkg{footnotehyper} is the successor of the package \pkg{footnote} -% and should be used preferently. The package \pkg{footnote} has some drawbacks, -% in particular: it must be loaded after the package \pkg{xcolor} and it is not -% perfectly compatible with \pkg{hyperref}. -% -% -% \subsection{The notes of tabular} -% -% The package \pkg{nicematrix} also provides a command |\tabularnote| which -% gives the ability to specify notes that will be composed at the end of the -% array with a width of line equal to the width of the array (excepted the -% potential exterior columns specified by |first-col| and |last-col|). With no -% surprise, that command is available only in the environments -% |{NiceTabular}|, |{NiceTabular*}| and |{NiceTabularX}|. -% -% In fact, this command is available only if the extension \pkg{enumitem} has -% been loaded (before or after \pkg{nicematrix}). Indeed, the notes are composed -% at the end of the array with a type of list provided by the package -% \pkg{enumitem}. -% -% \begin{scope} -% \fvset{commandchars=\~\#\!} -% \begin{Verbatim} -% \begin{NiceTabular}{@{}llr@{}} -% \toprule \RowStyle{\bfseries} -% Last name & First name & Birth day \\ -% \midrule -% Achard\tabularnote{~emphase#Achard is an old family of the Poitou.!} -% & Jacques & 5 juin 1962 \\ -% Lefebvre\tabularnote{~emphase#The name Lefebvre is an alteration of the name Lefebure.!} -% & Mathilde & 23 mai 1988 \\ -% Vanesse & Stephany & 30 octobre 1994 \\ -% Dupont & Chantal & 15 janvier 1998 \\ -% \bottomrule -% \end{NiceTabular} -% \end{Verbatim} -% \end{scope} -% -% \begin{center} -% \begin{NiceTabular}{@{}llr@{}} -% \toprule \RowStyle{\bfseries} -% Last name & First name & Birth day \\ -% \midrule -% Achard\tabularnote{Achard is an old family of the Poitou.} -% & Jacques & June 5, 2005 \\ -% Lefebvre\tabularnote{The name Lefebvre is an alteration of the name Lefebure.} -% & Mathilde & January 23, 1975 \\ -% Vanesse & Stephany & October 30, 1994 \\ -% Dupont & Chantal & January 15, 1998 \\ -% \bottomrule -% \end{NiceTabular} -% \end{center} -% -% -% \bigskip -% \begin{itemize} -% \item If you have several successive commands |\tabularnote{...}| \emph{with no -% space at all between them}, the labels of the corresponding notes are composed -% together, separated by commas (this is similar to the option |multiple| of -% \pkg{footmisc} for the footnotes). -% -% \item If a command |\tabularnote{...}| is exactly at the end of a cell (with -% no space at all after), the label of the note is composed in an overlapping -% position (towards the right). This structure may provide a better alignment of -% the cells of a given column. -% -% \item If the key |notes/para| is used, the notes are composed at the end of -% the array in a single paragraph (as with the key |para| of \pkg{threeparttable}). -% -% \item There is a key |tabularnote| which provides a way to insert some text in -% the zone of the notes before the numbered tabular notes. -% -% An alternative syntaxe is available with the environment |{TabularNote}|. That -% environment should be used at the end of the environment |{NiceTabular}| (but -% \emph{before} a potential instruction |\CodeAfter|). -% -% \item If the package \pkg{booktabs} has been loaded (before or after -% \pkg{nicematrix}), the key |notes/bottomrule| draws a |\bottomrule| of -% \pkg{booktabs} \emph{after} the notes. -% -% \item The command |\tabularnote| may be used \emph{before} -% the environment of \pkg{nicematrix}. Thus, it's possible to use it on the -% title inserted by |\caption| in an environment |{table}| of LaTeX (or in a -% command |\captionof| of the package \pkg{caption}). It's also possible, as -% expected, to use the command |\tabularnote| in the caption provided by the -% \emph{key} |caption| of the environment |{NiceTabaular}|. -% -% If several commands |\tabularnote| are used in a tabular with the same -% argument, only one note is inserted at the end of the tabular (but all the -% labels are composed, of course). It's possible to control that feature with -% the key |notes/detect-duplicates|.\footnote{For technical reasons, the final -% user is not allowed to put several commands |\tabularnote| with exactly the -% same argument in the caption of the tabular.} -% -% \item It's possible to create a reference to a tabular note created by |\tabularnote| -% (with the usual command |\label| used after the |\tabularnote|). -% \end{itemize} -% % -% For an illustration of some of those remarks, see table -% \ref{t:tabularnote}, p.~\pageref{t:tabularnote}. This table has been composed -% with the following code (the package \pkg{caption} has been loaded in this document). -% -% \begin{center} -% \fvset{commandchars=\~\#\!} -% \begin{Verbatim}[formatcom=\small\color{gray}] -% \begin{table} -% \centering -% \NiceMatrixOptions{caption-above} -% \begin{NiceTabular}{@{}llc@{} -% [ -% caption = A tabular whose caption has been specified by the key -% \texttt{caption}~emphase#\tabularnote{It's possible to put a tabular note in the caption}! , -% label = t:tabularnote , -% tabularnote = Some text before the notes. , -% notes/bottomrule -% ] -% \toprule -% Last name & First name & Length of life \\ -% \midrule -% Churchill & Wiston & 91\\ -% Nightingale~emphase#\tabularnote{Considered as the first nurse of history}! -% ~emphase#\tabularnote{Nicknamed ``the Lady with the Lamp''.}! -% & Florence~emphase#\tabularnote{This note is shared by two references.}! & 90 \\ -% Schoelcher & Victor & 89~emphase#\tabularnote{The label of the note is overlapping.}!\\ -% Touchet & Marie~emphase#\tabularnote{This note is shared by two references.}! & 89 \\ -% Wallis & John & 87 \\ -% \bottomrule -% \end{NiceTabular} -% \end{table} -% \end{Verbatim} -% \end{center} -% -% -% \begin{table}[hbt] -% \centering -% \NiceMatrixOptions{caption-above} -% \begin{NiceTabular}{@{}llc@{}}[ -% caption = A tabular whose caption has been specified by the key -% \texttt{caption}\tabularnote{It's possible to put a tabular note in the caption} , -% label = t:tabularnote , -% tabularnote = Some text before the notes. , -% notes/bottomrule -% ] -% \toprule -% Last name & First name & Length of life \\ -% \midrule -% Churchill & Wiston & 91\\ -% Nightingale\tabularnote{Considered as the first nurse of -% history.}\tabularnote{Nicknamed ``the Lady with the Lamp''.} -% & Florence\tabularnote{This note is shared by two references.} & 90 \\ -% Schoelcher & Victor & 89\tabularnote{The label of the note is overlapping.}\\ -% Touchet & Marie\tabularnote{This note is shared by two references.} & 89 \\ -% Wallis & John & 87 \\ -% \bottomrule -% \end{NiceTabular} -% \end{table} -% -% -%\subsection{Customisation of the tabular notes} -% -% -% The tabular notes can be customized with a set of keys available in -% |\NiceMatrixOptions|. The name of these keys is prefixed by |notes|. -% \begin{itemize} -% \item |notes/para| -% \item |notes/bottomrule| -% \item |notes/style| -% \item |notes/label-in-tabular| -% \item |notes/label-in-list| -% \item |notes/enumitem-keys| -% \item |notes/enumitem-keys-para| -% \item |notes/code-before| -% \end{itemize} -% For sake of commodity, it is also possible to set these keys in -% |\NiceMatrixOptions| via a key |notes| which takes in as value a list of -% pairs \textsl{key=value} where the name of the keys need no longer be -% prefixed by |notes|: -% \begin{center} -% \begin{BVerbatim}[formatcom = \small \color{gray}] -% \NiceMatrixOptions -% { -% notes = -% { -% bottomrule , -% style = ... , -% label-in-tabular = ... , -% enumitem-keys = -% { -% labelsep = ... , -% align = ... , -% ... -% } -% } -% } -% \end{BVerbatim} -% \end{center} -% -% -% \bigskip -% We detail these keys. -% -% \begin{itemize}[itemsep=\medskipamount] -% \item The key |notes/para| requires the composition of the notes (at the end of -% the tabular) in a single paragraph. -% -% Initial value: |false| -% -% That key is also available within a given environment. -% -% \item The key |notes/bottomrule| adds a |\bottomrule| of \pkg{booktabs} -% \emph{after} the notes. Of course, that rule is drawn only if there is really -% notes in the tabular. The package \pkg{booktabs} must have been loaded (before -% or after the package \pkg{nicematrix}). If it is not, an error is raised. -% -% Initial value: |false| -% -% That key is also available within a given environment. -% -% \item The key |notes/style| is a command whose argument is specified by |#1| -% and which gives the style of numerotation of the notes. That style will be -% used by |\ref| when referencing a tabular note marked with a command |\label|. -% The labels formatted by that style are used, separated by commas, when the user -% puts several consecutive commands |\tabularnote|. The marker |#1| is meant to -% be the name of a LaTeX counter. -% -% Initial value: |\textit{\alph{#1}}| -% -% Another possible value should be a mere |\arabic{#1}| -% -% \item The key |notes/label-in-tabular| is a command whose argument is -% specified by |#1| which is used when formatting the label of a note in the -% tabular. Internally, this number of note has already been formatted by -% |notes/style| before sent to that command. -% -% Initial value: |\textsuperscript{#1}| -% -% In French, it's a tradition of putting a small space before the label of note. -% That tuning could be acheived by the following code: -% % -% \begin{Verbatim} -% \NiceMatrixOptions{notes/label-in-tabular = \,\textsuperscript{~#1}} -% \end{Verbatim} -% -% -% \item The key |notes/label-in-list| is a command whose argument is specified -% by |#1| which is used when formatting the label in the list of notes at the -% end of the tabular. Internally, this number of note has already been formatted by -% |notes/style| before sent to that command. -% -% Initial value: |\textsuperscript{#1}| -% -% In French, the labels of notes are not composed in upper position when -% composing the notes. Such behaviour could be acheived by: -% \begin{Verbatim} -% \NiceMatrixOptions{notes/label-in-list = ~#1.\nobreak\hspace{0.25em}} -% \end{Verbatim} -% The command |\nobreak| is for the event that the option |para| is used. -% -% -% \item The notes are composed at the end of the tabular by using internally a -% style of list of \pkg{enumitem}. This style of list is defined as follows (with, of -% course, keys of \pkg{enumitem}): -% -% |noitemsep , leftmargin = * , align = left , labelsep = 0pt| -% -% The specification |align = left| in that style requires a -% composition of the label leftwards in the box affected to that label. -% With that tuning, the notes are composed flush left, which is pleasant when -% composing tabulars in the spirit of \pkg{booktabs} (see for example the -% table \ref{t:tabularnote}, p.~\pageref{t:tabularnote}). -% -% \medskip -% The key |notes/enumitem-keys| specifies a list of pairs -% \textsl{key=value} (following the specifications of \pkg{enumitem}) to -% customize that style of list (it uses internally the command |\setlist*| of -% \pkg{enumitem}). -% -% -% \item The key |notes/enumitem-keys-para| is similar to the previous one but -% corresponds to the type of list used when the option |para| is in force. Of -% course, when the option |para| is used, a list of type |inline| (as called by -% \pkg{enumitem}) is used and the pairs \textsl{key=value} should correspond to -% such a list of type |inline|. -% -% Initially, the style of list is defined by:\quad -% |afterlabel = \nobreak, itemjoin = \quad| -% -% -% \item The key |notes/code-before| is a token list inserted by \pkg{nicematrix} -% just before the composition of the notes at the end of the tabular. -% -% Initial value: \textsl{empty} -% -% For example, if one wishes to compose all the notes in gray and |\footnotesize|, -% he should use that key: -% \begin{Verbatim} -% \NiceMatrixOptions{notes/code-before = \footnotesize \color{gray}} -% \end{Verbatim} -% It's also possible to add |\raggedright| or |\RaggedRight| in that key (|\RaggedRight| -% is a command of \pkg{ragged2e}). -% -% \item The key |notes/detect-duplicates| activates the detection of the commands -% |\tabularnotes| with the same argument. -% -% Initial value : |true| -% \end{itemize} -% -% -% -% \bigskip -% For an example of customisation of the tabular notes, see p.~\pageref{ex:notes}. -% -% -% \subsection{Use of \{NiceTabular\} with threeparttable} -% -% -% If you wish to use the environment |{NiceTabular}|, |{NiceTabular*}| -% |{NiceTabularX}|in an environment |{threeparttable}| of the eponymous package, -% you have to patch the environment |{threeparttable}| with the following code -% (with a version of LaTeX at least 2020/10/01). -% \begin{Verbatim}[commandchars=\~\#\!] -% \makeatletter -% \AddToHook{env/threeparttable/begin} -% {\TPT@hookin{NiceTabular}\TPT@hookin{NiceTabular*}\TPT@hookin{NiceTabularX}} -% \makeatother -% \end{Verbatim} -% -% Nevertheless, the use of \pkg{threeparttable} in conjonction with -% \pkg{nicematrix} seems rather point-less because of the functionalities -% provided by \pkg{nicematrix}. -% -% -% \section{Other features} -% -% \subsection{The key rounded-corners of \{NiceTabular\}} -% -% \label{tabular-rounded-corners} -% \colorbox{yellow!50}{\textbf{New 6.18}}\par\nobreak -% -% \smallskip -% The key |rounded-corners| that we will descrite now has no direct link with -% the key |corners| (which is used to specify ``empty corners'') described in -% the part~\ref{corners}, p.~\pageref{corners}. -% -% \smallskip -% The environment |{NiceTabular}| provides also a key |rounded-corners| which -% specify that the tabular should have rounded corners with a radius equal to -% the value of that key (the default value is 4~pt\footnote{This value is the -% initial value of the \emph{rounded corners} of Tikz.}). More precisely, that -% key has two effects that we describe now. -% \begin{itemize} -% \item All the commands for coloring the cells, columns and rows (in the -% |\CodeBefore| but also directly in the array if the key |colortbl-like| is -% used) will respect those rounded corners. -% -% \item When the key |hvlines| is used, the exterior rules will be drawn with -% rounded corners. -% \end{itemize} - -% \bigskip -% \begin{BVerbatim}[baseline=c,boxwidth=9cm] -% \begin{NiceTabular} -% [hvlines,~emphase#rounded-corners@] -% {ccc} -% \CodeBefore -% \rowcolor{red!15}{1} -% \Body -% Last name & First name & Profession \\ -% Arvy & Jacques & Physicist \\ -% Jalon & Amandine & Physicist -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}{ccc}[hvlines,rounded-corners] -% \CodeBefore -% \rowcolor{red!15}{1} -% \Body -% Last name & First name & Profession \\ -% Arvy & Jacques & Physicist \\ -% Jalon & Amandine & Physicist -% \end{NiceTabular} -% -% -% \subsection{Command \textbackslash ShowCellNames} -% -% The command |\ShowCellNames|, which may be used in the |\CodeBefore| and in -% the |\CodeAfter| displays the name (with the form $i$-$j$) of each cell. When -% used in the |\CodeAfter|, that command applies a semi-transparent white -% rectangle to fade the array (caution: some \textsc{pdf} readers don't support -% transparency). -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm] -% \begin{NiceTabular}{ccc}[hvlines,cell-space-limits=3pt] -% \Block{2-2}{} & & test \\ -% & & blabla \\ -% & some text & nothing -% ~emphase#\CodeAfter \ShowCellNames@ -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}{ccc}[hvlines,cell-space-limits=3pt] -% \Block{2-2}{} & & test \\ -% & & blabla \\ -% & some text & nothing -% \CodeAfter \ShowCellNames -% \end{NiceTabular} -% -% -% \subsection{Use 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 = 11cm] -% $\begin{pNiceArray}{~emphase#S@cW{c}{1cm}c}[nullify-dots,first-row] -% {C_1} & \Cdots & & C_n \\ -% 2.3 & 0 & \Cdots & 0 \\ -% 12.4 & \Vdots & & \Vdots \\ -% 1.45 \\ -% 7.2 & 0 & \Cdots & 0 -% \end{pNiceArray}$ -% \end{BVerbatim} -% $\begin{pNiceArray}{ScW{c}{1cm}c}[nullify-dots,first-row] -% {C_1} & \Cdots & & C_n \\ -% 2.3 & 0 & \Cdots & 0 \\ -% 12.4 & \Vdots & & \Vdots \\ -% 1.45 \\ -% 7.2 & 0 & \Cdots & 0 -% \end{pNiceArray}$ -% -% \medskip -% On the other hand, the |d| columns of the package \pkg{dcolumn} are not -% supported by \pkg{nicematrix}. -% -% -% \subsection{Default column type in \{NiceMatrix\}} -% -% \label{columns-width} -% -% The environments without preamble (|{NiceMatrix}|, |{pNiceMatrix}|, -% |{bNiceMatrix}|, etc.) and the commande |\pAutoNiceMatrix| (and its variants) -% provide an option |columns-type| to specify the type of column which will be -% used (the initial value is, of course, |c|). -% -% The keys |l| and |r| are shortcuts for |columns-type=l| and |columns-type=r|. -% -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% $\begin{bNiceMatrix}[r] -% \cos x & - \sin x \\ -% \sin x & \cos x -% \end{bNiceMatrix}$ -% \end{BVerbatim} -% $\begin{bNiceMatrix}[r] -% \cos x & - \sin x \\ -% \sin x & \cos x -% \end{bNiceMatrix}$ -% -% \medskip -% The key |columns-type| is available in |\NiceMatrixOptions| but with the -% prefix |matrix|, which means that its name is, within |\NiceMatrixOptions| : -% |matrix/columns-type|. -% -% \subsection{The command \textbackslash rotate} -% -% \label{rotate} -% -% The package \pkg{nicematrix} provides a command |\rotate|. When used in the -% beginning of a cell, this command composes the contents of the cell after a -% rotation of 90° in the direct sens. -% -% In the following command, we use that command in the -% |code-for-first-row|.\footnote{It can also be used in |\RowStyle| -% (cf.~p.~\pageref{RowStyle}.} -% -%\bigskip -% -%\begin{BVerbatim}[baseline=c,boxwidth=12cm] -% \NiceMatrixOptions% -% {code-for-first-row = \scriptstyle ~emphase#\rotate@ \text{image of }, -% code-for-last-col = \scriptstyle } -% $A = \begin{pNiceMatrix}[first-row,last-col=4] -% e_1 & e_2 & e_3 \\ -% 1 & 2 & 3 & e_1 \\ -% 4 & 5 & 6 & e_2 \\ -% 7 & 8 & 9 & e_3 -% \end{pNiceMatrix}$ -% \end{BVerbatim} -% \begin{varwidth}{10cm} -% \NiceMatrixOptions% -% {code-for-first-row = \scriptstyle\rotate \text{image of }, -% code-for-last-col = \scriptstyle } -% $ A = \begin{pNiceMatrix}[first-row,last-col=4] -% e_1 & e_2 & e_3 \\ -% 1 & 2 & 3 & e_1 \\ -% 4 & 5 & 6 & e_2 \\ -% 7 & 8 & 9 & e_3 -% \end{pNiceMatrix}$ -% \end{varwidth} -% -% \bigskip -% If the command |\rotate| is used in the ``last row'' (exterior to the matrix), -% the corresponding elements are aligned upwards as shown below. -% -% \bigskip -% \begin{BVerbatim}[baseline=c,boxwidth=12cm] -% \NiceMatrixOptions% -% {code-for-last-row = \scriptstyle ~emphase#\rotate@ , -% code-for-last-col = \scriptstyle } -% $A = \begin{pNiceMatrix}[last-row=4,last-col=4] -% 1 & 2 & 3 & e_1 \\ -% 4 & 5 & 6 & e_2 \\ -% 7 & 8 & 9 & e_3 \\ -% \text{image of } e_1 & e_2 & e_3 -% \end{pNiceMatrix}$ -% \end{BVerbatim} -% \begin{varwidth}{10cm} -% \NiceMatrixOptions% -% {code-for-last-row = \scriptstyle\rotate , -% code-for-last-col = \scriptstyle }% -% $A = \begin{pNiceMatrix}[last-row=4,last-col=4] -% 1 & 2 & 3 & e_1 \\ -% 4 & 5 & 6 & e_2 \\ -% 7 & 8 & 9 & e_3 \\ -% \text{image of } e_1 & e_2 & e_3 -% \end{pNiceMatrix}$ -% \end{varwidth} -% -% -% -% \subsection{The option small} -% -% \label{small} -% -% With the option |small|, the environments of the package \pkg{nicematrix} -% are composed in a way similar to the environment |{smallmatrix}| of the -% package \pkg{amsmath} (and the environments |{psmallmatrix}|, -% |{bsmallmatrix}|, etc. of the package \pkg{mathtools}). -% % \bigskip -% \begin{Verbatim} -% $\begin{bNiceArray}{cccc|c}[~emphase#small@, -% last-col, -% code-for-last-col = \scriptscriptstyle, -% columns-width = 3mm ] -% 1 & -2 & 3 & 4 & 5 \\ -% 0 & 3 & 2 & 1 & 2 & L_2 \gets 2 L_1 - L_2 \\ -% 0 & 1 & 1 & 2 & 3 & L_3 \gets L_1 + L_3 -% \end{bNiceArray}$ -% \end{Verbatim} -% % -% \[\begin{bNiceArray}{cccc|c}[small, last-col, -% code-for-last-col = \scriptscriptstyle, -% columns-width=3mm] -% 1 & -2 & 3 & 4 & 5 \\ -% 0 & 3 & 2 & 1 & 2 & L_2 \gets 2 L_1 - L_2 \\ -% 0 & 1 & 1 & 2 & 3 & L_3 \gets L_1 + L_3 -% \end{bNiceArray}\] -% -% -% \bigskip -% One should note that the environment |{NiceMatrix}| with the option |small| is -% not composed \emph{exactly} as the environment |{smallmatrix}|. Indeed, all -% the environments of \pkg{nicematrix} are constructed upon |{array}| (of the -% package \pkg{array}) whereas the environment |{smallmatrix}| is constructed -% directly with an |\halign| of TeX. -% -% \medskip -% In fact, the option |small| corresponds to the following tuning: -% \begin{itemize} -% \item the cells of the array are composed with |\scriptstyle|; -% \item |\arraystretch| is set to $0.47$; -% \item |\arraycolsep| is set to $1.45$~pt; -% \item the characteristics of the dotted lines are also modified. -% \end{itemize} -% -% \medskip -% When the key |small| is in force, some functionalities of \pkg{nicematrix} are -% no longer available: for example, it's no longer possible to put vertical -% delimiters directly in the preamble of an environment with preamble (cf. -% section \ref{delimiters-in-preamble}, p.~\pageref{delimiters-in-preamble}). -% -% -% \subsection{The counters iRow and jCol} -% -% \label{iRow} -% -% In the cells of the array, it's possible to use the LaTeX counters |iRow| and -% |jCol| which represent the number of the current row and the number of the -% current column\footnote{We recall that the exterior ``first row'' (if it -% exists) has the number~$0$ and that the exterior ``first column'' (if it -% 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 |\CodeBefore| (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). -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=10.6cm] -% $\begin{pNiceMatrix}% don't forget the % -% [first-row, -% first-col, -% code-for-first-row = \mathbf{~emphase#\alph{jCol}@} , -% code-for-first-col = \mathbf{~emphase#\arabic{iRow}@} ] -% & & & & \\ -% & 1 & 2 & 3 & 4 \\ -% & 5 & 6 & 7 & 8 \\ -% & 9 & 10 & 11 & 12 -% \end{pNiceMatrix}$ -% \end{BVerbatim} -% $\begin{pNiceMatrix}[first-row, -% first-col, -% code-for-first-row = \mathbf{\alph{jCol}} , -% code-for-first-col = \mathbf{\arabic{iRow}} ] -% & & & & \\ -% & 1 & 2 & 3 & 4 \\ -% & 5 & 6 & 7 & 8 \\ -% & 9 & 10 & 11 & 12 -% \end{pNiceMatrix}$ -% -% \medskip -% If LaTeX counters called |iRow| and |jCol| are defined in the document by -% packages other than \pkg{nicematrix} (or by the final user), they are shadowed -% in the environments of \pkg{nicematrix}. -% -% \bigskip -% The package \pkg{nicematrix} also provides commands in order to compose -% automatically matrices from a general pattern. These commands are -% |\AutoNiceMatrix|, |\pAutoNiceMatrix|, |\bAutoNiceMatrix|, |\vAutoNiceMatrix|, -% |\VAutoNiceMatrix| and |\BAutoNiceMatrix|. -% -% These commands take in two mandatory arguments. The first is the format of the -% matrix, with the syntax $n$-$p$ where $n$ is the number of rows and $p$ the -% number of columns. The second argument is the pattern (it's a list of tokens -% which are inserted in each cell of the constructed matrix). -% -% \medskip -% \begin{Verbatim} -% $C = ~emphase#\pAutoNiceMatrix@{3-3}{C_{\arabic{iRow},\arabic{jCol}}}$ -% \end{Verbatim} -% -% -% \[C = \pAutoNiceMatrix{3-3}{C_{\arabic{iRow},\arabic{jCol}}}\] -% -% -% \subsection{The key light-syntax} -% -% \label{light-syntax} -% The option |light-syntax| (inpired by the package \pkg{spalign}) allows the -% user to compose the arrays with a lighter syntax, which gives a better -% legibility of the TeX source. -% -% When this option is used, one should use the semicolon for the end of a row -% and spaces or tabulations to separate the columns. However, as usual in the -% TeX world, the spaces after a control sequence are discarded and the elements -% between curly braces are considered as a whole. -% -% -% \medskip -% \begin{scope} -% \begin{BVerbatim}[baseline=c,boxwidth=10cm] -% $\begin{bNiceMatrix}[~emphase#light-syntax@,first-row,first-col] -% {} a b ; -% a 2\cos a {\cos a + \cos b} ; -% b \cos a+\cos b { 2 \cos b } -% \end{bNiceMatrix}$ -% \end{BVerbatim} -% \end{scope} -% $\begin{bNiceMatrix}[light-syntax,first-row,first-col] -% {} a b ; -% a 2\cos a {\cos a + \cos b} ; -% b \cos a+\cos b { 2 \cos b } -% \end{bNiceMatrix}$ -% -% \medskip -% It's possible to change the character used to mark the end of rows with the -% option |end-of-row|. As said before, the initial value is a semicolon. -% -% \medskip -% When the option |light-syntax| is used, it is not possible to put verbatim -% material (for example with the command |\verb|) in the cells of the -% array.\footnote{The reason is that, when the option |light-syntax| is used, -% the whole content of the environment is loaded as a TeX argument to be -% analyzed. The environment doesn't behave in that case as a standard -% environment of LaTeX which only put TeX commands before and after the content.} -% -% -% \subsection{Color of the delimiters} -% -% For the environments with delimiters (|{pNiceArray}|, |{pNiceMatrix}|, etc.), -% it's possible to change the color of the delimiters with the key -% |delimiters/color|. -% -% \medskip -% \begin{BVerbatim}[boxwidth=12cm,baseline=c] -% $\begin{bNiceMatrix}[delimiters/color=red] -% 1 & 2 \\ -% 3 & 4 -% \end{bNiceMatrix}$ -% \end{BVerbatim} -% $\begin{bNiceMatrix}[delimiters/color=red] -% 1 & 2 \\ -% 3 & 4 -% \end{bNiceMatrix}$ -% -% \medskip -% This colour also applies to the delimiters drawn by the command |\SubMatrix| -% (cf.~p.~\pageref{sub-matrix}). -% -% \subsection{The environment \{NiceArrayWithDelims\}} -% -% \label{NiceArrayWithDelims} -% -% In fact, the environment |{pNiceArray}| and its variants are based upon a -% more general environment, called |{NiceArrayWithDelims}|. 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 -% |{NiceArrayWithDelims}| if we want to use atypical or asymetrical delimiters. -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=11cm] -% $\begin{~emphase#NiceArrayWithDelims@} -% {\downarrow}{\uparrow}{ccc}[margin] -% 1 & 2 & 3 \\ -% 4 & 5 & 6 \\ -% 7 & 8 & 9 -% \end{~emphase#NiceArrayWithDelims@}$ -% \end{BVerbatim} -% $\begin{NiceArrayWithDelims} -% {\downarrow}{\uparrow}{ccc}[margin] -% 1 & 2 & 3 \\ -% 4 & 5 & 6 \\ -% 7 & 8 & 9 -% \end{NiceArrayWithDelims}$ -% -% \subsection{The command \textbackslash OnlyMainNiceMatrix} -% -% The command |\OnlyMainNiceMatrix| executes its argument only when it is in the -% main part of the array, that is to say it is not in one of the exterior rows. -% If it is used outside an environment of \pkg{nicematrix}, that command is no-op. -% -% For an example of utilisation, see \url{tex.stackexchange.com/questions/488566} -% -% \section{Use of Tikz with nicematrix} -% -% \label{name}\label{PGF-nodes} -% -% \subsection{The nodes corresponding to the contents of the cells} -% -% The package \pkg{nicematrix} creates a PGF/Tikz node\footnote{We recall that Tikz -% is a layer over PGF. The extension \pkg{nicematrix} loads PGF but does not -% load Tikz. We speak of PGF/Tikz nodes to emphase the fact that the PGF nodes -% created by \pkg{nicematrix} may be used with PGF but also with Tikz. The final -% user will probably prefer to use Tikz rather than PGF.} for each (non-empty) cell -% of the considered array. These nodes are used to draw the dotted lines between -% the cells of the matrix (inter alia). -% -% -% \smallskip -% \textbf{Caution} : By default, no node is created in a empty cell. -% -% \smallskip -% However, it's possible to impose the creation of a node with the command -% |\NotEmpty|. \footnote{One should note that, with that command, the cell is -% considered as non-empty, which has consequencies for the continuous dotted -% lines (cf. p.~\pageref{Cdots}) and the computation of the ``corners'' -% (cf.~p.~\pageref{corners}).} -% -% \medskip -% The nodes of a document must have distinct names. That's why the names of the -% nodes created by \pkg{nicematrix} contains the number of the current -% environment. Indeed, the environments of \pkg{nicematrix} are numbered by a -% internal global counter. -% -% \smallskip -% In the environment with the number $n$, the node of the row $i$ and -% column~$j$ has for name |nm-|$n$|-|$i$|-|$j$. -% -% \smallskip -% The command |\NiceMatrixLastEnv| provides the number of the last environment -% of \pkg{nicematrix} (for LaTeX, it's a ``fully expandable'' command and not a -% counter). -% -% \smallskip -% However, it's advisable to use instead the key |name|. This key gives a name -% to the current environment. When the environment has a name, the nodes are -% accessible with the name ``\textsl{name}-$i$-$j$'' where \textsl{name} is the -% name given to the array and $i$ and $j$ the numbers of row and column. It's -% possible to use these nodes with \textsc{pgf} but the final user will -% probably prefer to use Tikz (which is a convenient layer upon \textsc{pgf}). -% However, one should remind that \pkg{nicematrix} doesn't load Tikz by default. -% In the following examples, we assume that Tikz has been loaded. -% -% \bigskip -% \begin{BVerbatim}[baseline=c,boxwidth=11cm] -% $\begin{pNiceMatrix}[name=~emphase#mymatrix@] -% 1 & 2 & 3 \\ -% 4 & 5 & 6 \\ -% 7 & 8 & 9 -% \end{pNiceMatrix}$ -% \tikz[remember picture,overlay] -% \draw ~emphase#(mymatrix-2-2)@ circle (2mm) ; -% \end{BVerbatim} -% $\begin{pNiceMatrix}[name=mymatrix] -% 1 & 2 & 3 \\ -% 4 & 5 & 6 \\ -% 7 & 8 & 9 -% \end{pNiceMatrix}$ -% \tikz[remember picture,overlay] -% \draw (mymatrix-2-2) circle (2mm) ; -% -% \medskip -% Don't forget the options |remember picture| and |overlay|. -% -% \bigskip -% 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). -% -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=11cm] -% $\begin{pNiceMatrix} -% 1 & 2 & 3 \\ -% 4 & 5 & 6 \\ -% 7 & 8 & 9 -% \CodeAfter -% \tikz \draw ~emphase#(2-2)@ circle (2mm) ; -% \end{pNiceMatrix}$ -% \end{BVerbatim} -% $\begin{pNiceMatrix} -% 1 & 2 & 3 \\ -% 4 & 5 & 6 \\ -% 7 & 8 & 9 -% \CodeAfter -% \tikz \draw (2-2) circle (2mm) ; -% \end{pNiceMatrix}$ -% -% \medskip -% The nodes of the last column (excepted the potential «last column» specified -% by |last-col|\footnote{For the exterior columns, cf. part~\ref{exterior}, -% p.~\pageref{exterior}.}) may also be indicated by $i$-|last|. Similarly, the -% nodes of the last row may be indicated by |last|-$j$. -% -% \bigskip -% In the following example, we have underlined all the nodes of the matrix. -% -% \[ -% \NiceMatrixOptions -% { -% pgf-node-code = -% { -% \pgfsetfillcolor{red!15}% -% \pgfusepathqfill -% } -% } -% \begin{pNiceMatrix} -% a & a + b & a + b + c \\ -% a & a & a + b \\ -% a & a & a -% \end{pNiceMatrix}\] -% -% -% \bigskip -% \colorbox{yellow!50}{\textbf{New 6.17}}\enskip Since those nodes are PGF -% nodes, one won't be surprised to learn that they are drawn by using a specific -% PGF style. That style is called |nicematrix/cell-node| and its definition in -% the source file |nicematrix.sty| is as follows: -% -% \begin{Verbatim} -% \pgfset -% { -% ~emphase#nicematrix / cell-node@ /.style = -% { -% inner sep = 0 pt , -% minimum width = 0 pt -% } -% } -% \end{Verbatim} -% -% The final user may modify that style by changing the values of the keys |text/rotate|, -% |inner xsep|, |inner ysep|, |inner sep|, |outer xsep|, |outer ysep|, |outer sep|, -% |minimum width|, |minimum height| and |minimum size|. -% -% \medskip -% For an example of utilisation, see part~\ref{triangular}, p.~\pageref{triangular}. -% -% -% \subsubsection{The key pgf-node-code} -% -% \colorbox{yellow!50}{\textbf{New 6.17}}\enskip \textbf{For the experienced -% users}, \pkg{nicematrix} provides the key |pgf-node-code| which corresponds to -% some PGF node that will be executed at the creation, by PGF, of the nodes -% corresponding to the cells of the array. More pricisely, the value given to -% the key |pgf-node-code| will be passed in the fifth argument of the command -% |\pgfnode|. That value should contain at least an instruction such as -% |\pgfusepath|, |\pgfusepathqstroke|, |\pgfusepathqfill|, etc. -% -% \subsubsection{The columns V of varwidth} -% -% \label{node-V} -% When the extension \pkg{varwidth} is loaded, the columns of the type |V| -% defined by \pkg{varwidth} are supported by \pkg{nicematrix}. It may be -% interessant to notice that, for a cell of a column of type |V|, the PGF/Tikz -% node created by \pkg{nicematrix} for the content of that cell has a width -% adjusted to the content of the cell. This is in contrast to the case of the -% columns of type |p|, |m| or |b| for which the nodes have always a width equal -% to the width of the column. In the following example, the command |\lipsum| is -% provided by the eponymous package. -% -% \begin{Verbatim} -% \begin{NiceTabular}{V{10cm}} -% \bfseries \large -% Titre \\ -% \lipsum[1][1-4] -% \CodeAfter -% \tikz \draw [rounded corners] (1-1) -| (last-|2) -- (last-|1) |- (1-1) ; -% \end{NiceTabular} -% \end{Verbatim} -% -% -% \begin{center} -% \begin{NiceTabular}{V{10cm}} -% \bfseries \large -% Titre \\ -% \lipsum[1][1-4] -% \CodeAfter -% \tikz \draw [rounded corners] (1-1) -| (last-|2) -- (last-|1) |- (1-1) ; -% \end{NiceTabular} -% \end{center} -% -% We have used the nodes corresponding to the position of the potential rules, -% which are described below (cf. p.~\pageref{nodes-i}). -% -% -% \subsection[The medium nodes and the large nodes]{The ``medium nodes'' and the ``large nodes''} -% -% In fact, the package \pkg{nicematrix} can create ``extra nodes'': the ``medium -% nodes'' and the ``large nodes''. The first ones -% are created with the option |create-medium-nodes| and the second ones with the -% option |create-large-nodes|.\footnote{There is also an option -% |create-extra-nodes| which is an alias for the conjonction of -% |create-medium-nodes| and |create-large-nodes|.} -% -% \medskip -% These nodes are not used by \pkg{nicematrix} by default, and that's why they -% are not created by default. -% -% \medskip -% The names of the ``medium nodes'' are constructed by adding the suffix -% ``|-medium|'' to the names of the ``normal nodes''. In the following example, -% we have underlined the ``medium nodes''. We consider that this example is -% self-explanatory. -% \[\begin{pNiceMatrix}[create-medium-nodes] -% \CodeBefore [create-cell-nodes] -% \begin{tikzpicture} -% [every node/.style = {fill = red!15, inner sep = 0 pt}, -% name suffix = -medium] -% \node [fit = (1-1)] {} ; -% \node [fit = (1-2)] {} ; -% \node [fit = (1-3)] {} ; -% \node [fit = (2-1)] {} ; -% \node [fit = (2-2)] {} ; -% \node [fit = (2-3)] {} ; -% \node [fit = (3-1)] {} ; -% \node [fit = (3-2)] {} ; -% \node [fit = (3-3)] {} ; -% \end{tikzpicture} -% \Body -% a & a + b & a + b + c \\ -% a & a & a + b \\ -% a & a & a -% \end{pNiceMatrix}\] -% -% -% \medskip -% The names of the ``large nodes'' are constructed by adding the suffix -% ``|-large|'' to the names of the ``normal nodes''. In the following example, -% we have underlined the ``large nodes''. We consider that this example is -% self-explanatory.\footnote{There is no ``large nodes'' created in the exterior -% rows and columns (for these rows and columns, cf. p.~\pageref{exterior}).} -% \[\begin{pNiceMatrix}[create-large-nodes] -% \CodeBefore [create-cell-nodes] -% \begin{tikzpicture} -% [every node/.style = { inner sep = 0 pt} , -% name suffix = -large] -% \node [fit = (1-1),fill = red!15] {} ; -% \node [fit = (1-3),fill = red!15] {} ; -% \node [fit = (2-2),fill = red!15] {} ; -% \node [fit = (3-1),fill = red!15] {} ; -% \node [fit = (3-3),fill = red!15] {} ; -% \node [fit = (1-2),fill = blue!15] {} ; -% \node [fit = (2-1),fill = blue!15] {} ; -% \node [fit = (2-3),fill = blue!15] {} ; -% \node [fit = (3-2),fill = blue!15] {} ; -% \end{tikzpicture} -% \Body -% a & a + b & a + b + c \\ -% a & a & a + b \\ -% a & a & a -% \end{pNiceMatrix}\] -% -% -% -% \medskip -% The ``large nodes'' of the first column and last column may appear too small -% for some usage. That's why it's possible to use the options |left-margin| and -% |right-margin| to add space on both sides of the array and also space in the -% ``large nodes'' of the first column and last column. In the following example, -% we have used the options |left-margin| and |right-margin|.\footnote{The -% options |left-margin| and |right-margin| take dimensions as values but, if no -% value is given, the default value is used, which is |\arraycolsep| (by -% default: 5~pt). There is also an option |margin| to fix both |left-margin| and -% |right-margin| to the same value.} -% \[\begin{pNiceMatrix}[create-large-nodes,left-margin,right-margin] -% \CodeBefore [create-cell-nodes] -% \begin{tikzpicture} -% [every node/.style = {inner sep = 0 pt}, -% name suffix = -large] -% \node [fit = (1-1),fill = red!15] {} ; -% \node [fit = (1-3),fill = red!15] {} ; -% \node [fit = (2-2),fill = red!15] {} ; -% \node [fit = (3-1),fill = red!15] {} ; -% \node [fit = (3-3),fill = red!15] {} ; -% \node [fit = (1-2),fill = blue!15] {} ; -% \node [fit = (2-1),fill = blue!15] {} ; -% \node [fit = (2-3),fill = blue!15] {} ; -% \node [fit = (3-2),fill = blue!15] {} ; -% \end{tikzpicture} -% \Body -% a & a + b & a + b + c \\ -% a & a & a + b \\ -% a & a & a -% \end{pNiceMatrix}\] -% -% -% \medskip -% It's also possible to add more space on both side of the array with the -% options |extra-left-margin| and |extra-right-margin|. These margins are not -% incorporated in the ``large nodes''. It's possible to fix both values with the -% option |extra-margin| and, in the following example, we use |extra-margin| -% with the value $3$~pt. -% \[\begin{pNiceMatrix}[create-large-nodes,left-margin,right-margin,extra-right-margin=3pt,extra-left-margin=3pt] -% \CodeBefore [create-cell-nodes] -% \begin{tikzpicture} -% [every node/.style = {inner sep = 0 pt}, -% name suffix = -large] -% \node [fit = (1-1),fill = red!15] {} ; -% \node [fit = (1-3),fill = red!15] {} ; -% \node [fit = (2-2),fill = red!15] {} ; -% \node [fit = (3-1),fill = red!15] {} ; -% \node [fit = (3-3),fill = red!15] {} ; -% \node [fit = (1-2),fill = blue!15] {} ; -% \node [fit = (2-1),fill = blue!15] {} ; -% \node [fit = (2-3),fill = blue!15] {} ; -% \node [fit = (3-2),fill = blue!15] {} ; -% \end{tikzpicture} -% \Body -% a & a + b & a + b + c \\ -% a & a & a + b \\ -% a & a & a -% \end{pNiceMatrix}\] -% -% -% -% \bigskip -% \textbf{Be careful} : These nodes are reconstructed from the contents of the -% contents cells of the array. Usually, they do not correspond to the cells -% delimited by the rules (if we consider that these rules are drawn). -% -% \bigskip -% \begin{minipage}[c]{7.6cm} -% Here is an array composed with the following code: -% -% \medskip -% \begin{BVerbatim} -% \large -% \begin{NiceTabular}{wl{2cm}ll}[hvlines] -% fraise & amande & abricot \\ -% prune & pêche & poire \\[1ex] -% noix & noisette & brugnon -% \end{NiceTabular} -% \end{BVerbatim} -% \end{minipage} -% \hspace{0.9cm} -% \begin{scope} -% \large -% \begin{NiceTabular}[c]{wl{2cm}ll}[hvlines] -% fraise & amande & abricot \\ -% prune & pêche & poire \\[1ex] -% noix & noisette & brugnon -% \end{NiceTabular} -% \end{scope} -% -% \vspace{1cm} -% \begin{minipage}[c]{7cm} -% Here, we have colored all the cells of the array with |\chessboardcolors|. -% \end{minipage} -% \hspace{1.5cm} -% \begin{scope} -% \large -% \begin{NiceTabular}[c]{wl{2cm}ll}[hvlines,code-before = \chessboardcolors{red!15}{blue!15}] -% fraise & amande & abricot \\ -% prune & pêche & poire \\[1ex] -% noix & noisette & brugnon -% \end{NiceTabular} -% \end{scope} -% -% -% \vspace{1cm} -% \begin{minipage}[c]{7cm} -% Here are the ``large nodes'' of this array (without use of |margin| -% nor |extra-margin|). -% \end{minipage} -% \hspace{1.5cm} -% \begin{scope} -% \large -% \begin{NiceTabular}[c]{w{l}{2cm}ll}[hvlines,create-large-nodes] -% \CodeBefore [create-cell-nodes] -% \begin{tikzpicture} -% [every node/.style = {inner sep = 0 pt}, -% name suffix = -large] -% \node [fit = (1-1),fill = red!15] {} ; -% \node [fit = (1-3),fill = red!15] {} ; -% \node [fit = (2-2),fill = red!15] {} ; -% \node [fit = (3-1),fill = red!15] {} ; -% \node [fit = (3-3),fill = red!15] {} ; -% \node [fit = (1-2),fill = blue!15] {} ; -% \node [fit = (2-1),fill = blue!15] {} ; -% \node [fit = (2-3),fill = blue!15] {} ; -% \node [fit = (3-2),fill = blue!15] {} ; -% \end{tikzpicture} -% \Body -% fraise & amande & abricot \\ -% prune & pêche & poire \\[1ex] -% noix & noisette & brugnon -% \end{NiceTabular} -% \end{scope} -% -% -% \vspace{1cm} -% The nodes we have described are not available by default in the |\CodeBefore| -% (described p.~\pageref{code-before}).\par\nobreak -% -% It's possible to have these nodes available in the |\CodeBefore| by using the -% key |create-cell-nodes| of the keyword |\CodeBefore| (in that case, the nodes -% are created first before the construction of the array by using informations -% written on the |aux| file and created a second time during the contruction of -% the array itself). -% -% \bigskip -% Here is an example which uses these nodes in the |\CodeAfter|. -% -% \begin{center} -% \fvset{commandchars=\~\#\+} -% \begin{Verbatim} -% \begin{NiceArray}{c@{\;}c@{\;}c@{\;}c@{\;}c}[create-medium-nodes] -% u_1 &-& u_0 &=& r \\ -% u_2 &-& u_1 &=& r \\ -% u_3 &-& u_2 &=& r \\ -% u_4 &-& u_3 &=& r \\ -% \phantom{u_5} & & \phantom{u_4} &\smash{\vdots} & \\ -% u_n &-& u_{n-1} &=& r \\[3pt] -% \hline -% u_n &-& u_0 &=& nr \\ -% \CodeAfter -% \tikz[very thick, red, opacity=0.4, name suffix = -medium] -% \draw (1-1.north west) -- (2-3.south east) -% (2-1.north west) -- (3-3.south east) -% (3-1.north west) -- (4-3.south east) -% (4-1.north west) -- (5-3.south east) -% (5-1.north west) -- (6-3.south east) ; -% \end{NiceArray} -% \end{Verbatim} -% \end{center} -% -% \[\begin{NiceArray}{c@{\;}c@{\;}c@{\;}c@{\;}c}[create-medium-nodes] -% u_1 &-& u_0 &=& r \\ -% u_2 &-& u_1 &=& r \\ -% u_3 &-& u_2 &=& r \\ -% u_4 &-& u_3 &=& r \\ -% \phantom{u_5} & & \phantom{u_4} &\smash{\vdots} & \\ -% u_n &-& u_{n-1} &=& r \\[3pt] -% \hline -% u_n &-& u_0 &=& nr \\ -% \CodeAfter -% \tikz[very thick, red, opacity=0.4, name suffix = -medium] -% \draw (1-1.north west) -- (2-3.south east) -% (2-1.north west) --(3-3.south east) -% (3-1.north west) -- (4-3.south east) -% (4-1.north west) -- (5-3.south east) -% (5-1.north west) -- (6-3.south east) ; -% \end{NiceArray}\] -% -% -% -% \subsection{The nodes which indicate the position of the rules} -% -% \label{nodes-i} -% The package \pkg{nicematrix} creates a PGF/Tikz node merely called $i$ (with -% the classical prefix) at the intersection of the horizontal rule of number~$i$ -% and the vertical rule of number~$i$ (more specifically the potential position -% of those rules because maybe there are not actually drawn). The last node has -% also an alias called |last|. There is also a node called $i$|.5| midway -% between the node $i$ and the node $i+1$. -% -% These nodes are available in the |\CodeBefore| and the |\CodeAfter|. -% -% \begin{center} -% \begin{NiceTabular}{ccc}[hvlines,rules/width=1pt,rules/color=gray] -% & tulipe & lys \\ -% arum & & violette mauve \\ -% muguet & dahlia -% \CodeAfter -% \tiny -% \begin{tikzpicture} -% \foreach \i in {1,1.5,2,2.5,3,3.5,4} -% { -% \fill [red] (\i) circle (0.5mm) ; -% \node [red,above right] at (\i) {\i} ; -% } -% \end{tikzpicture} -% \end{NiceTabular} -% \end{center} -% -% \bigskip -% If we use Tikz (we remind that \pkg{nicematrix} does not load Tikz by default, -% by only \textsc{pgf}, which is a sub-layer of Tikz), we can access, in the -% |\CodeAfter| but also in the |\CodeBefore|, to the intersection of the -% (potential) horizontal rule~$i$ and the (potential) vertical rule~$j$ with the -% syntax |(|$i$\verb+-|+$j$|)|. -% -% \medskip -% \begin{Verbatim} -% \begin{NiceMatrix} -% \CodeBefore -% ~emphase#\tikz \draw [fill=red!15] (7-|4) |- (8-|5) |- (9-|6) |- cycle ;@ -% \Body -% 1 \\ -% 1 & 1 \\ -% 1 & 2 & 1 \\ -% 1 & 3 & 3 & 1 \\ -% 1 & 4 & 6 & 4 & 1 \\ -% 1 & 5 & 10 & 10 & 5 & 1 \\ -% 1 & 6 & 15 & 20 & 15 & 6 & 1 \\ -% 1 & 7 & 21 & 35 & 35 & 21 & 7 & 1 \\ -% 1 & 8 & 28 & 56 & 70 & 56 & 28 & 8 & 1 -% \end{NiceMatrix} -% \end{Verbatim} -% % -% \[\begin{NiceMatrix} -% \CodeBefore -% \tikz \draw [fill=red!15] (7-|4) |- (8-|5) |- (9-|6) |- cycle ; -% \Body -% 1 \\ -% 1 & 1 \\ -% 1 & 2 & 1 \\ -% 1 & 3 & 3 & 1 \\ -% 1 & 4 & 6 & 4 & 1 \\ -% 1 & 5 & 10 & 10 & 5 & 1 \\ -% 1 & 6 & 15 & 20 & 15 & 6 & 1 \\ -% 1 & 7 & 21 & 35 & 35 & 21 & 7 & 1 \\ -% 1 & 8 & 28 & 56 & 70 & 56 & 28 & 8 & 1 -% \end{NiceMatrix}\] -% -% -% \bigskip -% The nodes of the form $i$|.5| may be used, for example to cross a row of a -% matrix (if Tikz is loaded). -% -% \smallskip -% \begin{BVerbatim}[boxwidth=11cm,baseline=c] -% $\begin{pNiceArray}{ccc|c} -% 2 & 1 & 3 & 0 \\ -% 3 & 3 & 1 & 0 \\ -% 3 & 3 & 1 & 0 -% \CodeAfter -% \tikz \draw [red] (~emphase#3.5@-|1) -- (~emphase#3.5@-|last) ; -% \end{pNiceArray}$ -% \end{BVerbatim} -% $\begin{pNiceArray}{ccc|c} -% 2 & 1 & 3 & 0 \\ -% 3 & 3 & 1 & 0 \\ -% 3 & 3 & 1 & 0 -% \CodeAfter -% \tikz \draw [red] (3.5-|1) -- (3.5-|last) ; -% \end{pNiceArray}$ -% -% \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 -% public\footnote{According to the LaTeX3 conventions, -% each variable with name beginning with |\g_nicematrix| ou |\l_nicematrix| is -% public and each variable with name beginning with |\g__nicematrix| or -% |\l__nicematrix| is private.}: -% \begin{itemize} -% \item |\g_nicematrix_code_before_tl| ; -% \item |\g_nicematrix_code_after_tl|. -% \end{itemize} -% -% -% \medskip -% These variables contain the code of what we have called the ``|code-before|'' -% (usually specified at the beginning of the environment with the syntax using -% the keywords |\CodeBefore| and |\Body|) and the ``|code-after|'' (usually -% specified at the end of the environment after the keyword |\CodeAfter|). The -% developper can use them to add code from a cell of the array (the affectation -% must be global, allowing to exit the cell, which is a TeX group). -% -% \medskip -% One should remark that the use of |\g_nicematrix_code_before_tl| needs one -% compilation more (because the instructions are written on the |aux| file to be -% used during the next run). -% -% \bigskip -% \emph{Example} : We want to write a command |\crossbox| to draw a cross in the -% current cell. This command will take in an optional argument between square -% brackets for a list of pairs \textsl{key}-\textsl{value} which will be given to -% Tikz before the drawing. -% -% It's possible to program such command |\crossbox| as follows, explicitely -% using the public variable |\g_nicematrix_code_before_tl|. -% -% \begin{scope} -% \fvset{commandchars=\§\¤\μ} -% \begin{Verbatim} -% \ExplSyntaxOn -% \cs_new_protected:Nn \__pantigny_crossbox:nnn -% { -% \tikz \draw [ #3 ] -% ( #1 -| \int_eval:n { #2 + 1 } ) -- ( \int_eval:n { #1 + 1 } -| #2 ) -% ( #1 -| #2 ) -- ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ; -% } -% -% \NewDocumentCommand \crossbox { ! O { } } -% { -% \tl_gput_right:Nx §emphase¤\g_nicematrix_code_before_tlμ -% { -% \__pantigny_crossbox:nnn -% { \int_use:c { c@iRow } } -% { \int_use:c { c@jCol } } -% { \exp_not:n { #1 } } -% } -% } -% \ExplSyntaxOff -% \end{Verbatim} -% \end{scope} -% -% -% \ExplSyntaxOn -% \cs_new_protected:Nn \__pantigny_crossbox:nnn -% { -% \tikz \draw [ #3 ] -% ( #1 -| \int_eval:n { #2 + 1 } ) -- ( \int_eval:n { #1 + 1 } -| #2 ) -% ( #1 -| #2 ) -- ( \int_eval:n { #1 + 1 } -| \int_eval:n { #2 + 1 } ) ; -% } -% -% -% \NewDocumentCommand \crossbox { ! O { } } -% { -% \tl_gput_right:Nx \g_nicematrix_code_before_tl -% { -% \__pantigny_crossbox:nnn -% { \int_use:c { c@iRow } } -% { \int_use:c { c@jCol } } -% { \exp_not:n { #1 } } -% } -% } -% \ExplSyntaxOff -% -% \bigskip -% Here is an example of utilisation: -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=9cm] -% \begin{NiceTabular}{ccc}[hvlines] -% \CodeBefore -% \arraycolor{gray!10} -% \Body -% merlan & requin & cabillaud \\ -% baleine & ~emphase#\crossbox[red]@ & morue \\ -% mante & raie & poule -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}{ccc}[hvlines] -% \CodeBefore -% \arraycolor{gray!10} -% \Body -% merlan & requin & cabillaud \\ -% baleine & \crossbox[red] & morue \\ -% mante & raie & poule -% \end{NiceTabular} -% -% -% -% \section{Technical remarks} -% -% First remark: the package \pkg{underscore} must be loaded before -% \pkg{nicematrix}. If it is loaded after, an error will be raised. -% -% \subsection{Diagonal lines} -% -% \label{parallelization} -% By default, all the diagonal lines\footnote{We speak of the lines created by -% |\Ddots| and not the lines created by a command |\line| in the |\CodeAfter|.} of a -% same array are ``parallelized''. That means that the first diagonal line is -% drawn and, then, the other lines are drawn parallel to the first one (by -% rotation around the left-most extremity of the line). That's why the position -% of the instructions |\Ddots| in the array can have a marked effect on the -% final result. -% -% \medskip -% In the following examples, the first |\Ddots| instruction is written in color: -% -% % \medskip -% \begin{scope} -% \begin{minipage}{9.5cm} -% Example with parallelization (default): -% \begin{Verbatim} -% $A = \begin{pNiceMatrix} -% 1 & \Cdots & & 1 \\ -% a+b & ~emphase#\Ddots@~ & & \Vdots \\ -% \Vdots & \Ddots & & \\ -% a+b & \Cdots & a+b & 1 -% \end{pNiceMatrix}$ -% \end{Verbatim} -% \end{minipage} -% $A = \begin{pNiceMatrix} -% 1 & \Cdots & & 1 \\ -% a+b & \Ddots & & \Vdots \\ -% \Vdots & \Ddots & & \\ -% a+b & \Cdots & a+b & 1 -% \end{pNiceMatrix}$ -% -% \bigskip -% \NiceMatrixOptions{parallelize-diags=true}% -% \begin{minipage}{9.5cm} -% % \begin{Verbatim} -% $A = \begin{pNiceMatrix} -% 1 & \Cdots & & 1 \\ -% a+b & & & \Vdots \\ -% \Vdots & ~emphase#\Ddots@~ & \Ddots & \\ -% a+b & \Cdots & a+b & 1 -% \end{pNiceMatrix}$ -% \end{Verbatim} -% \end{minipage} -% $A = \begin{pNiceMatrix} -% 1 & \Cdots & & 1 \\ -% a+b & & & \Vdots \\ -% \Vdots & \Ddots & \Ddots & \\ -% a+b & \Cdots & a+b & 1 -% \end{pNiceMatrix}$ -% -% \bigskip -% It's possible to turn off the parallelization with the option -% |parallelize-diags| set to |false|: \par\nobreak -% -% \medskip -% \NiceMatrixOptions{parallelize-diags=false}% -% \begin{minipage}{9.5cm} -% The same example without parallelization: -% \end{minipage} -% $A = \begin{pNiceMatrix} -% 1 & \Cdots & & 1 \\ -% a+b & \Ddots & & \Vdots \\ -% \Vdots & \Ddots & & \\ -% a+b & \Cdots & a+b & 1 -% \end{pNiceMatrix}$ -% -% \end{scope} -% -% It's possible to specify the instruction |\Ddots| which will be drawn first -% (and which will be used to draw the other diagonal dotted lines when the -% parallelization is in force) with the key |draw-first|: |\Ddots[draw-first]|. -% -% \subsection[The empty cells]{The ``empty'' cells} -% -% \label{empty-cells} -% An instruction like |\Ldots|, |\Cdots|, etc. tries to determine the first -% non-empty cell on both sides. When the key |corners| is used -% (cf.~p.~\pageref{corners}), \pkg{nicematrix} computes corners consisting of -% empty cells. 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~|&|). -% The precise rules are as follow. -% -% \begin{itemize} -% \item An implicit cell is empty. For example, in the following matrix: -% -% \begin{Verbatim} -% \begin{pmatrix} -% a & b \\ -% c \\ -% \end{pmatrix} -% \end{Verbatim} -% -% the last cell (second row and second column) is empty. -% -% \medskip -% \item For the columns of type |p|, |m|, |b|, |V|\footnote{The columns of type -% |V| are provided by \pkg{varwidth}: cf.~p.~\pageref{varwidth}.} and -% |X|\footnote{See p.~\pageref{X-columns}}, the cell is empty if (and only if) -% its content in the TeX code is empty (there is only spaces between the -% ampersands |&|). -% -% \medskip -% \item For the columns of type |c|, |l|, |r| and |w{...}{...}|, the cell is -% empty if (and only if) its TeX output has a width equal to zero. -% -% \medskip -% \item A cell containing the command |\NotEmpty| is not empty (and a PGF/Tikz -% node is created in that cell). -% -% \medskip -% \item A cell with only a command |\Hspace| (or |\Hspace*|) is empty. This -% command |\Hspace| is a command defined by the package \pkg{nicematrix} with -% the same meaning as |\hspace| except that the cell where it is used is -% considered as empty. This command can be used to fix the width of some columns -% of the matrix without interfering with \pkg{nicematrix}. -% \end{itemize} -% -% -% \subsection{The option exterior-arraycolsep} -% -% The environment |{array}| inserts an horizontal space equal to |\arraycolsep| -% before and after each column. In particular, there is a space equal to -% |\arraycolsep| before and after the array. This feature of the environment -% |{array}| was probably not a good idea\footnote{In the documentation of -% \pkg{amsmath}, we can read: {\itshape The extra space of |\arraycolsep| that -% \pkg{array} adds on each side is a waste so we remove it [in |{matrix}|] -% (perhaps we should instead remove it from array in general, but that's a -% harder task).}}. The environment |{matrix}| of -% \pkg{amsmath} and its variants (|{pmatrix}|, |{vmatrix}|, etc.) of -% \pkg{amsmath} prefer to delete these spaces with explicit instructions -% |\hskip -\arraycolsep|\footnote{And not by inserting |@{}| on both sides of the -% preamble of the array. As a consequence, the length of the |\hline| is not -% modified and may appear too long, in particular when using square brackets.}. -% The package \pkg{nicematrix} does the same in all its environments, -% |{NiceArray}| included. However, if the user wants the environment -% |{NiceArray}| behaving by default like the environment |{array}| of -% \pkg{array} (for example, when adapting an existing document) it's possible to -% control this behaviour with the option |exterior-arraycolsep|, set by the -% command |\NiceMatrixOptions|. With this option, exterior spaces of length -% |\arraycolsep| will be inserted in the environments |{NiceArray}| (the other -% environments of \pkg{nicematrix} are not affected). -% -% -% -% -% \subsection{Incompatibilities} -% -% -% The package \pkg{nicematrix} is not compatible with the class \cls{ieeeaccess} -% (because that class is not compatible with PGF/Tikz).\footnote{See -% \url{https://tex.stackexchange.com/questions/528975/error-loading-tikz-in-ieeeaccess-class}} -% -% \bigskip -% In order to use \pkg{nicematrix} with the class \cls{aastex631} -% (of the \emph{American Astronomical Society}), you have to -% add the following lines in the preamble of your document : -% -% \begin{Verbatim} -% \BeforeBegin{NiceTabular}{\let\begin\BeginEnvironment\let\end\EndEnvironment} -% \BeforeBegin{NiceArray}{\let\begin\BeginEnvironment} -% \BeforeBegin{NiceMatrix}{\let\begin\BeginEnvironment} -% \end{Verbatim} -% -% \bigskip -% In order to use \pkg{nicematrix} with the class \cls{sn-jnl} (of -% \emph{Springer Nature}), \pkg{pgf} must -% be loaded before the |\documentclass| with |\RequirePackage|: -% -% \begin{Verbatim} -% \RequirePackage{pgf} -% \documentclass{sn-jnl} -% \end{Verbatim} -% -% \bigskip -% The package \pkg{nicematrix} is not fully compatible with the packages and classes -% of \LuaTeX-ja: the detection of the empty corners (cf. % p.~\pageref{corners}) -% may be wrong in some circonstances. -% -% \bigskip -% The package \pkg{nicematrix} is not fully compatible with the package -% \pkg{arydshln} (because this package redefines many internals of \pkg{array}). -% By any means, in the context of \pkg{nicematrix}, it's recommended to draw -% dashed rules with the tools provided by \pkg{nicematrix}, by creating a -% customized line style with |custom-line|: cf.~p.~\pageref{custom-line}. -% -% \bigskip -% The columns |d| of \pkg{dcolumn} are not supported (but it's possible to use -% the colums |S| of \pkg{siunitx}). -% -% \section{Examples} -% -% \subsection[{Utilisation of the key 'tikz' of the command \textbackslash -% Block}]{Utilisation of the key ``tikz'' of the command \textbackslash Block} -% \label{tikz-key-examples} -% -% -% The key |tikz| of the command |\Block| is available only when Tikz is -% loaded.\footnote{By default, \pkg{nicematrix} only loads \textsc{pgf}, which is -% a sub-layer of Tikz.} -% -% For the following example, we also need the Tikz library |patterns|. -% -% \begin{Verbatim} -% \usetikzlibrary{patterns} -% \end{Verbatim} -% -% -% \begin{Verbatim} -% \ttfamily \small -% \begin{NiceTabular}{X[m]X[m]X[m]}[hvlines,cell-space-limits=3pt] -% \Block[~emphase#tikz={pattern=grid,pattern color=lightgray}@]{} -% {pattern = grid,\\ pattern color = lightgray} -% & \Block[~emphase#tikz={pattern = north west lines,pattern color=blue}@]{} -% {pattern = north west lines,\\ pattern color = blue} -% & \Block[~emphase#tikz={outer color = red!50, inner color=white }@]{2-1} -% {outer color = red!50,\\ inner color = white} \\ -% \Block[~emphase#tikz={pattern = sixpointed stars, pattern color = blue!15}@]{} -% {pattern = sixpointed stars,\\ pattern color = blue!15} -% & \Block[~emphase#tikz={left color = blue!50}@]{} -% {left color = blue!50} \\ -% \end{NiceTabular} -% \end{Verbatim} -% -% \begin{center} -% \ttfamily \small -% \begin{NiceTabular}{X[m]X[m]X[m]}[hvlines,cell-space-limits=3pt] -% \Block[tikz={pattern=grid,pattern color=lightgray}]{} -% {pattern = grid,\\ pattern color = lightgray} -% & \Block[tikz={pattern = north west lines,pattern color=blue}]{} -% {pattern = north west lines,\\ pattern color = blue} -% & \Block[tikz={outer color = red!50, inner color=white }]{2-1} -% {outer color = red!50,\\ inner color = white} \\ -% \Block[tikz={pattern = sixpointed stars, pattern color = blue!15}]{} -% {pattern = sixpointed stars,\\ pattern color = blue!15} -% & \Block[tikz={left color = blue!50}]{} -% {left color = blue!50} \\ -% \end{NiceTabular} -% \end{center} -% -% \bigskip -% In the following example, we use the key |tikz| to hatch a row of the tabular. -% Remark that you use the key |transparent| of the command |\Block| in order to -% have the rules drawn in the block.\footnote{By default, the rules are not -% drawn in the blocks created by the command |\Block|: cf.~section~\ref{rules} -% p.~\pageref{rules}} -% -% \begin{Verbatim} -% \begin{NiceTabular}{ccc}[hvlines] -% \CodeBefore -% \columncolor[RGB]{169,208,142}{2} -% \Body -% one & two & three \\ -% \Block[~emphase#transparent, tikz={pattern = north west lines, pattern color = gray}@]{1-*}{} -% four & five & six \\ -% seven & eight & nine -% \end{Verbatim} -% -% \begin{center} -% \begin{NiceTabular}{ccc}[hvlines] -% \CodeBefore -% \columncolor[RGB]{169,208,142}{2} -% \Body -% one & two & three \\ -% \Block[transparent, tikz={pattern = north west lines, pattern color = gray}]{1-*}{} -% four & five & six \\ -% seven & eight & nine -% \end{NiceTabular} -% \end{center} -% -% \subsection{Use with tcolorbox} -% -% \label{tcolorbox} -% -% Here is an example of use of |{NiceTabular}| within a command |\tcbox| of -% \pkg{tcolorbox}. We have used the key |hvlines-except-borders| in order all -% the rules excepted on the borders (which are, of course, added by \pkg{tcolorbox}) -% -% \medskip -% \begin{BVerbatim} -% \tcbset -% { -% colframe = blue!50!black , -% colback = white , -% colupper = red!50!black , -% fonttitle = \bfseries , -% nobeforeafter , -% center title -% } -% -% \tcbox -% [ -% left = 0mm , -% right = 0mm , -% top = 0mm , -% bottom = 0mm , -% boxsep = 0mm , -% toptitle = 0.5mm , -% bottomtitle = 0.5mm , -% title = My table -% ] -% { -% \renewcommand{\arraystretch}{1.2}% <-- the % is mandatory here -% \begin{NiceTabular}{rcl}[~emphase#hvlines-except-borders@,rules/color=blue!50!black] -% \CodeBefore -% \rowcolor{red!15}{1} -% \Body -% One & Two & Three \\ -% Men & Mice & Lions \\ -% Upper & Middle & Lower -% \end{NiceTabular} -% } -% \end{BVerbatim} -% -% \medskip -% \begin{center} -% \tcbset -% { -% colframe = blue!50!black , -% colback = white , -% colupper = red!50!black , -% fonttitle = \bfseries , -% nobeforeafter , -% center title -% } -% -% \tcbox -% [ -% left = 0mm , -% right = 0mm , -% top = 0mm , -% bottom = 0mm , -% boxsep = 0mm , -% toptitle = 0.5mm , -% bottomtitle = 0.5mm , -% title = My table -% ] -% { -% \renewcommand{\arraystretch}{1.2}\begin{NiceTabular}{rcl}[hvlines-except-borders,rules/color=blue!50!black] -% \CodeBefore -% \rowcolor{red!15}{1} -% \Body -% One & Two & Three \\ -% Men & Mice & Lions \\ -% Upper & Middle & Lower -% \end{NiceTabular} -% } -% \end{center} -% -% -% -% \vspace{1cm} -% That example shows the use of \pkg{nicematrix} in conjunction with -% \pkg{tcolorbox}. If one wishes a tabular with an exterior frame with rounded -% corners, it's not necessary to use \pkg{tcolorbox}: it's possible to use the -% command |\Block| with the key |rounded-corners|. -% -% \medskip -% \begin{BVerbatim}[baseline=c,boxwidth=10.5cm] -% \begin{NiceTabular}{rcl}[hvlines-except-borders] -% \Block[draw,transparent,~emphase#rounded-corners@]{*-*}{} -% One & Two & Three \\ -% Men & Mice & Lions \\ -% Upper & Middle & Lower -% \end{NiceTabular} -% \end{BVerbatim} -% \begin{NiceTabular}{rcl}[hvlines-except-borders] -% \Block[draw,transparent,rounded-corners]{*-*}{} -% One & Two & Three \\ -% Men & Mice & Lions \\ -% Upper & Middle & Lower -% \end{NiceTabular} -% -% \medskip -% We have used the key |transparent| to have the rules specified by -% |hvlines-except-borders| drawn in the blocks (by default, the rules are not -% drawn in the blocks). -% -% \subsection{Notes in the tabulars} -% -% \label{ex:notes} -% -% The tools provided by \pkg{nicematrix} for the composition of the tabular -% notes have been presented in the section \ref{s:notes} p.~\pageref{s:notes}. -% -% \medskip -% Let's consider that we wish to number the notes of a tabular with -% stars.\footnote{Of course, it's realistic only when there is very few notes in -% the tabular.} -% -% \medskip -% First, we write a command |\stars| similar the well-known commands -% |\arabic|, |\alph|, |\Alph|, etc. which produces a number of stars equal to -% its argument\footnote{In fact: the value of its argument.}. -% \begin{Verbatim} -% \ExplSyntaxOn -% \NewDocumentCommand ~emphase#\stars@ { m } -% { \prg_replicate:nn { \value { ~#1 } } { $ \star $ } } -% \ExplSyntaxOff -% \end{Verbatim} -% % -% Of course, we change the style of the labels with the key |notes/style|. -% However, it would be interesting to change also some parameters in the type of -% list used to compose the notes at the end of the tabular. -% First, we required a composition flush right for the labels with the setting -% |align=right|. -% Moreover, we want the labels to be composed on a width equal to the width of -% the widest label. The widest label is, of course, the label with the greatest -% number of stars. We know that number: it is equal to |\value{tabularnote}| -% (because |tabularnote| is the LaTeX counter used by |\tabularnote| and, -% therefore, at the end of the tabular, its value is equal to the total number -% of tabular notes). We use the key |widest*| of \pkg{enumitem} in order to -% require a width equal to that value: |widest*=\value{tabularnote}|. -% \begin{Verbatim} -% \NiceMatrixOptions -% { -% notes = -% { -% ~emphase#style = \stars{~#1} , @ -% ~emphase#enumitem-keys = @ -% ~emphase# { @ -% ~emphase# widest* = \value{tabularnote} ,@ -% ~emphase# align = right @ -% ~emphase# } @ -% } -% } -% \end{Verbatim} -% -% -% -% \begin{scope} -% \ExplSyntaxOn -% \NewDocumentCommand \stars { m } -% { \prg_replicate:nn { \value { #1 } } { $ \star $ } } -% \NiceMatrixOptions -% { -% notes = -% { -% style = \stars{#1} , -% enumitem-keys = -% { -% widest* = \value{tabularnote} , -% align = right -% } -% } -% } -% \ExplSyntaxOff -% \begin{Verbatim} -% \begin{NiceTabular}{~@{}llr~@{}} -% \toprule \RowStyle{\bfseries} -% Last name & First name & Birth day \\ -% \midrule -% Achard\tabularnote{~emphase#Achard is an old family of the Poitou.@} -% & Jacques & 5 juin 1962 \\ -% Lefebvre\tabularnote{~emphase#The name Lefebvre is an alteration of the name Lefebure.@} -% & Mathilde & 23 mai 1988 \\ -% Vanesse & Stephany & 30 octobre 1994 \\ -% Dupont & Chantal & 15 janvier 1998 \\ -% \bottomrule -% \end{NiceTabular} -% \end{Verbatim} -% -% \begin{center} -% \begin{NiceTabular}{@{}llr@{}} -% \toprule \RowStyle{\bfseries} -% Last name & First name & Birth day \\ -% \midrule -% Achard\tabularnote{Achard is an old family of the Poitou.} -% & Jacques & June 5, 2005 \\ -% Lefebvre\tabularnote{The name Lefebvre is an alteration of the name Lefebure.} -% & Mathilde & January 23, 1975 \\ -% Vanesse & Stephany & October 30, 1994 \\ -% Dupont & Chantal & January 15, 1998 \\ -% \bottomrule -% \end{NiceTabular} -% \end{center} -% \end{scope} -% -% -% -% \subsection{Dotted lines} -% -% An example with the resultant of two polynoms:\par\nobreak -% -% \bigskip -% \begin{BVerbatim} -% \setlength{\extrarowheight}{1mm} -% \[\begin{vNiceArray}{cccc:ccc}[columns-width=6mm] -% a_0 & && &b_0 & & \\ -% a_1 &\Ddots&& &b_1 &\Ddots& \\ -% \Vdots&\Ddots&& &\Vdots &\Ddots&b_0 \\ -% a_p & &&a_0 & & &b_1 \\ -% &\Ddots&&a_1 &b_q & &\Vdots\\ -% & &&\Vdots & &\Ddots& \\ -% & &&a_p & & &b_q -% \end{vNiceArray}\] -% \end{BVerbatim} -% -% \bigskip -% -% \begin{scope} -% \setlength{\extrarowheight}{1mm} -% \[\begin{vNiceArray}{cccc:ccc}[columns-width=6mm] -% a_0 & && &b_0 & & \\ -% a_1 &\Ddots&& &b_1 &\Ddots& \\ -% \Vdots&\Ddots&& &\Vdots &\Ddots&b_0 \\ -% a_p & &&a_0 & & &b_1 \\ -% &\Ddots&&a_1 &b_q & &\Vdots\\ -% & &&\Vdots & &\Ddots& \\ -% & &&a_p & & &b_q -% \end{vNiceArray}\] -% \end{scope} -% -% \vspace{2cm} -% An example for a linear system:\par\nobreak -% -% \begin{Verbatim} -% $\begin{pNiceArray}{*6c|c}[nullify-dots,last-col,code-for-last-col=\scriptstyle] -% 1 & 1 & 1 &\Cdots & & 1 & 0 & \\ -% 0 & 1 & 0 &\Cdots & & 0 & & L_2 \gets L_2-L_1 \\ -% 0 & 0 & 1 &\Ddots & & \Vdots & & L_3 \gets L_3-L_1 \\ -% & & &\Ddots & & & \Vdots & \Vdots \\ -% \Vdots & & &\Ddots & & 0 & \\ -% 0 & & &\Cdots & 0 & 1 & 0 & L_n \gets L_n-L_1 -% \end{pNiceArray}$ -% \end{Verbatim} -% -% -% \[\begin{pNiceArray}{*6c|c}[nullify-dots,last-col,code-for-last-col=\scriptstyle] -% 1 & 1 & 1 &\Cdots & & 1 & 0 & \\ -% 0 & 1 & 0 &\Cdots & & 0 & & L_2 \gets L_2-L_1 \\ -% 0 & 0 & 1 &\Ddots & & \Vdots & & L_3 \gets L_3-L_1 \\ -% & & &\Ddots & & & \Vdots & \Vdots \\ -% \Vdots & & &\Ddots & & 0 & \\ -% 0 & & &\Cdots & 0 & 1 & 0 & L_n \gets L_n-L_1 -% \end{pNiceArray}\] -% -% -% -% \subsection{Dotted lines which are no longer dotted} -% -% The option |line-style| controls the style of the lines drawn by |\Ldots|, -% |\Cdots|, etc. Thus, it's possible with these commands to draw lines which are -% not longer dotted. -% -% -% \begin{Verbatim}[formatcom=\small\color{gray}] -% \NiceMatrixOptions{code-for-first-row = \scriptstyle,code-for-first-col = \scriptstyle } -% \setcounter{MaxMatrixCols}{12} -% \newcommand{\blue}{\color{blue}} -% \[\begin{pNiceMatrix}[last-row,last-col,nullify-dots,xdots/line-style={dashed,blue}] -% 1& & & \Vdots & & & & \Vdots \\ -% & \Ddots[line-style=standard] \\ -% & & 1 \\ -% \Cdots[color=blue,line-style=dashed]& & & \blue 0 & -% \Cdots & & & \blue 1 & & & \Cdots & \blue \leftarrow i \\ -% & & & & 1 \\ -% & & &\Vdots & & \Ddots[line-style=standard] & & \Vdots \\ -% & & & & & & 1 \\ -% \Cdots & & & \blue 1 & \Cdots & & \Cdots & \blue 0 & & & \Cdots & \blue \leftarrow j \\ -% & & & & & & & & 1 \\ -% & & & & & & & & & \Ddots[line-style=standard] \\ -% & & & \Vdots & & & & \Vdots & & & 1 \\ -% & & & \blue \overset{\uparrow}{i} & & & & \blue \overset{\uparrow}{j} \\ -% \end{pNiceMatrix}\] -% \end{Verbatim} -% -% -% \begin{scope} -% \NiceMatrixOptions{code-for-first-row = \scriptstyle,code-for-first-col = \scriptstyle } -% \setcounter{MaxMatrixCols}{12} -% \newcommand{\blue}{\color{blue}} -% \[\begin{pNiceMatrix}[last-row,last-col,nullify-dots,xdots/line-style={dashed,blue}] -% 1& & & \Vdots & & & & \Vdots \\ -% & \Ddots[line-style=standard] \\ -% & & 1 \\ -% \Cdots[color=blue,line-style=dashed]& & & \blue 0 & -% \Cdots & & & \blue 1 & & & \Cdots & \blue \leftarrow i \\ -% & & & & 1 \\ -% & & &\Vdots & & \Ddots[line-style=standard] & & \Vdots \\ -% & & & & & & 1 \\ -% \Cdots & & & \blue 1 & \Cdots & & \Cdots & \blue 0 & & & \Cdots & \blue \leftarrow j \\ -% & & & & & & & & 1 \\ -% & & & & & & & & & \Ddots[line-style=standard] \\ -% & & & \Vdots & & & & \Vdots & & & 1 \\ -% & & & \blue \overset{\uparrow}{i} & & & & \blue \overset{\uparrow}{j} \\ -% \end{pNiceMatrix}\] -% \end{scope} -% -% \interitem -% In fact, it's even possible to draw solid lines with the commands |\Cdots|, -% |\Vdots|, etc.\footnote{In this document, the Tikz library \pkg{arrows.meta} -% has been loaded, which impacts the shape of the arrow tips.} -% -% \begin{Verbatim} -% \NiceMatrixOptions -% {nullify-dots,code-for-first-col = \color{blue},code-for-first-row=\color{blue}} -% $\begin{pNiceMatrix}[first-row,first-col] -% & & \Ldots[line-style={solid,<->},shorten=0pt]^{n \text{ columns}} \\ -% & 1 & 1 & 1 & \Ldots & 1 \\ -% & 1 & 1 & 1 & & 1 \\ -% \Vdots[line-style={solid,<->}]_{n \text{ rows}} & 1 & 1 & 1 & & 1 \\ -% & 1 & 1 & 1 & & 1 \\ -% & 1 & 1 & 1 & \Ldots & 1 -% \end{pNiceMatrix}$ -% \end{Verbatim} -% -% -% \begin{scope} -% \NiceMatrixOptions -% {nullify-dots,code-for-first-col = \color{blue},code-for-first-row=\color{blue}} -% \[\begin{pNiceMatrix}[first-row,first-col] -% & & \Ldots[line-style={solid,<->},shorten=0pt]^{n \text{ columns}} \\ -% & 1 & 1 & 1 & \Ldots & 1 \\ -% & 1 & 1 & 1 & & 1 \\ -% \Vdots[line-style={solid,<->}]_{n \text{ rows}} & 1 & 1 & 1 & & 1 \\ -% & 1 & 1 & 1 & & 1 \\ -% & 1 & 1 & 1 & \Ldots & 1 -% \end{pNiceMatrix}\] -% \end{scope} -% -% \subsection{Dashed rules} -% \label{dashed} -% -% In the following example, we use the command |\Block| to draw dashed rules. -% For that example, Tikz should be loaded (by |\usepackage{tikz}|). -% -% -% \begin{Verbatim} -% \begin{pNiceMatrix} -% ~emphase#\Block[borders={bottom,right,tikz=dashed}]{2-2}{}@ -% 1 & 2 & 0 & 0 & 0 & 0 \\ -% 4 & 5 & 0 & 0 & 0 & 0 \\ -% 0 & 0 & ~emphase#\Block[borders={bottom,top,right,left,tikz=dashed}]{2-2}{}@ -% 7 & 1 & 0 & 0 \\ -% 0 & 0 & -1 & 2 & 0 & 0 \\ -% 0 & 0 & 0 & 0 & ~emphase#\Block[borders={left,top,tikz=dashed}]{2-2}{}@ -% 3 & 4 \\ -% 0 & 0 & 0 & 0 & 1 & 4 -% \end{pNiceMatrix} -% \end{Verbatim} -% -% -% \[\begin{pNiceMatrix} -% \Block[borders={bottom,right,tikz=dashed}]{2-2}{} -% 1 & 2 & 0 & 0 & 0 & 0 \\ -% 4 & 5 & 0 & 0 & 0 & 0 \\ -% 0 & 0 & \Block[borders={bottom,top,right,left,tikz=dashed}]{2-2}{} -% 7 & 1 & 0 & 0 \\ -% 0 & 0 & -1 & 2 & 0 & 0 \\ -% 0 & 0 & 0 & 0 & \Block[borders={left,top,tikz=dashed}]{2-2}{} -% 3 & 4 \\ -% 0 & 0 & 0 & 0 & 1 & 4 -% \end{pNiceMatrix}\] -% -% -% \subsection{Stacks of matrices} -% -% We often need to compose mathematical matrices on top on each other (for -% example for the resolution of linear systems). -% -% \medskip -% In order to have the columns aligned one above the other, it's possible to -% fix a width for all the columns. That's what is done in the following example -% with the environment |{NiceMatrixBlock}| and its option |auto-columns-width|. -% -% \begin{Verbatim}[formatcom=\small\color{gray}] -% ~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@ -% \NiceMatrixOptions -% { -% light-syntax, -% last-col, code-for-last-col = \color{blue} \scriptstyle, -% } -% \setlength{\extrarowheight}{1mm} -% -% $\begin{pNiceArray}{rrrr|r} -% 12 -8 7 5 3 {} ; -% 3 -18 12 1 4 ; -% -3 -46 29 -2 -15 ; -% 9 10 -5 4 7 -% \end{pNiceArray}$ -% -% \smallskip -% $\begin{pNiceArray}{rrrr|r} -% 12 -8 7 5 3 ; -% 0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ; -% 0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ; -% 0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ; -% \end{pNiceArray}$ -% -% \smallskip -% $\begin{pNiceArray}{rrrr|r} -% 12 -8 7 5 3 ; -% 0 64 -41 1 19 ; -% 0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 } -% \end{pNiceArray}$ -% -% \smallskip -% $\begin{pNiceArray}{rrrr|r} -% 12 -8 7 5 3 {} ; -% 0 64 -41 1 19 ; -% \end{pNiceArray}$ -% -% ~emphase#\end{NiceMatrixBlock}@ -% \end{Verbatim} -% -% \bigskip -% \begin{NiceMatrixBlock}[auto-columns-width] -% \NiceMatrixOptions -% { -% light-syntax, -% last-col, code-for-last-col = \color{blue} \scriptstyle , -% } -% \setlength{\extrarowheight}{1mm} -% -% \quad $\begin{pNiceArray}{rrrr|r} -% 12 -8 7 5 3 {} ; -% 3 -18 12 1 4 ; -% -3 -46 29 -2 -15 ; -% 9 10 -5 4 7 -% \end{pNiceArray}$ -% -% \smallskip -% \quad $\begin{pNiceArray}{rrrr|r} -% 12 -8 7 5 3 ; -% 0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ; -% 0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ; -% 0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ; -% \end{pNiceArray}$ -% -% \smallskip -% \quad $\begin{pNiceArray}{rrrr|r} -% 12 -8 7 5 3 ; -% 0 64 -41 1 19 ; -% 0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 } -% \end{pNiceArray}$\par\nobreak -% -% \smallskip -% \quad $\begin{pNiceArray}{rrrr|r} -% 12 -8 7 5 3 {} ; -% 0 64 -41 1 19 ; -% \end{pNiceArray}$ -% \end{NiceMatrixBlock} -% -% \bigskip -% However, one can see that the last matrix is not perfectly aligned with -% others. That's why, in LaTeX, the parenthesis have not exactly the same width -% (smaller parenthesis are a bit slimer). -% -% \medskip -% In order the solve that problem, it's possible to require the delimiters to be -% composed with the maximal width, thanks to the boolean key -% |delimiters/max-width|. -% -% \begin{Verbatim}[formatcom=\small\color{gray}] -% ~emphase#\begin{NiceMatrixBlock}[auto-columns-width]@ -% \NiceMatrixOptions -% { -% ~emphase#delimiters/max-width@, -% light-syntax, -% last-col, code-for-last-col = \color{blue}\scriptstyle, -% } -% \setlength{\extrarowheight}{1mm} -% -% $\begin{pNiceArray}{rrrr|r} -% 12 -8 7 5 3 {} ; -% 3 -18 12 1 4 ; -% -3 -46 29 -2 -15 ; -% 9 10 -5 4 7 -% \end{pNiceArray}$ -% -% ... -% ~emphase#\end{NiceMatrixBlock}@ -% \end{Verbatim} -% -% \bigskip -% \begin{NiceMatrixBlock}[auto-columns-width] -% \NiceMatrixOptions -% { -% delimiters/max-width, -% light-syntax, -% last-col, code-for-last-col = \color{blue}\scriptstyle, -% } -% \setlength{\extrarowheight}{1mm} -% -% \quad $\begin{pNiceArray}{rrrr|r} -% 12 -8 7 5 3 {} ; -% 3 -18 12 1 4 ; -% -3 -46 29 -2 -15 ; -% 9 10 -5 4 7 -% \end{pNiceArray}$ -% -% \smallskip -% \quad $\begin{pNiceArray}{rrrr|r} -% 12 -8 7 5 3 ; -% 0 64 -41 1 19 { L_2 \gets L_1-4L_2 } ; -% 0 -192 123 -3 -57 { L_3 \gets L_1+4L_3 } ; -% 0 -64 41 -1 -19 { L_4 \gets 3L_1-4L_4 } ; -% \end{pNiceArray}$ -% -% \smallskip -% \quad $\begin{pNiceArray}{rrrr|r} -% 12 -8 7 5 3 ; -% 0 64 -41 1 19 ; -% 0 0 0 0 0 { L_3 \gets 3 L_2 + L_3 } -% \end{pNiceArray}$\par\nobreak -% -% \smallskip -% \quad $\begin{pNiceArray}{rrrr|r} -% 12 -8 7 5 3 {} ; -% 0 64 -41 1 19 ; -% \end{pNiceArray}$ -% -% \end{NiceMatrixBlock} -% -% -% \interitem -% If you wish an alignment of the different matrices without the same width -% for all the columns, you can construct a unique array and place the -% parenthesis with commands |\SubMatrix| in the |\CodeAfter|. Of course, that -% array can't be broken by a page break. -% -% \medskip -% \begin{Verbatim} -% \setlength{\extrarowheight}{1mm} -% \[\begin{NiceMatrix}[ r, last-col=6, code-for-last-col = \scriptstyle \color{blue} ] -% 12 & -8 & 7 & 5 & 3 \\ -% 3 & -18 & 12 & 1 & 4 \\ -% -3 & -46 & 29 &-2 &-15 \\ -% 9 & 10 &-5 &4 & 7 \\[1mm] -% 12 & -8 & 7 &5 & 3 \\ -% 0 & 64 &-41 & 1 & 19 & L_2 \gets L_1-4L_2 \\ -% 0 & -192 &123 &-3 &-57 & L_3 \gets L_1+4L_3 \\ -% 0 & -64 & 41 &-1 &-19 & L_4 \gets 3L_1-4L_4 \\[1mm] -% 12 & -8 &7 &5 & 3 \\ -% 0 & 64 &-41 &1 &19 \\ -% 0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm] -% 12 & -8 &7 &5 & 3 \\ -% 0 & 64 &-41 & 1 & 19 \\ -% ~emphase#\CodeAfter [sub-matrix/vlines=4]@ -% ~emphase# \SubMatrix({1-1}{4-5})@ -% ~emphase# \SubMatrix({5-1}{8-5})@ -% ~emphase# \SubMatrix({9-1}{11-5})@ -% ~emphase# \SubMatrix({12-1}{13-5})@ -% \end{NiceMatrix}\] -% \end{Verbatim} -% -% \medskip -% \begin{scope} -% \setlength{\extrarowheight}{1mm} -% \[\begin{NiceMatrix}[ r, last-col=6, code-for-last-col = \scriptstyle \color{blue} ] -% 12 & -8 & 7 & 5 & 3 \\ -% 3 & -18 & 12 & 1 & 4 \\ -% -3 & -46 & 29 &-2 &-15 \\ -% 9 & 10 &-5 &4 & 7 \\[1mm] -% 12 & -8 & 7 &5 & 3 \\ -% 0 & 64 &-41 & 1 & 19 & L_2 \gets L_1-4L_2 \\ -% 0 & -192 &123 &-3 &-57 & L_3 \gets L_1+4L_3 \\ -% 0 & -64 & 41 &-1 &-19 & L_4 \gets 3L_1-4L_4 \\[1mm] -% 12 & -8 &7 &5 & 3 \\ -% 0 & 64 &-41 &1 &19 \\ -% 0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm] -% 12 & -8 &7 &5 & 3 \\ -% 0 & 64 &-41 & 1 & 19 \\ -% \CodeAfter [sub-matrix/vlines=4] -% \SubMatrix({1-1}{4-5}) -% \SubMatrix({5-1}{8-5}) -% \SubMatrix({9-1}{11-5}) -% \SubMatrix({12-1}{13-5}) -% \end{NiceMatrix}\] -% \end{scope} -% -% \bigskip -% In this tabular, the instructions |\SubMatrix| are executed after the -% composition of the tabular and, thus, the vertical rules are drawn without -% adding space between the columns. -% -% -%\bigskip -% In fact, it's possible, with the key |vlines-in-sub-matrix|, to choice a -% letter in the preamble of the array to specify vertical rules which will be -% drawn in the |\SubMatrix| only (by adding space between the columns). -% -% \medskip -% \begin{Verbatim} -% \setlength{\extrarowheight}{1mm} -% \[\begin{NiceArray} -% [ -% ~emphase#vlines-in-sub-matrix=I@, -% last-col, -% code-for-last-col = \scriptstyle \color{blue} -% ] -% {rrrrIr} -% 12 & -8 & 7 & 5 & 3 \\ -% 3 & -18 & 12 & 1 & 4 \\ -% -3 & -46 & 29 &-2 &-15 \\ -% 9 & 10 &-5 &4 & 7 \\[1mm] -% 12 & -8 & 7 &5 & 3 \\ -% 0 & 64 &-41 & 1 & 19 & L_2 \gets L_1-4L_2 \\ -% 0 & -192 &123 &-3 &-57 & L_3 \gets L_1+4L_3 \\ -% 0 & -64 & 41 &-1 &-19 & L_4 \gets 3L_1-4L_4 \\[1mm] -% 12 & -8 &7 &5 & 3 \\ -% 0 & 64 &-41 &1 &19 \\ -% 0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm] -% 12 & -8 &7 &5 & 3 \\ -% 0 & 64 &-41 & 1 & 19 \\ -% \CodeAfter -% \SubMatrix({1-1}{4-5}) -% \SubMatrix({5-1}{8-5}) -% \SubMatrix({9-1}{11-5}) -% \SubMatrix({12-1}{13-5}) -% \end{NiceArray}\] -% \end{Verbatim} -% -% -% \medskip -% \begin{scope} -% \setlength{\extrarowheight}{1mm} -% \[\begin{NiceArray} -% [ -% vlines-in-sub-matrix=I, -% last-col, -% code-for-last-col = \scriptstyle \color{blue} -% ] -% {rrrrIr} -% 12 & -8 & 7 & 5 & 3 \\ -% 3 & -18 & 12 & 1 & 4 \\ -% -3 & -46 & 29 &-2 &-15 \\ -% 9 & 10 &-5 &4 & 7 \\[1mm] -% 12 & -8 & 7 &5 & 3 \\ -% 0 & 64 &-41 & 1 & 19 & L_2 \gets L_1-4L_2 \\ -% 0 & -192 &123 &-3 &-57 & L_3 \gets L_1+4L_3 \\ -% 0 & -64 & 41 &-1 &-19 & L_4 \gets 3L_1-4L_4 \\[1mm] -% 12 & -8 &7 &5 & 3 \\ -% 0 & 64 &-41 &1 &19 \\ -% 0 & 0 &0 &0 & 0 & L_3 \gets 3L_2+L_3 \\[1mm] -% 12 & -8 &7 &5 & 3 \\ -% 0 & 64 &-41 & 1 & 19 \\ -% \CodeAfter -% \SubMatrix({1-1}{4-5}) -% \SubMatrix({5-1}{8-5}) -% \SubMatrix({9-1}{11-5}) -% \SubMatrix({12-1}{13-5}) -% \end{NiceArray}\] -% \end{scope} -% -% -% -% -% -% \subsection{How to highlight cells of a matrix} -% -% -% \label{highlight} -% -% \medskip -% In order to highlight a cell of a matrix, it's possible to ``draw'' that cell -% with the key |draw| of the command |\Block| (this is one of the uses of a -% mono-cell block\footnote{We recall that, if the first mandatory argument of -% the command |\Block| is left empty, that means that the block is a mono-cell block}). -% -% \label{example-CodeAfter} -% -% -% \begin{Verbatim} -% $\begin{pNiceArray}{>{\strut}cccc}[margin,rules/color=blue] -% ~emphase#\Block[draw]{}{a_{11}}@ & a_{12} & a_{13} & a_{14} \\ -% a_{21} & \Block[draw]{}{a_{22}} & a_{23} & a_{24} \\ -% a_{31} & a_{32} & \Block[draw]{}{a_{33}} & a_{34} \\ -% a_{41} & a_{42} & a_{43} & \Block[draw]{}{a_{44}} \\ -% \end{pNiceArray}$ -% \end{Verbatim} -% \[\begin{pNiceArray}{>{\strut}cccc}[margin,rules/color=blue] -% \Block[draw]{}{a_{11}} & a_{12} & a_{13} & a_{14} \\ -% a_{21} & \Block[draw]{}{a_{22}} & a_{23} & a_{24} \\ -% a_{31} & a_{32} & \Block[draw]{}{a_{33}} & a_{34} \\ -% a_{41} & a_{42} & a_{43} & \Block[draw]{}{a_{44}} \\ -% \end{pNiceArray}\] -% -% We should remark that the rules we have drawn are drawn \emph{after} the -% construction of the array and thus, they don't spread the cells of the array. -% We recall that, on the other side, the commands |\hline| and |\Hline|, the -% specifier ``"|"'' and the options |hlines|, |vlines|, |hvlines| and -% |hvlines-except-borders| spread the cells.\footnote{For the command |\cline|, -% see the remark p.~\pageref{remark-cline}.} -% -% -% \vspace{1cm} -% It's possible to color a row with |\rowcolor| in the |code-before| (or with -% |\rowcolor| in the first cell of the row if the key |colortbl-like| is -% used−even when \pkg{colortbl} is not loaded). -% -% \medskip -% \begin{Verbatim} -% \begin{pNiceArray}{>{\strut}cccc}[margin, extra-margin=2pt,colortbl-like] -% ~emphase#\rowcolor{red!15}@A_{11} & A_{12} & A_{13} & A_{14} \\ -% A_{21} & ~emphase#\rowcolor{red!15}@A_{22} & A_{23} & A_{24} \\ -% A_{31} & A_{32} & ~emphase#\rowcolor{red!15}@A_{33} & A_{34} \\ -% A_{41} & A_{42} & A_{43} & ~emphase#\rowcolor{red!15}@A_{44} -% \end{pNiceArray} -% \end{Verbatim} -% -% -% -% \[\begin{pNiceArray}{>{\strut}cccc}[margin, extra-margin=2pt,colortbl-like] -% \rowcolor{red!15}A_{11} & A_{12} & A_{13} & A_{14} \\ -% A_{21} & \rowcolor{red!15}A_{22} & A_{23} & A_{24} \\ -% A_{31} & A_{32} & \rowcolor{red!15}A_{33} & A_{34} \\ -% A_{41} & A_{42} & A_{43} & \rowcolor{red!15}A_{44} -% \end{pNiceArray}\] -% -% \bigskip -% However, it's not possible to do a fine tuning. That's why we describe now a -% method to highlight a row of the matrix. -% -% \medskip -% That example and the following ones require Tikz (by default, \pkg{nicematrix} -% only loads \textsc{pgf}, which is a sub-layer of Tikz) and the Tikz library -% |fit|. The following lines in the preamble of your document do the job: -% \begin{verbatim} -% \usepackage{tikz} -% \usetikzlibrary{fit} -% \end{verbatim} -% -% \medskip -% We create a rectangular Tikz node which encompasses the nodes of the second -% row by using the tools of the Tikz library \pkg{fit}. Those nodes are not -% available by default in the |\CodeBefore| (for efficiency). We have to require -% their creation with the key |create-cell-nodes| of the keyword |\CodeBefore|. -% -% \tikzset{highlight/.style={rectangle, -% fill=red!15, -% rounded corners = 0.5 mm, -% inner sep=1pt, -% fit = #1}} -% -% \medskip -% \begin{Verbatim} -% \tikzset{highlight/.style={rectangle, -% fill=red!15, -% rounded corners = 0.5 mm, -% inner sep=1pt, -% fit=~#1}} -% -% $\begin{bNiceMatrix} -% ~emphase#\CodeBefore [create-cell-nodes] @ -% ~emphase# \tikz \node [highlight = (2-1) (2-3)] {} ; @ -% ~emphase# \Body @ -% 0 & \Cdots & 0 \\ -% 1 & \Cdots & 1 \\ -% 0 & \Cdots & 0 \\ -% \end{bNiceMatrix}$ -% \end{Verbatim} -% \[\begin{bNiceMatrix} -% \CodeBefore [create-cell-nodes] -% \tikz \node [highlight = (2-1) (2-3)] {} ; -% \Body -% 0 & \Cdots & 0 \\ -% 1 & \Cdots & 1 \\ -% 0 & \Cdots & 0 \\ -% \end{bNiceMatrix}\] -% -% -% \vspace{1cm} -% We consider now the following matrix. If we want to highlight each row of -% this matrix, we can use the previous technique three times. -% -% \begin{Verbatim} -% \[\begin{pNiceArray}{ccc}[last-col, margin = 2pt] -% \CodeBefore [create-cell-nodes] -% \begin{tikzpicture} -% ~emphase# \node [highlight = (1-1) (1-3)] {} ;@ -% ~emphase# \node [highlight = (2-1) (2-3)] {} ;@ -% ~emphase# \node [highlight = (3-1) (3-3)] {} ;@ -% \end{tikzpicture} -% \Body -% a & a + b & a + b + c & L_1 \\ -% a & a & a + b & L_2 \\ -% a & a & a & L_3 -% \end{pNiceArray}\] -% \end{Verbatim} -% -% -% \[\begin{pNiceArray}{ccc}[last-col, margin = 2pt] -% \CodeBefore [create-cell-nodes] -% \begin{tikzpicture} -% \node [highlight = (1-1) (1-3)] {} ; -% \node [highlight = (2-1) (2-3)] {} ; -% \node [highlight = (3-1) (3-3)] {} ; -% \end{tikzpicture} -% \Body -% a & a + b & a + b + c & L_1 \\ -% a & a & a + b & L_2 \\ -% a & a & a & L_3 -% \end{pNiceArray}\] -% -% \medskip -% The result may seem disappointing. We can improve it by using the ``medium -% nodes'' instead of the ``normal nodes''. -% -% \begin{Verbatim} -% \[\begin{pNiceArray}{ccc}[last-col, margin = 2pt, create-medium-nodes] -% \CodeBefore [create-cell-nodes] -% \begin{tikzpicture} ~emphase#[name suffix = -medium]@ -% \node [highlight = (1-1) (1-3)] {} ; -% \node [highlight = (2-1) (2-3)] {} ; -% \node [highlight = (3-1) (3-3)] {} ; -% \end{tikzpicture} -% \Body -% a & a + b & a + b + c & L_1 \\ -% a & a & a + b & L_2 \\ -% a & a & a & L_3 -% \end{pNiceArray}\] -% \end{Verbatim} -% -% -%\[\begin{pNiceArray}{ccc}[last-col, margin = 2pt, create-medium-nodes] -% \CodeBefore [create-cell-nodes] -% \begin{tikzpicture} [name suffix = -medium] -% \node [highlight = (1-1) (1-3)] {} ; -% \node [highlight = (2-1) (2-3)] {} ; -% \node [highlight = (3-1) (3-3)] {} ; -% \end{tikzpicture} -% \Body -% a & a + b & a + b + c & L_1 \\ -% a & a & a + b & L_2 \\ -% a & a & a & L_3 -% \end{pNiceArray}\] -% -% - -% -% \subsection{Utilisation of \textbackslash SubMatrix in the \textbackslash CodeBefore} -% -% \label{submatrix-in-codebefore} -% -% In the following example, we illustrate the mathematical product of two -% matrices. -% -% The whole figure is an environment |{NiceArray}| and the three pairs of -% parenthesis have been added with |\SubMatrix| in the |\CodeBefore|. -% -% \tikzset{highlight/.style={rectangle, -% fill=red!15, -% rounded corners = 0.5 mm, -% inner sep=1pt, -% fit=#1}}% -% \[\begin{NiceArray}{*{6}{c}@{\hspace{6mm}}*{5}{c}}[nullify-dots] -% \CodeBefore [create-cell-nodes] -% \SubMatrix({2-7}{6-last}) -% \SubMatrix({7-2}{last-6}) -% \SubMatrix({7-7}{last-last}) -% \begin{tikzpicture} -% \node [highlight = (9-2) (9-6)] { } ; -% \node [highlight = (2-9) (6-9)] { } ; -% \end{tikzpicture} -% \Body -% & & & & & & & & \color{blue}\scriptstyle C_j \\ -% & & & & & & b_{11} & \Cdots & b_{1j} & \Cdots & b_{1n} \\ -% & & & & & & \Vdots & & \Vdots & & \Vdots \\ -% & & & & & & & & b_{kj} \\ -% & & & & & & & & \Vdots \\ -% & & & & & & b_{n1} & \Cdots & b_{nj} & \Cdots & b_{nn} \\[3mm] -% & a_{11} & \Cdots & & & a_{1n} \\ -% & \Vdots & & & & \Vdots & & & \Vdots \\ -% \color{blue}\scriptstyle L_i -% & a_{i1} & \Cdots & a_{ik} & \Cdots & a_{in} & \Cdots & & c_{ij} \\ -% & \Vdots & & & & \Vdots \\ -% & a_{n1} & \Cdots & & & a_{nn} \\ -% \CodeAfter -% \tikz \draw [gray,shorten > = 1mm, shorten < = 1mm] (9-4.north) to [bend left] (4-9.west) ; -% \end{NiceArray}\] -% -% -% \vspace{1cm} -% \begin{Verbatim} -% \tikzset{highlight/.style={rectangle, -% fill=red!15, -% rounded corners = 0.5 mm, -% inner sep=1pt, -% fit=~#1}} -% \end{Verbatim} -% -% \begin{Verbatim}[formatcom = \small\color{gray}] -% \[\begin{NiceArray}{*{6}{c}~LetterAt{\hspace{6mm}}*{5}{c}}[nullify-dots] -% \CodeBefore [create-cell-nodes] -% \SubMatrix({2-7}{6-last}) -% \SubMatrix({7-2}{last-6}) -% \SubMatrix({7-7}{last-last}) -% \begin{tikzpicture} -% \node [highlight = (9-2) (9-6)] { } ; -% \node [highlight = (2-9) (6-9)] { } ; -% \end{tikzpicture} -% \Body -% & & & & & & & & \color{blue}\scriptstyle C_j \\ -% & & & & & & b_{11} & \Cdots & b_{1j} & \Cdots & b_{1n} \\ -% & & & & & & \Vdots & & \Vdots & & \Vdots \\ -% & & & & & & & & b_{kj} \\ -% & & & & & & & & \Vdots \\ -% & & & & & & b_{n1} & \Cdots & b_{nj} & \Cdots & b_{nn} \\[3mm] -% & a_{11} & \Cdots & & & a_{1n} \\ -% & \Vdots & & & & \Vdots & & & \Vdots \\ -% \color{blue}\scriptstyle L_i -% & a_{i1} & \Cdots & a_{ik} & \Cdots & a_{in} & \Cdots & & c_{ij} \\ -% & \Vdots & & & & \Vdots \\ -% & a_{n1} & \Cdots & & & a_{nn} \\ -% \CodeAfter -% \tikz \draw [gray,shorten > = 1mm, shorten < = 1mm] (9-4.north) to [bend left] (4-9.west) ; -% \end{NiceArray}\] -% \end{Verbatim} -% -% -% -% \subsection{A triangular tabular} -% -% \label{triangular} -% -% In the following example, we use the style PGF/TikZ |nicematrix/cell-node| -% to rotate the contents of the cells (and, then, we compensate that rotation by -% a rotation of the whole tabular with the command |\adjustbox| of the eponymous -% package, which must be loaded previously). -% -% -% \medskip -% \begin{Verbatim} -% \pgfset -% { -% ~emphase#nicematrix/cell-node@/.append style = -% { text/rotate = 45, minimum size = 6 mm } -% } -% -% \setlength{\tabcolsep}{0pt} -% -% ~emphase#\adjustbox@{rotate = -45, set depth = 6mm + 1.414 \arrayrulewidth} -% {\begin{NiceTabular} [ hvlines, corners=SE, baseline = line-9 ] { cccccccc } -% \CodeBefore -% \chessboardcolors{red!15}{blue!15} -% \Body -% 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ -% 1 & 2 & 3 & 4 & 5 & 6 & 7 \\ -% 1 & 3 & 6 & 10 & 15 & 21 \\ -% 1 & 4 & 10 & 20 & 35 \\ -% 1 & 5 & 15 & 35 \\ -% 1 & 6 & 21 \\ -% 1 & 7 \\ -% 1 -% \end{NiceTabular}} -% \end{Verbatim} -% -% -% \begin{center} -% \pgfset -% { -% nicematrix/cell-node/.append style = -% { text/rotate = 45, minimum size = 6 mm } -% }% -% \setlength{\tabcolsep}{0pt}% -% \adjustbox{rotate = -45, set depth = 6mm + 1.414 \arrayrulewidth} -% {\begin{NiceTabular} [ hvlines, corners=SE, baseline = line-9 ] { cccccccc } -% \CodeBefore -% \chessboardcolors{red!15}{blue!15} -% \Body -% 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ -% 1 & 2 & 3 & 4 & 5 & 6 & 7 \\ -% 1 & 3 & 6 & 10 & 15 & 21 \\ -% 1 & 4 & 10 & 20 & 35 \\ -% 1 & 5 & 15 & 35 \\ -% 1 & 6 & 21 \\ -% 1 & 7 \\ -% 1 -% \end{NiceTabular}} -% \end{center} -% -% -% -% \section{Implementation} -% % 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 |\iddots| are redefined in the -% environments provided by \pkg{nicematrix} as explained previously. In the same -% way, if the option |renew-matrix| is used, the environment |{matrix}| of -% \pkg{amsmath} is redefined. +% environments provided by \pkg{nicematrix}. In the same way, if the option +% |renew-matrix| is used, the environment |{matrix}| of \pkg{amsmath} is +% redefined. % % \smallskip % On the other hand, the environment |{array}| is never redefined. @@ -6507,7 +120,7 @@ version 2005/12/01 or later. % % % \bigskip -% \subsection*{Declaration of the package and packages loaded} +% \section{Declaration of the package and packages loaded} % % % The prefix |nicematrix| has been registred for this package. @@ -6617,7 +230,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% \subsection*{Security test} +% \section{Security test} % % Within the package \pkg{nicematrix}, we will have to test whether a cell of a % |{NiceTabular}| is empty. For the cells of the columns of type |p|, |b|, |m|, @@ -6675,12 +288,12 @@ version 2005/12/01 or later. % % \bigskip % Here, the box |\l_tmpa_box| will be used as sandbox to take our security test. -% This code has benne modified in version 6.18 (see question 682891 on TeX +% This code has been modified in version 6.18 (see question 682891 on TeX % StackExchange). % \begin{macrocode} \hook_gput_code:nnn { begindocument / after } { . } { - \@ifpackageloaded { mdwtab } + \IfPackageLoadedTF { mdwtab } { \@@_fatal:n { mdwtab~loaded } } { \bool_if:NF \c_@@_no_test_for_array_bool @@ -6699,7 +312,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% \subsection*{Technical definitions} +% \section{Technical definitions} % % \begin{macrocode} \tl_new:N \l_@@_argspec_tl @@ -6715,22 +328,7 @@ version 2005/12/01 or later. % \begin{macrocode} \hook_gput_code:nnn { begindocument } { . } { - \@ifpackageloaded { varwidth } - { \bool_const:Nn \c_@@_varwidth_loaded_bool { \c_true_bool } } - { \bool_const:Nn \c_@@_varwidth_loaded_bool { \c_false_bool } } - \@ifpackageloaded { booktabs } - { \bool_const:Nn \c_@@_booktabs_loaded_bool { \c_true_bool } } - { \bool_const:Nn \c_@@_booktabs_loaded_bool { \c_false_bool } } - \@ifpackageloaded { enumitem } - { \bool_const:Nn \c_@@_enumitem_loaded_bool { \c_true_bool } } - { \bool_const:Nn \c_@@_enumitem_loaded_bool { \c_false_bool } } - \@ifpackageloaded { tabularx } - { \bool_const:Nn \c_@@_tabularx_loaded_bool { \c_true_bool } } - { \bool_const:Nn \c_@@_tabularx_loaded_bool { \c_false_bool } } - \@ifpackageloaded { floatrow } - { \bool_const:Nn \c_@@_floatrow_loaded_bool { \c_true_bool } } - { \bool_const:Nn \c_@@_floatrow_loaded_bool { \c_false_bool } } - \@ifpackageloaded { tikz } + \IfPackageLoadedTF { tikz } { % \end{macrocode} % In some constructions, we will have to use a |{pgfpicture}| which \emph{must} @@ -6746,12 +344,10 @@ version 2005/12/01 or later. % |\AtBeginDocument| the correct version of some commands. The tokens % |\exp_not:N| are mandatory. % \begin{macrocode} - \bool_const:Nn \c_@@_tikz_loaded_bool \c_true_bool \tl_const:Nn \c_@@_pgfortikzpicture_tl { \exp_not:N \tikzpicture } \tl_const:Nn \c_@@_endpgfortikzpicture_tl { \exp_not:N \endtikzpicture } } { - \bool_const:Nn \c_@@_tikz_loaded_bool \c_false_bool \tl_const:Nn \c_@@_pgfortikzpicture_tl { \exp_not:N \pgfpicture } \tl_const:Nn \c_@@_endpgfortikzpicture_tl { \exp_not:N \endpgfpicture } } @@ -6849,7 +445,7 @@ version 2005/12/01 or later. % \begin{macrocode} \hook_gput_code:nnn { begindocument } { . } { - \@ifpackageloaded { booktabs } + \IfPackageLoadedTF { booktabs } { \iow_now:Nn \@mainaux \nicematrix@redefine@check@rerun } { } } @@ -6873,11 +469,10 @@ version 2005/12/01 or later. % We have to know whether \pkg{colortbl} is loaded in particular for the % redefinition of |\everycr|. % \begin{macrocode} -\bool_new:N \l_@@_colortbl_loaded_bool \hook_gput_code:nnn { begindocument } { . } { - \@ifpackageloaded { colortbl } - { \bool_set_true:N \l_@@_colortbl_loaded_bool } + \IfPackageLoadedTF { colortbl } + { } { % \end{macrocode} % The command |\CT@arc@| is a command of \pkg{colortbl} which sets the color of @@ -7047,10 +642,7 @@ version 2005/12/01 or later. % The following command must be protected because of its use of the command |\color|. % \begin{macrocode} \cs_new_protected:Npn \@@_color:n #1 - { - \tl_if_blank:nF { #1 } - { \@@_exp_color_arg:Nn \color { #1 } } - } + { \tl_if_blank:nF { #1 } { \@@_exp_color_arg:Nn \color { #1 } } } \cs_generate_variant:Nn \@@_color:n { V } % \end{macrocode} % @@ -7062,29 +654,12 @@ version 2005/12/01 or later. % \bigskip % \textbf{The column S of siunitx}\par\nobreak % -% \medskip -% We want to know whether the package \pkg{siunitx} is loaded and, if it is -% loaded, we redefine the |S| columns of \pkg{siunitx}. -% \begin{macrocode} -\bool_new:N \l_@@_siunitx_loaded_bool -\hook_gput_code:nnn { begindocument } { . } - { - \@ifpackageloaded { siunitx } - { \bool_set_true:N \l_@@_siunitx_loaded_bool } - { } - } -% \end{macrocode} -% -% -% -% \bigskip % 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. % \begin{macrocode} \hook_gput_code:nnn { begindocument } { . } { - \bool_if:nTF { ! \l_@@_siunitx_loaded_bool } - { \cs_set_eq:NN \@@_renew_NC@rewrite@S: \prg_do_nothing: } + \IfPackageLoadedTF { siunitx } { \cs_new_protected:Npn \@@_renew_NC@rewrite@S: { @@ -7106,6 +681,7 @@ version 2005/12/01 or later. } } } + { \cs_set_eq:NN \@@_renew_NC@rewrite@S: \prg_do_nothing: } } % \end{macrocode} % @@ -7124,7 +700,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% \subsection*{Parameters} +% \section{Parameters} % % \bigskip % The following counter will count the environments |{NiceArray}|. The value of @@ -7169,11 +745,12 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% If, in a tabular, there is a tabular note in a caption that must be composed -% \emph{above} the tabular, we will store in |\l_@@_note_in_caption_int| the -% number of notes in that caption. It will be stored in the |aux| file. +% It's possible to put tabular notes (with |\tabularnote|) in the caption if +% that caption is composed \emph{above} the tabular. In such case, we will count +% in |\g_@@_notes_caption_int| the number of uses of the command +% |\tabularnote| \emph{without optional argument} in that caption. % \begin{macrocode} -\int_new:N \l_@@_note_in_caption_int +\int_new:N \g_@@_notes_caption_int % \end{macrocode} % % \bigskip @@ -7590,12 +1167,6 @@ version 2005/12/01 or later. \bool_new:N \g_@@_empty_cell_bool % \end{macrocode} % -% \bigskip -% The following boolean will be used to deal with the commands |\tabularnote| in -% the caption (command |\caption| or key |caption|). -% \begin{macrocode} -\bool_new:N \g_@@_second_composition_bool -% \end{macrocode} % % \bigskip % The following dimensions will be used internally to compute the width of the @@ -7967,7 +1538,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% \subsection*{The command \textbackslash tabularnote} +% \section{The command \textbackslash tabularnote} % % \bigskip % Of course, it's possible to use |\tabularnote| in the main tabular. But there @@ -7987,13 +1558,20 @@ version 2005/12/01 or later. % tabular notes in the logical order. That's why: % \begin{itemize} % \item The number of tabular notes present in the caption will be written on -% the |aux| file and available in |\l_@@_note_in_caption_int|. +% the |aux| file and available in |\g_@@_notes_caption_int|.\footnote{More +% precisely, it's the number of tabular notes which do not use the optional +% argument of |\tabularnote|.} % \item During the composition of the main tabular, the tabular notes will be -% numbered from |\l_@@_note_in_caption_int|+1 and the notes will be stored in -% |\g_@@_notes_seq|. +% numbered from |\g_@@_notes_caption_int|+1 and the notes will be stored in +% |\g_@@_notes_seq|. Each composant of |\g_@@_notes_seq| will be a kind of +% couple of the form : \texttt{\{\textsl{label}\}\{\textsl{text of the +% tabularnote}\}}. The first composante is the optional argument (between square +% brackets) of the command |\tabularnote| (if the optional argument is not used, +% the value will be the special marker |\c_novalue_tl|). % \item During the composition of the caption (value of |\l_@@_caption_tl|), the -% tabular notes will be numbered from $1$ to |\l_@@_note_in_caption_int| and the -% notes themselves will be stored in |\g_@@_notes_in_caption_seq|. +% tabular notes will be numbered from $1$ to |\g_@@_notes_caption_int| and the +% notes themselves will be stored in |\g_@@_notes_in_caption_seq|. The structure +% of the composantes of that sequence will be the same as for |\g_@@_notes_seq|. % \item After the composition of the main tabular and after the composition of % the caption, the sequences |\g_@@_notes_in_caption_seq| and |\g_@@_notes_seq| % will be merged (in that order) and the notes will be composed. @@ -8019,7 +1597,7 @@ version 2005/12/01 or later. % \bigskip % Before the actual tabular notes, it's possible to put a text % specified by the key |tabularnote| of the environment. The token list -% |\l_@@_tabularnote_tl| corresponds to the value of that key. +% |\g_@@_tabularnote_tl| corresponds to the value of that key. % \begin{macrocode} \tl_new:N \g_@@_tabularnote_tl % \end{macrocode} @@ -8077,14 +1655,7 @@ version 2005/12/01 or later. % \begin{macrocode} \hook_gput_code:nnn { begindocument } { . } { - \bool_if:nTF { ! \c_@@_enumitem_loaded_bool } - { - \NewDocumentCommand \tabularnote { m } - { - \@@_error_or_warning:n { enumitem~not~loaded } - \@@_gredirect_none:n { enumitem~not~loaded } - } - } + \IfPackageLoadedTF { enumitem } { % \end{macrocode} % The type of list |tabularnotes| will be used to format the tabular notes at @@ -8119,7 +1690,7 @@ version 2005/12/01 or later. % That's why we program |\tabularnote| to be no-op excepted in a floating % environment or in an environment of \pkg{nicematrix}. % \begin{macrocode} - \NewDocumentCommand \tabularnote { m } + \NewDocumentCommand \tabularnote { o m } { \bool_if:nT { \cs_if_exist_p:N \@captype || \l_@@_in_env_bool } { @@ -8127,50 +1698,79 @@ version 2005/12/01 or later. { \@@_error:n { tabularnote~forbidden } } { \bool_if:NTF \l_@@_in_caption_bool - { \@@_tabularnote_ii:n { #1 } } - { \@@_tabularnote_i:n { #1 } } + { \@@_tabularnote_caption:nn { #1 } { #2 } } + { \@@_tabularnote:nn { #1 } { #2 } } } } } + } + { + \NewDocumentCommand \tabularnote { o m } + { + \@@_error_or_warning:n { enumitem~not~loaded } + \@@_gredirect_none:n { enumitem~not~loaded } + } + } + } % \end{macrocode} % -% \bigskip -% For the version in normal conditions, that is to say not in the key |caption|. +% \bigskip +% For the version in normal conditions, that is to say not in the |caption|. +% |#1| is the optional argument of |\tabularnote| (maybe equal to the special +% marker |\c_novalue_tl|) and |#2| is the mandatory argument of |\tabularnote|. % \begin{macrocode} - \cs_new_protected:Npn \@@_tabularnote_i:n #1 - { +\cs_new_protected:Npn \@@_tabularnote:nn #1 #2 + { % \end{macrocode} % You have to see whether the argument of |\tabularnote| has yet been used as % argument of another |\tabularnote| in the same tabular. In that case, there % will be only one note (for both commands |\tabularnote|) at the end of the -% tabular. We search the argument of our command |\tabularnote| in the +% tabular. We search the argument of our command |\tabularnote| in % |\g_@@_notes_seq|. The position in the sequence will be stored in % |\l_tmpa_int| (0 if the text is not in the sequence yet). % \begin{macrocode} - \int_zero:N \l_tmpa_int - \bool_if:NT \l_@@_notes_detect_duplicates_bool + \int_zero:N \l_tmpa_int + \bool_if:NT \l_@@_notes_detect_duplicates_bool + { +% \end{macrocode} +% We recall that each component of |\g_@@_notes_seq| is a kind of couple of the form +% \begin{center} +% \texttt{\{\textsl{label}\}\{\textsl{text of the tabularnote}\}}. +% \end{center} +% If the user have used |\tabularnote| without the optional argument, the +% \texttt{\textsl{label}} will be the special marker |\c_novalue_tl|. +% \begin{macrocode} + \seq_map_indexed_inline:Nn \g_@@_notes_seq + { + \tl_if_eq:nnT { { #1 } { #2 } } { ##2 } + { \int_set:Nn \l_tmpa_int { ##1 } \seq_map_break: } + } + \int_compare:nNnF \l_tmpa_int = \c_zero_int + { \int_add:Nn \l_tmpa_int \g_@@_notes_caption_int } + } + \int_compare:nNnT \l_tmpa_int = \c_zero_int + { + \seq_gput_right:Nn \g_@@_notes_seq { { #1 } { #2 } } + \tl_if_novalue:nT { #1 } { \int_gincr:N \c@tabularnote } + } + \seq_put_right:Nx \l_@@_notes_labels_seq + { + \tl_if_novalue:nTF { #1 } + { + \@@_notes_format:n { - \seq_map_indexed_inline:Nn \g_@@_notes_seq - { - \tl_if_eq:nnT { #1 } { ##2 } - { \int_set:Nn \l_tmpa_int { ##1 } \seq_map_break: } + \int_eval:n + { + \int_compare:nNnTF \l_tmpa_int = \c_zero_int + \c@tabularnote + \l_tmpa_int } - \int_compare:nNnF \l_tmpa_int = 0 - { \int_add:Nn \l_tmpa_int \l_@@_note_in_caption_int } - } - \int_compare:nNnTF \l_tmpa_int = 0 - { - \int_gincr:N \c@tabularnote - \seq_put_right:Nx \l_@@_notes_labels_seq - { \@@_notes_format:n { \int_use:c { c @ tabularnote } } } - \seq_gput_right:Nn \g_@@_notes_seq { #1 } } - { - \seq_put_right:Nx \l_@@_notes_labels_seq - { \@@_notes_format:n { \int_use:N \l_tmpa_int } } - } - \peek_meaning:NF \tabularnote - { + } + { #1 } + } + \peek_meaning:NF \tabularnote + { % \end{macrocode} % If the following token is \emph{not} a |\tabularnote|, we have finished the % sequence of successive commands |\tabularnote| and we have to format the @@ -8178,37 +1778,37 @@ version 2005/12/01 or later. % |\l_tmpa_box| because we will do a special construction in order to have this % box in an overlapping position if we are at the end of a cell. % \begin{macrocode} - \hbox_set:Nn \l_tmpa_box - { + \hbox_set:Nn \l_tmpa_box + { % \end{macrocode} % We remind that it is the command |\@@_notes_label_in_tabular:n| that will % put the labels in a |\textsuperscript|. % \begin{macrocode} - \@@_notes_label_in_tabular:n - { - \seq_use:Nnnn - \l_@@_notes_labels_seq { , } { , } { , } - } - } + \@@_notes_label_in_tabular:n + { + \seq_use:Nnnn + \l_@@_notes_labels_seq { , } { , } { , } + } + } % \end{macrocode} % We want the (last) tabular note referenceable (with the standard command |\label|). % \begin{macrocode} - \int_gsub:Nn \c@tabularnote { 1 } - \int_set_eq:NN \l_tmpa_int \c@tabularnote - \refstepcounter { tabularnote } - \int_compare:nNnT \l_tmpa_int = \c@tabularnote - { \int_gincr:N \c@tabularnote } - \seq_clear:N \l_@@_notes_labels_seq - \hbox_overlap_right:n { \box_use:N \l_tmpa_box } + \int_gsub:Nn \c@tabularnote { 1 } + \int_set_eq:NN \l_tmpa_int \c@tabularnote + \refstepcounter { tabularnote } + \int_compare:nNnT \l_tmpa_int = \c@tabularnote + { \int_gincr:N \c@tabularnote } + \seq_clear:N \l_@@_notes_labels_seq + \hbox_overlap_right:n { \box_use:N \l_tmpa_box } % \end{macrocode} % If the command |\tabularnote| is used exactly at the end of the cell, the % |\unskip| (inserted by \pkg{array}?) will delete the skip we insert now % and the label of the footnote will be composed in an overlapping position (by % design). % \begin{macrocode} - \skip_horizontal:n { \box_wd:N \l_tmpa_box } - } - } + \skip_horizontal:n { \box_wd:N \l_tmpa_box } + } + } % \end{macrocode} % % \bigskip @@ -8217,53 +1817,91 @@ version 2005/12/01 or later. % times. In order to know the number of commands |\tabularnote| in the caption, % we will consider that there should not be the same tabular note twice in the % caption (in the main tabular, it's possible). Once we have found a tabular -% note which has yet been encoutered, we consider that you are in a new -% composition of the argument of |\caption|. At that time, we store in -% |\g_@@_nb_of_notes_int| the number of notes in the |\caption|. +% note which has yet been encountered, we consider that you are in a new +% composition of the argument of |\caption|. +% \begin{macrocode} +\cs_new_protected:Npn \@@_tabularnote_caption:nn #1 #2 + { + \bool_if:NTF \g_@@_caption_finished_bool + { + \int_compare:nNnT + \c@tabularnote = \g_@@_notes_caption_int + { \int_gzero:N \c@tabularnote } +% \end{macrocode} +% Now, we try to detect duplicate notes in the caption. % \begin{macrocode} - \cs_new_protected:Npn \@@_tabularnote_ii:n #1 + \bool_set_false:N \l_tmpa_bool + \seq_map_inline:Nn \g_@@_notes_in_caption_seq + { \@@_if_eq_two_three:nnn ##1 { #2 } } +% \end{macrocode} +% Be careful! We must put |\bool_if:NF| and not |\bool_if:NT|! +% \begin{macrocode} + \bool_if:NF \l_tmpa_bool + { \@@_error:n { Identical~notes~in~caption } } + } + { +% \end{macrocode} +% In the following code, we are in the first composition of the caption or at +% the first |\tabularnote| of the second composition. We have +% to see whether the text of our tabular note is among the texts of the +% tabularnotes stored in |\g_@@_notes_in_caption_seq|. For that, we will loop on +% |\g_@@_notes_in_caption_seq| and we will raise |\l_tmpa_bool| if the text is found. +% \begin{macrocode} + \bool_set_false:N \l_tmpa_bool + \seq_map_inline:Nn \g_@@_notes_in_caption_seq + { \@@_if_eq_two_three:nnn ##1 { #2 } } + \bool_if:NTF \l_tmpa_bool { - \int_gincr:N \c@tabularnote - \bool_if:NTF \g_@@_caption_finished_bool - { - \int_compare:nNnTF - \c@tabularnote > { \tl_count:N \g_@@_notes_in_caption_seq } - { \int_gset:Nn \c@tabularnote { 1 } } - \seq_if_in:NnF \g_@@_notes_in_caption_seq { #1 } - { \@@_fatal:n { Identical~notes~in~caption } } - } - { - \seq_if_in:NnTF \g_@@_notes_in_caption_seq { #1 } - { - \bool_gset_true:N \g_@@_caption_finished_bool - \int_gset:Nn \c@tabularnote { 1 } - } - { \seq_gput_right:Nn \g_@@_notes_in_caption_seq { #1 } } - } - \seq_put_right:Nx \l_@@_notes_labels_seq - { \@@_notes_format:n { \int_use:N \c@tabularnote } } - \peek_meaning:NF \tabularnote - { - \hbox_set:Nn \l_tmpa_box - { - \@@_notes_label_in_tabular:n - { - \seq_use:Nnnn - \l_@@_notes_labels_seq { , } { , } { , } - } - } - \seq_clear:N \l_@@_notes_labels_seq - \hbox_overlap_right:n { \box_use:N \l_tmpa_box } - \skip_horizontal:n { \box_wd:N \l_tmpa_box } - } +% \end{macrocode} +% Now, we known that are in the second composition of the caption since we are +% reading a tabular note which has yet been read. Now, the value of +% |\g_@@_notes_caption_int| won't change anymore: it's the number of uses +% \emph{without optional argument} of the command |\tabularnote| in the caption. +% \begin{macrocode} + \bool_gset_true:N \g_@@_caption_finished_bool + \int_gset_eq:NN \g_@@_notes_caption_int \c@tabularnote + \int_gzero:N \c@tabularnote } + { \seq_gput_right:Nn \g_@@_notes_in_caption_seq { { #1 } { #2 } } } } - } +% \end{macrocode} +% Now, we will compose the label of the footnote (in the caption). Even if we +% are not in the first composition, we have to compose that label! +% \begin{macrocode} + \tl_if_novalue:nT { #1 } { \int_gincr:N \c@tabularnote } + \seq_put_right:Nx \l_@@_notes_labels_seq + { + \tl_if_novalue:nTF { #1 } + { \@@_notes_format:n { \int_use:N \c@tabularnote } } + { #1 } + } + \peek_meaning:NF \tabularnote + { + \@@_notes_label_in_tabular:n + { \seq_use:Nnnn \l_@@_notes_labels_seq { , } { , } { , } } + \seq_clear:N \l_@@_notes_labels_seq + } + } % \end{macrocode} % +% \begin{macrocode} +\cs_new_protected:Npn \@@_if_eq_two_three:nnn #1 #2 #3 + { + \tl_if_eq:nnT { #2 } { #3 } + { + \bool_set_true:N \l_tmpa_bool + \seq_map_break: + } + } +% \end{macrocode} +% +% \begin{macrocode} +\cs_new_protected:Npn \@@_count_novalue_first:nn #1 #2 + { \tl_if_novalue:nT { #1 } { \int_gincr:N \g_@@_notes_caption_int } } +% \end{macrocode} % % -% \subsection*{Command for creation of rectangle nodes} +% \section{Command for creation of rectangle nodes} % % The following command should be used in a |{pgfpicture}|. It creates a % rectangle (empty but with a name). @@ -8332,7 +1970,7 @@ version 2005/12/01 or later. % % % \bigskip -% \subsection*{The options} +% \section{The options} % % The following parameter corresponds to the keys |caption|, |short-caption| and % |label| of the environment |{NiceTabular}|. @@ -8602,10 +2240,6 @@ version 2005/12/01 or later. line-style .code:n = { \bool_lazy_or:nnTF -% \end{macrocode} -% We can't use |\c_@@_tikz_loaded_bool| to test whether \pkg{tikz} is loaded -% because |\NiceMatrixOptions| may be used in the preamble of the document. -% \begin{macrocode} { \cs_if_exist_p:N \tikzpicture } { \str_if_eq_p:nn { #1 } { standard } } { \tl_set:Nn \l_@@_xdots_line_style_tl { #1 } } @@ -8846,8 +2480,9 @@ version 2005/12/01 or later. { \hook_gput_code:nnn { begindocument } { . } { - \bool_if:NT \c_@@_enumitem_loaded_bool + \IfPackageLoadedTF { enumitem } { \setlist* [ tabularnotes ] { #1 } } + { } } } , enumitem-keys .value_required:n = true , @@ -8855,8 +2490,9 @@ version 2005/12/01 or later. { \hook_gput_code:nnn { begindocument } { . } { - \bool_if:NT \c_@@_enumitem_loaded_bool + \IfPackageLoadedTF { enumitem } { \setlist* [ tabularnotes* ] { #1 } } + { } } } , enumitem-keys-para .value_required:n = true , @@ -9123,7 +2759,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% \subsection*{Important code used by \{NiceArrayWithDelims\} } +% \section{Important code used by \{NiceArrayWithDelims\} } % % The pseudo-environment |\@@_cell_begin:w|--|\@@_cell_end:| will be used to format the % cells of the array. In the code, the affectations are global because this @@ -9746,8 +3382,9 @@ version 2005/12/01 or later. % avoid the error messages of that redefinition % \footnote{cf. |\nicematrix@redefine@check@rerun|}. % \begin{macrocode} - \bool_if:NT \c_@@_booktabs_loaded_bool + \IfPackageLoadedTF { booktabs } { \tl_put_left:Nn \@BTnormal \@@_create_row_node_i: } + { } \box_clear_new:N \l_@@_cell_box \normalbaselines % \end{macrocode} @@ -9784,7 +3421,7 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_set_nopar:Npn \ialign { - \bool_if:NTF \l_@@_colortbl_loaded_bool + \IfPackageLoadedTF { colortbl } { \CT@everycr { @@ -9882,7 +3519,7 @@ version 2005/12/01 or later. { \tl_if_empty:NF \l_@@_note_in_caption_tl { - \int_set_eq:NN \l_@@_note_in_caption_int + \int_gset_eq:NN \g_@@_notes_caption_int { \l_@@_note_in_caption_tl } \int_gset:Nn \c@tabularnote { \l_@@_note_in_caption_tl } } @@ -10124,7 +3761,7 @@ version 2005/12/01 or later. % % % \bigskip -% \subsection*{The \textbackslash CodeBefore} +% \section{The \textbackslash CodeBefore} % % The following command will be executed if the |\CodeBefore| has to be actually executed. % \begin{macrocode} @@ -10193,7 +3830,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \begin{macrocode} - \bool_if:NT \c_@@_tikz_loaded_bool + \IfPackageLoadedTF { tikz } { \tikzset { @@ -10201,6 +3838,7 @@ version 2005/12/01 or later. { overlay , name~prefix = \@@_env: - } } } + { } \cs_set_eq:NN \cellcolor \@@_cellcolor \cs_set_eq:NN \rectanglecolor \@@_rectanglecolor \cs_set_eq:NN \roundedrectanglecolor \@@_roundedrectanglecolor @@ -10422,7 +4060,7 @@ version 2005/12/01 or later. % % % \bigskip -% \subsection*{The environment \{NiceArrayWithDelims\}} +% \section{The environment \{NiceArrayWithDelims\}} % % \begin{macrocode} \NewDocumentEnvironment { NiceArrayWithDelims } @@ -10829,7 +4467,7 @@ version 2005/12/01 or later. % This is the end of the environment |{NiceArrayWithDelims}|. % % \vspace{1cm} -% \subsection*{We construct the preamble of the array} +% \section{We construct the preamble of the array} % % \bigskip % The transformation of the preamble is an operation in several @@ -11548,7 +5186,7 @@ version 2005/12/01 or later. \tl_set:Nn \l_tmpa_tl { #1 } \tl_replace_all:Nnn \l_tmpa_tl { \@@_S: } { S } \@@_keys_p_column:V \l_tmpa_tl - \bool_if:NTF \c_@@_varwidth_loaded_bool + \IfPackageLoadedTF { varwidth } { \@@_patch_preamble_iv_iv:nn { #2 } { varwidth } } { \@@_error_or_warning:n { varwidth~not~loaded } @@ -11679,12 +5317,7 @@ version 2005/12/01 or later. % \begin{macrocode} \cs_new_protected:Npn \@@_patch_preamble_vii_ii:n #1 { -% \end{macrocode} -% We test whether the version of \pkg{nicematrix} is at least 3.0. We will -% change the programmation of the test further with something like |\@ifpackagelater|. -% -% \begin{macrocode} - \cs_if_exist:NTF \siunitx_cell_begin:w + \IfPackageAtLeastTF { siunitx } { 2022/01/01 } { \tl_gput_right:NV \g_@@_preamble_tl \g_@@_pre_cell_tl \tl_gclear:N \g_@@_pre_cell_tl @@ -12020,7 +5653,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% \subsection*{The redefinition of \textbackslash multicolumn} +% \section{The redefinition of \textbackslash multicolumn} % % \medskip % The following command must \emph{not} be protected since it begins with @@ -12377,17 +6010,18 @@ version 2005/12/01 or later. \@@_insert_caption: % \end{macrocode} % If there is one or several commands |\tabularnote| in the caption, we will -% write in the |aux| file the number of such tabular notes. +% write in the |aux| file the number of such tabular notes... but only the +% tabular notes for which the command |\tabularnote| has been used without its +% optional argument (between square brackets). % \begin{macrocode} - \int_gset:Nn \c@tabularnote - { \seq_count:N \g_@@_notes_in_caption_seq } - \int_compare:nNnF \c@tabularnote = 0 + \int_compare:nNnT \g_@@_notes_caption_int > 0 { \tl_gput_right:Nx \g_@@_aux_tl { \tl_set:Nn \exp_not:N \l_@@_note_in_caption_tl - { \int_eval:n { \c@tabularnote } } + { \int_use:N \g_@@_notes_caption_int } } + \int_gzero:N \g_@@_notes_caption_int } } } @@ -12427,6 +6061,7 @@ version 2005/12/01 or later. } % \end{macrocode} % +% % \bigskip % \begin{macrocode} \cs_new_protected:Npn \@@_insert_caption: @@ -12456,11 +6091,13 @@ version 2005/12/01 or later. % |\@makecaption| has been stored by \pkg{floatrow} in |\FR@makecaption|. That's % why we restore the old version. % \begin{macrocode} - \bool_if:NT \c_@@_floatrow_loaded_bool + \IfPackageLoadedTF { floatrow } { \cs_set_eq:NN \@makecaption \FR@makecaption } + { } \tl_if_empty:NTF \l_@@_short_caption_tl - { \caption { \l_@@_caption_tl } } - { \caption [ \l_@@_short_caption_tl ] { \l_@@_caption_tl } } + { \caption } + { \caption [ \l_@@_short_caption_tl ] } + { \l_@@_caption_tl } \tl_if_empty:NF \l_@@_label_tl { \label { \l_@@_label_tl } } \group_end: } @@ -12501,7 +6138,9 @@ version 2005/12/01 or later. \bool_if:NTF \l_@@_notes_para_bool { \begin { tabularnotes* } - \seq_map_inline:Nn \g_@@_notes_seq { \item ##1 } \strut + \seq_map_inline:Nn \g_@@_notes_seq + { \@@_one_tabularnote:nn ##1 } + \strut \end { tabularnotes* } % \end{macrocode} % The following |\par| is mandatory for the event that the user has put @@ -12511,7 +6150,9 @@ version 2005/12/01 or later. } { \tabularnotes - \seq_map_inline:Nn \g_@@_notes_seq { \item ##1 } \strut + \seq_map_inline:Nn \g_@@_notes_seq + { \@@_one_tabularnote:nn ##1 } + \strut \endtabularnotes } } @@ -12519,7 +6160,7 @@ version 2005/12/01 or later. \group_end: \bool_if:NT \l_@@_notes_bottomrule_bool { - \bool_if:NTF \c_@@_booktabs_loaded_bool + \IfPackageLoadedTF { booktabs } { % \end{macrocode} % The two dimensions |\aboverulesep| et |\heavyrulewidth| are parameters defined @@ -12540,6 +6181,21 @@ version 2005/12/01 or later. \int_gzero:N \c@tabularnote } % \end{macrocode} +% +% \medskip +% The following command will format (after the main tabular) one tabularnote +% (with the command |\item|) . |#1| is the label (when the command +% |\tabularnote| has been used with an optional argument between square +% brackets) and |#2| is the text of the note. The second argument is provided by +% currification. +% \begin{macrocode} +\cs_set_protected:Npn \@@_one_tabularnote:nn #1 + { + \tl_if_novalue:nTF { #1 } + { \item } + { \item [ \@@_notes_label_in_list:n { #1 } ] } + } +% \end{macrocode} % % \medskip % The case of |baseline| equal to |b|. Remember that, when the key |b| is used, @@ -13330,7 +6986,7 @@ version 2005/12/01 or later. % % % \bigskip -% \subsection*{The environment \{NiceMatrix\} and its variants} +% \section{The environment \{NiceMatrix\} and its variants} % % % \begin{macrocode} @@ -13397,7 +7053,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% \subsection*{\{NiceTabular\}, \{NiceTabularX\} and \{NiceTabular*\}} +% \section{\{NiceTabular\}, \{NiceTabularX\} and \{NiceTabular*\}} % % \begin{macrocode} \NewDocumentEnvironment { NiceTabular } { O { } m ! O { } } @@ -13492,7 +7148,9 @@ version 2005/12/01 or later. % definition of that columns in \pkg{tabularx} (this would result in an error in % |{NiceTabularX}|). % \begin{macrocode} - \bool_if:NT \c_@@_tabularx_loaded_bool { \newcolumntype { X } { \@@_X } } + \IfPackageLoadedTF { tabularx } + { \newcolumntype { X } { \@@_X } } + { } \str_gset:Nn \g_@@_name_env_str { NiceTabularX } \dim_zero_new:N \l_@@_width_dim \dim_set:Nn \l_@@_width_dim { #1 } @@ -13518,7 +7176,7 @@ version 2005/12/01 or later. % % % \bigskip -% \subsection*{After the construction of the array} +% \section{After the construction of the array} % % \medskip % \begin{macrocode} @@ -13721,7 +7379,7 @@ version 2005/12/01 or later. % \bigskip % Now, the pre-code-after and then, the |\CodeAfter|. % \begin{macrocode} - \bool_if:NT \c_@@_tikz_loaded_bool + \IfPackageLoadedTF { tikz } { \tikzset { @@ -13733,6 +7391,7 @@ version 2005/12/01 or later. } } } + { } \cs_set_eq:NN \ialign \@@_old_ialign: \cs_set_eq:NN \SubMatrix \@@_SubMatrix \cs_set_eq:NN \UnderBrace \@@_UnderBrace @@ -13989,7 +7648,7 @@ version 2005/12/01 or later. % % % \bigskip -% \subsection*{We draw the dotted lines} +% \section{We draw the dotted lines} % % A dotted line will be said \emph{open} in one of its extremities when it stops % on the edge of the matrix and \emph{closed} otherwise. In the following @@ -14870,7 +8529,7 @@ version 2005/12/01 or later. % % % \bigskip -% \subsection*{The actual instructions for drawing the dotted lines with Tikz} +% \section{The actual instructions for drawing the dotted lines with Tikz} % % The command |\@@_draw_line:| should be used in a |{pgfpicture}|. It has six % implicit arguments: @@ -15136,10 +8795,9 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% \subsection*{User commands available in the new environments} +% \section{User commands available in the new environments} % % -% \interitem % The commands |\@@_Ldots|, |\@@_Cdots|, |\@@_Vdots|, |\@@_Ddots| and % |\@@_Iddots| will be linked to |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots| and % |\Iddots| in the environments |{NiceArray}| (the other environments of @@ -15556,7 +9214,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% \subsection*{The command \textbackslash line accessible in code-after} +% \section{The command \textbackslash line accessible in code-after} % % In the |\CodeAfter|, the command |\@@_line:nn| will be linked to |\line|. This % command takes two arguments which are the specifications of two cells in the @@ -15673,7 +9331,7 @@ version 2005/12/01 or later. % % % \bigskip -% \subsection*{The command \textbackslash RowStyle} +% \section{The command \textbackslash RowStyle} % % \medskip % \begin{macrocode} @@ -15816,7 +9474,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% \subsection*{Colors of cells, rows and columns} +% \section{Colors of cells, rows and columns} % % We want to avoid the thin white lines that are shown in some \textsc{pdf} % viewers (eg: with the engine MuPDF used by SumatraPDF). That's why we try to @@ -16510,7 +10168,7 @@ version 2005/12/01 or later. % % % \bigskip -% \subsection*{The vertical and horizontal rules} +% \section{The vertical and horizontal rules} % % % \bigskip @@ -17314,12 +10972,11 @@ version 2005/12/01 or later. % \begin{macrocode} \keys_define:nn { NiceMatrix / custom-line } { - % here, we will use change in the future to use .str_set:N - letter .code:n = \str_set:Nn \l_@@_letter_str { #1 } , + letter .str_set:N = \l_@@_letter_str , letter .value_required:n = true , - command .code:n = \str_set:Nn \l_@@_command_str { #1 } , + command .str_set:N = \l_@@_command_str , command .value_required:n = true , - ccommand .code:n = \str_set:Nn \l_@@_ccommand_str { #1 } , + ccommand .str_set:N = \l_@@_ccommand_str , ccommand .value_required:n = true , } % \end{macrocode} @@ -17340,12 +10997,9 @@ version 2005/12/01 or later. \keys_set:nn { NiceMatrix / custom-line-bis } { #1 } \bool_if:NT \l_@@_tikz_rule_bool { -% \end{macrocode} -% We can't use |\c_@@_tikz_loaded_bool| to test whether \pkg{tikz} is loaded -% because |\NiceMatrixOptions| may be used in the preamble of the document. -% \begin{macrocode} - \cs_if_exist:NF \tikzpicture - { \@@_error:n { tikz~in~custom-line~without~tikz } } + \IfPackageLoadedTF { tikz } + { } + { \@@_error:n { tikz~in~custom-line~without~tikz }} \bool_if:NT \l_@@_color_bool { \@@_error:n { color~in~custom-line~with~tikz } } } @@ -17651,7 +11305,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% \subsection*{The key corners} +% \section{The key corners} % % When the key |corners| is raised, the rules are not drawn in the % corners. Of course, we have to compute the corners before we begin to draw the @@ -17839,7 +11493,7 @@ version 2005/12/01 or later. % % % \bigskip -% \subsection*{The environment \{NiceMatrixBlock\}} +% \section{The environment \{NiceMatrixBlock\}} % % The following flag will be raised when all the columns of the environments of % the block must have the same width in ``auto'' mode. @@ -17907,7 +11561,7 @@ version 2005/12/01 or later. % % % -% \subsection*{The extra nodes} +% \section{The extra nodes} % % First, two variants of the functions |\dim_min:nn| and |\dim_max:nn|. % \begin{macrocode} @@ -18217,7 +11871,9 @@ version 2005/12/01 or later. % |\multicolumn{|$n$|}{...}{...}| with $n$>1 was issued and in % |\g_@@_multicolumn_sizes_seq| the correspondant values of $n$. % \begin{macrocode} - \seq_mapthread_function:NNN + \cs_if_exist_use:NF + \seq_map_pairwise_function:NNN + \seq_mapthread_function:NNN \g_@@_multicolumn_cells_seq \g_@@_multicolumn_sizes_seq \@@_node_for_multicolumn:nn @@ -18258,7 +11914,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% \subsection*{The blocks} +% \section{The blocks} % % The code deals with the command |\Block|. This command has no direct link with % the environment |{NiceMatrixBlock}|. @@ -18701,7 +12357,7 @@ version 2005/12/01 or later. \keys_define:nn { NiceMatrix / Block / SecondPass } { tikz .code:n = - \bool_if:NTF \c_@@_tikz_loaded_bool + \IfPackageLoadedTF { tikz } { \seq_put_right:Nn \l_@@_tikz_seq { { #1 } } } { \@@_error:n { tikz~key~without~tikz } } , tikz .value_required:n = true , @@ -19158,6 +12814,7 @@ version 2005/12/01 or later. { \str_if_eq_p:Vn \l_@@_vpos_of_block_str { T } } { \str_if_eq_p:Vn \l_@@_vpos_of_block_str { B } } } +% \end{macrocode} % \medskip % \begin{macrocode} { @@ -19575,7 +13232,7 @@ version 2005/12/01 or later. % \end{macrocode} % % -% \subsection*{How to draw the dotted lines transparently} +% \section{How to draw the dotted lines transparently} % \begin{macrocode} \cs_set_protected:Npn \@@_renew_matrix: { @@ -19599,7 +13256,7 @@ version 2005/12/01 or later. % % % \bigskip -% \subsection*{Automatic arrays} +% \section{Automatic arrays} % % % @@ -19714,7 +13371,7 @@ version 2005/12/01 or later. % % % \bigskip -% \subsection*{The redefinition of the command \textbackslash dotfill } +% \section{The redefinition of the command \textbackslash dotfill } % % \begin{macrocode} \cs_set_eq:NN \@@_old_dotfill \dotfill @@ -19738,7 +13395,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% \subsection*{The command \textbackslash diagbox} +% \section{The command \textbackslash diagbox} % % The command |\diagbox| will be linked to |\diagbox:nn| in the environments of % \pkg{nicematrix}. However, there are also redefinitions of |\diagbox| in other @@ -19840,7 +13497,7 @@ version 2005/12/01 or later. % % % \bigskip -% \subsection*{The keyword \textbackslash CodeAfter} +% \section{The keyword \textbackslash CodeAfter} % % % The |\CodeAfter| (inserted with the key |code-after| or after the keyword @@ -19923,7 +13580,7 @@ version 2005/12/01 or later. % % % -% \subsection*{The delimiters in the preamble} +% \section{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 @@ -20020,7 +13677,7 @@ version 2005/12/01 or later. } % \end{macrocode} % -% \subsection*{The command \textbackslash SubMatrix} +% \section{The command \textbackslash SubMatrix} % % % \begin{macrocode} @@ -20631,7 +14288,7 @@ version 2005/12/01 or later. % % % \bigskip -% \subsection*{Les commandes \textbackslash UnderBrace et \textbackslash +% \section{Les commandes \textbackslash UnderBrace et \textbackslash % OverBrace} % % The following commands will be linked to |\UnderBrace| and |\OverBrace| in the @@ -20841,7 +14498,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% \subsection*{The command \textbackslash ShowCellNames} +% \section{The command \textbackslash ShowCellNames} % % \begin{macrocode} \NewDocumentCommand \@@_ShowCellNames_CodeBefore { } @@ -20913,7 +14570,10 @@ version 2005/12/01 or later. \pgf@relevantforpicturesizefalse \pgfpathrectanglecorners { \@@_qpoint:n { 1 } } - { \@@_qpoint:n { \int_eval:n { \c@iRow + 1 } } } + { + \@@_qpoint:n + { \int_eval:n { \int_max:nn \c@iRow \c@jCol + 1 } } + } \pgfsetfillopacity { 0.75 } \pgfsetfillcolor { white } \pgfusepathqfill @@ -20997,7 +14657,7 @@ version 2005/12/01 or later. % \end{macrocode} % % \bigskip -% \subsection*{We process the options at package loading} +% \section{We process the options at package loading} % % % We process the options when the package is loaded (with |\usepackage|) but we @@ -21095,10 +14755,10 @@ version 2005/12/01 or later. % 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 } + \IfClassLoadeTF { beamer } { \bool_set_false:N \c_@@_footnote_bool } { - \@ifpackageloaded { footnotehyper } + \IfPackageLoadedTF { footnotehyper } { \@@_error:n { footnote~with~footnotehyper~package } } { \usepackage { footnote } } } @@ -21112,10 +14772,10 @@ version 2005/12/01 or later. % 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 } + \IfClassLoadedTF { beamer } { \bool_set_false:N \c_@@_footnote_bool } { - \@ifpackageloaded { footnote } + \IfPackageLoadedTF { footnote } { \@@_error:n { footnotehyper~with~footnote~package } } { \usepackage { footnotehyper } } } @@ -21127,12 +14787,15 @@ version 2005/12/01 or later. % |{savenotes}|. % % \bigskip -% \subsection*{About the package underscore} +% \section{About the package underscore} % +% If the user loads the package \pkg{underscore}, it must be loaded +% \emph{before} the package \pkg{nicematrix}. If it is loaded after, we raise an +% error. % % \begin{macrocode} \bool_new:N \l_@@_underscore_loaded_bool -\@ifpackageloaded { underscore } +\IfPackageLoadedTF { underscore } { \bool_set_true:N \l_@@_underscore_loaded_bool } { } % \end{macrocode} @@ -21142,14 +14805,15 @@ version 2005/12/01 or later. { \bool_if:NF \l_@@_underscore_loaded_bool { - \@ifpackageloaded { underscore } + \IfPackageLoadedTF { underscore } { \@@_error:n { underscore~after~nicematrix } } + { } } } % \end{macrocode} % % \bigskip -% \subsection*{Error messages of the package} +% \section{Error messages of the package} % % \begin{macrocode} \bool_if:NTF \c_@@_messages_for_Overleaf_bool @@ -21194,21 +14858,23 @@ version 2005/12/01 or later. } } { - \bool_lazy_and:nnTF - { \bool_if_p:n \c_@@_tabularx_loaded_bool } - { ! \str_if_eq_p:Vn \g_@@_name_env_str { NiceTabularX } } + \IfPackageLoadedTF { tabularx } { - \int_compare:nNnTF \c@iRow = \c_zero_int - { \@@_fatal:n { X~columns~with~tabularx } } + \str_if_eq:VnTF \g_@@_name_env_str { NiceTabularX } { - \@@_fatal:nn { too~much~cols~for~array } + \int_compare:nNnTF \c@iRow = \c_zero_int + { \@@_fatal:n { X~columns~with~tabularx } } { - However,~this~message~may~be~erroneous:~ - maybe~you~have~used~X~columns~while~'tabularx'~is~loaded,~ - ~which~is~forbidden~(however,~it's~still~possible~to~use~ - X~columns~in~{NiceTabularX}). + \@@_fatal:nn { too~much~cols~for~array } + { + However,~this~message~may~be~erroneous:~ + maybe~you~have~used~X~columns~while~'tabularx'~is~loaded,~ + ~which~is~forbidden~(however,~it's~still~possible~to~use~ + X~columns~in~{NiceTabularX}). + } } } + { \@@_fatal:nn { too~much~cols~for~array } { } } } { \@@_fatal:nn { too~much~cols~for~array } { } } } @@ -21729,7 +15395,8 @@ version 2005/12/01 or later. (in~the~key~'borders'~of~the~command~\token_to_str:N \Block).~ The~available~values~are:~left,~right,~top~and~bottom~(and~you~can~ also~use~the~key~'tikz' - \bool_if:nF \c_@@_tikz_loaded_bool + \IfPackageLoadedTF { tikz } + { } {~if~you~load~the~LaTeX~package~'tikz'}).\\ This~specification~of~border~will~be~ignored. } @@ -21989,7 +15656,7 @@ version 2005/12/01 or later. { siunitx~too~old.\\ You~can't~use~'S'~columns~because~your~version~of~'siunitx'~ - is~too~old.~You~need~at~least~v~3.0~and~your~log~file~says:~"siunitx,~ + is~too~old.~You~need~at~least~v~3.0.38~and~your~log~file~says:~"siunitx,~ \use:c { ver @ siunitx.sty }". \\ This~error~is~fatal. } @@ -22379,634 +16046,6 @@ version 2005/12/01 or later. That~key~will~be~ignored. } % \end{macrocode} -% -% -% -% \vspace{1cm} -% \section{History} -% -% The successive versions of the file |nicematrix.sty| provided by TeXLive are available on the -% \textsc{svn} server of TeXLive:\par\nobreak -% -% \smallskip -% { -% \small -% \nolinkurl{https:www.tug.org/svn/texlive/trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty} -% } -% -% \subsection*{Changes between version 6.17 and 6.18} -% -% New key |opacity| in the commands to color cells, rows and columns. -% -% New key |rounded-corners| for a whole tabular. -% -% -% \subsection*{Changes between version 6.16 and 6.17} -% -% New PGF/Tikz style |nicematrix/cell-node|. -% -% New key |pgf-node-code| -% -% \subsection*{Changes between version 6.15 and 6.16} -% -% It's now possible to put any LaTeX extensible delimiter (|\lgroup|, |\langle|, -% etc.) in the preamble of an environment with preamble (such as |{NiceArray}|) -% by prefixing them by |\left| and |\right|. -% -% New key |code| for the command |\SubMatrix| in the |\CodeAfter|. -% -% \subsection*{Changes between version 6.14 and 6.15} -% -% New key |transparent| for the command |\Block| (with that key, the rules are -% drawn within the block). -% -% \subsection*{Changes between version 6.13 and 6.14} -% -% New keys for the command |\Block| for the vertical position of the content of -% that block. -% -% \subsection*{Changes between version 6.12 and 6.13} -% -% New environment |{TabularNote}| in |{NiceTabular}| with the same semantic as -% the key |tabularnote| (for legibility). -% -% The command |\Hline| nows accepts options (between square brackets). -% -% \subsection*{Changes between version 6.11 and 6.12} -% -% New keys |caption|, |short-caption| and |label| in the environment -% |{NiceTabular}|. -% -% In |{NiceTabular}|, a caption specified by the key |caption| is wrapped to the -% width of the tabular. -% -% Correction of a bug: it's now possible to use |\OverBrace| and |\UnderBrace| -% with \pkg{unicode-math} (with XeLaTeX or LuaLaTeX). -% -% \subsection*{Changes between version 6.10 and 6.11} -% -% New key |matrix/columns-type| to specify the type of columns of the matrices. -% -% New key |ccommand| in |custom-line| and new command |\cdottedline|. -% -% \subsection*{Changes between version 6.9 and 6.10} -% -% New keys |xdots/shorten-start| and |xdots/shorten-end|. -% -% It's possible to use |\line| in the |\CodeAfter| between two blocks (and not -% only two cells). -% -% \subsection*{Changes between version 6.8 and 6.9} -% -% New keys |xdots/radius| and |xdots/inter| for customisation of the continuous -% dotted lines. -% -% New command |\ShowCellNames| available in the |\CodeBefore| and in the |\CodeAfter|. -% -% \subsection*{Changes between version 6.7 and 6.8} -% -% In the notes of a tabular (with the command |\tabularnote|), the duplicates -% are now detected: when several commands |\tabularnote| are used with the same -% argument, only one note is created at the end of the tabular (but all the -% labels are present, of course). -% -% \subsection*{Changes between version 6.6 and 6.7} -% -% Key |color| for |\OverBrace| and |\UnderBrace| in the |\CodeAfter| -% -% Key |tikz| in the key |borders| of a command |\Block| -% -% \subsection*{Changes between version 6.5 and 6.6} -% -% Keys |tikz| and |width| in |custom-line|. -% -% \subsection*{Changes between versions 6.4 and 6.5} -% -% Key |custom-line| in |\NiceMatrixOptions|. -% -% Key |respect-arraystretch|. -% -% \subsection*{Changes between versions 6.3 and 6.4} -% -% New commands |\UnderBrace| and |\OverBrace| in the |\CodeAfter|. -% -% Correction of a bug of the key |baseline| (cf. question 623258 on TeX StackExchange). -% -% Correction of a bug with the columns |V| of \pkg{varwidth}. -% -% Correction of a bug: the use of |\hdottedline| and |:| in the preamble of the -% array (of another letter specified by |letter-for-dotted-lines|) was -% incompatible with the key |xdots/line-style|. -% -% \subsection*{Changes between versions 6.2 and 6.3} -% -% Keys |nb-rows|, |rowcolor| and |bold| for the command |\RowStyle| -% -% Key |name| for the command |\Block|. -% -% Support for the columns |V| of \pkg{varwidth}. -% -% \subsection*{Changes between versions 6.1 and 6.2} -% -% Better compatibility with the classes \cls{revtex4-1} and \cls{revtex4-2}. -% -% Key |vlines-in-sub-matrix|. -% -% \subsection*{Changes between versions 6.0 and 6.1} -% -% Better computation of the widths of the |X| columns. -% -% Key |\color| for the command |\RowStyle|. -% -% \subsection*{Changes between versions 5.19 and 6.0} -% -% Columns |X| and environment |{NiceTabularX}|. -% -% Command |\rowlistcolors| available in the |\CodeBefore|. -% -% In columns with fixed width, the blocks are composed as paragraphs (wrapping -% of the lines). -% -% The key |define-L-C-R| has been deleted. -% -% \subsection*{Changes between versions 5.18 and 5.19} -% -% New key |tikz| for the command |\Block|. -% -% \subsection*{Changes between versions 5.17 and 5.18} -% -% New command |\RowStyle| -% -% \subsection*{Changes between versions 5.16 and 5.17} -% -% The key |define-L-C-R| (only available at load-time) now raises a (non fatal) -% error. -% -% Keys |L|, |C| and |R| for the command |\Block|. -% -% Key |hvlines-except-borders|. -% -% It's now possible to use a key |l|, |r| or |c| with the command -% |\pAutoNiceMatrix| (and the similar ones). -% -% \subsection*{Changes between versions 5.15 and 5.16} -% -% It's now possible to use the cells corresponding to the contents of the nodes -% (of the form |i-j|) in the |\CodeBefore| when the key |create-cell-nodes| of -% that |\CodeBefore| is used. The medium and the large nodes are also available -% if the corresponding keys are used. -% -% \subsection*{Changes between versions 5.14 and 5.15} -% -% Key |hvlines| for the command |\Block|. -% -% The commands provided by \pkg{nicematrix} to color cells, rows and columns -% don't color the cells which are in the ``corners'' (when the key |corner| is -% used). -% -% It's now possible to specify delimiters for submatrices in the preamble of an -% environment. -% -% The version 5.15b is compatible with the version 3.0+ of \pkg{siunitx} -% (previous versions were not). -% -% \subsection*{Changes between versions 5.13 and 5.14} -% -% Nodes of the form |(1.5)|, |(2.5)|, |(3.5)|, etc. -% -% Keys |t| and |b| for the command |\Block|. -% -% Key |corners|. -% -% \subsection*{Changes between versions 5.12 and 5.13} -% -% New command |\arraycolor| in the |\CodeBefore| (with its key -% |except-corners|). -% -% New key |borders| for the command |\Block|. -% -% New command |\Hline| (for horizontal rules not drawn in the blocks). -% -% The keys |vlines| and |hlines| takes in as value a (comma-separated) list of -% numbers (for the rules to draw). -% -% \subsection*{Changes between versions 5.11 and 5.12} -% -% Keywords |\CodeBefore| and |\Body| (alternative syntax to the key -% |code-before|). -% -% New key |delimiters/max-width|. -% -% New keys |hlines|, |vlines| and |hvlines| for the command |\SubMatrix| in the -% |\CodeAfter|. -% -% New key |rounded-corners| for the command |\Block|. -% -% \subsection*{Changes between versions 5.10 and 5.11} -% -% It's now possible, in the |code-before| and in the |\CodeAfter|, to use the -% syntax \verb+|(i-|j)+ for the Tikz node at the intersection of the (potential) -% horizontal rule number~$i$ and the (potential) vertical rule number~$j$. -% -% \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 keyword |\CodeAfter|. -% -% \subsection*{Changes between versions 5.8 and 5.9} -% -% Correction of a bug: in the previous versions, it was not possible to use the -% key |line-style| for the continuous dotted lines when the Tikz library |babel| -% was loaded. -% -% New key |cell-space-limits|. -% -% \subsection*{Changes between versions 5.7 and 5.8} -% -% Keys |cols| and |restart| of the command |\rowcolors| in the |code-before|. -% -% Modification of the behaviour of |\\| in the columns of type |p|, |m| or |b| -% (for a behaviour similar to the environments of \pkg{array}). -% -% Better error messages for the command |\Block|. -% -% \subsection*{Changes between versions 5.6 and 5.7} -% -% New key |delimiters-color| -% -% Keys |fill|, |draw| and |line-width| for the command |\Block|. -% -% \subsection*{Changes between versions 5.5 and 5.6} -% -% Different behaviour for the mono-row blocks. -% -% New command |\NotEmpty|. -% -% \subsection*{Changes between versions 5.4 and 5.5} -% -% The user must never put |\omit| before |\CodeAfter|. -% -% Correction of a bug: the tabular notes |\tabularnotes| were not composed when -% present in a block (except a mono-column block). -% -% \subsection*{Changes between versions 5.3 and 5.4} -% -% Key |tabularnote|. -% -% Different behaviour for the mono-column blocks. -% -% \subsection*{Changes between versions 5.2 and 5.3} -% -% Keys |c|, |r| and |l| for the command |\Block|. -% -% It's possible to use the key |draw-first| with |\Ddots| and |\Iddots| to -% specify which dotted line will be drawn first (the other lines will be drawn -% parallel to that one if parallelization is activated). -% -% \subsection*{Changes between versions 5.1 and 5.2} -% -% The vertical rules specified by \verb+|+ or \verb+||+ in the preamble respect -% the blocks. -% -% Key |respect-blocks| for |\rowcolors| (with a \emph{s}) in the |code-before|. -% -% The variable |\g_nicematrix_code_before_tl| is now public. -% -% The key |baseline| may take in as value an expression of the form -% \textsl{line-i} to align the |\hline| in the row \textsl{i}. -% -% The key |hvlines-except-corners| may take in as value a list of corners (eg: NW,SE). -% -% \subsection*{Changes between versions 5.0 and 5.1} -% -% The vertical rules specified by \verb+|+ in the preamble are not broken by -% |\hline\hline| (and other). -% -% Environment |{NiceTabular*}| -% -% Command |\Vdotsfor| similar to |\Hdotsfor| -% -% The variable |\g_nicematrix_code_after_tl| is now public. -% -% \subsection*{Changes between versions 4.4 and 5.0} -% -% Use of the standard column types |l|, |c| and |r| instead of |L|, |C| and |R|. -% -% It's now possible to use the command |\diagbox| in a |\Block|. -% -% Command |\tabularnote| -% -% \subsection*{Changes between versions 4.3 and 4.4} -% -% New key |hvlines-except-corners| (now deprecated). -% -% \subsection*{Changes between versions 4.2 and 4.3} -% -% The horizontal centering of the content of a |\Block| is correct even when an -% instruction such as |!{\qquad}| is used in the preamble of the array. -% -% It's now possible to use the command |\Block| in the ``last row''. -% -% \subsection*{Changes between versions 4.1 and 4.2} -% -% It's now possible to write |\begin{pNiceMatrix}a&b\\c&d\end{pNiceMatrix}^2| -% with the expected result. -% -% \subsection*{Changes between versions 4.0 and 4.1} -% -% New keys |cell-space-top-limit| and |cell-space-bottom-limit| -% -% New command |\diagbox| -% -% The key |hvline| don't draw rules in the blocks (commands |\Block|) and in the -% virtual blocks corresponding to the dotted lines. -% -% \subsection*{Changes between versions 3.15 and 4.0} -% -% New environment |{NiceTabular}| -% -% Commands to color cells, rows and columns with a perfect result in the \textsc{pdf}. -% -% \subsection*{Changes between versions 3.14 and 3.15} -% -% It's possible to put labels on the dotted lines drawn by |\Ldots|, |\Cdots|, -% |\Vdots|, |\Ddots|, |\Iddots|, |\Hdotsfor| and the command |\line| in the -% |code-after| with the tokens |_| and |^|. -% -% The option |baseline| is now available in all the environments of -% \pkg{nicematrix}. Before, it was available only in |{NiceArray}|. -% -% New keyword |\CodeAfter| (in the environments of \pkg{nicematrix}). -% -% \subsection*{Changes between versions 3.13 and 3.14} -% -% Correction of a bug (question 60761504 on |stackoverflow|). -% -% Better error messages when the user uses |&| or |\\| when |light-syntax| is in -% force. -% -% \subsection*{Changes between versions 3.12 and 3.13} -% -% The behaviour of the command |\rotate| is improved when used in the ``last -% row''. -% -% The option |dotted-lines-margin| has been renamed in |xdots/shorten| and the -% options |xdots/color| and |xdots/line-style| have been added for a complete -% customisation of the dotted lines. -% -% In the environments without preamble (|{NiceMatrix}|, |{pNiceMatrix}|, etc.), -% it's possible to use the options |l| (=|L|) or |r| (=|R|) to specify the type -% of the columns. -% -% The starred versions of the commands |\Cdots|, |\Ldots|, |\Vdots|, |\Ddots| -% and |\Iddots| are deprecated since the version 3.1 of \pkg{nicematrix}. Now, -% one should load \pkg{nicematrix} with the option |starred-commands| to avoid -% an error at the compilation. -% -% The code of \pkg{nicematrix} no longer uses Tikz but only \textsc{pgf}. By -% default, Tikz is \emph{not} loaded by \pkg{nicematrix}. -% -% \subsection*{Changes between versions 3.11 and 3.12} -% -% Command |\rotate| in the cells of the array. -% -% Options |vlines|, |hlines| and |hvlines|. -% -% Option |baseline| pour |{NiceArray}| (not for the other environments). -% -% The name of the Tikz nodes created by the command |\Block| has changed: when -% the command has been issued in the cell $i$|-|$j$, the name is -% $i$|-|$j$|-block| and, if the creation of the ``medium nodes'' is required, a -% node $i$|-|$j$|-block-medium| is created. -% -% If the user tries to use more columns than allowed by its environment, an error -% is raised by nicematrix (instead of a low-level error). -% -% The package must be loaded with the option |obsolete-environments| if we want -% to use the deprecated environments. -% -% \subsection*{Changes between versions 3.10 and 3.11} -% -% Correction of a bug linked to |first-row| and |last-row|. -% -% \subsection*{Changes between version 3.9 and 3.10} -% -% New option |light-syntax| (and |end-of-row|). -% -% New option |dotted-lines-margin| for fine tuning of the dotted lines. -% -% \subsection*{Changes between version 3.8 and 3.9} -% -% New commands |\NiceMatrixLastEnv| and |\OnlyMainNiceMatrix|. -% -% New options |create-medium-nodes| and |create-large-nodes|. -% -% \subsection*{Changes between version 3.7 and 3.8} -% -% New programmation for the command |\Block| when the block has only one row. -% With this programmation, the vertical rules drawn by the specifier -% ``\verb+|+'' at the end of the block is actually drawn. In previous versions, -% they were not because the block of one row was constructed with -% |\multicolumn|. -% -% An error is raised when an obsolete environment is used. -% -% \subsection*{Changes between version 3.6 and 3.7} -% -% The four ``corners'' of the matrix are correctly protected against the four -% codes: |code-for-first-col|, |code-for-last-col|, |code-for-first-row| and -% |code-for-last-row|. -% -% New command |\pAutoNiceMatrix| and its variants (suggestion of Christophe -% Bal). -% -% \subsection*{Changes between version 3.5 and 3.6} -% -% LaTeX counters |iRow| and |jCol| available in the cells of the array. -% -% Addition of |\normalbaselines| before the construction of the array: in -% environments like |{align}| of \pkg{amsmath} the value of |\baselineskip| is -% changed and if the options |first-row| and |last-row| were used in an -% environment of \pkg{nicematrix}, the position of the delimiters was wrong. -% -% A warning is written in the |.log| file if an obsolete environment is used. -% -% There is no longer artificial errors |Duplicate~name| in the environments of -% \pkg{amsmath}. -% -% \subsection*{Changes between version 3.4 and 3.5} -% -% Correction on a bug on the two previous versions where the |code-after| was -% not executed. -% -% \subsection*{Changes between version 3.3 and 3.4} -% -% Following a discussion on TeX StackExchange\footnote{cf. -% |tex.stackexchange.com/questions/510841/nicematrix-and-tikz-external-optimize|}, -% optimization of Tikz externalization is disabled in the environments of -% \pkg{nicematrix} when the class \cls{standalone} or the package -% \pkg{standalone} is used. -% -% \subsection*{Changes between version 3.2 and 3.3} -% -% The options |first-row|, |last-row|, |first-col| and |last-col| are now -% available in the environments |{NiceMatrix}|, |{pNiceMatrix}|, -% |{bNiceMatrix}|, etc. -% -% The option |columns-width=auto| doesn't need any more a second compilation. -% -% The previous version of \pkg{nicematrix} was incompatible with a recent -% version of \pkg{expl3} (released 2019/09/30). This version is compatible. -% -% \subsection*{Changes between version 3.1 and 3.2 (and 3.2a)} -% -% Option |small|. -% -% \subsection*{Changes between version 3.0 and 3.1} -% -% Command |\Block| to draw block matrices. -% -% Error message when the user gives an incorrect value for |last-row|. -% -% A dotted line can no longer cross another dotted line (excepted the dotted -% lines drawn by |\cdottedline|, the symbol ``|:|'' (in the preamble of the -% array) and |\line| in |code-after|). -% -% The starred versions of |\Cdots|, |\Ldots|, etc. are now deprecated because, -% with the new implementation, they become pointless. These starred versions -% are no longer documented. -% -% The vertical rules in the matrices (drawn by ``"|"'') are now compatible with -% the color fixed by \pkg{colortbl}. -% -% Correction of a bug: it was not possible to use the colon ``|:|'' in the -% preamble of an array when |pdflatex| was used with \pkg{french-babel} (because -% \pkg{french-babel} activates the colon in the beginning of the document). -% -% \subsection*{Changes between version 2.3 and 3.0} -% -% Modification of |\Hdotsfor|. Now |\Hdotsfor| erases the |\vlines| (of ``"|"'') -% as |\hdotsfor| does. -% -% Composition of exterior rows and columns on the four sides of the matrix (and -% not only on two sides) with the options |first-row|, |last-row|, |first-col| -% and |last-col|. -% -% \subsection*{Changes between version 2.2.1 and 2.3} -% -% Compatibility with the column type |S| of \pkg{siunitx}. -% -% Option |hlines|. -% -% \subsection*{Changes between version 2.2 and 2.2.1} -% -% Improvment of the vertical dotted lines drawn by the specifier ``:'' in the -% preamble. -% -% Modification of the position of the dotted lines drawn by |\hdottedline|. -% -% \subsection*{Changes between version 2.1.5 and 2.2} -% -% Possibility to draw horizontal dotted lines to separate rows with the command -% |\hdottedline| (similar to the classical command |\hline| and the command -% |\hdashline| of \pkg{arydshln}). -% -% Possibility to draw vertical dotted lines to separate columns with the -% specifier ``|:|'' in the preamble (similar to the classical specifier -% ``"|"'' and the specifier ``|:|'' of \pkg{arydshln}). -% -% \subsection*{Changes between version 2.1.4 and 2.1.5} -% -% Compatibility with the classes \cls{revtex4-1} and \cls{revtex4-2}. -% -% Option |allow-duplicate-names|. -% -% \subsection*{Changes between version 2.1.3 and 2.1.4} -% -% Replacement of some options |O { }| in commands and environments defined with -% \pkg{xparse} by |! O { }| (because a recent version of \pkg{xparse} introduced -% the specifier |!| and modified the default behaviour of the last optional -% arguments). -% -% See |www.texdev.net/2018/04/21/xparse-optional-arguments-at-the-end| -% -% \subsection*{Changes between version 2.1.2 and 2.1.3} -% -% When searching the end of a dotted line from a command like |\Cdots| issued in -% the ``main matrix'' (not in the exterior column), the cells in the exterior -% column are considered as outside the matrix. That means that it's possible to -% do the following matrix with only a |\Cdots| command (and a single |\Vdots|). -% \[\begin{pNiceArray}{Wc{5mm}cWc{5mm}}[first-row,last-col] -% & C_j & \\ -% \mbox{\Large $0$} & \Vdots & \mbox{\Large $0$} \\ -% \strut & a & \Cdots & L_i \\ -% \mbox{\Large $0$} & & \mbox{\Large $0$} \\ -% \end{pNiceArray}\] -% -% \subsection*{Changes between version 2.1 and 2.1.1} -% -% Small corrections: for example, the option |code-for-first-row| is now -% available in the command |\NiceMatrixOptions|. -% -% Following a discussion on -% TeX StackExchange\footnote{cf. -% |tex.stackexchange.com/questions/450841/tikz-externalize-and-nicematrix-package|}, -% Tikz externalization is now deactivated in the environments of the -% package \pkg{nicematrix}.\footnote{Before this version, there was an error -% when using \pkg{nicematrix} with Tikz externalization. In any case, it's not -% possible to externalize the Tikz elements constructed by \pkg{nicematrix} -% because they use the options |overlay| and |remember picture|.} -% -% \subsection*{Changes between version 2.0 and 2.1} -% -% New implementation of the environment |{pNiceArrayRC}|. With this new -% implementation, there is no restriction on the width of the columns. -% -% The package \pkg{nicematrix} no longer loads \pkg{mathtools} but only -% \pkg{amsmath}. -% -% Creation of ``medium nodes'' and ``large nodes''. -% -% \subsection*{Changes between version 1.4 and 2.0} -% -% The versions 1.0 to 1.4 of \pkg{nicematrix} were focused on the continuous -% dotted lines whereas the version 2.0 of \pkg{nicematrix} provides different -% features to improve the typesetting of mathematical matrices. -% -% \subsection*{Changes between version 1.3 and 1.4} -% -% The column types |w| and |W| can now be used in the environments -% |{NiceArray}|, |{pNiceArrayC}| and its variants with the same meaning as in -% the package \pkg{array}. -% -% New option |columns-width| to fix the same width for all the columns of the -% array. -% -% \subsection*{Changes between version 1.2 and 1.3} -% -% New environment |{pNiceArrayC}| and its variants. -% -% Correction of a bug in the definition of |{BNiceMatrix}|, |{vNiceMatrix}| and -% |{VNiceMatrix}| (in fact, it was a typo). -% -% Options are now available locally in |{pNiceMatrix}| and its variants. -% -% The names of the options are changed. The old names were names in ``camel -% style''. -% -% \subsection*{Changes between versions 1.1 and 1.2} -% -% New environment |{NiceArray}| with column types |L|, |C| and |R|. -% -% \subsection*{Changes between versions 1.0 and 1.1} -% -% The dotted lines are no longer drawn with Tikz nodes but with Tikz circles -% (for efficiency). -% -% Modification of the code which is now twice faster. -% -% % % \newpage % \tableofcontents diff --git a/Master/texmf-dist/source/latex/nicematrix/nicematrix.ins b/Master/texmf-dist/source/latex/nicematrix/nicematrix.ins index 814600f7c2b..2fff6fcb8ca 100644 --- a/Master/texmf-dist/source/latex/nicematrix/nicematrix.ins +++ b/Master/texmf-dist/source/latex/nicematrix/nicematrix.ins @@ -30,7 +30,7 @@ and version 1.3 or later is part of all distributions of LaTeX version 2005/12/01 or later. \endpreamble -\generate{\file{nicematrix.sty}{\from{nicematrix.dtx}{package}}} +\generate{\file{nicematrix.sty}{\from{nicematrix-code.dtx}{package}}} \Msg{*********************************************************} \Msg{*} \Msg{* To finish the installation you have to move the} diff --git a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty index e676ebb9bca..e49a5c7964f 100644 --- a/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty +++ b/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty @@ -4,7 +4,7 @@ %% %% The original source files were: %% -%% nicematrix.dtx (with options: `package') +%% nicematrix-code.dtx (with options: `package') %% %% Copyright (C) 2018-2023 by F. Pantigny %% @@ -18,10 +18,8 @@ %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% -\def\myfileversion{6.18} -\def\myfiledate{2023/04/19} - - +\def\myfileversion{6.19} +\def\myfiledate{2023/05/15} \RequirePackage{pgfcore} \usepgfmodule{shapes} \RequirePackage{l3keys2e} @@ -100,7 +98,7 @@ } \hook_gput_code:nnn { begindocument / after } { . } { - \@ifpackageloaded { mdwtab } + \IfPackageLoadedTF { mdwtab } { \__nicematrix_fatal:n { mdwtab~loaded } } { \bool_if:NF \c__nicematrix_no_test_for_array_bool @@ -122,29 +120,12 @@ \cs_generate_variant:Nn \str_lowercase:n { V } \hook_gput_code:nnn { begindocument } { . } { - \@ifpackageloaded { varwidth } - { \bool_const:Nn \c__nicematrix_varwidth_loaded_bool { \c_true_bool } } - { \bool_const:Nn \c__nicematrix_varwidth_loaded_bool { \c_false_bool } } - \@ifpackageloaded { booktabs } - { \bool_const:Nn \c__nicematrix_booktabs_loaded_bool { \c_true_bool } } - { \bool_const:Nn \c__nicematrix_booktabs_loaded_bool { \c_false_bool } } - \@ifpackageloaded { enumitem } - { \bool_const:Nn \c__nicematrix_enumitem_loaded_bool { \c_true_bool } } - { \bool_const:Nn \c__nicematrix_enumitem_loaded_bool { \c_false_bool } } - \@ifpackageloaded { tabularx } - { \bool_const:Nn \c__nicematrix_tabularx_loaded_bool { \c_true_bool } } - { \bool_const:Nn \c__nicematrix_tabularx_loaded_bool { \c_false_bool } } - \@ifpackageloaded { floatrow } - { \bool_const:Nn \c__nicematrix_floatrow_loaded_bool { \c_true_bool } } - { \bool_const:Nn \c__nicematrix_floatrow_loaded_bool { \c_false_bool } } - \@ifpackageloaded { tikz } - { - \bool_const:Nn \c__nicematrix_tikz_loaded_bool \c_true_bool + \IfPackageLoadedTF { tikz } + { \tl_const:Nn \c__nicematrix_pgfortikzpicture_tl { \exp_not:N \tikzpicture } \tl_const:Nn \c__nicematrix_endpgfortikzpicture_tl { \exp_not:N \endtikzpicture } } { - \bool_const:Nn \c__nicematrix_tikz_loaded_bool \c_false_bool \tl_const:Nn \c__nicematrix_pgfortikzpicture_tl { \exp_not:N \pgfpicture } \tl_const:Nn \c__nicematrix_endpgfortikzpicture_tl { \exp_not:N \endpgfpicture } } @@ -189,7 +170,7 @@ } \hook_gput_code:nnn { begindocument } { . } { - \@ifpackageloaded { booktabs } + \IfPackageLoadedTF { booktabs } { \iow_now:Nn \@mainaux \nicematrix@redefine@check@rerun } { } } @@ -202,11 +183,10 @@ { \__nicematrix_old_pgfutil@check@rerun { ##1 } { ##2 } } } } -\bool_new:N \l__nicematrix_colortbl_loaded_bool \hook_gput_code:nnn { begindocument } { . } { - \@ifpackageloaded { colortbl } - { \bool_set_true:N \l__nicematrix_colortbl_loaded_bool } + \IfPackageLoadedTF { colortbl } + { } { \cs_set_protected:Npn \CT@arc@ { } \cs_set:Npn \arrayrulecolor #1 # { \CT@arc { #1 } } @@ -301,23 +281,12 @@ } \cs_generate_variant:Nn \__nicematrix_exp_color_arg:Nn { N V } \cs_new_protected:Npn \__nicematrix_color:n #1 - { - \tl_if_blank:nF { #1 } - { \__nicematrix_exp_color_arg:Nn \color { #1 } } - } + { \tl_if_blank:nF { #1 } { \__nicematrix_exp_color_arg:Nn \color { #1 } } } \cs_generate_variant:Nn \__nicematrix_color:n { V } \cs_set_eq:NN \__nicematrix_old_pgfpointanchor \pgfpointanchor -\bool_new:N \l__nicematrix_siunitx_loaded_bool -\hook_gput_code:nnn { begindocument } { . } - { - \@ifpackageloaded { siunitx } - { \bool_set_true:N \l__nicematrix_siunitx_loaded_bool } - { } - } \hook_gput_code:nnn { begindocument } { . } { - \bool_if:nTF { ! \l__nicematrix_siunitx_loaded_bool } - { \cs_set_eq:NN \__nicematrix_renew_NC@rewrite@S: \prg_do_nothing: } + \IfPackageLoadedTF { siunitx } { \cs_new_protected:Npn \__nicematrix_renew_NC@rewrite@S: { @@ -336,6 +305,7 @@ } } } + { \cs_set_eq:NN \__nicematrix_renew_NC@rewrite@S: \prg_do_nothing: } } \cs_new_protected:Npn \__nicematrix_rescan_for_spanish:N #1 { @@ -354,7 +324,7 @@ \cs_new_protected:Npn \__nicematrix_qpoint:n #1 { \pgfpointanchor { \__nicematrix_env: - #1 } { center } } \int_new:N \g__nicematrix_NiceMatrixBlock_int -\int_new:N \l__nicematrix_note_in_caption_int +\int_new:N \g__nicematrix_notes_caption_int \dim_new:N \l__nicematrix_columns_width_dim \dim_new:N \l__nicematrix_col_width_dim \dim_set:Nn \l__nicematrix_col_width_dim { -1 cm } @@ -431,7 +401,6 @@ \dim_zero_new:N \l__nicematrix_tmpc_dim \dim_zero_new:N \l__nicematrix_tmpd_dim \bool_new:N \g__nicematrix_empty_cell_bool -\bool_new:N \g__nicematrix_second_composition_bool \dim_new:N \g__nicematrix_width_last_col_dim \dim_new:N \g__nicematrix_width_first_col_dim \seq_new:N \g__nicematrix_blocks_seq @@ -528,14 +497,7 @@ \cs_set:Npn \thetabularnote { { \__nicematrix_notes_style:n { tabularnote } } } \hook_gput_code:nnn { begindocument } { . } { - \bool_if:nTF { ! \c__nicematrix_enumitem_loaded_bool } - { - \NewDocumentCommand \tabularnote { m } - { - \__nicematrix_error_or_warning:n { enumitem~not~loaded } - \__nicematrix_gredirect_none:n { enumitem~not~loaded } - } - } + \IfPackageLoadedTF { enumitem } { \newlist { tabularnotes } { enumerate } { 1 } \setlist [ tabularnotes ] @@ -556,7 +518,7 @@ label = \__nicematrix_notes_label_in_list:n { \__nicematrix_notes_style:n { tabularnotes*i } } } - \NewDocumentCommand \tabularnote { m } + \NewDocumentCommand \tabularnote { o m } { \bool_if:nT { \cs_if_exist_p:N \@captype || \l__nicematrix_in_env_bool } { @@ -564,93 +526,123 @@ { \__nicematrix_error:n { tabularnote~forbidden } } { \bool_if:NTF \l__nicematrix_in_caption_bool - { \__nicematrix_tabularnote_ii:n { #1 } } - { \__nicematrix_tabularnote_i:n { #1 } } + { \__nicematrix_tabularnote_caption:nn { #1 } { #2 } } + { \__nicematrix_tabularnote:nn { #1 } { #2 } } } } } - \cs_new_protected:Npn \__nicematrix_tabularnote_i:n #1 + } + { + \NewDocumentCommand \tabularnote { o m } { - \int_zero:N \l_tmpa_int - \bool_if:NT \l__nicematrix_notes_detect_duplicates_bool - { - \seq_map_indexed_inline:Nn \g__nicematrix_notes_seq - { - \tl_if_eq:nnT { #1 } { ##2 } - { \int_set:Nn \l_tmpa_int { ##1 } \seq_map_break: } - } - \int_compare:nNnF \l_tmpa_int = 0 - { \int_add:Nn \l_tmpa_int \l__nicematrix_note_in_caption_int } - } - \int_compare:nNnTF \l_tmpa_int = 0 - { - \int_gincr:N \c@tabularnote - \seq_put_right:Nx \l__nicematrix_notes_labels_seq - { \__nicematrix_notes_format:n { \int_use:c { c @ tabularnote } } } - \seq_gput_right:Nn \g__nicematrix_notes_seq { #1 } - } - { - \seq_put_right:Nx \l__nicematrix_notes_labels_seq - { \__nicematrix_notes_format:n { \int_use:N \l_tmpa_int } } - } - \peek_meaning:NF \tabularnote - { - \hbox_set:Nn \l_tmpa_box - { - \__nicematrix_notes_label_in_tabular:n - { - \seq_use:Nnnn - \l__nicematrix_notes_labels_seq { , } { , } { , } - } - } - \int_gsub:Nn \c@tabularnote { 1 } - \int_set_eq:NN \l_tmpa_int \c@tabularnote - \refstepcounter { tabularnote } - \int_compare:nNnT \l_tmpa_int = \c@tabularnote - { \int_gincr:N \c@tabularnote } - \seq_clear:N \l__nicematrix_notes_labels_seq - \hbox_overlap_right:n { \box_use:N \l_tmpa_box } - \skip_horizontal:n { \box_wd:N \l_tmpa_box } - } + \__nicematrix_error_or_warning:n { enumitem~not~loaded } + \__nicematrix_gredirect_none:n { enumitem~not~loaded } } - \cs_new_protected:Npn \__nicematrix_tabularnote_ii:n #1 + } + } +\cs_new_protected:Npn \__nicematrix_tabularnote:nn #1 #2 + { + \int_zero:N \l_tmpa_int + \bool_if:NT \l__nicematrix_notes_detect_duplicates_bool + { + \seq_map_indexed_inline:Nn \g__nicematrix_notes_seq { - \int_gincr:N \c@tabularnote - \bool_if:NTF \g__nicematrix_caption_finished_bool - { - \int_compare:nNnTF - \c@tabularnote > { \tl_count:N \g__nicematrix_notes_in_caption_seq } - { \int_gset:Nn \c@tabularnote { 1 } } - \seq_if_in:NnF \g__nicematrix_notes_in_caption_seq { #1 } - { \__nicematrix_fatal:n { Identical~notes~in~caption } } - } + \tl_if_eq:nnT { { #1 } { #2 } } { ##2 } + { \int_set:Nn \l_tmpa_int { ##1 } \seq_map_break: } + } + \int_compare:nNnF \l_tmpa_int = \c_zero_int + { \int_add:Nn \l_tmpa_int \g__nicematrix_notes_caption_int } + } + \int_compare:nNnT \l_tmpa_int = \c_zero_int + { + \seq_gput_right:Nn \g__nicematrix_notes_seq { { #1 } { #2 } } + \tl_if_novalue:nT { #1 } { \int_gincr:N \c@tabularnote } + } + \seq_put_right:Nx \l__nicematrix_notes_labels_seq + { + \tl_if_novalue:nTF { #1 } + { + \__nicematrix_notes_format:n { - \seq_if_in:NnTF \g__nicematrix_notes_in_caption_seq { #1 } + \int_eval:n { - \bool_gset_true:N \g__nicematrix_caption_finished_bool - \int_gset:Nn \c@tabularnote { 1 } + \int_compare:nNnTF \l_tmpa_int = \c_zero_int + \c@tabularnote + \l_tmpa_int } - { \seq_gput_right:Nn \g__nicematrix_notes_in_caption_seq { #1 } } } - \seq_put_right:Nx \l__nicematrix_notes_labels_seq - { \__nicematrix_notes_format:n { \int_use:N \c@tabularnote } } - \peek_meaning:NF \tabularnote + } + { #1 } + } + \peek_meaning:NF \tabularnote + { + \hbox_set:Nn \l_tmpa_box + { + \__nicematrix_notes_label_in_tabular:n { - \hbox_set:Nn \l_tmpa_box - { - \__nicematrix_notes_label_in_tabular:n - { - \seq_use:Nnnn - \l__nicematrix_notes_labels_seq { , } { , } { , } - } - } - \seq_clear:N \l__nicematrix_notes_labels_seq - \hbox_overlap_right:n { \box_use:N \l_tmpa_box } - \skip_horizontal:n { \box_wd:N \l_tmpa_box } + \seq_use:Nnnn + \l__nicematrix_notes_labels_seq { , } { , } { , } } } + \int_gsub:Nn \c@tabularnote { 1 } + \int_set_eq:NN \l_tmpa_int \c@tabularnote + \refstepcounter { tabularnote } + \int_compare:nNnT \l_tmpa_int = \c@tabularnote + { \int_gincr:N \c@tabularnote } + \seq_clear:N \l__nicematrix_notes_labels_seq + \hbox_overlap_right:n { \box_use:N \l_tmpa_box } + \skip_horizontal:n { \box_wd:N \l_tmpa_box } + } + } +\cs_new_protected:Npn \__nicematrix_tabularnote_caption:nn #1 #2 + { + \bool_if:NTF \g__nicematrix_caption_finished_bool + { + \int_compare:nNnT + \c@tabularnote = \g__nicematrix_notes_caption_int + { \int_gzero:N \c@tabularnote } + \bool_set_false:N \l_tmpa_bool + \seq_map_inline:Nn \g__nicematrix_notes_in_caption_seq + { \__nicematrix_if_eq_two_three:nnn ##1 { #2 } } + \bool_if:NF \l_tmpa_bool + { \__nicematrix_error:n { Identical~notes~in~caption } } + } + { + \bool_set_false:N \l_tmpa_bool + \seq_map_inline:Nn \g__nicematrix_notes_in_caption_seq + { \__nicematrix_if_eq_two_three:nnn ##1 { #2 } } + \bool_if:NTF \l_tmpa_bool + { + \bool_gset_true:N \g__nicematrix_caption_finished_bool + \int_gset_eq:NN \g__nicematrix_notes_caption_int \c@tabularnote + \int_gzero:N \c@tabularnote + } + { \seq_gput_right:Nn \g__nicematrix_notes_in_caption_seq { { #1 } { #2 } } } + } + \tl_if_novalue:nT { #1 } { \int_gincr:N \c@tabularnote } + \seq_put_right:Nx \l__nicematrix_notes_labels_seq + { + \tl_if_novalue:nTF { #1 } + { \__nicematrix_notes_format:n { \int_use:N \c@tabularnote } } + { #1 } + } + \peek_meaning:NF \tabularnote + { + \__nicematrix_notes_label_in_tabular:n + { \seq_use:Nnnn \l__nicematrix_notes_labels_seq { , } { , } { , } } + \seq_clear:N \l__nicematrix_notes_labels_seq + } + } +\cs_new_protected:Npn \__nicematrix_if_eq_two_three:nnn #1 #2 #3 + { + \tl_if_eq:nnT { #2 } { #3 } + { + \bool_set_true:N \l_tmpa_bool + \seq_map_break: } } +\cs_new_protected:Npn \__nicematrix_count_novalue_first:nn #1 #2 + { \tl_if_novalue:nT { #1 } { \int_gincr:N \g__nicematrix_notes_caption_int } } \cs_new_protected:Npn \__nicematrix_pgf_rect_node:nnnnn #1 #2 #3 #4 #5 { \begin { pgfscope } @@ -944,8 +936,9 @@ { \hook_gput_code:nnn { begindocument } { . } { - \bool_if:NT \c__nicematrix_enumitem_loaded_bool + \IfPackageLoadedTF { enumitem } { \setlist* [ tabularnotes ] { #1 } } + { } } } , enumitem-keys .value_required:n = true , @@ -953,8 +946,9 @@ { \hook_gput_code:nnn { begindocument } { . } { - \bool_if:NT \c__nicematrix_enumitem_loaded_bool + \IfPackageLoadedTF { enumitem } { \setlist* [ tabularnotes* ] { #1 } } + { } } } , enumitem-keys-para .value_required:n = true , @@ -1445,8 +1439,9 @@ \int_gzero:N \g__nicematrix_total_X_weight_int \__nicematrix_expand_clist:N \l__nicematrix_hlines_clist \__nicematrix_expand_clist:N \l__nicematrix_vlines_clist - \bool_if:NT \c__nicematrix_booktabs_loaded_bool + \IfPackageLoadedTF { booktabs } { \tl_put_left:Nn \@BTnormal \__nicematrix_create_row_node_i: } + { } \box_clear_new:N \l__nicematrix_cell_box \normalbaselines \bool_if:NT \l__nicematrix_small_bool @@ -1464,7 +1459,7 @@ } \cs_set_nopar:Npn \ialign { - \bool_if:NTF \l__nicematrix_colortbl_loaded_bool + \IfPackageLoadedTF { colortbl } { \CT@everycr { @@ -1524,7 +1519,7 @@ { \tl_if_empty:NF \l__nicematrix_note_in_caption_tl { - \int_set_eq:NN \l__nicematrix_note_in_caption_int + \int_gset_eq:NN \g__nicematrix_notes_caption_int { \l__nicematrix_note_in_caption_tl } \int_gset:Nn \c@tabularnote { \l__nicematrix_note_in_caption_tl } } @@ -1635,7 +1630,7 @@ \bool_if:NT \g__nicematrix_recreate_cell_nodes_bool \__nicematrix_recreate_cell_nodes: \endpgfpicture \__nicematrix_create_blocks_nodes: - \bool_if:NT \c__nicematrix_tikz_loaded_bool + \IfPackageLoadedTF { tikz } { \tikzset { @@ -1643,6 +1638,7 @@ { overlay , name~prefix = \__nicematrix_env: - } } } + { } \cs_set_eq:NN \cellcolor \__nicematrix_cellcolor \cs_set_eq:NN \rectanglecolor \__nicematrix_rectanglecolor \cs_set_eq:NN \roundedrectanglecolor \__nicematrix_roundedrectanglecolor @@ -2363,7 +2359,7 @@ \tl_set:Nn \l_tmpa_tl { #1 } \tl_replace_all:Nnn \l_tmpa_tl { \__nicematrix_S: } { S } \__nicematrix_keys_p_column:V \l_tmpa_tl - \bool_if:NTF \c__nicematrix_varwidth_loaded_bool + \IfPackageLoadedTF { varwidth } { \__nicematrix_patch_preamble_iv_iv:nn { #2 } { varwidth } } { \__nicematrix_error_or_warning:n { varwidth~not~loaded } @@ -2439,7 +2435,7 @@ { \__nicematrix_patch_preamble_vii_ii:n { #1 } } \cs_new_protected:Npn \__nicematrix_patch_preamble_vii_ii:n #1 { - \cs_if_exist:NTF \siunitx_cell_begin:w + \IfPackageAtLeastTF { siunitx } { 2022/01/01 } { \tl_gput_right:NV \g__nicematrix_preamble_tl \g__nicematrix_pre_cell_tl \tl_gclear:N \g__nicematrix_pre_cell_tl @@ -2860,15 +2856,14 @@ \bool_set_false:N \g__nicematrix_caption_finished_bool \int_gzero:N \c@tabularnote \__nicematrix_insert_caption: - \int_gset:Nn \c@tabularnote - { \seq_count:N \g__nicematrix_notes_in_caption_seq } - \int_compare:nNnF \c@tabularnote = 0 + \int_compare:nNnT \g__nicematrix_notes_caption_int > 0 { \tl_gput_right:Nx \g__nicematrix_aux_tl { \tl_set:Nn \exp_not:N \l__nicematrix_note_in_caption_tl - { \int_eval:n { \c@tabularnote } } + { \int_use:N \g__nicematrix_notes_caption_int } } + \int_gzero:N \g__nicematrix_notes_caption_int } } } @@ -2902,11 +2897,13 @@ { \group_begin: \bool_set_true:N \l__nicematrix_in_caption_bool - \bool_if:NT \c__nicematrix_floatrow_loaded_bool + \IfPackageLoadedTF { floatrow } { \cs_set_eq:NN \@makecaption \FR@makecaption } + { } \tl_if_empty:NTF \l__nicematrix_short_caption_tl - { \caption { \l__nicematrix_caption_tl } } - { \caption [ \l__nicematrix_short_caption_tl ] { \l__nicematrix_caption_tl } } + { \caption } + { \caption [ \l__nicematrix_short_caption_tl ] } + { \l__nicematrix_caption_tl } \tl_if_empty:NF \l__nicematrix_label_tl { \label { \l__nicematrix_label_tl } } \group_end: } @@ -2932,13 +2929,17 @@ \bool_if:NTF \l__nicematrix_notes_para_bool { \begin { tabularnotes* } - \seq_map_inline:Nn \g__nicematrix_notes_seq { \item ##1 } \strut + \seq_map_inline:Nn \g__nicematrix_notes_seq + { \__nicematrix_one_tabularnote:nn ##1 } + \strut \end { tabularnotes* } \par } { \tabularnotes - \seq_map_inline:Nn \g__nicematrix_notes_seq { \item ##1 } \strut + \seq_map_inline:Nn \g__nicematrix_notes_seq + { \__nicematrix_one_tabularnote:nn ##1 } + \strut \endtabularnotes } } @@ -2946,7 +2947,7 @@ \group_end: \bool_if:NT \l__nicematrix_notes_bottomrule_bool { - \bool_if:NTF \c__nicematrix_booktabs_loaded_bool + \IfPackageLoadedTF { booktabs } { \skip_vertical:N \aboverulesep { \CT@arc@ \hrule height \heavyrulewidth } @@ -2958,6 +2959,12 @@ \seq_gclear:N \g__nicematrix_notes_in_caption_seq \int_gzero:N \c@tabularnote } +\cs_set_protected:Npn \__nicematrix_one_tabularnote:nn #1 + { + \tl_if_novalue:nTF { #1 } + { \item } + { \item [ \__nicematrix_notes_label_in_list:n { #1 } ] } + } \cs_new_protected:Npn \__nicematrix_use_arraybox_with_notes_b: { \pgfpicture @@ -3562,7 +3569,9 @@ } \NewDocumentEnvironment { NiceTabularX } { m O { } m ! O { } } { - \bool_if:NT \c__nicematrix_tabularx_loaded_bool { \newcolumntype { X } { \__nicematrix_X } } + \IfPackageLoadedTF { tabularx } + { \newcolumntype { X } { \__nicematrix_X } } + { } \str_gset:Nn \g__nicematrix_name_env_str { NiceTabularX } \dim_zero_new:N \l__nicematrix_width_dim \dim_set:Nn \l__nicematrix_width_dim { #1 } @@ -3678,7 +3687,7 @@ \__nicematrix_adjust_pos_of_blocks_seq: \tl_if_empty:NF \l__nicematrix_hlines_clist \__nicematrix_draw_hlines: \tl_if_empty:NF \l__nicematrix_vlines_clist \__nicematrix_draw_vlines: - \bool_if:NT \c__nicematrix_tikz_loaded_bool + \IfPackageLoadedTF { tikz } { \tikzset { @@ -3690,6 +3699,7 @@ } } } + { } \cs_set_eq:NN \ialign \__nicematrix_old_ialign: \cs_set_eq:NN \SubMatrix \__nicematrix_SubMatrix \cs_set_eq:NN \UnderBrace \__nicematrix_UnderBrace @@ -5897,12 +5907,11 @@ } \keys_define:nn { NiceMatrix / custom-line } { - % here, we will use change in the future to use .str_set:N - letter .code:n = \str_set:Nn \l__nicematrix_letter_str { #1 } , + letter .str_set:N = \l__nicematrix_letter_str , letter .value_required:n = true , - command .code:n = \str_set:Nn \l__nicematrix_command_str { #1 } , + command .str_set:N = \l__nicematrix_command_str , command .value_required:n = true , - ccommand .code:n = \str_set:Nn \l__nicematrix_ccommand_str { #1 } , + ccommand .str_set:N = \l__nicematrix_ccommand_str , ccommand .value_required:n = true , } \cs_new_protected:Npn \__nicematrix_custom_line_i:n #1 @@ -5913,8 +5922,9 @@ \keys_set:nn { NiceMatrix / custom-line-bis } { #1 } \bool_if:NT \l__nicematrix_tikz_rule_bool { - \cs_if_exist:NF \tikzpicture - { \__nicematrix_error:n { tikz~in~custom-line~without~tikz } } + \IfPackageLoadedTF { tikz } + { } + { \__nicematrix_error:n { tikz~in~custom-line~without~tikz }} \bool_if:NT \l__nicematrix_color_bool { \__nicematrix_error:n { color~in~custom-line~with~tikz } } } @@ -6440,7 +6450,9 @@ } } } - \seq_mapthread_function:NNN + \cs_if_exist_use:NF + \seq_map_pairwise_function:NNN + \seq_mapthread_function:NNN \g__nicematrix_multicolumn_cells_seq \g__nicematrix_multicolumn_sizes_seq \__nicematrix_node_for_multicolumn:nn @@ -6743,7 +6755,7 @@ \keys_define:nn { NiceMatrix / Block / SecondPass } { tikz .code:n = - \bool_if:NTF \c__nicematrix_tikz_loaded_bool + \IfPackageLoadedTF { tikz } { \seq_put_right:Nn \l__nicematrix_tikz_seq { { #1 } } } { \__nicematrix_error:n { tikz~key~without~tikz } } , tikz .value_required:n = true , @@ -8244,7 +8256,10 @@ \pgf@relevantforpicturesizefalse \pgfpathrectanglecorners { \__nicematrix_qpoint:n { 1 } } - { \__nicematrix_qpoint:n { \int_eval:n { \c@iRow + 1 } } } + { + \__nicematrix_qpoint:n + { \int_eval:n { \int_max:nn \c@iRow \c@jCol + 1 } } + } \pgfsetfillopacity { 0.75 } \pgfsetfillcolor { white } \pgfusepathqfill @@ -8376,35 +8391,36 @@ } \bool_if:NT \c__nicematrix_footnote_bool { - \@ifclassloaded { beamer } + \IfClassLoadeTF { beamer } { \bool_set_false:N \c__nicematrix_footnote_bool } { - \@ifpackageloaded { footnotehyper } + \IfPackageLoadedTF { footnotehyper } { \__nicematrix_error:n { footnote~with~footnotehyper~package } } { \usepackage { footnote } } } } \bool_if:NT \c__nicematrix_footnotehyper_bool { - \@ifclassloaded { beamer } + \IfClassLoadedTF { beamer } { \bool_set_false:N \c__nicematrix_footnote_bool } { - \@ifpackageloaded { footnote } + \IfPackageLoadedTF { footnote } { \__nicematrix_error:n { footnotehyper~with~footnote~package } } { \usepackage { footnotehyper } } } \bool_set_true:N \c__nicematrix_footnote_bool } \bool_new:N \l__nicematrix_underscore_loaded_bool -\@ifpackageloaded { underscore } +\IfPackageLoadedTF { underscore } { \bool_set_true:N \l__nicematrix_underscore_loaded_bool } { } \hook_gput_code:nnn { begindocument } { . } { \bool_if:NF \l__nicematrix_underscore_loaded_bool { - \@ifpackageloaded { underscore } + \IfPackageLoadedTF { underscore } { \__nicematrix_error:n { underscore~after~nicematrix } } + { } } } \bool_if:NTF \c__nicematrix_messages_for_Overleaf_bool @@ -8437,21 +8453,23 @@ } } { - \bool_lazy_and:nnTF - { \bool_if_p:n \c__nicematrix_tabularx_loaded_bool } - { ! \str_if_eq_p:Vn \g__nicematrix_name_env_str { NiceTabularX } } + \IfPackageLoadedTF { tabularx } { - \int_compare:nNnTF \c@iRow = \c_zero_int - { \__nicematrix_fatal:n { X~columns~with~tabularx } } + \str_if_eq:VnTF \g__nicematrix_name_env_str { NiceTabularX } { - \__nicematrix_fatal:nn { too~much~cols~for~array } + \int_compare:nNnTF \c@iRow = \c_zero_int + { \__nicematrix_fatal:n { X~columns~with~tabularx } } { - However,~this~message~may~be~erroneous:~ - maybe~you~have~used~X~columns~while~'tabularx'~is~loaded,~ - ~which~is~forbidden~(however,~it's~still~possible~to~use~ - X~columns~in~{NiceTabularX}). + \__nicematrix_fatal:nn { too~much~cols~for~array } + { + However,~this~message~may~be~erroneous:~ + maybe~you~have~used~X~columns~while~'tabularx'~is~loaded,~ + ~which~is~forbidden~(however,~it's~still~possible~to~use~ + X~columns~in~{NiceTabularX}). + } } } + { \__nicematrix_fatal:nn { too~much~cols~for~array } { } } } { \__nicematrix_fatal:nn { too~much~cols~for~array } { } } } @@ -8816,7 +8834,8 @@ (in~the~key~'borders'~of~the~command~\token_to_str:N \Block).~ The~available~values~are:~left,~right,~top~and~bottom~(and~you~can~ also~use~the~key~'tikz' - \bool_if:nF \c__nicematrix_tikz_loaded_bool + \IfPackageLoadedTF { tikz } + { } {~if~you~load~the~LaTeX~package~'tikz'}).\\ This~specification~of~border~will~be~ignored. } @@ -9003,7 +9022,7 @@ { siunitx~too~old.\\ You~can't~use~'S'~columns~because~your~version~of~'siunitx'~ - is~too~old.~You~need~at~least~v~3.0~and~your~log~file~says:~"siunitx,~ + is~too~old.~You~need~at~least~v~3.0.38~and~your~log~file~says:~"siunitx,~ \use:c { ver @ siunitx.sty }". \\ This~error~is~fatal. } |