Getting started with LaTeX¶
Goal: compile a small document, recognize its source structure, and resolve a cross-reference. You only need basic text editing skills.
LaTeX is a typesetting system: you write a .tex file containing content and
commands, then compile it into a PDF. The source is not the final page layout.
Choose an editor¶
Overleaf is an online LaTeX editor. Your project files are stored online, and its servers turn your source into a PDF: no local TeX installation is required.
The file list organizes .tex files, bibliographies, images, and data.
The source editor is where you write LaTeX; the PDF preview shows the
compiled result. Editing source and compiling it are separate steps.
See the Overleaf walkthrough below.
Do not upload confidential documents without authorization.
Install TeX Live or
MiKTeX and an editor. Ensure pdflatex, latexmk,
and, for later lessons, biber are available on your PATH.
A minimal distribution may require additional packages.
In a terminal, run pdflatex --version and latexmk -v. If either command
is missing, fix the installation before editing a complex project.
Get the learning resources¶
Download the repository's ZIP using Code > Download ZIP, or use Git:
Keep the directory structure intact. Later bibliography examples share
resources/references.bib and resolve it relative to their own folders.
Your first document¶
Open the complete source on GitHub.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amsmath}
\title{My First LaTeX Document}
\author{Your Name}
\date{\today}
\begin{document}
\maketitle
\section{Introduction}
\label{sec:introduction}
Hello, LaTeX! This paragraph belongs to a numbered section.
\section{A first equation}
Section~\ref{sec:introduction} started this document.
\begin{equation}
E=mc^2.
\label{eq:energy}
\end{equation}
Equation~\ref{eq:energy} receives its number automatically.
\end{document}
The preamble ends at \begin{document}. It selects a document class, loads
packages, and defines title information. The document body ends at
\end{document}. amsmath supplies mathematical environments; fontenc
selects a text-font encoding, not an input-file encoding.
lmodern selects scalable Latin Modern fonts.
Compile¶
In Overleaf¶
- Open Overleaf, create an account or sign in,
and choose New project > Blank project. Name it
Hello LaTeX. - Open the generated
main.texin the file list and replace its contents with the complete example above, from\documentclassto\end{document}. Do not include the Markdown code fences. - In the project settings, select pdfLaTeX as the compiler and confirm
that
main.texis the main document. - Select Recompile. Overleaf runs LaTeX and updates the PDF preview. Changes to your source are saved online; recompile after editing to see their effect, or enable automatic compilation.
- Compare the preview with the expected output. If the compile reports errors, open the logs and fix the first source error. An older or incomplete PDF can still be visible, so a preview alone is not proof that the latest source compiled successfully.
- Download the PDF when you need the finished document. Also download the project source ZIP when you need a backup or want to move your work to another editor; the PDF does not contain your editable LaTeX project.
Use Share to invite collaborators and review their access before sharing. Available collaboration features and limits depend on the current plan. Uploading to Overleaf does not automatically synchronize changes with GitHub. For more interface guidance, see Overleaf's first-project guide and compilation guide.
Importing other repository examples
For a multi-file example, upload the contents of its folder so that
main.tex is at the Overleaf project root, retaining folders such as
chapters/ or sections/. Include its images and CSV data.
Bibliography examples also need the shared resources/references.bib:
upload it to your Overleaf project root and change
\addbibresource{../../resources/references.bib} to
\addbibresource{references.bib} in your Overleaf copy.
Keep the repository's original relative paths when compiling locally.
On your computer¶
From the repository root:
Open build/main.pdf. latexmk reruns LaTeX when references need another pass.
Without latexmk, run pdflatex main.tex twice and open main.pdf.
The online editor manages these passes automatically.
Expected output¶
A title, an author, a date, two numbered sections, and a numbered equation.
The references should read Section 1 and Equation 1, not ??.
Page breaks and fonts can vary slightly across TeX distributions.
Try it¶
Change the author, add a sentence to the introduction, and change the equation
to a^2+b^2=c^2. Recompile. The equation number should remain automatic.
Read the first error
If compilation fails, open the log and find the first error with a source line number. Fix it before interpreting the later messages, which may be consequences of the same mistake.
Mathematical notation¶
Write inline math as \(x^2\) and display math in \[...\] or an equation
environment. Continue with mathematics for alignment,
matrices, and units.
Academic writing¶
Use structural commands rather than manually formatting every heading. The academic writing lesson introduces an abstract, citations, and a reusable article.
Presentations¶
The Beamer lesson provides a complete slide deck rather than treating presentation slides as small article pages.
Quick reference¶
Use the cheat sheet when you remember an idea but not its command. It distinguishes complete documents from fragments.
Common errors¶
Missing commands usually indicate a typo or missing package. ?? usually
indicates an unresolved label or insufficient compilation passes.
See troubleshooting for a step-by-step diagnosis.
Next: fundamentals.