BarkleyBG
BarkleyBG

Reputation: 664

How to use bibliography in different directory when knitting rmarkdown document to beamer presentation?

I'm knitting some beamer slides in an RMarkdown script in Rstudio on a Windows 7 PC. The slides are in the directory

C:/me/slides/myslides.Rmd

I have a master bibliography that lives in

C:/me/bib/masterbib.bib

I cannot figure out how to link to the bibliography file from the RMarkdown document. Here's the YAML from my attempt:

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

Here's the error:

! 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

I've tried a couple other ways to specify the directory for masterbib.bib, but none have worked. I would prefer to keep the masterbib.bib file where it is, and not make an extra copy in the C:/me/slides/ directory. Thanks for your help!


Edit

When attempting to pass the following into YAML (quoteed with forward slashes):

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

I get a fatal error with log output:

! 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!

When passing the following into YAML (quoted with backslashes)

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

I get the following error in the Rstudio console

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

When passing the following into YAML (unquoted with backslashes)

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

I get the following error in the Rstudio console

! 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

Upvotes: 4

Views: 1641

Answers (1)

pirate LG
pirate LG

Reputation: 21

Try unquoted with two backslashes:

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

Upvotes: 2

Related Questions