# Look for file in different directory

I'm using gnuplot to graph some things and I have to embed the graphics in latex. The document class I'm using is article. I'm using an epslatex terminal in gnuplot so I get two files, a .tex and a .eps file. If both of them are in the same directory as the document .tex file, using this works:

``````\input{graph.tex}
``````

But I have the figure in another directory, and I have to use:

``````\input{../img/graph.tex}
``````

I get an error saying that graph.eps was not found. This error points to a line in the graph.tex file:

``````\includegraphics{graph}
``````

So it's looking for it in the main directory instead of ../img/. If I change that line to

``````\includegraphics{../img/graph}
``````

then it works, but I would like to make it look in the directory directly, because I have a lot of images and it would be hard to change it for all of them. Can I do that somehow?

• Apr 24 '15 at 22:15

For graphics, you can configure `\graphicspath` in the preamble of your document.

Here is an example:

``````\graphicspath{
{.} % document root dir
{images/}
{img/}
{files/pictures/}
{figures/}
}
``````

Then, you just need to call the figure name when using `\includegraphics`. In addition, you can use `\DeclareGraphicsExtensions{.eps}` to avoid specifying the file extension at every figure.

Regarding the `\input` and `\include` commands, you don't need that `./` before. Just call the directory before the name of the file: `\input{directory/filename}`