Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.




\input{input.tex}  %this is ok
    \addplot file {plot.dat};  %this is not working




1   2

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

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.

share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.