3

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
maphy-psd
  • 137
  • 3
    I wouldn't add it to the .sty, for sure. Somebody might prefer not to externalise nicematrix environments and keep optimisation. Hard-coding it in the .sty would confuse things. Maybe something in the documentation would be better or an option. – cfr Oct 03 '19 at 18:15
  • @cfr I agree with your objection but one could add something like \ifcsname tikzexternal@TEXDIALECT@collectpicture\endcsname \endcsname% <do something>\fi to 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 the nicearray environments. –  Oct 03 '19 at 18:23
  • @cfr nicematrix enviroments are not externalize per default (line 586 from nicematrix.sty). I mean to disable optimization only locally for the nicearray environments. – maphy-psd Oct 03 '19 at 18:45
  • @Schrödinger'scat I think that my suggestion turn off optimization for the nicearray environments, didn't it? – maphy-psd Oct 03 '19 at 18:45
  • Sorry if it already did! I have not checked carefully. –  Oct 03 '19 at 18:54
  • It might work better disabling externalisation for the picture rather than just setting export to false. I've found that the latter isn't always enough. Sometimes, only the former will do. – cfr Oct 03 '19 at 20:57
  • 1
    I will try to find the best solution... (I'm the author of nicematrix). – F. Pantigny Oct 04 '19 at 17:53

1 Answers1

2

I have written a new version of nicematrix (v. 3.4 of 2019/10/05). In this version, the optimisation of the externalisation of Tikz is disabled in the environments of nicematrix when the package or the class standalone is used.

F. Pantigny
  • 40,250