latex/handout.rst
changeset 36 4c4c8a9795b2
parent 30 3ca8ab883c13
child 56 eee394eb05fc
equal deleted inserted replaced
35:8f43cab360aa 36:4c4c8a9795b2
   543 ~~~~~~~~
   543 ~~~~~~~~
   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.     
   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.     
   545 ::
   545 ::
   546 
   546 
   547   \begin{verbatim}
   547   \begin{verbatim}
   548   10 PRINT "HELLO WORLD ";
   548   from numpy import *
   549   20 GOTO 10
   549   a = linspace(0, 5, 50, endpoint = False)
   550   \end{verbatim}
   550   \end{verbatim}
   551 
   551 
   552 
   552   from numpy import *
   553 10 PRINT "HELLO WORLD ";
   553   a = linspace(0, 5, 50, endpoint = False)
   554 
       
   555 20 GOTO 10
       
   556 
       
   557 
   554 
   558 Within a paragraph, similar behavior can be accessed with
   555 Within a paragraph, similar behavior can be accessed with
   559 ::
   556 ::
   560   
   557   
   561   \verb+text+ 
   558   \verb+text+ 
   563 The + is just an example of a delimiter character. You can use any character except letters, * or space.
   560 The + is just an example of a delimiter character. You can use any character except letters, * or space.
   564 
   561 
   565 The starred verstion of the verbatim environment emphasizes the spaces in the text. 
   562 The starred verstion of the verbatim environment emphasizes the spaces in the text. 
   566 ::
   563 ::
   567 
   564 
   568   \begin{verbatim*}
   565   \begin{verbatim}
   569   10 PRINT "HELLO WORLD ";
   566   from numpy import *
   570   20 GOTO 10
   567   a = linspace(0, 5, 50, endpoint = False)
   571   \end{verbatim*}
   568   \end{verbatim}
   572 
   569 
   573 10␣PRINT␣"HELLO␣WORLD␣";
   570   from␣numpy␣import␣*
   574 
   571   a␣=␣linspace(0,␣5,␣50,␣endpoint␣=␣False)
   575 20␣GOTO␣10
   572 
   576 
   573 
   577 Tables, Figures and Captions
   574 Tables, Figures and Captions
   578 ----------------------------
   575 ----------------------------
   579 
   576 
   580 The ``\tabular`` environment
   577 The ``\tabular`` environment
   657 
   654 
   658 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.
   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.
   659 
   656 
   660 +-----------+-------------------------------------------------------------------+
   657 +-----------+-------------------------------------------------------------------+
   661 | Specifier | Permission                                                        |
   658 | Specifier | Permission                                                        |
   662 +-----------+-------------------------------------------------------------------+
   659 +===========+===================================================================+
   663 |   h       |  Place the float here                                             |
   660 |   h       |  Place the float here                                             |
   664 |           |  (approximately at the same point it occurs in the source text)   |
   661 |           |  (approximately at the same point it occurs in the source text)   |
   665 +-----------+-------------------------------------------------------------------+
   662 +-----------+-------------------------------------------------------------------+
   666 |   t       |  Position at the top of the page.                                 |
   663 |   t       |  Position at the top of the page.                                 |
   667 +-----------+-------------------------------------------------------------------+
   664 +-----------+-------------------------------------------------------------------+
   775 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 ``\\``.
   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 ``\\``.
   776 
   773 
   777 Arrays and Matrices
   774 Arrays and Matrices
   778 +++++++++++++++++++
   775 +++++++++++++++++++
   779 
   776 
       
   777 To typset arrays, use the ``array`` environment. It works similar to the ``tabular`` environment. The ``\\`` command is used to break the lines. 
       
   778 ::
       
   779 
       
   780   \begin{equation*}
       
   781   \mathbf{X} = \left(
       
   782    \begin{array}{ccc}
       
   783    x_1 & x_2 & \ldots \\
       
   784    x_3 & x_4 & \ldots \\
       
   785    \vdots & \vdots & \ddots
       
   786    \end{array} \right)
       
   787   \end{equation*}
       
   788 
       
   789 The ``array`` environment can also be used to typeset piecewise functions by using a “.” as an invisible ``\right`` delimiter
       
   790 ::
       
   791 
       
   792   \begin{equation*}
       
   793   |x| = \left\{
       
   794    \begin{array}{rl}
       
   795     -x & \text{if } x < 0\\
       
   796      0 & \text{if } x = 0\\
       
   797      x & \text{if } x > 0
       
   798    \end{array} \right.
       
   799    \end{equation*}
       
   800 
       
   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.
       
   802 ::
       
   803 
       
   804   \begin{equation*}
       
   805     \begin{matrix}
       
   806     1 & 2 \\
       
   807     3 & 4
       
   808     \end{matrix} \qquad
       
   809  
       
   810     \begin{bmatrix}
       
   811     1 & 2 & 3 \\
       
   812     4 & 5 & 6 \\
       
   813     7 & 8 & 9
       
   814     \end{bmatrix}
       
   815   \end{equation*}
       
   816 
   780 
   817 
   781 Bibliography
   818 Bibliography
   782 ------------
   819 ------------
   783 
   820 
   784 You can produce a bibliography with the ``thebibliography`` environment.
   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. 
       
   822 
       
   823 ``thebibliography`` environment
       
   824 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   825 
       
   826 To use the thebibliography environment, you simply list down all the bibliography items within the bibliography environment as shown below. 
       
   827 
       
   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.
       
   829 ::
       
   830   
       
   831   Lamport's \cite{WBook} book is a good reference for LaTeX.
       
   832   
       
   833   \begin{thebibliography}{99}
       
   834   
       
   835     \bibitem{WBook} Lamport, Leslie (1994). \emph{LaTeX: A document preparation system: User's guide and reference}.
       
   836      illustrations by Duane Bibby (2nd ed.). Reading, Mass: Addison-Wesley Professional. 
       
   837   
       
   838   \end{thebibliography}
       
   839 
       
   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``. 
       
   841 
       
   842 BibTeX
       
   843 ~~~~~~
       
   844 
       
   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. 
       
   846 
       
   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. 
       
   848 
       
   849 The BibTeX database is stored in a ``.bib`` file. The structure of the file is quite simple and an example is shown below. 
       
   850 ::
       
   851 
       
   852   @book{Lamport94,
       
   853   author    = "Leslie Lamport",
       
   854   title     = "A Document Preparation System: User's Guide and Reference",
       
   855   publisher = "Addison-Wesley Professional",
       
   856   year      = "1994",
       
   857   edtion    = "second",
       
   858   note      = "illustrations by Duane Bibby"
       
   859   }
       
   860 
       
   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``.
       
   862 
       
   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}``. 
       
   864 
       
   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. 
       
   866 
       
   867 To get your LaTeX document to use the bibliography database, you just add the following lines to your LaTeX document. 
       
   868 ::
       
   869 
       
   870   \bibliographystyle{plain}
       
   871   \bibliography{LaTeX}
       
   872 
       
   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. 
       
   874 
       
   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``
       
   876 
       
   877 Compiling
       
   878 +++++++++
       
   879 
       
   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:
       
   881 
       
   882 1. Compile the ``.tex`` file using ``pdflatex`` - ``$pdflatex LaTeX(.tex)``
       
   883 2. Compile the ``.bib`` file using ``bibtex`` -  ``$bibtex LaTeX(.bib)``
       
   884 3. Compile the ``.tex`` file again. 
       
   885 4. Compile the ``.tex`` file for one last time!
   785 
   886 
   786 
   887 
   787 --------------------------------------------------------
   888 --------------------------------------------------------
   788 
   889 
   789 Acknowledgements, Attributions
   890 Acknowledgements, Attributions