CSUF LogoCSUF Site Navigation
optics.csufresno.edu

F14 Programing Applications AUCTeX

Department of Electrical and Computer Engineering
Associate Professor Gregory R. Kriehn
Forums
Wiki
F14 AUCTeX

AUCTeX is a nifty little extensible package for writing and formatting TeX files using emacs. It also supports many different TeX macro packages, such as AMS-TeX, LaTeX (my favorite), Texinfo, ConTeXt, and docTeX. The main purpose of using it is to provide color coding of LaTeX source files, so that it is easy to parse the code when writing and editing it. If you've never used LaTeX or emacs, AUCTex is not going to do much good, but if you have, and you've never used AUCTeX, then you'll be kicking yourself for not coming across this earlier.

Installation of AUCTeX is as simple as:

~> sudo yum install emacs-auctex emacs-auctex-doc
Press 'y' when prompted to install the programs and any additional dependencies.

Bindings for emacs, and activation of the color coding is done through your ~/.emacs file. Although only the AUCTeX sections are important here, I've gone included my current ~/.emacs file in its entirety:
;; Red Hat Linux default .emacs initialization file
(setq-default auto-fill-function 'do-auto-fill)
;; Are we running XEmacs or Emacs?
(defvar running-xemacs (string-match "XEmacs\\|Lucid" emacs-version))

;; Set up the keyboard so the delete key on both the regular keyboard
;; and the keypad delete the character under the cursor and to the right
;; under X, instead of the default, backspace behavior.
(global-set-key [delete] 'delete-char)
(global-set-key [kp-delete] 'delete-char)

;; Turn on font-lock mode for Emacs
(cond ((not running-xemacs)
       (global-font-lock-mode t)
))

;; Always end a file with a newline
(setq require-final-newline t)

;; Stop at the end of the file, not just add lines
(setq next-line-add-newlines nil)

;; Enable wheelmouse support by default
(if (not running-xemacs)
    (require 'mwheel) ; Emacs
  (mwheel-install) ; XEmacs
)

;rotate buffers
(defun rotate-buffers (arg)
  "Rotates to the next buffer"
  (interactive "p")
  (switch-to-other-buffer 0))

; idlwave stuff
(autoload 'idlwave-mode "idlwave" "IDLWAVE Mode" t)
(autoload 'idlwave-shell "idlw-shell" "IDLWAVE Shell" t)
(setq auto-mode-alist (cons '("\\.pro\\'" . idlwave-mode) auto-mode-alist))
(setq idlwave-help-directory "/usr/local/etc")

; auctex path
(setq load-path (cons "/usr/local/share/emacs/site-lisp" load-path))

; activate auctex
(require 'tex-site)

; auctex document parsing
(setq TeX-auto-save t)
(setq TeX-parse-self t)

; auctex multi-file document structure + indents
(setq-default TeX-master nil)
(setq LaTeX-indent-level 4)
(setq LaTeX-item-indent -2)

; auctex autofill
(add-hook 'LaTeX-mode-hook 'turn-on-auto-fill)

; preview-latex
; (load "preview-latex.el" nil t t)
If you wish to turn on preview-latex, which allowing for the visualization of selected source chunks in your LaTeX source file, uncomment the last line. I personally have used LaTeX to such an extent that I don't need it, but for others of you out there less familiar with the syntax, you may find it useful. To get a feel for what AUCTeX does, launch emacs and open a LaTeX source file. Notice all the color coding, and parsing? If you've never used it before, you'll never want to go back once you do. For additional information, see the AUCTeX website, which can be found at:

http://www.gnu.org/software/auctex/