# Append entries to an existing \graphicspath

I have a \graphicspath command at the beginning of a document (the main document):

\graphicspath{{images/}{extras/images/}}


I have sub-documents into which I insert images (actually SVG files from Inkscape):

\def\svgwidth{\linewidth}
\input{/another/path/images/ppn522-graphs.pdf_tex}


These sub-documents may be inserted into different main documents.

But they need some information about images to be included so I need to do this:

\def\svgwidth{\linewidth}
\graphicspath{{/another/path/images/}}
\input{/another/path/images/ppn522-graphs.pdf_tex}


Problem: this overrides my first \graphicspath declaration: my logo images (and extras/images) are not found anymore (generating errors) after I insert the \graphicspath{{/another/path/images/}}

My question: how could I append an entry to the \graphicspath ?

Or is there a variable that contains the \graphicspath value so I can re-use it ?

    \graphicspath{\thegraphicspathvalue{/another/path/images/}}


EDIT: I already tried this, but it does not work :

\graphicspath{\typeout{\Ginput@path}{../images/}}

-

The variable containing the paths is \Ginput@path, so you can define

\makeatletter
\newcommand\appendtographicspath[1]{%
}
\makeatother


and \appendtographicspath{{../images/}} should do. Remember the braces around the path; you can add several paths.

This addition is global. You might want to extend the macro for “prepending”; in this case, use etoolbox:

\usepackage{etoolbox}
\makeatletter
\newcommand\appendtographicspath[1]{%
\gappto\Ginput@path{#1}%
}
\newcommand\prependtographicspath[1]{%
\gpreto\Ginput@path{#1}%
}
\makeatother


With \appto and \preto the additions would be local, but I don't think it's good.

-
I works perfectly. A question: the order is important only if I have several images with the same name, isn't it ? –  lauhub Apr 15 at 8:43
@lauhub Yes. Note that using \graphicspath slows down the searching process, so more often visited directories should go first. –  egreg Apr 15 at 9:38