These are my notes on using tex on unix/linux machines. In principle, all you need is some sort of editor to create tex files, the command "tex" or "latex" to compile these to dvi. The command "xdvi" to preview them, and "dvips" to print them. But if you're documents are at all complicated you might need more.

- Donu

Setting up emacs for latex

Emacs is a powerful editor which is well suited for editing (La)TeX files. But you have to take a few steps to take advantage of these features.

If you're setting up your linux machine, then you probably have emacs already, but you probably don't have the AUCtex package; you'll need to download and intall it first. (Purdue math Solaris users can ignore this, since it's already installed.)

Next create a file .emacs in your home directory if it doesn't already exist. Add these lines to it:

(require 'tex-site)
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTex t)
(global-font-lock-mode t)
The last line turns on syntax colouring. Omit it, if you don't like this feature. If AUCtex was installed in some nonstandard place, say /X/Y . You'll have to tell emacs to look there by adding
(setq load-path (cons "/X/Y" load-path))
ahead of the previous lines. Restart emacs, and try editing a latex file. You'll notice some menus entitled "Latex", "Command" and "Ref" which are specific to editing/compiling/debugging latex files. Many of these commands should be self explanitory. See the manual for more information.

Instructions for setting up and using the new xdvi.

I'll explain how to replace xdvi with the newer version which has many nice feature such as the ability to save, print, and search the tex source. (If you run linux with a recent version of kde, kdvi will have many of the same features.) This will use the existing tex installation, so you only need to create a few files. I've compiled this for Solaris 8 on the Suns for you, and linux for me. I'm including binaries for Solaris only, since you can probably compile it yourself if you run linux. More information is available here.

1.a Basic Setup (Purdue math Solaris users)

If you haven't already done this, create a subdirectory ~/bin by
mkdir bin
and put this at the beginning of your path by putting
set path = ( ~/bin $path . )
in your .cshrc Then type
cp ~dvb/xdvik-22.76.1/texk/xdvik/xdvi-xaw.bin ~/bin
(Or if you're feeling adventurous, type
cp ~dvb/xdvik-22.76.1/texk/xdvik/xdvi-motif.bin ~/bin
instead. You'll get some annoying warnings if you use this version, but xdvi will look a lot nicer.)
mkdir xdviinputs
cp ~dvb/xdvik-22.76.1/texk/xdvik/texmf/* xdviinputs
mkdir texinputs
cp ~dvb/texinputs/src* texinputs
The first command ensures that you'll have a copy of the program regardless of what I do. Put
setenv TEXMF /pkgs/teTeX/texmf/
setenv XDVIINPUTS $HOME/xdviinputs
setenv TEXINPUTS ".:$HOME/texinputs/:"
in your .cshrc

1.b Basic Setup (Linux)

Get the source from here. Then type:
tar xfvz xdvik-22.76.1.tar.gz
cd xdvik-22.76.1
kpsewhich --expand-path='$TEXMFMAIN'
The output from the last command should give a directory, say /X/Y/texmf
./configure --datadir=/X/Y (leave texmf out)
If you're your own systems administrator, you can do an "su" and"make install" at this point. Or else modify the previous instructions appropriately.

1.c Testing

In a shell, type
xdvi -version
to check. It should say:
Xdvi version 22.76.1 (Xaw toolkit)
kpathsea version 3.4.5
Copyright (C) 1990-2002 Paul Vojta and others. (Yes, that Vojta.)
Try an actual dvi file to really make sure this really works. It should do everything that the old xdvi did, and then some (such as interacting with an editor).

2. More on Emacs

The nice thing about emacs is that it can communicate with other programs such as xdvi.

Tell xdvi to use emacs as the default editor by putting

xdvi.editor: emacsclient --no-wait +%l %f
xdvi.editor: gnuclient -q +%l %f
if you prefer xemacs) in your .Xdefaults (create this if necessary), and type
xrdb .Xdefaults
or simply logout and back in.

Put emacs into server mode by putting

in your .emacs file (Put
in your .(x)emacs file if you're using xemacs.) If emacs is already running, quit and restart it.

3. Xdvi-emacs interaction

If something.tex is a latex file, add \usepackage{srcltx} at the beginning. For a plain tex file, add \input srctex.sty at the beginning (this might work with AMS tex, but I haven't tried it). If you're planning to send the file to a journal, friend..., you'll probably want to comment out/remove that line first. You should also comment out the line and rerun (la)tex before you print it with dvips.

Start emacs if you haven't already. Compile something.tex and preview with

xdvi something.dvi
Hold down the control key and click with the left mouse button on any point in xdvi. Emacs should magically jump to the corresponding point in something.tex! This should work even if emacs is run from a terminal (i. e. with -nw option).