R Sweave(Rnw)不会生成PDF文件 - 退出代码1

问题描述 投票:0回答:1

我最近一直在学习如何在R中使用sweave从Rstudio创建PDF文件,我的机器突然停止使用sweave创建PDF。它仍然可以在rMarkdown中创建PDF,但是当它在sweave中无法执行时,它会提供一个退出代码。

我在网上发现的问题可能有十几个问类似问题,但没有一个答案有帮助。我已经尝试在我的环境窗口中更改%PATH%,我已经卸载并重新安装了rStudio和Miktex,我已经将乳胶的路径直接设置到Rstudio的控制台中,我尝试使用knitr而不是sweave,并且我已经尝试启用shell转义命令。不幸的是,这些都没有奏效。

为了验证它不是我的代码的问题,我创建了一个简单的例子,遇到了同样的问题。这是我的Rnw代码:


\documentclass{article}

\begin{document}
\SweaveOpts{concordance=TRUE}

Hello world

\end{document}

这是Compile PDF选项卡中的输出(注意,我有Miktex版本2.9,而不是1.9):

Writing to file trash.tex
Processing code chunks with options ...
 1 : echo keep.source term verbatim (trash.Rnw:6)

You can now run (pdf)latex on 'trash.tex'
Running pdflatex.exe on trash.tex...failed
Error running C:/PROGRA~1/MIKTEX~1.9/miktex/bin/x64/pdflatex.exe (exit code 1)

这是日志文件(注意它总是引用miktex 2.9,而不是1.9):

This is pdfTeX, Version 3.14159265-2.6-1.40.20 (MiKTeX 2.9.7000 64-bit) (preloaded format=pdflatex 2019.4.18)  19 APR 2019 09:52
entering extended mode
**./trash.tex
(trash.tex
LaTeX2e <2018-12-01>
("C:\Program Files\MiKTeX 2.9\tex/latex/base\article.cls"
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
("C:\Program Files\MiKTeX 2.9\tex/latex/base\size10.clo"
File: size10.clo 2018/09/03 v1.4i Standard LaTeX file (size option)
)
\c@part=\count80
\c@section=\count81
\c@subsection=\count82
\c@subsubsection=\count83
\c@paragraph=\count84
\c@subparagraph=\count85
\c@figure=\count86
\c@table=\count87
\abovecaptionskip=\skip41
\belowcaptionskip=\skip42
\bibindent=\dimen102
)
(C:/PROGRA~1/R/R-35~1.3/share/texmf/tex/latex\Sweave.sty
Package: Sweave 

("C:\Program Files\MiKTeX 2.9\tex/latex/base\ifthen.sty"
Package: ifthen 2014/09/29 v1.1c Standard LaTeX ifthen package (DPC)
)
("C:\Program Files\MiKTeX 2.9\tex/latex/graphics\graphicx.sty"
Package: graphicx 2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)

("C:\Program Files\MiKTeX 2.9\tex/latex/graphics\keyval.sty"
Package: keyval 2014/10/28 v1.15 key=value parser (DPC)
\KV@toks@=\toks14
)
("C:\Program Files\MiKTeX 2.9\tex/latex/graphics\graphics.sty"
Package: graphics 2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)

("C:\Program Files\MiKTeX 2.9\tex/latex/graphics\trig.sty"
Package: trig 2016/01/03 v1.10 sin cos tan (DPC)
)
("C:\Program Files\MiKTeX 2.9\tex/latex/graphics-cfg\graphics.cfg"
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
)
Package graphics Info: Driver file: pdftex.def on input line 99.

("C:\Program Files\MiKTeX 2.9\tex/latex/graphics-def\pdftex.def"
File: pdftex.def 2018/01/08 v1.0l Graphics/color driver for pdftex
))
\Gin@req@height=\dimen103
\Gin@req@width=\dimen104
)

我正在学习如何在错误开始的时候将我的一些代码块中的工作从rmarkdown转换为sweave,所以我只是希望在问题得到修复时获得一个普通的PDF说“hello world”。特别令人费解的是,在我运行一个简单的程序之前,sweave正在创建PDF文件,从那以后它一直都是下坡的。

提前感谢您的任何意见,建议或帮助!

latex rstudio pdflatex sweave
1个回答
1
投票

我也发生了(退出代码1)。稍后,在下载或加载MikTeX后,只需转到MikTeX控制台=>设置=>常规=>您可以选择是否即时安装丢失的软件包:选择始终安装丢失的软件包。参考https://yihui.name/en/2018/03/miktex-auto-install/


0
投票

如果有人正在阅读,我想出了(至少现在)一种获取PDF文件的方法。虽然我已经卸载并重新安装了Miktex和rstudio两次,但是我找到了一个链接,提到尝试在桌面上安装miktek并将更新包的设置变为自动。对我有用的解决方案的链接是here

© www.soinside.com 2019 - 2024. All rights reserved.