Home Open Source Classics Emacs, AUCTex, and XeLaTeX

About

Open Source Classics is a directory and how-to guide for free and open source programs and resources useful to classicists, as well as a place for musings about the relationship of scholarship to free and open source principles. Continue the conversation at the Open Source Classics Forum and Technology Forum. Have a recommendation for an article? Interested in becoming a contributor? Email the editors.

Login

Emacs, AUCTex, and XeLaTeX
Written by Kyle P. Johnson   
Sunday, 03 May 2009 19:36

For those who don't know, Emacs is not your average text editor. On the one hand, it is utterly simple in appearace and function, evoking for me memories of the Commodore 64. On the other hand, Emacs has a multitude of powerful functions for working with code of various sorts. Emacs is extensible, which means that there are extension packages that one can add to the program in order to customize and enhance it. For those using LaTeX, the AUCTeX package is especially useful, as it enables special menus for macros and commands for typing. Configuring Emacs is not difficult if you know exactly what to do.

This posting describes a how to quickly begin composing and compiling TeX–based documents with Emacs.

1) Install Emacs. If possible, I recommend installing the "snapshot" release of GNU Emacs, which I find an improvement over v. 22, including improved Unicode support.

A. If on Ubuntu, enter into the Terminal:

sudo apt-get emacs-snapshot

For installation on other Unix–based systems, find installation information here.

B. On Mac OS X, get Aquamacs or Carbon Emacs. Just download and drag into your Applications folder.

C. On Microsoft Windows, look here for information.

 

2) Install AUCTeX package to Emacs. 

A. On Ubuntu and other Linux systems, download and unarchive AUCTeX. (For more detailed instructions, see "INSTALL" file, within the downloaded folder.) If you unpacked the file to the desktop, in the Terminal, "cd" to:

cd/home/yourname/Desktop/auctex-11.85

[Note: be sure to change "yourname" here to your username.]

Then:

./configure

Then:

make

Then:

sudo make install

Look for a hidden .emacs file in your home folder. (To see hidden files, use "control-H" or in GNOME go to menu "View ––> Show Hidden Files".) If this file does not exist, make one. Into this file, copy and paste the following:

(load "auctex.el" nil t t)

You also need to let Emacs know where to find your TeX installation. If using TeXLive 2008, as I recommend, add the following:

(setenv "PATH" (concat (getenv "PATH") ":/usr/local/texlive/2008/bin/i386-linux"))

    (setq exec-path (append exec-path '("/usr/local/texlive/2008/bin/i386-linux")))

Save and close the .emacs file. Restart Emacs, then open a file ending with a .tex extension and the AUCTeX options should appear.

B. If using Aquamacs or Carbon Emacs, you're in luck – AUCTeX comes pre–installed.

C. I do not have access to a Windows platform, so I can only point one to the Windows directions offered by AUCTeX.

 

3) Configure Emacs to run XeLaTeX. If you are as big a fan of XeLaTeX as I am, then you need to add it to the list of Emacs's commands.

A. On Linux, put the following into your .emacs file, which will make XeLaTeX the default installation:

 ;;set xetex mode in tex/latex
(add-hook 'LaTeX-mode-hook (lambda()
(add-to-list 'TeX-command-list '("XeLaTeX" "%`xelatex%(mode)%' %t" TeX-run-TeX nil t))
(setq TeX-command-default "XeLaTeX")
(setq TeX-save-query nil)
(setq TeX-show-compilation t)
))

While you are in the .emacs file, add Flyspell, improved spell–checking:
(add-hook 'LaTeX-mode-hook 'flyspell-mode)
Save and close your .emacs file and restart Emacs. Now, to run XeLaTeX, type "control-c, control-c", then return; or go to the menu "Command ––> XeLaTeX".
[Note: if you do not want XeLaTeX to be your default TeX command, follow the directions for for Mac OS X, 3.B., below, only replace the command "%`xelatex --synctex=1%(mode)%' %t" with "%`xelatex%(mode)%' %t".]

B. On Aquamacs or Carbon Emacs, do the following (taken from directions here):

i) Open a .tex buffer
ii) Go to the following LaTeX menu: "LaTeX ––> Customize AUCTeX ––> Extend this Menu"
iii) In this expanded menu, choose "TeX Command ––> "TeX Command List…"
iv) Click on "INS" to create a new entry
v) Name: XeLaTeX
vi) Command: %`xelatex --synctex=1%(mode)%' %t
vii) Click in the "Modes" button and choose "Value Menu ––> Set"
viii) Check the boxes for: LaTeX, ConTeXt, AmSTeX
ix) Save the settings

Now you can run XeLaTeX through the menu "Command ––> XeLaTeX".

C. On a Windows version of Emacs, the directions should be similar to the Mac OS X directions, though I do not know exactly what command shouldbe entered the Command entry when customizing (maybe "%`xelatex%(mode)%' %t").

 4. Learn how to use Emacs. Emacs retains archaic commands for basic operations like copying, cutting, pasting, and saving. For a beginner's tutorial, see here. A major benefit to Aquamacs for Mac OS X is that it comes configured to standard commands, like, "Command-C" for copying.