# Including a tikz figure with a reference to a table on file, problems with folder structure

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:

\input{H6}


Inside H6.tex, I have the following

\begin{figure}
\centering
\input{./H6Figs/Eyeartable.tikz}
\end{figure}


The folder structure in a nutshell:

Main folder:
main.tex
H6.tex
|
--H6 (folder)
Eyeartable.tikz
Eyear.dat


The file Eyeartable.tikz:

\begin{tikzpicture}

\begin{axis}[
ylabel={$Daily \; Energy \; [kWh]$},
xmin=-7, xmax=371,
ymin=-50, ymax=40,
axis on top,
width=\figurewidth,
height=\figureheight,
xtick={0,59,120,181,243,304},
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}
]

\end{axis}

\end{tikzpicture}


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.