I'm trying to use the externalization library in LyX to speed up compilation and generate separate PDF files with each of my tikz figures. But for some reason LyX does not output a separate PDF file that only includes the figure.

Here's the tex file as exported from LyX:


\tikzset{external/system call={pdflatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource" & convert "\image".pdf "\image".eps}}


\tikzstyle{place}=[circle,draw=blue,fill=blue!20,line width=2pt]
\node at (0,0) [place] {Ti\textit{k}Z};

Under Tools > Preferences > File Handling I changed the converter for LaTeX (pdflatex) -> PDF (pdflatex) to pdflatex -shell-escape $$i

When I compile on my Windows machine I only get the PDF file with the main document, it does not create a separate file with the figure and it does not speed up the compilation at all. What am I missing?

  • For export (i.e. not view): LyX runs everything in a temporary folder and then copies what it needs back when you export. It thinks it only needs one PDF so that's all it copies. If you want it to copy more, write a script that does that and use that instead of the pdflatex -shell-escape $$i command. Read Help > Customization for more information. Now for Viewing you would need to create a script and put that as your "viewer" for a certain format. That script could open several PDFs (although it would need to guess the others from the main one).
    – scottkosty
    Feb 2, 2014 at 18:54
  • If you have access to a Linux machine, I can help you write the scripts. I don't know how to do this for Windows.
    – scottkosty
    Feb 2, 2014 at 18:55
  • @scottkosty What if I wasn't interested in a separate PDF with the figure. Right now the compilation time doesn't improve at all from using \usetikzlibrary{external}, so it seems to me like I'm not getting the package to work properly. I was hoping there would be a way to get it to work in LyX
    – Peter
    Feb 2, 2014 at 19:40
  • In that case my guess is it has nothing to do with LyX. Post the LaTeX (from File > Export > Latex) and hopefully someone can help you.
    – scottkosty
    Feb 2, 2014 at 20:50
  • 1
    @scottkosty I updated with the full TeX code now
    – Peter
    Feb 2, 2014 at 21:20

1 Answer 1


The code posted in the question actually did work. The tricky part in LyX is that LyX converts each picture to a separate PDF that it saves in a temporary directory as scottkosty pointed out to me. The path of this folder can be found under Tools > Preferences > Paths. The files can easily be copied and saved in other directories.

When using pdflatex to compile the conveter LaTeX (pdflatex) -> PDF (pdflatex) needs to be changed under Tools > Preferences > File Handling to pdflatex -shell-escape $$i.

When using XeTeX the converter LaTeX (XeTeX) -> PDF (XeTeX) needs to be changed to xelatex -shell-escape $$i. I also had to pass a subdirectory to tikzexternalize in the preample, e.g. \tikzexternalize[prefix=Figures/].

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .