Add TeX path to R Studio - Ubuntu

雨燕双飞 提交于 2019-12-05 12:36:36

If anyone faces the same problem, I opened R Studio and checked the pdflatex installation with

> Sys.which("pdflatex")
pdflatex 
  "" 

Which show that it is in fact empty, so I run the command Sys.getenv("PATH")to check the current PATH:

Sys.getenv("PATH")
[1]   "/usr/local/texlive/2014/bin:/usr/local/texlive/2014/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"

To add my pdflatex Path, I had to find the pdflatex file on my texlive directory, which was /usr/local/texlive/2014/bin/x86_64-linux, then I added this to my current Path:

> Sys.setenv(PATH=paste(Sys.getenv("PATH"),"/usr/local/texlive/2014/bin/x86_64-linux",sep=":"))

And now it works perfectly

EDIT: the solution above works only for the open session and is only temporary, you have to run the code everytime you open a new session. I'm still trying to find a permanent solution

see this page: Customizing Startup, modify this file /usr/lib/R/etc/Rprofile.site, and put your code in this file. It looks like a permanent solution maybe.

===

i saw this file /etc/environment is the same as the output of Sys.getenv("PATH"), so i think that sys.getenv("PATH") reads file /etc/environment.

Therefore the better way is to modify this file /etc/environment adding this code :/usr/local/texlive/2017/bin/x86_64-linux​.

after i did it, i tried source /etc/envronment and restarted Rstudio, but it didn't work.

Finally it makes sense after i restarted my ubuntu system. ^_^

I hope my poor English expression is clear enough.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!