latex - Synchronise pdf to Rnw in Knitr with texshop -
would know how synctex work pdf rnw in knitr texshop? work rnw pdf. many thanks.
this how worked out. not tried on multiple .rnw files.
in texshop preferences, make sure "sync method" set "synctex (tex ≥ 2010)".
on mac, make directory "~/library/texshop/rscripts" , put r file "patchknitrsynctex.r" downloaded https://github.com/jan-glx/patchknitrsynctex in directory.
create executable file "knitr.engine" including following shell scripts , put in "~/library/texshop/engines/":
#!/bin/bash # export path=$path:/usr/texbin:/usr/local/bin # on path! rscript -e "library(knitr); knit('$1')" latexmk -pdf -pdflatex='pdflatex -shell-escape -synctex=1 -file-line-error' "${1%.*}" rscript -e "source('~/library/texshop/rscripts/patchknitrsynctex.r', echo=false, encoding='utf-8'); patchknitrsynctex('${1%.*}')"
in r, install package "patchdvi".
in .rnw file, add "% !tex ts-program = knitr" on top line of document. inside .rnw document somewhere around top of document add r code chunk
<<setup, include=false>>= patchdvi::useknitr() … #any other knitr global setups @
happy knitting!
Comments
Post a Comment