从RStudio运行pdflatex时出错-自更新以来无法编译pdf [英] Error running pdflatex from RStudio - can't compile pdfs since updating

查看:33
本文介绍了从RStudio运行pdflatex时出错-自更新以来无法编译pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在RStudio中使用knitr制作pdf(使用pdflatex/MiKTeX).我在Windows 10机器上.在我本月(2021年2月)更新R,RStudio和MikTeX之前,这种方法一直很好.我收到一条错误消息,

I am trying to use knitr in RStudio to make a pdf (using pdflatex/MiKTeX). I'm on a Windows 10 machine. This was working fine until I updated R, RStudio, and MikTeX this month (Feb 2021). I'm getting an error that says,

"在testdoc.tex上运行pdflatex.exe ...失败运行C:/Users/myusername/AppData/Local/Programs/MiKTeX/miktex/bin/x64/pdflatex.exe(退出代码-1073740791)时出错.
或者C:/PROGRA~1/MiKTeX/miktex/bin/x64/pdflatex.exe

"Running pdflatex.exe on testdoc.tex...failed Error running C:/Users/myusername/AppData/Local/Programs/MiKTeX/miktex/bin/x64/pdflatex.exe (exit code -1073740791)"
OR C:/PROGRA~1/MiKTeX/miktex/bin/x64/pdflatex.exe

我的文件名为testdoc.Rnw,其中包含:

My file is named testdoc.Rnw and contains:

\documentclass{article}

\begin{document}
some text
\end{document}

  1. 我已经卸载并重新安装了MiKTeX,R和Rstudio尝试用户和管理员.(我的所有版本都是2021年2月19日的最新版本)
  2. 无论我使用用户还是管理员模式,都会发生此问题.
  3. 错误中给出的路径是正确的路径.
  4. 当我键入 Sys.which("pdflatex")时的路径是正确的.
  5. 未创建日志文件.它只是到达尝试运行pdflatex的部分并给出了错误.
  6. 我可以构建和查看使用TeX Studio生成的.tex文件.
  7. 我的MiKTeX控制台已更新.
  8. 我选择了针织衫"在我的选项中,并尝试选中和取消选中大多数复选框.关闭并打开并重新启动.

我不希望改用TinyTeX.我已经尝试了所有我可以在Rstudio中找到的建议以及堆栈溢出帖子.我看过日志文件.我注意到我不是唯一遇到此问题的人,但是其他所有人似乎都有不同的错误编号.请帮忙.

I would prefer not to switch to TinyTeX. I have tried every suggestion I could find in Rstudio and stack overflow posts. I have looked at log files. I notice I'm not the only one with this problem, but everyone else seems to have a different error number. Please help.

这是 sessionInfo()的输出:

R version 4.0.4 (2021-02-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 16299)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
[1] compiler_4.0.4 tools_4.0.4  

对于我的环境变量,"path"(并且我尝试在系统级别更改它们)我尝试了 C:\ PROGRA〜1 \ MiKTeX \ miktex \ bin \ x64 \ C:\ Users \ myusername \ AppData \本地\程序\ MiKTeX \ miktex \ bin \ x64 \ .我还尝试以管理员和用户身份运行.似乎没什么区别.

For my environment variables for "path" (and I have tried changing them at the system level) I have tried C:\PROGRA~1\MiKTeX\miktex\bin\x64\ and C:\Users\myusername\AppData\Local\Programs\MiKTeX\miktex\bin\x64\. I also tried running as both administrator and as my user. It seems to make no difference.

我只是基于一条评论注意到, Sys.which("pdftex") Sys.which("pdflatex")都返回相同的内容而且我不知道这是否重要.

I did just notice based on a comment that Sys.which("pdftex") and Sys.which("pdflatex") both return the same thing and I don't know if it matters.

我可以在texstudio或命令行中使用tex文件创建pdf.这是在命令行中运行它的输出:

I can create a pdf using the tex file either in texstudio or in the command line. Here is the output from running it in the command line:

This is pdfTeX, Version 3.141592653-2.6-1.40.22 (MiKTeX 21.2)
entering extended mode
(testdoc.tex
LaTeX2e <2020-10-01> patch level 4
L3 programming layer <2021-02-18> xparse <2020-03-03>
(C:\Program Files\MiKTeX\tex/latex/base\article.cls
Document Class: article 2020/04/10 v1.4m Standard LaTeX document class
(C:\Program Files\MiKTeX\tex/latex/base\size10.clo))
(C:\Program Files\MiKTeX\tex/latex/graphics\graphicx.sty
(C:\Program Files\MiKTeX\tex/latex/graphics\keyval.sty)
(C:\Program Files\MiKTeX\tex/latex/graphics\graphics.sty
(C:\Program Files\MiKTeX\tex/latex/graphics\trig.sty)
(C:\Program Files\MiKTeX\tex/latex/graphics-cfg\graphics.cfg)
(C:\Program Files\MiKTeX\tex/latex/graphics-def\pdftex.def)))
(C:\Program Files\MiKTeX\tex/latex/graphics\color.sty
(C:\Program Files\MiKTeX\tex/latex/graphics-cfg\color.cfg))
(C:\Users\myusername\AppData\Roaming\MiKTeX\tex/latex/framed\framed.sty)
(C:\Program Files\MiKTeX\tex/latex/base\alltt.sty)
(C:\Users\myusername\AppData\Roaming\MiKTeX\tex/latex/upquote\upquote.sty)
(C:\Program Files\MiKTeX\tex/latex/l3backend\l3backend-pdftex.def)
No file testdoc.aux.
(C:\Program Files\MiKTeX\tex/context/base/mkii\supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (C:\Program Files\MiKTeX\tex/latex/epstopdf-pkg\epstopdf-base.sty) [1{C:/User
s/myusername/AppData/Local/MiKTeX/pdftex/config/pdftex.map}] (testdoc.aux) )<C:/Pro
gram Files/MiKTeX/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on testdoc.pdf (1 page, 12954 bytes).
Transcript written on testdoc.log.

到目前为止,根据您的输入,

推荐答案

好吧,我想您正在目睹这种问题"的变化.​​乳胶错误:找不到"Sweave.sty"吗?.
因此,我的第一个尝试是让MiKTeX通过
知道其他 texmf 文件夹,即 R_HOME/share/texmf 其管理控制台:设置->目录[Tab]点击 + 符号并在其中添加该路径(如链接答案中所提到的,该路径不比 texmf 更远-例如进入 tex文件夹).

Ok based on your input so far I would guess that you are witnessing a variation of this "issue" Latex Error: 'Sweave.sty' not found?.
So my first attempt would be to make MiKTeX aware of that additional texmf folder ie R_HOME/share/texmf via
its Admin Console: Settings -> Directories [Tab] clik the + sign and add that path there (as mentioned in the linked answer do not go further down the path than texmf - eg into tex folder or so from there).

我认为这至少应该给您机会>pdflatex testdoc.tex [终端中的此命令-假设您位于RStudio应该从 testdoc.Rnw 创建的包含 testdoc.tex 的文件夹中和 pdlatex 可以通过您的PATH]找到.

I think this should at least give you the chance to > pdflatex testdoc.tex [this command in Terminal - under the assumption that you are in the folder containing testdoc.tex which RStudio should have created from testdoc.Rnw and pdlatex can be found via your PATH].

就剩下的事情而言(例如,使RStudio在不使用tinytex的情况下正确编织一个Sweave .Rnw文档),方法是在RStudio中单击编译PDF"-我确实很强烈,因为您在那里发现了一个错误.我只是不确定是否应该通知哪些维护者(RStudio的维护者或MiKTeX的维护者).可能是更好的主意,即将其发布到RStudio成员的效率更高,因为他们那里有更多资源,如果有,他会与 edocevoli (MiKTeX维护者)取得联系.

As far as the rest goes (ie making RStudio correctly knit a Sweave .Rnw doc without tinytex) from within RStudio via clicking 'Compile PDF' there - I do have a strong feeling tha you have discovered a bug there. I am just not fully sure which maintainers (the ones at RStudio or the one at MiKTeX) should be informed about it. Probably better idea ie more efficient to post it to the RStudio folks since they have more resources there that will get in touch with edocevoli (MiKTeX maintainer) in case it is on his side.

分别是我正在寻找的骗子... https://tex.stackexchange.com/questions/582041/r-sweave-does-not-compile-to-pdf 相当不满意的临时解决方案,用于降级MiKTeX而不更新软件包(此问题可能是最早的版本:https://tex.stackexchange.com/questions/582041/r-sweave-does-未编译为pdf )

Respectively here is the dupe I was looking for ... https://tex.stackexchange.com/questions/582041/r-sweave-does-not-compile-to-pdf a rather unsatisfying temporary solution to downgrade MiKTeX and not update packages (potentially earliest version of this issue: https://tex.stackexchange.com/questions/582041/r-sweave-does-not-compile-to-pdf)

@Ben Elizabeth Ward -我使用RStudio链接(重新打开了)链接到与"tinytex"相关的先前问题-此处不涉及imo(请参阅:#9019 )

@Ben Elizabeth Ward - I created a ticket with RStudio linking (sort of reopening) to a prior issue connected to 'tinytex' - which is not involved here imo (see: #9019)

这篇关于从RStudio运行pdflatex时出错-自更新以来无法编译pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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