Closed mocenigo closed 2 weeks ago
I guess the cause here is that the amsmath
environment align
gets typeset twice, see texdoc amsmath.pdf
(v2.17s, 2024/10/30), p.48 in sec. 17.2 Preliminaries
\ifmeasuring@
All display environments get typeset twice—once during a “measuring” phase and then again during a “production” phase;
\ifmeasuring@
will be used to determine which case we’re in, so we can take appropriate action.
\newif\ifmeasuring@
The external
library is currently unmaintained and it is unlikely that any bugs are going to be fixed in the future, due to the inherent defective design of the library. However, there are other third-party libraries for externalization which have learned from these past mistakes and which seem to be quite usable:
forest
)Both are included in TeX Live 2024.
Duplicate of https://github.com/pgf-tikz/pgf/issues/759
The
external
library is currently unmaintained and it is unlikely that any bugs are going to be fixed in the future, due to the inherent defective design of the library. However, there are other third-party libraries for externalization which have learned from these past mistakes and which seem to be quite usable:
- https://github.com/sasozivanovic/memoize / https://ctan.org/pkg/memoize (same author as the venerable
forest
)- https://github.com/leo-colisson/robust-externalize / https://ctan.org/pkg/robust-externalize
Both are included in TeX Live 2024.
Thank you. I moved my code to memoize and it was a breeze! Thank you!
Brief outline of the bug
Please look at the MWE and run it. Have a look at the externalized file "a-triangle.pdf". Then delete "a-triangle.pdf" and change the align environment to equation.
In the first case there are two copies of the same file. In the second case there is only one.
It seems that if there are more instances of \tikzsetnextfilename in a document with the same output name, the outputs are re-run and written to the same file. align needs to run its contents twice while equation does not.
This is a variation of what is discussed here: https://tex.stackexchange.com/questions/668448/tikz-externalize-creating-pdf-with-repeated-images
In my opinion this is a bug, since the TikZ picture is not supposed to change during re-runs. Alternatively, I could use a workaround: how can I tell tikz to generate only one copy of the triangle in the externalised output and reuse it immediately?
Minimal working example (MWE)