I am trying to set Emacs/AUCTeX to invoke an external PDF viewer so I can view the document output, preferably with source correlation via SyncTeX. AUCTeX, by default, suggested evince file.pdf; however, I don't have Evince installed and I figure Skim is a better option.

I searched around for how to go about this and found the following modifications to the .emacs file that should allow me to do this:

(add-hook 'LaTeX-mode-hook 'TeX-source-correlate-mode)

(setq TeX-source-correlate-method 'synctex)

(add-hook 'LaTeX-mode-hook
        (add-to-list 'TeX-expand-list
             '("%q" skim-make-url))))

(defun skim-make-url () (concat
        " "
        (expand-file-name (funcall file (TeX-output-extension) t)
            (file-name-directory (TeX-master-file)))
        " "

(setq TeX-view-program-list
      '(("Skim" "/Applications/Skim.app/Contents/SharedSupport/displayline %q")))

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

Source: https://web.archive.org/web/20120602072451/http://www.bleedingmind.com/index.php/2010/06/17/synctex-on-linux-and-mac-os-x-with-emacs

The hooks load without complaints. I tested on a filed named sandbox.tex, which produced the output sandbox.pdf and the C-c C-c view command attempts to invoke Skim as follows:

 /Applications/Skim.app/Contents/SharedSupport/displayline 1 /path-to-sandbox.pdf /path-to-sandbox.tex

but nothing happens: Skim does not launch nor does AUCTeX complain. I'm stumped here.

I'm using GNU Emacs 23.2.1 (x86_64-apple-darwin10.4.0, NS apple-appkit-1038.32) and AUCTeX v.11.86 on OSX 10.6.6.

  • I have more or less the same configuration and it works just fine here. What happens if you run the displayline command (exactly as it is invoked by Emacs) through the Terminal?
    – cefstat
    Commented Feb 21, 2011 at 9:00
  • Running the display command through the Terminal opens the PDF with Skim. It complains some as follows, but seems to work things out by itself.
    – Ricardo
    Commented Feb 21, 2011 at 13:06
  • 2011-02-21 09:05:23.459 osascript[62878:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find: /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
    – Ricardo
    Commented Feb 21, 2011 at 13:08
  • Try installing evince and see if that works. Does skim work on the PDF if you open it manually? If you open it from inside emacs with M-! skim file.pdf ?
    – Seamus
    Commented Feb 21, 2011 at 13:15
  • 3
    shouldn't you set skim as your default PDF viewer, then in emacs, the command to open it should be open foo.pdf -- or that always worked for me with carbon emacs.
    – Mica
    Commented Feb 21, 2011 at 17:24

3 Answers 3


Got it to work. A hard wrap happened in the following function after formatting it with M-q, separating the %q from the rest of the command.

(setq TeX-view-program-list
      '(("Skim" "/Applications/Skim.app/Contents/SharedSupport/displayline 

I couldn't catch it initially because it looked OK (even though it was not). I also must have fixed it when I pasted it in the question. At any rate, the proper form is:

(setq TeX-view-program-list
  '(("Skim" "/Applications/Skim.app/Contents/SharedSupport/displayline %q")))

and now things work as they should.

  • 1
    Thank you very much -- greatly appreciated!!!!!!!!!!! Just in case I didn't put in enough exclamation points, here are a few more !!!!!!!! :)
    – lawlist
    Commented Apr 24, 2013 at 5:00
  • Do you know what should I write if I want to use Mac's preview instead of skim?
    – LWZ
    Commented Oct 30, 2013 at 1:41
  • You would be better served by asking a new question. That being said, tex.stackexchange.com/a/70409/3731 suggests using open -a/Applications/Preview.app/Contents/MacOS/Preview %.pdf if one is already using a different viewer. If Preview.app is your default, adding this to your .emacs should work: (add-to-list 'TeX-command-list (list "View" "/Applications/Preview.app/Contents/MacOS/Preview %o" 'TeX-run-discard t t :help "Run Viewer")). Finally, this does the same thing: tex.stackexchange.com/a/119649/3731.
    – Ricardo
    Commented Oct 30, 2013 at 5:03

skim-make-url doesn't work with paths with spaces (at least for me) so I had to double quote the paths, like this:

(defun skim-make-url ()
   " \""
   (expand-file-name (funcall file (TeX-output-extension) t)
             (file-name-directory (TeX-master-file)))
   "\" \""

Not exactly an answer to your question but a work-around. I use skim too and a tool called latexmk that I just found today. It's like a MakeFile for LateX only better. If you call it as: latexmk yourfile.tex -pvc it will look for changes and rerun whenever you save your files. And skim will see that the file has changed and reload. Seems to work nicely (only lately the auto reload function of my skim is messing up but that is beside the point). By default it outputs dvi though so you probably want to run it as:

$ latexmk yourfile.tex -pvc -pdf
  • I get the same auto-reload behavior with the Mac's Preview.app when I open it manually. If it weren't for that I would have probably gone insane opening files upon each modification! How do you get Skim to launch?
    – Ricardo
    Commented Feb 21, 2011 at 20:08
  • I launch Skim (once) the same way as I launch any mac application. Then I load the pdf I want to view. Once I have done that skim notices whenever the file has changed and asks whether to reload or not reload. In that dialog window there is an auto button which sets skim to reload automatically whenever there is a change. Was that what you were asking?
    – jonalv
    Commented Feb 22, 2011 at 12:58
  • Yes, that was my question. Unfortunately I was hoping you would tell me you launched it from Emacs with C-c C-v or C-c C-c View. I can live with launching Skim or Preview once and having it auto-reload, but it would be nice to get Emacs to do it for me.
    – Ricardo
    Commented Feb 22, 2011 at 18:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .