4

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.

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/}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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