I want to use rmarkdown and generate html as well as docx documents simultaneously. But depending on format (docx vs. html) a chunk should be run or not. Is it possible to find out what actually format is running? I use rmarkdown::render("demo.Rmd", output_format = "all") for the following Rmd file:
You can do this with the function is_html_output() from the knitr package. There is also is_latex_output() if you want to allow for that option as well.