Reputation: 1944
I feel like this is a straight forward thing, but everything I find doesn't quite get me what I want. I'm using rmarkdown and knitting to a latex .pdf
. I'd like to have my in-text citations have round ()
parenthesis instead of the block ones. The yaml below uses a references.bib
file to correctly import the references. Is there anything I can do to easily change my parenthesis to round?
---
title: "Title"
author: "Author"
date: "16/03/2020"
output:
pdf_document:
fig_caption: yes
citation_package: natbib
bibliography: references.bib
editor_options:
chunk_output_type: console
---
I've used an approach here, but it returns an error:
Error in yaml::yaml.load(..., eval.expr = TRUE) : Parser error: while parsing a block mapping at line 6, column 5 did not find expected key at line 7, column 30` --- title: "Title" author: "Author" date: "16/03/2020" output: pdf_document: fig_caption: yes bibliography: references.bib editor_options: chunk_output_type: console \usepackage[round]{natbib} ---
Any ideas? Thanks for your suggestions / ideas...
Upvotes: 2
Views: 823
Reputation: 1821
Using the header-includes:
option should fix the issue.
---
title: "Title"
author: "Author"
date: "16/03/2020"
output:
pdf_document:
fig_caption: yes
citation_package: natbib
bibliography: references.bib
editor_options:
chunk_output_type: console
header-includes:
- \usepackage[round]{natbib}
---
Upvotes: 0
Reputation: 38748
The problem with your attempt to include \usepackage[round]{natbib}
in the rmarkdown header is that rmarkdown seems not clever enough to parse commands with optional arguments. One can trick it by hiding the command in a .tex
file
---
title: "Title"
author: "Author"
date: "16/03/2020"
output:
pdf_document:
fig_caption: yes
includes:
in_header: preamble.tex
bibliography: references.bib
---
test [@knuth]
with preamble.tex
\usepackage[round]{natbib}
https://rstudio.cloud/project/1061588
Upvotes: 2