4

I am attempting to place tooltips over acronyms to show the long-form. My command \ac works for acronyms with plain text descriptions. The problem I run into is that if the acronyms contain other acronyms, eg. \gls{other} in the long-form, that part does not get expanded.

EDIT:

Another concern that I ran into is that if the description has some sort of formatting, eg. \bfseries, the tooltip contains unwanted text, I believe from the character expansion (?) of \bfseries. This makes me want to ask the question: is there a way to expand some command and keep only the plain text characters? Perhaps expand a command, and delete all cat codes except for 11 and 12? I may take a dive into explicit syntax or LuaTeX to see what this would look like.

MWE below:

\documentclass[11pt]{scrartcl}
\usepackage[xindy,style=super,nogroupskip,section=paragraph,savewrites=true,acronym]{glossaries-extra}
\makeglossaries
\usepackage{pdfcomment}

\newcommand{\SomeWords}{Hello World}

\newacronym{abc}{ABC}{Acronym just BeCause}
\newacronym{sabc}{SABC}{Special \gls{abc}. \SomeWords}

\newcommand{\ac}[1]{\pdftooltip{\gls*{#1}}{\glsentrylong{#1}}}

\begin{document}
    \ac{abc}  % tooltip is "Acronym just BeCause. Hello World"
    \ac{sabc} % tooltip is "Special abc. Hello World", I want "Special Acronym just BeCause. Hello World"
              % does not expand (?) the \gls{abc} to its long form? I am surprised that \SomeWords gets expanded however.
\end{document}
1

1 Answer 1

0

A solution that I've come up with that although doesn't quite satisfy my desire to understand the issue, can present a workaround for others. I also noticed that if the long-form of the acronym contains any formatting commands, eg. \bfseries, a lot of additional unwanted characters are produced. My simple idea is to create "exception" commands, so if I have any acronyms that contain other acronyms or formatting commands in their long-form, is to create a command called [key]ToolTipText and spell it out in plain text.

\newcommand{\GetTheToolTipText}[1]{%
  \ifcsname#1ToolTipText\endcsname%
    \csname#1ToolTipText\endcsname%
  \else%
    \glsentrylong{#1}
  \fi%
}
\newcommand{\ac}[1]{\pdftooltip{\gls*{#1}}{\GetTheToolTipText{#1}}}

In the case of sabc, simply define \sabcToolTipText in plain text how you'd like it to appear. Not idea, but a workaround for the exceptions.

You must log in to answer this question.

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