Another question about Sweave (actually it is more a question
about TeX). Is there a reliable (system-independent) way to
use Sweave.sty without having to place it in the current working
directory? MiKTeX under Windows has dropped the use of
TEXINPUTS, and this complicates the problem.

Furthermore, you cannot refer to Sweave.sty using its full path
as this would obviously not be system-independent.

Yet another small issue: If I configure Sweave to use a
temp directory for its temp files, and if this temp directory
does not exist, TeX fails with error diagnostics that is not
clear at all. Is there a way to have TeX automatically
create the directory if necessary?

Thanks,
Dominick

On Tue, Dec 14, 2010 at 7:21 AM, Friedrich Leisch <
friedrich.lei...@stat.uni-muenchen.de> wrote:

> >>>>> On Tue, 14 Dec 2010 12:40:04 +0100,
> >>>>> Romain Francois (RF) wrote:
>
>  > Hello,
>  > Sweave lets you use alternative drivers through the driver argument, and
>  > several packages take advantage of that and define custom Sweave driver
>  > for various purposes. Most of them are listed on the Reproducible
>  > Research CTV:
>  > (http://cran.r-project.org/web/views/ReproducibleResearch.html)
>
>  > The next natural step is for package developpers to take advantage of
>  > this in their vignettes. In Rcpp we work around the way package building
>  > works and we do:
>  > - let R build a dummy vignette
>  > - then use the inst/doc/Makefile to replace it with a vignette that is
>  > processed by the driver from the highlight package (giving syntax
>  > highlighting).
>
>  > I played with Sweave so that it would be able to create the driver from
>  > some text included in the text of the .Rnw file:
>
>  > $ svn diff
>  > Index: src/library/utils/R/Sweave.R
>  > ===================================================================
>  > --- src/library/utils/R/Sweave.R    (revision 53846)
>  > +++ src/library/utils/R/Sweave.R    (working copy)
>  > @@ -20,6 +20,16 @@
>  >   # We don't need srclines for code, but we do need it for text, and
>  > it's easiest
>  >   # to just keep it for everything.
>
>  > +SweaveGetDriver <- function(file){
>  > +    txt <- readLines(file)
>  > +    line <- grep( "\\SweaveDriver", txt, value = TRUE )
>  > +    if( length(line) ){
>  > +        txt <- sub( "^.*\\SweaveDriver[{](.*)[}]", "\\1", line[1L] )
>  > +        driver <- try( eval( parse( text = txt ) ), silent = TRUE )
>  > +        if( !inherits( driver, "try-error") ) driver
>  > +    }
>  > +}
>  > +
>  >   Sweave <- function(file, driver=RweaveLatex(),
>  >                      syntax=getOption("SweaveSyntax"), ...)
>  >   {
>  > @@ -28,7 +38,9 @@
>  >       else if(is.function(driver))
>  >           driver <- driver()
>
>  > -
>  > +    drv <- SweaveGetDriver(file)
>  > +    if( !is.null(drv) ) driver <- drv
>  > +
>  >       if(is.null(syntax))
>  >           syntax <- SweaveGetSyntax(file)
>  >       if(is.character(syntax))
>
>
>
>  > This allows one to write something like this in their file:
>
>  > %\SweaveDriver{ { require(highlight); HighlightWeaveLatex() } }
>
>  > So that when calling :
>
>  >> Sweave( "somefile.Rnw" )
>
>  > the highlight driver is used instead of the default driver.
>
>  > Could something like that be added to Sweave ?
>
> Yes, sure!
>
> Will have a look at the patch later this week and apply it if it
> passes the tests. The patch is against a current r-devel?
>
> Best,
> Fritz
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to