0% found this document useful (0 votes)
4 views

Lecture 5

Uploaded by

Srijani Goswami
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Lecture 5

Uploaded by

Srijani Goswami
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Technical document preparation with LaTeX?

With hands on experience

Kaushik Roy

West Bengal State University, Barasat


[email protected]

May 29, 2024

Kaushik Roy (WBSU) LaTeX May 29, 2024 1 / 17


Outline

1 Introduction to LATEX

2 Text formatting

3 Figure & Tables

4 Mathematics & Algorithm

5 Reference & Cross Reference

6 Advanced features of LATEX

7 Presentation using LATEX

8 Drawing Figures
Kaushik Roy (WBSU) LaTeX May 29, 2024 2 / 17
Symbols

• To use equation and other mathematical environments


mathematical symbols are needed.
• All mathematics must appear in maths mode
• For symbols to be used mathematical environment and names are
required.
• $$ is the mathematical environment
• \name, where name names the symbol
• \leq for ≤
• \pi for π
• \infty for ∞

Kaushik Roy (WBSU) LaTeX May 29, 2024 3 / 17


Math environment

The math environment may be specified, as with all environments, by

\beginmath
math equation
\endmath

However, it is used so often that it has two equivalent shorter forms:

\( math equation \) or just

$ math equation $

In LaTeX2e one can also use

\ensuremath{math equation}

Kaushik Roy (WBSU) LaTeX May 29, 2024 4 / 17


Inserting Equations & Mathematical Symbols

• If a mathematical expression appears in a line of normal text, use


a dollar symbol $ to start and to end the mathematics.

Kaushik Roy (WBSU) LaTeX May 29, 2024 5 / 17


Inserting Equations & Mathematical Symbols

• If a mathematical expression appears in a line of normal text, use


a dollar symbol $ to start and to end the mathematics.
• This ensures that the lines are kept as narrow as possible to avoid
LATEXhaving to change line spacing drastically.

Kaushik Roy (WBSU) LaTeX May 29, 2024 5 / 17


Inserting Equations & Mathematical Symbols

• If a mathematical expression appears in a line of normal text, use


a dollar symbol $ to start and to end the mathematics.
• This ensures that the lines are kept as narrow as possible to avoid
LATEXhaving to change line spacing drastically.

\documentclass{article}
\begin{document}
Sample symbol $ α $ is as a equation in text
\end{document}

Kaushik Roy (WBSU) LaTeX May 29, 2024 5 / 17


Inserting Equations & Mathematical Symbols

• If a mathematical expression appears in a line of normal text, use


a dollar symbol $ to start and to end the mathematics.
• This ensures that the lines are kept as narrow as possible to avoid
LATEXhaving to change line spacing drastically.

\documentclass{article}
\begin{document}
Sample symbol $ α $ is as a equation in text
\end{document}

Output
Sample symbol α is as a equation in text

Kaushik Roy (WBSU) LaTeX May 29, 2024 5 / 17


Equation
• Quite regularly, one needs equations with aligned equality signs.
The environment eqnarray is used for this.
• Separate lines using \\ and the left hand side, equality, and right
hand side of the equations using &.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Output
\begin{equation}
\label{tab:my label}
\begin{split} πr 2
A=
A & = \frac{\pi r2̂}{2} 2 (1)
& = \frac{1}{2} \pi r2̂ 1 2
= πr
\end{split} 2
\end{equation}
\end{document}
Kaushik Roy (WBSU) LaTeX May 29, 2024 6 / 17
Equation (contd.)

• Spacing is ignored in math mode – $x y$ gives the same result as


$xy$.
• If you need to escape from math mode to include normal text (eg
for the name of a function) use the command \mbox{text} (eg
$en̂+\mbox{fibonacci}(n+1)$)
• Never use math mode to emphasise text – because $different$
gives different , not different !

Kaushik Roy (WBSU) LaTeX May 29, 2024 7 / 17


Equation (contd.)
• Quite regularly, one needs equations with aligned equality signs.
The environment eqnarray is used for this.
• Separate lines using \\, and the left hand side, equality, and right
hand side of the equations using &.
\begin{eqnarray} a 0 &=& 1 \\ a {n+1} &=& 2\times a n
\end{eqnarray}

Output

a0 = 1 (2)
an+1 = 2 × an (3)

Output
Note that the equations are numbered. If you don’t want this feature,
use the eqnarray* environment instead
Kaushik Roy (WBSU) LaTeX May 29, 2024 8 / 17
Algorithm

To typeset algorithms or pseudocode in LATEXyou can use one of the


following options:
• Choose ONE of the (algpseudocode OR algcompatible OR
algorithmic) packages to typeset algorithm bodies, and the
algorithm package for captioning the algorithm.
• The algorithm2e package.

Kaushik Roy (WBSU) LaTeX May 29, 2024 9 / 17


Sample Algorithm

\documentclass{article}
\usepackage{algpseudocode}
\begin{algorithmic}
Output
\State $ i \gets 10$ i ← 10
\If{$i \geq 5$} if i ≥ 5 then
i ←i −1
\State $ i \gets i-1$
else
\Else \If{$i \lq 3$} if i ≤ 3 then
i ←i +2
\State $ i \gets i+2$ end if
\Endif end if
\Endif
\end{algorithmic}

Kaushik Roy (WBSU) LaTeX May 29, 2024 10 / 17


Another algorithm with Caption

Kaushik Roy (WBSU) LaTeX May 29, 2024 11 / 17


Algorithm with line number

1: i ← 10
2: if i ≥ 5 then
3: i ←i −1
4: else ▷ This is a comment
5: if i ≤ 3 then
6: i ←i +2
7: end if
8: end if

Kaushik Roy (WBSU) LaTeX May 29, 2024 12 / 17


Outline

1 Introduction to LATEX

2 Text formatting

3 Figure & Tables

4 Mathematics & Algorithm


Equation

5 Reference & Cross Reference

6 Advanced features of LATEX

7 Presentation using LATEX

8 Drawing Figures

Kaushik Roy (WBSU) LaTeX May 29, 2024 13 / 17


Outline

1 Introduction to LATEX

2 Text formatting

3 Figure & Tables

4 Mathematics & Algorithm


Equation

5 Reference & Cross Reference

6 Advanced features of LATEX

7 Presentation using LATEX

8 Drawing Figures

Kaushik Roy (WBSU) LaTeX May 29, 2024 14 / 17


Outline

1 Introduction to LATEX

2 Text formatting

3 Figure & Tables

4 Mathematics & Algorithm


Equation

5 Reference & Cross Reference

6 Advanced features of LATEX

7 Presentation using LATEX

8 Drawing Figures

Kaushik Roy (WBSU) LaTeX May 29, 2024 15 / 17


Outline

1 Introduction to LATEX

2 Text formatting

3 Figure & Tables

4 Mathematics & Algorithm


Equation

5 Reference & Cross Reference

6 Advanced features of LATEX

7 Presentation using LATEX

8 Drawing Figures

Kaushik Roy (WBSU) LaTeX May 29, 2024 16 / 17


Exercise

1 Show use of equation both in line and using equation number


2 show an example algorith

Kaushik Roy (WBSU) LaTeX May 29, 2024 17 / 17

You might also like