Your default PDF-viewer is controlled by two variables called TeX-view-program-list
and TeX-view-program-selection
. There are several ways of modifying these:
Through the Emacs's interface
M-x customize-group <RET>
AUCTeX
Select the group called: Tex Command
then find TeX View
. Under TeX View Program List
is all the list of known commands for viewing your generated pdf. In my case I use SumatraPDF.exe which I also have in my global PATH
variable. Insert following:
Name: SumatraPDF
Command: SumatraPDF.exe %o
Under TeX View Program Selection
the default viewer for pdf and dvi can be selected. Select the previously defined SumatraPDF.
Inserting setup in .emacs
Just insert following code in your .emacs
configuration file:
(setq TeX-output-view-style '("^pdf$" "." "SumatraPDF.exe %o"))
(setq TeX-view-program-list
'(("SumatraPDF" "SumatraPDF.exe %o")
))
(cond
((eq system-type 'windows-nt)
(add-hook 'LaTeX-mode-hook
(lambda ()
(setq TeX-view-program-selection '((output-pdf "SumatraPDF")
(output-dvi "Yap"))))))
((eq system-type 'gnu/linux)
(add-hook 'LaTeX-mode-hook
(lambda ()
(setq TeX-view-program-selection '((output-pdf "Okular")
(output-dvi "Okular")))))))
If you don't use SumatraPDF (I really recommend you do), then change the name and command. Remember to have your pdf-viewer in your PATH or refer directly to it through the full path.
You could insert at the end of your .tex
file:
%%% Local Variables:
%%% mode: LaTeX
%%% TeX-PDF-mode: t
%%% TeX-engine: xetex
%%% End:
and type C-c C-n
to activate the style change. And next time you open the file in an emacs buffer, the engine will already be set to xetex
.
[earlier wrong answer replaced by this one provided by Sean Allred in his comment]
Best Answer
After son hours of struggle i finally got what i want.
First you set the PDF viewer of your preference, then you follows these steps http://blog.modelworks.ch/?p=210 (note that you have to set the program list first, then restart emacs, then set the program view selection and restart emacs again) and you are done.
In my case i had to change
<directory of your SumatraPDF.exe> -reuse-instance %o
tostart SumatraPDF -reuse-instance %o
but i don't know the reason, maybe you can explain this to me.