is_latex_output {knitr} | R Documentation

## Check if the current output type is LaTeX or HTML

### 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

    is_latex_output()

    is_html_output(fmt = pandoc_to(), excludes = NULL)

### 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

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

[Package knitr version 1.22 Index]