Wednesday, August 02, 2006


LaTeX Tutorial

pix
Go back to home page

This page provides a progression of examples of using LaTeX for scientific typesetting. Links are provided to both downloadable and online references about LaTeX.
last modified: 02:41 AM CDT, Sun 16 Jul 2006

This page is designed for Unix/Linux users. But I have assembled some tips for people needing LaTeX on windows.

On Unix/Linux, you will need latex, pdflatex, xdvi, dvips and gv. Mandrake Linux 9.0 (and greater) has the annoying feature of only installing latex, but not xdvi, dvips of gv. You will need to install the rpm's for these programs, if they are missing in your Linux distribution. Oddly, pdflatex will not work without dvips, and Mandrake sets no formal dependency of the pdflatex rpm on the dvips rpm.


A first experience with LaTeX

Here we go. Download into a suitable directory (playtex might be a suitable name):

then:

latex jfm2esam.tex
latex jfm2esam.tex That's right, you really should type it twice
xdvi jfm2esam.dvi
dvips -o jfm2esam.ps jfm2esam.dvi
lpr jfm2esam.ps or preview first with gv

After looking at jfm2esam.ps (preferably at the 600 dpi resolution of a good printer) and being suitably impressed and excited, crack open jfm2esam.tex with a text editor and be suitably horrified. Does it really have to be that complicated? Well not always.

Try this for a gentler introduction. Download first.tex. Then

 latex first.tex
latex first.tex
xdvi first.dvi
dvips -o first.ps first.dvi
gv first.ps
lpr first.ps
pdflatex first.tex
gv first.pdf

Note: On some Linux systems, you may have gpdf or xpdf available for viewing pdf files. But gv, which originated as a postscript viewer, seems to have adequate pdf capabilities. ghostview has yielded to gv in recent Linux distros, with ghostview merely providing a symbolic link to gv.

Below you will find a progression of further examples that introduce the finer points of LaTeX. But first, read the manual...


Learning more about LaTeX

  • Besides needing latex, I highly recommend that you have the utilities jpeg2ps, ps2eps and epstopdf, which have been introduced here.
  • I recommend that you use gvim to view and edit the .tex files. For these examples to be highlighted correctly you will need some amendments to tex.vim, provided in my gvim tuneup.

  • Some of the best things in life are free. Not only LaTeX, but the documentation:

    • A not so Short Introduction to LaTeX2e: lshort.pdf. This document might be the only paper reference manual that you will ever need. Here is the home page of one of the authors: Tobi Oetiker.

    • Using EPS Graphics in Latex2e Documents: epslatex.pdf (86 pages) Detailed information about including encapsulated postscript figures in your LaTeX documents.

    • A Sample LaTeX Document: DuplexRef.ps (3 pages) Print this out to see a side-by-side example of the .tex file shown next to the final printed page.

    • Cambridge University Engineering Department also has a lot of good on-line help, though some of the advice is specific to their system.

  • As of March, 2005, the best book about LaTeX is (IMO):
    Guide to LaTeX, Fourth Edition Helmut Kopka and Patrick W. Daly. ISBN 0-321-17385-6

  • Here are some other books worthy of mention. There are three books that constitute the definitive guide to LaTeX. If you have money to burn, you will want to get all three of them, at about $35 each. Owning only one of them would be a rather frustrating experience. But they are becoming out or date, for example there is no mention of pdflatex. You can probably do without these:

    • LaTeX: a document preparation system. Leslie Lamport. ISBN 0-201-52983-1

    • The LaTeX companion. Goosens et al. ISBN 0-201-54199-8

    • The LaTeX Graphics companion. Goosens et al. ISBN 0-201-85469-4

    A book that empasizes typing complicated equations is:

    • Math into LaTeX, 3rd Edition. George Gratzer. ISBN 0-8176-4131-9

  • Latex2e help may be useful to you as an online reference, after you are familiar with LaTeX.

Bundled LaTeX examples

Below are several examples of using LaTeX. After you download thefiles.tar.gz then:

gunzip thefiles.tar.gz
tar xvf thefiles.tar
cd thefiles
cat Readme
  • texample.tar.gz Demonstrates user-defined commands, how to include graphics, and how to ultimately make either a .pdf file or a .ps file. revised February 25, 2003.
    If you are doing this course for credit, your task is to write your own paper in LaTeX. Modifying this example into an original work of your own may be the most productive way to attempt the task. Your paper must include at least two figures, at least one raster image (e.g., photo) and at least one vector graphics image (e.g., a graph of y(x)). Your paper must include at least four equations, with a least two inline and two displayed. At least two of the displayed equations must have a label, and the text must reference the equations.

  • pdfprob.tar.gz New on August 5, 2001. Demonstrates how to overcome certain problems that arise when attempting to use epic graphics within pdflatex. A short description of the problem. Revised slightly on July 13, 2006.

  • amermeteorsoc.tar.gz Shows how to use a "style file" to make the output conform to a publications standard, in this case the preprint style of the American Meteorological Society. The use of BibTex to make bibliographies is also introduced. Revised March 1, 2006.

  • oudis2.tar.gz Shows how to use the style file OUdissertation.cls to make a thesis or dissertation conforming to the standards of the University of Oklahoma's Graduate College. Loaded with examples of graphics, tables, equations, "includes" and BibTex. Revised July 15, 2006 to avoid obsolete doublespace.sty, fix margins, and upgrade for pdflatex.

  • semex.tar.gz Shows how to use LaTeX to make big-print transparencies and how to use the "psfrag" system to annotate .eps graphics with LaTeX symbols. (Traditional transparencies offer much more resolution on the screen than does Powerpoint.) Note: this may be obsolete.

Some Tips

  • As you adapt some of these examples for your own work, you are advised to make a single directory in which to store all the .sty, .cls, .bst and .bib files that you will be reusing in various projects. I made one called mysty in my home directory and have the following line in my .bashrc on gentry.metr.ou.edu:
    TEXINPUTS=.:$HOME/mysty:/usr/share/texmf/tex//:/usr/share/texmf/tex//:
    export TEXINPUTS
    BSTINPUTS=.:$HOME/mysty:/usr/share/texmf/bibtex//
    export BSTINPUTS
    BIBINPUTS=.:$HOME/mysty:/usr/share/texmf/bibtex//
    export BIBINPUTS
    If your texmf directory is elsewhere (try locate texmf), you will need to alter the path accordingly.

  • One of the annoyances of LaTeX is getting the bugs out. When an error is encountered, latex will stop, showing a prompt of ? on the monitor. Note the message about the line number of the alleged error, enter X to abort latex, and then enter :linenumber in gvim (if that is the editor you are using) to lead you to the offending line. For some errors, just (continually) hitting return at the ? prompt will allow latex to complete, and then you may find where things went wrong by viewing the .dvi file.

  • I do my work with three windows open: gvim, xterm and xdvi. Use :w within gvim to write without quitting, use xterm to execute commands and see error messages, and use xdvi to view the .dvi file. Note that xdvi will automatically refresh when it is clicked to become the top window.

  • For spell checking, long ago I used:
    ispell myfile.tex
    ispell is smart enough to skip some, but not all, LaTeX tags and math. But now I use the spell checking features of gvim.

Links


pix
Go back to home page

pix
Move to top of page

No comments: