Sync Emacs AUCTeX with Sumatra PDF

With these lines in my init.el I can synchronize the Emacs LaTeX buffer with Sumatra:

 (setq TeX-source-correlate-mode t) (setq TeX-source-correlate-method 'synctex) (setq TeX-view-program-list '(("Sumatra PDF" ("\"C:/bin86/SumatraPDF/SumatraPDF.exe\" -reuse-instance" (mode-io-correlate " -forward-search %b %n ") " %o")))) (setq TeX-view-program-selection '(((output-dvi style-pstricks) "dvips and start") (output-dvi "Yap") (output-pdf "Sumatra PDF") (output-html "start"))) 

In order to double-click on the PDF to bring me to the corresponding LaTeX code, I also set the Sumatra Set inverse search command line parameters:

 "c:\bin86\GNU Emacs 24.2\bin\emacsclient.exe" --no-wait +%l "%f" 

Despite working with synchronization, Id loves to code it differently.

If I did not set the last expression, (setq TeX-view-program-selection... , I would get the default values ​​that are the same as above, except for the value for the PDF output, which will be: (output-pdf "start") . Id would like to change this to" Sumatra PDF "and leave the other default values, that is, Id would like to ask Emacs the default values ​​for viewers and change only the PDF value.

This is basically an ELisp question regarding the manipulation of the variable TeX-view-program-selection . Thanks for the help.

PS Please tell me if this question is best suited for tex.stackexchange

Update based on comments and answers by lunaryorn

To update TeX-view-program-selection , I could use:

 (assq-delete-all 'output-pdf TeX-view-program-selection) (add-to-list 'TeX-view-program-selection '(output-pdf "Sumatra PDF")) 

The first line is optional, but it makes the list "clean."

In both cases (with or without assq-delete-all ) I now need to paste the code into the correct hook, since TeX-view-program-selection not valid in init.el

+6
source share
5 answers

My loans to the Lunanorns for the offers! I repack the steps associated with the benefits of others.

Emacs Party

Add to your init.el :

 (setq TeX-PDF-mode t) (setq TeX-source-correlate-mode t) (setq TeX-source-correlate-method 'synctex) (setq TeX-view-program-list '(("Sumatra PDF" ("\"path/to/SumatraPDF/SumatraPDF.exe\" -reuse-instance" (mode-io-correlate " -forward-search %b %n ") " %o")))) (eval-after-load 'tex '(progn (assq-delete-all 'output-pdf TeX-view-program-selection) (add-to-list 'TeX-view-program-selection '(output-pdf "Sumatra PDF")))) 

Sumatra side

In the Settings-> Options dialog box, set Set inverse search command line to:

 "path\to\GNU Emacs ver\bin\emacsclient.exe" --no-wait +%l "%f" 

How to use

In your LaTeX document in Emacs, enter Cc Cv or double-click the corresponding PDF in Sumatra and ... enjoy))

+12
source

Use add-to-list instead of setq . See Ch f add-to-list details.

TeX-view-program-selection is defined in tex.el , so you will need to execute this code after loading this library:

 (eval-after-load 'tex '(progn (assq-delete-all 'output-pdf TeX-view-program-selection) (add-to-list 'TeX-view-program-selection '(output-pdf "Sumatra PDF")))) 
+1
source

I was almost insane due to citation conventions for windows -> emacs. If you install SumatraPDF in the default location, then this works on Windows 8.1

 (setq TeX-view-program-list '(("Sumatra PDF" ("\"C:/Program Files (x86)/SumatraPDF/SumatraPDF.exe\" -reuse-instance" (mode-io-correlate " -forward-search %b %n ") " %o"))))) 

To an hour ago I will never come back :)

+1
source

I prepared the batch file Emacs_SumatraPDF.bat .

It works great with sumatra-forward.el to implement forward and reverse searches.

For instance:

Download

http://www.ai.soc.i.kyoto-u.ac.jp/~shi/files/Emacs_SumatraPDF.bat

Http: /william.famille-blum.org/software/sumatra/sumatra-forward.el


Preparation

type Emacs_SumatraPDF.bat and SumatraPDF.exe %Emacs_Home%/bin .

put sumatra-forward.el %Emacs_Home%/site-lisp


Using

 ;Emacs_Home=C:/Program Files (x86)/GNU Emacs 23.4 ;~\.emacs add following information ;;; Emacs_SumatraPDF.bat ;; @info: pdf viewer ; @refer: (setq TeX-view-program-list '( ("Sumatra" "C:/Program Files (x86)/GNU Emacs 23.4/bin/Emacs_SumatraPDF.bat %o %t %n") )) (setq TeX-view-program-selection '( (output-pdf "Sumatra") (output-dvi "Yap") ((output-dvi style-pstricks) "dvips and start") (output-html "start"))) ;;; sumatra-forward.el ;; @info: forward search. ; @refer: http:/william.famille-blum.org/blog/static.php?page=static081010-000413 (require 'sumatra-forward) 

That's all.


Besides,

Emacs 4 Latex support for Windows 7 for beginners for Emacs.

http://chunqishi.imtqy.com/emacs4ls/


0
source

It is worth noting that the Set inverse search command line by default invisible in the Settings->Options dialog box. To show this option field, go to Settings->Advanced options or open SumatraPDF-settings.txt and enable EnableTeXEnhancements = true .

0
source

All Articles