training lat

Upload: nvrkrishna456

Post on 03-Jun-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 Training Lat

    1/34

    Sectioning, Listing, Mathematical Equations, andAlgorithms in LATEX

    Soubhagya Sankar Barpanda(PhD. Scholar)

    Dept. of CSE

    Department of Computer Science and Engineering

    National Institute of Technology Rourkela

    http://find/
  • 8/12/2019 Training Lat

    2/34

    Table of Contents

    1 Section

    2 List

    3 Mathematical Symbols

    4 Mathematical Equations

    5 Algorithm

    http://find/
  • 8/12/2019 Training Lat

    3/34

    Section

    Introduction

    LATEX provides seven levels of division or sectioning to be used instructuring text.

    All document divisions get numbered automatically. Parts get Romannumerals (Part I, Part II, etc.); chapters and sections get decimalnumbering, and Appendices are lettered (A, B, C, etc.).

    http://find/
  • 8/12/2019 Training Lat

    4/34

    Section

    Paragraphs in LATEX are usually fully justified, i.e. flush with both the leftand right margins. By default, the first paragraph after a heading followsthe standard Anglo-American publishers practice of no indentation.

    \paragraph{} can be used to create a paragraph in document.

    S i

    http://find/
  • 8/12/2019 Training Lat

    5/34

    Section

    Table: Different levels of structuring in text

    -1 Part \part Not in letters

    0 Chapter \chapter Books and reports

    1 Section \section Not in letters

    2 Subsection \subsection Not in letters

    3 Subsubsection \subsubsection Not in letters

    4 Titled paragraph \paragraph Not in letters

    5 Titled subparagraph \subparagraph Not in letters

    S ti

    http://find/http://goback/
  • 8/12/2019 Training Lat

    6/34

    Section

    \section{New recruitment policies}

    ...

    \subsection{Effect on staff turnover}

    ...

    \subsubsection{Business plan 2005--2007}

    List

    http://find/
  • 8/12/2019 Training Lat

    7/34

    List

    Lists in LATEX

    Lists are useful tools for arranging thoughts in small piece of informationat a time.

    Within a list environment, list items are always identified by the command\item

    List

    http://find/
  • 8/12/2019 Training Lat

    8/34

    List

    Different types of lists

    Random or arbitrary lists

    Enumerated or sequential lists

    Descriptive or labeled lists

    Inline lists

    List

    http://find/
  • 8/12/2019 Training Lat

    9/34

    List

    Example of Arbitrary lists

    A

    BC

    List

    http://find/
  • 8/12/2019 Training Lat

    10/34

    List

    \begin{itemize}

    \item A

    \item B

    \item C

    \end{itemize}

    List

    http://find/
  • 8/12/2019 Training Lat

    11/34

    List

    Example ofEnumerated lists

    1 A

    2 B3 C

    List

    http://find/
  • 8/12/2019 Training Lat

    12/34

    \begin{enumerate}

    \item A

    \item B

    \item C

    \end{enumerate}

    List

    http://find/http://goback/
  • 8/12/2019 Training Lat

    13/34

    Example of Description lists

    A: This is first description

    B: This is second descriptionC: This is third description

    List

    http://find/
  • 8/12/2019 Training Lat

    14/34

    \begin{description}

    \item[ A: ] This is first description

    \item[ B: ] This is second description

    \item[ C: ] This is third description

    \end{description}

    List

    http://find/http://goback/
  • 8/12/2019 Training Lat

    15/34

    Example of Random Inline lists

    Inline lists, which are sequential in nature, just like enumerated lists, but

    are a) formatted within their paragraph; b) usually labeled with letters; andc) usually have the final item prefixed with and or or , like this example.

    \textbf{\itshape Inline lists}, which are sequential in

    nature, just like enumerated lists, but are\begin{inparaenum}[ a)]

    \item formatted within their paragraph;

    \item usually labeled with letters; and

    \item usually have the final

    item prefixed with and or or \end{inparaenum},

    like this example.

    List

    http://find/
  • 8/12/2019 Training Lat

    16/34

    Nested lists

    1 The first item1 Nested item 1

    2 Nested item 22 The second item

    3 The third etc . . .

    List

    http://find/
  • 8/12/2019 Training Lat

    17/34

    \begin{enumerate}

    \item The first item

    \begin{enumerate}

    \item Nested item 1

    \item Nested item 2\end{enumerate}

    \item The second item

    \item The third etc \ldots

    \end{enumerate}

    List

    http://find/
  • 8/12/2019 Training Lat

    18/34

    Lists with use-defined characters

    a. The first item

    b. The second item

    c. The third etc . . .

    I. The first item

    II. The second item

    III. The third etc ...

    List

    http://find/
  • 8/12/2019 Training Lat

    19/34

    Lists with use-defined characters

    \begin{enumerate}[a.]

    \item The first item

    \item The second item

    \item The third etc \ldots

    \end{enumerate}

    Mathematical Symbols

    M h i l S b l

    http://find/
  • 8/12/2019 Training Lat

    20/34

    Mathematical Symbols

    One of the greatest motivating forces behind development LATEX systemwas to create something that allowed simple construction of mathematicalformulas, while professional look is ensured when printed.

    Mathematics has many symbols! One of the most difficult aspects oflearning LATEX is remembering how to produce symbols. There are ofcourse a set of symbols that can be accessed directly from the keyboard:

    + , - , = , ! , / , ( ) , [ ] , < > , | , , :

    Mathematical Symbols

    http://find/
  • 8/12/2019 Training Lat

    21/34

    LATEX needs to know beforehand that the subsequent text does indeed

    contain mathematical elements. This is because LATEX typesets mathsnotation differently from normal text. Therefore, special environmentshave been declared for this purpose. They can be distinguished into twocategories depending on how they are presented:

    1 text formulas are displayed inline, that is, within the body of textwhere it is declared, for example, I can say that a+a= 2a within thissentence.

    2 displayedformulas are separate from the main text. Ex. The scaling

    function is given by:(t) = 2|H0()|=0

    n

    h0(n)(2tn)

    http://find/
  • 8/12/2019 Training Lat

    22/34

    Mathematical Equations

  • 8/12/2019 Training Lat

    23/34

    LA

    TEX is a very powerful tool for typesetting in general and for typesettingmath in particular. The main strength of LATEXconcerning typesetting ofmathematics is based on the package amsmath. Example:

    a=b+c (1)

    LATEX code for the above equation:

    \begin{equation}

    a = b + c

    \end{equation}

    Mathematical Equations

    http://find/
  • 8/12/2019 Training Lat

    24/34

    Writing multiple equations at one shot

    a=b+c (2) 0

    ex

    dx (3)

    LATEX code for the above equation:

    \begin{eqnarray}

    a = b + c \\

    \int_0^\infty \mathrm{e}^{-x}\,\mathrm{d}x\end{eqnarray}

    Mathematical Equations

    http://find/
  • 8/12/2019 Training Lat

    25/34

    Splitting equations

    A=

    r2

    2

    =1

    2r2

    = 0.5r2

    (4)

    LATEX code for the above equation:

    \begin{equation} \label{eq1}

    \begin{split}

    A = \frac{\pi r^2}{2} \\= \frac{1}{2} \pi r^2\\

    = 0.5 \pi r^2

    \end{split}

    \end{equation}

    Mathematical Equations

    http://find/
  • 8/12/2019 Training Lat

    26/34

    Aligning the previous equation

    A=

    r2

    2

    =1

    2r2

    = 0.5r2

    (5)

    LATEX code for the above equation:

    \begin{equation}

    \begin{split}

    A & = \frac{\pi r^2}{2} \\& = \frac{1}{2} \pi r^2 \\

    & = 0.5 \pi r^2

    \end{split}

    \end{equation}

    Mathematical Equations

    http://find/
  • 8/12/2019 Training Lat

    27/34

    Writing multi-line equation

    p(x) = 3x6 +14x5y+590x4y2 +19x3y312x2y412xy5 +2y6a3b3 (6)

    LA

    TEX code for the above equation:\begin{equation}

    p(x) = 3x^6 + 14x^5y + 590x^4y^2 + 19x^3y^3

    - 12x^2y^4 - 12xy^5 + 2y^6 - a^3b^3

    \end{equation}

    Mathematical Equations

    http://find/
  • 8/12/2019 Training Lat

    28/34

    Writing multi-line equation

    p(x) = 3x6 + 14x5y+ 590x4y2 + 19x3y3

    12x2y4 12xy5 + 2y6 a3b3 (7)

    LATEX code for the above equation:

    \begin{multline}

    p(x) = 3x^6 + 14x^5y + 590x^4y^2 + 19x^3y^3 \\

    - 12x^2y^4 - 12xy^5 + 2y^6 - a^3b^3\end{multline}

    Mathematical Equations

    http://find/
  • 8/12/2019 Training Lat

    29/34

    Aligning several equations

    2x5y = 8 (8)

    3x+ 9y =12 (9)

    LATEX code for the above equations:

    \begin{eqnarray}

    2x - 5y = 8 \\

    3x + 9y = -12

    \end{eqnarray}

    Mathematical Equations

    http://find/
  • 8/12/2019 Training Lat

    30/34

    Aligning several equations

    2x5y = 8 (10)

    3x+ 9y =12 (11)

    LATEX code for the above equation:

    \begin{align}

    2x - 5y &= 8 \\

    3x + 9y &= -12

    \end{align}

    Algorithm

    Writing algorithm in LATEX

    http://find/
  • 8/12/2019 Training Lat

    31/34

    Writing algorithm in LTEX

    LATEX has several packages for typesetting algorithms in form ofpseudocode. They provide stylistic enhancements over a uniform style(i.e., all in typewriter font) so that constructs such as loops or conditionalsare visually separated from other text.

    Algorithm

    http://find/
  • 8/12/2019 Training Lat

    32/34

    Algorithm 1: How to write algorithms

    Data: this textResult: how to write algorithm with LATEX2einitialization;1while not at end of this document do2

    read current;3if understand then4

    go to next section;5current section becomes this one;6

    else7

    go back to the beginning of current section;8

    Algorithm

    http://find/
  • 8/12/2019 Training Lat

    33/34

    \begin{algorithm}[H]

    \KwData{this text}

    \KwResult{how to write algorithm with \LaTeX2e }initialization\;

    \While{not at end of this document}{

    read current\;

    \eIf{understand}{

    go to next section\;current section becomes this one\;

    }{

    go back to the beginning of current section\;

    }

    }

    \caption{How to write algorithms}

    \end{algorithm}

    Algorithm

    http://find/
  • 8/12/2019 Training Lat

    34/34

    Thank

    You!

    http://find/