How to specify LaTeX style file precedence when multiple versions (might) exist

The order in which the TEXMF trees are searched is fixed in the configuration somewhere. The canonical order is: current directory, user's TEXMF in ~/texmf, system-local TEXMF (usually called texmf-local), and finally texmf and texmf-dist. So, installing manually (into texmf-local as admin/root or ~/texmf as user) always takes precedence.

I've once looked at this situation in the multiver package, but I'm not sure if it will handle files in different texmf trees. (It will try to recognize the optional-argument form \usepackage[opts]{pkg}[yyyy/mm/dd vVersion] and look for vVersion/pkg.sty instead.

But it turns out anyway that the situation is more difficult, because if your "overriding" package loads other packages, they may or may not need to be different versions. Something like a KoMa-Script class would certainly like to load its matching auxiliary packages.

And not giving a version at all would result in some version from a subdirectory being picked (first one found), so a working solution needed a change to the format of the ls-R database.

Long story short: having multiple versions of the same file in the same installation is fraught with danger. One thing you can do is to have, for example, multiple localtexmfs, I think you can switch between those with an environment variable.


you can run from the command line:

kpsewhich -show-path tex

then you get as output all directories where TeX will search for *.tex|*.sty|*.cls|*.fd|*.aux|*.bbl|*.def|*.clo|*.ldf files. Always the first found file will be used. If a doubled !! appears in the list before a directory, then TeX looks for a file ls-R which lists all dir contents, instead of a recursive search in that directory.


You can specify the path to the correct package file in the \usepackage command, for example:

\usepackage{/Users/myname/latex/mypackage}

or with relative path:

\usepackage{../../latex/mypackage}

It works on my system (Mac OS + TeXLive 2010 with pdflatex).

Tags:

Packages