GuidesFebruary 26, 20267 min read

LaTeX to PDF: The Complete Guide to Compiling Your Documents

Everything you need to know about compiling LaTeX to PDF — from local compilers to cloud solutions, with troubleshooting tips.

compilationpdflatexpdflatexcompiler

You've written your LaTeX document — now what? Unlike a word processor, LaTeX doesn't show you the final output as you type. You need to compile your .tex source into a PDF. This process is straightforward once you understand it, but the number of tools and options can be overwhelming for newcomers. Here's everything you need to know.

What Does "Compiling" Actually Mean?

When you compile a LaTeX document, a program reads your .tex file and converts it into a typeset PDF. During compilation, the engine:

  1. Parses your document structure (\documentclass, \begin{document}, etc.)
  2. Lays out text, math, figures, and tables according to typographic rules
  3. Resolves cross-references (\ref, \cite, table of contents)
  4. Embeds fonts and images into the final PDF

This is why LaTeX produces such beautiful output — it has a complete picture of your document before generating the PDF, unlike a WYSIWYG editor that renders line by line.

Choosing a Compiler: pdfLaTeX vs. LuaLaTeX vs. XeLaTeX

There are three main LaTeX engines. Each produces PDF output, but they differ in features and speed:

EngineSpeedUnicodeSystem FontsBest For
pdfLaTeXFastestLimitedNoMost English-language papers, theses, and submissions
XeLaTeXMediumFullYesDocuments with non-Latin scripts, custom fonts
LuaLaTeXSlowestFullYesAdvanced scripting, complex font features

Our recommendation: Use pdfLaTeX unless you specifically need Unicode support or system fonts. It's the fastest, most compatible option, and virtually all conference and journal templates are designed for it. For a deeper comparison, see our pdfLaTeX guide.

Option 1: Local Compilation with TeX Live

To compile on your own machine, you need a TeX distribution installed:

  • TeX Live (Linux, macOS, Windows) — the most comprehensive and widely used distribution
  • MacTeX (macOS) — a TeX Live package with macOS-specific extras
  • MiKTeX (Windows) — auto-installs missing packages on demand

Once installed, open a terminal and run:

# Single compilation
pdflatex main.tex

# Full compilation with citations
pdflatex main.tex
bibtex main
pdflatex main.tex
pdflatex main.tex

The first run creates auxiliary files. The bibtex step processes your bibliography. The final two runs resolve all cross-references and citations. Yes, it takes four commands — this is why many people use an editor that automates the process.

Using latexmk (recommended for local users)

latexmk automates the multi-pass process. It figures out how many runs you need and runs them:

# Compile to PDF, running as many passes as needed
latexmk -pdf main.tex

# Continuous compilation (recompiles on file save)
latexmk -pdf -pvc main.tex

This is the most reliable way to compile locally. It handles BibTeX/Biber, makeindex, and glossaries automatically.

Option 2: Cloud Compilation

Cloud editors compile your document on remote servers, so you don't need to install anything locally. This is increasingly popular because:

  • No TeX distribution to install or update
  • Consistent environment across all your devices
  • Collaboration is built in
  • Packages are always up to date

Bibby AI's cloud compiler takes this further with no arbitrary compile timeouts. Many cloud editors cut you off after 60 seconds on free plans — Bibby lets your document compile until it's done, regardless of complexity.

Multi-Pass Compilation for Citations

If your bibliography isn't appearing, you probably haven't run enough compilation passes. Here's why LaTeX needs multiple runs:

  1. Pass 1 (pdflatex): LaTeX writes citation keys to .aux but can't resolve them yet → you see [?]
  2. Pass 2 (bibtex/biber): The bibliography processor reads .aux + your .bib file and creates a .bbl file with formatted references
  3. Pass 3 (pdflatex): LaTeX reads .bbl and inserts the bibliography, but some references may still show [?]
  4. Pass 4 (pdflatex): Final pass resolves all remaining cross-references

If you're still seeing [?] after four passes, check our guide to fixing compilation issues for common solutions.

Troubleshooting Common Compilation Errors

"Undefined control sequence"

A typo in a command name or a missing package. Check the spelling and add the required \usepackage{}.

"File not found"

Your \includegraphics or \input references a file that doesn't exist at that path. Double-check the filename and relative path.

"Missing $ inserted"

You used a math command (like _ or \frac) outside of math mode. Wrap it in $...$ or \[...\].

PDF not updating after changes

Your PDF viewer may be caching the old file. Close and reopen it, or use a viewer that watches for file changes (SumatraPDF on Windows, Skim on macOS).

Compilation hangs or times out

Large images, TikZ diagrams, and excessive packages slow compilation. See our 7 ways to fix slow LaTeX compilation for optimization strategies.

The Simplest Path: Write and Compile in One Place

Managing compilers, distributions, and multi-pass sequences is overhead that takes time away from writing. Bibby AI's integrated compiler handles everything — you write LaTeX, hit compile, and get a PDF. Combined with AI-powered writing assistance, it's the fastest path from idea to published document.

Ready to skip the setup? Try Bibby AI free — cloud compilation with no timeouts, AI features, and 75+ templates ready to go.

Try a LaTeX Editor Built for Researchers

AI-powered writing, smart citations, no compile timeouts. Join 5,000+ researchers using Bibby AI.

Start Writing Free
LaTeX to PDF: The Complete Guide to Compiling Your Documents | Bibby AI Blog