How to Convert LaTeX Equations to PDF: A Complete Guide
How to convert LaTeX equations to PDF with Overleaf, pdflatex or latexmk, crop a single equation, export it as SVG or PNG for Word, and fix compile errors.
To convert LaTeX equations to PDF, put them in a .tex document and compile it with a LaTeX engine: press Recompile in Overleaf and then Download PDF, or run latexmk -pdf main.tex on your own computer. For a single equation you want to drop into Word, slides or a web page, compile it with the standalone document class so the PDF page is cropped to the equation, then convert that PDF to SVG or PNG. This guide covers each route with commands that work, how to fix the errors that stop a compile, and how to show LaTeX equations on the web without a PDF at all. If you need the commands for the equations themselves, keep the LaTeX equations cheat sheet open alongside.

Pick a route
| Route | Best for | What you need |
|---|---|---|
| Overleaf | Getting a PDF in minutes, sharing with a co-author, no install | A browser and a free account |
| Local TeX distribution with latexmk | Working offline, large documents, full control | TeX Live, MacTeX or MiKTeX |
| TeXstudio or VS Code with LaTeX Workshop | A local editor with a build button and a PDF preview | A TeX distribution plus the editor |
standalone class plus pdfcrop |
One equation as a tightly cropped PDF | Any of the above |
| pdftocairo or dvisvgm | An equation as SVG or PNG for Word, slides or a website | Poppler utilities or dvisvgm (included in TeX Live) |
| Pandoc | Markdown notes with $...$ math turned into a PDF or Word file |
Pandoc plus a TeX distribution |
| MathJax or KaTeX | Equations on a web page, no PDF | A script tag on the page |
Method 1: Overleaf
Overleaf compiles LaTeX on its servers, so nothing needs installing, and every common package is already available.
- Sign in at overleaf.com, choose New Project, then Blank Project.
- Replace the contents of
main.texwith your document. A minimal one with an equation:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
The roots of $ax^2 + bx + c = 0$ are
\begin{equation}
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}.
\label{eq:quadratic}
\end{equation}
\end{document}
- Press Recompile. The PDF appears in the right-hand pane. Errors and warnings appear under the log icon next to the button, with a link to the line that caused each one.
- Click the Download PDF button above the preview (or open the menu and choose PDF under Download).
The default engine is pdfLaTeX. If your document uses system fonts or the fontspec or unicode-math packages, switch the compiler to XeLaTeX or LuaLaTeX in the project menu's settings. Overleaf's free plan has a compile time limit, so very large documents may need a paid plan or a local install; check Overleaf's plans page for the current limits.
Method 2: Compile locally with pdflatex or latexmk
Install a distribution first. TeX Live (Linux and Windows) and MacTeX (TeX Live for macOS) include everything; MiKTeX (Windows) starts smaller and downloads packages the first time a document needs them. The step-by-step Windows install guide walks through both Windows options.
Save your document as main.tex, open a terminal in that folder, and run one of these:
pdflatex main.tex # the classic engine, writes main.pdf
xelatex main.tex # Unicode input and system fonts (fontspec, unicode-math)
lualatex main.tex # Unicode and system fonts, plus Lua scripting
latexmk -pdf main.tex # runs pdflatex (and BibTeX or Biber) as many times as needed
latexmk -xelatex main.tex # the same, with XeLaTeX
latexmk -lualatex main.tex # the same, with LuaLaTeX
latexmk -pdf -pvc main.tex # keeps watching and recompiles every time you save
latexmk -c # deletes the .aux, .log and other helper files
Use latexmk when you can. A single pdflatex run leaves ?? wherever you wrote \ref or \eqref, because LaTeX only learns the equation numbers on the first pass and prints them on the second. latexmk reruns the engine until the numbers and citations settle, and it is included in TeX Live, MacTeX and MiKTeX (MiKTeX needs Perl for it).
Which engine: pdflatex is the fastest and is what most journal templates expect. Choose xelatex or lualatex when you type Greek letters or accented characters directly into equations, or when you want a different math font through unicode-math.
Method 3: An editor with a build button
If you prefer a desktop editor to the terminal, these call the same engines for you:
- TeXstudio: free and cross-platform. F5 runs Build & View and shows the PDF beside the source; the default compiler is set under Options, Configure TeXstudio, Build. Best for people who want menus and a symbol palette.
- VS Code with the LaTeX Workshop extension: builds with latexmk when you save and opens the PDF in a tab, with SyncTeX jumps between source and PDF. Best for people who already write code in VS Code.
- TeXworks: a minimal editor that ships with MiKTeX and the Windows TeX Live installer. Best for a first document with nothing extra to install.
All three need a TeX distribution installed first; they are editors, not compilers.
Method 4: One equation as its own PDF
For a single equation to put in a slide, a poster or a Word file, use the standalone class. It crops the page to the content instead of producing a letter-size page with a small equation in the middle.
\documentclass[border=2pt]{standalone}
\usepackage{amsmath}
\begin{document}
$\displaystyle \int_{-\infty}^{\infty} e^{-x^2} \, dx = \sqrt{\pi}$
\end{document}
By default standalone puts everything in one horizontal box, so display environments such as \[ ... \], equation or align fail with an error. The inline $\displaystyle ... $ above sidesteps that. To use a display environment, add the varwidth option, or the preview option:
\documentclass[border=2pt,varwidth]{standalone}
\usepackage{amsmath}
\begin{document}
\begin{align*}
\nabla \cdot \mathbf{E} &= \frac{\rho}{\varepsilon_0} \\
\nabla \cdot \mathbf{B} &= 0
\end{align*}
\end{document}
border=2pt leaves a small margin so the edges of tall symbols are not clipped. Compile with pdflatex as usual.
Crop an equation out of an existing PDF
If the equation already sits in a full-page PDF, pdfcrop (included in TeX Live and MiKTeX; it needs Perl and Ghostscript) trims each page to its visible content:
pdfcrop --margins 2 page.pdf equation.pdf
This works best on a page that contains only the equation, so put it on its own page first (or use the standalone route, which saves this step).
Method 5: Turn the equation into SVG or PNG for Word, slides or the web
A PDF is fine for Keynote, which places PDF files as images, and for LaTeX Beamer slides. Most other tools want SVG or PNG.
| Goal | Command | Result |
|---|---|---|
| SVG from the cropped PDF | pdftocairo -svg equation.pdf equation.svg |
A vector file that stays sharp at any size |
| PNG from the cropped PDF | pdftocairo -png -r 600 -transp -singlefile equation.pdf equation |
equation.png at 600 dpi with a transparent background |
| SVG straight from LaTeX | latex equation.tex then dvisvgm --no-fonts equation.dvi |
equation.svg with every glyph drawn as a path, so it needs no fonts on the viewer's machine |
| SVG from a PDF with dvisvgm | dvisvgm --pdf --no-fonts equation.pdf |
Same, if your dvisvgm build has PDF support (it needs Ghostscript or mutool) |
pdftocairo comes with the Poppler utilities (brew install poppler on macOS, the poppler-utils package on Debian and Ubuntu). dvisvgm is part of TeX Live.
Where each format fits:
- Microsoft Word and PowerPoint (Microsoft 365): Insert, Pictures accepts SVG, which stays crisp when resized. For an equation you want to keep editing, Word's own equation editor also accepts LaTeX: insert an equation, choose LaTeX in the Conversions group of the Equation tab, paste the code, and convert it. It understands common commands, not every package.
- Google Docs and Google Slides: use the PNG. Neither inserts SVG.
- Websites: an SVG image works, but for more than a few equations, MathJax or KaTeX (below) is less work and keeps the text selectable.
If you need a whole LaTeX document in Word, Pandoc converts it with editable equations: pandoc paper.tex -o paper.docx turns LaTeX math into native Word equations. Complex layouts and custom macros may need manual fixes afterward.
Method 6: Markdown with math to PDF using Pandoc
If your notes are in Markdown with dollar-sign math (as in Obsidian, Typora or a Jupyter notebook export), Pandoc can turn them into a typeset PDF through LaTeX:
pandoc notes.md -o notes.pdf # uses pdflatex by default
pandoc notes.md -o notes.pdf --pdf-engine=xelatex # for Unicode characters in the text
Inline math goes between single dollar signs ($E = mc^2$, with no space after the opening $ or before the closing one) and display math between double dollar signs. Pandoc needs a TeX distribution installed for this, because it hands the document to a LaTeX engine.
Method 7: LaTeX equations on the web without a PDF
To show equations on a web page, a blog or course notes in HTML, you do not need to convert them at all. A JavaScript library renders LaTeX in the browser:
- MathJax: best for broad LaTeX coverage and accessibility (screen readers can read its output).
- KaTeX: best for speed on pages with many equations; it supports fewer commands than MathJax.
A MathJax 3 setup that also accepts single dollar signs for inline math:
<script>
window.MathJax = {
tex: { inlineMath: [['$', '$'], ['\\(', '\\)']] }
};
</script>
<script id="MathJax-script" async
src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
By default MathJax only treats \( ... \) as inline math, so prices like "$5 and $10" are not mistaken for equations; the configuration above turns on single dollars, so escape a literal dollar sign as \$. MathJax 4 is also available and uses a similar configuration; follow the version on mathjax.org for new sites.
Advanced equations that compile cleanly to PDF
Longer documents raise a few problems that short examples never hit. These are the fixes worth knowing.
- Long derivations across pages.
alignnever breaks across pages by default, so a long derivation can leave a half-empty page. Put\allowdisplaybreaksin the preamble (amsmath) to let LaTeX break between lines, or write\displaybreakat the line where a break is acceptable. - One equation too wide for the line. Use
multlineto break it with the first part left and the last part right, orsplitinsideequationto align the pieces under one number. Break before a binary operator such as+or=, and start the next line with it. - Numbering by section.
\numberwithin{equation}{section}in the preamble gives 2.1, 2.2, 3.1, which makes references in a long report easier to find. - Clickable equation references. Load
hyperref(near the end of the preamble) and every\eqrefin the PDF becomes a link to the equation. The same package sets the PDF's title and author fields, which some repositories and journals check:
\usepackage{hyperref}
\hypersetup{
pdftitle = {Lecture 4: Gaussian Integrals},
pdfauthor = {Your Name}
}
- A different math font. With XeLaTeX or LuaLaTeX, the
unicode-mathpackage loads OpenType math fonts:\usepackage{unicode-math}then\setmathfont{texgyrepagella-math.otf}switches to TeX Gyre Pagella Math, which ships with TeX Live. It also lets you type Greek letters such as α directly in an equation. - Fonts embedded for submission. Journals and print shops require every font embedded in the PDF. pdflatex, xelatex and lualatex embed fonts by default; check with
pdffonts main.pdf(Poppler), where every row should say "yes" in the emb column. - Bold vectors and Greek.
\usepackage{bm}and\bm{\mu}give a bold Greek mu;\mathbfonly boldens Latin letters and digits.
Fix the errors that stop a compile
LaTeX reports errors in the .log file (and in Overleaf's log pane) with a line number, like l.12. Fix the first error first: later ones are often side effects.
| Error message | Usual cause | Fix |
|---|---|---|
Missing $ inserted |
A math command, _ or ^ used outside math mode, or a blank line inside display math |
Wrap the math in $...$ or \[...\]; write an underscore in text as \_; remove blank lines inside equations |
Undefined control sequence |
A misspelled command, or a command from a package you did not load | Check the spelling; load the package (\mathbb needs amssymb, \text and \eqref need amsmath) |
LaTeX Error: File `physics.sty' not found |
The package is not installed | TeX Live: tlmgr install physics (may need administrator rights). MiKTeX: install it in MiKTeX Console under Packages, or allow on-the-fly installs. Overleaf has all common packages |
Misplaced alignment tab character & |
An & outside align, a matrix or a table |
Move the equation into align, or write a literal ampersand as \& |
Missing \right. inserted |
A \left without a matching \right in the same line |
Add the \right, or use \right. for an invisible closing delimiter |
Extra }, or forgotten $ |
Unbalanced braces or dollar signs | Count the braces around the line in the log; editors highlight matching pairs |
Unicode character α (U+03B1) not set up for use with LaTeX |
A Greek letter or symbol typed directly into math under pdflatex | Use the command (\alpha), or compile with XeLaTeX or LuaLaTeX and unicode-math |
?? in the PDF where a number should be |
References not resolved yet | Compile again, or use latexmk, which reruns automatically |
When a log is hard to read, cut the document down: comment out half of the body with %, recompile, and repeat until the failing line is obvious.
Tools that help before you compile
- Detexify: draw a symbol and get its LaTeX command. Best for "what is this symbol called".
- Mathpix: converts a screenshot or photo of an equation into LaTeX. Best for retyping equations from a textbook or handwritten notes; check the output, especially subscripts.
- CodeCogs Equation Editor: a browser editor with buttons that writes LaTeX and previews it as an image. Best for a one-off equation image without installing anything.
- LaTeXiT: a macOS app that compiles one equation and lets you drag it into Keynote, Pages or Word as PDF or an image. Best for Mac users who make slides.
After the PDF: studying from it
Once your lecture notes or problem sets are a PDF, you may want to study from them rather than only file them. Scholarly takes a PDF and turns it into flashcards and practice quizzes or a narrated video lecture, and answers questions with citations to the pages it used. It does not edit or compile LaTeX, so write and compile the document with the tools above first.



