Aug 22, 2022

Introduction to LaTeX

Resources/References:

Paragraphs in LaTeX

  • To start a new paragraph at least one vertical line spacing is necessary.

1
2
3
random words.

New paragraph
  • Use ‘’%’’ to comment out your code.

1
2
3
To comment out, use % symbol.

Example. This will be seen when complied % but this won't be
  • Single line spacing does not start a new paragraph.

1
2
3
4
5
student1
student2
student3
student4
student5

produces

student1 student2 student3 student4 student5

There are two ways to make a new line.

  • We put the new line command ‘’\’’.

1
2
3
4
5
student1\\
student2\\
student3\\
student4\\
student5 % One does not need a new line here.
  • We use the itemize environment.

1
2
3
4
5
6
7
\begin{itemize} % or enumerate
\item student1
\item student2
\item student3
\item student4
\item student5
\end{itemize}

It produces something similar to

  • student1

  • student2

  • student3

  • student4

  • student5

Note

Unlike programming languages such as Python and YAML, in LaTeX code indentation does not do anything. It is mostly for the reader’s convenience.

Math in LaTeX

In LaTeX, we need to specify math mode by using one of the following keywords.

  1. Inline mode

1
2
\( <math expressions> \)
\$ <math expressions> \$

Mathematical expressions created in inline mode are considered as part of regular text. For instance, the quadratic formula in inline mode produces \(\frac{-b \pm \sqrt{b^2-4ac}}{2a}\).

  1. Math mode

1
2
3
4
\[ <math expressions> \]
$$ <math expressions> $$
\begin{equation} <math expressions> \end{equation} # this provides a numbered environment.
\begin{equation*} <math expressions> \end{equation*}

LaTeX math mode produces math such that it is not considered to be part of regular text but mathematical expressions themselves. It creates vertical space and most of the time, mathematical expressions are center aligned. For example, the quadratic formula in inline mode produces

\[\frac{-b \pm \sqrt{b^2-4ac}}{2a}.\]

Note

In general, when typing math in LaTeX keep in mind that different fonts mean different symbols. That is the following four are different characters

\[\text{p}, p, \mathfrak{p}, \mathbf{p}\]