Sunday, September 25, 2005

emacs and AUCTeX

Warning: I'm a nerd. Also, I don't want to start a holy war about Emacs vs VI. They're both good, I had my reason for learning Emacs first, so shaddup.

So today I opened up my trusty text editor to do some work, but to my dismay it crashed! Funny thing is it worked before I installed the latest Mac OS X security update.

This made me really angry since I just recently figured out how to get AUCTeX properly working with Emacs on my computer. It turns out there was a problem with me having some certain utils in /sw/bin... I'll discuss the fix later. (For those of you who don't know, AUCTeX is the greatest thing imagineable for Emacs based LaTeX editing). Pissed off, I tried reinstalling Emacs from the binary I made last week, but that TOO crashed! Steamrolling, I retreived the source and built it again from scratch. This gave me an opportunity to upgrade to the latest CVS build, although slowly, and I had a meal while it compiled.

I had trouble remembering how to get AUCTeX to install with the OS X binary I built, but once I figured it out I was very pleased -- the preview-latex package works now! I can preview my equations and figures right inside the text editor! This is naturally as close as I want to get to WYSIWYG.



Anyway, I'm going to post my steps here so I can do this much more quickly next time -- that and for the people who want it.

0. Set up global environment variables
This step is confusing. The emacs binary won't adapt AUCTeX properly unless the global environment knows where a few needed tools are. If you're a FINK user (like me), these utilities are in a nonstandard place: /sw/bin.

[sid@lappy] ~% mkdir .MacOSX
[sid@lappy] ~% cat<<EOF > environment.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist
SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>PATH</key>
<string>
.:/usr/bin:/sw/bin:/usr/local/bin:
/sw/local/bin:~/bin:/bin:/usr/local/sbin:
/usr/sbin:/sbin:/sw/sbin
</string>
</dict>
</plist>
EOF
[sid@lappy] ~%


1. Get Emacs and build it

[sid@lappy] ~% cvs -z3 -d:ext:anoncvs@savannah.gnu.org:/cvsroot/emacs co emacs
[sid@lappy] ~% cd ./emacs/mac
[sid@lappy] ~% ./make-package --self-contained
[sid@lappy] ~% open ./EmacsInstaller.dmg

Then run the installer.

2. Get and configure auctex.

[sid@lappy] ~% wget
http://ftp.gnu.org/pub/gnu/auctex/auctex-11.81.tar.gz
[sid@lappy] ~% tar xzf auctex-11.81.tar.gz
[sid@lappy] ~% cd auctex-11.81
[sid@lappy] ~% ./configure
--with-emacs=/Applications/Emacs.app/Contents/MacOS/Emacs
--with-lispdir=/Applications/Emacs.app/Contents/Resources/site-lisp
[sid@lappy] ~% make
[sid@lappy] ~% sudo make install


3. Append .emacs file to use AUCTeX and preview-latex

(setenv "PATH" (concat "/sw/bin;" (getenv "PATH")))
(require 'tex-site)
(load "preview-latex.el" nil t t)


4. Launch Emacs, and enjoy.

1 comment:

  1. By the way, I can't take credit for the nasty typesetting of nCr. I just pulled an example off the web and tried it out. I guess I was too wrapped up in the cool preview feature to care...

    ReplyDelete