output_type: Check if the current output type is LaTeX or HTML

Description Usage Arguments Details Examples

Description

The function is_latex_output() returns TRUE when the output format is LaTeX; it works for both ‘.Rnw’ and R Markdown documents (for the latter, the two Pandoc formats latex and beamer are considered LaTeX output). The function is_html_output() only works for R Markdown documents.

Usage

1
2
3

Arguments

fmt

A character vector of output formats to be checked. By default, this is the current Pandoc output format.

excludes

A character vector of output formats that should not be considered as HTML format.

Details

These functions may be useful for conditional output that depends on the output format. For example, you may write out a LaTeX table in an R Markdown document when the output format is LaTeX, and an HTML or Markdown table when the output format is HTML.

Internally, the Pandoc output format of the current R Markdown document is stored in knitr::opts_knit$get('rmarkdown.pandoc.to'). By default, these formats are considered as HTML formats: c('markdown', 'epub', 'html', 'html5', 'revealjs', 's5', 'slideous', 'slidy').

Examples

1
2
3
knitr::is_latex_output()
knitr::is_html_output()
knitr::is_html_output(excludes = c("markdown", "epub"))

yihui/knitr documentation built on Dec. 14, 2018, 6:22 p.m.