
\documentclass[bib,11pt]{article}

 \usepackage{epsfig}
 \usepackage{graphicx}
 \DeclareGraphicsRule{.JPG}{eps}{*}{`jpeg2ps #1}

% I think the default margins are too wide 
\setlength{\topmargin}{-1.2cm}
%\setlength{\headsep}{.2cm}
\setlength{\textheight}{9.5in}
\setlength{\textwidth}{6in}
\setlength{\oddsidemargin}{0cm}
\setlength{\evensidemargin}{0cm}


%\def\baselinestretch{1.2}
% this is how you get double spaced

\def\rule1{DO NOT USE FIRST PERSON}
% these definitions are called macros
% abreviations are excellent for lazy people
 
\begin{document}

\section{Intro}\label{s:intro}

In this section I will introduce the problem.
I will not use heavy mathematical terms. I will
describe the problem in laymans terms only.
And, oops, I have forgotten the golden rule: \rule1!

This file should have extension .tex. You then ``latex" it, to produce
a .dvi which is the document to read. This is done by typing
{\tt latex filename.tex} on the command line. If you are on a math department
machine, Tex will already be there. For your home pc or Wondows laptop,
google Miktex. This is a Latex package you can download for free.
On your start menu, go to {\tt run...}, put in {\tt cmd} and hit enter.
This gives you are command line. Use {\tt cd } to change to the directory
your .tex file is in. Then {\tt latex filename.tex} should work. 


A .aux file is also
produced when you latex your file. This contains all the numbering for
the sections and equations. Anything you might want to refer to
later in your document, you put a label on. The .aux file contains
all your label info.

The label on the section heading is so I can refer to it
later. I put ``s:" at the start of my section labels just
to help kep them distinct from other labels. For example,
I put ``eq:" at the start of equation labels.

\section{A more interesting section}\label{s:defn}

Section \ref{s:intro} was light-weight mathematically.
Now in Section \ref{s:defn} I'll lift the pace a bit.

The first time you latex the file, some numbers are just ??.
This is because first time through the .aux file is empty,
but the labeling info is then stored in the aux file. So
latexing again will fill all the numbers in. So, latexing twice
is good practice to ensure the numbering is correct.

If you are not sharing your file, then the .dvi will be all you need.
But if are going to share your file with someone who doesn't use tex,
they probaby won't have a .dvi viewer. So in those cases I do
{\tt pdflatex}, rather than {\tt latex} to latex my document. 

\subsection{Biology}\label{ss:bio}
Now I might start by giving the basic info on the biological
process i am going to study. Con't forget to reference
everything. This is so important, not just because of plagerism,
but because if you don't keep track of where you got your information from,
you can forget where you found it \cite[pages 9, 58]{stig}. 


\subsection{Math}\label{ss:math}
And at last I'll start describing the equations
that I'll use to model the problem.
%
\begin{equation}\label{eq:important}
y_t=\phi y_{t-1}+\epsilon_t,
\end{equation}
%
Equation \ref{eq:important} has only one equation. Equation
\ref{eq:moreimportant} is an example of using more that one equation.
%
\begin{eqnarray}\label{eq:moreimportant}
y_t&=&\phi y_{t-1}+\epsilon_t,\nonumber \\
y_t&=&\phi y_{t-1}+\epsilon_t.
\end{eqnarray}


\section{Heavy duty}\label{s:mywork}
Now it's time to get to your actual work.
I'm sure you'll need to include some
graphs and pictures you got from the internet.
 Figure \ref{f:coolpic} shows you how to do that.
%
\begin{figure}[ht]
\begin{center}
\epsfig{file=ar1.eps}
\end{center}
\caption{An autoregressive process with $\phi=0.8$ and $\sigma=0.5$.}
\label{f:coolpic}
\end{figure}

 Figure \ref{f:secondpic} is another picture. Notice that latex will move a picture
 around so that the page breaks are OK.
%
\begin{figure}[ht]
\begin{center}
\epsfig{file=arac1.eps}
\end{center}
\caption{Sample autocorrelation function for AR(1), $\phi=0.8$, $\sigma=0.5$.}
\label{f:secondpic}
\end{figure}



Figures in a tex document are best in .eps format.
But pictures from the internet are oftern .jpg or .gif.
For those we need to specify the size of the picture.
Figure \ref{f:euler} is an example of how to do that.
%
\begin{figure}[ht]
\begin{center}
\parbox{2.4in}{\includegraphics [width=2.35in, bb= 1 1 227 276]{euler.jpg}}
\end{center}
\caption{Leonhard Euler}
\label{f:euler}
\end{figure}


When you have figures a .tex, you can't use {\tt pdflatex}
to make a .dfp in one step. To get a pdf takes two extra steps.
First {\tt latex} as usual to get the .dvi.
Then do {\tt dvips filename.dvi} to convert the 
.dvi to .ps. Now you convert the .ps to a .pdf using another piece
of software. On my Windows laptop,
I use Ghostview, which is a postscript viewer and
converter I downloaded free from the internet.
I pull a menu to select ``convert", I specify ``pdf" and
it makes a .pdf from the .ps.


You often need to include code snippets. 
The verbatim environment is great for that.
%
{\small\begin{verbatim}
      clear
      set obs 2000
      set seed 80348
      scalar phi=0.8
      scalar sigma=0.5
      gen t=_n
      gen eps=sigma*invnorm(uniform())
      gen y=0 in 1
      replace y=phi*y[_n-1]+eps in 2/l
      drop if _n<=500
      replace t=_n
\end{verbatim}}
 

The big advantage of tex is how well it can do math type setting.
You {\it can find examples} of just about anything you are looking for
on the web.
%
\[\left[
\begin{array}{ccccc}
   1   & \rho & \rho^2 &\rho^3 & \dots\\
\rho   & 1    & \rho   &\rho^2 & \dots\\
\rho^2 & \rho &    1   &  \rho & \dots\\
\vdots & \dots& \dots  &\ddots & \dots\\
\dots  & \dots& \dots  & \dots & \ddots
\end{array}
\right]\]

\section{How to get the references right}
Endnote is a companion to Word that automatically produces a reference
section for a Word document. For Tex, we have Bibtex.
Let me explain how it works.
 
Create a separate file called, say, papers.bib.
The .bib file contains all the info on the papers you might want to
reference. Each paper you give a code, and the code is what you
put in your .tex document to refer to the paper \cite{choud}. 
The cites are collected in the .aux file. 

To create the bibliography you need to do two things. First have
the right commands at the end of your .tex documents so that it knows
how to format your references and the name of your .bib file.
Second after doing {\tt latex filename.tex}, do {\tt bibtex filename.tex},
and then {\tt latex filename.tex} twice.

One thing I haven't told you: what the .bib file looks like.
Pretty complicated is the answer. This is because you have to enter the
info just right, so that the book or paper has the right parts in italics
and so on. Luckily, getting this right is now easy. When you use a
database or index, for example {it Web of Science}, this citation info
is there for you to copy and paste directly into your .bib file.
When you find a paper in the index, you'll see a little button to
click to download the Endnote version. Well, scroll to the bottom and you should
see a place where you can specify a different type of bibliograph software, and
when you pull the little menu, Bibtex will be one of the choices.

\bibliographystyle{plain}
\bibliography{papers}
\end{document}
