83

First: I know that this has been asked before:

There has been a couple of questions closed about accessibility and LaTeX since these questions.

I am also aware of Ross More's paper from 2009 and his presentation from 2010.


The question is still: Is possible to make PDF files that are accessible using LaTeX?

I understand that one can disagree on what accessible means. Different countries/regions will have different (legal) definitions. I am interested in how accessibility is understood in different countries, but for this question my main concern is the US context. Here I believe that Americans with Disabilities Act of 1990 (ADA)/Section 508 is what defines what accessible content is. More concretely, I am thinking being able to read the PDF file using a screen reader (like JAWS). Concretely the desire is to create pdf files that can be used in a class setting at a university where federal law requires that content is accessible. This is a real concern (see for example this).

The standard way to check whether a pdf file is accessible seems to to use Adobe Pro's accessibility checker. This can, for example, reveal whether a document is tagged. But it also seems like one needs to actually test it with a screen reader to make sure that everything is as desired.

Right now using pdfLaTeX and checking with Adobe Pro's accessibility checker I in general get two errors:

  • the page lacks a language specification and
  • there are no tags.

I am hoping that there has been some development over the last two years on this. Even though I use LaTeX frequently, I still consider myself a casual user. Answers in the past seem to point out that there are ways to do this, but I haven't been able to find a user friendly guide written in English. I have checked some document where text is read by a screen reader, but the problem seems to be the mathematics content.

From what I can understand it isn't possible to create a truly accessible PDF file. If this is true, I am wondering:

Question: What is the current best practice is to create accessible PDF files? Are there are user friendly guides available?

I am also aware of this answer (from 08/2014):

https://tex.stackexchange.com/a/194226/5870

Here it is pointed out in the comments that the created PDF file doesn't pass the accessibility checker in Adobe Pro. Also, one actually has to edit the .sty file that is used. (I still think it is a great answer!) Also, this file might have been created for a German context (but might still have international use?)

17
  • 1
    There is all accsupp. One issue I see is that stuff has been created without clear licensing or distributed in a way which undermines further unclear licensing, and never even makes it to CTAN let alone into TeX distros. A lot of work is being wasted and, in the meantime, Word documents remain the gold standard in terms of accessibility. (That's what we're advised to provide, although I don't. But if I have a student who needs it, I'll have to.)
    – cfr
    Aug 15, 2015 at 21:46
  • 3
    I typically take a different approach: create (or convert to) structured content; this allows you to create a tex file with associated beautiful PDF, together with screen-reader accessible HTML/ePUB. Possible conversion tools from tex to XML include plastex
    – cmhughes
    Aug 16, 2015 at 8:01
  • 3
    ross moore presented a further paper on this topic at tug 2015. also, olaf drümmer talked about the standardization of pdf/ua. both talks are now on line. there is still manual adjustment needed to provide all necessary metadata. Aug 16, 2015 at 17:38
  • 2
    See ac­cess PDF fea­tures topic on CTAN. May be too obvious, but probably the best solution at least for a highly formated PDF is attach a plain text version that can be easily reproduced by some text-to-speech system as festival or even a script for lauch this program easily.
    – Fran
    Aug 20, 2015 at 19:54
  • 1
    Language is an easy fix with \usepackage[pdflang={en-US},pdftex]{hyperref} but the tags are harder.
    – ayman
    Jan 5, 2016 at 4:07

3 Answers 3

19
+50

Accessibility requires a number of settings in the PDF. Some of them are rather easy to implement (e.g. that a title and the language should be set) other are more difficult. The most difficult part is the requirement that the PDF should be "tagged", this means that it contains structure informations.

The LaTeX Team has started a multi-year project "Tagged PDF" to allow LaTeX to create such tagged PDF. Details of the project can be found at https://www.latex-project.org/news/2020/11/30/tagged-pdf-FS-study/

The current state of the project is that paragraphs and links can be tagged automatically. This requires a current LaTeX, a current pdfmanagement-testphase and the current version of the experimental research package tagpdf (and currently still lualatex):

\RequirePackage{pdfmanagement-testphase}
\DeclareDocumentMetadata{uncompress,pdfversion=2.0}

\documentclass{book}
\usepackage{tagpdf}
\tagpdfsetup{activate,paratagging,interwordspace}
\usepackage{hyperref,lipsum}
\begin{document}

Tagged project: \url{https://www.latex-project.org/news/2020/11/30/tagged-pdf-FS-study/}

\lipsum[1-4]

\end{document}

The structure of the PDF (compile twice) can be inspected at https://ngpdf.com.

Other structure elements can be tagged too, but this has to be done manually (or by patching commands). The next task will be to add automatic tagging to basic structures like sections and lists.

The coming TUG conference will have a few talks about the progress of the project https://www.tug.org/tug2021/index.html

Update April 2023

with the latest latex-dev release more tagging related test code has been released https://www.latex-project.org/news/2023/03/13/latex-dev-1/. So now this here can be tagged

\DocumentMetadata{testphase=phase-III,testphase=math}
\documentclass{article}

\begin{document}

\tableofcontents 
\section{section}
\subsection{Subsection}%

some text with a \footnote{a footnote}

\begin{enumerate}
\item a list
 \begin{itemize}
  \item more list
 \end{itemize}
\end{enumerate}

\begin{verbatim}
some verbatim
some verbatim
\end{verbatim}

inline math $a=b$

display math
\begin{equation}
x=y
\end{equation}
\end{document}      

The tagging of graphics is under development (there is already branch in the github), and floats are handled soon too. With the june release it should be possible to tag most standard commands.

Update February 2024

With the newest LaTeX release in june and november 2023 support for graphics, floats and support for basic tables has been added. The newest LaTeX-dev in february 2024 corrected various issues and added support for marginpar (that is loaded automatically in phase-III), for \maketitle (this must currently be loaded explicitly as title module). The math module has been reworked and extended and now contains code to attach semi-automatically mathml representations of equations. It now also handles the amsmath \text command (but some other commands which internally use \mathchoice are still open and can led to faulty structures). Some examples that has been tagged with the new code are at https://github.com/latex3/tagging-project/discussions/56.

In summary that means that (with the exception of the tabbing environment) almost everything described in the Leslie Lamport manual can now be tagged.

Documentations about the various modules can be found with texdoc -l latex-lab. They describe options but also restrictions and open problems.

We created a special repository for issues, discussions and feedback: https://github.com/latex3/tagging-project

4
  • 1
    This is great news. Thanks for the update.
    – RTS
    Jul 22, 2021 at 15:17
  • Any updates on this topic? Apr 27, 2023 at 14:50
  • @NajibIdrissi I added an update. Apr 27, 2023 at 15:09
  • Awesome, thanks for the quick response! Apr 27, 2023 at 15:24
14

It seems the answer was hiding in a footnote of this paper on making ADA compliant PDFs. See this project!

UPDATE: Having spent time attempting to use this tool in conjunction with a complex custom class, I want to temper expectations. While the accessibility.sty package is a useful tool for simple documents, it is incompatible with multiple packages and commands. An improved version of the package, called accessibility_meta, is available here.

Even the updated package is not perfect. For example neither work with the package "fancyhdr" nor with simple commands like "\setlist".

UPDATE 2: The accessibility.sty package is now on CTAN, but still has issues.

2
  • 2
    I'm the maintainer of accessibility and had taken it over to get it on to CTAN. For the reasons you identified in your other answer (it breaks every time another package or LaTeX changes) I am going to withdraw it from CTAN. I can no longer recommend using it! Jun 25, 2020 at 11:25
  • 1
    This accessibility package never really worked. It is obsolete as of today. Consider deleting the answer.
    – tanGIS
    Aug 11, 2022 at 7:17
10

This answer presents what seems to me the most efficient way to improve the accessibility of LaTeX documents. Unfortunately, it requires the use of R and Adobe Acrobat. My previous approach involved using only a modified version of Babett Schaltz’s accessibility.sty. (Schaltz created it as part of her 2007 PhD thesis in Germany.) Despite making hundreds of modifications to the original .sty file, the arrival of new incompatibilities with every MikTeX update led me to switch to my current approach.

The first step involves knitting an RMarkdown file, however adding the following commands to the header of your standard LaTeX document will allow you to follow along from step two.

\RequirePackage{accsupp}
\RequirePackage{pdfcomment}
\newcommand{\AccTool}[2]{\BeginAccSupp{method=pdfstringdef,unicode,Alt={{#1}}}\pdftooltip{{#2}}{{#1}}\EndAccSupp{}}

Step 1: Generate TeX Output Using RMarkdown

Click this text to access the example Rmd file, or download all of the content by clicking here. The first difference between this file and a plain Rmd is the YAML. The fontsize command does what you might expect. The keep_tex command ensures we have access to the intermediate files for step two. Finally, the header_includes command adds required LaTeX code to the header.

fontsize: 11pt
output:
  pdf_document:   
    keep_tex: yes
header-includes:
   - \RequirePackage{accsupp}
   - \RequirePackage{pdfcomment}
   - \newcommand{\AccTool}[2]{\BeginAccSupp{method=pdfstringdef,unicode,Alt={{#1}}}\pdftooltip{{#2}}{{#1}}\EndAccSupp{}}

Step 2: Make Modifications to the TeX

This file will modify the TeX output from step one. It uses R's gsub command to add tooltips and accessibility tags to the document. One can design clever regular expressions to capture caption text for the accessibility tags. To learn regular expressions visit this website. I used a ~100-line variation of this file to add more than 1,000 tags to this 218-page document.

The last line of the script uses the texi2pdf command to generate a PDF file.

Step 3: Run Adobe Acrobat Scripts

The final step requires Adobe Acrobat Pro. Open the PDF file generated in step two and perform the accessibilty actions defined in this Acrobat script. You can install the scripts by simply opening the accessibility.sequ file if Acrobat is installed. You can access the script under Tools-->Action Wizard. For those managing multiple documents, Acrobat offers simple batch processing which you can apply to the accessibility.sequ commands.

Results

After performing all three steps, your document will be far closer to 508 compliance than the original knitr ouput. Among the four issues remaining after processing, logical reading order and color contrast always require manual judgement, Title is fixed with two clicks, and the final Headings-Nesting rule can be skipped according to Adobe. Specifically they say, "The order of headings is not required under WCAG, and is only an advisory technique."

accessibility checks

Notice the figure's alternative text tooltip: enter image description here

2
  • Back to the R requirement, it seems that the first two steps are really just to get the appropriate TeX code in place. Is that correct? Could someone hardcode their TeX file so that step 3 would work?
    – Teepeemm
    Apr 17, 2019 at 20:47
  • Absolutely correct.
    – RTS
    Apr 24, 2019 at 7:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .