[Tex/LaTex] Is there “screen reader” software or a built in method that supports LaTeX equations

accessibilityequationsmath-mode

I was asked a question during a LaTeX how-to session which I did not have a good answer for. The person asking is interested in accessibility software which is able to read LaTeX formatted equations in a meaningful way.

Example:

\documentclass{minimal}
\begin{document}
    \begin{equation}
        x^2 + y^2 = z^2
    \end{equation}
\end{document}

When the document is read by the Okular screenreader, it sounds like:

x two plus y two equals z two

but what we really are showing should sound like:

x squared plus y squared equals z squared

Such accessibility options are available for other equation editors, such as MathJax. This question was asked before, but closed due to unclear questioning. So allow me to produce specific questions:

Is there:

  1. A PDF reader which interprets mathematical conventions such as superscripts and symbols in a mathematically meaningful way?
  2. An external tool which reads equations out loud directly from the LaTeX style?
  3. A tool within LaTeX which can add comments to a PDF versions of the document which are invisible, yet listenable? (similar to alt text in images)

Best Answer

Using my new tokcycle package (https://www.ctan.org/pkg/tokcycle )...I find the result pleasingly legible, when read audibly via the Adobe Reader.

This MWE relies on you having a new enough LaTeX installation to support the new \expanded primitive. If not, you can, for the time being, change the \tcremap[x] in the \speakifytext definition to \tcremap[1] and also change the \noexpand\pauseafter (2 instances) to \pauseafter. The net effect of this change is that the token register \cytoks that holds the transformed text, will contain things like \tcmapto^ rather than , raised to the power. That is to say, the transformation occurs when the token register is typeset, rather than before being placed into the token register.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[margin=1in]{geometry}
\usepackage{tokcycle,amsmath}
\tokcycleenvironment\speakifytext
  {\tcremap[x]{##1}}
  {\processtoks{##1}}
  {\tcremap[1]{##1}}
  {\addcytoks{##1}}
\newcommand*\tcmapto[3][\noexpand\pauseafter]{%
  \expandafter\def\csname tcmapto\string#2\endcsname{\text{#3 }#1}}
\newcommand*\tcmaptomacro[3][\noexpand\pauseafter]{%
  \expandafter\def\csname tcmapto\string#2\endcsname{#3#1}}
\newcommand*\tcremap[2][1]{\ifcsname tcmapto\string#2\endcsname
  \addcytoks[#1]{\csname tcmapto\string#2\endcsname}\else\addcytoks{#2}\fi}
\newcommand\pauseafter[1]{\tctestifcatnx#1\relax{#1}{#1,}}
\tcmapto[] ({, left paren,}
\tcmapto[] ){, right paren ,}
\tcmapto   ^{, raised to the power}
\tcmapto   _{, sub}
\tcmaptomacro[] \frac\readfrac
\newcommand\readfrac[2]{\text{, the fraction, } #1 \text{, divided by, }#2%
  \text{, end fraction, }}
\begin{document}
\speakifytext
\section{Making \LaTeX{} Math Audibly Legible}
We use the new tokcycle package to transform math symbols into spoken text.
See if you agree.
    \begin{equation}
       x_i^2 + y^2 = (z^2 + 1)
    \end{equation}
Or this one:
    \begin{equation}
       Z = \frac{x+1}{2}
    \end{equation}
\endspeakifytext
\end{document}

enter image description here

Just remove the two lines, \speakifytext and \endspeakifytext, and recover the original output.

enter image description here

See also this question, which I find related: In which way have fake spaces made it to actual use?