auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX] Inverse search for dvi


From: linuxfever
Subject: [AUCTeX] Inverse search for dvi
Date: Tue, 25 Oct 2011 15:00:40 -0700 (PDT)

Hello all,

I had been having problems when trying to perform inverse-search on dvi
files. After a long search I found a solution to the problem, so I thought
to post it here in case it may help someone else too.

In my understanding, it seems that there are (currently) two options
supported in Auctex for correlating the source tex file and the output file.
If the output file is a DVI file, then latex needs to be run with the
"-src-specials" flag in order to enable inverse-search. On the other hand,
if the output file is a PDF file, then the "synctex" option is used by
Auctex.

Now, when you activate the correlation mode (TeX-source-correlate-mode, C-c
C-t C-s), Auctex needs to find out what type of output it will produce, so
that it can choose between "source-specials" or "synctex". I had a look at
the tex.el file and it seems (at least to me), that the function that
determines this choice is the following:

(defun TeX-source-correlate-determine-method ()
  "Determine which method is available for forward and inverse search."
  (let ((help (condition-case nil
                  (with-output-to-string
                    (call-process LaTeX-command
                                  nil (list standard-output nil) nil "--help"))
                (error ""))))
    (if (string-match "^[ ]*-synctex" help)
        'synctex
      'source-specials)))

which essentially, runs a shell command "latex --help" and if the resulting
string contains the word "synctex", then it assumes that "synctex" is what
it should choose. The problem is that the command "latex --help" outputs
(among other things):

-synctex=NUMBER         generate SyncTeX data for previewers if nonzero

and therefore Auctex always chooses "synctex" instead of "source-specials"
no matter the type of output file you wish to produce.

Therefore, if you wish to produce a DVI document, inverse search will not
work unless you manually set the variable "TeX-source-correlate-method" to
"src-specials" (instead of "auto" which is the default).

After a bit of digging, I found a way to get the job done by setting the
variable "TeX-source-correlate-method-active". This variable holds the
current correlation mode and can take either "nil", "source-specials" or
"synctex".

So, I finally edited the "TeX-PDF-mode" function, so that everytime it is
invoked (i.e. changing from DVI output to PDF output), it also sets the
"TeX-source-correlate-method-active" to the appropriate value:

(define-minor-mode TeX-PDF-mode
  "Minor mode for using PDFTeX.

If enabled, PDFTeX will be used as an executable by default.
You can customize an initial value, and you can use the
function `TeX-global-PDF-mode' for toggling this value."
  :group 'TeX-command
  (when (eq TeX-engine 'omega)
    (setq TeX-PDF-mode nil))
  (setq TeX-PDF-mode-parsed nil)
  (TeX-set-mode-name nil nil t)
  (setq TeX-output-extension
        (if TeX-PDF-mode "pdf" "dvi"))
  (setq TeX-source-correlate-method-active
        (if TeX-PDF-mode 'synctex 'source-specials)))

Now, you just need to byte-compile the file, put both tex.el and tex.elc in
your auctex installation directory and things should work.

-- 
View this message in context: 
http://old.nabble.com/Inverse-search-for-dvi-tp32720326p32720326.html
Sent from the Gnu - AUCTeX - General mailing list archive at Nabble.com.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]