[Tex/LaTex] Defining a local graphicspath for gnuplot epslatex plots

epslatexgnuplot

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.

Best Answer

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

Related Question