FormaTeX

\engines{comparison}

XeLaTeX vs pdfLaTeX

Both engines produce high-quality PDFs — but they make different trade-offs. This guide covers every meaningful difference so you can pick the right one for each document.

pdfLaTeX— fast & universalXeLaTeX— Unicode & system fonts
Use pdfLaTeX when…
  • Speed matters (fastest engine)
  • Using standard Latin text
  • You need maximum package compatibility
  • Microtype kerning/protrusion is required
Use XeLaTeX when…
  • Unicode / non-Latin text (Arabic, Chinese, Greek…)
  • You need system or OpenType fonts
  • Modern math fonts (XITS Math, Libertinus)
  • RTL or bidirectional text layout

\section{Technical Differences}

What actually differs under the hood

Unicode & Input Encoding

pdfLaTeX

pdfLaTeX predates Unicode and treats source files as 8-bit byte streams. You must declare \usepackage[utf8]{inputenc} to handle UTF-8 input, and \usepackage[T1]{fontenc} for correct output encoding. Characters outside the T1 encoding require additional packages.

XeLaTeX

XeLaTeX is built on a Unicode engine. It reads UTF-8 natively — no inputenc or fontenc declarations are needed. Every Unicode character is available as long as the chosen font covers the codepoint.

Font Loading

pdfLaTeX

pdfLaTeX uses TeX font metrics (.tfm files) and Type 1 or OTF fonts pre-installed in the TeX distribution. You cannot load an arbitrary system font by name — only fonts that have been packaged for TeX are accessible.

XeLaTeX

XeLaTeX accesses fonts through the operating system font API. With fontspec, you can load any installed font by name: \setmainfont{Fira Sans}. OpenType features (ligatures, small caps, variable axes) are accessible directly.

Compilation Speed

pdfLaTeX is consistently the fastest engine — roughly 2x faster than XeLaTeX on equivalent documents. The gap narrows on large documents with heavy math, and widens on font-rich documents where XeLaTeX must resolve system font paths.

pdfLaTeX

~0.8s

typical single-pass document

XeLaTeX

~1.5s

typical single-pass document

Package Compatibility

pdfLaTeX

Decades of packages were written with pdfLaTeX as the assumed engine. Packages like microtype, pdfpages, and the majority of CTAN packages work fully. Expect near-universal compatibility.

XeLaTeX

Most packages work with XeLaTeX, but some have limited or no support — in particular packages that hook into pdfLaTeX-specific font internals. microtype works in XeLaTeX but loses character protrusion and expansion features.

Mathematics

Both engines produce excellent mathematical output. pdfLaTeX uses the classic Computer Modern / AMS math font stack. XeLaTeX supports this too, but also unlocks OpenType math fonts via unicode-math — including XITS Math, Libertinus Math, and STIX Two Math. For documents mixing Unicode characters with math (e.g. Greek letters inline), XeLaTeX is the natural choice.

\subsection{Feature Matrix}

Side-by-side comparison

Feature
pdfLaTeX
XeLaTeX
Unicode input
Via inputenc
Native
System fonts
No
Yes (fontspec)
Compilation speed
Fast (~0.8s)
Moderate (~1.5s)
Package compat.
Excellent
Good
OpenType math
No
Yes (unicode-math)
RTL languages
Limited
Yes (bidi)
Microtype
Full support
Limited
Default in most templates
Yes
No

\begin{examples}

Minimal working examples

Both examples compile with FormaTeX. Try them directly in the playground.

pdfLaTeX
% pdfLaTeX — fastest, widest package support
\documentclass{article}
\usepackage[utf8]{inputenc}   % required for pdfLaTeX
\usepackage[T1]{fontenc}
\usepackage{microtype}        % works best with pdfLaTeX

\begin{document}
Hello, World! Standard Latin text compiles in milliseconds.
$E = mc^2$
\end{document}
XeLaTeX
% XeLaTeX — Unicode native, system fonts
\documentclass{article}
\usepackage{fontspec}          % system font loading
\usepackage{unicode-math}      % Unicode math support

\setmainfont{Linux Libertine O}
\setmathfont{XITS Math}

\begin{document}
XeLaTeX natively handles Unicode: α β γ δ — no inputenc needed.
Greek: Αλφαβητικό σύστημα
$∫₀^∞ e^{−x²} dx = √π/2$
\end{document}

\subsection{Packages}

Key packages for each engine

pdfLaTeX packages

inputenc

Input encoding (required for UTF-8 in pdfLaTeX)

fontenc

Font encoding — T1 for Western European

microtype

Micro-typographic improvements; best with pdfLaTeX

babel

Multilingual support and hyphenation

XeLaTeX packages

fontspec

Load any system or OpenType font by name

unicode-math

Unicode math fonts (XITS Math, Libertinus Math)

polyglossia

Modern multilingual support, replaces babel

bidi

Bidirectional text layout (Hebrew, Arabic, etc.)

\section{Migration}

Switching from pdfLaTeX to XeLaTeX

Most pdfLaTeX documents compile with XeLaTeX after a small preamble adjustment. With FormaTeX, you only need to change the "engine" parameter in your API call — then update your preamble accordingly.

Remove
\usepackage[utf8]{inputenc}

XeLaTeX reads UTF-8 natively — no inputenc needed

Remove
\usepackage[T1]{fontenc}

fontenc is a pdfLaTeX-specific package

Add
\usepackage{fontspec}

Required for system font loading in XeLaTeX

Optional
\usepackage{unicode-math}

Enables OpenType math fonts like XITS Math

Consider
\usepackage{polyglossia}

Replace babel for multilingual documents

\subsection{API Usage}

Selecting the engine via FormaTeX API

Switching engines is a single-field change. Both engines are available on all plans — no extra configuration required.

Engine selection via API
curl -X POST https://api.formatex.io/v1/compile/sync \
  -H "Authorization: Bearer $FORMATEX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "engine": "xelatex",
    "source": "\\documentclass{article}\\usepackage{fontspec}\\begin{document}Hello\\end{document}"
  }' \
  --output document.pdf

Change "engine": "xelatex" to "engine": "pdflatex" to switch engines. See the full engines guide for all four supported engines.

Switch engines any time

Compile with any engine in seconds

FormaTeX runs pdfLaTeX, XeLaTeX, LuaLaTeX, and latexmk. One API key, no infrastructure.

One quick thing

We track anonymous usage — page views, feature usage, compilation events — to understand what works and what doesn't. No ads, no personal data, no third-party sharing.

Cookie policy