latex/handout.rst
changeset 56 eee394eb05fc
parent 36 4c4c8a9795b2
child 61 cfae54ede139
equal deleted inserted replaced
55:6aa9568b5874 56:eee394eb05fc
     1 LaTeX
     1 LaTeX
     2 =====
     2 =====
     3 
     3 
     4 Introduction
     4 Introduction
     5 ------------
     5 ------------
     6 LaTeX is a typesetting program that is excellent for producting scientific and mathematical documents of high typographical quality. It is also suitable for producing all sorts of other documents, from simple letters to complete books. LaTeX uses TeX as its formatting engine.
     6 LaTeX is a typesetting program used to produce excellently typeset documents. It is extensively used for producing high quality scientific and mathematical documents. It may also be used for producing other kinds of documents, ranging from simple one page articles or letters 
     7 
     7 
     8 
     8 
     9 TeX & LaTeX
     9 TeX & LaTeX
    10 ~~~~~~~~~~~
    10 ~~~~~~~~~~~
    11 
    11 
    12 TeX
    12 TeX
    13 +++
    13 +++
    14 
    14 
    15 TeX is a typesetting system designed and mostly written by Donald Knuth. It was designed with two goals in mind-
    15 TeX is a typesetting system designed by Donald Knuth, the renowned Computer Scientist and Emeritus professor at Stanford University. Typesetting is placing text onto a page with all the style formatting defined, so that content looks as intended. 
    16   
    16 
       
    17 It was designed with two goals in mind-
       
    18 
    17 1. To allow anybody to produce high-quality books using a reasonable amount of effort. 
    19 1. To allow anybody to produce high-quality books using a reasonable amount of effort. 
    18 2. To provide a system that would give the exact same results on all computers, now and in the future
    20 2. To provide a system that would give the exact same results on all computers, now and in the future
    19 
    21 
    20 It’s also a Turing-complete programming language, in the sense that it supports the if-else construct, it can calculate (the calculations are performed while compiling the document), etc., but you would find it very hard to make anything else but typesetting with it. The fine control TeX offers makes it very powerful, but also difficult and time-consuming to use.
    22 TeX is well known for it's stability and portability. 
    21 
    23 
    22 TeX is renowned for being extremely stable, for running on many different kinds of computers, and for being virtually bug free. 
    24 TeX is pronounced as "tech".
    23 
    25 
    24 The version number of TeX is converging to π and is now at 3.1415926.
    26 The current version of TeX is 3.1415926 and is converging to π.
    25 
       
    26 The characters T, E, X in the name come from capital Greek letters tau, epsilon, and chi, as the name of TeX derives from the Greek: τέχνη (skill, art, technique); for this reason, TeX's creator Donald Knuth promotes a /tɛx/ pronunciation
       
    27 
    27 
    28 LaTeX
    28 LaTeX
    29 +++++
    29 +++++
    30 LaTeX is a macro package based on TeX created by Leslie Lamport. It was intended to provide a high-level language that provides access to TeX. It essentially comprises a collection of TeX macros and a program to process LaTeX documents. For the end-users, it is much simpler to use than TeX. It has become the dominant method for using TeX (relatively few people write in TeX anymore).
    30 
       
    31 LaTeX was originally written by Leslie Lamport in the early 1980s. It is an extension of TeX, consisting of TeX macros and a program to parse the LaTeX files. It is easier to use than TeX itself, at the same time producing the same quality of output. 
    31 
    32 
    32 LaTeX is pronounced either as "Lah-tech" or "Lay-tech"
    33 LaTeX is pronounced either as "Lah-tech" or "Lay-tech"
    33 
    34 
    34 WYSIWG vs. WYSIWM
    35 WYSIWG vs. WYSIWM
    35 ~~~~~~~~~~~~~~~~~
    36 ~~~~~~~~~~~~~~~~~
    36 The Advantages-
    37 
    37 
    38 WYSIWG is an acronym for "What You See Is What You Get". Word processors, are typically WYSIWG tools. LaTeX, TeX or other TeX based tools are not. They are typesetting or text formatting or document description programs. They can be called WYSIWM or "What You See Is What you Mean" systems, since you give a description of how things look, and LaTeX typesets the document for you.
    38   * It is free (both as in free-beer and free-speech)
    39 
    39   * It is platform independent. 
    40 Here are a few reasons, why you should use LaTeX -
    40   * It is very stable. 
    41 
    41   * LaTeX is ASCII and any text editor of your choice can be used to view and edit the source.
    42   * LaTeX produces documents with excellent visual quality, especially mathematical and scientific documents. 
    42   * The typesetting is better, especially the maths.
    43   * It does the typesetting to you. Typically, when one works with a word-processor, the user is doing the text formatting or typesetting along with typing out the content. LaTeX allows the user to concentrate on the content leaving aside the typesetting to LaTeX. 
    43   * It encourages Authors to write well-structured texts, since specifying structure is an integral part of how LaTeX works.
    44   * It is light on your resources as compared to most of the word processors available today. 
    44   * LaTeX is extensible. If you want a new feature, you can look around for a free add-on or write one yourself. 
    45   * It is well known for it's stability and for it's virtually bug free code base. 
    45 
    46   * It encourages users to structure documents by meaning rather than appearance, thereby helping produce well structured documents. 
    46 and some Disadvantages - 
    47   * It uses plain text files as input, which have a lot of well known advantages over binary files. To state a few, they can be opened with any editor on any operating system, they are smaller in size compared to the binaries, can be version controlled and can be processed using widely used text processing utilities. 
    47 
    48   * The output can be generated in more than one formats.
    48   * Font selection is difficult 
    49   * It is free software (free as in freedom) and gratis too.
    49   * LaTeX's not good at flowing text around pictures.
    50   * It is widely used.
    50   * LaTeX encourages (almost insists on) structured writing and the separation of style from content. This is not the way that many people (especially non-programmers) are used to working.
    51 
    51   * Without a WYSIWYG front end, it's not always easy to find out how to do things.
    52 Hello World
    52 
    53 ~~~~~~~~~~~
    53 LaTeX Source
    54 
    54 ~~~~~~~~~~~~
    55 Ok, let's get started with our first LaTeX document. Open up your favorite editor and type in the following code. 
    55 
    56 
    56 ::
    57 ::
    57 
    58 
    58   %hello.tex - First LaTeX document
    59   %hello.tex - First LaTeX document
    59   \documentclass{article}
    60   \documentclass{article}
    60 
    61 
    61   \begin{document}
    62   \begin{document}
    62     Hello, World!
    63     Hello, World!
    63   \end{document}
    64   \end{document}
    64 
    65 
       
    66 Save the file as ``hello.tex`` and open up a terminal to compile your ``tex`` file to get the output in a ``pdf`` format. 
       
    67 
       
    68 Compiling & Output
       
    69 ++++++++++++++++++
       
    70 
       
    71 ::
       
    72 
       
    73   $pdflatex hello.tex
       
    74 
       
    75   Output written on hello.pdf (1 page, 5733 bytes).
       
    76   Transcript written on hello.log.
       
    77 
       
    78 Open the ``hello.pdf`` to see the output as shown. 
       
    79 
       
    80 .. image:: examples/hello.jpg
       
    81 
       
    82 Note: The command ``latex`` is often used to get the ``dvi`` output. But, throughout this course, we shall use pdflatex to compile our documents. 
       
    83 
       
    84 A peek at the source
       
    85 ++++++++++++++++++++
       
    86 
       
    87 ``%hello.tex - First LaTeX document``
       
    88 
       
    89   This line is a comment. LaTeX ignores this line and it is meant only for the human readers. LaTeX ignores anything after a ``%`` symbol to the end of the line. 
       
    90 
       
    91 ``\documentclass{article}``
       
    92 
       
    93   This line is a command and sets the ``documentclass`` of the document to ``article``. LaTeX has other classes like ``report``, ``book``, ``letter``, etc. The typesetting of the document varies depending on the ``documentclass`` of the document. 
       
    94 
       
    95 
       
    96 ``\begin{document}``
       
    97 
       
    98   This line informs LaTeX that this is the beginning of the content of the document. 
       
    99 
       
   100 ``Hello, World!``
       
   101 
       
   102   This is the actual text displayed in the document. 
       
   103 
       
   104 ``\end{document}``
       
   105 
       
   106   This line tells LaTeX that the document is complete and LaTeX will simply ignore anything written after this line.
       
   107 
       
   108 Where do we want to go
       
   109 ~~~~~~~~~~~~~~~~~~~~~~
       
   110 
       
   111 During the course of this session we will learn how to do various things in LaTeX and try to produce the sample document provided. 
       
   112 
       
   113 Some Basics
       
   114 ~~~~~~~~~~~
       
   115 Before we get started with creating the document, let's try to understand a few things that would be useful during the course of this session. 
    65 
   116 
    66 Spaces
   117 Spaces
    67 ++++++
   118 ++++++
    68 
   119 
    69 LaTeX ignores whitespaces. Multiple white spaces are treated as one space. An empty line between two lines of text is considered as a change of paragraphs. 
   120 LaTeX treats multiple empty spaces (or lines) as a single space (or line). An empty line between two lines of text is considered as a change of paragraphs. 
       
   121 
       
   122 Line & Page Breaks
       
   123 ++++++++++++++++++
       
   124 
       
   125 LaTeX usually does the job of breaking up your content into lines and pages, and does it well. But under some circumstances, you might want to instruct LaTeX to break line or start a new page at a particular point. 
       
   126 
       
   127 ``\\`` or ``\newline`` command is used to create a new line at the point where the command is issued. 
       
   128 Appending ``*`` to ``\\``,  instructs LaTeX to create a new line, without creating a new page at that point. 
       
   129 
       
   130 Paragraphs
       
   131 ++++++++++
       
   132 
       
   133 As already mentioned, LaTeX considers an empty line between two lines of text as a new paragraph. ``\par`` command may also be used to start a newline. It is equivalent to the blank line. 
       
   134 
       
   135 By default LaTeX indents new paragraphs. If you do not wish to have the paragraph indented, you can use the ``\nointend`` command at the beginning of the paragraph. 
    70 
   136 
    71 Special Characters
   137 Special Characters
    72 ++++++++++++++++++
   138 ++++++++++++++++++
    73 
   139 
    74 The characters ``~ # $ % ^ & _ { } \`` have special meanings associated with them.
   140 LaTeX associates special meaning to the  characters ``~ # $ % ^ & _ { } \``. 
    75 
   141 
    76 These characters can be used in your document by adding a prefix backslash. ``\~ \# \% \$ \^ \& \_ \{ \} \textbackslash``
   142 To have these characters in the text of your document, you need to prefix a backslash to them. ``\~ \# \% \$ \^ \& \_ \{ \} \textbackslash``
    77 
   143 
    78 Comments
   144 
       
   145 Commands
    79 ++++++++
   146 ++++++++
    80 
   147 
    81 % character is used to insert comments into a LaTeX document. All the text from the % character to the end of that line is ignored by LaTeX.
   148 * All LaTeX commands start with a backslash ``\``.
    82 
   149 * Like the commands in Linux, they are case sensitive.
    83 
   150 * They usually have a backslash followed by a consisting of letters only. Any character other than letters, like space, numbers or special characters terminate the command. 
    84 LaTeX Commands
   151 * The commands for producing special characters in the text, is an exception. They contain a backslash followed by a single special character.
    85 ++++++++++++++
   152 * Commands may have parameters, which are supplied to them by enclosing them in curly braces ``{ }``.
    86 
   153 * They may also have a few optional parameters which are added after the name in square brackets ``[ ]``.
    87 * LaTeX commands are case sensitive. 
   154 
    88 * They start with a backslash ``\``
   155 
    89 * They come in two formats
   156 Environments
    90 
   157 ++++++++++++
    91   - a backslash followed by a name consisting of letters only. These command names are terminated by any non-letter. 
   158 
    92   - a backslash followed by exactly one non-character. 
   159 Environments are very similar to the commands, except that they effect larger parts of the document. For example, we used the ``document`` environment in our first LaTeX document. 
    93 
       
    94 * Some commands need to be given a parameter, which is enclosed in curly braces ``{ }``
       
    95 * Some command support optional parameters, which are added after the name in square brackets ``[ ]``
       
    96 
       
    97 LaTeX Environments
       
    98 ++++++++++++++++++
       
    99 
       
   100 Environments are similar in their role, to commands, except that they effect a larger part of the document.
       
   101 
   160 
   102 * They begin with a ``\begin`` and end with a ``\end``
   161 * They begin with a ``\begin`` and end with a ``\end``
   103 * Nested environments are generally supported
   162 * In general environments can be nested within each other. 
   104 
   163 
   105 Anything in LaTeX can be expressed in terms of Commands and Environments.
   164 Some Structural Elements
   106 
   165 ------------------------
   107 Hello, World!
       
   108 ~~~~~~~~~~~~~
       
   109 
       
   110 ::
       
   111 
       
   112   %hello.tex - First LaTeX document
       
   113   \documentclass{article}
       
   114 
       
   115   \begin{document}
       
   116     Hello, World!
       
   117   \end{document}
       
   118 
       
   119 Now, look at what each line does. 
       
   120 
       
   121 
       
   122 ``%hello.tex - First LaTeX document``
       
   123 
       
   124   This line is a comment. Comments in LaTeX begin with a %
       
   125 
       
   126 ``\documentclass{article}``
       
   127 
       
   128   This line is a command and sets the documentclass to be used for this document to ``article``. If you want to change the appearance of the document, you simply have to change the documentclass. 
       
   129 
       
   130 
       
   131 ``\begin{document}``
       
   132 
       
   133   This line is the beginning of a LaTeX environment called ``document``. It informs LaTeX that the content of the document is beginning. Anything between the ``\documentclass`` line and this line is called the *preamble*
       
   134 
       
   135 ``Hello, World!``
       
   136 
       
   137   This is the text that is displayed in the document. 
       
   138 
       
   139 ``\end{document}``
       
   140 
       
   141   The ``document`` environment ends here. It tells LaTeX that the document is complete and anything written after this line will be ignored by LaTeX.
       
   142 
       
   143 Compiling & Output
       
   144 ~~~~~~~~~~~~~~~~~~
       
   145 ``latex`` command can be used to get ``dvi`` output. But, we shall be using ``pdflatex`` all through this document and producing ``pdf`` output.
       
   146 
       
   147 ::
       
   148 
       
   149   $pdflatex hello.tex
       
   150 
       
   151   Output written on hello.pdf (1 page, 5733 bytes).
       
   152   Transcript written on hello.log.
       
   153 
       
   154 .. .. image:: sample/hello.jpg
       
   155 
       
   156 
       
   157 
       
   158 Document Structure
       
   159 ------------------
       
   160 
       
   161 This section gives a basic idea about the general sturcture of a LaTeX document. LaTeX is different from other typesetting software in that, it requires the user to specify the logical and semantic structure of the text. Therefore, it helps (almost forces) the author to organize his text better and hence improving the structure and clarity of the document. 
       
   162 
   166 
   163 ``\documentclass``
   167 ``\documentclass``
   164 ~~~~~~~~~~~~~~~~~~
   168 ~~~~~~~~~~~~~~~~~~
   165 
   169 As already stated, the ``documentclass`` command tells LaTeX, the type of the document that you intend to create. Each class has a few differences in how the content of the document is typeset. We presently have it set to the article class. Let us try changing it to the report class. 
   166 The type of the document to be created is specified using the ``\documentclass`` command. 
   170 
   167 ::
   171 Note that the top matter of the document appears in a different page for the report class. 
   168 
   172 
   169   \documentclass[options]{class}
   173 Some of the LaTeX classes that you may want to use are, article, proc, report, book, slides, letter. 
   170 
   174 
   171 Here, ``class`` defines the type of document that is to be created. The LaTeX distribution provides a variety of document class, that can be used for a variety of purposes. The ``options`` parameter customizes various properties of the document. The options have to be separated by commas. 
   175 The ``documentclass`` command also accepts a few optional parameters. For example::
   172 
   176   \documentclass[12pt,a4paper,oneside,draft]{report}
   173 For example ``\documentclass[11pt, twoside, a4paper]{article}`` produces a document of the article class with the base font size as eleven points, and to produce a layout suitable for double sided printing on A4 paper. 
   177 
   174 
   178 ``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. 
   175 Some of the document classes that are available in LaTeX are ``article, report, book, slides, letter``
   179 
   176 
   180 ``a4paper`` specifies the size of the paper to be used for the document. 
   177 
   181 
   178 The document environment
   182 ``oneside`` specifies that the document will be printed only on one side of the paper. The ``article`` and ``report`` classes are ``oneside`` by default and the ``book`` class is ``twoside``.
   179 ~~~~~~~~~~~~~~~~~~~~~~~~
   183 
   180 The text of the document is enclosed in between the commands ``\begin{document}`` and ``\end{document}`` which identify the beginning and the end of the document respectively. 
   184 ``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. 
   181 
   185 
   182 The reason for marking off the beginning of your text is that LaTeX allows you to insert extra setup specifications before it. The reason for marking off the end of your text is to provide a place for LaTeX to be programmed to do extra stuff automatically at the end of the document, like making an index.
   186 Note: Everything written in between the ``\documentclass`` command and the ``\begin{document}`` command is called the Preamble. 
   183 
   187 
   184 A useful side-effect of marking the end of the document text is that you can store comments or temporary text underneath the \end{document} in the knowledge that LaTeX will never try to typeset them
   188 
   185 
   189 Parts, Chapters and Sections
   186 Preamble
   190 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   187 ~~~~~~~~
   191 
   188 Everything written in between the ``\documentclass`` command and the ``\begin{document}`` command is called the Preamble. It normally contains commands that effect the whole document. 
   192 Often documents are divided into various parts, chapters, sections and subsections. LaTeX provides an intuitive mechanism to include this in your documents. It has various commands like ``part``, ``chapter``, ``section``, ``subsection``, ``subsubsection``, ``paragraph`` and ``subparagraph``. Note that all these commands are not available in all the document classes. The ``chapter`` command is available only in books and reports. Also, the ``letter`` document class does not have any of these commands. 
   189 
   193 
   190 Packages
   194 Let us now give our document some structure, using these commands. 
   191 ~~~~~~~~
   195 
   192 
   196 Note that you do not need to provide any numbers to the commands. LaTeX automatically takes care of the numbering. 
   193 While writing your document, you will probably find that there are some areas where basic LaTeX cannot solve your problem. If you want to include graphics, coloured text or source code from a file into your document, you need to enhance the capabilities of LaTeX. Such enhancements are called packages. Packages are activated with the  
   197 Also, you do not need to enclose the text of a block within ``\begin`` and ``\end`` commands. LaTeX starts a new block each time it finds a sectioning command. 
   194 ::
   198 ::
   195 
   199 
   196   \usepackage[options]{package}
   200   \section[Short Title]{This is a very long title and the Short Title will appear in the Table of Contents.}
   197 
   201 
   198 command, where package is the name of the package and options is a list of keywords that trigger special features in the package. Some packages come with the LaTeX2e distribution and others are provided separately. You can even write your own packages, if and when required. 
   202 
       
   203 Section Numbering
       
   204 +++++++++++++++++
       
   205 
       
   206 As already, you don't need to explicitly do any numbering in LaTeX. Parts are numbered using roman numerals; Chapters and sections are numbered using decimal numbers. When the table of contents is inserted into a document, all the numbered headings automatically appear in it.
       
   207 
       
   208 By default LaTeX has numbering up 2 levels, i.e, the parts, chapters, sections and subsections are numbered. You can change this by setting the ``secnumdepth`` counter using the ``\setcounter`` command. The following command removes numbering of the subsections. Only parts, chapters and sections are numbered. 
       
   209 ::
       
   210 
       
   211   \setcounter{secnumdepth}{1}
       
   212 
       
   213 A sectioning command appended with an asterisk gives an unnumbered heading that is not included in the table of contents.
       
   214 ::
       
   215 
       
   216   \section*{Introduction}
   199 
   217 
   200 Top Matter
   218 Top Matter
   201 ~~~~~~~~~~
   219 ~~~~~~~~~~
   202 
   220 
   203 At the beginning of most documents there will be information about the document itself, such as the title and date, and also information about the authors, such as name, address, email etc. All of this type of information within Latex is collectively referred to as top matter. Although never explicitly specified (there is no \topmatter command) you are likely to encounter the term within Latex documentation.
   221 The information about the document such as it's title, the date, the author(s) information etc, is collectively known as the topmatter. Though there is no command called ``topmatter``, the term topmatter is frequently used in LaTeX documentation. 
   204 
   222 
   205 An example::
   223 Let us input the top matter for our document now. 
   206 
   224 ::
   207   \documentclass[11pt,a4paper,oneside]{report}
   225 
   208   \title{LaTeX - A Howto}
   226   \title{LaTeX - A How-to}
   209   \author{The FOSSEE Team}
   227   \author{The FOSSEE Team}
   210   \date{August 2009}
   228   \date
   211   \maketitle
   229 
   212 
   230 The  commands ``\title`` and  ``\author`` are self explanatory. 
   213 The ``\title``, ``\author`` and ``\date`` commands are self-explanaotry. You put the title, author name, and date in curly braces after the relevant command. If no date command is used, today's date is insert by default. 
   231 The ``\date`` command automatically puts in today's date into the document. Now let us compile and look at the result. 
   214 
   232 
   215 Topmatter is always finished by the ``\maketitle`` command
   233 You would observe that the details do not appear in the document after recompilation. This is because, LaTeX has not been instructed what to do with the top matter information that you have given it. Use the ``\maketitle`` command within the document environment to instruct LaTeX to place the top matter information into the document. 
   216 
   234 
   217 Abstract
   235 Abstract
   218 ~~~~~~~~
   236 ~~~~~~~~
   219 
   237 Lets now place and abstract in the document using the ``abstract`` environment of LaTeX. The abstract appears in the document after the topmatter but before the main body of the document. 
   220 As most research papers have an abstract, there are predefined commands for telling LaTeX which part of the content makes up the abstract. This should appear in its logical order, therefore, after the top matter, but before the main sections of the body. This command is available for the document class article and report, but not book. 
       
   221 ::
       
   222 
       
   223   \documentclass{article}
       
   224   \begin{abstract}
       
   225   Your abstract goes here...
       
   226   \end{abstract}
       
   227   \begin{document}
       
   228   ...
       
   229   \end{document}
       
   230 
       
   231 By default, LaTeX will use the word “Abstract” as a title for your abstract, if you want to change it into anything else, e.g. “Executive Summary”, add the following line in the preamble::
       
   232 
       
   233     \renewcommand{\abstractname}{Executive Summary}
       
   234 
       
   235 Sectioning Commands
       
   236 ~~~~~~~~~~~~~~~~~~~
       
   237 
       
   238 The commands for inserting sections are fairly intuitive. Of course, certain commands are appropriate to different document classes. For example, a book has chapters but an article doesn’t.
       
   239 
       
   240 Examples::
       
   241   
       
   242   \Chapter{LaTeX}
       
   243 
       
   244   \section{Introduction}
       
   245 
       
   246   \subsection{TeX & LaTeX}
       
   247   
       
   248   \subsubsection{TeX}
       
   249 
       
   250 Notice that you do not need to specify section numbers. LaTeX will sort that out for you! Also, for sections, you do not need to markup which content belongs to a given block, using \begin and \end commands, for example. 
       
   251 
       
   252 All the titles of the sections are added automatically to the table of contents (if you decide to insert one). But if you make manual styling changes to your heading, for example a very long title, or some special line-breaks or unusual font-play, this would appear in the Table of Contents as well, which you almost certainly don’t want. LaTeX allows you to give an optional extra version of the heading text which only gets used in the Table of Contents and any running heads, if they are in effect. This optional alternative heading goes in [square brackets] before the curly braces. 
       
   253 ::
       
   254 
       
   255   \section[Short Title]{This is a very long title and the Short Title will appear in the Table of Contents.}
       
   256 
       
   257 Section Numbering
       
   258 +++++++++++++++++
       
   259 
       
   260 You don't need to explicitly do any section numbering as LaTeX does it automatically. Parts get roman numerals, Chapters and Sections get decimal numbering and Appendices are lettered. You can change the depth to which section numbering occurs, which is set to 2 by default. 
       
   261 
       
   262 For example, if you want only the Parts, Chapters and Sections to be numbered and not the subsections, subsubsections etc., you can set the ``secnumdepth`` to 1 using the ``\setcounter`` command. 
       
   263 ::
       
   264 
       
   265   \setcounter{secnumdepth}{1}
       
   266 
       
   267 To get an unnumbered section heading which does not go into the Table of Contents, follow the command name with an asterisk before the opening curly brace.
       
   268 ::
       
   269 
       
   270   \subsection*{Introduction}
       
   271 
       
   272 All the divisional commands from ``\part*`` to ``\subparagraph*`` have this “starred” version which can be used on special occasions for an unnumbered heading when the setting of ``secnumdepth`` would normally mean it would be numbered.
       
   273 
       
   274 Appendices
       
   275 ~~~~~~~~~~
       
   276 
       
   277 The separate numbering of appendices is also supported by LaTeX. The \appendix macro can be used to indicate that following sections or chapters are to be numbered as appendices.
       
   278 ::
       
   279 
       
   280   \appendix
       
   281   \chapter{First Appendix}
       
   282 
       
   283   \appendix
       
   284   \section{First Appendix}
       
   285 
       
   286 Table of Contents
       
   287 ~~~~~~~~~~~~~~~~~
       
   288 
       
   289 All auto-numbered headings get entered in the Table of Contents (ToC) automatically. Just add the command ``\tableofcontents`` at the point where you want it placed. 
       
   290 
       
   291 The counter ``tocdepth`` specifies what depth to take the ToC to. It can be set using the ``\setcounter`` command as shown below. 
       
   292 ::
       
   293 
       
   294   \setcounter{tocdepth}{3}
       
   295 
       
   296 If you want the unnumbered section to be in the table of contents anyway, use the ``\addcontentsline`` command like this.
       
   297 ::
       
   298 
       
   299   \section*{Introduction}
       
   300   \addcontentsline{toc}{section}{Introduction}
       
   301 
       
   302 Entries for the ToC are recorded each time you process your document, and re- produced the next time you process it, so you need to re-run LaTeX one extra time to ensure that all ToC pagenumber references are correctly calculated. We’ve already seen how to use the optional argument to the sectioning commands to add text to the ToC which is slightly different from the one printed in the body of the document. It is also possible to add extra lines to the ToC, to force extra or unnumbered section headings to be included.
       
   303 
       
   304 
       
   305 Bibliography
       
   306 ~~~~~~~~~~~~
       
   307 Any good research paper will have a whole list of references. LaTeX, therefore, has a sane way to manage your references. There are two ways to insert references into your LaTeX document:
       
   308 
       
   309 1. You can embed them within the doucment itself. It's simpler, but it can be time consuming if you are writing several papers about similar subjects so that you often have to cite the same references
       
   310 2. You can store them in an external BibTeX file and then link them to your current document. You can also use a BibTeX style to define how they should appear. This way you create a small databases of the references you might need, and use them as and when you need to cite them. 
       
   311 
       
   312 We shall discuss this in more detail in the Bibliography section. 
       
   313 
       
   314 Including files
       
   315 ~~~~~~~~~~~~~~~
       
   316 When you are working on a large document, you might want to split the input files into multiple files. LaTeX has three methods for inserting one file into another when compiling. 
       
   317 
       
   318 1. ``\input``
       
   319 
       
   320   It is equivalent to an automatic cut-paste just before compiling. To include ``file1.tex`` in our document, we just say
       
   321   ::
       
   322   
       
   323     \input{file1}
       
   324 
       
   325 
       
   326 2. ``\include``
       
   327 
       
   328   It is similar to the ``\input`` command, except that it inserts a new page, each time it is executed. So, it is useful for inserting large blocks like new chapters. To inlcude chapter1.tex in our document, we say
       
   329   ::
       
   330     
       
   331     \include{chapter1}
       
   332 
       
   333 3. ``\includeonly``
       
   334 
       
   335   This command is useful in restricting the ``\include`` commands that we wish to be executed. For example, if we have ``\include{chapter1}``, ``\include{chapter2}`` and ``\include{chapter3}`` in the document, but we wish to just verify the changes made to ``chapter1.tex`` and ignore the other chapters for a while, we could add the following command to the preamble.
       
   336   ::
       
   337 
       
   338     \includeonly{chapter1}
       
   339 
       
   340 A note on filenames
       
   341 +++++++++++++++++++
       
   342 
       
   343 Never use filenames or directories that contain spaces. Make filenames as long or short as you would like, but strictly avoid spaces. Stick to upper or lower case letters (without accents), the digits, the hyphen and the full stop or period.
       
   344 
       
   345 Typesetting Text
       
   346 ----------------
       
   347 
       
   348 Line and Page Breaks
       
   349 ~~~~~~~~~~~~~~~~~~~~
       
   350 
       
   351 Books are often typeset with each line having the same length. LaTeX inserts the necessary line breaks and spaces between words by optimizing the con- tents of a whole paragraph. If necessary, it also hyphenates words that would not fit comfortably on a line. How the paragraphs are typeset depends on the document class.
       
   352 
       
   353 In special cases it might be necessary to order LaTeX to start a newline. 
       
   354 
       
   355 ``\\`` or ``\newline`` starts a newline without starting a new paragraph. 
       
   356 
       
   357 ``\\*`` additionally prohibits a page break after the line break. 
       
   358 
       
   359 [Optional material::
       
   360 
       
   361   \linebreak[n], \nolinebreak[n], \pagebreak[n], \nopagebreak[n]
       
   362 
       
   363   \hyphenation
       
   364 
       
   365   \mbox
       
   366 
       
   367 ]
       
   368 
       
   369 Symbols & More Special Characters
       
   370 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   371 
       
   372 Quotation Marks
       
   373 +++++++++++++++
       
   374 
       
   375 You should not use the " for quotation marks as you would on a typewriter. In publishing there are special opening and closing quotation marks. In  A LaTeX, use two ` (grave accent) for opening quotation marks and two ' (vertical quote) for closing quotation marks. For single quotes you use just one of each.
       
   376 ::
       
   377 
       
   378   `` Here is an example of putting `text' in quotes ''
       
   379 
       
   380 “ Here is an example of putting ‘text’ in quotes ”
       
   381 Need to include an image as example. ?
       
   382 
       
   383 Dashes and Hyphens
       
   384 ++++++++++++++++++
       
   385 
       
   386 LaTeX has four kinds of dashes. Three of them can be accessed with different number of consecutive dashes. The fourth one is a mathematical symbol, the minus sign. 
       
   387 ::
       
   388 
       
   389   The names of these dashes are: `-' hyphen, `--' en-dash, `---' em-dash and `$-$' minus sign.
       
   390 
       
   391 The names for these dashes are: ‘‐’ hyphen, ‘–’ en-dash, ‘—’ em-dash and ‘−’ minus sign.
       
   392 
       
   393 Tilde(~)
       
   394 ++++++++
       
   395 
       
   396 A character often seen in web addresses is the tilde. To generate this in LaTeX you can use ``\~`` but the result ˜ is not really what you want. Try ``$\sim$`` instead.
       
   397 ::
       
   398 
       
   399   http://www.rich.edu/\~{}bush\\
       
   400   http://www.clever.edu/$\sim$demo
       
   401 
       
   402 
       
   403 http://www.rich.edu/˜bush
       
   404 
       
   405 http://www.clever.edu/~demo
       
   406 
       
   407 Ellipsis
       
   408 ++++++++
       
   409 
       
   410 On a typewriter, a comma or a period takes the same amount of space as any other letter. In book printing, these characters occupy only a little space and are set very close to the preceding letter. Therefore, you cannot enter ‘ellipsis’ by just typing three dots, as the spacing would be wrong. Instead, there is a special command for these dots. It is called ``\ldots``
       
   411 
       
   412 Emphasized Words
       
   413 ~~~~~~~~~~~~~~~~
       
   414 
       
   415 If a text is typed using a typewriter, important words are emphasized by underlining them.
       
   416 ::
       
   417 
       
   418   \underline{text}
       
   419 
       
   420 In printed books, however, words are emphasized by typesetting them in an *italic* font. LaTeX provides the command
       
   421 ::
       
   422 
       
   423  \emph{text}
       
   424 
       
   425 to emphasize text. If you use emphasizing inside emphasized text, LaTeX uses normal font for emphasizing. 
       
   426 ::
       
   427 
       
   428   \emph{This is emphasized text, and \emph{this is emphasized text with normal font}, within emphasized text.}
       
   429 
       
   430 *This is emphasized text, and* this is emphasized text with normal font, *within emphasized text.*
       
   431 
       
   432 
       
   433 Cross References
       
   434 ~~~~~~~~~~~~~~~~
       
   435 
       
   436 In books, reports and articles, there are often cross-references to figures, tables and special segments of text. LaTeX provides the following commands for cross referencing::
       
   437 
       
   438   \label{marker}, \ref{marker} and \pageref{marker} 
       
   439 
       
   440 where ``marker`` is an identifier chosen by the user. LaTeX replaces ``\ref`` by the number of the section, subsection, figure, table, or theorem after which the corresponding ``\label`` command was issued. ``\pageref`` prints the page number of the page where the ``\label`` command occurred. 
       
   441 
       
   442 As with the section titles, the numbers from the previous run are used. Therefore, to get the correct numbering, you will need to compile twice. 
       
   443 
       
   444 
       
   445 Footnotes
       
   446 ~~~~~~~~~
       
   447 
       
   448 With the command::
       
   449 
       
   450   \footnote{footnote text}
       
   451 
       
   452 a footnote is printed at the foot of the current page. Footnotes should always be put after the word or sentence they refer to. Footnotes referring to a sentence or part of it should therefore be put after the comma or period.
       
   453 
       
   454 [optional::
       
   455 
       
   456   \marginpar - Margin notes. 
       
   457 
       
   458 ]
       
   459 
       
   460 
       
   461 Itemize, Enumerate, and Description
       
   462 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   463 ::
       
   464 
       
   465   \begin{enumerate}
       
   466     \item You can mix the list   environments to your taste:
       
   467 
       
   468     \begin{itemize}
       
   469       \item But it might start to look silly.
       
   470       \item[-] With a dash.
       
   471     \end{itemize}
       
   472 
       
   473   \item Therefore remember:
       
   474 
       
   475     \begin{description}
       
   476       \item[Stupid] things will not become smart 
       
   477        because they are in a list.
       
   478       \item[Smart] things, though, can be
       
   479        presented beautifully in a list
       
   480     \end{description}
       
   481 
       
   482   \end{enumerate}
       
   483 
       
   484 1. You can mix the list environments to your taste:
       
   485 
       
   486    * But it might start to look silly
       
   487 
       
   488    - With a dash. 
       
   489 
       
   490 2. Therefore remember:
       
   491 
       
   492   **Stupid** things will not become smart because they are in a list
       
   493 
       
   494   **Smart** things, though, can be presented beautifully in a list. 
       
   495 
       
   496 
       
   497 
       
   498 Flushleft, Flushright, and Center
       
   499 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   500 
       
   501 The environments ``flushleft`` and ``flushright`` generate paragraphs that are either left- or right-aligned. The ``center`` environment generates centered text.
       
   502 
       
   503 
       
   504 Quote, Quotation, and Verse
       
   505 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   506 
       
   507 The ``quote`` environment is useful for quotes, important phrases and examples.
       
   508 ::
       
   509 
       
   510   A typographical rule of thumb for the line length is:
       
   511   \begin{quote}
       
   512   On average, no line should
       
   513   be longer than 66 characters.
       
   514   \end{quote}
       
   515   This is why LaTeX pages have
       
   516   such large borders by default
       
   517   and also why multicolumn print
       
   518   is used in newspapers.
       
   519 
       
   520 A typographical rule of thumb for the line length is:
       
   521 
       
   522   On average, no line should be longer than 66 characters.
       
   523 
       
   524 This is why LaTeX pages have such large borders by default and also why multicolumn print is used in newspapers.
       
   525   
       
   526 
       
   527 There are two similar environments: the quotation and the verse environments. The quotation environment is useful for longer quotes going over several paragraphs, because it indents the first line of each paragraph.
       
   528 
       
   529 The verse environment is useful for poems where the line breaks are important. The lines are separated by issuing a \\\\ at the end of a line and an empty line after each verse.
       
   530 
       
   531 
       
   532 
       
   533 Abstract
       
   534 ~~~~~~~~
       
   535 In scientific publications it is customary to start with an abstract which gives the reader a quick overview of what to expect. LaTeX provides the abstract environment for this purpose. Normally abstract is used in documents typeset with the article document class. 
       
   536 ::
   238 ::
   537 
   239 
   538   \begin{abstract}
   240   \begin{abstract}
   539   The abstract abstract.
   241   The abstract abstract.
   540   \end{abstract}
   242   \end{abstract}
   541 
   243 
       
   244 
       
   245 Appendices
       
   246 ~~~~~~~~~~
       
   247 
       
   248 LaTeX allows for separate numbering for appendices. ``\appendix`` command indicates that the sections following are to be included in the appendix. 
       
   249 ::
       
   250 
       
   251   \appendix
       
   252   \chapter{First Appendix}
       
   253 
       
   254 Table of Contents
       
   255 ~~~~~~~~~~~~~~~~~
       
   256 
       
   257 Parts, chapters or sections that have been auto numbered by LaTeX automatically appear in the Table of Contents (ToC). ``\tableofcontents`` command places a the ToC, where the command has been issued. 
       
   258 
       
   259 The counter ``tocdepth`` specifies the depth up to which headings appear in the ToC. It can be set using the ``\setcounter`` command as shown below. 
       
   260 ::
       
   261 
       
   262   \setcounter{tocdepth}{3}
       
   263 
       
   264 Unnumbered sections can be placed in the table of contents using the ``\addcontentsline`` command as shown below.
       
   265 ::
       
   266 
       
   267   \section*{Introduction}
       
   268   \addcontentsline{toc}{section}{Introduction}
       
   269 
       
   270 Note: To get the correct entries in your table of contents, you will need to run one extra compilation, each time. This is because, the entries of the table of contents are collected during each compilation of the document and utilized during the next compilation. 
       
   271 
       
   272 Elementary Text Typesetting
       
   273 ---------------------------
       
   274 
       
   275 Emphasizing
       
   276 ~~~~~~~~~~~
       
   277 
       
   278 *Italic* font is generally used to emphasize text. The ``\emph`` command may be used to achive this effect in LaTeX.
       
   279 ::
       
   280 
       
   281   This is the \emph{emphasized text}.
       
   282 
       
   283 If the ``\emph`` command is nested within another emphasize command, LaTeX emphasized that text using normal fonts. 
       
   284 ::
       
   285 
       
   286   \emph{Did you wonder what happens when we try \emph{emphasizing text} within \emph{emphasized text}}?
       
   287 
       
   288 *This is emphasized text, and* this is emphasized text with normal font *, within* emphasized text.
       
   289 
       
   290 Quotation Marks
       
   291 ~~~~~~~~~~~~~~~
       
   292 
       
   293 When typing in LaTeX, the double quotation mark ``"`` character shouldn't be used. The grave accent ````` character produces the left quote and the apostrophe ``'`` character produces the right quote. To obtain double quotes they are, each, used twice. 
       
   294 ::
       
   295 
       
   296   `` Here is an example of putting `text' in quotes ''
       
   297 
       
   298 Dashes and Hyphens
       
   299 ~~~~~~~~~~~~~~~~~~
       
   300 
       
   301 LaTeX has four dashes of different lengths. Three of them can be produces with different number of consecutive dashes. The short dashes are used for hyphens, slightly longer ones for number ranges and the longest ones for comments. The fourth one is a mathematical symbol, the minus sign. 
       
   302 ::
       
   303 
       
   304   The names of these dashes are: `-' hyphen, `--' en-dash, `---' em-dash and `$-$' minus sign.
       
   305 
       
   306 The names for these dashes are: ‘‐’ hyphen, ‘–’ en-dash, ‘—’ em-dash and ‘−’ minus sign.
       
   307 
       
   308 Footnotes
       
   309 ~~~~~~~~~
       
   310 
       
   311 With the command::
       
   312 
       
   313   \footnote{footnote text}
       
   314 
       
   315 a footnote is printed at the foot of the current page. Footnotes should always be put after the word or sentence they refer to. Footnotes referring to a sentence or part of it should therefore be put after the comma or period.
       
   316 
       
   317 Note: Look at the ``\marginpar`` command to insert margin notes
       
   318 
       
   319 Flushleft, Flushright, and Center
       
   320 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   321 
       
   322 The environments ``flushleft`` and ``flushright`` generate paragraphs that are either left- or right-aligned. 
       
   323 
       
   324 The ``center`` environment generates centered text.
       
   325 
       
   326 Itemize, Enumerate, and Description
       
   327 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   328 LaTeX has three different enivronments for producing lists. Itemize, Enumerate and Description allow you to produce lists of various types in LaTeX. 
       
   329 
       
   330 Itemize is used to produce unnumbered lists. The bullets of the list can be easily changed to use any character. Enumerate environment allows you to produce auto-numbered lists. The description environment, allows you to produce a list of definitons. These environments can be nested within each other, easily. 
       
   331 
       
   332 ::
       
   333 
       
   334   \begin{itemize}
       
   335     \item Now we move onto some elementary \emph{Text Typesetting}.
       
   336     \item How do we get \emph{emphasized or italic text}?
       
   337     \item \emph{Did you wonder what happens when we try \emph{emphasizing text} within \emph{emphasized text}}?
       
   338     \item ``Beautiful is better than ugly.''
       
   339   \end{itemize}
       
   340   
       
   341   \begin{description}
       
   342     \item[Description] This list is a description list. 
       
   343     \item[Enumerate] Numbered lists are often useful.
       
   344       \begin{enumerate}
       
   345       \item First
       
   346       \item Second
       
   347       \item Third
       
   348       \item \ldots
       
   349       \end{enumerate}
       
   350     \item[Itemize] The list above this description list is an itemize list.
       
   351   \end{description}
       
   352   
       
   353 Quote, Quotation, and Verse
       
   354 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   355 
       
   356 LaTeX provides a ``quote`` environment that can be used for quoting, highlighting important material, etc. 
       
   357 ::
       
   358 
       
   359   The Zen of Python
       
   360   \begin{quote}
       
   361     The Zen of Python, by Tim Peters
       
   362     
       
   363     Beautiful is better than ugly.
       
   364     Explicit is better than implicit.
       
   365     Simple is better than complex.
       
   366     Complex is better than complicated.
       
   367     Flat is better than nested.
       
   368     Sparse is better than dense.
       
   369     Readability counts.
       
   370     Special cases aren't special enough to break the rules.
       
   371     Although practicality beats purity.
       
   372     Errors should never pass silently.
       
   373     Unless explicitly silenced.
       
   374     In the face of ambiguity, refuse the temptation to guess.
       
   375     There should be one-- and preferably only one --obvious way to do it.
       
   376     Although that way may not be obvious at first unless you're Dutch.
       
   377     Now is better than never.
       
   378     Although never is often better than *right* now.
       
   379     If the implementation is hard to explain, it's a bad idea.
       
   380     If the implementation is easy to explain, it may be a good idea.
       
   381     Namespaces are one honking great idea -- let's do more of those!
       
   382   \end{quote}
       
   383 
       
   384 LaTeX provides two other similar environments, the quotation and the verse environments. 
       
   385 
       
   386 The quotation environment can be used for longer quotes which have several paragraphs, since it indents the first line of each paragraph. 
       
   387 
       
   388 The verse environment may be used to quote verses or poems, since the line breaks are important in quoting them. The lines are separated using ``\\\\`` at the end of a line and an empty line after each verse. 
       
   389 
   542 Verbatim
   390 Verbatim
   543 ~~~~~~~~
   391 ~~~~~~~~
   544 Text that is enclosed between ``\begin{verbatim}`` and ``\end{verbatim}`` will be directly printed, as if typed on a typewriter, with all line breaks and spaces, without any LaTeX command being executed.     
   392 The verbatim environment allows us to insert pre-formatted text in a LaTeX document. It is useful for inserting code samples within the document. The verbatim text needs to be enclosed between ``\begin{verbatim}`` and ``\end{verbatim}``. 
   545 ::
   393 ::
   546 
   394 
   547   \begin{verbatim}
   395   \begin{verbatim}
   548   from numpy import *
   396   from numpy import *
   549   a = linspace(0, 5, 50, endpoint = False)
   397   a = linspace(0, 5, 50, endpoint = False)
   550   \end{verbatim}
   398   \end{verbatim}
   551 
   399 
   552   from numpy import *
   400   from numpy import *
   553   a = linspace(0, 5, 50, endpoint = False)
   401   a = linspace(0, 5, 50, endpoint = False)
   554 
   402 
   555 Within a paragraph, similar behavior can be accessed with
   403 To insert verbatim text inline, the ``\verb`` command can be used. 
   556 ::
   404 ::
   557   
   405   
   558   \verb+text+ 
   406  The verb command allows placing \verb|verbatim text| inline. 
   559 
   407 
   560 The + is just an example of a delimiter character. You can use any character except letters, * or space.
   408 The | is just an example of a delimiter character. You can use any character except letters, * or space.
   561 
       
   562 The starred verstion of the verbatim environment emphasizes the spaces in the text. 
       
   563 ::
       
   564 
       
   565   \begin{verbatim}
       
   566   from numpy import *
       
   567   a = linspace(0, 5, 50, endpoint = False)
       
   568   \end{verbatim}
       
   569 
       
   570   from␣numpy␣import␣*
       
   571   a␣=␣linspace(0,␣5,␣50,␣endpoint␣=␣False)
       
   572 
       
   573 
   409 
   574 Tables, Figures and Captions
   410 Tables, Figures and Captions
   575 ----------------------------
   411 ----------------------------
   576 
   412 
   577 The ``\tabular`` environment
   413 The ``\tabular`` environment
   578 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   414 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   579 
   415 
   580 The tabular environment can be used to typeset beautiful tables with optional horizontal and vertical lines. LaTeX determines the width of the columns automatically.
   416 The ``tabular`` environment allows you to typeset tables in LaTeX. ``\begin{tabular}[pos]{col fmt}`` command can be used to specify the parameters of the table and start creating the table. 
   581 ::
   417 
   582 
   418 The ``pos`` argument specifies the vertical position of the table relative to the baseline of the surrounding text. It can take on the values ``t`` for top, ``b`` for bottom, or ``c`` for center. 
   583   \begin{tabular}[pos]{table spec}
   419 
   584 
   420 
   585 The table spec argument defines the format of the table. Use an ``l`` for a column of left-aligned text, ``r`` for right-aligned text, and ``c`` for centred text; ``p{width}`` for a column containing justified text with line breaks, and ``|`` for a vertical line.
   421 The ``col fmt`` argument specifies the formatting of the columns of the table. You need to explicitly specify the formatting for each of the columns in the table. The ``col fmt`` argument can take on the following values. 
   586 
   422 
   587 If the text in a column is too wide for the page, LaTeX won’t automatically wrap it. Using ``p{width}`` you can define a special type of column which will wrap-around the text as in a normal paragraph.
   423 +---------------+------------------------------------+
   588 
   424 | ``l``         | left justified column content      |
   589 The pos argument specifies the vertical position of the table relative to the baseline of the surrounding text. Use either of the letters ``t`` , ``b`` and ``c`` to specify table alignment at the top, bottom or center.
   425 +---------------+------------------------------------+
   590 
   426 | ``r``         | right justified column content     |
   591 Within a tabular environment, ``&`` jumps to the next column, ``\\`` starts a new line and ``\hline`` inserts a horizontal line. You can add partial lines by using the ``\cline{i-j}``, where ``i`` and ``j`` are the column numbers the line should extend over.
   427 +---------------+------------------------------------+
   592 
   428 | ``c``         | centered column content            |
   593 ::
   429 +---------------+------------------------------------+
   594 
   430 | ``*{n}{col}`` | produces ``n`` columns with the    |
   595   \begin{tabular}{|r|l|}
   431 |               | ``col`` type of formatting         |
   596   \hline
   432 |               | ``*{3}{c}`` is the same as {c c c} |
   597   7C0 & hexadecimal \\
   433 +---------------+------------------------------------+
   598   3700 & octal \\ \cline{2-2}
   434 | ``|``         | produces a vertical line.          |
   599   11111000000 & binary \\
   435 +---------------+------------------------------------+
   600   \hline \hline
   436 
   601   1984 & decimal \\
   437 Now we look at how to input the actual entries of the tables. Each horizontal row in a table is separated by ``\\``. Each column entry of a row is separated by ``&``. 
   602   \hline
   438 
       
   439 The ``\hline`` command allows you to draw horizontal lines between two rows of the table. But it does not allow you do draw partial lines. ``\cline{a-b}`` draws a horizontal line from column ``a`` to column ``b``.
       
   440 ::
       
   441 
       
   442   \begin{tabular}{|c|c|}
       
   443     \hline
       
   444     \verb+l+ & left justified column content\\ 
       
   445     \hline
       
   446     \verb+r+ & right justified column content\\ 
       
   447     \hline
       
   448     \verb+c+ & centered column content\\ 
       
   449     \hline
       
   450     \verb+*{n}{col}+ & produces \verb+n+ columns with the\\
       
   451                    & \verb+col+ type of formatting\\
       
   452     \cline{2-2}
       
   453                    &\verb+*{3}{c}+ is the same as \verb+{c c c}+ \\
       
   454     \hline
       
   455     \verb+|+ & produces a vertical line\\ 
       
   456     \hline
   603   \end{tabular}
   457   \end{tabular}
   604 
       
   605 [include an image of a table, as example]
       
   606 
   458 
   607 Importing Graphics
   459 Importing Graphics
   608 ~~~~~~~~~~~~~~~~~~
   460 ~~~~~~~~~~~~~~~~~~
   609 
   461 
   610 Strictly speaking, LaTeX cannot manage pictures directly: in order to introduce graphics within documents, LaTeX just creates a box with the same size of the image you want to include and embeds the picture, without any other processing. This means you will have to take care that the images you want to include are in the right format to be included. This is not such a hard task because LaTeX supports the most common picture formats around.
   462 To include images in LaTeX, we require to use an additional package known as ``graphicx``.  To load a package, we use the ``\usepackage`` directive in the preamble of the document.
   611 
       
   612 We need to load the ``graphicx`` package in the preamble of the document to be able to include images. 
       
   613 ::
   463 ::
   614 
   464 
   615   \usepackage{graphicx}
   465   \usepackage{graphicx}
   616 
   466 
   617 When compiling with ``pdflatex`` command, (which we assume is being used all through this course) you can insert **jpg**, **png** and **pdf** files. 
   467 When compiling with ``pdflatex`` command,  **jpg**, **png**, **gif** and **pdf** images can be inserted. 
   618 
   468 
   619 ::
   469 ::
   620 
   470 
   621   \includegraphics[optional arguments]{imagename}
   471   \includegraphics[optional arguments]{imagename}
   622 
   472 
   623 A few ``optional arguments``:
   473 A few ``optional arguments``:
   624 
   474 
   625   ``width=xx``
   475   ``width=x``, ``height=x``
   626     specify the width of the imported image to ``xx``. 
   476     If only the height or width is specified, the image is scaled, maintaining the aspect ratio.
   627 
       
   628   ``height=xx``
       
   629     specify the height of the imported image to ``xx``. 
       
   630     Specifying only the width or height of the image will scale the image whilst maintaining the aspect ratio. 
       
   631 
   477 
   632   ``keepaspectratio``
   478   ``keepaspectratio``
   633     This can be either set to true or false. When set to true, it will scale the image according to both width and height, without distorting the image so that it does not exceed both the width and the height dimensions. 
   479     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. 
   634 
   480 
   635   ``scale=xx``
   481   ``scale=x``
   636     Scale the image by a factor of ``xx``. For eg. ``scale=2``, will double the image size. 
   482     Scale the image by a factor of ``x``. For eg. ``scale=2``, will double the image size. 
   637 
   483 
   638   ``angle=xx``
   484   ``angle=x``
   639     This option can be used to rotate the image by ``xx`` degrees, anti-clockwise. 
   485     This option can be used to rotate the image by ``x`` degrees, counter-clockwise. 
   640 
   486 
       
   487 ::
       
   488 
       
   489   \includegraphics[scale=0.8, angle=30]{lion_orig.png}
   641 
   490 
   642 Floats
   491 Floats
   643 ~~~~~~
   492 ~~~~~~
   644 
   493 
   645 Figures and Tables need special treatment, because they cannot be broken across pages. One method would be to start a new page every time a figure or a table is too large to fit on the present page. This approach would leave pages partially empty, which looks very bad.
   494 Tables and Figures need to be treated in a special manner, since they cannot be split over pages, and they are referred to as floats in LaTeX. 
   646 
   495 
   647 The solution to this problem is to ‘float’ any figure or table that does not fit on the current page to a later page, while filling the current page with body text. LaTeX offers two environments for floating bodies; one for tables and one for figures. To take full advantage of these two environments it is important to understand approximately how LaTeX handles floats internally. 
   496 When there is not enough space on a page, to fit in a table or figure, it is floated over to the next page filling up the current page with text. LaTeX has float environments called table and figure for tables and images, respectively.
   648 
   497 
   649 Any material enclosed in a figure or table environment will be treated as floating matter. 
   498 Anything enclosed within the table or figure environments will be treated as floats.
   650 ::
   499 ::
   651 
   500 
   652   \begin{figure}[placement specifier] or 
   501   \begin{figure}[pos] or 
   653   \begin{table}[placement specifier]
   502   \begin{table}[pos]
   654 
   503 
   655 Both float environments support an optional parameter called the placement specifier. This parameter is used to tell LaTeX about the locations to which the float is allowed to be moved. A placement specifier is constructed by building a string of float-placing permissions.
   504 The ``pos`` parameter specifies the placement of the float. The possible values it can take are as follows. 
   656 
   505 
   657 +-----------+-------------------------------------------------------------------+
   506 +-----------+-------------------------------------------------------------------+
   658 | Specifier | Permission                                                        |
   507 | Specifier | Permission                                                        |
   659 +===========+===================================================================+
   508 +===========+===================================================================+
   660 |   h       |  Place the float here                                             |
   509 |   h       |  at approximately the same place where it occurs in the source    |
   661 |           |  (approximately at the same point it occurs in the source text)   |
       
   662 +-----------+-------------------------------------------------------------------+
   510 +-----------+-------------------------------------------------------------------+
   663 |   t       |  Position at the top of the page.                                 |
   511 |   t       |  at the top of the page.                                          |
   664 +-----------+-------------------------------------------------------------------+
   512 +-----------+-------------------------------------------------------------------+
   665 |   b       |  Position at the bottom of the page.                              |
   513 |   b       |  at the bottom of the page.                                       |
   666 +-----------+-------------------------------------------------------------------+
   514 +-----------+-------------------------------------------------------------------+
   667 |   p       |  Put on a special page for floats only.                           |
   515 |   p       |  on a special page for floats only.                               |
   668 +-----------+-------------------------------------------------------------------+
   516 +-----------+-------------------------------------------------------------------+
   669 |   !       |  Override internal parameters Latex uses for determining “good”   | 
   517 |   !       |  Override LaTeX's internal parameters for good positions          |
   670 |           |  float positions.                                                 |
       
   671 +-----------+-------------------------------------------------------------------+
   518 +-----------+-------------------------------------------------------------------+
   672 |   H       |  Places the float at precisely the location in the LaTeX code.    | 
   519 |   H       |  nearly equivalent to h!                                          |
   673 |           |  Requires the float package. ``\usepackage{float}``.              |
       
   674 |           |  This is somewhat equivalent to h!                                |
       
   675 +-----------+-------------------------------------------------------------------+
   520 +-----------+-------------------------------------------------------------------+
   676 
   521 
   677 Examples::
   522 Examples::
   678 
   523 
   679   \begin{table}[!hbp]
   524   \begin{figure}[h]
   680   \begin{tabular}{...}
   525   \centering
   681   ... table data ...
   526   \includegraphics[scale=0.8, angle=30]{lion_orig.png}
   682   \end{tabular}
       
   683   \end{table}
       
   684 
       
   685   \begin{figure}[b]
       
   686     \includegraphics[scale=0.5]{image1.jpg}
       
   687   \end{figure}
   527   \end{figure}
   688 
   528 
   689 
   529 
   690 Captions
   530 Captions
   691 ~~~~~~~~
   531 ~~~~~~~~
   692 
   532 
   693 It is always good practice to add a caption to any figure or table. All you need to do is use the ``\caption{text}`` command within the float environment. LaTeX will automatically keep track of the numbering of figures, so you do not need to include this within the caption text.     
   533 The ``\caption{text}`` command allows you to add captions to images or tables. LaTeX automatically numbers your tables and figures and you need not include numbers in the captions that you write. The caption appears below or on top of the image (or table), depending on whether you place it after or before the ``importgraphics`` (or ``tabular``) command. 
   694 
   534 
   695 The location of the caption is traditionally underneath the float. However, it is up to you to therefore insert the caption command after the actual contents of the float (but still within the environment). If you place it before, then the caption will appear above the float.
   535 ::
   696 ::
   536   \begin{figure}[h]
   697 
   537   \centering
   698   \begin{figure}[b]
   538   \includegraphics[scale=0.8]{lion_orig.png}
   699     \caption{This is a caption at the top of the image}
   539   \caption{CTAN lion drawing by Duane Bibby; thanks to www.ctan.org}
   700     \includegraphics[scale=0.5]{image1.jpg}
       
   701   \end{figure}
   540   \end{figure}
   702 
   541 
   703   \begin{figure}[b]
   542 The caption command also, like the section command, has the short caption optional parameter. The short caption will appear in the list of tables or figures. 
   704     \includegraphics[scale=0.5]{image1.jpg}
       
   705     \caption{This is a caption at the bottom of the image}
       
   706   \end{figure}
       
   707 
       
   708 
   543 
   709 List of Figures, Tables
   544 List of Figures, Tables
   710 ~~~~~~~~~~~~~~~~~~~~~~~
   545 ~~~~~~~~~~~~~~~~~~~~~~~
   711 
   546 
   712 Captions can be listed in a “List of Tables” or a “List of Figures” section by using the ``\listoftables`` or ``\listoffigures`` commands, respectively. The caption used for each table or figure will appear in these lists, along with the table or figure numbers, and page numbers that they appear on.
   547 LaTeX can automatically generate a List of Tables or Figures, with the table or figure numbers, the captions and page numbers on which they appear. This can be done using the ``\listoftables`` or ``listoffigures`` commands. 
   713 
   548 
   714 The ``\caption`` command also has an optional parameter, ``\caption[short]{long}`` which is used for the List of Tables or List of Figures. Typically the short description is for the caption listing, and the long description will be placed beside the figure or table. This is particularly useful if the caption is long, and only a “one-liner” is desired in the figure/table listing. 
   549 Note: Just like table of contents, these lists also require an extra compilation. 
       
   550 
       
   551 Cross References
       
   552 ~~~~~~~~~~~~~~~~
       
   553 
       
   554 LaTeX has a very efficient mechanism of inserting cross-references in documents. 
       
   555 
       
   556 The command ``\label{name}`` is used to label figures, tables or segments of text. ``\ref{name}`` refers to the object marked by the ``name`` by it's numbering (figure, table, section etc.) ``\pageref{name}`` gives the page number of the object which has been labeled with ``name``. 
       
   557 
       
   558 Note: Cross referencing also requires an extra compilation, like table of contents. 
       
   559 
       
   560 Bibliography
       
   561 ------------
       
   562 
       
   563 Bibliography or references can be added to LaTeX documents in two ways - using the ``thebibliography`` environment, or using BibTeX. Let's first look at using the ``\thebibliography`` environment and then move on to BibTeX.
       
   564 
       
   565 ``thebibliography`` environment
       
   566 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   567 
       
   568 Writing bibliographies in LaTeX using the ``thebibliography`` environment is pretty easy. You simply have to list down all the bibliography items within the bibliography environment. 
       
   569 
       
   570 Each entry of the bibliography begins with the command ``\bibitem[label]{name}``. The name is used to cite the bibliography item within the document using  ``\cite{name}``. The label option replaces the numbers from the auto enumeration with the labels given. 
       
   571 ::
       
   572 
       
   573   He used this lion in the illustrations for D Knuth's original TeXbook\cite{DKnuth}, for L Lamport's LaTeX book\cite{LLamport}
       
   574 
       
   575   \begin{thebibliography}{99}
       
   576     \bibitem{DKnuth} Donald E. Knuth (1984). \emph{The TeXbook} (Computers and Typesetting, Volume A). Reading, Massachusetts: Addison-Wesley. ISBN 0-201-13448-9.
       
   577   
       
   578     \bibitem{LLamport} Lamport, Leslie (1994). \emph{LaTeX: A document preparation system: User's guide and reference}.
       
   579      illustrations by Duane Bibby (2nd ed.). Reading, Mass: Addison-Wesley Professional. 
       
   580   \end{thebibliography}
       
   581 
       
   582 The ``99`` in the example above indicates the maximum width of the label that the references may get. We here assume that the number of Bibliography items will be less than 100. If your document has less than 10 references, you may want to replace ``99`` with ``9``. 
       
   583 
       
   584 BibTeX
       
   585 ~~~~~~
       
   586 
       
   587 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.
       
   588 
       
   589 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. 
       
   590 
       
   591 The BibTeX database is stored in a ``.bib`` file. The structure of the file is quite simple and an example is shown below. 
       
   592 ::
       
   593 
       
   594   @book{Lamport94,
       
   595   author    = "Leslie Lamport",
       
   596   title     = "A Document Preparation System: User's Guide and Reference",
       
   597   publisher = "Addison-Wesley Professional",
       
   598   year      = "1994",
       
   599   edition    = "second",
       
   600   note      = "illustrations by Duane Bibby"
       
   601   }
       
   602 
       
   603 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``.
       
   604 
       
   605 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}``. 
       
   606 
       
   607 This is followed by the relevant fields and their values, listed one by one. Each entry must be followed by a comma to delemit one field from the other. 
       
   608 
       
   609 To get your LaTeX document to use the bibliography database, you just add the following lines to your LaTeX document. 
       
   610 ::
       
   611 
       
   612   \bibliographystyle{plain}
       
   613   \bibliography{LaTeX}
       
   614 
       
   615 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. 
       
   616 
       
   617 The ``bibliography`` command specifies the file that shoule be used as the database for references. The file used in this example is ``LaTeX.bib``
       
   618 
       
   619 Compiling
       
   620 +++++++++
       
   621 
       
   622 Adding BibTeX based references, slightly complicates the process of compiling the document to obtain the desired output. The exact workings of LaTeX and BibTeX will not be explained here. The procedure for obtaining the output (without any explanations) is as follows:
       
   623 
       
   624 1. Compile the ``.tex`` file using ``pdflatex`` - ``$pdflatex LaTeX(.tex)``
       
   625 2. Compile the ``.bib`` file using ``bibtex`` -  ``$bibtex LaTeX(.bib)``
       
   626 3. Compile the ``.tex`` file again. 
       
   627 4. Compile the ``.tex`` file for one last time!
   715 
   628 
   716 Typesetting Math
   629 Typesetting Math
   717 ----------------
   630 ----------------
   718 
   631 
   719 If you wish to typset advanced mathematics, it is best to use the AMS-LaTeX bundle, which is a collection of packages and classes for mathematical typsetting. Note that LaTeX does, provide some basic features and environments for mathematical typsetting, but they are limited and in some cases even inconsistent. We shall stick to using the ``amsmath`` package from the AMS-LaTeX bundle, throughout this course. 
   632 It is advisable to use the AMS-LaTeX bundle to typeset mathematics in LaTeX. It is a collection of packages and classes for mathematical typesetting. 
   720 
   633 
   721 We load ``amsmath`` by issuing the ``\usepackage{amsmath}`` in the preamble. Through out this section, it is assumed that the ``amsmath`` package has been loaded. 
   634 We load ``amsmath`` by issuing the ``\usepackage{amsmath}`` in the preamble. Through out this section, it is assumed that the ``amsmath`` package has been loaded. 
       
   635 
   722 
   636 
   723 Math Mode
   637 Math Mode
   724 ~~~~~~~~~
   638 ~~~~~~~~~
   725 
   639 
   726 There are a few differences between the *math mode* and the *text mode*:
   640 There are a few differences between the *math mode* and the *text mode*:
   727 
   641 
   728 1. Most spaces and line breaks do not have any significance, as all spaces are either derived logically from the mathematical expressions, or have to be specified with special commands such as ``\,``, ``\quad`` or ``\qquad``
   642 1. Most spaces and line breaks do not have any significance, as all spaces are either derived logically from the mathematical expressions, or have to be specified with special commands such as ``\``, ``\quad`` or ``\qquad``
   729 
   643 
   730 2. Empty lines are not allowed.  
   644 2. Empty lines are not allowed.  
   731 
   645 
   732 3. Each letter is considered to be the name of a variable and will be typeset as such. If you want to typeset normal text within a formula, then you have to enter the text using the \text{...} command
   646 3. Each letter is considered to be the name of a variable and will be typeset as such. If you want to typeset normal text within a formula, then you have to enter the text using the \text{...} command
   733 
   647 
   734 Single Equations
   648 Single Equations
   735 ~~~~~~~~~~~~~~~~
   649 ~~~~~~~~~~~~~~~~
   736 
   650 
   737 There are two ways to typeset mathematical equations in LaTeX - inline within a paragraph (*text style*), or the paragraph can be broken to typeset it separately (*display style*). 
   651 Mathematical equations can be inserted in-line within a paragraph (*text style*), or the paragraph can be broken to typeset it separately (*display style*). 
   738 
   652 
   739 A mathematical equation within a paragraph is entered between ``$`` and ``$``.
   653 A mathematical equation within a paragraph is entered between ``$`` and ``$``. Larger equations are set apart from the paragraph, by enclosing them within ``\begin{equation}`` and ``\end{equation}``. If you don't wish to number a particular equation, the starred version of equation can be used. ``\begin{equation*}`` and ``\end{equation*}``
   740 
   654 
   741 If you want the larger equations to be set apart from the paragraph, it is better to use the display style. To do this, you enclose the equations within ``\begin{equation}`` and ``\end{equation}``. You can then \label an equation number and refer to it somewhere else in the text by using the ``\eqref`` command. If you want to name the equation something specific, you ``\tag`` it instead. You can’t use ``\eqref`` with ``\tag``. If you donot want LaTeX to number a particular equation, use the starred version of equation using an ``\begin{equation*}`` and ``\end{equation*}``
   655 The equation can also be cross referenced using the ``\label`` and ``\eqref`` commands. 
   742 
   656 
   743 [need to include images as examples?]
   657 Basic Elements
   744 
   658 ~~~~~~~~~~~~~~
   745 Building Blocks of a Mathematical Formula
       
   746 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   747 
   659 
   748 Greek Letters can are entered as ``\alpha, \beta, \gamma, \delta, ...`` for lowercase letters and ``\Alpha, \Beta, \Gamma, ...`` for uppercase ones. 
   660 Greek Letters can are entered as ``\alpha, \beta, \gamma, \delta, ...`` for lowercase letters and ``\Alpha, \Beta, \Gamma, ...`` for uppercase ones. 
   749 
   661 
   750 Exponents and Subscripts can be specified using the ^ and the _ character. Most math mode commands act only on the next character, so if you want a command to affect several characters, you have to group them together using curly braces: {...}.
   662 Exponents and subscripts can be typeset using the carat ``^`` and the underscore ``_`` respectively. Most of the math mode commands act only on the next character. If you want a command to affect several characters, they need to be enclosed in curly braces. 
   751 
   663 
   752 The square root is entered as ``\sqrt``; the nth root is generated with ``\sqrt[n]``. The size of the root sign is determined automatically by LaTeX. If just the sign is needed, use ``\surd``.
   664 The ``\sqrt`` command is used to typeset the square root symbol. LaTeX of the root sign is determined automatically. The nth root is generated with ``\sqrt[n]``. 
   753 
   665 
   754 To explicitly show a multiplication a dot may be shown. \cdot could be used, which typesets the dot to the centre. \cdots is three centered dots while \ldots sets the dots on the baseline. Besides that, there are \vdots for vertical and \ddots for diagonal dots.
   666 To explicitly show a multiplication a dot may be shown. ``\cdot`` could be used, which typesets the dot to the centre. ``\cdots`` is three centered dots while ``\ldots`` sets the dots on the baseline. Besides that ``\vdots`` for vertical and ``\ddots`` can be used for diagonal dots.
   755 
   667 
   756 A fraction can be typeset with the command ``\frac{...}{...}``
   668 A fraction can be typeset with the command ``\frac{..}{..}``
   757 
   669 
   758 The integral operator is generated with ``\int``, the sum operator with ``\sum``, and the product operator with ``\prod``. The upper and lower limits are specified with ``^`` and ``_`` like subscripts and superscripts.
   670 The integral operator is generated with ``\int``, the sum operator with ``\sum``, and the product operator with ``\prod``. The upper and lower limits are specified with ``^`` and ``_`` like subscripts and superscripts.
   759 
   671 
   760 If you put ``\left`` in front of an opening delimiter and ``\right`` in front of a closing delimiter, LaTeX will automatically determine the correct size of the delimiter. Note that you must close every ``\left`` with a corresponding ``\right``.
   672 LaTeX provides all kinds of braces as delimiters. The round and square brackets can be produces using the keys on the keyboard and appending a backslash. Other delimiters can be produced using special commands of LaTeX. Placing ``\left`` in front of an opening delimiter and ``\right`` in front of a closing delimiter, instructs LaTeX to automatically take care of the sizes of the delimiters. 
   761 
       
   762 
       
   763 
       
   764 Vertically Aligned Material
       
   765 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   766 
   673 
   767 Multiple Equations
   674 Multiple Equations
   768 ++++++++++++++++++
   675 ~~~~~~~~~~~~~~~~~~
   769 
   676 
   770 For formulae running over several lines or for equation systems, you can use the environments ``align`` and ``align*`` instead of ``equation`` and ``equation*``. With ``align`` each line gets an equation number. The ``align*`` does not number anything. 
   677 Long formulae that run over several lines or equation systems, can be typeset using the ``align`` or ``align*`` environments. ``align`` numbers each of the lines in the environment, and ``align*`` as expected, does not number any of them. 
   771 
   678 
   772 The ``align`` environments center the single equation around the ``&`` sign. The ``\\`` command breaks the lines. If you only want to enumerate some of equations, use ``\nonumber`` to remove the number. It has to be placed before the ``\\``.
   679 The ``&`` is used to align the equations vertically and the ``\\`` command is used to break the lines. Line numbering can be skipped for a particular line in the ``align`` environment by placing a ``\nonumber`` before the line break.
       
   680 
       
   681 ::
       
   682 
       
   683   \begin{align}
       
   684   \alpha^2 + \beta^2 &= \gamma^2 \\
       
   685   \sum_{i=1}^ni &= \frac{n(n+1)}{2}\\
       
   686   \sqrt{-1} &= \pm1 \nonumber
       
   687   \end{align}
       
   688 
   773 
   689 
   774 Arrays and Matrices
   690 Arrays and Matrices
   775 +++++++++++++++++++
   691 ~~~~~~~~~~~~~~~~~~~
   776 
   692 
   777 To typset arrays, use the ``array`` environment. It works similar to the ``tabular`` environment. The ``\\`` command is used to break the lines. 
   693 To typset arrays, use the ``array`` environment. It works similar to the ``tabular`` environment. The ``\\`` command is used to break the lines. 
   778 ::
   694 ::
   779 
   695 
   780   \begin{equation*}
   696   \begin{equation*}
   781   \mathbf{X} = \left(
   697   \mathbf{X} = \left(
   782    \begin{array}{ccc}
   698    \begin{array}{ccc}
   783    x_1 & x_2 & \ldots \\
   699    a_1 & a_2 & \ldots \\
   784    x_3 & x_4 & \ldots \\
   700    b_1 & b_2 & \ldots \\
   785    \vdots & \vdots & \ddots
   701    \vdots & \vdots & \ddots
   786    \end{array} \right)
   702    \end{array} \right)
   787   \end{equation*}
   703   \end{equation*}
   788 
   704 
   789 The ``array`` environment can also be used to typeset piecewise functions by using a “.” as an invisible ``\right`` delimiter
   705 The ``array`` environment can also be used to typeset piecewise functions by using a “.” as an invisible ``\right`` delimiter
   790 ::
   706 ::
   791 
   707 
   792   \begin{equation*}
   708   \begin{equation*}
   793   |x| = \left\{
   709   f(x) = \left\{
   794    \begin{array}{rl}
   710    \begin{array}{rl}
   795     -x & \text{if } x < 0\\
   711      0 & \text{if } x \le 0\\
   796      0 & \text{if } x = 0\\
   712      1 & \text{if } x > 0
   797      x & \text{if } x > 0
       
   798    \end{array} \right.
   713    \end{array} \right.
   799    \end{equation*}
   714    \end{equation*}
   800 
   715 
   801 The ``array`` environment can be used for typesetting matrices also, but ``amsmath`` provides a better solution using the different matrix environments. There are six versions with different delimiters: ``matrix`` (none), ``pmatrix`` (, ``bmatrix`` [, ``Bmatrix`` {, ``vmatrix`` | and ``Vmatrix`` ‖. The number of columns need not be specified, unlike the ``array`` environment.
   716 Six different types of matrix environments are available in the ``amsmath`` package for typesetting matrices.  They essentially have different delimiters: ``matrix`` (none), ``pmatrix`` (, ``bmatrix`` [, ``Bmatrix`` {, ``vmatrix`` | and ``Vmatrix`` ‖. In these matrix environments, the number of columns need not be specified, unlike the ``array`` environment.
   802 ::
   717 ::
   803 
   718 
   804   \begin{equation*}
   719   \begin{equation*}
   805     \begin{matrix}
   720     \begin{matrix}
   806     1 & 2 \\
   721     1 & 2 \\
   812     4 & 5 & 6 \\
   727     4 & 5 & 6 \\
   813     7 & 8 & 9
   728     7 & 8 & 9
   814     \end{bmatrix}
   729     \end{bmatrix}
   815   \end{equation*}
   730   \end{equation*}
   816 
   731 
   817 
   732 Miscellaneous Stuff
   818 Bibliography
   733 -------------------
   819 ------------
   734 
   820 
   735 Presentations
   821 As mentioned previously, you can either use the ``thebibliography`` environment to include your references in the main document file itself, or use BibTeX to generate a database of references and keep using them as and when required. We shall first look at how we can include the reference items within our document itself. 
   736 ~~~~~~~~~~~~~
   822 
   737 
   823 ``thebibliography`` environment
   738 LaTeX has quite a few options to produce presentation slides. We shall look at the ``beamer`` class, which is well developed and easy to use. We shall only briefly look at some of the features of beamer. For the best documentation, look at the beamer user guide.
   824 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   739 
   825 
   740 To write a ``beamer`` presentation, it is recommended that you use one of the templates that beamer provides. We shall use the ``speaker_introduction`` template to get started with beamer. 
   826 To use the thebibliography environment, you simply list down all the bibliography items within the bibliography environment as shown below. 
   741 
   827 
   742 As you can see, the document begins with the ``documentclass`` being set to beamer. 
   828 Each item starts with ``\bibitem[label]{marker}``. The marker is then used to cite the bibliography item within the document, using ``\cite{marker}``. If the ``label`` option is not used, the bibliography items get enumerated automatically.
   743 
   829 ::
   744 The ``\setbeamertemplate`` command sets the template for various parameters. The ``background canvas``, ``headline`` and ``footline`` are being set using the command.
   830   
   745 
   831   Lamport's \cite{WBook} book is a good reference for LaTeX.
   746 ``\usetheme`` command sets the theme to be used in the presentation. 
   832   
   747 
   833   \begin{thebibliography}{99}
   748 Notice that each slide is enclosed within ``\begin{frame}`` and ``\end{frame}`` commands. The ``\begin{frame}`` command can be passed the Title and Subtitle of the slide as parameters. 
   834   
   749 
   835     \bibitem{WBook} Lamport, Leslie (1994). \emph{LaTeX: A document preparation system: User's guide and reference}.
   750 To achieve more with beamer, it is highly recommended that you look at the ``beameruserguide``.
   836      illustrations by Duane Bibby (2nd ed.). Reading, Mass: Addison-Wesley Professional. 
   751 
   837   
   752 Including Code
   838   \end{thebibliography}
   753 ~~~~~~~~~~~~~~
   839 
   754 
   840 The ``99`` in the example above indicates the maximum width of the label that the references may get. We here assume that the number of Bibliography items will be less than 100. If your document has less than 10 references, you may want to replace ``99`` with ``9``. 
   755 The ``listings`` package can be used to embed source code into your LaTeX document. We shall briefly explore inserting python code into our document. 
   841 
   756 
   842 BibTeX
   757 Obviously, you first need to tell LaTeX that you want it to use the ``listings`` package, using the ``\usepackage`` command. 
   843 ~~~~~~
   758 ::
   844 
   759 
   845 The previous section detailed the process of embedding the references at the end of the document's source file and using the ``\cite`` command to cite them. In this section we shall use the BibTeX environment for references. 
   760   \usepackage{listings}
   846 
   761 
   847 Using BibTeX you can create a database of all your references in a text file and cite the appropriate ones in each document. This method is much more convinient than writing down all the references for each document at the end of it, when you are writing multiple documents in a field. 
   762 Then, we tell LaTeX that we are going to embed Python code into this document. A simple code highlighting for Python code can be achieved using this. 
   848 
   763 ::
   849 The BibTeX database is stored in a ``.bib`` file. The structure of the file is quite simple and an example is shown below. 
   764 
   850 ::
   765   \lstset{language=Python,
   851 
   766           showstringspaces=false,
   852   @book{Lamport94,
   767          }
   853   author    = "Leslie Lamport",
   768 
   854   title     = "A Document Preparation System: User's Guide and Reference",
   769 You might want to customize the code highlighting further using other variables like ``basicstyle``, ``commentstyle``, ``stringstyle``, ``keywordstyle`` etc. For detailed information on all this, you should look at the ``listings`` package documentation. 
   855   publisher = "Addison-Wesley Professional",
   770 
   856   year      = "1994",
   771 You include a block of code into your document by enclosing it within the ``lstlisting`` environment. 
   857   edtion    = "second",
   772 ::
   858   note      = "illustrations by Duane Bibby"
   773 
   859   }
   774   \begin{lstlisting}
   860 
   775   string="Hello, World! "
   861 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``.
   776   for i in range(10):
   862 
   777       print string*i
   863 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}``. 
   778   \end{lstlisting} 
   864 
   779 
   865 This is followed by the relevant fields and their values, listed one by one. Each entry must be followed by a comma to delemit one field from the other. 
   780 You can also include source code files directly into your latex document, using the ``lstinputlisting`` command. 
   866 
   781 ::
   867 To get your LaTeX document to use the bibliography database, you just add the following lines to your LaTeX document. 
   782 
   868 ::
   783   \lstinputlisting[lastline=20]{lstexample.py}
   869 
   784 
   870   \bibliographystyle{plain}
   785 This command includes the first 20 lines of the file ``lstexample.py`` into out LaTeX document. 
   871   \bibliography{LaTeX}
   786 
   872 
   787 Including files
   873 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. 
   788 ~~~~~~~~~~~~~~~
   874 
   789 When working on a large document, it is convinient sometimes, to split the large file into smaller input files and club them together at the time of compiling. 
   875 The ``bibliography`` command specifies the file that shoule be used as the database for references. The file used in this example is ``LaTeX.bib``
   790 
   876 
   791 The ``\input`` or ``\include`` commands may be used to embed one LaTeX file into another. The ``\input`` command is equivalent to a copy and paste of the document, just before the compilation. The ``\include`` command is exactly similar, except for the fact that it creates a new page every time it is issued.
   877 Compiling
   792 
   878 +++++++++
   793 ``\input{file}`` or ``\include{file}`` commands will include the file ``file1.tex`` with in the file where the command has been issued. Note that you do not need to specify the ``.tex`` extension of the file. 
   879 
   794 
   880 Adding BibTeX based references, slightly complicates the process of coompiling the document to obtain the desired output. The exact workings of LaTeX and BibTeX will not be explained here. The procedure for obtaining the output (without any explanations) is as follows:
   795 The ``\includeonly`` is useful for debugging or testing the LaTeX document that you are creating, since it restricts the ``\include`` command. Only the files which are given as arguments to the ``\includeonly`` command will be included in the document (wherever a ``\include`` command for those files, has been issued).
   881 
   796 
   882 1. Compile the ``.tex`` file using ``pdflatex`` - ``$pdflatex LaTeX(.tex)``
   797 A note on filenames
   883 2. Compile the ``.bib`` file using ``bibtex`` -  ``$bibtex LaTeX(.bib)``
   798 +++++++++++++++++++
   884 3. Compile the ``.tex`` file again. 
   799 
   885 4. Compile the ``.tex`` file for one last time!
   800 Never use filenames or directories that contain spaces. Make filenames as long or short as you would like, but strictly avoid spaces. Stick to upper or lower case letters (without accents), the digits, the hyphen and the full stop or period.
   886 
       
   887 
   801 
   888 --------------------------------------------------------
   802 --------------------------------------------------------
   889 
   803 
   890 Acknowledgements, Attributions
   804 Acknowledgements, Attributions
   891 ------------------------------
   805 ------------------------------
   892 
   806 
   893 1. *LaTeX Wikibook*
   807 1. *LaTeX Wikibook*
   894 
   808 
   895 2. *The Not So Short Introduction to LaTeX2e* by Tobias Oetikar et. al. 
   809 2. *The Not So Short Introduction to LaTeX2e* by Tobias Oetikar et al.. 
   896 
   810 
       
   811 3. http://www.ctan.org/tex-archive/info/l2tabu/english/
       
   812 ..  LocalWords:  LaTeX WYSIWG WYSIWM pdf
       
   813 
       
   814 
       
   815 
       
   816 
       
   817