\documentclass[12pt]{article}
\pagestyle{plain}
\usepackage{amssymb,graphicx,amscd}
\newtheorem{theorem}{Theorem}
\newtheorem{prop}{Proposition}
\newtheorem{cor}{Corollary}
\newtheorem{ex}{Example}
\begin{document}
\title{\LaTeX\ for Beginners}
\author{John B. Little}
\date{February 3, 2016}
\maketitle 

\begin{abstract}
\TeX and \LaTeX\ are typesetting programs for mathematical and
other technical documents including in-line and ``displayed''
equations.  This document shows some basic examples of
formatting in the article document style in \LaTeX.
To use them, you create
an input source file (like this one!) containing text, specifications
for the equations and formatting commands using
a text editor.  Then a \TeX\ or \LaTeX\ translator is called
to convert the source file to a ``device-independent'' or
.dvi file containing an intermediate specification of the 
typeset document.  Finally, a previewer or printer-driver
program is used to display the type-set version of the 
file on the computer screen or send it to a printer.
For more information, consult \cite{kn:L}, 
\end{abstract}

\begin{section}{First Steps}

A typeset \LaTeX\ document may consist of
text, ``in-line'' equations, ``displayed equations'' (possibly
occupying one or several lines) and other elements.  It can also contain diagrams,
Postscript graphics, etc.  We'll leave the ``fancy stuff'' for
later!  For now, let's just look at how basic text and 
equations are entered and processed.  

Ordinary text is inserted in the source file just 
as it will appear in the typeset document.  (\LaTeX\ 
is quite ``smart'' about formatting of lines, paragraphs, pages
etc. It right justifies output automatically, knows
to indent paragraphs when a blank line occurs in the 
source file, breaks pages when they are ``full'' automatically, etc.)
For now, I think you'll generally be very satisfied with how things
come out ``by default.''  But
once you get to be a ``master user'', you may (will probably) start to get
very picky and find that you will want to override the 
way \LaTeX\ does things by default on occasion.  For now, 
though, we will just let it do ``its own thing'' in almost all 
cases!

The overall structure of a \LaTeX\ source file is this:  There
is a ``preamble'' at the start indicating the ``document style''
and ``page style''
to be used.  For now, we will use the {\it article}
document style because it is the simplest and the {\it plain}
page style.  There are other
predefined styles, and you can also create your own.

After the preamble comes a line that says
\begin{verbatim} 
\begin{document}
\end{verbatim}
(There is a matching 
\begin{verbatim} 
\end{document}
\end{verbatim}
at the end.
All the text, etc. are placed between these.  (The stuff
between a begin and end like this is called an 
``environment'' in \LaTeX.  The document as a whole
can be thought of as the ``top-level'' environment.
The preamble also includes several definitions of 
``environments'' for statements of theorems, propositions, and
corollaries.  Another example of an environment is the 
``verbatim'' environment used to produce the lines above.
Articles will have titles at the top of the first page and
may have abstracts -- look
at the way the title and abstract are specified above. 

Equations come in two forms as mentioned above,
``in-line'' and displayed.  ``In-line'' equations
are set off from plain text in the source file
by single \$'s (dollar signs).  For example, 
here is a simple in-line equation: $a = b\beta + c\gamma$.
Note that the typeset version uses italics
for the letters and includes the actual Greek letters
specified by their names in the input.  If you look at the
point in the source file corresponding to second
sentence of this paragraph,
you will also see that the dollar sign there
was entered with a preceeding ``backslash character''.
Specifications for special symbols (such as Greek letters
and mathematical symbols) and 
\LaTeX\ formatting commands begin with this character.
(That's how \LaTeX\ knew we wanted an actual dollar
sign above rather than the start or end of an
in-line equation.)  

Within equations, subscripts are indicated by the 
underscore character, and superscripts (exponents)
by the carat.  If you want a subscript with several
characters, they need to be grouped together using
curly brackets.  For example:
$f'(x) = nx^{n-1} +  g(x)$. 
(Question:  Suppose you want to actually include
a curly bracket in an equation -- for instance
in a definition of a set.  How do you think
that is done?  Right:  using backslashes! $\{\}$.)

Within text or equations, you can also control the 
fonts used to display things.  For instance in text
you can use {\it italic} (or \emph{italic}), {\bf bold}, ... .  In 
equations, you can use ${\mathbb R}$ ("blackboard bold" -- 
this is part of the amssymb package loaded in the preamble),
$\mathcal{C}$ (``calligraphic'' letters), $\mathfrak{a}$
(old-style German ``fraktur'' letters) and many others.

In general the specifications for special symbols
in \LaTeX\ are usually (close to) their actual names.
For instance the integral sign is ``backslash - int'':
$\int_0^1 \sin(t^2)\,dt$.  The \LaTeX\ book and numerous
online \LaTeX\ ``reference cards'' that you will 
find easily via Google have tables
showing all of the standard ones and their specifications.

Displayed equations can be specified in several
ways, either using double dollar signs, or 
using backslash-square brackets.  Here is a 
displayed equation giving one definition 
of what's called \emph{the Fourier transform}:
\[
{\cal F}[f](\omega) = 
\frac{1}{2\pi}\int_{-\infty}^\infty f(t)e^{-i\omega t}\ dt.
\]

Displayed equations extending over several lines 
can be created with the {\tt eqnarray} or {\tt eqnarray*} environments.
This one is an {\tt eqnarray*}:

\begin{eqnarray*}
a_0(x,0)/b_0(x,0) & = & -3 - 2x - 9x^2,\\
b_0(0,y) & = & -3 + y,
\end{eqnarray*}

This one is an {\tt eqnarray}:

\begin{eqnarray}
a_0(x,0)/b_0(x,0) & = & -3 - 2x - 9x^2,\\
b_0(0,y) & = & -3 + y,
\end{eqnarray}

See the difference?  Some people number every displayed equation in
a paper, but I think that ends up looking ``busy'' on the page -- I'd
recommend only numbering equations that you want to refer back to 
later.  Here's how to do that:  In the equation, put in a \begin{verbatim} \label \end{verbatim}
definition like this:

\begin{verbatim}
\begin{equation}
\label{newformula}
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}.
\end{equation}
\end{verbatim}

The typeset version of the equation looks like this:

\begin{equation}
\label{newformula}
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}.
\end{equation}

To create the statement of a Theorem, Proposition, etc. use 
environments like this: 

\begin{verbatim}
\begin{theorem}
\label{MVT}
(Mean Value Theorem) Let $f(x)$ be continuous
on $[a,b]$ and differentiable on $(a,b)$.  Then there exists
a $c\in (a,b)$ such that 
$$f'(c) = \frac{f(b) - f(a)}{b-a}.$$
\end{theorem}
\end{verbatim}

And the typeset version looks like this:

\begin{theorem}
\label{MVT}
(Mean Value Theorem) Let $f(x)$ be continuous
on $[a,b]$ and differentiable on $(a,b)$.  Then there exists
a $c\in (a,b)$ such that 
$$f'(c) = \frac{f(b) - f(a)}{b-a}.$$
\end{theorem}

Note that the convention is to typeset the text of theorems, propositions, etc.
in an italic font to make them stand out.
The ``labels'' lines here are used if you want to make cross-references
to this theorem within the text by number. 
Then if you want to refer to a theorem or an equation later, you use a \emph{reference},
like one of these:
The quadratic formula gives (\ref{newformula}) for the roots of the equation 
\[
a x^2 + b x + c = 0.
\]
\LaTeX\ keeps track of the equation numbers automatically. If you say 
Theorem~\ref{MVT}, the number is filled in automatically by 
\LaTeX.  This is especially useful for when you make changes, 
insert new items in a source file, and so forth.  \LaTeX\ will
automatically generate the correct new numbers when you 
recompile the source file. 


\begin{prop} If the infinite series $\sum_{n=1}^\infty a_n$ converges,
then 
\[
\lim_{n\to\infty} a_n = 0.
\]
\end{prop}
\end{section}

To typeset matrices:

\tiny
\[
A = \left( \begin{array}{ccc} a & b & c \\
                              d & e & f \\
                              g & h & i \end{array}\right).
\]
\normalsize

\[
A = \left( \begin{array}{ccc} a & b & c \\
                              d & e & f \\
                              g & h & i \end{array}\right).
\]
Note that the default is to number Theorems, Propositions, etc. 
in separate sequences.  You can override that if you want, though.

Note that summations, integrals, etc. are typeset differently in 
inline formulas and in displayed formulas.  If you want to use the 
display style in an inline formula, though, (for instance to improve readability)
you can do it like this:  $\displaystyle{\sum_{n=1}^\infty a_n}$.
This was produced by the following commands in the source file:
\begin{verbatim}
$\displaystyle{\sum_{n=1}^\infty a_n}$.
\end{verbatim}

\begin{section}{Graphics in \LaTeX\ documents}

\LaTeX\ has several features for incorporating graphics of 
various sorts into documents.  For \emph{basic} pictures (say
things with straight lines, circles, ...) you can use
the built-in {\tt picture} environment.  The idea here is based
on specifying parts of an image through Cartesian coordinates.    
Here is an example, showing the source file lines:
\begin{verbatim}
\begin{center}
\begin{picture}(100,120)
\put(60,10){\line(0,1){100}}
\put(-10,50){\line(1,0){140}}
\put(120,40){$x$}
\put(63,110){$y$}
\put(90,70){\circle*{4}}
\put(95,70){$P = (a,b)$}
\put(75,40){$a$}
\put(53,57){$b$}
\put(90,70){\line(0,-1){20}}
\put(90,70){\line(-1,0){30}}
\put(90,53){\line(1,0){3}}
\put(93,53){\line(0,-1){3}}
\put(63,70){\line(0,-1){3}}
\put(63,67){\line(-1,0){3}}
\end{picture}
\end{center}
\end{verbatim}
and the picture they produce:
\begin{center}
\begin{picture}(100,120)
\put(60,10){\line(0,1){100}}
\put(-10,50){\line(1,0){140}}
\put(120,40){$x$}
\put(63,110){$y$}
\put(90,70){\circle*{4}}
\put(95,70){$P = (a,b)$}
\put(75,40){$a$}
\put(53,57){$b$}
\put(90,70){\line(0,-1){20}}
\put(90,70){\line(-1,0){30}}
\put(90,53){\line(1,0){3}}
\put(93,53){\line(0,-1){3}}
\put(63,70){\line(0,-1){3}}
\put(63,67){\line(-1,0){3}}
\end{picture}
\end{center}
Can you guess what each command does?

For more complicated graphs (such as plots produced by Maple\footnote{This is a commercial
computer algebra package.}
or other software, you can use the {\tt epsfig} package to 
include Postscript graphics files -- note
this was included in the {\tt usepackage} in the preamble.
Once you have generated the Postscript, you put in a line like
this:  
\begin{verbatim}
\begin{center}
\includegraphics[width=3.0truein,height=3.0truein]{II.ps}
\end{center}
\end{verbatim}
\noindent
and the graphics are inserted (close to) the point where you 
placed this in the file.  (Note:  \LaTeX\ will sometimes 
move a graph to the top of the next page if there is not 
enough space for it on the current page, or do other things
to try to compose good-looking pages).  Note:  I had to ``fiddle''
with the placement of this graph, though, to keep \LaTeX\ from 
leaving a massive hole at the end of one page(!)
\end{section}

\begin{section}{Installations of \LaTeX}

There are implementations of \LaTeX\ on almost all computer systems now.
The simplest way to use \LaTeX\ and work on a thesis is probably to 
use one of the machines on the Mathematics/CS departmental network,
which has full installations of \TeX\ and \LaTeX\ available for 
all users.  You would create the source file using any text editor.

\begin{figure}
\begin{center}
\includegraphics[width=3.0truein,height=3.0truein]{II.ps}
\end{center}
\caption{A Maple Graph}
\end{figure}

Then from a terminal window:
\begin{itemize}
\item {\tt latex filename} -- (with the name of your source file substituted
in, of course!) compiles the source file.
\item {\tt dvips -t letter filename -o} -- creates a PostScript version of the 
file (suitable for printing on some printers)
\item {\tt ps2pdf filename.ps} -- converts to a .pdf file 
\item {\tt acroread filename.pdf} -- open the file in Acrobat reader (Adobe's previewer
for .pdf files).  You can print from this on paper if you want.  Do that sparingly though(!)
\end{itemize}

The \LaTeX\ system is also available as freeware from several 
sources if you want to install it on a personal PC or Mac.
I recommend the {\tt MiKTeX} version, in conjunction with the 
{\tt WinEdt} ``front end,'' if you are using a Windows PC.  WinEdt
offers a good text editor and toolbar buttons for compiling, previewing,
and printing documents.  It is easy to use and it works very well.  
These are both downloadable from corresponding web sites.  
\end{section}

\begin{thebibliography}{1}
\bibitem{kn:L}  Lamport, L.  The \LaTeX\ Book. Addison-Wesley.  
\end{thebibliography}
\end{document}
