title: How to use bibliography in different directory when knitting rmarkdown document to beamer presentation?
body: <p>I'm knitting some beamer slides in an RMarkdown script in Rstudio on a Windows 7 PC. The slides are in the directory</p>
  
  <pre><code>C:/me/slides/myslides.Rmd
  </code></pre>
  
  <p>I have a master bibliography that lives in </p>
  
  <pre><code>C:/me/bib/masterbib.bib
  </code></pre>
  
  <p>I cannot figure out how to link to the bibliography file from the RMarkdown document. Here's the YAML from my attempt:</p>
  
  <pre><code>---
  title: "Slides"
  author: "me"
  date: "2016-12-20"
  bibliography: C:/me/bib/masterbib.bib
  biblio-style: "apalike"
  output: 
    beamer_presentation:
      citation_package: natbib
  ---
  </code></pre>
  
  <p>Here's the error:</p>
  
  <pre><code>! Undefined control sequence.
  &lt;write&gt; \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
  </code></pre>
  
  <p>I've tried a couple other ways to specify the directory for <code>masterbib.bib</code>, but none have worked. I would prefer to keep the <code>masterbib.bib</code> file where it is, and not make an extra copy in the <code>C:/me/slides/</code> directory. Thanks for your help!</p>
  
  <hr>
  
  <p>Edit</p>
  
  <p>When attempting to pass the following into YAML (quoteed with forward slashes):</p>
  
  <p><code>bibliography: "C:/LaTeXstuff/BibTexLibrary/BrianBib.bib"</code></p>
  
  <p>I get a fatal error with log output:</p>
  
  <pre><code>! Undefined control sequence.
  &lt;write&gt; \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
  
  !  ==&gt; Fatal error occurred, no output PDF file produced!
  </code></pre>
  
  <hr>
  
  <p>When passing the following into YAML (quoted with backslashes)</p>
  
  <p><code>bibliography: "C:\me\bib\masterbib.bib"</code></p>
  
  <p>I get the following error in the Rstudio console</p>
  
  <pre><code>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: &lt;Anonymous&gt; ... yaml_load_utf8 -&gt; mark_utf8 -&gt; &lt;Anonymous&gt; -&gt; .Call
  Execution halted
  </code></pre>
  
  <hr>
  
  <p>When passing the following into YAML (unquoted with backslashes)</p>
  
  <p><code>bibliography: C:\me\bib\masterbib.bib</code></p>
  
  <p>I get the following error in the Rstudio console</p>
  
  <pre><code>! Undefined control sequence.
  &lt;write&gt; \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
  </code></pre>