title: RStudio on Windows not using XeLaTeX
body: <p>I'm using <strong>RStudio</strong> 0.99.896 on Windows 10.</p>
  
  <p>I am trying to use <strong>knitr</strong> to convert a <strong>RMarkdown</strong> file to PDF using the <strong>XeLaTex</strong> engine. </p>
  
  <p>I have set the Global Options <em>and</em> the Project Options in RStudio to build with XeLaTex</p>
  
  <p>You can see that I have selected XeLaTeX in the global options (see pic)
  <a href="https://i.stack.imgur.com/fu2A7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fu2A7.png" alt="enter image description here"></a></p>
  
  <p>and I have also selected it in the project options (see pic)
  <a href="https://i.stack.imgur.com/MisXh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MisXh.png" alt="enter image description here"></a></p>
  
  <p>Here is a minimal reproducible example of a markdown file that fails when I call knitr:</p>
  
  <pre><code>---
  header-includes:
      - \usepackage{fontspec}
  output:
      pdf_document
  ---
  
  
  ```{r}
  data(mtcars)
  ```
  </code></pre>
  
  <p>When I call <strong>Knit PDF</strong> on the file above, I get the following output:</p>
  
  <blockquote>
    <p>"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS
    sample1.utf8.md --to latex --from
    markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures
    --output sample1.pdf --template "C:\Users\xxxx\Documents\R\win-library\3.2\rmarkdown\rmd\latex\default-1.14.tex"
    --highlight-style tango <strong>--latex-engine pdflatex</strong> --variable graphics=yes --variable "geometry:margin=1in"  output file:
    sample1.knit.md</p>
    
    <p>!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ! Fatal fontspec
    error: "cannot-use-pdftex" !  ! The fontspec package requires either
    XeTeX or LuaTeX to function. !  ! You must change your typesetting
    engine to, e.g., "xelatex" or "lualatex" ! instead of plain "latex" or
    "pdflatex".</p>
  </blockquote>
  
  <p>You can see in the bold part of the output shown above that RStudio is still calling <strong>pdflatex</strong> instead of <strong>xelatex</strong>. </p>
  
  <p>I'm not sure why that is. Any thoughts on a setting that I have missed?</p>