How to hold figure position with figure caption in pdf output of knitr?

后端 未结 7 1951
不知归路
不知归路 2020-11-29 18:45

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

7条回答
  •  情书的邮戳
    2020-11-29 19:12

    As Andrew pointed out, this fig.pos doesn't work in chunks, but it does work if it is put in global options:

    ```{r global_options, include=FALSE}
    knitr::opts_chunk$set(fig.pos = 'H')
    ```
    

    EDIT: the above apparently used to work and needs \usepackage{float} in the preamble:

    header-includes:
     \usepackage{float}
    

    See also here.

提交回复
热议问题