I am trying to typeset citations in my R Markdown document, and it appears that the citations are not parsed correctly in some cases, specifically, when citations appear with a :
, such as [@ref1]:
and some text following it.
Here is an MWE:
---
title: Citations Parsing
references:
- id: fenner2012a
title: One-click science marketing
author:
- family: Fenner
given: Martin
container-title: Nature Materials
volume: 11
URL: 'http://dx.doi.org/10.1038/nmat3283'
DOI: 10.1038/nmat3283
issue: 4
publisher: Nature Publishing Group
page: 261-263
type: article-journal
issued:
year: 2012
month: 3
---
1. [@fenner2012a]: Here is some text. **This does not work.**
2. [@fenner2012a]:
3. [@fenner2012a] : Here is some text. **This works.**
I am on the latest version of rmarkdown
from CRAN (0.8.1). Note that in the example above, #2 works as well. It is when you chase up the :
with text, that the citation stops rendering.
This could very well be a knitr
problem as well. I am on the latest version of knitr from CRAN (1.11).
The usual way to include citations in an R Markdown document is to put references in a plain text file with the extension . bib, in BibTex format. Then reference the path to this file in index. Rmd's YAML header with bibliography: example.
To cite an entry, use @key or [@key] (the latter puts the citation in braces), e.g., @R-base is rendered as R Core Team (2022), and [@R-base] generates “(R Core Team 2022)”. If you are familiar with the natbib package in LaTeX, @key is basically \citet{key} , and [@key] is equivalent to \citep{key} .
To create a footnote in R Markdown, you use the carrot ^ followed immediately by square brackets []. Put the text inside of the [] and it'll print that at the bottom of the page. Code for a footnote will look like this: ^[This sentence will be printed as a footnote.] .
It looks like knitr
is trying to parse the whole citation, including the semicolon. To stop it, use a \
to escape the colon:
[@fenner2012a]\: Here is some text. **This works now.**
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With