Skip to content
Prev 38732 / 63424 Next

Error in generating sweave-tex -> pdf file

Thanks for all replies.

I found Sweave.sty in the system files of my local machine. It was sitting in 
/usr/share/R/texmf/. The content is the same as the file sent previously. So the 
file has always been in the system but R has been unable to find it.

I put the sty file in the home directory, in the folder where the Rnw file is, 
used \usepackage{/usr/share/R/texmf/Sweave.sty},
set SWEAVE_STYLEPATH_DEFAUL = TRUE, 

still with R CMD check, texi2dvi can't be found.

Recall that before I started to create the package vignette, I could generated 
the pdf file of the tex file by invoking texi2dvi in an R session after loading 
library(tools).

Best,

Carol


----- Original Message ----
From: Kasper Daniel Hansen <kasperdanielhansen at gmail.com>
To: carol white <wht_crl at yahoo.com>
Cc: Duncan Murdoch <murdoch.duncan at gmail.com>; r-devel at r-project.org
Sent: Thu, December 23, 2010 5:13:58 PM
Subject: Re: [Rd] Error in generating sweave-tex -> pdf file

Hi Carol

As you now know, this is because per default R/Sweave puts the line
  \usepackage{Sweave}
in the generated tex file.  This means the tex file is "portable", but
it also implies that Sweave.sty needs to be "installed" in your tex
installation.  Or you can put the Sweave.sty in the directory of the
Rnw file since tex usually is set up to search the same directory.

An alternative is to get R to generate a line like
  \usepackage{FULL_PATH_TO_SWEAVE.STY}
in the tex document.  This implies that the tex file can only be
tex'ed on a setup where the Sweave.sty is at the same place - hence it
kind of break portability.  Now portability of the tex file does not
matter to many users - most of us think of the tex file as an
intermediate file and only care about the Rnw file and the final PDF.
You get this behaviour by setting the environment variable
  SWEAVE_STYLEPATH_DEFAULT
to
  TRUE
An easy way to do this is to include the following line in your .Rprofile
Sys.setenv("SWEAVE_STYLEPATH_DEFAULT" = "TRUE")

This trick also fixes running Sweave on a system where you do not have
admin rights.

Kasper
On Thu, Dec 23, 2010 at 5:14 AM, carol white <wht_crl at yahoo.com> wrote: