FormaTeX

\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.

·3 min read·
XeLaTeX vs pdfLaTeX: Which Engine Should You Use?

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.

bash
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 inputenc and fontenc packages
  • Limited to fonts converted to Type 1 or TrueType formats
  • Non-Latin scripts require workarounds
latex
\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.

latex
\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 inputenc needed
  • 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

FeaturepdfLaTeXXeLaTeX
Unicode inputVia inputencNative
Custom fontsLimitedFull (fontspec)
Compilation speedFastModerate
Package compatibilityExcellentGood
RTL languagesNoYes
FormaTeX planFree+Pro+
Best forStandard docs, journalsCustom fonts, multilingual

Font Loading in XeLaTeX

The fontspec package is the key difference. You can reference fonts by name:

latex
\usepackage{fontspec}
\setmainfont{Georgia}
\setsansfont{Helvetica Neue}
\setmonofont{JetBrains Mono}

Or by file path when bundling fonts with your project:

latex
\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

typescript
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}

Back to blog

\related{posts}

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