# External library spawns figures inside math environment #759

Open
opened this issue Oct 25, 2019 · 7 comments
Open

# External library spawns figures inside math environment#759

opened this issue Oct 25, 2019 · 7 comments
Labels
Milestone

### Turgon-Aran-Gondolin commented Oct 25, 2019 • edited by Mo-Gul

 I was using the following code to externalize the tikz-feynman diagrams \usepackage{shellesc} \usetikzlibrary{external} \tikzexternalize[ shell escape=-enable-write18, prefix=./, system call={lualatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"}, up to date check=md5, ] When the diagrams are in figure environment everything works fine. But those in align environment were generated twice. So my working dir is now filled with duplicated figures. While the md5 of those duplicated figures are exactly the same, they continue to exist and the compiling effort is doubled. Is there any way to resolve this?

### Mo-Gul commented Oct 25, 2019

 It would be nice if you could add a full working minimal example (MWE) which will make it much easier to see the issue and than hopefully provide a solution or fix.
added the label Oct 25, 2019

### Turgon-Aran-Gondolin commented Oct 25, 2019 • edited by Mo-Gul

 This should reproduce what I described: \documentclass{article} \usepackage{amsmath} \usepackage[compat=1.1.0]{tikz-feynman} \usepackage{shellesc} \usetikzlibrary{external} \tikzexternalize[shell escape=-enable-write18,prefix=./,system call={lualatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"},up to date check=md5] \begin{document} \begin{align} \begin{tikzpicture} \begin{feynman} \node[dot] (a); \node[right=1 in of a,dot] (b); \diagram*{ (a) -- (b); }; \end{feynman} \end{tikzpicture} \end{align} \end{document}

### davidcarlisle commented Oct 25, 2019

 align (like all AMS environments) evaluates its body twice, with \ifmeasuring@ being true the first time and false the second, so probably you want to avoid the external calls on the second pass.

### Turgon-Aran-Gondolin commented Oct 26, 2019

 Thanks for pointing this out. Do you have a solution for this? I'm not really familiar with options of the external library and I'm not sure which one can achieve this.
added this to the 3.1.5 milestone Nov 3, 2019
added a commit to hmenke/pgf that referenced this issue Dec 14, 2019
 Check \ifmeasuring@ pgf-tikz#759 
 005442c 
added a commit to hmenke/pgf that referenced this issue Dec 15, 2019
 Check \ifmeasuring@ pgf-tikz#759 
 135e361 
added the label Dec 15, 2019
closed this Dec 15, 2019

### Turgon-Aran-Gondolin commented Jan 7, 2020 • edited by Mo-Gul

 After updated to 3.15a, there's a new problem. If there're multiple figures in one math environment, the first one will get evaluated every single pass despite it remains unchanged. MWE: \RequirePackage{luatex85} \documentclass{article} \usepackage{amsmath} \usepackage[compat=1.1.0]{tikz-feynman} \usetikzlibrary{external} \tikzexternalize[shell escape=-enable-write18,prefix=./,system call={lualatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource"},up to date check=diff] \begin{document} \begin{align} \feynmandiagram{ a -- b[dot]; };\qquad & \int \qquad \feynmandiagram{ a[dot] -- b; }; \end{align} \end{document}
reopened this Jan 7, 2020

### Turgon-Aran-Gondolin commented Jan 7, 2020

 Also all figures inside one math environment got merged into the first figure file (one figure per page). And all except the first figure files are still generated normally.

### hmenke commented Jan 7, 2020

 Okay, it looks like this has become unusable. I will revert the fix and publish a new release.
added a commit to hmenke/pgf that referenced this issue Jan 7, 2020
 Revert "Check \ifmeasuring@ pgf-tikz#759" 
 aa28fda 
This reverts commit 135e361.
removed the label Jan 7, 2020
modified the milestones: 3.1.5, 3.1.6 Jan 7, 2020