# Getting \includeonly functionality with import package

I had problems compiling with the `\includeonly` `\include` system since I had images in the document form different subdirectories. For example the main file would be at `/Main/MainFile.tex` and the included file at `/Main/Chapter1/Chapter1.tex` and one of the images would be at `/Main/Chapter1/Images/Image1.jpg` which was actually loaded through the `Chapter1` file as `\includegraphics{./Images/Image1}`.

I had the problem fixed with the `import` package using `\subimport{}{}`, but I don't have the `include` functionality of different `.aux` files which keeps the pagination and cross references intact.

How do I get the best of both?

-

## 1 Answer

You can tell LaTeX where to look for included pictures, using the `\graphicspath` setting. For example,

``````\graphicspath{{/data/experiments/plots/}{/data/simulations/}}
``````

will prompt LaTeX to look for pictures relative to both these folders. You can then include e.g. `/data/experiments/plots/first/straightline.pdf` as `first/straightline`, and `/data/simulations/rollthedice.pdf` just as `rollthedice`.

In this way, you can avoid typing out very long absolute paths every time, and yet you don't have to change anything if you move parts of your document from one directory to another.

-