LATEX notes
LATEX notes
What is Latex?
Advantages of latex.
Basic structure of Latex.
Formatting in latex.
Section, List and Referencing in Latex.
Tables and figures in Latex.
Mathematical Notations.
What is LaTeX?
LaTeX is a markup language and document preparation system used for
typesetting documents.
LaTeX is a typesetting system which is commonly used for producing scientific
and mathematical documents, including academic papers, theses, reports, and
presentations. It provides a high-quality output, particularly for complex
documents with mathematical equations, tables, and graphics.
Advantages of LaTeX:
Superior typesetting quality, especially for mathematical equations and
technical content.
Consistent formatting across different platforms and printers.
Separation of content and formatting, allowing users to focus on writing without
worrying about layout.
Extensive customization options for document styles and templates.
LaTeX Editors:
TeXstudio
TeXworks
Overleaf
TeXShop
LaTeXila
Texmaker
Miktex
\documentclass{article}
\title{Introduction to LaTeX}
\author{Your Name}
\date{\today}
\begin{document}
\maketitle
\begin{abstract}
\end{abstract}
\end{document}
● Commenting:In LaTeX, we can add comments using the % symbol. Anything next to
the % sign treated as a comment and will not be printed in the output. Comments are
useful for adding explanations to your code or temporarily excluding certain lines
without deleting them.
Text Formatting:-
● Font styles: In LaTeX, you can apply various font styles to text using commands.
Here are some common font styles.
\textbf{Text}: Renders the text in bold.
\textit{Text}: Renders the text in italics.
\underline{Text}: Underlines the text.
\texttt{Text}: Renders the text in a monospaced (typewriter) font.
\textsf{Text}: Renders the text in a sans-serif font.
● Font Sizes: In LaTeX, you can set the font size using various commands. Here are the
basic commands for changing font sizes.
Example:
\documentclass{article}
\begin{document}
{\tiny Tiny text.}
{\scriptsize Scriptsize text.}
{\footnotesize Footnotesize text.}
{\small Small text.}
{\large Large text.}
{\Large Larger text.}
{\LARGE Even larger text.}
{\huge Huge text.}
{\Huge Largest text.}
\end{document}
Output:
Tiny text. Scriptsize text. Footnotesize text. Small text. Large text.
Larger text. Even larger text.
Huge text. Largest
text.
● Text Color: In Latex we change the color of text using the ‘\textcolor’ command from
the ‘xcolor’ package.
● Background color: Using the command ‘\colorbox’ form the ‘xcolor’ package.
Example:
\documentclass{article}
\usepackage{xcolor}
\begin{document}
\textcolor{red}{Red text}
Red text
Text with yellow background color
Text Alignment:
● Center alignment: To text horizontally on the page, we use the ‘\centering’ command
or ‘center’ environment.
● Right alignment: To right-align text, we use the ‘flushright’ environment.
Spaces:
● Vertical space: ‘\vspace{length}’ adds vertical space.
● Horizontal space: ‘\hspace{length}’ adds horizonatal space.
● Negative space: Use negative values for \vspace and \hspace.
Length can be specified in varies unites e.g. pt, cm, in.
Paragraph:
● For new paragraph leave a blank line or use command \newparagraph.
● For new line use command \\ or \newline.
● \noindent suppresses paragraph indentation.
● \smallskip ,\medskip, \bigskip adds small, medium or large vertical space between
paragraph.
\usepackage[a4paper,margin=1in]{geometry}
\usepackage[paperwidth=15cm,paperheight=25cm, margin=2.5cm]{geometry}
Hyperlink:
● In Latex we can create hyperlinks using the \href command from the hyperref
package. The hyperref package provides extensive support for hyperlinks, including
links to URLs, email addresses, and internal document links. Here’s a simple
example:
\documentclass{article}
\usepackage{hyperref}
\begin{document}
Click \href{https://www.example.com}{link}
\end{document}
Enumerates:
● To create enumerated lists in LaTeX, you can use the enumerate environment. Here’s
a simple example:
\documentclass{article}
\begin{document}
\begin{enumerate}
\item First item
\item Second item
\item Third item
\end{enumerate}
\end{document}
Header and Footer:
● To create custom headers and footers in LaTeX, we use the fancyhdr package. Here’s
a simple example:
\documentclass{article}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[r]{page no \thepage}
\fancyhead[L]{page no \thepage}
\fancyfoot[c]{this is footer}
\begin{document}
\end{document}
\begin{wrapfigure}{l}{0.25\textwidth}
\includegraphics[width=0.9\linewidth]{image.png}
\caption{Caption1}
\label{fig:wrapfig}
\end{wrapfigure}
Table in LaTeX
• Tabular environment:
Eg.
\begin{tabular}{|c|c|c|}
\hline
cell1 & cell2 &cell3 \\
\hline
cell4 & cell5 & cell6 \\
\hline
cell4 & cell5 & cell6 \\
\hline
\end {tabular}
• Table environment:
Eg.
\begin{table}
\centering
\caption{caption}
\begin{tabular}{|c|c|c|}
\hline
cell1 & cell2 &cell3 \\
\hline
cell4 & cell5 & cell6 \\
\hline
cell4 & cell5 & cell6 \\
\hline
\end {tabular}
Roots:
• Square root: \sqrt{}
eg. \sqrt{x} gives √𝑥
• nth root: \sqrt[n]{}
𝑛
eg. \sqrt[n]{x} gives √𝑥
Integrals and derivatives:
• Integral: \int_{lower}^{upper} expression \dx.
• Derivative: \frac{d}{dx}.
Equation alignment:
• Use the ‘align’ environment for aligned equations. Insert ‘&’ before ‘=’ for align ‘=’ in
vertical line.
Summation and Product:
• Summation: \sum_{lower}^{upper}
• eg. \sum_{i=1}^{m} gives ∑𝑚 𝑖=1 ⬚
• Product: \prod_{lower}^{upper}
eg. \prod_{j=1}^{\infty} gives ∏∞𝑗=1 ⬚
Limit:
• Limit: \lim_{}
Eg. \lim_{x \to 0} gives lim ⬚
𝑥→0
Matrices:
To create matrices in LaTeX, you can use pmatrix, bmatrix, vmatrix, and Bmatrix
environments for different types of brackets.
• pmatrix environment for parentheses bracket.
• bmatrix environment for square brackets.
• vmatrix environment for vertical bars.
• Bmatrix environment for curly braces.
Example:
\begin{equation}
B = \begin{bmatrix}
b_{11} & b_{12} \\
b_{21} & b_{22}
\end{bmatrix}
\end{equation}