The nicematrix package
The package nicematrix
Abstract
The LaTeX package nicematrix provides new environments similar to the classical environments {tabular}, {array} and {matrix} of array and amsmath but with extended features.
Contents
1The environments of this package
2The vertical space between the rows
3The vertical position of the arrays
4The blocks
5The rules
6The color of the background of the rows and columns
7The command \RowStyle
8The width of the columns
9The exterior rows and columns
10Dotted leaders in the matrices
11Delimiters in the preamble of the environment
12The \CodeAfter
13Captions and notes in the tabulars
14Other features
- 14.1Trees
- 14.2The key rounded-corners of the environments
- 14.3The command \ShowCellNames
- 14.4Use of the column type S of siunitx
- 14.5Default column type in {NiceMatrix}
- 14.6The command \rotate
- 14.7The key small
- 14.8\AutoNiceMatrix and the counters iRow and jCol
- 14.9The key light-syntax
- 14.10Color of the delimiters
- 14.11The environment {NiceArrayWithDelims}
- 14.12The command \OnlyMainNiceMatrix
15Explicit use of TikZ with nicematrix
16API for the developers
17Technical remarks
18Examples
- 18.1Notes in the tabulars
- 18.2Use of the key “tikz” of the command \Block
- 18.3Use with tcolorbox
- 18.4A sign chart
- 18.5A variation table
- 18.6Example of description of a table of a database
- 18.7Use of the key borders of the command \Block
- 18.8Leaders in the matrices
- 18.9How the illustrate the numbers of rows and columns in a matrix
- 18.10Stacks of matrices
- 18.11How to highlight cells of a matrix
- 18.12A triangular tabular
History
Introduction
The package 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 nicematrix with a TeX distribution such as MiKTeX, TeX Live or MacTeX.
Remark
If you use LaTeX via Internet with, for example, Overleaf or TeXPage, you can upload the file nicematrix.sty in the repertory of your project in order to take full advantage of the latest version de nicematrix.1
This package can be used with xelatex, lualatex, pdflatex but also by the classical workflow latex-dvips-ps2pdf (or Adobe Distiller). However, the file nicematrix.dtx of the present documentation should be compiled with LuaLaTeX.
This package requires and loads the packages array, amsmath, pgfcore and the module shapes of pgf (tikz, which is a layer over pgf, is not loaded). The final user only has to load the package with \usepackage{nicematrix}.
The idea of nicematrix is to create pgf nodes under the cells and the positions of the rules of the tabular created by array and to use these nodes to develop new features. As usual with pgf, the coordinates of these nodes are written in the aux file to be used on the next compilation and that’s why nicematrix may need several compilations2. One must not use the command \nofiles (which prevents the creation of the aux file).
Most features of nicematrix may be used without explicit use of pgf or TikZ (which, in fact, is not loaded by default).
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).
1 The latest version of the file nicematrix.sty may be downloaded on the GitHub depot of nicematrix:
https://github.com/fpantigny/nicematrix/releases
2 If you use Overleaf, Overleaf will do automatically a sufficient number of compilations (by using latexmk).