CSE 271 Lab 14: LaTeX

1. Overview

Today we will spend our time exploring LATEX. Among other things, you can use LATEX to write beautifully formatted reports, articles, papers, letters, dissertations, books, and presentation slides. We will only explore a small part of what LATEX can provide in today's class. However, your homework will require that you do some more.

LATEX is actually built on top of TEX. What are they? From Peter Flynn's book (link below):

There are many good online tutorials for LATEX. Some of these include: Today, rather than generate something inferior, I'm going to ask you to skim quickly through a few chapters of Flynn's book in order to get started using LATEX.

2. Using LATEX on the CSE/ECE Suns

While you can write LATEX files with any text editor, in order to view the resulting files, you'll want to be able to run something like ggv (for PostScript files) and acroread or gpdf (for PDF files) from the suns, which means you'll need to have X-Windows running. If you are sitting in front of one of the Suns, then you are ready. If you want to do this work remotely from another computer, you'll need to have X-Windows installed and operational.

One workaround (which I have used from time to time when X was not available) is to ssh to the Suns to edit and 'compile' LATEX source files, and then move the resulting PDF file to a web-accessible location, and then view the PDF using the local web browser (assuming Acrobat Reader is installed locally).

A third option is to install LATEX on your own system. LATEX is available for pretty much every operating system, and there are both very good free and commercial packages. See Flynn, chapter 1 if that is what you want to do.

At this point, you now have access to a number of useful programs relating to LATEX, including latex, xdvi, dvips, bibtex, and more.

2. Writing your first LATEX document

Please read Flynn, Chapter 2: Using your editor to create documents to see a sample document that you can try, and to learn how to format a variety of things in LATEX.

Exercise 1. Revise the sample document from chapter 2 to include the sentence:
Professor Davison said "LATEX is worth much more than $1,000,000 and you can get it for free!".
Make certain that you use the special symbol that will generate the logo which looks a little like LATEX. Also be careful about the quotes and the dollar sign. If you are using Emacs, note how it helps with some of these issues.

3. Learning about LATEX document structure

Please read Flynn, Chapter 3: Basic document structures to learn about various commands to determine the kind of document you can create, and some aspects of how it is to be presented.

Exercise 2. Work through the (very simple) exercises in chapter 3, but make sure you use letterpaper instead of a4paper.

Unfortunately, none of those steps included running latex -- so it is difficult to know if you've made an error. But that is taken care of next...

4. Learning about typesetting, viewing, and printing LATEX documents

Please read Flynn, Chapter 4: Typesetting, viewing and printing to learn how to take the document you have typed and make it into a document that can be viewed or printed.

Pay particular attention to running latex in a terminal or console, as this is the mode you will commonly use. Use dvips to convert the .dvi file to postscript, and ps2pdf to convert the postscript to PDF. Note that the postscript version is the one easily printed (the same way you would print a text file) as the printers here all support the postscript language. You can display a postscript file using ggv file.ps and a PDF file using acroread file.pdf.

Exercise 3. Perform exercise #11 from chapter 4 (that is, to actually print the postscript version of your document). Don't print from Acrobat Reader (too easy). If you've forgotten how to print form the shell, go back to Lab 1 to look it up.

5. Lab complete.

You have now learned enough about LATEX to write simple documents. Note that there is lots more to this system, and you might want to explore other chapters of this tutorial (or look at other tutorials). Note that some CSE (and ISE and Math) faculty will be impressed if you were to use LATEX for your homework assignments.

In practice, you'll probably want to simplify the process so that you don't have to remember all the commands to interpret and convert LATEX files. My approach is to treat it just like a programming project, and build a Makefile. For example, here is the Makefile to a book chapter I wrote in LATEX:

all:    chapter.pdf

chapter.pdf:    chapter.ps
        ps2pdf chapter.ps

chapter.ps:     chapter.dvi
        dvips -P cmz -t letter -o chapter.ps chapter.dvi

chapter.dvi:    chapter.aux
        latex chapter.tex

chapter.aux:    chapter.tex chapter.bbl
        latex chapter.tex
        makeindex -s svind.ist -o chapter.ind chapter

chapter.bbl:    learningweb.bib chapter.tex
        bibtex chapter

If you still have time, you can work on your final homework due Friday.

Last revised: 18 April 2013, Prof. Davison.