Grabbed from: http://www.astro.rug.nl/~kuijken/latex.html [2000­12­11]
Some changes have been made by me, for me. [zrajm]

A Quick Guide to LaTeX

Table of Contents

  1. DESCRIPTION
  2. STUPID TEX TRICKS
  3. MOST USEFUL (AND MOST ASKED) ANSWERS TO QUESTIONS
  4. SUMMARY OF LATEX COMMANDS
  5. SAMPLE SESSION
  6. THE MANY MODES OF LATEX
  7. USEFUL LATEX PACKAGES
  8. USAGE OF BIBTEX
  9. SAMPLE DOCUMENTS
  10. DEBUGGING HINTS
  11. COMMON PROBLEMS AND DUMB LATEX TRICKS
  12. ACKNOWLEDGEMENTS
  13. SEE ALSO (FILES)
  14. SEE ALSO (BOOKS)
  15. SEE ALSO (PROGRAMS)

DESCRIPTION

LaTeX is a document preparation system of relative non­complexity and great frustration. For the most part, it also works.

The best use of LaTeX is for long, complicated documents with lots of formulas and few pictures. Trust me on this one...

It does a good job for documents that *need* structure, allowing you the flexibility to easily modify the text, without worrying about how it's going to turn out.

LaTeX is actually a set of macros on top of the TeX document preparation system. This describes only the formats of LaTeX.

The format of a document is pretty simple:


\documentstyle{}

... this is called the preamble ....

\begin{document}

... nice text and actual work here ....
...  this is called the body  ...

\end{document}
There are, as implied by the comment above, many different 'styles' of documents. The ones that I know of (I haven't bothered to actually create any styles of my own :) are:

style: letter article report book slides

There are several nice formatting tricks that LaTeX does, depending upon which format you use.

STUPID TEX TRICKS

First of all, file names (except inside your document) NEED the '.tex' extension. You do need it!

The following characters are illegal TeX input (except if you know how to use them, of course):

 # $ % & ~ _ ^ \ { }
DON'T use these unless you know what you're doing! In order to get what you expect, type a '\' in front of them:

 \# \$ \% \& \~ \_ \^ \\ \{ \}
Notice that the comment character in LaTeX is the '%' character. Comments start from the comment character until the end­of­line.

LaTeX also allows free­form text input. This means that it doesn't matter how many tabs, spaces you have, LaTeX has its own idea of what your document will look like. It is important to note that a single newline is NOT enough to make different paragraphs. There has to be at least two of them to separate the paragraphs.

MOST USEFUL (AND MOST ASKED) ANSWERS TO QUESTIONS

How Do I Insert PostScript Graphics Into LaTeX?

It's not nice but it can be done. Here is a sample document that just inserts in an EPS (PostScript) file called 'test.eps' into LaTeX. Note that the size of the graphic must be guesstimated and inserted.


\documentstyle{article}

% define a macro
\def\texpsfig#1#2#3{\vbox{\kern #3\hbox{\special{psfile=#1}\kern #2}}\typeout{(#1)}}

\input epsf   % load the epsf library

\begin{document}

%  Insert the graphic and put a border around it
\centerline{\texpsfig{test.eps}{4.563in}{3.813in}}
\makebox[4.563in]{\rule{0in}{3.813in}}

\end{document}
For more information on this (at your own risk), see dvips(1).

How Do I Get LaTeX to Double­Space?

Simple, just type:

\renewcommand{\baselinestretch}{2}
For other spacing (ie triple) just change the 2. Now doesn't that just seem intuitively obvious? :)

How Do I Make a Simple Table?

Not that difficult. The following creates a table (with lines surrounding all of the entries):

\begin{tabular}{|l|r|c|}
Person & Money Owing & Silly Comment \\ \hline
Mr. Cairo & $1943.12 & pay him again, Sam \\ \hline
Mr. Pink & \$55.55 & what robbery? \\ \hline
Mr. Scaramanga & \$666.00 & the golden rule \\ \hline
Mr. Capone & \$300.51 & bad accountants \\ \hline
\end{tabular}
Things to notice:

How Do I Make A Landscape (Sideways) Page?

There are two universally accepted orientations to pages: landscape and portrait. These refer to how a rectangular piece of paper is oriented, and the names are supposed to be indicative of their typical use. A landscape page is flipped in the same way that you would see a painting of a lovely hillside scene (ie lambs, shepherds, chainsaw...). A portrait page is such that it most tellingly reveals the features of the human face - as awful a concept as that sounds...

This ought to fix it:

 \special{landscape}
Note however, that xdvi(1) currently barfs all over the virtual rugscape, as it does not understand the landscape option.

A voice from the Netherland wilderness yells: "No wait! There is a way":

   xdvi -paper a4r filename
(Thanks to Peter@infolab8@kub.nl for this suggestion)

Alternatively, use dvips to do it:

   dvips -t landscape
See dvips(1) for more information and other options.

SUMMARY OF LATEX COMMANDS

Note that some of this won't be useful unless you actually (gasp!) buy a book on LaTeX. A book really does help, by the way...

Document Wide Stuff:

	\documentstyle[options]{style}
      style: article  report  book  slides
    options: 11pt  12pt  twoside  twocolumn  titlepage  leqn  openbib
             fleqn

	\pagestyle{style}
		style: plain  empty  headings  myheadings

	\pagenumbering{style}
		style: arabic  roman  alph  Roman  Alph

Title Page Stuff:

	\maketitle

	\begin{titlepage} ... \end{titlepage}

	\begin{abstract} ... \end{abstract}

Cross­Reference:

	\label{key} 
		assign current counter value to key

	\ref{key}  
		print value assigned to key

Bibliography and Citation

There is (well, it'll be here RSN) some more information here in this document that gives an example of the bibtex stuff.

	\bibliography{...}

	\begin{thebibliography}{label} ... \end{...}
		make bibliography; lable is the widest entry label

	\bibitem[label]{key}
		begin bibliography entry for citation key
		 with label as its label

	\cite[note]{keys}
		cite reference(s) keys with added note

Input from Different Files:

	\input{file}  
		read the file

	\include{file}  
		read the file unless not in \includeonly{}

	\includeonly{filelist}  
		exclude any file not in filelist

Mathematical Formulas:

	$ ... $ or \( ... \)  
		in­text formulas

	\[ .. \] 
		displayed formulas

	\begin{equation} ... \end{equation}
		a numbered equation

	\begin{eqnarray} ... \end{eqnarray}
		numbered equations, like 3 column array enviroment
		\nonumber omits one equation number,
		eqnarray* omits all

	_{ ... }
		subscript.  NB: don't need the braces for one character

	^{ ... }
		superscript.  NB: don't need the braces for one character

	'    prime

	\frac{n}{d} print the numerator over the denominator

	\sqrt[n]{arg}   the nth  root of the argument arg

	ellipsis \ldots ...  \cdots ...  \vdots ...

Greek letters \alpha ... \omega  and \Alpha ... \Omega

	delimiters \left or \right followed by delimiters

	\overline{expression}
		print a rule over the expression

	space thin \.  medium \:  thick \;  negative thin \!

Displayed Paragraphs:

	\begin{quote} ... \end{quote}
		short displayed quotation

	\begin{quotation} ... \end{quotation}
		long displayed quotation

	\begin{flushleft} ... \end{flushleft}
		left flush lines, separated by \\

	\begin{center} ... \end{center}
		centered lines, separated by \\

	\begin{flushright} ... \end{flushright}
		right flush lines, separated by \\

	\begin{verse} ... \end{verse}
		\\ between lines, blank line between stanzas

	\begin{verbatim} ... \end{verbatim}
		in fixed­length, typewriter face exactly as formated
		- use any characters you like!

Lists:

Begin each item with \item or \item[label]
	\begin{itemize} ... \end{itemize}
   		a 'bulleted' list

	\begin{enumerate} ... \end{enumerate}
		a numbered list

	\begin{description} ... \end{description}
		a list of labelled items

Sentences and Paragraphs:

	quotes single ` ... ' and double `` ... ''

        (separate with small space \, if double quote is followed by
        aphostrope or vice versa, if you literaly want two aphostropes
        place empty brackets between '{}')

	dashes intra-word: -     number range: --    punctuation: ---

	emphasis  {\em }

	unbreakable text \mbox{ ... }

	footnotes \footnote{ ... }

	date \today

Type Styles:

	\rm roman  \em emphasis  \bf boldface  \it italic  \sl slant

	\sf  sans serif  \sc  small caps  \tt monospace typewriter face

	\boldmath  use bold math symbols

Type Size:

These need to be organized into a reasonable sequence of small to large or vice versa

	\tiny   \small  \large  \huge  \scriptsize  \normalsize  \Large

	\Huge  \footnotesize   \LARGE

Accents and Symbols:

You *really* need to see these to make any sense of it!

	\'{o} \`{o} \~{o} \v{o} \c{o} \={o} \H{o} \d{o} \^{o} \.{o} \t{o} \b{o}

	\"{o} \u{o}

	\dag  \ddag  \S  \P  \copyright  \pounds

Sectioning and Table of Contents:

	\part  \section  \paragraph  \ chapter  \subsection

	\subsubsection  \subparagraph

	\appendix   
		no output, but the next sectioning commands are
		in the appendices

	\tableofcontents  
		create a table of contents

Line Breaking:

	\linebreak[n]
		force [or encourage] a linebreak; 0 <= n <= 4

	\nolinebreak[n]
		forbid [or discourage] a linebreak; 0 <= n <= 4

	\\[len]
		start new line and leave len vertical space
                [[doesn't align the right margin of the broken line]]

	\-	permit hyphenation

	\begin{sloppypar} ... \end{sloppypar}
		Don't complain about lines that are a bit too long or
		too short

Page Breaking:

	\pagebreak[n]
		force [or encourage] a page break; 
		0 <= n <= 4

	\nopagebreak[n]
		forbid [or discourage] a page break.
		0 <= n <= 4.

	\samepage
		Only break pages in between paragraphs

	\newpage
		Begin a new page

	\clearpage
		Prints all figures and tables on the page
                and begins a new page

Boxes:

	\mbox{...}
	\makebox[wd][pos]{...}
		make box of width wd; pos puts text at (l)eft, (r)ight,
		or center pos defaults to center

	\fbox{text}
	\framebox[wd][pos]{text}
		Same as \mbox or \makebox except draws a box around the box

	\newsavebox{cmd}
		defines cmd as a "bin" for saving boxes into

	\sbox{cmd}{text}
	\savebox{cmd}[wd][pos]{text}
		same as \mbox or \makebox but saves the box in bin cmd

	\usebox{cmd}
		Print the box saved in bin cmd

	\begin{minipage}[pos]{wd} ... \end{minipage}
		make a parbox of width wd, aligned by pos at 
		(t)op, (b)ottom, or center line.
		center is the default

	\parbox[pos]{wd}{...}
		same as minipage for small amounts of text,
		no displayed environments.

Length:

units: cm, em, ex, in, pc, pt, mm
	cm	Centimetres
	em	The width of the letter M in the current font
	ex	The height of the letter x in the current font
	in	Inches
	pc	Picas (1pc = 12pt)
	pt	Points (1in = 72.27pt)
	mm	Millimetres

	\newlength{cmd}
		define cmd to be a length

	\setlength{cmd}{len}
		set length of cmd to be len

	\addtolength{cmd}{len}
		add len to length cmd

	\settowidth{cmd}{txt}
		set cmd to width of txt

Some useful length names to know:

	\baselinestretch	A decimal value for the spacing.  Example:
				To set double­spacing on your document,
				use the command:
					\renewcommand{\baselinestretch}{2}

	\textwidth		The normal width of the text on the page
				Example:  To change this, use the command:
					\setlength{\textwidth}{x}
				where x is a length.  NOTE: If you change
				the textwidth, you will almost certainly want
				to change the evenside­ and oddsidemargin

	\textheight		The normal height of the body of a page.

	\oddsidemargin		One inch less than the distance from
				the left edge of the paper to the left
				margin of the text on right­hand pages

	\evensidemargin		The same as \oddsidemargin except for
				left­hand pages

	\marginparwidth		The width of marginal notes

	\marginparsep		The amount of horiz. space between the
				outer margin and a marginal note

	\topmargin		One inch less than the distance from the
				top edge of the paper to the top of the
				page's head

	\headheight		The height of a box containing the header

	\headsep		The amount of vertical space between the
				header and the body of a page

	\topskip		The minimum distance from the top of the
				body to the bottom of the first line of text

	\footheight		The height of a box containing the page's
				footer

	\footskip		The distance from the bottom of the last
				line of text in the body to the bottom of
				the footer

Adding/Removing Space:

	\hspace{len}
		Make len horizontal space.
		NOTE: len can be negative

	\hfill
	\hrulefill
	Fills the current line with space.  With \hrulefill, the space
	is underlined.  Example:  If you want to create a form that says
	Name: __________, where the underline is 3 inches long, use this:
		Name: \makebox[3in]{\hrulefill}

	\vspace{len}
		Leave len vertical space.

Pictures:

	\begin{picture}(x,y)(x',y') ... \end{ ... }
		x by y picture with the lower left corner at (x',y')

	\put(x,y){ ... }  
		put object at point (x,y)

	\multiput(x,y)(delta­x,delta­y){n}{ ... }
       make n copies of the picture with the first at (x,y) and
       others offset by (delta­x,delta­y)

	\makebox(x,y)[pos]{ ... }
       make x by y box; pos puts object at top (t), bottom (b),
       left (l), right (r), and / or centered (default);
       \framebox and \savebox have analogous forms

	\dashbox{d}(x,y)[pos]{ ... }
		 like \makebox but puts dashed lines of length d
		 around box

	\line(h,v){l}
		line of slope h by v and length l; 0 <= h, v <= 6

	\vector{h,v}{l}
		same as \line but draws arrowhead; 0 <= h, v <= 4

	\shortstack[pos]{ ... }
		like \begin{tabular[pos] ...

	\circle{d}
		draw circle of diameter d; * form draws solid disk

	\oval{x,y}[partial]
		draw x by y (partial) oval

	\frame{ ... }
		draw frame around object

	line thickness   \thinlines or \thicklines

Figures and Tables

:
	\begin{figure} ... \end{figure}
		make a floating figure

	\begin{table} ... \end{table}
		make a floating table

	\caption{ ... }
		make figure or table caption

The 'tabbing' Environment:

Rows are separated by \\; columns determined by:

\= set tab stop \> go to the next tab stop \kill throw­away line

The 'array' and 'tabular' Environments:

	\begin{array}[pos]{cols} ... \end{array}

	\begin{tabular}[pos]{cols} ... \end{tabular}
Use array for fomulae; tabular for text. Items separated by '&' and rows by '\\'; pos aligns with top (t), bottom (b); cols entries format columns

 	 l left­justified column

 	 r right­justified column

 	 c centered column

 	 | vertical rule

  @{ ... } text or space between columns

  *{n}{ ... } equivalent to n copies of ...

	\multicolumn{n}{col}{ ... }
		span next n columns with col format

	\hline
		draw horizontal rule between rows

	\cline{i-j} 
		horizontal rule between columns i-j

Definitions:

	\newcommand{cmd}[n]{ ... }
		 define new command cmd with n arguments

	\newenvironment{name}[n]{beg}{end}
		define new environment name with n arguments

	\newtheorem{name}{caption}
		define a theorem­like environment name
		captioned by caption

Numbering:

	\setcounter{ctr}{n}  set counter ctr to n

	\addtocounter{ctr}{n}  add n to counter ctr

SAMPLE SESSION

Note that, for some reason. LaTeX requires a looong time to start up. Wait for it.

The following is an example latex session of a document called 'final.tex'. You can see that latex usually complains a lot, for no good reason. Don't worry about it. That's what it does...

	cab017% latex final.tex
This is TeX, C Version 3.14t3
(final.tex
LaTeX Version 2.09 <7 Dec 1989>
(/usr/TeX/tex/macros/report.sty
Document Style `report' <13 Nov 89>.
(/usr/TeX/tex/macros/rep10.sty) (/usr/TeX/tex/macros/titlepage.sty))
(final.aux (budget-mechanical.aux) (budget-electrical.aux) (budget-motor.aux)
(budget-sensor.aux)) [0] (final.toc [1]) [2]
Chapter 1.
[3]
Chapter 2.
[4] (budget-mechanical.tex
Chapter 3.
[5] [6] [7] [8]) [9] (budget-electrical.tex
Chapter 4.
[10] [11]
Overfull \hbox (24.54887pt too wide) in paragraph at lines 107--120
 [] 
[12] [13] [14] [15]
Overfull \hbox (1.5408pt too wide) in paragraph at lines 356--364
 [] 
[16]) [17] (budget-motor.tex
Chapter 5.
[18] [19] [20]) [21] (budget-sensor.tex
Chapter 6.
[22] [23] [24] [25] [26]) [27] [28]
Chapter 7.
(beam.tex [29] [30] [31] (final.aux (budget-mechanical.aux)
(budget-electrical.aux) (budget-motor.aux) (budget-sensor.aux)) ) )
(see the transcript file for additional information)
Output written on final.dvi (32 pages, 69940 bytes).
Transcript written on final.log.
You can view the document by running xdvi:

	cab017% xdvi final.dvi &
xdvi should be fairly self­explanatory. Note that you can 'page' forward through xdvi with the space bar (or n), backward with p, and quit with q. Those are useful enough, if you find something else, tell somebody.

If you find that you like your document, you can pump out a PostScript file by using the command dvips, a la:

	cab017% dvips final.dvi
This creates a PostScript file in your current directory called 'final.ps'. You can print it to your local printer using lpr:

	cab017% lpr -h -Pcab_sparc1 final.ps
CAVEAT: DO NOT PRINT THIS TO A DECWRITER!

A PostScript file typically contains about 40 pages of crap, then the actual document. You *really* don't want to kill the printer, your print quota and the eardrums of people in the room beside you, SO DON'T SEND IT TO A DECWRITER!!!!

THE MANY MODES OF LATEX

So many that I can only remember one right now. Oh well, if you're actually reading this, and know of others, mail pub@cs.ualberta.ca Otherwise I just might decide to ramble on somewhat aimlessly for no good reason whatsoever. And believe me, that would be long, boring and ultimately very unbenefical to read. But that's alright, really.

Math Mode

Math mode is fun, math mode is good for everyone!

USEFUL LATEX PACKAGES

There are several good LaTeX­packages to use:

        ifthen                  Makes it possible to use \ifthenelse
                                and \whiledo loops and ifs.

        calc                    Make arithmetics much simpler!

        vmargin                 A good package to make it easier to
                                set the margins.

        babel                   Hyphenation patterns etc. for
                                different languages. For Swedish use:
                                  \usepackage[T1]{fontenc}  % add åäö
                                  \usepackage[swedish]{babel}

        avantgar                A sanserif typeface (Avantgarde).

        charter                 A serif typeface (Charter).

        tipa                    International Phonetic Alphabet.
                                (Not standard, download it somewhere.)

        cd-cover                Use this to produce CD­covers and booklets.
                                (Not standard, download it somewhere.)

USAGE OF BIBTEX

BibTeX is an organized way of referencing that huge bibliography that we all would like to have for all of our papers, assignments, obituaries, etc. Here is (hopefully) a cogent explanation of how to do it.

There are two parts to the process:

  1. Generate your bibliography in a '.bib' file
  2. Reference your bibliography entry
Note that the sample document for a book has a complete bibliography usage example.

Referencing a Bibliography Entry

This is the useful bit. To reference a work, use a \cite with a comment. For example, to reference the forty­second page of "The HitchHiker's Guide to the Galaxy", which you have given the label 'nopanic', you simply

   ...text that needs a reference to the Guide\cite{nopanic}(page 42)
Simple enough, eh?

Format of the Bibliography File

The name of the file that you create should have a '.bib' extension. The format of each entry is:

   @{label,AUTHOR= "",TITLE= "", ... }
where the document type is one of:

	book   unpublished  article  misc  proceedings
and 'label' is how you want to refer to the entry.

Here is a sample bibliography file:

	@book{booklabel,   % Used when you \cite{this work}
	AUTHOR = "First Last Name",
	TITLE = "Name of the Book",
	VOLUME = 2,  % The volume number -- not needed
	Publisher = {Publisher},
	Address = {City, Province/State,Country},
	Year = 1994}  %  The year the book was published

	@unpublished{unpublishedlabel,
	AUTHOR = "First Last Name",
	TITLE = "Name of the Work",
	Publisher = {Publisher},
	Address = {City, Province/State,Country},
	note= {Just to let you know that BibTeX is fairly flexible...},
	Year = 1994}  %  The year the work was published

	@misc{misclabel,
	TITLE = "Title of whatever it is"}

	@article{articlelabel,
	AUTHOR = "First Last Name",
	JOURNAL = {The Harvard Journal of Really Stinky Things},
	PAGES = {137 -- 142},
	TITLE = "Spiritual Aspects of Locker Room Socks",
	VOLUME = 65,
	NUMBER = 5,
	YEAR = 1992}

	@proceedings{proceedingslabel,
	EDITOR = "Name of the Editors",
	TITLE = "Title of whatever it is"}
	Publisher = {Publisher},
	Address = {City, Province/State,Country},
	Year = 1994}  %  The year the proceedings was published

Notes on BibTeX

Don't forget the '.bib' ending to your bibliography file! For books that you want to be listed in your bibliography, but you just couldn't reference, use a \nocite{label} to do this.

SAMPLE DOCUMENTS

Simple Example

Neat Stuff Example (Nomination Form)

It's nasty, it's brutish, but it works and looks quite nice, thank you very much!

	\documentstyle{article}
	\renewcommand{\baselinestretch}{1.5}
	\setlength{\topmargin}{0pt}
	\setlength{\textheight}{10in}
	\setlength{\parindent}{0pt}
	\setlength{\textwidth}{5.5in}
	\setlength{\topskip}{0in}
	\setlength{\headheight}{0in}
	\setlength{\headsep}{0in}

	\pagestyle{empty}
	\setlength{\oddsidemargin}{.5in}

	\begin{document}

	\begin{center}
	{\LARGE \bf UACS EXECUTIVE ELECTIONS NOMINATION FORM}
	\vspace{.25in}

	\begin{tabular}{ll}
	Position running for: & \makebox[2in]{\hrulefill}\\
	Name of candidate: & \makebox[2in]{\hrulefill} \\
	email: & \makebox[2in]{\hrulefill} 
	\end{tabular}
	\end{center}
	\Vspace{.2in}

	\hspace{0.5in}I, \makebox[2in]{\hrulefill}\hspace{-2in}\makebox[2in]{\raisebox{-0.5em}{\tiny Name (please print)}} nominate \makebox[2in]{\hrulefill}\hspace{-2in}\makebox[2in]{\raisebox{-0.5em}{\tiny Name (please print)}} as\\

	a candidate for the position of \makebox[2in]{\hrulefill}.\\

	email: \makebox[2in]{\hrulefill}\hspace{.5in}Signature: \makebox[2in]{\hrulefill}

	\section*{Supporters:}

	\begin{tabular}{lrr}
	Name: & \makebox[2in]{\hrulefill} & Signature: \makebox[2in]{\hrulefill}\\
	email: & \makebox[2in]{\hrulefill} & \\ 
\ \\
	Name: & \makebox[2in]{\hrulefill} & Signature: \makebox[2in]{\hrulefill}\\
	email: & \makebox[2in]{\hrulefill} & \\
\ \\
	Name: & \makebox[2in]{\hrulefill} & Signature: \makebox[2in]{\hrulefill}\\
	email: & \makebox[2in]{\hrulefill} & \\
\ \\
	Name: & \makebox[2in]{\hrulefill} & Signature: \makebox[2in]{\hrulefill}\\
	email: & \makebox[2in]{\hrulefill} & \\
\ \\
	Name: & \makebox[2in]{\hrulefill} & Signature: \makebox[2in]{\hrulefill}\\
	email: & \makebox[2in]{\hrulefill} &\\
	\end{tabular}

	\section*{Candidate Information}

	\begin{tabular}{lll}
	Are you a UACS member? & Yes: $\bigcirc$ & No: $\bigcirc$ \\
	Are you in the CS program? & Yes: $\bigcirc$ & No: $\bigcirc$ \\
	If no: Are you applying for CS? & Yes: $\bigcirc$ & No: $\bigcirc$
	\end{tabular}

	\vspace{.25in}
	Current Department: \makebox[1.5in]{\hrulefill}\hspace{.25in}Year: \makebox[.5in]{\hrulefill}\hspace{.25in}ID\#: \makebox[1in]{\hrulefill}
\ \\
	Date: \makebox[2in]{\hrulefill} \hspace{.5in} Signature: \makebox[2in]{\hrulefill} 

\end{document}

Neat Stuff Example - Letter

	\documentstyle{letter}

	\begin{document}
	\address{Your name (Confused? Check your Student ID :) \\
	address \\
	postie code}

	\begin{letter}{ To whomever you're addressing/threatening  \\
	their address \\
	their postie code}

	\opening{addressee}

	...  references to pets, burning, and other childhood activities
                   ...

	\signature{Your name (See above)}
	\closing{Yours untruthfully, and backstabbingly (love),}
	\end{letter}

	\end{document}

Article

Sample article which has a title page and some sectioning commands.

	\documentstyle{article}

	\begin{document}
	\title{JFK Assasination: Who Dunnit?}
	\author{Who Me \and Not U \and Not Me Really}

	% Optional:  LaTeX will put in current date if you don't
	%            put in the \date command
	\date{November 22, 1963}

	\maketitle
	\pagebreak


	\section{Dallas, Texas Assisination of JFK}

	... describe this conspiracy ...

	\subsection{The ``Magic Bullet'' Theory}

	... an alternative physical modelling ...

	\subsubsection{The Warren Commission's Findings}

	...  blah, blah, blah ....


	\section{The Aftershocks}

	... Yet Another Section ...

	\section{Who Gained From the Murder?}

	... Even more in­depth stuff ...

	\end{document}

Report/Book

This is a sample book format. The report format is *very* similar. Notice that for long documents, it's a good idea to have separate files in order to modularize the input, and not create one huge, goopy mess.

Notice that this has a table of contents (toc). This means that you have to run latex over the file twice in order for the toc entries to come out correctly.

	\documentstyle{book}

	\begin{document}
	\tableofcontents
	\pagebreak

	\chapter{The First Chapter}

	\include{number1}
	% So this chapter includes a file called 'number1.tex'
	% in the current directory

	\chapter{Now for the Second Chapter}

	\include{blah/number2}
	% So this chapter includes a file called 'number2.tex'
	% that is in the 'blah' directory 


	\chapter{The One Worth Waiting For}

	This could have been an interesting bit\footnote{One of eight}
	except that it has been shown to be injurious to your
	health \cite{nothealthy}(page 666).

	\begin{quote}
	``NO, YOU FOOL!!!  Don't you know that process cheese
	is {\bf CONDUCTIVE}!!!''
	\end{quote}

	\section{Well, Not Really}

	\subsection*{Umm, Just a Throwaway, Actually}

	\subsubsection*{It Only Fills Space Meaninglessly}

	%  Note that when you put the asterisk '*' in front of
	% the text, that the section, subsection etc  DOES NOT appear
	% in the table of contents

	\appendix

	\chapter{And now for the Technical Stuff}

	\include{appendicitis}

	\nocite{notseen}	% Do this so that something you didn't
				% reference makes into your bibliography
	\pagebreak
	\bibliographystyle{plain}
	\bibliography{different}	% references a file called
					%   'different.bib'
	\end{document}

DEBUGGING HINTS

Before panicking, type the letter 'e' and hit return. That will bring up the editor defined in the TEXEDIT environment variable, which can be defined in csh by:

	setenv TEXEDIT "/usr/ucb/vi +%d %s"
This sets the editor to be 'vi' and tells 'vi' to put the cursor at the '%d'th line of the file. For bash users, the variable can be set by:

	export TEXEDIT="/usr/gnu/bin/emacs +%d %s"
This will run the 'emacs' editor.

The line that LaTeX found the error on will then be displayed. At this point, you'll have to know what the error is or you can't compile the document. Sorry, you're on your own.

Getting Rid of Overfull Boxes

LaTeX is very good at documenting its work and puts a lot of information, including error messages, into a log file. For businessletter.latex, it will be called businessletter.log. Every error is described there as best as LaTeX can, together with a line number, which helps to quickly find the right place in a file.

Although the visual method of finding errors with the help of xdvi is probably best for a beginner, there is one category of bugs that requires a different approach - the famous Overfull box. LaTeX produces that message when it cannot properly break a line of text or hyphenate a word, which happens quite often when trying to print a long web page address.

The quickest way of finding those messages is by using grep:

grep Overfull businessletter.log | less
After issuing the above command in an Xterm window, you will see either an empty window (a good thing) or a list of lines where LaTeX has put the ominous word. Go back to Emacs, find the offending lines, then use xdvi to judge how to best fix your document.

COMMON PROBLEMS AND DUMB LATEX TRICKS

ACKNOWLEDGEMENTS

This manpage(?) was created by Kelly Kearney and Geoff Baskwill, who have entirely too much time on their hands, seeing as they are both only undergraduate students... :) (as of March, '94)

Further note that the LaTeX book by Leslie Lamport was originally used (sigh) without permission to create the Commonly Used Commands section.

For some sample ideas and documents, we have to thank: Steve Charlton, Andrew Morris and lots of other people.

SEE ALSO (FILES)

Located in the TeX directory is a set of files which seem to provide some latex­able documents.

In the directory /usr/TeX/tex/macros you find the following files:

btxdoc.tex         lablst.tex         psfig.tex          tb0cyr.tex
btxhak.tex         latex.tex          rotate.tex         tb0hyf.tex
btxmac.tex         lfonts.tex         sample.tex         testfont.tex
epsf.tex           logo.tex           sfonts.tex         testpage.tex
hyphen.tex         lplain.tex         slides.tex         tryfonts.tex
idx.tex            manmac.tex         slitex.tex         tubguide.tex
idxmac-amstex.tex  mftmac.tex         slogofonts.tex     tugbot.tex
idxmac.tex         nul.tex            small.tex          webmac.tex
ind+.tex           null.tex           splain.tex
ind-.tex           plain.tex          story.tex
You can copy these and latex 'em, and read 'em. Won't you? :)

SEE ALSO (BOOKS)

Leslie Lamport, LaTeX: User's Guide & Reference Manual "It's *MUCH* better than nothing..." -- Kells

SEE ALSO (PROGRAMS)

tex(1),latex(1),gnuplot(),xpaint(),xdvi(),emacs(),dvips(1), dviselect(1)
June 19, 1994
pub@cs.ualberta.ca