Learn LaTeX: Setup, Documents, Math and References
Login
Sign upSign up for free
16 Sep 2021··7 min read
LaTeX for Beginners: A Simple Step-by-Step Guide (2026)
A comprehensive LaTeX guide to learn basic & advanced features to write a paper or thesis, explained via full code examples, in videos, of LaTeX.
LaTeX (say "Lay-tech" or "Lah-tech") is a free tool for writing clean, professional documents, and it is the standard for theses, research papers and anything with heavy math.
Word and Google Docs show you the page as you type it. LaTeX works differently: you write plain text with simple commands, and LaTeX turns it into a polished PDF. You focus on your content, and LaTeX handles fonts, spacing, numbering and layout.
This beginner's guide walks you through installing LaTeX, building your first document, and adding tables, images, equations and citations. No prior experience is needed, and each section stands on its own, so you can jump to what you need.
TeX vs. LaTeX: What's the Difference?
TeX is the engine, and LaTeX is the easy-to-use layer on top of it.
Computer scientist Donald Knuth created TeX in the late 1970s because he was unhappy with how his book The Art of Computer Programming looked in print. TeX gave him precise control over text and math, but it was hard to learn. In the 1980s, Leslie Lamport built LaTeX on top of TeX, adding ready-made document styles, automatic numbering and cross-references.
Here is a simple example. To add a section heading in plain TeX, you pick the font size, style and spacing yourself. In LaTeX, you type one command and the formatting is done for you:
latex
\section{Introduction}
Why Learn LaTeX?
LaTeX is worth learning if you write long, technical or math-heavy documents. Its main benefits:
Beautiful math. Equations, symbols and formulas look right with almost no effort.
Consistent formatting. Fonts, spacing and headings stay uniform across the whole document.
Automatic everything. Numbering, cross-references, tables of contents, indexes and bibliographies update themselves.
Plain-text source. Any text editor can open your files, and version control tools like Git can track every change.
Stable with big documents. Theses and books with hundreds of pages are far less likely to break than in a word processor.
Free and widely supported. Many universities and journals offer LaTeX templates, though you should always check a journal's submission rules before choosing your workflow.
How to Install LaTeX
You have two options: install LaTeX on your computer, or use a free online editor and skip installation entirely.
Option 1: Use an online editor
Online editors such as Overleaf run in your browser, need no setup, and make it easy to share and co-write documents. This is the fastest way to start.
Option 2: Install on your computer
A LaTeX "distribution" bundles the compiler, fonts and thousands of packages. The most common choices are:
Your system
Recommended distribution
Notes
Windows
TeX Live or MiKTeX
TeX Live is the full, official-style install. MiKTeX is lighter and downloads missing packages on demand.
macOS
MacTeX
Based on TeX Live. Check its page for the macOS versions it supports.
Linux
TeX Live
Install through your package manager, or use the official TeX Live installer.
To install TeX Live on Windows:
Go to the TeX Users Group site (tug.org) and download the official TeX Live installer.
Run the installer and choose an install location and default paper size (A4 or Letter). You can change page size per document later.
Click Install and wait. The full install is large, so it can take a while.
When it finishes, click Close and open your LaTeX editor (TeXworks comes with the install).
TeX Live is updated every year, so always follow the current instructions on the download page. Once installed, compile a short test document (see the last section) to confirm everything works.
How to Install LaTeX Packages
Packages are add-ons that give LaTeX extra features, such as inserting images, adding color or formatting code. Most popular packages are already included, and you load one in your document with a single line:
latex
\usepackage{graphicx}
If you need one that is missing, here is how to add it:
MiKTeX: It offers to download missing packages automatically the first time you compile.
TeX Live: Use the built-in package manager. For example, run tlmgr install packagename in a terminal.
Manual install: Only needed for rare packages. Download the package from CTAN (the main LaTeX package archive), run the .ins file through LaTeX to extract the files, then copy them into your local texmf folder and refresh the file database (texhash or mktexlsr on TeX Live, initexmf --update-fndb on MiKTeX).
To read any package's manual, type texdoc packagename in a terminal.
Basic LaTeX Document Structure
Every LaTeX file has two parts: the preamble (your setup) and the body (your content). Here is the smallest useful example:
The preamble is everything before \begin{document}. It sets the document type, font size and paper size, and it loads packages.
The body sits between \begin{document} and \end{document}. This is where your text, headings, tables and figures go. The \maketitle command prints the title, author and date you defined above it.
Choosing a document class
The class sets the overall layout. The most common ones are:
Class
Best for
article
Papers, short reports, assignments
report
Longer reports and theses with chapters
book
Books, with front matter, chapters and appendices
beamer
Presentation slides
letter
Letters
Add options in square brackets, separated by commas. For example, [12pt,twoside] gives 12-point text set up for double-sided printing.
Abstract
If your paper needs one, add it right after the title:
latex
\begin{abstract}
Your summary goes here.
\end{abstract}
Keyword formatting depends on your class or journal template, so check its instructions.
Sections, Table of Contents and Paragraphs
LaTeX numbers your headings automatically, so you never type section numbers by hand.
Add a star (*) to skip numbering. Starred headings also stay out of the table of contents. To keep an unnumbered heading in the contents, add \addcontentsline{toc}{section}{Acknowledgements} after it.
Books and reports also offer \chapter and \part.
Table of contents
Place these commands where you want the lists to appear, usually after the title or abstract:
latex
\tableofcontents
\listoffigures
\listoftables
To show more heading levels in the contents, add this to your preamble:
latex
\setcounter{tocdepth}{4}
To rename the contents heading, use \renewcommand{\contentsname}{Your Title}. Compile twice so LaTeX can fill in the page numbers.
Paragraphs and spacing
To start a new paragraph, leave one blank line in your source. The blank line does not appear in the output.
Use \noindent to remove a paragraph's first-line indent. For line spacing, load the setspace package, then use \onehalfspacing or \doublespacing.
Formatting Text, Lists, Tables and Images
Bold, italics and comments
latex
\textbf{bold text}
\textit{italic text}
\emph{emphasized text}
% This line is a comment and will not appear in the PDF.
\emph is the preferred way to stress a word. Inside already-emphasized text, it switches back to normal, so the emphasis always stays visible.
Lists
Use itemize for bullets, enumerate for numbers and description for terms with definitions. Lists can be nested.
latex
\begin{enumerate}
\item First item
\item Second item
\begin{itemize}
\item A nested bullet
\end{itemize}
\end{enumerate}
For more control over list styles, try the enumitem package.
Footnotes
latex
This sentence needs a note.\footnote{This is the footnote text.}
LaTeX numbers and places footnotes for you.
Tables
Tables and figures are "floats," which means LaTeX moves them to the best spot so they do not split awkwardly across pages.
latex
\begin{table}[t]
\centering
\caption{A simple table.}
\label{tab:example}
\begin{tabular}{| l | c | r |}
\hline
Name & Score & Grade \\
\hline
Ana & 92 & A \\
Ben & 85 & B \\
\hline
\end{tabular}
\end{table}
In {| l | c | r |}, each letter sets a column's alignment (left, center, right) and each | draws a vertical line. Use & between cells, \\ to end a row, and \hline for horizontal lines. Refer to the table in your text with \ref{tab:example}.
The placement options are h (here), t (top), b (bottom) and p (separate page).
Images
Load the graphicx package in your preamble, then insert the image. PNG, JPG and PDF files all work.
For several aligned lines, use align (or align* for no numbers). Use & to mark where lines line up. Avoid the older eqnarray, which has spacing problems.
Use \left and \right so brackets grow to fit what is inside:
latex
\left( \frac{1}{\sqrt{x}} \right)
Matrices
The pmatrix environment adds round brackets for you. Use bmatrix for square ones.
latex
\begin{bmatrix}
1 & 0 \\
0 & 1
\end{bmatrix}
How to Add a Bibliography and Citations
LaTeX keeps your references in a separate .bib file and builds the reference list for you.
Step 1: Create a file called references.bib:
latex
@book{doe2020,
author = {John Doe},
title = {A Sample Book},
publisher = {Example Press},
year = {2020}
}
Step 2: Cite it in your document and point LaTeX to the file:
latex
\documentclass{article}
\begin{document}
This idea comes from earlier work \cite{doe2020}.
\bibliographystyle{ieeetr}
\bibliography{references}
\end{document}
ieeetr is a common style in science and engineering. Swap it for another style, such as plain or apalike, to change how citations look.
Compile with LaTeX, then BibTeX, then LaTeX twice more. Most editors, including TeXworks and Overleaf, run these steps automatically. For more flexible citation styles, many writers later move to biblatex.
Create Your First PDF
Put everything together with this starter file:
latex
\documentclass[11pt,a4paper]{article}
\usepackage{graphicx}
\usepackage{amsmath}
\title{My First LaTeX Document}
\author{Your Name}
\date{\today}
\begin{document}
\maketitle
\section{Introduction}
Hello, LaTeX! Here is a famous equation:
\begin{equation}
E = mc^2
\end{equation}
\end{document}
Then:
Open your editor (TeXworks, TeXstudio, MiKTeX's editor or Overleaf) and paste in the code.
Save the file with a .tex extension, such as first.tex.
Click the green Typeset or Recompile button.
Your PDF appears in a preview window and is saved next to your .tex file. Open or share it like any other PDF.
If you see an error, check for a missing brace } or a misspelled command. The error message usually names the line number.
LaTeX FAQs
Next Steps
Now that you know the basics, try these:
Write a short document using your school's or journal's LaTeX template.
Explore the texdoc manuals for packages like geometry, hyperref and booktabs.
Browse CTAN to discover new packages.
Keep a cheat sheet of commands nearby while you practice.