All guides
Basics

Your first LaTeX document

The parts every document has: the class, the preamble, the body, sections — and how to compile.

The three parts

Every LaTeX file starts with \documentclass, which chooses the layout (article, report, book, or a journal class). Between it and \begin{document} is the preamble, where you load packages and set the title. Everything you want printed goes between \begin{document} and \end{document}.

\documentclass{article}      % the layout
\usepackage{amsmath}          % preamble: packages and settings

\title{My first document}
\author{Your Name}

\begin{document}
\maketitle
Hello, world!
\end{document}

Sections and paragraphs

Use \section, \subsection and \subsubsection for headings; they are numbered automatically. A blank line starts a new paragraph — single line breaks in the source are ignored, so you can write one sentence per line.

\section{Introduction}
This is the first paragraph.
This sentence is still in the same paragraph.

This one starts a new paragraph.

\subsection{Background}
\subsubsection*{An unnumbered heading}

Compiling

Press Compile (or Ctrl+Enter) to build the PDF. If something is wrong, the log explains it in plain words and often has a one-click fix. Lines starting with % are comments and do not appear in the PDF.

Try it: the full example compiles as it is. Open as a project
Next guide
Formatting text and lists