Guide

How to produce a tagged PDF from LaTeX

LaTeX's tagging project reached usable in 2024. What works now, what still needs post-processing, and the maths problem nobody has solved.

About 15 minutes · involved

The state of it

For twenty years the honest answer to “can LaTeX make an accessible PDF” was no. That changed with the LaTeX Project’s tagged-PDF work, which has been usable since the 2024 format releases and continues to develop.

What follows is what works now. Check the current latex-lab documentation before relying on any specific detail, because this is moving.

The minimum that works

\DocumentMetadata{
  lang        = en-GB,
  pdfversion  = 2.0,
  pdfstandard = ua-2,
  testphase   = {phase-III, math},
}
\documentclass{article}

\usepackage{hyperref}
\hypersetup{
  pdftitle            = {A Structured Title, Not the Filename},
  pdfdisplaydoctitle  = true,
}

\begin{document}
\section{Introduction}
...
\end{document}

Three things about this preamble matter.

\DocumentMetadata must come before \documentclass. It is not a package; it configures the format before the class loads. Putting it after silently disables tagging.

testphase selects how much of the tagging code is active. Higher phases tag more and are less settled. phase-III handles sectioning, lists, tables, links and floats. Add math for equation tagging, which is the newest and least stable part.

pdfdisplaydoctitle = true is not optional. Without it a reader announces the filename regardless of pdftitle. See the title guide.

Compile with LuaTeX. lualatex document.tex. The other engines do not support the tagging callbacks.

What comes out correct

  • Sectioning. \section, \subsection and friends become H1H6 with correct levels, provided you do not skip levels in the source. Skipping in LaTeX produces skipping in the PDF — condition 14-003.
  • Lists. itemize, enumerate and description become proper L/LI/LBody.
  • Links. hyperref’s links get /Link structure elements, not just annotations.
  • Tables. tabular becomes a Table with TR and TD. Header rows need to be declared — see below.
  • Language. lang in \DocumentMetadata sets /Lang, and babel’s language switches emit per-run language, which is more than most word processors manage.

What still needs work

Table headers

tabular has no concept of a header row; it is a grid of cells. The tagging code cannot infer which row is a header, so you must say:

\begin{tblr}{
  row{1} = {font=\bfseries},
  cell{1}{1-3} = {cmd=\TableHeader},
}

Or use \rowstyle from tabularray. Without it every cell is a TD and the table fails 15-003. This is the most common LaTeX tagging failure.

Floats

A figure or table float appears wherever LaTeX put it, which is frequently not where it is discussed. Structurally it is tagged in the order the float was placed, so a figure pushed to the top of the next page is read there.

There is no automatic fix, because the correct reading position is a judgement about your document. Either constrain float placement with [h] and \FloatBarrier, or fix the order in post-processing.

Alt text on graphics

\includegraphics produces an image with no alt text. Provide it:

\includegraphics[alt={Revenue rose from 4.2 to 6.8 million between 2021 and 2025}]{revenue.pdf}

The alt key needs a recent graphicx. For a decorative rule or ornament, use artifact instead so it is excluded from the structure rather than given empty alt text.

For a chart, the alt text should carry the finding, not describe the picture — see writing alt text. A data-heavy figure usually also wants the underlying numbers in a table somewhere, because no sentence substitutes for twelve data points.

The maths problem

This is where honesty is more useful than optimism.

PDF has no native representation for mathematical semantics. The available routes are:

Associated MathML — PDF 2.0 allows a structure element to carry an associated file containing MathML, and this is the technically correct answer. Reader support is uneven: some assistive technologies use it, many ignore it, and PDF/UA-1 does not standardise it at all. If your target is PDF/UA-1 rather than 2.0, this route is outside the standard you are conforming to.

/ActualText on the equation — a linear string, like x squared plus y squared equals z squared. Universally supported and semantically flat. A reader cannot explore the expression, navigate its structure, or re-hear a sub-term, which is precisely what mathematical reading requires.

Alt text — a description. Adequate for a decorative equation, inadequate for anything a reader needs to follow.

The math testphase generates structure and associated MathML for LaTeX’s own maths. It is the best available option, and you should still expect a reader with a screen reader and a maths document to be doing real work that the file does not do for them.

If the document is a teaching text or anything where the mathematics is the content, consider producing an HTML version alongside the PDF. HTML with MathML has genuinely good support; PDF does not. Publishing both is not a defeat, it is the correct engineering answer.

Hebrew and Arabic in LaTeX

LuaTeX with babel’s bidi support produces correctly ordered text in the output — that is, the stored characters are in logical order, which is right. Do check it rather than assume it, because some older packages, and bidi under XeTeX in particular, reverse text at the source level and produce exactly the visual-order failure described in TG-RTL-001.

The two-keystroke check applies: compile, open, select all, copy, paste into a plain-text editor, and look at where the Hebrew final letters fall.

Verify the output

The tagging code is young and your document is probably doing something it has not seen. Do not skip this.

lualatex document.tex
verapdf --flavour ua1 --format text document.pdf

Then the human check: select all, copy, paste, and read the order. Floats and multi-column layouts are where LaTeX’s output most often surprises, and no validator reports either.

Frequently asked questions

Can LaTeX produce a PDF/UA-conformant file today?

For text-heavy documents with straightforward structure, close to it, using the LaTeX Project's tagging code with a recent format. For documents with substantial mathematics, floats and custom layouts, not yet without manual work. The project is explicit that this is in development, and that honesty is worth more than a vendor's claim would be.

What about the maths?

This is the genuinely unsolved part. PDF has no native maths semantics; the route is associated MathML, which PDF 2.0 supports and PDF/UA-1 does not standardise. Reader support is inconsistent, and the practical fallback — alt text on the equation image — collapses a structured expression into a sentence.

Is pdflatex, lualatex or xelatex the right engine?

LuaTeX. The tagging implementation depends on Lua callbacks that are not available in pdfTeX, and XeTeX's output routine does not expose what the tagging code needs. If your document is Hebrew or Arabic, LuaTeX is also the engine with the most workable bidi story.

What is the simplest path if my document is a paper for a journal?

Check what the publisher accepts before investing anything. Many take LaTeX source and produce their own tagged output, in which case your effort should go into clean semantic markup — real \section commands, real environments, alt text on figures — rather than into producing a tagged PDF they will discard.

Related failure conditions

Check your own file. Taggart's validator is free and unlimited — no page cap, no watermark, and no account at all up to 60 pages.

Check a PDF free

Last updated .