Skip to main content

Emacs, Evince and SyncTeX Magic - Look Ma no Code!

In my previous post I showed how it is possible to better integrate the LaTeX editing in Emacs and viewing the result in the GNOME Evince PDF viewer. With the help of SyncTeX it is easy to control click inside the PDF and let Emacs find the corresponding source for it ("inverse search") or to notify Evince out of Emacs to focus on the currently edited area ("forward search").

AUCTeX Logo

Some ELisp code recklessly stolen from StackExchange was required to do some plumping but I already noticed that it should be possible to integrate things in a much nicer way. And sure enough, Tassilo Horn commented on Mastodon that the Emacs package AUCTeX already includes all of this (and much more).

The AUCTeX manual documents this in the section I/O Correlation. The important part is to enable TeX-source-correlate-mode. For example this can be done from the menu as in the following screenshot:

AUCTEX Options

Once enabled, simply recompile the source with C-c C-c and start the viewer also with C-c C-c. This time it will have enabled SyncTeX and doing a C-c C-v in Emacs will make Evince recenter around the current source. Doing a control click in Evince will tell Emacs to recenter.

And all of this with out of the box software - no extra code involved!

Comments

Comments powered by Disqus