如何在将rmarkdown文档编织到beamer演示文稿时在不同的目录中使用参考书目?

时间:2016-12-20 20:21:06

标签: knitr r-markdown pandoc beamer bibtex

我正在Windows 7 PC上的Rstudio中的RMarkdown脚本中编织一些beamer幻灯片。幻灯片位于目录

C:/me/slides/myslides.Rmd

我有一份住在

的主要参考书目
C:/me/bib/masterbib.bib

我无法弄清楚如何从RMarkdown文档链接到参考书目文件。这是我尝试的YAML:

---
title: "Slides"
author: "me"
date: "2016-12-20"
bibliography: C:/me/bib/masterbib.bib
biblio-style: "apalike"
output: 
  beamer_presentation:
    citation_package: natbib
---

这是错误:

! Undefined control sequence.
<write> \string \bibdata {C:\me\bib\masterbib}
l.174 \end{frame}

Error: Failed to compile Slides.tex. See Slides.log for more info.
In addition: Warning message:
running command '"pdflatex" -halt-on-error -interaction=batchmode "Slides.tex"' had status 1 
Execution halted

我已经尝试了其他几种方法来指定masterbib.bib的目录,但没有一种方法可行。我希望将masterbib.bib文件保留在原来的位置,而不是在C:/me/slides/目录中创建额外的副本。谢谢你的帮助!

修改

尝试将以下内容传递给YAML时(引用正斜杠引用):

bibliography: "C:/LaTeXstuff/BibTexLibrary/BrianBib.bib"

我在日志输出中遇到致命错误:

! Undefined control sequence.
<write> \string \bibdata {C:\me
                                        \bib\masterbib}
l.174 \end{frame}

Here is how much of TeX's memory you used:
 18047 strings out of 494045
 334241 string characters out of 3145937
 424206 words of memory out of 3000000
 20891 multiletter control sequences out of 15000+200000
 31808 words of font info for 44 fonts, out of 3000000 for 9000
 715 hyphenation exceptions out of 8191
 56i,11n,55p,434b,376s stack positions out of 5000i,500n,10000p,200000b,50000s

!  ==> Fatal error occurred, no output PDF file produced!

将以下内容传递给YAML(引用反斜杠)

bibliography: "C:\me\bib\masterbib.bib"

我在Rstudio控制台中收到以下错误

Error in yaml::yaml.load(enc2utf8(string), ...) : 
  Scanner error: while parsing a quoted scalar at line 4, column 15found unknown escape character at line 4, column 29
Calls: <Anonymous> ... yaml_load_utf8 -> mark_utf8 -> <Anonymous> -> .Call
Execution halted

将以下内容传递给YAML(不带反斜杠)

bibliography: C:\me\bib\masterbib.bib

我在Rstudio控制台中收到以下错误

! Undefined control sequence.
<write> \string \bibdata {C:\me
                                        \bib\masterbib}
l.174 \end{frame}

Error: Failed to compile BibTest.tex. See BibTest.log for more info.
In addition: Warning message:
running command '"pdflatex" -halt-on-error -interaction=batchmode "BibTest.tex"' had status 1 
Execution halted

1 个答案:

答案 0 :(得分:1)

尝试使用两个反斜杠:

...    
bibliography: C:\\me\\bib\\masterbib.bib
...