3

I am familiar with \graphicspath and have used it in numerous papers where all of my figures are in a single directory.

However, I am now working on a larger project and I have images hierarchically organized by year and month (i.e. all of the images for entries created during July 2016 are in ./Figures/2016/07).

I realize I could generate a long list of folders in the preamble declaration of \graphicspath, but I'd prefer simply updating the setting w/in the document so that for a given section of the document the \graphicspath is {Figures/2016/07} and in the next section it reset to {Figures/2016/08}.

Is there a straightforward way to do this?

UPDATE: I have added \listfiles to the preamble and updated the body so it has

\makeatletter \show\Ginput@path \makeatother   

\graphicspath{{Figures/2016/07/}} 

\makeatletter \show\Ginput@path \makeatother

And posted a copy of the .log file here

To me it looks like the new path is used once and then it reverts back to the path set in the preamble which is {Figures/}.

Here's an example.

> \Ginput@path=macro:
->Figures/.
l.3398 \makeatletter \show\Ginput@path
                                       \makeatother
? 
> \Ginput@path=macro:
->{Figures/2016/07/}.
l.3402 \makeatletter \show\Ginput@path
                                       \makeatother
? 
[94] [95]

...    
[97]

Package hyperref Warning: Difference (2) between bookmark levels is greater 
(hyperref)                than one, level fixed on input line 3505.

<Figures/2016/07/IMG_0152.JPG, id=2868, 2788.4175pt x 1643.13875pt>
File: Figures/2016/07/IMG_0152.JPG Graphic file (type jpg)

<use Figures/2016/07/IMG_0152.JPG>
Package pdftex.def Info: Figures/2016/07/IMG_0152.JPG used on input line 3515.
(pdftex.def)             Requested size: 430.00653pt x 253.38011pt.

Overfull \hbox (199.15846pt too wide) in paragraph at lines 3514--3516
[]\OT1/cmr/m/n/10.95 Notes on board from our dis-cus-sion. [] 
 []


...

LaTeX Warning: File `IMG_0161_and_0162_composite.png' not found on input line 3
936.


! Package pdftex.def Error: File `IMG_0161_and_0162_composite.png' not found.

See the pdftex.def package documentation for explanation.
Type  H <return>  for immediate help.

1 Answers1

2

There is nothing fancy about \graphicspath. You can use it in the preamble or within the document environment, and update it as you need it.

Note that updating it from

\graphicspath{{<pathA>}}

to

\graphicspath{{<pathB>}}

will remove <pathA> from the selected graphics locations.

Werner
  • 603,163
  • Perhaps it's the version of pdflatex (pdfTeX 3.1415926-2.5-1.40.14 (TeX Live 2013/Debian)) I am using, but if I try defining \graphicspath{} within the document the changes aren't recognized. Both of these answers assume otherwise. – mikemtnbikes Jul 26 '16 at 19:50
  • What does \makeatletter \show\Ginput@path \makeatother before and after \graphicspath yield in your .log. – Werner Jul 26 '16 at 20:16
  • If my answer doesn't resolve your problem, how about including \listfiles in your preamble and supplying the community with your .log **File List**. See Which package version am I using? – Werner Jul 27 '16 at 06:40
  • I've added the information you've requested. Thanks for your help. – mikemtnbikes Aug 09 '16 at 20:51
  • @mikemtnbikes: Why not just post it to Pastebin rather? I don't want to sign up to filehosting.org or give them my email address... – Werner Aug 09 '16 at 21:31
  • I am unfamiliar with the different hosting services and went to the first one I found at a link I was pointed to in the SE FAQ area. I've updated the post and it now links to a pastbin.com page. – mikemtnbikes Aug 10 '16 at 14:28
  • @mikemtnbikes: Where is this SE FAQ? Perhaps it should be changed...? – Werner Aug 10 '16 at 15:54
  • @mikemtnbikes: I'd suggest updating your distribution; see How do I update my TeX distribution? Also, your .log doesn't include any reference to the \show command I suggested. Moreover, the document compiled fine (or without error). – Werner Aug 10 '16 at 16:02
  • Sorry there were no errors. I forgot I had revised the file so I could get it to compile. The \listfiles and \show commands were in the file. If you don't mind looking at the .log file with the errors, I'd appreciate it. I've summarized the output above as well. – mikemtnbikes Aug 11 '16 at 14:31
  • @mikemtnbikes: The only reason \graphicspath would revert back to something it was defined as before is when you redefine it within a group. Without seeing the code, I can only speculate. Regardless, I note that most of your packages are out-of-date. Update your distribution. – Werner Aug 11 '16 at 15:28
  • I acknowledge your advice to upgrade my distribution, but am holding off for a number of reasons. I suspect you've identified the problem, though since I'm not doing that explicitly (my definitions are made outside of any explicit environment) I expect it is a result of the labbook.sty file I'm using. – mikemtnbikes Aug 11 '16 at 16:54