简体   繁体   English

在 flextable 的单元格内引用

[英]Citing inside the cell of flextable

I'm trying to create a table with rmarkdown and flextable where I am citing various works.我正在尝试使用 rmarkdown 和 flextable 创建一个表,我在其中引用了各种作品。

my Rmakrdown file:我的 Rmakrdown 文件:

---
title: "Innovative title"
author: "Vag Vaf"
date: '2021-12-29'
bibliography: references.bib
csl: apa-6th-edition.csl
output:
  bookdown::word_document2:
    fig_caption: yes
  pdf_document:
    toc: true
    toc_depth: 2
    citation_package: natbib
    keep_tex: true
    extra_dependencies: rotating, bookmark
  fontsize: 12pt
  geometry: margin=1in
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
knitr::opts_chunk$set(fig.retina = 3, warning = FALSE, message = FALSE)
```

```{r studies-table}
studies.table <- tibble (
  Authors = c("@Author1",
              "@Author2"),
  Area = c("Area1",
           "Area2")
    )
ft <- flextable(studies.table)
```

in my references.bib:在我的references.bib中:

@article{Author1,
author = {Author, Solo},
journal = {Journal of Reproducible Examples},
pages = {1--18},
title = {{Yet another Test Title}},
volume = {1},
year = {2022}
}
@article{Author2,
author = {Author, Two and Author, Four},
journal = {Journal of Reproducible Examples},
pages = {75--82},
title = {{Awesome title}},
volume = {1},
year = {2022}
}

I am trying with this code, but @Author1 and @Author2 are not converted to the actual citation.我正在尝试使用此代码,但 @Author1 和 @Author2 未转换为实际引用。 They are displayed as @Aurthor1 and @Author2 in the table.它们在表中显示为@Aurthor1@Author2 Is there any way to indicate that this should be converted to a citation?有什么方法可以表明应该将其转换为引文?

The package ftExtra is required for markdown syntaxes work in flextable cells: ftExtra语法在 flextable 单元格中工作需要 package ftExtra:

```{r setup, include=FALSE}
library(easypackages)
packages(
  "tidyverse",
  "flextable",
  "ftExtra"
)
knitr::opts_chunk$set(echo = FALSE)
knitr::opts_chunk$set(fig.retina = 3, warning = FALSE, message = FALSE)
```

```{r studies-table}
studies.table <- tibble(
  Authors = c(
    "@Author1",
    "@Author2"
  ),
  Area = c(
    "Area1",
    "Area2"
  )
)
flextable(studies.table) %>%
  ftExtra::colformat_md()
```

回答结果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM