# A Gentle Introduction to LaTeX

Are you a complete LaTeX beginner? This post will arm you with the very basic knowledge you need to get started.

My assumption is that you might have heard the word “LaTeX” at least once before, but do not know what it is or how to use it. By the end of this post, I aim for you to be able to create very simple documents and be prepared to further discover the world of LaTeX on your own.

Contents

## What is it?

LaTeX is a way of creating written documents. Its main difference from word processing tools (such as Microsoft Word) is that, very roughly speaking, in LaTeX your content and the document’s style are separate. Generally, you give it your text and it will process and think about the style on its own. In Word and Pages, while writing your text, you are also micro-managing how the text will look, and the expectation is that what you see on the screen is what you will get in the final document. In LaTeX you usually only give it general rules (e.g.: make this look like an article, or, make this look like a book) and it will create a document with your text.1

I know, that’s a bit abstract and hard to imagine in practice. This is why I believe giving a concrete example will help immensely.

## A Concrete Example

Overleaf is a website that allows you to create documents using LaTeX in a quick and easy way, and it is perfect for beginners. I will be using it throughout this post. While you don’t need to, feel free to sign up and try things out along with me. I will be creating a new, blank project. This is roughly what you should see immediately afterwards.

What’s on the left is what we input, that is, what we tell LaTeX. What’s on the right is the output, the document LaTeX gives us in return.2 Let’s take a closer look at our input, and go through it. Here it is for convenience:

\documentclass{article}

\begin{document}

This is the body of the document.

\end{document}

Let’s go through the lines:

• \documentclass{article} tells LaTeX that we want this document to be and look like an article. This must always be the first line of every LaTeX document. If we had instead typed, say, \documentclass{book}, LaTeX would have made it look like a book. There’s lots of other document classes, but these two will suffice for now.
• \begin{document} and \end{document} tell LaTeX that everything between these two lines should be printed out to the document. Anything before or after is not printed out.
• This is the body of the document is kind of self-explanatory. To note that, since this line was typed in between the commands “begin” and “end,” it is shown and printed on the document on the right.

This is the bare minimum we need to have a working document: every line typed here is essential to LaTeX’s functioning. As you can see, words after backslashes (\) like “documentclass” or “begin/end” were not shown in the document: they are for LaTeX only, so that it can understand what type of document we are creating, where it starts, and where it ends. These are called “commands.”3 I am aware that there’s some terminology in this post. If you scroll towards the end, you’ll find I have compiled a glossary of all this LaTeX jargon, so that hopefully you don’t get lost. While it is true that you don’t need to know what things are called in order to use them, you’ll find it will be extremely helpful for you to have this knowledge, as it will make it far easier to look things up online when you will need them.

I think now you might be starting to understand what I meant earlier about not directly telling LaTeX what things should look like and instead just focusing on your text. As you can see from the example, the text that we have typed in between the “begin” and “end” commands was taken by LaTeX and automatically positioned and printed out in the final document. We did not tell it to use any particular font, spacing, nor anything else related to style other than the very first line. This is because the document class “article” that we have used already tells LaTeX everything it needs to know about the stylistic side of things.

Our document is a little barebones though, isn’t it? Let’s spice it up a little.

### Title

Most documents need a title, so let’s add one. If you recall, anything that we type before \begin{document} is not printed out. This space is called the preamble, and it’s where we tell LaTeX about various document properties. One such property is the title.

Anywhere in the preamble, add the following line: \title{Your Title}. With this, we assign the document a title. This does not, however, print it out, as it’s in the preamble. It only assigns the document the title. In order to display it, after the line \begin{document}, type \maketitle. The maketitle command prints out the document’s assigned title wherever you place it. This is what you should see now:

### Author

Your document is slowly starting to take shape. In a new line right after the \title{} command, add \author{Your Name}. You do not need to add anything to the document itself as maketitle also prints out the author for you. For flavor, I’ve also added some text to the body. Let’s see what we’ve got.

### Sections

Our example document is almost done, I’d say. Only thing is, when the text gets a bit long, it’s nice to add sections to clearly separate different chunks of text. We can easily do so by adding \section{Section Title} in the document wherever we would like to start a new section. Something like this:

### Bold and Italics

Lastly you might be wondering: how do I do bold and italics? With \textbf{} and \textit{}, respectively, like this:

### Math

Perhaps LaTeX’s true million-dollar feature, and why so many in the scientific community use it, is its incredible math support. Anything you type between pairs of dollar signs will be interpreted as being math. Let me show you just what that looks like below.

I typed ax^2 + bx + c = 0 in between , so LaTeX knows it’s math. The ^ sign means “to the power of,” and so that’s what we get in the result. Some other useful commands that you might want to know now are \sqrt{} for the square root of anything you put between curly brackets, and \over to create a division. Let me show you what those look like in action with a more complex example:

Of course, there’s a lot more to math in LaTeX than these commands, but this is the gist of it, for now. This should be enough for a gentle introduction. On Overleaf, you can click on the small “download” icon on top of the PDF to download it.

## Where to Go from Here

This was only a brief introduction, and I am sure you have more questions. How do I cite? How do I work offline? While I might post more if the demand exists, for now here’s some links you might want to check out next:

• The Overleaf Documentation is kind of like this post, but goes much deeper. I’d recommend checking this out after you close this tab.
• The Not So Short Introduction to LaTeX 2e is kind of like the Overleaf Documentation on hyper-steroids. Also it’s a document itself created with LaTeX, so you can see just what you can do with it.
• This LaTeX cheatsheet can come in handy.
• TeX StackExchange. It will happen in your LaTeX journey that you’ll have a question or two. In all likelihood, it’s been asked there already, and if not, you can ask it yourself.
• The LaTeX Wikibook is the reference for LaTeX. Don’t read it back-to-back, instead look at the index and consult it when you want to know more about a certain topic.

## Glossary

• Command: any word that comes right after a backslash (\) is a command. It’s something we tell LaTeX to do, and is not shown in the output document. Some commands are, for example, \documentclass{} and \begin{}.
• Parameter: anything that comes after a command and is in curly brackets. It’s essentially the input for the command. For instance when assigning a title, you use the command \title{My title goes here!}.
• Preamble: anything that comes between \documentclass{} and \begin{document}. What we type here will not be shown in the output. We use this space to give LaTeX some information about the document that follows, such as \author{}, \date{}, \title{}, etc.
1. Please do take note that this is an oversimplification of what actually occurs, but it should help get the idea across.
2. You might need to click on the green “recompile” button in order for the output to show.
3. Some people call them “tags.” I personally don’t really like that nomenclature, but to each their own.