-
Notifications
You must be signed in to change notification settings - Fork 111
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
\pgfimage
should support \graphicspath
#1314
Comments
I assume you meant an example other than |
Yes, if you put, e.g., |
sure but you need to rename it as otherwise it'll always pick up the standard one anyway the example as posted gives no error whether or not |
Ah, okay, I guess I didn't quite test thoroughly enough, thanks. I've renamed it. I'm not sure if there's any advantage, but |
You can try what I posted in this TeX-SX answer, \makeatletter
\let\pgfutil@InputIfFileExists=\InputIfFileExists
\let\pgfutil@IfFileExists=\IfFileExists
\makeatother |
Is there a way to make this work with \documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}
\usepackage{import}
\DeclareUnicodeCharacter{2212}{−}
\usepgfplotslibrary{groupplots,dateplot}
\usetikzlibrary{patterns,shapes.arrows}
\pgfplotsset{compat=newest}
\usepackage{graphicx}
\usepackage{amssymb}
\makeatletter
\let\pgfutil@InputIfFileExists=\InputIfFileExists
\let\pgfutil@IfFileExists=\IfFileExists
\makeatother
\usetikzlibrary{external}
\tikzexternalize
\begin{document}
\immediate\write18{mkdir -p images}
\begin{filecontents}{images/some-image.tex}
\documentclass{article}
\begin{document}
.
\end{document}
\end{filecontents}
\immediate\write18{pdflatex -output-directory=images images/some-image.tex}
\begin{filecontents}{images/foo.tex}
\begin{tikzpicture}
\begin{axis}[
title=Example Plot,
xlabel=$x$,
ylabel={$f(x)$},
]
% Attempting to use \addplot graphics without specifying the full path
\addplot graphics [includegraphics cmd=\pgfimage,xmin=0,xmax=1,ymin=0,ymax=1] {some-image.pdf};
\end{axis}
\end{tikzpicture}
\end{filecontents}
\begin{figure}
\centering
\import{images/}{foo.tex}
\caption{Plot with an external image}
\end{figure}
\end{document} |
I was wrong in #1314 (comment) in part. This issue is not a direct duplicate of #1259 since apart from Example 1 redefines all these three commands and now \documentclass{article}
\usepackage{tikz}
\makeatletter
\let\pgfutil@InputIfFileExists=\InputIfFileExists
\let\pgfutil@IfFileExists=\IfFileExists
\ifdefined\ExplLoaderFileDate
\ExplSyntaxOn
\def\pgfutil@getfullnameTF{\file_get_full_name:nNTF}
\def\pgfutil@ifemptyTF{\tl_if_empty:nTF}
\ExplSyntaxOff
\def\pgf@findfile#1:#2+#3{%
\begingroup
% similar to how \Ginput@path is used in \Ginclude@graphics, graphics.sty
\let\input@path=\Ginput@path
\pgf@findfile@i#1:#2+{#3}%
\endgroup
}
\def\pgf@findfile@i#1:#2+#3{%
\pgfutil@getfullnameTF{#3#1}\pgf@filefound
{\global\let\pgf@filename=\pgf@filefound}%
{\pgfutil@ifemptyTF{#2}{}{\pgf@findfile@i#2+{#3}}}%
}
\fi
\makeatother
\graphicspath{{./tikz-gh1314}}
% create sub-dir "./tikz-gh1314" and image "./tikz-gh1314/some-image-2.pdf"
\immediate\write18{mkdir -p tikz-gh1314}
\begin{filecontents}[force]{tikz-gh1314/some-image-2.tex}
\documentclass{standalone}
\begin{document}
\fbox{some-image-2.tex}
\end{document}
\end{filecontents}
\immediate\write18{pdflatex -output-directory=tikz-gh1314 tikz-gh1314/some-image-2.tex}
\begin{document}
\includegraphics{some-image-2}
\pgfimage{some-image-2}
\end{document} Adding the same redefinitions to example in #1314 (comment), it errors in first run, but then works in all following runs. Content of ! Extra }, or forgotten \endgroup.
\@endfloatbox ...pagefalse \outer@nobreak \egroup
\color@endbox
l.74 \end{figure} Example 2,
|
Thank you!
What's the cause of the error? |
I don't know why. Either removing With Example header
Example 3: A simplified version raising error If \documentclass{article}
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize
\begin{filecontents}[force]{bar.tex}
\begin{tikzpicture}
\draw (0,0) rectangle (1,1);
\end{tikzpicture}
\end{filecontents}
\begin{document}
\input bar.tex
\end{document} |
Brief outline of the bug
Using
includegraphics cmd=\pgfimage
breaks use of\graphicspath
Minimal working example (MWE)
The text was updated successfully, but these errors were encountered: