As explained in the pgf
manual under 32.4 and in various other questions/comments here on TeX.sX (https://tex.stackexchange.com/a/44508/9077, https://tex.stackexchange.com/a/32363/9077, https://tex.stackexchange.com/a/23565/9077), it's possible to export a TikZ picture as a pdf with document like this:
\documentclass{article}
% main document, called main.tex
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize % activate!
\begin{document}
\begin{tikzpicture}
\node {root}
child {node {left}}
child {node {right}
child {node {child}}
child {node {child}}
};
\end{tikzpicture}
\end{document}
The problem, however, is that neither the manual nor these answers provide any detailed explanation for how to compile this document. I'm using texlive in Windows 7 with TeXworks, so please do not suggest command line compilation procedures.
I need to compile with XeLaTeX since I'm using fontspec
. My XeLaTeX compilations look like the following:
What do I need to change to be able to use the external TikZ library?
Best Answer
With the help of Paul Gessler's link to How to enable shell-escape in TeXworks?,
--shell-escape
can be added to theXeLaTeX
compilation inTeXworks
like this:Running the
MWE
in the original question, the compiler will compile a separate filemain-figure0.pdf
with only theTikZ
figure, in addition to the full documentmain.pdf
: