R: Convert Rnw or Rrst files to PDF using knit() and texi2pdf()...

knit2pdf {knitr} | R Documentation

## Convert Rnw or Rrst files to PDF using knit() and texi2pdf() or rst2pdf()

### Description

Knit the input Rnw or Rrst document, and compile to PDF using `texi2pdf` or `rst2pdf`.

### Usage

    knit2pdf(input, output = NULL, compiler = NULL, envir = parent.frame(), quiet = FALSE,
        encoding = getOption("encoding"), ...)

### Arguments

`input` | path of the input file
`output` | path of the output file for `knit()`; if `NULL`, this function will try to guess and it will be under the current working directory
`compiler` | a character string which gives the LaTeX program used to compile the tex document to PDF (by default it uses the default setting of `texi2pdf`, which is often PDFLaTeX); this argument will be used to temporarily set the environmental variable PDFLATEX. For an Rrst file, setting compiler to `'rst2pdf'` will use `rst2pdf` to compiles the rst file to PDF using the ReportLab open-source library.
`envir` | the environment in which the code chunks are to be evaluated (for example, `parent.frame()`, `new.env()`, or `globalenv()`)
`quiet` | whether to suppress the progress bar and messages
`encoding` | the encoding of the input file; see `file`
`...` | options to be passed to `texi2pdf` or `rst2pdf`

### Value

The filename of the PDF file.

### Note

The `output` argument specifies the output filename to be passed to the PDF compiler (e.g. a tex document) instead of the PDF filename.

### Author(s)

Ramnath Vaidyanathan, Alex Zvoleff and Yihui Xie

### See Also

`knit`, `texi2pdf`, `rst2pdf`

### Examples

    #' compile with xelatex
    ## knit2pdf(..., compiler = 'xelatex')

    #' compile a reST file with rst2pdf
    ## knit2pdf(..., compiler = 'rst2pdf')

[Package knitr version 1.16 Index]