Learn R Programming

knitr (version 1.52)

knit2pdf: 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,
  ...
)

Value

The filename of the PDF file.

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. For an Rtyp file, setting compiler to 'typst' will use the typst command-line tool to compile the typ file to PDF.

envir

Environment in which code chunks are to be evaluated, for example, parent.frame(), new.env(), or globalenv()).

quiet

Whether to suppress the progress bar and messages.

...

Options to be passed to tinytex::latexmk() or rst2pdf().

Author

Ramnath Vaidyanathan, Alex Zvoleff and Yihui Xie

Examples

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

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

#' compile an Rtyp file with typst
## knit2pdf(..., compiler = 'typst')

Run the code above in your browser using DataLab