R Markdown: suppress parentheses in specific citations

2.9k views Asked by At

I have an R Markdown document that includes some citations. I am using the default citation style, which usually works well for me. But I have some sentences that lie within parentheses, and in these sentences, I want to cite works without adding a second set of parentheses. That is, I want to suppress the parentheses that would normally appear around the year of publication in the citation. Here is an example of the output that I am trying to create:

Lorem ipsum dolor. (Fourscore and seven years ago: see Smith 2020.)

where Smith 2020 is produced with an R Markdown citation like @Smith_2020. In LaTeX, this sort of thing can be done with the \citealp macro in the "natbib" package. It can also be done with that package's \citeauthor and \citeyear macros, which list the author's name and the year of publication, respectively. Is there an equivalent feature in R Markdown?


To further illustrate the problem, here is a minimal working example. Assume that "myBib.bib" is

@BOOK{Smith_2020,
  AUTHOR       = {John Smith},
  TITLE        = {Some Title},
  YEAR         = {2020},
  PUBLISHER    = {Knopf},
  address      = {New York, NY},
}

and that I have this Rmd file:

---
output: html_document
bibliography: 'myBib.bib'
---

(See @Smith_2020 for details.)

The output is (See Smith (2020) for details.) I want to eliminate the parentheses around 2020. One way to do this is to put the entire sentence within brackets: for example, [See @Smith_2020 for details.]. But this approach is a bit clunky, especially when the passage within brackets is large. Is there another way?

I don't think that changing the default citation style will help, as that citation style is usually what I want. I just want to suppress parentheses in citations when the citation lies within a passage that is itself parenthesized.

I've looked to the bookdown book and the R Markdown cookbook, but I can't see that they offer a solution. I've also searched Stack Overflow and tex.stackexchange.com for related questions, but I haven't found anything that speaks to this question.

2

There are 2 answers

1
Carlos Luis Rivera On

(See Smith -@Smith_2020 for details.) will show:

(See Smith 2020 for details.)

See also a previous question and RStudio's official documentation.

4
GaelS On

The correct answer is to put the whole sentence in-between square brackets:

[See Smith -@Smith_2020 for details.]

it follows the first example in the Citation syntax section Rstudio's official doc (link provided in the previous answer).

Blah blah [see @doe99, pp. 33-35; also @smith04, ch. 1].