1

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:

\usepgfplotslibrary{external}
\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:

.
..
...
tikz/output-figure20.md5
tikz/output-figure20.pdf
tikz/output-figure21.dpth
tikz/output-figure21.md5
tikz/output-figure21.pdf
tikz/output-figure22.dpth
tikz/output-figure22.md5
tikz/output-figure22.pdf
tikz/output-figure23.log
etc.

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.

3
  • 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

2

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
\documentclass{article}
\usepackage{pgfplots}
    \usetikzlibrary{
        % use the one from PGFPlots which is more recent than the one from tikz
        pgfplots.external,
    }
    % put all externalized images in a "special" folder
    \tikzsetexternalprefix{Pics/pgf-export/}
    % enable externalization
    \tikzexternalize
\begin{document}
% (I prefer to give the images reasonable names)
\tikzsetnextfilename{first}
\begin{tikzpicture}
    \begin{loglogaxis}[
        xlabel={A},
        ylabel={B},
        legend to name=named,
    ]
        \addplot+ [domain=1:10] {x};
        \addlegendentry{$10\%$}
    \end{loglogaxis}
\end{tikzpicture}

\tikzsetnextfilename{second}
\begin{tikzpicture}
    \begin{loglogaxis}[
        xlabel={A},
        ylabel={B},
    ]
        \addplot+ [domain=1:10] {1/x};
    \end{loglogaxis}
\end{tikzpicture}

    % (you can also name this image, if you want to)
    \tikzsetnextfilename{first-legend}
    \pgfplotslegendfromname{named}
\end{document}

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 .