knitPDF: Simple functions to knit a file and run it through LaTeX

Description Usage Arguments Details Value Examples

View source: R/patchPDF.R

Description

This is a simple script to run knit, then LaTeX, then patchDVI.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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,
    ...)

Arguments

Rnw

The .Rnw input file

main

The .tex file on which to run latex, defaulting to the output file from Sweave

cmd

The LaTeX command to run

options

Options to pass to LaTeX

includedir

The prefix for an option to give the location of Sweave.sty

stylepath

stylepath argument to pass to Sweave

source.code

If not NULL, a filename to source before running Sweave

make

Value to pass to SweaveAll to control which Sweave files are processed

preview

Command to use to preview result, or NULL for no preview

patchLog

Whether to attempt to patch the console log and ‘.log’ file

sleep

Number of seconds to sleep if an error is detected in the run

texinputs

Extra paths to pass to texi2dvi

links

If not NULL, an option to turn on production of source links via Synctex or source specials

latex,latexOpts

The function to call to convert the ‘.tex’ to ‘.dvi’, and options to put on the command line.

dvipdfm, dvipdfmOpts

The function to call to convert the ‘.dvi’ to ‘.pdf’, and options to put on the command line.

weave

The function to carry out the weaving.

...

Additional options to pass to SweaveAll

Details

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.

Value

These functions are run for the side effects.

Examples

1
2
3
4
## Not run: 
knitPDF("chapter.Rnw", "book.tex")

## End(Not run)

patchDVI documentation built on May 5, 2020, 3 p.m.