You are on page 1of 34

Sectioning, Listing, Mathematical Equations, and

Algorithms in L
A
T
E
X
Soubhagya Sankar Barpanda
(PhD. Scholar)
Dept. of CSE
Department of Computer Science and Engineering
National Institute of Technology Rourkela
Table of Contents
1 Section
2
List
3 Mathematical Symbols
4 Mathematical Equations
5 Algorithm
Section
Introduction
L
A
T
E
X provides seven levels of division or sectioning to be used in
structuring text.
All document divisions get numbered automatically. Parts get Roman
numerals (Part I, Part II, etc.); chapters and sections get decimal
numbering, and Appendices are lettered (A, B, C, etc.).
Section
Paragraphs in L
A
T
E
X are usually fully justied, i.e. ush with both the left
and right margins. By default, the rst paragraph after a heading follows
the standard Anglo-American publishers practice of no indentation.
\paragraph{} can be used to create a paragraph in document.
Section
Table: Dierent 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
Section
\section{New recruitment policies}
...
\subsection{Effect on staff turnover}
...
\subsubsection{Business plan 2005--2007}
List
Lists in L
A
T
E
X
Lists are useful tools for arranging thoughts in small piece of information
at a time.
Within a list environment, list items are always identied by the command
\item
List
Dierent types of lists
Random or arbitrary lists
Enumerated or sequential lists
Descriptive or labeled lists
Inline lists
List
Example of Arbitrary lists
A
B
C
List
\begin{itemize}
\item A
\item B
\item C
\end{itemize}
List
Example of Enumerated lists
1
A
2
B
3
C
List
\begin{enumerate}
\item A
\item B
\item C
\end{enumerate}
List
Example of Description lists
A: This is rst description
B: This is second description
C: This is third description
List
\begin{description}
\item[ A: ] This is first description
\item[ B: ] This is second description
\item[ C: ] This is third description
\end{description}
List
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; and
c) usually have the nal item prexed 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
Nested lists
1
The rst item
1 Nested item 1
2 Nested item 2
2
The second item
3
The third etc . . .
List
\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
Lists with use-dened characters
a. The rst item
b. The second item
c. The third etc . . .
I. The rst item
II. The second item
III. The third etc . . .
List
Lists with use-dened characters
\begin{enumerate}[a.]
\item The first item
\item The second item
\item The third etc \ldots
\end{enumerate}
Mathematical Symbols
Mathematical Symbols
One of the greatest motivating forces behind development L
A
T
E
X system
was to create something that allowed simple construction of mathematical
formulas, while professional look is ensured when printed.
Mathematics has many symbols! One of the most dicult aspects of
learning L
A
T
E
X is remembering how to produce symbols. There are of
course a set of symbols that can be accessed directly from the keyboard:
+, -, =, !, /, ( ), [ ], < >, |, , :
Mathematical Symbols
L
A
T
E
X needs to know beforehand that the subsequent text does indeed
contain mathematical elements. This is because L
A
T
E
X typesets maths
notation dierently from normal text. Therefore, special environments
have been declared for this purpose. They can be distinguished into two
categories depending on how they are presented:
1
text formulas are displayed inline, that is, within the body of text
where it is declared, for example, I can say that a + a = 2a within this
sentence.
2
displayed formulas are separate from the main text. Ex. The scaling
function is given by:
(t) =
2
|H
0
()|
=0

n
h
0
(n)(2t n)
Mathematical Symbols
The scaling function is given by:\\
$\phi(t)=\frac{2}{|H_0(\omega)|_{\omega=0}}\sum_{n}h_0(n)
\phi(2t-n)$
Mathematical Equations
L
A
T
E
X is a very powerful tool for typesetting in general and for typesetting
math in particular. The main strength of L
A
T
E
Xconcerning typesetting of
mathematics is based on the package amsmath. Example:
a = b + c (1)
L
A
T
E
X code for the above equation:
\begin{equation}
a = b + c
\end{equation}
Mathematical Equations
Writing multiple equations at one shot
a = b + c (2)


0
e
x
dx (3)
L
A
T
E
X code for the above equation:
\begin{eqnarray}
a = b + c \\
\int_0^\infty \mathrm{e}^{-x}\,\mathrm{d}x
\end{eqnarray}
Mathematical Equations
Splitting equations
A =
r
2
2
=
1
2
r
2
= 0.5r
2
(4)
L
A
T
E
X 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
Aligning the previous equation
A =
r
2
2
=
1
2
r
2
= 0.5r
2
(5)
L
A
T
E
X 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
Writing multi-line equation
p(x) = 3x
6
+14x
5
y +590x
4
y
2
+19x
3
y
3
12x
2
y
4
12xy
5
+2y
6
a
3
b
3
(6)
L
A
T
E
X 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
Writing multi-line equation
p(x) = 3x
6
+ 14x
5
y + 590x
4
y
2
+ 19x
3
y
3
12x
2
y
4
12xy
5
+ 2y
6
a
3
b
3
(7)
L
A
T
E
X 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
Aligning several equations
2x 5y = 8 (8)
3x + 9y = 12 (9)
L
A
T
E
X code for the above equations:
\begin{eqnarray}
2x - 5y = 8 \\
3x + 9y = -12
\end{eqnarray}
Mathematical Equations
Aligning several equations
2x 5y = 8 (10)
3x + 9y = 12 (11)
L
A
T
E
X code for the above equation:
\begin{align}
2x - 5y &= 8 \\
3x + 9y &= -12
\end{align}
Algorithm
Writing algorithm in L
A
T
E
X
L
A
T
E
X has several packages for typesetting algorithms in form of
pseudocode. They provide stylistic enhancements over a uniform style
(i.e., all in typewriter font) so that constructs such as loops or conditionals
are visually separated from other text.
Algorithm
Algorithm 1: How to write algorithms
Data: this text
Result: how to write algorithm with L
A
T
E
X2e
initialization; 1
while not at end of this document do 2
read current; 3
if understand then 4
go to next section; 5
current section becomes this one; 6
else 7
go back to the beginning of current section; 8
Algorithm
\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
T
h
a
n
k
Y
o
u
!

You might also like