[Rd] Working with Sweave: inverse search?

Duncan Murdoch murdoch at stats.uwo.ca
Sun Jan 14 19:54:20 CET 2007

On 1/13/2007 3:58 PM, Duncan Murdoch wrote:
> The xdvi and yap DVI viewers allow inverse (aka reverse) search:  you 
> click on a location in the output display, and your editor moves to the 
> corresponding location in the input file.  yap at least also allows 
> forward search, where you can have your editor tell it to location where 
> a particular input line is displayed.
> I would like something like this to work in Sweave files.  That is, I 
> write an Sweave file and process it through to a .dvi in the previewer, 
> then I click in a previewer and am taken to the original location in the 
> Sweave file.
> There seem to be two obstacles:  The latex I'm using (from MikTeX) 
> doesn't give any way to indicate the original source file when the .tex 
> comes out of Sweave, and Sweave doesn't keep track of the concordance 
> between input lines and output lines.
> Both of these are fixable, but it looks like a few hours work; has 
> anyone done this already?

I went ahead and wrote a prototype of this.  It works by having Sweave 
output a \special that contains the information necessary to patch the 
.dvi file so it points to the .Rnw rather than .tex source.  There's an 
R function that carries out the patching, after you run latex on the 
document.  Currently the patching runs pretty slowly, but I suspect if I 
rewrite it in C rather than R it would be acceptably fast.

If anyone has any interest in this, please let me know.

Duncan Murdoch

More information about the R-devel mailing list