title: LaTeX figure label from R plot using KnitR?
body: <p>I can't get R/KnitR to create the LaTeX <code>\label{}</code> statement for a figure. The <a href="http://yihui.name/knitr/options" rel="noreferrer">manual</a> seems to indicate that a <code>\label{}</code> statement will be created by concatenating the string in fig.lp ("fig:" by default) with the label for the R-code chunk. I haven't been able to get this to work, however. No <code>\label{}</code> statement is created for the first figure created by knitting the MWE below. The second figure has it's label added with a workaround that I just discovered, putting the R chunk in a figure environment, and putting the <code>\label</code> tag after or inside the <code>\caption</code> tag.</p>
  
  <pre><code>\documentclass[12pt, english, oneside]{amsart}
  \begin{document}
  
  Figure \ref{fig:plot} doesn't have it's label.
  
  &lt;&lt;plot&gt;&gt;=
  plot(x=0, y=0)
  @
  
  Figure \ref{fig:plot2} has its label.
  
  \begin{figure}
  \caption{\label{fig:plot2}}
  &lt;&lt;&gt;&gt;=
  plot(x=1,y=1)
  @
  \end{figure}
  
  \end{document}
  </code></pre>
  
  <p>Okay, I've found a workaround by putting the R chunk in a <code>\begin{figure} . . .\end{figure}</code> environment in LaTeX. I can create the label in that same environment. Still, I'd like to understand how Yihui intends for this to be handled with KnitR.</p>