Learn LaTeX in 30 Minutes
Learn LaTeX in 30 Minutes
Learn LaTeX in 30 Minutes
overleaf.com
LaTeX is used all over the world for scientific documents, books, as
well as many other forms of publishing. Not only can it create
beautifully typeset documents, but it allows users to very quickly
tackle the more complicated parts of typesetting, such as inputting
mathematics, creating tables of contents, referencing and creating
bibliographies, and having a consistent layout across all sections.
Due to the huge number of open source packages available (more
on this later), the possibilities with LaTeX are endless. These
1 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
The first step is to create a new LaTeX project. You can do this on
your own computer by creating a new .tex file, or else you can
start a new project in Overleaf. Let's start with the simplest working
example:
\documentclass{article}
\begin{document}
First document. This is a simple example, with no
extra parameters or packages included.
\end{document}
You can see that LaTeX has already taken care of the first piece of
formatting for you, by indenting the first line of the paragraph. Let's
have a close look at what each part of our code does.
2 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
The first line of code declares the type of document, known as the
class. The class controls the overall appearance of the document.
Different types of documents will require different classes i.e. a
CV/resume will require a different class than a scientific paper. In
this case, the class is article, the simplest and most common
LaTeX class. Other types of documents you may be working on
may require different classes such as book or report.
After this, you write the content of our document, enclosed inside
the \begin{document} and \end{document} tags. This is
known as the body of the document. You can start writing here and
make changes to the text if you wish. To see the result of these
changes in the PDF you have to compile the document. To do this
in Overleaf, simply hit Recompile. (You can also set your project to
automatically recompile when you edit your files, by clicking on the
small arrow next to the 'Recompile button and set 'Auto Compile
to 'On.)
If you are using a basic text editor such as gedit, emacs, vim,
sublime, notepad etc., you will have to compile the document
manually. To do this, simply run pdflatex <your document> in
your computers terminal/command line. See here for more
information on how to do this.
Now that you have learnt how to add content to our document, the
next step is to give it a title. To do this, we must talk briefly about
the preamble.
3 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
\documentclass[12pt, letterpaper]{article}
\usepackage[utf8]{inputenc}
\documentclass[12pt, letterpaper]{article}
As said before, this defines the type of document. Some
additional parameters included in the square brackets brackets
can be passed to the command. These parameters must be
comma-separated. In the example, the extra parameters set
the font size (12pt) and the paper size (letterpaper). Of
course other font sizes (9pt, 11pt, 12pt) can be used, but if
none is specified, the default size is 10pt. As for the paper
size other possible values are a4paper and legalpaper;
see the article about Page size and margins for more details
about this.
\usepackage[utf8]{inputenc}
This is the encoding for the document. It can be omitted or
changed to another encoding but utf-8 is recommended.
Unless you specifically need another encoding, or if you are
unsure about it, add this line to the preamble.
To add a title, author and date to our document, you must add three
lines to the preamble (NOT the main body of the document). These
4 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
lines are
\title{First document}
This is the title.
\author{Hubert Farnsworth}
Here you put the name of the Author(s) and, as a optional
parameter, you can add the next command:
\date{February 2014}
You can enter the date manually or use the command \today
so the date will be updated automatically at the time you
compile your document
With these lines added, your preamble should look something like
this
\title{First document}
\author{Hubert Farnsworth \thanks{funded by the
Overleaf team}}
\date{February 2017}
5 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
Now that you have given your document a title, author and date,
you can print this information on the document with the
\maketitle command. This should be included in the body of the
document at the place you want the title to be printed.
\begin{document}
\maketitle
\end{document}
As with any code you are writing, it can often be useful to include
comments. Comments are pieces of text you can include in the
document which will not be printed, and will not affect the document
in any way. They are useful for organizing your work, taking notes,
or commenting out lines/sections when debugging. To make a
comment in LaTeX, simply write a % symbol at the beginning of the
line as shown below:
\begin{document}
\maketitle
6 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
\end{document}
7 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
\documentclass{article}
\usepackage{graphicx}
8 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
\graphicspath{ {images/} }
\begin{document}
The universe is immense and it seems to be
homogeneous,
in a large scale, everywhere we look at.
\includegraphics{universe}
LaTeX can not manage images by itself, so you will need to use a
package. Packages can be used to change the default look of your
LaTeX document, or to allow more functionalities. In this case, you
need to include an image in our document, so you should use the
graphicx package. This package gives new commands,
\includegraphics{...} and \graphicspath{...}. To use
the graphicx package, include the following line in you preamble:
\usepackage{graphicx}
9 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
\begin{figure}[h]
\centering
\includegraphics[width=0.25\textwidth]{mesh}
\caption{a nice plot}
\label{fig:mesh1}
\end{figure}
10 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
Lists are very simple to create in LaTeX. You can create lists using
different list environments. Environments are sections of our
document that you want to present in a different way to the rest of
the document. They start with a \begin{...} command and end
with an \end{...} command.
There are two main different types of lists, ordered lists and
unordered lists. Each will use a different environment.
Unordered lists
11 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
\begin{itemize}
\item The individual entries are indicated with
a black dot, a so-called bullet.
\item The text in the entries may be of any
length.
\end{itemize}
By default the individual entries are indicated with a black dot, so-
called bullet. The text in the entries may be of any length.
Ordered lists
\begin{enumerate}
\item This is the first entry in our list
\item The list numbers increase with each entry
we add
\end{enumerate}
12 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
\[ E=mc^2 \]
13 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
\begin{equation}
E=m
\end{equation}
14 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
Mathematical expressions
Aligning Equations
Operators
15 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
Mathematical fonts
Abstracts
\begin{document}
\begin{abstract}
This is a simple paragraph at the beginning of the
document. A brief introduction about the main
subject.
\end{abstract}
\end{document}
\begin{document}
16 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
\begin{abstract}
This is a simple paragraph at the beginning of the
document. A brief introduction about the main
subject.
\end{abstract}
17 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
You can find more information in the Paragraphs and new lines
article.
\chapter{First Chapter}
\section{Introduction}
\section{Second Section}
18 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
\subsection{First Subsection}
Praesent imperdietmi nec ante. Donec ullamcorper,
felis non sodales...
\section*{Unnumbered Section}
Lorem ipsum dolor sit amet, consectetuer
adipiscing elit.
Etiam lobortis facilisissem
-1 \part{part}
0 \chapter{chapter}
1 \section{section}
19 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
2 \subsection{subsection}
3 \subsubsection{subsubsection}
4 \paragraph{paragraph}
5 \subparagraph{subparagraph}
Note that \part and \chapter are only available in report and
book document classes.
\begin{center}
\begin{tabular}{ c c c }
cell1 & cell2 & cell3 \\
cell4 & cell5 & cell6 \\
cell7 & cell8 & cell9
\end{tabular}
\end{center}
20 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
and that the text inside each one of them must be centred. You can
also use r to align the text to the right and l for left alignment. The
alignment symbol & is used to specify the breaks in the table
entries. There must always be one less alignment symbol in each
line than the number of columns. To go to the next line of your
table, we use the new line command \\. We wrap the entire table
inside the center environment so that it will appear in the center of
the page.
Adding borders
\begin{center}
\begin{tabular}{ |c|c|c| }
\hline
cell1 & cell2 & cell3 \\
cell4 & cell5 & cell6 \\
cell7 & cell8 & cell9 \\
\hline
\end{tabular}
\end{center}
You can add borders using the horizontal line command \hline
21 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
\begin{center}
\begin{tabular}{||c c c c||}
\hline
Col1 & Col2 & Col2 & Col3 \\ [0.5ex]
\hline\hline
1 & 6 & 87837 & 787 \\
\hline
2 & 7 & 78 & 5415 \\
\hline
3 & 545 & 778 & 7507 \\
\hline
4 & 545 & 18744 & 7560 \\
\hline
5 & 88 & 788 & 6344 \\ [1ex]
\hline
\end{tabular}
\end{center}
22 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
You can caption and reference tables in much the same way as
images. The only difference is that instead of the figure
environment, you use the table environment.
\begin{table}[h!]
\centering
\begin{tabular}{||c c c c||}
\hline
Col1 & Col2 & Col2 & Col3 \\ [0.5ex]
\hline\hline
1 & 6 & 87837 & 787 \\
2 & 7 & 78 & 5415 \\
3 & 545 & 778 & 7507 \\
4 & 545 & 18744 & 7560 \\
5 & 88 & 788 & 6344 \\ [1ex]
\hline
23 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
\end{tabular}
\caption{Table to test captions and labels}
\label{table:data}
\end{table}
\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
\maketitle
\tableofcontents
24 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
\section{Introduction}
\addcontentsline{toc}{section}{Unnumbered Section}
\section*{Unnumbered Section}
\section{Second Section}
\end{document}
25 of 26 19-03-2020, 22:59
Learn LaTeX in 30 minutes about:reader?url=https://www.overleaf.com/learn/latex/Learn_LaTeX_i...
You can download your finished PDF from the left hand menu as
above by clicking PDF. There is also the quicker option of clicking
the Download PDF button on your PDF viewer as shown below.
26 of 26 19-03-2020, 22:59