Skip to main content
Typesetting For Academia And Beyond:

Get started with LaTeX

Summary

A structured LaTeX tutorial for beginners covering the complete workflow: preamble setup, text formatting, mathematical expressions, images with captions and cross-references, tables, lists, document organization, automatic table of contents, and PDF export.

Introduction #

I just finished reading the book “LaTeX Beginner’s Guide: Write research papers, theses, and presentations with professional formatting, math, and citations” by Stefan Kottwitz. I liked it a lot. The book is clear, practical, and full of examples that actually work. Two thumbs up. The book inspired me to write this little introduction to LaTeX.

I am part of the web team of www.latex-project.org and www.learnlatex.org. As the webmaster, I should at least have one LaTeX article on ditig.com, right? So here we go.

LaTeX (pronounced “Lah-tech” or “Lay-tech”) is a typesetting system widely used in academia, scientific publishing, and technical writing. Unlike word processors, LaTeX separates content from formatting. You write plain text with markup commands, and LaTeX produces a professionally typeset Portable Document Format (PDF) document.

This guide walks you through the essential steps to create your first LaTeX document. You will learn how to structure your file, format text, add images and tables, write mathematical expressions, and generate a table of contents automatically. All examples assume you are using a standard LaTeX distribution such as TeX Live or an online editor like Overleaf.

Setting up your document’s preamble #

Every LaTeX document begins with a preamble. The preamble is the section before \begin{document}. It contains global settings, loads packages, and defines custom commands.

A minimal preamble looks like this:

\documentclass{article}

The \documentclass command declares the type of document. Common classes are article, report, book, and letter. Each class provides different default layouts and sectioning commands.

You will typically add more instructions to the preamble:

\documentclass[12pt, a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{amsmath}

The optional arguments 12pt and a4paper set the font size and paper size. The inputenc and fontenc packages ensure correct handling of accents and special characters. The graphicx package allows you to insert images. The amsmath package provides advanced mathematical typesetting.

Document metadata #

Adding the title, author, and date to your document is straightforward. Place these commands in the preamble:

\title{Getting Started with LaTeX}
\author{Your Name}
\date{April 2026}

After these definitions, call \maketitle inside the document body (after \begin{document}) to render the title block. If you omit the \date command, LaTeX automatically uses the current date. Use \date{} for no date.

Using comments in LaTeX code #

Comments begin with a percent sign %. Everything after % on that line is ignored by LaTeX. Comments help you leave notes for yourself or temporarily disable code.

% This is a comment. The following line prints "Hello"
Hello % this text after % is ignored
World.

The example above produces “Hello World.” with a space. You cannot nest comments. For multi-line comments, either start each line with % or use the comment package (which provides a comment environment).

Text formatting basics #

LaTeX provides simple commands for bold, italic, and underlined text.

  • Bold: \textbf{bold text}
  • Italic: \textit{italic text}
  • Underlined: \underline{underlined text}

You can combine them:

\textbf{bold \textit{bold and italic} only bold again}

For emphasis (usually italic), use \emph{text}. In contexts that are already italic, \emph switches to roman (upright) text.

Do not use underlining for emphasis in print documents; it is a convention from typewriters. Use \emph or \textit instead. Reserve \underline for special cases like highlighting in markup.

Working with images #

Inserting graphics #

To insert an image, load the graphicx package in the preamble. Then use the \includegraphics command.

\includegraphics{filename}

Supported image formats with pdflatex are Portable Network Graphics (PNG), Joint Photographic Experts Group (JPG), and Portable Document Format (PDF). For Encapsulated PostScript (EPS) images, use latex + dvipdfm or convert to PDF.

Place images inside a figure environment to add a caption and make it float to a suitable position:

\begin{figure}[htbp]
  \centering
  \includegraphics[width=0.8\textwidth]{example-image}
  \caption{This is a caption.}
  \label{fig:example}
\end{figure}

The optional argument [htbp] controls placement: here, top, bottom, or on a dedicated float page. \centering centers the image horizontally. The width option scales the image to 80% of the text width.

Using captions, labels, and cross-references #

Add a \label command after \caption. Then refer to the figure number anywhere in your document with \ref{fig:example}. For the page number, use \pageref{fig:example}.

As shown in Figure~\ref{fig:example}, the layout is consistent.

The tilde ~ produces a non-breaking space between “Figure” and the reference number.

Creating lists #

Bullet point (unordered) lists #

Use the itemize environment:

\begin{itemize}
  \item First item
  \item Second item
  \item Third item
\end{itemize}

Numbered (ordered) lists #

Use the enumerate environment:

\begin{enumerate}
  \item First item
  \item Second item
  \item Third item
\end{enumerate}

You can nest lists up to four levels. Each level changes the bullet symbol or numbering style automatically.

Incorporating mathematical expressions #

LaTeX excels at typesetting mathematics. You have two main modes: inline and display.

Inline math mode #

Wrap math expressions in single dollar signs $...$ or \(...\). The formula stays within the text line.

The Pythagorean theorem is $a^2 + b^2 = c^2$.

Display math mode #

Display math centers the formula on its own line. Use double dollar signs $$...$$ (plain TeX style) or \[ ... \] (LaTeX recommended). For numbered equations, use \begin{equation} ... \end{equation}.

\[
  \int_{0}^{\infty} e^{-x^2} dx = \frac{\sqrt{\pi}}{2}
\]

\begin{equation}
  E = mc^2
\end{equation}

Complete math examples #

% Inline: $\sum_{i=1}^{n} i = \frac{n(n+1)}{2}$

% Display with alignment:
\begin{align*}
  (x+y)^2 &= x^2 + 2xy + y^2 \\
  (x-y)^2 &= x^2 - 2xy + y^2
\end{align*}

The align* environment (from amsmath) aligns equations at the & symbol. The * version suppresses equation numbers.

Organizing the document structure #

Writing an abstract #

In the article and report classes, use the abstract environment after \maketitle and before your first section.

\begin{abstract}
  This paper provides an introduction to LaTeX.
\end{abstract}

Formatting paragraphs and line breaks #

LaTeX automatically indents the first line of each paragraph except after section headings. To start a new paragraph, leave a blank line in your source code.

For a line break without starting a new paragraph, use \\ or \newline. For a page break, use \newpage.

Do not use blank lines inside environments like equation or itemize. They will cause errors.

Dividing content into chapters and sections #

LaTeX provides hierarchical sectioning commands:

  • \section{Section Title}
  • \subsection{Subsection Title}
  • \subsubsection{Subsubsection Title}
  • \paragraph{Paragraph Title} (inline heading, no number)
  • \subparagraph{Subparagraph Title}

The book and report classes also have \chapter{Chapter Title}.

Use \section*{Title} for unnumbered sections. These do not appear in the table of contents unless you add them manually with \addcontentsline.

Building tables #

Constructing a simple table #

Tables are created with the tabular environment. Specify column alignment with l (left), c (center), or r (right). Use & to separate columns and \\ to end a row.

\begin{tabular}{lcr}
  Left & Center & Right \\
  1    & 2      & 3     \\
  a    & b      & c
\end{tabular}

Adding cell borders and rules #

Vertical lines are added in the column specification: {|l|c|r|}. Horizontal lines are added with \hline.

\begin{tabular}{|l|c|r|}
  \hline
  Left & Center & Right \\
  \hline
  1    & 2      & 3     \\
  a    & b      & c     \\
  \hline
\end{tabular}

For partial horizontal lines, use \cline{2-3} to draw a line only over columns 2 through 3.

Managing captions, labels, and references for tables #

Wrap your tabular inside a table environment to add a caption and make it float.

\begin{table}[htbp]
  \centering
  \begin{tabular}{|l|c|r|}
    \hline
    Left & Center & Right \\
    \hline
    1    & 2      & 3     \\
    a    & b      & c     \\
    \hline
  \end{tabular}
  \caption{Sample table}
  \label{tab:example}
\end{table}

Refer to the table with Table~\ref{tab:example}.

Generating a table of contents automatically #

After you have used \section, \subsection, and (in book/report) \chapter commands, add \tableofcontents where you want the table of contents to appear. LaTeX needs two compilation passes: first to write the table of contents data to a .toc file, and second to read it back and generate the actual table.

\documentclass{article}
\begin{document}
\tableofcontents
\section{Introduction}
...
\end{document}

Use \listoffigures and \listoftables to generate lists of figures and tables. These also require two compilation passes.

Exporting your final document #

The standard way to produce a PDF is to run pdflatex on your .tex file. From the command line:

pdflatex document.tex

Run it twice to resolve cross-references, citations, and the table of contents. If you use BibTeX for bibliographies, you need four steps: pdflatex document, bibtex document, pdflatex document, pdflatex document.

If you are using Overleaf, the platform compiles automatically each time you save. You can download the generated PDF using the “Download PDF” button.

For local installations, most LaTeX editors (TeXstudio, TeXmaker, VS Code with LaTeX Workshop) provide a “Build” or “Compile” button that runs the correct sequence for you.

Discovering and using LaTeX packages #

Where to find package documentation: CTAN #

The Comprehensive TeX Archive Network (CTAN) is the central repository for all LaTeX packages. Visit ctan.org and search for a package. Each package page includes a link to its documentation (usually a PDF manual). Most manuals are also available on your local system after installation via the command texdoc packagename.

How to load a package #

Load a package in the preamble with the \usepackage command:

\usepackage[options]{packagename}

For example, a single option:

\usepackage[margin=2.5cm]{geometry}

The geometry package changes page margins. Multiple options are separated by commas. Here is an example with multiple options:

\usepackage[margin=2.5cm, headheight=15pt, includehead]{geometry}

This sets the page margin to 2.5 cm, the header height to 15 points, and includes the header in the margin calculation.

What is TeX Live? (Packages available in Overleaf) #

TeX Live is a complete LaTeX distribution for Linux, macOS, and Windows. It includes the LaTeX engine (pdflatex, lualatex, xelatex), hundreds of packages, fonts, and supporting tools. TeX Live is maintained by the TeX Users Group (TUG). You can install it from tug.org/texlive.

Overleaf, the online LaTeX editor, includes a full TeX Live distribution. When you select a package on Overleaf, it is already available. You do not need to install anything. For packages not pre-installed (rare), Overleaf provides a “custom texmf” feature documented in their help pages.

FAQ's #

Most common questions and brief, easy-to-understand answers on the topic:

What is the difference between \begin{equation} and \[?

Both create display math. \begin{equation} adds an automatic equation number. \[ ... \] produces unnumbered display math. Use \begin{equation*} (with the amsmath package) for unnumbered display math as well.

Why do my images not appear in the PDF?

Make sure you have compiled the document with pdflatex (or lualatex/xelatex) and that the image file path is correct. Supported formats are PDF, PNG, JPG, and (with pdflatex) only those three. For EPS images, use latex + dvipdfm or convert them to PDF.

How do I create a list without extra spacing between items?

Load the paralist package and use \begin{compactitem} for bullet points or \begin{compactenum} for numbered lists. Alternatively, load enumitem and add nosep as an option: \begin{itemize}[nosep].

Do I need to install LaTeX to use it?

No. You can use online editors like Overleaf (mentioned in this article) or Papeeria. For local installation on Windows, Mac, or Linux, install TeX Live (recommended), MacTeX (for macOS), or MikTeX (Windows).

What is the correct way to type quotation marks in LaTeX?

Use two backticks `` for opening double quotes and two single quotes '' for closing double quotes. For single quotes, use a backtick ` for opening and a single quote ' for closing. Straight quotes from the keyboard " produce inch or foot symbols, not proper quotation marks.

How do I include LaTeX code in a markdown document?

This depends on your markdown processor. Many support inline math with $...$ and display math with $$...$$. For full LaTeX documents, you cannot embed them inside markdown directly. Instead, compile your .tex file to PDF and then link or embed the PDF.

Further readings #

Sources and recommended, further resources on the topic:

Author

Jonas Jared Jacek • J15k

Jonas Jared Jacek (J15k)

Jonas works as project manager, web designer, and web developer since 2001. On top of that, he is a Linux system administrator with a broad interest in things related to programming, architecture, and design. See: https://www.j15k.com/

License

Get started with LaTeX by Jonas Jared Jacek is licensed under CC BY-SA 4.0.

This license requires that reusers give credit to the creator. It allows reusers to distribute, remix, adapt, and build upon the material in any medium or format, for noncommercial purposes only. To give credit, provide a link back to the original source, the author, and the license e.g. like this:

<p xmlns:cc="http://creativecommons.org/ns#" xmlns:dct="http://purl.org/dc/terms/"><a property="dct:title" rel="cc:attributionURL" href="https://www.ditig.com/get-started-with-latex">Get started with LaTeX</a> by <a rel="cc:attributionURL dct:creator" property="cc:attributionName" href="https://www.j15k.com/">Jonas Jared Jacek</a> is licensed under <a href="https://creativecommons.org/licenses/by-sa/4.0/" target="_blank" rel="license noopener noreferrer">CC BY-SA 4.0</a>.</p>

For more information see the Ditig legal page.

All Topics

Random Quote

“I do hope and expect to be able to find a job much more easily due to Linux.”

Linus Torvalds  Finnish software engineer, creator of the Linux kernel and GitLinux Journal, - IT quotes