I have pgfplots tikzpicture where I use data from external data file. I use this picture in multiple latex documents that are located in different directories. So when I try to compile these documents, the relative path for data files is not always the same. Is there a way to import data that is relative to tikzpicture document instead of relative to working directory?


Yes. you can use the import package for this.

\import{path to folder}{filename}
  • I am not so sure this works for pgfplots. Let's say that I have main document in latex/main.tex and I use input to include tikzpicture from latex/plots/diagram.tex. In diagram.tex file I import data from data/dataForDiagram.dat file with pgfplots table command. I tried to import diagram.tex file with import and subimport commands but data won't be imported. It causes error: could not read table file '../../data/dataForDiagram.dat' – Lesenger Jul 21 '16 at 11:02

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.