UMass Amherst
Department of Mathematics and Statistics
Directory  Courses  Undergraduate  Graduate  Research  Seminars  Calendar  Contacts  Resources  Donate  
RCF  Math/Stat Res Ctr  OWL Login  SPIRE  Links  US Math Depts  For Dept Members  

LaTeX Local-Guide


Introduction

This document is meant to serve two purposes: First, it is a guide to help new users get started using TeX and LaTeX on the main RCF systems. Second, it is intended to be the Local Guide referred to in the book LaTeX: A Document Preparation System by Leslie Lamport [Lamport]. In addition, the last section of this document contains some more advanced topics that may interest those with more experience.

If you plan to become comfortable (and productive) using TeX and LaTeX, we recommend reading many sections of the references listed at the end of this document. As a minimum, the beginning LaTeX-er should read Chapters 1 - 4 of [Lamport] or Chapters 1 - 4 in LaTeX For Everyone by Jane Hahn [Hahn]. Those who want the entire story behind TeX should begin by reading the first several chapters in [Knuth].

We also wish to point out that this document was written using LaTeX, so pay special attention to some of the professional looking features which appear throughout this guide. For instance the table of contents was produced by typing a single command. The file used to create this document is available, along with some other examples, by typing get-tex-examples on shark10. This will be explained further in Section 3.1.

A Word About TeX

TeX is a typesetting program, or a text formatter. TeX allows you to separate the content of your document from its form. This means that the process of writing a document can be split into two parts. First, the overall form of the document must be chosen, this includes margins, line spacing, the type and placement of section or chapter headings, etc. Then, with these considerations out of the way, attention can be focused on content. The advantage this separation provides may seem small now, but its importance will become clearer when you must revise a document of significant complexity. The distinction between a word processor and a text formatter is too subtle to explain fully here, but there are important differences. One you will notice immediately is that TeX, unlike many word processors, is not wysiwyg.

The term wysiwyg stands for what you see is what you get and refers to the fact that many wordprocessors show you the output you can expect as you are typing. TeX cannot do this because many of its decisions about formatting are made based upon aspects of the entire document. At first, this may appear to be a burden. You cannot see your output immediately and the commands you need to type for a variety of features may seem unnecessarily cumbersome, however, the flexibility and power that TeX offers are worth the effort. In addition, the quality of output that TeX and LaTeX produce is unequaled by other programs. The benefits of TeX and LaTeX are definitely an acquired taste.

Before we continue, we need to briefly explain the distinction between TeX and LaTeX. TeX is Donald Knuth's typsetting program which is also a programming lanuage in its own right. For example, you can program TeX to place different headers on odd and even pages in your documents. These sorts of programs within TeX are called macros. LaTeX is a large and complicated collection of macros which run on top of TeX. Many of these macros override pure TeX\ commands, so when you use LaTeX, you are also using TeX indirectly, but you do not have all of the TeX commands at your disposal. However, you do have all the LaTeX commands detailed in [Lamport]. The macros defined in LaTeX allow the average user to perform some complex typesetting with fairly easy commands. While TeX can typeset anything, LaTeX lets you do much of it more easily.

TeX's speciality is its ability to typeset mathematics. LaTeX adds to this a simple referencing system which allows you to label and refer to equations, sections, chapters -- virtually any unit of text. This referencing scheme does not depend on chapter, section, or equation numbers so that when these items are changed during revisions, the references will be updated automatically. Because this referencing system is indispensable for organizing and revising all but the shortest documents, the RCF recommends using LaTeX. For the remainder of this document, we will discuss features of LaTeX only and refer the interested reader to [Knuth] for information on TeX.

Getting Started

The best way to learn LaTeX is to sit down and start using it. As mentioned, the RCF has two excellent books to help you start learning LaTeX. The first is [Lamport]. This book is the standard LaTeX manual and its value can not be overstressed.

The second book, [Hahn], is newer. If you don't like the style of [Lamport], you may prefer this one. Both books contain essentially the same information but they are written in very different styles. [Lamport] is filled with many excellent examples showing how most basic commands work. [Hahn] is more of a tutorial, encouraging the reader to try variations of the examples shown in the book. [Hahn] also contains many lists and tables of information that make it an excellent quick reference once you become more familiar with LaTeX.

Running a Sample File

For a good introduction to LaTeX you will need to use a workstation. The graphics capabilities of these machines will allow you to preview your documents on the computer screen. This is something that new users will find extremely helpful since LaTeX does not always produce the results that you think it should. Once you have logged in to a workstationgif you should do two things before running LaTeX. In the console window (usually in the upper left corner of the screen) type:

xhost + shark10

This command will allow shark10 to display graphics on the screen of the workstation. Now open a shark10 window and type:

setenv DISPLAY hostname:0.0

where hostname is the name of the workstation that you are using; for example gin, tonic, stone, etc. These two commands will need to be typed each time you login to use LaTeXgif.

There are two sample files, simple.tex and sample.tex, mentioned repeatedly in [Lamport]. These files, and all of the files used to create this document, are available for you to use as additional examples to help you learn LaTeX. Simply typing get-tex-examples on shark10 will copy these files into a directory called latex-examples in your home directory.

Using LaTeX on our system is simple, just type `latex filename', where the `filename' is the name of a LaTeX file. To run `small.tex' type:

latex small

Notice that the .tex extension was not typed. Figure 1 shows the output produced by LaTeX.

   figure84
Figure: An example of LaTeX output.

Most of what was printed on the screen can be ignored for now. Everything written after the line that starts with ``Transcript written...'' is unique to our system. The extra lines come from a shell script written by the RCF to make all our lives a little easier. Chosing one of the options allows you to perform that function automatically. This saves us all from having to remember the commands for printing these documents. It also saves a lot of paper because the commands for printing only certain ranges of pages are not at all easy to remember.

The best way to save paper (and time, since printers can be slow) is to preview documents on the computer screen. This allows you to see if your changes gave the results that you intended. When one of the view options (v or vp) is chosen, a new window will appear containing your document. Some of the features of these viewers will be discussed in Section 3.1.2. Previewing can only be done on a workstation.

What LaTeX Does With an Input File

When a `.tex' file is run using LaTeX, the program creates additional files which start with the same name as the original .tex file. There are always at least three new files created. These files are:

Dvips, Xdvi, and Pageview

dvips, xdvi, and pageview can each be run automatically using our latex script. However, each of them is an independent program with a variety of features. The latex script allows you to use these programs without having to know too much about them. For those users interested in some of the more elaborate features of these programs there are man pages for each describing how to use them.

The function of dvips is to convert LaTeX and TeX output into PostScript format. This conversion is necessary because each of our printers is configured to accept PostScript files. To learn about some of the special features of dvips see [Rokicki]. This document describes, among other things, how dvips can be used to add PostScript pictures to a document, an overview of this will also be given in Section  4.1.2. Another way to learn about dvips is simply to type dvips. This will cause a short list of command line options to appear on the screen. The descriptions are quite brief but they do give a glimpse at what dvips is capable of.

xdvi and pageview are both previewers. xdvi uses the `.dvi' file directly to display an image. pageview converts the `.dvi' file into a PostScript file and displays the `.ps' file. This is a subtle difference but pageview does offer a PostScript programmer the chance to edit the `.ps' file itself before printing.

pageview is only available on Gin and Tonic and tends to run rather slowly because of the many powerful PostScript features it provides. xdvi is available on most workstations.

The main difference between xdvi and pageview is in their use. pageview operates using pull down menus exclusively. xdvi has buttons on the screen for the most commonly used commands and all other commands are key sequences which can be memorized if needed. For a complete list of features and commands see the manual pages for these programs.

How to Create LaTeX Files

To create a LaTeX file you will need to use a text editing program, usually called an editor. The RCF has many editors available. To list just a few, we have ed, vi and emacs.

Emacs is, with out a doubt, the editor of choice on our system. The reasons for this are clear after you have some experience with it. Emacs has many commands which are rather cryptic, but you soon get used to them and you may even learn to appreciate them. If you are unfamiliar with Emacs, the RCF has some handouts and an excellent reference book, Learning GNU Emacs[Cameron]. The RCF also conducts a short course in using Emacs each fall. The time and location of these classes will be announced using electronic mail.

One of Emacs' useful features is it's ability to automatically adapt itself to the project you are working on. For example, when using emacs on a file which ends in `.tex' you are automatically placed in TeX or LaTeX mode (see [Cameron] for more about modes). These modes define new commands within Emacs that may be useful when preparing a `.tex' file. Emacs looks at both the file extension (in this case `.tex') and the file contents to try and determine which mode is correct. One of the added features available in LaTeX mode is a simple way to automatically end an environment when you begin one so that you do not forget to end it later. Forgetting to end an environment is probably the most common LaTeX error. See [Cameron] for a complete explanation of emacs. The TeX\ related features of emacs are covered in [Cameron, pages 183-189, 345,].

What Document Styles are Available

The RCF has all of the standard document styles. The .doc files are contained in the directory `/usr/local/lib/texmf/tex/latex/doc'. We also have many document style options that are not mentioned in the standard documentation. A few of the most useful options and one additional document style are briefly described below.

amstex
This style option adds all of the powerful commands for typesetting mathematics available in -TeX. Some of these commands provide an easier way to handle multiline equations, matrices, and commutative diagrams. LaTeX, when used with this style option, is commonly referred to as -LaTeX. This combination allows you to use the best features of two powerful macro packages, therefore, we strongly encourage its use. See [Kieffer] for an introduction to -LaTeX.

bezier
This style option defines a single command which can only be used within the `picture' environment. The command, \bezier\{n\}tex2html_wrap_inline4672 , draws a Bezier spline made up of n points. The Bezier spline is a parabolic arc from tex2html_wrap_inline4676 to tex2html_wrap_inline4678 . Further, the line segment from tex2html_wrap_inline4676 to tex2html_wrap_inline4682 is tangent to the curve at the point tex2html_wrap_inline4676 . Similarly, the line segment from tex2html_wrap_inline4678 to tex2html_wrap_inline4682 is tangent to the curve at the point tex2html_wrap_inline4678 . This command does not connect the n dots. If a solid line is desired, n should be set so that there are roughly 75 dots per inch.

box
The box style option redefines a small set of commands that were lost when the New Font Selection Scheme was initiated. These commands are listed in Table 1.

   table146
Table 1: Commands Redefined in box.sty

When this style option is used each of these commands will again work exactly as mentioned in [Lamport].

doublespace
This style option typesets the document in double space. It also defines a `singlespace' environment for use in small sections of the document.

epsf
This provides one way to include PostScript files in a LaTeX\ document. See section 4.1.2 for more details about this style option.

ifthen
This style option defines two programming language features for use in LaTeX:
\ifthenelse\{test\}\{then clause\}\{else clause\}
\whiledo\{test\}\{do clause\}
The then, else, and do clauses can be any combination of valid LaTeX commands. The test is one of the following:

  • A relation between two numbers formed with ;SPMlt;, ;SPMgt;, or =; for example, \value\{page\}>3.
  • \equal\{string1\}\{string2\}, which evaluates to true if string1 and string2 are the same strings of characters after all commands have been replaced by their definitions. (Upper- and lowercase letters are unequal.)
  • A logical combination of the above two kinds of tests using the operators \or, \and, and \not and the parentheses \( and \)-for example:
    \not \( \value\{section\} = 1 \and \equal\{Jones\}\{\myname\}\)

The test argument is a violently moving argument, which means that not only fragile commands but even some commands that are not normally fragile will break, causing TeX to enter an infinite loop. The \protect command works in these situations.

seminar
This document style is an alternative to using SliTeX, described in [Lamport]. It can be used for preparing slides, transparencies, and accompanying notes. A detailed user's guide [Zandt] for this document style is available from the RCF.
Note: Transparencies (even those labeled as `laser printer safe') can leave damaging residues on internal portions of the printer and permanently alter the quality of the printer. Always consult an RCF staff member before preparing transparencies with our printers.

showidx
This option may be used with the `report' or `book' document styles. It causes index entries to be printed in the margins of the pages that those entries refer to. It, therefore, provides a fairly simple way to determine whether the index of your document will contain the appropriate references.

umthesis
This is a style option to be used with the `report' document style. It is designed to produce documents formatted according to the ``Typing Guidelines'' issued by the Graduate School at the University of Massachusetts. Documentation for this style option is being prepared by the RCF.

undhead
This style option simply underlines the header of each page.
Using LaTeX on the NeXT Machines

LaTeX is very easy to use on the NeXT computers. In the File viewer `.tex' files have a special icon. Double clicking on this icon runs LaTeX and, if no errors are detected, displays the DVI file on the screen. If this did not work the first time, you will need to change your TeXview preferences as follows. Choose `Info' from the TeXview menu, then pick `Preferences'. In the preferences window change the default to LaTeX and click on `Save Preferences'.

Using LaTeX on the NeXT machines is very convenient because you can preview your changes very quickly. To recompile a document select `Compile' from the TeXview menu and then select LaTeX. Your document will be displayed on the screen at the same page that you were last looking at.

TeXview also has a large (110 page) on-line manual, just select `View Manual' from the `Info' submenu. The manual has a complete table of contents and an index, so it is quite easy to use.

Advanced Topics

Adding Pictures to a Document

The LaTeX `picture' environment can be used to generate simple pictures. When more complicated pictures are required, such as the one at the beginning of this section, it is often possible to use a graphics program to create the picture for you. There are two basic ways to include these graphics in a LaTeX document. First, LaTeX\ can include files stored in LaTeX format. Second, dvips can include files stored as encapsulated PostScript. The examples given in the next two sections were both created using a plotting program called GnuPlot. Documentation for this program is available from the RCF, see [Williams].

Including LaTeX Pictures

Figure 2 shows the commands used to include the LaTeX picture which appears as figure 3. The name of the LaTeX file containing the picture itself is `bessel-1-pic.tex'. This method of including pictures is usually the easiest. The only drawback is that the LaTeX `picture' environment places certain restrictions on the slopes of lines, sizes of circles, and so on, which sometimes cause noticable defects in certain pictures.

   figure203
Figure: Including a LaTeX Picture

   figure207
Figure: Example of a LaTeX Picture
Including PostScript Files

Including PostScript files in a document usually produces the best quality output but it can take a little extra work. Figure 4 shows the commands used to create figure 5. The \epsffile command is used in place of the more standard \input command. This command, and other similar commands, are defined by the `epsf' style option mentioned in section 3.3. Some of the other `epsf' commands allow you to change the size and placement of the PostScript graphics. For more information on these `epsf' commands see [Rokicki].

   figure3183
Figure 4: Including a PostScript Picture

  
Figure 5: Example of an Encapsulated PostScript Picture

References

Cameron
Debra Cameron and Bill Rosenblatt. Learning GNU Emacs. O'Reilly & Associates, Inc.

Hahn
Jane Hahn. LaTeX For Everyone. P T R Prentice-Hall, Inc.

Kieffer
Gordon Kieffer. A Crash Course in LaTeX with the New Font Selection Scheme and in -LaTeX. Research Computing Facility (RCF).

Knuth
Donald E. Knuth. The TeXbook. Addison-Wesley Publishing Company, Inc.

Lamport
Leslie Lamport. LaTeX: A Document Preparation System. Addison-Wesley Publishing Company, Inc.

Rokicki
Thomas Rokicki. Dvips: A DVI-to-PostScript Translator. Public Domain.

Walsh
Norman Walsh. Making TeX Work. O'Reilly & Associates, Inc.

Williams
Thomas Williams & Colin Kelly. GNUPLOT An Interactive Plotting Program. Public Domain.

Zandt
Timothy Van Zandt. seminar.sty: A LaTeX style for slides and notes-User's Guide. Public Domain.



Return to front