title: How to hold figure position with figure caption in pdf output of knitr?
body: <p>I am using knitr (1.9.5 and 1.9.17) and rmarkdown (0.5.3.1), and would like to hold figure position in the pdf output. The generated pdf file is working fine when chunk option <code>fig.pos="H"</code> is used. </p>
  
  <p>However, the figure position is not hold when <code>fig_caption: yes</code> is set in the 
  yaml header.</p>
  
  <p>How should I fix this problem? Thanks for any suggestions.</p>
  
  <p>EDIT:</p>
  
  <p>After learning the float environment of Latex. I add <code>float</code> package into header.</p>
  
  <pre><code>\usepackage{float}
  </code></pre>
  
  <p>But the generated tex file always use <code>htbp</code> in the <code>figure</code> environment regard to any <code>fig.pos</code> options are used. After manually changing <code>htbp</code> to <code>H</code>, positions of all figures are hold.</p>
  
  <p>This is my example of rmd file:</p>
  
  <pre><code>---
  title: "Untitled"
  output:
    pdf_document:
      fig_caption: yes
      includes:
          in_header: mystyles.sty
  ---
  
  # Section 1
  
  
  Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
  
  Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
  
  Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
  
  Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
  
  
  ```{r fig1, echo=FALSE, fig.height=8.5, fig.pos="H"}
  plot(cars)
  ```
  
  # Section 2
  
  More test
  
  ```{r fig2, echo=FALSE, fig.height=8.5, fig.pos="H"}
  plot(cars)
  ```
  
  # Section 3
  
  ```{r fig3, echo=FALSE, fig.height=8.5, fig.pos="H"}
  plot(cars)
  ```
  
  More test
  </code></pre>