
\documentclass{article}
\usepackage{amssymb}	% Allows use of AMS's mathematical symbols
\usepackage{latexsym}	% Allows use of old latex symbols

%% For old versions of latex, replace the above three lines by
%\documentstyle[amssymbols]{article}

\input{psfig}	% This loads the psfig macros which can be used
		% to include postscript figures in your document.

%
% The next lines declare various styles of theorems that will be numbered
%   consectively.
%
\newtheorem{theorem}{Theorem}
\newtheorem{maintheorem}[theorem]{Main Theorem}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{mainlemma}[theorem]{Main Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}

%
% A custom definition of the definition environment
%
\newenvironment{definition}{\begin{trivlist}\item[]{\bf Definition}\ \em }%
{\end{trivlist}}

%% Some lines you should omit (I used them to make there be less on
%% each page, so I can magnify the document to be legible on overhead
%% transparencies.
%\addtolength{\oddsidemargin}{-.5in}
%\addtolength{\evensidemargin}{-.5in}
%\addtolength{\topmargin}{-.5in}
%\addtolength{\textheight}{-1.8in}

% Begin Document --   Title & Abstract

% These lines specify the title.
\title{
Some Examples of Using \LaTeX \\
(First Draft) }
\author {Samuel R. Buss\thanks{
Supported in part by an NSF grant DMS-3.1415926535 and DMS-2.718281828459045 .}
\\ \small Department of Mathematics \\
\small University of California, San Diego}
\date{\today}

% The Abstract

\begin{document}

\maketitle    % This command generates the title.

\begin{abstract}
We discuss some of the more useful features of LaTeX, especially ones
which differ from other versions of TeX.  We are not trying to give
definitive or in-depth documentation, but just to show some of the
more useful elementary features of \LaTeX.
\end{abstract}

\section{ Numbering sections}
The previous is an example of how section are numbered.

\subsection{ Numbering subsections}
Now we have an example of how subsections are numbered.
One can also number subsubsections.

\section{Typesetting Mathematics}

\LaTeX{} supports the usual features of TeX for typesetting mathematics;
in addition, it has some macros which are useful for formating
mathematics.


\subsection{Automatic numbering of theorems }  Using commands such as
\verb+\begin{theorem}...\end{theorem}+, one can have theorems
automatically numbered.  For example,

\begin{theorem}
Let $ m\ge 0 $.  Then
\[
\sum_{i=0}^m i~ = ~ \frac{ m(m+1) }{ 2 }.
\]
\end{theorem}
\begin{corollary} 
\[
\sum_{i=0}^m ~ = ~ \Omega(m)
\]
\end{corollary}
\begin{lemma}
\[ \sum_{i=0}^m 1 ~ = ~ m+1 \]
\end{lemma}

One can also readily define environments for definitions.  For example, see
the definition of the \verb+definition+ environment above.

\begin{definition}
The numeral 1 denotes the least integer greater than
zero.
\end{definition}

\subsection{Numbered equations}
One can use the commands \verb+\begin{equation}...\end{equation}+ to
typeset a numbered equation.
An example of this the equation
\begin{equation}
\label{TriangleSum}
\sum_{i=0}^m i~ = ~ \frac{ m(m+1) }{ 2 }.
\end{equation}
Please note the use of \verb+\label{...}+ in the above equation,
which allows one
to refer to equation~(\ref{TriangleSum}) by its number using
\verb+\ref{...}+.

\subsection{Multiline equations}
Multiline equations are always difficult to typeset, but \LaTeX{}
supplies a few tools that help somewhat.  Nonetheless, good judgement
is needed to make multiline equations attractive.  

The basic tool for multiline equations is 
\begin{center}
\verb+\begin{eqnarray}...\end{eqnarray}+.
\end{center}
This command generates equation numbers on every line of the
equation: the equations numbers can be turned off selectively
by using \verb+\nonumber+, or they can all be omitted, but using
\verb+eqnarray*+ in place of \verb+eqnarray+.

An example of a multiline equation is:
\begin{eqnarray}
\frac{m(m+1)}{2} & = & 1+2+\cdots+m \\[1ex]
		& = & 0+1+2+\cdots+m \nonumber \\[1ex]
		& = & \sum_{i=0}^m i. \nonumber
\end{eqnarray}

Another example, with a long first line, is:
\begin{eqnarray*} 
\lefteqn{1+2+3+4+5+6+7+8+9+\cdots+(m-1)+m} \\[1ex]    
                & = & 0+1+2+3+4+5+6+7+8+9+10+11 \\
		& & ~~~~ +12+13+\cdots+(m-1)+m \\[1ex]  
		& = & \frac{m(m+1)}{2} \\[1ex]    
                & = & \sum_{i=0}^m i. 
\end{eqnarray*} 


\subsection{Tables and arrays in mathematics}
Arrays or tables are often used in math mode.  Two common examples
are shown next:
\[
I ~ = ~ \left(
	  \begin{array}{ccc}
		1 & 0 & 0 \\
		0 & 1 & 0 \\
		0 & 0 & 1
	  \end{array}
	\right)
\]
and
\[
\delta_{ij} ~=~ \left\{ 
		\begin{array} {ll}
		   1 ~~~ & \mbox{\rm if $i=j$} \\[1ex]
		   0 & \mbox{\rm otherwise}
		\end{array}
	      \right.
\]

\subsection{Tables in non-math mode}
One can also build tables in non-math mode, using the
\verb+tabular+ environment.  Here is a small example:

\begin{center}
\begin{tabular}{|l|cc|}
\hline
\multicolumn{3}{|c|}{Title of table} \\
\hline
\hline
Animal & Feet & Eyes \\
\hline
Sheep & Four & Two \\
Fish & Zero & Two \\
Fly & Six & Many \\
\hline
\end{tabular}
\end{center}

Note that the above example enclosed the \verb+tabular+ environment
in a \verb+center+ environment to make the table be centered.

By the way, entries in tables can be almost anything, including
mathematical formulas, or paragraphs of text, or even tables.
%
% Some things to notice in the above table.
%   & separates columns
%   Every line must end with a \\
%   One can override the standard columning and placement in columns
%         with the \multicolumn command.


\subsection{Tabbing}
Finally, the \verb+tabbing+ environment is a another simply and
useful way to align your data; it's not as flexible as tables,
but it is a lot easier.  For example,

\begin{tabbing}
New Years Day:~ \=January 1 \\
Cinco de Mayo: \>May 5 \\
Halloween: \>October 30 \\
Christmas: \>December 25
\end{tabbing}

\section{Lists and Itemizations}

\LaTeX{} has several similar commands for enumerating or
itemizing lists.  These are controlled with the 
\verb+enumerate+ environment,
the \verb+itemize+ environment,
and the \verb+description+ environment.  The first two automatically
generate numbers or bullets, but these can be overridden with
the \verb+\item[...]+ command.
\medskip

\noindent
Example of the \verb+enumerate+ environment:
\begin{enumerate}
\item This is the first item in the list.

Of course, multiple line and multiple paragraphs are permitted in
the body of a single item in the enumeration.

\item The second item in the list.

\item The last item in the list.  The numeric labels on the items in
the \verb+enumerate+ environment can be overridden with \verb+\item[...]+.
\end{enumerate}

\noindent
Example of the \verb+itemize+ environment:
\begin{itemize}
\item This is the first item in the list.

Of course, multiple line and multiple paragraphs are permitted in
the body of a single item in the itemization.

\item The second item in the list.

\item The last item in the list.  The bullets on the items in
the \verb+itemize+ environment can be overridden with \verb+\item[...]+.
\end{itemize}

\noindent
Example of the \verb+description+ environment:
\begin{description}
\item[First] This is the first item in the list.

Of course, multiple line and multiple paragraphs are permitted in
the body of a single item in the description list.

\item[\sc Second] The second item in the list.

\item[Last] The last item in the list.
\end{description}


\section{Using Bibtex }

Bibtex provides a convenient way of including citations to papers
in a bibliography file.  It allows you to create a single bibliography
file that can be shared among many \LaTeX{} papers.  In addition, many
sources of bibliographic information on the Web now provide citations
in Bibtex format, and these can be readily included in your own
Bibtex files.

For example, one can reference books~\cite{Barwise:handbook},
or one can reference Ph.D. theses~\cite{Bennett:Spectra},
or one can reference journal articles~\cite{AJ,Ackermann},
or one can reference articles in conferences~\cite{Cobham}.
And many other types of references are also possible.

To prepare bibliographies, one must do the following:
\begin{description}
\item[(1)] Create a \verb+.bib+ file, such as the file \verb+samplebibl.bib+
used for this document,
\item[(2)] Add the lines 
\begin{quote}
\verb+\bibliography{samplebibl}  + \\
\verb+\bibliographystyle{siam}     +
\end{quote}
near the end of the \LaTeX{} document, where you want the bibliography
to appear,
\item[(3)] Write citations in the form \verb+\cite{AJ}+ which cite the 
article with the name ``AJ''.
\end{description}

One has to run  latex and bibtex alternately to create all the
appropriate auxiliary files that generate the bibliography citations.
For this file, I had to run:
\begin{quote}
\verb+% latex samplelatex+ \\
\verb+% bibtex samplelatex+ \\
\verb+% latex samplelatex+ \\
\verb+% bibtex samplelatex+ \\
\verb+% latex samplelatex+
\end{quote}

\section{Graphics in \LaTeX}

There are two ways to create pictures in \LaTeX{}.  The first is
its built-in picture environment, which allows a limited amount
of functionality forming pictures.  The second is to include postscript
pictures in your document.

\subsection{The picture environment}

The \verb+picture+ environment allows pictures to be formed from
lines, vectors, circles, disks, psuedo-ovals, boxes, and any \LaTeX{}
object.  Unfortunately, the picture environments has some
serious limitations; lines can have slopes only from a limited set of
slope values, lines must have a certain minimum length, circles
can be no larger than 40 points (about 1/2 inch) in diameter.
However, if a picture environment suffices from your application, it
is often the best choice.

Here is an example, showing some of the features:

\begin{center}
\setlength{\unitlength}{.5pt}
\begin{picture}(225,240)(75,75)    % The x and y dimensions of the picture are
			            %  1000 by 1000.
\put(100,100){\vector(1,0){100}}   % Horizontal vector of x dimension 100
\put(100,100){\vector(0,1){200}}   % Vertical  vector of y dimension 200
\put(100,300){\vector(1,-2){100}}   % Slope -1/2 vector of x dimension 200
\put(145,75){\makebox{$\vec r$}}
\put(75,195){\makebox{$\vec s$}}
\put(165,200){\makebox{$\vec t = \vec s - \vec r$}}

\put(300,150){\circle*{30}}
\put(300,250){\circle{30}}

\multiput(400,100)(0,10){16}{\line(1,1){60}}
\end{picture}
\end{center}

\subsection{The pstricks environment}
The pstricks macro package allows much sophisticated graphics commands
than are allowed by the built-in \verb+picture+ environment.  
Documentation for this is not included in this document.  (You can
get it from the Web from the CTAN - Comprehensive TeX Achive Network -
web site.)

Pstricks is the only package that I know of that allows the full power
of postscript, plus allows you to include TeX formatted mathematical
text in the same figure.

\subsection{Including postscript files}
To include a postscript figure in your document, one uses the
\verb+psfig+ package.  First, near the beginning of the \LaTeX{} document
include the command \verb+\input{psfig}+.  Then use the
\verb+\psfig+ command to include encapsulated postscript files wherever
you wish.  The general format of the \verb+\psfig+ command:
\begin{quote}
\verb+\psfig{figure=+{\it filename}\verb+,height=2.7in,width=4.5in}+
\end{quote}
where the figure will be stretched or compressed to fit the specified
dimensions.  (Important: there should be no extra spaces in the
\verb+\psfig+ command!)

\subsubsection{Including {\sc Mathematica} drawings}
One can include Mathematica graphics in your \LaTeX{} file; for example,
here are two graphs of $sin(x)$, the second having an extra vertical
line at $x=2\pi$.

\penalty10
\vspace*{-.7in}

\noindent
\hfill\psfig{figure=SinePlotFile.eps,height=4.0in,width=4.5in} \hfill

\vspace{-2.0in}
\penalty10

\noindent
\hfill \psfig{figure=SineWithLineFile.eps,height=3.7in,width=4.5in} \hfill

\penalty10
\vspace*{-.7in}

To generate the encapsulated postscript files from Mathematics,
one outputs a graphics object to a file using the \verb+Display+
command.  The \verb+Display+ command does not include the
postscript encapsulation commands, so one must build an encapsulated
postscript file using the \verb+psfix+ command which is supplied with
Mathematica.  As an illustration, the commands that generated the 
two encapsulated postscript files which contain the above two plots
are:

\pagebreak[3]  % Put in a page break if near bottom of page.

\begin{verbatim}
euclid.ucsd.edu% math                                              
Mathematica (sun4) 1.2 (November 6, 1989) [With pre-loaded data]
by S. Wolfram, D. Grayson, R. Maeder, H. Cejtin,
   S. Omohundro, D. Ballman and J. Keiper
with I. Rivin and D. Withoff
Copyright 1988,1989 Wolfram Research Inc.
 -- X11 windows graphics initialized -- 

In[1]:= graphSin = Plot[ Sin [x], {x, 0, 4 Pi}]

Out[1]= -Graphics-

In[2]:= Display [ "SinePlotFile", graphSin ]

Out[2]= -Graphics-

In[3]:= myLine = Graphics[ Line[ {{2Pi, -1}, {2Pi, 1}}] ]

Out[3]= -Graphics-

In[4]:= Show [ graphSin, myLine ]

Out[4]= -Graphics-
 
In[5]:= Display [ "SineWithLineFile", % ] 

Out[5]= -Graphics-
 
In[6]:= Quit
euclid.ucsd.edu% psfix SinePlotFile > SinePlotFile.eps
euclid.ucsd.edu% psfix SineWithLineFile > SineWithLineFile.eps
\end{verbatim}

\subsubsection{Using xfig to generate postscript files}

{sc Unix} has a command \verb+xfig+ that can be used to 
handdraw figures in the \verb+fig+ style.  The native file format
for xfig file are files which the \verb+.fig+ extension.
However, xfig can export files in encapsulated postscript format.

Here is a very simple example of a drawing generated with \verb+xfig+:
\begin{center}
\psfig{figure=collidefig.eps,height=2.5in,width=3in}
\end{center}

To run xfig, you must use OpenWin or another X-windows environment and
give the command
\begin{center}
\verb+% xfig+
\end{center}
If you have used CAD-style programs before, xfig is fairly self-explanatory.
Some things to note especially are that the function of the mouse button
is dynamically displayed in the upper right corner of the window.
Choosing the correct grid resolution will simplify the drawing process
considerably.
Also note that the \verb+Edit+ feature allows you to modify the attributes
of picture objects after they have been created.
You should always save you drawing as a \verb+.fig+ file and, then export
it to postscript afterwards.  (Since xfig can read only \verb+.fig+ format
files, you will need the \verb+.fig+ version to make subsequent
changes.)

\bibliography{samplebibl}  % The name of your .bib file.

\bibliographystyle{siam}     % The style of your bibliography

\end{document}
