简体   繁体   English

为什么 RMarkdown 中的“Knit to pdf”会引发错误?

[英]Why "Knit to pdf" in RMarkdown throws error?

I have installed tinytex package in R.我已经在 R 中安装了 tinytex package。 While using R Markdown, I can not knit to pdf, even though I can knit to html.在使用 R Markdown 时,我无法编织到 pdf,即使我可以编织到 ZFC335FDC70D2FCZA76D。

I have tried knit to html, that works.我已经尝试编织到 html,这很有效。 But knit to pdf shows error.但是编织到 pdf 显示错误。

I get the following error message:我收到以下错误消息:

Error: Failed to compile New_Rmamrkdown.tex.错误:无法编译 New_Rmamrkdown.tex。 See https://yihui.name/tinytex/r/#debugging for debugging tips.调试提示见https://yihui.name/tinytex/r/#debugging See New_Rmamrkdown.log for more info.有关详细信息,请参阅 New_Rmamrkdown.log。
In addition: Warning message: package 'tidyverse' was built under R version 3.5.3此外:警告消息:package 'tidyverse' 是在 R 版本 3.5.3 下构建的
Execution halted执行停止

It requires an additional third party software(latex), there are various softwares to do the task. 它需要一个附加的第三方软件(乳胶),可以使用各种软件来完成任务。 Try this miktex . 试试这个miktex I tried in my Ubuntu OS with RStudio, it works good. 我在带有RStudio的Ubuntu OS中进行了尝试,效果很好。 Install this package, and please mention whether it works for you! 安装此软件包,请注明它是否对您有用!

Step 1: To fix this issue, go to Tools ---> Global Options ---> Sweave in R Studio.第 1 步:要解决此问题,go 到Tools ---> Global Options ---> R Studio 中的Sweave

  • Then under Typeset LaTex into PDF using select XeLaTex .然后在使用 select XeLaTex Typeset LaTex into PDF using下。
  • Under LaTex Editing and Compilation , tick "Use tinytex when compiling.tex files.LaTex Editing and Compilation下,勾选“编译.tex文件时使用tinytex。
  • Click Apply and Ok .单击ApplyOk

Step 2: In R Markdown, install tinytex in an R chunk第 2 步:在 R Markdown 中,在 R 块中安装 tinytex

```{r}
tinytex::install_tinytex(force = TRUE)
library(tinytex)

Step 3: In the header block, type the output as:第 3 步:在 header 块中,键入 output 为:

output:
  pdf_document:
    latex_engine: xelatex

Select the Knit to PDF and your document should knit correctly. Select Knit to PDF并且您的文档应该正确编织。

If any of these help, kindly upvote it so more people can see the solution that worked.如果其中任何一项有帮助,请点赞,以便更多人可以看到有效的解决方案。 Cheers!!!干杯!!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM