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.
It is now possible to use the tikz
external library to cache tikz drawings:
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
As the externalised tikz PDFs are considered as output files, you will not see them show up in the file list, but they are indeed present within the project.
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
.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
.dpth for that particular tikz drawing.