“编译pdf"表示“在Rstudio中工作,但knit2pdf在R或RStudio中不工作 [英] "Compile pdf" in Rstudio works but knit2pdf does not work in R or RStudio

查看:538
本文介绍了“编译pdf"表示“在Rstudio中工作,但knit2pdf在R或RStudio中不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人可以指出我的内部设置,该问题可以通过从R编译tex文档来解决我的问题.

I'm hoping someone can point me to the internal setting that can fix my issue with compiling tex docs from R.

我的问题是texi2pdfknit2pdf会发出警告,并且不会生成pdf.

My issues is that texi2pdf and knit2pdf throw warnings and do not generate a pdf.

我可以使用RStudio中的编译pdf"按钮来编译Rnw文件,可以将rnw文件编织为文本文件,也可以使用TeXnicCenter将tex文件编译为pdf,但是我无法获得texi2pdfknit2pdf函数可在R中工作.

I can get Rnw files to compile using the "Compile pdf" button in RStudio, I can knit rnw files into text files, and I can get my tex files to compile into pdf using TeXnicCenter, but I can't get the texi2pdf or knit2pdf functions to work in R.

在Windows 7中,当我运行以下命令时,在一台装有TexLive的计算机上以及另一台装有MikTex 2.9的计算机上:

In Windows 7 on one machine with TexLive installed and on another machine with MikTex 2.9 installed, when I run the following:

library(knitr)
f = system.file("examples", "knitr-minimal.Rnw", package = "knitr")
knit(f)  # compile to tex
texi2pdf(gsub('Rnw', 'tex', f))

第一部分有效(rnw-> tex),但texi2pdf(tex-> pdf)产生:

the first part works (rnw->tex), but the texi2pdf (tex->pdf) results in:

Warning message:
running command '"C:\PROGRA~2\MIKTEX~1.9\miktex\bin\texify.exe" --quiet --pdf 
"C:/Program Files/R/R-3.3.3/library/knitr/examples/knitr-minimal.tex" --max-
iterations=20 -I "C:/PROGRA~1/R/R-33~1.3/share/texmf/tex/latex" -I 
"C:/PROGRA~1/R/R-33~1.3/share/texmf/bibtex/bst"' had status 1 

如果我运行knit2pdf(f),也是如此,我得到相同的警告消息,并弹出"pdflatex.EXE已停止工作".

The same is true if I run knit2pdf(f), I get the same warning message + a pop up "pdflatex.EXE has stopped working".

我不明白的另一件事是我的路径中有MikTex 2.9,但是警告消息引用了MikTex 1.9,该MikTex 1.9尚未安装在我的计算机上,也不在路径中.

One other thing I don't understand is that I have MikTex 2.9 in my path, but the warning message references MikTex 1.9, which is not installed on my machine and is not in the path.

推荐答案

今天发生在我身上,这似乎是因为MikTex 2.9已安装在我的用户帐户下. R也安装在我的用户帐户下.这是对我有用的东西:

This happened to me today, and it seems it was because MikTex 2.9 was installed under my User account. R is also installed under my User account. Here is what worked for me:

  1. 卸载MikTex,然后将其重新安装在程序文件下.从其控制台更新MikTex.
  2. 在Windows路径中添加"C:\ Program Files \ MiKTeX 2.9 \ miktex \ bin \ x64"(删除旧的MikTex路径).
  3. 重新启动计算机
  4. 卸载并重新安装knitr软件包(可能没有必要).

这篇关于“编译pdf"表示“在Rstudio中工作,但knit2pdf在R或RStudio中不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆