[Tex/LaTex] Integrate ‘Sweave.sty’ in the TeXLive 2010 search path (on Linux)


I'd like to add 'Sweave.sty' to my search-path, so that I don't need to copy 'Sweave.sty' to every Sweave-Document I create.

I've located 'Sweave.sty' in '/usr/share/R/share/texmf/tex/latex'. I tried to create a symlink to this folder in my package-folder, however, this didn't really work.

Anyway, I think adding this folder to TeXLive's search path would be the most elegant solution. I also found instructions on how to expand the search path in TexLive (here). Well, I seem to be too stupid to understand that 🙁 Could somebody explain in clear words how I can add the path mentioned above to my search path?

Thank you!

Best Answer

There are (at least) two parameters you may want to set, and two ways to set them (env var vs conf file) and finally you might want the setting to be system-wide or user specific. Since all this is more or less orthogonal, it makes like 8 possibilities.

First, you may change either TEXINPUTS or TEXMF. The former acts only of TeX's input search path, the later is also used by other tools (imagine the tree contains fonts, bibtex or makeindex styles, etc.) With TEXINPUTS, you should append (or preppend, if files from the new tree should override other versions) /usr/share/R/share/texmf/tex//, separated with a :. For TEXMF, should need to insert the same path where you want inside the braces in the current definition.

Second, environment vs configuration file. For the environment, adding something to TEXINPUTS is easy, but for TEXMF you need to copy the full definition, so that it may look like TEXMF='{$TEXMFCONFIG,$TEXMFVAR,$TEXMFHOME,$TEXMFR,...,$TEXMFDIST}' (with an appropriate definition of a TEXMFR environment variable). Editing the configuration file goes the same for TEXMF, but it's less convenient if you want to change TEXINPUTS since you also need to edit the various TEXINPUTS.format for each format you intend to use. With and envvar, it is easier, since setting TEXINPUTS=:$TEXMFR/tex// in the environment will insert the appropriate TEXINPUTS.format from the conffile before the leading colon.

Finally, user vs system. If you chose to use envvars, I refer you to your favourite shell's (and desktop environment) documentation. For configuration files, it should be noted that, system-wide, there are usually two texmf.cnf files which are both read. You should edit the first one returned by kpsewhich texmf.cnf (in case of doubt, look at the comments in the file). Include only your definitions, eg:

TEXMFR = /usr/share/R/share/texmf

(this is my preferred option btw). Note that if you use a packaged (by Debian or other) version of TeX Live, this may change, see Sylvain's answer. If you want to proceed for a single user, it's harder, because you should place a full (edited) copy of the original texmf.cnf file in some place (~/.texlive2010/texmf-config/web2c would be a ratonal choice) and defined an environment variable TEXMFCNF pointing to that directory.

I hope I didn't got you confused with too much choices, but I thought it might be interesting to explore the different options. If you have admin rights, I'd recommend editing the system-wide additional texmf.cnf to define a TEXMFR and adding it to the definition of TEXMF, as explained above.