Typevia
Accessibility and Modern Features

Understanding Accessibility in LaTeX

Accessibility in the digital world means ensuring that your documents can be read and understood by everyone, including people with visual, auditory, cognitive, or motor impairments. When we talk about LaTeX accessibility, we are primarily concerned with creating Tagged PDFs.

A standard PDF is often just a "map" of where ink should go on a page. A Tagged PDF, however, contains hidden metadata that describes the structure of the document (e.g., "this is a heading," "this is a list item," "this is an image description"). This allows screen readers—software used by blind or visually impaired users—to navigate the document logically rather than just reading a stream of disconnected words.

While LaTeX has historically struggled with automated accessibility, recent developments by the LaTeX Project team have made it significantly easier to create accessible documents that comply with standards like PDF/UA (Universal Accessibility).

1. Setting Up the Document Metadata

The first step in creating an accessible LaTeX document is to provide high-quality metadata. This helps screen readers identify the language, title, and author of the document before the user even begins reading the content.

In modern LaTeX, we use the \DocumentMetadata command. This command must be placed before \documentclass. It triggers the "tagging" features that are currently being integrated into the LaTeX kernel.

\DocumentMetadata{
  testphase = {phase-III,math}, % Enables automated tagging and math support
  pdfstandard = A-2u,            % Ensures Unicode support
  lang = en-US                   % Sets the document language
}
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}

\hypersetup{
    pdftitle={How to Create Accessible Documents},
    pdfauthor={Jane Doe},
    pdfsubject={LaTeX Accessibility Tutorial},
    pdfkeywords={LaTeX, Accessibility, Tagged PDF}
}

\begin{document}
  Hello, accessibility!
\end{document}

Note: The testphase keys are part of an ongoing project to make LaTeX accessible by default. Always use a modern TeX distribution (like TeX Live 2023 or later) and compile with LuaLaTeX for the best results when working with accessibility features.

2. Logical Document Structure

Screen reader users often navigate documents by jumping from heading to heading. If you skip heading levels (e.g., going from a \section directly to a \subsubsection), you create a confusing "map" for the user.

Best Practices for Structure:

  1. Use Hierarchical Headings: Always follow a logical order: \section $\rightarrow$ \subsection $\rightarrow$ \subsubsection.
  2. Avoid Visual Formatting for Structure: Never use \textbf{...} or \large to create a heading. Use the actual heading commands so they are tagged correctly in the PDF backend.
  3. Language Declaration: If your document contains multiple languages, ensure you switch between them using the babel package so the screen reader knows which pronunciation rules to apply.
\usepackage[french, english]{babel}

\begin{document}

\section{Introduction}
This is a standard English paragraph.

\begin{otherlanguage}{french}
Ceci est un paragraphe en français.
\end{otherlanguage}

\end{document}

3. Adding Alternative Text to Images

One of the most critical aspects of accessibility is providing Alternative Text (Alt-Text). Since a screen reader cannot "see" an image, it relies on a text description to convey the information to the user.

In the newest versions of the LaTeX tagging project, you can provide descriptions directly within the figure environment.

\usepackage{graphicx}

\begin{document}

\begin{figure}[ht]
    \centering
    \includegraphics[width=0.5\textwidth]{growth-chart.png}
    % The tagging engine uses the caption for context, 
    % but you should provide a specific description for the image.
    \caption{Company growth from 2020 to 2024.}
    \label{fig:growth}
\end{figure}

\end{document}

Best Practice: While full automated tagging for alt-text is still evolving in LaTeX, ensure your captions are descriptive. Avoid saying "Image of a chart"; instead, say "Line chart showing a 20% increase in revenue between 2020 and 2024."

4. Accessible Tables and Lists

Tables are notoriously difficult for screen readers. A screen reader reads a table cell by cell, and without proper structure, the user may lose track of which column or row they are in.

Creating Better Tables:

  • Keep it simple: Avoid merging cells (\multicolumn or \multirow) unless absolutely necessary, as these break the linear reading flow.
  • Use Captions: Always use the \caption command above the table.
  • Clear Headers: Ensure the first row clearly defines the data below it.

For lists, always use the standard environments (itemize, enumerate). LaTeX automatically tags these as list structures, telling the screen reader how many items are in the list.

\section{Essential Tools}
\begin{itemize}
    \item \textbf{LuaLaTeX:} The preferred engine for accessible PDF generation.
    \item \textbf{Hyperref:} For clickable links and metadata.
    \item \textbf{Babel:} For proper language tagging.
\end{itemize}

\begin{table}[ht]
    \caption{User Survey Results}
    \centering
    \begin{tabular}{|l|c|}
        \hline
        Tool & Satisfaction Score \\
        \hline
        LaTeX & 9.5 \\
        Word & 6.2 \\
        \hline
    \end{tabular}
\end{table}

5. Mathematical Accessibility

LaTeX is the gold standard for typesetting math, but standard PDFs often turn equations into a collection of symbols that screen readers read as "thin space, Greek letter sigma, superscript..." which is incomprehensible.

By using the math testphase in \DocumentMetadata, LaTeX attempts to embed MathML (Mathematical Markup Language) or actual LaTeX source code into the PDF. This allows specialized screen readers (like NVDA with MathPlayer) to read the equation as "The sum from i equals 1 to n."

Tips for Accessible Math:

  1. Avoid using images for math: Always use LaTeX notation ($ ... $ or \[ ... \]).
  2. Use semantic commands: Use \frac{a}{b} rather than a/b when possible, as it provides more structural information.
  3. Don't abuse math mode: Don't use math mode to italicize regular words; use \textit{...}.
% Example of a structured equation that 
% modern tagging can interpret correctly.
\begin{equation}
    E = mc^2 \label{eq:einstein}
\end{equation}

6. Common Pitfalls and Validation

Creating an accessible document is a process of constant checking. Here are some common mistakes to avoid:

  • Color Contrast: Ensure your text color has a high contrast ratio against the background. Avoid using color as the only way to convey meaning (e.g., "the red text is important").
  • Empty Lines for Spacing: Do not use \\ or multiple empty lines to create vertical space. Use \vspace{...} or adjust your paragraph settings. This prevents screen readers from announcing "blank line" repeatedly.
  • Hard-coded Links: Instead of writing "click here," use descriptive link text.

How to Validate:

After compiling your document with LuaLaTeX, you should check its accessibility:

  1. Adobe Acrobat Pro: Use the "Accessibility Check" tool.
  2. PAC (PDF Accessibility Checker): A free, industry-standard tool for checking PDF/UA compliance.
  3. Screen Readers: Test your PDF with a free screen reader like NVDA (Windows) or VoiceOver (macOS) to see how it sounds.

By following these steps, you move beyond just "making a document" and start "communicating with everyone," making your academic or professional work truly inclusive.