A pointing finger.

What is a command?

Commands tell LaTeX to do something. If you want to add a new page, make a formatting change, render a special character... these behaviors are enacted by commands.

A command consists of the character \ (backslash) followed by a word.

Some commands have additional options called parameters, contained in {} (curly braces) or [] (square brackets).

The backslash will be one of the most important keys as you use LaTeX, so make sure to find it on your keyboard - and note the difference from / (forward slash)!

A nice feature of LaTeX is that the command names correspond very intuitively to their functions, sometimes as full words and sometimes as abbreviations.

For example, the command \frac is used to write fractions, and the command \hat produces a hat (a circumflex accent) over a variable.

To get a better idea of what commands are, let's look at some more examples.

Hat command. Expectations: the variable x wears a snappy hat. Reality: the variable x has a circumflex accent.
While LaTeX is close to expectations, there are some exceptions.


In line 1 of the project in Overleaf, you probably see the following text:


Note the structure: documentclass is the command. It is preceded by a backslash. It is followed by the parameter article in curly braces.

The command documentclass tells LaTeX what kind of document we are creating - in this case, an article (a sort of catch-all for shorter papers). This allows us to add the typical elements of an article, like a title and author, or sections and subsections.

In contrast, the command \documentclass{book} would allow us to add elements that are typically in a book, like chapters and subchapters.

Exercise 2.1.1

When you opened a Blank Project, Overleaf automatically added a number of commands. What commands do you see in your project so far?

Solution 2.1.1

Some examples include:





These are all commands with parameters that define some aspect of the document.



These are two matching commands. They delimit what is called an environment (we will learn more about these later).


This is a command without a parameter. This one causes the Title, Author, and Date to appear in your PDF preview. Try removing this command and compiling the Preview, then add it back.

Now that we have learned about the building blocks of LaTeX, on the next page we will look at the project as a whole.