I'm having trouble including gnuplot plots (epslatex terminal) that are stored in a subdir of my main tex.

Here's how i create a plot in gnuplot:

set datafile separator ","
set terminal epslatex input color size 3.2in,2.8in font 8 header \

set out 'test.tex'
plot    "../data/points.csv"  using 22:$11 with lines title 'curve'
set out

Because I use this same gnuplot code for lots of different datasets, I cannot assign a unique name to the output instead of "test.tex" but simply distinguish the datasets only by the subdirectories they are stored in.

Say I have a set of "test.tex" and "test.eps" in each of the subdirectories "subdir1" and "subdir2" of my main.tex. Now consider the following not working minimal example:



This does not work, because the epslatex terminal writes


into test.tex which is however included in the main directory. Furthermore I can't use


because then the .eps files that have all the same name would be mixed up.

Is there a way to define a local graphicspath within the \input{} or the test.tex or at least within an environment (that can itself be included into a subfloat) I could put the \input{} command into?

Until now I have to go to each included test.tex and specify the exact path of the test.eps which is tedious, because this correction gets overwritten every time I redo the plot in gnuplot.

  • {\graphicspath{{./subdir1}} \input{./subdir1/test}} probably works – David Carlisle Aug 27 '14 at 18:02
  • Putting '{\graphicspath{{./subdir1}}' before the '\input{}' commands does not work, unfortunately. – Christoph90 Aug 27 '14 at 18:46
  • 1
    It should work:-) (I implemented it:-) what error message do you get oh also the components should end in / so \graphicspath{{./subdir1/}} – David Carlisle Aug 27 '14 at 18:54
  • Thank you very much, ending the paths with / made it work! Used xparse to define a macro \DeclareDocumentCommand \gnuplot {m m}{{\graphicspath{{./#1/}} \input{./#1/#2}}} then. Could you post you comment as an answer so I could accept it? – Christoph90 Aug 28 '14 at 7:23
{\graphicspath{{./subdir1/}} \input{./subdir1/test}} 

should work, setting the path in a local group. Note that always in graphicspath, the path components have to end with the directory separator (usually /).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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