\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.
- Speed matters (fastest engine)
- Using standard Latin text
- You need maximum package compatibility
- Microtype kerning/protrusion is required
- 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
\begin{examples}
Minimal working examples
Both examples compile with FormaTeX. Try them directly in the playground.
% 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 — 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
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
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.
\usepackage[utf8]{inputenc}XeLaTeX reads UTF-8 natively — no inputenc needed
\usepackage[T1]{fontenc}fontenc is a pdfLaTeX-specific package
\usepackage{fontspec}Required for system font loading in XeLaTeX
\usepackage{unicode-math}Enables OpenType math fonts like XITS Math
\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.
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.pdfChange "engine": "xelatex" to "engine": "pdflatex" to switch engines. See the full engines guide for all four supported engines.
Compile with any engine in seconds
FormaTeX runs pdfLaTeX, XeLaTeX, LuaLaTeX, and latexmk. One API key, no infrastructure.

