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.

  1. in texshop preferences, make sure "sync method" set "synctex (tex ≥ 2010)".

  2. on mac, make directory "~/library/texshop/rscripts" , put r file "patchknitrsynctex.r" downloaded https://github.com/jan-glx/patchknitrsynctex in directory.

  3. 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%.*}')"

  4. in r, install package "patchdvi".

  5. 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

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -