Latex Introduction
Latex Introduction
LATEX
LATEX, pronounced ”Lah-tech” or ”Lay-tech,” is built on the TeX typesetting system created
by Donald Knuth. LaTeX emerged in the early 1980s as a user-friendly extension of Donald
Knuth’s complex TeX typesetting system. Created by Leslie Lamport, LaTeX aimed to sim-
plify the process of creating professional-quality documents, especially those demanding
intricate formatting like mathematical equations or scientific notations. Its ability to han-
dle complex layouts and produce high-quality output has made it a popular choice among
academics, scientists, and engineers. As an open-source project, LaTeX continues to evolve
with new features and improvements, solidifying its position as a leading tool for document
creation.
LaTeX is a powerful tool for crafting sophisticated documents, going beyond the capabil-
ities of ordinary word processors. It’s designed for those who demand precise control over
every aspect of their text, from the simplest paragraph to the most intricate mathematical
equation or complex table.
It’s used to create professional-looking documents, especially those with lots of num-
bers, equations, or complicated layouts. Instead of clicking buttons to format text, you
use special codes to tell the computer how you want the document to look. It’s like giving
instructions to a robot designer to create a beautiful document.
Document Structure
In LaTeX, the preamble is the section of the document that comes before the
‘\begin{document}‘ command. It is where the document class is specified, along with
any packages, commands, or settings that are needed to customize the document’s ap-
pearance or behavior.
The preamble typically includes commands that define the document’s overall structure,
such as the title, author, and date, as well as any formatting options, such as font size,
margins, and line spacing. It may also include custom commands or macros that simplify
the process of formatting or entering content.
The preamble is an important part of a LATEXdocument, as it sets the stage for the rest
of the content. It allows the user to customize the document’s appearance and behavior
to suit their needs, and provides a centralized location for managing these settings. The
preamble allows us to set up the document’s overall structure, appearance, and additional
functionality before the main content of the document begins. It plays a crucial role in
defining the document’s characteristics and appearance.
• Creating a Title: The title, author, and date of the document are set using commands
such as ‘\title‘, ’\author‘, and ‘\date‘. The ‘\maketitle‘ command is then
used to generate the title page with the provided information.
Page 1
MMSE101A:LATEX UNACCO COLLEGE
• **Chapters and Sections**: LATEXallows for the hierarchical organization of content into
chapters, sections, subsections, and subsubsections using commands like ‘\chapter‘,
‘\section‘, ‘\subsection‘, and ‘\subsubsection‘. This aids in structuring the
document and creating a clear hierarchy of information.
• **List and Table of Contents**: Lists and tables of contents can be automatically
generated using commands like ‘\tableofcontents‘ and various list environments.
This feature simplifies the management of document structure and navigation.
Text Formatting
LaTeX typically uses a standard font size of 12pt for regular text, which is standard for
technical documents. However, chapter numbers and titles, sections, subsections, and
subsubsections have default font sizes of 16, 14, 13, and 12, respectively. In certain
situations, you might need different font sizes for regular text. However, in normal text,
different font sizes are required, the following table provides a set of commands.
Page 2
MMSE101A:LATEX UNACCO COLLEGE
Page 3
MMSE101A:LATEX UNACCO COLLEGE
LATEX, by default, uses black color for text. To change the color of specific text, we can add
an extra package \usepackage{color} in the Preamble.
Page 4
MMSE101A:LATEX UNACCO COLLEGE
\begin{enumerate}
\item Introduction
\begin{enumerate}
\item Calculus
\item Algebra
\end{enumerate}
\item Skill Enhancement Course
\begin{itemize}
\item Article class
\item Book class
\end{itemize}
\item AECC
\begin{itemize}
\item [+] Bachelor of Arts
\item [+] Bachelor of Science
\begin{itemize}
\item[-] Mathematics
\item[-] Computer Science
\item[-] Physics
\end{itemize}
\end{itemize}
\item First Semester
\end{enumerate}
1. Introduction
(a) Calculus
(b) Algebra
• Article class
• Book class
3. AECC
+ Bachelor of Arts
+ Bachelor of Science
- Mathematics
- Computer Science
- Physics
4. First Semester
Page 5
MMSE101A:LATEX UNACCO COLLEGE
The Einstein’s general theory of relativity nullified the concept of Newtons’s law of universal
gravitation.
Horizontal Spacing
In LATEX, multiple consecutive spaces are treated as single space. In order to intention-
ally give a space, this symbol ”˜” is to be used as ”absolutely˜˜˜˜˜˜free” will generate
”absolutely free”.
Vertical Spacing
Several empty lines are treated as on empty line in LATEX. Double ”Enter” is required to
start a new paragraph. for a specified vertical space, the \vspace{} command is used. For
example, the following sentence
Newtons’s law of universal gravitation. This never mean that Newton’s \vspace{1in}
calculations were wrong but the concept of gravity was not right.
will produce
The Einstein’s general theory of relativity nullified the concept of Newtons’s law of universal
gravitation. This never mean that Newton’s calculations were wrong but the concept of
Line Spacing
The setspace package simplifies the process of adjusting line spacing in LaTeX documents.
It provides commands and options to set different spacing values, such as singlespacing,
one-and-a-half spacing, and doublespacing.
To use the setspace package, we need to include it in the preamble of our LaTeX
document. The preamble is the section before \begin{document} where we set up the
overall formatting and configuration of the document. The package provides options for
different line spacing settings:
In LATEX, \hfill is like a flexible space command used to spread content horizontally. It’s
often used to push elements apart within a line. For example, if you want something on the
left and something else on the right, \hfill fills the space between them evenly. Another
command, \vfill is a way to spread things out vertically. It helps to create space between
elements, pushing them to the top and bottom of the available area.
Page 6
MMSE101A:LATEX UNACCO COLLEGE
Some of the symbols are reserved characters in LATEX. In order to insert these symbols,
the following format is to be followed:
Input Output
‘Mathematics’ ‘Mathematics’
‘‘Mathematics" “Mathematics”
Mathematics’s Mathematics’s
,,Mathematics" ,,Mathematics”
minus $-1$ −1
$ \$ $
% \% %
# \# #
ˆ \ˆ{} ˆ
{} \{\} {}
˜ \˜{} ˜
\ \textbackslash \
Page 7
MMSE101A:LATEX UNACCO COLLEGE
Table
In LATEX, tables are a useful way to organize and present information. Tables in LATEX are
typically created using the table and tabular environments. To insert a table, a command
environment begin{tabular}{....} and \end{tabular} is used.
• Inside the curly brackets {....}, “l”, “r” and “c” are used for left, right and centered
aligned texts, respectively. For example {lll} produce 3 columns with left aligned
text.
• {lcrl} produces 4 column with left-, centered-, right- and left-aligned texts.
• Vertical line in the table is inserted by “|”, while horizontal line by the command
\hline.
• To join two columns, the command \cline{1-2} inserts a partial horizontal line
between column 1 and column 2.
Example
The following command
\begin{tabular}{lcr}
10&2& 3 \\
100&4& 9 \\
10000&16& 81 \\
100000000&256& 6561 \\
10000000000000000&65536& 43046721 \\
\end{tabular}
will produce the table as follows.
10 2 3
100 4 9
10000 16 81
Page 8
MMSE101A:LATEX UNACCO COLLEGE
1 & 16 & 81 \\
1 & 256 & 6561 \\
1 & 65536 & 43046721 \\
\hline
\end{tabular}
\end{table}
will produce the table
1 2 3
1 4 9
1 16 81
1 256 6561
1 65536 43046721
1 2 3
1 4 9
1 16 81
1 256 6561
1 65536 43046721
Page 9
MMSE101A:LATEX UNACCO COLLEGE
• ‘alignment’: Specifies the alignment of the content within the merged cell (c for cen-
ter, l for left, r for right).
Example
\begin{tabular}{|p{3cm}|p{3cm}|p{3cm}|}
\hline
\multicolumn{3}{c}{Mathematics} \\
\hline
\textbf{First Name} & \textbf{Last Name} & \textbf{Roll No} \\
\hline
Redeemson & Gangmei & UC/23/73 \\
\hline
Phurailatpham & Guiness Sharma & UC/23/74 \\
\hline
Micheal Vashkher & Thingbaijam & UC/23/75 \\
\hline
Lisham & Michael Singh & UC/23/76
\end{tabular}
Mathematics
The \multirow command in LATEXis used to merge cells vertically in a table. We need
to include \usepackage{multirow} to used the \multirow in LATEX. It is especially use-
ful when we want to create a table with cells spanning multiple rows. The syntax for
\multirow is as follows:
\multirow{number_of_row}{width}{content}
• width: Specifies the width of the cell. We can use ‘*’ for automated width.
Page 10
MMSE101A:LATEX UNACCO COLLEGE
Example
\begin{tabular}{|c|c|c|}
\hline
a & b & c \\
\hline
\multirow{2}{4em}{ABC} & B & C\\
\cline{2-3}
& d & e \\ \hline
f & g & h \\
\hline
\end{tabular}
Output
a b c
B C
ABC
d e
f g h
Positioning of Table
To specify the position of a table in LATEX, you use the table environment along with
placement parameters. One common parameter is h!. Additional parameters include:
So,h! essentially means ”here, and if that’s not possible, do the best you can.” Adjust these
parameters based on our preferences and document layout.
\begin{equation}
y=mx+c
\end{equation}
Page 11
MMSE101A:LATEX UNACCO COLLEGE
y = mx + c
2
ax + bx + c = 0
√
−b ± b2 − 4ac
x=
2a
Page 12
MMSE101A:LATEX UNACCO COLLEGE
Symbols
To starts with mathematics, the command \usepackage{amsmath}, \usepackage{amssymb},
and \usepackage{gensymb} are to be inserted in the Preamble. Some of the commands
like +, -, = ! / () [] : etc. can be directly entered through keypad, while most of the
symbols are inserted through commands.
Mathematical Symbols
Some of the common mathematical symbols are shown in the table below:
Table 5: List of familiar mathematical symbols, which are to be enclosed in math-mode i.e.
$ $.
≃, ∼
= \simeq, \cong ∥, ∦ \parallel, \nparallel
⊕, ⊖ \oplus, \ominus ∈, ∈
/ \in, \notin
Tex-mode Equivalence
Some of the symbols can be written without math-mode. Table below shows the text-mode
equivalence of some symbols.
| $|$ \textbar
– $-$ \textendash
— $-$ \textemdash
† $\dagger$ \dag
‡ $\ddagger$ \ddag
Page 13
MMSE101A:LATEX UNACCO COLLEGE
â $\hat{a}$ \ˆa
ã $\tilde{a}$ \˜a
ȧ $\dot{a}$ \.a
ä $\ddot{a}$ \"a
ā $\bar{a}$ \=a
a2 $aˆ2$ a\textsuperscript 2
a2 $a_2$ a\textsubscript 2
Greek Letters
Some of the Greek letters ans their respective commands are shown in the table below:
Page 14
MMSE101A:LATEX UNACCO COLLEGE
Roots
Square root symbols are inserted using the command \sqrt{} as $\sqrt{x}$ produces
√
x.For the specfication of magnitude, the command is used with optional square brackets
as $$\sqrt[y]{x}$$ produces √y
x
.
Page 15
MMSE101A:LATEX UNACCO COLLEGE
However, if the same is written in-line $\prod_{n=1}ˆ{3}xˆn$ it will look like 3n=1 xn then
Q
the in-line look can be changed by using the command $\displaystyle\prod_{n=1}ˆ{3}xˆn$
Y 3
produces xn
n=1
In case of integration, the command $$\int f(x)$$ produces
Z
f (x)
To write the limits above the integral, the code is to be changed as $$\int\limits_aˆb f(x)$$
produce
Zb
f (x)
a
For a close loop integral, the code $$\oint f(x)$$ produces
I
f (x)
For double and triple integrals, the codes $$\iint f(x)$$ and $$\iiint f(x)$$ pro-
duces ZZ
f (x)
ZZZ
f (x)
Matrices
A basic matrix can be created using the matrix environment, which is just like a table en-
vironment. For example, to start with simple matrix, the following command is used
\begin{matrix}
a & b & c \\
d & e & f \\
g & h & i \\
\end{matrix}
will produce
a b c
d e f
g h i
In order to enclosed the matrix in brackets, the following environment is used.
Page 16
MMSE101A:LATEX UNACCO COLLEGE
\begin{pmatrix}
a & b & c \\
d & e & f \\
g & h & i \\
\end{pmatrix}
will produce
a b c
d e f
g h i
This way, to enclosed in square bracket [ ] bmatrix, for curli bracket {} \Bmatrix, and
for vertical lines as in a determinant || vmatrix are used.
Array Environment
The LATEX array environment is used frequently to create tables in LATEX documents and
serves the purpose for the presentation of structured data. Data can be arranged into
rows, columns, and cells with this feature, which also offers customization choices for
height, width, alignment, and padding. When the array environment is used properly, it
may provide visually pleasing and well-organized tables that are appropriate for a variety of
information, such as tables, statistical data, and equations.The basic syntax is as follows:
$$
\begin{array}{|c|c|c|}
\hline
\text{First column} & \text{Second column} & \text{Third column} \\
\hline
& & \\
\hline
\end{array}
$$
This is like eqnarray but with flexible rows and columns. It has one equation num-
ber for the entire formula and must be nested within another math environment, such
as equation or displaymath. An example of using the array environment within the
equation environment to create a system of equations:
2x + 3y − z = 5
−3x + 4y + 2z = −7 (8)
x − y + 3z = 10
LATEX provides different tools to write cases and piecewise functions. The array environment
can be used to produce arrays of cases, while the cases environment is more user-friendly
Page 17
MMSE101A:LATEX UNACCO COLLEGE
and can be used in other situations. The amsmath and amssymb packages are required for
these tools.The array environment can be used to typeset a definition by cases. for example
writing the below code
\begin{equation}
Y(i,k) =
\left\lbrace
\begin{array}{lr}
||R_{k}-R_{i}||ˆ{2}, & \text{if } i \neq k\\
||\triangle_{i}||ˆ{2}, & \text{if } i\leq k
\end{array}
\end{equation}
will produce
||Rk − Ri ||2 , if i ̸= k
Y (i, k) =
||△i ||2 , if i ≤ k
This array environment is very useful and flexible, is not the easiest way to produce this
kind of case situation. As it is usual, the amsmath package provides an easier and more
user-friendly way to typeset piecewise-defined functions, that can also be used in other
situations. Writing the simple code
\begin{equation*}
\chi_{\mathbb{Q}}(x)=
\begin{cases}
1 & \text{if } x \in \mathbb{Q}\\
0 & \text{if } x \in \mathbb{R}\setminus\mathbb{Q}
\end{cases}
\end{equation*}
will produce
1 if x ∈ Q
χQ (x) =
0 if x ∈ R \ Q
Ellipsis
Mathematical equations and textual contents sometimes contain a row of dots (· · ·). These
dots’ meaning together is “ and so on”. These three dots refer to ellipsis points. Ellipses are
exactly three dots, not less or more. In LATEX, if we would only type a period (.) three times
in a row, it will generate undesirable results such as . . . , In the output, those dots are too
close together. LATEX provides several commands to space the Ellipses correctly:
Page 18
MMSE101A:LATEX UNACCO COLLEGE
Examples
A low ellipsis: $x_1, x_2, \ldots, x_n$
A centered ellipsis: $a_1, a_2, \cdots, a_n$
compiling these codes yield
A low ellipsis: x1 , x2 , . . . , xn
A centered ellipsis: a1 , a2 , · · · , an
The command \ldots is usable both in text and math mode; the remaining three kinds
of ellipsis are only allowed in math mode.
3. Changing Symbols:
• Use specific commands for symbols, e.g., ‘\mathbb{}‘ for blackboard bold,
‘\mathcal{}‘ for calligraphy, ‘\mathfrak{}‘ for Fraktur, etc.
• Example:Giving the command \(\mathbb{R}\), \(\mathcal{ABC}\),
\(\mathfrak{abc}\) will produce R, ABC, abc
4. Coloring Text:
• Use different math environments for specific styles, such as ‘align‘, ‘eqnarray‘,
or ‘cases‘.
• Example:
f (x) = x2 (9)
√
g(x) = x (10)
Remember to use these commands and environments appropriately within math mode
‘$ ... $‘ for in-line math, or ‘\[ ... \]‘ for display math).
Page 19
MMSE101A:LATEX UNACCO COLLEGE
Footnote
In LATEX, footnotes are used to provide additional information or comments at the bottom
of a page. They are typically used to explain, elaborate, or cite sources for specific points
in the main text. Here’s a simple explanation of how footnotes work in LATEX:
In LATEX, we can insert a footnote using the \footnote{} command. The content we
want to appear as a footnote goes inside the curly braces. Here’s a basic example:
\documentclass{article}
\begin{document}
This is some text with a footnote.\footnote{This is a footnote with
additional information.}
\end{document}
will give the following output This is some text with a footnote.1 See the lower part of the
this page we will see what we have written inside the curly brackets.
1
This is a footnote with additional information.
Page 20