更改R Markdown中的书目风格 [英] Change bibliographystyle in R Markdown
问题描述
我想更改R Markdown中的bibliographystyle
,但我发现无济于事.
I want to change the bibliographystyle
in R Markdown but nothing I found could help.
我不希望书目中有任何和"(在最后一位作者之前).
我的首选选择是是否可以使用alphadin
(bst文件这里),但我无法正常工作.
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.
到目前为止,这是我的YAML:
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}
---
bst文件与R Markdown文件位于同一目录中.
The bst-file is in the same directory as the R Markdown file.
推荐答案
如果要将书目样式设置为使用bst文件,则需要强制R Markdown使用natbib
或biblatex
作为引文管理器.默认情况下,它将使用pandoc构建引用. 本文进一步说明了这种行为.
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.
其次,一旦完成该工作,就需要更改文件的引用样式.默认情况下,natbib将使用作者年份引文,但您提供的bst文件不适用于这些年份.因此,我将引用样式更改为数字.
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.
下面是一个最小的示例.它将创建一个书目文件test.bib
,但是您需要确保alphadin.bst文件位于同一目录中.
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")
```
这篇关于更改R Markdown中的书目风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!