The document provides an overview of LaTeX, including its use for writing reports and documents, the compiling procedure, document structure using chapters, sections and paragraphs, basic LaTeX commands and formatting, and how to include mathematics, graphics, tables, and bibliographies. Key aspects covered include using the \documentclass command to specify the document type, compiling tex files into dvi or pdf formats, and dividing the document into logical components like chapters and sections using commands like \chapter and \section.
2. Introduction
Latex is used for writing reports , research papers, articles, books and general
purpose documents. Almost everything you can do in word can be accom-
plished using Latex. In the academic community Latex is used more often
than word and those who get used to it stick to it for life long. Unlike word,
the presentation of the document is explicitly specified using commands in
Latex. Most probably you would write your FYP reports in Latex. you can
also write your semester project reports in Latex.
Compiling Procedure
word documents have an extension of doc. Latex documents have an exten-
sion of tex. these tex files are processed by the latex processor (MikTex in
our case) and produces output with extension dvi . These DVI files are not
pdf files yet. These are converted into pdf using pdflatex. you can compile
using command line. Texmakaer provides a graphical interface so the editing
and compiling procedure is very smooth for writers. Texmaker also provides
a pdf viewer so the output can be viewed instantly.
Latex Document Structure
Just like a book is divided into chapters, sections and paragraphs, a latex
documents is divided into chapters, sections and paragraphs at the basic
level. sections can have sub sections.
Chapters
the chapter is inserted using chapter{} command. the argument to the
chapter command is the title of the chapter. the chapter command creates
a chapter with a title given in the argument and gives it a number. All the
subsequent chapters would have a number increased by one. there is a starred
version of the chapter command which gives the chapter a title but removes
the chapter number from it. A chapter remains in continuation until a new
chapter command is encountered where latex creates a new chapter. The
content of the chapter goes after the chapter command. A chapter can have
lists, tables, sections and other environments that are supported by latex. to
1
3. include mathematical content latex provides the math modes. math modes
are covered in the mathematics part of this booklet.
Sections
sections are inserted using section{} command. a section can have a sub-
section which can be inserted using subsection{} command. the argument
to the section is the title of the section. latex gives a number to the section
which is prefixed by the the number of the chapter to which it belongs, if
any. the content of the section comes after the section command. similar
to chapter command, starred version of the section command section*{}
exists as well which removed the section number.
Paragraphs
a paragraph can be inserted using paragraph{} command. a paragraph
can have its own styling. Normally content is added to the document without
specially using paragraph command
Latex Basics
document types
the top level command is latex is documentclass[]{}. it specifies the type
of the document. i.e. an article, report, book, paper, etc. there are two
arguments to it. the arguments in the square brackets are optional and those
in the curly brackets are mandatory. the mandatory argument is usually one
of
• article
• book
• report
in the optional argument the user specifies the font, size of paper, etc
2
4. preamble
the portion of the document between the documentclass[]{} and the
begin{document}end{document} is called the preamble of the document.
Here the style commands and the package import declarations are made. the
packages are imported(included) using usepackage[]{} command. we will
have more to say about it in the packages section.
commands format
LATEXcommands are case sensitive they are defined as:
• They start with a backslash and then have a name consisting of letters
only
• Many commands exist in a starred variant where a star is appended to
the command name
environments
begin{environment } content end{environment }
Where environment is the name of the environment. Environments can
be nested within each other as long as the correct nesting order is maintained.
begin{aaa}...begin{bbb}...end{bbb}...end{aaa}
spacing
latex by default ignores any white spaces. if two paragraphs in the text are
separated by a line, a line separates them in the output. a blank line can be
inserted using double backslash . the content appearing after would
appear in the next line. a new line can also be inserted using newline. a
new page can be inserted using newpage command.
text alignment
The environments flushleft and flushright generate paragraphs that are either
left- or right-aligned. The center environment generates centered text. If you
do not issue to specify line breaks, LATEXwill automatically determine line
breaks.
3
5. begin{flushleft}
This text is left-aligned.
LaTeX{} is not trying to make
each line the same length.
end{flushleft}
This text is
left-aligned. LATEX is not trying to make each line the same length.
begin{flushright}
This text is right-aligned.
LaTeX{} is not trying to make
each line the same length.
end{flushright}
This text is right-
aligned. LATEX is not trying to make each line the same length.
begin{center}
At the centerof the earth
end{center}
At the center
of the earth
special characters
the table below shows a few special characters commonly used
4
6. command meaning
LaTeX LATEX
slash /
~ ˜
$sim$ ∼
today May 12, 2015
ldots . . .
font styles
you can perform the following basic font styling in LATEX
command description
textbf{} bolds the content given in the argument
emph{} emphasizes the content in the argument
textit{} italicizes the content in the argument
text inside a box
you can place a text inside a box using the framed environment
begin{framed} end{framed}
for this you have to use the framed package
usepackage{framed}
footnotes
With the command footnote{footnote text } a footnote is printed at
the foot of the current page. the argument to the footnote command is the
footnote to be printed. Footnotes should always be put after the word or
sentence they refer to. Footnotes referring to a sentence or part of it should
therefore be put after the comma or period
Footnotesfootnote{This is
a footnote.} are often used
by people using LaTeX.
5
7. Footnotes1
are often used by people using LATEX.
Verbatim
Text that is enclosed between begin{verbatim} and end{verbatim} will
be directly printed with all line breaks and spaces, without any LATEXcommand
being executed. Within a paragraph, similar behavior can be accessed with
verb+text+ .The + is just an example of a delimiter character. Use any
character except letters, * or space
Quotations
Quotations can be inserted using the quote environment
. begin{quote} quotation text end{quote}
begin{quote}
begin{center}
War is like opening the door of a dark room. You font know what lies inside
end{center}
end{quote}
War is like opening the door of a dark room. You font know
what lies inside
Packages
packages are used to enhance the features and capabilities of LATEX. packages
are included in a latex document using the usepackage{} command. the
name of the package goes into the argument of the usepackage command. the
usepackage command in included in the preamble portion of the document.
Lists
lists in latex are defined by itemize and enumerate environments.
6
8. begin{itemize}
list items come here
end{itemize}
begin{enumerate}
list items come here
end{enumerate}
itemized lists are not numbered. each list element in an itemized list is
added into a billeted list. we can use a character of our own choice instead of
bullets .enumerated lists are numbered lists. each list item is specified using
list command. the content of a list item goes after the list command
begin{itemize}
item Digital Signal Processing
item Power Electronics
item Power System Analysis
item High Voltage Engineering
item Microwave Engineering
end{itemize}
• Digital Signal Processing
• Power Electronics
• Power System Analysis
• High Voltage Engineering
• Microwave Engineering
7
9. begin{enumerate}
item Digital Signal Processing
item Power Electronics
item Power System Analysis
item High Voltage Engineering
item Microwave Engineering
end{enumerate}
1. Digital Signal Processing
2. Power Electronics
3. Power System Analysis
4. High Voltage Engineering
5. Microwave Engineering
A List can be nested inside another list
begin{itemize}
item Digital Signal Processing
begin{itemize}
item an introductory course in signal processing
item signals and systems , control system and probability are pre-requisites
end{itemize}
item Microwave engineering
begin{enumerate}
item Electromagnetic theory is pre-requisite.
item offered only to telecom specialization students
end{enumerate}
end{itemize}
8
10. • Digital Signal Processing
– an introductory course in signal processing
– signals and systems , control system and probability are pre-
requisites
• Microwave engineering
1. Electromagnetic theory is pre-requisite.
2. offered only to telecom specialization students
Tables
Tables are inserted using the tabular environment.
begin{tabular}{}
end{tabular}
the structure of the table is defined in the arguments to the tabular en-
vironment. the content of the table goes inside the tabular environment. a
column can be inserted in a table by adding l,r or c in the arguments which
that the contents of the table would be either left justified, right justified or
center justified. a table by default has only one row. a new row is inserted
by . in a row the contents are specified starting form the first column. to
move to the next column use & .
there are no row and column margins in a table by default. to insert
a column margin use — in the column definitions in the argument of the
tabular environment. To insert row margins use the hline command.
Country independence
Pakistan 1947
India 1947
China 1948
UAE 1971
9
11. Mathematics in Latex
Mathematics in latex can be inserted in two ways
• inline math mode
it is used when a mathematical content is part of paragraph. it begins
with $ sign and ends with a $ sign. all the content goes between the
the square brackets
• display math mode
it is used for mathematics rich content. it begins with [ and ends
with ] . all the content goes between the the square brackets
• equation environment
a mathematics content can also go into the equation environment
begin{equation} content here end{equation}
Examples
begin{equation}
lim_{n to infty}
sum_{k=1}^n frac{1}{k^2}
= frac{pi^2}{6}
end{equation}
lim
n→∞
n
k=1
1
k2
=
π2
6
begin{equation*}
|x| = left{
begin{array}{rl}
-x & text{if } x < 0,
0 & text{if } x = 0,
x & text{if } x > 0.
end{array} right.
10
12. end{equation*}
|x| =
−x if x < 0,
0 if x = 0,
x if x > 0.
Add $a$ squared and $b$ squared
to get $c$ squared. Or, using
a more mathematical approach
begin{equation}
a^2 + b^2 = c^2
end{equation}
Einstein says
begin{equation}
E = mc^2 label{clever}
end{equation
Add a squared and b squared to get c squared. Or, using a more
mathematical approach
a2
+ b2
= c2
(1)
Einstein says
E = mc2
(2)
in the equation environment note that the equations are numbered.
to avoid numbering of equations use starred equation environment
begin{equation*} equation comes here end{equation*}
Including Graphics
to include graphics, you have to use graphicx package. usepackage{graphicx}
11
13. to include graphics in your document use the includegraphics[]{} com-
mand. the mandatory argument to this command is the name of the picture
you wan to use in your document. the optional arguments specify the size
of the picture. the type of the picture must be EPS, PDF, JPG or PNG.
the file must be located in the same directory as the tex file including the
picture.
optional arguments to a includegraphics[]{} command can be
• width
• height
• scale
• angle
includegraphics[scale = 4]{uetlogo}
Case Studies
Report
Resume
Adding a Bibliography
References are one of the most important sections of a document. an author
is required to mentioned the source of the information to avoid plagiarism.
references are also necessary to avoid any copyrights violation. References in
latex can be separated into a re fences database. the references are stored in
a special file with an extension .bib. This file would be processed by BibTex,
Latex for bibliography management.
inside the bibliography database, each reference is mentioned separately
which can be referenced into the main document using a citation key. cita-
tions are made using cite{} command. the argument to the cite command
is the citation key of the reference. citation keys must be unique.
12
14. In the main text document you specify a bibliography using bibliographystyle{}
and bibliography{} commands. Since there can be more than one bibli-
ography databases, the argument to the bibliography command must be the
name of the bibliography database being referenced. after that the entries
inside the bibliography database can be referenced using cite command
13
15. Bibliography
[1] John F. Wakerly. Digital Design, Principles and Practices. Pearson, 2010.
[2] John F. Wakerly. Digital Design, Principles and Practices. Pearson, 2010.
[3] John F. Wakerly. Digital Design, Principles and Practices. Pearson, 2010.
[1] [2] [3]
14