Re: [Rd] Working with Sweave: inverse search?

From: Duncan Murdoch <>
Date: Sun 14 Jan 2007 - 18:54:20 GMT

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 mailing list Received on Mon Jan 15 06:04:22 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 15 Jan 2007 - 16:31:13 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.