Fix #8019 (from yihui)

* avoid creation of file Rplots.pdf in document file
* find correctly Sweave.sty on old R versions


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40703 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2012-02-02 22:30:38 +00:00
parent fa44bf7961
commit d6246362e6

View File

@ -23,8 +23,12 @@
# The advantage compared to the use of stylepath, is that the exported
# .tex file will be portable to another machine. (JMarc)
if (!length(system("kpsewhich Sweave.sty", intern=TRUE, ignore.stderr=TRUE))) {
file.copy(file.path(R.home("share"), "texmf", "tex", "latex", "Sweave.sty"),
dirname(.cmdargs[2]), overwrite=TRUE)
.texmf.path <- file.path(R.home("share"), "texmf")
if (!file.exists(.sweave.sty <- file.path(.texmf.path, "Sweave.sty"))) {
.sweave.sty <- file.path(.texmf.path, "tex", "latex", "Sweave.sty")
}
file.copy(.sweave.sty, dirname(.cmdargs[2]), overwrite=TRUE)
rm(list = c('.sweave.sty', '.texmf.path'))
}
@ -39,6 +43,11 @@ tmpout <- gsub(".", "-", sub("\\.tex$", "", basename(.cmdargs[2])), fixed = TRUE
.prefix.str <- paste(dirname(.cmdargs[2]), tmpout, sep="/")
rm(tmpout)
# avoid the default Rplots.pdf
options(device = function(...) {
pdf(file = tempfile())
})
# finally run sweave
# The Sweave version provided with R >= 0.13.1 has proper handling for