Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm new to Emacs and AUCTeX. On my home computer (with Windows XP) I can successfully compile .tex files and then, using C-c C-c again, launch a pdf viewer (Adobe Reader or Sumatra) to view the file.

However, on my work computer (Windows 7), I can successfully compile a .tex file to pdf using C-c C-c, but when I do C-c C-c again to view, the default view command that appears is start "" "a.pdf". Pressing Enter brings up the Windows error message Windows cannot find 'a.pdf'. Make sure you typed the name correctly, and then try again. If I change the command so that it includes the full location of the file, e.g. start "" "//servername/mark/a.pdf", then the pdf viewer opens. At home, there is no need to change the default command start "" "a.pdf".

I'd appreciate if anyone can tell me how to get the pdf viewer to open without having to edit the command each time. At work I have AUCTeX version 11.86.

share|improve this question
add comment

2 Answers

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.

share|improve this answer
    
Thanks for your reply, but it didn't work. My problem doesn't seem to be in specifying the pdf viewer to be used, rather it is in specifying the location of the pdf file to be viewed. If I change the default command start "" "a.pdf" to start "" "//servername/mark/a.pdf" then it works with both Acrobat and Sumatra. What I'd like to know is how to get Emacs/AUCTeX to look for the pdf file in the same directory as the .tex file. –  mark999 May 22 '12 at 0:41
add comment

I had the same issue under Windows 7 and i accidentally found out a while ago that editing start "" "a.pdf" manually into start "a.pdf" opens Sumatra PDF correctly. Following the beginning of the other answer, i figured out that i can solve the issue permanently by changing the corresponding command under Tex Output View Style, Extension ^pdf$, accordingly from start "" %o to start %o. You find the option Tex Output View Style by starting with

M-x customize-group <RET> 
AUCTeX

and selecting the group Tex Command.

share|improve this answer
    
Thanks for the reply, but it didn't work. When I use start "a.pdf" instead of start "" "a.pdf", it opens another window with a command prompt (like a "DOS prompt"). I just open the pdf file manually, which I don't really mind. –  mark999 Sep 11 '12 at 5:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.