Is there any way I can alter the line-numbers reported by TeX and friends in error messages?

This is almost an identical question to Add offset to line number (in error message) when using input files, but the solution there (that LaTeX already treats \input properly) is not helpful for my problem.

I am programmatically generating (using a custom python version of Sweave) .tex files from a different .Plw source file that inserts generated figures, source code etc. As a result, when LaTeX complains, it refers to lines numbers in the generated .tex file rather then the .Plw file that I am editing. Is there anyway I can insert something into the generated .tex file to instruct TeX that the line x in .tex is actually line y in the .Plw file?

The specific problem is simply a matter of offsets: each time a figure, or source code listing is inserted into the file, the current offset changes – it can go up or down – but all the other lines are copied verbatim with the same wrapping etc. as in the original .Plw file.


Your understanding is absolutely correct (it is a matter of offsets). Sweave has the option concordance=TRUE/FALSE to control whether to write a "concordance file" which contains the offset information. However, the error navigation has never really been done in the past 10(?) years.

Recently RStudio tackled this problem and implemented both error navigation and PDF <--> Rnw synchronization based on this concordance information. You can download the preview version to test it out.

Also FYI, I wrote an R package named knitr which is an alternative to Sweave. I looked at Pweave and it seems some of its features are also in knitr. RStudio also supports knitr, which means error navigation also works with knitr.

  • Writing a concordance file is a good idea so that external tools can do the translation (and might work for me as I ultimately use emacs, which I can probably train to use the concordance information). I would still like to know if there is some way to coax TeX to use this information, so I will leave this question unanswered for a while. – mforbes Apr 13 '12 at 2:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.