2016-04-23 40 views
2

我使用RStudio 0.99.896在Windows 10RStudio在Windows上不使用XeLaTeX

我想使用knitr使用XeLaTex引擎RMarkdown文件轉換爲PDF 。

我已經設置了全局選項在RStudio項目選項構建具有XeLaTex

你可以看到,我已在全局選項(參見圖) enter image description here

,我選擇XeLaTeX在項目中的選項也選擇了它(參見圖) enter image description here

這是當我打電話knitr一個失敗的降價文件的最小的可重複的例子:

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


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

當我打電話針織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

我不確定這是爲什麼。任何想法,我已經錯過了一個設置?

+0

正如Rstudio首選項中所述,這些設置用於* Rnw *文件;在這裏,您正在處理* Rmarkdown *。您需要在每個文檔的YAML前端內容中添加'latex_engine:xelatex'設置。 – scoa

回答

0

我也有這個問題。

試試這個:

output: 
    pdf_document: 
    latex_engine: xelatex 

除了一切你沒有。這爲我修好了!