# Setting up forward search between Emacs+AUCTeX and Evince

Did anyone succeed setting up forward search between Emacs+AUCTeX and evince?

In order to establish inverse/forward search between Emacs+AUCTeX and evince, it is necessary to:

• install new TeX Live version, as explained in here;
• add special lisp script to .emacs file, (the script depends of gnome version and it can be found here).

However, since release of TeX Live 2011, there is a problem of a new synctex format, as it is pointed by Richard Hansen.

I've noticed that Emacs+AUCTeX invokes pdflatex compilation as (taken from latex output file):

``````pdflatex --shell-escape --synctex=1 -interaction=nonstopmode "\input" file.tex
``````

If I do the same compilation manually, using absolute path, i.e.

``````pdflatex --shell-escape --synctex=1 -interaction=nonstopmode "\input" /absolute/path/to/file.tex
``````

forward search is working properly!

So the question is:

are there any ways to force Emacs/AUCTeX to use absolute path name (as in the second pattern) while running pdflatex compilation?

-

## 2 Answers

You can tell auctex use absolute path by changing the LaTeX command. First, you need an updated version of auctex, as Richard Hansen points out. I've installed the CVS version, but I think it should be enough updating `tex.el(c)`.

Then, go to the "Customize AUCTex" menu:

LaTeX → Customize AUCTeX → Extend this Menu

LaTeX → Customize AUCTeX → TeX Command → TeX expand list

and add a new item:

Key: `%(dir)`
Expander: `(lambda nil default-directory)`

and save for future sessions (if you wish)

Now, go to "TeX command list" (LaTeX → Customize AUCTeX → TeX Command → TeX command list) and edit the "LaTeX" item:

Command: `%`%l%(mode)%' %(dir)%t`

save and, you got it!

This way works fine for me, in Ubuntu 11.10, auctex from CVS (2012-01-11), evince 3.2.1, TeX Live 2011 and emacs 23.3.

-
This is a proper answer to my question, everything works perfect now. If I could I would vote up this answer. Greetings and thank you for help. – przemq Apr 2 '12 at 11:56
@przemq You can accept the answer (by clicking the checkmark just to the left). – Torbjørn T. Apr 2 '12 at 12:21

Apparently TeX Live 2011 changed the format of the synctex file, and AUCTeX had to be changed accordingly: email discussion, commit email with link to patch.

Note that it still doesn't work if there are symlinks involved.

-
Thanks for replay. I have tried the tex.el script with patch added (taken from cvs) and it still doesn't work. – przemq Mar 20 '12 at 10:28
@przemq: You may also need these additional patches: support Evince 3.x, bug fix for one-page documents. Even better would be to check out CVS trunk and use that. – Richard Hansen Mar 20 '12 at 15:31
Have you got forward search working properly? I've installed AUCTeX completely form cvs, and the problem remains (inverse search is working all right, by the way). I've checked *synctex.gz archive (as it is mentioned in the seventh post) and there is still a dot in the path. After manual removing the dot from the path, forward search starts to work. – przemq Mar 23 '12 at 12:06