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:


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.

  • 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 – user2478 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).

  • 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

If you have multiple files you could make sure that /some/path/preferred/package/versions/ comes before the current directory . in the environment variable TEXINPUTS:


(assuming that . is already in TEXINPUTS).

You can put that line in your .bashrc (if applicable).

Note: I'm not sure whether this is a general solution or some compilers use . first anyways. At least for me (texlive 2016) it worked like this.

  • If TEXINPUTS is not predefined, TEXINPUTS="/some/path/preferred/package/versions/:.:" should work. – Paul Gaborit Feb 1 '17 at 8:51
  • Or simply TEXINPUTS="/some/path/preferred/package/versions/:${TEXINPUTS-.}"; works if defined and if not. – Scz Feb 1 '17 at 8:54
  • Don't forget the final :: TEXINPUTS="/some/path/preferred/package/versions/:${TEXINPUT‌​S-.:}" – Paul Gaborit Feb 1 '17 at 8:56

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.