tikz.dev / nicematrix Manual

The nicematrix package

2 The vertical space between the rows

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.

Compiled output

$\begin{pmatrix}
\frac{1}{2} & -\frac{1}{2} \\
\frac{1}{3} & \frac{1}{4} \\
\end{pmatrix}$

Inspired by the package cellspace which deals with that problem, the package nicematrix provides two keys cell-space-top-limit\(^+\) and cell-space-bottom-limit\(^+\) similar to the parameters of cellspace called \cellspacetoplimit and \cellspacebottomlimit.1

The initial values of these parameters is \(0\) pt.

There is also a key cell-space-limits\(^+\) to set both parameters at once.

All these keys have a normal syntax but also an “additive” syntax. That means that it’s possible to write, for example, cell-space-limits = 2pt but also cell-space-limits += 1pt.

Compiled output

$\begin{pNiceMatrix}[cell-space-limits = 1pt]
\frac12 & -\frac12 \\
\frac13 & \frac14 \\
\end{pNiceMatrix}$

It’s also possible to change these parameters for only a few rows by using the command \RowStyle provided by nicematrix (cf. 7).

1 One should remark that these parameters apply also to the columns of type S of siunitx whereas the package cellspace is not able to act on such columns of type S.