LaTeX for Beginners: Complete Guide

This guide takes you from zero to producing your first real LaTeX document. No prior experience required — just a browser and 30 minutes.

Document Structure

Every LaTeX document has the same fundamental structure: a preamble and a body. The preamble is where you declare the document class, load packages, and set global options. The body is where your actual content goes, enclosed between \begin{document} and \end{document}.

% ── PREAMBLE ──────────────────────────────
\documentclass[12pt, a4paper]{article}  % Document class
\usepackage[utf8]{inputenc}             % Character encoding
\usepackage{amsmath}                    % Math support
\usepackage{geometry}                  % Page margins

\title{My Document Title}
\author{Your Name}
\date{\today}

% ── BODY ───────────────────────────────────
\begin{document}

\maketitle    % Insert title, author, date

\section{Introduction}
Your content goes here.

\end{document}

Comments in LaTeX start with %. Everything after % on a line is ignored by the compiler.

Document Classes

The document class is the first thing in every LaTeX file. It determines the overall layout and default settings. Choose the class that best matches your document type:

ClassBest for
articlePapers, essays, short reports — the default for most documents
reportLonger reports with chapters, e.g. lab reports, case studies
bookFull books and long manuscripts with front matter and parts
beamerPresentation slides — creates a slide deck from LaTeX source
letterFormal letters with address and salutation formatting
IEEEtranIEEE conference and journal papers (separate class file required)

Essential Packages

Packages extend LaTeX with additional functionality. Load them in the preamble with \usepackage{}name}. Here are the packages every beginner should know:

amsmath

Essential for mathematics: aligned equations, matrices, special operators, and symbols from the American Mathematical Society.

graphicx

Include images in your document with \includegraphics. Supports PNG, JPEG, PDF, and EPS formats.

hyperref

Makes cross-references and citations clickable in the PDF. Also adds document metadata for PDF readers.

geometry

Control page margins: \usepackage[margin=2.5cm]{geometry}

fontenc

Correct font encoding for Western European characters. Use with \usepackage[T1]{fontenc}

babel

Localisation: correct hyphenation, date formats, and section names for your language. \usepackage[english]{babel}

booktabs

Professional quality tables with \toprule, \midrule, and \bottomrule — much better than default LaTeX tables.

listings

Include formatted source code with syntax highlighting. Supports Python, C, JavaScript, and many other languages.

Text Formatting

LaTeX handles text formatting through commands rather than toolbar buttons. In LaTeX, formatting is always explicit and consistent — there is no risk of accidentally inheriting a random style from a previous paragraph.

CommandEffectExample
\textbf{text}Boldimportant term
\textit{text}Italicemphasis
\underline{text}Underlineunderlined phrase
\texttt{text}Monospacecode snippet
\emph{text}Context-aware emphasisadapts to surroundings
\large, \Large, \hugeIncrease font sizeheadings, titles
\small, \footnotesizeDecrease font sizecaptions, footnotes
\textsuperscript{2}Superscript
\textsubscript{n}Subscriptxₙ

Document Structure Commands

LaTeX automatically numbers your sections, generates the table of contents, and handles all cross-references. You just declare the structure:

\section{Introduction}
This is the first section. LaTeX numbers it 1.

\subsection{Background}
This becomes section 1.1.

\subsubsection{Historical context}
This is section 1.1.1.

\section{Methodology}
LaTeX automatically numbers this 2.

\tableofcontents  % Put this at the start — auto-generated!

Lists

LaTeX has three list environments built in: unordered (itemize), ordered (enumerate), and descriptive (description). Lists can be nested to any depth.

% Bullet list
\begin{itemize}
  \item First item
  \item Second item
  \begin{itemize}        % Nested list
    \item Sub-item
  \end{itemize}
\end{itemize}

% Numbered list
\begin{enumerate}
  \item Step one
  \item Step two
  \item Step three
\end{enumerate}

% Definition list
\begin{description}
  \item[LaTeX] A document preparation system
  \item[PDF] Portable Document Format
\end{description}

Special Characters

Ten characters have special meaning in LaTeX and must be escaped if you want to print them literally:

\&   prints &       (ampersand)
\%   prints %       (percent)
\$   prints $       (dollar)
\#   prints #       (hash)
\_   prints _       (underscore)
\{   prints {       (open brace)
\}   prints }       (close brace)
\textasciitilde   prints ~
\textasciicircum  prints ^
\textbackslash    prints \

Practice what you just learned

Open the editor and try these commands. The live PDF preview updates every time you compile.

Start Writing

Continue Learning