Latex Notes

Download as pdf or txt
Download as pdf or txt
You are on page 1of 66

T.

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.

This is the second paragraph.


\end{document}
Spaces, Line Breaks, Paragraphs
Spaces, Line Breaks, Paragraphs and Comments
• LaTeX treats multiple spaces just like a single space.
• A single line break has the same effect like a single space.
• It doesn't matter how you arrange your text in the editor
using spaces or breaks, the output will stay the same.
• A blank line denotes a paragraph break.
• Multiple empty lines are treated as one.
• Everything following a percent sign (% symbol used as
comment) until the end of the line will be ignored by LaTeX.
Writing Special Characters
\section{Writing Special Characters}
Statement \#1:
50\% of \$100 makes \$50.
\\
More special symbols are \&, \_, \{ and \}.
\\
\textbackslash
Writing Special Characters
Bolds, Italics and Underlining

Text can be \emph{emphasized}.\\

\textit{italic} words could be \textbf{bold}.\\

\textsl{slanted} or in \textsc{Small Caps}.\\

Commands can be \textit{\textbf{nested}}.\\

\emph{Here \emph{emphasizing} nested.}


Bolds, Italics and Underlining
Fonts Sizes
Fonts Families
Fonts Styles
Text Alignments

\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

Various types of list in LaTeX:


• itemize environment for creating a bulleted (unordered) list
• enumerate environment for creating a numbered (ordered) list
• description environment for creating a list of descriptions
Unordered List
\section{Creating an Unordered List}
Lists are easy to create:
\begin{itemize}
\item start with the \verb|\item| command.
\item Entries start with bullets.
\item The text may be of any length.
\end{itemize}
Unordered List (Output)
Ordered List

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

There's a picture of a galaxy above


\end{document}
Image by StockSnap from Pixabay
Changing the image size and rotation

\includegraphics[scale=0.5, angle=45]{galaxy}
\documentclass{article}
\usepackage{graphicx}
\graphicspath{{./images/}}
\begin{document}
\title{Image Size Adjustment in LaTeX}
\author{}
\date{}
\maketitle

Here is a smaller version of the image:


\vspace{1em} % Add some vertical space before the image
\includegraphics[width=0.5\textwidth]{my.jpg} % Adjust width
\vspace{1em} % Add some vertical space after the image
There’s a smaller version of the image above.
\end{document}
Creating Tables

\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

LATEX allows two writing modes for mathematical


expressions:
• inline math mode is used to write formulas that are part
of a paragraph
• display math mode is used to write expressions that are
not part of a paragraph, and are therefore put on
separate lines
Inline Math Mode

You can use any of these "delimiters" to typeset your


math in inline mode:

\(...\)
$...$
\begin{math}...\end{math}
Display Math Mode

Use one of these constructions:


\[...\]
\begin{displaymath}...\end{displaymath}
\begin{equation}...\end{equation}
Mathematical Expressions
\begin{document}

The Pythagorean theorem \(x^2 + y^2 = z^2\) was


proved to be invalid for other exponents.
Meaning the next equation has no integer
solutions:

\[ x^n + y^n = z^n \]

\end{document}
Display Math Mode (with equation number)
The mass-energy equivalence is described by the equation

\begin{equation}
E=mc^2
\end{equation}

discovered in 1905 by Albert Einstein.

\begin{equation}
E=m
\end{equation}
Display Math Mode (with equation number)
Subscript and Superscript

\[ \int\limits_0^1 x^2 + y^2 \ dx \]


Operators using subscripts and superscripts

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

y = 1 + & \left( \frac{1}{x} + \frac{1}{x^2} + \frac{1}{x^3} +


\ldots \right. \\
&\left. \quad + \frac{1}{x^{n-1}} + \frac{1}{x^n} \right)

\end{align*}

1) Use of align* environment for not numbering the equations.


2) Use of ‘&’ symbol for aligning the multiple equations.
amsmath
matrix
environments
amsmath
matrix
environments
Continued Fractions

\[
\frac{1+\frac{a}{b}}{1+\frac{1}{1+\frac{1}{a}}}
\]

You might also like