Skip to main content
LaTeX is a powerful document preparation system that produces beautifully formatted documents. This guide covers the essential syntax you need to get started with Typeset.

Document structure

Every LaTeX document follows a basic structure:
\documentclass{article}

% Preamble - document settings and packages
\title{My Document}
\author{Your Name}
\date{\today}

\begin{document}

\maketitle

% Your content goes here

\end{document}
Everything before \begin{document} is the preamble. Everything between \begin{document} and \end{document} is your actual content.

Document classes

The \documentclass command defines the type of document:
\documentclass{article}    % For short documents and articles
\documentclass{report}     % For longer reports with chapters
\documentclass{book}       % For books
\documentclass{letter}     % For letters
\documentclass{beamer}     % For presentations
You can pass options to customize the document:
\documentclass[12pt, a4paper]{article}  % 12pt font on A4 paper
\documentclass[twocolumn]{article}      % Two-column layout

Sections and headings

Organize your document with hierarchical sections:
\section{Introduction}
This is the introduction.

\subsection{Background}
Some background information.

\subsubsection{Historical context}
More detailed context.

\paragraph{Note}
A named paragraph.
Sections are automatically numbered. Use \section*{Title} with an asterisk to create an unnumbered section.

Text formatting

Basic formatting

\textbf{Bold text}
\textit{Italic text}
\underline{Underlined text}
\texttt{Monospace text}
\emph{Emphasized text}

Font sizes

{\tiny Tiny text}
{\small Small text}
{\normalsize Normal text}
{\large Large text}
{\Large Larger text}
{\LARGE Even larger text}
{\huge Huge text}
{\Huge Hugest text}

Line and paragraph breaks

First paragraph.

Second paragraph. Use blank lines to separate paragraphs.

Force a line break here.\\
New line without a paragraph break.

Lists

Unordered lists

\begin{itemize}
  \item First item
  \item Second item
  \item Third item
    \begin{itemize}
      \item Nested item
      \item Another nested item
    \end{itemize}
\end{itemize}

Ordered lists

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

Description lists

\begin{description}
  \item[Term 1] Definition of term 1
  \item[Term 2] Definition of term 2
\end{description}

Mathematical expressions

One of LaTeX’s greatest strengths is typesetting mathematics.

Inline math

Use $...$ for math within text:
The equation $E = mc^2$ is famous.
The variable $x$ represents the unknown.

Display math

Use \[...\] or equation environments for centered equations:
\[
  f(x) = x^2 + 2x + 1
\]

\begin{equation}
  \int_{0}^{\infty} e^{-x^2} dx = \frac{\sqrt{\pi}}{2}
\end{equation}
The equation environment automatically numbers equations. Use equation* for unnumbered equations.

Common math symbols

% Greek letters
\alpha, \beta, \gamma, \Delta, \pi, \Sigma

% Operators
\times, \div, \pm, \leq, \geq, \neq, \approx

% Fractions and roots
\frac{numerator}{denominator}
\sqrt{x}
\sqrt[3]{x}  % cube root

% Subscripts and superscripts
x^2, x_i, x^{2n}, x_{i,j}

% Summations and integrals
\sum_{i=1}^{n} x_i
\int_{a}^{b} f(x) dx
\prod_{i=1}^{n} x_i

Matrix notation

\[
  \begin{matrix}
    a & b \\
    c & d
  \end{matrix}
\]

% With brackets
\[
  \begin{bmatrix}
    1 & 2 & 3 \\
    4 & 5 & 6 \\
    7 & 8 & 9
  \end{bmatrix}
\]

Tables

Create tables using the tabular environment:
\begin{table}[h]
  \centering
  \begin{tabular}{|l|c|r|}
    \hline
    Left & Center & Right \\
    \hline
    1 & 2 & 3 \\
    4 & 5 & 6 \\
    \hline
  \end{tabular}
  \caption{A sample table}
  \label{tab:sample}
\end{table}
  • l = left-aligned column
  • c = center-aligned column
  • r = right-aligned column
  • | = vertical line
  • \hline = horizontal line

Figures and images

Typeset currently focuses on text-based LaTeX documents. Image handling may require additional packages or workarounds.
\begin{figure}[h]
  \centering
  \includegraphics[width=0.5\textwidth]{image.png}
  \caption{A sample figure}
  \label{fig:sample}
\end{figure}

Cross-references

Reference sections, equations, figures, and tables:
\section{Introduction}
\label{sec:intro}

\begin{equation}
  E = mc^2
  \label{eq:einstein}
\end{equation}

As shown in Section~\ref{sec:intro}, Equation~\ref{eq:einstein} is important.
Use ~ (tilde) before \ref to prevent line breaks between “Section” and the number.

Packages

Extend LaTeX functionality by loading packages in the preamble:
\documentclass{article}

% Common packages
\usepackage{amsmath}     % Enhanced math features
\usepackage{graphicx}    % Include images
\usepackage{hyperref}    % Clickable links
\usepackage{geometry}    % Page layout
\usepackage{booktabs}    % Professional tables

\begin{document}
% Your content
\end{document}

Essential packages

PackagePurpose
amsmathAdvanced mathematical typesetting
amssymbAdditional math symbols
graphicxImage inclusion
hyperrefHyperlinks and PDF features
geometryPage margins and layout
natbib or biblatexBibliography management

Comments

Add comments that won’t appear in the output:
% This is a comment
This text will appear. % This comment won't

% Comments are useful for:
% - Explaining complex code
% - Temporarily disabling content
% - Leaving notes for collaborators

Special characters

Some characters have special meaning in LaTeX and need to be escaped:
% These need backslash to print literally:
\$ \% \& \_ \{ \} \# \\

% Quotes
`single quotes'
``double quotes''

% Dashes
- hyphen
-- en-dash
--- em-dash

Bibliography

Create references for academic documents:
\begin{document}

According to Smith~\cite{smith2020}, this is true.

\bibliographystyle{plain}
\bibliography{references}

\end{document}
Bibliography management typically requires external .bib files. Check Typeset’s documentation for multi-file project support.

Common mistakes to avoid

Characters like $, %, &, _, {, } have special meaning. Use \$, \%, etc. to print them literally.
While $$...$$ works, it’s deprecated. Use \[...\] or \begin{equation}...\end{equation} instead.
LaTeX requires compilation to see changes. Click “Compile” in Typeset frequently to catch errors early.
Use x^{10} not x^10 for multi-character exponents. Without braces, only the first character is superscripted.

Testing your LaTeX code

In Typeset, you can test any LaTeX code immediately:
1

Write your LaTeX code

Type or paste LaTeX code in the editor panel.
2

Click Compile

Click the “Compile” button (play icon) in the top navigation.
3

View the result

See the rendered PDF in the preview panel on the right.
4

Fix any errors

If compilation fails, error messages appear in the preview panel. Fix the errors and compile again.

Learning resources

  • Overleaf Documentation: Comprehensive LaTeX guides and examples
  • LaTeX Wikibook: Community-maintained LaTeX reference
  • CTAN: Comprehensive TeX Archive Network for packages
  • Typeset AI: Use the built-in chat to ask questions about LaTeX syntax
Use Typeset’s AI chat feature to get help with LaTeX syntax. Ask questions like “How do I create a matrix?” or “Show me how to make a numbered list.”

Build docs developers (and LLMs) love