Following this question the nicematrix v3.3 (2019/10/01) package from @f-pantigny has no problems with the tikz tikzexternalize library.
But this code
\documentclass{standalone}
\usepackage{amstext}
\usepackage{nicematrix}
\usetikzlibrary{external}
\tikzexternalize
\begin{document}
$
\begin{pNiceArray}{CCCC|C}
\star & \circ & \Cdots & \circ & \circ \\
0 & * & \Ddots & \Vdots & \Vdots \\
\Vdots & \Ddots & \Ddots & \circ & \\
0 & \Cdots & 0 & 0 & \circ
\end{pNiceArray}
$
\tikz\draw (0,0) circle [radius=1cm];
\end{document}
don't compile (TeX 3.14159265 (TeX Live 2019/W32TeX)) with the error
Package tikz Error: Sorry, the system call 'pdflatex -shell-escape -halt-on-e
The externalize logfile has the lines
A tikzpicture has been optimized away. Use '/tikz/external/optimize=false' to d
isable this.
! Package nicematrix Error: A dotted line can't be drawn because you have not
(nicematrix) put all the ampersands required on the row 3.
(nicematrix) If you go on, this dotted line will be ignored.
If we use
\tikzexternalize[optimize=false]
then everything compile.
Is this a bug and if yes, why?
@f-pantigny: Maybe a fix is to add at line 586 from nicematrix.sty
external / optimize = false
.sty, for sure. Somebody might prefer not to externalisenicematrixenvironments and keep optimisation. Hard-coding it in the.stywould confuse things. Maybe something in the documentation would be better or an option. – cfr Oct 03 '19 at 18:15\ifcsname tikzexternal@TEXDIALECT@collectpicture\endcsname \endcsname% <do something>\fito make sure that this will only be executed if externalize is loaded. It might also be better to turn off optimization only locally, i.e. within thenicearrayenvironments. – Oct 03 '19 at 18:23exporttofalse. I've found that the latter isn't always enough. Sometimes, only the former will do. – cfr Oct 03 '19 at 20:57nicematrix). – F. Pantigny Oct 04 '19 at 17:53