# standalone - build option not working with \graphicspath

I have a TikZ figure (fig.tex) in a subfolder as an standalone, and I want to use mode=buildnew in my main document so that I can optimize compilation times. I indicate the subfolder by using \graphicspath{{images/}}.

However, the figure is not build separately but compiled every time, together with the main document, and I get the warning Graphic 'fig.pdf' could not be build.

If I move fig.tex out of the subfolder, and leave it in the main one, together with main.tex, then it works properly and generates fig.pdf. I would like to get this result also when referring to TikZ figures in the subfolder.

I have version 1.2 of the standalone package and I included the "magic" TeXstudio comment % !TeX TXS-program:compile = txs:///pdflatex/[-shell-escape] in the main file, according to some of the answers that I have found around.

Here is the MWE:

fig.tex

\documentclass[tikz]{standalone}
\usepackage{fontenc}

\begin{document}
\begin{tikzpicture}[node distance=35mm,auto]

\node[draw,fill=yellow] (n) {Fig};

\end{tikzpicture}
\end{document}


main.tex

% !TeX TXS-program:compile = txs:///pdflatex/[-shell-escape]
\documentclass{article}

\usepackage[mode=buildnew]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[british]{babel}
\usepackage{tikz}

\selectlanguage{british}

\graphicspath{{images/}}

\begin{document}

Text.

\includestandalone{fig}

\end{document}


EDIT:

• Adding --enable-write18 to the magic comment.
• Changing the path to \graphicspath{{./images/}}.
• If I use \includestandalone{images/fig} and take away \graphicspath it works properly and the figure is compiled.
• It works for me. But you could try relativ path \graphicspath{{./images/}} (see question here) – dexteritas Jan 21 '17 at 14:49
• it works for me also. Although when compiling main file message Package standalone Warning: Graphic 'fig.pdf' could not be build. is shown, the final result includes the standalone figure as expected. – Ignasi Jan 24 '17 at 10:20
• Maybe I should make the question more explicit. It compiles correctly for me too in all cases, but the point is that I want to compile the TikZ figures just when they are new and just once, for optimisation reasons, since I have documents with a lot of them. Hence the buildnew option. So it should generate the fig.aux, fig.log and fig.pdf in all cases, and give no warnings, but it does not work. Should I edit the question to make it less confusing? – Fernando Jan 24 '17 at 13:42
• The use of \graphicspath is not yet a feature of standalone. However, there is already a feature request for it. – Martin Scharrer Mar 16 '18 at 7:44