我在 Windows 10 上使用 RStudio 0.99.896。
我正在尝试使用knitr通过XeLaTex引擎将RMarkdown文件转换为PDF。
我已在 RStudio 中设置全局选项和项目选项以使用 XeLaTex 进行构建
这是一个最小的可重现的 markdown 文件示例,当我调用 knit 时该文件失败:
---
header-includes:
- \usepackage{fontspec}
output:
pdf_document
---
```{r}
data(mtcars)
```
当我对上面的文件调用 Knit PDF 时,我得到以下输出:
"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 --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, e.g., "xelatex" or "lualatex" ! instead of plain "latex" or "pdflatex".
您可以在上面显示的输出的粗体部分中看到,RStudio 仍在调用 pdflatex 而不是 xelatex。
我不知道为什么会这样。对我错过的设置有什么想法吗?
最佳答案
我也遇到这个问题了。
试试这个:
output:
pdf_document:
latex_engine: xelatex
除了你所做的一切之外。这为我解决了这个问题!
关于Windows 上的 RStudio 不使用 XeLaTeX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36806255/