Creating Accessible LaTeX Generated PDFs

Summary

How to create accessible PDFs from LaTeX.

Body

How to create an accessible PDF/UA-2 document from LaTeX.

Project Setup and Required Environment

To produce a tagged PDF with accessible math, you must set up your project to use:

  • Engine: LuaLaTeX 
    • Switch to LuaLaTeX
    • PDF/UA-1 requires that the document language be encoded in the PDF tag tree. This is only possible with LuaLaTeX; pdflatex cannot write the language entry to the structure tree.
    • Replace your build command:  pdflatex main.tex  →  lualatex main.tex
  • Version: TeX Live 2025 or newer
  • Packages: `unicode-math` and LuaMML compatible packages (check status).
  • Font: An Opentype font is required; TFM-based fonts are not supported. If you use other fonts, `unicode-math` should be loaded after them.

Preamble Requirements: Metadata Declaration

The `\documentmetadata` command is essential to creating an accessible PDF. It must be the very first declaration, before `\documentclass`.

This loads the necessary code and packages. Next, use `\DocumentMetadata` to define required standards and tagging features:

  \DocumentMetadata{lang=en-US, pdfstandard=ua-1}

  \documentclass{...}   (This activates LaTeX's PDF resource management layer, declares the document language, and embeds the PDF/UA-1 XMP schema entry in the output.)

For reading math: 

\DocumentMetadata{
  tagging = on,
  lang = en,
  pdfstandard = ua-2,
  pdfstandard = a-4f, % optional archival standard
  tagging-setup = {math/setup={mathml-AF,mathml-SE},
                   extra-modules={verbatim-mo},
                   table/header-rows=1}}

PDF Standards

This method requires the use of PDF standard UA-2 for accessibility. You may also use PDF standard **A-4F** for archival purposes, but this is optional.

Tagging Setup

The `math/setup` portion of `\documentmetadata` enables the creation of MathML as structure elements and associated files, as well as designating the first row of each table as a header row and enabling verbatim. These elements are required.

Package Requirements for Math

Required Package

\usepackage{unicode-math}

Recommended Packages

These packages assist with proper structure and tagging of specific elements:

  • `graphicx`: Required if including any images. Allows for alt text to be added within `\includegraphics` (replaces the older `accsup` method).
  • `tabularx` (or `tabular` or `tabular*`): Supported table environments.
  • `float`: Required if using floating elements (tables, graphics). You must use the `[H]` position specifier to ensure correct reading order.
  • `hyperref`: Recommended if there are any internal or external hyperlinks.
  • `enumerate`: Recommended for lists and bullets.

OR

Load tagpdf and activate full tagging

 \usepackage{tagpdf} 

\tagpdfsetup{activate-all}

 tagpdf is part of TeX Live and MiKTeX. With activate-all, it tags paragraphs, headings, lists, and other block elements automatically with the correct PDF structure types. No per-environment changes are needed for standard document content.

Set Accessible Document Properties

Set Document Properties

Set document properties with \hypersetup{

\hypersetup{ 

  pdftitle={Accessibility Recommendations for LaTeX Documents}, 

  pdfauthor={eSAIL @ TAMU - Accessibility Team}, 

  pdfsubject={Accessible LaTeX Recommendations (PDF/UA-2)}, 

  pdfkeywords={LaTeX, accessibility, PDF/UA-2, NVDA, MathML}, 

  pdfdisplaydoctitle=true 

}

OR

Update \hypersetup

  Add two keys:

  \hypersetup{

pdflang          = {en-US},

pdfdisplaydoctitle = true,

 % ... your existing keys ...

  } 

pdfdisplaydoctitle=true satisfies §7.1 of the standard, which requires PDF viewers to display the document title (from pdftitle) rather than the filename.

 

Example:

● \hypersetup{

    pdftitle          = {Operating Systems: Three Easy Pieces},

    pdfauthor         = {Remzi H. Arpaci-Dusseau and Andrea C. Arpaci-Dusseau},

    pdfsubject        = {Operating Systems},

    pdfkeywords       = {operating systems, virtualization, concurrency, persistence},

    pdfencoding       = auto,

    pdflang           = {en-US},

    pdfdisplaydoctitle = true,

    colorlinks        = true,

    linkcolor         = blue,

    urlcolor          = blue,

    bookmarksnumbered = true,

  }

Set Document Elements

You must manually ensure the following elements are properly formatted if present in your document.

Headers

Ensure your document is organized into headers and subheaders using \section{ }  (this will be read as Header 1) and \subsection{ } (read as Header 2). Each section should have a corresponding title defined and should not be left blank.

Floating Elements

Floating elements such as images and tables create problems with the reading order of the PDF, because the element may “float” to the bottom of the tag tree, or get mixed in with other content. To remedy this:

  1. Load the float package and use `[H]` to ensure the element is read in the correct order in the document. This may interfere with the visual formatting, but it is essential to ensure the content is presented to assistive technology users in logical order.
  2. Manually wrap a tag container around the floating element
    • Place `\tagstructbegin{tag=Part}` immediately before your floating element. Ensure there is a blank line immediately prior to this command to avoid tagpdf structure errors. Place `\tagstructend` immediately following the floating element to close the section.
    • Only the element and its caption should be inside this structure. See graphics and table examples below for examples.

Math

  • Inline Math: For inline math (equations shown within a sentence) it is recommended to use the standard $ $ delimiters to define a math expression.Example: Define the loop gain $L(s)=G(s) G_{c}(s)$.
  • Display Math: For an equation in displayed math mode (equations on their own line), you should use `\[ \]`.Example: \[T(s)=\frac{Y(s)}{R(s)} \]
  • Align and cases environments can also be used.

Tables

  • Table headers. Currently table headers are defined by `table/header-rows=1` in the `\documentmetadata` command.
  • To ensure your table and caption read in the correct order, you should use `[H]` and wrap the element with a manual tag structure See floating elements, above, for full information.
%leave an empty line before \tagstructbegin

\tagstructbegin{tag=Part}%required to ensure correct reading order of contents if the table has any caption
\begin{table}[H]
\caption{Sample Table}%caption must be first or last element of environment
\centering
\begin{tabularx}{\linewidth}{|X|X|}
\hline
\textbf{Category 1} & \textbf{Category 2} \\ \hline
First block of information & Second block of information \\ \hline
More information & Other information \\ \hline
\end{tabularx}
\end{table}
\tagstructend

Graphics and Alt Text

Images must include alt text (alternative text describing the content of the image) to ensure accessibility for screen readers. The `graphicx` package allows you to easily add alt text using the `\includegraphics` command. Within the `\includegraphics` command, specify your main parameters and then insert a comma and add: `alt={your descriptive text here}`.

Here is an example of alt text use:

\includegraphics[width=.75\textwidth,alt={SVM classifier showing the maximum margin hyperplane and support
vectors separating two classes}]{Images/img1.png}

If your image is decorative and you wish to exclude it from tags, you can use the word `artifact` within the include graphics commands.

Here is an example:

\includegraphics[width=.75\textwidth,artifact]{Images/img1.png}

If your graphic has a caption, you must add a manual section break around the graphic to ensure the correct reading order. See floating elements, above, for full information.

The full graphics command with alt text should now look like the following:

%leave an empty line before \tagstructbegin

\tagstructbegin{tag=Sect}%required to ensure correct reading order of contents if the table has any caption
\begin{figure}[H]
\centering
\includegraphics[width=.75\textwidth,alt={Unity Feedback Configuration for Error Signal Analysis}]{Images/img1.png}
\caption{Unity Feedback Configuration for Error Signal Analysis}
\end{figure}
\tagstructend

Another example:

 Every \includegraphics must carry a text description. Load pdfcomment and wrap each image:

\usepackage{pdfcomment}

Then, because \pdftooltip from pdfcomment normally creates a button widget annotation (which fails §7.18.4), redefine it after all packages load to emit a proper Figure structure element instead:

  \AtBeginDocument{%

    \renewcommand{\pdftooltip}[2]{%

      \begingroup

        \def\@tagpdf@alttext{#2}%

        \tagstructbegin{tag=Figure,alttext=\@tagpdf@alttext}%

        \tagmcbegin{tag=Figure}%

        #1%

        \tagmcend

      \tagstructend

      \endgroup

    }%

  }

The \def\@tagpdf@alttext{#2} indirection is required: if alt text contains a comma, passing it directly to alttext={#2} causes the l3keys parser to split on the comma and error. The macro is expanded as a single token, bypassing that parser.

Wrap each image at the point of use:

  \pdftooltip{%

    \includegraphics[width=\textwidth]{figure.pdf}%

  }{A diagram showing the three-process timeline from fork to exec to exit.}

Note: the alt={...} option on \includegraphics itself does not write to the PDF structure tree in current TeX Live — only the \pdftooltip wrapper above does.

Validation and Accessibility Scoring

PDF Validation

Most PDF checkers (Adobe Acrobat, PAC, Canvas Ally) do not yet fully recognize MathML content tags and may flag them as errors.

  • VeraPDF is the currently recommended tool to check your document for proper tag structure. (VeraPDF is a free, open-source PDF/UA validator. After building:

     verapdf --flavour 1b yourfile.pdf

  • Recommendation: Listen to the math content with a screen reader to ensure it is being read correctly.

PDF Limitations and Requirements

This method was tested using Foxit PDF reader and Adobe Acrobat. Other PDF readers may not be able to interface with math content and/or screen readers to output accessible content.

Screen Reader Limitations and Requirements

This method was tested with NVDA screen reader with the Mathcat addon which allows the screen reader to announce MathML content within a PDF document. While Jaws can read math in HTML format and Word documents, it cannot yet read MathML content in PDF files.

A fully compliant document reports all assertions passed and zero failures. The 1b flavour selects the PDF/UA-1 machine-readable rules profile.

 

Here is a minimal example of making a PDF/UA-1 compliant file using lualatex

YouTube Videos on LaTeX Accessibility

 

References:

Dr. Stephen A. Torri, Associate Teaching Professor, Mississippi State University
Mary Lyn and Niles Moseley Endowed Chair in Cybersecurity
E: storri@cse.msstate.edu

https://esail.tamu.edu/faculty-tutorials/accessible-latex-pdf-ua-2-overleaf-2025/

https://www.youtube.com/watch?v=BnQltcExOVc

https://www.youtube.com/watch?v=qCLYv3Tdg9I

https://www.youtube.com/watch?v=oCTsAqZqm9A

Details

Details

Article ID: 2317
Created
Thu 6/4/26 4:00 PM
Modified
Tue 6/9/26 5:30 PM