Search code examples
rknitrr-markdownbookdown

R markdown - how can I remove additional brackets around year in cited articles?


I'm preparing a document in which I cite more than one article. I wish to place all of them in one brackets, for example:

It was mentioned in (article1; article2;, article 3).

Unfortunately I noticed that RMarkdown adds brackets around year:

brackets around year

How can I remove them?

My document:

---
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

Solution

  • Use this format:

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

    In other words, I would rename your id names to something like: Sh1, Sh2, Sh3, and say:

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

    Here's your revised example (with my example references):

    ---
    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
    

    And here's what it shows:

    It was mentioned in (Barras, Scaillet, and Wermers 2010a; Barras, Scaillet, and Wermers 2010b; Barras, Scaillet, and Wermers 2010c)

    I hope that helps you.