Search code examples
latexr-markdownbookdowntexcitations

Equivalent of \usepackage[round]{natbib} in Rmarkdown yaml


This question is related to Is there a way to keep LaTeX citation keys in .tex file when knitting r-markdown to PDF. Using natbib and xelatex resulted in in-text citations with square parentheses, such as [First et al., 2020] but I need round parentheses: (First et al., 2020). Switching around different latex engines or pdf_document or pdf_document2 does not change this behavior.

I prefer pdf_document2 to accommodate some of my tables better than what pdf_document does. Here is my yaml

title: "abc"
output: 
  bookdown::pdf_document2: 
    keep_tex: true
    toc: false
    latex_engine: lualatex
    citation_package: natbib
bibliography: ref.bib
csl: apa-no-ampersand.csl  

As stated here https://tex.stackexchange.com/questions/466819/use-round-brackets-instead-of-square-brackets-in-natbib-citations, I can edit my .tex file to set the parenthesis style, upload it to a tex processing program, then download the pdf, but that's quite inefficient.

Any leads to how to render in-text citations in round parentheses straight from R are much appreciated.


Solution

  • Just specify your natbiboptions. If you use BibLaTeX, then you can set biblatexoptions. If you want to specify multiple options, use a list notation with - (two-space indent and hyphen). If you want to comment out an option, use #.

    title: "abc"
    output: 
      bookdown::pdf_document2: 
        keep_tex: true
        toc: false
        latex_engine: lualatex
        citation_package: natbib
    bibliography: ref.bib
    natbiboptions: round
    biblatexoptions:
      - sortcites = true
      - sorting = nyt
      - backend = biber
      # - maxcitenames = 2