问题
I want to change the bibliographystyle
in R Markdown but nothing I found could help.
I do not want any "and"s in the bibliography (before the last author).
My preferred option was if I could use alphadin
(bst-file here) but I could not get it to work.
Here is my YAML so far:
---
output:
pdf_document
bibliography: literatur.bib
biblio-style: alphadin.bst
header-includes:
- \usepackage{graphicx}
- \usepackage{float}
- \usepackage[ngerman]{babel}
- \usepackage{fancyhdr}
- \usepackage{hyperref}
- \pagenumbering{gobble}
- \usepackage{booktabs}
- \usepackage{natbib}
---
The bst-file is in the same directory as the R Markdown file.
回答1:
If you want to set the bibliography style to use a bst file, you need to force R Markdown to use natbib
or biblatex
as the citation manager. By default, it will use pandoc to build the citation. This article explains the behaviour more.
Secondly, once you have that working, you need to change the citation style of the file. By default, natbib will use author-year citations, but the bst file you provided does not work with these. So I have change the citation styles to numbers.
Below is a minimal example. It will create a bibliography file test.bib
but you need to make sure the alphadin.bst file is in the same directory.
---
output:
pdf_document:
citation_package: natbib
bibliography: test.bib
biblio-style: alphadin
header-includes:
- \setcitestyle{numbers}
---
[@R-rmarkdown]
```{r}
knitr::write_bib(x = "rmarkdown", file = "test.bib")
```
来源:https://stackoverflow.com/questions/50048754/change-bibliographystyle-in-r-markdown