[Tex/LaTex] Setting up forward search between Emacs+AUCTeX and Evince

auctexemacsevinceforward-inverse-searchlinux

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?

Best Answer

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.