When using pdflatex with -output-directory
I run into issues when externalizing tikz figures. While the .md5 files are created where I expect them the command creating the externalized picture files (.pdf, .log, .dpth) fails. My assumption is that this happens because the pdflatex
to create these files does not inherit the -output-directory
option and thus fails to create the files in the right spot.
This is a minimal example showing the behavior.
main.tex:
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize[prefix=tikz/]
\begin{document}
Test externalize in combination with -output-directory
\tikzsetnextfilename{testpicture}
\begin{tikzpicture}
\node {Node};
\end{tikzpicture}
\end{document}
bash:
mkdir -p build/tikz
pdflatex -output-directory build -shell-escape main.tex
error:
===== 'mode=convert with system call': Invoking 'pdflatex
-shell-escape -halt-on-error -interaction=batchmode -jobname
"tikz/testpicture" "\def\tikzexternalrealjob{main}\input{main}"'
======== This is pdfTeX, Version 3.14159265-2.6-1.40.16
(TeX Live 2015/Debian) (preloaded format=pdflatex)
\write18 enabled.
entering extended mode
! I can't write on file `tikz/testpicture.log'.
resulting directory structure (output of tree
):
.
├── build
│ ├── main.aux
│ ├── main.auxlock
│ ├── main.log
│ ├── main.pdf
│ └── tikz
│ └── testpicture.md5
└── main.tex
So again, as far as I understand the log file creation fails due to the lack of a tikz directory in the working directory of the pdflatex
command executed by the externalization.
Are my assumptions correct? If they are, how should how I should proceed with this?
Best Answer
As far as I have found out the easiest solution is to create a symlink in your main folder to the tikz folder inside build. Like so:
ln -s build/tikz .
This was the solution I found in the documentation of another tikz externalizing library.