Emacs AUCTeX and PDF Synchronization on Windows

In this technical note, we’d like to setup GNU Emacs and AUCTeX so that it can do both forward searches (using Emacs to control the PDF Viewer) and inverse searches (using the PDF Viewer to control Emacs). This work is based on William’s instructions, but with some additional modifications from Miguel Frasson that remove the dependency on sumatra-forward.el, as long you primarily use pdflatex as your LaTeX target. The technique uses the command line rather than DDE to interface with Sumatra PDF.
- Unlike on the Mac, TeX tool support on Windows is quite a challenge. With the exception of Sumatra PDF, there are basically no PDF viewers that support source synchronization. Be sure to use the full installer, and not the portable apps version of Sumatra PDF.
- To get PDF synchronization to work, you’ll need to set a few AUCTeX variables in Emacs (
M-x customize-variable). The first isTeX-view-program-list, which is perhaps the most complicated. TheNameshould read asSumatra PDF, and theChoiceshould be set toCommand parts. Then, you will need to insert (INS) twoCommand parts:
- The first
Command parthas a value of"C:/Program Files (x86)/SumatraPDF/SumatraPDF.exe" -reuse-instance, adjusting accordingly for your actual path. - The second part is a
Predicate and command partwith aPredicateofmode-io-correlateand aCommand partof␣-forward-search %b %n. The character ␣ is meant to represent a leading whitespace character. - The third part is a
Command partwith␣%o. Once again, don’t forget the leading whitespace character.
- Since the last step isn’t entirely obvious, the following screen capture should help you with this variable (click to enlarge). And if you’re curious about what
%o,%nand so on do, then check the variableTeX-expand-list.
- Select
Save for future sessionsand then restart Emacs; otherwise the next step won’t work without knowing some Emacs tricks. For the remaining variables in this recipe, remember toSave for future sessionsas well. - The next variable is
TeX-view-program-selection, where theViewerforoutput-pdfshould be set toSumatra PDF. - Similarly, find
TeX-source-correlate-modeand set this toOn. Finally, setTeX-source-correlate-methodtosynctex. - You’ll probably want to setup Emacs with
(server-start)ahead of time, so add this to yourinit.el. On Windows in particular,(server-start)is problematic and can fail by default with something like:error: The directory
