2

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:

D:\a\b\c\stys

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

D:\a\b\c\daaa

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

\usepackage{../stys/main} 

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:

\usepackage{other}

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

\usepackage{../stys/other}

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:

D:\a\b\c\dbbb\e

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:

\usepackage{../stys/other}

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

../../stys/other

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).

Cheers,

Fabio

  • 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 '14 at 12:26
1

All your personnal configuration files should go in one directory :

/home/myself/texmf/tex/latex/Perso

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 '14 at 1:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.