This is a simple script to run Sweave, then convert the LaTeX file, then patch it.
SweaveMiktex(Rnw, main,
cmd = "texify",
options = "--tex-option=-src-specials --tex-option=-interaction=nonstopmode",
includedir = "--tex-option=--include-directory=",
stylepath = FALSE,
source.code = NULL,
make = 1,
preview = 'yap "%s"',
patchLog=TRUE,
sleep = 0, ...)SweavePDFMiktex(Rnw, main,
cmd = "texify --pdf",
options = "--tex-option=-synctex=-1 --tex-option=-interaction=nonstopmode",
includedir = "--tex-option=-include-directory=",
stylepath = FALSE,
source.code = NULL,
make = 1,
preview = NULL,
patchLog = TRUE,
sleep = 0, ...)
SweaveDVI(Rnw, main,
texinputs = NULL,
source.code = NULL,
make = 1,
links = NULL,
preview = NULL,
patchLog = TRUE, ...)
SweavePDF(Rnw, main,
texinputs = NULL,
source.code = NULL,
make = 1,
links = NULL,
preview = NULL,
patchLog = TRUE, ...)
SweaveDVIPDFM(Rnw, main,
latex = "latex", latexOpts = "-synctex=1 -interaction=nonstopmode",
dvipdfm = "dvipdfm", dvipdfmOpts = "",
texinputs = NULL,
source.code = NULL,
make = 1,
preview = NULL,
patchLog = TRUE, ...)
These functions are run for the side effects.
The .Rnw input file
The .tex file on which to run latex, defaulting to the output file from Sweave
The LaTeX command to run
Options to pass to LaTeX
The prefix for an option to give the location of Sweave.sty
stylepath
argument to pass to Sweave
If not NULL
, a filename to source before running Sweave
Value to pass to SweaveAll
to control which Sweave files are processed
Command to use to preview result, or NULL
for no preview
Whether to attempt to patch the console log and .log
file
Number of seconds to sleep if an error is detected in the run
Extra paths to pass to texi2dvi
If not NULL
, an option to turn on production of source links
via Synctex or source specials
The function to call to convert the .tex
to .dvi
,
and options to put on the command line.
The function to call to convert the .dvi
to .pdf
,
and options to put on the command line.
Additional options to pass to SweaveAll
If the Rnw
argument is a filename ending in .tex
, then
weaving is skipped, but the .dvi
file is still patched (because
one of the other files in the project might have come from Sweave).
The source.code
argument may be used to temporarily install code before
running the document through the weaver (e.g. Sweave
).
It could install
an experimental version of Sweave
, or set up some variables
to be used by other code chunks, etc. (Note that things are sourced locally,
whereas Sweave
runs things in the global environment,
so the file will need to make explicit assignments there, and it should
avoid using names that clash with the argument names to SweaveMiktex
or SweavePDFMiktex
.)
The functions invoke Latex differently. SweaveMiktex
is designed
to call Miktex's texify
command to produce a .dvi
file. SweavePDFMiktex
does the same, but produces a .pdf
. SweaveDVI
and SweavePDF
are similar, but use a modified version of R's texi2dvi
function to invoke Latex. SweaveDVIPDFM
does the conversion to
.pdf
in two stages.
The patchLog
option makes use of the new patchLog
function.
if (FALSE) {
SweaveMiktex("chapter.Rnw", "book.tex")
}
Run the code above in your browser using DataLab