R降价 - 如何在引用的文章中删除附近的其他括号?

时间:2017-02-25 14:34:01

标签: r knitr r-markdown bookdown

我正在准备一份文件,其中我引用了不止一篇文章。我希望将它们全部放在一个括号中,例如:

在(第1条;第2条,第3条)中提到过。

不幸的是,我注意到RMarkdown在年内增加了括号:

brackets around year

如何删除它们?

我的文件:

---
title: Additional brackets around year in citations
author:
  - name: Mateusz Kędzior
    email: alice@sample.com
    affiliation: WUT
    footnote: Corresponding Author
abstract: |
  First line

  The second line

keywords: some \sep thing \sep some \sep where
bibliography: listb.bib # I get .bib file from http://shelah.logic.at/eindex.html
csl: elsevier-harvard.csl # I get style from: https://www.zotero.org/styles/
link-citations: true

output:
   bookdown::pdf_book:
    base_format: rticles::elsevier_article
    keep_tex: true
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

# What I receive

Cite only one article: @Sh:2

It was mentioned in: @Sh:1, @Sh:2, @Sh:3

It was mentioned in [ @Sh:1, @Sh:2, @Sh:3 ]

# Expected result

I wish to have something like:

It was mentioned in (Shelah, 1969b; Shelah, 1969a; Shelah, 1970)

# References

1 个答案:

答案 0 :(得分:1)

使用以下格式:

It was mentioned in [@barras2010a; @barras2010b; @barras2010c]

换句话说,我会将您的ID名称重命名为:Sh1Sh2Sh3,并说:

It was mentioned in [@Sh1; @Sh2; @Sh3]

这是您修改后的示例(带有我的示例参考):

---
title: Additional brackets around year in citations
author:
  - name: Mateusz Kędzior
    email: alice@sample.com
    affiliation: WUT
    footnote: Corresponding Author
output:
   html_document
references:
- id: barras2010a
  title: False Discoveries in Mutual Fund Performance - Measuring Luck in Estimated Alphas
  author:
  - family: Barras
    given: Lauren
  - family: Scaillet
    given: Olivier
  - family: Wermers
    given: Russ
  container-title: Journal of Finance
  volume: 65
  URL: 'http://onlinelibrary.wiley.com/doi/10.1111/j.1540-6261.2009.01527.x/abstract'
  DOI: 10.1111/j.1540-6261.2009.01527.x
  page: 179-216
  type: article-journal
  issued:
    year: 2010
    month: February
- id: barras2010b
  title: False Discoveries in Mutual Fund Performance - Measuring Luck in Estimated Alphas
  author:
  - family: Barras
    given: Lauren
  - family: Scaillet
    given: Olivier
  - family: Wermers
    given: Russ
  container-title: Journal of Finance
  volume: 65
  URL: 'http://onlinelibrary.wiley.com/doi/10.1111/j.1540-6261.2009.01527.x/abstract'
  DOI: 10.1111/j.1540-6261.2009.01527.x
  page: 179-216
  type: article-journal
  issued:
    year: 2010
    month: February
- id: barras2010c
  title: False Discoveries in Mutual Fund Performance - Measuring Luck in Estimated Alphas
  author:
  - family: Barras
    given: Lauren
  - family: Scaillet
    given: Olivier
  - family: Wermers
    given: Russ
  container-title: Journal of Finance
  volume: 65
  URL: 'http://onlinelibrary.wiley.com/doi/10.1111/j.1540-6261.2009.01527.x/abstract'
  DOI: 10.1111/j.1540-6261.2009.01527.x
  page: 179-216
  type: article-journal
  issued:
    year: 2010
    month: February
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

# What I receive

Cite only one article: @barras2010a

It was mentioned in: @barras2010a, @barras2010b, @barras2010c

It was mentioned in [@barras2010a; @barras2010b; @barras2010c]

# Expected result

I wish to have something like:

It was mentioned in (Shelah, 1969b; Shelah, 1969a; Shelah, 1970)

# References

这就是它所显示的内容:

在(Barras,Scaillet和Wermers 2010a; Barras,Scaillet和Wermers 2010b; Barras,Scaillet和Wermers 2010c)中提到过

我希望能帮助你。