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 opti
The option that worked for me:
In the .tex put at the beginning: \usepackage{float}
.
At the beginning of the Rmd: knitr::opts_chunk$set(fig.pos = 'H')
. The H
in upper case).
And in every chunk with an image: fig.cap="lorem blabla"
and out.extra=''
(parameter value=empty string).
No need to define:
fig_caption: yes
and keep_tex: yes
in the yaml.
These options make the image to keep their position, either for include_graphics
and the plots generated by R code.
I used them in the bookdown
enviroment, generating the pdf and the html as expected :)