Latex Notes
Latex Notes
Latex Notes
LATESH BABU
Content
1) LaTeX Introduction
2) LaTeX Benefits
3) LaTeX Editors
4) First document in LaTeX
5) Text formatting
6) Custom commands
7) Table of Contents
Content
8) Lists
9) Images
10) Tables
11) Mathematics
LaTeX Introduction
• LaTeX (pronounced either "Lah-tech" or "Lay-tech") is a
software for typesetting documents.
• It's a document preparation system.
• It is not a word processor, but is used as a document markup
language.
• It is a free, open source software.
• It was originally written by Leslie Lamport and is based
on the TeX typesetting engine by Donald Knuth.
LaTeX Benefits
• It is well-suited for scientific and technical documents.
• Its superior for typesetting of mathematical formulas.
• It produces very high quality output, it is extremely stable, and
handles complex documents easily no matter how large they
are.
• Its cross-referencing capabilities, its automatic numbering and
generation of lists of contents, figures and tables, indexes,
glossaries, and bibliographies.
LaTeX Benefits
• It is multilingual with language-specific features.
• Produces the output in PostScript, PDF, DVI, and HTML format.
• It is incredibly flexible—there are templates for letters,
presentations, bills, philosophy books, law texts, music scores,
and even for chess game notations.
• It is available for Windows, Linux, Mac OS X, and others
• Its file format is plain text – readable and editable.
• It will produce the same output on all operating systems.
LaTeX Editors (Offline)
• MikTex
• TeXstudio
• TexLive
• TeXworks
• TexMaker
• TeXnicCenter
• Gummi
• Lyx
LaTeX Editors (Online)
• Overleaf
• ShareLatex
• Papeeria
• CoCalc
• LatexBase
• LatexLab
• Sciweavers
• Authorea
Creating First Document
Command
\documentclass[a4paper, 12pt]{article}
\title{Introduction to LaTeX} Preamble
\author{T.Latesh Babu}
\begin{document}
\maketitle
Environment
This is my first LaTeX document
\end{document}
Output in PDF Format
LaTeX Commands
• LaTeX commands begin with a backslash, followed by big or
small letters.
• Commands may have arguments, given in curly braces or in
square brackets.
• Calling a command looks like the following:
\command[optional argument]{argument}
• There could be several arguments, each of them in braces or
brackets.
• Arguments in curly braces are mandatory.
Spaces, Line Breaks, Paragraphs
\begin{document}
\maketitle
\section{Introduction}
This is the
first paragraph.
\begin{flushleft} \begin{center}
This is left aligned.\\ This is center aligned.\\
\end{flushleft} \end{center}
\begin{flushright} \begin{centering}
This is right aligned.\\ This is a justified Text.
\end{flushright} \end{centering}
Text Alignments
Two Columns
\documentclass[a4paper,12pt]{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}
\twocolumn
\blindtext[5]
\end{document}
Two Columns (Output)
Multiple Columns
\documentclass{article}
\usepackage{blindtext}
\usepackage{multicol}
\begin{document}
\begin{multicols}{3}
[
\section{Multiple Columns Example}
This is a document with 3 columns.
]
\blindtext[2]
\end{multicols}
\end{document}
Table of Contents
\documentclass[a4paper,12pt]{book}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[a4paper, inner=1.5cm, outer=3cm, top=2cm, bottom=3cm,
bindingoffset=1cm] {geometry}
\begin{document}
\tableofcontents
\chapter{Exploring the page layout}
In this chapter we will study the layout of pages.
\section{Some filler text}
\blindtext
\section{A lot more filler text}
More dummy text will follow.
\subsection{Plenty of filler text}
\blindtext[10]
\end{document}
Table of Contents (First Page Output)
Lists in LaTeX
\begin{enumerate}
\item Items are numbered automatically.
\item start at 1 with each \texttt{enumerate}.
\item Another entry in the list
\end{enumerate}
Ordered List (Output)
Description List
\begin{description}
\item This is an entry \textit{without} a label.
\item[Something short] A short one-line description.
\item[Something long] A much longer description.
\blindtext[1]
\end{description}
Description List (Output)
Inserting Images
\documentclass[a4paper, 12pt]{article}
\usepackage{graphicx}
\graphicspath{ {./images/} }
\begin{document}
\section{Inserting Images in a document}
The universe is immense and it seems to be homogeneous,
in a large scale, everywhere we look at.
\includegraphics{galaxy}
\includegraphics[scale=0.5, angle=45]{galaxy}
\documentclass{article}
\usepackage{graphicx}
\graphicspath{{./images/}}
\begin{document}
\title{Image Size Adjustment in LaTeX}
\author{}
\date{}
\maketitle
\begin{center} \begin{center}
\begin{tabular}{ c c c } \begin{tabular}{ |c|c|c| }
cell1 & cell2 & cell3 \\ \hline
cell4 & cell5 & cell6 \\ cell1 & cell2 & cell3 \\
cell7 & cell8 & cell9 cell4 & cell5 & cell6 \\
\end{tabular} cell7 & cell8 & cell9 \\
\end{center} \hline
\end{tabular}
\end{center}
Combining Columns
\begin{center}
\begin{tabular}{ |c|c|c|c| }
\hline
\multicolumn{3}{|c|}{Combined Columns}\\
\hline
col1 & col2 & col3 \\
col4 & col5 & col6 \\
col7 & col8 & col9 \\
\hline
\end{tabular}
\end{center}
Combining Rows
\usepackage{multirow}
\begin{tabular}{ |c|c|c|c| }
\hline
col1 & col2 & col3 \\
\hline
\multirow{3}{4em}{Multiple row} & cell2 & cell3 \\
& cell5 & cell6 \\
& cell8 & cell9 \\
\hline
\end{tabular}
Mathematical Modes
\(...\)
$...$
\begin{math}...\end{math}
Display Math Mode
\end{document}
Display Math Mode (with equation number)
The mass-energy equivalence is described by the equation
\begin{equation}
E=mc^2
\end{equation}
\begin{equation}
E=m
\end{equation}
Display Math Mode (with equation number)
Subscript and Superscript
\[ \sum_{i=1}^{\infty} \frac{1}{n^s}
= \prod_p \frac{1}{1 - p^{-s}} \]
Brackets and Parentheses
Brackets and Parentheses
\[
F = G \left( \frac{m_1 m_2}{r^2} \right)
\]
Aligning Equations with amsmath package
\begin{align*}
x&=y & w &=z & a&=b+c\\
2x&=-y & 3w&=\frac{1}{2}z & a&=b\\
-4 + 5x&=2+y & w+2&=-1+w & ab&=cb
\end{align*}
Spacing Commands (use amsmath package)
Spacing Commands (Example)
\begin{align*}
f(x) &= x^2\! +3x\! +2 \\
f(x) &= x^2+3x+2 \\
f(x) &= x^2\, +3x\, +2 \\
f(x) &= x^2\: +3x\: +2 \\
f(x) &= x^2\; +3x\; +2 \\
f(x) &= x^2\ +3x\ +2 \\
f(x) &= x^2\quad +3x\quad +2 \\
f(x) &= x^2\qquad +3x\qquad +2
\end{align*}
Spacing Commands (Output)
Invisible Brackets
(\left. and \right.)
\usepackage{amsmath}
\begin{align*}
\end{align*}
\[
\frac{1+\frac{a}{b}}{1+\frac{1}{1+\frac{1}{a}}}
\]