Using LuaLaTeX

What is LuaLaTeX?

LuaLaTeX is a modern TeX engine that extends pdfLaTeX with the Lua scripting language. It is the recommended engine for most contemporary LaTeX projects because it supports:

  • Unicode natively — no need for inputenc or fontenc
  • OpenType and TrueType fonts via the fontspec package
  • Lua scripting for dynamic document generation
  • Full backwards compatibility with most pdfLaTeX documents
  • Better support for complex scripts (Arabic, CJK, etc.)

LuaLaTeX is bundled with all major TeX distributions (TeX Live, MiKTeX) so chances are that you already have LuaLaTeX on your computer.

For accessible tagging to work, you need to use a current version of LuaLaTeX. Please refer to the documentation of the TeX-distribution or IDE you are using for instructions on how to update LuaLaTeX to the latest release.


An Example LuaLaTeX Document

Here is a minimal LuaLaTeX document that you can use for testing your installation:

hello-lualatex.tex
\documentclass{article}

% LuaLaTeX-specific packages
\usepackage{fontspec}       % OpenType font support
\usepackage{luacode}        % Lua scripting in LaTeX

% Set a system font (change to one available on your system)
\setmainfont{Latin Modern Roman}

\title{My First LuaLaTeX Document}
\author{Your Name}
\date{\today}

\begin{document}

\maketitle

\section{Hello, LuaLaTeX!}

This document is compiled with LuaLaTeX.
It supports Unicode natively: café, naïve, Ångström, 日本語.

\section{Lua Scripting}

The answer to life is
\begin{luacode}
tex.sprint(6 * 7)
\end{luacode}.

\end{document}

Common Issues and Fixes

Problem Cause Fix
lualatex: command not found TeX not on PATH Add TeX bin dir to your PATH
Font not found System font not installed Install font or use a TeX font
! Package fontspec Error Using pdfLaTeX accidentally Ensure LuaLaTeX is the selected engine
Slow compilation LuaLaTeX is inherently slower Use --draftmode for intermediate builds
Unicode characters not rendering Missing font coverage Use a broader font like Noto or DejaVu

Additional Resources