I tried to use the externalize library. It worked fine when all my files where located in the same folder. Usually I am using a subfolder as build folder, where all generated files should be stored. Setting this up with the prefix for externalize, I get an error message that seems to me weird.

What am I doing wrong?

Here is a MWE that throws the error message ! I can't write on file `build/Test-figure0.md5'

I am using TexStudio and Texlive 2014. To compile I use the command:

pdflatex.exe -synctex=1 -interaction=nonstopmode -shell-escape -output-directory=build %.tex

Here is a not working example:



\tikzset{external/up to date check={md5}}
\tikzset{external/mode=convert with system call} 


\tikzstyle{myedgestyle} = [diamond-open diamond]

\node (v2) at (2,4) {};
\node (v1) at (-0.5,2) {};
\draw [diamond-open diamond] (v1) edge (v2);


Until now I tried the following things:

  1. Try to run it without the prefix

It works, but all the files will be created in the main folder

  1. Using \tikzset{external/system call={pdflatex \tikzexternalcheckshellescape -halt-on-error -output-directory=build -interaction=batchmode -jobname "\image" "\texsource"}} without the prefix option to change the build location

It creates the pictures in the build directory but I will get this error: ===== Image 'Test-figure0' is up-to-date. ====== !pdfTeX error: pdflatex.exe (file Test-figure0.pdf): cannot find image file ==> Fatal error occurred, no output PDF file produced! –

  1. Using the former \tikzset and the prefix option together I will get the md5 massage again, if the picture wasn't created before. If I am not using the prefix option within the first run, the picture will be created in the build folder. Switching the prefix option back on in a second run it will generate no errors and use the previously generated pictures.

I think that this is a pretty dirty workaround. Is there a better solution?

  1. Changing the folder for the tikz pictures does not make any difference.

  2. Runing the example in draft mode and tikzset and prefix set will run with no errors, but the pictureboxes have a standard size.

  • Welcome to TeX SE! Have you tried not setting the prefix at all? You are already outputting to build/. Do you need the prefix as well?
    – cfr
    May 8 '15 at 23:32
  • Yes, I did that and if I am not using the prefix it works but all the picture are created in the main folder.
    – DMZ
    May 9 '15 at 5:34
  • 7
    For some reason tikz wants to create the .md5 file inside build/build/. If you create that sub folder, it should work. May 12 '15 at 7:51
  • 2
    @JonasNyrup I guess it concatenates the build directory and the prefix. That's why I thought maybe just not using prefix at all might work. Interesting that it works with build/build/ but if you use no prefix it won't use build/ correctly....
    – cfr
    May 12 '15 at 13:01
  • 1
    To sum it up... there is a good workaround but the question whether the problem is a bug or a feature is unsolved.
    – DMZ
    Jun 1 '15 at 19:34

Your issue occurs because you are using the flag -output-directory=build when running pdflatex.

In order to makes explanations less ambiguous, let's rename folders:

  • you are using the flag -output-directory=foo;
  • your .tex file is in a folder named root;
  • you are using following macro in your .tex file: \tikzexternalize[prefix=bar/].

What happens is that the externalization creates .pdf (as well as .log and .dpth files) in the folder root/bar/. However, the externalization also creates "output files" (actually .md5) and thus stores them into... root/foo/bar.

The error is raised because the folder root/foo/bar doesn't exist on your computer (you only have created root/bar). Creating it should solve the problem.


You can try:

\tikzexternalize[prefix=build/] %  activates folder access folderName=build


\tikzsetnextfilename{TestFigure} % filename = TestFigure

My solution is this:

  1. Compile Command:

    pdflatex -shell-escape tikzImageCreate

2.tikzImageCreate.tex: (The .tex file name have to be the same like in the command above (see1.)

%compile with: pdflatex -shell-escape tikzImageCreate



% storage location
\tikzexternalize[prefix=build/] %  your external folderName= build

%filename of the tikz fig.,
\tikzsetnextfilename{TestFigure} % your name for the tikz fig.for example filename=TestFigure
\node (v2) at (2,4) {};
\node (v1) at (-0.5,2) {};
\draw (v1) edge (v2);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.