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 Answer 1

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}
0

You must log in to answer this question.

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