# Missing pdf when using \usetikzlibrary{external} in LyX

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:

\documentclass[12pt,english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[a4paper]{geometry}
\setcounter{secnumdepth}{0}
\setcounter{tocdepth}{2}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}

\makeatletter
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize[]
\tikzset{external/system call={pdflatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource" & convert "\image".pdf "\image".eps}}

\makeatother

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


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 '14 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 '14 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 '14 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 '14 at 20:50
• @scottkosty I updated with the full TeX code now – Peter Feb 2 '14 at 21:20

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/].