Open prowlett opened 4 years ago
plasTeX seems to have no concept of alt text for images. You can't add keyword options to LaTeX macros willy-nilly, so we'd have to define a new macro which renders to \includegraphics in latex, but has an alt
keyword option that plasTeX can use.
A \caption
inside a figure
environment is rendered as a figcaption
element, which becomes the figure's accessible text. So, the following:
\begin{figure}
\includegraphics{image.png}
\caption{An image}
\end{figure}
will be read out as "Figure 1 An image". It doesn't look like figure*
or caption*
omits the figure counter.
The code
\begin{figure}
\includegraphics{image.png}
\caption{An image}
\end{figure}
produces something like
<figure id="axxxxxxxxxx">
<p>
<img src=".../images/img-0001.jpg"/>
</p>
<figcaption>
<span class="caption_title"><b>Figure</b></span>
<span class="caption_ref"><b>1</b></span>
<span class="caption_text">An image</span>
</figcaption>
</figure>
I am not an expert, but I suspect a screenreader might read "image without alt text. Figure 1 An image", which is not ideal.
Also there is an issue here that a figure caption is not the same thing as alt text - a caption contextualises what you are seeing, an alt tag should replace seeing it.
It has nice features around course organisation, but a major draw for using coursebuilder is the idea that it eats LaTeX and produces accessible notes. Images without alt text are a major gap in this mission that I would urge you to prioritise.
Alt text has been implemented as part of c57ab7bdd2106cffc087b57ec2ba604269896095.
Here is an example using the new \alt{}
macro to add alt text to an image:
\begin{figure}
\includegraphics[width=10cm]{images/hist.pdf}
\caption{A histogram originally provided in .pdf format}
\alt{A plot titled "A histogram". The x axis is labelled "x-axis".
The y axis is labelled "Frequency". The histogram shows a peak at
a value of approximately 70.}
\end{figure}
Works brilliantly! I can use \includegraphics (including with PDF) or draw something directly in tikz and it appears in HTML with alt text. Thanks @extigy and @christianp so much, that's very helpful!
A note: The current implentation of this is with \alttext{}, not \alt{}
FYI (years later)the official LaTeX syntax is \includegraphics[alt={the alt text}]{theImage}
Ah! Let's support that, then.
@Lycanic: since LaTeX has official syntax for this now, we should add support for it to plasTeX and deprecate the \alttext
command.
For completeness, I think this is the relevant PR https://github.com/latex3/latex2e/pull/669
FWIW I still think your macro is a good idea (and more ideas are needed - see for example https://github.com/AmerMathSoc/texml/issues/55). The new LaTeX syntax is rather limited given that WCAG 1.1.1 requires text alternatives for any non-text content (and at least on the web those text alternatives can be provided in many different ways).
This is a good point. Also a lot of my \alttext{}
are on TikZ graphics that become <img>
tags but were never \includegraphics{}
commands. I was quite excited about this new format until I remembered that!
What is the approach to putting alt text on images in coursebuilder? I've seen various suggestions for how to add alt text in LaTeX online, but I'm asking what you use to do this in a way that works in coursebuilder for the web and PDF versions. Thanks.