Sublime Forum

Problems in setting up knitr support in LaTeXing

#1

Hi there,

I want to use LaTeXing in combination with the R package knitr.
I studied the LaTeXing documentation thoroughly but I still have two problems:

  1. The LaTeXing check does not find Rscript. But what is Rscript exactly? It seems to look for a Rscript.exe somewhere, but such a file does not seem to exist. It is not the R executable, apparently.
  2. It is unclear to me how to activate knitr support in the latexing user settings. I copied the whole Latexing settings - default into Latexing user settings - user (as ‘default’ is not editable). Then: on the latexing documentation release 0.9.10 I read on page 42 that I simply have to insert

“knitr”: true

but on http://docs.latexing.com/stable/settings.html I read that there is a second line and that ‘false’ apparently must not be converted into ‘true’:

“knitr”: false,
“knitr_command”: “Rscript -e “library(knitr); knit(’{file}’)””

I am on Windows.
I am quite confused. If anybody has even just a piece of advice I would be very grateful!

0 Likes

#2

I solved the problems with the help of some friends, I’ll post the solutions here in case they are useful for somebody else in the future:

  1. Rscript.exe is indeed one of the many executable of R, usually found like R.exe in the folder \bin. You must tell Windows where to find it (or tell LaTeX where to find it with an absolute path, though the latter is a weaker solution).
  2. The best approach is to a) ONLY copy into the “user settings - user” the lines that you wish to modify (in this case: ‘“knitr”: false’), so NOT the whole “user settings - default”; b) modify them - in this case, change “false” to “true”; c) enclose the whole file in curly braces (very important point!). The second line was, in my case, not necessary - though I suspect it might be because I did not use, as the LaTeXing documentations suggested, R-Box to send R code chunks to R for evaluation, but simply SublimeREPL (by modifying its “additional_scopes”: [“tex.latex.knitr.ing”], as described here). It MIGHT have been needed if you want to use R-box.
0 Likes