Skip to content
LemmaGet the app

LaTeX basics

pdfLaTeX vs XeLaTeX vs LuaLaTeX: Which Engine to Use

By Laxmi SolutionsPublished 2 min read

The same .tex file can be compiled by different programs, called engines. pdfLaTeX is the classic default, while XeLaTeX and LuaLaTeX were built for Unicode text and system fonts. For most documents the choice comes down to fonts and languages. Here is what actually differs, and how to move a document between engines.

The short answer

LaTeX engines at a glance
pdfLaTeXXeLaTeXLuaLaTeX
Input8-bit; Unicode via inputenc for common accentsNative UTF-8Native UTF-8
FontsTeX fonts installed as packagesAny OpenType/TrueType font via fontspecAny OpenType/TrueType font via fontspec
Non-Latin scriptsLimitedGood (Devanagari, Arabic, CJK with packages)Good
SpeedFastestFastSlower, especially at start-up
microtypeFullProtrusion onlyFull
ScriptingNoNoLua inside the document

Choose pdfLaTeX for a classic English document with Computer Modern or another TeX font. Choose XeLaTeX or LuaLaTeX when you want your own fonts, or write in a language beyond Western European accents. Choose LuaLaTeX only if you need Lua scripting or full microtype.

Fonts: the biggest practical difference

With pdfLaTeX a font must exist as a LaTeX package, such as \usepackage{libertine}. XeLaTeX and LuaLaTeX load any OpenType or TrueType font by name through fontspec:

\usepackage{fontspec}
\setmainfont{Inter}
\setmonofont{JetBrains Mono}[Scale=MatchLowercase]

That is why résumés and designed documents are often compiled with XeLaTeX: the font you see in a design tool is the font you get.

Unicode and languages

XeLaTeX and LuaLaTeX read UTF-8 natively, so you can type é, ß, ₹, ∑ or a whole sentence in Hindi directly, provided the font has the glyphs. With pdfLaTeX, characters outside the supported encodings fail with errors like Unicode character … not set up for use with LaTeX.

  • For multilingual documents, pair fontspec with polyglossia or babel to get the right hyphenation and conventions.
  • Pick fonts per script with \newfontfamily, for example a Devanagari font for Hindi passages.

Moving a pdfLaTeX document to XeLaTeX

Most pdfLaTeX documents compile unchanged with XeLaTeX. The lines worth checking are the ones about encodings and fonts:

Common preamble lines when switching to XeLaTeX
LineWhat to do
\usepackage[utf8]{inputenc}Harmless; you can remove it.
\usepackage[T1]{fontenc}Works, but for full Unicode switch to fontspec.
\usepackage{lmodern}Not needed: fontspec defaults to Latin Modern.
Font packages like times or helvetUse \setmainfont{…} with an OpenType font instead.
\pdfoutput=1 or other \pdf… primitivespdfTeX only; remove them or guard them with iftex.

To keep one source for several engines, load \usepackage{iftex} and branch with \ifPDFTeX … \else … \fi.

Which engine Lemma uses

Lemma compiles with Tectonic, a modern XeTeX-based engine, entirely on your phone. Documents written for XeLaTeX work as they are, most pdfLaTeX documents work unchanged, and fontspec loads fonts by name. With Lemma Pro you can add your own .ttf or .otf files in Settings → Fonts and use them in any project with \setmainfont.

Two desktop tools aren't available: Biber and makeindex. For biblatex, add backend=bibtex, as explained in BibTeX vs biblatex. Moving a project from Overleaf? See Overleaf projects on Android.