pdfLaTeX vs XeLaTeX vs LuaLaTeX
Three programs turn the same .tex file into a PDF. They are not interchangeable: a document written for one can fail outright on another. This is how to tell which one you need.
The short answer
Use pdfLaTeX unless something forces you off it. The two things that most often force you off it are wanting a font installed on your computer, and writing in a script that is not Latin, Greek or Cyrillic. Both point at XeLaTeX orLuaLaTeX, which share a font model and differ mainly in what else they can do.
If a template tells you which engine to use, use that one. The choice was made by whoever wrote the class file, and it is usually not negotiable without editing the preamble.
What the catalogue actually uses
Every template on this site is compiled before it is published, and the engine that produced the PDF is recorded. Across 909 templates:
| Engine | Templates | Share | Why |
|---|---|---|---|
| pdflatex | 752 | 83% | The default, and what most classes on CTAN are written for. |
| xelatex | 125 | 14% | Chosen when the document needs system fonts or non-Latin scripts. |
| lualatex | 28 | 3% | Chosen when the document needs Lua scripting or heavy font work. |
| pdftex | 2 | 0% | Plain TeX rather than LaTeX — a handful of legacy documents. |
| latex-dvips | 2 | 0% | The DVI route, still required by a few older classes. |
That distribution is worth reading carefully, because it contradicts the impression you get from forum advice. Roughly 83% of working, compiling documents still use pdfLaTeX — not because their authors are behind the times, but because it does everything those documents need. The newer engines are a minority, and they are chosen for specific reasons rather than as a general upgrade.
These are not opinions about what people should use. They are the engines that produced a PDF that actually built.
The real difference: fonts
Almost every practical distinction between the engines comes back to fonts, so it is worth being precise about it.
pdfTeX inherits TeX's original font model. It uses fonts that have been installed into your TeX distribution and described to it by metric files — historically Type 1 fonts. TeX Live ships a large collection of these, and they are excellent, but the set is fixed at install time. You cannot point pdfLaTeX at a .ttf or.otf file sitting on your desktop.
XeTeX and LuaTeX can load TrueType and OpenType fonts directly, including the fonts already installed on your operating system, by name. This is what the fontspec package provides:
\documentclass{article}
\usepackage{fontspec}
\setmainfont{EB Garamond}
\begin{document}
Set in whichever EB Garamond the system can find.
\end{document}This is the single most common reason a document will not compile. Run the file above through pdfLaTeX and it does not degrade gracefully or substitute a default — it stops:
! Fatal Package fontspec Error: The fontspec package requires either XeTeX or
(fontspec) LuaTeX.So \usepackage{fontspec} in a preamble is a reliable signal: that document needs XeLaTeX or LuaLaTeX, and no amount of rerunning will change it. The reverse is also worth knowing — a document written for pdfLaTeX will usually compile fine under the newer engines, so the incompatibility mostly runs one way.
Unicode and non-Latin scripts
A related confusion is worth clearing up, because it is often stated too strongly. Since the April 2018 release, LaTeX assumes your source file is UTF-8 by default under every engine, so\usepackage[utf8]{inputenc} is no longer needed in new documents — and under XeTeX and LuaTeX it never did anything at all. Accented Latin characters therefore work in pdfLaTeX without ceremony.
What pdfLaTeX cannot do easily is typeset scripts outside its installed font encodings. Chinese, Japanese, Korean, Arabic, Hebrew, Devanagari and Thai all want a Unicode engine plus a font that contains the glyphs. Arabic and Hebrew additionally need right-to-left support, and complex scripts need the shaping engine that XeTeX and LuaTeX provide. This is why templates for East Asian and Indic universities cluster on xelatex in the table above.
microtype, stated correctly
microtype is the package that makes LaTeX output look subtly better — it nudges punctuation into the margin (protrusion) and imperceptibly stretches glyphs to improve line breaking (expansion). Guides frequently say it "only works with pdfLaTeX". That is not right, and the accurate version is more useful.
- pdfLaTeX: both protrusion and expansion, which is the full effect.
- LuaLaTeX: both, also fully supported.
- XeLaTeX: protrusion works; font expansion does not. Asking for it explicitly produces
Package microtype Error: Font expansion does not work with xetex, and the document continues without it.
So you do not lose microtype by moving to XeLaTeX — you lose one of its two mechanisms, and the one you keep is the more visible. If typographic polish is the priority and you also need OpenType fonts, LuaLaTeX is the combination that gives up nothing.
When you must switch
Concrete cases, rather than general advice:
- The preamble loads
fontspec,unicode-math,polyglossiaorluacode. These require a Unicode engine. This is not a preference. - You need a specific font you have as a file. A corporate typeface, a font your department mandates, anything not already in TeX Live. XeLaTeX or LuaLaTeX.
- You are writing in a non-Latin script. XeLaTeX is the usual choice; many Chinese templates use it via
ctex, and Japanese ones often use LuaLaTeX vialuatexja. - You need OpenType features — real small caps, old-style figures, alternate glyphs, proper ligatures. These live in the font file and need an engine that can read it.
- The class file says so. Many university thesis classes hard-require one engine. Check the class documentation first; it overrides everything on this page.
And the case for not switching: if your document compiles under pdfLaTeX today, moving it is work with no reward. Bibliography styles, font packages and layout can all shift underneath you.
Choosing between XeLaTeX and LuaLaTeX
Once you need a Unicode engine, the two are close enough that either will usually work. The differences that decide it:
- LuaTeX embeds Lua. You can run a real programming language during typesetting, and packages can reach into TeX's internals in ways that were not previously possible. Modern packages increasingly assume it.
- LuaTeX keeps full microtype. As above — it is the only Unicode engine with font expansion.
- XeTeX has been around longer, so more existing templates and more accumulated advice target it. If a class was written for XeLaTeX, run XeLaTeX.
- LuaLaTeX is generally slower on large documents. It does more work, and it is doing that work in Lua.
For a new document with no constraints, LuaLaTeX is the forward-looking choice. For an existing document, use whatever it was written for.
Finding out which engine a document needs
If you have inherited a .tex file, read the preamble before guessing. fontspec, unicode-math orpolyglossia mean a Unicode engine.inputenc or fontenc with[T1] suggests it was written for pdfLaTeX. Many templates also state it in a comment on the first line, or in a% !TEX program = xelatex directive that editors read automatically.
Every template on this site records the engine it was compiled with on its own page, so you do not have to infer it.