# import input pgfplots with relative paths

The package import makes it posible to \input (and \include) a .tex document which itself \input (or \includegraphics etc.) stuff using relative paths. I was hoping that this also would work with the \addplot file in pgfplots, but it does not. Is there a way to use relative paths in pgfplots?

Failing example: Place main.tex anywhere and edit path to fig.tex. - File fig.tex, input.tex and plot.dat in same directory. I can compile the standalone fig.tex, but main.tex can not find plot.dat.

### main.tex

\documentclass{article}
\usepackage{import}
\usepackage{standalone}
\usepackage{pgfplots}
\begin{document}
mainMain
\import{\absolute\path\to\fig.tex}{fig.tex}
\end{document}


### fig.tex

\documentclass{standalone}
\usepackage{pgfplots}
\begin{document}
\input{input.tex}  %this is ok
\begin{tikzpicture}
\begin{axis}
\addplot file {plot.dat};  %this is not working
\end{axis}
\end{tikzpicture}
\end{document}


### input.tex

anything


### plot.dat

1   2


-

Pgfplots processes input files line-by-line, a requirement which is impossible using \input or \include. Consequently, pgfplots uses \read (a low level TeX macro) for the job.

The requested feature is unsupported by pgfplots and would need to be implemented.

Note that while it is not programmatically supported by pgfplots, you could still modify the TEXINPUTS variable (i.e. the file search path used by TeX globally): this would also allow pgfplots to find your file. This is particularly simple on a unix system (does someone know if miktex also respects this variable?). The main idea here would be to set the environment variable to /your/path:/your/other/path: . Note the final colon (:): it tells TeX to append the system pathes at this location.

-
It would be be a nice thing, so please implement it. \begin{badJoke} You have my permission. \end{badJoke} –  Hans-Peter E. Kristiansen Dec 16 '11 at 12:05
Thanks ;-) . There are other pending feature requests (namely to support search paths programmatically). Wouldn't this also solve the problem? –  Christian Feuersänger Dec 16 '11 at 13:36
Problem: Standalones with pgfplots can with relative paths be moved, copied and distributed:o) -but not inserted into other documents:o( –  Hans-Peter E. Kristiansen Dec 16 '11 at 16:17
I do not know exactly what 'support search paths programmatically' means, but I hope it solves my problem. –  Hans-Peter E. Kristiansen Dec 16 '11 at 16:20
The feature request "support search paths programmatically" involves some command like \graphicspath{{/your/path}{/your/path2}} which is defined in the preamble (pgfplots would use a different syntax). Any file input routine would then search through this path in order to find a match. –  Christian Feuersänger Dec 16 '11 at 21:38
show 1 more comment