[Tex/LaTex] place the own .sty or .cls files, to make them available to all the .tex files

document-classesinstallingpackagestexmf

I know how to define a package or a class, but how do I make it available (to myself) at all times?

Say I have the package file commonstuff.sty (or myprettyclass.cls), that I want to be able to include in any .tex file I create on my computer. Where do I put it? Do I need to run some installer on it, or is it enough to keep it in a certain folder?

Note: I know I can just place it in the same folder as the .tex file, but that's not what I'm after here. I'm looking for a way to "install" the package centrally on my computer.

Best Answer

You could create a folder below your TeX home directory and put your .sty file therein. Use this command at the command prompt to find out where:

kpsewhich -var-value=TEXMFHOME

On my computer it shows

C:/Users/stefan/texmf

but it might also be ~/texmf/ on a Linux or Unix computer.

Following the TeX directory structure, you should place your file in a subdirectory like ~/texmf/tex/latex/commonstuff/, according to Arthur's comment below. This has the advantage that it is not necessary to update the package database as TeX searches your personal texmf tree directly. If there is an ls-R file in your home texmf tree you can safely delete it as TeX will not use it anyway. (Note: this assumes your personal tree is on a local file system: users with remotely-mounted home folders may still need to hash.)

Regarding MiKTeX, have a look at the section "Installing sty or cls files" in the answer to the question How can I manually install a package on MikTex (Windows).

You can then verify what file will be used with:

kpsewhich filename.sty

This will show the path to the file picked up by the TeX implementation.