# Including pictures in subdirectories with standalone package

After using standalone package extensively, I ran into one problem, which I cannot solve. The problem is that I need to include a TikZ picture in main files subdirectory. What is more I want to build it with standalone mode = buildnew. Consider the following filetree:

/mwe.tex
/sub/mwefig.tex


File mwe.tex contains the following:

\documentclass{article}
\usepackage{standalone}
\usepackage{tikz,pgfplots}
\standaloneconfig{mode=buildnew}

\begin{document}
Time is money!

\includestandalone{sub/mwefig}

\end{document}


And the file mwefig.tex contains the following code:

\documentclass{standalone}
\usepackage{tikz,pgfplots}

\begin{document}

\begin{tikzpicture}
\draw (0,0) circle (2);
\end{tikzpicture}

\end{document}


After execution of mwe.tex I would expect mwefig.tex to be built, which would result in mwefig.pdf file created in /sub/ directory, which could then be used for later compilations.

What I rather get is a warning: Package standalone Warning: Graphic 'sub/mwefig.pdf' could not be build. Even though, the main PDF is produced containing the required graphics.

I also noticed, the mwefig.pdf file is actually created, however in a separate directory and with different name:

/sub'/mwefig'.pdf


So after compilation I have the following filetree (excluding aux and log files):

/mwe.tex
/mwe.pdf
/sub/mwefig.tex
/sub'/mwefig'.pdf


I am probably using something wrong, so if anyone could give any hints on how to solve this problem I would be very grateful. (Note: --enable-write18 is enabled, MikTex 2.9)

• standalone uses quotes around the file name to avoid issues with potential spaces and other special characters in them. However, Windows requires double quotes here but Linux (my main OS) requires single quotes. There is a test built in to use the correct quotes for the users OS. Could you check the version of standalone. It should be fixed in v1.1 and later. See the bug report: bitbucket.org/martin_scharrer/standalone/issue/2/… – Martin Scharrer May 20 '13 at 9:42
• @MartinScharrer, thank You for replying. By building the document in the link you specified, I get a log file, which states that the current version of standalone is v1.1b. (The log file can be seen Test Log). Also, could you provide an example of quote option usage. I have tried including \standaloneconfig{convert={quote={"}}} in either mwefig.tex and mwe.tex preamble. However upon compiling, an error is produced: ! Package xkeyval Error: convert' undefined in families standalone.sty'.. – Karolis K May 20 '13 at 12:24
• Ok, it seems that migrating from v1.1b to v1.2 solved the problem. I have probably used wrong syntax in v1.1b. – Karolis K May 20 '13 at 14:43
• @MartinScharrer, as Karolis, I also get this error using v1.1b which can not be fixed by the convert{quote{=}}} trick. Since v1.2 is not in the CTAN archive I'm not much for using it, so I tried by overriding the build setting latexoptions byt adding build={latexoptions={-interaction=batchmode -shell-escape -jobname " \\buildjobname "}} to the package options. This however, ends in a runaway argument. Can you provide a work-around? – Juhl Jul 17 '13 at 12:11
• @Juhl: v1.2 isn't released yet. I will have a look at this problem in the next way as soon I find some time. About your latexoptions code: the double backslash is wrong. Try it with \noexpand\buildjobname if you are using it as class option. Note that there is also a config file as explained by the manual. – Martin Scharrer Jul 17 '13 at 12:38

The problem seems to be solved by version 1.1b:

\documentclass{article}
\usepackage{standalone}
\standaloneconfig{mode=buildnew}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{filecontents}

\begin{filecontents*}{Documents/test_standalone_slave.tex}
\documentclass{standalone}
\usepackage{tikz,pgfplots}

\begin{document}

\begin{tikzpicture}
\draw (0,0) circle (2);
\end{tikzpicture}

\end{document}
\endinput
\end{filecontents*}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{tikz,pgfplots}

The only issue that still appears to me is while using an external style sheet by using \input{macros.tex} in the slave's preamble.