XeTeX is a TeX engine that reads UTF-8 directly and uses the fonts already installed on your system. With no TFM or map-file setup, you simply name a font through the fontspec package and OpenType fonts just work. It was written by Jonathan Kew, and you normally invoke it as xelatex.
What XeTeX is
In classic TeX and pdfTeX, using a font meant preparing a TFM (TeX Font Metrics) dimension file and mapping it to a real font through a .map file — a fiddly dance. XeTeX removes that chore: it lets you name any font the operating system knows about (OpenType / TrueType, and AAT on macOS) and use it directly. Input is interpreted as UTF-8 by default, so you can write Japanese, Greek, or accented letters as literal characters.
Jonathan Kew originally wrote it for SIL International, built around the Mac typesetting technology of the day, AAT (Apple Advanced Typography); it later became a cross-platform engine running on Windows and Linux too. Internally it includes the e-TeX extension set, so the facilities that modern LaTeX assumes are all present.
The Xe in the name plays on TeX’s final X (the Greek χ) flipped around — a pun on “the reverse of TeX.” In English it is read informally as “zee-tech” or “zi-tech,” though pronunciations vary.
A minimal example
Here is the smallest document that compiles with xelatex. It loads fontspec and sets the body font with \setmainfont, naming the font as the system knows it. Bundled fonts such as Latin Modern or TeX Gyre work with no extra install, but an OS font like Hiragino Mincho ProN is named the very same way.
\documentclass{article}
\usepackage{fontspec}
\setmainfont{TeX Gyre Termes}
\begin{document}
Hello, \XeTeX! こんにちは、世界。
\[ E = mc^2 \]
\end{document}The key point is that you **do not load inputenc or fontenc**. UTF-8 input and Unicode fonts are the baseline, so the character-encoding incantations that pdfLaTeX needed simply disappear. You compile with a single xelatex document.tex (twice if you have cross-references).
Fonts — fontspec is the star
In practice you reach XeTeX’s font power through the **fontspec package**. You set the body, sans-serif, and monospaced fonts as below, and can also spin up a new font family for a specific purpose.
\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}
\setsansfont{TeX Gyre Heros}
\setmonofont{TeX Gyre Cursor}
\newfontfamily\headingfont{TeX Gyre Adventor}fontspec also exposes the OpenType features baked into a font. Through its options you can switch on historic ligatures, small caps, or oldstyle figures, among others. Features the font does not carry simply have no effect.
\setmainfont{TeX Gyre Pagella}[
Ligatures = {Common, Historic},
Numbers = OldStyle,
SmallCapsFeatures = {Letters = SmallCaps},
]
% 生の OpenType / Graphite タグを直接指定:
\newfontfamily\swashfont{EB Garamond}[RawFeature = {+swsh}]For finer control there are options such as Renderer (choose the HarfBuzz / AAT / Graphite shaper) and RawFeature (pass a font’s raw feature tags directly). To switch the input encoding mid-document, the engine provides the built-in \XeTeXinputencoding. And when you want a Unicode math font (STIX Two Math, Latin Modern Math, …), you pair XeTeX with the **unicode-math package**.
The pipeline — XDV to PDF
Where pdfTeX writes PDF directly, XeTeX works in two stages. The engine first emits an intermediate XDV (extended DVI; XeTeX DeVice-independent) file, which the bundled **xdvipdfmx** driver then turns into PDF. From your side a single run of xelatex does everything, but internally these two stages run in sequence (since version 0.997, xdvipdfmx has been the default driver on all platforms).
This design matters for **\special, driver-dependent options, and graphics inclusion**. Because xdvipdfmx is what actually produces the PDF, when a package like graphicx needs an explicit driver you point it at xetex (i.e. xdvipdfmx). Most packages auto-detect XeTeX, so you rarely have to think about it.
Multilingual and complex scripts
One reason XeTeX is so widely used is its strength with right-to-left (RTL) and complex scripts. Modern XeTeX shapes glyphs with HarfBuzz (adopted in version 0.9999, in 2013, replacing the older ICU LayoutEngine), so it correctly sets Arabic joining and ligature-rich scripts.
For switching languages you use the **polyglossia package** of the XeTeX / LuaTeX era (the replacement for classic babel). RTL typesetting is handled by the bidi package, and polyglossia loads bidi automatically when you request Arabic, Hebrew, and the like. Chinese, Korean, and Japanese (CJK) are handled with **xeCJK — though for Japanese specifically, many still prefer LuaTeX-ja (luatexja) or upLaTeX** for vertical writing and the finer rules of Japanese typesetting.
XeTeX versus LuaTeX
XeTeX and LuaTeX share the same modern foundation — Unicode input plus system fonts — but they have different temperaments. XeTeX is simpler and fast: it suits “I just want to use the OS fonts with Unicode,” and years of use have made it stable and mature. LuaTeX, by contrast, embeds the Lua language in the typesetting engine, letting you program its behavior in fine detail through low-level hooks.
The flip side is that XeTeX cannot run Lua and has fewer low-level hooks. Development of new font technology and typesetting machinery tends to gather on the LuaTeX side. As a rough division of labor: XeTeX for ease and stability, LuaTeX for programmability and longevity.
| Aspect | XeTeX | LuaTeX |
|---|---|---|
Unicode 入力 | Yes (UTF-8 default) | Yes (UTF-8 default) |
システムフォント | Directly, via fontspec | Directly, via fontspec |
シェーピング | HarfBuzz / AAT / Graphite | HarfBuzz (luaotfload) |
PDF 化 | XDV → xdvipdfmx (two stages) | Direct output |
スクリプト言語 | None | Embedded Lua |
性格 | Simple, stable, mature | Programmable, evolving |
When to reach for XeTeX
- Use the fonts already on your system. Name an OpenType / TrueType font and you are done.
- Write Unicode literally. UTF-8 input is the default; no encoding setup required.
- Set multilingual / RTL text. polyglossia + bidi make it strong for Arabic, Hebrew, and more.
- Get going quickly and reliably. Little configuration, and a long, stable track record.
- Consider LuaTeX if you need Lua-level customization, or upLaTeX / luatexja for precise Japanese typesetting.