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

LaTeX Tutorial Book

This document is a LaTeX tutorial for beginners that covers: 1. An introduction to LaTeX, its history and uses 2. Instructions on installing LaTeX and configuring the necessary software 3. Detailed explanations and examples of how to structure documents, format text, insert tables, figures, equations and more using LaTeX commands.

Uploaded by

Siva Narayanan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
202 views

LaTeX Tutorial Book

This document is a LaTeX tutorial for beginners that covers: 1. An introduction to LaTeX, its history and uses 2. Instructions on installing LaTeX and configuring the necessary software 3. Detailed explanations and examples of how to structure documents, format text, insert tables, figures, equations and more using LaTeX commands.

Uploaded by

Siva Narayanan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 103

LATEX Tutorial for Beginners

Dr. Shahid Ali Yousafzai


Second Edition

November 10, 2019


2
Contents

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

6 Mathematics and Equations 41


6.1 Inserting Equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
6.2 Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
6.2.1 Mathematical Symbols . . . . . . . . . . . . . . . . . . . . . . . . 44
6.2.2 Tex-mode Equivalence . . . . . . . . . . . . . . . . . . . . . . . . 45
6.2.3 Greek Letters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
6.2.4 Trigonometric Functions . . . . . . . . . . . . . . . . . . . . . . . 47
6.2.5 Powers and Indices . . . . . . . . . . . . . . . . . . . . . . . . . . 47
6.2.6 Fractions and Binomials . . . . . . . . . . . . . . . . . . . . . . . 48
6.2.7 Roots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.2.8 Sums and Integrals . . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.3 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
6.4 Labeling Captions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
6.5 Track changes in a document . . . . . . . . . . . . . . . . . . . . . . . . 52

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

“Writing a technical document in MS Word is like designing one’s jewelry by a


blacksmith”

This is an absolute beginners guide to learning LATEX using TeXStudio. It is intended to


start from scratch, so no prior knowledge of LATEX is required. This book is a collection
of lectures delivered as seminars to the students during learning LATEX. It is a computer
language program designed specifically for technical writings (e.g. Thesis, Article and
Report etc.). Writing the aforementioned documents in MS word or other word processing
software is a hectic and cumbersome job. This book in the early chapters teaches the
basic commands to create a simple document in LATEX and then aims to learn writing a
thesis and finally an article.

7
8 CONTENTS
Chapter 1

Introduction

1.1 LATEX
• Pronounced as Lah-tech or Lay-tech, is based on TEX developed by Leslie Lamport

• TEX is a low-level computer language typesetting system designed by Donald Ervin


Knuth (born January 10, 1938), an American computer scientist, mathematician,
and professor emeritus at Stanford University in 1978

• τ χνη (techne) for technical

• Output can be PDF, PostScript, PNG, JPEG, etc.

• Not a word processor i.e. ‘What You See Is What You Get’ (WYSIWYG), its
document is a plain text file (*.tex)

• Particularly suited for producing long, structured documents, equations etc.

• Available as free software for most operating systems

• Packages or styles available on Comprehensive TeX Archive Network (CTAN)


(http://www.ctan.org)

• Composed of two softwares, TEX distribution {MiKTeX (Windows), TeXLive (Linux),


MacTeX4 (Mac OS)} and an Editor (TeXstudio, TeXmaker, TeXworks, and many
others)

1.2 Why to learn LATEX

Figure 1.1 shows a comparative analysis between MS Word and LATEX

9
10 CHAPTER 1. INTRODUCTION

Table 1.1: Why LATEXis a better choice than Microsoft Word.

Counting LATEX MS Word


on
1 LaTeX is for technical writing MS Word is for general purpose docu-
mentation
2 LaTeX and all its packages are free to MS Word is not free
use
3 LaTeX is very easy to use for sections These features are at the stage of devel-
and subsections, captions, tables, foot- opment in MS Word
notes, labels, references and equations
etc.
4 LaTeX output is a pdf, no issues of com-
MS Word different versions have com-
patibility patibility issues
5 LaTeX has specified templates for an ar-
MS Word has no such templates differ-
ticle, book and report etc. ent versions have compatibility issues
6 LaTeX learning seems to be difficult atMS Word seems to be an easy learning
first project
7 LaTeX document has a perfect look MS Word document lacks such a look in
a technical document
8 LaTeX is painful at the beginning, but MS Word is not having such addiction
once learnt, one can’t live without it

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;

– MikTeX 2.9 32 bit (folder)


– Setup-2.9.4250 (file)

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

Figure 1.1: Comparative analysis between MS Word and LaTeX

Figure 1.2: Difference of look in equations written in MS Word and LaTeX.

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

16. Click “Close” to finish with the installation

1.4 Post-Installation Configurations


1. Open TeXmaker, click “Options” and then click “Configure TeXmaker”

2. Under the “Commands” tick “Embed”

3. Under the “Quick Build” confirm that “PdfLaTeX+ViewPDF” is selected

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

2.1 Start a new Document


Figure 2.1 shows the starting view of the TeXStudio.

Figure 2.1: Starting view of the TeXStudio

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

Figure 2.2: View of the command code in TeXStudio

Table 2.1: Explanation of the structure and commands

This command must appear only once at the start of ev-


ery LATEX document. The square brackets specifies optional
\documentclass
formatting, if not specified, LATEX will run with the default
parameters. The options which are specified usually are,
[a4paper,12pt,sort&compress,oneside/twoside]. The
curly brackets specifies the class of document. The document
class may be a “book”, “letter”, “report” or an “article” etc.
Anything written between these two commands is
the actual document. Anything typed between the
\begin{document}
“\documentclass{...}” and the “\begin{document}”
and
is called the Preamble, and is not part of the output docu-
\end{document}
ment. Text written after the “\end{document}” is not part
of the document and is ignored by LATEX.

2.2 Creating a Title


To create title of a document, the following command is used between the \begin{document}
and \end{document}.

\title{\LaTeX Tutorial for Beginners}


\author{Dr. Shahid Ali Yousafzai}
\date{\today}
\maketitle

The output of the above command is shown in Figure 2.4.


\today is a command that picks today’s date. If the \date command is not used, today’s
date will be printed by default. To change date to a specific date, \today is to be replaced
with the specific date in the curly brackets e.g. \date{January 20, 2013}. In order to
skip writing date, the curly brackets must be left empty as \date{}.

2.3 Chapters and Sections


To insert a new chapter, \chapter{} command is used. Similarly, \section{} inserts a
section, \subsection{} inserts a subsection, and so on.
2.3. CHAPTERS AND SECTIONS 15

Figure 2.3: Output of the first attempt in LaTeX.

Figure 2.4: Output of the title page creation.

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.

The output of the above command is shown in Figure 2.5.


As from Figure 2.5, LaTeX is not giving numbering to the subsubsection by default. To
include the subsubsection numbering (considered as level 4), the command
\setcounter{secnumdepth}{4} is to be used in the Preamble. Subsequently, to include
this in the “Table of Contents”, which will be discussed in the next Section 2.4, the
numbering level can be extended by the command \setcounter{tocdepth}{4}. It is
to be noted that \chapter{} command is limited only to the “book and report” of the
documentclass.
16 CHAPTER 2. DOCUMENT STRUCTURE

Figure 2.5: Output of the chapter, section, subsection and subsubsection command.

2.4 List and Table of Contents


The “List of Tables” and “List of Figures” can be automatically generated by using the
commands \listoftables and \listoffigures, respectively, where ever required in
the document. These lists are generated on a new page by default. In order to generate
“Table of Contents”, \tableofcontents command is used. It is usually generated after
the title page. It will not be generated automatically unless “Enter” is entered before
and after the command or new page is inserted before the command by using \newpage
command.

2.5 Page Numbering


By default, LaTeX is using Arabic numerals (i.e. 1, 2, 3, ...) as page numbers. As a
custom, the first few pages of a thesis are numbered as roman numerals (i, ii, iii, ...),
while rest of the pages are numbered as Arabic numerals (1, 2, 3, ...). To start with a
specific page numbering, e.g. roman numbering up to some pages and then with Arabic
numbering, the following command is used.

\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

3.1 Font Sizes


By default, LaTeX writes the ordinary text with a normal font size (12pt), which is the
standard for writing technical documents. While, chapter numbering and title, section,
subsection, and subsubsection etc. are written with a default bold font sizes of 16, 14,
13, and 12, respectively. However, in the case, in normal text, different font sizes are
required, the following Table 3.1 provides a set of commands.

Table 3.1: For different font sizes, the following commands are used.

Font Size Command Output


tiny size \tiny{LaTeX Tutorial} LaTeX Tutorial

script size \scriptsize{LaTeX Tutorial} LaTeX Tutorial


footnote size \footnotesize{LaTeX Tutorial} LaTeX Tutorial
small size \small{LaTeX Tutorial} LaTeX Tutorial
normal size \normalsize{LaTeX Tutorial} LaTeX Tutorial
large size \large{LaTeX Tutorial} LaTeX Tutorial
larger size \Large{LaTeX Tutorial} LaTeX Tutorial
largest size \LARGE{LaTeX Tutorial} LaTeX Tutorial
huge size \huge{LaTeX Tutorial} LaTeX Tutorial

19
20 CHAPTER 3. TEXT FORMATTING

3.2 Font Effects

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.

Font Effect Command Output


italic \textit{physics} physics
bold \textbf{physics} physics
underline \underline{physics} physics
small caps \textsc{physics} physics
slanted \textsl{physics} physics
emphasize \emph{physics} physics
teletype \texttt{physics} physics
san serif \textsf{physics} physics
roman \textrm{physics} physics

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.

3.3 Font Color

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.

Table 3.3: Command for coloring a text.

Font Color Command Output


blue {\color{blue}blue} blue
green {\color{green}green} green
yellow {\color{yellow}yellow} yellow
red {\color{red}red} red

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

3.4 Numbered or Bulleted Lists


For producing a numbered list, the items (starting with \item command) are to be
enclosed in \begin{enumerate} and \end{enumerate} commands. The replacement of
{enumerate} by {itemize} will produce bulleted list. Sub-category is automatically
introduced, as the commands are entered. An optional “number” or “bullet”, can be
pre-defined in the square brackets in \item[ ]. For example, a simple numbered list is
generated by the following command;

\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,

Figure 3.1: Output of the enumerated and itemized command.

if \begin{itemize} and \end{itemize} commands are used, the numbering will be


replaced by bullets. For example, the following command;

\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

Figure 3.2: Output of the enumerated and itemized command.

\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}

Which will produce the output as shown in Figure 3.3.

3.5 Comments and Spacing


In order not to include a phrase, sentence or a paragraph, use of a “%” exclude it from
the print. For example, the following sentence;
3.5. COMMENTS AND SPACING 23

Figure 3.3: Output of the enumerated and itemized commands.

The Einstein’s general theory of relativity nullified the concept of


Newton’s law of universal gravitation. %This never means that Newton’s
calculations were wrong but the concept of gravity was not right.

will be printed out as;

3.5.1 Horizontal Spacing


Multiple consecutive spaces are treated as a single space. In order to intentionally give
a space, this symbol “~” is to be used as “absolutely ~~~~~free” will generate “abso-
lutely free”

3.5.2 Vertical Spacing


Several empty lines are treated as one empty line. Double “Enter” is required to start
a new paragraph. For a specified vertical space, the \vspace{} command is used. For
example, the following sentence;

The Einstein’s general theory of relativity nullified the concept of \vspace{12pt}


24 CHAPTER 3. TEXT FORMATTING

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.

will produce the output as shown in Figure 3.4.

Figure 3.4: Output of the vertical spacings.

3.5.3 Line Spacing


For standard line spacing like one-half (1.5) and double-spacing (2), the package
\usepackage[ ]{setspace} is to be used in the Preamble. For example,
\usepackage[singlespacing]{setspace}, \usepackage[onehalfspacing]{setspace}
and \usepackage[doublespacing]{setspace} will produce single, one-and-half, and
double spacings, respectively.
The two commands \hfill and \vfill fills all the space horizontally and vertically be-
tween, respectively.
The following command;

\LaTeX ~Tutorial for Beginners \hfill \today \\


\LaTeX ~Tutorial for Beginners \vfill \today

will produce the output as shown in Figure 3.5.

3.6 Quotation Marks


To enclose a given text in quotation is completely different. Table 3.4 shows different
inverted quotes.

3.7 Dashes and Hyphens


Formats for Dashes and Hyphens are shown in the following Table 3.5 .
3.8. SPECIAL CHARACTERS 25

Figure 3.5: Output of the line spacing.

Table 3.4: Inverted quotations

Input Output
‘tutorial’ ‘tutorial’
‘‘tutorial" “tutorial”
tutorial’s tutorial’s
,,tutorial" ,,tutorial”

3.8 Special Characters


Some of the symbols are reserved characters in LATEX. In order to insert these symbols,
the following format is to be followed;

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

Table 3.5: Dashes and Hyphens formats

Label Input Output


hyphen sofa-cum-bed sofa-cum-bed
en dash pages 16--17 pages 16–17
em dash yes---no yes—no
minus $-1$ −1

Table 3.6: Special character insertion formats

Symbol Input Output


$ \$ $
% \% %
# \# #
^ \^{} ˆ
& \& &
_ \_
{ } \{ \} {}
~ \~{} ˜
\ \textbackslash \

\usepackage{graphicx}
\usepackage{color}
\usepackage{subfigure}
\usepackage{hyperref}
\usepackage[onehalfspacing]{setspace}
\usepackage{filecontents}
Chapter 4

Tables

Table is the comparatively a complex thing to do as compared to MS Excel. However,


step by step guidelines to the designing of different types of tables. 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} 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.

• & is used to separate data between two columns

• \\ is used to start a new row

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;

4.1 Simple Tables


The following command

\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}

will produce the table as follows

The following command

\begin{tabular}{lcr}
1 & 2 & 3 \\
1 & 4 & 9 \\
1 & 16 & 81 \\
1 & 256 & 6561 \\
1 & 65536 & 43046721
\end{tabular}

will produce the table as follows The following command


4.1. SIMPLE TABLES 29

\begin{tabular}{ccc}
1 & 2 & 3 \\
1 & 4 & 9 \\
1 & 16 & 81 \\
1 & 256 & 6561 \\
1 & 65536 & 43046721
\end{tabular}

will produce the table as follows

The following command

\begin{tabular}{|l|l|l|}
1 & 2 & 3 \\
1 & 4 & 9 \\
1 & 16 & 81 \\
1 & 256 & 6561 \\
1 & 65536 & 43046721
\end{tabular}

will produce the table as follows


The following command

\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}

will produce the table as follows

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

1 & 256 & 6561 \\


1 & 65536 & 43046721 \\
\hline
\end{tabular}
\end{table}

will produce the table as follows;


32 CHAPTER 4. TABLES

The following command

\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}

will produce the table as follows


4.1. SIMPLE TABLES 33

The following command

\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}

will produce the table as follows


34 CHAPTER 4. TABLES

The following command

\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}

will produce the table as follows


4.2. COMPLEX TABLES 35

4.2 Complex Tables


For designing complex tables, some additional packages like \usepackage{array} and
\usepackage{multirow} are to be added. In order to fix the width of a column, the
following codes are helpful.
To fix width of the first column to 0.5in, second as 1in and third as 2in, the command
p{...} is used. p{...} the column is justified and its width is wth (the text is inserted
into a parbox of width wth);

\begin{tabular}{p{0.5in} p{1in} p{2in} }


\hline
1 & 2 & 3 \\
\hline
1 & 4 & 9 \\
1 & 16 & 81 \\
1 & 256 & 6561 \\
\hline
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

{Samples} & {Film Deposition} & \multicolumn{3}{c}


{{Experimental Treatments}} & {Laser Irradiation}
\tabularnewline
\hline \hline
& Top-Bottom (nm) & Electric Field (V/mm) & Temperature
(\degree C) & Diffusion Duration (hr) & Q-switched Nd:YAG
Laser \tabularnewline
\hline
\multirow{2}{1.8cm}{{Ag-doped BSG}} & \multirow{2}{1.7cm}
{500--200} & 250 & 400 & 2 & 200 pulses\tabularnewline
%\cline{3-6}
& & 400 & 400 & 2 & 200 pulses\tabularnewline
\hline
\multirow{2}{1.8cm}{{Ag-doped SG}} & \multirow{2}{1.7cm}
{700--170} & 2 & 400 & 7 & 200 pulses\tabularnewline
%\cline{3-6}
& & 150 & 400 & 5 & 200 pulses\tabularnewline
\hline
\multirow{2}{1.8cm}{{Au-doped SLG}} & \multirow{2}{1.7cm}
{500--200} & 400 & 400 & 5 & 200 pulses\tabularnewline
%\cline{3-6}
& & 500 & 400 & 5 & 200 pulses\tabularnewline
\hline \hline
\end{tabular}

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

Table 5.1: Explanation of the figure insertion code.

This command is the usual command for generating figure en-


vironment in every LATEX document. After \begin{figure}
\begin{figure}
the square brackets are called position specifiers for the figure
and
in the document. ‘h’ for here, ‘t’ for top of the page, ‘b’ for
\end{figure}
bottom, and ‘p’ for a separate page. An exclamation mark
as [...!], which will force LATEXto place it at the specified
location. LATEX sometime does not put the figure as desired,
which is due to the size of the image more than the available
space at the designated place. If no placement in the form of
[ ] brackets is specified, LATEX will place it somewhere close
to the specified position. If multiple placements are specified
as [bt], it is the flexibility to LATEX to place the figure either
on the bottom or top of the page, and so on.
\centering This will center the figure and the caption at the center
This is a command which include the figure, in this case ‘Fig1’.
Writing extension of the figure is not essential. Option in the
\includegraphics
square brackets specifies the size of the Figure, in this case 1
[scale=1]{Fig1}
or 100%.
\caption{...} Here the caption of the figure is to be written. Captions
can then be used to generate ‘List of Figures’ by using the
command \listoffigures
\label{fig:Fig1} The \label{} command is the same, as can be used for la-
beling a section or table etc. If it is used inside the caption, it
will count the number independent of section very accurately.
See Section 6.4 for details on labeling.

For example, the following code is for inserting LATEX image;

\begin{figure}
\centering
\includegraphics[scale=1]{LaTeX}
\caption {LaTeX image}
\label{fig:LaTeX}
\end{figure}

produces
39

Figure 5.1: LaTeX image


40 CHAPTER 5. FIGURES
Chapter 6

Mathematics and Equations

6.1 Inserting Equations


An in-line equation in LATEX can be written by enclosing the equation in $ symbols. A
straight line equation is written as; $y=mx+c$ which produces y = mx + c. In order to
insert the same equation in a separate line, it is to be enclosed in double $$ symbols, as
$$y=mx+c$$ will produce
y = mx + c

To provide automatic numbering to an equation, the equation is to be written inside


an equation environment i.e. \begin{equation} and \end{equation} For example, the
following code

\begin{equation}
y=mx+c
\end{equation}

produces a numbered equation


y = mx + c (6.1)

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

Similarly, the code

\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

6.2.1 Mathematical Symbols


Some of the common mathematical symbols are shown in Table 6.1.

Table 6.1: List of familiar mathematical symbols, which are to be enclosed in math-
mode i.e. $ $.

Symbol Command Symbol Command


≤,≥ \leq , \geq , \ll , \gg
6= , ≡ \neq , \equiv ∼,≈ \sim , \approx
',∼ = \simeq , \cong k,∦ \parallel , \nparallel
⊥,` \perp , \vdash ±,∓ \pm , \mp
×,÷ \times , \div ∗,? \ast , \star
†,‡ \dagger , \ddagger ·, \cdot , \odot
⊕, \oplus , \ominus ∈,∈ / \in , \notin
→,← \rightarrow , \leftarrow 7→ , ↔ \mapsto , \leftrightarrow
=⇒ , ⇐⇒ \implies , \iff ↑,↓ \uparrow , \downarrow
∧,∨ \land , \lor ⇑,⇓ \Uparrow , \Downarrow
6.2. SYMBOLS 45

6.2.2 Tex-mode Equivalence


Some of the symbols can be written without math-mode. Table 6.2 shows the text-mode
equivalence of some symbols.

Table 6.2: List of some mathematical symbols having text-mode equivalence

Symbol Math-mode Text-mode


| $|$ \textbar
< $<$ \textless
> $>$ \textgreater
- $-$ \textendash
− $-$ \textemdash
† $\dagger$ \dag
‡ $\ddagger$ \ddag
â $\hat{a}$ \^a
~a $\vec{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
a12 a$^{12}$ a\textsuperscript {12}
a12 a$_{12}$ a\textsubscript {12}
46 CHAPTER 6. MATHEMATICS AND EQUATIONS

6.2.3 Greek Letters


Some of the Greek letters and their respective commands are shown in Table 6.3.

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

6.2.4 Trigonometric Functions

Some of the trigonometric functions are shown in Table 6.4.

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$

6.2.5 Powers and Indices

To write power, the code $$x^n$$ produces

xn

Similarly, the code $$a_n$$ produces


an

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 .

As a compact example, the following code


$n_1 + n^2=k_{n+1} + k_n^2 - k^{n-1}$
produces

n1 + n2 = kn+1 + kn2 − k n−1

Similarly, the code


$f(x) = x^5 + 4x^2|^{x=10} + 2|_{x=12}$
generates
f (x) = x5 + 4x2 |x=10 + 2|x=12
48 CHAPTER 6. MATHEMATICS AND EQUATIONS

6.2.6 Fractions and Binomials


The command \frac{}{} and \binom{}{} are used for fraction and bionomial, respec-
tively.
The code $$\frac{a}{b}$$ produces
a
b
For example the following code
$$\frac{n!}{k!(n-k)!} = \binom{n}{k}$$
generates  
n! n
=
k!(n − k)! k
n!
If the same command is used as in-line with text as k!(n−k)! , it is seemed as collapsed. To
resolve this, another command \dfrac{}{} is used as the command \dfrac{n!}{k!(n-k)!}
n!
will generate . It is to be noted that for \frac{}{} no extra package is required,
k!(n − k)!
while for \dfrac{}{} the package \usepackage{amsmath} must be used.

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

Root with a fraction e.g. $$\sqrt{\frac{a}{ax^2+bx}}$$ produces


r
a
ax2 + bx

while code $$\sqrt[y]{\frac{a}{ax^2+bx}}$$ produces


r
y
a
ax2 + bx

6.2.8 Sums and Integrals


The command \sum and \int are used for sum and integral, respectively.
The code $$\sum_{n=1}^3 x^n$$ produces

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)

For definite integral, the code $$\int_a^b f(x)$$ produces


Z b
f (x)
a

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 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)

Some complex integrals are


$$\int_0^R \int_0^\pi \int_0^{2\pi} f(x)$$
Z R Z π Z 2π
f (x)
0 0 0
50 CHAPTER 6. MATHEMATICS AND EQUATIONS

Figure 6.1: A simple matrix

$$\int \limits_0^R \int \limits_0^\pi \int \limits_0^{2\pi} 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}

The output of this command is shown in Figure 6.1.


In order to enclose the matrix in brackets, the following environment is used.

\begin{pmatrix}
a & b & c \\
d & e & f \\
g & h & i
\end{pmatrix}

The output of this command is shown in Figure 6.2.


This way, to enclose in sqaure brackets [ ] bmatrix, for curli brackets { } Bmatrix, and
for vertical lines as in a determinant || vmatrix are used.
6.4. LABELING CAPTIONS 51

Figure 6.2: A simple matrix enlosed in brackets

6.4 Labeling Captions


Labeling is one of the strongest feature of LATEX. In a given document, labeling can
be applied to a chapter, section, subsection, table, figure, page number, and equa-
tion etc. The respective commands for labeling are as follows; \label{ch:label},
\label{sec:label}, \label{subsec:label}, \label{tab:label}, \label{fig:label}
and \label{eq:label} etc. To refer to any label in the document, \ref{} command is
used, while for page number referencing \pageref{} is used. As an example, the follow-
ing sentence is referring to a Figure and Table in the text.
Command view

In this document, comparative analysis between MS Word and LaTeX is shown


in Figure \ref{fig:2}, while basic structure of LaTeX is discussed in Table
\ref{tab:structure}.

Output view: as shown in Figure 6.3.

Figure 6.3: Output of the Figure and Table cross-referencing

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}

The output view of the above command is shown in Figure 6.4.

Figure 6.4: Output of the different sections and equation referencing

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.

6.5 Track changes in a document


To see all the changes made in a document, the following steps are to be followed in a
sequence.
6.5. TRACK CHANGES IN A DOCUMENT 53

1. The main tex document is e.g. Original.tex

2. Copy paste this file in the same folder and rename it as e.g. Revised.tex

3. Go the webpage https://downloads.activestate.com/ActivePerl/releases/5.24.3.2404/


and download and install ActivePerl-5.24.3.2404-MSWin32-x64-404865

4. Open MilTeX console and install the package latexdiff

5. It’s better to restart the computer after these installations

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.

8. Open command terminal (cmd) and type

latexdiff Original.tex Revised.tex > diff.tex

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.

Figure 6.5 shows the track changes in a document.


54 CHAPTER 6. MATHEMATICS AND EQUATIONS

Figure 6.5: Track changes in a LaTeX document.


Chapter 7

Presentation-Beamer

7.1 Beamer introduction


Making presentation with LaTeX is an easy and quick job for those who have learnt some
basic commands of LaTeX. Among some other advantages of making presentation with
LaTeX are;

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

3. A huge range of overlays and dynamic effects available in LaTeX

4. Equations and mathematical formula look neater, and can be easily copied from a
LaTeX document

5. Beamer comes with a wide range of familiar themes

Among the disadvantages; it is unlike Powerpoint where ‘select and operate’ works, and
some knowledge of LaTeX is required.

7.2 Title slide


To start with a presentation, the documentclass is defined as ‘beamer’ as \documentclass{beamer}
Some optional formatting commands can be applied in square brackets as
\documentclass[options]{beamer}. There are several options that can be specified
to the package, for example, ‘slidestop’ puts frame titles on top left corner (while the
default is slidescentered), ‘compress’ makes all navigation bars as small as possible (while
the default is un-compressed) etc.
To design a title slide, the following command is used;

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.

7.3 Customized Title Page


\documentclass[12pt]{beamer}
\usetheme{Boadilla}
\makeatother
\setbeamertemplate{footline}
58 CHAPTER 7. PRESENTATION-BEAMER

{
\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.

7.4 General slide


For a slide, other than title slide, the following command is used;
7.4. GENERAL SLIDE 59

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}

This will generate a slide, as shown in Figure 7.4.


60 CHAPTER 7. PRESENTATION-BEAMER

Figure 7.4: Output of the commands that generates the title slide and general slide.

7.5 Table of Contents


To create table of contents, the frame environment is as follows;

\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.

7.6 Sections and Subsections


A presentation can be structured using the usual LaTeX commands of \section{} and
\subsection{} before the frame environment.
This will generate an entry into the ‘Table of Contents’ as well as insert a new entry
into the navigation bars (in many themes) but does not generate a frame heading or any
text in the slide the version. While, the command \section*{} adds only an entry in
the navigation bars, but not in the ‘Table of Contents’. For example, the following code
will generate the output, as shown in Figure 7.6.

\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}

Figure 7.6: Output of the section and subsection commands.

7.7 Themes
7.7.1 Inner Themes
The inner themes specify the typesetting of elements within the frame such as:

• title and part pages

• itemize, enumeration and description environment

• blocks, theorems, examples, alerts and proof environment

• figures and tables

• 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

Figure 7.8: Starting numbering from some specific number.

In environment, the mathematical blocks can be generated by using the following


commands;

\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}

will produce the output, as shown in Figure 7.9.

7.8 Text in boxes


Like mathematical boxes, texts can also be inserted in general blocks. For example, the
following code generates the output, as shown in Figure 7.10.

\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

Figure 7.9: The mathematical blocks.

\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.

7.9.1 Pause Command


the \pause command pauses the next line and comes in display by pressing ‘enter’.
By using this command somewhere in the frame, only the text on the frame up to the
\pause command is shown on the first slide. On the second slide, everything up to the
second \pause and so on. This command can be used inside environments, mathematical
equations and texts.

\begin{frame}
\begin{enumerate}
\item First
\pause
\item Second
\pause
\item Third
66 CHAPTER 7. PRESENTATION-BEAMER

Figure 7.10: Different types of blocks.

\pause
\item Fourth
\end{enumerate}
\end{frame}

This will produce the output as bullet text and appear as one-onward by pressing enter.

7.9.2 Pointed Brackets Command


In order to show some text and then show next text, while the first shown text disappears,
pointed brackets as ¡...¿ are used. For example;

\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

7.9.3 Special Commands


The following commands have special overlay specifications which affect the text within
the curly brackets or behind the command, as taken from Kathrin Wunsch presentation
in Figure 7.11. The previous commands and these special commands can be applied to
different environments and graphics.

7.10 Column, Spaces and Alignments


To generate columns, the \begin{columns} and \end{columns} is used. For example,
the following command;

\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}

produces the output as shown in Figure 7.12.


68 CHAPTER 7. PRESENTATION-BEAMER

Figure 7.11: Special commands for overlay specifications.

7.11 Smart Diagrams


The package \usepackage{smartdiagram} can be used to draw smart diagrams. The
following code generates the output, as shown in Figure 7.13.

\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}

The following code generates the output, as shown in Figure 7.14.

\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}

The following code generates the output, as shown in Figure 7.15.

\smartdiagram[descriptive diagram]{{\LaTeX,{Used for technical writing}},


7.11. SMART DIAGRAMS 69

Figure 7.12: Columns and blocks in a slide.

{STR, {The Special Theory of Relativity}},


{GTR, The General Theory of Relativity},
{GUT, Grand Unification Theory}}

The following code generates the output, as shown in Figure 7.16.

\smartdiagram[priority descriptive diagram]{General Theory of Relativity,


Special Theory of Relativity,
Gravitational Lensing,
Existence of Blackholes,
No Absolute Time,
Spacetime Coordinates}

The following code generates the output, as shown in Figure 7.17.

\smartdiagram[flow diagram:horizontal]{\TeX,
\LaTeX, \TeX Studio, \TeX Maker}
70 CHAPTER 7. PRESENTATION-BEAMER

Figure 7.13: Smart diagram in circular form.

Figure 7.14: Smart diagram in round rectangular boxes.


7.11. SMART DIAGRAMS 71

Figure 7.15: Smart diagram in round rectangular boxes.


72 CHAPTER 7. PRESENTATION-BEAMER

Figure 7.16: Smart diagram in line rectangular boxes.

Figure 7.17: A flowchart in horizontal form.


Chapter 8

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.

Table 8.1: Inputs and outputs of bond types

Bond type Command Output


single \chemfig{A-B} A B
double \chemfig{A=B} A B
triple \chemfig{A~B} A B
wedge solid \chemfig{<} and \chemfig{>} and
wedge hollow \chemfig{<|} and \chemfig{>|} and
wedge dash \chemfig{<:} and \chemfig{>:} and

8.1 Bond angles


An angle in the range 0◦ –360◦ can be defined as an absolute between two atoms or relative
among more than two atoms. For example,

1. If two atoms A and B are at 30◦ , the command is


B
\chemfig{A-[:30]B}, which will produce A

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]}

8.2 Editing bonds and angles


1. Bond length between two atoms can be changed from the default settings by incor-
porating length in the square brackets. For example, the command;
B

\chemfig{A-[:30,1.5]B} gives A
B

and the command \chemfig{A-[:30,3]B} gives A

2. Color of bond is changed by incorporating name of the color in square brackets.


8.3. RING STRUCTURES 75

That is, the command


B
\chemfig{A-[:30,,,,red]B} gives A
It is to be noted that color name to be mentioned after fourth comma.

3. Width of the line can be changed as; the command


B
\chemfig{A-[:30,,,,line width=2pt]B} gives A

and the command


B
\chemfig{A-[:30,,,,red,line width=2pt]B} gives A

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

8.3 Ring structures


1. A ring structure of 6 sides can be produced by the command \chemfig{*6(------)}

2. A ring structure of 8 sides can be produced by the command \chemfig{*8(--------)}

3. A benzene structure by a command \chemfig{*6(-=-=-=)}

4. A branched extension to the benzene structure by a command Ring with branch:


\chemfig{*6(-=-(-[:30]=[:-30]-[:30])=-=-)}
76 CHAPTER 8. CHEMISTRY

5. A complete ring with three atoms by the command \chemfig{A*3(-B-C-)}


C
B
A

6. An incomplete ring with three atoms by the command \chemfig{A*3(-B-C)}


C
B
A

7. For nested rings, the command


Nested rings: \chemfig{*5(--*6(-*4(-*5(----)--)----)---)}

8.4 Lewis structures


For Lewis structure, the command \lewis{} is used. In Lewis structure, predefined
angles are used, i.e 0◦ =0, 45◦ =1, 90◦ =2, 135◦ =3, 180◦ =4, 225◦ =5, 270◦ =6, 315◦ =7.
Angle is followed by a period “.” for a single electron and by a colon “:” for a paired
electron.

1. The following commands produces


\lewis{0.,O} → O \lewis{1.,O} → O \lewis{2.,O} → O
\lewis{3.,O} → O \lewis{4.,O} → O \lewis{5.,O} → O
\lewis{6.,O} → O \lewis{7.,O} → O

2. Similarly, The following commands produces


\lewis{0:,O} → O \lewis{1:,O} → O \lewis{2:,O} → O
\lewis{3:,O} → O \lewis{4:,O} → O \lewis{5:,O} → O
\lewis{6:,O} → O \lewis{7:,O} → O

3. A water molecule with a display of ions can be produced by


\chemfig{H-[:52.24]\lewis{1:3:,O}-[::-104.48]H}

H H

4. The ions can be written in a \chemfig{} as


\chemfig{A^+-B^{-}} produces A+ B−
8.5. CHEMICAL REACTION 77

8.5 Chemical reaction


A chemical reaction is enclosed in \schemestart and \schemestop commands, as the
hydrolysis of ester due to the presence of water can be written as;

\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.

Figure 9.1: The view of configuration interface.

79
80 CHAPTER 9. NOMENCLATURE

To write nomenclature in LATEX document, the following package is to be included in


the Preamble.
\usepackage{nomencl}
\makenomenclature
The place where nomenclature is to be printed, the following command is to written there
as; \printnomenclature
Example
Now to write nomenclature, the command \nomenclature{}{} is used. In the first curly
brackets, the symbol is written, as usually enclosed in $ $ symbols; while in the second
curly brackets, the name or abbreviation is written. The execution way is a bit different,
and is as follows;
PdfLaTeX→MakeIndex→PdfLaTeX→View PDF

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.

9.1 List of Abbreviations


To generate list of abbreviations, write the following command in the Preamble;
\renewcommand{\nomname}{List of Abbreviations} For example, in the following sec-
tion many abbreviations have been defined, from which we can generate list of abbrevia-
tions as;

Scanning electron microscopy (SEM) is used for microstructural analysis,


while X-ray diffraction (XRD) gives the phase of the material. For
detailed and in-depth compositional analysis, SEM is replaced by the
transmission electron microscopy (TEM). To find the molecular
structure of a material, Fourier transform infrared (FTIR) spectroscopy is used.
9.1. LIST OF ABBREVIATIONS 81

Figure 9.2: Nomenclature of the above example.

Abbreviations in the above paragraph are written as;

\nomenclature{SEM}{Scanning electron microscopy}


\nomenclature{XRD}{X-ray diffraction}
\nomenclature{TEM}{Transmission electron microscopy}
\nomenclature{FTIR}{Fourier transform infrared}
\printnomenclature

The above command will print the list of abbreviations on a separate page as shown in
Figure 9.3.

Figure 9.3: List of abbreviations

The space between abbreviation and definition can be changed by defining the space
82 CHAPTER 9. NOMENCLATURE

in square brackets in front of \printnomenclature[3cm]. This will insert 3cm space, as


shown in Figure 9.4.

Figure 9.4: List of abbreviations with 3cm spacings.


Chapter 10

Customization of LATEX

10.1 Changing the default names


By default, LATEXwill adopt the name ‘Bibliography’ for references at the end. In order
to change the name from ‘Bibliography’ to ‘References’, the \renewcommand{}{} is used
as;
\renewcommand{\bibname}{References}
Similarly, when nomenclature is printed, it prints the default name as “Nomenclature”.
To change the default name to “List of Abbreviations”, the following command is used.
\renewcommand{\nomname}{List of Abbreviations} Similarly, Table 10.1 discuss the
default LaTeX style, the desired style and the respective command for the desired style.

Table 10.1: The default LaTeX styles, the desired styles and the respective commands
for the desired styles.

Default Style Desired Style Commands


Abstract ABSTRACT \renewcommand{\abstractname}{ABSTRACT}
Chapter CHAPTER \renewcommand{\chaptername}{CHAPTER}
Figure Fig. \renewcommand{\figurename}{Fig.}
Figure FIGURE \renewcommand{\figurename}{FIGURE}
Table TABLE \renewcommand{\tablename}{TABLE}
Table of Contents CONTENTS \renewcommand{\contentsname}{CONTENTS}
List of Figures FIGURES \renewcommand{\listfigurename}{FIGURES}
List of Tables TABLES \renewcommand{\listtablename}{TABLES}
Bibliography REFERENCES \renewcommand{\bibname}{REFERENCES}
References REFERENCES \renewcommand{\refname}{REFERENCES}

10.2 Changing the default style


By default, LATEXwrites the Chapter and its Name as left-aligned. In order to change
both the Chapter and its Name to center-aligned, the package \usepackage{sectsty}

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.

Figure 10.1: Chapter and its Name as left-aligned

Figure 10.2: Chapter and its Name as center-aligned


10.3. NEW COMMANDS 85

10.3 New commands


In LATEX, in addition to the the built-in commands, new commands can also be de-
fined and used in LaTeX. in the Preamble, add \newcommand{}{} in the first curly
brackets, write the command of choice, while in the second curly brackets, the de-
sired functioning or phrase or a sentence etc. e.g., if a new command is defined as
\newcommand{\asf}{as shown in Figure}; it will insert ‘as shown in Figure’, wher-
ever \asf is inserted.
86 CHAPTER 10. CUSTOMIZATION OF LATEX
Chapter 11

References

Insertion of references is the easiest job in LATEXcompared to MS Word or other refer-


ence managing softwares like Endnote or Mendeley etc. The following packages are to be
activated first in the Preamble; \‘usepackage{natbib}, \usepackage{hyperref} and
\usepackage{filecontents} At the end of the document (article, thesis etc.), all the ref-
erences are to be put inside these commands \begin{filecontents}{References.bib}
and \end{filecontents} Here, LATEXwill generate automatically the specified file (Ref-
erences.bib) in the folder containing the LaTeX document.

11.1 Inserting a Reference


To download a reference, follow the following steps;

1. Search a reference on Google Scholar webpage

2. When a selected reference is shown, click on inverted commas below the link to
show various available referencing formats

3. Scroll down to BibTeX option

4. By clicking BibTeX, a text arranged in the following format will be opened

@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

publisher={Nature Publishing Group}


}

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.

7. After the \end{filecontents}, write the following two commands


\bibliographystyle{plain}
\bibliography{References}

8. In the above commands, the first command \bibliographystyle{plain}, spec-


ifies the bibliographic style as ‘plain’. Other styles include ‘abbrv’, ‘unsrt’ and
‘alpha’. While the second command, \bibliography{References} mention the
file ‘References.bib” but here it will be written without extension.

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.

(a) Run, ‘Quick Build’ once

(b) From the drop-down menu, Run ‘BibTeX’ once

(c) Run, ‘Quick Build’ twice


11.1. INSERTING A REFERENCE 89

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}

11.1.1 Editing a Reference


• Title: Capital Letters
LATEX converts ‘Title’ of the reference to a plain text and capitalizing only the First
letter of the title. If the Title contains some capital letters, they will automatically
be converted to small letters. As in the above example, in the title, “TiO” is used,
which will be converted in the reference as “tio”. To keep the letters as they are,
the letters or the whole word is to be enclosed in curly brackets without changing
any bracket or format of the reference, as;
title={Effects of graphene in graphene/{TiO} composite films} will pro-
duce the title as
“Effects of graphene in graphene/TiO composite films”.

• Title: Subscripts and Superscripts


In the case, the reference contains a subscript or superscript, it is to be corrected
the way which was discussed in Section 6.2.5. For example, if in the title a word
appears as “TiO2 ”, it will be automatically converted to plain text as “TiO2”. The
correction as for subscript as {TiO$_2$} will produce TiO2 in the title.

• 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 and Year


In the case volume and year are to be bold, they can be bold manually as

volume={7},
year={2016}

can be changed as
90 CHAPTER 11. REFERENCES

volume={\textbf{7}},
year={\textbf{2016}}

The actual brackets must not be tempered.

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.

11.2 Customized reference style


Making one’s own Reference style is a complicated and one-go process, which is executed
in ‘Command Prompt’. It makes up a docstrip batch job to produce a customized .bst
file for running with BibTeX. ‘Makebst’ command can be used to automatically generate
a *.bst file based on one’s input. It will ask a series of sensible questions and once it
is complete, it will then output the appropriate style file at the ‘User Folder’. To make
a ‘*.bst’ file, follow the following steps; Click on ‘Search’ and type ‘cmd’ A command
prompt will open, type ‘latex makebst’ without quotes and press ‘Enter’. If it asks for
download, proceed with the downloading certain files. The first question that will appear
will be; Do you want a description of the usage? (NO). This means the default value
is NO, if you press enter, the default value will be selected. If the default value is not
desired, type y and press enter, then. A lengthy series of questions will start, and one
will have to carefully select its choice, as once an option is selected, there’s no going back
or alteration possible, the whole process is to be started again. Some of the possible
questions are reproduced as follows;

Enter the name of the MASTER file (default=merlin.mbs)

Name of the final OUTPUT .bst file? (default extension=bst)

Give a comment line to include in the style file.


Something like for which journals it is applicable.

Do you want verbose comments? (NO)

Name of language definition file (default=merlin.mbs)

Name of language file:

Include file(s) for extra journal names? (NO)


11.2. CUSTOMIZED REFERENCE STYLE 91

INTERNAL LANGUAGE SUPPORT (if no external language file)


(*) English words used explicitly
(b) Babel (words replaced by commands defined in babelbst.tex)
Select:
\begin{verbatim}
STYLE OF CITATIONS:
(*) Numerical as in standard LaTeX
(a) Author-year with some non-standard interface
(b) Alpha style, Jon90 or JWB90 for single or multiple authors
(o) Alpha style, Jon90 even for multiple authors
(f) Alpha style, Jones90 (full name of first author)
(c) Cite key (special for listing contents of bib file)
Select:
STYLE OF CITATIONS:
(*) Numerical as in standard LaTeX
(a) Author-year with some non-standard interface
(b) Alpha style, Jon90 or JWB90 for single or multiple authors
(o) Alpha style, Jon90 even for multiple authors
(f) Alpha style, Jones90 (full name of first author)
(c) Cite key (special for listing contents of bib file)
Select:

HTML OUTPUT (if non author-year citations)


(*) Normal LaTeX output
(h) Hypertext output, in HTML code, in paragraphs
(n) Hypertext list with sequence numbers
(k) Hypertext with keys for viewing databases
Select:

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:

ORDERING OF REFERENCES (if non-author/year and non-alph)


(*) Alphabetical by all authors
(c) Citation order (unsorted, like unsrt.bst)
(d) Year ordered and then by authors
(r) Reverse year ordered and then by authors
Select:

ORDER ON VON PART (if not citation order)


(*) Sort on von part (de la Maire before Defoe)
(x) Sort without von part (de la Maire after Mahone)
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:

PUNCTUATION BETWEEN AUTHOR NAMES:


(*) Author names separated by commas
(s) Names separated by semi-colon
(h) Names separated by slash /
11.2. CUSTOMIZED REFERENCE STYLE 93

Select:

ADJACENT REFERENCES WITH REPEATED NAMES:


(*) Author/editor names always present
(d) Repeated author/editor names replaced by dash
(2) Repeated author/editor names replaced by 2 dashes
(3) Repeated author/editor names replaced by 3 dashes
Select:

NUMBER OF AUTHORS IN BIBLIOGRAPHY:


(*) All authors included in listing
(l) Limited authors (et al replaces missing names)
Select:

Maximum number of authors (1-99)


Minimum number (before et al given) (1-3)
AUTHORS IN CITATIONS:
(*) One author et al for three or more authors
(m) Some other truncation scheme
Select:
TYPEFACE FOR AUTHORS IN LIST OF REFERENCES:
(*) Normal font for author names
(s) Small caps authors (\sc)
(i) Italic authors (\it or \em)
(b) Bold authors (\bf)
(u) User defined author font (\verb;\bibnamefont;)
Select:
DATE POSITION:
(*) Date at end
(b) Date after authors
(j) Date part of journal spec. (as 1994;45:34-40) else at end
(e) Date at very end after any notes
Select:
DATE FORMAT (if non author-year citations)
(*) Plain month and year without any brackets
(p) Date in parentheses as (May 1993)
(b) Date in brackets as [May 1993]
(c) Date preceded by colon as ‘: May 1993’
94 CHAPTER 11. REFERENCES

(d) Date preceded by period as ‘. May 1993’


(m) Date preceded by comma as ‘, May 1993’
(s) Date preceded by space only, as ‘ May 1993’
Select:
SUPPRESS MONTH:
(*) Date is month and year
(x) Date is year only
Select:
DATE FONT:
(*) Date in normal font
(b) Date in bold face
Select:
TITLE OF ARTICLE:
(*) Title plain with no special font
(i) Title italic (\em)
(q) Title and punctuation in single quotes (‘Title,’ ..)
(d) Title and punctuation in double quotes (‘‘Title,’’ ..)
(g) Title and punctuation in guillemets (<<Title,>> ..)
(x) Title in single quotes (‘Title’, ..)
(y) Title in double quotes (‘‘Title’’, ..)
(z) Title in guillemets (<<Title>>, ..)
Select:
CAPITALIZATION OF ARTICLE TITLE:
(*) Sentence style (capitalize first word and those in braces)
(t) Title style (just as in bib entry)
Select:
ARTICLE TITLE PRESENT:
(*) Article title present in journals and proceedings
(x) No article title
Select:
JOURNAL NAMES:
(*) Periods in journal names are retained, as ‘Phys. Rev.’
(x) Dotless journal names as ‘Phys Rev’
Select:
JOURNAL NAME FONT:
(*) Journal name italics
(r) Journal name normal font
Select:
THESIS TITLE:
11.2. CUSTOMIZED REFERENCE STYLE 95

(*) Thesis titles like books


(a) Thesis title like article
(x) No thesis title
Select:
TECHNICAL REPORT TITLE:
(*) Tech. report title like articles
(b) Tech. report title like books
Select:
TECHNICAL REPORT NUMBER:
(*) Tech. report and number plain as ‘Tech. Rep. 123’
(i) Tech. report and number italic as ‘{\it Tech. Rep. 123’}
Select:
JOURNAL VOLUME:
(*) Volume plain as vol(num)
(i) Volume italic as {\em vol}(num)
(b) Volume bold as {\bf vol}(num)
(d) Volume and number bold as {\bf vol(num)}
Select:
JOURNAL VOL AND NUMBER:
(*) Journal vol(num) as 34(2)
(s) Journal vol (num) as 34 (2)
(c) Journal vol, num as 34, 2
(n) Journal vol, no. num as 34, no. 2
(h) Journal vol, \# number as 34, \#2
(b) Journal vol number as 34 2
(x) Journal vol, without number as 34
Select:
VOLUME PUNCTUATION:
(*) Volume with colon as vol(num):ppp
(s) Volume with colon and space as vol(num): ppp
(h) Volume with semi-colon as vol(num); ppp
(c) Volume with comma as vol(num), ppp
(b) Volume with blank as vol(num) ppp
Select:
YEAR IN JOURNAL SPECIFICATION:
(*) Journal year like others as given by date position
(v) Journal vol(year) as 34(1995)
(s) Journal vol (year) as 34 (1995)
(p) Year with pages as 34(2), (1995) 1345--1387
96 CHAPTER 11. REFERENCES

(c) Year, comma, pages as 34(2), (1995), 1345--1387


Select:
PAGE NUMBERS:
(*) Start and stop page numbers given
(f) Only start page number
Select:
LARGE PAGE NUMBERS:
(*) No separators for large page numbers
(c) Comma inserted over 9999 as 11,234
(s) Thin space inserted over 9999 as 11 234
(p) Period inserted over 9999 as 11.234
Select:
WORD ‘PAGE’ IN ARTICLES:
(*) Article pages numbers only as 234-256
(p) Include ‘page’ in articles as pp. 234--256
Select:
POSITION OF PAGES:
(*) Pages given mid text as is normal
(e) Pages at end but before any notes
Select:
WORD ‘VOLUME’ IN ARTICLES:
(*) Article volume as number only as 21
(p) Include ‘volume’ in articles as vol. 21
Select:
NUMBER AND SERIES FOR COLLECTIONS:
(*) Allows number without series and suppresses word "number"
(s) Standard BibTeX as: "number 123 in Total Works"; error if number and no ser
ies
Select:
POSITION OF NUMBER AND SERIES:
(*) After chapter and pages as in standard BibTeX
(t) Just before publisher or organization
Select:
VOLUME AND SERIES FOR BOOKS/COLLECTIONS:
(*) Vol. 23 of Series as in standard BibTeX
(s) Series, vol. 23
Select:
POSITION OF VOLUME AND SERIES FOR INCOLLECTIONS:
(*) Series and volume after the editors
11.2. CUSTOMIZED REFERENCE STYLE 97

(e) Series and volume after booktitle and before editors


Select:
JOURNAL NAME PUNCTUATION:
(*) Comma after journal name
(x) Space after journal name
Select:
BOOK TITLE:
(*) Book title italic (\em)
(p) Book title plain (no font command)
Select:
PAGES IN BOOKS:
(*) Pages in book plain as pp. 50-55
(p) Pages in book in parentheses as (pp. 50-55)
(x) Pages in book bare as 50-55
Select:
TOTAL PAGES OF A BOOK:
(*) Total book pages not printed
(p) For book: 345 pages or pp.
(a) Total book pages before publisher
Select:
PUBLISHER ADDRESS:
(*) Publisher, address as Harcourt, New York
(a) Address: Publisher as New York: Harcourt
Select:
PUBLISHER IN PARENTHESES:
(*) Publisher as normal block without parentheses
(p) Publisher in parentheses
(d) Publisher and date in parentheses (Oxford, 1994)
(c) Publisher and date in parentheses, no comma (Oxford 1994)
(f) Publisher and date without parentheses Oxford, 1994
(k) Publisher and date, no parentheses, no comma Oxford 1994
Select:
PUBLISHER POSITION:
(*) Publisher after chapter, pages
(p) Publisher before chapter, pages
(e) Publisher after edition
Select:
ISBN NUMBER:
(*) Include ISBN for books, booklets, etc.
98 CHAPTER 11. REFERENCES

(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

(u) Colon after titles of articles, books, etc else commas


(a) Period after titles of articles else commas
(d) Colon after titles of articles else commas
Select:
PUNCTUATION AFTER AUTHORS:
(*) Author block normal with regular block punctuation
(c) Author block with colon
Select:
PUNCTUATION AFTER ‘IN’:
(*) Space after ‘in’ for incollection or inproceedings
(c) Colon after ‘in’ (as ‘In: ...’)
(i) Italic ‘in’ and space
(d) Italic ‘in’ and colon
(x) No word ‘in’ for edited works
Select:
FINAL PUNCTUATION:
(*) Period at very end of the listed reference
(x) No period at end
Select:
ABBREVIATE WORD ‘PAGES’ (if not using external language file)
(*) ‘Page(s)’ (no abbreviation)
(a) ‘Page’ abbreviated as p. or pp.
(x) ‘Page’ omitted
Select:
ABBREVIATE WORD ‘EDITORS’:
(*) ‘Editor(s)’ (no abbreviation)
(a) ‘Editor’ abbreviated as ed. or eds.
Select:
OTHER ABBREVIATIONS:
(*) No abbreviations of volume, edition, chapter, etc
(a) Abbreviations of such words
Select:
ABBREVIATION FOR ‘EDITION’ (if abbreviating words)
(*) ‘Edition’ abbreviated as ‘edn’
(a) ‘Edition’ abbreviated as ‘ed’
Select:
MONTHS WITH DOTS:
(*) Months with dots as Jan.
(x) Months without dots as Feb Mar
100 CHAPTER 11. REFERENCES

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

You might also like