-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use \graphicspath to search for images #565
Comments
Migrated from SourceForge
|
I have a working implementation for this feature. The changes are already used in a complex project which also makes heavy use of TikZ externalization. Currently, the changes are injected into Please advise how to integrate the changes into TikZ directly. The changes are currently loaded through a package: % inputpath.sty
\RequirePackage{etoolbox}
\def\inputpath@pgf@findfile#1:#2+#3{%
\ifx\Ginput@path\@empty
% There's nothing we can loop over: pass the arguments to the original
% command as is.
\inputpath@old@pgf@findfile{#1}:{#2}+{#3}%
\else
\let\inputpath@cur\@secondoftwo
\expandafter\@tfor\expandafter
\inputpath@cur\expandafter:\expandafter=\Ginput@path\do{%
\def\inputpath@filename{\inputpath@cur/#3#1}%
\pgfutil@IfFileExists{\inputpath@filename}%
{\xdef\pgf@filename{\inputpath@filename}%
% Found the file. We're done.
\@break@tfor
}%
{\def\pgf@mightbeempty{#2}%
\ifx\pgf@mightbeempty\pgfutil@empty\else%
\inputpath@pgf@findfile#2+{#3}%
\fi
}%
}%
\fi
}%
\newcommand\inputpath@pgf@declareimage@fail{%
\PackageWarning{inputpath}{\string\pgf@declareimage\space could not be
patched\MessageBreak
to enable graphicx search path support.\MessageBreak
Using \string\graphicspath\space may not extend the\MessageBreak
image search path\@gobble}%
}
\AtEndPreamble{%
\ifx\pgf@findfile\@undefined\else
% Add search path support to \pgfdeclareimage
\let\inputpath@old@pgf@findfile=\pgf@findfile
% Uncomment the following line for debugging purposes:
% \tracingpatches
\PackageInfo{inputpath}%
{Patching two occurrences of \string\pgf@findfile\space in\MessageBreak
\string\pgf@declareimage\space for enabling\MessageBreak
graphicx search path support\@gobble}%
% As of TikZ/PGF 3.1.8b, \pgf@declareimage contains two calls to
% \pgf@findfile. Both references to the original macro must be replaced.
% Check pgfcoreimage.code.tex if patching succeeds but \pgfdeclareimage
% still cannot locate images in the graphicx search path.
\patchcmd\pgf@declareimage
{\pgf@findfile}%
{\inputpath@pgf@findfile}%
{%
\PackageInfo{inputpath}{Patched first occurrence of
\string\pgf@findfile\space in\MessageBreak
\string\pgf@declareimage\@gobble}%
\PackageInfo{inputpath}{Patching second occurrence of
\string\pgf@findfile\space in\MessageBreak
\string\pgf@declareimage\@gobble}%
\patchcmd\pgf@declareimage
{\pgf@findfile}%
{\inputpath@pgf@findfile}%
{\PackageInfo{inputpath}{Successfully patched
\string\pgf@declareimage.\MessageBreak
It is now possible to use \string\graphicspath\space\MessageBreak
to extend the image search path\@gobble}}%
{\inputpath@pgf@declareimage@fail}%
}%
{\inputpath@pgf@declareimage@fail}%
\fi
} Afterwards, one can simply use \graphicspath{{./images/ch00/}} to extend the search path for image declarations. |
Migrated from SourceForge
Author: *anonymous
Timestamp: 2008-08-25 17:38:22
It is quite common to use
\graphicspath{{../images/}}
or similar with\includegraphics
. It would be nice to have pgf search in these directories for\pgfdeclareimage
just like\includegraphics
does.The text was updated successfully, but these errors were encountered: