Subfigures or Subcaptions with knitr?

knitr (>= v1.5) supports subfigures. You can use the chunk option fig.subcap. Here is a minimal example.

\documentclass{article}
\usepackage{subfig}
\begin{document}

<<fig-sub, fig.cap='two plots', fig.subcap=c('one plot', 'the other one'), out.width=".49\\linewidth">>=
plot(1:10)
plot(rnorm(10), pch=19)
@

\end{document}

subfigures in knitr

Leave a Comment