Speed up slow TikZ renders in Overleaf with externalization.
Complex plots and diagrams make compilation crawl because LaTeX redraws every path on every run. The PGF TikZ external library compiles each figure once to a standalone PDF and includes it as a graphic thereafter.
The short answer: add the TikZ external library to your preamble, create a latexmkrc file with shell-escape enabled, and set up a cache folder for your compiled figures.
How to set up TikZ externalization
Externalization tells LaTeX to save each tikzpicture environment as an individual PDF file on the first run and load that file as an image on later runs. This turns heavy vector math into simple graphic inclusion.
You need two parts to make this work in an online editor: the package commands in your preamble and a configuration file that permits recursive compilation.
Step-by-step implementation
Add the library to your preamble
Load the external library in your main document before \begin{document} and define a folder where intermediate graphics will live.
Configure shell-escape with latexmkrc
Online compilers disable system calls by default for security. To let pdfLaTeX compile individual figures recursively, create a plain text file named latexmkrc in the root of your project directory.
Fixing common errors in Overleaf
Running externalization inside a managed web environment often triggers specific file-permission errors that do not appear on a local TeX Live installation.
Questions
Why does TikZ externalization fail on Overleaf without latexmkrc?
Externalization requires the compiler to invoke sub-processes via shell-escape (-shell-escape) to generate individual PDFs for each picture. Overleaf turns this off by default, so you must enable it explicitly using a latexmkrc configuration file.
How do I fix the 'I can't write on file' error?
This error happens when the designated cache folder does not exist or lacks write permissions. Create the target folder in your project file tree, and if necessary, add an empty .md5 file inside it to satisfy file-locking checks.
Does TikZ externalization update figures when I change code?
Yes. The library generates checksums for each picture environment. When you edit the code inside a tikzpicture, the checksum changes, and LaTeX recompiles just that specific figure during the next build.
Can I use externalization with PGFPlots and external data files?
Yes, but data files read via \addplot table need to remain accessible during external passes. If your plot reads an external .csv file, ensure the file path is relative to the root directory so the sub-process can find it.
Why are my reference numbers missing in externalized figures?
References like \ref inside a TikZ picture require auxiliary file support. Ensure your main document auxiliary files are shared correctly across passes, or use multiple compilation runs so the labels resolve properly.
Does Texeno require a latexmkrc file for shell-escape?
Texeno supports shell-escape commands and packages like minted and TikZ externalize out of the box on every plan, without needing manual configuration files for basic compiler flags.
What should I do if a figure fails to compile during externalization?
You can temporarily disable externalization for a single troublesome picture using \tikzexternaldisable before it and \tikzexternalenable after it, allowing the rest of the document to build normally while you debug.
Try your own paper in Texeno.
Start free, upload a project as a .zip and press Recompile. Upgrade when you need longer compiles.
Start writing