Starting on Latex: a brief introduction by Christina C. Christara


Latex is a piece of software with the help of which you can write reports, theses or slides. One may say that it is nothing more than Word, but when it comes to mathematics, latex is much richer than Word and its output looks much nicer (albeit not as nice as good old troff). Virtually, all of our grad students use it to write theses (MSc or PhD), or papers for publication, or slides for oral presentations.

You can find lots of information on latex on the web. One useful report is in This is a long but relatively complete document, as far as the basics of latex. There are also books on latex which you can find in the library. Hypertext help with Latex is found in several web sites such as and

However, the easier way to get started it to get some sample files and try to build upon them. Here are some latex files that you can use as samples.

A latex file is a text file ending in .tex.

Simple example

The first example consists of file simple.tex. To run it, type

% latex simple.tex
% latex simple.tex
% dvips simple.dvi
This creates the file (and a few other files which you can "ignore".) You can then ghostview (gv) the postscript file created.

If you prefer to get a pdf file, type

% latex simple.tex
% latex simple.tex
% dvipdf simple.dvi
to get the file simple.pdf, and proceed accordingly.

Note that latex is not "interactive", in the sense that what you see in the latex file is not what you get eventually. You have to run latex and create the ps/pdf file to see the end result.

Another example

The second example is a bit more advanced. It uses a "class file" ( mypaper.cls), a latex file ( mysample.tex), a bibliography file ( paper.bib -- this is useful if you have references), and two encapsulated postscript files ( spyalt.eps, spyblock.eps), read by mysample.tex Do not edit the class file and do not bother with it. Similarly, you don't need to bother with the bibliography file, unless you have references. Of course, do not edit the eps files.

To get an eps (encapsulated postscript) file from matlab, once you have a matlab plot in some window, give

> print -deps file.eps
or, if you have colours,
> print -depsc file.eps
inside the main matlab session. Once you have the eps file you can embed it in any latex file. See, for example, the use of epsfig package in the file mysample.tex.

To run the second example type

% latex mysample.tex
% bibtex mysample
% latex mysample.tex
% latex mysample.tex
% dvips mysample.dvi
You can then ghostview the postscript file created.

Notice that the bibtex command creates the file mysample.bbl. Once you have mysample.bbl created, every time you make a change to the file mysample.tex, you only need to run

% latex mysample.tex
% latex mysample.tex
% dvips mysample.dvi
unless you make a change to the paper.bib file or unless you change the citations to the references inside mysample.tex, in which cases you need to run all commands, including bibtex.


Another use of latex is to produce slides in portrait or landscape format. There are two example files: talkp.tex for portrait and talkl.tex for landscape format. You compile them with latex the same way you do for other latex files, and once you have the postscript files, you can make those print in 4-in-1 format. Use

% psnup -4 > talkp.ps4
for portrait and
% psnup -4 -c -r > talkl.ps4
for landscape. If you ghostview (gv) the files talkp.ps4 or talkl.ps4, you will see that you get four logical pages in one physical page.

The class file for slides is called slides.cls. This file exists on the standard latex distribution, but it is provided here as well, in a version that outputs a little smaller fonts than the regular. One more note: When viewing landscape ps documents with gv you may need to set the gv orientation to "seascape" (this is done within gv), otherwise the document may be upside-down.


For a thesis, there is a special class of documents, ut-thesis.cls This is available already on the system, for example, in

on cogitate.cs, or
on the apps* machines. You don't need to copy this file, it is automatically invoked, when you call it. For an example, of a thesis see
on cogitate.cs, or
on the apps* machines. You can copy that file to your directory and use it as a start for your thesis.

The files ut-thesis.cls and ut-thesis.tex are also found in the Comprehensive TEX Archive Network (CTAN).

You may also be interested in the tips for writing latex files and the MATLAB plot example therein.