Okay, this extremely specific, but a headache that must be solved if you plan to create or modify R extensions (aka R source code packages). This is because R requires that you also build documentation through a process that is partially dependent on LaTeX, and a few specific .sty files. On Mac OS X (snow leopard) running the latest (2.13.1) version of R and the BasicTeX version of TeXLive (2011) via MacTeX.
I find that I prefer to use an unholy (but effective) combination of command-line and GUI for navigating complex distro structures, especially when they are within “hidden” portions of the OS X filesystem, where navigating directly in Finder is not straightforward. Assuming you have the BasicTeX-2011 installed and the a recent version of R installed AND both were installed with the default directory paths for OS X, the following code will bring up the a folder with the .sty files that you need to copy (from within the R framework):
> cd /Library/Frameworks/R.framework/Resources/share/texmf/tex
> open -a Finder latex
Once you have that folder in front of you, grab the “Rd.sty” and “Sweave.sty” files, copy them with command-c, then open the LaTeX folder that you need for the paste:
> cd /usr/local/texlive/2011basic/texmf-dist/tex/latex/
> open -a Finder base
And do your command-p to paste. When done adding those .sty files to the tex/latex/base/ directory, make sure to run:
> sudo texhash
The texhash command will update tex so that its aware of the new .sty files that you just added.
You’ll also notice that the R directory you broke into has an “upquote.sty” file in it. The upquote package is also required for building R package documentation, as are the “helvetic” and “courier” packages, but they are all available from CTAN, so I recommend installing them through your favorite TeX/LaTeX package installing method.
The all-command-line version of what I described above is:
> cp /Library/Frameworks/R.framework/Resources/share/texmf/tex/latex/Rd.sty /usr/local/texlive/2011basic/texmf-dist/tex/latex/base
> cp /Library/Frameworks/R.framework/Resources/share/texmf/tex/latex/Sweave.sty /usr/local/texlive/2011basic/texmf-dist/tex/latex/base
> sudo texhash
I Googled-around for a while to try and find an official repo approach to getting these R-depending LaTeX style files into the LaTeX path. Eventually, I gave up and hacked this approach. I hope it saves someone else some time. The LaTeX-side of these instructions is version dependent, but the R-side is not (necessarily) version dependent and may stay accurate for some time.
Thanks, you saved my life! Now I have a problem with the fonts, but that’s more traceable.
Really, really helpful, thanks!
You’re welcome! And thanks for the comments. I just had to re-use these instructions after updating to texlive-2012. Good thing I wrote this down! What a headache. I don’t know why CRAN hasn’t uploaded these special packages to CTAN. Would save some troubleshooting…
Thanks also from this TeX useR
Pingback: Sweave worked on MacOs Lion Texshop | Preparing and Thinking
Thanks so much, very helpful!