3

Consider the following minimal example:

\documentclass{article}

\usepackage[acronym, shortcuts]{glossaries}
\makeglossaries

\newcommand{\abbr}[1]{\underline{#1}}
\newacronym{snr}{SNR}{\abbr{s}ignal-to-\abbr{n}oise \abbr{r}atio}

\begin{document}
    This: \gls{snr} looks as desired, but \acl{snr} doesn't.
\end{document}

I want the underlining to appear on the first use of an acronym (i.e. for the "full" version) and when I print the glossary (i.e. in the "description") but no underlining for the "long" version when I use \acl. My main problem is that I don't know how to toggle the \abbr command such that it does essentially nothing. I tried using something like

\newcommand{\myacl}[1]{
    \renewcommand{\abbr}[1]{##1}            
    \acl{#1}
} 

but that doesn't work. Any suggestions?

1

Possibly not the most elegant solution, but it seems to work. Save the original meaning of \acl, then redefine the command so that it disables \@@underline inside a group and then calls its own original meaning.

\documentclass{article}

\usepackage[acronym,shortcuts]{glossaries}
\makeglossaries

\newcommand{\abbr}[1]{\underline{#1}}

\makeatletter
\let\aclOLD=\acl
\renewcommand{\acl}[1]{%
  \begingroup    
  \let\@@underline=\relax
  \aclOLD{#1}%
  \endgroup
}
\makeatother

\newacronym{snr}{SNR}{\abbr{s}ignal-to-\abbr{n}oise \abbr{r}atio}

\begin{document}

This: \gls{snr} looks as desired, and this: \acl{snr} too.

And also the printed glossary:

\printglossaries

\end{document}
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.