# HG changeset patch # User Puneeth Chaganti # Date 1296995223 -19800 # Node ID 3174d4803cd548047a6bb8decc93eb346c702331 # Parent 8f4806a1a64dc8673a3455eb9ea41d782359408b latex: Changes to slides and handout before and after class. diff -r 8f4806a1a64d -r 3174d4803cd5 latex/handout.rst --- a/latex/handout.rst Mon Jan 31 17:59:35 2011 +0530 +++ b/latex/handout.rst Sun Feb 06 17:57:03 2011 +0530 @@ -4,109 +4,204 @@ Introduction ------------ -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 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 may also be +used for producing other kinds of documents, ranging from simple one page +articles to complete books. LaTeX is based on the TeX typesetting language. + +LaTeX is pronounced either as "Lah-tech" or "Lay-tech". + + +Why LaTeX? +~~~~~~~~~~ + +A few reasons for using LaTeX - -LaTeX is pronounced either as "Lah-tech" or "Lay-tech" + * It produces documents with excellent visual quality. + * It does the typesetting for you, leaving you - the author - to focus on + writing the content. You will appreciate this, as you learn more. + * 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 and has a large user community. -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. + +Course Outline +~~~~~~~~~~~~~~ + +In this course, we will learn enough LaTeX to be a able to produce a simple +document with text, tables, figures, math, references and bibliography. We +will also briefly see how to create presentations using LaTeX, such as the +one use for the slides of this course. + +The sample document, ``sample.pdf``, available in the course material, will +serve as a teaching/learning tool to learn LaTeX. During the course, we shall +reproduce this sample document, starting from scratch, in LaTeX A Look at the Sample Document ------------------------------ ++++++++++++++++++++++++++++++ -Let's first look at the basic structure of the sample document. +A look at the sample document gives us an idea about the various elements +present in the document, that we will be learning during this course. -Slides with screen shots of +We shall be learning how to add the following elements to our LaTeX +documents. * Title, Author, Date * Abstract - * Sections - * Subsections - * Appendix + * Sections & Subsections + * Appendices * References/Bibliography * Tables * Figures * Math -Writing the source & compiling it ---------------------------------- + +LaTeX is not a Word Processor +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +What do we mean by LaTeX not being a Word Processor? Suppose we wanted to +create a simple document as shown in the image below. If one used a normal +word processor, the author would have to worry about setting the font sizes +of the fonts, centering the title, date and author information, etc. + +.. image:: images/latex_not_wp.png + :alt: LaTeX is not a Word Processor + +To generate this document in LaTeX, we just tell it what we want as the +title, author's name, date etc. and what we want as the content. LaTeX takes +care of proper font size ratios and other presentation details. + +:: -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} + \title{My First Document} + \author{FOSSEE} + \date{January 2011} + \begin{document} + \maketitle + Hello world! + \end{document} + +LaTeX can be considered to be a document based markup language. What we mean +by a markup language is that you mark up pieces of your text to be particular +elements of your document and then a typesetter or processor typesets your +document based on a set of rules. What do we mean by being document-based? It +means, that in LaTeX, you can change the structure of the whole document +consistently, with a few changes in the preamble of the document, with-out +having to change each element separately. + +First steps -- Typesetting a minimal document +--------------------------------------------- + +Let us start with a minimal example to learn how to write a LaTeX document +and compile it to see the **typeset** output. + +To begin, type out the following code into your text editor and save it as +``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:: +To compile your document, type the following command in your terminal:: - $ pdfLaTeX draft.tex + $ 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. +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. + +What does it mean? +~~~~~~~~~~~~~~~~~~ + +As we have already seen, LaTeX is a document based markup. The first line, +``\documentclass{article}``, tells that our document is an article type +document. LaTeX then, typesets the document accordingly. The documentclass +command, defines the structure and formatting of our document. + +The ``begin`` and ``end`` document commands, mark the beginning and the end +of the content of the LaTeX document. The text in between the begin and end +commands is typeset in the output document. + +A little digression +~~~~~~~~~~~~~~~~~~~ + +Just like in ``bash`` and ``Python``, the commands in LaTeX are +case-sensitive. ``\Documentclass`` is therefore not a valid command. + +All the commands in LaTeX begin with a ``\``. An environment begins with a +``begin`` command and ends with an ``end`` command. In our minimal example, +``document`` is an environment. Only the text enclosed by the begin and end +commands is effected by the environment. + +So, as expected LaTeX ignores anything that is written after the +``\end{document}`` command. (The part of the file before the +``\begin{document}`` command is called the preamble, and is used to +*"configure"* the LaTeX typesetter and change various parameters for +typesetting. Details later.) + +Essentially, anything written after the ``\end{document}`` command turns out +to be a comment. But, how do we write comments with in the document. ``%`` is +the character to indicate comments. Anything written after a ``%`` symbol in +a line, is ignored. For example, we can add a comment to the minimal document +saying, this is our first document in LaTeX, by saying ``% My First LaTeX +document``. + +But what if we wanted to insert the ``%`` symbol in the document? We can do +so by escaping it with a ``\`` (backslash). ``%`` is one of the many special +characters in LaTeX. The others are, ``~ # $ ^ & _ { } \``. All of them, +except the ``\`` itself, can be inserted by escaping it with a ``\``. To +insert a ``\`` in our document, we use the command ``\textbackslash``. + +What would happen if we escape a ``\`` with a ``\``? Yes, you guessed it. A +double backslash is actually another command. It inserts a new line in the +typeset document. The ``\\`` command or ``\newline`` command is used to +insert a newline in the output document. Line breaks in the input document, +do not translate into line breaks in the output document. A single line break +in the input document, doesn't cause any change in the output. A single empty +line causes a change in paragraphs in the output. (Multiple empty lines are +equivalent to a single empty line.) Similarly, multiple spaces are treated as +a single space. + +Adding Structure +---------------- + +Let us now, look at giving the document some basic structure, like title, +sections, etc. ``\documentclass`` ------------------- - -The documentclass command, defines the structure and formatting of our -document. LaTeX typsets the document, based on the documentclass. - -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. +As we have already seen, the ``documentclass`` command tells LaTeX, the type +of the document that we intend to create. Some of the available LaTeX classes +are, ``article``, ``proc``, ``report``, ``book``, ``slides``, ``letter``. +Each class has a few differences in how the content of the document is +typeset. -Why should you use it? -~~~~~~~~~~~~~~~~~~~~~~ - -A few reasons for using LaTeX - +The ``documentclass`` command also accepts a few optional parameters. For +example:: - * 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 and has a large user community. + \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. - -``\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. +``a4paper`` specifies the size of the paper to be used for the document. -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 ``{ }``. - +``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. Top Matter ---------- @@ -126,20 +221,21 @@ \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. +``\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. :: +Next we shall add an abstract to our document. LaTeX provides an environment, +for adding an abstract to the document. + +:: \documentclass{article} @@ -158,15 +254,15 @@ SciPy is open-source software for mathematics, science, and engineering. \end{document} -The abstract environment is placed at the location where we wish it to -appear in the document. +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. +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`` @@ -177,32 +273,33 @@ 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. +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. -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:: +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. +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. :: +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} +What do you expect to happen if we changed the secnumdepth to 1? What if it +is 0 or -1? Appendix @@ -219,112 +316,106 @@ Table of Contents ----------------- -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! +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! -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. +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. -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 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. -Let's change our Introduction section to be an un-numbered one and try -to make it appear 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} -We shall talk about adding and managing bibliographies, later in the -course. +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. +Now, that we have the basic structure of the document, let's get into the +content and the details of it. 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'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. -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. +As already discussed, we need to an insert an empty line, to insert a new +paragraph in LaTeX. Also, notice that the new paragraph is indented. Quotation Marks --------------- -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. +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. +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. +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. + +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. -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. +Also, we notice that ``LaTeX`` starts a new paragraph at the beginning of the +table. To avoid this, we use the ``flushleft`` environment. -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. +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. -``\textbf`` is used to change text to bold face and ``\texttt`` is -used to change text to fixed width font. +``\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. +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 ----- -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. +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. +LaTeX also has a description list, which shall be an exercise, for you. + Footnotes, Labels and References -------------------------------- -Let's now add the footnote to pylab. LaTeX provides a footnote command -to add a footnote. +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 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 @@ -614,3 +705,10 @@ To achieve more with beamer, it is highly recommended that you look at the ``beameruserguide``. +.. + Local Variables: + mode: rst + indent-tabs-mode: nil + sentence-end-double-space: nil + fill-column: 77 + End: diff -r 8f4806a1a64d -r 3174d4803cd5 latex/slides.tex --- a/latex/slides.tex Mon Jan 31 17:59:35 2011 +0530 +++ b/latex/slides.tex Sun Feb 06 17:57:03 2011 +0530 @@ -1,16 +1,25 @@ -\documentclass[english]{beamer} - -% generated by Docutils -\usepackage{fixltx2e} % LaTeX patches, \textsubscript -\usepackage{cmap} % fix search and cut-and-paste in PDF -\usepackage{babel} +\documentclass{beamer} +\usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} -\usepackage[latin1]{inputenc} +\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} -\usepackage{amsmath} \lstset{ language=TeX, - basicstyle=\small\ttfamily, + basicstyle=\ttfamily\bfseries, commentstyle=\ttfamily\color{blue}, stringstyle=\ttfamily\color{orange}, showstringspaces=false, @@ -18,11 +27,7 @@ postbreak = \space\dots } -\usepackage{ifthen} -\usepackage{longtable} -\usepackage{array} -\setlength{\extrarowheight}{2pt} -\newlength{\DUtablewidth} % internal use in tables +\newcommand{\typ}[1]{\lstinline{#1}} \mode { @@ -66,20 +71,45 @@ \section{Introduction} \begin{frame} - \frametitle{\LaTeX~- Introduction} + \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 books. - \item Based on \TeX - \item Pronounced ``Lah-tech'' or ``Lay-tech'' + \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{This Course} + \frametitle{Why \LaTeX?} \begin{itemize} - \item Look at Sample document - \texttt{sample.pdf} + \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 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 @@ -87,50 +117,9 @@ \end{itemize} \end{frame} - -\begin{frame} - \frametitle{A Look at the Sample Document} +\begin{frame}[fragile]{{\LaTeX}{is awesome} \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 {\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 @@ -140,71 +129,107 @@ \end{frame} \begin{frame}[fragile] - \frametitle{Environments and Commands} - \lstinline{document} is an environment, present in every document. + \frametitle{Typesetting a minimal document} + \begin{itemize} + \item Write the sample code 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} + +\newline \\ +\newpage + + +\begin{frame}[fragile] + \frametitle{Comments \& Special Characters} \begin{itemize} - \item Environments + \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 \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 + \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} - \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. + Let's add the title, author's name and the date. \begin{itemize} - \item Add title, author and date. Compile. Nothing changes. + \item Add title, author and date. + \item Compile. + \item 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.} + {\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 Compile again. + \item Add the command to the document \& 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.} + \tiny{See \typ{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. + \item \typ{\\abstract} environment inserts abstract. + \item Place it at the location where you want your abstract. \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} + \tiny See rev3 of \typ{hg} \end{frame} \begin{frame}[fragile] @@ -213,14 +238,9 @@ \item \lstinline{\section}, \lstinline{\subsection} \lstinline{\subsubsection} \item Auto numbered sections! - \item \* to prevent numbering of a section + \item \typ{*} 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} + \tiny See rev4 of \typ{hg} \end{frame} \begin{frame}[fragile] @@ -242,21 +262,19 @@ \begin{lstlisting} \setcounter{secnumdepth}{3} \end{lstlisting} - \tiny See rev5 of \texttt{hg} + \tiny See rev5 of \typ{hg} \end{frame} \begin{frame}[fragile] \frametitle{Appendices} \begin{itemize} - \item Anything following the \lstinline{\appendix} command is added - to the Appendix. + \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} - \begin{lstlisting} - \appendix - - \section{Plotting using Pylab} - \end{lstlisting} - \tiny See rev7 of \texttt{hg} + \tiny See rev7 of \typ{hg} \end{frame} \begin{frame}[fragile] @@ -271,19 +289,17 @@ \item Re-compile. \item Any numbered section/block automatically appears \end{itemize} - \tiny See rev8 of \texttt{hg} + \tiny See rev8 of \typ{hg} \end{frame} \begin{frame}[fragile] \frametitle{TOC \ldots} \begin{itemize} - \item To add un-numbered sections, use \lstinline{\addcontentsline} + \item Un-numbered sections are added to TOC using + \lstinline{\addcontentsline} + \item For instance, \lstinline+\addcontentsline{toc}{section}{Intro}+ \end{itemize} - \begin{lstlisting} - \section*{Introduction} - \addcontentsline{toc}{section}{Intro} - \end{lstlisting} - \tiny See rev9 of \texttt{hg} + \tiny See rev9 of \typ{hg} \end{frame} \begin{frame} @@ -293,74 +309,35 @@ \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} + \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 \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 + \item \typ{flushleft} to have text left aligned + \item \typ{flushright}, \typ{center} \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} + \tiny See rev12 of \typ{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 + \item \lstinline{\texttt} gives fixed width font + \item \lstinline{\textbf} bold face font + \item \lstinline{--} en dash (--); \lstinline{---} em dash (---). \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} + \tiny See rev13 of \typ{hg} \end{frame} -\subsection{Lists} \begin{frame}[fragile] \frametitle{Lists} \begin{itemize} @@ -368,66 +345,26 @@ \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} + \tiny See rev14 of \typ{hg} \end{frame} \begin{frame}[fragile] \frametitle{Footnotes} \begin{itemize} - \item Add footnote for \lstinline{pylab} - \item It's easily done using \lstinline{\footnote} command + \item \typ{\\footnote} command adds a footnote \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} + \tiny See rev15 of \typ{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 \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} - \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} + \tiny See rev15 of \typ{hg} \end{frame} \begin{frame}[fragile] @@ -435,59 +372,32 @@ \begin{itemize} \item Instead of using \lstinline{\texttt} we could use \lstinline{\verbatim} - \item \lstinline{listings} is a powerful package + \item \lstinline+\lstinline{listings}+ is a powerful package \item \lstinline+\usepackage{listings}+ needs to be added - \item Tell \LaTeX the language, you are going to use + \item Tell {\LaTeX} the language to be used, using \typ{\\lstset} \end{itemize} - \begin{lstlisting} - \usepackage{listings} - \lstset{language=Python, - basicstyle=\ttfamily\bfseries, - showstringspaces=false} - \end{lstlisting} - \tiny See rev16 of \texttt{hg} + \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 \lstinline+\lstinline+ for inline code - \item Let's add the code to Appendix + \item Use \lstinline+\lstlisting+ for a block of code + \item \typ{\\lstinline} for inline code \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} + \tiny See rev16 of \typ{hg} \end{frame} \section{Figures, Tables \& Floats} \begin{frame}[fragile] \frametitle{Figures} \begin{itemize} - \item Let's add the figure in the Appendix + \item The \typ{graphicx} package allows us to insert graphics \item \lstinline+\usepackage{graphicx}+ \item To add a graphic, use \lstinline{\includegraphics} command - \item We give the relative path to the \lstinline+.png+ image + \item Use relative path to the 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} + \tiny See rev17 of \typ{hg} \end{frame} \begin{frame}[fragile] @@ -538,14 +448,12 @@ \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 label should be added after the caption command \item Figures are auto numbered \end{itemize} - \tiny See rev17 of \texttt{hg} + \tiny See rev17 of \typ{hg} \end{frame} -\subsection{Tables} - \begin{frame}[frame] \frametitle{Tables} \begin{itemize} @@ -583,32 +491,14 @@ \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} + \tiny See rev18 of \typ{hg} \end{frame} \begin{frame}[fragile] \frametitle{List of Tables, Figures} \begin{itemize} - \item \lstinline+listoftables+ - \item \lstinline+listoffigures+ + \item \lstinline+\listoftables+ -- to add a list of tables + \item \lstinline+\listoffigures+ -- to add a list of figures \end{itemize} \end{frame} @@ -617,8 +507,8 @@ \begin{frame}[fragile] \frametitle{Math in \LaTeX} \begin{itemize} - \item Math is enclosed in a pair of \lstinline{$} signs o - \lstinline+\( \)+ %$ + \item Math is enclosed in a pair of \lstinline{$} signs of %%$ + \lstinline+\( \)+ \item Used for typesetting inline Math. \item \lstinline+\usepackage{amsmath}+ \item Let's now move on to matrices. @@ -632,25 +522,7 @@ \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} + \item Other matrix environments \begin{table} \center \begin{tabular}{c|c} @@ -661,15 +533,16 @@ \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 To have multiple characters as sub/superscript, enclose in - \lstinline+{ }+ \item \lstinline+_+ for subscripts + \item Enclose multiple characters in \lstinline+{ }+ \end{itemize} \end{frame} @@ -687,20 +560,16 @@ \begin{frame}[fragile] \frametitle{\lstinline+displayed+ math} \begin{itemize} - \item The equation in Determinants section is different. - \item It is a displayed equation. + \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 \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} + \tiny See rev20 of \typ{hg} \end{frame} \begin{frame}[fragile] @@ -714,15 +583,7 @@ 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} + \tiny See rev21, 22 of \typ{hg} \end{frame} \begin{frame}[fragile] @@ -787,18 +648,7 @@ \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} + \tiny See rev23 of \typ{hg} \end{frame} \section{Presentations - Beamer} @@ -835,5 +685,13 @@ \end{itemize} \end{frame} +\begin{frame}[fragile] + \frametitle{} + \begin{center} + \Huge{Thank You!} + \end{center} +\end{frame} + + \end{document}