\documentclass[12pt]{article}
\usepackage{amsmath,float,graphicx}

\textwidth=6.5in
\textheight=9.5in
\topmargin=-.5in
\headheight=0in
\headsep=.1in
\hoffset  -.75in

\def\dst{\displaystyle}
\def\LA{\LaTeX}
 \def\ra{\rightarrow}
\def\i{\infty}


\pagestyle{empty}

 
\begin{document}

\begin{center}{\large Lesson 14: The Figure environment, the float package and Graphics\\[2ex]
 \ Name:
\rule[-1pt]{2.25in}{1pt} }
 \end{center}
\vskip.25in

Many documents contain tables and figures. If you want \LaTeX to keep track of figures, say for a
list  of figures or tables in a thesis, then these must be treated in a special way. 
The general syntax for a figure or table is\\[2ex]
\begin{minipage}{3in}
\begin{verbatim}
\begin{figure}
PLACE FIGURE HERE
\caption{NAME}\label{FIG:xxx}
\end{figure}
\end{verbatim}
\end{minipage}
\ \ \ \ \ 
 \begin{minipage}{3in}
\begin{verbatim}
\begin{table}
PLACE FIGURE HERE
\caption{NAME}\label{TA:xxx}
\end{table}
\end{verbatim}
\end{minipage} 
\medskip

Also since figures and tables
cannot break across a page they are  what are called floating objects. This means that \LA moves them
around to whereever it thinks they should be.  \LA has options that are supposed to allow you to help
determine where the figures float to. These are used as by replacing the \verb+\begin{figure}+ by
\verb+\begin{figure}[htp]+ (which is the default), for example, if you want the figure to be
\textit{here} and at the 
\textit{top} or a \textit{separate page}. The order that you list the options is not relevent. \LA
claims that an exclamation mark \verb+!+  such as \verb+[!ht]+ will override any of \LA attempts  to
change the floating. I haven't tried it yet.





 To me all this floating   is one of the worst aspects of \LA but
I have learned to deal with it using a special package named \verb+float+. To use it you put in the
preamble the line \verb+\usepackage{float}+. If you use this package with \verb+[H]+ the figure will be
exactly where you put it. Options are
 
\begin{table}[H]
\begin{center}
\begin{tabular}{*2{cl}}
t& Top of page & b & Bottom of page \\
p & Page of floats & h & Here, if possible\\
H & Here, always
\end{tabular}
\caption{The Float Package}
\end{center}
\end{table}

This table was generated using 
\begin{verbatim}
\begin{table}[H]
\begin{center}
\begin{tabular}{*2{cl}}
t& Top of page & b & Bottom of page \\
p & Page of floats & h & Here, if possible\\
H & Here, always
\end{tabular}
\caption{The Float Package}
\end{center}
\end{table}
\end{verbatim}


\vskip.25in
\noindent\textbf{THE CAPTION} 
\vskip.1in

There are a few things you should know about the caption.   The general syntax is
\begin{verbatim}
\caption[short text]{long text}
\end{verbatim}
The \textit{short text} is a short title for the \textit{list of figures} or \textit{list of tables}
pages at the beginning of the thesis or book or whatever you are typing. There should always be a short
name given which is less than a line in length. 
\vskip.1in

\noindent \textbf{N.B.} The \verb+\label+ command must come after the caption in order to function
properly. 
\vskip.1in

\vskip.25in
\noindent\textbf{THE LIST OF FIGURES} 
\vskip.1in
 
To generate the list of figures for the TTU Thesis you would need to put in the commands 
\begin{verbatim}
\listoffigures
\addcontentsline{toc}{chapter}{LIST OF FIGURES}
\end{verbatim}
just after the \verb+\begin{document}+  statement. Similarly for \verb+\listoftables+.  These have
already been put in the Template thesis file on my web page. 



\vskip.25in
\noindent\textbf{Generating EPS Files in Matlab and Incluing in \LA} 
\vskip.1in

In Matlab type 
\begin{verbatim}
x=linspace(0,2*pi);
y1=sin(x);
y2=cos(x);
figure
plot(x,y1)
axis([0,2*pi,-1.2,1.2])
set(gca,'fontsize',18)
print -deps2c sin.eps
figure
plot(x,y2)
axis([0,2*pi,-1.2,1.2])
set(gca,'fontsize',18)
print -deps2c cos.eps
\end{verbatim}

\begin{verbatim}
\begin{figure}[ht]
\centerline{\includegraphics[scale=.5]{sin.eps}\hspace*{.2in}
\includegraphics[scale=.5]{cos.eps}}
\caption{This shows how you might include eps files}
\label{fig1}
\end{figure}
\end{verbatim}

\vspace{.2in}
\begin{figure}[ht]
\centerline{\includegraphics[scale=.5]{sin.eps}\hspace*{.2in}
\includegraphics[scale=.5]{cos.eps}}
\caption{This shows how you might include eps files}
\label{fig1}
\end{figure}

 
\noindent \textbf{PROBLEM:}   
 
 Generate a plot of $  \sin(x) $ and $ \cos(x)$ on the interval $[0,2\pi]$ on the same figure window.
Save the picture to a eps file named \verb+sincos.eps+ and give the syntax to inclue this picture in a
\LA document. 

 

 \vskip.1in
\setlength{\fboxrule}{1pt}

\setlength{\fboxsep}{2in}
\noindent \framebox[6.6in]{}





 

\end{document}
