My usual practice for large documents with a lot of illustrations is to organize the graphics files into one or more subdirectories, and then to add those subdirectories to the graphics path so that \includegraphics
can find the illustrations:
\documentclass{article}
\usepackage{graphicx}
\graphicspath{{images/}}
\begin{document}
\includegraphics[width=\linewidth]{cc-by-sa}
\end{document}
The problem with this approach is that if my TeX installation happens to contain a file named, say, cc-by-sa.png
(which, coincidentally, TeX Live 2015 does), then \includegraphics
uses that graphic instead of mine. In this case, instead of ./images/cc-by-sa.pdf
, my document contains /opt/texlive/2015/texmf-dist/tex/latex/stex/mikoslides/cc-by-sa.png
.
Maybe the package authors had good reasons for implementing this behaviour, but I find it inconvenient for my use cases. When I am naming a graphics file for use in my document, I don't want to have to manually check for clashes against a list of all graphics in my entire TeX installation (which, to be safe, is something I need to do every time I update TeX Live, since package authors occasionally add graphics files).
How can I prevent \includegraphics
from looking for graphics in my entire TeX installation, or at least from looking there first? I want my own manually specified graphics paths to take precedence.
The package documentation (dated 2014/04/27) seems to contradict itself as to whether this is possible. On page 12 it says that \graphicspath
"may be used to specify a list of directories in which to search for graphics files" and that "the default setting of this path is \input@path
". To me this implies that there exists a default which will be overridden if \graphicspath
is explicitly set. However, the following page suggests that manually setting \graphicspath
only supplements, but does not replace, the default: "Note that LaTeX will find the graphics file by searching along TEXINPUTS (and possibly other places, as specified with \graphicspath
)". The search order is not specified.
.//:
so that subdirectories of the current directory are at the head of the search path, path searching with TEXINPUTS is much faster than \graphicspath which does the logic in TeX rather than C – David Carlisle Apr 7 '16 at 22:33