6

我似乎无法破解所有可能性,并在 RStudio、knitr.Rnw 脚本和“编译 PDF”按钮的 PDF 输出中插入完整的参考书目。PDF 中所需的文本将是被引作品的详细信息。

这是一个 Lilliputian bibtex 文件,名为jabrefbibtest.bib,保存在工作目录中。

@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]

除了Yihui Xie的 The Latex CompanionR 和 knitr的动态文档、两本 LaTeX 入门书和 262 页 biblatex 手册外,我还在这些网站的复杂建议中苦苦挣扎。无果。

https://tex.stackexchange.com/questions/71565/knitr-and-biblatex

https://tex.stackexchange.com/questions/63852/question-mark-instead-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/bibliography

评论后编辑

所有PDF文件都是这样的:

参考文献 这是一个引用 [?],这是第二个 [?]。现在完整的参考文献显示在下面吗?

4

4 回答 4

2

正如错误消息告诉您的那样:

  1. 不要使用\bibliographystyle{plain}(这不适用于 biblatex);改用该style选项\usepackage[]{biblatex}
  2. \bibliography{jabrefbibtest}必须放在序言而不是正文中。

更正这些问题后,它应该可以工作:

\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 可能不支持 的默认后端biberbiblatex因此backend=bibtex使用了该选项。

于 2015-10-25T20:50:28.293 回答
1

我完全使用下面的这个设置来获取(注意我不喜欢wd在 knitr/rmarkdown 中进行更改并删除了它;而且您在 Rnw 中的键与 mwe 中的键不匹配):

在此处输入图像描述

\documentclass[11pt]{article}

\usepackage[american]{babel}
\usepackage[style=apa,backend=biber,bibencoding=latin1]{biblatex}
\DeclareLanguageMapping{american}{american-apa}

\addbibresource{jabrefbibtest.bib}


\begin{document}

<<bibbackground, echo=FALSE, include=FALSE>>=
#setwd("~/R/knitr docs/")
Sys.setenv(TEXINPUTS=getwd(),
           BIBINPUTS=getwd(),
           BSTINPUTS=getwd())
@

%\bibliographystyle{plain}

Here is one citation \cite{GreentargetEngagement2012} and here is a second \cite{CitiprivateBank}.

Now do full References show below?

\printbibliography
\end{document}

同样在 Rnw 编织之后,我必须通过 LaTeX 编译器运行 tex 文件以第一次呈现引用。

于 2015-10-25T21:16:01.890 回答
0

要将 .bib 文件中的所有引用包含在参考书目中,即即使是您最终没有引用的引用,请在该行 \nocite{*}之前包含该行\printbibliography

于 2016-09-13T19:04:40.760 回答
0

我总是把 \bibliography{jabrefbibtest}我希望引用发生在脚本的末尾。

于 2015-12-09T13:27:00.087 回答