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.
is_latex_output()is_html_output(fmt = pandoc_to(), excludes = NULL)
A character vector of output formats to be checked. By default, this is the current Pandoc output format.
A character vector of output formats that should not be considered as HTML format.
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')
.
# NOT RUN {
knitr::is_latex_output()
knitr::is_html_output()
knitr::is_html_output(excludes = c("markdown", "epub"))
# }
Run the code above in your browser using DataLab