2

我正在尝试在降价中制作参考书目。为了构建参考书目,我使用 R 中的 knitr 包和 pandoc 将 .Rmd 文件转换为 PDF。

我的 .bib 文件中的条目如下所示,取自http://johnmacfarlane.net/pandoc/demo/biblio.bib

@Book{item1,
author="John Doe",
title="First Book",
year="2005",
address="Cambridge",
publisher="Cambridge University Press"
}

@Article{item2,
author="John Doe",
title="Article",
year="2006",
journal="Journal of Generic Studies",
volume="6",
pages="33-34"
}

为了构建我的参考书目,我使用了以下函数,取自:http: //quantifyingmemory.blogspot.co.il/2013/02/reproducible-research-with-r-knitr.html

knitsPDF <- function(name) {
  library(knitr)
  knit(paste0(name, ".Rmd"), encoding = "utf-8")
  system(paste0("pandoc -o ", name, ".pdf ", name, ".md --bibliography /Users/.../Desktop/test.bib --csl /Users/.../Desktop/taylor-and-francis-harvard-x.csl"))
}

我的 .Rmd 文件的内容是

This is some text [@item1]

This is more text [@item2]

References

输出PDF的内容是:

This is some text (Doe 2005)
This is more text (Doe 2006)

Bibliography
Doe, J. et al., 2005. First Book. Cambridge: Cambridge University Press. 

Doe, J. et al., 2006. Article. Journal of Generic Studies, 6, 33–34.

请注意参考书目中出现的“et al”。为什么 et al 会出现,我该如何阻止它出现?我需要参考书目是:

Bibliography
    Doe, J., 2005. First Book. Cambridge: Cambridge University Press. 

    Doe, J., 2006. Article. Journal of Generic Studies, 6, 33–34.
4

1 回答 1

1

事实上,这只是样式文件的问题。下载此样式文件:http ://www.zotero.org/styles/harvard-durham-university-business-school

并更改此代码

knitsPDF <- function(name) {
  library(knitr)
  knit(paste0(name, ".Rmd"), encoding = "utf-8")
  system(paste0("pandoc -o ", name, ".pdf ", name, ".md --bibliography /Users/.../Desktop/test.bib --csl /Users/.../Desktop/harvard-durham-university-business-school.csl"))
}

解决了问题

于 2013-05-06T10:16:15.903 回答