knitr -> LaTeX -> PDF 时出现编码错误

knitr -> LaTeX -> PDF 时出现编码错误

我有一份用 knitr 编写的文档。我可以将其导出为 HTML 和 docx,但出于某种原因不能导出为 PDF。Rmd 文件在这里http://cl.ly/dJka?_ga=1.30252732.2076817589.1442770201

它说

! Package inputenc Error: Unicode char \u8: not set up for use with LaTeX.

See the inputenc package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.429 

Try running pandoc with --latex-engine=xelatex.
pandoc: Error producing PDF from TeX source
Error: pandoc document conversion failed with error 43
In addition: Warning message:
In native_encode(text) :
  some characters may not work under the current locale
Execution halted

有趣的是,它对 docx 所说的内容几乎相同,但一切都运行正常。

Output created: a22.docx
Warning message:
In native_encode(text) :
  some characters may not work under the current locale

然后我查看了控制台中的错误代码,发现

label: plot colgpa and residuals
cropping a22_files/figure-latex/plot colgpa and residuals-1.pdf
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LC_ALL = (unset),
    LC_CTYPE = "en_SE.UTF-8",
    LANG = "en_SE.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
PDFCROP 1.38, 2012/11/02 - Copyright (c) 2002-2012 by Heiko Oberdiek.
==> 1 page written on `a22_files/figure-latex/plot colgpa and residuals-1.pdf'.
  |..........

所以我认为这是因为如果我在 Rmd 中有一个带有图形输出的“代码块”,我无法用空格来命名它,因为 R 没有地方放置图形 - 目录不能包含空格。所以我删除了它们。

现在我得到的错误更少了,但仍然无法渲染它。整个错误代码是

During startup - Warning messages:
1: Setting LC_CTYPE failed, using "C" 
2: Setting LC_COLLATE failed, using "C" 
3: Setting LC_TIME failed, using "C" 
4: Setting LC_MESSAGES failed, using "C" 
5: Setting LC_MONETARY failed, using "C" 


processing file: a22.Rmd
(*) NOTE: I saw chunk options "q4 colgpa = athlete + sat"
 please go to http://yihui.name/knitr/options
 (it is likely that you forgot to quote "character" options)
Error in base::parse(text = code, srcfile = NULL) : 
  1:11: unexpected symbol
1: alist( q4 colgpa
              ^
Calls: <Anonymous> ... withCallingHandlers -> eval -> parse_only -> <Anonymous>
In addition: Warning message:
In native_encode(text) :
  some characters may not work under the current locale
Execution halted

我将其发布在这里,因为 knitr 执行 Rmd -> LaTeX -> PDF 并且我没有看到 latex-step。

相关内容