]> git.lyx.org Git - lyx.git/blobdiff - lib/scripts/lyxsweave.R
ePub: update doc for running script.
[lyx.git] / lib / scripts / lyxsweave.R
index fd41a4422ed82df146428b0f46112f51ac0b183f..7573d315c1fd5d7b668edd23236757355ef6ae7a 100644 (file)
 # 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