Refresh look at this best solution here . (a summary of the problem below is still good, but follow the link for the best solution).
To summarize some tests in RStudio
The argument chitr chrin fig.pos = "H" works until fig_caption: yes is in the yaml header.
Each shape in the generated .tex looks like this:
\subsection{my_section}\label{my_section} \includegraphics{path_to_fig.pdf}
But if fig_caption: yes is in the yaml header, then .tex looks like this:
\subsection{my_section}\label{my_section} \begin{figure}[htbp] \centering \includegraphics{path_to_fig.pdf} \caption{} \end{figure}
fig.pos = "H" not used, instead is "htbp" .
Workaround for this with RStudio:
put
fig_caption: yes keep_tex: yes
in the barley as well
header-includes: \usepackage{float}
then search and replace [htbp] with [H] in the generated .tex file
then open the .tex file in RStudio and use the "Compile PDF" button.
Example .Rmd
--- title: "Testing fig placement with captions" author: "Andrew Dolman" date: "1 September 2015" output: pdf_document: fig_caption: yes keep_tex: yes header-includes: \usepackage{float} --- This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http:
Andrew
source share