From: Jean-Marc Lasgouttes Date: Thu, 2 Feb 2012 22:30:38 +0000 (+0000) Subject: Fix #8019 (from yihui) X-Git-Tag: 2.1.0beta1~2077 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=d6246362e653368fa9d49b7eaac613f802097c7f;p=features.git 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 --- diff --git a/lib/scripts/lyxsweave.R b/lib/scripts/lyxsweave.R index fd41a4422e..7573d315c1 100644 --- a/lib/scripts/lyxsweave.R +++ b/lib/scripts/lyxsweave.R @@ -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