[R] Understanding the workflow between sweave, R and Latex

Michael Friendly friendly at yorku.ca
Sat Oct 1 23:09:44 CEST 2011


On 9/30/2011 9:08 AM, syrvn wrote:
> Hi Duncan,
>
> I use Eclipse and StatET plus TexClipse and Sweave which comes with the
> StatET package.
> So fore me it is basically one click as well to produce the pdf from the
> .Rnw file.
>
> I installed the MacTex live 2011 version on my computer and thought it might
> actually be
> easy to find out how and where latex searches for packages. But I did not
> find the place
> where all this is coded...
>

First, since this is Mac-related, you would probably get better answers 
on the R-sig-mac list.

Second, most latex distributions support both a system 'texmf' tree and 
one or more local/user texmf trees, that you can configure with 
something like Preferences somewhere in MacTex.  On my linux system, I use
~/texmf/ and simply copied Sweave.sty to
~/texmf/tex/latex/misc/Sweave.sty   (if my path-memory serves)
No more worries (unless Sweave.sty is changed in a new R distro)

Finally, it does help to RTFM, where you can find other options
under ?RweaveLatex in the Details section.

The LaTeX file generated needs to contain the line \usepackage{Sweave}, 
and if this is not present in the Sweave source file (possibly in a 
comment), it is inserted by the RweaveLatex driver. If stylepath = TRUE, 
a hard-coded path to the file ‘Sweave.sty’ in the R installation is set 
in place of Sweave. The hard-coded path makes the LaTeX file less 
portable, but avoids the problem of installing the current version of 
‘Sweave.sty’ to some place in your TeX input path. However, TeX may not 
be able to process the hard-coded path if it contains spaces (as it 
often will under Windows) or TeX special characters.

The default for stylepath is now taken from the environment variable 
SWEAVE_STYLEPATH_DEFAULT, or is FALSE it that is unset or empty. If set, 
it should be exactly TRUE or FALSE: any other values are taken as FALSE.

As from R 2.12.0, the simplest way for frequent Sweave users to ensure 
that ‘Sweave.sty’ is in the TeX input path is to add 
‘R_HOME/share/texmf’ as a ‘texmf tree’ (‘root directory’ in the parlance 
of the ‘MiKTeX settings’ utility).

By default, ‘Sweave.sty’ sets the width of all included graphics to:
\setkeys{Gin}{width=0.8\textwidth}.



More information about the R-help mailing list