michele caseposta
2013-Jan-09 20:25 UTC
[R] Sweave, Texshop, and sync with included Rnw file
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? Thanks, Mic
I believe RStudio has done a fairly good job in terms of the synchronization. If you have to stick to TeXShop, I do not have any ideas on how to make it work with Sweave child documents. Regards, Yihui -- Yihui Xie <xieyihui at gmail.com> Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA On Wed, Jan 9, 2013 at 2:25 PM, michele caseposta <mic.cipi at gmail.com> 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? > > Thanks, > Mic
Hi Perhaps you need to make a master file and call the chapter files from it eg (just copying the relevant section from my master GClimate12.Rnw file) latex preliminaries + R options + begin % plots \SweaveInput{GClimate12RX.Rnw} % Soil 300 % 15 \SweaveInput{GClimate12SP.Rnw} % proportions % 16 \SweaveInput{GClimate12RS.Rnw} % cumsum days % 17 \SweaveInput{GClimate12RC.Rnw} closing commands etc end document This means that you require 1 setup page rather than individual ones and the benefits attached for TOC etc Regards Duncan Duncan Mackay Department of Agronomy and Soil Science University of New England Armidale NSW 2351 Email: home: mackay at northnet.com.au At 06:25 10/01/2013, you 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? > >Thanks, >Mic >______________________________________________ >R-help at r-project.org mailing list >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.
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. Duncan Murdoch