title: Rmarkdown with xelatex
body: <p>I'm trying to use Calibri font, but from what I understand I first need to be able to use the xelatex engine. This is where I run into problems. Sample code and error are below.</p>
  
  <p>Please note that I am very new to latex so chances are I missed something obvious. If it matters I have MikTeX 2.9 installed, and I have successfully generated pdfs using the default pdflatex engine (from what I understand this has very limited fonts.)</p>
  
  <p>I'm on windows 10 64 bit. </p>
  
  <pre><code>---
  header-includes:
  - \usepackage{fontspec}
  output:
     pdf_document:
       latex_engine: xelatex
  ---
  
  
  ```{r}
  data(mtcars)
  ```
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS 
  SimpleTest.utf8.md --to latex --from 
  markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --
  output SimpleTest.pdf --template "C:\Users\ce29109\Documents\R\win-
  library\3.4\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style 
  tango --latex-engine xelatex --variable graphics=yes --variable 
  "geometry:margin=1in" 
  ! Undefined control sequence.
  &lt;argument&gt; \LaTeX3 error: 
                         Erroneous variable \c__fontspec_shape_n_n_tl used!
  l.3806 \emfontdeclare{ \emshape, \eminnershape }
  
  pandoc.exe: Error producing PDF
  Error: pandoc document conversion failed with error 43
  In addition: Warning message:
  running command '"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -
  RTS SimpleTest.utf8.md --to latex --from 
  markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --
  output SimpleTest.pdf --template "C:\Users\ce29109\Documents\R\win-
  library\3.4\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style 
  tango --latex-engine xelatex --variable graphics=yes --variable 
  "geometry:margin=1in"' had status 43 
  Execution halted
  </code></pre>
  
  <p>Edit:Incorrectly identified latex distribution used, I'm using MikTex</p>