\begin{article}
XeLaTeX vs pdfLaTeX: Which Engine Should You Use?
A practical comparison of XeLaTeX and pdfLaTeX — covering Unicode support, custom fonts, compilation speed, and when to choose each engine.

Choosing the wrong LaTeX engine is one of the most common sources of compilation errors. Both pdflatex and xelatex produce PDFs, but they work differently under the hood — and the difference matters for your document.
The Short Answer
Use pdflatex unless you need custom fonts or non-Latin scripts. Then use xelatex.
pdfLaTeX
pdflatex is the default engine and the fastest of the four FormatEx supports. It has been the standard for decades and works with virtually every package on CTAN.
curl -X POST https://api.formatex.io/api/v1/compile \
-H "X-API-Key: $KEY" \
-d '{"content":"...","engine":"pdflatex"}'What it does well:
- Fastest compilation time
- Widest package compatibility
- Best supported by journals and publishers
- Available on the free plan
Limitations:
- Encoding handled via
inputencandfontencpackages - Limited to fonts converted to Type 1 or TrueType formats
- Non-Latin scripts require workarounds
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\begin{document}
Standard document — pdflatex handles this perfectly.
\end{document}XeLaTeX
xelatex was built to address pdfLaTeX's font limitations. It uses the Unicode standard natively and can load any OpenType or TrueType font installed on the system — or bundled with your project.
\documentclass{article}
\usepackage{fontspec}
\setmainfont{TeX Gyre Termes}
\begin{document}
This uses a custom OpenType font directly.
\end{document}What it does well:
- Native Unicode input — no
inputencneeded - Load any system or OpenType font with
fontspec - Right-to-left languages (Arabic, Hebrew) via
bidi - Better for multilingual documents
Limitations:
- Slower than pdflatex
- Some older packages (especially font-related) are incompatible
- Requires Pro plan or above on FormaTeX
XeLaTeX ignores \usepackage[utf8]{inputenc} — if you're porting a pdflatex
document, remove that line first or you'll get a package clash error.
Side-by-side Comparison
| Feature | pdfLaTeX | XeLaTeX |
|---|---|---|
| Unicode input | Via inputenc | Native |
| Custom fonts | Limited | Full (fontspec) |
| Compilation speed | Fast | Moderate |
| Package compatibility | Excellent | Good |
| RTL languages | No | Yes |
| FormaTeX plan | Free+ | Pro+ |
| Best for | Standard docs, journals | Custom fonts, multilingual |
Font Loading in XeLaTeX
The fontspec package is the key difference. You can reference fonts by name:
\usepackage{fontspec}
\setmainfont{Georgia}
\setsansfont{Helvetica Neue}
\setmonofont{JetBrains Mono}Or by file path when bundling fonts with your project:
\setmainfont{CustomFont}[
Path = ./fonts/,
Extension = .otf,
UprightFont = *-Regular,
BoldFont = *-Bold,
ItalicFont = *-Italic
]When using custom font files, include them in your request payload or host them at a URL accessible by the FormatEx worker. File-based font loading is supported on Pro plan and above.
Which to Pick via the API
const engine = needsCustomFonts || hasNonLatinScript
? "xelatex"
: "pdflatex";
const response = await fetch("https://api.formatex.io/api/v1/compile", {
method: "POST",
headers: { "X-API-Key": process.env.FORMATEX_KEY! },
body: JSON.stringify({ content: latexSource, engine }),
});What About LuaLaTeX?
LuaLaTeX shares XeLaTeX's Unicode and font capabilities but adds a full Lua scripting environment. If you don't need scripting, XeLaTeX compiles faster. See the engines reference for a full four-way comparison.
\end{article}
\related{posts}




