LaTeX Tutorial Book
LaTeX Tutorial Book
1 Introduction 9
1.1 LATEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.2 Why to learn LATEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.3 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.4 Post-Installation Configurations . . . . . . . . . . . . . . . . . . . . . . . 12
2 Document Structure 13
2.1 Start a new Document . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.2 Creating a Title . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.3 Chapters and Sections . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2.4 List and Table of Contents . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.5 Page Numbering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3 Text Formatting 19
3.1 Font Sizes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.2 Font Effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.3 Font Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.4 Numbered or Bulleted Lists . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.5 Comments and Spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.5.1 Horizontal Spacing . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.5.2 Vertical Spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.5.3 Line Spacing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.6 Quotation Marks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.7 Dashes and Hyphens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.8 Special Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.9 Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4 Tables 27
4.1 Simple Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.2 Complex Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3
4 CONTENTS
5 Figures 37
7 Presentation-Beamer 55
7.1 Beamer introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
7.2 Title slide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
7.3 Customized Title Page . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
7.4 General slide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
7.5 Table of Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
7.6 Sections and Subsections . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
7.7 Themes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
7.7.1 Inner Themes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
7.8 Text in boxes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
7.9 Overlays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
7.9.1 Pause Command . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
7.9.2 Pointed Brackets Command . . . . . . . . . . . . . . . . . . . . . 66
7.9.3 Special Commands . . . . . . . . . . . . . . . . . . . . . . . . . . 67
7.10 Column, Spaces and Alignments . . . . . . . . . . . . . . . . . . . . . . . 67
7.11 Smart Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
8 Chemistry 73
8.1 Bond angles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
8.2 Editing bonds and angles . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
8.3 Ring structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
8.4 Lewis structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
8.5 Chemical reaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
CONTENTS 5
9 Nomenclature 79
9.1 List of Abbreviations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
10 Customization of LATEX 83
10.1 Changing the default names . . . . . . . . . . . . . . . . . . . . . . . . . 83
10.2 Changing the default style . . . . . . . . . . . . . . . . . . . . . . . . . . 83
10.3 New commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
11 References 87
11.1 Inserting a Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
11.1.1 Editing a Reference . . . . . . . . . . . . . . . . . . . . . . . . . . 89
11.2 Customized reference style . . . . . . . . . . . . . . . . . . . . . . . . . . 90
6 CONTENTS
Preface
7
8 CONTENTS
Chapter 1
Introduction
1.1 LATEX
• Pronounced as Lah-tech or Lay-tech, is based on TEX developed by Leslie Lamport
• Not a word processor i.e. ‘What You See Is What You Get’ (WYSIWYG), its
document is a plain text file (*.tex)
9
10 CHAPTER 1. INTRODUCTION
1.3 Installation
The following guidelines for installation contain step-by-step instructions for instal-
lation. The file “Latex full set up.rar” contains the following file and folder, which
can be extracted by using Winrar software;
1. Open the folder “MikTeX 2.9 32 bit” that contains the following folder and
file
– MikTeX 2.9 32 bit (folder)
– Setup-2.9.4250 (file)
2. Copy the folder ”MikTeX 2.9 32 bit” and paste it in “C:\Program Files (x86)”
3. Run the file “setup-2.9.4250” to install
4. Accept MikTeX copying condition and click Next
5. Select option “Install MikTeX” and click Next
6. Select option “Complete MikTeX” and click Next
1.3. INSTALLATION 11
7. Select option “anyone who uses this computer” and click Next
8. Click “Browse” to select the location “C:\Program Files (x86)\MikTeX 2.9 32
bit and click Next and Next
9. Leave “Preferred paper as A4” and on the option “Install missing packages
on-the-fly” click “Yes” click Next
10. Click “Start”
11. It will take around 10 to 30 min (depending on the computer speed) to install
12. After installation the main task, click Next and “Close”
13. Now for TeXmaker installation, click the file “texmakerwin32-install” in the
folder
14. Click “I agree” to start the installation
15. By default, the installation directory “C:\Program Files (x86)\Texmaker will
be selected, click “Install”
12 CHAPTER 1. INTRODUCTION
4. Under the “Editor” confirm that all the following options are ticked (as shown in
red enclosure in Figure 1.3).
Figure 1.3: Under the “Editor” all these options must be ticked
Chapter 2
Document Structure
Click on “File” and select “New”. An untitled document will open. Save this document
in a Folder as *.tex document. Saving in a Folder is must as it will save some other
documents too in this Folder. Further, everything related to this document are supposed
to be saved in this Folder as well. Write the following command code in the input section;
\documentclass[a4paper,12pt]{book}
\begin{document}
This is my first sentence in LaTeX.
\end{document}
In TeXStudio, the command code will look like as shown in Figure 2.2.
Click on the double green play button (or F5) to generate a PDF output. This PDF
file is automatically saved in the same folder in which the *.tex document is saved earlier.
The above command will generate the output pdf file as shown in Figure 2.3.
13
14 CHAPTER 2. DOCUMENT STRUCTURE
In order to designate a chapter, section or subsection and not to number it, the “*” after
the corresponding headings i.e. \chapter*{}, \section*{} and \subsection*{} etc. is
to be used. The following command;
\chapter{Introduction}
This is the Introduction chapter.
\section{General Aims}
This is the first section of Introduction.
\subsection{Objectives}
This is the subsection in the Introduction chapter.
\subsubsection{Research Outline}
This is the subsubsection in the Introduction chapter.
Figure 2.5: Output of the chapter, section, subsection and subsubsection command.
\pagenumbering{roman}
\tableofcontents
2.5. PAGE NUMBERING 17
\newpage
\pagenumbering{arabic}
The above command will insert page numbers as “roman” for the “Table of Contents”
and “Arabic” afterwards. For changing the style of page numbering, new page must be
started before new type of numbering by the command \newpage.
18 CHAPTER 2. DOCUMENT STRUCTURE
Chapter 3
Text Formatting
Table 3.1: For different font sizes, the following commands are used.
19
20 CHAPTER 3. TEXT FORMATTING
In a technical document,usually no text font effects are applied. However, the two very
common font effects i.e. bold and italic are sometimes applied. The following Table 3.2
provides a set of commands for such reformatting
Table 3.2: For different font effects, the following commands are used.
Note: The “bold” and “italic” commands can also be directly executed by selecting
a word and pressing ctrl+b and ctrl+i, respectively, as normally executed in MS Word
through keyboard shortcuts.
LaTeX uses black color as default for writing. To change color of a certain text, an extra
package \usepackage{color} is to be added in the Preamble. Different color commands
are shown in Table 3.3.
Note: Other colors except these four colors are to be pre-defined in the Preamble. For
further details, see wikibook on LaTeX1 .
1
https://en.wikipedia.org/wiki/LaTeX
3.4. NUMBERED OR BULLETED LISTS 21
\begin{enumerate}
\item Introduction
\item Literature Review
\item Materials and Methods
\item Results and Discussion
\item Conclusions
\end{enumerate}
The above command will generate the output as shown in Figure 3.1. Similarly,
\begin{itemize}
\item Introduction
\item Literature Review
\item Materials and Methods
\item Results and Discussion
\item Conclusions
\end{itemize}
will produce the output as shown in Figure 3.2. The following comprehensive code in-
cludes all of the above commands and options;
22 CHAPTER 3. TEXT FORMATTING
\begin{enumerate}
\item Introduction
\begin{enumerate}
\item Literature
\item Outline
\end{enumerate}
\item Materials and Methods
\begin{itemize}
\item Materials
\item Methods
\end{itemize}
\item Results and Discussion
\begin{itemize}
\item[+] Results
\item[+] Discussion
\begin{itemize}
\item[-] Discussion in Brief
\item[-] Discussion in Detail
\end{itemize}
\end{itemize}
\item Conclusions
\end{enumerate}
Newton’s law of universal gravitation. This never means that Newton’s \vspace{1in}
calculations were wrong but the concept of gravity was not right.
Input Output
‘tutorial’ ‘tutorial’
‘‘tutorial" “tutorial”
tutorial’s tutorial’s
,,tutorial" ,,tutorial”
3.9 Packages
The following set of packages must be used as a default in all LATEXdocuments like synopsis
and thesis.
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{natbib}
\usepackage{gensymb}
\usepackage{array}
\usepackage{multirow}
26 CHAPTER 3. TEXT FORMATTING
\usepackage{graphicx}
\usepackage{color}
\usepackage{subfigure}
\usepackage{hyperref}
\usepackage[onehalfspacing]{setspace}
\usepackage{filecontents}
Chapter 4
Tables
• Inside the curly brackets {...} “l”, “r” and “c” are used for left, right and centered
aligned texts, respectively. For example, {lll} produces 3 columns with left aligned
text.
• {lcrl} produces 4 columns 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.
It is also very easy to generate a Table in Excel and covert it to LaTeX command by an
addin “ExceltoLaTeX”1 or online through web2 . Some examples are as follows;
\begin{tabular}{lll}
1 & 2 & 3 \\
1
web
2
www.exceltolatex.com
27
28 CHAPTER 4. TABLES
1 & 4 & 9 \\
1 & 16 & 81 \\
1 & 256 & 6561 \\
1 & 65536 & 43046721
\end{tabular}
\begin{tabular}{lcr}
1 & 2 & 3 \\
1 & 4 & 9 \\
1 & 16 & 81 \\
1 & 256 & 6561 \\
1 & 65536 & 43046721
\end{tabular}
\begin{tabular}{ccc}
1 & 2 & 3 \\
1 & 4 & 9 \\
1 & 16 & 81 \\
1 & 256 & 6561 \\
1 & 65536 & 43046721
\end{tabular}
\begin{tabular}{|l|l|l|}
1 & 2 & 3 \\
1 & 4 & 9 \\
1 & 16 & 81 \\
1 & 256 & 6561 \\
1 & 65536 & 43046721
\end{tabular}
\begin{tabular}{|l|l|l|}
\hline
1 & 2 & 3 \\
\hline
1 & 4 & 9 \\
1 & 16 & 81 \\
1 & 256 & 6561 \\
1 & 65536 & 43046721 \\
30 CHAPTER 4. TABLES
\hline
\end{tabular}
To put the above table at the center, label it and give a caption to it, the tabular{}
commands are to be enclosed in \begin{table} and \end{table} commands. For ex-
ample the following code
\begin{table}
\centering
\caption{Example of a table with label and caption. \label{tab:LC}}
\begin{tabular}{|l|l|l|}
\hline
1 & 2 & 3 \\
\hline
1 & 4 & 9 \\
1 & 16 & 81 \\
4.1. SIMPLE TABLES 31
\begin{tabular}{|c|c|c|}
\hline
1 & 2 & 3 \\
\hline
1 & 4 & 9 \\
\hline
1 & 16 & 81 \\
\hline
1 & 256 & 6561 \\
\hline
1 & 65536 & 43046721 \\
\hline
\end{tabular}
\begin{tabular}{|c|c|c|}
\hline
1 & 2 & 3 \\
\hline
1 & 4 & 9 \\
\hline
1 & 16 & 81 \\
\hline
1 & 256 & 6561 \\
\hline
1 & 65536 & 43046721 \\
\hline
\end{tabular}
\begin{tabular}{|c|c|c|}
\hline
1 & 2 & 3 \\
\cline{1-2}
1 & 4 & 9 \\
\hline
1 & 16 & 81 \\
\hline
1 & 256 & 6561 \\
\cline{2-3}
1 & 65536 & 43046721 \\
\hline
\end{tabular}
produces
For a thorough description on Tables, see Ref.3 . As an example, a more complex figure
with the command
\begin{tabular}{>{\centering}p{1.8cm}>{\centering}p{2cm}
>{\centering}p{1.5cm}>{\centering}p{2.2cm}>{\centering}
p{1.7cm}>{\centering}p{2.1cm}}
\hline \hline
3
Tables in LATEX: Packages and Methods by Lapo Filippo Mori, http://www.lapomori.com/
36 CHAPTER 4. TABLES
produces
Chapter 5
Figures
To insert a figure (png, jpg, gif, pdf) in a LATEX document, the package \usepackage{graphicx}
must be added first in the Preamble. The following code is used for inserting a figure.
\begin{figure}
\centering
\includegraphics[scale=1]{Fig1}
\caption {IR transmission spectra of silicate glasses in
400--1400 cm$^{-1}$ region.\label{fig:Fig1}}
\end{figure}
37
38 CHAPTER 5. FIGURES
\begin{figure}
\centering
\includegraphics[scale=1]{LaTeX}
\caption {LaTeX image}
\label{fig:LaTeX}
\end{figure}
produces
39
\begin{equation}
y=mx+c
\end{equation}
In order to write more than one numbered equation, the equation is to be written in-
side another equation environment i.e. \begin{eqnarray} and \end{eqnarray}. For
example, the following code
\begin{eqnarray}
y=mx+c \\
ax^2+bx+c=0 \\
x=\dfrac{-b\pm \sqrt{b^2-4ac}}{2a}
\end{eqnarray}
41
42 CHAPTER 6. MATHEMATICS AND EQUATIONS
produces
y = mx + c (6.2)
ax2 + bx + c = 0 (6.3)
√
−b ± b2 − 4ac
x= (6.4)
2a
To write the same set of equations in a way that equalities symbol (=) of all equations
are aligned, then the symbol & is to be used before and after the = symbol inside the
equation. For example, the following code,
\begin{eqnarray}
y & =& mx+c \\
ax^2+bx+c & = & 0 \\
x & = & \dfrac{-b\pm \sqrt{b^2-4ac}}{2a}
\end{eqnarray}
produces
y = mx + c (6.5)
ax2 + bx + c = 0 (6.6)
√
−b ± b2 − 4ac
x = (6.7)
2a
In case numbering is not desired, the respective commands are to be replaced by {equation*}
and {eqnarray*}. For example, the code
\begin{equation*}
y=mx+c
\end{equation*}
produces
y = mx + c
\begin{eqnarray*}
y=mx+c \\
ax^2+bx+c=0 \\
x=\dfrac{-b\pm \sqrt{b^2-4ac}}{2a}
\end{eqnarray*}
6.2. SYMBOLS 43
produces
y = mx + c
ax2 + bx
√ +c=0
−b ± b2 − 4ac
x=
2a
6.2 Symbols
To start with mathematics, the commands \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.
44 CHAPTER 6. MATHEMATICS AND EQUATIONS
Table 6.1: List of familiar mathematical symbols, which are to be enclosed in math-
mode i.e. $ $.
Table 6.3: List of familiar Greek letters, which are to be enclosed in math-mode i.e. $
$
Symbol Command
α,β \alpha , \beta
γ,Γ \gamma , \Gamma
π,Π \pi , \Pi
φ,ϕ,Φ \phi , \varphi , $\Phi$
,ε $\epsilon$ , $\varepsilon$
σ,ς ,Σ $\sigma$ , $\varsigma$ , $\Sigma$
ρ,% \varrho , \varrho
δ,∆ \delta , \Delta
θ,ϑ,Θ \theta , \vartheta v $\Theta$
µ,ν \mu , \nu
ξ,Ξ \xi , \Xi
η,ζ \eta , \zeta
ι,χ \iota , \chi
τ ,~ \tau , \hbar
κ,∂ \kappa , \partial
λ,Λ \lambda , \Lambda
ψ,Ψ \psi , \Psi
ω,Ω \omega , \Omega
∇,∞ \nabla , \infinity
<,= \Re , \Im
◦
C , 45◦ \degree C , 45\degree
Å, h| , |i \AA , $\langle |$ , $|\rangle $
6.2. SYMBOLS 47
Table 6.4: List of familiar trigonometric functions, which are to be enclosed in math-
mode i.e. $ $
Function Command
sin , arcsin , sinh , $\sin$ , $\arcsin$ , $\sinh$
cos , arccos , cosh , $\cos$ , $\arccos$ , $\cosh$
tan , arctan , tanh , $\tan$ , $\arctan$ , $\tanh$
cot , coth , $\cot$ , $\coth$
sec , csc , $\cot$ , $\csc$
xn
If power or index is more than one number, curly brackets are used as, $x^{10}$ and
$a_{11}$ produces x10 and a11 , respectively.
If both subscript and superscript are associated with a letter, then it can be written
both ways as; $ x_n^2 $ or $ x_n^2 $, which produces x2n .
6.2.7 Roots
Square root symbols are inserted using the command \sqrt{} as $\sqrt{x}$ produces
√
x
For the specification of magnitude, the command is used with optional square brackets,
as $$\sqrt[y]{x}$$ produces
√y
x
3
X
xn
n=1
6.2. SYMBOLS 49
However, if the same command is written in-line $\sum_{n=1}^3 x^n$ it will look like
P3 n
n=1 x
The in-line look can be changed as the previous by using the command $\displaystyle\sum_{n=1}^3 x
X 3
produces xn . Similarly, the product can be written as $$\prod_{n=1}^3 x^n$$,
n=1
which produces
3
Y
xn
n=1
However, if the same is written in-line $\prod_{n=1}^3 x^n$ it will look like 3n=1 xn .
Q
The in-line look can be changed as the previous by using the command $\displaystyle\prod_{n=1}^3
Y3
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)$$
Zb
f (x)
a
For double and triple integrals, the codes $$\iint f(x)$$ and $$\iiint f(x)$$ pro-
duces ZZ
f (x)
ZZZ
f (x)
ZR Zπ Z2π
f (x)
0 0 0
6.3 Matrices
A basic matrix can be created using the matrix environment, which is just like a table
environment. For example, to start with a simple matrix, the following command is used.
\begin{matrix}
a & b & c \\
d & e & f \\
g & h & i
\end{matrix}
\begin{pmatrix}
a & b & c \\
d & e & f \\
g & h & i
\end{pmatrix}
A command line is given below that will refer to chapter, section, subsection,and equation
in a sentence at the end.
\begin{document}
\chapter{Introduction}\label{ch:Intro}
This is the Introduction chapter.
\section{General Aims}\label{sec:Gen. Aims}
This is the first section of Introduction.
52 CHAPTER 6. MATHEMATICS AND EQUATIONS
\subsection{Objectives}\label{subsec:Obj}
This is the subsection in the Introduction chapter.
\begin{equation}\label{eq:sol}
x^2 - 5 x + 6 = 0
\end{equation}
A quadratic equation \ref{eq:sol} is discussed in the subsection
\ref{subsec:Obj} under the first section in chapter \ref{ch:Intro},
which starts on page \pageref{ch:Intro}.
\end{document}
Note: A given document is to be build twice before the references appear in the PDF
document. The references will change automatically, if any of the chapter, section or
page number is changed.
2. Copy paste this file in the same folder and rename it as e.g. Revised.tex
6. Open cmd and change the directory to your folder where both the tex files i.e.
Original.tex and Revised.tex are located
7. If folder is on the Desktop and the name of Folder is LaTeX, type the command
C:\Users\SAY\Desktop\LaTeX where SAY is the username, so change it to your
own username.
it will generate diff.tex docuemnt in the folder. This is the document by building
it, a pdf will be generated that will show like the “Track Change” document.
Presentation-Beamer
1. Standard commands work for beamer as well, which make it easy to copy directly
from a LaTeX document
2. Output is usually a pdf file, which is compatible with all operating systems
4. Equations and mathematical formula look neater, and can be easily copied from a
LaTeX document
Among the disadvantages; it is unlike Powerpoint where ‘select and operate’ works, and
some knowledge of LaTeX is required.
55
56 CHAPTER 7. PRESENTATION-BEAMER
\documentclass{beamer}
\title {This is the title page}
\author{Dr. Shahid Ali Yousafzai}
\date{\today}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\end{document}
The familiar commands \title{},\author{} and \date{} have been discussed Sec-
tion 2.2. Among these familiar commands, the new command is \begin{frame} and
\end{frame} must be used for generating a slide, called ‘frame’ here. Everything includ-
ing figures, tables, equations and normal text etc. can be place between these commands.
The command \titlepage will generate the title slide. The above command will generate
the titlepage as shown in Figure 7.1.
Figure 7.1: Output of the first commands that generates the title slide.
In addition to the blank slide, there is a wide range of available themes that enhances
the look of presentation. For example, among the available themes (i.e. Boadilla, Frank-
furt, Madrid, Berlin, Warsaw etc. ), the following code utilizes the theme ‘Boadilla’ by
adding a command \usetheme{Boadilla}
The following code;
\documentclass{beamer}
7.3. CUSTOMIZED TITLE PAGE 57
\usetheme{Boadilla}
\title {This is the title page}
\author{Dr. Shahid Ali Yousafzai}
\date{\today}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\end{document}
Thus reshapes the title slide to the one shown in Figure 7.2.
Figure 7.2: Output of the commands that generates the title slide when a theme ‘War-
saw’ is used.
{
\leavevmode%
\hbox{%
\begin{beamercolorbox}[wd=.2\paperwidth,ht=2.25ex,dp=1ex,center]{author
in head/foot}%
\usebeamerfont{author in head/foot}\insertshortauthor
\end{beamercolorbox}%
\begin{beamercolorbox}[wd=.7\paperwidth,ht=2.25ex,dp=1ex,center]{title
in head/foot}%
\usebeamerfont{title in head/foot}
{Picturizing the First-ever Image of a Black-hole}
\end{beamercolorbox}}%011
\begin{beamercolorbox}[wd=.1\paperwidth,ht=2.25ex,dp=1ex,center]{author
in head/foot}%
\usebeamerfont{title in head/foot}\hspace*{1em}
\insertframenumber{} / \inserttotalframenumber\hspace*{1ex}
\end{beamercolorbox}%
\vskip0pt%
}
\makeatletter
\setbeamertemplate{navigation symbols}{}
\author{Dr. Shahid Ali}
\title{Picturizing the First-ever Image of a Black-hole}
\titlegraphic{\includegraphics[scale=0.35]{P1}}
\institute{Department of Physics\\University of Peshawar}
\date{\today}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\end{document}
It is to be noted that image mentioned above i.e. ‘P1’ is to be placed in the same folder of
presentation before building the document. The output of the above command is shown
in Figure 7.3.
Figure 7.3: Output of the commands that generates the customized title slide.
\documentclass{beamer}
\usetheme{Boadilla}
\title{This is the title page}
\author{Dr. Shahid Ali Yousafzai}
\date{\today}
\begin{document}
\begin{frame}
\titlepage
\end{frame}
\begin{frame}
\frametitle{General slide}
\framesubtitle{Subtitle, if any}
Contents of the frame
\end{frame}
\end{document}
Figure 7.4: Output of the commands that generates the title slide and general slide.
\begin{frame}{Outline}
\tableofcontents
\end{frame}
This will automatically design the table of contents based on the sections and sub-sections
in the later slides. In order to show “Table of Contents” (only proceeding section is
shown active while the other sections are passive) at the beginning of each new section,
the following command must be added in the preamble.
\AtBeginSection[] {
\begin{frame}
\frametitle{Outline}
\tableofcontents[currentsection]
\end{frame}}
This will show the output for different sections and subsections as shown in Figure 7.5
7.6. SECTIONS AND SUBSECTIONS 61
Figure 7.5: Output of the commands that generates active section before the start of
the same section.
\begin{frame}{Outline}
\tableofcontents
\end{frame}
\section{Introduction}
\begin{frame}
This slide discusses the introduction.
\end{frame}
\section{Materials and Methods}
\subsection{Materials}
\subsection{Methods}
62 CHAPTER 7. PRESENTATION-BEAMER
\begin{frame}
This section discusses the materials and methods.
\end{frame}
7.7 Themes
7.7.1 Inner Themes
The inner themes specify the typesetting of elements within the frame such as:
• footnotes
• bibliography entries
7.7. THEMES 63
Title and part pages have been discussed in Section 7.2, while itemized and enumerated
lists can be generated as discussed in Section 3.4. To increase spacing among the num-
bered items, the command \itemsep0.75em is used. For example, the following command
will increase spacing among the numbered contents of section 3.4. Figure 7.7 shows the
comparative analysis. The difference in style of bullets is due to the beamer theme.
\begin{enumerate}
\itemsep0.75em
\item Introduction
\item Literature Review
\item Materials and Methods
\item Results and Discussion
\item Conclusions
\end{enumerate}
Figure 7.7: Comparative analysis of the numbered list with and without the itemsep
command.
In the case when numbering is supposed to start from a specific number, the following
command is used, which generates the output, as shown in Figure 7.8. The command
\setcounter{enumi}{5} will start numbering from 6, as;
\begin{enumerate}
\setcounter{enumi}{5}
\itemsep0.75em
\item Drug development
\item Imaging
\item Diagnostic tests
\item Water treatment
\item Consumers goods
\end{enumerate}
64 CHAPTER 7. PRESENTATION-BEAMER
\begin{theorem}
This is the theorem block.
\end{theorem}
\begin{definition}
This is the definition block.
\end{definition}
\begin{example}
This is the example block.
\end{example}
\begin{frame}
\begin{block}{Text in a block}
This is a text in a block.
\end{block}
\begin{alertblock}{Text in an alertblock}
This is a text in an alertblock
\end{alertblock}
\begin{exampleblock}{Text in an exampleblock}
Text in an exampleblock.
\end{exampleblock}
7.9. OVERLAYS 65
\end{frame}
7.9 Overlays
Overlays control the order in which parts of the frame appear. These are helpful to focus
the attention of audience to the information that is currently being discussed. However,
excessive use end up in a mess.
\begin{frame}
\begin{enumerate}
\item First
\pause
\item Second
\pause
\item Third
66 CHAPTER 7. PRESENTATION-BEAMER
\pause
\item Fourth
\end{enumerate}
\end{frame}
This will produce the output as bullet text and appear as one-onward by pressing enter.
\begin{frame}
\begin{enumerate}
\item <1> First
\item <2> Second
\item <3> Third
\item <4> Fourth
\end{enumerate}
\end{frame}
7.10. COLUMN, SPACES AND ALIGNMENTS 67
Similarly, if a dash is used after the number, the first shown text will not disappear, while
showing the next bullet. For example;
\begin{frame}
\begin{enumerate}
\item <1-> First
\item <2-> Second
\item <3-> Third
\item <4-> Fourth
\end{enumerate}
\end{frame}
As a summary;
h1i displays on slide 1 only and then disappear
h2−i display from slide 2 onward
h1 − 3i display from slide 1 to slide 3
h−3, 5 − 6, 8−i display on all slides except slides 4 and 7
\begin{frame}
\begin{columns}
\begin{column}[]{.5\textwidth}
\begin{block}{Block First} The contents of first block\end{block}
\end{column}
\begin{column}[]{.5\textwidth}
\begin{block}{Block Second} The contents of second block\end{block}
\end{column}
\end{columns}
\end{frame}
\begin{frame}
\smartdiagram[bubble
diagram]{Thanks,Questions,Comments,Feedback,Concerns,Opinions}
\smartdiagramset{module minimum width=3cm,module minimum height=3cm,text
width=5cm}
\end{frame}
\begin{frame}
\smartdiagramset{module minimum width=3cm,module minimum height=1cm,text
width=3cm}
\smartdiagram[circular diagram:clockwise]{\LaTeX,\TeX,\TeX Studio,\TeX
Maker}
\end{frame}
\smartdiagram[flow diagram:horizontal]{\TeX,
\LaTeX, \TeX Studio, \TeX Maker}
70 CHAPTER 7. PRESENTATION-BEAMER
Chemistry
To facilitate Chemistry writing and sketches in a LATEX document, the package \usepackage{chemfig}
must be added first in the Preamble. The following tables explain codes for inserting atom,
bond type, bond angle and bond environment etc.
2. Changing the sign of the angle will also change the orientation i.e. the command
\chemfig{A-[:-30]B} will produce A
B
3. In the case of three atoms, the relative angle can be incorporated by a double angle
command, as for water molecule, the command \chemfig{H-[:52.24]O-[::-104.48]H}
O
will produce H H
73
74 CHAPTER 8. CHEMISTRY
4. For more than three atoms, the simple angle command will be extended; as the
command for writing CCl4
\chemfig{C(-[:0]Cl)(-[:90]Cl)(-[:180]Cl)(-[:-90]Cl)}
Cl
will produce Cl C Cl
Cl
5. The following code produces
\chemfig{R-[:0]C(=[:60]O)(-[:-60]O)}
O
R C
O
6. The following code produces
O
\chemfig{R-[:0]C(=[:60]O)(-[:-60]O-[:-120]C(-[:-180]R)(=[:-60]O))} R C
R C
O
7. A skeletal draw can be produced by the command
\chemfig{-[:30]-[:-30]=[:30]-[:-30]~[:30]}
\chemfig{A-[:30,1.5]B} gives A
B
4. The bond pattern can be changed to the dashed pattern by the command
B
\chemfig{A-[:30,,,,dash pattern=on 2pt off 2pt]B} gives A
H H
\schemestart
\chemfig{R-[:0]C(=[:30]O)(-[:-30]OH)} \+ ROH \arrow{->}
\chemfig{R-[:0]C(=[:30]O)(-[:-30]OR)} \+ \chemfig{H_2O}
\schemestop
O O
R C + ROH R C + H2 O
OH OR
Some of the typical arrow styles are as follows;
\schemestart \arrow{->}\schemestop produces
\schemestart \arrow{-/>}\schemestop produces
\schemestart \arrow{<-}\schemestop produces
\schemestart \arrow{<->}\schemestop produces
\schemestart \arrow{<=>}\schemestop produces
\schemestart \arrow{<->>}\schemestop produces
\schemestart \arrow{<<->}\schemestop produces
78 CHAPTER 8. CHEMISTRY
Chapter 9
Nomenclature
The following configuration change in the TeXmaker is to be done before proceeding with
the nomenclature or abbreviation. Go to Option→Configure Texmaker, under the option
“Commands” change the Makeindex to
makeindex %.nlo -s nomencl.ist -o %.nls -t %.nlg
The view of configuration interface is shown in Figure 9.1.
79
80 CHAPTER 9. NOMENCLATURE
To create a nomenclature, the following example can be copied directly into the TeX-
maker;
\begin{equation}
E=h\nu=\hbar \omega
\end{equation}
\nomenclature{$E$}{Energy of the particle}
\nomenclature{$h$}{Planck constant}
\nomenclature{$\hbar$}{Reduced Planck constant}
\nomenclature{$\nu$}{Frequency}
\printnomenclature
The above example will generate the nomenclature on a separate page as shown in Figure
9.2.
The above command will print the list of abbreviations on a separate page as shown in
Figure 9.3.
The space between abbreviation and definition can be changed by defining the space
82 CHAPTER 9. NOMENCLATURE
Customization of LATEX
Table 10.1: The default LaTeX styles, the desired styles and the respective commands
for the desired styles.
83
84 CHAPTER 10. CUSTOMIZATION OF LATEX
is used as;
\usepackage{sectsty}\chapterfont{\centering} Figure 10.1 and Figure 10.2 show
the effect of use of this command.
References
2. When a selected reference is shown, click on inverted commas below the link to
show various available referencing formats
@article{tai2016efficient,
title={Effects of graphene in graphene/TiO composite films
applied to solar cell photoelectrode},
author={Tai, Qidong and You, Peng and Sang, Hongqian and Liu,
Zhike and Hu, Chenglong and Chan, Helen LW and Yan, Feng},
journal={Nature Communications},
volume={7},
year={2016},
87
88 CHAPTER 11. REFERENCES
5. Copy all the text and paste it inside the above commands. The file will look like
below
\begin{filecontents}{References.bib}
@article{tai2016efficient,
title={Effects of graphene in graphene/TiO composite films},
author={Tai, Qidong and You, Peng and Sang, Hongqian and Liu,
Zhike and Hu, Chenglong and Chan, Helen LW and Yan, Feng},
journal={Nature Communications},
volume={7},
year={2016},
publisher={Nature Publishing Group}
}
\end{filecontents};
6. In this manner, all the references are to be placed. The order of the references here
is not important and has nothing to do with the citations order.
9. To cite a reference, \citep{} command is used. In the curly brackets, the ‘citation
key’ is the content of the dots only i.e. {.............., . To cite the above
reference \citep{tai2016efficient} is to be used.
10. In order to see the output of the reference insertion, the following steps are to be
followed.
11. In the case, citations are not in order, a command sort&compress to be used in
the optional parameters of the ‘documentclass’ i.e.
\documentclass[a4paper,12pt,sort&compress]{Book}
• Authors
Sometimes, in the list of authors, two names appear as connected with a dash, as
John Gold-Smith. LaTeX picks it as J. -Smith in the reference. To correct this,
either dash is to be removed from the name or the name to be splitted in three,
which will be then written in references as J. G. Smith.
• Journal
Each letter of the words of a journal are to be capitalized. BibTeX normally write
them in a standard format i.e. each first letter capitalized. If not, the letters are
to be capitalized manually inside the curly brackets. The name of the journal is
italicized by LaTeX automatically, so no need to italicize manually.
volume={7},
year={2016}
can be changed as
90 CHAPTER 11. REFERENCES
volume={\textbf{7}},
year={\textbf{2016}}
Note: Sometime, BibTeX by default picks a reference with a wrong format. To resolve
this, either the corrections are to be performed manually or the reference is to be taken
from somewhere else, other than Google Scholar.
LANGUAGE FIELD
(*) No language field
(l) Add language field to switch hyphenation patterns temporarily
Select:
ANNOTATIONS:
(*) No annotations will be recognized
(a) Annotations in annote field or in .tex file of citekey name
Select:
92 CHAPTER 11. REFERENCES
PRESENTATIONS:
(*) Do not add presentation type for conference talks
(p) Add presentation, speaker not highlighted
(b) Presentation, speaker bold face
(i) Presentaion, speaker italic
(c) Presentaion, speaker in small caps
Select:
AUTHOR NAMES:
(*) Full, surname last (John Frederick Smith)
(f) Full, surname first (Smith, John Frederick)
(i) Initials + surname (J. F. Smith)
(r) Surname + initials (Smith, J. F.)
(s) Surname + dotless initials (Smith J F)
(w) Surname + comma + spaceless initials (Smith, J.F.)
(x) Surname + pure initials (Smith JF)
(y) Surname + comma + pure initials (Smith, JF)
(z) Surname + spaceless initials (Smith J.F.)
(a) Only first name reversed, initials (AGU style: Smith, J. F., H. K. Jones)
(b) First name reversed, with full names (Smith, John Fred, Harry Kab Jones)
Select:
Select:
(x) No ISBN
Select:
ISSN NUMBER:
(*) Include ISSN for periodicals
(x) No ISSN
Select:
DOI NUMBER:
(*) Include DOI as "doi: number"
(u) Format DOI as URL //dx.doi.org/doi (must give url options!)
(a) Insert DOI AGU style as part of page number
(x) No DOI
Select:
‘EDITOR’ AFTER NAMES (EDITED BOOKS WITHOUT AUTHORS):
(*) Word ‘editor’ after name
(a) ‘Name (editor),’ in parentheses, after name, comma after
(b) ‘Name (Editor),’ as above, editor upper case
(c) ‘Name, (editor)’ in parentheses, after name, comma between
(d) ‘Name, (Editor)’ as above, editor upper case
(e) ‘Name (editor)’ in parentheses, after name, no commas
(f) ‘Name (Editor)’ as above, editor upper case
Select:
EDITOR IN COLLECTIONS:
(*) Same as for edited book (names before booktitle)
(b) In booktitle, edited by .. (where .. is names)
(p) In booktitle (edited by ..)
(c) In booktitle, (edited by ..)
(e) In booktitle, editor ..
(f) In booktitle, (editor) ..
(k) In booktitle (editor..)
(g) In booktitle, (editor..)
(j) In booktitle, .., editor
(m) In booktitle (.., editor)
Select:
PUNCTUATION BETWEEN SECTIONS (BLOCKS):
(*) \newblock after blocks (periods or new lines with openbib option)
(c) Comma between blocks
(s) Semi-colon between blocks
(b) Blanks between blocks
(t) Period after titles of articles, books, etc else commas
11.2. CUSTOMIZED REFERENCE STYLE 99
Select:
EDITION NUMBERS:
(*) Editions as in database saving much processing memory
(w) Write out editions as first, second, third, etc
(n) Numerical editions as 1st, 2nd, 3rd, etc
Select:
Reading external language file
STORED JOURNAL NAMES:
(*) Full journal names for prestored journals
(a) Abbreviated journal names
(s) Abbreviated with astronomy shorthands like ApJ and AJ
Select:
AMPERSAND:
(*) Use word ‘and’ in author lists
(a) Use ampersand in place of ‘and’
(v) Use \verb;\BIBand; in place of ‘and’
Select:
COMMA BEFORE ‘AND’:
(*) Comma before ‘and’ as ‘Tom, Dick, and Harry’
(n) No comma before ‘and’ as ‘Tom, Dick and Harry’
(c) Comma even with 2 authors as ‘Tom, and Harry’
Select:
NO ‘AND’ IN REFERENCE LIST:
(*) With ‘and’ before last author in reference list
(x) No ‘and’ as ‘Tom, Dick, Harry’
Select:
COMMA BEFORE ‘ET AL’:
(*) Comma before ‘et al’ in reference list
(x) No comma before ‘et al’
Select:
FONT OF ‘ET AL’:
(*) Plain et al
(i) Italic et al
(r) Roman et al even when authors something else
Select:
ADDITIONAL REVTeX DATA FIELDS:
(*) No additional fields for REVTeX
(r) Include REVTeX data fields collaboration, eid, eprint, archive, numpages, u
rl
11.2. CUSTOMIZED REFERENCE STYLE 101
Select:
E-PRINT DATA FIELD: (without REVTeX fields)
(*) Do not include eprint field
(e) Include eprint and archive fields for electronic publications
Select:
URL ADDRESS: (without REVTeX fields)
(*) No URL for electronic (Internet) documents
(u) Include URL as regular item block
(n) URL as note
(l) URL on new line after rest of reference
Select:
REFERENCE COMPONENT TAGS:
(*) No reference component tags in the \verb;\bibitem; entries
(b) Reference component tags like \verb;\bibinfo; in the content of \verb;\bibitem;
Select:
EMPHASIS: (affects all so-called italics)
(*) Use emphasis ie, V\verb;em;, allows font switching
(i) Use true italics ie, \verb;\it;, absolute italics
(x) No italics at all
(u) Underlining in place of italics, best with ulem package
Select:
COMPATIBILITY WITH PLAIN TEX:
(*) Use LaTeX commands which may not work with Plain TeX
(t) Use only Plain TeX commands for fonts and testing
Select:
Finished!!
Batch job written to file ‘Name of File.dbj’
Shall I now run this batch job? (NO)
Write Y
102 CHAPTER 11. REFERENCES
Acknowledgment
In writing this tutorial, I have taken help from many online available resources especially
tex.stackexchange.com. The tutorials from LATEX Wikibook, iSkill and Chandra Has
tutorials helped a lot in writing this beginners tutorial.
103