I want to use knitr with TeXShop. So far I can’t get knitr and TeXShop to talk. I’m not sure how to make a reproducible example nor how to make the following succinct, but here’s what I’ve tried:
Versions, recently updated, are: R 3.4.2, knitr 1.17, TeXShop 3.88. Within RStudio on a Mac with Sierra OS, knitr has worked well recently and often. The manuscript I want to migrate is an .rmd. [Btw, the reason finally to switch is blurred plots as described at https://stackoverflow.com/questions/29568923/geom-raster-comes-out-smeared-when-saving-to-pdf. Preview, which recipients are likely to use, no longer has an option to disable Smooth Text and Line Art: https://discussions.apple.com/thread/7681819?start=0&tstart=0. I use TeXShop rather than, for example, LyX, is that my work group does.]
Per https://yihui.name/knitr/demo/editors/, I created Knitr.engine. In TeXShop, knitr now appears as an option in Programs.
Per https://iangow.wordpress.com/2014/04/04/using-knitr-with-texshop/, I made Knitr.engine executable with chmod +x ~/Library/TeXShop/Engines/Knitr.engine. Rebooted afterward for good measure.
Following https://stackoverflow.com/questions/14617041/how-can-i-see-the-current-value-of-my-path-variable-on-os-x, included in the returned string for echo $PATH is /Library/TeX/texbin. Since understanding this part is a bit beyond my skill level, here’s the full response: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/TeX/texbin
A year ago TeXShop worked fine for a long document not connected to r. To check again, I copied https://github.com/yihui/knitr-examples/blob/master/005-latex.Rtex to TeXShop then Typeset with Program = LaTeX. Obviously except the r part, it rendered nicely. In case this is a clue, in place of r snippets like “…x is \rinline{x[1]}. And…” the .pdf has a polite “…x is SOMETHING WRONG WITH knitr. And…”
Using the same example file, I changed the TeXShop Program to knitr then tried Typeset. The console screen is blank and no .pdf is returned.
Potentially related questions: Comments on the unanswered https://stackoverflow.com/questions/33570145/texshop-and-knitr didn’t get me un-stuck. I don’t understand https://stackoverflow.com/questions/22901174/synchronise-pdf-to-rnw-in-knitr-with-texshop beyond step 1 enough to know if it should help. The versioning issue described at https://stackoverflow.com/questions/27915263/knitr-in-texshop-uses-late-r-version doesn’t apply; The version shown in my R.framework is 3.4.
Thank you very much for any ideas.
.engine
file in the link in 2 still uses/usr/texbin
to set the path. Did you change this to/Library/TeX/texbin
?knitr
library in R and (ii) adjusted the path in theknitr.engine
to be/Library/TeX/texbin
). Try running this file instead: github.com/yihui/knitr/blob/master/inst/examples/…shell-escape
for compilation. Theknitr.engine
linked in point 2 works fine once the path is corrected.