I need to write several documents (mainBook1.tex, mainBook2.tex,..), all with the same layout. So basically I moved all common settings to outer file (baseSettings.sty) extension, which is pleaced in other path from docs main TeX files. See my files tree:

   | +-baseSettings.sty
   | +-BaseImages
   |   +-headerImage.jpg
   |   +-footerImage.jpg
   | +-mainBook1.tex




\newgeometry{margin=2.0cm, bottom=3.5cm, top=2.5cm}

And problem is, that those .jpg files cant be found. If I move folder BaseImages into Book1 folder, everything works fine. But I would like to have base images stored only once.

So the question is: How to set those paths in .sty file as relative from this file?

I use: MiKTeX with TeXworks. I just press the Typeset button to create PDFs – I'm not familiar wih all the magic behind.

Is it possible to compile it with command?

  • 3
    Set the TEXINPUTS environment variable to ssomething ../Base;../Base/BaseImages; and then you should be able to use \usepackage{baseSettings} and the images will work. See tex.stackexchange.com/questions/149714/….
    – user30471
    Commented Mar 7, 2019 at 7:03

1 Answer 1


You should never use a path with \usepackage just use \usepackage{baseSettings} and it's usually more portable to omit the path from \includegraphics as well, so \includegraphics[scale=0.3]{headerImage} then just arrange that Base// is in the tex input path and any files anywhere below that will be found.

 TEXINPUTS=Base//: pdflatex mainBook1

would work for example if you have a bash or similar command line, but normally you would set the default TEXINPUTS elsewhere.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .