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:
| Class | Best for |
|---|---|
| article | Papers, essays, short reports — the default for most documents |
| report | Longer reports with chapters, e.g. lab reports, case studies |
| book | Full books and long manuscripts with front matter and parts |
| beamer | Presentation slides — creates a slide deck from LaTeX source |
| letter | Formal letters with address and salutation formatting |
| IEEEtran | IEEE 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:
amsmathEssential for mathematics: aligned equations, matrices, special operators, and symbols from the American Mathematical Society.
graphicxInclude images in your document with \includegraphics. Supports PNG, JPEG, PDF, and EPS formats.
hyperrefMakes cross-references and citations clickable in the PDF. Also adds document metadata for PDF readers.
geometryControl page margins: \usepackage[margin=2.5cm]{geometry}
fontencCorrect font encoding for Western European characters. Use with \usepackage[T1]{fontenc}
babelLocalisation: correct hyphenation, date formats, and section names for your language. \usepackage[english]{babel}
booktabsProfessional quality tables with \toprule, \midrule, and \bottomrule — much better than default LaTeX tables.
listingsInclude 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.
| Command | Effect | Example |
|---|---|---|
| \textbf{text} | Bold | important term |
| \textit{text} | Italic | emphasis |
| \underline{text} | Underline | underlined phrase |
| \texttt{text} | Monospace | code snippet |
| \emph{text} | Context-aware emphasis | adapts to surroundings |
| \large, \Large, \huge | Increase font size | headings, titles |
| \small, \footnotesize | Decrease font size | captions, footnotes |
| \textsuperscript{2} | Superscript | x² |
| \textsubscript{n} | Subscript | xₙ |
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