在 R 中为 pdflatex 设置 miktex 的路径 [英] Set path to miktex for pdflatex in R

查看:12
本文介绍了在 R 中为 pdflatex 设置 miktex 的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试让 pdflatex 使用正确版本的 miktex,但没有成功.

I have been trying to get pdflatex to use the correct version of miktex and have not been successful.

我已将 R 路径设置为 Miktex 2.9 的正确位置,并验证它是否适用:

I have set the R Path to have the correct location of Miktex 2.9, and verified that it worked with:

Sys.getenv("PATH")
"C:\Program Files\MiKTeX 2.9\miktex\bin\x64\pdflatex;..." 

但是,当我查看 pdflatex 正在使用的 miktex 版本时:

However when i look at the version of miktex that pdflatex is using:

Sys.which("pdflatex")
"C:\PROGRA~1\MIKTEX~1.9\miktex\bin\x64\pdflatex.exe"

这个 1.9 路径指向一个甚至不再存在的旧版本的 miktex.

This 1.9 path is to an old version of miktex that no longer even exists.

在命令提示符下运行 pdflatex 返回正确的路径,所以问题出在 R 中.如何让 R 使用正确的 pdflatex 路径?

Running in the command prompt which pdflatex returns the correct path, so the problem is just in R. How can I get R to use the correct path to pdflatex?

推荐答案

您可以尝试以下几种解决方案:

There are couple solutions you can try:

  1. 在工具 > 全局选项 > Sweave 中禁用启用 shell 转义命令"

根据此answer手动设置路径.每次重新启动 RStudio 时都必须运行它.

Set the path manually per this answer. You will have to run this every time you restart RStudio.

 Sys.setenv(PATH = paste(Sys.getenv("PATH"), "C:/Program Files/MiKTeX 2.9/miktex/bin/x64", sep=.Platform$path.sep))

  • R_HOME/etc文件夹的Renviron.site中加入下面一行,其中R_HOMESys.getenv("R_HOME").参考

  • Put the following line in Renviron.site in the folder R_HOME/etc where R_HOME is the path returned by Sys.getenv("R_HOME"). Ref

     PATH=C:/Program Files/MiKTeX 2.9/miktex/bin/x64:"${PATH}"
    

  • 安装 tinytex 包.请注意,您应该使用 MiKTeX 或 tinytex,但不能同时使用两者.如果您都安装了,易会建议您在这种情况下删除 MiKTeX.参考

  • Install tinytex package. Note that you should use either MiKTeX or tinytex, but not both. If you have both installed, Yihui recommended that you remove MiKTeX in this case. Ref

    您可能需要在每次更改后重新启动 R/RStudio 甚至您的 PC/笔记本电脑,以查看它是否有效

    You might have to restart R/RStudio or even your PC/laptop after each change to see if it works or not

    这篇关于在 R 中为 pdflatex 设置 miktex 的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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