# output-directory and shell commands

Let's use a small example to use gnuplot to draw a nice function using tikz.

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw plot[domain=-3:3,samples=100] function {sin(x)} ;
\end{tikzpicture}
\end{document}


If I compile (using pdflatex or xelatex) it with --shell-escape, no problem.

BUT, if I compile with -ouput-directory=path, with path different from current directory with only the file.tex, it does not work (except if you previously compile it in current directory and keep some intermediate files).

I want to use the gnuplot functions of tikz, and I need to have separate output dir. How can I say to pgf/tikz that it can find the output files of gnuplot in the right directory ?

EDIT

I realized the problem comes from the file

..../texmf-dist/tex/generic/pgf/modules/pgfmoduleplot.code.tex on line 347 :

\immediate\pgfutil@write18{gnuplot \pgf@plotgnuplotfile}%


So it calls gnuplot without taking into account the fact that the file .gnuplot is not in current directory but in output directory. I juste don't know how to specify the output directory in this line. Is there a macro that contains the path of the output directory ?

EDIT 2 : I realized someone asked the same last question in 2011, and did not get a proper answer (only for luatex) on a mailing list. Does it mean there is no standard solution for pdflatex ?

EDIT 3 : I have the same problem with the package minted, so I wonder now if it's possible to use shell-escape commands and output-directory in the same time !

EDIT 4 : I just realized that someone asked the very same question on SE on using-pgfplots-and-gnuplot-and-compiling-with-output-directory and did not get a proper answer as well.

-
How do you compile pgfplots codes which have a gnuplot option? I am a windows user. – Enthusiastic Student Nov 11 '14 at 21:31
@EnthusiasticStudent I'm sorry, I'm not a windows user :) – Xoff Nov 11 '14 at 21:44