Windows 上的 RStudio 不使用 XeLaTeX

标签 rstudio r-markdown pdflatex xelatex

我在 Windows 10 上使用 RStudio 0.99.896。

我正在尝试使用knitr通过XeLaTex引擎将RMarkdown文件转换为PDF。

我已在 RStudio 中设置全局选项项目选项以使用 XeLaTex 进行构建

你可以看到我在全局选项中选择了XeLaTeX(见图) enter image description here

我还在项目选项中选择了它(见图) enter image description here

这是一个最小的可重现的 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/

相关文章:

r - 在 Windows 10 中使用 Linux bash 将 Linux R 解释器引入 Rstudio(Windows 应用程序)。

r - 通过单击 RStudio 查看器 Pane 中的图来获取点坐标

rstudio - 编织时出现 isIncomplete(con) 错误 pdf

r - 在 RMarkdown 中的标题页后插入空白页

r - 有没有办法从 RMarkdown 文件中引用 yaml frontmatter 部分?

latex - 合并 LaTeX 表格中的单元格

java - 如何在 Mac 上用 Java 运行命令 'pdflatex'

shiny - 在 RMarkdown 中编织 Shiny 时出错。 appshot.shiny.appobj 中的错误

docker : Can a container A call an executable located on an other container B?

r - 关于 R Markdown html 输出的评论