Skip to content

Setup Latex + Emacs + AucTex on Mac (pdf viewer = Skim , Latex compiler = TexLive)

June 19, 2013

—-It took me 2 hours to finally setup a working Emacs that can create and view pdf on my Mac, with lots of help from internet experts. Here is a summary:

Solved the issue: “LaTeX: problems after [0] pages.”

  • Option 1 (only works on Mac): Just use Aquamacs, a variation of Emacs for Mac. It can be downloaded from here. It comes with everything you need to compile Latex using Emacs. The reason why I stopped using it is because since it is not a standard Emacs, I found it hard to customize (for example, change color theme, etc.)
  • Option 2 (works on Mac, may give you a hint on other systems):
    • Idea: Need 3 things (on Mac)-
      1. Emacs 24: Use as Latex editor (also need the AucTex package installed, see below).
      2. TexLive: Latex compiler, which create the pdf file from your Latex code. Download here.
      3. Skim: Pdf viewer. Download here.
    • Details:
      1. Install the AucTex package in Emacs. Do the following:  Open Emacs; Hit M - x ; Type package-list-packages;  Hit Enter ;  In the list find and left click auctex (alternatively, move your curser to that line [remember you can “search” by typing C-s auctex], type then type x.
      2. (AucTex webpage)
      3. Install TexLive.
      4. Install Skim.
      5. Now the fun part. On my machine, Emacs doesn’t know where to find the compiler, neither does it know where to find the pdf viewer. Adding The following codes to the .emacs file should solve the problem. (if you have no idea what an “.emacs” is, take a look at this site. In short, it is an initial file that modifies the behavior of Emacs. It should be at ~/.emacs, where ~ is your home directory.)
  • Codes to be added to .emacs:

;; This line tells emacs where to find the latex compiler
(setenv "PATH" (concat "/usr/texbin:" (getenv "PATH")))
;; This line tells emacs to create pdf files instead of dvi files.
(setq-default TeX-PDF-mode t)
(setq TeX-view-program-selection '((output-pdf "PDF Viewer")))
(setq TeX-view-program-list
'(("PDF Viewer" "/Applications/ -b -g %n %o %b")))

;; start emacs in server mode so that skim can talk to it
'(LaTeX-command "latex -synctex=1")
(add-hook 'TeX-mode-hook
(lambda ()
(add-to-list 'TeX-output-view-style
'("^pdf$" "."
"/Applications/ -b %n %o %b")))

  • Final words. Now C-c C-v  in Emacs should compile a .tex file, create a pdf file and view it in Skim.

From → Uncategorized

One Comment
  1. Gabriel Matthews permalink

    Hi, thanks this worked for me.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: