如何在R中设置用于编织的乳胶路径? [英] How can I set the latex path for sweave in R?

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

问题描述

我想知道如何在R中设置pdflatex路径以使用sweave.因为我有2种不同的MikTeX安装,并且其中一种工作正常.请考虑到我正在使用Windows中的R(RStudio).但是,我发现了一些针对Linux或Unix用户的建议.

I would like to know how I can set the pdflatex path in R to use sweave. Because I have 2 different MikTeX installations and one is working properly. Please take into account that I am using R (RStudio) in Windows. I found some suggestion however, for Linux or Unix users.

提前感谢

推荐答案

如果您安装了多个LaTeX(即MikTeX),并且要使用其中的特定安装,则需要确保R找到了其中一个您需要首先.这意味着您必须在PATH系统环境变量的前面添加首选版本的pdfLaTeX的位置.

If you have multiple installs of LaTeX (i.e. MikTeX) and you want to use a specific one of these, then you need to make sure that R finds the one you need first. This means that you have to add the location of your preferred version of pdfLaTeX at the front of your PATH system environment variable.

如果您在Windows中没有管理员权限,则可以使用R的环境文件来仅更改R的PATH变量.有关此过程的详细信息,请参见R中的?Startup.请执行以下步骤:

If you do not have administrator rights in Windows, then you can use R's environment file to change the PATH variable for R only. See ?Startup in R for details on this process. Follow the following steps:

    在R中的
  1. 中,检查Sys.getenv("R_ENVIRON")的输出.这会将完整路径返回到现有环境文件,但是在大多数情况下将为空.如果存在文件,请跳至下面的第3步.
  2. 如果在步骤1中未返回任何路径,请在文件夹 R_HOME/etc 中创建文件 Renviron.site ,其中 R_HOME 是路径由Sys.getenv("R_HOME")返回.
  3. 在环境文件中添加一行,如下所示:PATH=C:\\full\\path\\to\\the\\folder\\with\\pdflatex;"${PATH}"(引号很重要)
  4. 重新启动R并检查Sys.getenv("PATH"),然后Sys.which("pdflatex")返回正确的路径.
  1. in R, check the output of Sys.getenv("R_ENVIRON"). This will return the full path to an existing environment file, but will be empty in most cases. If a file exists, skip to step 3 below.
  2. if no path is returned in step 1, create a file Renviron.site in the folder R_HOME/etc where R_HOME is the path returned by `Sys.getenv("R_HOME").
  3. add a line to the environment file as follows: PATH=C:\\full\\path\\to\\the\\folder\\with\\pdflatex;"${PATH}" (the quotations marks are important)
  4. restart R and check Sys.getenv("PATH") and Sys.which("pdflatex") returns the correct paths.

如果您无权在 R_HOME \ etc 中创建 Renviron.site 文件,则还可以创建 .Renviron HOME (Sys.getenv("HOME"))中的文件.

If you do not have rights to create a Renviron.site file in R_HOME\etc, then you can also create a .Renviron file in HOME (Sys.getenv("HOME")).

这篇关于如何在R中设置用于编织的乳胶路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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