I have the following file organization: Main/figures
in 'Main/' I have my main.tex file, in 'Main/figures/' I have a .tikz file and a image.png image that gets included in the tikz file.
The path written in the tikz file is generated automatically and it points to the local folder, but when I load from the Main folder the tikz file, it fails to find the png image, as it tries to search locally.
I can fix this error by setting the path to "figures/image.png" instead of just "image.png", but I want to avoid doing so, as ideally I would like to external people to use these files without further knowledge on how to arrange them.
Minimal example:
main.tex
\documentclass[english]{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{figure}
\input{figures/tikzfile.tikz}
\end{figure}
\end{document}
tikzfile.tikz
\begin{tikzpicture}
\begin{axis}[width=5cm,height=5cm]
\addplot graphics [includegraphics cmd=\pgfimage,xmin=0, xmax=1, ymin=0, ymax=1]
{image.png};
\end{axis}
\end{tikzpicture}
Error
(there are several nonesense errors like "missing $ inserted." There is a warning "File "image.png" not found when defining image "pgflastimage". Tried all extensions in ".pdf:.jpg:.jpeg:.png:" )
Handmade fix I want to avoid
modify in the tikzfile.tikz: {image.png} to {figures/image.png}.
Attempted methods
I've found in SE the use of \graphicspath as an alternative to search for the figures, but it doesn't works in my case.
Here they have a similar problem to include a table.dat, the suggested change seems to apply just for tables in the \addplot command. Trying to modify the solution \pgfplotsset{ table/search path={plots/data}, }
from "table" to "graphics", doesn't works.
graphicxand the other bypgf.\graphicspathwill have no effect on the inclusion of graphics using the PGF mechanism, as far as I know. – cfr Feb 24 '18 at 23:18figuresto your input path. If it doesn't exist, it won't hurt anything, but it will cause TeX to search there, as well as everywhere else. Does it not work to use\includegraphicshere rather than\pgfimage? – cfr Feb 25 '18 at 21:40graphicxinstead. Like I said, you can add it to TEXINPUTS regardless. – cfr Feb 28 '18 at 17:29\pgfimage. I'd expect you could alternatively do the scaling with\includegraphics- as far as I know, the masking stuff is the main thing\pgfimagehas which\includegraphicsdoesn't. In the latter case, you can either use\graphicspathor you could set texinputs, so you have an additional option for helping TeX find the PNG. Masking can be used if, for example, you want to show an image as if it had holes in it or if you want so create a fading effect, so that the image is more (or less) opaque in some parts than others. You make a black ... – cfr Mar 01 '18 at 17:22graphicxdoesn't offer this functionality. – cfr Mar 01 '18 at 17:24