Help

I have a lot of tikz, matlab2tikz or pgfplots figures, so I'm getting a compilation timeout. Can I externalise my figures?

The output-from-other-project solution

If you create a separate project that just contains the figure, you can include the output of the figure in your original project by going to its project menu, selecting Add files…, and then choosing Output from another project.

That way, you only have to compile the complicated figure once, and then you can include the resulting pdf as a normal figure in your main project.

The tikz-external solution

It is now possible to use the tikz external library to cache tikz drawings:

\usetikzlibrary{external}
\tikzexternalize[prefix=tikz/]

You will then need to create a tikz folder in your project. For this to work on Overleaf, the folder you create needs to have a (dummy) file in it — for example, you can add a blank foo.txt file in the tikz folder.

As the externalised tikz PDFs are considered as output files, you will not see them show up in the file list. If you wish to download them, you can click on the arrow just next to the "Download as ZIP" button at the end of the file list, then select the "Input and output files" option.

There're just too many of them!

However, if your drawings are too complex and there are too many of them, you will still get a timeout the first time the externalised files are generated. Building your project incrementally (by commenting different chunks of your project) may help, but bear in mind that all generated files are garbage collected at fixed intervals on the servers. Your project may then fail to compile when you next log in, and you'd have to re-generate them all incrementally again.

As a workaround, you can generate the files on a local machine first, by downloading your project and compiling it on your own local machine. After the compile completes, you should see the tikz folder containing .pdf, .md5, .dep and .dpth files for each of your tikz drawings. If you then upload these files to your Overleaf project's tikz folder, your project will then use these files directly, and compilation should be fairly fast. These files won't be deleted by the server, as uploaded file are never garbage-collected.

A caveat: if you change your tikz code in future, you may have to delete the corresponding files in the tikz folder first, so that Overleaf can generate and use a new version. Alternatively, you can re-generate the files on your machine, and re-upload them to Overleaf. Remember that you need to replace all the .pdf, .md5, .dep and .dpth for that particular tikz drawing.