I'm attempting to set up LaTeX to work with Emacs on my Mac, running OS X El Capitan 10.11.5. I can compile everything all right, but I'm unable to use forward/inverse searches with Skim.

From reading other answers, I've attempted to adjust my ~/.emacs, and create a ~/.latexmkrc file. Here is what I'm currently using:

  • ~/.emacs:
;; Tells emacs where to find LaTeX.
(let ((my-path (expand-file-name "/usr/local/bin:/usr/local/texlive/2016/bin/x86_64-darwin")))
(setenv "PATH" (concat my-path ":" (getenv "PATH")))
(add-to-list 'exec-path my-path)) 

;; AucTeX settings
(setq TeX-PDF-mode t)

(add-hook 'LaTeX-mode-hook
(lambda ()
   '("latexmk" "latexmk -pdf %s" TeX-run-TeX nil t
     :help "Run latexmk on file")
(add-hook 'TeX-mode-hook '(lambda () (setq TeX-command-default "latexmk")))

(setq TeX-view-program-selection '((output-pdf "PDF Viewer")))
(setq TeX-view-program-list
      '(("PDF Viewer" "/Applications/Skim.app/Contents/SharedSupport/displayline -b -g %n %o %b")))

     '(TeX-source-correlate-method 'synctex)
     '(TeX-source-correlate-mode t)
     '(TeX-source-correlate-start-server t))
  • ~/.latexmkrc:

    $pdflatex = 'pdflatex -interaction=nonstopmode -synctex=1 %O %S';
    $pdf_previewer = 'open -a skim';
    $clean_ext = 'bbl rel %R-blx.bib %R.synctex.gz';

I've also set my Sync settings in Skim to use the Emacs preset. Does anyone have any ideas or resources I could look at to attempt to get forward and inverse searches working? Thanks!

UPDATE: I've managed to get inverse search running. I was saving my ~/.latexmkrc file in Rich Text Format as opposed to plaintext. Converting to plaintext, going to Skim -> Preferences -> Sync, selecting Custom and entering /usr/local/bin/emacsclient appears to have corrected my inverse search issues.

Unfortunately, forward search is still not working. I can compile my TeX documents in Emacs just fine using C-c C-c, but C-c C-v does not go from the TeX file to the corresponding line in the PDF output in Skim. Once again, I would appreciate any advice on this!

UPDATE 2: Forward search appears to be working just fine now. The file I was originally experimenting on had spaces in the filename, which may have caused some hiccups with all this. Forward search works perfectly on one of my better named files.

  • Your description what happens is a bit short. How do you start inverse search in Skim and what happens? How did you customise Skim? – Keks Dose Jun 28 '16 at 7:22
  • Hello @Keks, thank you for your response! I've added a small update, and I think I've fixed the inverse search issues with Skim. Forward search is still proving troublesome. – Jesse Jun 28 '16 at 9:32
  • 1
    @Jesse - I'm not on OS X, but you could try to guard the file names with "" and see if that helps: (setq TeX-view-program-list '(("PDF Viewer" "/Applications/Skim.app/Contents/SharedSupport/displayline -b -g %n \"%o\" \"%b\""))) – Arash Esbati Jun 28 '16 at 12:46
  • 1
    I have the exact same problem, but in my case the file name guarding doesn't help. If I explicitly run, e.g., /Applications/Skim.app/Contents/SharedSupport/displayline -b -g 6 "main.pdf" "introduction.tex", I get the output 571:633: execution error: Skim got an error: AppleEvent handler failed. (-10000) -- did you encounter any problems like this? – jwimberley Nov 7 '16 at 19:35
  • getting the same error here. help anyone? – John Smith Nov 8 '16 at 10:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.