diff options
Diffstat (limited to 'macros/latex/contrib/nicematrix/nicematrix.tex')
-rw-r--r-- | macros/latex/contrib/nicematrix/nicematrix.tex | 229 |
1 files changed, 129 insertions, 100 deletions
diff --git a/macros/latex/contrib/nicematrix/nicematrix.tex b/macros/latex/contrib/nicematrix/nicematrix.tex index 91758773dd..77c4e8d9f9 100644 --- a/macros/latex/contrib/nicematrix/nicematrix.tex +++ b/macros/latex/contrib/nicematrix/nicematrix.tex @@ -435,8 +435,8 @@ 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. +The command |\Block| must be used in the upper leftmost cell of the cells of the +block with two mandatory arguments. \begin{itemize} \item The first argument is the size of the block with the syntax @@ -483,7 +483,9 @@ 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.} +the content of the block. It's also possible to put in that optional argument +the command |\rotate| provided by \pkg{nicematrix} (cf. part~\ref{rotate}, +p.~\pageref{rotate}).} \medskip \begin{BVerbatim}[baseline=c,boxwidth=10.6cm] @@ -515,6 +517,10 @@ follows: \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{opacity (key of \texttt{\textbackslash Block})} +\colorbox{yellow!50}{\bfseries New 6.22}\enskip the key +\Definition{opacity} sets the opacity of +the filling color specified by |fill|; \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 @@ -529,7 +535,8 @@ color; 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 +block, as always with \pkg{nicematrix}: the rules are not drawn in the blocks, +except when they have the key |transparent| (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 @@ -842,24 +849,24 @@ is used for the horizontal alignement.}, \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 +With the key \Definition{v-center}, the content of the block is vertically centered. +\item With the key \Definition{t}, the baseline of the content of the block is aligned +with the baseline of the first row concerned by the block. +\item with the key \Definition{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. +\item With the key \Definition{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. +\item With the key \Definition{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). +When no key is given, the key |v-center| applies (except in the mono-row blocks). @@ -967,7 +974,7 @@ text & text \\ \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 +\pkg{nicematrix} (except |\vline|). However, there is some small differences with the classical environments. \bigskip @@ -1826,7 +1833,7 @@ h & i & j \\ \bigskip \item The command \Definition{\textbackslash arraycolor} takes in as mandatory -argument a color and color the whole tabular with that color (excepted the +argument a color and color the whole tabular with that color (except the potential exterior rows and columns: cf.~p.~\pageref{exterior}). It's only a particular case of |\rectanglecolor|. @@ -2227,7 +2234,10 @@ preamble of the array); \item \colorbox{yellow!50}{\textbf{New 6.21}}\enskip |\rowcolors| which takes in as arguments two colors and color the rest of the tabular with those colors; \item \colorbox{yellow!50}{\textbf{New 6.21}}\enskip |\rowlistcolors| which takes in as argument a color and color the rest of -the tabular with the colors of that list of colors. +the tabular with the colors of that list of colors.\footnote{When the command + |\rowlistcolors| (or the command |\rowcolors| is used in a cell of the + column~$j$ of the array, the command applies only on the columns above~$j$ (by +design).} \end{itemize} \smallskip @@ -2278,23 +2288,23 @@ will be applied to each cell on the rest of the current row. 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 +\item \index{nb-rows (key of \texttt{\textbackslash RowStyle})} The key \Definition{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 keys \Definition{cell-space-top-limit}, \Definition{cell-space-bottom-limit} and +\Definition{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 +The key \Definition{rowcolor} sets the color of the background and the key +\Definition{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 of LaTeX).} -\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. +\item \index{bold (key of \texttt{\textbackslash RowStyle})} The key +\Definition{bold} enforces bold characters for the cells of the row, both in +math and text mode. \end{itemize} \medskip @@ -2350,7 +2360,7 @@ Rio & Tokyo & Oslo \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 +width of all the columns (except the potential exterior columns: cf. p.~\pageref{exterior}) directly with the key |columns-width|. \medskip @@ -2745,7 +2755,7 @@ 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 +a dotted line drawn in that exterior ``first row'' (except 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 @@ -3135,12 +3145,18 @@ $\begin{pmatrix} \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 +The commands |\Ldots|, |\Cdots|, |\Vdots|, |\Ddots|, |\Iddots|, |\Hdotsfor| and +|\Vdotsfor| (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|. +\colorbox{yellow!50}{\textbf{New 6.22}}\enskip The version 6.22 introduces a new +label, specified by the token ``|:|'' for a label placed on the line. The label +is composed on a white background which is put on the line previously drawn (see +example on p.~\pageref{ex:colon}). + +\bigskip \begin{BVerbatim}[baseline=c,boxwidth=10cm] $\begin{bNiceMatrix} 1 & \hspace*{1cm} & 0 \\[8mm] @@ -3156,7 +3172,6 @@ $\begin{bNiceMatrix} \bigskip -\colorbox{yellow!50}{\textbf{New 6.20}}\enskip With the key |xdots/horizontal-labels|, the labels stay horizontal.\par\nobreak % \medskip @@ -3232,7 +3247,13 @@ is 0.53~pt. The keys \Definition{xdots/shorten-start} and \Definition{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). +length dependent of the current font).\footnote{In fact, when + |xdots/shorten|, |xdots/shorten-start| and |xdots/shorten-end| are used in + |\NiceMatrixOptions| or at the level of an environment (such as + |{pNiceMatrix}|), those keys only apply to the extremeties of dotted lines + corresponding to a non-empty content of a cell. When they are used for a command + such as |\Cdots| (and, in that case, their names are |shorten|, + |shorten-start| and |shorten-end|), they apply to all the extremities.} \bigskip The option \Definition{xdots/inter} fixes the length between the dots. The @@ -3427,8 +3448,9 @@ 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.} +|delimiters/color|, |rules| and its sub-keys, |sub-matrix| (linked to the +command |\SubMatrix|) and its sub-keys and |xdots| (for the command |\line|) and +its sub-keys.} \medskip @@ -3927,7 +3949,7 @@ 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| +the tabular (except 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}. @@ -3988,7 +4010,7 @@ perfectly compatible with \pkg{hyperref}. 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 +a width of line equal to the width of the array (except 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}|. @@ -4557,18 +4579,16 @@ $A = \begin{pNiceMatrix}[last-row=4,last-col=4] \end{varwidth} \bigskip -\colorbox{yellow!50}{\textbf{New 6.21}}\enskip The command |\tabular| has a key -|c|: |\tabular[c]|. When that key is used, the content is composed in a -|\vcenter| and, therefore, in most cases, we will have a vertical alignment. - - +\colorbox{yellow!50}{\textbf{New 6.21}}\enskip The command |\rotate| has a key +|c|: |\rotate[c]| (spaces are deleted after |\rotate[c]|). When that key is +used, the content is composed in a |\vcenter| and, therefore, in most cases, we +will have a vertical alignment. \bigskip Caution: the command |\rotate| is designed to be used in a |\Block| or in columns of type |l|, |r|, |c|, |w| ou |W|; if it is used in other column types (such as |p{...}|), the result will maybe differ from what is expected. - \subsection{The option small} \label{small} @@ -4640,8 +4660,8 @@ 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). +(except the potential exterior rows) and |jCol| represents the total number +of columns (except the potential exterior columns). \medskip \begin{BVerbatim}[baseline=c,boxwidth=10.6cm] @@ -4911,7 +4931,7 @@ $\begin{pNiceMatrix} \end{pNiceMatrix}$ \medskip -The nodes of the last column (excepted the potential ``last column'' specified +The nodes of the last column (except 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$. @@ -4936,10 +4956,9 @@ a & a & a \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: +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 @@ -4964,13 +4983,13 @@ For an example of utilisation, see part~\ref{triangular}, p.~\pageref{triangular \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. +\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} @@ -5717,6 +5736,9 @@ be loaded before the |\documentclass| with |\RequirePackage|: \documentclass{sn-jnl} \end{Verbatim} +However, it seems that this is no longer mandatory with the recent versions of +\cls{sn-jnl}. + \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}) @@ -5754,7 +5776,7 @@ For the following example, we also need the Tikz library |patterns|. \begin{Verbatim} \ttfamily \small -\begin{NiceTabular}{X[m]X[m]X[m]}[hvlines,cell-space-limits=3pt] +\begin{NiceTabular}{X[m]X[m]X[m]}[hvlines,cell-space-limits=3pt,rounded-corners] \Block[~emphase#tikz={pattern=grid,pattern color=lightgray}@]{} {pattern = grid,\\ pattern color = lightgray} & \Block[~emphase#tikz={pattern = north west lines,pattern color=blue}@]{} @@ -5770,7 +5792,7 @@ For the following example, we also need the Tikz library |patterns|. \begin{center} \ttfamily \small -\begin{NiceTabular}{X[m]X[m]X[m]}[hvlines,cell-space-limits=3pt] +\begin{NiceTabular}{X[m]X[m]X[m]}[hvlines,cell-space-limits=3pt,rounded-corners] \Block[tikz={pattern=grid,pattern color=lightgray}]{} {pattern = grid,\\ pattern color = lightgray} & \Block[tikz={pattern = north west lines,pattern color=blue}]{} @@ -5826,7 +5848,7 @@ seven & eight & nine 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}) +the rules except on the borders (which are, of course, added by \pkg{tcolorbox}) \medskip \begin{BVerbatim} @@ -5834,7 +5856,6 @@ the rules excepted on the borders (which are, of course, added by \pkg{tcolorbox { colframe = blue!50!black , colback = white , - colupper = red!50!black , fonttitle = \bfseries , nobeforeafter , center title @@ -5875,7 +5896,6 @@ the rules excepted on the borders (which are, of course, added by \pkg{tcolorbox { colframe = blue!50!black , colback = white , - colupper = red!50!black , fonttitle = \bfseries , nobeforeafter , center title @@ -5905,34 +5925,6 @@ the rules excepted on the borders (which are, of course, added by \pkg{tcolorbox \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} @@ -6168,36 +6160,65 @@ In fact, it's even possible to draw solid lines with the commands |\Cdots|, has been loaded, which impacts the shape of the arrow tips.} \begin{Verbatim} -\tikzset{H/.style = {solid,<->,shorten > = -1mm, shorten < = -1mm}} -\tikzset{V/.style = {solid,<->}} -\NiceMatrixOptions{xdots/horizontal-labels} +\NiceMatrixOptions{xdots={horizontal-labels,line-style = <->}} $\begin{pNiceArray}{ccc|cc}[first-row,last-col,margin] -\Hdotsfor[line-style=H]{3}^{3} & \Hdotsfor[line-style=H]{2}^{2} \\ -2 & 1 & 1 & 1 & 1 & \hspace*{4mm}\Vdotsfor[line-style=V]{3}^{3}\\ +\Hdotsfor{3}^{3} & \Hdotsfor{2}^{2} \\ +2 & 1 & 1 & 1 & 1 & \Vdotsfor{3}^{3}\\ 1 & 1 & 1 & 1 & 1 \\ 1 & 1 & 1 & 1 & 1 \\ \Hline -1 & 1 & 1 & 1 & 1 & \Vdotsfor[line-style=V]{2}^{2}\\ +1 & 1 & 1 & 1 & 1 & \Vdotsfor{2}^{2}\\ 1 & 1 & 1 & 1 & 1 \\ \end{pNiceArray}$ \end{Verbatim} \begin{center} -\tikzset{H/.style = {solid,<->,shorten > = -1mm, shorten < = -1mm}} -\tikzset{V/.style = {solid,<->}} -\NiceMatrixOptions{xdots/horizontal-labels} +\NiceMatrixOptions{xdots={horizontal-labels,line-style = <->}} $\begin{pNiceArray}{ccc|cc}[first-row,last-col,margin] -\Hdotsfor[line-style=H]{3}^{3} & \Hdotsfor[line-style=H]{2}^{2} \\ -2 & 1 & 1 & 1 & 1 & \hspace*{4mm}\Vdotsfor[line-style=V]{3}^{3}\\ +\Hdotsfor{3}^{3} & \Hdotsfor{2}^{2} \\ +2 & 1 & 1 & 1 & 1 & \Vdotsfor{3}^{3}\\ 1 & 1 & 1 & 1 & 1 \\ 1 & 1 & 1 & 1 & 1 \\ \Hline -1 & 1 & 1 & 1 & 1 & \Vdotsfor[line-style=V]{2}^{2}\\ +1 & 1 & 1 & 1 & 1 & \Vdotsfor{2}^{2}\\ 1 & 1 & 1 & 1 & 1 \\ \end{pNiceArray}$ \end{center} +\interitem +\label{ex:colon} +If you want the lable \emph{on the line}, you should use the special token~``|:|'': + +\begin{Verbatim} +\NiceMatrixOptions{xdots={horizontal-labels,line-style = <->}} +$\begin{pNiceArray}{ccc|cc}[first-row,last-col,margin] +\Hdotsfor{3}:{3} & \Hdotsfor{2}:{2} \\ +2 & 1 & 1 & 1 & 1 & \Vdotsfor{3}:{3}\\ +1 & 1 & 1 & 1 & 1 \\ +1 & 1 & 1 & 1 & 1 \\ +\Hline +1 & 1 & 1 & 1 & 1 & \Vdotsfor{2}:{2}\\ +1 & 1 & 1 & 1 & 1 \\ +\end{pNiceArray}$ +\end{Verbatim} + + +\begin{center} +\NiceMatrixOptions{xdots={horizontal-labels,line-style = <->}} +$\begin{pNiceArray}{ccc|cc}[first-row,last-col,margin] +\Hdotsfor{3}:{3} & \Hdotsfor{2}:{2} \\ +2 & 1 & 1 & 1 & 1 & \Vdotsfor{3}:{3}\\ +1 & 1 & 1 & 1 & 1 \\ +1 & 1 & 1 & 1 & 1 \\ +\Hline +1 & 1 & 1 & 1 & 1 & \Vdotsfor{2}:{2}\\ +1 & 1 & 1 & 1 & 1 \\ +\end{pNiceArray}$ +\end{center} + + + \subsection{Dashed rules} \label{dashed} @@ -6903,6 +6924,14 @@ The successive versions of the file |nicematrix.sty| provided by TeXLive are ava \nolinkurl{https:www.tug.org/svn/texlive/trunk/Master/texmf-dist/tex/latex/nicematrix/nicematrix.sty} } +\subsection*{Changes between version 6.21 and 6.22} + +Key |opacity| for the command |\Block|. + +It's now possible to put a label on a ``continuous dotted line'' with the +specifier ``|:|''. + + \subsection*{Changes between version 6.20a and 6.21} Key |c| for the command |\tabularnote|. |