RStudio on Windows not using XeLaTeX
I'm using RStudio 0.99.896 on Windows 10.
I am trying to use knitr to convert a RMarkdown file to PDF using the XeLaTex engine.
I have set the Global Options and the Project Options in RStudio to build with XeLaTex
You can see that I have selected XeLaTeX in the global options (see pic)
and I have also selected it in the project options (see pic)
Here is a minimal reproducible example of a markdown file that fails when I call knitr:
---
header-includes:
- usepackage{fontspec}
output:
pdf_document
---
```{r}
data(mtcars)
```
When I call Knit PDF on the file above, I get the following output:
"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:UsersxxxxDocumentsRwin-library3.2rmarkdownrmdlatexdefault-1.14.tex" --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in" output file: sample1.knit.md
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ! Fatal fontspec error: "cannot-use-pdftex" ! ! The fontspec package requires either XeTeX or LuaTeX to function. ! ! You must change your typesetting engine to, eg, "xelatex" or "lualatex" ! instead of plain "latex" or "pdflatex".
You can see in the bold part of the output shown above that RStudio is still calling pdflatex instead of xelatex .
I'm not sure why that is. Any thoughts on a setting that I have missed?
I had this problem too.
Try this:
output:
pdf_document:
latex_engine: xelatex
In addition to everything else you did. This fixed it for me!
链接地址: http://www.djcxy.com/p/33470.html