[英]How to cite a reference in kableExtra footnote?
我正在寫一個 R Markdown 文檔,其中有一個表格。 在此表的腳注中,我想引用一位作者。 但是,在這種情況下,使用@citationkey
不起作用。
有人知道怎么做嗎?
這是一個可重現的示例(我在kableExtra
包含了所有需要的 LaTeX 包,但其中一些在這里可能是不必要的):
---
title: "Untitled"
author: ""
date: ""
output:
bookdown::pdf_document2
bibliography: refs.bib
toc: false
header-includes:
- \usepackage[utf8]{inputenc}
- \usepackage[T1]{fontenc}
- \usepackage{booktabs}
- \usepackage{longtable}
- \usepackage{array}
- \usepackage{multirow}
- \usepackage{wrapfig}
- \usepackage{float}
- \usepackage{colortbl}
- \usepackage{pdflscape}
- \usepackage{tabu}
- \usepackage{threeparttable}
- \usepackage{threeparttablex}
- \usepackage[normalem]{ulem}
- \usepackage{makecell}
- \usepackage{xcolor}
---
Here, I can cite @abel2018.
```{r}
library(kableExtra)
kable(head(mtcars)) %>%
footnote(general = paste0("A footnote in which I would like to cite @abel2018."))
```
# References {-}
和refs.bib
的參考:
@article{abel2018,
title = {Estimates of {{Global Bilateral Migration Flows}} by {{Gender}} between 1960 and 2015},
author = {Abel, Guy J.},
date = {2018-09},
journaltitle = {International Migration Review},
shortjournal = {International Migration Review},
volume = {52},
pages = {809--852},
doi = {10.1111/imre.12327},
url = {http://journals.sagepub.com/doi/10.1111/imre.12327},
urldate = {2019-12-14},
langid = {english},
number = {3}
}
您的方法的問題在於paste()
無法識別密鑰,而只是將其視為文本。
要寫入 HTML,可以使用knitr::asis_output("@abel2018")
。
不幸的是,這不適用於預訂。 但是,您可以使用bookdown 中記錄的文本參考:
文本引用的語法是
(ref:label) text
,其中label
是整個文檔中text
的唯一標簽。 它必須在一個單獨的段落中,上面和下面都有空行。 段落不得多行,也不得以空格結尾。然后你可以在你的圖形/表格標題中使用
(ref:foo)
例如:
(ref:abel-citation) @abel2018
```{r}
library("kableExtra")
kable(mtcars) %>%
footnote(general = paste0("A footnote in which I would like to cite (ref:abel-citation)"))
```
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.