External Tikz pictures

2017/12/12



I produce almost all pictures in my math writing in TikZ. This is a nice library (and I’ve learned it over the years), which allows for-loops, effects, etc. The downside for me always was that compiling inline TikZ pictures takes a lot of time. For some months now, while writing a particularly figure-heavy paper, I wondered how I can optimize this.

Following this stackoverflow discussion, I have now adopted a great way of optimizing TikZ pictures by placing them into separate standalone tex files.

For example, this file

1
2
3
4
5
6
7
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
	%tikz code
\end{tikzpicture}
\end{document}

can be fed into my usual latexmk

latexmk -pdf -pvc -f -silent -synctex=1 FILENAME

for automatic constant compilation, and the pdf result can be included into the main file using another thread of automatic latexmk compilation.

Note. For further possible optimization, class standalone can already produce png output, which (I think) cost less compile time to be included into the main file.

PS. I enjoy turning on latexmk to constantly recompile the sources for me. I think this might be the reason why my laptop battery just died…