Some Updates on Tagged PDF documents – Accessibility in Latex

Latex's PDF tagging features now start to be usable.

More on Accessibility with Latex

Basic Recommedations

I have written here previously regarding the generation of accessible documents in Latex. Since this report in 2024, one can note that much progress has taken place behind the scenes on improving the accessibility-testphase LaTeX package. Many of my documents which only compiled with difficulties last year can now produce output without many errors being reported.

So, my first recommendation is to go and get the very latest LaTeX distribution. For a comprehensive release, see the TeX Live distribution on the TeX users group, which has links to the Windows, Mac and Linux versions. Once you have installed the latest annual release (currently 2025), do take the time and also run the update manager that comes with the distribution and pull all available updates for individual packages, also.

All of the resources on this page are available via this OneFile directory, including a small package for convenient generation of tagged figures accessibleimage.sty.

Be more explicit about structure

Sometimes, you might want extra tags in your document that are not required for normal document flow, such as to highlight in-line tables or figures more explicitly. I have created the following small command to achieve this, adding an entry for an (otherwise invisible) section.

% ===================== Command to manually tag unnumbered sections =====================

\newcommand{\HiddenHOne}[1]{%

  \tagstructbegin{tag=H1}%

    \tagmcbegin{tag=H1,actualtext={#1}}%

    \tagmcend

  \tagstructend%

}

You could create similar commands for lower-level headings, too.

Refinements and additional features

Tagging Figures

The precise instructions on how best to tag figures depend slightly on the version of tagpdf and whether the native testphase capabilities are used. To help you navigate these I have created a small package “accessibleimage.sty” to select the correct commands. The package defines a command that issues the correct instructions for alt-text for all reasonably recent LaTeX engines. Simply use the command provided:

\accessibleimage[<figure options>]{<Figure-Filename>}[<alt-text>]

If the alt-text is omitted, this will automatically mark the figure decorative.

Should you be interested in how this works, read on below!

I have also included a command to include background images such as logos appropriately, via

\backgroundaccessibleimage[<figure options>]{<Figure-Filename>}[<alt-text>]

Note the <alt-text> here is for your own documentation purposes, as this figure will be marked decorative by default.

Details on Pdf Tagging – TagPDF version

I have already discussed tagging previously. However, I was not quite aware of two refinements which I will now explain. Firstly, tagging can be done by defining alt-texts using the tagpdf package. This enables manual explicit embedding of alt-text and pulling entries into the list of pdf tags (but it still requires the pdfmanagement-testphase setup to be loaded, but here, set testphase ={}, or simply omit this tag in the header).

One of the possible caveats is that use of tagging can significantly bloat the file-size for the pdf output generated from the source. Some practical steps to keep this to the minimum is load the tagpdf package and set the setup options as early as possible in your latex source. I have used a RequirePackage prior to the documentclass definition (or in a custom LaTex class), and then passed package options as follows:

% Ask to Load Package (prior to documentclass)

\RequirePackage{tagpdf}

Then, early inside your document, call:

% PDF and tagging setup

\tagpdfsetup{tabsorder=structure,activate-all,interwordspace=true,uncompress}

You can toggle on or off the bookmarks via the hyperref setup:

\RequirePackage[bookmarks=true]{hyperref}

To make sure compression is at its best, I have further added some options to enhance the compression settings for the pdf generator.

% ===================== COMPRESS PDF =====================

\pdfcompresslevel=9

\pdfobjcompresslevel=3

You will know that you succeeded to place these commands in reasonable positions if your tagged pdf is only moderately larger than the version without tagging. If the file does become many MB large, then try to remedy this by changing the order in which you load packages.

Once the tagpdf package is loaded appropriately, you can then define alt-text for figures (similarly to what I proposed in my earlier post):

\tagstructbegin{tag=Figure, alttext={This is a random smiley face.}}
\includegraphics[width=0.2\textwidth]{a-smiley-face.png} % Your image here
\tagstructend

Instead, if you want to declare figures as decorative, and avoid them being read in a screen reader, they should be defined as “Artifact” rather than figures, using

\tagstructbegin{tag=Artifact}
\includegraphics[width=0.2\textwidth]{a-smiley-face.png} % This image will not get reported
\tagstructend

A worked example is available as source file DummyTaggedPDF-TagPDF.tex.

Pdf Tagging – Built-in version

Tagging can also be enabled using the newly built integrated capabilities of the LaTeX engine, which are activated by loading the pdfmanagement-testphase package. This is what I talked about previously, but in my first attempt I added tagpdf on top of this. It turns out that this is not actually required, as the testphase setup can handle tagging internally. To set up a document for using this functionality, we need a header before the documentclass (as explained in my previous post):

\RequirePackage{pdfmanagement-testphase}

\DocumentMetadata{

   testphase = phase-III, % tagging level ‘Phase-III’ required in order for the internal tagging to work (in addition to a modern LaTeX installation)

   pdfstandard=ua-1,

   pdfversion = 1.7,      % version 1.7 is good for standard ua-1

   lang=en-UK % set language for the document

}

As of the latest MacTex2025 install with extra package updates pulled in Sept 2025, you can then get your alt-text with the minimal tagging as follows:

\includegraphics[width=0.2\textwidth,alt={This is a random smiley face.}]{a-smiley-face.png}

Or, for a decorative figure without alt-text:

\includegraphics[width=0.2\textwidth,artifact]{a-smiley-face.png}

A worked example with this option is shown as DummyTaggedPDF-Native.tex.

Background figures

You might want to additionally include decorative pictures such as a company logo in the background of a letter. In that case, the following code does the job:

% — Optional Banner Image —

\AddToShipoutPictureBG*{%

  \begin{tikzpicture}[remember picture, overlay]

    \node[anchor=north west, inner sep=0pt] at (current page.north west) {

      \includegraphics[artifact,width=\paperwidth]{UKent-Logo.png}

    };

  \end{tikzpicture}%

}

If using the tagpdf implementation for pdf tagging you will need to omit the extra keyword ‘artifact’ when calling includegraphics.

This code is generated automatically via the \backgroundimage command in the accessiblefigure package.

Accessibility Standards

You can also set the level of accessibility standard for your output, enabling slightly different sets of embedded accessibility data in the final pdf. This needs to be set prior to calling the \documentclass command in your document. If you’d like to be able to toggle this setting easily, you can use this code block to switch between available versions. For use of material on moodle pages which are tested for accessibility with BlackBoard Ally, you will want to stick to version 1:

% !TEX encoding = UTF-8 Unicode

% — Accessibility Standard Switch —

% choose either ua1 (default, more compatible) or ua2 (newer, more efficient)

% toggle to get best compatibility with Blackboard Ally.

\def\AccessibilityStandard{ua1}

\ifx\AccessibilityStandard\undefined

  \def\AccessibilityStandard{ua1} % fallback

\fi

\ifx\AccessibilityStandard\ua1

  \DocumentMetadata{

    lang        = en-GB,

    tagging     = on,

    pdfstandard = ua-1,

    pdfversion  = 1.7

  }

\else\ifx\AccessibilityStandard\ua2

  \DocumentMetadata{

    lang        = en-GB,

    tagging     = on,

    pdfstandard = ua-2,

    pdfversion  = 2.0

  }

\else

  \PackageWarningNoLine{accessibility}{Unknown value for \string\AccessibilityStandard.

    Defaulting to UA-1/1.7}

  \DocumentMetadata{

    lang        = en-GB,

    tagging     = on,

    pdfstandard = ua-1,

    pdfversion  = 1.7

  }

\fi\fi

All of the code examples are prepared for download as zip archive, available here.