Disclosure up front: I make ModernTex, a Mac LaTeX editor, and it comes up in one section below. The commands come from the LaTeX Project's own documentation, and I built one test document on a Mac to confirm them. Last checked October 19, 2026.
What a tagged PDF is, and who asks for one
A tagged PDF carries a structure tree next to the page content. Headings, paragraphs, lists, tables and figures are labelled and put in reading order, so a screen reader can move through the document instead of reading a flat stream of text. Without tags, assistive software has to guess.
You are most likely to meet the request from a university accessibility office, a funder or a publisher that asks for an accessible PDF. LaTeX did not produce tags on its own for years. The LaTeX Project now ships the code in the format itself, so for a current TeX distribution you turn it on with one declaration. The requirement is on the document, not on you: a tagged PDF still needs the human steps in the last section.
The preamble lines
The declaration goes before \documentclass, on the very first lines of the file. This is the example from the Project's usage instructions, trimmed to the keys that matter here:
\DocumentMetadata{
lang = en-US,
pdfstandard = ua-2,
pdfstandard = a-4f,
tagging = on,
tagging-setup = {math/setup=mathml-SE}
}
\documentclass{article}
\usepackage{unicode-math}
langsets the document language, which screen readers use to pick a voice. Changeen-USto yours.tagging=onturns tagging on. The conformance keys do not do this for you.pdfstandardnames the target standard. The page showsua-2together witha-4f(ora-4). PDF/UA-2 goes with PDF 2.0, which is the default version.tagging-setupaccepts the same keys as\tagpdfsetup.math/setup=mathml-SEwrites equations as MathML structure elements.
Overleaf's own page for this feature shows a shorter form with the same four ideas, tagging=on, tagging-setup, pdfstandard=ua-2 and lang. It also describes tagging=draft, which runs the tagging code without writing tags and can speed up compiles on a large project. Use on for the file you send.
Which release. The usage instructions say they apply to LaTeX 2026-06-01 and 2025-11-01, recommend a current release, and say tagging=on was not available in older ones. In practice that means TeX Live 2025 or later. Older guides online show a testphase key; that belongs to the prototype and is out of date.
Which engine
The usage instructions say the code works with pdfLaTeX or LuaLaTeX, and that LuaLaTeX is the preferred engine for new documents. They do not mention XeLaTeX. For equations the difference is real: with LuaLaTeX and unicode-math the math is tagged with MathML, and Overleaf's page says MathML structure tagging requires LuaLaTeX. With pdfLaTeX you only get the associated-file method, where you supply the MathML yourself in a separate file. Start new documents on LuaLaTeX.
Build it on a Mac
In Terminal with latexmk
Save the document with the declaration first, then build with LuaLaTeX:
latexmk -lualatex paper.tex
I ran this on October 19, 2026 with TinyTeX (TeX Live 2026, LuaHBTeX 1.24.0) on a one-page test file with a title, a section, an inline equation, a numbered list, one image with alt text and a small table. It built with no errors and wrote paper.pdf as PDF 2.0, plus a MathML file next to it. PDF dictionaries are normally packed where a text search cannot see them, so I built a second copy with the uncompress key added to \DocumentMetadata, only to look inside. It held a structure tree, the marked-content flag, the language en-US, the alt text on the figure, a table element, and the PDF/UA part 2 and PDF/A-4f identification. I did not run a conformance validator, so this shows that tagging is switched on and populated, not that the file passes a standard.
In ModernTex
With no engine saved for the project, no % !TEX program line and no latexmkrc that sets one, ModernTex 1.10.1 and later picks LuaLaTeX when the preamble has \DocumentMetadata. That is all the app does here (changelog, October 16, 2026). The tags come from LaTeX, and your TeX installation has to be recent enough to know the tagging key. If you have not set one up, how to install LaTeX on a Mac covers the options.
In Overleaf
Per Overleaf's guide, set the project's TeX Live version to 2025 or later so the compiler knows the tagging and tagging-setup keys, and switch the compiler from the default pdfLaTeX to LuaLaTeX. The usage instructions add that, at the time of writing, only the 2025-11-01 release was available there, under the Rolling TeX Live option.
Check the result
Do three things, in this order.
- Resolve every error. Overleaf's page warns that non-stop mode can still write a PDF after errors, and that such a PDF does not have an intact tag structure. A PDF that appears is not proof that the build was clean. Read the log.
- Look at the structure. The Project's usage page points to ngPDF for browsing the tag tree and the HTML derived from it. Check that headings are headings, the reading order matches the page, and the table has header cells.
- Run a checker for the standard you were asked for. I have not tested a validator for PDF/UA-2 on this Mac, so I am not naming one. Use whichever checker your accessibility office or publisher names. Overleaf's page notes that checkers differ and that a tool can flag an accessible LaTeX file, so read the report instead of trusting a single pass or fail.
What still needs a manual fix
- Alt text on every figure. Each graphic needs
alt,actualtextorartifact:\includegraphics[width=6cm,alt={A line chart of monthly downloads}]{chart.pdf}. The same keys work withtikzpictureandpicture. No tool can judge whether the text you wrote is enough. - Table header rows. Mark them before the table with
\tagpdfsetup{table/header-rows={1}}. Other cells are data cells by default. For a table used only for layout, the usage page liststable/tagging=presentation. - Packages that are not tag-aware. Packages that change document structure, build complex layouts or draw text are the likeliest to cause trouble. The Project keeps a tagging status list that marks each package as compatible, partially compatible, currently incompatible, unsupported or unchecked. Check your preamble against it. Overleaf's page adds that the
beamerclass is not compatible and points to the experimentalltx-talkclass instead. - Equations. Blank lines and forced line breaks inside equations can cause errors that break the tag structure, per Overleaf's page.
- Older readers. Overleaf notes that
pdfstandard=ua-2may not work in older PDF readers and that PDF/UA-1 may be needed. If a reader or a checker asks for it, ask which standard they require before you choose.
Sources
- Guidelines for generating accessible PDF with LaTeX, LaTeX Tagging Project, read October 19, 2026.
- Tagging status of packages and classes, LaTeX Tagging Project, read October 19, 2026.
- Creating accessible PDFs, Overleaf documentation, read October 19, 2026.
- ModernTex changelog, version 1.10.1, October 16, 2026.