TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

\documentclass[a4paper,10pt]{scrreprt}

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

\graphicspath{{./tmp/}}
\epstopdfsetup{outdir=./tmp/}

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

\begin{document}

\begin{figure}[htbp]
    \begin{gnuplot}[terminal=epslatex,terminaloptions=color]
        reset
        plot sin(x)
    \end{gnuplot}
    \caption[Gnuplot]{Gnuplot direkt in \LaTeX}
    \label{fig:gnu}
\end{figure}

\end{document}

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 directory

(./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?

share|improve this question
    
Added egreg's proposed fix (in comments). Unfortunately it doesn't work. Error message: [Loading MPS to PDF converter (version 2006.09.02).] ) ! I can't write on file './tmp/bla-gnuplottex-fig1.gnuplot'. \gnuplotverbatimwrite ...openout \verbatim@out #1 \BeforeStream \let \do \@m... l.20 ...}[terminal=epslatex,terminaloptions=color] ! Emergency stop. \gnuplotverbatimwrite ...openout \verbatim@out #1 \BeforeStream \let \do \@m... l.20 ...}[terminal=epslatex,terminaloptions=color] – con-f-use Nov 27 '11 at 10:09
    
Did you try removing \graphicspath? – egreg Nov 28 '11 at 17:59
    
Yep, it's in the example code above... – con-f-use Nov 29 '11 at 8:17
1  
It works for me. Ensure that the tmp directory exists and you have write privileges in it. – egreg Nov 29 '11 at 8:35
    
Been there, done that. Not working, but thanks. – con-f-use Nov 29 '11 at 21:33

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

\usepackage{etoolbox}

\let\nodirfigname\figname
\def\figname{./tmp/\nodirfigname}

\expandafter\patchcmd\csname\string\gnuplot\endcsname
  {\figname}{\nodirfigname}{}{}

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).


Update

With xpatch it's easier

\usepackage{xpatch}

\let\nodirfigname\figname
\def\figname{./tmp/\nodirfigname}

\xpatchcmd\gnuplot{\figname}{\nodirfigname}{}{}
share|improve this answer
    
Nope, sorry that doesn't work for me. When I try your fix I get: I can't write on file './tmp/bla-gnuplottex-fig1.gnuplot'. \gnuplotverbatimwrite ...openout \verbatim@out #1 \BeforeStream \let \do \@m... l.20 ...}[terminal=epslatex,terminaloptions=color] I edited my post with comments showing where I included your code. – con-f-use Nov 27 '11 at 9:59
    
Thanks for your help though, I could use some more. – con-f-use Nov 27 '11 at 10:05
    
This worked for me (Windows7, Miktex, TeXworks with "-aux-directory=tmp"). Thanks! – Cornelius Sicker Jul 6 at 9:09
    
@CorneliusSicker You can use xpatch and avoid the funny code – egreg Jul 6 at 9:16
    
@egreg Thanks for the update. Actually I had problems with the old version using etoolbox when I tried to use the gnuplot environment within a subfile embedded in a master document with the help of the subfiles package. In this case the figures just would not be rendered (with no errors while compiling). The xpatch version seems to have solved that issue. – Cornelius Sicker Jul 6 at 11:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.