LaTeX for beginners

What to install, what a document is made of, and the handful of commands that carry most of the work. If you have not met LaTeX at all, start withwhat LaTeX is.

1. Decide where to run it

You have two reasonable options, and the choice is mostly about whether you want to install anything.

2. Understand the shape of a document

Every LaTeX document has the same two parts. The preamble comes first and sets things up; the body is the actual content, between \begin{document} and\end{document}.

document.tex
\documentclass[12pt,a4paper]{article}  % preamble starts
\usepackage{graphicx}
\title{My First Document}
\author{A. Name}

\begin{document}                       % body starts
\maketitle

\section{Introduction}
This is a paragraph. A blank line starts a new one.

\end{document}

Two rules that surprise everybody at first: a single line break in your source does not start a new paragraph — a blank line does. And a% starts a comment, so to print an actual per-cent sign you write \%.

3. Learn these commands first

CommandWhat it does
\documentclass{...}Chooses the overall design: article, report, book, beamer.
\usepackage{...}Loads an extension — graphics, maths, colour, bibliographies.
\section{...}A numbered heading. Also \subsection and \subsubsection.
\textbf{...}Bold. \emph{...} is emphasis, and usually what you want.
\begin{itemize}A bulleted list; \begin{enumerate} numbers it instead.
\includegraphics{...}Places an image. Needs \usepackage{graphicx}.
\label / \refName a thing, then refer to it. LaTeX keeps the number right.
\cite{...}Cite a source from your bibliography database.

4. Start from a template, not a blank file

This is the single biggest time-saver for a beginner. A working document that already compiles gives you something to change one line at a time, which is a far better way to learn than assembling a preamble from scratch and debugging all of it at once. Change one thing, recompile, see what moved.

5. Expect to read errors

LaTeX's error messages are famously terse, and the line number it reports is where it noticed the problem, not always where you made it. Three habits handle most cases:

6. Compile more than once

Cross-references, tables of contents and bibliographies work by writing information to an auxiliary file on one pass and reading it on the next. So a document with references usually needs two compilations to settle, and one with a bibliography needs a bibliography tool run in between. Most editors and build tools do this for you — if a reference shows up as??, an extra compile is the usual fix.

A realistic first hour

Open a template, compile it unchanged, and confirm you get a PDF. Change the title and your name. Add a section. Add a list. Break something deliberately and read the error. That sequence teaches you more than any amount of reading, because it puts the compile loop — the thing you will actually spend your time in — into your hands straight away.

Why use LaTeX?What is LaTeX?