5

I work on XUbuntu 12.04 and I have installed R 2.15. Since the package manager only provides TeX Live 2009, I use the following to install TeX Live 2011 on XUbuntu:

  1. download install-tl-unx.tar.gz from Installing TeX Live over the Internet
  2. tar -xzf install-tl-unx.tar.gz
  3. sudo ./install-tl # see TeX Live - Quick install (hit "I")
  4. add the newly installed version to PATH (in .profile):

    PATH=/usr/local/texlive/2011/bin/x86_64-linux:$PATH
    

Whenever I compile a .tex document containing \usepackage{Sweave}, I obtain

ERROR: LaTeX Error: File 'Sweave.sty' not found.

Typically, one uses a symbolic link to teach (pdf)latex (actually, latexmk in my case) where to find Sweave.sty. I did the following:

cd /usr/local/texlive/2011/texmf/tex/latex # that's the tex tree obtained by kpsewhich -var-value TEXMFMAIN
sudo ln -s /usr/share/R/share/texmf Sweave

I also created a link named Sweave in /usr/share/texmf/tex/latex (via sudo ln -s /usr/share/R/share/texmf Sweave). In both cases, I still obtain that Sweave.sty was not found (even after a reboot/texhash...).

How can I tell pdflatex where to find Sweave.sty?

If you need more information about my setup of R etc., just let me know.

FINAL SOLUTION

Alan's answer below is completely correct. The reason why Sweave.sty was not found in /usr/local/texlive/texmf-local/tex/latex is that I installed TeXLive 2011 via sudo and so I also had to execute mktexlsr via sudo. The problem is (see sudo which mktexlsr vs which mktexlsr) that sudo mktexlsr updates only the old (2009) TeXLive tex tree. I found two posts that precisely address this (http://compgroups.net/comp.text.tex/texlive-not-searching-texmflocal/266185 and http://ubuntuforums.org/showthread.php?t=1843563). The final solution is to sudo chown -R myuser:myuser /usr/local/texlive. Then one can simply use mktexlsr (without sudo) to update the new (2011) TeXLive tex tree. Then, Sweave.sty is found as Alan described.

2 Answers 2

5

The reason why your link isn't found is that additions to the main texmf tree require the ls-R databases to be updated using mktexlsr. However, the usual place for local additions on a Linux system is ~/texmf. If you put your symbolic link in ~/texmf/tex/latex, then you won't need do anything else for it to be found.

You should never place files in any of the .../texlive/<year> directories, since they are for the actual distribution files and can be overwritten by updates.

If you truly need system-wide local additions (for multiple users) you can put them in /usr/local/texlive/texmf-local. If you put things here, you must run sudo mktexlsr to rebuild the ls-R databases.

6
  • Dear Alan, thanks for helping. Your first solution (~/texmf/tex/latex) works (which is good). Your second solution unfortunately doesn't work. I put the link once in /usr/local/texlive/texmf-local and in a second trial in /usr/local/texlive/texmf-local/tex/latex', neither worked (after sudo mktexlsr). Do you know why? Ideally, I would prefer the second solution since it does not clutter my ~. I also found ~/.texlive2011, put in a subfolder /tex/latex/, and created the link from in there, but again, Sweave.sty` was not found. Commented May 25, 2012 at 20:10
  • @Marius Putting the link in /usr/local/texlive/texmf-local/tex/latex + mktexlsr should have worked. That's how my system is set up. (I'm using a Mac, but that shouldn't make a difference in this case.) What does kpsewhich -var-value TEXMFLOCAL return on your system?
    – Alan Munn
    Commented May 26, 2012 at 1:49
  • Dear Alan, thanks again for helping. It returns /usr/local/texlive/2011/../texmf-local, which -- when I cd in that directory -- gives me pwd: /usr/local/texlive/texmf-local Commented May 26, 2012 at 6:09
  • I tested another thing: I copied Sweave.sty in /usr/local/texlive/texmf-local/tex/latex (then executed mktexlsr). But even then it wasn't found. Commented May 26, 2012 at 6:43
  • Can it be that mktexlsr does not work correctly? I obtain: mktexlsr: Updating /usr/local/share/texmf/ls-R... mktexlsr: Updating /var/lib/texmf/ls-R-TEXMFMAIN... mktexlsr: Updating /var/lib/texmf/ls-R-TEXLIVE... mktexlsr: Updating /var/lib/texmf/ls-R... mktexlsr: Done. Commented May 26, 2012 at 9:56
0

I do not have the status to comment, but would like to add one thing for posterity:

If in the above you would have wanted to run the 2011 mktexlsr with sudo, then what you can do (also to update with tlmgr where the same problem occurs if you have an older installation) is to cd into the ../2012/bin/x86_64-linux folder and execute de binary directly from there.

So you would see something like:

/usr/local/texlive/2012/bin/x86_64-linux $ sudo ./mktexlsr

or

/usr/local/texlive/2012/bin/x86_64-linux $ sudo ./tlmgr

(in my case I have 2011 and 2011 installed, hence the foldername above).

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .