Rmarkdown nocite does not display citations in pdf
Asked Answered
P

1

6

It has been a hard time finding what does not work. I want to use the nocite command to display bibiography entries that I don't cite in the document, but I cannot figure why it does not work.

Here is a MWE

---
title: "Test"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output: 
  pdf_document:
    number_sections: true
    df_print: kable
    highlight: haddock
    citation_package: biblatex
biblio-style: "authoryear"
bibliography: biblio.bib
link-citations: true
linkcolor: blue
---

One citation [@wuthrich2008modelling]

---
nocite: |
  @wuthrich2009uncertainty
...

# References

and my biblio.bib contains the following

@inproceedings{wuthrich2008modelling,
  title={Modelling the claims development result for solvency purposes},
  author={W{\"u}thrich, Mario V and Merz, Michael},
  booktitle={Casualty Actuarial Society E-Forum},
  pages={542--568},
  year={2008}
}


@article{wuthrich2009uncertainty,
  title={Uncertainty of the claims development result in the chain ladder method},
  author={W{\"u}thrich, Mario V and Merz, Michael and Lysenko, Natalia},
  journal={Scandinavian Actuarial Journal},
  volume={2009},
  number={1},
  pages={63--84},
  year={2009},
  publisher={Taylor \& Francis}
}


@article{merz2007prediction,
  title={Prediction error of the expected claims development result in the chain ladder method},
  author={Merz, Michael and W{\"u}thrich, Mario V},
  journal={Bulletin of Swiss Association of Actuaries},
  volume={1},
  number={2007},
  pages={117--137},
  year={2007}
}

Ideally, I want to use the '@*' command to cite all the bibliography.

But after a long search online, I cannot find the reason. When I keep track of the tex file with keep_tex, there is no \nocite{} that appears. So that makes sense that it doesn't show up in the bibliography. But why?

I tried to put the nocite at different places in the document, but nothing changed.

The sessionInfo() is

R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252    LC_MONETARY=French_France.1252
[4] LC_NUMERIC=C                   LC_TIME=French_France.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_3.6.1  htmltools_0.4.0 tools_3.6.1     yaml_2.2.0      Rcpp_1.0.3     
 [6] rmarkdown_1.17  knitr_1.26      xfun_0.11       digest_0.6.22   rlang_0.4.1    
[11] evaluate_0.14 
Piscary answered 5/11, 2019 at 11:3 Comment(0)
W
5

As a workaround, you can directly use \nocite{wuthrich2009uncertainty} in the document:

---
title: "Test"
date: "`r format(Sys.time(), '%d %B, %Y')`"
output: 
  pdf_document:
    number_sections: true
    df_print: kable
    highlight: haddock
    citation_package: biblatex
    keep_tex: true
biblio-style: "authoryear"
bibliography: biblio.bib
link-citations: true
linkcolor: blue
---

One citation [@wuthrich2008modelling]

\nocite{wuthrich2009uncertainty}

---

...

# References

enter image description here

Writhen answered 19/11, 2019 at 12:27 Comment(3)
Thank you, it works indeed. But did you have the same problem as me too? Do you have an explanation of that? In the meantime, I will use your solution. I marked it as usefull, and if no one can provide an explanation, I will accept itPiscary
To provide an explanation: by using citation_package: biblatex, one forces R Markdown to skip pandoc-citeproc, which otherwise handles citations and the nocite field. The nocite info is lost in that case, normal cites are handled by biblatex as expected. Probably worth raising a feature request over at github.com/jgm/pandoc/issuesCapernaum
@Capernaum Thank you for that explanation! It makes sense then. It should be quite new, because all the examples I found don't mention it. I will look at doing a request, never done that on github!Piscary

© 2022 - 2024 — McMap. All rights reserved.