使用 r markdown 在图形标题中引用

citing within a figure caption using r markdown

我正在使用 R markdown 和 bookdown 创建 pdf 输出。据我所知 question and this github issue 我使用了正确的语法,但它对我不起作用,我只是在标题中以文本形式返回“[@citation]”。 是否需要特定的 yaml、块选项或包才能使其正常工作?

---
title: "caption citation test"
output:
  bookdown::pdf_document2
bibliography: Bibliography_mini.bib
---

```{r echo=FALSE,warning=FALSE}
 library(knitr)
 library(kableExtra)
  opts_chunk$set(fig.path='figure/graphics-', 
                 cache.path='cache/graphics-', 
                 fig.align='center',
                 external=TRUE,
                 echo=TRUE,
                 warning=FALSE,
                 fig.pos='H'
                )
  a4width<- 8.3
  a4height<- 11.7
```
Some text here look the citation works [@moravec1980obstacle]

```{r moravec, echo=FALSE, fig.cap="look the citation doesn't work 
[@moravec1980obstacle]"}
knitr::include_graphics("Moravec.png")
```

您可以使用文本引用(参见 Section 2.2.4 of the bookdown book)。

(ref:moravec) look the citation doesn't work [@moravec1980obstacle]

```{r moravec, echo=FALSE, fig.cap="(ref:moravec)"}
knitr::include_graphics("Moravec.png")
```

latex 解决方案也有效,它在引用样式上有 far more control,但显然仅限于 pdf 输出,例如\citep{Bradshaw2010}