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}
9
  • 2
    What should the alt text do?
    – mickep
    Commented Feb 19 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
    Commented Feb 19 at 15:37
  • 3
    Are you looking for tex.stackexchange.com/a/703340/36296 ? Commented Feb 19 at 15:38
  • 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 Commented Feb 19 at 19:39
  • 1
    @Teepeemm "work" for some definition of work. It is defined in recent graphicx releases but does nothing. Commented Feb 19 at 19:40

1 Answer 1

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.

5
  • 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
    Commented Feb 20 at 7:16
  • Probably not. Will run an update later. Thanks for the hint.
    – MS-SPO
    Commented Feb 20 at 7: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
    Commented Feb 20 at 8: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
    Commented Feb 20 at 8: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
    Commented Feb 20 at 8:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .