Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use emacs auctex to write latex files. Since the text is pretty long, and I tend to change things in different places, I would like emacs to open the pdf so that the position in the text is shown that the cursor is at in the source file.

I have seen this on a windows machine with MikTex/Texniccenter/Acroreader. Is it possible to do this on Ubuntu in emacs/auctex/evince?

share|improve this question
up vote 2 down vote accepted

To do this you need add the following lines to your .emacs file so that when you view the pdf using evince it will tell evince the page number:

(setq TeX-view-program-list '(("Evince" "evince --page-index=%(outpage) %o")))
(setq TeX-view-program-selection '((output-pdf "Evince")))

Then once you've opened your tex file in emacs you need to turn on source correlation using the command:

C-c C-t C-s

Or if you don't want to start it manually every time then add the following line to your .emacs:

(add-hook 'LaTeX-mode-hook 'TeX-source-correlate-mode)

Also, if you want to prevent emacs from promting you if you want to start a correlation server then add the following line:

(setq TeX-source-correlate-start-server t)

And that should be it.

Edit: actually, it turns out that you shouldn't use the package pdfsync, so I've removed all reference to it. It isn't needed for this solution (apparently it's now built into all TeX-based engines) and using it actually seems to cause problems (for me it seems to break code using tables).

Edit 2: I was having problems with auto-enabling TeX-source-correlate-mode using .emacs, but now they seem to have gone. Not sure if that's because I updated emacs or because I removed pdfsync. Anyway, that works now :)

share|improve this answer
@dbddkmezz How to I open the pdf from Emacs then? C-c C-v doesn't do it. – dustin Apr 9 '13 at 20:33
@dustin C-c C-v works for me. Maybe you need to set up your pdf viewer a bit? – xuhdev Dec 17 '15 at 4:47

I used the description given at (the last section: Synctex and Evince), worked like a charm... with this you get two way syncing (e.g. hit C-c C-v in emacs to go the pdf page or hit C-mouse1 in evince to go to correct spot in emacs). Overall it's similar to the first answer, but you don't need to include pdfsync by hand and emacs and evince use dbus to communicate. You do have to do C-c C-t C-s too though.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .