Change figure and table captions in blogdown

时间:2018-03-22 23:52:07

标签: hugo bookdown blogdown

I'm tinkering with blogdown and would like to create figures and table with non-English caption headers. The following chunk

```{r label1, echo=FALSE, fig.cap="Fancy caption", fig.fullwidth=TRUE}
plot(1,1)
```

produces the plot and a caption that reads

Figure 1: Fancy caption

I'd like to be able to change the label such that, say, "Figure" becomes "Plot". I thought I could fix it in the same way as for bookdown: In the _bookdown.yml file I could have

language:
  ui:
    chapter_name: "Chap "
    appendix_name: "App " 
  label:
    fig: 'Plot '
    tab: 'Fancy table '

but I'm not sure how to do something similar with a Hugo-based setup from blogdown. How can I add the above information to, say, the config.toml file or set it somewhere else?

1 个答案:

答案 0 :(得分:3)

首先,将您描述的_bookdown.yml文件存储在与博客帖子来源.Rmd文件相同的文件夹中,例如content/post/_bookdown.yml如果您的文件位于content/post/my_post.Rmd

然后,将_bookdown.yml添加到ignoreFiles的{​​{1}}列表中,以便Hugo不会将config.toml移动到公共目录。

这是有效的,因为_bookdown.yml基于blogdown::html_page(),它会在源Rmd的同一目录中选取bookdown::html_document2()。我不认为可以从blogdown根目录全局设置,但如果你将所有帖子存储在_bookdown.yml中,那基本上是相同的。