Handout 7: Introduction to Latex

Adapted from a Guide by Carleton DeTar, Utah Physics

next up previous
Next: About this document

LaTeX is a scientific wordprocessing language. Because it is distributed free of charge, and is extremely versatile, it has become very popular. Indeed the American Institute of Physics among other publishers now accepts manuscripts in LaTeX form, and uses LaTeX to typeset many of its journals, thereby eliminating the need for laborious retypesetting.

This handout provides a quick introduction to LaTeX . For good references, see LaTeX for Engineers and Scientists by David Buerger (McGraw Hill, New York, 1990) and LaTeX, User's Guide and Reference Manual by Leslie Lamport (Addison-Wesley, Reading, MA, 1986).

LaTeX is a compiled markup language. That is, with your own favorite text editor -- such as emacs -- you prepare an ASCII document with LaTeX commands. Then you ``compile'' the document using latex, producing a ``dvi'' (device-independent) file that can either be displayed on the screen with xdvi or converted to postscript form for printing using dvips. Postscript files can also be displayed using ghostview. The road map of files and display options is shown here:

    FILE           COMMAND	       OUTPUT

    mydoc.tex ----(latex mydoc)----> mydoc.dvi

    mydoc.dvi ----(xdvi mydoc)-----> Console display under X-windows
                |
                 ---(dvips mydoc)------> To local printer
                |
                 ---(dvips mydoc -o)---> mydoc.ps 

    mydoc.ps  --(ghostview mydoc)--> Console display under X-windows

Because it is not a WYSIWYG (what you see is what you get) wordprocessing system, the user interface for LaTeX is not nearly as friendly as that of many popular commercial wordprocessors. However, the quality of scientific documents produced by LaTeX is professional and of the highest standard.

To illustrate the basic features of LaTeX you can study some sample LaTeX files. The files can be found on noether, in the common directory /usr/people/phys503/common/ They can also be accessed online from http://www.emory.edu/PHYSICS/Faculty/Benson/503/latex.html. The names of the files are

math1.tex with output math1.dvi , and math1.ps

A simple and general example, illustrating the latex math typesetting commands. You should view both files ``math1.tex'' and its output ``math1.dvi'' for a primer on writing mathematical expressions.

math2.tex with output math2.dvi , and math2.ps

More of the same . . . .

hw1.tex with output hw1.dvi , and hw1.ps

Source code for the first homework assignment. Course specific subtleties here:

soln1.tex with output soln1.dvi , and soln1.ps

Source code for the first solution set. Since this was a long document, an example of just about every mathematical construction you would want to make is in here.

Note that LaTeX documents begin with a \documentstyle line that specifies the font size (ours are 10 point), supporting style files (such as epic and eepic) and document style (for us, handout). After any macro or variable definitions, the document is then enclosed between the \begin{document} and \end{document} lines.

You should first practice working with the sample latex files. First, you need to get onto your noether account. If you want to preview any files (very useful for debugging), you should be sure you can drive your local display from noether. On a unix workstation (such as the suns in Cox Hall or the North Decatur Building), type xhost +noether.physics.emory.edu . On a mac with macX, run macX.

THEN rlogin to your account with the command rlogin noether.physics.emory.edu -l your-last-name. You each have accounts with the home directory /usr/people/phys503/your-last-name. You can move between directories using the unix cd command, or copy files using cp. Like any unix command, you can learn the syntax of, say, the cd command by typing man cd at the unix prompt.

Once into your account, try copying a sample document from the common directory to your own to play with: cp /usr/people/phys503/common/math1.tex ./ Then run LaTeX on the document, by typing latex math1.tex.

The output is called math1.dvi . Check that it is there, by typing ls. Note that LaTeX creates a bunch of auxiliary files as well, with names built from the original file name.

Now try to run xdvi to display the LaTeX output, by typing xdvi math1 & . If everything goes smoothly, a window will appear on your screen showing the processed document. If you get a message that xdvi cannot open the display (permission denied), of if nothing happens, there are two possible solutions: 1) you forgot to give noether permission to drive your local display, before logging in -- return to a shell on your local machine and set the permission as discussed above; or 2) noether was unable to guess correctly what console you are logging in from, so it doesn't know where to send your graphical output. (This could happen if you are logged in through a chain of different computers.) Find out the ip address of the workstation you are sitting in front of (to do this, return to your local shell, and type hostname). Then, on your noether shell, type setenv DISPLAY your-hostname:0 and try xdvi again.

Finally, you can print to the physics printers using the dvips command; or upload and download files to and from your account with the ftp command.




next up previous
Next: About this document

Katherine Benson
Tue Sep 10 14:05:53 EDT 1996