[TxMt] RE: Sweave & Find Texniscope source

Alan Schussman alan at schussman.com
Tue Jul 4 15:13:49 UTC 2006


On Jul 4, 2006, at 6:55 AM, Charilaos Skiadas wrote:

> On Jul 4, 2006, at 1:44 AM, Allan Odgaard wrote:
>
>> On 4/7/2006, at 8:22, xolela at mac.com wrote:
>>
>>> [...] Is it possible for the TeXniscope sync to go to the  Sweave  
>>> (snw) source  file rather than the tex equivalent  in this case?
>>
>> One idea which springs to mind is to let TeXniscope call a script  
>> rather than call mate directly. This script would map the filename  
>> to the actual source and possibly also ensure that the line number  
>> is adjusted if there is a discrepancy.
>
> TeXniscope uses pdfsync to find out where to take you, and i am  
> guessing pdfsync links back to the tex file, not the sweave file.  
> So one would need some script that, seeing the tex file, knows that  
> it has come from a sweave file and knows how to find a location in  
> the sweave file given a location in the tex file. I know nothing  
> about sweave, but given such a sweave<->tex sync script the rest  
> can be done.

This sounds maybe doable, though tricky. I'm somewhat not encouraged  
by this text on the pdfsync page:

     "The most important problem is the support for multiple input  
files, which is not detailled here. However, people will appreciate  
the difficulties to design and implement the pdfsync feature."

I appreciate those difficulties after taking a quick look at one of  
my Sweave projects:

diss.tex includes a separate file for each chapter, some of which are  
generated by Sweave. If I understand pdfsync correctly, it manages to  
identify all those files and then locate a line number according to  
mappings of coordinates in the PDF. It must do a little magic to  
concatenate the included input files and then find line numbers --  
have I got that right? The problem is that the line number is likely  
to be erroneous in the case of Sweave, because the Snw files can have  
a great number of extra lines.

One possibility might be to take the pdfsync line, find some text  
that corresponds to that line number, and then find the line that  
corresponds to some match of that text in the sweave file(s). There's  
any number of things that would prevent that from working (the line  
corresponds to a table that's generated by sweave code, for example).  
I'll think about this some more. It would be a neat problem to solve.

-Alan




More information about the textmate mailing list