R: Convert Rnw or Rrst files to PDF

knit2pdf {knitr} | R Documentation

## Convert Rnw or Rrst files to PDF

### Description

Knit the input Rnw or Rrst document, and compile to PDF using `tinytex::latexmk()` or `rst2pdf()`.

### Usage

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

### Arguments

`input` | Path to the input file.
`output` | Path to the output file for `knit()`. If `NULL`, this function will try to guess a default, which will be under the current working directory.
`compiler` | A character string giving the LaTeX engine used to compile the tex document to PDF. For an Rrst file, setting `compiler` to `'rst2pdf'` will use `rst2pdf` to compile the rst file to PDF using the ReportLab open-source library.
`envir` | Environment in which code chunks are to be evaluated, for example, `parent.frame()`, `new.env()`, or `globalenv()`).
`quiet` | Boolean; suppress the progress bar and messages?
`encoding` | Encoding of the input file; see `file`.
`...` | Options to be passed to `tinytex::latexmk` 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

### Examples

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

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

[Package knitr version 1.20 Index]