2

I need to add alt text to all my figures in latex. This is for the purpose of writing a book chapter.I tried using \Description command which did not work. I also tried using alt text inside \includegraphics. Can anyone help me out to write alt text in latex. A sample script which I have tried is given below:

    \documentclass[runningheads,a4paper]{llncs}
    \usepackage{graphicx}
    \usepackage{caption}
    \usepackage{subcaption}
    \begin{figure}[h]
    \centering
    \includegraphics[alt={Alternative text},width=\linewidth]{Figures/myfig.pdf}
    % \alt{Alt text}
    \caption{My caption}
    \label{fig1}
    \end{figure}
Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
  • 2
    What should the alt text do? – mickep Feb 19 '24 at 15:29
  • I believe alt= is the correct thing, and should work on an updated TeX. But that alt text is not visible, and gets read by a screen reader. Is it possible you think it didn't work because you didn't see it? In which case, to echo mickep, what are you expecting to have happen? – Teepeemm Feb 19 '24 at 15:37
  • 3
    Are you looking for https://tex.stackexchange.com/a/703340/36296 ? – samcarter_is_at_topanswers.xyz Feb 19 '24 at 15:38
  • @mickep Alt text is an accessibility aid used by screen readers. – LaTeXereXeTaL Feb 19 '24 at 18:27
  • 1
    @LaTeXereXeTaL screen readers reading html... or tagged pdf but not classic untagged pdf, as such alt= does nothing by default in latex but is used by tagpdf when creating tagged pdf and used (originally) by tex4ht when creating html – David Carlisle Feb 19 '24 at 19:39
  • 1
    @Teepeemm "work" for some definition of work. It is defined in recent graphicx releases but does nothing. – David Carlisle Feb 19 '24 at 19:40
  • @mickep Alt text is a short text description that can be digitally attached to figures or images to convey to readers the nature or contents of the image. It is used by systems such as pronouncing screen readers to make the object accessible to people that cannot read or see the object due to a visual impairment or print disability. – Abhiram B R Feb 20 '24 at 02:02
  • @Teepeemm Yes, it is not visibile in the pdf. I was expecting the alt text to pop up when a cursor is placed on the image. – Abhiram B R Feb 20 '24 at 02:08
  • @AbhiramBR What you describe is a 'tool tip' in PDF terms. With a tagged PDF, there are alt keys but these don't just 'appear', they are used by e.g. screen readers when speaking a PDF. – Joseph Wright Feb 20 '24 at 07:26

1 Answers1

1

Welcome.

A general remark: Just in case you need some material on LaTeX, here are some.

Following samCs hint How do I define alt text on images in tagpdf? the correct syntax should be, adjusted a little bit:

\DocumentMetadata{testphase=phase-III}
\documentclass[runningheads,a4paper]{llncs}
\usepackage{graphicx}
%\usepackage{caption}
%\usepackage{subcaption}% not needed in this example

\begin{document} \begin{figure}[h] \centering \includegraphics[alt={Alternative text},width=\textwidth]{example-image} % \alt{Alt text} \caption{My caption} \label{fig1} \end{figure} \end{document}

However, I can't test it, as my installation may be incomplete (or I entered a stupid mistake too early in the morning), concluding from compile errors:

\DocumentMetadata{testphase=phase-III}
\documentclass[a4paper]{article}
%%\documentclass[runningheads,a4paper]{llncs}
%\usepackage{graphicx}
%%\usepackage{caption}
%%\usepackage{subcaption}

\begin{document} hi % \begin{figure}[h] % \centering % \includegraphics[alt={Alternative text},width=\textwidth]{example-image} % % \alt{Alt text} % \caption{My caption} % \label{fig1} % \end{figure} \end{document}

errors

However, as Ulrike explains here it appears to me that what you want is just in the process of being implemented.

So in worst case you may have to drop the alt-text feature for now.

MS-SPO
  • 11,519
  • Have you got the latest expl3, etc.? For me, there is one error, related to footnotes, and I do get a PDF out – Joseph Wright Feb 20 '24 at 07:16
  • Probably not. Will run an update later. Thanks for the hint. – MS-SPO Feb 20 '24 at 07:19
  • @JosephWright, even after updating packages this one seems to be missing, at least: l3bitset.sty . No idea, how to add theat via MiKTeX Console. – MS-SPO Feb 20 '24 at 08:08
  • l3bistset was integrated into the expl3 core in the 2023-12-08 release - have you got an up-to-date system across the board? Usual MiKTeX advice applies: update both as 'you' and as Admin. – Joseph Wright Feb 20 '24 at 08:11
  • @JosephWright, thank you. Well, I'm the only and local user. For the time being I'll take it as it is ;-) Thanks again – MS-SPO Feb 20 '24 at 08:24