[Tex/LaTex] How to install custom sty files where the LaTeX compiler can find them

tex-coretexliveUbuntu

I created a custom beamer style. For this I have several .sty files. I am able to install this custom theme on my Ubuntu 12.04 with the standard tex-live provided distribution by putting it my home as following:

~/texmf/tex/latex/beamer/base/themes

And then running texhash

I want to know how to proceed in order to have pdftolatex compiler aware of this package if I put it in a custom directory.

Best Answer

Tex-live supports a number of environment variables that are used to specify where to look for files. The most important ones are TEXINPUTS (for packages, classes and support files), BSTINPUTS (for bibtex/biblatex styles) and BIBINPUTS (for bibtex/biblatex databases).

To add your own folder ~/mystuff, just add it to TEXINPUTS and maybe also BSTINPUTS (bash syntax):

export TEXINPUTS=~/mystuff//:${TEXINPUTS}
export BSTINPUTS=~/mystuff//:${BSTINPUTS}

If a directory is postfixed by a trailing double slash, it is searched recursively by pdftex for files, so you may store arbitrary folder structures inside it.

The path can also be relative, which comes handy in collaborative settings (with using a source control system, such as git or subversion). For such projects, I usually maintain a per-project texmf folder with all "unusal" packages, package versions and so on that is committed together with the project's source file into the repository. In the accompanying makefile I then set TEXINPUTS to ./texmf//:${TEXINPUTS}, so that the project is "self-contained" and can be checked out and compiled by any colleague with a standard tex-live distribution. Details about this approach can be found in this answer.