All posts

pdfLaTeX, XeLaTeX or LuaLaTeX? How to choose, and how Luzbase decides for you

What each LaTeX engine is good at, how Luzbase picks one automatically, and the one-line comment that overrides it.

A main file starting with the % !TEX program = xelatex magic comment, above the four engine options.

LaTeX has three engines in common use, and the template you copied rarely says which one it expects. Pick the wrong one and you get errors about fonts or Unicode characters that make no sense at first.

Here's what each engine does well, and how Luzbase chooses for you.

The short version

Engine

Pick it when

pdfLaTeX

You're writing in English or a language with a standard LaTeX setup, using standard fonts. This covers most papers.

XeLaTeX

You need system fonts (Times New Roman, Calibri, a university font), or text in many scripts in one document.

LuaLaTeX

You need XeLaTeX's font support plus programmability, or a package that requires it.

pdfLaTeX: the default

pdfLaTeX is the oldest and fastest of the three, and almost every journal class is tested with it first. If your document compiles with pdfLaTeX, there's rarely a reason to change.

Its limit is Unicode. Type a character pdfLaTeX doesn't know about, a Chinese character, an emoji, some rarer accented letters, and the compile fails. Luzbase's error panel spots this and tells you which character caused it.

XeLaTeX: for fonts and scripts

XeLaTeX understands Unicode natively and can use system fonts through the fontspec package:

\usepackage{fontspec}
\setmainfont{TeX Gyre Termes}

That makes it the usual choice for documents in Arabic, Chinese, Persian or Hindi, documents that mix several scripts, and theses whose university mandates a specific font.

LuaLaTeX: XeLaTeX plus scripting

LuaLaTeX also supports Unicode and system fonts, and it embeds a programming language (Lua) inside the engine. Most people never need that. You'll know you need LuaLaTeX when a package's documentation tells you so.

How Luzbase picks

By default, a project's engine is Automatic. When you compile, Luzbase looks at your main file:

  1. If the file starts with a magic comment, that wins:
% !TEX program = lualatex
  1. If the preamble loads fontspec, unicode-math, polyglossia, xltxtra or xunicode, Luzbase uses XeLaTeX. Those packages don't work with pdfLaTeX, so using them is a clear signal.
  2. Otherwise, pdfLaTeX.

So most documents compile correctly without you ever thinking about engines. LuaLaTeX is only used if you ask for it with the magic comment.

Overriding it

Add the magic comment as the very first line of your main file:

% !TEX program = xelatex
\documentclass{article}

It works the same way in most desktop editors, so the project still compiles if a co-author downloads it.

What runs around the engine

Whichever engine you choose, Luzbase runs it through latexmk on TeX Live. latexmk works out how many passes your document needs, runs BibTeX or biber when your bibliography changes, and re-runs LaTeX until cross-references settle. You don't have to compile three times to get rid of "??" in your references.

Bibliographies use a Unicode-aware version of BibTeX, so author names like Gödel, Erdős or Dvořák come through without special escaping.

Start writing free.