TeX and LaTeX Information

Last Updated 28th Sept. 1995

Introduction

Due to the recent changes we've made in TeX and LaTeX utilities on the system, it's about time someone made a list of the present capabilities for the text formatting systems that we have. The present guide aims to give a brief overview of what we have, and how to use it.

The main advantage of using TeX systems over the easier-to-use word processing package that we have is in the quality of the output. It is the most commonly used standard for text formatting, and as such is the most popular amongst scientific journals for guaranteeing high quality, standardised output. The flexibility of using pre-formulated macros is a huge advantage; without needing to know anything about page or line layout, the text you've written is in JGR (or whatever) format, complete with their own style of references/citations/figure captions and so forth.

Generic TeX

TeX is the basic system upon which everything else sits, and is described in `The TeX Book' by Donald E. Knuth [1989]. This is the fundamental formatting language which produces the high quality output you see; it was originally written for publishing Maths textbooks, which explains why it is so careful with the formatting of equations. You may want to write your documents in TeX itself; you don't need to use any of the `macro' definition files, and can simply write. The disadvantage is that you may want the output to look different from the default, and you'll then have to write your own definition files to make it do what you want. This is almost certainly the best way of using TeX, and not half as difficult as it first appears, as TeX is completely flexible, and allows you to make your work look any way you want it to.

LaTeX

To take some of the work out of learning how to use TeX, Leslie Lamport constructed LaTeX, a system that uses the basic language of TeX in conjunction with a large array of style files. This makes many bits of TeX easier to use, and the user doesn't need to delve far into the workings of the language. The style files allow choice of a wide variety of different output styles; if you want to be awkward and design your own output, it would be easier to use TeX. If you don't need the flexibility, stick to LaTeX.


Details for CAS

The following details describe the TeX environment on the CAS Sun network.

Configuration

Before you use TeX or LaTeX for the first time, you'll need to set up the correct environment. Add `/usr/local/bin/TeX' to the $path in your .cshrc file. Then add the following lines to your .cshrc file:

setenv LD_LIBRARY_PATH /usr/openwin/lib:/usr/local/lib
setenv XDVIFONTS /usr/local/tex/tex.rasters/generic
setenv TEXINPUTS .:/usr/local/tex/tex.macros:/usr/local/tex/tex.macros/contrib

Logout and back in again for these changes to take effect, or type source .cshrc in from the cmdtool you're using.

Macros

Macros are definitions in TeX/LaTeX, defining what TeX should do on reaching a particular command. For example, you might want to define a `\heading' macro:

\centerline{\def\head#1{\centerline{\underbar{#1}}\vskip 5mm}}

which will center and underline your heading, leaving 5mm of space before the following text, whenever you write `\head{This is my heading}'. For more information, see the TeX and LaTeX books.

The style files used by LaTeX consist of large numbers of these definitions, written in ways that TeX can read them, and hence the work of constructing these definitions has been done for you.


How to use TeX or LaTeX

To run latex, simply type:

latex filename

which will produce the device-independent file filename.dvi. It is conventional to call your original file filename.tex, but not essential. TeX produces a similar dvi file.

The dvi files can be viewed by typing:

xdvi filename.dvi &

which will draw up a window on the screen, displaying the dvi file. You can then page forward and backward with the buttons, and use the various shrink factors to view the file at different magnifications. The mouse buttons can be used to zoom in on a little bit of the file at different magnifications - a very useful option!

xdvi can also be controlled by keystrokes; the most useful of these is to vary the shrink size, hence typing `6 s' in the window will take you to shrink size 6. Just typing `s' will take you to the largest magnification that gets the whole page in the window. Also, to go to page 23 of your document, simply type `23 g'. There are lots of other commands; try the on-line man page to see the full list.

The new xdvi uses ghostscript to render PostScript files embedded in the dvi file; this is particularly useful, as you can arrange text suitably around included PostScript plots.

To translate the dvi file into something the printer can cope with, try:

dvips filename.dvi -o filename.ps

which will give you a PostScript file, filename.ps. Note that dvips has a large number of options, allowing you to select just a few pages of the dvi file to translate, choosing formats, setting resolution or magnification etc. It also reverses the page order of your text on the printer, so that it's the right way round when you collect it. If you want your file printed in landscape mode rather than the default portrait mode, this is the time to do it. Also, if you want to save paper by arranging 4 sheets of your file on each A4 PostScript page, dvips has the power - the easiest way is to put the following line at the top of your TeX/LaTeX file:

\special{header=four.pro}

There's more information on the man page, and a summary available by typing dvips with no arguments.

To view the PostScript, type:

gs filename.ps &

which uses ghostscript to view the PostScript files in the form they'll be printed. If you want a closer look, type:

ghostview filename.ps &

which will allow you to page through the document forwards and backwards, go to particular pages, reorientate them, magnify them etc; it has the same useful magnifying glass feature using the mouse buttons that xdvi has. It will also give you give you the PostScript co-ordinates of the cursor in the window, useful if you have any last minute lines to add or remove from your plots.

The Possibilities

Now you've got TeX or LaTeX running, you'll want to know what macro files we have that will allow you to flex your TeX muscles, and give you the power to control what the text you write looks like when it's printed.

This is not a conclusive list, but the following files may be of interest:

There are a full suite of AMS style files from the American Mathematical Society. There are also title pages, trademark styles, trees... everything is in /usr/local/tex/tex.macros. I'm hoping to create a directory with documentation on the various macro files we have; you'll have to wait for it, though!

Including Pictures

It's very easy to include pictures into TeX or LaTeX files. The basic environment required is set up by calling:

\input epsf

at the top of the text. You can then use a simple box system to include an Encapsulated PostScript file fig.epsf from Unigraph (or wherever) into your text:

\centerline{\epsfysize=5in \epsfbox{ fig.epsf}}

You can control the size with epsfxsize or epsfysize, and stick two side by side using (in TeX for example):

\centerline{\epsfxsize=120mm \epsfbox{ fig1.epsf}
\hskip 22mm \hskip -20mm
\hskip 22mm \epsfxsize=120mm\epsfbox{ fig2.epsf}}

with a similar method in LaTeX.

If you don't have Encapsulated PostScript files, all is not lost - a standard PostScript file can be converted to EPSF by adding a bounding box. This can be done by typing:

bbfig filename.ps > junkfile
gs junkfile

This will display your picture with the bounding box labelled. Simply add the line shown to the top of your filename.ps file, rename it filename.epsf, and delete junkfile.

PSTricks

As well as including PostScript plots, you may want to draw your own diagrams in TeX or LaTeX. This is now possible with the PSTricks package. All you need to use these are the following calls at the top of you text:

\input pstricks.tex
\input pst-node.tex
\input pst-coil.tex

More information is available in the manual.

\pspicture(0,0)(10,10) \hskip 10mm % This defines the picture environment
\hskip 2mm \pnode(5,5){Middle} \hskip 12mm % place `Middle' in the middle
\hskip 2mm \pline(0,2)(10,2) \hskip 18mm % draw a horizontal line
\endpspicture

OK, that's a very simple example; there's a slightly more complex example above. Lines, curves, arrows, arcs, regions of particular colour or fill style; all are available. Complex tree diagrams are especially well treated.

Figure 1. A more ambitious use of PSTricks, considering Odd-Oxygen and Odd-Hydrogen chemistry and some of the feedbacks between them.

Figure 2. Use of PSTricks to draw pretty diagrams....


Fonts

The type face of what you write is controlled by the fonts available on our system. At present the printer has a resolution of 400 dots per inch (d.p.i), and hence the fonts we have are tailored to that resolution. They are also specifically tailored to a sparc printer, and might not look quite so good on other printers. Up until January '95 we were using 300 d.p.i. fonts suitable for a Canon printer; the correct fonts provided a great improvement in both resolution and density.

The font files used by TeX and LaTeX are in the /usr/local/tex/tex.rasters/generic subdirectory, linked to the sparcptr subdirectory. These are compressed as * .pk files. Fonts are defined with respect to the base resolution; they correspond to the basic TeX magnification steps of 0, 0.5, 1, 2, 3, 4 and 5, hence we have fonts at the resolutions 400, 438, 480, 576, 691, 830, and 995.

To use these files, TeX and LaTeX need to be able to find the TeX font metric *.tfm files, which are in /usr/local/tex/tex.fonts.

If you're trying to use a font that we don't have, TeX and LaTeX will tell you. The answer is to use Metafont which makes the font up for you. You can then ask Glenn to put it on the system.

Metafont

This is installed on the system, but not fully available for reasons of space and security. It can be used by arrangement with Glenn.

Metafont is a programme written by Don Knuth for font design. There aren't many word processing packages that let you design your own letter shapes and styles! In practice there are hundreds of different font styles currently available, in almost as many different languages, and the most commonly used are installed on the system.

If you want to use a font that we don't have, first get the *.mf metafont design file from the TeX Archive. Metafont will use this design file (specifications of Bezier curves fitting the font design) to create a font at the desired resolution. A magnification factor is required to produce a font at the required resolution; the base file for Metafont on the system specifies the base resolution (400 d.p.i.) and printer (sparcptr). This will produce a *.gf font, which will need to be packed down into a *.pk font with the gftopk command. More information is available on the man page by typing `man mf'


Information

The usual rule applies here: `If in doubt, read the manual'. However, there are a number of people in the group who have had a certain amount of experience using TeX or LaTeX, and would be happy to help; Oliver, David, Martyn, Nikos....

Personal Additions

To make further additions, it may be worth setting up your own environmental variables to point TeX or LaTeX towards your own personal macros or fonts.

There are a number of other variables, but these are the most important.

It is also helpful to set up a few aliases in your .cshrc file, for example:

alias xdv xdvi -s 4 \!*.dvi (so that you can type: xdv filename)
alias dvi dvips \!* -o \!*.ps (so that you can type: dvi filename)

Useful Information

Most of software connected with TeX, LaTeX or dvi is available from the TeX Archive, and all of it is Free as a matter of principle. To access it,
FTP it from here. The directory tex-archive contains almost anything you could wish for in the TeX world; there's so much stuff there, it'll probably take a moment to find what you're looking for. The same page is available on the World Wide Web.

Happy TeX-ing!


oliver@atm.ch.cam.ac.uk