Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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}
share|improve this answer
    
The solution works! Thank you! –  Christian Jun 5 '11 at 12:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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