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

cfe*_*ell 3 markdown r r-markdown bookdown

我正在使用 R markdown 和 bookdown 创建 pdf 输出。据我从这个问题和这个github 问题中可以看出,我使用了正确的语法,但它对我不起作用,我只是在标题中将“[@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")
```
Run Code Online (Sandbox Code Playgroud)

输出图片

Yih*_*Xie 5

您可以使用文本参考(参见bookdown book 的第 2.2.4 节)。

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

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