2

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:

enter image description here

enter image description here

What do I need to change to be able to use the external TikZ library?

Sverre
  • 20,729
  • You need --shell-escape active. – Qrrbrbirlbel Nov 10 '13 at 20:21
  • @Qrrbrbirlbel Yes, the manual and the questions I link to say something of that sort, but I have tried to add --shell-escape in various places, but it never works. Could you (or someone) please provide a complete compilation procedure for XeLaTeX? – Sverre Nov 11 '13 at 11:32
  • xelatex --shell-escape --synctex <filename> should do. However, you also need to setup external to use XeLaTeX, especially if the preamble uses XeLaTeX-specific stuff, the /tikz/external/system call needs to be setup correctly. – Qrrbrbirlbel Nov 11 '13 at 19:13
  • @Qrrbrbirlbel 1. The inclusion of <filename> there indicates to me that this is a command line interface? I don't use the command line, so I wondering (as indicated in my question) what I need to include in TeXworks compilation. 2. I'm sure I need to set up external correctly, but I have no idea how to do that ... – Sverre Nov 11 '13 at 19:46
  • Well, TeXworks doesn’t do anything but to use that command sent to the system/shell/whatever. Can’t you use the + button and add --shell-escape to the options? I don’t know about latexmk but it probably has also an option to use the compiler with --shell-escape. – Qrrbrbirlbel Nov 11 '13 at 20:02
  • Yes, but <filename>? If I need to add the name of my file here every time I compile, then the compilation is not automatic anymore, which I believe is the point of this feature in TeXworks. But this wouldn't matter much in the end if it won't compile anyway without me having set up external "correctly" first ... – Sverre Nov 11 '13 at 20:40
  • Isn’t that covered by $fullname? – Qrrbrbirlbel Nov 11 '13 at 21:00
  • I have no idea, since I don't know what $fullname means. The reason I am asking how to modify these TeXworks compilations is that I don't have much knowledge of these things. If I did, I presumably would have figured out how to do this on my own. What about the "correct" setup for external? – Sverre Nov 11 '13 at 21:02
  • @Sverre have you successfully set up --shell-escape in TeXworks by now? Or is this still an open issue? – Paul Gessler Mar 02 '14 at 04:43
  • @PaulGessler This is still an open issue. – Sverre Mar 02 '14 at 10:50
  • @Sverre what problems are you having? – Paul Gessler Mar 02 '14 at 14:13
  • @PaulGessler: Nothing has changed since I wrote the original question. So the problem is "that neither the manual nor these answers provide any detailed explanation for how to compile this document". – Sverre Mar 02 '14 at 14:18
  • 1
    @Sverre please see here: http://tex.stackexchange.com/questions/82699/how-to-enable-shell-escape-in-texworks – Paul Gessler Mar 02 '14 at 14:23

1 Answers1

1

With the help of Paul Gessler's link to How to enable shell-escape in TeXworks?, --shell-escape can be added to the XeLaTeX compilation in TeXworks like this:

enter image description here

Running the MWE in the original question, the compiler will compile a separate file main-figure0.pdf with only the TikZ figure, in addition to the full document main.pdf:

enter image description here

Sverre
  • 20,729