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

## 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.

### 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}

### 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:
• the column entries are separated by the ampersand '&'
\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}
postie code}

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

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

\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

\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:

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

• You *cannot* have an empty \begin{verbatim}...\end{verbatim} Put garbage text in until you have some real stuff.
• Remove *all* whitespace before the closing brace '}' or your document might blow up.
• Don't leave extra returns in tables and things -- it's nasty...

## 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.

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? :)