Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using the package import for chapters of a document. This makes it possible for me to use relative paths when I call \input. It also adjusts paths when I call \includegraphics. It does not, however, adjust the path when I call \graphicspath.

Q: How can I prepend the current sub-directory from \subimport to \graphicspath.

Example

paper.tex contains:

\begin{document}
...
\subimport{subdirectory}{contents}
...
\end{document}

and subdirectory/contents.tex contains:

...
\graphicspath{images//}
\includegraphics{picture}
...

The error is then:

LaTeX Error: File `picture' not found.

It is at ./subdirectory/images/picture.png


Edit: I have posted my own unsatisfactory workaround to this problem below.

share|improve this question

1 Answer 1

Here's my current solution. I redefine \graphicspath to inject the directory (in this case subdirectory).

  \let\gp\graphicspath
  \renewcommand*{\graphicspath}[1]{\gp{{subdirectory//#1}}}
  \subimport*{subdirectory//}{contents}

I then call renewcommand before each call to subimport with the same path.


This is not optimal for me, however, because it does not work if I enclose the path in a block, as in:

  \graphicspath{{images//}}

So, I've had to edit all the graphicspath calls to remove the blocks, as in:

  \graphicspath{images/}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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