From 24cd11aa70e7a902ecc11c6b604d91baa36395a4 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Fri, 3 Feb 2012 17:30:21 +0000 Subject: [PATCH] backport r40703 (fix #8019) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_2_0_X@40706 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/scripts/lyxsweave.R | 13 +++++++++++-- status.20x | 7 ++++--- 2 files changed, 15 insertions(+), 5 deletions(-) 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 diff --git a/status.20x b/status.20x index 77dc411ab2..b01e033dfc 100644 --- a/status.20x +++ b/status.20x @@ -24,9 +24,6 @@ What's new * DOCUMENT INPUT/OUTPUT -- Fix Sweave support for document encoding with R >= 2.13.1 (bug - 7876). - - Add support for `knitr', an alternative for Sweave on R >= 2.14.1 (bug 7887). @@ -161,6 +158,10 @@ What's new - Fix error when exporting DocBook tables (bug 7004). +- Fix Sweave support for document encoding with R >= 2.13.1 (bug + 7876). + +- Avoid creation of a spurious Rplots.pdf file when using Sweave (bug 8019). * TEX2LYX -- 2.39.5