latex3 / tagpdf

Tagging support code for LaTeX
59 stars 7 forks source link

Inclusion of Special Characters in Alt Text #89

Closed michael-kruse closed 8 months ago

michael-kruse commented 8 months ago

There seems to be no way to include special characters inside of alt text for figures, and if there is a way to do this, it is not well documented. When leaving special characters without a delimiter, (expectedly) an error is thrown on compilation. When instead delimiting the special characters with a backslash, the file compiles and produces output, but the delimiter is seen as plain text in the output alt text. This is especially concerning since a comma is a special character that needs delimiting, meaning no alt text can include commas.

Details: Using RMarkdown with LaTeX to generate 508-compliant PDFs, tagged with tagpdf (testphase II) Using lualatex engine

Localized code to help reproduce bug:

(on a separate note, alt text applied to tags that are not "figure" tags seem to not get properly added. I am unable to see alt text added to a "P" tag in adobe, but I have not spent much time looking into this yet)

Let me know if you need any additional details!

davidcarlisle commented 8 months ago

You haven't provided a reproducible example but

alttext=text which includes special characters, like a comma

as always in latex key=value syntax you need

alttext={text which includes special characters, like a comma}

if the value includes a comma.

u-fischer commented 8 months ago

Please always provide a proper complete minimal example and not some snippet.

The alttext key has been renamed to alt more than a year ago. This code is under development! You should keep your system up-to-date if you want to use it.

Generally: in all arguments accepting key-value lists, you have to surround an argument which contains a comma with braces, so

\tagstructbegin{tag=Figure,alt={some text with a comma, and other stuff}}

Alternatively define a command with the text and use alt=\mycommand.

michael-kruse commented 8 months ago

Thank you for the fast reply! Sorry about not providing a minimal example, if I ever have questions in the future I will be sure to ask properly. It seems the problem was in using alttext instead of alt as the key. I'm not really sure how I missed this considering I've read the documentation for this package a couple times now.. Either way, using alt + the curly brace worked like a charm!

I also just wanted to say thank you for all of the work you've done (and continue to do) with this package. The work you are doing here is very appreciated and very needed. Seeing your name pop up in most questions I find throughout various forums makes me feel so much more confident in the direction things are going with LaTeX and 508-compliance, and gets me excited for what is to come in the future 😄