[Tex/LaTex] How to get the gnuplottex/epstopdf package to work with “-output-dir” and “-aux-dir” option


I can't seem to get the gnuplottex package to work with my preferred compile options. This is a (not too) minimal example of what I mean:


%     \usepackage{etoolbox}    % proposed fix (not working)


% proposed fix (not working)
%     \let\nodirfigname\figname
%     \def\figname{./tmp/\nodirfigname}
%     \expandafter\patchcmd\csname\string\gnuplot\endcsname
%     {\figname}{\nodirfigname}{}{}


        plot sin(x)
    \caption[Gnuplot]{Gnuplot direkt in \LaTeX}


If I compile the above file via:

pdflatex -shell-escape -output-directory=./tmp -aux-directory=./tmp bla.tex

I get the following error messages:

[Loading MPS to PDF converter (version 2006.09.02).] ) Opening gnuplot
stream bla-gnuplottex-fig1.gnuplotCannot open load file
'bla-gnuplottex-fig1.gnuplot' line 0: util.c: No such file or

(./tmp/bla-gnuplottex-fig1.texepstopdf ($Id: epstopdf.pl 17496
2010-03-18 17:57:31Z karl $) 2.15 !!! Error: Cannot open
bla-gnuplottex-fig1.eps: No such file or directory

! Package pdftex.def Error: File
`./tmp/bla-gnuplottex-fig1-eps-converted-to.pd f' not found.

So obviously epstopdf doesn't like my tmp-dir too much. How do I get the damn thing to convert the .eps files to pdf so that gnuplottex can include it? Any ideas?

Best Answer

You have to patch the \figname command of gnuplottex, but now the gnuplot environment must not use \figname and it's necessary to patch also this one




The curious way to patch \gnuplot is necessary because it's a command having an optional argument.

The code must go after loading gnuplottex (of course \usepackage{etoolbox} can go anywhere before).


With xpatch it's easier