2

I have recently upgraded to El Capitan and I can't make knitr work with texmaker anymore. I have red all the issue concerning MacTex and the change in the path from /usr to /Library/Tex but here I can't figure out what is happening.

I have set up a knitr command : Rscript -e "knitr::knit2pdf('%.Rnw')" but texmaker refuses to run it. When I copy and paste the error message into the terminal it works fine so there is no typo error. I don't understand what's going on!

  • 2
    @noname Not a Mac user, but do run knitr with texmaker in Windows. Suggestion. verify that you can run that specific command Rscript -e "knitr::knit2pdf('%.Rnw')" with the replacement of the % with an existing (in the current folder) Rnw file. If you cannot run it from a command shell, then the problem is one of paths in the operating system. – R. Schumacher Nov 23 '15 at 5:24
  • Thanks for the comment it makes me look onto Rscript localisation, and then finally fix the bug ! I add the anwser below – clemlaflemme Nov 23 '15 at 12:06
1

The solution is to specify the full path to the Rscript command and to modify the .Rprofile file as well to add latex to your R session:

  • in texmaker I have now /Library/Frameworks/R.framework/Resources/Rscript -e "knitr::knit2pdf('%.Rnw')" (this is default location on Mac, but you can get yours by typing R.home() in a R session)
  • in my .Rprofile I used the solution from this SO post, ie I write Sys.setenv("PATH" = paste(Sys.getenv("PATH"),"/Library/TeX/texbin",sep=":")) (the .Rprofile is a hidden file on /Users/my_user_name directory`)

Hope this can help !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.