Specifying multiple simultaneous output formats in knitr (new)

I actually briefly mentioned in Render all vignette formats #1051 and you missed it:

rmarkdown::render('your.Rmd', output_format = 'all')

It is documented on the help page ?rmarkdown::render.


Notwithstanding Yihui Xie's authoritative answer, and with due respect to the author of a great package, there are many cases in which output_format = 'all' is sub-optimal.
One of the issues that this solution raises is that the R script is re-processed from scratch for each format. Proof:

 rmarkdown::render("new.Rmd", output_format = c("html_document", "pdf_document"))


processing file: new.spin.Rmd
  |.......................                                               |  33%
  ordinary text without R code

  |...............................................                       |  67%
label: unnamed-chunk-1
  |......................................................................| 100%
  ordinary text without R code


output file: new.knit.md

"C:/Users/fabrn/AppData/Local/Pandoc/pandoc" +RTS -K512m -RTS new.utf8.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output new.html --lua-filter "C:\Users\fabrn\R\win-library\4.0\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\Users\fabrn\R\win-library\4.0\rmarkdown\rmarkdown\lua\latex-div.lua" --email-obfuscation none --self-contained --standalone --section-divs --template "C:\Users\fabrn\R\win-library\4.0\rmarkdown\rmd\h\default.html" --no-highlight --variable highlightjs=1 --variable "theme:bootstrap" --include-in-header "C:\Users\fabrn\AppData\Local\Temp\RtmpW6Vban\rmarkdown-str3490247b1f1e.html" --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" 

Output created: new.html


processing file: new.spin.Rmd
  |.......................                                               |  33%
  ordinary text without R code

  |...............................................                       |  67%
label: unnamed-chunk-1
  |......................................................................| 100%
  ordinary text without R code


output file: new.knit.md

"C:/Users/fabrn/AppData/Local/Pandoc/pandoc" +RTS -K512m -RTS new.utf8.md --to latex --from markdown+autolink_bare_uris+tex_math_single_backslash --output new.tex --lua-filter "C:\Users\fabrn\R\win-library\4.0\rmarkdown\rmarkdown\lua\pagebreak.lua" --lua-filter "C:\Users\fabrn\R\win-library\4.0\rmarkdown\rmarkdown\lua\latex-div.lua" --self-contained --highlight-style tango --pdf-engine pdflatex --variable graphics --variable "geometry:margin=1in" 

This really is an issue when it comes to processing big data.
In real-world examples, I usually use latex output as a single rmarkdown::render output, then reprocess the .tex files using pandoc or similar tools (like prince for pdf). So my workflow is like:

 rmarkdown::render('new.R', output_format = 'latex_document')
 lapply(c("html", "pdf", ...), 
        function(form) rmarkdown::pandoc_convert("new.tex", output=paste0("new.", form)))

The bottom line is: all depends on your data. If small, output_format='all' is straightforward. If big, you are better off with a common-ground format (latex is a good choice but html may be better in some cases) as an input to conversion tools.