Skip to Main Content

Overleaf - LaTeX: Creating a LaTeX Document in Overleaf

Getting started

When you open your first document, you will see that LaTeX provides you with some code by default.

\documentclass{article}
\usepackage[utf8]{inputenc}

\title{My First LaTeX Document}
\author{Jane Doe }
\date{February 2021}

\begin{document}

\maketitle

\section{Introduction}

\end{document}

Commands in LaTeX are preceded by a blackslash \.

The command \documentclass{..} refers to the type of document you want to create. The type of document is specified within the curly brackets. The default document class is article. Other popular classes include book, report, and letter.

The inputenc package command on the second line allows you to use accented characters in LaTeX. A package in LaTeX is a collection of files with commands that produce additional features. Often, you will need to add packages to your document in order to customize your text.

The \title{..} command is used to specify a title for your document, where the title is entered in the curly brackets.

The \author{..} and \date{..} commands are used to display information regarding the document author's name and the date of the document. Both commands can be updated by changing the information within the curly brackets. To include today's date in the document, use the command \today.

\date{\today}

The \begin{document} command starts the document, and the \end{document} command ends it. Each time a begin command is used, you must use an end command as well. 

It is useful to know that the section of your document before the \begin{document} command is known as the "preamble". Packages are added to the preamble of your document.

The \maketitle command generates the title, author, and date in the document. Without this command, the information entered before the \begin{document} command will not appear in the document.

 

After you've finished entering your code, click on the recompile button. Clicking this button will generate a pdf of your document.

Adding comments

You can ignore a command in LaTeX or include notes for yourself in the code by using the % sign. Simply add the % sign before the text or code you would like LaTeX to ignore. The parts that are commented out will appear in green in the editor.

\begin{document}

\maketitle %The \maketitle command generates a title

\section{Introduction}