Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image descriptions for SVGs (\tikzpictures) #2165

Open
rzach opened this issue Jul 24, 2023 · 5 comments
Open

image descriptions for SVGs (\tikzpictures) #2165

rzach opened this issue Jul 24, 2023 · 5 comments

Comments

@rzach
Copy link

rzach commented Jul 24, 2023

Issue #1452 added support for alt attributes for img tags produced by \includegraphics. It looks like no similar mechanism exists for images produced with \tikzpicture (which are turned into inline SVG).

@dginev
Copy link
Collaborator

dginev commented Jul 25, 2023

Interesting observation, @rzach . I believe we followed the lead of the LaTeX team for the alt support, who added the key to the \includegraphics macro. Is there a similar development for the native \tikzpicture?

I don't know the answer, and maybe this extra information can be requested from the pgf-tikz project?

I am finding a similar request for htlatex's {tikzpicture}, but that doesn't really indicate if this has become native since...

@dginev dginev added this to the LaTeXML-0.9 milestone Jul 25, 2023
@rzach
Copy link
Author

rzach commented Jul 25, 2023

If I understand the spec correctly, <svg> doesn't have an alt attribute, but rather you put title and/or description inside the <svg> between <title>...</title> and <desc>...</desc> tags. Since you don't know if latexml will generate inline SVGs or write to an image file or whatnot, I suppose it's harder to decide how to implement.

Perhaps the easiest way to do this is to provide something in latexml.sty so you can insert <title> and <desc> into the SVG code (\lxSvgTitle, \lxSvgDesc, or something more general that adds raw XML?)

[The way I get around it now is to use features provided by https://github.com/vlmantova/bookml: Surround the tikzpicture with \begin{bmlimage}...\end{bmlimage}. BookML then converts the picture to SVG by running it through LaTeX and converting the DVI to an SVG file which is then included using <img>. And you can set the alt tag on that image using \bmlDescription{...} right after \end{bmlimage}. That works well enough but the images generated aren't optimal--for one, everything is in Computer Modern. But if LaTeXML had an option to write the SVG to a file instead of inlining it (which I think is issue #2144?), and a way to provide the ALT tag on the resulting <img>, ...]

@dginev
Copy link
Collaborator

dginev commented Jul 25, 2023

Right, sure. I am not that concerned about passing the information into the SVG, various nice accessibility guides exist to that end, and it is relatively easy to accommodate the different approaches in latexml.

What is less certain - and I am fishing for - is how to build an authoring solution supported by the official tikz package (the way alt is now an official \includegraphics key in graphicx.sty), so that the same LaTeX source can be converted with any of latexml/tex4ht/pandoc/plastex/tralics/... without reinventing the macro dialect inside each conversion tool.

The description has to be provided by the author of the figure, so that's a main prerequisite here, before we start fleshing out latexml implementation details.

@rzach
Copy link
Author

rzach commented Jul 25, 2023

This doesn't address the issue you raise (of having a way to provide title and description in the tikzpicture using some mechanism provided by TikZ directly), but another option would be to provide an environment in latexml.sty that can wrap things in a div with a ARIA attributes. Then authors could produce an inline SVG (or other graphic with with even just styled boxes), wrap it in a <div aria-hidden=true>, and wrap the whole thing in <div aria-label="...">...</div>. (The aria-hidden div might be necessary to prevent AT from reading out text embedded in the SVG.)

@brucemiller
Copy link
Owner

Knowing that the LaTeX3 team is actively interested in this topic, I'm hesitant to jump ahead and start adding latexml-specific (and likely eventually incompatible) markup to supply the descriptions. We might assume that they'll continue on with the convention of adding alt keywords (an unfortunate name, imho) to anything that takes keyvals . We could then add alts likewise and propagate them to whatever form is required in html/svg/whatever. Seems a risky investment of time at this point, however.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants