How to Use LaTeX

Open a free Overleaf account (or install TeX Live or MiKTeX), create a blank project and type a document: \documentclass{article}, then text between \begin{document} and \end{document}. Add headings with \section{}, math between dollar signs like $x^2$, and click Recompile to get the PDF.

The first commands you need

  • \documentclass{article}
    Text mode, no math preview

    What kind of document: article, report, book, beamer (slides).

  • \begin{document} ... \end{document}
    Text mode, no math preview

    Everything printed goes between these two lines.

  • \section{Introduction}
    Text mode, no math preview

    A numbered heading.

  • \textbf{bold} \textit{italic}
    Text mode, no math preview

    Text styles.

  • $a^2 + b^2 = c^2$
    a 2 + b 2 = c 2

    Math in a sentence.

  • \[ \sum_{k=1}^{n} k \]
    ∑ k = 1 n k

    Math on its own line.

  • \begin{itemize} \item A \item B \end{itemize}
    Text mode, no math preview

    A bullet list.

Try it live

Change the formula and the preview redraws as you type. Copy the LaTeX, download a PNG or SVG, copy it for Word, or use Edit here on any example below to load it.

Templates

How to use LaTeX examples

Each result below is drawn from the LaTeX under it. Copy the code, edit it on this page, or open it in the full editor.

  • Inline-style formula

    a 2 + b 2 = c 2
    LaTeX
    a^2 + b^2 = c^2
  • Normal distribution

    f ( x ) = 1 σ 2 π e − ( x − μ ) 2 2 σ 2
    LaTeX
    f(x) = \frac{1}{\sigma\sqrt{2\pi}}\, e^{-\frac{(x-\mu)^2}{2\sigma^2}}
  • Derivative

    d d x sin ⁡ x = cos ⁡ x
    LaTeX
    \frac{d}{dx} \sin x = \cos x
  • System of equations

    { x + y = 3 x − y = 1
    LaTeX
    \begin{cases} x + y = 3 \\ x - y = 1 \end{cases}

In a LaTeX document

These commands work in the text of a .tex document (Overleaf, TeX Live, MiKTeX), not inside math. The box on the right shows what the compiled PDF looks like.

  • Your first document

    LaTeX
    \documentclass{article}
    \usepackage{amsmath}
    \usepackage{graphicx}
    
    \title{My First Document}
    \author{Your Name}
    
    \begin{document}
    \maketitle
    
    \section{Introduction}
    This is \textbf{bold} and this is \textit{italic}.
    
    \section{Some Math}
    Pythagoras: $a^2 + b^2 = c^2$. A displayed formula:
    \[ \int_0^1 x^2 \, dx = \frac{1}{3} \]
    
    \begin{itemize}
      \item First point
      \item Second point
    \end{itemize}
    \end{document}
  • A small table

    LaTeX
    \begin{tabular}{lr}
    Item & Price \\
    \hline
    Book & 12.00 \\
    Pen & 1.50 \\
    \end{tabular}
    Compiled result
    ItemPrice
    Book12.00
    Pen1.50
  • Reading an error

    LaTeX
    ! Undefined control sequence.
    l.12 \textbf{bold} and \textitt
                                    {italic}

Where to write LaTeX

The easiest start is Overleaf in the browser: nothing to install, packages are ready, and the PDF appears next to the source. To work offline, install TeX Live (Windows, Linux), MacTeX (Mac) or MiKTeX, and an editor such as TeXstudio or VS Code with LaTeX Workshop.

LaTeX is not a word processor. You write plain text with commands, then compile it into a PDF. The source is the document; the PDF is the result.

How a document is built

Everything before \begin{document} is the preamble: the document class and the packages (\usepackage{amsmath} for math, graphicx for images). Inside the document, a blank line starts a new paragraph, \section makes headings, and environments (\begin{…} … \end{…}) make lists, tables, figures and multi-line equations.

Math is where LaTeX shines: put formulas between $ … $ inside sentences or \[ … \] on their own line. Use ^ for powers, _ for indices, \frac{}{} for fractions and named commands like \alpha and \sum for symbols.

Compiling and fixing errors

Click Recompile in Overleaf, or run pdflatex file.tex locally. When it fails, read the first error: it names the problem ("Undefined control sequence", "Missing $ inserted") and the line number after l.. Fix the first error first; later ones are often caused by it.

Already have formulas in a PDF, a photo or on paper? The image to LaTeX converter on this site turns a screenshot into LaTeX you can paste into your document.

Common mistakes

  • The document class must be the first command; anything printed before it fails.

    Instead of
    Text before \documentclass
    Write
    \documentclass{article} first
  • Math commands only work in math mode.

    Instead of
    x^2 written in text
    Write
    $x^2$
  • Packages can only be loaded before the document starts.

    Instead of
    \usepackage{graphicx} after \begin{document}
    Write
    Packages in the preamble

In Overleaf, MathJax and Word

  • Overleaf and pdfLaTeX

    Overleaf is the quickest start: New Project › Blank Project gives a working template; Recompile builds the PDF.

  • MathJax and KaTeX

    On websites and in apps such as Notion, Obsidian and Jupyter, only the math part of LaTeX is used, rendered by MathJax or KaTeX; there is no document to compile.

  • Microsoft Word

    Word for Microsoft 365 accepts LaTeX math in its equation editor (Equation › LaTeX), but not whole LaTeX documents.

Already have the whole document?

Move complete papers between PDF, Word and LaTeX without retyping; every equation stays editable.

Single printed formulas are free: 3 a day without an account, 6 with a free account. New accounts get 30 credits to try handwriting, pages and documents; failed conversions return their credits. See plans and credit prices.

How to use LaTeX in LaTeX: questions

Is LaTeX hard to learn?
The basics take an afternoon: a document skeleton, sections, lists and simple math. Tables and figures take a little longer.
Is LaTeX a programming language?
It is a markup language for typesetting. It has commands and macros, but you mostly write text and formulas.
Do I need to install anything?
No. Overleaf runs in the browser. Install TeX Live, MacTeX or MiKTeX only if you want to work offline.
Is LaTeX still worth learning?
Yes for math-heavy writing: journals, theses and lecture notes in STEM use it, and its math syntax works in Word, Notion, Markdown and many apps.

Have the formula as a picture?

Paste a screenshot or photo of the equation and get its LaTeX, ready to copy or open in the editor.

Convert an image to LaTeX