LaTex Notes
Introduction
LaTeX is a typesetting system commonly used for creating technical and scientific documents, as
well as books and articles. It uses a markup language to describe the structure and layout of a
document, and produces high-quality typeset output in a variety of formats. Some of the key
features of LaTeX include the ability to create complex mathematical equations, cross-
referencing and bibliographies, and support for a wide range of document styles and layouts. To
use LaTeX, you will need to install a TeX distribution and a text editor, and then learn the basic
syntax of the markup language. There are many resources available online to help you learn
LaTeX, including tutorials, documentation, and forums.
LaTeX is a typesetting system widely used in academia for typesetting mathematical and scientific
documents. Here are some key points about LaTeX:
1. It's based on TeX, a typesetting system developed by Donald Knuth.
2. LaTeX is free and open-source.
3. LaTeX uses markup language, which is easier to read and write than low-level
programming languages.
4. LaTeX handles formatting, page layout, and references automatically, leaving the author
to focus on content.
5. LaTeX has a large user community, resulting in a vast library of templates, packages, and
tools.
6. LaTeX is widely used in academia, especially in mathematics, physics, computer science,
and engineering.
7. LaTeX produces high-quality typeset documents, with support for mathematical symbols,
tables, and figures.
8. LaTeX files can be compiled into PDFs, making it easy to share documents electronically.
9. LaTeX has some learning curve, but it's worth it for the level of control and the quality of
the final result.
What is LaTeX
LaTeX is a typesetting system used for typesetting mathematical and scientific documents. It is
based on TeX and is free and open-source. LaTeX uses markup language rather than low-level
programming languages, making it easier to read and write. It automatically handles formatting,
page layout, and references, leaving the author to focus on content. LaTeX is widely used in
academia, especially in mathematics, physics, computer science, and engineering, and produces
high-quality typeset documents with support for mathematical symbols, tables, and figures. It is
popular for its level of control and the quality of the final result, although there is a learning
curve.
Structure of Latex
The structure of a LaTeX document typically includes the following components:
1. Document class: This determines the overall format and layout of the document.
2. Preamble: This section contains any necessary packages, custom definitions, and style
configurations.
3. Document body: This is the main content of the document, where you write the text,
include figures and tables, and typeset equations.
4. References: This section lists any references cited in the document, and is usually created
using a package like BibTeX.
5. Appendices: This section includes any additional material, such as detailed derivations or
supporting data.
Each section of the document is structured using a hierarchy of sectioning commands, such as
\section, \subsection, \subsubsection, etc. The document body is also often divided into
chapters, which are denoted using the \chapter command. LaTeX uses a markup language, which
means that you add formatting and structure to your document using commands, rather than
using a visual interface. Basic commands include \textit for italic text, \textbf for bold text, \frac
for fractions, and \begin{equation}...\end{equation} for typesetting mathematical equations.
Layout in LaTex
The layout of a LaTeX document can be defined by the document class and any custom
configurations in the preamble. Some of the aspects of the layout that can be configured include:
1. Page size and margins
2. Typeface and font size
3. Line spacing and paragraph spacing
4. Headers and footers
5. Page numbering
6. Table of contents and lists of figures/tables
7. Document structure (e.g. chapter and section headings)
8. Equation formatting
The document class determines the overall format and layout of the document, and there are
many classes available for different purposes, such as articles, books, and presentations. Custom
configurations in the preamble can further refine the layout to meet the specific requirements
of the document. LaTeX provides a high level of control over the document layout, which allows
for consistent and professional-looking documents to be produced.
Margin in LaTex
In LaTeX, margins can be set using the geometry package. To set the margins, use the following
code in the preamble of the document:
\usepackage[margin=1in]{geometry}
Where "1in" sets the margin to 1 inch. The measurement unit can be changed to cm, mm, etc.
To set different margins for each page, use the following code:
\usepackage{geometry}
\newgeometry{left=1in,right=1in,top=0.75in,bottom=0.75in}
Where "1in" sets the margin to 1 inch. The measurement unit can be changed to cm, mm, etc.
To set different margins for each page, use the following code:
\usepackage{geometry}
\newgeometry{left=1in,right=1in,top=0.75in,bottom=0.75in}
This sets the left and right margins to 1 inch and the top and bottom margins to 0.75 inches.
Header/Footer in Latex
LaTeX is a typesetting language widely used in the academic and scientific community to produce
high-quality documents. In LaTeX, you can add header and footer to your document using the
"fancyhdr" package.
Here are the steps to add header and footer in LaTeX:
1. Load the "fancyhdr" package:
The first step to add header and footer in LaTeX is to load the "fancyhdr" package in the preamble
of your document. You can do this by adding the following line of code to your document
\usepackage{fancyhdr}
2. Define the page style:
The next step is to define the page style using the "\pagestyle" command. In this case, you will
be using the "fancy" style for the header and footer. You can do this by adding the following line
of code to your document:
\pagestyle{fancy}
3. Define the header and footer content:
Once you have defined the page style, you can now specify the content of the header and footer.
The header and footer are defined using the "\fancyhead" and "\fancyfoot" commands,
respectively.
For example, to add the page number in the center of the footer and on the right side of the
header, you can use the following code:
\fancyhead[RE,RO]{\thepage}
\fancyfoot[CE,CO]{}
The "\thepage" command is used to insert the page number. The argument "[RE,RO]" in
"\fancyhead" specifies that the page number should be on the right side of the header, and the
argument "[CE,CO]" in "\fancyfoot" specifies that the content should be centered and in the
middle of the footer.
4. Add section or chapter names in the header:
You can also add the section or chapter names in the header. To do this, you can use the
"\leftmark" and "\rightmark" commands, respectively.
For example, to add the section name on the left side of the header and the chapter name on the
right side of the header, you can use the following code:
\fancyhead[LE,RO]{\thepage}
\fancyhead[RE,LO]{\rightmark}
\fancyhead[LE,LO]{\leftmark}
The "\leftmark" and "\rightmark" commands are used to insert the section and chapter names,
respectively. The argument "[LE,LO]" in "\fancyhead" specifies that the section name should be
on the left side of the header, and the argument "[RE,RO]" in "\fancyhead" specifies that the
chapter name should be on the right side of the header.
5. Add text in the footer:
You can also add custom text in the footer. To do this, you can use the "\fancyfoot" command.
For example, to add the text "Footer text" in the footer, you can use the following code:
\fancyfoot[LE,RO]{Footer text}
6. Remove header and footer on specific pages:
If you want to remove the header and footer on specific pages, you can use the "\thispagestyle"
command
Sectioning in LaTex
LaTeX provides several commands for creating sections and subsections in a document, which
help to organize the content and improve its readability. Here are some of the commonly used
sectioning commands in LaTeX:
1. \section: This command creates a new section with a numbered heading. For example:
\section{Introduction}
2. \subsection: This command creates a new subsection within a section, also with a
numbered heading. For example:
\subsection{Background}
3. \subsubsection: This command creates a new subsubsection within a subsection, with a
numbered heading. For example:
\subsubsection{Related Work}
4. \paragraph: This command creates a new paragraph within a subsubsection, with a non-
numbered heading. For example:
\paragraph{Methodology}
5. \subparagraph: This command creates a new subparagrah within a paragraph, with a
non-numbered heading. For example:
\subparagraph{Data Collection}
In LaTeX, the appearance of the sectioning headings can be customized using the "titlesec"
package. The default styles for sectioning headings can be changed to suit your needs, such
as changing the font size, font type, and text color.
Bullets and Numbering
LaTeX provides several ways to create bulleted and numbered lists in a document. Here are some
of the commonly used methods for creating bulleted and numbered lists:
1. itemize environment for bulleted lists: This environment creates a bulleted list, with
each item in the list marked by a bullet symbol. For example:
\begin{itemize}
\item First item
\item Second item
\item Third item
\end{itemize}
2. enumerate environment for numbered lists: This environment creates a numbered list,
with each item in the list marked by a sequential number. For example:
\begin{enumerate}
\item First item
\item Second item
\item Third item
\end{enumerate}
3. description environment for labeled lists: This environment creates a list with a label
and a description for each item. For example:
\begin{description}
\item[First item] Description of the first item
\item[Second item] Description of the second item
\item[Third item] Description of the third item
\end{description}
In LaTeX, the appearance of the lists, such as the bullet symbol, numbering format, and
indentation, can be customized using the "enumitem" package. Additionally, you can also change
the label for each item in the list.
Images
LaTeX provides several ways to insert and manage images in a document. Here are some of the
commonly used methods for inserting images in LaTeX:
1. \includegraphics command: This command is used to insert an image file into a LaTeX
document. The syntax is as follows:
\includegraphics[width=0.5\textwidth]{example.jpg}
The width option is used to set the width of the image, which can be specified as a fraction of
the text width, as shown above.
2. figure environment: This environment is used to create a figure, which is a floating
object that can be placed anywhere in the document. The syntax is as follows:
\begin{figure}
\includegraphics[width=0.5\textwidth]{example.jpg}
\caption{Example figure.}
\end{figure}
The \caption command is used to add a caption to the figure, which will appear below the image.
3. wrapfigure environment: This environment is used to wrap text around an image. The
syntax is as follows:
\begin{wrapfigure}{l}{0.5\textwidth}
\includegraphics[width=0.5\textwidth]{example.jpg}
\caption{Example figure.}
\end{wrapfigure}
The wrapfigure environment accepts two arguments: the placement of the figure (left or right),
and the width of the figure. The text will wrap around the figure, filling the available space on the
opposite side.
In LaTeX, the appearance of the images, such as the placement, size, and caption style, can be
customized using the "graphicx" and "caption" packages.