## 1. Introduction

In this tutorial, we’ll describe what LaTeX is and how it works. Next, we’ll demonstrate some of its functions and why it’s more desirable over other document-preparation software. Lastly, we’ll describe places to download and install the software.

## 2. Overview of LaTeX

LaTeX is a powerful preparation tool or software for creating high-quality and professional-looking documents. This software lets users focus on the document’s content instead of worrying about the look. **LaTeX makes writing easier, faster, and more consistent**.

### 2.1. The Need for LaTeX

LaTeX is suitable for many things, including:

- handling long or complex equations and scientific symbols
- it allows users to automate repetitive tasks
- the production of high-quality and organized documents
- drawing of figures such as flowcharts

### 2.2. How LaTeX Works

```
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\begin{document}
...
\end{document}
```

The *\documentclass *specifies what type of document (i.e., *article*), the paper size (i.e., *a4paper*), and the font size (i.e., *10pt*). We need the *\usepackages* to tell LaTeX to import specific libraries (i.e., *graphicx* is required for importing graphics or images).

We type our content into a **.tex* editor and compile it to generate output as PDF. The content of the **.tex* file is referred to as source code because it contains all the codes and symbols.

**We should keep in mind that the content of our document must be written within \begin{document} and \end{document} environment.**

## 3. Key Things LaTeX Can Do

LaTeX has many functions and is used across many fields. Let’s now discuss them.

### 3.1. Create Simple and Complex Equations

One of the key things LaTeX can do is create equations. Equations in LaTeX must begin and end with a *$* symbol. A single $ indicates an inline equation, and *$$* indicates a centralized equation.

We’ll write simple equations in LaTeX as:

```
\begin{document}
\alpha x + y = 3
x^{2}+ \beta y^4 = 47
\frac{x^{2}}{y^{2}} - 3y^4 = 7
\end{document}
```

This line of code would generate the following equations:

LaTeX also supports writing complex or long equations. Examples of a more complex equation can be written as follows:

using the following line of code:

```
\begin{document}
f(x) = \frac{1}{2} \sum_{i=1}^{n} ||x_{i}||^{2} + \prod_{i=1}^{n} (y_{i} - 1)^{2}
f(x) = ln(1+b) \int_{0}^{\infty} x^{\alpha_{i}-1}exp(\frac{-x}{\beta_{i}}) \gamma(\alpha_{j}\frac{x}{\beta_{j}})dx
\frac{a}{b} = \frac{1}{ln(1+b) \int_{0}^{\infty} x^{\alpha_{i}-1}exp(\frac{-x}{\beta_{i}}) \gamma(\alpha_{j}\frac{x}{\beta_{j}})dx} \prod_{i=1}^{n} (y_{i} - 1)^{2}
\end{document}
```

### 3.2. Automate Repetitive Tasks

Repetitive tasks can be avoided with the use of variables. Variables act as placeholders for storing values we can use throughout a document.

To use a variable, we’ll start with *def* command, followed by the variable name and its value (in curly braces). As a demonstration, let’s define a variable with:

`\def\morning{Good Morning}`

The variable name is *\morning*. Simply calling the command *\morning* will return its value, in this case, ‘Good Morning’. The following line of code:

```
\begin{document}
\morning Aerial
\morning Baller
\morning Carelle
\morning Diego
\end{document}
```

will generate the following output:

We can notice that we didn’t have to type ‘Good Morning’ four times. We defined a variable called *\morning* and called it wherever we wanted. Another advantage of variables in LaTeX is that whenever we need to update the ‘Good Morning’ to ‘Hello’, we’ll effect the changes only in the variable definition, and LaTeX will update it automatically.

### 3.3. Insert a PDF

We can insert an existing PDF into a LaTeX document with the *pdfpages* packages in LaTeX. The following line of code:

```
\begin{document}
\includepdf[pages={1-2}]{sample.pdf}
\end{document}
```

tells LaTeX to import pages 1 and 2 of a PDF document called *sample.pdf. *We can import a large document with multiple pages in LaTeX.

### 3.4. Create Custom Diagrams and Illustrations

LaTeX support the drawing of high-resolution figures. We use the *tikz* packages for drawing. For example, we can draw a simple flowchart and other illustrations:

## 4. Conclusion

In this article, we explained what LaTeX is and how it works. We described some features of LaTeX that make it more desirable than other software.