I am working on a beamer presentation that consists about 25 tikz and pgfplots graphics scattered all over the ~50 frames.

Because of the multitude of tikzpictures , I am using the tikzexternalise commands:

\tikzexternalize[prefix=tikz/,optimize command away=\pdfpages]

(the pdfpages exception is due to some inclusion of pdf files using \includegraphics)

together with a latemkrc file that provides a command line switch:

$latex = 'pdftex -shell-escape main.tex %O %S';

pdfLaTeX then outputs files in ascending order with respect to their appearance in the main.tex file:


What if during the writing progress of my presentation I decide to move one frame above the other? And completly delete one frame because I decide it is not relevant. Would it cause graphics to move too? How would it affect the use of already generated tikz outputs?

What is the correct workflow in such case?

Another question: Can I give names to those generated files so that it would be easier to keep track of their respective content? If yes, then how?

Can I redact the *.md5, *.log, *.dpth and *.dep files and keep only the `.pdf files?

I am afraid that this whole incorrect workflow I just described causes the error message

Package tikz Error: Sorry, the system call 'pdflatex -shell-escape -halt-on-error -interaction=batchmode -jobname "tikz/output-figure23" "\def\tikzexternalrealjob{output}\input{output}"' did NOT result in a usable output file 'tikz/output-figure23' (expected one of .pdf:.jpg:.jpeg:.png:).

which at the moment prevents me from going on working on my presentation.

  • 1
    github.com/pgf-tikz/pgf/issues/758 Commented May 14, 2021 at 20:12
  • @HenriMenke All right I think I understand the idea. Please correct me if I am wrong. Before every \begin{figure}, insert \tikzsetnextfilename{<file name>} where <file name> hopefully has a meaningful name, such as barPlot05 or scatter02. I just tested it and it seems to be working on a sandbox project. But what about all the *.md5, *.log, *.dpth and *.dep files? Do I need to keep them?
    – tush
    Commented May 14, 2021 at 20:39
  • @HenriMenke "[...] because the code of the externalization library is mostly unreadable gibberish." :) :) :) Commented May 15, 2021 at 2:27

1 Answer 1


Too long for a comment.

As you have already written in the comment below the question I also recommend to use \tikzsetnextfilename, but you should write it directly before the \tikz command or the \begin{tikzpicture} environment. Then you also have a workflow if there is more than one TikZ environment in a figure environment.

Here some "random" code for the further discussion borrowed from https://tex.stackexchange.com/a/436405/95441.

% used PGFPlots v1.16
        % use the one from PGFPlots which is more recent than the one from tikz
    % put all externalized images in a "special" folder
    % enable externalization
% (I prefer to give the images reasonable names)
        legend to name=named,
        \addplot+ [domain=1:10] {x};

        \addplot+ [domain=1:10] {1/x};

    % (you can also name this image, if you want to)

As you can see I store all the externalized files in a separate folder, which has the additional benefit that also all the auxiliary files which are created during externalization are stored in that folder. From that you can delete all files except

  • non-zero dep files
  • non-zero dpth files
  • md5 files (Hopefully I didn't miss anything. Otherwise please add a comment or directly edit the answer.)

To do so I have created a bat file (sorry, I am a Windows child) which is also located in the "externalize" folder. That I execute from time to time and looks like

REM pause
del *.acn
del *.log
del *.glo
del *.ist
del *.nlo
del *.xml

REM delete zero byte DPTH files
@echo off
for %%f in (*.dpth) do if %%~zf==0 del /F /Q "%%f"

REM delete zero byte DEP files
@echo off
for %%f in (*.dep) do if %%~zf==0 del /F /Q "%%f"

Feel free to adapt it to your needs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .