I've been looking into using latexmk
to create my documents because it automatically handles how many passes the document needs to be fully processed etc. So, for example, a simple run of latexmk -pdf file.tex
will run pdflatex
and bibtex
as many times as necessary to resolve all references.
I was wondering whether it's possible to not lose the ability to do so when using the TikZ
/external
library in the list and make
mode. If list and make
is used, the TikZ
/external
makefile is generated, but it is not automatically called by latexmk
. You can run the makefile manually and, of course, that will generate the graphic files, but the problem is that, as far as latexmk
is concerned, the .tex
files remain unchanged, so running latexmk
once more does not insert the newly-generated graphics into the document.
So, given file.tex
that uses TikZ
/external
in the list and make
mode, this is what happens:
latexmk -pdf file.tex
generates the pdf and inserts placeholders for the not-yet-generated graphics.make -f file.makefile
processes and generates the pdf files for the graphics.latexmk -pdf file.tex
does nothing because the source files have not changed.
I assume there's a way to force the generation of the pdf in the second latexmk
pass, but that would mean that this would happen even if the source files remained unchanged.
I was wondering whether there was a way to use latexmk
to handle all of this "automagicaly"? That would be great!
Here's a MWE to get everyone started:
\documentclass{article}
\usepackage{tikz,pgfplots}
\usetikzlibrary{external}
\tikzexternalize[mode=list and make]
\begin{filecontents}{plot.tikz}
\begin{tikzpicture}
\begin{axis}
\addplot coordinates {(1,1) (2,2) (3,3)};
\end{axis}
\end{tikzpicture}%
\end{filecontents}
\begin{document}
\input{plot.tikz}
\end{document}