3
votes

Let's say I have written the following tiny .Rnw file:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{Sweave}
\usepackage{tikz}
\usepackage{pgf}
\begin{document}

<<>>=
sessionInfo()
@ 

\end{document}

I then can go to R and use sweave to translate the .Rnw file into a .tex file Once this is done the latex interpreter can be called and because I used \usepackage{Sweave} Latex knows how to handle the sweave specific code tags. When I first did this procedure I got the common error that the Sweave.sty file could not be found. I googled and could solve the problem by typing the following command into the Mac OS Terminal:

mkdir -p ~/Library/texmf/tex/latex 
cd ~/Library/texmf/tex/latex 
ln -s /Library/Frameworks/R.framework/Resources/share/texmf Sweave 

What I don't understand now is how does the latex package \usepackage{Sweave} know that it has to look at ~/Library/texmf/tex/latex to find the symbolic link to the Sweave.sty file? What happens if I change the following line:

ln -s /Library/Frameworks/R.framework/Resources/share/texmf Sweave

to

ln -s /Library/Frameworks/R.framework/Resources/share/texmf Sweave_Link

In the .Rnw file do I have to use then \usepackage{Sweave_Link}?

1

1 Answers

3
votes

That path is set automatically when you install LaTeX; it's your personal texmf tree and you can put any style or class files you want LaTeX to find there. The directory names don't matter, it searches recursively in them for Sweave.sty. So changing the directory link to Sweave_Link shouldn't matter.

You can test this by running kpsewhich Sweave.sty which looks in all the texmf trees for the desired file.

Also, you don't need to have \usepackage{Sweave} in the Rnw file; Sweave will add it automatically.