Understanding Document Accessibility in LaTeX
For many years, the primary goal of LaTeX was to produce beautiful, print-ready PDF documents. However, in the digital age, being "printable" isn't enough. We must ensure our documents are accessible.
An accessible document is one that can be easily navigated and understood by people with disabilities, specifically those who use screen readers (software like JAWS, NVDA, or VoiceOver that reads text aloud). By default, standard LaTeX PDFs are often "untagged," meaning a screen reader sees a wall of characters without understanding what is a heading, what is a caption, or what is a table cell.
Creating accessible LaTeX documents involves three main pillars:
- Logical Structure: Using proper sectioning commands.
- Alternative Text: Providing descriptions for non-text elements like images.
- Tagging: Embedding metadata in the PDF so screen readers can follow the "reading order."
Setting the Foundation: Document Structure
The most important step in accessibility is using LaTeX's structural commands correctly. Screen readers rely on the document's hierarchy to allow users to jump between sections.
Best Practices for Structure
- Never skip levels: Do not use a
\subsubsectionif you haven't used a\subsectionfirst. - Use Hyperref: The
hyperrefpackage is essential. It creates a "Table of Contents" inside the PDF metadata, allowing users to navigate through bookmarks.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[hidelinks]{hyperref} % Creates clickable links and metadata
\begin{document}
\section{Introduction}
This is a high-level heading. Screen readers identify this as a level 1 heading.
\subsection{Background}
This is a nested heading. Logical nesting helps users understand the relationship between topics.
\end{document}Note: Always use the
\title,\author, and\datecommands in the preamble. When combined withhyperref, these are exported as PDF metadata, which helps screen readers identify the document immediately upon opening.
Adding Alternative Text to Images
Screen readers cannot "see" images. If you include a graph or a photo, the software will simply say "Graphic" or read the filename, which is unhelpful. You must provide Alternative Text (Alt-Text).
While standard LaTeX doesn't have a native alt attribute for images like HTML does, we can use the pdfcomment package or the newer experimental accessibility features. Currently, the most robust way to ensure accessibility in images is through the tagpdf package or by providing descriptions in the text.
Example: Using descriptions
The simplest way for a beginner to ensure an image is accessible is to ensure the Caption is descriptive or to use a hidden description.
\usepackage{graphicx}
\begin{figure}[h]
\centering
\includegraphics[width=0.5\textwidth]{revenue_chart.png}
\caption{Bar chart showing a 20\% increase in revenue from 2022 to 2023.}
% The caption serves as the primary description for the screen reader user.
\end{figure}Best Practice: If an image is purely decorative (like a divider line or a corner flourish), it should ideally be "artifacted" (hidden from screen readers). If it conveys information, that information must exist in the text or the caption.
Making Mathematics Accessible
Mathematics is where LaTeX shines, but it is also the most difficult part for screen readers. Standard PDFs turn math formulas into a series of symbols that sound like gibberish when read aloud (e.g., "$\sum$" might be read as "sigma" rather than "the sum of").
To improve this, we can use the accsupp package to provide a "Replacement String" that the screen reader will use instead of trying to interpret the symbols.
Example: Providing Text Alternatives for Math
\usepackage{accsupp}
\newcommand{\accessiblemath}[2]{%
\BeginAccSupp{ActualText={#1}}%
#2%
\EndAccSupp{}%
}
% Usage in document:
\accessiblemath{E equals m c squared}{
\begin{equation}
E = mc^2
\end{equation}
}In this example, while the sighted user sees the beautifully typeset equation, the screen reader will read the plain English "E equals m c squared."
Tables and Data Accessibility
Tables are notoriously difficult for screen readers because they are often read linearly (left to right, top to bottom) without context. If a user is in the middle of a large table, they may forget which column they are looking at.
Tips for Accessible Tables
- Keep it simple: Avoid merged cells (
\multicolumnor\multirow) whenever possible. - Define headers: Ensure the first row clearly defines the data below it.
- Use the
captionpackage: Always provide a label and caption.
\usepackage{booktabs} % For cleaner, more readable tables
\begin{table}[h]
\caption{Average Rainfall by Month}
\centering
\begin{tabular}{ll}
\toprule
\textbf{Month} & \textbf{Rainfall (mm)} \\
\midrule
January & 50 \\
February & 45 \\
March & 60 \\
\bottomrule
\end{tabular}
\end{table}The Future: Tagged PDF Project
The LaTeX team is currently working on the LaTeX Tagged PDF project, which aims to automate much of this. In the near future, adding a single line to your preamble will trigger many accessibility features automatically.
You can try the experimental "automatic tagging" by adding this to the very top of your document (even before \documentclass):
\DocumentMetadata{testphase={phase-III,math}}
\documentclass{article}
% ... rest of your documentWarning: This is an experimental feature (as of 2023/2024). It may cause conflicts with some older packages, but it represents the future of how LaTeX will handle screen readers.
Common Pitfalls to Avoid
- Using Color as the Only Identifier: Never say "the items in red are mandatory." Screen readers don't communicate color. Instead, use "the items marked with an asterisk (*) and shown in red are mandatory."
- Poor Contrast: While not strictly a screen reader issue, accessibility includes visual clarity. Ensure your text is dark enough against the background.
- Meaningless Link Text: Instead of writing
\href{url}{click here}, write\href{url}{Download the Annual Report}. Screen readers often extract a list of links, and a list of twenty "click here" links is impossible to navigate. - Using "Tabular" for Layout: Never use a table to position text on a page. Use columns or margins. Tables should only be used for data.
Final Checklist for Beginners
- Did I use
\sectionand\subsectionin the correct order? - Did I include
\usepackage{hyperref}for navigation? - Do all my images have descriptive captions?
- Did I fill out the
titleandauthorin the preamble? - Is my math clear enough, or should I provide an
AccSuppdescription for complex formulas?
