Forums | OpenR

OpenR: R & Statistics /
A question about knit to PDF


Jiayi Li's profile picture
Posts: 5

20 March 2022, 12:11 AM

I use the Rmarkdown--document-- default output format, I can only knit the doc document. But when I want to knit the PDF document, the error is shown below. I don't know how to solve this problem, even after seeing the website in error
 
error:
 
output file: essay初始模板.knit.md
 
! LaTeX Error: Unicode character 锛?(U+FF1A)
               not set up for use with LaTeX.
 
错误: LaTeX failed to compile essay初始模板.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See essay初始模板.log for more info.
此外: Warning message:
In grepl("==> Fatal error occurred", x[i], fixed = TRUE) :
  输入的字符串1不适用于此语言环境
停止执行
Liancheng Lu's profile picture
Posts: 8

20 March 2022, 10:38 AM

```{r message=FALSE, warning=FALSE}
library(ggplot2)
```

Jiayi Li's profile picture
Posts: 5

20 March 2022, 10:47 AM

okok, thank you very much!!

Peng Zhao's profile picture
Posts: 128

20 March 2022, 11:07 AM

Has your problem been solved? I do not see anything relevant to ggplot2, as Liancheng suggested.

Liancheng Lu's profile picture
Posts: 8

20 March 2022, 12:06 PM

Because I had the same error and found it was the porblem of ggplot2 warning. Maybe ‘输入的字符串1不适用于此语言环境’ is the problem of ‘Warning message:

程辑包'ggplot2'是用R版本4.1.1 来建造的’

Peng Zhao's profile picture
Posts: 128

20 March 2022, 2:01 PM

I see. Now I know what is going on. The problem is that the default setting does not support knitting a document with Chinese characters or other multibyte characters into pdf, unless you declare some support from LaTeX settings and packages. 

In this case, when you load the ggplot2 package, some messages in Chinese are generated in the document. Yes, suppressing the messages is a solution, but  I would suggest that you switch to the English environment (change your computer's locale to English) so that the messages in R will be displayed in English. 

Jiayi Li's profile picture
Posts: 5

20 March 2022, 12:23 PM

I have solved this problem.

7 results