FormaTeX

\engines{comparison}

LuaLaTeX vs pdfLaTeX

Both engines produce high-quality PDFs, but LuaLaTeX adds a full Lua scripting runtime and modern font loading at the cost of speed. This guide covers every meaningful difference so you can pick the right engine for each document.

pdfLaTeX— fast & universalLuaLaTeX— Lua scripting & modern fonts
Use pdfLaTeX when…
  • Speed matters — fastest engine available
  • Maximum package compatibility required
  • Standard Latin text documents
  • Microtype kerning and protrusion needed
Use LuaLaTeX when…
  • Lua scripting for dynamic content generation
  • Modern font loading with fontspec
  • Unicode text beyond basic Latin
  • Complex algorithmic typesetting

\section{Technical differences}

Technical Differences

Understanding the underlying architecture helps you predict behavior when packages interact, fonts are loaded, or scripts run.

Lua scripting capability

LuaLaTeX embeds a full Lua 5.3 interpreter. You can write procedural code, loop over data, call tex.print(), and manipulate the typesetting engine programmatically. pdfLaTeX has no such scripting layer.

Font loading

LuaLaTeX uses fontspec to load any OpenType or system font by name — no manual .tfm configuration. pdfLaTeX relies on the TeX font system and requires inputenc + fontenc for proper encoding.

Unicode support

LuaLaTeX reads UTF-8 natively at the engine level. pdfLaTeX approximates Unicode through the inputenc package, which covers most Latin scripts but requires workarounds for CJK, Arabic, or advanced mathematical symbols.

Compilation speed

pdfLaTeX is the fastest LaTeX engine — typically 0.6–1 second for a simple document. LuaLaTeX initialises the Lua VM and a larger font system, making it 2–3× slower on average. For CI pipelines or live preview, this difference is significant.

\section{Feature comparison}

Feature Comparison

FeaturepdfLaTeXLuaLaTeX
Unicode input
Via inputenc
Native
System fonts
No
Yes (fontspec)
Lua scripting
No
Yes (luacode)
Compilation speed
Fast (~0.8s)
Slower (~2–3×)
Package compat.
Excellent
Good
Microtype
Full support
Partial
RTL languages
Limited
Yes (luabidi)
Memory usage
Low
Higher (Lua VM)

\section{Code examples}

Code Examples

Side-by-side minimal documents for each engine.

pdfLaTeX
% pdfLaTeX — fast, maximum compatibility
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{microtype}

\begin{document}
Standard pdfLaTeX document. Fast compilation, excellent package support.
$f(x) = \int_0^x t^2\, dt = \frac{x^3}{3}$
\end{document}
LuaLaTeX
% LuaLaTeX — Lua scripting, modern fonts
\documentclass{article}
\usepackage{fontspec}
\usepackage{luacode}

% Lua scripting inside LaTeX
\begin{luacode}
  local n = 10
  local sum = 0
  for i = 1, n do sum = sum + i end
  tex.print("Sum 1.." .. n .. " = " .. sum)
\end{luacode}

\begin{document}
LuaLaTeX natively handles Unicode and supports Lua scripts.
\end{document}

\section{When to use LuaLaTeX}

When to Use LuaLaTeX

LuaLaTeX is the right choice in these specific scenarios.

Dynamic content generation

Use Lua loops and conditionals to generate repetitive table rows, chapter lists, or structured output programmatically inside LaTeX.

Custom font rendering

Load any OpenType or system font by name with fontspec — ideal for branded reports, custom typography, or non-Latin scripts.

Complex algorithms

Embed number-crunching Lua code directly in your document: statistics, transformations, or data formatting before typesetting.

Modern arXiv submissions

Some newer journal templates and arXiv submissions explicitly require or prefer LuaLaTeX for modern font and Unicode handling.

\section{Migration guide}

Migrating pdfLaTeX → LuaLaTeX

Most pdfLaTeX documents compile under LuaLaTeX with a few preamble changes.

ActionPackage / command
Remove\usepackage[utf8]{inputenc}
Remove\usepackage[T1]{fontenc}
Add\usepackage{fontspec}
Optional\usepackage{luacode}
Consider\usepackage{polyglossia}

\api{FormaTeX}

Using LuaLaTeX via the API

Pass "engine": "lualatex" in your compile request to select LuaLaTeX.

curl -X POST https://api.formatex.io/v1/compile/sync \
  -H "Authorization: Bearer $FORMATEX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "engine": "lualatex",
    "source": "\\documentclass{article}\\usepackage{fontspec}\\begin{document}Hello\\end{document}"
  }' \
  --output document.pdf

\begin{document}

Compile LuaLaTeX in the cloud

FormaTeX supports pdfLaTeX, LuaLaTeX, and XeLaTeX. No local TeX Live install required — compile via API or the browser playground.

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