Rmarkdown with xelatex

2019-02-27 05:04发布

问题:

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.

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.)

I'm on windows 10 64 bit.

---
header-includes:
- \usepackage{fontspec}
output:
   pdf_document:
     latex_engine: xelatex
---


```{r}
data(mtcars)
```

Error:

"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.
<argument> \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

Edit:Incorrectly identified latex distribution used, I'm using MikTex