diff options
Diffstat (limited to 'slides/latex')
-rw-r--r-- | slides/latex/examples/glimpse-at-scipy.tex | 426 | ||||
-rw-r--r-- | slides/latex/examples/sine.png | bin | 0 -> 27614 bytes | |||
-rw-r--r-- | slides/latex/lab-workbook.tex | 133 | ||||
-rw-r--r-- | slides/latex/slides.tex | 694 | ||||
-rw-r--r-- | slides/latex/workbook/bibtex.rst | 35 | ||||
-rw-r--r-- | slides/latex/workbook/example1.tex | 4 | ||||
-rw-r--r-- | slides/latex/workbook/example10.tex | 19 | ||||
-rw-r--r-- | slides/latex/workbook/example2.tex | 26 | ||||
-rw-r--r-- | slides/latex/workbook/example3.tex | 23 | ||||
-rw-r--r-- | slides/latex/workbook/example4.tex | 11 | ||||
-rw-r--r-- | slides/latex/workbook/example5.tex | 24 | ||||
-rw-r--r-- | slides/latex/workbook/example6.tex | 31 | ||||
-rw-r--r-- | slides/latex/workbook/example7.tex | 13 | ||||
-rw-r--r-- | slides/latex/workbook/example8.tex | 176 | ||||
-rw-r--r-- | slides/latex/workbook/example9.tex | 11 | ||||
-rw-r--r-- | slides/latex/workbook/lion_orig.png | bin | 0 -> 32381 bytes |
16 files changed, 1626 insertions, 0 deletions
diff --git a/slides/latex/examples/glimpse-at-scipy.tex b/slides/latex/examples/glimpse-at-scipy.tex new file mode 100644 index 0000000..8227c34 --- /dev/null +++ b/slides/latex/examples/glimpse-at-scipy.tex @@ -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} diff --git a/slides/latex/examples/sine.png b/slides/latex/examples/sine.png Binary files differnew file mode 100644 index 0000000..c059105 --- /dev/null +++ b/slides/latex/examples/sine.png diff --git a/slides/latex/lab-workbook.tex b/slides/latex/lab-workbook.tex new file mode 100644 index 0000000..95f33ae --- /dev/null +++ b/slides/latex/lab-workbook.tex @@ -0,0 +1,133 @@ +% Created 2010-08-31 Tue 20:40 +\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} diff --git a/slides/latex/slides.tex b/slides/latex/slides.tex new file mode 100644 index 0000000..ea23cf4 --- /dev/null +++ b/slides/latex/slides.tex @@ -0,0 +1,694 @@ +\documentclass{beamer} +\usepackage[latin1]{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 +\usepackage[english]{babel} \usepackage{ae,aecompl} +\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet} +\usepackage{listings} +\lstset{ + language=TeX, + basicstyle=\ttfamily\bfseries, + commentstyle=\ttfamily\color{blue}, + stringstyle=\ttfamily\color{orange}, + showstringspaces=false, + breaklines=true, + postbreak = \space\dots +} + +\newcommand{\typ}[1]{\lstinline{#1}} + +\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 + \begin{itemize} + \item What is typesetting? + \end{itemize} + \item Excellently Typeset Documents - specially Math + \item Anything from one page articles to huge books + \item Pronounced \emph{Lah-tech} or \emph{Lay-tech} + \end{itemize} +\end{frame} + +\begin{frame} + \frametitle{Why \LaTeX?} + \begin{itemize} + \item Excellent visual quality! + \item Handles the typesetting; Lets you focus on content + \item Makes writing math extremely simple + \item It is a standard -- widely used in Scientific community + \end{itemize} + \begin{block}{} + \[\tilde{N}_{\mathbf{x}}\times \mathbf{r}(\mathbf{x}) f_{1k}(\mathbf{x},t) - \frac{1}{2} \tilde{N} \tilde{N}:\mathbf{BB}^{T}P(\mathbf{x},t) = -m_{k}f_{1k}(\mathbf{x},t) + 2 \mathop{\mathbf{\aa}}_{j=1}^{K} f_{1j}(\mathbf{x},t)m_{j}P_{k|j} \] + \end{block} +\end{frame} + +\begin{frame} + \frametitle{Course Outline} + \begin{itemize} + \item Look at the sample document - \typ{sample.pdf} + \begin{itemize} + \item Title, Author, Date + \item Abstract + \item Sections \& Subsections + \item Appendix + \item References/Bibliography + \item Tables + \item Figures + \item Math + \end{itemize} + \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}[fragile] + \frametitle{\LaTeX~ as a Mark-up} + \begin{itemize} + \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{Typesetting a minimal document} + \begin{itemize} + \item Write the sample code into the file \typ{draft.tex}\\ + {\tiny See \typ{hg} rev0 of draft} + \item To compile, (in terminal) \\ + \begin{lstlisting}[language=bash] + $ pdflatex draft.tex + \end{lstlisting} %%$ + \item This produces the output file \typ{draft.pdf} + \item \alert{Note:} \typ{latex} vs. \typ{pdflatex} + \end{itemize} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Commands \& Environments} + \begin{itemize} + \item {\LaTeX} is case sensitive + \item Commands begin with a \typ{\\} + \item Environments have a \typ{\\begin} and \typ{\\end} + \item Any content after the \typ{\\end\{document\}} is ignored + \end{itemize} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Comments \& Special Characters} + \begin{itemize} + \item Anything that follows a \typ{\%} symbol till end of the line + is a comment + \item Special characters (\typ{\~ \# \$ \^ \& \_ \{ \}}) are escaped by a + \typ{\\} + \item \typ{\\} symbol is inserted using \typ{\\textbackslash} + command + \end{itemize} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Spacing} + \begin{itemize} + \item \typ{\\\\} inserts a new line in the output + \item An empty line marks the beginning of a new paragraph + \item Multiple spaces (or empty lines) are equivalent to a single + space (or empty line) + \end{itemize} +\end{frame} + +\section{Adding Structure} + +\begin{frame}[fragile] + \frametitle{\typ{documentclass}} + \begin{itemize} + \item Used to select the \emph{class} of our document + \item Some available classes - \typ{article}, \typ{proc}, + \typ{report}, \typ{book}, \typ{slides}, \typ{letter}. + \item For example: + \typ{\\documentclass\[12pt,a4paper,draft\]\{report\}}\\ + The parameters within \typ{\[ \]} are optional. + \begin{itemize} + \item \typ{12pt} -- sets the font size of main font and others are + relatively, adjusted. \typ{10pt} is the default. + \item \typ{a4paper} -- specify paper size + \item \typ{draft} -- marks hyphenation and justification problems in + typesetting with a square in the margin + \end{itemize} + + \end{itemize} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Top Matter} + Let's add the title, author's name and the date. + \begin{itemize} + \item Add title, author and date. + \item Compile. + \item Nothing changes. + \end{itemize} + {\tiny See \typ{hg} rev1 of draft.} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Top Matter \ldots} + \begin{itemize} + \item \lstinline{\maketitle} command inserts the top-matter. + \item Add the command to the document \& compile again. + \item If no date is specified, today's date is automatically + inserted. + \end{itemize} + \tiny{See \typ{hg} rev2 of draft.} +\end{frame} + + +\begin{frame}[fragile] + \frametitle{Abstract} + \begin{itemize} + \item \typ{abstract} environment inserts abstract. + \item Place it at the location where you want your abstract. + \end{itemize} + \tiny See rev3 of \typ{hg} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Sectioning} + \begin{itemize} + \item \lstinline{\section}, \lstinline{\subsection} + \lstinline{\subsubsection} + \item Auto numbered sections! + \item \typ{*} to prevent numbering of a section + \end{itemize} + \tiny See rev4 of \typ{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 \typ{hg} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Appendices} + \begin{itemize} + \item \lstinline{\appendix} command indicates the beginning of + Appendices. + \item Any content after \lstinline{\appendix}, will be added to the + appendix + \item Use sectioning commands to add sections + \end{itemize} + \tiny See rev7 of \typ{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 \typ{hg} +\end{frame} + +\begin{frame}[fragile] + \frametitle{TOC \ldots} + \begin{itemize} + \item Un-numbered sections are added to TOC using + \lstinline{\addcontentsline} + \item For instance, \lstinline+\addcontentsline{toc}{section}{Intro}+ + \end{itemize} + \tiny See rev9 of \typ{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{Quotation Marks} + \begin{itemize} + \item Use \`~ (accent) for left quote + \item Use \'~ (apostrophe) for right quote + \item For double quotes, use them twice + \end{itemize} + \tiny See rev11 of \typ{hg} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Fonts - Emphasis, Fixed width, \ldots} + \begin{itemize} + \item \lstinline{\emph} gives emphasized or italic text + \item \typ{flushleft} to have text left aligned + \item \typ{flushright}, \typ{center} + \end{itemize} + \tiny See rev12 of \typ{hg} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Fonts - Emphasis, Fixed width, \ldots} + \begin{itemize} + \item \lstinline{\texttt} gives fixed width font + \item \lstinline{\textbf} bold face font + \item \lstinline{--} en dash (--); \lstinline{---} em dash (---). + \end{itemize} + \tiny See rev13 of \typ{hg} +\end{frame} + +\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 + \end{itemize} + \tiny See rev14 of \typ{hg} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Footnotes} + \begin{itemize} + \item \typ{\\footnote} command adds a footnote + \end{itemize} + \tiny See rev15 of \typ{hg} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Labels and References} + \begin{itemize} + \item \lstinline+\label{labelname}+ is used to label an element + \item \lstinline+\ref{labelname}+ is used to refer to that element + \item Compile twice + \end{itemize} + \tiny See rev15 of \typ{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 to be used, using \typ{\\lstset} + \end{itemize} + \tiny See rev16 of \typ{hg} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Including code} + \begin{itemize} + \item Use \lstinline+\lstlisting+ for a block of code + \item \typ{\\lstinline} for inline code + \end{itemize} + \tiny See rev16 of \typ{hg} +\end{frame} + +\section{Figures, Tables \& Floats} +\begin{frame}[fragile] + \frametitle{Figures} + \begin{itemize} + \item The \typ{graphicx} package allows us to insert graphics + \item \lstinline+\usepackage{graphicx}+ + \item To add a graphic, use \lstinline{\includegraphics} command + \item Use relative path to the image + \end{itemize} + \tiny See rev17 of \typ{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 should be added after the caption command + \item Figures are auto numbered + \end{itemize} + \tiny See rev17 of \typ{hg} +\end{frame} + +\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 \typ{hg} +\end{frame} + +\begin{frame}[fragile] + \frametitle{List of Tables, Figures} + \begin{itemize} + \item \lstinline+\listoftables+ -- to add a list of tables + \item \lstinline+\listoffigures+ -- to add a list of figures + \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 or %%$ + \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 the tabular environment + \item \lstinline+&+ for demarcating columns + \item \lstinline+\\+ for demarcating rows + \item Other matrix environments + \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{itemize} + \tiny See rev19 of \typ{hg} +\end{frame} + +\begin{frame}[fragile] + \frametitle{Superscripts \& Subscripts} + \begin{itemize} + \item \lstinline+^+ for superscripts + \item \lstinline+_+ for subscripts + \item Enclose multiple characters in \lstinline+{ }+ + \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 Display equations are the other type of displaying math + \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} + \tiny See rev20 of \typ{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} + \tiny See rev21, 22 of \typ{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 width 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} + \tiny See rev23 of \typ{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 one 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} + +\begin{frame}[fragile] + \frametitle{} + \begin{center} + \Huge{Thank You!} + \end{center} +\end{frame} + + +\end{document} + diff --git a/slides/latex/workbook/bibtex.rst b/slides/latex/workbook/bibtex.rst new file mode 100644 index 0000000..dec3097 --- /dev/null +++ b/slides/latex/workbook/bibtex.rst @@ -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`` + diff --git a/slides/latex/workbook/example1.tex b/slides/latex/workbook/example1.tex new file mode 100644 index 0000000..f2d8b7b --- /dev/null +++ b/slides/latex/workbook/example1.tex @@ -0,0 +1,4 @@ +\documentclass{article} +\begin{document} +This is my first LaTeX document. +\end{document} diff --git a/slides/latex/workbook/example10.tex b/slides/latex/workbook/example10.tex new file mode 100644 index 0000000..a521468 --- /dev/null +++ b/slides/latex/workbook/example10.tex @@ -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} diff --git a/slides/latex/workbook/example2.tex b/slides/latex/workbook/example2.tex new file mode 100644 index 0000000..1f760cd --- /dev/null +++ b/slides/latex/workbook/example2.tex @@ -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} diff --git a/slides/latex/workbook/example3.tex b/slides/latex/workbook/example3.tex new file mode 100644 index 0000000..70cfdaa --- /dev/null +++ b/slides/latex/workbook/example3.tex @@ -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} diff --git a/slides/latex/workbook/example4.tex b/slides/latex/workbook/example4.tex new file mode 100644 index 0000000..317d3f5 --- /dev/null +++ b/slides/latex/workbook/example4.tex @@ -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} + + diff --git a/slides/latex/workbook/example5.tex b/slides/latex/workbook/example5.tex new file mode 100644 index 0000000..7600797 --- /dev/null +++ b/slides/latex/workbook/example5.tex @@ -0,0 +1,24 @@ +\documentclass{article} +\begin{abstract} + This content is from Wikipedia page on Python. +\end{abstract} +\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. +\end{document} diff --git a/slides/latex/workbook/example6.tex b/slides/latex/workbook/example6.tex new file mode 100644 index 0000000..828a188 --- /dev/null +++ b/slides/latex/workbook/example6.tex @@ -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} diff --git a/slides/latex/workbook/example7.tex b/slides/latex/workbook/example7.tex new file mode 100644 index 0000000..6b7d14d --- /dev/null +++ b/slides/latex/workbook/example7.tex @@ -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} diff --git a/slides/latex/workbook/example8.tex b/slides/latex/workbook/example8.tex new file mode 100644 index 0000000..87267ae --- /dev/null +++ b/slides/latex/workbook/example8.tex @@ -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} diff --git a/slides/latex/workbook/example9.tex b/slides/latex/workbook/example9.tex new file mode 100644 index 0000000..e066c1e --- /dev/null +++ b/slides/latex/workbook/example9.tex @@ -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} diff --git a/slides/latex/workbook/lion_orig.png b/slides/latex/workbook/lion_orig.png Binary files differnew file mode 100644 index 0000000..0026477 --- /dev/null +++ b/slides/latex/workbook/lion_orig.png |