The MSRI Computing Handbook

TeX



TeX is a typesetting system designed to create beautiful manuscripts - especially manuscripts that contain a lot of mathematics. TeX is a powerful program, and thus takes some effort to learn, but the quality of output is unsurpassed.
Note: the following is by no means comprehensive documentation. For further assistance, see Silvio Levy, in the library, or Joe Christy, in room 229. Documentation for virtually every every TeX package and supporting tool is available online. MSRI also has copies of the various TeX manuals available for checkout in the library.

The Many Dialects of TeX

In the years since TeX was introduced, many TeX macro packages have been written. TeX can be thought of as the general typesetting tool, while the different macro packages make it easier to prepare specific documents. These macro packages are not designed with each other in mind---they are independent dialects evolving in different directions. If you are not sure which TeX package is best for you, talk to Silvio Levy, in the library, or Joe Christy, in room 229.

A Note on LaTeX

At MSRI, our LaTeX is LaTeX2e. We have found that most old LaTeX documents written under LaTeX version 2.09 work perfectly fine under LaTeX2e `compatibility mode'. Since LaTeX2e is, after nearly four years, now the de facto standard for for LaTeX, we no longer support LaTeX version 2.09; if your document does not work under compatibility mode, we will help you upgrade it to the current version. In the fall of 1994, the AMS released its long awaited upgrade to AMSLaTeX, version 1.2, which is compatible with LaTeX2e. With this version, you no longer need to invoke AMSLaTeX to TeX your file, merely use the amsart or amsbook document class in your file and invoke LaTeX. AMSLaTeX 1.2 is much more robust than previous versions, and we urge all AMSLaTeX users to upgrade.

Writing a TeX document

TeX documents are regular ASCII text files, so just use your favorite text editor (see section on Editors) to write the source file. You must give your TeX file a name with a .tex extension (e.g. paper.tex), or else TeX will not be able to find it. The TeX program then takes this file and compiles it into a ``.dvi'' file (for ``device-independent''). It is the .dvi file which gets sent to the screen for previewing, or is translated into a page-description language like PostScript for the printer.

Typesetting a file

To typeset (compile) your source file paper.tex, type one of the following, whichever is appropriate (see the Note on LaTeX) about AMSLaTeX:
tex paper for Plain TeX
tex paper.tex for Plain TeX
latex paper for LaTeX
latex paper for AMSLaTeX
amstex paper for AMSTeX
In general, with any of above commands the .tex extension may be left off. The resulting .dvi file will be called paper.dvi.

Previewing a dvi file with xdvi

After compiling your TeX document, we suggest that you preview it on the screen. Previewing a document is much faster than printing, and conserves paper. We recommend that you use the xdvi previewer.
  1. To preview the file paper.dvi, type: xdvi paper.dvi
  2. When the preview window appears, use the buttons or these keystrokes:
    U
    Move the page up
    D
    Move the page down
    R
    Move the page right
    L
    Move the page left
    F, N, RETURN
    Go to the next page
    B, P
    Go to the previous page
    G x
    Go to page x
    n s
    Use xdvi's scale n magnification.
    R
    Reread the dvi file
    Q
    Quit xdvi
While xdvi pops up sized to display a whole page, you may find this hard to read. I prefer scale 4. Note: the scale is not linear and has nothing to do with TeX's magstep - experiment to find your choice.

Clicking the mouse over the page image pops up a little magnified window, which will follow the mouse.

Printing a dvi file

At MSRI, we use Tom Rokicki's excellent filter dvips to print TeX documents. For more information, see the dvips section of the Supplemental TeX Documentation binder or browse the online documentation.

Note that the lpr -d command is not implemented at MSRI. Printing a dvi file with lpr can easily fill thousands of pages paper with garbage, ravaging forests and depleting the ozone layer.

Here are some example dvips commands:

dvips paper
You need not specify the .dvi extension.
dvips paper.dvi
If you do not specify a printer with the -P flag, the file paper.dvi will be printed to the printer specified by the PRINTER environment variable (usually the one on your floor).
dvips -P2 paper.dvi
The file paper.dvi is printed on the second floor printer.
dvips -p4 paper.dvi
The -p flag (for premier) tells dvips where to begin printing (in this case, page 4).
dvips -p3 -l6 paper.dvi
The -l flag (for last) tells dvips where to stop. In this example, only pages 3 through 6 are printed.
dvips -p4 -l4 paper.dvi
In this example, only page 4 is printed.
dvips paper.dvi -o
The -o flag tells dvips to write its output to a file with the same name as the input, but with the extension .ps, paper.ps here.
dvips -o quux.ps paper.dvi
If the -o flag is followed by a file name, it writes its output there. Here, the output is written to a file named quux.ps

If your dvi file mysteriously stops printing after 30 or 40 pages, it may be too large for the printer spool directory. By writing an intermediate PostScript file with the dvips -o command and printing with the lpr -s command (for more information, see section on Printing a UNIX Text File) you can circumvent this problem:
dvips -o paper.ps paper.dvi;lpr -s paper.ps.

Illustrations in TeX Documents

We strongly recommend that you produce your illustrations in PostScript. Adobe Illustrator and xfig are two good PostScript drawing programs, and both Maple and Mathematica can produce graphic output in encapsulated PostScript. Please speak to a member of the computing staff about getting started with one of the illustration programs.

There is also a wealth of information on other approaches in the online documentation, most notably the LaTeX graphics package and the metapost system.

Encapsulated PostScript is a structured form of PostScript; encapsulated PostScript documents conventionally have the extension .eps. Encapsulated Postscript documents will begin with
%!PS-Adobe-N.N
%%BoundingBox: x y w h

where N.N is a version number, x y are the coordinates of the lower left corner of the smallest rectangle containing the figure, and w h are the width and height of the rectangle. Here the units are PostScript points, which TeX refers to as bp, and which are 1/72 of an inch in size.

To insert a figure into the TeX document, use the epsf.tex macro package. This is a quite flexible collection of macros which is rapidly becoming a standard. It is extensively documented in the dvips section of the Supplemental TeX Documentation binder, but an example should be enough to get you started:

\midinsert
\centerline {
% This figure is 152.0 bp by 114.0 bp
% \vspace{114.0 bp}
\epsfbox{L52paving.eps}
}
\botcaption{ Figure 3.1 }
The paving of the boundary of $\bold L_{5,2}^*$.
\endcaption
\endinsert
This fragment will insert the encapsulated PostScript figure L52paving.eps into the middle of a page, centered from right to left. Its caption will appear below the figure. I like to include the dimensions of the figure in a TeX comment so that I can leave a blank space of the appropriate size for backwards publishers who insist on separate figures.

Writing Letters on MSRI Letterhead

We have a LaTeX class and a plain TeX macro package for the preparation of letters including MSRI letterhead. This eliminates the need to hand feed letterhead into the printer, where you will inevitably discover that someone else's print job has snuck in ahead of yours.

If you are a LaTeX user, prepare your letter in LaTeX as you usually would, but instead of letter, use msriletter in the preamble. E.g.:

%&latex
\documentclass[12pt,wide]{msriletter}
...

The file /local/teTeX/texmf/tex/latex/msri/msriletterSample.tex contains a template.

If you are a plain TeX user, follow the template /local/teTeX/texmf/tex/plain/msri/msriletterSample.tex. Note that the plain TeX macros are more rudimentary than the LaTeX class file.

Making Mailing Labels

We have (courtesy of R. Bharat Rao) a functional TeX macro for printing mailing labels that is well adapted to the Avery 1" x 2 5/8" labels that MSRI stocks. It works well with addresses of 5 lines or less, is marginal for 6 line addresses (because of the inaccuracies in paper feeding), and disfunctional with 7 line addresses (because of insufficient space with legible fonts). It will produce 10 rows, 3 columns per page.

To create mailing labels:

  1. Assemble a list of addresses and contemplate how to edit them so as to be 5 lines or less in length for best results.

  2. Prepare a TeX file of the following form:
    %&plain
    \input labelmac3
    \address{
    Addressee 1
    Address 1, line 2
    % ... up to 4 lines more
    }
    
    %	... [as many addresses as you like]
    
    \address{
    Addressee N
    Address N, line 2
    % ... up to 4 lines more
    }
    
    \bye
    % end of file
    
    There is an example file in /local/teTeX/texmf/tex/generic/msri/labelExample.tex. The one thing to watch out for is that you escape &'s; e.g Texas A&M should be typed Texas A\&M.

  3. Run this file through TeX and preview it so you can find and correct mistakes without wasting paper.

  4. Print the labels with dvips onto plain paper. It is essential that you not run mailing labels through the lab laser printers. The paper path on these machines has some sharp bends, so labels have a tendency to come off the backing inside the printer. This leads to very costly repairs.

  5. Get some Avery 1" x 2 5/8" labels from Marsha (if you are a postdoc applying for jobs) or your favorite stationary store.

  6. Place the labels face down into one of the paper supplies of the mailing room copier, and then make sure that the copier will take its paper from the appropriate supply.

  7. Copy the addresses that you recently created onto the labels.

  8. Stick them onto your envelopes and relax.



Last modified by Silvio Levy on $Date: 1998/01/17 16:38:42 $