X Close

Digital Education team blog


Ideas and reflections from UCL's Digital Education team


Accessible documents from LaTeX

By Jim R Tyson, on 22 July 2020

Note: in this piece, many of the specific LaTeX examples are taken from package vignettes or documentation.  All packages mentioned have CTAN links.

ISD has published good general guidance on producing accessible materials on its Accessibility Fundamentals pages, with links to a host of useful resources.

While it is relatively straightforward to follow the guidelines and meet the standards set for users of Microsoft Office and for web developers, it is still not clear to many of us LaTeX (and I include markdown) users what we should and can (and maybe cannot) do.

I want to make a few points about the what, and then outline a few essential hows.

There are three aims here:

  1. get as close as possible to producing ‘tagged PDF’ or PDF/UA documents using LaTeX;
  2. produce HTML from LaTeX for screenreader software;
  3. produce Microsoft Word from LaTeX for consumers who need to modify a document themselves for accessibility purposes.

These aims are met by using the LaTeX package accessibility and the open source document conversion utility pandoc.

The package accessibility is found on this CTAN page.  To produced structured, tagged PDF include

\usepackage[[tagged, highstructure]]{accessibility}

in the document preamble.

I am not adressing using Beamer here: the same general considerations apply and ordinary LaTeX techniques can be used. Beamer cannot currently be used with the accessibility package mentioned above. To add alternative text to a Beamer presentation you can use the package pdfcomment from this CTAN archive page. At the moment, I can offer no good solution for dealing with existing Beamer presentations, but ISD is looking into what might be doable, including working on the compatibility of the accessibility package and Beamer. I am now using markdown to produce html presentations rather than PDF.

Before I get into specifics, I want to emphasize that where possible, we should try to provide people with documents that they can modify to suit their needs and that therefore in many cases a Microsoft Office or HTML document is more usefully accessible than a PDF. Pandoc makes conversion from LaTeX to HTML very simple and you can use LaTeX mathematics in your documents to be converted to HTML with either MathML or Mathjax options.


LaTeX users producing text documents are probably already covering the need for clearly structured text with headings by using the \section{} family of commands. It is worth considering use the package hyperref so that you can create clickable cross-references in your documents and a clickable table of contents. Screenreader users will find hyperlinked sections and a clickable table of contents very useful.  Hyperref can also take care of the language metadata of your PDF. Programs that access your PDF should be able to determine the language (or main language) of the document.  One way to do this is to include this hyperref command in the preamble (after calling the package hyperref):


Using a sans serif font, like computer modern sans serif will help make your document easier to read. LaTeX users who are typesetting mathematics should note that what research has been published has not – to my knowledge – addressed the issue of font choice for mathematics (or logic, or linguistics, chemistry and so on). Just as important is to use a good size for text. I try to use 12pt body text and 14pt and 16pt headers. The code to change font is as follows and should be in your preamble


You can use the package setspace to change linespacing in a document to 1.5, with the command


Many readers benefit from slightly wider than normal margins.  The default margins for LaTeX documents are already quite generous leading to a line-scan length that is comfortable for most readers.  If you do wish to change the margins, you should use the package geometry from this CTAN archive. There are a number of ways to use geometry.  You can use it with options in your preamble like this:



\usepackage[total={6.5in,8.75in},top=1.2in, left=0.9in, includefoot]{geometry}

Or you can use the command \geometry{} in your preamble like this:

\geometry{a4paper, margin=2in}

Use bold \textbf{} for emphasis and avoid italic. If you wish to modify an existing document that uses \emph{} (which we have conscientiously preferred for decades) you can include the following code

    \@nomath\em \if b\expandafter\@car\f@series\@nil
    \normalfont \else \bfseries \fi}

in the preamble of your document to change the default appearance of emphasis.

You can use the package xcolor available from this TeX archive page and command \pagecolor{Ivory} (for example) to change the background colour of a PDF for electronic use.


Make your hyperlinks clearly distinguishable from text; make them meaningful (don’t use the URL itself or text like ‘click here’; make sure that any colour contrast complies with the guidelines on this WCAG colour contrast guidance page.) If your document is likely to be disseminated in print form, then it is useful to add a short and easily typable URL for print format readers, eg https://tinyurl.com/contrastguidance.

To get a properly presented URL use code like this:

\href{http://www.ucl.ac.uk/isd}{ISD home page.}

To control the colours used with hyperlinks you can include something like the following in your preamble after calling the hyperref package:


Images and tables

The package accessibility mentioned earlier, provides a LaTeX command \alt{} which can be used to add alternative text in any float environment.  Unfortunately \alt{} from package accessibility cannot be used with the Beamer presenation package.

While good captioning for images and tables will enhance accessibility, where necessary alternative text should describe not just what data is in a table for example EU GDP by Country 2010 to 2018 but what its relevance is : EU GDP by Country 2018 to 2020 showing the trend of reduced growth over time. The reader may choose to skip the data table sometimes if the alternative text is clear enough. Also be sure to use \lable{} and \ref{} to enable screenreader software to quickly locate relevant data or images.

If you use images which are essentially decorative, then use \alt{} to let the screenreader software know that.

Mathematical content

LaTeX source code including mathematical content can produce screenreader friendly HTML via pandoc. The best result with most modern browsers (including Edge, Safari, Chrome and Firefox) is achieved using the MathJax option on conversion. The instructions to do this are on the pandoc demo page. In all examples so far tested (and we will test more, and more fully) the mathematical content was read semantically rather than typographically so that a fraction is read “fraction with denominator X and numerator y” (with some minor variation, ie sometimes reading “ratio” rather than “fraction”).


Matthew Towers has written a useful page about accessibility and pdf files, although it has been overtaken by events with respect to useful LaTeX packages.

The TeX User Group (tug) web page on PDF accessibility and PDF standards is unfortunately of largely historical interest.

Leave a Reply