# How to switch from using color graphics to grayscale graphics?

What is the easiest way to switch from a document with color graphics to one with grayscale graphics?

I have various `fig/` directories that contain my color graphics, and I already have corresponding `fig-gray/` directories that contain the same graphics in grayscale.

Example directories:

``````path1/fig/foo.pdf
path2/fig/bar.pdf

path1/fig-gray/foo.pdf
path2/fig-gray/bar.pdf
``````

I have `includegraphics` commands in various included .tex files, e.g. `\includegraphics[width=5in]{path1/fig/foo.pdf}`.

Now what is the easiest way to tell LaTeX to switch to using the `fig-gray/` directories instead? (I'd like to avoid having to preprocess my .tex files with search and replace.)

-
@user823: It would be nice if you could rename your user name to something more meaningful. Thanks. –  Martin Scharrer Feb 27 '11 at 0:02
@Martin: That actually seems to be a stack exchange bug. I have never registered as "user823". –  Frank Feb 27 '11 at 0:11
Yes, you have now two accounts. The user823 one is 6 month old and the Frank one only 2 days. But I think the moderators can merge the two. –  Martin Scharrer Feb 27 '11 at 0:46
Strange. I have no idea how that happened. I personally don't care though. :) –  Frank Feb 27 '11 at 0:59

Use the `\graphicspath` macro from the `graphics/x` package to specify the directories with your images:

``````\graphicspath{{path1/fig/}{path2/fig/}}
``````

Then you can remove them from the `\includegraphics` macros and only need to change the one line to:

``````\graphicspath{{path1/fig-gray/}{path2/fig-gray/}}
``````

Alternative you could make the `-gray` part a macro, which avoid adding new paths twice:

``````%\newcommand*{\gray}{-gray}% Uncomment to switch to gray-scale images
\graphicspath{{path1/fig\gray/}{path2/fig\gray/}}
``````

This also works directly with `\includegraphics`:

``````\includegraphics[width=5in]{path1/fig\gray/foo.pdf}
``````
-
Thanks! But unfortunately, many files in the different directories have similar names, e.g. `path1/fig/illustration.pdf` and `path2/fig/illustration.pdf`. I hope there's a way that doesn't require me to rename them to make globally unique names... –  Frank Feb 27 '11 at 0:02
@Frank: I see. In this case you should use my second suggestion of using macros as part of the path, but with the actual `\includegraphics` commands. –  Martin Scharrer Feb 27 '11 at 0:07