Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers 2

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
add comment

I used the description given at http://www.emacswiki.org/emacs/AUCTeX (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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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