[英]knitr: can I cite an article in a figure caption using the fig.cap chunk option?
我想在我的圖標題中引用一篇文章。 我已經嘗試在fig.cap
塊選項中使用Rmarkdown / pandoc [@citekey]
和latex \\\\citep{citekey}
表單,但沒有任何運氣。
這是一個可重復的例子:
---
output:
rmarkdown::tufte_handout
references:
- id: Nobody06
title: 'My Article'
author:
- family: Nobody
given: Jr
issued:
year: 2006
---
Some text [@Nobody06].
```{r figure, fig.cap="A figure [@Nobody06]"}
library(ggplot2)
qplot(1:10, rnorm(10))
```
# References
這會在文本塊中生成正確的引文,但是[@Nobody06]
(當我使用RMarkdown表單時)或(?)
(當我使用Latex表單時)在圖標題中。
有誰知道在fig.cap
領域是否可以使用引文?
bookdown軟件包擴展了rmarkdown的功能並提供了一些有用的工具。 文本引用可用於解決此問題。 如包作者所述,可以使用文本引用:
您可以為標簽指定一些文本,並使用文檔中其他位置的標簽引用文本。
這適用於引用,如下所示:
---
output: bookdown::tufte_handout2
references:
- id: Nobody06
title: 'My Article'
author:
- family: Nobody
given: Jr
issued:
year: 2006
---
(ref:crossref) Some text [@Nobody06].
```{r figure, fig.cap="(ref:crossref)"}
library(ggplot2)
qplot(1:10, rnorm(10))
```
# References
您會注意到輸出格式已經調整為bookdown::tufte_handout2
,它允許使用bookdown功能。 您可以在此處找到輸出格式的完整列表。
在此處閱讀有關文本參考的更多信息: https : //bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html#text-references
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.