Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

/path/to/install/latex/somepackage.sty

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

/some/other/dir/myfile.tex
/some/other/dir/somepackage.sty

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:

/some/path/preferred/package/versions/somepackage.sty
/my/current/project/myfile.tex
share|improve this question
add comment

3 Answers 3

up vote 4 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
add comment

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
add comment

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).

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
add comment

Your Answer

 
discard

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.