# Externalize TikZ with TeXstudio and MikTeX [closed]

I have the same problem as written here before, but the externalization doesn't work. I always get the following message:

tikz: Sorry, the system call 'pdflatex -halt-on-error -interact


I try to input some simulation result from Matlab via matlab2tikz. If I run my .tex file without externalization it works just fine, but if I write

\tikzexternalize[prefix=tikzfig/]


it does not work any more.

Here is a part of my header:

\usepackage{pgfplots}
\pgfplotsset{plot coordinates/math parser=false}
\usepackage{tikz}
\usepackage{tikzscale}
\usepgfplotslibrary{external}
\tikzexternalize[prefix=tikzfig/]


I also saw the answer here, but it still doesn't work.

I am using Miktex and Texstudio. I am also compiling via dvips since I am using psfrag. The compile command is:

pdflatex -shell-escape name


where name is just the file name without file extension, here .tex.

## closed as unclear what you're asking by Paul Gessler, Jesse, Przemysław Scherwentke, ChrisS, user31729 Jan 15 '15 at 4:44

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Why don't you use the standalone class for this? – SLx64 May 24 '14 at 10:57

The error message you get is incomplete. If you invoke pdflatex from the command line, you will get a full error message:

! Package tikz Error: Sorry, the system call 'pdflatex -halt-on-error -interaction=batchmode -jobname "chapter-figure0" "\def\tikzexternalrealjob{chapter}\input{chapter}"' did NOT result in a usable output file 'chapter-figure0' (expected one of .pdf:.jpg:.jpeg:.png:).


Your problem is different, but you may be able to resolve it in a similar way. For me, manually running 'pdflatex -halt-on-error -interaction=batchmode -jobname "chapter-figure0" "\def\tikzexternalrealjob{chapter}\input{chapter}"' got me the file that I needed, but this is not satisfactory for a large number of pictures. Further debugging using "\tracingall" resulted in this error:

\pgf@tempa ->pdflatex -halt-on-error -interaction=batchmode -jobname "chapter-figure0" "\def\tikzexternalrealjob{chapter}\input{chapter}" runsystem(pdflatex -halt-on-error -interaction=batchmode -jobname "chapter-figure0" "\def\tikzexternalrealjob{chapter}\input{chapter}")...disabled (restricted).


This can be resolved by running pdflatex with the "--shell-escape" option. The precise procedure to add this option depends on your tex editor. For TeXstudio, go to Options, Configure texstudio, Commands, and change "pdflatex -synctex=1 -interaction=nonstopmode %.tex" to "pdflatex -synctex=1 -interaction=nonstopmode --shell-escape %.tex". This fully fixed the problem.