4

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 \
   "\\scriptsize"

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:

\documentclass{scrbook}
\usepackage{graphicx}
\usepackage{epstopdf}

\begin{document}
  \input{./subdir1/test}
  \input{./subdir2/test}
\end{document}

This does not work, because the epslatex terminal writes

\put(0,0){\includegraphics{test}}

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

\graphicspath{{./subdir1}{./subdir2}} 

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.

4
  • {\graphicspath{{./subdir1}} \input{./subdir1/test}} probably works Commented Aug 27, 2014 at 18:02
  • Putting '{\graphicspath{{./subdir1}}' before the '\input{}' commands does not work, unfortunately. Commented Aug 27, 2014 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/}} Commented Aug 27, 2014 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? Commented Aug 28, 2014 at 7:23

1 Answer 1

6
{\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 /).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .