First steps of LaTeX

Last week I showed you how to get started with ShareLaTeX. When you create a new project, ShareLaTeX automatically generates a document including the bare bones basics of a LaTeX document. This week, let’s examine each of these elements in detail.


Before we begin, there are three basic kinds of input in a LaTeX document:

  • Commands begin with a backslash \. ShareLaTeX color codes commands in purple.
  • Comments begin with a percentage sign %. ShareLaTeX color codes comments in green.
  • All other text is black (on a white background).

Keeping these kinds of text in mind, let’s work through the commands included by default. Commands begin with a backslash \ and end with a definition included in braces {}. In between the command and the definition you may see some options included in brackets [].

Document class

The command for \documentclass tells LaTeX what kind of document you want to create, and you have quite a few options. For now, let’s look at the most common few:

  • Article: article, the default option, produces a generic document that looks like a term paper. We will work with this option mainly, but later on, we will discuss some of the other options.
  • Book: book allows for chapters, each of which can include sections and other material, whereas article only allows up to sections. A book also includes a title page, but this is possible with article (though not the default).
  • Letter: letter includes blocks for sender and recipient addresses and omits title information (letters do not have titles). This is great for cover letters, which we’ll discuss later on with curricula vitae.
  • Beamer: beamer produces slides for presentations, which we’ll discuss later on as well.


Many of the mechanical and stylistic tweaks, adjustments, and refinements you’ll want to make to your document begin with packages. Some of the document classes include the possibility of some adjustments or have special ways of making these adjustments.

In the article class, you have few built-in options, so packages become necessary. As you become more comfortable with LaTeX, and as you demand more and more adjustments, you can add as many packages as you like. Sometimes packages may have conflicts with each other, but these are rare, usually documented, and mostly easily addressed.

To use a package, include its name in braces {} after the command \usepackage. ShareLaTeX includes the package inputenc by default, along with the option utf8.1 For now, we’ll leave this package in and won’t add any more.

Title information

The next three lines tell LaTeX what title information you want to include in the output. This includes the title after the \title command; the author’s or authors’ name(s), included after the \author command; and the date. ShareLaTeX includes the month and year by default for the date, but you can change this however you want. You can even use the command \today within the braces after \date to print the current date in the output: \date{\today} will print the current date.2

Begin document

The header information precedes the \begin{document} command and will not be printed in the output. Only what you add after the \begin{document} and before the \end{document} commands will appear in the output.

You should notice, after the \begin{document} command, the \maketitle command. This tells laTeX to include the title information you input above, before the \begin{document} command. In other words, rather than directly input the title, author, and date into the document, LaTeX takes that information you defined in the header information and uses those definitions when it prints the title information in your document.3


The basic unit of an article is the section, and LaTeX includes a special command for section headers. You can give your sections whatever title you want within the braces following the \section command. To add another section to your document, add another \section command. You can have as many sections as you want, you can title each of them whatever you want, and you can arrange them however you want.

I often begin a new paper by transposing the outline from my notes into the LaTeX document by way of the section headers. Then, as I write, I can focus on a certain section at any given time.

While the basic unit of an article is a section, the basic unit of writing is the paragraph. To start a new paragraph, hit “Enter” or “Return” twice so that you leave a blank line between paragraphs. LaTeX will interpret that blank line as starting a new paragraph and indent the new paragraph (the default).4

End document

This command ends the document in terms of the desired output. Anything you type after this point will not affect the output. I do that to move chunks of text I’m considering deleting—but haven’t made up my mind yet—out of the way of the rest of the text.

Those few commands are all you need for a basic paper in LaTeX. Of course, there is much more you can—and should—do, but we will get to that.

  1. This package allows for inputting special text, such as characters with accents, into the input. ↩︎
  2. The “current” date means the date when you compile the document, producing the output. ↩︎
  3. This comes in handy in more complex documents when you may want, for example, the author’s or authors’ name(s) or the title printed on page headers on every other page, like some journals do. ↩︎
  4. Depending on the packages and options you use, LaTeX can also insert a blank line between the old and new paragraphs. ↩︎

Jeremy L. Wells

Leave a Reply

Your email address will not be published. Required fields are marked *