# Configuring Emacs/AucTeX in Windows 10 to use Sumatra PDF?

This is surely easy-ish to do, but all the advice I can find is either several years old (2012), or not helpful - the Emacs Wiki claims that "Unfortunately, configuration can be tricky to get right, mainly because there are so many steps." Well, I don't mind taking "many" steps, if I only knew which ones to take! Note that I've used Emacs/AucTeX under Linux for years, but for reasons of work I'm having to spend more time in Windows 10.

Anyway, if I could be pointed to a fairly recent set of instructions or examples (of .emacs configurations, for example), I'd be very pleased. Thanks!

• I think the relevant variable is TeX-view-program-list. You might start there, via describe-variable – Paul Stanley Mar 25 '19 at 11:47

AUCTeX's built-in support for SumatraPDF was improved with the release of version 11.90. So make sure you have the latest version installed, which can be easily done from ELPA.

You need to touch three areas:

## Win10's PATH environment variable

This step is optional: Adjust the PATH environment variable and add the directory containing SumatraPDF.exe to it.

## Emacs and AUCTeX

You have to adjust two AUCTeX variables: TeX-view-program-list and TeX-view-program-selection. In short, in TeX-view-program-list you define the available viewers and in TeX-view-program-selection, you associate the defined viewers to the document types. If you have SumatraPDF in your PATH, you can skip this step. Otherwise, you have to hardcode the path to the executable in TeX-view-program-list by putting something like this in your .emacs:

(setq TeX-view-program-list
'(("SumatraPDF"
("c:/path/to/SumatraPDF -reuse-instance"
(mode-io-correlate " -forward-search \"%b\" %n")
" %o")
"SumatraPDF")))


Now you associate SumatraPDF as viewer for generated .pdf files in TeX-view-program-selection. Again, put this line in your .emacs:

(setq TeX-view-program-selection '((output-pdf "SumatraPDF")))


Finally, make sure you have this line in your .emacs:

(server-start)


Now restart Emacs.

## SumatraPDF

Configuring SumatraPDF is easy. You need to add this line to SumatraPDF preferences for inverse search:

"C:\path\to\emacs\bin\emacsclientw.exe" -n +%l "%f"


If you don't see the field for inverse search, open the file SumatraPDF-settings.txt, search for EnableTeXEnhancements and set it to true. Restart SumatraPDF and try again.

Open a .tex file, hit C-c C-t C-s and check the message in the Minibuffer. Make sure it says Tex-Source-Correlate mode enabled. Now hit C-c C-c to compile the file and C-c C-v to change to SumatraPDF.
Just a small comment: if the path to SumatraPDF contains spaces (as is the case for a default install to "Program Files (x86)", then the path must be quoted: "\"c:/Program Files (x86)/SumatraPDF/SumatraPDF\" -reuse-instance" etc.