title: Subfigures or Subcaptions with knitr?
body: <p>Is it possible to produce subfigures (with associated subcaptions) using knitr? Here is a minimal working example:</p>
  
  <pre><code>\documentclass{article}
  
  \begin{document}
  
  &lt;&lt;echo = FALSE, fig.cap = c("Some numbers.", "Some more numbers."), out.width = "0.5\\textwidth", fig.align = "center"&gt;&gt;=
  
  plot(1:10)
  plot(30:100)
  
  @
  
  \end{document}
  </code></pre>
  
  <p>This results in two figures labelled Figure 1 and Figure 2 with captions as defined (respectively).  But I want them to be labelled "Figure 1a" and "Figure 1b", as you can do with the subcaption LaTeX package.</p>
  
  <p>I know there is a knitr options "fig.env", but this doesn't solve it (at least not using, for example, "fig.env = 'subfigure'").  There is a similar post here regarding Sweave, but the solution is an inelegant hack: <a href="http://texblog.org/2011/12/01/sweave-subfig-controlling-figure-size-and-placement/">http://texblog.org/2011/12/01/sweave-subfig-controlling-figure-size-and-placement/</a></p>