This is a simple script to run knit, then LaTeX, then patchDVI.
knitMiktex(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,
weave = knitr::knit,
...)
knitPDFMiktex(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,
weave = knitr::knit,
...)
knitDVI(Rnw, main,
texinputs = NULL,
source.code = NULL,
make = 1,
links = NULL,
preview = NULL,
patchLog = TRUE,
weave = knitr::knit,
...)knitPDF(Rnw, main,
texinputs = NULL,
source.code = NULL,
make = 1,
links = NULL,
preview = NULL,
patchLog = TRUE,
weave = knitr::knit,
...)
knitDVIPDFM(Rnw, main,
latex = "latex", latexOpts = "-synctex=1 -interaction=nonstopmode",
dvipdfm = "dvipdfm", dvipdfmOpts = "",
texinputs = NULL,
source.code = NULL,
make = 1,
preview = NULL,
patchLog = TRUE,
weave = knitr::knit,
...)
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.
The function to carry out the weaving.
Additional options to pass to SweaveAll
If the Rnw
argument is a filename ending in .tex
, then
knitting is skipped, but the output file is still patched (because
one of the other files in the project might have come from knitr).
The source.code
argument may be used to temporarily install code before
running the document through the weaver (e.g. knit
).
It could install
an experimental version of knit
, or set up some variables
to be used by other code chunks, etc.
The functions invoke Latex differently. knitMiktex
is designed
to call Miktex's texify
command to produce a .dvi
file. knitPDFMiktex
does the same, but produces a .pdf
. knitDVI
and knitPDF
are similar, but use a modified version of R's texi2dvi
function to invoke Latex. knitDVIPDFM
does the conversion to
.pdf
in two stages.
The patchLog
option makes use of the patchLog
function.
if (FALSE) {
knitPDF("chapter.Rnw", "book.tex")
}
Run the code above in your browser using DataLab