# build tex file with pdflatex from other path

I have such a structure:

``````..path..\pyt\go.py
..path..\tex\base\base.sty
..path..\tex\base\img\1.jpg
..path..\tex\book\book1.tex
..path..\tex\book\images\img.pdf
..path..\tex\book\bin\
..path..\tex\book\pdfs\
``````

inside book1.tex there is:

``````\includegraphics{images/img.pdf}
``````

from go.py (python script) i call commands:

``````set TEXINPUTS="..\\tex\\base"
pdflatex -quiet "..\\tex\\book\\book1.tex" -output-directory "..\\tex\\book\\bin\\"
``````

How can i tell pdflatex to read paths inside tex files as relative to its path..? (But this base.sty - can take its 1.jpg file which is attached like: img/1.jpg) If i remove image, everything builds succesfully.

I have found the answear!

inside book1.tex file just add `\graphicspath` command with two paths:

``````\graphicspath{{images/}{../book/images/}}
``````

First path is valid from .tex files folder (usefull for manual build) The second path is valid from build scripts folder. Finally, images are included just by their filenames:

``````\includegraphics{img.pdf}
``````
• I was halfway through that recommendation however it may help to consider expanding to include {../..//} which should include all subdirectories below grandparent directory, however beware that could also search in unwanted sibling directories – user170109 Apr 11 at 13:52
• It would be much better to change to the directory of your main file and to start the compilation from there. – Ulrike Fischer Apr 11 at 13:55
• i will try it.. as i understood: in go.py i change the folder and then set the texinput and run pdflatex? If so... it does not work for me. – pi.314 Apr 11 at 13:57