我正在尝试在降价中制作参考书目。为了构建参考书目,我在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'。为什么等人出现了,我怎么能阻止它出现?我需要参考书目:
Bibliography
Doe, J., 2005. First Book. Cambridge: Cambridge University Press.
Doe, J., 2006. Article. Journal of Generic Studies, 6, 33–34.
答案 0 :(得分: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"))
}
解决了问题