[TxMt] RE: Sweave & Find Texniscope source
Charilaos Skiadas
cskiadas at uchicago.edu
Tue Jul 4 15:57:11 UTC 2006
On Jul 4, 2006, at 10:13 AM, Alan Schussman wrote:
> 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.
Actually the way I understood it to work was that pdfsync adds
information into the pdf file, describing at each area in the file
what line in the .pdfsync file it corresponds to. So the pdf viewer,
when asked to sync back to the tex file, looks into that .pdfsync
file to find where it should go.
And of course when creating the pdfsync file, we are still at the
latex compiling stage, so it is easy to determine what file things
come from, and hence if you look at a pdfsync file you see different
sections, one for each of the different files that were \include'd in
the master. I believe this does not work with \input'ed files.
To be more precise, the .pdfsync file contains pairs of latex code
line numbers and corresponding pdf locations for them.
So effectively the best way around it would be if we could somehow
provide pdfsync with the appropriate information. Problem is of
course that pdfsync only sees the latex files generated by sweave,
not the sweave code.
> 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.
This has a better chance to succeed, though it will probably not be
perfect (same things appearing in multiple places can't be
distinguished easily).
Actually the best thing would be this:
Create a mapping between sweave-code lines and latex-code lines, just
like pdfsync is a mapping between latex-code lines and pdf-code lines.
Then you could run a post processor that takes this file and alters
the corresponding sections of the .pdfsync file, to make then link
back to the sweave files instead of the tex files. pdfsync doesn't
really care (at least I don't think it does) what files you link to,
as long as their name appears in there. So it would be just a
question of changing the line numbers and name of files linked to in
the .pdfsync file, probably doable with a little trial and error.
Btw, here is some information on the pdfsync format, so that you can
find what each number means:
http://itexmac.sourceforge.net/pdfsync.html
> -Alan
Haris
More information about the textmate
mailing list