LaTeX Basics
Since the main usage of LaTeX is creating documents, let's learn how to create a basic document!
Last updated
Since the main usage of LaTeX is creating documents, let's learn how to create a basic document!
Last updated
In order to start working with , you need to create a project on Overleaf, or a file ending with .tex
on your local machine. I'll be more focusing on Overleaf since it's easier to use.
Here is a very sample piece of code:
The output:
First, we have \documentclass{article}
. This line will declare the document type, known as its class, which controls the overall appearance of the document. There are many different types, each of them will have different settings to the layout, as well as have their own set of commands.
After that, we have the main content of the document, surrounded by the pair \begin{document}
and \end{document}
. You can change the content inside, which will be reflected after re-compiling the document.
Everything in your .tex
file that appearing before that \begin{document}
is called the preamble, which acts as the document’s “setup” section. Within the preamble you define the document class (type) together with configuration such as languages to be used when writing the document; loading packages you would like to use (which will be talked later), and it is where you would apply other types of configuration.
Moreover, you can define information that are related to the document (author, title, date of publishing, institution..). With that knowledge in mind, let's make a descriptive preamble.
Let's analyze this preamble:
\documentclass[a4paper]{article}
- declares a paper with the size A4 (there are many different sizes)
\usepackage[utf8]{vietnam}
- usepackage
is the keyword to import a library to the document, here I am importing a library that supports Vietnamese language. (by default doesn't support Vietnamese)
\usepackage{fancyhdr}
- another imported library, this one's responsible for creating headers/footers for the document.
\title{}
- the text inside the curly brackets will be the title of the page, same applied to \author
and \date
\maketitle
- create a beautiful title for your paper.
The result will be: