# How to set path in STY file as relative to this file path

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:

 +-Documents
+-Base
| +-baseSettings.sty
| +-BaseImages
|   +-footerImage.jpg
+-Book1
| +-mainBook1.tex
+-Book2
+-mainBook2.tex


mainBook1.tex:

\documentclass[12pt]{article}
\usepackage{import}
\usepackage{../Base/baseSettings}
\begin{document}
...


baseSettings.sty:

\ProvidesPackage{baseSettings}
\usepackage{geometry}
\newgeometry{margin=2.0cm, bottom=3.5cm, top=2.5cm}
\usepackage{...}
% HEADER AND FOOTER:
\rfoot{\includegraphics[scale=0.2,valign=c]{BaseImages/footerImage.jpg}}
...


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?

• 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/…. – Andrew Mar 7 at 7:03

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