How to Use LuaLaTeX for Automatic MathML Tagging
Mathematical content in PDFs has historically been inaccessible to screen readers — equations are treated as opaque images. LuaLaTeX, combined with the modern LaTeX tagging framework, can automatically embed MathML representations of your equations into the PDF structure. This means screen readers can read your math aloud correctly: 'integral from zero to infinity of e to the negative x squared dx' instead of silence or gibberish. Bibby AI supports LuaLaTeX compilation with full MathML tagging enabled, producing the most accessible math PDFs available from any LaTeX platform.
Enable MathML Tagging with DocumentMetadata
Configure DocumentMetadata and compile with LuaLaTeX to get automatic MathML tagging for all math content:
% Compile with: lualatex
\DocumentMetadata{
lang = en-US,
pdfstandard = ua-1, % PDF/UA for accessibility
pdfversion = 2.0,
testphase = {phase-III, math}, % Enable math tagging
}
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}
\title{Accessible Mathematics}
\author{Author Name}
\maketitle
\section{Equations with MathML Tagging}
Inline math is tagged: $E = mc^2$.
Display equations are also tagged:
\[
\int_0^\infty e^{-x^2}\,dx = \frac{\sqrt{\pi}}{2}
\]
The quadratic formula:
\[
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
\]
\begin{align}
\nabla \cdot \mathbf{E} &= \frac{\rho}{\epsilon_0} \\
\nabla \times \mathbf{B} &= \mu_0 \mathbf{J} + \mu_0 \epsilon_0 \frac{\partial \mathbf{E}}{\partial t}
\end{align}
A screen reader will interpret these equations correctly via their embedded MathML.
\end{document}Verify and Test MathML Output
Inspect the generated PDF to confirm MathML tags are present, and test with accessibility tools:
% After compiling with lualatex, verify the tagging:
%
% Method 1: Use pdfinfo with structure dump
% pdfinfo -struct output.pdf | grep -i math
%
% Method 2: Open in Adobe Acrobat Pro
% View → Navigation Panels → Tags
% Look for <Formula> tags containing MathML
%
% Method 3: Use PAC (PDF Accessibility Checker)
% Free tool from access-for-all.ch
% Checks PDF/UA compliance including math tags
% Example of what the tagged structure looks like internally:
% <Formula>
% <math xmlns="http://www.w3.org/1998/Math/MathML">
% <mrow>
% <mi>E</mi>
% <mo>=</mo>
% <mi>m</mi>
% <msup><mi>c</mi><mn>2</mn></msup>
% </mrow>
% </math>
% </Formula>
% Minimal test document to verify MathML is working:
\DocumentMetadata{
lang = en-US,
pdfversion = 2.0,
testphase = {phase-III, math},
}
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Test: $a^2 + b^2 = c^2$
\[
\sum_{n=1}^{\infty} \frac{1}{n^2} = \frac{\pi^2}{6}
\]
\end{document}💡 Tips
- •MathML tagging requires LuaLaTeX — pdfLaTeX and XeLaTeX cannot produce MathML-tagged PDFs.
- •Add 'math' to the testphase list alongside 'phase-III' to specifically enable math structure tagging.
- •Test with NVDA (free screen reader for Windows) or VoiceOver (macOS) to hear how your equations sound.
- •Some complex custom macros may not tag correctly — define them using standard amsmath commands for best results.
Try This in Bibby AI
Write LaTeX faster with AI auto-complete and instant compilation.
Start Writing Free