0

Situation

I am compiling a document using the TikZ externalize library, and want to create my output in an output folder /out/, but have the TikZ externalize figures stored in a subfolder /out/figures/. The /out/ folder is specified by passing the -output-directory=[path to main.tex]/out argument to pdfLatex, and the /out/figures/ folder is specified using \tikzexternalize[prefix=out/figures/].

Expected behavior

All externalized files are created in the /out/figures/ folder.

Actual behavior

The figure.md5 file is created in the /out/out/figures/ folder, whereas all other externalized files are created in the /out/figures/ folder.

MWE

Run the following command:

pdflatex -output-directory=[path to main]/out -shell-escape main.tex

where main.tex contains:

\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{external}
\tikzexternalize[prefix=out/figures/]

\usepackage[abspath]{currfile} \getabspath{\jobname.log}

% Avoid having to create these folders manually \IfFileExists{"\theabsdir out"}{}{\immediate\write18{mkdir "out"}} \IfFileExists{"\theabsdir out/figures"}{}{\immediate\write18{mkdir "out/figures"}} \IfFileExists{"\theabsdir out/out"}{}{\immediate\write18{mkdir "out/out"}} \IfFileExists{"\theabsdir out/out/figures"}{}{\immediate\write18{mkdir "out/out/figures"}}

\begin{document} \begin{figure} \tikzsetnextfilename{figure} \begin{tikzpicture}[domain=0:4] \draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9); \draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$}; \draw[->] (0,-1.2) -- (0,4.2) node[above] {$f(x)$}; \draw[color=red] plot[id=x] function{x} node[right] {$f(x) =x$}; \end{tikzpicture} \end{figure} \end{document}

Is there any way to make TikZ externalize create all externalized files in the same folder? Why is the prefix interpreted inconsistently by tikz externalize?

0 Answers0