Merging all the changes made bu madhu and punch
authoramit
Tue, 07 Sep 2010 11:03:27 +0530
changeset 123 7a16c80c584d
parent 122 70b86355e851 (current diff)
parent 120 7428e411bd7a (diff)
child 124 fe7f10950014
Merging all the changes made bu madhu and punch
latex/examples/final-include.tex
latex/examples/final.bib
latex/examples/final.tex
latex/examples/hello.jpg
latex/examples/hello.tex
latex/examples/lion_orig.png
--- a/.hgignore	Tue Sep 07 10:45:11 2010 +0530
+++ b/.hgignore	Tue Sep 07 11:03:27 2010 +0530
@@ -14,6 +14,7 @@
 *.sty
 *.pyc
 *.zip
+*.org
 *~
 .project
 .pydevproject
@@ -31,4 +32,4 @@
 develop-eggs
 .gitignore
 .DS_Store
-index.yaml
\ No newline at end of file
+index.yaml
--- a/latex/examples/final-include.tex	Tue Sep 07 10:45:11 2010 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-This is the part of the document that has been written into another file, for convenience. This was included in the main file. 
--- a/latex/examples/final.bib	Tue Sep 07 10:45:11 2010 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-@book{Lamport94,
-author    = "Leslie Lamport",
-title     = "A Document Preparation System: User's Guide and Reference",
-publisher = "Addison-Wesley Professional",
-year      = "1994",
-edition    = "second",
-note      = "illustrations by Duane Bibby"
-}
-
-@book{Knuth84,
-author    = "Donald Knuth",
-title     = "The TeXbook",
-publisher = "Addison-Wesley",
-year      = 1984,
-note      = "illustrations by Duane Bibby"
-}
-
-
-
-
--- a/latex/examples/final.tex	Tue Sep 07 10:45:11 2010 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,199 +0,0 @@
-%hello.tex - First LaTeX document
-\documentclass[11pt,a4paper,twoside]{article}
-
-\usepackage{graphicx}
-\usepackage{listings}
-\usepackage{amsmath}
-
-\lstset{language=Python, showstringspaces=false}
-\bibliographystyle{plain}
-
-\title{LaTeX - A Two Hour Introduction}
-\author{The FOSSEE Team}
-\date{August 2009}
-
-
-\begin{document}
-\maketitle
-\tableofcontents
-\listoftables
-\listoffigures
-\begin{abstract}
-This is a sample document to be used in the STTP course for a quick introduction to \LaTeX
-\end{abstract}
-\section{Introduction}
-LaTeX is a typesetting program used to produce excellently typeset documents. It is extensively used for producing high quality scientific and mathematical documents. It may also be used for producing other kinds of documents, ranging from simple one page articles or letters 
-\section{Structural Elements}
-Let us now look at giving a better structure to our document. 
-\subsection{documentclass}
-The \verb+documentclass+ variable tells \LaTeX, the type of document we wish to prepare. 
-
-\subsection{Sections, Chapters and Parts}
-We shall first look at how to divide the document into Sections, Chapters and Parts. 
-
-\subsubsection{Appendices}
-I can't tell you how to add an appendix, in the main document. Refer Appendix \ref{append} to see how to do it. 
-
-\section{Text Typesetting}
-\begin{itemize}
-\item Now we move onto some elementary \emph{Text Typesetting}.
-
-\item How do we get \emph{emphasized or italic text}?
-
-\item \emph{Did you wonder what happens when we try \emph{emphasizing text} within \emph{emphasized text}}?
-
-\item ``Beautiful is better than ugly.''
-
-\item `In the face of ambiguity, refuse the temptation to guess.'
-
-\item LaTeX has 4 different types of dashes. The names of these dashes are: `-' hyphen, `--' en-dash, `---' em-dash and `$-$' minus sign. \footnote{We shall look at how to do math in a later section}
-
-\item \LaTeX has \verb+enumerate+, \verb+itemize+ and \verb+description+ commands to generate lists. 
-
-\end{itemize}
-
-\begin{flushleft}This is left flushed text. \LaTeX normally produces text with no white space at the end of the line. But, this text isn't so, if you can see.\end{flushleft}
-\begin{flushright}Similarly, Right-aligned Text here\end{flushright}
-\begin{center} and centered text here.\end{center}
-
-\begin{description}
-  \item[Description] This list is a description list. 
-  \item[Enumerate] Numbered lists are often useful.
-    \begin{enumerate}
-    \item First
-    \item Second
-    \item Third
-    \item \ldots
-    \end{enumerate}
-  \item[Itemize] The list above this description list is an itemize list.
-\end{description}
-
-\subsection{Quotes \& Verbatim Text}
-Since the \emph{Zen of Python} instructs that, 
-\begin{quote}
-Readability counts.
-\end{quote}
-we use the \verb+quote+ environment to include quotes. 
-
-\begin{verbatim}
-def signum( r ):
-    """returns 0 if r is zero
-    -1 if r is negative
-    +1 if r is positive"""
-    if r < 0:
-        return -1
-    elif r > 0:
-        return 1
-    else:
-        return 0
-\end{verbatim}
-
-\section{Tables \& Figures}
-
-\begin{table}[h]
-\caption{A simple table, on making tables}
-\centering
-\begin{tabular}{|c|c|}
-  \hline
-  \verb+l+ & left justified column content\\ 
-  \hline
-  \verb+r+ & right justified column content\\ 
-  \hline
-  \verb+c+ & centered column content\\ 
-  \hline
-  \verb+*{n}{col}+ & produces \verb+n+ columns with the\\
-                   & \verb+col+ type of formatting\\
-  \cline{2-2}
-                   &\verb+*{3}{c}+ is the same as \verb+{c c c}+ \\
-  \hline
-  \verb+|+ & produces a vertical line\\ 
-  \hline
-\end{tabular}
-\end{table}
-
-\begin{figure}
-\centering
-\caption[CTAN Lion]{CTAN lion drawing by Duane Bibby; thanks to www.ctan.org}
-\label{fig:lion}
-\includegraphics[scale=0.8, angle=30]{lion_orig.png}
-\end{figure}
-
-List of Tables and List of figures can be autogenerated suigng the \verb+\listoftables+ and \verb+\listoffigures+ commands. Let's insert them after the table of contents. 
-
-Cross referencing is one of the best features of \LaTeX. The CTAN lion has the figure number \ref{fig:lion} and is on page number \pageref{fig:lion}
-
-It was drawn by Duane Bibby, a well-known commercial artist. He used this lion in the illustrations for Donald Knuth's original TeXbook\cite{Knuth84}, for Leslie Lamport's LaTeX book\cite{Lamport94}, and for other books having to do with TeX, so his work is familiar to everyone in the community. 
-
-%% \begin{thebibliography}{99}
-%%   \bibitem{Knuth84} Donald E. Knuth (1984). \emph{The TeXbook} (Computers and Typesetting, Volume A). Reading, Massachusetts: Addison-Wesley. ISBN 0-201-13448-9.
-  
-%%   \bibitem{Lamport94} Lamport, Leslie (1994). \emph{LaTeX: A document preparation system: User's guide and reference}.
-%%      illustrations by Duane Bibby (2nd ed.). Reading, Mass: Addison-Wesley Professional. 
-%% \end{thebibliography}
-
-\section{Typesetting Math}
-The equation $F=m \cdot a$ is an equation, that has been set inline. 
-Equation \eqref{force} is the same equation typeset in the display style. Note, that it is also numbered. 
-\begin{equation}
-\label{force}
-F=m\cdot a
-%%\tag{Fore-acceleration}
-\end{equation}
-More equations --- vertically aligned. 
-
-\begin{align}
-\alpha^2 + \beta^2 &= \gamma^2 \\
-\sum_{i=1}^ni &= \frac{n(n+1)}{2}\\
-\sqrt{-1} &= \pm1 \nonumber \\
-y &= \frac{r_1^2-r_3^2-x^2+(x-i)^2+j^2}{2j} \nonumber \\
-  &= \frac{r_1^2-r_3^2+i^2+j^2}{2j}-\frac{i}{j}x \\
-\end{align}
-
-\begin{equation*}
-s(t) = \left\{
- \begin{array}{rl}
-   0 & \text{if } t \le 0\\
-   1 & \text{if } t > 0
- \end{array} \right.
-\end{equation*}
-
-\begin{equation*}
-\mathbf{X} = \left(
- \begin{array}{ccc}
- a_1 & a_2 & \ldots \\
- b_1 & b_2 & \ldots \\
- \vdots & \vdots & \ddots
- \end{array} \right)
-\end{equation*}
-
-\begin{equation}
-  \begin{matrix}
-  1 & 2 \\
-  3 & 4
-  \end{matrix} \qquad \& \qquad 
-  \begin{bmatrix}
-  1 & 2 & 3 \\
-  4 & 5 & 6 \\
-  7 & 8 & 9
-  \end{bmatrix}
-\end{equation}
-
-\section{Miscellaneous}
-\subsection{Presentations}
-\subsection{Including Code}
-\begin{lstlisting}
-string="Hello, World! "
-for i in range(10):
-    print string*i
-\end{lstlisting} 
-\subsection{Including files}
-\input{final-include}
-
-\bibliography{final}
-
-\appendix
-\section{Appendices - How to}
-\label{append}
-Every Part, Chapter or Section that follows the \verb+\appendix+ command is included in the appendix. Appendices have auto numbering too. The numbering begins freshly in the appendices. 
-
-\end{document}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/latex/examples/glimpse-at-scipy.tex	Tue Sep 07 11:03:27 2010 +0530
@@ -0,0 +1,426 @@
+\documentclass{article}
+
+\usepackage{amsmath} 
+\usepackage{graphicx} 
+\usepackage{color}
+\usepackage{listings} 
+\usepackage{url}
+%\definecolor{darkgreen}{rgb}{0,0.5,0}
+
+\lstset{language=Python,
+    basicstyle=\ttfamily\bfseries,
+    commentstyle=\color{red}\itshape,
+  stringstyle=\color{green},
+  showstringspaces=false,
+  keywordstyle=\color{blue}\bfseries}
+
+\title{A Glimpse at Scipy}
+\author{FOSSEE}
+\date{June 2010}
+
+\begin{document}
+\maketitle
+
+\begin{abstract}
+This document shows a glimpse of the features of Scipy that will be
+explored during this course.
+\end{abstract}
+
+\section{Introduction}
+
+SciPy is open-source software for mathematics, science, and
+engineering.
+
+SciPy (pronounced ``Sigh Pie'') is a collection of mathematical
+algorithms and convenience functions built on the Numpy extension for
+Python. It adds significant power to the interactive Python session by
+exposing the user to high-level commands and classes for the
+manipulation and visualization of data. With SciPy, an interactive
+Python session becomes a data-processing and system-prototyping
+environment rivaling sytems such as \emph{Matlab, IDL, Octave, R-Lab,
+  and Scilab}. \cite{scipy}
+
+%% \begin{quote}
+%%         	In 1998, ... I came across Python and its numerical extension
+%%       	(Numeric) while I was looking for ways to analyze large data sets
+%%       	... using a high-level language. I quickly fell in love with
+%%       	Python programming which is a remarkable statement to make about a
+%%       	programming language. If I had not seen others with the same view,
+%%       	I might have seriously doubted my sanity.  -- Travis Oliphant, Creator of Numpy    
+%% \end{quote}
+
+\subsection{Sub-packages of Scipy}
+
+SciPy is organized into subpackages covering different scientific
+computing domains. These are summarized in the \underline{table
+  \ref{subpkg}}.
+
+\begin{table}
+  \caption{Sub-packages available in Scipy}
+  \label{subpkg}
+\begin{tabular}{|l|l|}
+\hline
+
+\textbf{Subpackage} & \textbf{Description}\\
+
+\hline
+
+\texttt{cluster} & Clustering algorithms\\
+
+\hline
+
+\texttt{constants} & Physical and mathematical constants\\
+
+\hline
+
+\texttt{fftpack} & Fast Fourier Transform routines\\
+
+\hline
+
+\texttt{integrate} & Integration and ordinary differential equation
+solvers\\
+
+\hline
+
+\texttt{interpolate} & Interpolation and smoothing splines\\
+
+\hline
+
+\texttt{io} & Input and Output\\
+
+\hline
+
+\texttt{linalg} & Linear algebra\\
+
+\hline
+
+\texttt{maxentropy} & Maximum entropy methods\\
+
+\hline
+
+\texttt{ndimage} & N-dimensional image processing\\
+
+\hline
+
+\texttt{odr} & Orthogonal distance regression\\
+
+\hline
+
+\texttt{optimize} & Optimization and root-finding routines\\
+
+\hline
+
+\texttt{signal} & Signal processing\\
+
+\hline
+
+\texttt{sparse} & Sparse matrices and associated routines\\
+
+\hline
+
+\texttt{spatial} & Spatial data structures and algorithms\\
+
+\hline
+
+\texttt{special} & Special functions\\
+
+\hline
+
+\texttt{stats} & Statistical distributions and functions\\
+
+\hline
+
+\texttt{weave} & C/C++ integration\\
+
+\hline
+\end{tabular}
+\end{table}
+
+\subsection{Use of Scipy in this course}
+Following is a partial list of tasks we shall perform using Scipy, in
+this course.
+
+\begin{enumerate}
+  \item Plotting \footnote{using \texttt{pylab} - see Appendix
+    \ref{mpl}}
+  \item Matrix Operations
+  \begin{itemize}
+    \item Inverse
+    \item Determinant
+  \end{itemize}
+  \item Solving Equations
+  \begin{itemize}
+    \item System of Linear equations
+    \item Polynomials
+    \item Non-linear equations
+  \end{itemize}
+  \item Integration 
+  \begin{itemize}
+    \item Quadrature
+    \item ODEs
+  \end{itemize}
+\end{enumerate}
+\section{A Glimpse of Scipy functions}
+
+This section gives a brief overview of the tasks that are going to be
+performed using Scipy, in future classes of this course.
+
+\subsection{Matrix Operations}
+
+Let $\mathbf{A}$ be the matrix 
+\(
+\begin{bmatrix}
+1 &3 &5\\
+2 &5 &1\\
+2 &3 &8
+\end{bmatrix}
+\) 
+
+To input $\mathbf{A}$ matrix into python, we do the following in
+\texttt{ipython}\footnote{\texttt{ipython} must be started with
+  \texttt{-pylab} flag}\\
+
+\begin{lstlisting}
+  In []: A = array([[1,3,5],[2,5,1],[2,3,8]])
+\end{lstlisting}
+
+\subsubsection{Inverse}
+
+The inverse of a matrix $\mathbf{A}$ is the matrix $\mathbf{B}$ such
+that $\mathbf{A}\mathbf{B} = \mathbf{I}$ where $\mathbf{I}$ is the
+identity matrix consisting of ones down the main diagonal. Usually
+$\mathbf{B}$ is denoted $\mathbf{B} = \mathbf{A}^{-1}$ . In SciPy, the
+matrix inverse of matrix $\mathbf{A}$ is obtained using
+
+\lstinline+inv(A)+.
+\begin{lstlisting}
+  In []: inv(A)
+  Out[]: 
+  array([[-1.48,  0.36,  0.88],
+         [ 0.56,  0.08, -0.36],
+         [ 0.16, -0.12,  0.04]])
+\end{lstlisting}
+
+\subsubsection{Determinant}
+
+The determinant of a square matrix $\mathbf{A}$ is denoted
+$\left|\mathbf{A}\right|$. Suppose $a_{ij}$ are the elements of the
+matrix $\mathbf{A}$ and let
+$\mathbf{M}_{ij}=\left|\mathbf{A}_{ij}\right|$ be the determinant of
+the matrix left by removing the $i^{th}$ row and $j^{th}$ column from
+$\mathbf{A}$. Then for any row $i$
+
+    \[ \left|\mathbf{A}\right|=\sum_{j}\left(-1\right)^{i+j}a_{ij}\mathbf{M}_{ij} \]
+
+This is a recursive way to define the determinant where the base case
+is defined by accepting that the determinant of a $1\times1$ matrix is
+the only matrix element. In SciPy the determinant can be calculated
+with $det$ . For example, the determinant of
+
+    \[ \mathbf{A}=\begin{bmatrix} 1 & 3 & 5\\ 2 & 5 & 1\\ 2 & 3 & 8\end{bmatrix}\]
+
+is
+
+    \begin{eqnarray*} 
+      |\mathbf{A}| & = & 1\begin{vmatrix} 5 & 1\\ 3 & 8\end{vmatrix}
+                        -3\begin{vmatrix} 2 & 1\\ 2 & 8\end{vmatrix}
+                        +5\begin{vmatrix}2 & 5\\ 2 & 3\end{vmatrix}\\  
+                   & = & 1(5\cdot8-3\cdot1)-3(2\cdot8-2\cdot1)+5(2\cdot3-2\cdot5)=-25
+    \end{eqnarray*}
+
+In SciPy, this is computed as shown below
+
+\begin{lstlisting}
+  In []: A = array([[1, 3, 5], [2, 5, 1], [2, 3, 8]])
+  In []: det(A)
+  Out[]: -25.0
+\end{lstlisting}
+
+\subsection{Solving Equations}
+
+\subsubsection{Linear Equations}
+
+Solving linear systems of equations is straightforward using the scipy
+command \lstinline+solve+. This command expects an input matrix and a
+right-hand-side vector. The solution vector is then computed. An
+option for entering a symmetrix matrix is offered which can speed up
+the processing when applicable.  As an example, suppose it is desired
+to solve the following simultaneous equations:
+
+    \begin{eqnarray} x+3y+5z & = & 10\\ 2x+5y+z & = & 8\\ 2x+3y+8z & = & 3\end{eqnarray}
+
+We could find the solution vector using a matrix inverse:
+
+    \[ \left[\begin{array}{c} x\\ y\\ z\end{array}\right]=\left[\begin{array}{ccc} 1 & 3 & 5\\ 2 & 5 & 1\\ 2 & 3 & 8\end{array}\right]^{-1}\left[\begin{array}{c} 10\\ 8\\ 3\end{array}\right]=\frac{1}{25}\left[\begin{array}{c} -232\\ 129\\ 19\end{array}\right]=\left[\begin{array}{c} -9.28\\ 5.16\\ 0.76\end{array}\right] \]
+
+However, it is better to use the solve command which can be faster and
+more numerically stable. In this case it however gives the same
+answer.
+
+\begin{lstlisting}
+  In []: A = array([[1, 3, 5], [2, 5, 1], [2, 3, 8]])
+  In []: b = array([[10], [8], [3]])
+  In []: dot(inv(A), b)
+  Out[]: 
+  array([[-9.28],
+         [ 5.16],
+         [ 0.76]])
+
+  In []: solve(A,b)
+  Out[]: 
+  array([[-9.28],
+         [ 5.16],
+         [ 0.76]])
+\end{lstlisting}
+
+\subsubsection{Polynomials}
+
+Solving a polynomial is straightforward in scipy using the
+\lstinline+roots+ command. It expects the coefficients of the
+polynomial in their decreasing order. For example, let's find the
+roots of $x^3 - 2x^2 - \frac{1}{2}x + 1$ are $2$, $\sqrt{2}$ and
+$-\sqrt{2}$. This is easy to see.
+
+\begin{align*}
+x^3 - 2x^2 - \frac{1}{2}x + 1 = 0\\
+x^2(x-2) - \frac{1}{2}(x-2) = 0\\
+(x-2)(x^2 - \frac{1}{2}) = 0\\
+(x-2)(x - \frac{1}{\sqrt{2}})(x + \frac{1}{\sqrt{2}}) = 0
+\end{align*}
+
+We do it in scipy as shown below:
+\begin{lstlisting}
+  In []: coeff = array([1, -2, -2, 4])
+  In []: roots(coeff)
+\end{lstlisting}
+
+\subsubsection{Non-linear Equations}
+
+To find a root of a set of non-linear equations, the command
+\lstinline+fsolve+ is needed. For example, the following example finds
+the roots of the single-variable transcendental equation
+
+    \[ x+2\cos\left(x\right)=0,\]
+
+and the set of non-linear equations
+
+    \begin{align} 
+      x_{0}\cos\left(x_{1}\right) &= 4,\\ 
+      x_{0}x_{1}-x_{1} &= 5
+    \end{align}
+
+The results are $x=-1.0299$ and $x_{0}=6.5041,\, x_{1}=0.9084$ .
+
+\begin{lstlisting}
+In []: def func(x):
+   ...:     return x + 2*cos(x)
+
+In []: def func2(x):
+  ...:     out = [x[0]*cos(x[1]) - 4]
+  ...:     out.append(x[1]*x[0] - x[1] - 5)
+  ...:     return out
+
+In []: from scipy.optimize import fsolve
+In []: x0 = fsolve(func, 0.3)
+In []: print x0
+-1.02986652932
+
+In []: x02 = fsolve(func2, [1, 1])
+In []: print x02
+[ 6.50409711  0.90841421]
+\end{lstlisting}
+
+\subsection{Integration}
+% To be done in the lab. 
+\subsubsection{Quadrature}
+
+The function \texttt{quad} is provided to integrate a function of one
+variable between two points. The points can be $\pm\infty$ ($\pm$
+\texttt{inf}) to indicate infinite limits. For example, suppose you
+wish to integrate the expression $e^{\sin(x)}$ in the interval
+$[0,2\pi]$, i.e. $\int_0^{2\pi}e^{\sin(x)}dx$, it could be computed
+using
+
+\begin{lstlisting}
+In []: def func(x):
+   ...:     return exp(sin(x))
+
+In []: from scipy.integrate import quad
+In []: result = quad(func, 0, 2*pi)
+In []: print result
+(7.9549265210128457, 4.0521874164521979e-10)
+\end{lstlisting}
+
+\subsubsection{ODE}
+
+We wish to solve an (a system of) Ordinary Differential Equation. For
+this purpose, we shall use \lstinline{odeint}. As an illustration, let
+us solve the ODE 
+
+\begin{align} 
+  \frac{dy}{dt} = ky(L-y)\\ 
+  L = 25000,\,k = 0.00003,\,y(0) = 250 \nonumber 
+\end{align}
+
+We solve it in scipy as shown below. 
+
+\begin{lstlisting}
+In []: from scipy.integrate import odeint
+In []: def f(y, t):
+  ...:     k, L = 0.00003, 25000
+  ...:     return k*y*(L-y)
+  ...:
+In []: t = linspace(0, 12, 60)
+In []: y0 = 250
+In []: y = odeint(f, y0, t)
+\end{lstlisting}
+
+Note: To solve a system of ODEs, we need to change the function to
+return the right hand side of all the equations and the system and the
+pass the required number of initial conditions to the
+\lstinline{odeint} function.
+
+\appendix
+
+\section{Plotting using Pylab}\label{mpl}
+
+The following piece of code, produces the plot in Figure \ref{fig:sin}
+using \texttt{pylab}\cite{pylab} in \texttt{ipython}\footnote{start
+  \texttt{ipython} with \texttt{-pylab} flag}\cite{ipy}
+
+\begin{lstlisting}
+In []: x = linspace(0, 2*pi, 50)
+In []: plot(x, sin(x))
+In []: title('Sine Curve between 0 and $\pi$')
+In []: legend(['sin(x)'])
+\end{lstlisting}
+
+\begin{figure}[h!]
+  \begin{center}
+    \includegraphics[scale=0.4]{sine}    
+  \end{center}
+  \caption{Sine curve}
+  \label{fig:sin}
+\end{figure}
+
+
+
+\begin{thebibliography}{9}
+  \bibitem{scipy} 
+    Eric Jones and Travis Oliphant and Pearu Peterson and others,
+    \emph{SciPy: Open source scientific tools for Python}, 2001 -- , 
+    \url{http://www.scipy.org/} 
+
+  \bibitem{pylab}
+   John D. Hunter, ``Matplotlib: A 2D Graphics Environment,''
+   \emph{Computing in Science and Engineering}, vol. 9, no. 3,
+   pp. 90-95, May/June 2007, doi:10.1109/MCSE.2007.55 
+
+  \bibitem{ipy}
+    Fernando Perez, Brian E. Granger, ``IPython: A System for
+    Interactive Scientific Computing,'' \emph{Computing in Science and
+    Engineering}, vol.~9, no.~3, pp.~21-29, May/June 2007,
+    doi:10.1109/MCSE.2007.53. 
+
+\end{thebibliography}
+\end{document}
Binary file latex/examples/hello.jpg has changed
--- a/latex/examples/hello.tex	Tue Sep 07 10:45:11 2010 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-  %hello.tex - First LaTeX document
-  \documentclass{article}
-
-  \begin{document}
-    Hello, World!
-  \end{document}
Binary file latex/examples/lion_orig.png has changed
Binary file latex/examples/sine.png has changed
--- a/latex/handout.rst	Tue Sep 07 10:45:11 2010 +0530
+++ b/latex/handout.rst	Tue Sep 07 11:03:27 2010 +0530
@@ -3,422 +3,443 @@
 
 Introduction
 ------------
-LaTeX is a typesetting program used to produce excellently typeset documents. It is extensively used for producing high quality scientific and mathematical documents. It may also be used for producing other kinds of documents, ranging from simple one page articles or letters 
 
-
-TeX & LaTeX
-~~~~~~~~~~~
-
-TeX
-+++
-
-TeX is a typesetting system designed by Donald Knuth, the renowned Computer Scientist and Emeritus professor at Stanford University. Typesetting is placing text onto a page with all the style formatting defined, so that content looks as intended. 
-
-It was designed with two goals in mind-
-
-1. To allow anybody to produce high-quality books using a reasonable amount of effort. 
-2. To provide a system that would give the exact same results on all computers, now and in the future
-
-TeX is well known for it's stability and portability. 
-
-TeX is pronounced as "tech".
-
-The current version of TeX is 3.1415926 and is converging to π.
-
-LaTeX
-+++++
-
-LaTeX was originally written by Leslie Lamport in the early 1980s. It is an extension of TeX, consisting of TeX macros and a program to parse the LaTeX files. It is easier to use than TeX itself, at the same time producing the same quality of output. 
+LaTeX is a typesetting program that produces excellently typeset
+documents. Typesetting is placing text onto a page with all the style
+formatting defined, so that content looks as intended. It is
+extensively used for producing high quality scientific and
+mathematical documents. It is also used for producing other kinds of
+documents, ranging from simple one page articles or letters to
+books. LaTeX is based on the TeX typesetting language.
 
 LaTeX is pronounced either as "Lah-tech" or "Lay-tech"
 
-WYSIWG vs. WYSIWM
-~~~~~~~~~~~~~~~~~
+In this course, we shall use the sample document, ``sample.pdf``, as a
+tool to learn various commands of LaTeX. By the end of the sessions on
+LaTeX, we will have produced a copy of that document, starting from
+scratch.
+
+A Look at the Sample Document
+-----------------------------
+
+Let's first look at the basic structure of the sample document.
+
+Slides with screen shots of
+
+  * Title, Author, Date
+  * Abstract
+  * Sections
+  * Subsections
+  * Appendix
+  * References/Bibliography
+  * Tables
+  * Figures
+  * Math
+
+Writing the source & compiling it
+---------------------------------
 
-WYSIWG is an acronym for "What You See Is What You Get". Word processors, are typically WYSIWG tools. LaTeX, TeX or other TeX based tools are not. They are typesetting or text formatting or document description programs. They can be called WYSIWM or "What You See Is What you Mean" systems, since you give a description of how things look, and LaTeX typesets the document for you.
+Let's begin with a simple hello world, to see how to write a LaTeX
+document and compile it.  Write the following code into the file
+``draft.tex``.  ::
+
+  \documentclass{article}
+  \begin{document}
+  SciPy is open-source software for mathematics, science, and engineering.   
+  \end{document}
+
+To compile the document, do the following in your terminal::
 
-Here are a few reasons, why you should use LaTeX -
+  $ pdfLaTeX draft.tex
+
+This produces the output file ``draft.pdf``
+
+Note: The ``LaTeX`` command is often used, instead of ``pdfLaTeX`` to
+get the ``dvi`` output. But, throughout this course, we shall use
+pdfLaTeX to compile our documents.
+
+``\documentclass``
+------------------
+
+The documentclass command, defines the structure and formatting of our
+document. LaTeX typsets the document, based on the documentclass.
 
-  * LaTeX produces documents with excellent visual quality, especially mathematical and scientific documents. 
-  * It does the typesetting to you. Typically, when one works with a word-processor, the user is doing the text formatting or typesetting along with typing out the content. LaTeX allows the user to concentrate on the content leaving aside the typesetting to LaTeX. 
-  * It is light on your resources as compared to most of the word processors available today. 
-  * It is well known for it's stability and for it's virtually bug free code base. 
-  * It encourages users to structure documents by meaning rather than appearance, thereby helping produce well structured documents. 
-  * It uses plain text files as input, which have a lot of well known advantages over binary files. To state a few, they can be opened with any editor on any operating system, they are smaller in size compared to the binaries, can be version controlled and can be processed using widely used text processing utilities. 
-  * The output can be generated in more than one formats.
+LaTeX is a document based markup language. 
+
+First of all, a markup language is a system of annotating text or
+adding in extra information to the text that specifies it's structure
+or presentation.
+
+LaTeX is a document based markup and not an element based one. You
+generally don't have to worry about typesetting each of the elements
+of your document. Choosing an appropriate documentclass, gives you a
+suitable typesetting. You as an author can worry about the content of
+the document, rather than the appearance or presentation of the
+document.
+
+Why should you use it?
+~~~~~~~~~~~~~~~~~~~~~~
+
+A few reasons for using LaTeX - 
+
+  * It produces documents with excellent visual quality.
+  * It does the typesetting for you, leaving you - the author - to
+    focus on writing the content.
+  * It makes writing math just as easy as writing simple text.
+  * It's renowned for it's stability and a virtually bug free code
+    base.
+  * It is light on your resources as compared to most of the word
+    processors available today.
+  * It uses plain text files as input and can give output in a variety
+    of formats including PDFs and html making it platform independent.
   * It is free software (free as in freedom) and gratis too.
-  * It is widely used.
+  * It is widely used and has a large user community. 
+
+
+``\begin`` and ``\end`` commands define environments. In our document,
+we have the document environment, which defines the beginning and end
+of the content of the document. We place all the content of the
+document within this environment.
 
-Hello World
-~~~~~~~~~~~
+Also, as you may have noticed, all the commands in LaTeX begin with a
+``\``. Note that they are case sensitive. Command names in LaTeX
+usually have only alpha characters. Any characters other than alpha
+characters, terminate the command name. Parameters to commands are
+passed in ``{ }``.
 
-OK, let's get started with our first LaTeX document. Open up your favorite editor and type in the following code. 
+
+Top Matter
+----------
+
+Let us begin with adding the Title, Author's name and the date to the
+document.
 
 ::
 
-  %hello.tex - First LaTeX document
   \documentclass{article}
+  \title{A Glimpse at Scipy}
+  \author{FOSSEE}
+  \date{June 2010}
+  \begin{document}
+  \maketitle
+  SciPy is open-source software for mathematics, science, and engineering.   
+  \end{document}
+
+We add the title, the author and the date to the document before the
+``\begin{document}`` directive. We compile the document to see if the
+details appear in the document, but they donot. These details do not
+appear in the document until we use the ``\maketitle`` command with
+the document environment to instruct LaTeX to place the top matter
+information into the document. Now the document has these details, on
+compiling again.
+
+If no date is specified, LaTeX automatically inserts the current date.
+
+Abstract
+--------
+
+Next we shall add an abstract to our document. LaTeX provides an
+environment, for adding an abstract to the document.  ::
+
+  \documentclass{article}
+
+  \title{A Glimpse at Scipy}
+  \author{FOSSEE}
+  \date{June 2010}
 
   \begin{document}
-    Hello, World!
+
+  \maketitle
+
+  \begin{abstract}
+  This document shows a glimpse of the features of Scipy that will be explored during this course.
+  \end{abstract}
+
+  SciPy is open-source software for mathematics, science, and engineering.   
   \end{document}
 
-Save the file as ``hello.tex`` and open up a terminal to compile your ``tex`` file to get the output in a ``pdf`` format. 
+The abstract environment is placed at the location where we wish it to
+appear in the document.
+
+Sections
+--------
+
+Now let's look at how to add (chapters,) sections and sub-sections to
+our document. Let's add the section headings and sub headings present
+in our sample document to the working copy of our document.
+
+``\section``, ``\subsection``, ``\subsubsection``
+
+On compiling, we can see that the headings of the sections and the
+sub-sections appear in the document.
+
+You may have noticed that LaTeX automatically numbers the sections. To
+prevent a section from getting numbered, an asterix is appended to the
+corresponding sectioning command.
+
+If the document was a longer document, we could have used a report or
+a book class. (Note: Books donot have the abstract environment.) Let's
+look at what happens to the document, when we change it to the report
+class.
 
-Compiling & Output
-++++++++++++++++++
+The numbering strangely begins from zero, now. This is because,
+chapters have an additional sectioning command called
+``\chapter``. The chapter is one level above a section and since, our
+document does not have a ``\chapter`` command, the sections are
+numbered from 0. To change this, we add a chapter command before the
+first section. We say::
+
+  \chapter{One}
+
+Now, observe that we now have a chapter title appearing and the
+numbering starting from 1.
+
+Also, note that the subsubsections donot get a numbering now. This is
+controlled by a variable called the secnumdepth. By default it is set
+to 2. We can now, change it to 3 and get numbering for subsubsections
+also.  ::
+
+  \setcounter{secnumdepth}{3}
+
+What do you expect to happen if we changed the secnumdepth to 1? What
+if it is 0? -1? {Lab excercise}
+
+
+Appendix
+--------
+
+Notice that our document also has an appendix. Let's add an appendix
+to our document.
 
 ::
 
-  $pdflatex hello.tex
-
-  Output written on hello.pdf (1 page, 5733 bytes).
-  Transcript written on hello.log.
-
-Open the ``hello.pdf`` to see the output as shown. 
-
-.. image:: examples/hello.jpg
-
-Note: The command ``latex`` is often used to get the ``dvi`` output. But, throughout this course, we shall use pdflatex to compile our documents. 
-
-A peek at the source
-++++++++++++++++++++
-
-``%hello.tex - First LaTeX document``
+  \appendix
+  \section{Plotting using Pylab}
 
-  This line is a comment. LaTeX ignores this line and it is meant only for the human readers. LaTeX ignores anything after a ``%`` symbol to the end of the line. 
-
-``\documentclass{article}``
-
-  This line is a command and sets the ``documentclass`` of the document to ``article``. LaTeX has other classes like ``report``, ``book``, ``letter``, etc. The typesetting of the document varies depending on the ``documentclass`` of the document. 
-
-
-``\begin{document}``
-
-  This line informs LaTeX that this is the beginning of the content of the document. 
-
-``Hello, World!``
-
-  This is the actual text displayed in the document. 
-
-``\end{document}``
-
-  This line tells LaTeX that the document is complete and LaTeX will simply ignore anything written after this line.
+Table of Contents
+-----------------
 
-Where do we want to go
-~~~~~~~~~~~~~~~~~~~~~~
-
-During the course of this session we will learn how to do various things in LaTeX and try to produce the sample document provided. 
-
-Some Basics
-~~~~~~~~~~~
-Before we get started with creating the document, let's try to understand a few things that would be useful during the course of this session. 
-
-Spaces
-++++++
-
-LaTeX treats multiple empty spaces (or lines) as a single space (or line). An empty line between two lines of text is considered as a change of paragraphs. 
-
-Line & Page Breaks
-++++++++++++++++++
-
-LaTeX usually does the job of breaking up your content into lines and pages, and does it well. But under some circumstances, you might want to instruct LaTeX to break line or start a new page at a particular point. 
-
-``\\`` or ``\newline`` command is used to create a new line at the point where the command is issued. 
-Appending ``*`` to ``\\``,  instructs LaTeX to create a new line, without creating a new page at that point. 
-
-Paragraphs
-++++++++++
-
-As already mentioned, LaTeX considers an empty line between two lines of text as a new paragraph. ``\par`` command may also be used to start a newline. It is equivalent to the blank line. 
-
-By default LaTeX indents new paragraphs. If you do not wish to have the paragraph indented, you can use the ``\nointend`` command at the beginning of the paragraph. 
-
-Special Characters
-++++++++++++++++++
-
-LaTeX associates special meaning to the  characters ``~ # $ % ^ & _ { } \``. 
-
-To have these characters in the text of your document, you need to prefix a backslash to them. ``\~ \# \% \$ \^ \& \_ \{ \} \textbackslash``
+Our sample document is not long enough to warrant a table of contents,
+but let us learn to add a table of contents to a LaTeX document. If
+you ever tried adding a table of contents, to a document in a
+wordprocessor, you would know how much of a trouble it is. In LaTeX,
+it is a matter of just one command and placing the command at the
+location where you would want to have the table of contents. Let's now
+add a table of contents to our draft. Now, compile the document and
+look at the output document. It does not have the table of contents!
 
-
-Commands
-++++++++
-
-* All LaTeX commands start with a backslash ``\``.
-* Like the commands in Linux, they are case sensitive.
-* They usually have a backslash followed by a consisting of letters only. Any character other than letters, like space, numbers or special characters terminate the command. 
-* The commands for producing special characters in the text, is an exception. They contain a backslash followed by a single special character.
-* Commands may have parameters, which are supplied to them by enclosing them in curly braces ``{ }``.
-* They may also have a few optional parameters which are added after the name in square brackets ``[ ]``.
-
-
-Environments
-++++++++++++
-
-Environments are very similar to the commands, except that they effect larger parts of the document. For example, we used the ``document`` environment in our first LaTeX document. 
-
-* They begin with a ``\begin`` and end with a ``\end``
-* In general environments can be nested within each other. 
-
-Some Structural Elements
-------------------------
-
-``\documentclass``
-~~~~~~~~~~~~~~~~~~
-As already stated, the ``documentclass`` command tells LaTeX, the type of the document that you intend to create. Each class has a few differences in how the content of the document is typeset. We presently have it set to the article class. Let us try changing it to the report class. 
-
-Note that the top matter of the document appears in a different page for the report class. 
-
-Some of the LaTeX classes that you may want to use are, article, proc, report, book, slides, letter. 
-
-The ``documentclass`` command also accepts a few optional parameters. For example::
-  \documentclass[12pt,a4paper,oneside,draft]{report}
-
-``12pt`` specifies the size of the main font in the document. The relative sizes of the various fonts is maintained, when the font size is changed. If no size is specified, ``10pt`` is assumed by default. 
+On the first compilation only the "Contents" heading appears in the
+document, but the actual table does not appear. You will need to
+compile your document once more, for the actual table to appear in
+your document. On the first run, LaTeX has gone through your document
+and generated a temporary file (``.toc``), with the entries that
+should go into the table of contents. These entries are made, when you
+compile your document for the second time.
 
-``a4paper`` specifies the size of the paper to be used for the document. 
-
-``oneside`` specifies that the document will be printed only on one side of the paper. The ``article`` and ``report`` classes are ``oneside`` by default and the ``book`` class is ``twoside``.
-
-``draft`` marks the hyphenation and justification problems in the document with a small square in the right hand margin of the document, so that they can be easily spotted. 
-
-Note: Everything written in between the ``\documentclass`` command and the ``\begin{document}`` command is called the Preamble. 
-
-
-Parts, Chapters and Sections
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Often documents are divided into various parts, chapters, sections and subsections. LaTeX provides an intuitive mechanism to include this in your documents. It has various commands like ``part``, ``chapter``, ``section``, ``subsection``, ``subsubsection``, ``paragraph`` and ``subparagraph``. Note that all these commands are not available in all the document classes. The ``chapter`` command is available only in books and reports. Also, the ``letter`` document class does not have any of these commands. 
-
-Let us now give our document some structure, using these commands. 
+Note that any section/block that has been numbered automatically
+appears in the table of contents. It is possible to get un-numbered
+sections, for instance a Preface or a Foreword section to appear in
+the Table of Contents.
 
-Note that you do not need to provide any numbers to the commands. LaTeX automatically takes care of the numbering. 
-Also, you do not need to enclose the text of a block within ``\begin`` and ``\end`` commands. LaTeX starts a new block each time it finds a sectioning command. 
-::
-
-  \section[Short Title]{This is a very long title and the Short Title will appear in the Table of Contents.}
-
-
-Section Numbering
-+++++++++++++++++
-
-As already, you don't need to explicitly do any numbering in LaTeX. Parts are numbered using roman numerals; Chapters and sections are numbered using decimal numbers. When the table of contents is inserted into a document, all the numbered headings automatically appear in it.
-
-By default LaTeX has numbering up 2 levels, i.e, the parts, chapters, sections and subsections are numbered. You can change this by setting the ``secnumdepth`` counter using the ``\setcounter`` command. The following command removes numbering of the subsections. Only parts, chapters and sections are numbered. 
-::
-
-  \setcounter{secnumdepth}{1}
-
-A sectioning command appended with an asterisk gives an unnumbered heading that is not included in the table of contents.
-::
+Let's change our Introduction section to be an un-numbered one and try
+to make it appear in the table-of-contents.  ::
 
   \section*{Introduction}
+  \addcontentsline{toc}{section}{Intro}
 
-Top Matter
-~~~~~~~~~~
+We shall talk about adding and managing bibliographies, later in the
+course.
+
+Now, that we have the basic structure of the document, let's get into
+the content and the details of it.
 
-The information about the document such as it's title, the date, the author(s) information etc, is collectively known as the topmatter. Though there is no command called ``topmatter``, the term topmatter is frequently used in LaTeX documentation. 
+Typesetting Text
+----------------
+
+Let's begin with adding the second paragraph to the introduction
+section. Let's place the text of the second para, after the first
+line, that we already have. Now, compile the document. 
 
-Let us input the top matter for our document now. 
-::
+Notice, that the second para appears in continuation with the previous
+line. To start a new paragraph in LaTeX, we need to insert an empty
+line. Multiple empty lines are considered as a single empty line. To
+start a new line, use the ``\newline`` or ``\\`` command. Notice the
+difference (in the output), in starting a new paragraph and starting a
+newline. A new paragraph is indented.
+
+Quotation Marks
+---------------
 
-  \title{LaTeX - A How-to}
-  \author{The FOSSEE Team}
-  \date
+Look at the quotation marks around the text, Sigh Pie. They are not
+formatted properly. To place quotation marks in LaTeX, you should use
+````` character for the left quote & ``'`` character for the right
+quote. For double quotes, they should be used twice.
+
+Fonts
+-----
+
+The names of the software tools, Scilab, Matlab, etc. appear in
+italics or emphasized as it is called in LaTeX. To emphasize text, the
+``\emph`` command is used.
+
+Let's also add the contents of the subsection "Sub-packages of
+Scipy". We shall add the table as plain text, until we learn how to
+edit tables.
 
-The  commands ``\title`` and  ``\author`` are self explanatory. 
-The ``\date`` command automatically puts in today's date into the document. Now let us compile and look at the result. 
+Let's try and form a tabular structure by separating the left and
+right columns using spaces. On compiling we find that LaTeX doesn't
+add multiple spaces between words. Just like multiple empty lines,
+multiple spaces are considered as a single space.
+
+The names of the sub-packages appear in a fixed width font in the
+sample document provided to us. The headings of the columns appear in
+bold-face. Let's make changes to this effect.
 
-You would observe that the details do not appear in the document after recompilation. This is because, LaTeX has not been instructed what to do with the top matter information that you have given it. Use the ``\maketitle`` command within the document environment to instruct LaTeX to place the top matter information into the document. 
+``\textbf`` is used to change text to bold face and ``\texttt`` is
+used to change text to fixed width font.
+
+We could also change the separating - (hyphen) to an em-dash (or
+en-dash) -- is em-dash and --- is an em-dash, to improve the
+appearance of the document.
+
+Lists
+-----
 
-Abstract
-~~~~~~~~
-Lets now place and abstract in the document using the ``abstract`` environment of LaTeX. The abstract appears in the document after the topmatter but before the main body of the document. 
-::
+The section on Use of Scipy in this course, contains lists. Let's now
+add lists to our document. The ``enumerate`` environment adds numbered
+lists to our document and the ``itemize`` environment adds un-numbered
+lists. ``\item`` command adds a new entry to a list. Note, that LaTeX
+can easily handle nested lists. In fact most environments can be
+embedded within other environments, without any problems.
+
+LaTeX also has a description list, which shall be looked at, during
+the lab sessions.
+
+Footnotes, Labels and References
+--------------------------------
 
-  \begin{abstract}
-  The abstract abstract.
-  \end{abstract}
+Let's now add the footnote to pylab. LaTeX provides a footnote command
+to add a footnote.
+
+We added the footnote with Appendix A, as plain text. But, in case we
+added another Appendix before the section on using ``pylab``, the
+footnote will have to be edited. To avoid this, LaTeX provides a handy
+system of labels and referencing.
+
+We first add a label to the section that we want to refer in this
+footnote. Then, we change the footnote, and add the reference to this
+label instead of the character A. If you look at the output after
+compiling the document once, you will see that the footnote has
+question marks instead of the section number.  You will have to
+compile once again, for the section number to appear in the footnote.
 
 
-Appendices
-~~~~~~~~~~
-
-LaTeX allows for separate numbering for appendices. ``\appendix`` command indicates that the sections following are to be included in the appendix. 
-::
-
-  \appendix
-  \chapter{First Appendix}
+Including code
+--------------
 
-Table of Contents
-~~~~~~~~~~~~~~~~~
-
-Parts, chapters or sections that have been auto numbered by LaTeX automatically appear in the Table of Contents (ToC). ``\tableofcontents`` command places a the ToC, where the command has been issued. 
-
-The counter ``tocdepth`` specifies the depth up to which headings appear in the ToC. It can be set using the ``\setcounter`` command as shown below. 
-::
-
-  \setcounter{tocdepth}{3}
+In the footnote above, and in the table for the sub-packages list, we
+used the ``\texttt`` command to get a fixed width font. But we could
+instead use an environment provided by LaTeX to include pre-formatted
+text or code. LaTeX by default provides the verbatim environment to
+include pre-formatted text. You can try that out during the lab
+session. We shall look at using the listings package, specifically
+meant for including code in our document.
 
-Unnumbered sections can be placed in the table of contents using the ``\addcontentsline`` command as shown below.
-::
-
-  \section*{Introduction}
-  \addcontentsline{toc}{section}{Introduction}
-
-Note: To get the correct entries in your table of contents, you will need to run one extra compilation, each time. This is because, the entries of the table of contents are collected during each compilation of the document and utilized during the next compilation. 
-
-Elementary Text Typesetting
----------------------------
+First of all you need to tell LaTeX, that you want to use the listings
+package in your document. We add the directive
+``\usepackage{listings}`` to the preamble of our document.
 
-Emphasizing
-~~~~~~~~~~~
-
-*Italic* font is generally used to emphasize text. The ``\emph`` command may be used to achieve this effect in LaTeX.
-::
+Then we set the language of the code that we are going to embed into
+our document. For this we use the lstset command.  ::
+ 
+  \lstset{language=Python,
+          showstringspaces=false,}
 
-  This is the \emph{emphasized text}.
-
-If the ``\emph`` command is nested within another emphasize command, LaTeX emphasized that text using normal fonts. 
-::
-
-  \emph{Did you wonder what happens when we try \emph{emphasizing text} within \emph{emphasized text}}?
+The listings package allows you to use color and do a lot of things
+with your embedded code, but all that during a lab exercise.
 
-*This is emphasized text, and* this is emphasized text with normal font *, within* emphasized text.
-
-Quotation Marks
-~~~~~~~~~~~~~~~
-
-When typing in LaTeX, the double quotation mark ``"`` character shouldn't be used. The grave accent ````` character produces the left quote and the apostrophe ``'`` character produces the right quote. To obtain double quotes they are, each, used twice. 
-::
-
-  `` Here is an example of putting `text' in quotes ''
+Now, to put a line of code, inline and not as a separate block, we use
+the ``\lstinline`` command. We change the name pylab in the footnote
+to use lstinline instead of the texttt. To embed a block of code, we
+use the lstlisting environment (``\begin{lstlisting}`` and
+``\end{lstlisting}``). For example, let's add the code to the Appendix
+of our document.
 
-Dashes and Hyphens
-~~~~~~~~~~~~~~~~~~
-
-LaTeX has four dashes of different lengths. Three of them can be produces with different number of consecutive dashes. The short dashes are used for hyphens, slightly longer ones for number ranges and the longest ones for comments. The fourth one is a mathematical symbol, the minus sign. 
-::
+Figures, Tables and Floats
+--------------------------
 
-  The names of these dashes are: `-' hyphen, `--' en-dash, `---' em-dash and `$-$' minus sign.
-
-The names for these dashes are: ‘‐’ hyphen, ‘–’ en-dash, ‘—’ em-dash and ‘−’ minus sign.
-
-Footnotes
-~~~~~~~~~
+Let's now add the figure, to the appendix.
 
-With the command::
-
-  \footnote{footnote text}
-
-a footnote is printed at the foot of the current page. Footnotes should always be put after the word or sentence they refer to. Footnotes referring to a sentence or part of it should therefore be put after the comma or period.
-
-Note: Look at the ``\marginpar`` command to insert margin notes
-
-Flushleft, Flushright, and Center
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+To include graphics in a LaTeX document, we need to use the graphicx
+package. Add the ``\usepackage{graphicx}`` directive to the preamble
+of the document.
 
-The environments ``flushleft`` and ``flushright`` generate paragraphs that are either left- or right-aligned. 
-
-The ``center`` environment generates centered text.
+To add the graphic, use the ``includegraphics`` command. The relative
+path of the image that we wish to include is passed as an argument to
+includegraphics. It takes an optional argument of scaling the
+image. We use a scale of 0.4 to scale our image.
 
-Itemize, Enumerate, and Description
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-LaTeX has three different environments for producing lists. Itemize, Enumerate and Description allow you to produce lists of various types in LaTeX. 
+It takes other optional arguments. 
 
-Itemize is used to produce unnumbered lists. The bullets of the list can be easily changed to use any character. Enumerate environment allows you to produce auto-numbered lists. The description environment, allows you to produce a list of definitions. These environments can be nested within each other, easily. 
-
-::
+  ``width=x``, ``height=x`` 
+    If only the height or width is specified,
+    the image is scaled, maintaining the aspect ratio.
 
-  \begin{itemize}
-    \item Now we move onto some elementary \emph{Text Typesetting}.
-    \item How do we get \emph{emphasized or italic text}?
-    \item \emph{Did you wonder what happens when we try \emph{emphasizing text} within \emph{emphasized text}}?
-    \item ``Beautiful is better than ugly.''
-  \end{itemize}
-  
-  \begin{description}
-    \item[Description] This list is a description list. 
-    \item[Enumerate] Numbered lists are often useful.
-      \begin{enumerate}
-      \item First
-      \item Second
-      \item Third
-      \item \ldots
-      \end{enumerate}
-    \item[Itemize] The list above this description list is an itemize list.
-  \end{description}
-  
-Quote, Quotation, and Verse
-~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ``keepaspectratio``
+    This parameter can either be set to true or false. When set to
+    true, the image is scaled according to both width and height,
+    without changing the aspect ratio, so that it does not exceed both
+    the width and the height dimensions.
+
+  ``angle=x``
+    This option can be used to rotate the image by ``x`` degrees,
+    counter-clockwise.
 
-LaTeX provides a ``quote`` environment that can be used for quoting, highlighting important material, etc. 
-::
+Figures (and tables) are treated specially because, they cannot be
+broken across pages. They are "floated" across to the next page, if
+they donot fit on the current page, filling the current page with
+text.
+
+To make our graphic into a float, we should enlose it within a figure
+environment. For a table, the table environment should be used. We now
+move our graphic into a figure environment. The figure environment
+takes an additional parameter for the location of the
+float. ``\begin{figure}[hbtp!]``. The specifiers ``htbp`` are
+permissions to place the float at various locations. ``t`` for top of
+page, ``b`` for bottom of page, ``p`` for a separate page for floats
+and ``h`` for here, as in the same place where the command appears in
+the source. ``!`` mark overrides a few of LaTeX's internal parameters
+for good position of floats.
 
-  The Zen of Python
-  \begin{quote}
-    The Zen of Python, by Tim Peters
-    
-    Beautiful is better than ugly.
-    Explicit is better than implicit.
-    Simple is better than complex.
-    Complex is better than complicated.
-    Flat is better than nested.
-    Sparse is better than dense.
-    Readability counts.
-    Special cases aren't special enough to break the rules.
-    Although practicality beats purity.
-    Errors should never pass silently.
-    Unless explicitly silenced.
-    In the face of ambiguity, refuse the temptation to guess.
-    There should be one-- and preferably only one --obvious way to do it.
-    Although that way may not be obvious at first unless you're Dutch.
-    Now is better than never.
-    Although never is often better than *right* now.
-    If the implementation is hard to explain, it's a bad idea.
-    If the implementation is easy to explain, it may be a good idea.
-    Namespaces are one honking great idea -- let's do more of those!
-  \end{quote}
+The figure environment also, allows us to add a caption to the graphic
+using the ``\caption`` command.
+
+To place the graphic in the center aligned in the page, we use the
+center environment.
 
-LaTeX provides two other similar environments, the quotation and the verse environments. 
+To label a figure, we just add a label with in the figure
+environment. Note, that the label to a figure should be added after
+the caption command. Also, note that tables are auto-numbered.
 
-The quotation environment can be used for longer quotes which have several paragraphs, since it indents the first line of each paragraph. 
-
-The verse environment may be used to quote verses or poems, since the line breaks are important in quoting them. The lines are separated using ``\\\\`` at the end of a line and an empty line after each verse. 
+Let us finish the appendix, by adding the content present at the
+beginning of the appendix. The bibliographic citations will be dealt
+with later.
 
-Verbatim
-~~~~~~~~
-The verbatim environment allows us to insert pre-formatted text in a LaTeX document. It is useful for inserting code samples within the document. The verbatim text needs to be enclosed between ``\begin{verbatim}`` and ``\end{verbatim}``. 
-::
+Tables
+~~~~~~
 
-  \begin{verbatim}
-  from numpy import *
-  a = linspace(0, 5, 50, endpoint = False)
-  \end{verbatim}
-
-  from numpy import *
-  a = linspace(0, 5, 50, endpoint = False)
+Now, let us look at the other kind of floats - Tables. We shall
+convert the list of sub-packages in the sub-packages section to a
+table.
 
-To insert verbatim text in-line, the ``\verb`` command can be used. 
-::
-  
- The verb command allows placing \verb|verbatim text| in-line. 
-
-The | is just an example of a delimiter character. You can use any character except letters, * or space.
-
-Tables, Figures and Captions
-----------------------------
+To begin a table, we use the tabular environment. And to make this a
+float, it is enclosed in the table environment. The table environment
+also allows us to add captions to the table and Tables are also auto
+numbered.
 
-The ``\tabular`` environment
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-The ``tabular`` environment allows you to typeset tables in LaTeX. ``\begin{tabular}[pos]{col fmt}`` command can be used to specify the parameters of the table and start creating the table. 
-
-The ``pos`` argument specifies the vertical position of the table relative to the baseline of the surrounding text. It can take on the values ``t`` for top, ``b`` for bottom, or ``c`` for center. 
-
-
-The ``col fmt`` argument specifies the formatting of the columns of the table. You need to explicitly specify the formatting for each of the columns in the table. The ``col fmt`` argument can take on the following values. 
+The tabular environment takes as arguments the columns and the
+formatting of each column. The possible arguments to the tabular
+environment are
 
 +---------------+------------------------------------+
 | ``l``         | left justified column content      |
@@ -427,385 +448,169 @@
 +---------------+------------------------------------+
 | ``c``         | centered column content            |
 +---------------+------------------------------------+
-| ``*{n}{col}`` | produces ``n`` columns with the    |
-|               | ``col`` type of formatting         |
-|               | ``*{3}{c}`` is the same as {c c c} |
-+---------------+------------------------------------+
 | ``|``         | produces a vertical line.          |
 +---------------+------------------------------------+
 
-Now we look at how to input the actual entries of the tables. Each horizontal row in a table is separated by ``\\``. Each column entry of a row is separated by ``&``. 
+It also takes an optional parameter that specifies the position of the
+table; ``t`` for top, ``b`` for bottom, or ``c`` for center.
 
-The ``\hline`` command allows you to draw horizontal lines between two rows of the table. But it does not allow you do draw partial lines. ``\cline{a-b}`` draws a horizontal line from column ``a`` to column ``b``.
-::
+Each column of a table is separated by an ``&`` symbol and each row is
+separated by a new line. The ``\hline`` command allows you to draw
+horizontal lines between two rows of the table. But it does not allow
+you do draw partial lines. ``\cline{a-b}`` draws a horizontal line
+from column ``a`` to column ``b``.
+
+We also add a label to the table and refer to it in the first line of
+the section.
 
-  \begin{tabular}{|c|c|}
-    \hline
-    \verb+l+ & left justified column content\\ 
-    \hline
-    \verb+r+ & right justified column content\\ 
-    \hline
-    \verb+c+ & centered column content\\ 
-    \hline
-    \verb+*{n}{col}+ & produces \verb+n+ columns with the\\
-                   & \verb+col+ type of formatting\\
-    \cline{2-2}
-                   &\verb+*{3}{c}+ is the same as \verb+{c c c}+ \\
-    \hline
-    \verb+|+ & produces a vertical line\\ 
-    \hline
-  \end{tabular}
+You could also add a listoftables or listoffigures to the document,
+similar to the way we added table of contents.
+
+Typesetting Math
+----------------
 
-Importing Graphics
-~~~~~~~~~~~~~~~~~~
+Now we shall move to typesetting the Math in the sample document given
+to us. We shall start with the Matrices subsection.
 
-To include images in LaTeX, we require to use an additional package known as ``graphicx``.  To load a package, we use the ``\usepackage`` directive in the preamble of the document.
-::
-
-  \usepackage{graphicx}
+In general, it is advised to use the AMS-LaTeX bundle to typeset
+mathematics in LaTeX. AMS-LaTeX is a collection of packages and
+classes for mathematical typesetting.
 
-When compiling with ``pdflatex`` command,  **jpg**, **png**, **gif** and **pdf** images can be inserted. 
-
-::
-
-  \includegraphics[optional arguments]{imagename}
+We load ``amsmath`` by issuing the ``\usepackage{amsmath}`` in the
+preamble. Through out this section, it is assumed that the ``amsmath``
+package has been loaded.
 
-A few ``optional arguments``:
+Let's now typeset the matrix A.
 
-  ``width=x``, ``height=x``
-    If only the height or width is specified, the image is scaled, maintaining the aspect ratio.
-
-  ``keepaspectratio``
-    This parameter can either be set to true or false. When set to true, the image is scaled according to both width and height, without changing the aspect ratio, so that it does not exceed both the width and the height dimensions. 
+To typeset math, we just have to enclose it within ``\(`` and ``\)``
+or a pair of ``$`` signs.
 
-  ``scale=x``
-    Scale the image by a factor of ``x``. For example, ``scale=2``, will double the image size. 
-
-  ``angle=x``
-    This option can be used to rotate the image by ``x`` degrees, counter-clockwise. 
-
-::
+To typeset the matrix A, we use the ``bmatrix`` environment. It works
+similar to a tabular environment - ``&`` is used to demarcate columns
+and ``\\`` is used to add a new row. ``bmatrix`` environment gives the
+``[`` ``]`` as delimiters. There are 5 other matrix environments
+giving matrices with other delimiters - ``matrix`` (none), ``pmatrix``
+``(``, ``Bmatrix`` ``{``, ``vmatrix`` ``|`` and ``Vmatrix`` ``||``.
 
-  \includegraphics[scale=0.8, angle=30]{lion_orig.png}
+To write the name of the matrix A, a bold-faced A is used. This is
+obtained by using the ``\mathbf`` command.
 
-Floats
-~~~~~~
+This subsection doesn't have much more math. The next section on
+inverse doesn't have anything new except for writing inverse of A.
 
-Tables and Figures need to be treated in a special manner, since they cannot be split over pages, and they are referred to as floats in LaTeX. 
-
-When there is not enough space on a page, to fit in a table or figure, it is floated over to the next page filling up the current page with text. LaTeX has float environments called table and figure for tables and images, respectively.
+To typeset superscripts in LaTeX, the ``^`` character is used. The
+carat operator just acts on the next character. To have multiple
+characters as superscript they must be enclosed in ``{ }``. Similarly
+for typesetting text as subscripts the ``_`` character is used.
 
-Anything enclosed within the table or figure environments will be treated as floats.
-::
-
-  \begin{figure}[pos] or 
-  \begin{table}[pos]
-
-The ``pos`` parameter specifies the placement of the float. The possible values it can take are as follows. 
+To typeset the summation symbol, use the command ``\sum.`` The upper
+and lower limits are specified using the ``^`` and ``_``
+characters. Similarly, the integral symbol is obtained using the
+``\int`` command.
 
-+-----------+-------------------------------------------------------------------+
-| Specifier | Permission                                                        |
-+===========+===================================================================+
-|   h       |  at approximately the same place where it occurs in the source    |
-+-----------+-------------------------------------------------------------------+
-|   t       |  at the top of the page.                                          |
-+-----------+-------------------------------------------------------------------+
-|   b       |  at the bottom of the page.                                       |
-+-----------+-------------------------------------------------------------------+
-|   p       |  on a special page for floats only.                               |
-+-----------+-------------------------------------------------------------------+
-|   !       |  Override LaTeX's internal parameters for good positions          |
-+-----------+-------------------------------------------------------------------+
-|   H       |  nearly equivalent to h!                                          |
-+-----------+-------------------------------------------------------------------+
+Next, let us type in the equation present in the section on
+Determinants. Note that it is different from all the math we've typed
+until now, since it is not inline and is "displayed", in the LaTeX
+lingo. LaTeX has a number of environments for displaying equations,
+with minor subtle differences. In general use ``\[`` ``\]`` to typeset
+displayed equations without numbering them. ``\begin{equation*}`` is
+equivalent to it.  To obtain numbered equations use
+``\begin{equation}``.
 
-Examples::
-
-  \begin{figure}[h]
-  \centering
-  \includegraphics[scale=0.8, angle=30]{lion_orig.png}
-  \end{figure}
+Next we wish to typeset a group of equations. The equation environment
+does not accept ``\\`` to get a new line. For multiple equations
+amsmath has a handful of environments with subtle differences. We
+shall use the ``eqnarray`` environment. ``eqnarray*`` environment
+gives unnumbered equations, as expected. The ``eqnarray`` environment
+works similar to a table environment. The parts of the equation that
+need to be aligned are indicated using an ``&`` symbol. The
+``newline`` command is used to enter a every new equation after the
+first one. We now typeset the equations in the section on linear
+equations using the ``eqnarray`` environment. (The equations in the
+determinants section use ``eqnarray*``)
 
-
-Captions
-~~~~~~~~
-
-The ``\caption{text}`` command allows you to add captions to images or tables. LaTeX automatically numbers your tables and figures and you need not include numbers in the captions that you write. The caption appears below or on top of the image (or table), depending on whether you place it after or before the ``importgraphics`` (or ``tabular``) command. 
+We next typeset the math in the section on polynomials. To typeset
+fractions use the ``\frac`` command. To typeset surds, we use the
+``\sqrt`` command with the optional paramter of ``[n]``.
 
-::
-  \begin{figure}[h]
-  \centering
-  \includegraphics[scale=0.8]{lion_orig.png}
-  \caption{CTAN lion drawing by Duane Bibby; thanks to www.ctan.org}
-  \end{figure}
+Inserting Greek letters into LaTeX is simple. ``\alpha``, ``\beta``,
+``\gamma``, ... on for small letters and ``\Alpha``, ``\Beta``,
+``\Gamma``, ... for capital.
 
-The caption command also, like the section command, has the short caption optional parameter. The short caption will appear in the list of tables or figures. 
+Also, math environments do not give extra spaces using the space or
+tab characters. The following commands are available to specify the
+spacing required.
 
-List of Figures, Tables
-~~~~~~~~~~~~~~~~~~~~~~~
-
-LaTeX can automatically generate a List of Tables or Figures, with the table or figure numbers, the captions and page numbers on which they appear. This can be done using the ``\listoftables`` or ``listoffigures`` commands. 
-
-Note: Just like table of contents, these lists also require an extra compilation. 
-
-Cross References
-~~~~~~~~~~~~~~~~
-
-LaTeX has a very efficient mechanism of inserting cross-references in documents. 
-
-The command ``\label{name}`` is used to label figures, tables or segments of text. ``\ref{name}`` refers to the object marked by the ``name`` by it's numbering (figure, table, section etc.) ``\pageref{name}`` gives the page number of the object which has been labeled with ``name``. 
-
-Note: Cross referencing also requires an extra compilation, like table of contents. 
++---------+--------------------+---------+
+| Abbrev. | Spelled out        | Example |
++---------+--------------------+---------+
+| ``\,``  | ``\thinspace``     |         |
++---------+--------------------+---------+
+| ``\:``  | ``\medspace``      |         |
++---------+--------------------+---------+
+| ``\;``  | ``\thickspace``    |         |
++---------+--------------------+---------+
+|         | ``\quad``          |         |
++---------+--------------------+---------+
+|         | ``\qquad``         |         |
++---------+--------------------+---------+
+| ``\!``  | ``\negthinspace``  |         |
++---------+--------------------+---------+
+|         | ``\negmedspace``   |         |
++---------+--------------------+---------+
+|         | ``\negthickspace`` |         |
++---------+--------------------+---------+
 
 Bibliography
 ------------
 
-Bibliography or references can be added to LaTeX documents in two ways - using the ``thebibliography`` environment, or using BibTeX. Let's first look at using the ``\thebibliography`` environment and then move on to BibTeX.
-
-``thebibliography`` environment
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Writing bibliographies in LaTeX using the ``thebibliography`` environment is pretty easy. You simply have to list down all the bibliography items within the bibliography environment. 
-
-Each entry of the bibliography begins with the command ``\bibitem[label]{name}``. The name is used to cite the bibliography item within the document using  ``\cite{name}``. The label option replaces the numbers from the auto enumeration with the labels given. 
-::
-
-  He used this lion in the illustrations for D Knuth's original TeXbook\cite{DKnuth}, for L Lamport's LaTeX book\cite{LLamport}
-
-  \begin{thebibliography}{99}
-    \bibitem{DKnuth} Donald E. Knuth (1984). \emph{The TeXbook} (Computers and Typesetting, Volume A). Reading, Massachusetts: Addison-Wesley. ISBN 0-201-13448-9.
-  
-    \bibitem{LLamport} Lamport, Leslie (1994). \emph{LaTeX: A document preparation system: User's guide and reference}.
-     illustrations by Duane Bibby (2nd ed.). Reading, Mass: Addison-Wesley Professional. 
-  \end{thebibliography}
-
-The ``99`` in the example above indicates the maximum width of the label that the references may get. We here assume that the number of Bibliography items will be less than 100. If your document has less than 10 references, you may want to replace ``99`` with ``9``. 
-
-BibTeX
-~~~~~~
-
-The previous section explained the process of listing references at the end of a document and embedding cross references. In this section let us explore the BibTeX environment for keeping track of references.
-
-Using BibTeX is a very convenient method to use, when writing multiple documents in a single area or field. BibTeX allows you to create a database of all your references and use them as and when required. 
+Let's now look at how to write bibliography and cite references.
 
-The BibTeX database is stored in a ``.bib`` file. The structure of the file is quite simple and an example is shown below. 
-::
-
-  @book{Lamport94,
-  author    = "Leslie Lamport",
-  title     = "A Document Preparation System: User's Guide and Reference",
-  publisher = "Addison-Wesley Professional",
-  year      = "1994",
-  edition    = "second",
-  note      = "illustrations by Duane Bibby"
-  }
-
-Each bibliography entry starts with a declaration of the type of the reference being mentioned. The reference is in the above example is of the book type. BibTeX has a wide range of reference types, for example, ``article, book, conference, manual, proceedings, unpublished``.
+Writing bibliographies in LaTeX using the ``thebibliography``
+environment is pretty easy. You simply have to list down all the
+bibliography items within the bibliography environment.
 
-The type of reference is followed by a left curly brace, and immediately followed by the citation key. The citation key, ``Lamport94`` in the example above is used to cite this reference using the command ``\cite{Lamport94}``. 
-
-This is followed by the relevant fields and their values, listed one by one. Each entry must be followed by a comma to delimit one field from the other. 
-
-To get your LaTeX document to use the bibliography database, you just add the following lines to your LaTeX document. 
-::
-
-  \bibliographystyle{plain}
-  \bibliography{LaTeX}
-
-Bibliography styles are files that tell BibTeX how to format the information stored in the ``.bib`` database file. The style file for this example is ``plain.bst``. Note that you do not need to add the ``.bst`` extension to the filename.  If you wish to achieve a particular style of listing the bibliography items and citing them, you should use an appropriate style file. 
-
-The ``bibliography`` command specifies the file that should be used as the database for references. The file used in this example is ``LaTeX.bib``
-
-Compiling
-+++++++++
+Each entry of the bibliography begins with the command
+``\bibitem[label]{name}``. The name is used to cite the bibliography
+item within the document using ``\cite{name}``. The label option
+replaces the numbers from the auto enumeration with the labels given.
 
-Adding BibTeX based references, slightly complicates the process of compiling the document to obtain the desired output. The exact workings of LaTeX and BibTeX will not be explained here. The procedure for obtaining the output (without any explanations) is as follows:
-
-1. Compile the ``.tex`` file using ``pdflatex`` - ``$pdflatex LaTeX(.tex)``
-2. Compile the ``.bib`` file using ``bibtex`` -  ``$bibtex LaTeX(.bib)``
-3. Compile the ``.tex`` file again. 
-4. Compile the ``.tex`` file for one last time!
-
-Typesetting Math
-----------------
-
-It is advisable to use the AMS-LaTeX bundle to typeset mathematics in LaTeX. It is a collection of packages and classes for mathematical typesetting. 
-
-We load ``amsmath`` by issuing the ``\usepackage{amsmath}`` in the preamble. Through out this section, it is assumed that the ``amsmath`` package has been loaded. 
-
-
-Math Mode
-~~~~~~~~~
-
-There are a few differences between the *math mode* and the *text mode*:
-
-1. Most spaces and line breaks do not have any significance, as all spaces are either derived logically from the mathematical expressions, or have to be specified with special commands such as ``\``, ``\quad`` or ``\qquad``
-
-2. Empty lines are not allowed.  
-
-3. Each letter is considered to be the name of a variable and will be typeset as such. If you want to typeset normal text within a formula, then you have to enter the text using the \text{...} command
-
-Single Equations
-~~~~~~~~~~~~~~~~
+The ``9`` passed as an argument to ``thebibliography`` command
+indicates the maximum width of the label that the references will
+have. In our sample document, we have less than 10 items in the
+Bibliography and therefore we use 9.
 
-Mathematical equations can be inserted in-line within a paragraph (*text style*), or the paragraph can be broken to typeset it separately (*display style*). 
-
-A mathematical equation within a paragraph is entered between ``$`` and ``$``. Larger equations are set apart from the paragraph, by enclosing them within ``\begin{equation}`` and ``\end{equation}``. If you don't wish to number a particular equation, the starred version of equation can be used. ``\begin{equation*}`` and ``\end{equation*}``
-
-The equation can also be cross referenced using the ``\label`` and ``\eqref`` commands. 
-
-Basic Elements
-~~~~~~~~~~~~~~
-
-Greek Letters can are entered as ``\alpha, \beta, \gamma, \delta, ...`` for lowercase letters and ``\Alpha, \Beta, \Gamma, ...`` for uppercase ones. 
-
-Exponents and subscripts can be typeset using the carat ``^`` and the underscore ``_`` respectively. Most of the math mode commands act only on the next character. If you want a command to affect several characters, they need to be enclosed in curly braces. 
-
-The ``\sqrt`` command is used to typeset the square root symbol. LaTeX of the root sign is determined automatically. The nth root is generated with ``\sqrt[n]``. 
+Presentations with Beamer
+-------------------------
 
-To explicitly show a multiplication a dot may be shown. ``\cdot`` could be used, which typesets the dot to the center. ``\cdots`` is three centered dots while ``\ldots`` sets the dots on the baseline. Besides that ``\vdots`` for vertical and ``\ddots`` can be used for diagonal dots.
-
-A fraction can be typeset with the command ``\frac{..}{..}``
-
-The integral operator is generated with ``\int``, the sum operator with ``\sum``, and the product operator with ``\prod``. The upper and lower limits are specified with ``^`` and ``_`` like subscripts and superscripts.
-
-LaTeX provides all kinds of braces as delimiters. The round and square brackets can be produces using the keys on the keyboard and appending a backslash. Other delimiters can be produced using special commands of LaTeX. Placing ``\left`` in front of an opening delimiter and ``\right`` in front of a closing delimiter, instructs LaTeX to automatically take care of the sizes of the delimiters. 
-
-Multiple Equations
-~~~~~~~~~~~~~~~~~~
-
-Long formulae that run over several lines or equation systems, can be typeset using the ``align`` or ``align*`` environments. ``align`` numbers each of the lines in the environment, and ``align*`` as expected, does not number any of them. 
-
-The ``&`` is used to align the equations vertically and the ``\\`` command is used to break the lines. Line numbering can be skipped for a particular line in the ``align`` environment by placing a ``\nonumber`` before the line break.
-
-::
+Using beamer for you presentations is a good idea, since you can use
+the LaTeX that you have used for the report/document for the
+presentation as well.
 
-  \begin{align}
-  \alpha^2 + \beta^2 &= \gamma^2 \\
-  \sum_{i=1}^ni &= \frac{n(n+1)}{2}\\
-  \sqrt{-1} &= \pm1 \nonumber
-  \end{align}
-
-
-Arrays and Matrices
-~~~~~~~~~~~~~~~~~~~
-
-To typeset arrays, use the ``array`` environment. It works similar to the ``tabular`` environment. The ``\\`` command is used to break the lines. 
-::
-
-  \begin{equation*}
-  \mathbf{X} = \left(
-   \begin{array}{ccc}
-   a_1 & a_2 & \ldots \\
-   b_1 & b_2 & \ldots \\
-   \vdots & \vdots & \ddots
-   \end{array} \right)
-  \end{equation*}
-
-The ``array`` environment can also be used to typeset piecewise functions by using a “.” as an invisible ``\right`` delimiter
-::
+To write a ``beamer`` presentation, it is recommended that we use one
+of the templates that beamer provides. We shall use the
+``speaker_introduction`` template to get started with beamer.
 
-  \begin{equation*}
-  f(x) = \left\{
-   \begin{array}{rl}
-     0 & \text{if } x \le 0\\
-     1 & \text{if } x > 0
-   \end{array} \right.
-   \end{equation*}
-
-Six different types of matrix environments are available in the ``amsmath`` package for typesetting matrices.  They essentially have different delimiters: ``matrix`` (none), ``pmatrix`` (, ``bmatrix`` [, ``Bmatrix`` {, ``vmatrix`` | and ``Vmatrix`` ‖. In these matrix environments, the number of columns need not be specified, unlike the ``array`` environment.
-::
+As you can see, the document begins with the ``documentclass`` being
+set to beamer.
 
-  \begin{equation*}
-    \begin{matrix}
-    1 & 2 \\
-    3 & 4
-    \end{matrix} \qquad
- 
-    \begin{bmatrix}
-    1 & 2 & 3 \\
-    4 & 5 & 6 \\
-    7 & 8 & 9
-    \end{bmatrix}
-  \end{equation*}
+``\usetheme`` command sets the theme to be used in the presentation.
 
-Miscellaneous Stuff
--------------------
-
-Presentations
-~~~~~~~~~~~~~
-
-LaTeX has quite a few options to produce presentation slides. We shall look at the ``beamer`` class, which is well developed and easy to use. We shall only briefly look at some of the features of beamer. For the best documentation, look at the beamer user guide.
-
-To write a ``beamer`` presentation, it is recommended that you use one of the templates that beamer provides. We shall use the ``speaker_introduction`` template to get started with beamer. 
-
-As you can see, the document begins with the ``documentclass`` being set to beamer. 
-
-The ``\setbeamertemplate`` command sets the template for various parameters. The ``background canvas``, ``headline`` and ``footline`` are being set using the command.
-
-``\usetheme`` command sets the theme to be used in the presentation. 
+``\usecolortheme`` command sets the color theme of the presentation.
 
-Notice that each slide is enclosed within ``\begin{frame}`` and ``\end{frame}`` commands. The ``\begin{frame}`` command can be passed the Title and Subtitle of the slide as parameters. 
-
-To achieve more with beamer, it is highly recommended that you look at the ``beameruserguide``.
-
-Including Code
-~~~~~~~~~~~~~~
-
-The ``listings`` package can be used to embed source code into your LaTeX document. We shall briefly explore inserting python code into our document. 
-
-Obviously, you first need to tell LaTeX that you want it to use the ``listings`` package, using the ``\usepackage`` command. 
-::
-
-  \usepackage{listings}
+Notice that each slide is enclosed within ``\begin{frame}`` and
+``\end{frame}`` commands. The ``\begin{frame}`` command can be passed
+the Title and Subtitle of the slide as parameters.
 
-Then, we tell LaTeX that we are going to embed Python code into this document. A simple code highlighting for Python code can be achieved using this. 
-::
-
-  \lstset{language=Python,
-          showstringspaces=false,
-         }
-
-You might want to customize the code highlighting further using other variables like ``basicstyle``, ``commentstyle``, ``stringstyle``, ``keywordstyle`` etc. For detailed information on all this, you should look at the ``listings`` package documentation. 
-
-You include a block of code into your document by enclosing it within the ``lstlisting`` environment. 
-::
-
-  \begin{lstlisting}
-  string="Hello, World! "
-  for i in range(10):
-      print string*i
-  \end{lstlisting} 
+The title page of the presentation can be set like any other LaTeX
+document.
 
-You can also include source code files directly into your latex document, using the ``lstinputlisting`` command. 
-::
-
-  \lstinputlisting[lastline=20]{lstexample.py}
-
-This command includes the first 20 lines of the file ``lstexample.py`` into out LaTeX document. 
-
-Including files
-~~~~~~~~~~~~~~~
-When working on a large document, it is convenient sometimes, to split the large file into smaller input files and club them together at the time of compiling. 
-
-The ``\input`` or ``\include`` commands may be used to embed one LaTeX file into another. The ``\input`` command is equivalent to a copy and paste of the document, just before the compilation. The ``\include`` command is exactly similar, except for the fact that it creates a new page every time it is issued.
-
-``\input{file}`` or ``\include{file}`` commands will include the file ``file1.tex`` with in the file where the command has been issued. Note that you do not need to specify the ``.tex`` extension of the file. 
+To do overlays, use the ``\pause`` command. It does sequential
+overlays. Non sequential overlays can also be done. (Lab exercise.)
 
-The ``\includeonly`` is useful for debugging or testing the LaTeX document that you are creating, since it restricts the ``\include`` command. Only the files which are given as arguments to the ``\includeonly`` command will be included in the document (wherever a ``\include`` command for those files, has been issued).
-
-A note on filenames
-+++++++++++++++++++
-
-Never use filenames or directories that contain spaces. Make filenames as long or short as you would like, but strictly avoid spaces. Stick to upper or lower case letters (without accents), the digits, the hyphen and the full stop or period.
-
-
+If you have fragile environments like ``verbatim`` or ``lstlisting``,
+you need to give the frame an optional parameter ``[fragile]``.
 
-Recommended Reading
--------------------
+To achieve more with beamer, it is highly recommended that you look at
+the ``beameruserguide``.
 
-1. *LaTeX Wikibook*
-
-2. *The Not So Short Introduction to LaTeX2e* by Tobias Oetikar et al.. 
-
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/latex/lab-workbook.tex	Tue Sep 07 11:03:27 2010 +0530
@@ -0,0 +1,133 @@
+% Created 2010-08-31 Tue 18:51
+\documentclass[11pt]{article}
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage{fixltx2e}
+\usepackage{graphicx}
+\usepackage{longtable}
+\usepackage{float}
+\usepackage{wrapfig}
+\usepackage{soul}
+\usepackage{textcomp}
+\usepackage{marvosym}
+\usepackage{wasysym}
+\usepackage{latexsym}
+\usepackage{amssymb}
+\usepackage{hyperref}
+\tolerance=1000
+\providecommand{\alert}[1]{\textbf{#1}}
+
+\title{Lab Workbook --- \LaTeX}
+\author{FOSSEE}
+\date{August, 2010}
+
+\begin{document}
+
+\maketitle
+
+\setcounter{tocdepth}{3}
+\tableofcontents
+\vspace*{1cm}
+
+\section{Lab-1}
+\label{sec-1}
+
+
+\begin{enumerate}
+\item Compile and produce a pdf output of \texttt{example1.tex}.
+\item Modify \texttt{example1.tex} replacing \texttt{LaTeX} with \texttt{\textbackslash{}LaTeX}.
+\item Add a title, author and date to the document.
+\item What happens if \texttt{\textbackslash{}date} is replaced by \texttt{\textbackslash{}date\{IIT, Bombay\}} ?
+\item Debug and compile examples 2, 3, 4, 5
+\item Provide a document (pdf and source) with a TOC, but has been
+     compiled only once. Exercise for Debugging.
+\item What happens when you add the following \LaTeX{} code to the
+     document from the previous question? 
+     
+\begin{verbatim}
+      \renewcommand{\contentsname}{What is Here?}
+\end{verbatim}
+
+\item Experiment with setting the secnumdepth counter to 1, 0, -1.
+\item Debug and compile example 6.
+\item Experiment with the options of \texttt{\textbackslash{}documentclass}.
+
+\begin{itemize}
+\item 10pt, 11pt, 12pt sets the size of the text of the document.
+\item onecolumn, twocolumn
+\item draft --- makes \LaTeX{} highlight problems in typesetting to
+        be looked at by a human.
+\end{itemize}
+
+\end{enumerate}
+\section{Lab-2}
+\label{sec-2}
+
+
+\begin{enumerate}
+\item \texttt{\textbackslash{}newpage} command adds a page break. Add some page breaks to
+     example 6 and see how the command works.
+\item Try out the commands \texttt{\textbackslash{}pagestyle} and \texttt{\textbackslash{}thispagestyle} with the
+     following parameters and look at the outputs obtained.
+
+\begin{itemize}
+\item \texttt{empty},
+\item \texttt{plain},
+\item \texttt{heading}
+\end{itemize}
+
+\item Add the following description list describing the options to
+     \texttt{\textbackslash{}includegraphics} command to a document and look at the output. 
+
+\begin{verbatim}
+\begin{description}
+\item[{\texttt{width=x}, \texttt{height=x}}] 
+If only the height or width is specified, the image is scaled, maintaining the aspect ratio.
+
+\item[{\texttt{keepaspectratio}}]  
+This parameter can either be set to true or false. When set to true, the image is scaled according to both width and height, without changing the aspect ratio, so that it does not exceed both the width and the height dimensions.
+
+\item[{\texttt{angle=x}}] 
+This option can be used to rotate the image by \texttt{x} degrees, counter-clockwise.
+
+\end{description}
+\end{verbatim}
+\item \texttt{\textbackslash{}ldots} is used to get ellipsis in \LaTeX{} documents.
+\item Read the manual of listings package and learn how to include a
+     set of lines from a file into a \LaTeX{} document. Include a few
+     lines from your previous lab exercises of ULT.
+\item To change the line spacing of your document
+     \texttt{\textbackslash{}usepackage\{setspace\}} and then specify the line spacing of
+     your document, using \texttt{\textbackslash{}doublespace}, \texttt{\textbackslash{}onehalfspace}, etc.
+\item Debug and compile examples 9, 10
+\end{enumerate}
+\section{Lab-3}
+\label{sec-3}
+
+
+\begin{enumerate}
+\item Debug and compile example 7.
+\item BibTeX is another way of handling bibliography. Look at
+       bibtex.rst and change draft.tex to use BibTeX.
+\item As you would've already observed, \LaTeX{} compilation produces a
+       lot of other files along with the pdf output.
+
+\begin{itemize}
+\item .log --- gives a log of what happened during last
+         compilation.
+\item .toc --- stores section headers. Edit this file and observe
+         changes in this document to see how the compilation of \LaTeX{}
+         works and why two compilations are required for table of
+         contents to work.
+\item .aux --- used to share information between consecutive
+         compiler runs.
+\end{itemize}
+
+\item Prepare a presentation in beamer with solutions to any 10
+       problems from the Lab workbook.
+\item Debug and compile example 8.
+\item Finish the incomplete parts of the draft to obtain the complete
+       output of the sample document that we started out to prepare.
+\end{enumerate}
+
+\end{document}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/latex/slides.tex	Tue Sep 07 11:03:27 2010 +0530
@@ -0,0 +1,839 @@
+\documentclass[english]{beamer}
+
+% generated by Docutils <http://docutils.sourceforge.net/>
+\usepackage{fixltx2e} % LaTeX patches, \textsubscript
+\usepackage{cmap} % fix search and cut-and-paste in PDF
+\usepackage{babel}
+\usepackage[T1]{fontenc}
+\usepackage[latin1]{inputenc}
+\usepackage{listings}
+\usepackage{amsmath}
+\lstset{
+  language=TeX,
+  basicstyle=\small\ttfamily,
+  commentstyle=\ttfamily\color{blue},
+  stringstyle=\ttfamily\color{orange},
+  showstringspaces=false,
+  breaklines=true,
+  postbreak = \space\dots
+}
+
+\usepackage{ifthen}
+\usepackage{longtable}
+\usepackage{array}
+\setlength{\extrarowheight}{2pt}
+\newlength{\DUtablewidth} % internal use in tables
+
+\mode<presentation>
+{
+  \usetheme{Warsaw}
+  \useoutertheme{infolines}
+  \setbeamercovered{transparent}
+}
+
+
+\title{\LaTeX}
+\author[FOSSEE] {FOSSEE}
+\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT
+  Bombay}
+\date{}
+
+%% Delete this, if you do not want the table of contents to pop up at
+%% the beginning of each subsection:
+\AtBeginSubsection[]
+{
+  \begin{frame}<beamer>
+    \frametitle{Outline}
+    \tableofcontents[currentsection,currentsubsection]
+  \end{frame}
+}
+
+\AtBeginSection[]
+{
+  \begin{frame}<beamer>
+    \frametitle{Outline}
+    \tableofcontents[currentsection,currentsubsection]
+  \end{frame}
+}
+
+\begin{document}
+
+% Document title
+\begin{frame}
+  \maketitle  
+\end{frame}
+
+\section{Introduction}
+
+\begin{frame}
+  \frametitle{\LaTeX~- Introduction}
+  \begin{itemize}
+  \item Typesetting program
+  \item Excellently Typeset Documents - specially Math
+  \item Anything from one page articles to books. 
+  \item Based on \TeX
+  \item Pronounced ``Lah-tech'' or ``Lay-tech''
+  \end{itemize}
+\end{frame}
+
+\begin{frame}
+  \frametitle{This Course}
+  \begin{itemize}
+  \item Look at Sample document - \texttt{sample.pdf}
+  \item The document will be produced by the end of the course. 
+  \item First Hour - Basic Structure
+  \item Second Hour - Text, Tables, Figures, References
+  \item Third Hour - Math, Bibliography, Presentations
+  \end{itemize}
+\end{frame}
+
+
+\begin{frame}
+  \frametitle{A Look at the Sample Document}
+  \begin{itemize}
+  \item Title, Author, Date
+  \item Abstract
+  \item Sections
+  \item Subsections
+  \item Appendix
+  \item References/Bibliography
+  \item Tables
+  \item Figures
+  \item Math
+  \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{The source \& compilation}
+  Write the following code into the file \texttt{draft.tex}.
+  \begin{lstlisting}
+    \documentclass{article}
+    \begin{document}
+    SciPy is open-source software for mathematics, 
+    science, and engineering.   
+    \end{document}
+  \end{lstlisting}
+  To compile the document, do the following in your terminal: 
+  \begin{lstlisting}[language=bash]
+    $ pdflatex draft.tex
+  \end{lstlisting}
+  This produces the output file \texttt{draft.pdf} %%$
+  Note: \texttt{latex} command is often used to get \texttt{dvi}
+  output. Throughout this course, we shall use \texttt{pdflatex} to
+  compile our documents to \texttt{pdf} output.
+\end{frame}  
+
+\section{Structure of the Document}
+
+\begin{frame}[fragile]
+  \frametitle{\lstinline+documentclass+}
+  \begin{itemize}
+  \item \LaTeX~typesets based on \lstinline{documentclass}
+  \item Defines structure and formatting of a document
+  \item \LaTeX~is a document based mark-up
+  \item Mark-up --- a system of annotating text, adding extra
+    information to specify structure and presentation of text
+  \item Document based markup $\rightarrow$ you don't have to worry
+    about each element individually 
+  \item Allows you to focus on content, rather than appearance.
+  \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Environments and Commands}
+  \lstinline{document} is an environment, present in every document. 
+  \begin{itemize}
+  \item Environments
+    \begin{itemize}
+    \item \lstinline{\begin} and \lstinline{\end} define the beginning
+      and end of an environment
+    \item All the content of the document is placed inside the
+      \lstinline{document} environment 
+    \end{itemize}
+  \item Commands
+    \begin{itemize}
+    \item All commands begin with \textbackslash
+    \item They are case-sensitive
+    \item Only alpha caracthers; other characters terminate commands
+    \end{itemize}
+  \end{itemize}
+\end{frame}
+
+
+\begin{frame}[fragile]
+  \frametitle{Top Matter}
+  Let's add the Title, Author's name and the date to the document.
+  \begin{itemize}
+  \item Add title, author and date. Compile. Nothing changes.
+  \end{itemize}
+  \begin{lstlisting}
+    \title{A Glimpse at Scipy}
+    \author{FOSSEE}
+    \date{June 2010}
+  \end{lstlisting}
+  \tiny{See \texttt{hg} rev1 of draft.}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Top Matter \ldots}
+  \begin{itemize}
+  \item \lstinline{\maketitle} command inserts the top-matter.
+  \item Compile again. 
+  \item If no date is specified, today's date is automatically
+    inserted.
+  \end{itemize}
+  \begin{lstlisting}
+    \begin{document}
+    \maketitle
+    SciPy is open-source software for mathematics, science, and engineering.   
+    \end{document}
+   \end{lstlisting}
+  \tiny{See \texttt{hg} rev2 of draft.}
+\end{frame}
+
+
+\begin{frame}[fragile]
+  \frametitle{Abstract}
+  \begin{itemize}
+  \item The abstract environment is placed at the location where it's
+    put in the source. 
+  \end{itemize}
+  \begin{lstlisting}
+    \begin{abstract}
+      This document shows a glimpse of the features of Scipy that will
+      be explored during this course.
+    \end{abstract}
+  \end{lstlisting}
+  \tiny See rev3 of \texttt{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Sectioning}
+  \begin{itemize}
+  \item \lstinline{\section}, \lstinline{\subsection}
+    \lstinline{\subsubsection}
+  \item Auto numbered sections!
+  \item \* to prevent numbering of a section
+  \end{itemize}
+  \begin{lstlisting}
+    \section{A Glimpse of Scipy functions}
+    \subsection{Matrix Operations}
+    \subsubsection{Inverse}
+  \end{lstlisting}
+  \tiny See rev4 of \texttt{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Sectioning \ldots}
+  \begin{itemize}
+  \item Longer documents, use \lstinline{report} or \lstinline{book}
+    class
+  \item Chapter can be added using \lstinline{\chapter}
+  \end{itemize}
+  \begin{lstlisting}
+    \documentclass{report}
+
+    \chapter{One}
+  \end{lstlisting}
+  \begin{itemize}
+  \item subsections do not get numbering
+  \item Change \lstinline{secnumdepth}
+  \end{itemize}
+  \begin{lstlisting}
+    \setcounter{secnumdepth}{3}
+  \end{lstlisting}
+   \tiny See rev5 of \texttt{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Appendices}
+  \begin{itemize}
+  \item Anything following the \lstinline{\appendix} command is added
+    to the Appendix. 
+  \end{itemize}
+  \begin{lstlisting}
+    \appendix
+    
+    \section{Plotting using Pylab}
+  \end{lstlisting}
+  \tiny See rev7 of \texttt{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Table of Contents [TOC]}
+  \begin{itemize}
+  \item Our document is short, but let's learn to add a TOC.
+  \item Add \lstinline{\tableofcontents} where you want TOC to
+    appear.
+  \item Compile. 
+  \item Only headings appear. No page numbers. 
+  \item A \lstinline{\.toc} file is generated. 
+  \item Re-compile.
+  \item Any numbered section/block automatically appears
+  \end{itemize}
+  \tiny See rev8 of \texttt{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{TOC \ldots}
+  \begin{itemize}
+  \item To add un-numbered sections, use \lstinline{\addcontentsline}
+  \end{itemize}
+  \begin{lstlisting}
+    \section*{Introduction}
+    \addcontentsline{toc}{section}{Intro}
+  \end{lstlisting}
+  \tiny See rev9 of \texttt{hg}
+\end{frame}
+
+\begin{frame}
+  \frametitle{Bibliography}
+  We shall look at Bibliographies, later in the course. 
+\end{frame}
+
+\section{Typesetting Text}
+\begin{frame}[fragile]
+  \frametitle{Line breaks, Paragraphs}
+  \begin{itemize}
+  \item Add the text of second paragraph in the introduction section. 
+  \item Compile. 
+  \item An empty line starts a new para
+  \item New paragraphs are indented
+  \item Multiple spaces or empty lines are considered as one
+  \item To start a new line \lstinline{\\} or \lstinline{\newline}
+  \end{itemize}
+  \tiny See rev10 of \texttt{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Quotation Marks}
+  \begin{itemize}
+  \item The quotation marks around Sigh Pie are not formatted properly
+  \item Use \`~ (accent) for left quote
+  \item Use \'~ (apostrophe) for right quote
+  \item For double quotes, use them twice
+  \end{itemize}
+  \begin{center}
+    \`~\`~Sigh Pie\'~\'~
+  \end{center}
+  \tiny See rev11 of \texttt{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Fonts - Emphasis, Fixed width, \ldots}
+  \begin{itemize}
+  \item \lstinline{\emph} gives emphasized or italic text
+  \item \LaTeX environments can be nested
+  \item Let's add sub-package names as text, before learning to
+    typeset tables
+  \item Note multiple spacing won't work
+  \end{itemize}
+  \begin{lstlisting}
+    Subpackage - Description\\
+    cluster - Clustering algorithms\\
+    constants - Physical and mathematical constants\\
+    fftpack - Fast Fourier Transform routines\\
+  \end{lstlisting}
+  \begin{center}
+    \hspace{1in}\vdots
+  \end{center}
+  \tiny See rev12 of \texttt{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Fonts - Emphasis, Fixed width, \ldots}
+  \begin{itemize}
+  \item Use \lstinline{\texttt} for sub-packages names - fixed width
+  \item \lstinline{\textbf} for bold face
+  \item \lstinline{-} can be replaced with \lstinline{--} or
+    \lstinline{---} for better formatting
+  \end{itemize}
+  \begin{lstlisting}
+    \textbf{Subpackage} --- \textbf{Description}\\
+    \texttt{cluster} --- Clustering algorithms\\
+    \texttt{constants} --- Physical and mathematical constants\\
+    \texttt{fftpack} --- Fast Fourier Transform routines\\
+  \end{lstlisting}
+  \begin{center}
+    \hspace{1in}\vdots
+  \end{center}
+  \tiny See rev13 of \texttt{hg}
+\end{frame}
+
+\subsection{Lists}
+\begin{frame}[fragile]
+  \frametitle{Lists}
+  \begin{itemize}
+  \item \lstinline{enumerate} environment is used for numbered lists
+  \item \lstinline{itemize} environment gives un-numbered lists
+  \item Each item in the list is specified using \lstinline{\item}
+  \item Nested lists are also easily handled, as expected
+  \item Example on next slide
+  \end{itemize}
+  \tiny See rev14 of \texttt{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Lists \ldots}
+  \begin{lstlisting}
+    \begin{enumerate}
+    \item Plotting
+    \item Matrix Operations
+      \begin{itemize}
+      \item Inverse
+      \end{itemize}
+    \item Solving Equations
+      \begin{itemize}
+      \item System of Linear equations
+      \end{itemize}
+    \item Integration 
+      \begin{itemize}
+      \item Quadrature
+      \item ODEs
+      \end{itemize}
+    \end{enumerate}
+  \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Footnotes}
+  \begin{itemize}
+  \item Add footnote for \lstinline{pylab}
+  \item It's easily done using \lstinline{\footnote} command 
+  \end{itemize}
+  \begin{lstlisting}
+    Plotting \footnote{using \texttt{pylab} - see Appendix A} 
+  \end{lstlisting}
+  \begin{itemize}
+  \item We have just written down the name of the appendix
+  \item But if another section is added before it, the reference has
+    to be changed
+  \item \LaTeX provides labels and references
+  \end{itemize}
+  \tiny See rev15 of \texttt{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Labels and References}
+  \begin{itemize}
+  \item First add a label to the section that we wish to refer to
+  \item \lstinline+\label{labelname}+
+  \item Change footnote to use the reference
+  \item \lstinline+\ref{labelname}+
+  \item Compile twice
+  \end{itemize}
+  \begin{lstlisting}
+    \section{Plotting using Pylab}\label{mpl}
+
+    Plotting \footnote{using \texttt{pylab} - see Appendix \ref{mpl}} 
+  \end{lstlisting}
+  \tiny See rev15 of \texttt{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Including code}
+  \begin{itemize}
+  \item Instead of using \lstinline{\texttt} we could use
+    \lstinline{\verbatim} 
+  \item \lstinline{listings} is a powerful package
+  \item \lstinline+\usepackage{listings}+ needs to be added 
+  \item Tell \LaTeX the language, you are going to use
+  \end{itemize}
+  \begin{lstlisting}
+    \usepackage{listings} 
+    \lstset{language=Python,
+      basicstyle=\ttfamily\bfseries,
+      showstringspaces=false}
+  \end{lstlisting}
+  \tiny See rev16 of \texttt{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Including code}
+  \begin{itemize}
+  \item Use \lstinline{lstlisting} for a block of code
+  \item \lstinline+\lstinline+ for inline code
+  \item Let's add the code to Appendix
+  \end{itemize}
+  \begin{lstlisting}
+    \begin{lstlisting.}
+      In []: x = linspace(0, 2*pi, 50)
+      In []: plot(x, sin(x))
+      In []: title('Sine Curve between 0 and $\pi$')
+      In []: legend(['sin(x)'])
+    \end{lstlisting.}
+  \end{lstlisting}
+  \tiny See rev16 of \texttt{hg}
+\end{frame}
+
+\section{Figures, Tables \& Floats}
+\begin{frame}[fragile]
+  \frametitle{Figures}
+  \begin{itemize}
+  \item Let's add the figure in the Appendix
+  \item \lstinline+\usepackage{graphicx}+
+  \item To add a graphic, use \lstinline{\includegraphics} command
+  \item We give the relative path to the \lstinline+.png+ image
+  \end{itemize}
+  \begin{lstlisting}
+    \usepackage{graphicx}
+    
+    \begin{figure}[h!]
+    \begin{center}
+      \includegraphics[scale=0.4]{../sine.png}      
+    \end{center}
+    \caption{Sine Curve}
+    \label{fig:sin}
+    \end{figure}
+  \end{lstlisting}
+
+  \tiny See rev17 of \texttt{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{\lstinline{includgraphics}}
+  It takes following optional arguments
+  \begin{itemize}
+  \item \lstinline+scale+ --- specifies the factor by which to scale
+    the image 
+  \item \lstinline+height+, \lstinline+width+ --- If only one of them
+    is specified, aspect ratio is maintained 
+  \item \lstinline+keepaspectratio+ --- boolean value to keep aspect
+    ratio or not 
+  \item \lstinline+angle+ --- specify by what angle the image should
+    be rotated 
+  \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Floats}
+  \begin{itemize}
+  \item Graphics (\& Tables) are special because they cannot be broken
+    across pages 
+  \item They are ``floated'' to the next page, if they don't fit in
+    the current page 
+  \item Enclose graphic within \lstinline+figure+ environment to make
+    it float 
+  \item Figure environment takes additional parameter for location of
+    float 
+  \end{itemize}
+  \begin{table}
+    \caption{Permission Specifiers}
+    
+    \begin{tabular}{|c|c|}
+      Specifier & Permission\\\hline
+      t & Top of page\\
+      b & Bottom of page\\
+      p & Separate page for floats\\
+      h & here (the same place where command appears in source)\\
+      ! & override \LaTeX's internal parameters for good position
+    \end{tabular}
+  \end{table}
+\end{frame}
+
+\begin{frame}
+  \frametitle{Captions and References}
+  \begin{itemize}
+  \item Figure environment allows us add a caption
+  \item To place the image in the center we enclose it in the
+    \lstinline+center+ environment 
+  \item We can label images too
+  \item label shoule be added after the caption command
+  \item Figures are auto numbered
+  \end{itemize}
+  \tiny See rev17 of \texttt{hg}
+\end{frame}
+
+\subsection{Tables}
+
+\begin{frame}[frame]
+  \frametitle{Tables}
+  \begin{itemize}
+  \item \lstinline+tabular+ is used to typeset a table
+  \item It is enclosed in a \lstinline+table+ environment to make it a
+    float 
+  \item \lstinline+table+ environment also gives captions, auto
+    numbering  
+  \end{itemize}
+\end{frame}
+
+
+\begin{frame}[fragile]
+  \frametitle{\lstinline+tabular+}
+  \begin{itemize}
+  \item tabular takes formatting of each column as argument
+  \end{itemize}
+
+  \begin{table}
+    \caption{tabular environment}
+    
+    \begin{tabular}{|l|l|}
+      \lstinline+l+ & left justified column content\\\hline
+      \lstinline+r+ & right justified column content\\\hline
+      \lstinline+c+ & centered column content\\\hline
+      \lstinline+|+ & produces a vertical line\\
+    \end{tabular}
+  \end{table}
+  \begin{itemize}
+  \item also takes an optional parameter for specifying position of
+    table 
+  \item \lstinline+t+ for top, \lstinline+b+ for bottom, \lstinline+c+
+    for center 
+  \item each column of table is separated by \&
+  \item each row is separated by newline \lstinline{\\}
+  \item \lstinline+\hline+ give a horizontal line between two rows
+  \end{itemize}
+  \tiny See rev18 of \texttt{hg}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{\lstinline+tabular+ \ldots}
+  \begin{lstlisting}
+    \begin{table}
+      \caption{Sub-packages available in Scipy}
+      \label{subpkg}
+      \begin{tabular}{|l|l|}
+        \hline
+        \textbf{Subpackage} & \textbf{Description}\\
+        \texttt{constants} & Physical and mathematical constants\\
+        \hline
+        \texttt{fftpack} & Fast Fourier Transform routines\\
+        \hline
+        \end{tabular}
+      \end{table}
+    \end{lstlisting}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{List of Tables, Figures}
+  \begin{itemize}
+  \item \lstinline+listoftables+
+  \item \lstinline+listoffigures+
+  \end{itemize}
+\end{frame}
+
+
+\section{Typesetting Math}
+\begin{frame}[fragile]
+  \frametitle{Math in \LaTeX}
+  \begin{itemize}
+  \item Math is enclosed in a pair of \lstinline{$} signs o
+    \lstinline+\(  \)+ %$
+  \item Used for typesetting inline Math. 
+  \item \lstinline+\usepackage{amsmath}+
+  \item Let's now move on to matrices. 
+  \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Matrices}
+  \begin{itemize}
+  \item \lstinline+\bmatrix+ is used to typeset the matrix A
+  \item It works similar to ta tabular environment
+  \item \lstinline+&+ for demarcating columns
+  \item \lstinline+\\+ for demwarcating rows
+  \end{itemize}
+  \begin{lstlisting}
+    Let $\mathbf{A}$ be the matrix 
+    \(
+    \begin{bmatrix}
+      1 &3 &5\\
+      2 &5 &1\\
+      2 &3 &8
+    \end{bmatrix}
+    \)
+  \end{lstlisting}
+  \tiny See rev19 of \texttt{hg}    
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Matrices \ldots}
+  \begin{itemize}
+  \item There are 5 other matrix environments 
+  \end{itemize}
+  \begin{table}
+    \center
+    \begin{tabular}{c|c}
+      \lstinline+matrix+  &  none\\
+      \lstinline+pmatrix+ &  \lstinline+(+\\
+      \lstinline+Bmatrix+ &  \lstinline+{+\\
+        \lstinline+vmatrix+ &  \lstinline+|+\\  
+        \lstinline+Vmatrix+ &  \lstinline+||+
+    \end{tabular}
+  \end{table}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Superscripts \& Subscripts}
+  \begin{itemize}
+  \item \lstinline+^+ for superscripts
+  \item To have multiple characters as sub/superscript, enclose in
+    \lstinline+{ }+
+  \item \lstinline+_+ for subscripts
+  \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Summation \& integration}
+  \begin{itemize}
+  \item \lstinline+\sum+ command gives the summation symbol
+  \item The upper and lower limits are specified using the
+    \lstinline+^+ and \lstinline+_+ symbols. 
+  \item Similarly the integral symbol is obtained using
+    \lstinline+\int+ command. 
+  \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{\lstinline+displayed+ math}
+  \begin{itemize}
+  \item The equation in Determinants section is different. 
+  \item It is a displayed equation. 
+  \item \LaTeX~ or \lstinline+amsmath+ has a number of environments
+    for ``displaying'' equations, with minor differences. 
+  \item In general, enclose math in \lstinline+\[+ and \lstinline+\]+
+    to get displayed math. 
+  \item \lstinline+\begin*{equation}+ is equivalent to this.
+  \item Use \lstinline+\begin{equation}+ to get numbered
+    equations. %%\end{equation} 
+  \end{itemize}
+  \begin{lstlisting}
+    \[ \left|\mathbf{A}\right|=\sum_{j}\left(-1\right)^{i+j}a_{ij}\mathbf{M}_{ij} \]
+  \end{lstlisting}
+  \tiny See rev20 of \texttt{hg}    
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Groups of equations}
+  \begin{itemize}
+  \item The \lstinline+equation+ environment allows typesetting of
+    just 1 equation. 
+  \item \lstinline+eqnarray+ allows typesetting of multiple equations 
+  \item It is similar to the \lstinline+table+ environment
+  \item The parts of the equation that need to be aligned are
+    indicated using \& symbol.
+  \item Each equation is separated by a \lstinline+\newline+ command
+  \end{itemize}
+  \begin{lstlisting}
+    \begin{eqnarray*}
+      x^3 - 2x^2 - \frac{1}{2}x + 1 = 0\\
+      x^2(x-2) - \frac{1}{2}(x-2) = 0\\
+      (x-2)(x^2 - \frac{1}{2}) = 0\\
+      (x-2)(x - \frac{1}{\sqrt{2}})(x + \frac{1}{\sqrt{2}}) = 0
+    \end{eqnarray*}    
+  \end{lstlisting}
+  \tiny See rev21, 22 of \texttt{hg}    
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Fractions \& Surds}
+  \begin{itemize}
+  \item Fractions are typeset using \lstinline+\frac+ command 
+  \item \lstinline+\frac{numerator}{denominator}+ is typeset as
+    $\frac{numerator}{denominator}$
+  \item Surds are typeset using \lstinline+\sqrt[n]+ command
+  \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Greek characters \& Spacing}
+  \begin{itemize}
+  \item Typesetting Greek characters is simple
+  \item \lstinline+\alpha+, \lstinline+\beta+, \lstinline+\gamma+,
+    \ldots \lstinline+\Alpha+, \lstinline+\Beta+, \lstinline+\Gamma+
+    \ldots 
+  \item To get additional spacing in Math environments ---
+\begin{center}
+\begin{tabular}{|l|l|l|}
+\hline
+ Abbrev. & Spelled out & Example  \\
+\hline
+ \lstinline+\,+ & \lstinline+\thinspace+ & $A\,B$ \\
+\hline
+ \lstinline+\:+ & \lstinline+\medspace+ & $A\:B$ \\
+\hline
+ \lstinline+\;+ & \lstinline+\thickspace+ & $A\;B$ \\
+\hline
+   & \lstinline+\quad+ & $A \quad B$ \\
+\hline
+   & \lstinline+\qquad+ & $A \qquad B$ \\
+\hline
+ \lstinline+\!+ & \lstinline+\negthinspace+ & $A!B$ \\
+\hline
+   & \lstinline+\negmedspace+ & $A \negmedspace B$ \\
+\hline
+   & \lstinline+\negthickspace+ & $A \negthickspace B$ \\
+\hline
+
+\end{tabular}
+\end{center}
+  \end{itemize}
+\end{frame}
+
+\section{Bibliography}
+\begin{frame}[fragile]
+  \frametitle{Bibliography}
+  \begin{itemize}
+  \item \lstinline+thebibliography+ environment provides a clean and
+    simple way to add a bibliography to \LaTeX documents. 
+  \item \lstinline+\begin{thebibliography}+ takes as argument the
+    maximum with of the label that references will have. 
+  \item Each item of the Bibliography is similar to an item in a
+    list. 
+  \item \lstinline+\bibitem[label]{name}+ followed by the actual
+    reference info. 
+  \item label replaces auto enumeration numbers 
+  \item \lstinline+\cite{name}+ is used to \lstinline+cite+ the
+    \lstinline+bibitem+ 
+  \item You will need to compile twice. 
+  \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Bibliography}
+  \begin{lstlisting}
+    \begin{thebibliography}{9}
+    \bibitem{scipy} 
+      Eric Jones and Travis Oliphant and Pearu Peterson and others,
+      \emph{SciPy: Open source scientific tools for Python}, 2001 -- , 
+      \url{http://www.scipy.org/} 
+  \end{lstlisting}
+  \tiny See rev23 of \texttt{hg}    
+\end{frame}
+
+\section{Presentations - Beamer}
+\begin{frame}[fragile]
+  \frametitle{Beamer}
+  \begin{itemize}
+  \item Use beamer since your report's \LaTeX~ would be re-usable.
+  \item It is recommended to start with on of the beamer templates.
+  \item Let's look at speaker introduction template.
+  \item \lstinline+\documentclass{beamer}+ tells \LaTeX~ to start a
+    beamer presentation. 
+  \item A beamer document is very similar to any other \LaTeX~
+    document except that content is divided into slides. 
+  \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{Beamer \ldots}
+  \begin{itemize}
+  \item \lstinline+\usetheme+ command is used to specify the theme of the
+    presentation. 
+  \item \lstinline+\usecolortheme+ command is used to specify the color
+    theme. 
+  \item The content of a slide is enclosed within
+    \lstinline+\begin{frame}{Title}{Subtitle}+ and
+    \lstinline+\end{frame}+ 
+  \item If the slide contains \lstinline+verbatim+
+    \lstinline+lstlisting+ environments, the \lstinline+\begin{frame}+
+    should be passed an additional argument \lstinline+[fragile]+
+  \item Overlays can be achieved using the \lstinline+\pause+
+    command. 
+  \item To achieve more with beamer, it is highly recommended that you
+    look at the \texttt{beameruserguide} 
+  \end{itemize}
+\end{frame}
+
+\end{document} 
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/latex/workbook/bibtex.rst	Tue Sep 07 11:03:27 2010 +0530
@@ -0,0 +1,35 @@
+BibTeX
+~~~~~~
+
+The previous section explained the process of listing references at the end of a document and embedding cross references. In this section let us explore the BibTeX environment for keeping track of references.
+
+Using BibTeX is a very convenient method to use, when writing multiple documents in a single area or field. BibTeX allows you to create a database of all your references and use them as and when required. 
+
+The BibTeX database is stored in a ``.bib`` file. The structure of the file is quite simple and an example is shown below. 
+::
+
+  @book{Lamport94,
+  author    = "Leslie Lamport",
+  title     = "A Document Preparation System: User's Guide and Reference",
+  publisher = "Addison-Wesley Professional",
+  year      = "1994",
+  edition    = "second",
+  note      = "illustrations by Duane Bibby"
+  }
+
+Each bibliography entry starts with a declaration of the type of the reference being mentioned. The reference is in the above example is of the book type. BibTeX has a wide range of reference types, for example, ``article, book, conference, manual, proceedings, unpublished``.
+
+The type of reference is followed by a left curly brace, and immediately followed by the citation key. The citation key, ``Lamport94`` in the example above is used to cite this reference using the command ``\cite{Lamport94}``. 
+
+This is followed by the relevant fields and their values, listed one by one. Each entry must be followed by a comma to delimit one field from the other. 
+
+To get your LaTeX document to use the bibliography database, you just add the following lines to your LaTeX document. 
+::
+
+  \bibliographystyle{plain}
+  \bibliography{LaTeX}
+
+Bibliography styles are files that tell BibTeX how to format the information stored in the ``.bib`` database file. The style file for this example is ``plain.bst``. Note that you do not need to add the ``.bst`` extension to the filename.  If you wish to achieve a particular style of listing the bibliography items and citing them, you should use an appropriate style file. 
+
+The ``bibliography`` command specifies the file that should be used as the database for references. The file used in this example is ``LaTeX.bib``
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/latex/workbook/example1.tex	Tue Sep 07 11:03:27 2010 +0530
@@ -0,0 +1,4 @@
+\documentclass{article}
+\begin{document}
+This is my first LaTeX document. 
+\end{document}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/latex/workbook/example10.tex	Tue Sep 07 11:03:27 2010 +0530
@@ -0,0 +1,19 @@
+\documentclass{article}
+\begin{document}
+This is my simple document with nested lists. 
+\begin{enumerate}
+\item First Enumerated Item. 
+\item Second Enumerated Item. 
+\item Third Enumerated Item. 
+  \begin{itemize}
+  \item First Item.
+  \item Second Item.
+  \item Third Item.
+    \begin{itemize}
+    \item First Sub-Item.
+    \item Second Sub-Item.
+    \item Third Sub-Item.
+    \item Fourth Sub-Item.
+    \end{itemize}
+\end{enumerate}
+\end{document}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/latex/workbook/example2.tex	Tue Sep 07 11:03:27 2010 +0530
@@ -0,0 +1,26 @@
+\documentclass{article}
+\title{Python}
+\author{Wikipedia}
+\maketitle
+\begin{document}
+Python is a general-purpose high-level programming language whose
+design philosophy emphasizes code readability. Python aims to combine
+"remarkable power with very clear syntax", and its standard library is
+large and comprehensive. Its use of indentation for block delimiters
+is unusual among popular programming languages.
+
+Python supports multiple programming paradigms, primarily but not
+limited to object oriented, imperative and, to a lesser extent,
+functional programming styles. It features a fully dynamic type system
+and automatic memory management, similar to that of Scheme, Ruby,
+Perl, and Tcl. Like other dynamic languages, Python is often used as a
+scripting language, but is also used in a wide range of non-scripting
+contexts. 
+
+The reference implementation of Python (CPython) is free and open
+source software and has a community-based development model, as do all
+or nearly all of its alternative implementations. CPython is managed
+by the non-profit Python Software Foundation.
+
+This content is from Wikipedia's Python page. 
+\end{document}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/latex/workbook/example3.tex	Tue Sep 07 11:03:27 2010 +0530
@@ -0,0 +1,23 @@
+\documentclass{article}
+\begin{document}
+Python is a general-purpose high-level programming language whose
+design philosophy emphasizes code readability.[3] Python aims to
+combine "remarkable power with very clear syntax",[4] and its standard
+library is large and comprehensive. Its use of indentation for block
+delimiters is unusual among popular programming languages. 
+
+Python supports multiple programming paradigms, primarily but not
+limited to object oriented, imperative and, to a lesser extent,
+functional programming styles. It features a fully dynamic type system
+and automatic memory management, similar to that of Scheme, Ruby,
+Perl, and Tcl. Like other dynamic languages, Python is often used as a
+scripting language, but is also used in a wide range of non-scripting
+contexts. 
+
+The reference implementation of Python (CPython) is free and open
+source software and has a community-based development model, as do all
+or nearly all of its alternative implementations. CPython is managed
+by the non-profit Python Software Foundation.
+
+This content is from Wikipedia's Python page. 
+\end{docment}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/latex/workbook/example4.tex	Tue Sep 07 11:03:27 2010 +0530
@@ -0,0 +1,11 @@
+\documentclass{article}
+\title{A Glimpse at Scipy}
+\author{FOSSEE}
+date{2010}
+\begin{document}
+\maketitle
+SciPy is open-source software for mathematics, science, and
+engineering.   
+\end{document}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/latex/workbook/example5.tex	Tue Sep 07 11:03:27 2010 +0530
@@ -0,0 +1,24 @@
+\documentclass{article}
+\begin{document}
+\begin{abstract}
+  This content is from Wikipedia page on Python. 
+\end{abstract}
+Python is a general-purpose high-level programming language whose
+design philosophy emphasizes code readability. Python aims to combine
+"remarkable power with very clear syntax", and its standard library is
+large and comprehensive. Its use of indentation for block delimiters
+is unusual among popular programming languages.
+
+Python supports multiple programming paradigms, primarily but not
+limited to object oriented, imperative and, to a lesser extent,
+functional programming styles. It features a fully dynamic type system
+and automatic memory management, similar to that of Scheme, Ruby,
+Perl, and Tcl. Like other dynamic languages, Python is often used as a
+scripting language, but is also used in a wide range of non-scripting
+contexts. 
+
+The reference implementation of Python (CPython) is free and open
+source software and has a community-based development model, as do all
+or nearly all of its alternative implementations. CPython is managed
+by the non-profit Python Software Foundation.
+\end{document}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/latex/workbook/example6.tex	Tue Sep 07 11:03:27 2010 +0530
@@ -0,0 +1,31 @@
+%hello.tex - First LaTeX document
+\documentclass[12pt]{article}
+
+\title{LaTeX}
+\author{The FOSSEE Team}
+\date{August 2010}
+
+\begin{document}
+\maketitle
+\tableofcontents
+
+\begin{abstract}
+This is a sample document to be used in the STTP course for a quick introduction to \LaTeX
+\end{abstract}
+
+\section{Introduction}
+LaTeX is a typesetting program used to produce excellently typeset documents.
+
+\section{Structural Elements}
+Let us now look at giving a better structure to our document. 
+
+\subsection{documentclass}
+The \verb+documentclass+ variable tells \LaTeX, the type of document we wish to prepare. 
+
+\subsection{Sections, Chapters and Parts}
+We shall first look at how to divide the document into Sections, Chapters and Parts. 
+
+\subsubsection{Appendices}
+I can't tell you how to add an appendix, in the main document. 
+
+\end{document}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/latex/workbook/example7.tex	Tue Sep 07 11:03:27 2010 +0530
@@ -0,0 +1,13 @@
+\documentclass{article}
+\begin{document}
+This is my first LaTeX document. 
+\begin{equation}
+  a^2 + b^2 = c^2 
+\end{equation}
+\[
+\begin{pmatrix}
+\alpha& \beta^{*}\\
+\gamma^{*}& \delta
+\end{pmatrix}
+\]
+\end{document}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/latex/workbook/example8.tex	Tue Sep 07 11:03:27 2010 +0530
@@ -0,0 +1,176 @@
+\documentclass[english]{beamer}
+
+% generated by Docutils <http://docutils.sourceforge.net/>
+\usepackage{fixltx2e} % LaTeX patches, \textsubscript
+\usepackage{cmap} % fix search and cut-and-paste in PDF
+\usepackage{babel}
+\usepackage[T1]{fontenc}
+\usepackage[latin1]{inputenc}
+\usepackage{listings}
+\usepackage{amsmath}
+\lstset{
+  language=TeX,
+  basicstyle=\small\ttfamily,
+  commentstyle=\ttfamily\color{blue},
+  stringstyle=\ttfamily\color{orange},
+  showstringspaces=false,
+  breaklines=true,
+  postbreak = \space\dots
+}
+
+\usepackage{ifthen}
+\usepackage{longtable}
+\usepackage{array}
+\setlength{\extrarowheight}{2pt}
+\newlength{\DUtablewidth} % internal use in tables
+
+\mode<presentation>
+{
+  \usetheme{Warsaw}
+  \useoutertheme{infolines}
+  \setbeamercovered{transparent}
+}
+
+
+\title{\LaTeX}
+\author[FOSSEE] {FOSSEE}
+\institute[IIT Bombay] {Department of Aerospace Engineering\\IIT
+  Bombay}
+\date{}
+
+%% Delete this, if you do not want the table of contents to pop up at
+%% the beginning of each subsection:
+\AtBeginSubsection[]
+{
+  \begin{frame}<beamer>
+    \frametitle{Outline}
+    \tableofcontents[currentsection,currentsubsection]
+  \end{frame}
+}
+
+\AtBeginSection[]
+{
+  \begin{frame}<beamer>
+    \frametitle{Outline}
+    \tableofcontents[currentsection,currentsubsection]
+  \end{frame}
+}
+
+\begin{document}
+
+% Document title
+\begin{frame}
+  \maketitle  
+\end{frame}
+
+\section{Introduction}
+
+\begin{frame}
+  \frametitle{\LaTeX~- Introduction}
+  \begin{itemize}
+  \item Typesetting program
+  \item Excellently Typeset Documents - specially Math
+  \item Anything from one page articles to books. 
+  \item Based on \TeX
+  \item Pronounced ``Lah-tech'' or ``Lay-tech''
+  \end{itemize}
+\end{frame}
+
+\begin{frame}
+  \frametitle{This Course}
+  \begin{itemize}
+  \item Look at Sample document - \texttt{sample.pdf}
+  \item The document will be produced by the end of the course. 
+  \item First Hour - Basic Structure
+  \item Second Hour - Text, Tables, Figures, References
+  \item Third Hour - Math, Bibliography, Presentations
+  \end{itemize}
+\end{frame}
+
+
+\begin{frame}
+  \frametitle{A Look at the Sample Document}
+  \begin{itemize}
+  \item Title, Author, Date
+  \item Abstract
+  \item Sections
+  \item Subsections
+  \item Appendix
+  \item References/Bibliography
+  \item Tables
+  \item Figures
+  \item Math
+  \end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+  \frametitle{The source \& compilation}
+  Write the following code into the file \texttt{draft.tex}.
+  \begin{lstlisting}
+    \documentclass{article}
+    \begin{document}
+    SciPy is open-source software for mathematics, 
+    science, and engineering.   
+    \end{document}
+  \end{lstlisting}
+  To compile the document, do the following in your terminal: 
+  \begin{lstlisting}[language=bash]
+    $ pdflatex draft.tex
+  \end{lstlisting}
+  This produces the output file \texttt{draft.pdf} %%$
+  Note: \texttt{latex} command is often used to get \texttt{dvi}
+  output. Throughout this course, we shall use \texttt{pdflatex} to
+  compile our documents to \texttt{pdf} output.
+\end{frame}  
+
+\section{Structure of the Document}
+
+\begin{frame}[fragile]
+  \frametitle{\lstinline+documentclass+}
+  \begin{itemize}
+  \item \LaTeX~typesets based on \lstinline{documentclass}
+  \item Defines structure and formatting of a document
+  \item \LaTeX~is a document based mark-up
+  \item Mark-up --- a system of annotating text, adding extra
+    information to specify structure and presentation of text
+  \item Document based markup $\rightarrow$ you don't have to worry
+    about each element individually 
+  \item Allows you to focus on content, rather than appearance.
+  \end{itemize}
+\end{frame}
+
+\begin{frame}
+  \frametitle{Environments and Commands}
+  \lstinline{document} is an environment, present in every document. 
+  \begin{itemize}
+  \item Environments
+    \begin{itemize}
+    \item \lstinline{\begin} and \lstinline{\end} define the beginning
+      and end of an environment
+    \item All the content of the document is placed inside the
+      \lstinline{document} environment 
+    \end{itemize}
+  \item Commands
+    \begin{itemize}
+    \item All commands begin with \textbackslash
+    \item They are case-sensitive
+    \item Only alpha caracthers; other characters terminate commands
+    \end{itemize}
+  \end{itemize}
+\end{frame}
+
+
+\begin{frame}[fragile]
+  \frametitle{Top Matter}
+  Let's add the Title, Author's name and the date to the document.
+  \begin{itemize}
+  \item Add title, author and date. Compile. Nothing changes.
+  \end{itemize}
+  \begin{lstlisting}
+    \title{A Glimpse at Scipy}
+    \author{FOSSEE}
+    \date{June 2010}
+  \end{lstlisting}
+  \tiny{See \texttt{hg} rev1 of draft.}
+\end{frame}
+\end{document}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/latex/workbook/example9.tex	Tue Sep 07 11:03:27 2010 +0530
@@ -0,0 +1,11 @@
+\documentclass{article}
+\begin{document}
+This document contains a figure. 
+The figure \ref{fig:lion} is a drawing by Duane Bibby. 
+\begin{figure}
+\centering
+\label{fig:lion}
+\caption[CTAN Lion]{CTAN lion drawing by Duane Bibby; thanks to www.ctan.org}
+\includegraphics[scale=0.8, angle=30]{lion_orig.png}
+\end{figure}
+\end{document}
Binary file latex/workbook/lion_orig.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tdd/generate_testcases.py	Tue Sep 07 11:03:27 2010 +0530
@@ -0,0 +1,36 @@
+import random
+
+def gcd(a, b):
+    while b != 0:
+        a, b = b, a % b
+    return a
+
+a = random.sample(xrange(100), 10)
+b = random.sample(xrange(1000), 10)
+c = random.sample(xrange(10000), 10)
+c = random.sample(xrange(10000), 10)
+d = random.sample(xrange(100000), 10)
+e = random.sample(xrange(1000000), 10)
+f = a + b + c + d + e
+f.sort()
+a = random.sample(xrange(100), 10)
+b = random.sample(xrange(1000), 10)
+c = random.sample(xrange(10000), 10)
+d = random.sample(xrange(100000), 10)
+e = random.sample(xrange(1000000), 10)
+g = a + b + c + d + e
+
+testcases = []
+for item in f:
+    a = f[random.randrange(0, len(f))]
+    b = g[random.randrange(0, len(g))]
+    gc = gcd(a, b)
+    testcases.append([a, b, gc])
+
+sortedcases = sorted(testcases, key=lambda case: case[0])
+
+fil = open('/home/madhu/Desktop/gcdtest.dat', 'w')
+for case in sortedcases:
+    fil.write('%d, %d, %d\n' % (case[0], case[1], case[2]))
+
+fil.close()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tdd/math_utils/gcd.py	Tue Sep 07 11:03:27 2010 +0530
@@ -0,0 +1,22 @@
+def gcd(a, b):
+    """Returns the Greatest Common Divisor of the two integers
+    passed as arguments.
+
+    Args:
+      a: an integer
+      b: another integer
+
+    Returns: Greatest Common Divisor of a and b
+
+    >>> gcd(48, 64)
+    16
+    >>> gcd(44, 19)
+    1
+    """
+    if b == 0:
+        return b
+    return gcd(b, a%b)
+
+if __name__ == "__main__":
+    import doctest
+    doctest.testmod()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tdd/math_utils/gcd_testcases.dat	Tue Sep 07 11:03:27 2010 +0530
@@ -0,0 +1,50 @@
+6, 22, 2
+6, 48744, 6
+14, 143295, 1
+22, 751, 1
+35, 79, 1
+35, 96, 1
+52, 12, 4
+73, 79, 1
+73, 184790, 1
+86, 11, 1
+93, 8, 1
+93, 798, 3
+113, 42785, 1
+209, 2135, 1
+395, 8989, 1
+587, 331, 1
+643, 751, 1
+721, 242525, 1
+733, 5622, 1
+854, 42785, 1
+1695, 57, 3
+1695, 798, 3
+3429, 177203, 1
+4603, 12, 1
+4603, 48744, 1
+6139, 57, 1
+6139, 204, 1
+6660, 96, 12
+6660, 410400, 180
+6703, 410400, 1
+8964, 22, 2
+9673, 751, 1
+9673, 7909, 1
+9673, 3335, 1
+16028, 891, 1
+44231, 378, 1
+49020, 751, 1
+57908, 184790, 2
+65482, 548045, 1
+79715, 8, 1
+79715, 891, 1
+79715, 66371, 1
+321807, 891, 3
+366607, 97, 1
+402212, 5595, 1
+448426, 66371, 1
+575271, 4617, 9
+575271, 402152, 1
+680256, 48744, 72
+779565, 184790, 5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tdd/math_utils/test_gcd.py	Tue Sep 07 11:03:27 2010 +0530
@@ -0,0 +1,29 @@
+import gcd
+import unittest
+
+class TestGcdFunction(unittest.TestCase):
+
+    def setUp(self):
+        self.test_file = open('gcd_testcases.dat')
+        self.test_cases = []
+        for line in self.test_file:
+            values = line.split(', ')
+            a = int(values[0])
+            b = int(values[1])
+            g = int(values[2])
+
+            self.test_cases.append([a, b, g])
+
+    def test_gcd(self):
+        for case in self.test_cases:
+            a = case[0]
+            b = case[1]
+            g = case[2]
+            self.assertEqual(gcd.gcd(a, b), g)
+
+    def tearDown(self):
+        self.test_file.close()
+        del self.test_cases
+
+if __name__ == '__main__':
+    unittest.main()
--- a/tdd/tdd.rst	Tue Sep 07 10:45:11 2010 +0530
+++ b/tdd/tdd.rst	Tue Sep 07 11:03:27 2010 +0530
@@ -1,3 +1,7 @@
+=======================
+Test Driven Development
+=======================
+
 Fundamentals
 ============
 
@@ -6,8 +10,8 @@
 code that doesn't even exist yet. The actual code is written later to pass
 the test and then refactored.
 
-Writing tests
-=============
+First "Test"
+============
 
 Writing a test is simple. Writing a failing test? It is much more simple.
 Let us consider a very simple program which returns the Greatest Common
@@ -42,37 +46,568 @@
   def gcd(a, b):
       pass
 
-This stub does nothing other than defining a new function called gcd which
-takes two parameters a and b for which the GCD must be calculated. The body
-of the function just contains pass which means it does nothing, i.e. empty.
-We have our stub ready. One important thing we need to keep in mind when
-we adopt TDD methodology is that we need to have a clear set of results
-defined for our code units. To put it more clearly, for every given set of
-inputs as test case we must have, before hand, the exact outputs that are
-expected for those input test cases. If we don't have that we have failed
-in the first step of the TDD methodology itself. We must never run for
-outputs for our test cases after we have the code ready or even while
-writing tests. The expected outputs/behaviour must be in our hands before
-we start writing tests. Therefore let us define our test cases and the
-expected output for those inputs. Let one of our test cases be 48 and 64
-as *a* and *b* respectively. For this test case we know that the GCD is
-16. So that is the expected output. Let our second test case be 44 and
-19 as *a* and *b* respectively. We know that their GCD is 1 by simple paper
-and pen calculation.
+This stub does nothing other than defining a new function called gcd
+which takes two parameters a and b for which the GCD must be
+calculated. The body of the function just contains Python's **pass**
+statement which means it does nothing, i.e. empty. We have our stub
+ready. One important thing we need to keep in mind when we adopt TDD
+methodology is that we need to have a clear set of results defined for
+our code units. To put it more clearly, for every given set of inputs
+as test case we must have, before hand, the exact outputs that are
+expected for those input test cases. If we don't have that we have
+failed in the first step of the TDD methodology itself. We must never
+run looking for outputs for our test cases after we have the code
+ready or even while writing tests. The expected outputs/behaviour must
+be in our hands before we start writing tests. Therefore let us define
+our test cases and the expected output for those inputs. Let one of
+our test cases be 48 and 64 as *a* and *b* respectively. For this test
+case we know that the GCD is 16. So that is the expected output. Let
+our second test case be 44 and 19 as *a* and *b* respectively. We know
+that their GCD is 1 by simple paper and pen calculation.
 
 Now we know what a test is? What are the ingredients required to write
 tests? So what else should we wait for? Let us write our first test!::
 
   tc1 = gcd(48, 64)
   if tc1 != 16:
-      print "Test failed for the case a=48 and b=64. Expected 16. Obtained
-          %d instead." % tc1
+      print "Test failed for the case a=48 and b=64. Expected 16. Obtained %d instead." % tc1
       exit(1)
   
   tc2 = gcd(44, 19)
   if tc2 != 1:
-      print "Test failed for the case a=44 and b=19. Expected 1. Obtained
-          %d instead." % tc2
+      print "Test failed for the case a=44 and b=19. Expected 1. Obtained %d instead." % tc2
       exit(1)
 
   print "All tests passed!"
+
+Let us put all these in a file and call this file **gcd.py**::
+
+  def gcd(a, b):
+      pass
+
+  if __name__ == '__main__':
+      tc1 = gcd(48, 64)
+      if tc1 != 16:
+          print "Test failed for the case a=48 and b=64. Expected 16. Obtained %d instead." % tc1
+          exit(1)
+
+      tc2 = gcd(44, 19)
+      if tc2 != 1:
+          print "Test failed for the case a=44 and b=19. Expected 1. Obtained %d instead." % tc2
+          exit(1)
+
+      print "All tests passed!"
+
+Note that we have introduced a new semantic which uses two new magic names
+in Python *__name__* and *__main__*. This is a very common idiom used in
+Python. Every Python code in a file can be run in two ways: Either as an
+independent stand-alone script or as a Python module which can be imported
+by other Python scripts or modules. When the idiom::
+
+  if __name__ == '__main__':
+
+is used, the code within this if block is executed first when we run the
+Python file as a stand-alone script. In other words, when we run this
+python file as a stand-alone script the control of the program first starts
+from the code that is within this if block from which the control is
+transferred to other parts of the program or to other modules from
+here. This comes as an extremely handy feature especially when we want to
+test our modules individually. Now let us run our code as a stand-alone
+script.::
+
+  $ python gcd.py
+  Traceback (most recent call last):
+    File "gcd.py", line 7, in <module> print "Test failed for the case a=48 and b=64. Expected 16. Obtained %d instead." % tc1
+  TypeError: %d format: a number is required, not NoneType
+
+Now we have our tests, the test cases and the code unit stub at
+hand. We also have the failing test. So we know for sure that we have
+cleared the first check point of TDD where the tests have failed. The
+failing tests also give a green signal for us to go ahead to our next
+check point i.e. to write the actual code in our code unit and make
+the test pass. So let us write the code for the gcd function by
+removing the **pass** control statement which had just created a gcd
+function stub for us.
+
+Most of us have learnt in high school math classes that the best and
+the easiest known algorithm to compute the gcd of two numbers was
+given to us 2300 years ago by a greek mathematician named Euclid. So
+let us use the Euclid's algorithm to compute the gcd of two numbers a
+and b::
+
+  def gcd(a, b):
+      if a == 0:
+          return b
+      while b != 0:
+          if a > b:
+              a = a - b
+          else:
+              b = b - a
+      return a
+
+**Note**: If you are unaware of Euclidean algorithm to compute the gcd
+of two numbers please refer to it on wikipedia. It has a very detailed
+explanation of the algorithm and its proof of validity among other
+things.
+
+Now let us run our script which already has the tests written in it
+and see what happens::
+
+  $ python gcd.py
+  All tests passed!
+
+Success! We managed to pass all the tests. But wasn't that code simple
+enough? Indeed it was. If you take a closer look at the code you will
+soon realize that the chain of subtraction operations can be replaced
+by a modulo operation i.e. taking remainders of the division between
+the two numbers since they are equivalent operations. Also modulo
+operation is far better than chain of subtractions because you will
+reduce much faster using modulo operation than the subtraction. For
+example if let us take 25, 5 as a and b in our example. If we write
+down the steps of the algorithm written above we have the following:
+
+Step 1: a = 25 b = 5: Since both a and b are not 0 and b is greater
+than a: b = 25 - 5 = 20
+Step 2: Since b is still not 0 and b is greater than a: b = 20 - 5 =
+15
+Step 3: Since b is still not 0 and b is greater than a: b = 15 - 5 =
+10
+Step 4: Since b is still not 0 and b is greater than a: b = 10 - 5 = 5
+Step 5: Since b is still not 0 and b is equal to a: b = 5 - 5 = 0
+Step 6: Since b is 0 the gcd is a = 5 which is returned
+
+If we adopt the modulo operation instead of subtraction and follow the
+steps:
+
+Step 1: a = 25 b = 5: Since both a and b are not 0 and b is greater
+than a: b = 25 % 5 = 0
+Step 2: Since b is 0 the gcd is a = 5 which is returned
+
+Wow! That was overwhelmingly lesser number of steps! So now we are
+convinced that if we replace the subtraction operation with the modulo
+operation our code performs much better. But if we think carefully we
+know that the modulo of a and b is less than b irrespective of how
+large the value of a is, including the case where a is already less
+than b. So we can eliminate that extra conditional **if** statement by
+just swapping the result of the modulo operation to the position of b
+and b to the position of a. This ensures that a is always greater than
+b and if not the swapping combined with modulo operation takes care of
+it. To exemplify it, if a = 5 and b = 25 then by swapping and
+performing modulo we have a = b = 25 and b = a % b = 5 % 25 = 5 and
+hence we proceed. So let us replace our original code with this new
+improved code we have come up with simple observations::
+
+  def gcd(a, b):
+      while b != 0:
+          a, b = b, a % b
+      return a
+
+Executing our script again we will see that all the tests pass. One
+final improvement we can think of which is not necessary in terms of
+efficiency but is certainly good to do keeping in mind the readability
+is that we can use the concept of recursion for the same
+algorithm. Without going into much detail this is how the code looks
+if we use a recursive approach::
+
+  def gcd(a, b):
+      if b == 0:
+          return a
+      return gcd(b, a%b)
+
+Much shorter and sweeter! And it passes all the tests! But there is
+one small problem yet. For the users of this function there is no way
+to determine how to use it, how many parameters it takes what it
+returns among other things. And same as well for those who read the
+code. So this function is not a very well written piece of code since
+it lacks documentation. So to make this function mode readable let us
+add the docstring for this function. Rewriting the function with the
+docstring looks like this::
+
+  def gcd(a, b):
+      """Returns the Greatest Common Divisor of the two integers
+      passed as arguments.
+
+      Args:
+        a: an integer
+        b: another integer
+
+      Returns: Greatest Common Divisor of a and b
+      """
+      if b == 0:
+          return a
+      return gcd(b, a%b)
+
+Now we have refactored our code enough to make it well written piece
+of code. Let us move on.
+
+More realistic "Tests"
+======================
+
+Now we have successfully completed writing our first test, writing the
+relevant code and ensured the tests passed. We also refactored our
+code to perform better. With the knowledge of all these and some
+concepts and semantics like __main__ magic names we learnt we have
+come a long way with respect to writing tests. But our thirst is still
+unquenched! We want to do more and more tests! Not just write better
+code but also better tests! So let us keep building upon what we have
+learnt so far.
+
+Let us start writing tests for more realistic test cases. Generally
+tests are predetermined as said above, if not the software design in
+itself is flawed. The predetermined tests are stored along with the
+test code in some persistent format like in a database, a text file, a
+file of specific format like XML or in some other way. Let us continue
+with our example of GCD function. We will keep all our test cases in a
+text file, which is indeed persistent. Let us specify the format of
+the test data in our file as follows.
+
+  1. The file has multiple lines of test data.
+  2. Each line in this file corresponds to a single test case.
+  3. Each line consists of three comma separated coloumns:
+
+     i. First two coloumns are the integers for which the GCD has to
+        be computed
+     ii. Third coloumn is the expected GCD to the preceding two
+         numbers.
+
+So how do we write our tests to use these test cases? Pretty simple, let
+us review the machinery required first.
+
+  1. File reading: We already have learnt this in the modules on
+     Basic Python.
+  2. Parsing the read data from the file: This just involves a using a
+     **for** loop which iterates over the data line by line since we
+     know that the file contains each test case as a sepate line which
+     are equivalent to the file records and hence parse the data line
+     by line as strings as we iterate over it and convert it to the
+     required data type.
+
+Since we already have all the machinery required, let us proceed writing
+our test cases. We do not need not make any changes to the gcd
+function so we will just write down the test here. Let us call our
+data file gcd_testcases.dat::
+
+  if __name__ == '__main__':
+      for line in open('gcd_testcases.dat'):
+          values = line.split(', ')
+          a = int(values[0])
+          b = int(values[1])
+          g = int(values[2])
+
+          tc = gcd(a, b)
+          if tc != g:
+              print "Test failed for the case a=%d and b=%d. Expected %d. Obtained %d instead." % (a, b, g, tc)
+              exit(1)
+
+      print "All tests passed!"
+
+When we execute the gcd.py script again we will notice that all the
+tests passed.
+
+Python Testing Framework
+========================
+
+Python provides two ways to test the code we have written. One of them
+is the unittest framework and the the other is the doctest module.
+
+doctest
+~~~~~~~
+
+To start with let us discuss the doctest module. As we have already
+discussed a well written piece of code must always be accompanied by
+its documentation. For a function or a module we document them in their
+respective docstrings. In addition to this, we can also place the
+samples of using these functions or modules in the Python interactive
+interpreter in the docstrings. When we run the doctest module it picks
+up all such interactive session samples, executes them and determines
+if the documented piece of code runs as it is documented. Let us see
+how to write doctests for our gcd function::
+
+  def gcd(a, b):
+      """Returns the Greatest Common Divisor of the two integers
+      passed as arguments.
+
+      Args:
+        a: an integer
+        b: another integer
+
+      Returns: Greatest Common Divisor of a and b
+
+      >>> gcd(48, 64)
+      16
+      >>> gcd(44, 19)
+      1
+      """
+      if b == 0:
+          return a
+      return gcd(b, a%b)
+
+This is all a doctest is. To explain it in more simple terms tests
+which are written as part of the docstrings are called as
+doctests. Now how do we use our doctest module to execute this
+tests. That is fairly straight forward as well. All we need to do is
+tell the doctest module to execute. Let us place this piece of code at
+the same place where we placed our tests earlier. So putting all these
+together we have our gcd.py module which looks as follows::
+
+  def gcd(a, b):
+      """Returns the Greatest Common Divisor of the two integers
+      passed as arguments.
+
+      Args:
+        a: an integer
+        b: another integer
+
+      Returns: Greatest Common Divisor of a and b
+
+      >>> gcd(48, 64)
+      16
+      >>> gcd(44, 19)
+      1
+      """
+      if b == 0:
+          return a
+      return gcd(b, a%b)
+
+  if __name__ == "__main__":
+      import doctest
+      doctest.testmod()
+
+All we need to do is import the doctest module that is part of the
+Python's standard library. Call the testmod() function in this
+module. This function automatically checks for all the docstrings that
+have sample sessions from the interactive interpreter, if they exist
+it executes them and compares the output with the results as specified
+in the sample sessions. It complains if the results don't match as
+documented. When we execute this script as a stand-alone script we
+will get back the prompt with no messages which means all the tests
+passed::
+
+  $ python gcd.py
+  $ 
+
+If we further want to get a more detailed report of the tests that
+were executed we can run python with -v as the command line option
+to the script::
+
+  $ python gcd.py -v
+  Trying:
+      gcd(48, 64)
+  Expecting:
+    16
+  ok
+  Trying:
+      gcd(44, 19)
+  Expecting:
+      1
+  ok
+  1 items had no tests:
+      __main__
+  1 items passed all tests:
+     2 tests in __main__.gcd
+  2 tests in 2 items.
+  2 passed and 0 failed.
+  Test passed.
+
+
+**Note:** We can have the sample sessions as test cases as long as the
+outputs of the test cases do not contain any blank lines. In such
+cases we may have to use the exact string *<BLANKLINE>*
+
+For the sake of illustrating a failing test case, let us assume that
+we made a small mistake in our code. Instead of returning **a** when b
+= 0 we typed it as return b when b = 0. So all the gcds returned will
+have the value of 0 in such a piece of code. The code looks as
+follows::
+
+  def gcd(a, b):
+      """Returns the Greatest Common Divisor of the two integers
+      passed as arguments.
+
+      Args:
+        a: an integer
+        b: another integer
+
+      Returns: Greatest Common Divisor of a and b
+
+      >>> gcd(48, 64)
+      16
+      >>> gcd(44, 19)
+      1
+      """
+      if b == 0:
+          return a
+      return gcd(b, a%b)
+
+Executing this code snippet without -v option to the script::
+
+  $ python gcd.py
+  **********************************************************************
+  File "gcd.py", line 11, in __main__.gcd
+  Failed example:
+      gcd(48, 64)
+  Expected:
+      16
+  Got:
+      0
+  **********************************************************************
+  File "gcd.py", line 13, in __main__.gcd
+  Failed example:
+      gcd(44, 19)
+  Expected:
+      1
+  Got:
+      0
+  **********************************************************************
+  1 items had failures:
+     2 of   2 in __main__.gcd
+  ***Test Failed*** 2 failures.
+
+The output clearly complains that there were exactly two test cases
+that failed. If we want a more verbose report we can pass -v option to
+the script. This is pretty much about the doctest module in
+Python. doctest is extremely useful when we want to test each Python
+function or module individually. For more information about the
+doctest module refer to the Python library reference on doctest[0].
+
+unittest framework
+~~~~~~~~~~~~~~~~~~
+
+Not too far ahead we go we, we will start complaining that the doctest
+is not sufficient to write complicated tests especially when we want
+to automate our tests, write tests that need to test for more
+convoluted code pieces. For such scenarios Python provides a unittest
+framework.  unittest framework provides methods to efficiently
+automate tests, setup and teardown functionalities which helps to
+setup the initializing code and data for executing the specific tests
+and cleanly shutting them down once the tests are executed and ways to
+aggregate tests into collections and better way of reporting the
+tests.
+
+Let us continue testing our gcd function in the Python module named
+gcd.py. To get ourselves started, the unittest framework expects us to
+subclass TestCase class in unittest module and place all our test code
+as methods of this class. We will begin the name of the test method
+with **test_** so that the test runner knows which methods are to be
+executed as tests. We will use the test cases supplied by
+gcd_testcases.dat. Lastly, to illustrate the way to test Python code
+as a module let create a new file called test_gcd.py following the
+same convention used to name the test methods. We will place our test
+code within test_gcd.py module. Our test code looks like this::
+  
+  import gcd
+  import unittest
+
+  class TestGcdFunction(unittest.TestCase):
+
+      def setUp(self):
+          self.test_file = open('gcd_testcases.dat')
+          self.test_cases = []
+          for line in self.test_file:
+              values = line.split(', ')
+              a = int(values[0])
+              b = int(values[1])
+              g = int(values[2])
+
+              self.test_cases.append([a, b, g])
+
+      def test_gcd(self):
+          for case in self.test_cases:
+              a = case[0]
+              b = case[1]
+              g = case[2]
+              self.assertEqual(gcd.gcd(a, b), g)
+
+      def tearDown(self):
+          self.test_file.close()
+          del self.test_cases
+
+  if __name__ == '__main__':
+      unittest.main()
+
+Since we don't want to read this file into memory each time we run a
+separate test method, we will read all the data in the file into
+Python lists in the setUp method. The entire data file is kept in a
+list called test_cases which happens to be an attribute of the
+TestGCDFunction class. In the tearDown method of the class we
+will delete this attribute to free up the memory and close the
+opened file.
+
+Our actual test code sits in the method which begins with the name
+**test_** as said earlier, the test_gcd method. Note that we import
+the gcd Python module we have written at the top of this test file and
+from this test method we call the gcd function within the gcd module
+to be tested with the each set of **a** and **b** values in the
+attribute test_cases. Once we execute the function we obtain the
+result and compare it with the expected result as stored in the
+corresponding test_cases attribute using the assertEqual methods
+provided by our parent class TestCase in the unittest framework. There
+are several other assertion methods supplied by the unittest
+framework. For a more detailed information about this, refer to the
+unittest library reference at [1].
+
+nose
+====
+
+Now we know almost all the varities of tests we may have to use to
+write self-sustained, automated tests for our code. There is one last
+thing that is left. However one question remains, how do we easily
+organize choose and run the tests that is scattered around several
+files? 
+
+To further explain, the idea of placing tests with in the Python
+scripts and executing that test scripts themselves as stand-alone
+scripts works well as long as we have our code in a single Python file
+or as long as the tests for each script can be run separately. But in
+a more realistic software development scenario, often this is not the
+case. The code is spread around multiple Python modules and may be
+even across several Python packages.
+
+In such a such a scenario we wish we had a better tool to
+automatically aggregate these tests and execute them. Fortunately for
+us there exists a tool called nose. Although nose is not part of the
+standard Python distribution itself, it can be very easily installed
+by using easy_install command as follows::
+
+  $ easy_install nose
+
+Or download the nose package from [2], extracting the archive and
+running the command from the extracted directory::
+
+  $ python setup.py install
+
+Now we have nose up and running, but how do we use it? It is very
+straight forward as well. We will use the command provided by nose
+called as nosetests. Run the following command in the top level
+directory of your code::
+
+  $ nosetests
+
+Thats all, nose automatically picks all the tests in all the
+directories and subdirectories in our code base and executes them
+all. However if we want to execute specific tests we can pass the test
+file names or the directories as arguments to nosetests command. For a
+detailed explanation about this, refer to [3]
+
+Conclusion
+==========
+
+Now we have all the trappings we want to write state-of-the art
+tests. To emphasize the same point again, any code which was written
+before writing the test and the testcases in hand is flawed by
+design. So it is recommended to follow the three step approach while
+writing code for any project as below:
+
+  1. Write failing tests with testcases in hand.
+  2. Write the code to pass the tests.
+  3. Refactor the code for better performance.
+
+This approach is very famously known to the software development world
+as "Red-Green-Refactor" approach[4].
+
+
+[0] - http://docs.python.org/library/doctest.html
+[1] - http://docs.python.org/library/unittest.html
+[2] - http://pypi.python.org/pypi/nose/
+[3] - http://somethingaboutorange.com/mrl/projects/nose/0.11.2/usage.html
+[4] - http://en.wikipedia.org/wiki/Test-driven_development