1

I've seen this sort of question on a lot of fora, but I haven't found an answer to my question. If the answer is already out there and I didn't find it, I apologize in advance. The situation is as follows:

I have 1 big folder (let's call it, 'MyProject'), consisting of 16 other folders, say Case1, Case2,..., Case16. Those folders in turn consist each time of 2 folders each, say Property1 and Property2. In Property1 and Property2, there are always 10 figures, and always with the same name. For example: In Property1, there's a figure called method1. In Property2, there's also a figure called method1, but is now a different figure (showing the second property of said method). Here's an attempt of a schematic overview:

MyProject

Case1

  • Property1
    • method1.eps
    • ...
    • method10.eps
  • Property2
    • method1.eps
    • ...
    • method10.eps

Case 2

  • Property1
    • method1.eps
    • ...
    • method10.eps
  • Property2
    • method1.eps
    • ...
    • method10.eps

And so on.

My problem is: I want to include all those figures in a LaTeX-file, but I'd prefer if they could stay in these folders and if I didn't have to change each name of each file, that would be perfect. I'm aware of the command \graphicspath{{C:/...}{subdir2/}{subdir3/}...{subdirn/}}, but I'm afraid that won't work in my case as the names of my figures are each time the same. Does anyone have some pointers for me?

As always, any help would be dearly appreciated.

  • 2
    Why don't you use \includegraphics{Case1/Property1/method1} ? – Ulrike Fischer Apr 7 '16 at 9:22
  • D'oh. Is it really that simple? If so, thank you kindly my lady! – Riley Apr 7 '16 at 9:23
  • As long as your document resides in the main folder it should work. And I'm not a sir. – Ulrike Fischer Apr 7 '16 at 9:25
  • @Riley Ulrike is female ;-) – daleif Apr 7 '16 at 9:25
  • Woops, edited. And it works! Thanks, my lady! ;-) – Riley Apr 7 '16 at 9:38
2

Here is a different way than specifying the path explictly, \graphicspath sets it stuff locally, so we can do

\documentclass[a4paper]{memoir}
\usepackage{graphicx}

\newenvironment{localgraphicspath}[1]{
  \graphicspath{#1}
}{}

\begin{document}

\begin{localgraphicspath}{{A/}}
  \includegraphics{test}
\end{localgraphicspath}

\begin{localgraphicspath}{{B/}}
  \includegraphics{test}
\end{localgraphicspath}

\end{document}

Here I have two folders A and B each containing test.jpg (different images from the mwe package in TeXLive)

Thus in your master you could say

\begin{localgraphicspath}{{B/}}
  \include{Chapter1}
  \include{Chapter2}
\end{localgraphicspath}

and then for others.

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.