title: How do I produce R package vignettes in multiple formats?
body: <p>I use <em>knitr</em> and <em>rmarkdown</em> to write vignettes for R packages. Thanks to the magic of <em>pandoc</em> it is easy to turn these documents into a variety of formats. I would like to take advantage of this by offering vignettes as both HTML and PDF. There is support from <em>rmarkdown</em> to specify parameters for multiple output formats in the documents metadata block. For example, I might have something like this:</p>
  
  <pre><code>output:
    html_document:
      standalone: true
      smart: true
      normalize: true
      toc: true
      highlight: tango
      self-contained: true
      theme: cerulean
    pdf_document:
      toc: true
      highlight: tango
  geometry: margin=2cm
  documentclass: article
  classoption: a4paper
  </code></pre>
  
  <p>From the R command-line I can use <code>rmarkdown::render</code> to build either one or both of the output documents without difficulties. However, when the package is build only the output format that is listed first is used. I have tried to include a <em>Makefile</em> that builds both by including something along the lines of</p>
  
  <pre><code>all: %.Rmd
      $(R_HOME)/bin/Rscript -e "rmarkdown::render('$*.Rmd', 'all')"
  </code></pre>
  
  <p>and that is successful in the sense that all output files are generated but only one of them is recognised as vignette by R. To get additional outputs included in <code>docs/</code> they have to be added to <em>.install_extras</em>. While that ensures they are accessible via the HTML index they are listed separately from the vignettes and and I don't think they can be accessed from within R (via <code>vignette()</code>).</p>
  
  <p>Is there a better way (or any automated way) to do this?</p>