使用适用于LaTeX的knitr和.Rnw,如何在PDF输出中打印完整的参考书目? [英] With knitr and .Rnw for LaTeX, how do you print the full bibliography in PDF output?
问题描述
我似乎无法破解所有的可能性,并在RStudio的PDF输出,knitr
、. Rnw脚本和编译PDF"按钮中插入了完整的参考书目. PDF中所需的文本将是所引用作品的详细信息.
I can't seem to hack my way through all the possibilities and have a full bibliography inserted in the PDF output of RStudio, knitr
, an .Rnw script, and the "Compile PDF" button. The desired text in the PDF would be the details of the cited works.
这是一个保存在工作目录中的Lilliputian bibtex文件,名为jabrefbibtest.bib
.
Here is a Lilliputian bibtex file, called jabrefbibtest.bib
, saved in the working directory.
@Book{GreentargetEngagement2012,
Title = {"2012 - In - House Counsel New Media Engagement Survey"},
Author = {"Inside Counsel "},
Publisher = {"Greentarget"},
Year = {"2012"},
Pages = {"20"},
Plots = {"9"},
Tables = {"0"},
Url = {"http://www.greentarget.com/wp-content/uploads/2012/01/2012GTZGICSurveyReportFinal-WebsiteVersion.pdf"}
}
@Book{CitiprivateBank,
Title = {"Intellectual Leadership with Law Watch"},
Author = {""},
Publisher = {""},
Year = {"2008"},
Pages = {"2"},
Plots = {"1"},
Tables = {"4"},
Url = {"http://www.citigroup.com/privatebank/lawassociates/pdfs/lawwatch/slipsheet.pdf"}
}
被精简的.Rnw
脚本是
\documentclass[11pt]{article}
\usepackage[backend=bibtex]{biblatex}
% \addbibresource{} # not sure if this is needed
\begin{document}
<<bibbackground, echo=FALSE, include=FALSE>>=
setwd("~/R/knitr docs/")
Sys.setenv(TEXINPUTS=getwd(),
BIBINPUTS=getwd(),
BSTINPUTS=getwd())
@
\bibliographystyle{plain}
\bibliography{jabrefbibtest}
Here is one citation \cite{GreentargetEngagement2012} and here is a second \cite{CitiprivateBank}.
Now do full References show below?
\printbibliography
\end{document}
日志:
! Package biblatex Error: '\bibliographystyle' invalid.
See the biblatex package documentation for explanation.
Type H <return> for immediate help.
...
l.59 \bibliographystyle{plain}
Use the package option 'style' instead.
I'm ignoring this command.
! LaTeX Error: Can be used only in preamble.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.60 \bibliography
{jabrefbibtest}
Your command was ignored.
Type I <command> <return> to replace it with another command,
or <return> to continue without it.
LaTeX Warning: Citation 'GreentargetEngagement2012' on page 1 undefined on inpu
t line 62.
[more omitted]
与 The Latex Companion ,带有R和knitr的 Dynamic Documents 一起,谢一辉(Yihui Xie)撰写的两本LaTeX入门书籍和262页的biblatex手册,我在其中苦苦挣扎.这些网站的复杂建议.徒劳无功.
Along with The Latex Companion, Dynamic Documents with R and knitr, by Yihui Xie, two LaTeX primers and the 262-page manual for biblatex I have struggled through the complicated advice of these sites. Fruitlessly.
https://tex.stackexchange.com/questions/71565/knitr-and-biblatex
https://tex.stackexchange.com/questions/63852/question -mark-instan-of-citation-number
http://texblog.org/2013/08/20/rknitr-automatic-bibliography-generation-with-biblatex-in-rstudio/
http://www.inside-r.org/packages /cran/knitcitations/docs/参考书目
在评论后进行编辑
所有PDF文件都具有以下内容:
All the PDF file has is this:
参考 这是一个引文[?],而第二个[?]. 现在,下面显示完整的参考文献吗?
References Here is one citation [?] and here is a second [?]. Now do full References show below?
推荐答案
错误消息告诉您:
- 请勿使用
\bibliographystyle{plain}
(这不适用于biblatex);使用\usepackage[]{biblatex}
中的style
选项代替; -
\bibliography{jabrefbibtest}
必须放在前言而不是正文中.
- Don't use
\bibliographystyle{plain}
(this does not work for biblatex); use thestyle
option in\usepackage[]{biblatex}
instead; \bibliography{jabrefbibtest}
must be put in the preamble instead of the body.
纠正这些问题后,它应该可以工作:
After you correct these issues, it should work:
\documentclass[11pt]{article}
\usepackage[backend=bibtex]{biblatex}
\bibliography{jabrefbibtest}
% or use \addbibresource{jabrefbibtest.bib}
\begin{document}
Here is one citation \cite{ABFWomenFirstChairs2015} and
here is a second \cite{ACCGCSkills2013}.
Now do full References show below?
\printbibliography
\end{document}
顺便说一句,RStudio可能不支持biblatex
的默认后端biber
,因此使用了backend=bibtex
选项.
BTW, RStudio probably does not support the default backend biber
of biblatex
, so the backend=bibtex
option was used.
这篇关于使用适用于LaTeX的knitr和.Rnw,如何在PDF输出中打印完整的参考书目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!