title: Figure position in markdown when converting to PDF with knitr and pandoc
body: <p>I'm trying to control the position of a plot when converting to PDF using knitr and pandoc. My .Rmd file looks this:</p>
  
  <pre><code># My report
  
  Some text some text some text some text some text some text some text some text some text
  
  
  ```{r myplot, echo=FALSE, fig.pos="placeHere", results='hide'}
  
  library(ggplot2)
  
  ggplot(mtcars, aes(mpg, drat)) + geom_point()
  
  ```
  
  Some text some text some text some text some text some text some text some text some text
  
  \usepackage{graphicx}
  \begin{figure}[placeHere]
    \centering
      \includegraphics[width=0.5\textwidth]{placeHere}
  \end{figure}
  
  Some text some text some text some text some text some text some text some text some text
  </code></pre>
  
  <p>I'm converting to PDF using the functions provided here: <a href="http://quantifyingmemory.blogspot.co.uk/2013/02/reproducible-research-with-r-knitr.html">http://quantifyingmemory.blogspot.co.uk/2013/02/reproducible-research-with-r-knitr.html</a></p>
  
  <p>How can I place the plot between the second and third blocks of text? The latex code is not working as it currently stands.</p>
  
  <p><strong>EDIT:</strong> This is what I'm trying now.</p>
  
  <pre><code># My report
  
     ```{r setup, include=FALSE}
  # set global chunk options
  opts_chunk$set(cache=FALSE)
  library(ggplot2)
  ```
  
  ```{r, echo=FALSE, fig.height=3}
  
  ggplot(mtcars, aes(disp, hp)) + geom_point()
  
  
  ```
  
  
  
  Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some textSome text Some text Some text 
  
  Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some textSome text Some text Some text 
  
  
  Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some textSome text Some text Some text 
  
  
  Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some textSome text Some text Some text 
  
  
  ```{r, echo=FALSE, fig.height=3}
  
  
  
  ggplot(mtcars, aes(vs, am)) + geom_point()
  
  
  ```
  
  
  
  Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some textSome text Some text Some text 
  
  Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some textSome text Some text Some text 
  
  
  Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some textSome text Some text Some text 
  
  
  ```{r, echo=FALSE, fig.height=6}
  
  
  
  ggplot(mtcars, aes(disp, cyl)) + geom_point()
  
  ```
  
  
  ```{r, echo=FALSE, fig.height=6}
  
  ggplot(mtcars, aes(hp, qsec)) + geom_point()
  
  
  ```
  
  
  Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some textSome text Some text Some text 
  
  
  
  
  ```{r, echo=FALSE, fig.height=3}
  
  ggplot(mtcars, aes(hp, wt)) + geom_point()
  
  ```
  
  
  
  Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some textSome text Some text Some text 
  
  
  
  ```{r, echo=FALSE, fig.height=5}
  
  ggplot(mtcars, aes(mpg, drat)) + geom_point()
  
  ```
  
  
  
  
  Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some text Some textSome text Some text Some text 
  </code></pre>