TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For example, let's say that a user has an older version of somepackage.sty somewhere on their system.


Placing a (possibly different version) somepackage.sty in the working directory appears to shadow the system/installed version.


However, if the preferred version of somepackage.sty is not in the local working directory, how can it be specified on the command line? Is it even possible? In the example below, I want to be able to specify the non-system/non-default version of somepackage.sty:

share|improve this question
up vote 6 down vote accepted

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.

share|improve this answer

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.

share|improve this answer
On my system, the command can be simplified to kpsepath tex. – frabjous Jan 23 '11 at 15:48
I know, but Windows has no kpsepath which is on Linux only a link to kpsetool – Herbert Jan 23 '11 at 16:05

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


or with relative path:


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

share|improve this answer
I think that will always complain that "you requested ../../mypackage, but the package provides mypackage", but that is harmless. (I've not checked in a while, though.) – Ulrich Schwarz Jan 23 '11 at 7:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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