Suppose I have one folder (folder name: stys) where I stored the following files:

  • main.sty
  • other.sty

The full path for the stys folder is:


I created one document (doc1.tex) which I stored in the following directory


doc1.tex requires main.sty, so I used the following line of code, given their relative paths, to call it:


So far, no problems. Then, I need main.sty to call other.sty. I would think that since main.sty and other.sty are in the same folder, the command for calling other.sty would be simply:


But I quickly found that even though both .sty files are in the same directory the command I need is:


because doc1.tex is calling main.sty so the "current directory" is the one where doc1.tex is stored.

My problem arises when I start working on a new document, doc2.tex, which is stored in a different path:


I want to call the same main.sty file, which as I said before calls other.sty

The problem is that the line of code inside main.sty that works for calling other.sty for doc1.tex, which was:


does not work (File `../stys/other.sty' not found.) for doc2.tex because the path of other.sty relatively to doc2.tex would be:


What is the clever way to make this work without having to change the line where other.sty is called inside main.sty every time I create a new document in a different directory? (I want to have main.sty stored in a single location so that is easy to customize it to my needs over time).



  • The best way (in my point of view) is to keep all personal .sty files in one folder and use the system enviroment variable TEXINPUTS point to that folder. However, you use Windows, there might be something similar.
    – user31729
    Apr 26, 2014 at 12:26

1 Answer 1


All your personnal configuration files should go in one directory :


remplace /home/myself by some other path depending of your OS and latex distribution. Then run some program to make your files known and referenced by the latex distribution (mktexlsr for me). Once the file is knows, you can modify it without running this program, and it is visible from every where you want compile a tex file.

TEXIMPUTS variable is not for this purpose.

  • You do not need to run mktexlsr if you place the files in TEXMFHOME and are using TeX Live, at least. TeX does not use a filename database in that case - the default setting is to search the disk. If using TeX Live, use kpsewhich --var TEXMFHOME to get the correct texmf root for installation.
    – cfr
    Apr 27, 2014 at 1:24

You must log in to answer this question.

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