4

I'm using pdflatex. I'm building in a "build" subdirectory with the --output-directory of pdflatex and it works really well, every file is generated in this directory.

Now, I want to externalize my pgfplots, so I'm using:

\usetikzlibrary{external}
\tikzexternalize[shell escape=-enable-write1 -shell-escape, prefix=./build/]

In that case, the external files are created in the build directory (the MD5 files are created in the build/build, but it does not matter). However, after this, several files are created in the working directory rather than in the build directory. After the build, I have these files:

master.acn
master.glo
master.ist
master.maf
master.mw
master.run.xml

in the working directory rather than in the build directory :(

I know that these files are not related to tikz, but they only appear here when I use tikzexternalize.

Why is tikzexternalize creating some extra files in the current working directory ? Is it possible to get rid of these files ?

Thanks

1
  • 1
    You should make a complete example. You should also mention your tex system. Nov 10, 2016 at 16:49

2 Answers 2

8
+250

I think the most straightforward way to do this is not to set prefix at all but to instead do two things.

  1. Ensure that --output-directory is passed to the compiler when it is run by the externalisation process by overriding the default compilation command.

    • This should ensure that all files generated when producing the externalised images are written to build/ and not only those directly concerned with externalisation.
  2. Ensure that TikZ searches in the correct place for the externalised images by overriding the default image inclusion command.

    • This should ensure TeX looks in the correct place for the externalised images by directly manipulating the path used when including images rather than by setting prefix. prefix won't work here because it will also be used when externalising, creating an unwanted cumulative effect when producing images (build/build/<image>) but not when including them (build/<image>), resulting in errors.

For example, you might want something like this (based on the information in your question and the default explained on page 609 of the TikZ manual and the information on page 616):

\begin{filecontents}{\jobname.bib}
@article{author-art,
  author              =   {Author, A. N.},
  title               =   {Believe It or Not \dots},
  volume              =   290,
  year                =   3056,
  doi                 =   {44.897/gje.x789},
  pages               =   {x789},
  eprinttype          =   {gje},
  eprint              =   {x789},
  eprintclass         =   {290},
  journal             =   {Greatest Journal Ever}}
@article{author-anart,
  author              =   {Author, A. N.},
  title               =   {Suppose It or Not \dots},
  volume              =   78,
  number              =   3,
  year                =   3049,
  pages               =   {22--29},
  eprinttype          =   {jstor},
  eprint              =   {12980258},
  journal             =   {Second Best Journal Ever}}
\end{filecontents}

\documentclass[british]{article}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[backend=biber]{biblatex}
\bibliography{\jobname}
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize
\tikzset{%
  external/system call={pdflatex \tikzexternalcheckshellescape --halt-on-error --interaction=batchmode --output-directory=./build --jobname "\image" "\texsource"},
  /pgf/images/include external/.code={%
    \includegraphics{build/#1}%
  },
}
\begin{document}
\Textcite{author-art,author-anart}

\begin{tikzpicture}
  \draw (0,0) rectangle (1,1);
\end{tikzpicture}

\printbibliography

\end{document}

I then compiled with

pdflatex --shell-escape --output-directory=./build <filename>.tex 
biber --output-directory=./build <filename>
pdflatex --shell-escape --output-directory=./build <filename>.tex 

This generated all files in build/ and seemed to compile successfully, using the externalised image rather than recompiling the TikZ code on the second run.

result

4
  • I think I'm almost there with your solution. The problem with that solution is that the PDF of the figures are generated in build/build but are searched by tikz in build/ and are therefore not found. If I create a symbolic link build/build -> build/ it works... It is weird that you don't have this problem Nov 11, 2016 at 7:59
  • @BaptisteWicht I just realised that you said you are externalising pgfplots. If you are using pgfplots, you should probably use its externalisation facilities. (I don't think this is the solution to your problem, but just a side-note.) I'll try to look at this again later - it certainly seemed to work for me, but maybe I did something in experimenting which just made it appear that way.
    – cfr
    Nov 11, 2016 at 16:30
  • @BaptisteWicht Hmmm... Now I can't even get it to compile. I wonder what I did before ...
    – cfr
    Nov 11, 2016 at 22:18
  • @BaptisteWicht Please see edit above. I think this version works - please test and let me know.
    – cfr
    Nov 11, 2016 at 22:37
3

The files you list are mostly unrelated to tikz, .glo is your document glossary, .ist is a makeindex style, and .run.xml is generated by biblatex.

2
  • 1
    I think acn is also glossaries related. The maf though, no idea. Oct 13, 2016 at 13:17
  • I know that they are unrelated. But they only appear in the working directory if I use tikzexternalize. Otherwise, they are simply inside the build directory. Oct 14, 2016 at 5:13

You must log in to answer this question.

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