2

When I produce a graph with PGFplots, I first test it, before importing it in my main document tex file.

I have the file tikzpicture.tikz in which the tikzpicture environment data is included, and I have the file tikzpicture_standalone.tex with the minimal content

\documentclass{article}
\usepackage{pgfplots}
\pagestyle{empty}
\begin{document}
    \input{tikzpicture.tikz}
\end{document}

to 'test' the picture.

In tikzpicture.tikz I use the command \addplot{table.txt}, where table.txt is in the same directory. The testing goes fine.

When I then use the \input command to call tikzpicture.tikz in my main tex file, which is in another directory, it obviously does not work as table.txt is not in the same directory anymore. I have to use path/table.txt instead.

Changing this for all table data every time is annoying and inefficient, so I was wondering if there is a way to let the \addplot command check the local directory too, for the file table.txt. Then, I would not need to add the file paths all the time.

3

You can use the method suggested in

pgfplots from file: search path, looking for \graphicspath equivalent

to tell pgfplots the path of your data files. You have to specify a global path starting from root folder so pgfplots looks in the right folder independently from where is compiled.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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