As I have hinted in this post about pdfopen, it is possible to do some sort of round-trip LaTeX editing with the right tools. There are two directions to make the round-trip complete.
The forward jump is editor-to-previewer: given the current cursor location in the editor, jump to the corresponding paragraph in the previewer. The backward jump is symmetrical. The magic behind this is called “source specials”.
While it sounds somewhat like a Chinese dish with special sauces, it really isn’t.
Instead, when you generate the DVI file, you ask latex to tag the DVI file with “source specials”. Imagine each word in the DVI file is tagged with the source filename and the line number of the word.
The forward jump is to ask the previewer to display the location that is right after the editor’s cursor location (filename and line number). The backward jump is to ask the editor to put the cursor closest to the current location in the previewer (usually the location of a double-click).
Let’s get to the example. I will show how to get round-tripping to work in Windows using MiKTeX distribution 2.4 and GNU Emacs. Other configurations are similar.
(Round-tripping between LaTeX and PDF is similar in principle, but the tools are not very mature yet. I will save this for a later post.)
- Install the AUC TeX package into Emacs.
- To enable tagging in
latex, invoke it with the--src-specialsoption. Say the primary LaTeX source ismain.tex, AUC TeX invokes it this way, :
latex --src-specials \nonstopmode\input{main.tex} - To do the forward jump with YAP (the DVI previewer in MiKTeX), say when the cursor is on line 65 of
hetero.tex, AUC TeX will execute:
yap -1 -s65hetero.tex main.dvi - To enable the backward search, install the
gnuservpackage. Google can help you locate many links, like this and the rest. - Assuming you have
gnuclientwinstalled on your path, in YAP, go to View->Options->Inverse Search. Inside Program combo, you should see “GNU Emacs (Single Instance)”. Example command line:
gnuclientw.exe -F +%l "%f" - Note that installing
gnuclientwaddresses the problem in this comment. In general, you rarely want to invokeemacsdirectly. Usegnuclientwinstead.
Have fun!