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.
Compiling your .tex file
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.
TeX-view-program-list
. You might start there, viadescribe-variable
– Paul Stanley Mar 25 '19 at 11:47