These are the steps I followed to work with Emacs on Windows and be able to code LaTeX, view the resulting PDFs and use reverse search, that is, clicking on the PDF and telling emacs to move to the right point in the text.
Step 1: Install Emacs, AucTeX and SumatraPDF
This is not painless, but it is ok for anybody familiar with computers.
- SumatraPDF can be downloaded from its web page, It has a simple installer. The appearance may be simplistic, but it is very lean and I recommend it for Windows and tablets in particular.
- Emacs 24.5 or later can be downloaded from the GNU page, but I personally use the 64-bit optimized recompilation.
- AucTeX is Emacs' best plug-in for working with TeX and LaTeX files. You can download a precompiled version that matches your emacs version from their web page. Make sure you unpack it in the right place.
Step 2: Configure SumatraPDF
Open SumatraPDF and click on the top-left corner menu you have to make two changes:
- Select "Settings" and "Advanced Options" and ensure that there is a line saying
EnableTeXEnhancements = true
- Select "Settings" and then "Options" and enter the following text
"C:\Program Files\emacs\bin\emacsclientw.exe" -n +%l "%f"
Make sure the path
corresponds to the folder where you unzipped your emacs installation.
Step 3: Configure Emacs
This is the way I configure my Emacs.
- Before opening Emacs, define an environment variable "HOME" to point to your user directory. This can be done in the Control Panel > System and Security > System > Advanced System Settings > Advanced tab.
- Go to the folder where you unzipped the Emacs distribution. In the "bin" directory you will find an executable "runemacs.exe". Click with the right button and select "Pin to Start" to have that program available at all times.
- Open "runemacs.exe" and open the file "~/.emacs". Store the following settings in it
(setq TeX-PDF-mode t)
(setq TeX-source-correlate-mode t)
(setq TeX-source-correlate-method 'synctex)
("\"C:/Program Files/SumatraPDF/SumatraPDF.exe\" -reuse-instance" (mode-io-correlate " -forward-search %b %n ") " %o"))))
"dvips and start")
(output-pdf "Sumatra PDF")
(defun my-latex-mode ()
(assq-delete-all 'output-pdf TeX-view-program-selection)
(add-to-list 'TeX-view-program-selection '(output-pdf "Sumatra PDF")))
(add-hook 'LaTeX-mode-hook 'my-latex-mode)
With this you should be able to open the PDF associated to a latex file and click twice in Sumatra PDF to go back to the emacs window, right at the paragraph or line where you clicked.