I have a large document which consists of ~100 smaller files which are compiled together using the subfiles package. To be able to use a common style file for them, whose relative path should be the same from every compilable file, I use the following folder structure:

Project folder


-- Main folder

-- Subfolder 1

-- Subfolder 2

and write


at the top of the file main.tex. However, since the project is large and contains a lot of tikz file, the compilation now takes quite a long time. I can speed up the compilation of the main file by using the externalize command from the tikz/pgf package by writing e.g.


at the top of the main file. This works when compiling the main file, given that I put a folder named tikz in the Main folder. However, I would also make this work when compiling the subfiles by them selves, as this is the whole point of using the subfiles package. Here it would be optimal if I could use a relative path to the folder in which to externalize the graphics, and put this on the same level as the style file, and then write


but this does not seem to work, as the compiler (pdflatex) complains that

! I can't write on file `../../tikz/main-figure0.md5'.

when I try to compile the main file. Is there any way to get around this?

I do realize one solution would be to write


in the main file (or in the style file), and then add a folder named tikz to all folders which contains compilable documents, but then I would have two copies of each image, which seems to be quite a waste of space...


If it is really just about disk space (as indicated in the last paragraph), you can use symbolic links instead of real copies of the tikz directory.

| improve this answer | |
  • 4
    Welcome to TeX.SE! Depends on which operating system is used ... Please explain a little bit more, for example how to set the symbolic link ... – Mensch Jun 11 '15 at 16:43

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.