I am trying to include a tikz figure in the chapter 6 of my thesis. I am using separate folders and .tex files for each chapter, as you may notice in the example. This means that in my main document I have the following code:


Inside H6.tex, I have the following


The folder structure in a nutshell:

Main folder:
   --H6 (folder)

The file Eyeartable.tikz:


ylabel={$Daily \; Energy \; [kWh]$},
xmin=-7, xmax=371,
ymin=-50, ymax=40,
axis on top,
xticklabels={Jan 1,Mar 1,May 1,Jul 1,Sep 1,Nov 1},
legend entries={Consumed,Generated,Exchanged},
xticklabel style={anchor=north east,rotate=45}

\addplot[mark=none,color=blue] table[x index=0,y index=1,header=false] {"Eyear.dat"}; 
\addplot[mark=none,color=green!50.0!black] table[x index=0,y index=2,header=false] {"Eyear.dat"}; 
\addplot[mark=none,color=red] table[x index=0,y index=3,header=false] {"Eyear.dat"}; 



This figure shows perfectly in qtikz, but when trying to compile it in my document I get:

Package pgfplots Error: Could not read table file '"Eyear.dat"

Any help would be greatly appreciated.

  • Is the .dat file in the present working directory of the .tex documents?
    – dustin
    Jun 26 '13 at 17:54
  • I believe this is a duplicate of tex.stackexchange.com/questions/38412/…
    – Jake
    Jun 26 '13 at 18:05
  • Including H6Figs/ in the tikz file helps (although now it doesn't work anymore in qtikz, but I can live with that). I actually tried it before but probably missed one Eyear.dat, throwing me of my trail. Thanks for the help
    – BartV
    Jun 27 '13 at 9:30
  • This problem can be solved by the currfile package, at least partially. see this question and answer by Jost
    – zljt3216
    Jul 1 '16 at 4:23

Namefiles are relative to the path of your main document, not to the path of the last input document. So you have to put your .dat file in the main folder, or to write the relative route H6Figs/ before the filename in each \addplot.

Alternatively, you can set TEXINPUTS=.//: before compiling. This basically "flattens" all your directory tree at the eyes of latex. It is not advisable if files with the same name appear in different directories.

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.