I want to use the externalize option for tikz pictures to save up compilation time. Because of the need for psfrag, I want to compile via latex, i.e. dvi–>ps–>pdf.
I use texStudio. My Latex specs are MikTex 2.9, I use Windows 7 (shame on me), my latex command line reads
latex.exe -src -synctex=1 -interaction=nonstopmode -shell-escape %.tex
My minimal example sort of works, however there are some problems related to the result I achieve so far.
I want to include figures – for simplicity's sake, a circle in this MWE. Originally, mySphere1 and mySphere2 are included from two seperate files with identical content, but different names.
For some reason, in the original problem where I include mySphere2 from a file, the corresponding figure does not show in the result while its title does – I do not receive any compilation error message for this one.
The second issue is: Why does each figure occupy a new page? Is there any workaround here?
\documentclass{article}
\usepackage[english]{babel}
\usepackage{pgfplots}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{pgfplots.groupplots}
\usepgfplotslibrary{external}
\tikzexternalize[shell escape=-enable-write18]
\tikzset{external/system call={latex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource" & dvips -o "\image".ps "\image".dvi}}
\begin{document}
This is a simple test.
\begin{figure}[h!]
\centering
\newlength\figureheight % define length \figureheight
\newlength\figurewidth % define length \figurewidth
\setlength\figureheight{6cm} % set \figureheight
\setlength\figurewidth{6cm} % set \figurewidth
\tikzsetnextfilename{mySphere1}
\begin{tikzpicture}
\draw[blue] (0,0) circle [radius=1];
\end{tikzpicture}
\end{figure}
Next page
\begin{figure}[h!]
\centering
\newlength\figuregheight % define length \figureheight
\newlength\figuregwidth % define length \figurewidth
\setlength\figuregheight{6cm} % set \figureheight
\setlength\figuregwidth{6cm} % set \figurewidth
\tikzsetnextfilename{mySphere2}
\begin{tikzpicture}
\draw[blue] (0,0) circle [radius=1];
\end{tikzpicture}
\end{figure}
And now for something completely different: a sawtooth.
\begin{figure}[!htb]
\centering
\tikzsetnextfilename{force1}
\begin{tikzpicture}
\draw[blue] (0,0) circle [radius=1];
\end{tikzpicture}
\caption{y-direction}
\end{figure}
The sawtooth.
\begin{figure}[!htb]
\centering
\tikzsetnextfilename{force2}
\begin{tikzpicture}
\draw[blue] (0,0) circle [radius=1];
\end{tikzpicture}
\caption{x-direction}
\end{figure}
\end{document}
Best Answer
I think you need to update your version of MikTeX.
I had been struggling with similar issues using TeXstudio and MikTex 2.9.4xxx. Upgrading to the latest version (2.9.5840) fixed my issues. I just tried compiling your tex file (with the latest MikTex) and it works for me.