I would like to make a glossary of a text where sometimes operations are described. One of this is the "overline" operation.
In the text, I would like to write:
\gls{Overline}[u]
such that only the bar created by the \overline command is linked to the glossary, and not the argument under it (here u).
Picture bellow shows the kind of result I want (links in red color):
The following code is largely inspired by Symbols with optional parameter in glossaries with \newglossary issue:
\documentclass{article}
\usepackage[hidelinks, colorlinks=true]{hyperref}
\usepackage[abbreviations]{glossaries-extra}
\makeglossaries
\glsnoexpandfields
\newcommand{\glsdefaultarg}{i}
\newcommand{\glsarg}{\glsdefaultarg}
\newglossaryentry{Overline}{
category=arg,% requires an argument
name=\ensuremath{\overline{\glsdefaultarg}},
text=\ensuremath{\overline{\glsarg}},
description={Overline description}
}
% modify the entry's format
\preto\glsentryfmt{%
\glsifcategory{\glslabel}{arg}% if category set to "arg"
{%
\ifdefempty\glsinsert
{\let\glsarg\glsdefaultarg}%
{%
\let\glsarg\glsinsert
\let\glsinsert\empty
}%
}%
{}%
}
\begin{document}
(\gls{Overline})
\phantom{}
(\gls{Overline}[a])
\phantom{}
(\gls{Overline}[(u, v)])
\phantom{}
(\gls{Overline}[f])
\phantom{}
(\gls{Overline})
\printglossaries
\end{document}
It outputs this:
As you can see, both the bar produced by \overline and the text under it are linked to the glossary (in red thanks to hyperref package).
Note that the printed glossary is correct.
The key idea is perhaps to create a macro that simulates \overline result (see with tikz here: a bolder \overline), and customise the glossary format in the text. But I don't really know how to do this.
Thank you for reading me, Have a nice day



\Overlinecommand, it is necessary to call\textbefore. e.g.L_{\text{\Overline{f}}}– vepain Oct 17 '22 at 17:22