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.

Is there a way to specify a \graphicspath that includes all sub-directories? I know I could put all my graphics in a texmf tree, but I'd like to have them in another directory tree. As far as I can tell, \graphicspath won't include sub-directories.

I'm using MikTeX 2.8.

share|improve this question
    
You marked Trevor's answer as correct: did this work for you, and if so how? I'm trying to track down some information one whether this really works, and if so the detailed requirements (TeX system, etc.). –  Joseph Wright Sep 14 '11 at 20:33
    
I think it used to work, but I actually just ended up putting my images into a texmf root so I didn't use it. In any case, it doesn't work now. I'm using MikTeX 2.9 on Windows 7 64bit. –  Rob Hyndman Sep 15 '11 at 4:23
add comment

5 Answers

up vote 3 down vote accepted

Nope. (Not as far as I know.) The way \graphicspath works is simply to iterate over each directory specified and ask the equivalent of \IfFileExists{<thepath><thegraphic>.pdf} when you try to \includegraphics{<thegraphic>}. Since you can't specify wildcards when asking TeX to input a file, similarly you can't specify wildcards when asking it to insert a graphic.

One small caveat: with -shell-escape you could run a batch script (or, better, a Lua script) that iteratively listed the subdirectories of a given path and then inserted them back into the document for \graphicspath. But there's nothing around currently that will do that. (Again, as far as I know. I don't use Windows these days so I'm a bit out of the loop with MiKTeX.)

share|improve this answer
add comment

You could add the relevant directory to your TEXINPUTS environment variable. If you end with a double-slash (eg, TEXINPUTS=.:/home/me/images// on a unix system) TeX should search recursively (I haven't tested personally). This is much more efficient than having latex macros do the searching.

share|improve this answer
    
I tried using texlive2012 on Windows and for me it works, but with usual windows paths ( ; and \ instead of : and ) Thanks! –  Marco van de Voort Oct 2 '13 at 8:03
add comment

For me \graphicspath{{Figures//}} seems to work with miktex. Note the extra slash.

share|improve this answer
    
using this will be very very usefull, but I've tried to use \graphicspath{{Figures//}} on windows7, texmaker, and it doesn't work. Why? . Can you include and example document? Thank you –  Daniteba Jan 16 '13 at 13:39
    
Sorry for the extremely late reply. I haven't logged into tex.stackexchange for a long time. This method worked for me or used to work (I haven't tried it recently) but judging by more recent comments it no longer does. From the dates I can only assume something must have changed some time in 2011 since all references of this working for me and others are from 2010 or earlier sometimes with a warning against its use. eg latex-community.org/viewtopic.php?f=5&t=3205 –  cue Feb 5 '13 at 16:50
add comment

Sure, it is possible. E.g.

\usepackage{graphicx}
\graphicspath{{}{eps/}{eps/seminar/}{png/}}

if the eps, png folders are placed at same level as your source file. A more sophisticated version allows importing graphics from the parent folder:

\usepackage{graphicx}
\graphicspath{{}{../eps/}{../eps/seminar/}{../png/}}

With this settings, you don't need (althoug you can!) to indicate path to graphics file from within \includegraphics.

share|improve this answer
add comment

It sounds like what you want is to specify one folder using \graphicspath and then recursively use all the subfolders as part of the graphics path.

If this is what you need, then you can easily do that by doing the following (from wikibooks Latex):

\graphicspath{{images//}}

Explanation of the above command:

  • The root folder is "images". But you could replace that with any path.
  • The more important part of this code is the double slash "//". The double slash "//" tells graphicspath to recursively include all the subfolders.
    • There is a caveat that using this recursive search may hog memory, please keep this in mind.
share|improve this answer
    
Can you point to a system where this actually works? At the LaTeX level, recursion is not possible, so this would have to use modified binaries. For me, both TeX Live 2011 (Mac, Ubuntu, Windows) and MiKTeX 2.9 (Windows) do not do this. –  Joseph Wright Sep 14 '11 at 20:13
    
hm... well... i don't know what to say. Other than i didn't test it. the person asking the question accepted it... so i assumed he tested. but i guess not??? AND i got the answer from wikibooks... so i guess they are also wrong. –  Trevor Boyd Smith Sep 14 '11 at 20:30
    
cue also answered... below mine... he says it works on miktek. –  Trevor Boyd Smith Sep 14 '11 at 20:31
    
What I've seen is that various people say 'it is in the wikibook', but I'm yet to find someone who has actually done this! It certainly does not work at a LaTeX package level, so it would have to be engine dependent, hence asking about it. Thanks for the quick response: I'll ask the questioner! –  Joseph Wright Sep 14 '11 at 20:32
    
@Joseph I was under the impression that double-slash for recursive search was only for paths in TEXINPUTS env variable. –  Lev Bishop Sep 14 '11 at 21:06
show 1 more comment

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.