knitr - Figure captions above

后端 未结 1 738
无人共我
无人共我 2020-12-17 00:27

Is there a way, in knitr to move the fig.cap above the figure? I need them above so that when the list-of-figure\'s hyperlink is selected for a certain table it navigates t

1条回答
  •  北荒
    北荒 (楼主)
    2020-12-17 01:12

    Maybe too late, but I think Yihui answered this.

    You can change the knit hook for all figures to have the caption above the figure. For example, here is a version of a chunk from an .Rmd document. If you tell knitr to change the option for figure to have the document look first at and then at the actual .

    ```{r setup}
    library(knitr)
    knit_hooks$set(plot = function(x, options) {
      paste('
    ', options$fig.cap, '
    ', sep = '') }) ```

    0 讨论(0)
提交回复
热议问题