On Sat, 25 Jul 2026 at 13:19, Gavin Smith <[email protected]> wrote:

> On Sat, Jul 25, 2026 at 08:58:35AM +0100, David Carlisle wrote:
> > Sorry, replying to myself
> >
> > \makeatletter
> > \providecommand\KV@Gin@alt{}
> > \makeatother
> >
> > would be preferable to
> >
> > \makeatletter
> > \define@key{Gin}{alt}{}
> > \makeatother
> >
> > so that it only does something if alt processing is not already defined
> > (otherwise the user would need to remove this if adding \DeclareMetada)
> >
> > David
>
> Thanks, it should be no problem to use this then and output the alt
> information without any customization variable or option needing to be
> added to texi2any.
>
> I looked at the documentation of the "graphicx" package (link at
> https://ctan.org/pkg/graphicx?lang=en) and the manual does not appear to
> contain the strings "providecommand" or "KV" anywhere.
>

\providecommand is a core latex definition command (that does nothing if
the command is defined, otherwise is like \newcommand) see page 14 of

https://mirror.ox.ac.uk/sites/ctan.org/macros/latex/base/usrguide-historic.pdf

(or texdoc usrguide-historic  in a local tex installation)

the \KV@Gin@alt macro is as you suggest the internal macro holding the
definition of a defined alt key for the graphics package. "Gin" = "Graphics
Inclusion" (although I'm not sure I ever wrote down anywhere it's just a
unique prefix for the \includegraphics internals)


The reason for patching at that level is that in current latex the default
definition of the alt key is no-op but once tagging is enabled it is given
a real definition, so here you need to "time" adding the no-op definition
for old latex in a way that doesn't undo that patching. It is of course
relying on internal definitions but as it is only needed at all for
historic latex releases the internals are by definition fixed...



> It would be good if we could reference some documentation explaining
> why we use these commands.  This could help people in the future coming
> back to this code if they are wondering why it works.
>
> (Rant: In my experience I do not like seeing comments in source code like
> "Information from David Carlisle, bug-texinfo 2026-07-26" - with people's
> names.  (We attribute in git commit messages and ChangeLog entries, but
> reading these should be considered optional for future readers of the
> code.)  It doesn't actually add much useful information and actually makes
> the code harder to modify - future hackers may think "If I change this am
> I deleting some important historical information, or making the comment
> incorrect?")
>
> I found references online to a "keyval" package.  Would a comment like
> the following be accurate?
>

yes keyval was written at same time as graphicx and distributed with it to
add
key=value parsing for latex2e, so it's part of the core latex release.


>
>   "In the 'keyval' package, in "Gin" family, set "alt" to "", if not
> already
>   set.  This is used to support output of the "alt" attribute for images in
>   older versions of graphicx."
>

yes exactly. Or more explicitly you could say

"This is used to provide a default no-ooperation definition of the alt key,
so that it does not generate an error in older versions of graphicx"


Incidentally rather than explicitly define \KV@Gin@alt  you could use the
form Ulrike suggested which is

\usepackage{keyval}
\makeatletter
\define@key{alt}{}
\makeatother
\usepackage{graphicx}

That similarly defines alt to do nothing without doing it after loading
graphicx (which would undo the active definition for tagging case)

But I think I'd use my version, with your description.

David




> That should give people enough pointers to research what keyval is and
> how graphicx uses it.
>

Reply via email to