0% found this document useful (0 votes)
11 views29 pages

Latex Book

The document is a comprehensive guide on LaTeX, a high-quality typesetting system used for various types of documents. It covers the basics of LaTeX, installation instructions, document formatting, and advanced features like font styles, alignments, and lists. The guide is specifically designed for beginners transitioning from Microsoft Word, providing step-by-step tutorials and examples.

Uploaded by

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

Latex Book

The document is a comprehensive guide on LaTeX, a high-quality typesetting system used for various types of documents. It covers the basics of LaTeX, installation instructions, document formatting, and advanced features like font styles, alignments, and lists. The guide is specifically designed for beginners transitioning from Microsoft Word, providing step-by-step tutorials and examples.

Uploaded by

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

LaTeX Tutorials

K. A. Kshirsagar and S. A. Tarate


Department of Mathematics, New Arts, Commerce and Science (Autonomous)
College, Ahmednagar

1 What is LaTeX?
LaTeX is a document preparing system for high-quality typesetting. It is used for Articles, Research
Papers, Scientific and Technical Documents, Presentations, Law-Texts, Scorecards, Bills, Letters,
Books, Reports and almost any form of publishing. LaTeX maintains its standards. A high quality
auto formatting of the content is perhaps the best feature in LaTeX. Just we have to take care of
the proper content and rest will be done by LaTeX.

2 Why LaTeX?
→ Open Source and Freeware
→ Available for Windows, Linux, Macintosh, Browsers, Android
→ Low Sized documents with High Quality Outputs
→ Post Script and Pdf Outputs
→ Extremely Stable: Handles very large and complex documents Smoothly
→ Cross Referencing Capabilities : Figures, Tables, Equations, Index etc.
→ Automatic Numbering: Chapters, Sections, Figures, Equations etc.
→ Automatic Generations : List of Contents, List of Figures, Index, Bibliography etc.
→ Constantly Evolving and Standard is maintained
→ Same Output Anytime, Anywhere on Any Operating System

3 How to use this Book?


This book is intended for beginners of LaTeX. It is specially written keeping in mind the difficulties
of those who are used to use Microsoft Word. Almost all tasks that one is used to do in MS word
are covered. A simple principle is used: Do it (Type it) . . . Get it. So you just have to type tutorials
(or copy and paste from pdf file to LaTeX editor) . . . Understand the things . . . and you will learn
LaTeX!
Caution!: This book is NOT for intermediate or advanced users of LaTeX!.

4 Installing LaTeX
For creating and viewing documents, two things are required:
i) TeX Distribution ii) LaTeX Editor.
TeX viewers and LaTeX Editors are available across platforms: Windows, Linux, Mac OS, Browser-
based and Android. For Windows Operating System, following is the list of some of popular TeX
distributions and LaTeX editors. Many of LaTeX editors are freewares while some of them are
sharewares.
TeX Distributions LaTeX Editors

TeX Live Texworks Editor, Texnic Centre, Tex Studio

MikTex Winedt, Lyx, Texmaker, Winshell

To begin creating your documents you may use “Miktex + Texworks Editor” or ”Miktex + “Texnic
Centre” or maybe “Miktex + Tex Studio”.

5 Understanding Basics
There are very few basic things that you need to understand . . . not more than two . . .
A) Command Format in LaTeX
\CommandName[Optional Argmument]{Compulsory Argument}
OR
\CommandName{Compulsory Argument}[Optional argument]

Every Command in LaTeX is of this form. It starts with Backslash followed by Command
Name, Optional Arguments in Square Brackets (if any) and Compulsory Arguments in Curly
Brackets.
Examples:
\documentclass[11pt]{article}
\documentclass{article}
\documentclass{article}[11pt]

B) Environments in LaTeX
\begin{environment}
...
...
\end{environment}

In LaTeX we always work in environments like this.


Examples:
\begin{document} ... \end{document}
\begin{equation} ... \end{equation}
\begin{tabular} ... \end{tabular}

Believe it or not . . . if you clearly understood the above basics, half of the job is done. You
are advised to read the above basics once again.
Remember:
A) \CommandName[Optional Argmument]{Compulsory Argument}

B) \begin{environment} ... \end{environment}

6 First Document
Type as in the following box.
\documentclass[11pt]{article}
\begin{document}
This is Our First Document.
\end{document}

Compile and Check the Output.

This is Our First Document.

Congrats . . . ! First Document is Compiled and Produced Successfully.

7 Line Break or New Line

What you type ? What you get ?

First Sentence in Line.


First Sentence in Line. Second Sentence in Same Line.
Second Sentence in Same Line.
First Sentence in Line. \\
First Sentence in Line.
Second Sentence in New Line.
Second Sentence New Line.

Key Point: A doubleslash \\ is used for New Line. The alternative is to use \newline.
Similarly, \newpage is used for New Page.

8 New Paragraph
A Blank Line is used for new paragraph.

What you type ? What you get ?

I Sentence in I Paragraph.\\
I Sentence in I Paragraph.
II Sentence in New Line but in Same Paragraph.
II Sentence in New Line but in Same Paragraph.
I Sentence in I Paragraph.\\
I Sentence in I Paragraph.
II Sentence in New Line and in New Paragraph.
II Sentence in New Line and in New Paragraph.

Points to Understand
A) Multiple Spaces are equivalent to Single Space in LaTeX. For example,
How Are You?
and
How Are You ?
produce same viz. How Are You?
B) Multiple Blank Lines are equivalent to Single Blank Line in LaTeX. For Example,
This is First Sentence.
This is Second Sentence.
and
This is First Sentence.

This is Second Sentence.

produce same viz.


This is First Sentence.
This is Second Sentence.

Tips
1. For manually adding spaces, type backslash and space ( \ ). It acts as Spacebar in LaTeX.
2. For manually adding blank lines, type backslash two times (\\). It acts as Enter in
LaTeX.

9 Font Styles

What you type ? What you get ?

\textbf{This is text in Bold font.} This is text in Bold font.

\textit{This is text in Italic font.} This is text in Italic font.

\underline{This is Underlined text.} This is Underlined text.

\emph{This is Emphasized text.} This is Emphasized text.

\textsl{This is Slanted text.} This is Slanted text.

10 Typing Out Special Symbols

What you type ? What you get ?

\# \$ \% \{ \} \& \_ \textbackslash \textendash \textemdash #$ % { } & \–—

\copyright \textregistered \texttrademark ©®™

Key Point: For typing out many of special symbols, we just have to type \ before it.
11 Different Fonts

What you type ? What you get ?

\texttt {A text in Typewriter Font.} A text in Typewriter Font.

\textsf{A text in Serif Font.} A text in Serif Font.

\textrm{A text in Roman Font.} A text in Roman Font.

12 Font Size

What you type ? What you get ?

\tiny Tiny, \scriptsize Scriptsize Tiny, Scriptsize

\footnotesize Footnotesize, \small Small Footnotesize, Small

\normalsize Normal Normal

\large Large, \Large Larger Large, Larger

\huge Largest, \Huge Largest Largest, Largest


13 Alignments

What you type ? What you get ?

\begin{raggedright}
This is RaggedRight text. This is RaggedRight text.
\end{raggedright}

This is Normally Aligned text. This is Normally Aligned text.

\begin{center}
This is Center Aligned Text. This is Center Aligned Text.
\end{center}

\begin{raggedleft}
This is RaggedLeft text. This is RaggedLeft text.
\end{raggedleft}
14 Adding Horizontal and Vertical Space

\documentclass{article}
A horizontal space of 10 points.
\begin{document}
A horizontal \hspace{10pt} space of 10 points.\\ A horizontal space of 2 cm.
A horizontal \hspace{2cm} space of 2 cm.\\
A first Paragraph.
A first Paragraph.

\vspace{1cm} A second Pargraph with additional


A second Pargraph with additional space of 1cm.
\end{document}
space of 1cm.

Key Point: Use \hspace and \vspace for adding horizontal and vertical space.

15 Page Layout
\documentclass{article}
\begin{document}
This is a sample document.
\end{document}

With above, a document is produced having default parameters as


Paper Size: Letter, Font: Computer Modern, Font Size: 10pt., Orientation: Portrait, One Column
\documentclass[12pt]{article}
\usepackage[a4paper,landscape]{geometry}
\begin{document}
This is a sample document.
\end{document}

With above, a document is produced having parameters as


Paper Size: A4, Font: Computer Modern, Font Size: 12pt., Orientation: Landscape, One Column
\documentclass[14pt,twocolumn]{article}
\usepackage[legalpaper,landscape]{geometry}
\begin{document}
This is a sample document.
\end{document}

With above, a document is produced having parameters as


Paper Size: Legal, Font: Computer Modern, Font Size: 14pt., Orientation: Landscape, Two
Columns
\documentclass[14pt,twocolumn]{article}
\usepackage[paperheight=11in,paperwidth=8.5in,landscape,
left=1in,right=1in,top=1in,bottom=1cm]{geometry}
\begin{document}
This is a sample document.
\end{document}

With above, a document is produced having parameters as


Paper Height: 11 inch, Paper Width: 8.5 inch, Font: Computer Modern, Font Size: 14pt., Orien-
tation: Landscape, Two Columns, Left Margin: 1 inch, Right Margin: 1 inch, Top Margin: 1 inch,
Bottom Margin : 1 cm
Different Page Size in LaTeX

a0paper, a1paper, ..., a6paper,


b0paper, b1paper, ..., b6paper,
letterpaper,
legalpaper,

Different Document Classes in LaTeX: Article, Letter, Book, Report, Slides , Beamer etc.

Key Point: Use Geometry Package for Selecting Paper Size, Setting Margins, Orientation.

16 Drawing Line
\documentclass{article}
\begin{document}
\rule{\linewidth}{1pt}
\end{document}

produces a simple line as follows

Point to Understand: The command format is


\rule[raise-height]{width}{thickness}

1. raise height specifies how high to raise the rule (optional).


2. width specifies the length of the rule (mandatory).
3. thickness specifies the thickness of the rule (mandatory).
17 Bullets and Numbering

\documentclass{article} \documentclass{article} \documentclass{article}


\begin{document} \begin{document} \usepackage{enumitem}
\textbf{Simple List} \textbf{Numbered List} \begin{document}
\begin{itemize} \begin{enumerate} \textbf{Small Alphabetic List with dot}
\item First Member \item First Member \begin{enumerate}[label=\alph*.]
\item Second Member \item Second Member \item First Member
\item Third Member \item Third Member \item Second Member
\end{itemize} \end{enumerate} \item Third Member
\end{document} \end{document} \end{enumerate}
\end{document}

Simple List Numbered List Small Alphabetic List with dot


• First Member 1. First Member a. First Member
• Second Member 2. Second Member b. Second Member
• Third Member 3. Third Member c. Third Member

\documentclass{article} \documentclass{article}
\usepackage{enumitem} \usepackage{enumitem}
\begin{document} \begin{document}
\textbf{Small Roman List with dot} \textbf{Capital Alphabetic List with bracket}
\begin{enumerate}[label=\roman*.] \begin{enumerate}[label=\Alph*)]
\item First Member \item First Member
\item Second Member \item Second Member
\item Third Member \item Third Member
\end{enumerate} \end{enumerate}
\end{document} \end{document}

Small Roman List with dot Capital Alphabetic List with bracket
i. First Member A) First Member
ii. Second Member B) Second Member
iii. Third Member C) Third Member

Tip: [label = {}] for unlabelled lists.


\documentclass{article} \documentclass{article}
\usepackage{enumitem} \usepackage{paralist}
\begin{document} \begin{document}
\textbf{Capital Roman List with Bracket \textbf{Small Numbered List INSIDE PARAGRAPH : }
Starting from 3} This is a list inside paragraph.
\begin{enumerate}[label=\Roman*.,start=3] \begin{inparaenum}
\item First Member \item First Member
\item Second Member \item Second Member
\item Third Member \item Third Member.
\end{enumerate} \end{inparaenum}
\end{document} \end{document}

Capital Roman List with Bracket Starting Small Numbered List INSIDE PARAGRAPH : This
from 3 is a list inside paragraph. 1. First Member 2. Second Mem-
III. First Member ber 3. Third Member.
IV. Second Member
V. Third Member

\documentclass{article} \documentclass{article}
\usepackage{paralist} \begin{document}
\begin{document} \textbf{Nested List}
\textbf{Small Alphabetic List INSIDE \begin{itemize}
PARAGRAPH:} \item First Memeber of Main List
This is a list inside paragraph. \item Second Member of Main List
\begin{inparaenum}[a)] \item Third Member of Main List
\item First Member \begin{itemize}
\item Second Member \item First Member of Sublist of Third Member
\item Third Member. \item Second Member of Sublist of Third Member
\end{inparaenum} \end{itemize}
\end{document} \item Fourth and Last Member of Main List
\end{itemize}
\end{document}

Small Alphabetic List INSIDE PARA- Nested List


GRAPH: This is a list inside paragraph. • First Memeber of Main List
a) First Member b) Second Member c) Third • Second Member of Main List
Member. • Third Member of Main List
– First Member of Sublist of Third Member
– Second Member of Sublist of Third Member
• Fourth and Last Member of Main List

Key Points:
1. Use package enumitem for bullets and numbering.
2. Use package paralist for bullets and numbering inside a paragraph.
18 Listing Theorems, Examples, Def initions etc.

\documentclass{article} \documentclass{article}
\usepackage{paralist} \begin{document}
\begin{document} \textbf{Simple Definition List.}
\textbf{Definition List Inside Paragraph:} \begin{description}
\begin{inparadesc} \item[First Definition:]A first definition.
\item[First Definition:]A first definition. \item[Second Definition:]A second definition.
\item[Second Definition:]A second \item[Third Definition:]A third definition.
definition. \end{description}
\item[Third Definition:]A third definition. \end{document}
\end{inparadesc}
\end{document}

Inside Paragraph: First Definition: A first Simple Definition List.


definition. Second Definition: A second defi- First Definition: A first definition.
nition. Third Definition: A third definition. Second Definition: A second definition.
Third Definition: A third definition.

Key Points:
1. To produce definition lists
\begin{description}...\end{description}

2. Use package inparadesc for examples,definitions, theorems etc. inside a paragraph.

19 Numbered Lists of Theorems, Examples, Def initions, etc.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\newtheorem{thmv}{Theorem}
\newtheorem{dfnb}{Definition}
\newtheorem{lem}{Lemma}
\begin{thmv}
Theorem 1 This is a theorem.
This is a theorem.
\end{thmv} Theorem 2 This is another theorem.
\begin{thmv} Definition 1 This is definition.
This is another theorem. Definition 2 This is another definition.
\end{thmv} Lemma 1 This is lemma.
\begin{dfnb}
This is definition.
\end{dfnb}
\begin{dfnb}
This is another definition.
\end{dfnb}
\begin{lem}
This is lemma.
\end{lem}
\end{document}
20 Tabs in LaTeX

\documentclass{article}
\begin{document}
\begin{tabbing}
\= Tab1 \= Tab2 \= Tab3 \= Tab4 \= Tab5 \= Tab6 \\ Tab1 Tab2 Tab3 Tab4 Tab5 Tab6
\> Tab1 \\ Tab1
\> \>Tab2 \\ Tab2
\> \> \> Tab3 \\
Tab3
\> \> \> \> Tab4 \\
\> \> \> \> \> Tab5 \\ Tab4
\> \> \> \> \> \> Tab6 Tab5
\end{tabbing} Tab6
\end{document}

Key Points:
1. Use \= to SET tab positions.
2. Use \> to MOVE to tab positions.

21 Header and Footer

\documentclass{article} Left Header Center Header Right Header


\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\lhead{Left Header}
This is Content Part.
\chead{Center Header}
\rhead{Right Header}
\lfoot{Left Footer}
\cfoot{Center Footer}
\rfoot{Right Footer} Left Footer Center Footer Right Footer
\begin{document}
This is content part.
\end{document}

\documentclass{article} Left Header Center Header Right Header


\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\lhead{Left Header}
This is Content Part.
\chead{Center Header}
\rhead{Right Header}
\lfoot{Left Footer}
\cfoot{Page \thepage}
\rfoot{Right Footer} Left Footer Page 1 Right Footer
\begin{document}
This is content part.
\end{document}

Key Point: Use package fancyhdr for Header and Footer.


Point to Understand: \renewcommand {\headrulewidth}{0pt} is used to remove line after
header.

22 Tables
22.1 Simple Tables:

\documentclass{article}
\begin{document}
\textbf{Table: 3 columns (Center Aligned)}\\

\begin{tabular}{ccc} Table: 3 columns (Center Aligned)


\hline
\textbf{Column 1}&\textbf{Column 2}& \textbf{Column 3}\\ Column 1 Column 2 Column 3
\hline
11 12 13
11 & 12 & 13 \\
\hline 21 22 23
21 & 22 & 23 \\ 31 32 33
\hline
31 & 32 & 33 \\
\hline
\end{tabular}\\
\end{document}

Point to Understand:

1. A tabular environment for creating tables.


\begin{tabular}...\end{tabular}

2. l is used for left alignment, c is used for center alignment and r is used for right alignment.
3. & is used for separating entries in row.
4. \\ is used for end of row.
5. \hline is used for drawing horizontal line.
6. | is used for drawing vertical line.
\documentclass{article}
\begin{document}
\textbf{Table: 3 columns (Right Aligned)}\\

\begin{tabular}{rrr} Table: 3 columns (Right Aligned)


\hline
\textbf{Column 1} & \textbf{Column 2} & \textbf{Column 3} \\ Column 1 Column 2 Column 3
\hline
11 12 13
11 & 12 & 13 \\
\hline 21 22 23
21 & 22 & 23 \\ 31 32 33
\hline
31 & 32 & 33 \\
\hline
\end{tabular}\\
\end{document}

\documentclass{article}
\begin{document}
\textbf{Table: 3 columns (Left Aligned)}\\

\begin{tabular}{lll} Table: 3 columns (Left Aligned)


\hline
\textbf{Column 1} & \textbf{Column 2} & \textbf{Column 3} \\ Column 1 Column 2 Column 3
\hline
11 12 13
11 & 12 & 13 \\
\hline 21 22 23
21 & 22 & 23 \\ 31 32 33
\hline
31 & 32 & 33 \\
\hline
\end{tabular}\\
\end{document}

\documentclass{article}
\begin{document}
\textbf{Table: 3 columns (Fixed Width)}\\

\begin{tabular}{p{2cm}p{2cm}p{2cm}} Table: 3 columns (Fixed Width)


\hline
\textbf{Column 1} & \textbf{Column 2} & \textbf{Column 3} \\ Column 1 Column 2 Column 3
\hline
11 12 13
11 & 12 & 13 \\
\hline 21 22 23
21 & 22 & 23 \\ 31 32 33
\hline
31 & 32 & 33 \\
\hline
\end{tabular}\\
\end{document}
\documentclass{article}
\begin{document}
\textbf{Table: 3 columns (Center Aligned)}\\

\begin{tabular}{|c|c|c|} Table: 3 columns (Center Aligned)


\hline
\textbf{Column 1} & \textbf{Column 2} & \textbf{Column 3} \\ Column 1 Column 2 Column 3
\hline
11 12 13
11 & 12 & 13 \\
\hline 21 22 23
21 & 22 & 23 \\ 31 32 33
\hline
31 & 32 & 33 \\
\hline
\end{tabular}\\
\end{document}

\documentclass{article}
\begin{document}
\textbf{Table: 3 columns (Right Aligned)}\\

\begin{tabular}{|r|r|r|} Table: 3 columns (Right Aligned)


\hline
\textbf{Column 1} & \textbf{Column 2} & \textbf{Column 3} \\ Column 1 Column 2 Column 3
\hline
11 12 13
11 & 12 & 13 \\
\hline 21 22 23
21 & 22 & 23 \\ 31 32 33
\hline
31 & 32 & 33 \\
\hline
\end{tabular}\\
\end{document}

\documentclass{article}
\begin{document}
\textbf{Table: 3 columns (Left Aligned)}\\

\begin{tabular}{|l|l|l|} Table: 3 columns (Left Aligned)


\hline
\textbf{Column 1} & \textbf{Column 2} & \textbf{Column 3} \\ Column 1 Column 2 Column 3
\hline
11 12 13
11 & 12 & 13 \\
\hline 21 22 23
21 & 22 & 23 \\ 31 32 33
\hline
31 & 32 & 33 \\
\hline
\end{tabular}\\
\end{document}
\documentclass{article}
\begin{document}
\textbf{Table: 3 columns (Fixed Width)}\\

\begin{tabular}{|p{2cm}|p{2cm}|p{2cm}|} Table: 3 columns (Fixed Width)


\hline
\textbf{Column 1} & \textbf{Column 2} & \textbf{Column 3} \\ Column 1 Column 2 Column 3
\hline
11 12 13
11 & 12 & 13 \\
\hline 21 22 23
21 & 22 & 23 \\ 31 32 33
\hline
31 & 32 & 33 \\
\hline
\end{tabular}\\
\end{document}

Tip: Avoid vertical lines in tables for better readability of content.

22.2 Aligning Cells:

\documentclass{article}
\usepackage{array}
\begin{document} Cell Alignment:
\textbf{Cell Alignment:}\\
top
\begin{tabular}{|b{1.6cm}|m{1.6cm}|p{1.6cm}|} middle
aligned bottom
\hline aligned
aligned
top aligned & middle aligned & bottom aligned\\
\hline
\end{tabular}
\end{document}

Key Point: Alignment of cells is done with array package.

22.3 Row Height:

\documentclass{article}
\usepackage{array}
\begin{document}
\setlength{\extrarowheight}{4pt} 11 12 13
\begin{tabular}{|c|c|c|}
\hline 21 22 23
11 & 12 & 13\\
\hline
21 & 22 & 23 \\
\hline
\end{tabular}
\end{document}
\documentclass{article}
\usepackage{array}
\begin{document}
\setlength{\extrarowheight}{16pt}
\begin{tabular}{|c|c|c|} 11 12 13
\hline
11 & 12 & 13\\
\hline 21 22 23
21 & 22 & 23 \\
\hline
\end{tabular}
\end{document}

Key Point: Use \setlength in array package to set row height.

22.4 Adding Blank Line in a Row

\documentclass{article}
\usepackage{array}
\begin{document}
Column 1 Column 2 Column 3
\begin{tabular}{ccc} 11 12 13
\hline 21 22 23
\textbf{Column 1} & \textbf{Column 2} & \textbf{Column 3} \\
\hline
31 32 33
11 & 12 & 13 \\
\hline
21 & 22 & 23 \\
&\\
\hline
31 & 32 & 33 \\
\hline
\end{tabular}
\end{document}

Key Point: Use &\\ to add blank line.

22.5 Slashbox in a table:

\documentclass{article}
\usepackage{slashbox}
\begin{document}
\begin{tabular}{|c|c|c|}
\hline
\backslashbox{row}{column} & B & C \\
\hline
11 & 12 & 13 \\
\hline
21 & 22 & 23 \\
\hline
31 & 32 & 33 \\
\hline
\end{tabular}
\end{document}
Key Point: Use slashbox package for slashbox in a table.

22.6 Beautiful Tables with booktabs package

\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{ccc} A B C
\toprule[1.5pt]
A & B & C \\ 11 12 13
\midrule 21 22 23
11 & 12 & 13 \\ 31 32 33
21 & 22 & 23 \\
31 & 32 & 33 \\
\bottomrule[1.5pt]
\end{tabular}
\end{document}

22.7 Merging Cells in a Row

\documentclass{article}
\begin{document}
\begin{tabular}{ccc}
\hline Combined Column Last Column
\multicolumn{2}{l}{Combined Column}& 11 12 13
\multicolumn{1}{l}{Last Column}\\ 21 22 23
\hline 31 32 33
11 & 12 & 13 \\
21 & 22 & 23 \\
31 & 32 & 33 \\
\hline
\end{tabular}
\end{document}

Key Point: Use \multicolumn for merging cells in a row. The command format is
\multicolumn{cols}{pos}{text}

1. cols specifies the number of columns to span.


2. pos specifies the formatting of the entry; c for centred, l for left, r for right.
3. text specifies what text is to make up the entry.
\documentclass{article}
\begin{document}
\begin{tabular}{ccc}
\hline Combined Column Last Column
\multicolumn{2}{l}{Combined Column}& 11 12 13
\multicolumn{1}{l}{Last Column}\\ 21 22 23
\cline{1-2} 31 32 33
11 & 12 & 13 \\
21 & 22 & 23 \\
31 & 32 & 33 \\
\hline
\end{tabular}
\end{document}

Point to Understand: \cline is used to draw horizontal line from first column to second
column after first row.

\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{ccc} Combined Column Last Column
\toprule[1.5pt] A B C
\multicolumn{2}{l}{Combined Column}&
\multicolumn{1}{l}{Last Column}\\ 11 12 13
A & B & C\\ 21 22 23
\cmidrule(r){1-2}\cmidrule(l){3-3} 31 32 33
11 & 12 & 13 \\
21 & 22 & 23 \\
31 & 32 & 33 \\
\bottomrule[1.5pt]
\end{tabular}
\end{document}

Booktabs package for beautiful tables!

22.8 Merging Cells in a Column

\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{tabular}{cccc} A 11 12
Combined Row
\hline B 21 22
\multirow{2}{*}{Combined Row} & A & 11 & 12\\ Last Row C 31 32
& B & 21 & 22 \\
\hline
\multirow{1}{*}{Last Row} & C & 31 & 32 \\
\hline
\end{tabular}
\end{document}

Key Point: Use package multirow for merging cells in a column.


\multirow{numrows}{width}{content}

1. numrows specifies the number of rows to span.


2. width specifies the width of the entry; * is used for natural width.
3. content specifies what text is to make up the entry.

\documentclass{article}
\usepackage{booktabs}
\usepackage{multirow}
\begin{document}
\begin{tabular}{cccc} A 11 12
\toprule[1.5pt] Combined Row
B 21 22
\multirow{2}{*}{Combined Row} & A & 11 & 12\\
& B & 21 & 22 \\ Last Row C 31 32
\hline
\multirow{1}{*}{Last Row} & C & 31 & 32 \\
\bottomrule[1.5pt]
\end{tabular}
\end{document}

22.9 Naming Tables:

\documentclass{article}
\begin{document}
\begin{table}[htbp]
\begin{tabular}{ccc}
\hline Column 1 Column 2 Column 3
\textbf{Column 1} & \textbf{Column 2} & \textbf{Column 3} \\ 11 12 13
\hline 21 22 23
11 & 12 & 13 \\
31 32 33
\hline
21 & 22 & 23 \\
\hline Table 1: Table Name - Below
31 & 32 & 33 \\
\hline
\end{tabular}
\centering
\caption{Table Name - Below}
\end{table}
\end{document}
\documentclass{article}
\begin{document}
\begin{table}[htbp]
\centering
\caption{Table Name - Above}
\vspace{10pt} Table 1: Table Name - Above
\begin{tabular}{ccc}
\hline Column 1 Column 2 Column 3
\textbf{Column 1} & \textbf{Column 2} & \textbf{Column 3} \\ 11 12 13
\hline
21 22 23
11 & 12 & 13 \\
\hline 31 32 33
21 & 22 & 23 \\
\hline
31 & 32 & 33 \\
\hline
\end{tabular}\\
\end{table}
\end{document}

Key Point: Put tabular environment in table environment. Use \caption before or after
tabular environment.

22.10 Colouring Tables

\documentclass{article} \documentclass{article} \documentclass{article}


\usepackage{colortbl} \usepackage{colortbl} \usepackage{colortbl}
\begin{document} \begin{document} \begin{document}
\begin{tabular}{ccc} \begin{tabular} \begin{tabular}
\hline {>{\columncolor{red}}c> {>{\columncolor{red}}c>
\rowcolor{red} {\columncolor{blue}}c> {\columncolor{blue}}c>
11 & 12 & 13 \\ {\columncolor{green}}c} {\color{yellow}\columncolor{green}}c}
\hline \hline \hline
\rowcolor{blue} 11 & 12 & 13 \\ 11 & 12 & 13 \\
21 & 22 & 23 \\ \hline \hline
\hline 21 & 22 & 23 \\ 21 & 22 & 23 \\
\rowcolor{green} \hline \hline
31 & 32 & 33 \\ 31 & 32 & 33 \\ 31 & 32 & 33 \\
\hline \hline \hline
\end{tabular} \end{tabular} \end{tabular}
\end{document} \end{document} \end{document}

11 12 13 11 12 13 11 12 13
21 22 23 21 22 23 21 22 23
31 32 33 31 32 33 31 32 33

Key Point: Use colortbl package for coloring table contents.


23 Including Figures

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}[htbp]
\begin{center}
\includegraphics[width=0.3\textwidth, angle=0]{sample.jpg}
\caption{Sample Figure}
\end{center}
\end{figure}
Figure 1: Sample Figure
\end{document}

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}[htbp]
\begin{center}
\fbox{\includegraphics[width=3cm,
angle=0]{sample.jpg}}
\caption{Sample Figure} Figure 2: Sample Figure
\end{center}
\end{figure}
\end{document}

Key Point: Use graphicx package for including figures.

Points to Understand:
1. 0.3\width denotes 30% of total page width.
2. \fbox is used to frame the figure. It can also be used to frame the text.
24 Mathematics Environment in LaTeX
24.1 Understanding Basics

a) \( ... \) OR $ ... $

creates INLINE mathematics environment.


b) \[ ... \] OR $$ ... $$

creates mathematics environment in NEW LINE.


c) \begin{equation} ... \end{equation}

creates mathematics environment in NEW LINE with numbered equations.

You are strongly advised to read the above basics at least once.

Tip: Try to avoid use of $ ...$ OR $$ . . . $$.

\documentclass{article}
\begin{document}
Equations are \( a + b = c \) and \( x + y Equations are a + b = c and x + y = z
= z \)
\end{document}

Equations are
\documentclass{article}
\begin{document} a+b=c
Equations are \[ a + b = c \] and \[ x + y = z \]
\end{document} and
x+y =z

\documentclass{article}
\begin{document}
Equation are Equation are
\begin{equation}
a + b = c a+b=c (1)
\end{equation}
\begin{equation} x+y =z (2)
a + b = c
\end{equation}
\end{document}
Tip: Use \begin{fleqn} ...\end{fleqn} for left aligned unnumbered equations.

24.2 Aligning Equations

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{multline}
x = a + b + c + d + e+ \\ x = a + b + c + d + e+
f + g + h + i + j+ \\
k + l + m + n f + g + h + i + j+
\end{multline} k + l + m + n (3)

\begin{gather}
x + y + z = 0\\ x+y+z =0 (4)
y + z = 1 y+z =1 (5)
\end{gather}

\begin{align} x+y+z =1 (6)


x + y + z = 1\\
y + z = 0\\ y+z =0 (7)
u + v + w + z =2 u+v+w+z =2 (8)
\end{align}

\begin{equation}
\begin{split} a=b
a = b\\ (9)
=c
=c\\
\end{split}
\end{equation}
\end{document}

Points to Understand:
1. Alignment of Equations is done with amsmath package.
2. Multiline is used for equations longer than a line.
3. Gather is used to centre align list of equations.
4. Align is used to vertically align the equations w.r.t. <, >, = etc.
5. Split is used to align right hand sides of equations w.r.t. <, >, = etc.

Tip: Use asterisk for unnumbered equations;


\begin{equation*},\begin{multiline*}, \begin{gather*}, \begin{align*}

24.3 Greek Letters


\documentclass{article}
\begin{document}
\[\alpha, \beta, \gamma, \delta,\] α, β, γ, δ,
\[\epsilon, \theta, \eta, \tau, \pi, \sigma\] , θ, η, τ, π, σ
\end{document}
24.4 Common Sets
\documentclass{article}
\usepackage{bbm}
\begin{document}
\[\mathbbm{C,Z,Q,R, N, Z_+, R^+} \] C, Z, Q, R, N, Z+, R+
\[\mathcal{A}, \mathcal{S}, \mathcal{T} \] A, S, T
\end{document}

24.5 Common Symbols\Operators


\documentclass{article}
\begin{document}
\[\infty \] ∞
\[\leq, \geq, \neq, \ll, \gg \] ≤, ≥, 6=, , 
\[ \prec, \preceq, \succ, \succeq \] ≺, , , 
\[\forall,\exists, \not\exists, \iff \] ∀, ∃, 6 ∃, ⇐⇒
\[\sim,\cong,\simeq,\approx,\equiv\] ∼, ∼
=, ', ≈, ≡
\[\perp, \parallel,\propto, \not\perp\] ⊥, k, ∝, 6⊥
\[\wedge,\vee\] ∧, ∨
\[\pm,\times,\ast\] ±, ×, ∗
\end{document}

24.6 Sets and Operations on Sets


\documentclass{article}
\begin{document}
\[\O, \in, \ni, \setminus\] Ø, ∈, 3, \
\[\subset, \supset, \subseteq, \supseteq\] ⊂, ⊃,S⊆,T⊇
\[\cup, \cap, \bigcup, \bigcap\] ∪, ∩, ,
\end{document}

24.7 Few Common Operations with AMS Package


\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}
\[\therefore \implies \because \] ∴ =⇒ ∵
\[\nless, \ngtr, \nleq, \ngtr\] ≮, ≯, , ≯
\[\nsubseteq, \nsupseteq, \subsetneq, \supsetneq\] *, +, (, )
\[\nmid, \nparallel, \nsim, \ncong\] -, ∦, , 
\end{document}

24.8 Accents
\documentclass{article}
\begin{document}
\[\bar{a},\vec{a},\hat{a}\] ā, ~a, â

\[\tilde{a},\dot{a},\ddot{a}\] ã, ȧ, ä

\[\check{a},\acute{a},\breve{a}\] ǎ, á, ă


\end{document}
24.9 Dots, Overlines\Underlines, Overbraces\Underbraces etc.
\documentclass{article}
\begin{document}
\[a + b + c + \cdots \] a + b + c + ···

\[a + b + c + \ldots\] a + b + c + ...

\[\overline{abc}, \underline{abc}\] abc, abc


←− −→
\[\overleftarrow{abc}, \overrightarrow{abc}\] abc, abc

\[\widetilde{abc}, \widehat{abc}\] abc,


f abcc

z}|{
\[\overbrace{abc},\underbrace{abc}\] abc , |{z}
abc
\end{document}

24.10 Powers, Roots and Fractions


\documentclass{article}
\begin{document}
\[x,y,z\] x, y, z
\[x_1,y_2,z_3\] x1 , y2 , z3
\[x^2,y^2,z^2\] x2 , y 2 , z 2
\[x_1^2,y_2^3,z_3^4\] x21 , y23 , z34
√ √ 3
\[\sqrt{x}, \sqrt[3]{x}\]
qx,
p√ p
x
\[\sqrt{\sqrt{\sqrt{x}}}, \sqrt[n]{x_1^2+y_2^3}\] x, n x21 + y23
a
x
y,
b
\[\frac{x}{y}, \frac{\frac{a}{b}}{\frac{c}{d}}\] c
d
\end{document}

24.11 Summations
\documentclass{article}
\begin{document} P
\[\sum\]
P
\[\sum a + b + c + \ldots\] a + b + c + ...
Pn=∞ 1
\(\sum_{n=1}^{n=\infty}\frac{1}{n}\) n=1 n

n=∞
\(\sum\limits_{n=1}^{n=\infty}\frac{1}{n}\)
P 1
n
n=1
\end{document}

Observe the use of \limits.


24.12 Binomial Coefficients
\documentclass{article}
\usepackage{amsmath}
\begin{document}
n n!

\[\binom{n}{r} = \frac{n!}{r!(n-r)!}\] r = r!(n−r)!

n!
\[^nC_r = \frac{n!}{r!(n-r)}\] nCr = r!(n−r)

nP n!
\[^nP_r = \frac{n!}{(n-r)!} \] r = (n−r)!
\end{document}

24.13 Limits
\documentclass{article}
\begin{document}
1
\(\lim_{n \to \infty}\frac{1}{n} = 0\) limn→∞ n =0

\(\lim\limits_{n \to \infty}\frac{1}{n} = 0\) lim 1 =0


n→∞ n

n
\(\lim_{n \to \infty}{(1 + \frac{1}{n})}^{n} = e\) limn→∞ (1 + n1 ) = e
n
\(\lim\limits_{n \to \infty}{(1 + \frac{1}{n})}^{n} = e\) lim (1 + n1 ) = e
n→∞
\end{document}

Observe the use of \limits.

24.14 Derivatives
\documentclass{article}
\begin{document}
dy
\[\frac{dy}{dx}\] dx

d2 y
\[\frac{d^2y}{dx^2}\] dx2

\[\frac{\partial z}{\partial x}\] ∂z


∂x

\[\frac{\partial^2 z}{\partial x^2}\] ∂2z


∂x2

\[\frac{\partial^2 z}{\partial x \partial y}\] ∂2z


∂x∂y

\end{document}
24.15 Integration
\documentclass{article}
\begin{document} R H
\(\int,\oint\) ,
R R
\(\int f(x)\,dx, \int \!f(x)\,dx\) f (x) dx, f (x) dx
R 2π R 2π
\(\int_{0}^{2\pi}x\,dx, \int_{0}^{2\pi}\!x\,dx \) 0 x dx, 0 x dx

R2π R2π
\(\int\limits_{0}^{2\pi}x\,dx, \int\limits_{0}^{2\pi}\!x\,dx\) x dx, x dx
0 0

R 2π R 2π
\(\int_{0}^{2\pi}x\,\mathrm{d}x, \int_{0}^{2\pi}\!x\,\mathrm{d}x\) 0 x dx, 0 x dx

R2π R2π
\(\int\limits_{0}^{2\pi}x\,\mathrm{d}x, \int\limits_{0}^{2\pi}\!x\,\mathrm{d}x\) x dx, x dx
0 0
\end{document}

Points to Understand:
R
1. \! is used to reduce space between and integrand.
2. \limits is used for proper placing of limits in inline equations.
3. \mathrm is used for proper formatting of differential d.
24.16 Double Integration
\documentclass{article}
\usepackage{amsmath}
\begin{document} RR RR
\(\iint, \iint f(x)\,dx\) , f (x) dx
RR
\(\iint f(x)\,dx\,dy\) f (x) dx dy
RR
\(\iint_D f(x)\,dx\,dy \) D f (x) dx dy
RR
\(\iint\limits_D f(x)\,dx\,dy \) f (x) dx dy
D

RbRd
\(\int_{a}^{b}\int_{c}^{d} f(x)\,dx\,dy\) a c f (x) dx dy

Rb Rd
\(\int\limits_{a}^{b}\int\limits_{c}^{d} f(x)\,dx\,dy\) f (x) dx dy
a c
RR
\(\iint \!f(x)\,dx\,dy\) f (x) dx dy
RR
D f (x) dx dy
\(\iint_D \!f(x)\,dx\,dy \)
RR
\(\iint\limits_D \!f(x)\,dx\,dy \) f (x) dx dy
D

RbRd
\(\int_{a}^{b}\int_{c}^{d}\!f(x)\,dx\,dy\) a c f (x) dx dy

Rb Rd
\(\int\limits_{a}^{b}\int\limits_{c}^{d} \!f(x)\,dx\,dy\) f (x) dx dy
a c
RR
D f (x) dx dy
\(\iint_D \!f(x)\,\mathrm{d}x\,\mathrm{d}y \)
RR
\(\iint\limits_D \!f(x)\,\mathrm{d}x\,\mathrm{d}y \) f (x) dx dy
D

RbRd
\(\int_{a}^{b}\int_{c}^{d}\!f(x)\,\mathrm{d}x\,\mathrm{d}y\) a c f (x) dx dy

Rb Rd
\(\int\limits_{a}^{b}\int\limits_{c}^{d} \!f(x)\,\mathrm{d}x\,\mathrm{d}y\) f (x) dx dy
a c
\end{document}

\iiintis used for triple integration.


24.17 Matrices and Determinants

\documentclass{article} \documentclass{article} \documentclass{article} \documentclass{article}


\begin{document} \begin{document} \begin{document} \begin{document}
\[\begin{array}{cc} \[ A = \begin{array}{cc} \[ A = \left( \[ A = \left[
a_{11} & a_{12}\\ a_{11} & a_{12}\\ \begin{array}{cc} \begin{array}{cc}
a_{21} & a_{22} a_{21} & a_{22} a_{11} & a_{12}\\ a_{11} & a_{12}\\
\end{array}\] \end{array} \] a_{21} & a_{22} a_{21} & a_{22}
\end{document} \end{document} \end{array} \end{array}
\right) \] \right] \]
\end{document} \end{document}

   
a11 a12 a a a11 a12 a11 a12
A = 11 12 A=
a21 a22
A=
a21 a22
a21 a22 a21 a22

\documentclass{article} \documentclass{article} \documentclass{article} \documentclass{article}


\usepackage{amsmath} \usepackage{amsmath} \usepackage{amsmath} \usepackage{amsmath}
\begin{document} \begin{document} \begin{document} \begin{document}
\[ A = \begin{matrix} \[ A = \begin{pmatrix} \[ A = \begin{bmatrix} \[ A = \begin{Bmatrix}
a_{11} & a_{12}\\ a_{11} & a_{12}\\ a_{11} & a_{12}\\ a_{11} & a_{12}\\
a_{21} & a_{22} a_{21} & a_{22} a_{21} & a_{22} a_{21} & a_{22}
\end{matrix} \] \end{pmatrix} \] \end{bmatrix} \] \end{Bmatrix} \]
\end{document} \end{document} \end{document} \end{document}

     
a a a11 a12 a a a11 a12
A = 11 12 A= A = 11 12 A=
a21 a22 a21 a22 a21 a22 a21 a22

\documentclass{article} \documentclass{article}
\usepackage{amsmath} \usepackage{amsmath}
\begin{document} \begin{document}
\[ A = \begin{vmatrix} \[ A = \begin{Vmatrix}
a_{11} & a_{12}\\ a_{11} & a_{12}\\
a_{21} & a_{22} a_{21} & a_{22}
\end{vmatrix} \] \end{Vmatrix} \]
\end{document} \end{document}

a11 a12 a11 a12


A= A=
a21 a22 a21 a22

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy