Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to use AUCTeX to write my LaTeX documents. However I'm having issues with performing inverse search from Xdvi to Emacs.

Software Specifications

I currently use Emacs 24.3.1 / AUCTeX-11.87 in Ubuntu 12.04.

  • The Emacs was downloaded and installed from ppa:Cassou and installed using their recommended commands.

  • The AUCTeX-11.87 was downloaded from the AUCTeX website which was then configured (using just ./configure) and installed (using make) inside the ~/.emacs.d folder.

The following AUCTeX environment was set in the init file (~/.emacs).

(add-to-list 'load-path "~/.emacs.d/auctex-11.87")
(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)

(add-hook 'LaTeX-mode-hook 'visual-line-mode)
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)

(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)

;; Inverse DVI Search
(tex-dvi-view-command "xdvi -editor 'emacsclient -a emacs --no-wait +%l %f'")
(setq TeX-source-correlate-method 'source-specials)
;;(setq TeX-source-correlate-method 'SyncTeX)  ;; auctex 10.86  

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

;;(TeX-source-correlate-mode)  
;;(add-to-list 'TeX-command-list '("View" "%V" TeX-run-discard nil t))

;;update the dvi file after each successful compilation
(add-to-list 'TeX-output-view-style 
        '("^dvi$" "." 
          "%(o?)xdvi -watchfile 1 %dS %d"))

Issues

The most important issues that I have are

  • Inspite of the environment specification, the TeX-source-correlate-mode is not automatically enabled when I open a .tex file. I need to enable it every time employing C-c C-t C-s command.

  • The source special is not attached by AUCTeX automatically when I compile the .tex file using Command -> LaTeX option. Because when I open the .dvi ouput using xdvi, it complains to me stating the following Warning No source specials in this DVI file - couldn't do reverse search.

The source specials do get attached to the dvi file if I just perform the following command line option

latex --src-specials main.tex

It will be of help if someone can help me identify the mistake I'm making in trying to create an inverse search from

share|improve this question

2 Answers 2

up vote 2 down vote accepted

It's better to activate TeX-source-correlate-mode setting the option with the same name to non-nil.

Here is a working (for me) .emacs based on your:

(setq tex-dvi-view-command "xdvi -editor 'emacsclient -a emacs --no-wait +%l %f'")
(eval-after-load "tex"
  '(progn
     ;;update the dvi file after each successful compilation
     (add-to-list 'TeX-output-view-style
          '("^dvi$" "."
            "%(o?)xdvi -watchfile 1 %dS %d"))
     (setq TeX-source-correlate-start-server t
       TeX-auto-save t
       TeX-parse-self t
       reftex-plug-into-AUCTeX t
       ;; Activate TeX-source-correlate-mode
       TeX-source-specials-mode t
       ;; Inverse DVI Search
       TeX-source-correlate-method 'source-specials)
     (setq-default TeX-master nil)
     (add-hook 'LaTeX-mode-hook
           (lambda
         (visual-line-mode)
         (flyspell-mode)
         (LaTeX-math-mode)
         (turn-on-reftex)))))
share|improve this answer
    
Although I solved this issue before I saw this comment, your .emacs looks better than mine and for that reason I will accept your answer –  WanderingMind Jul 29 '13 at 2:27

Actually I solved this issue by debugging by init file with the command

emacs --debug-init

Based on debugging I compiled the preview subfolder under AucTeX and also loaded its path. I also made other changes to the .emacs file as follows

(add-to-list 'load-path "~/.emacs.d/auctex-11.87")
(add-to-list 'load-path "~/.emacs.d/auctex-11.87/preview")

(load "auctex.el" nil t t)
(load "preview-latex.el" nil t t)
(setq TeX-auto-save t)
(setq TeX-parse-self t)
(setq-default TeX-master nil)

(add-hook 'LaTeX-mode-hook 'visual-line-mode)
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)

(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)
(setq TeX-source-correlate-method 'source-specials)

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

Further I also ensured that emacs is the default editor for xdvi by adding the the following export command to ~/.bashrc

export XEDITOR="emacsclient --alternate-editor=emacs --no-wait +%l %f"

The AucTeX is now able to do inverse search seamlessly from Xdvi to Emacs.

share|improve this answer

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.