[R] Sweave, Texshop, and sync with included Rnw file

Duncan Murdoch murdoch.duncan at gmail.com
Fri Jan 11 11:38:25 CET 2013


On 13-01-10 4:54 PM, michele caseposta wrote:
> Hi everybody,
> thanks for the replies.
> I might have not explained the problem completely.
> Duncan Mackay:
> Yes, I am already having a master file and separate Rnw files.
> Duncan Murdock:
> I am using patchDVI in the TexShop Sweave engine.
> Sync works flawlessly between the master file and the pdf produced by pdflatex.
>
> My problem is that I don't seem to be able to obtain sync between the *included* Rnws and the pdf, either way.
>
> The sweave engine is as follows:
>
> #!/bin/bash
>
> R CMD Sweave "$1"
> latexmk -pdf -silent -pdflatex=‘pdflatex –shell-escape –synctex=1′"${1%.*}"
> Rscript -e "library(‘patchDVI’);patchSynctex(‘${1%.*}.synctex.gz’)"
>
>
> Funny thing is that the sync works in texworks, using the following Rscript line
>
> patchDVI::SweavePDF('$fullname',stylepath=FALSE)
>
> I tried to mix and match configurations between texshop and texworks but I had no luck

I just tried a simple example in TeXShop and it worked for me.  My 
Sweave engine is

#!/bin/tcsh

# set path= ($path /usr/local/bin)
Rscript -e "patchDVI::SweavePDF(  '$1' )"


So it seems to be work listing versions:  On the Mac, I'm using R 2.15.0 
patched, rev 59478, with patchDVI version 1.8.1584 (I just uploaded 1.9 
to CRAN, by the way), TeXShop version 2.43.

It also works on Windows, where I have current releases of R and 
patchDVI installed.

If you've got current versions of everything installed and it's still 
not working, could you try putting together a small reproducible example?

Duncan Murdoch

>
>
>
>
>
>
> On Jan 10, 2013, at 11:23 AM, Duncan Murdoch wrote:
>
>> On 13-01-09 9:09 PM, Duncan Murdoch wrote:
>>> On 13-01-09 3:25 PM, michele caseposta wrote:
>>>> Hello everyone.
>>>> I am in the process of writing a book in Latex with Texshop, on Mac.
>>>> This book contains a lot of R code, hence the need to use Sweave.
>>>> I was able to compile Rnw files, and to sync back and forth from the pdf to the source Rnw.
>>>> My problem now is that the book is divided in Chapters, and every chapter is in its own Rnw file.
>>>> I can compile them from the main one (book.Rnw) using the directive
>>>>
>>>> \SweaveInput{chapter1.Rnw}
>>>>
>>>> The problem stands in the fact that like this I am missing synchronization between the pdf and the source Rnw. If part of text is in book.Rnw I can synchronize, but if the text is in one of the included files, it just doesn't work.
>>>> I am using the sweave engine found in the following webpage:
>>>>
>>>> http://cameron.bracken.bz/synctex-with-sweavepgfsweave-in-texshoptexworks
>>>>
>>>> Has anybody succeeded in synchronizing with included Rnw files?
>>>
>>> This is a problem addressed by my patchDVI package, available on
>>> R-forge.  You have a main file (which can be .tex or .Rnw), and put code
>>> at the start of each .Rnw file to indicate where to find it.  Then you
>>> just run Sweave on one of the chapters, and it automatically produces
>>> the full document.
>>>
>>> The sample document here:
>>>
>>> http://www.umanitoba.ca/statistics/seminars/2011/3/4/duncan-murdoch-using-sweave-R/
>>>
>>> includes an appendix describing how to set this up with TeXShop.
>>
>> I just committed an update to the vignette in patchDVI giving a quick version of the instructions for basic use. Version 1.8.1585 has the new vignette.
>>
>> I should get around to pushing it to CRAN one of these days...
>>
>> Duncan Murdoch
>>
>
>




More information about the R-help mailing list