7

I want to use acronym package for acronyms. And for that I use \ac and \acs in text and \caption or \section. However, in \caption and \section I don't want hyperlinks to the acronym table, but only in the text.

Therefore, is there a way to define new two commands based on \ac and \acs that when used do not make hyperlink, but work in the same behavior as the previous ones and includes the acronyms in the table of acronym?

Probably part of the code of acronyms.sty shall be used for that. But I do not know where to start.

cmhughes
  • 100,947
cacamailg
  • 8,405
  • 1
    I want really disable then, that way they will not appear when I use \tableofcontents (and so on), but will appear in the list of acronyms. – cacamailg Jul 26 '12 at 12:15

1 Answers1

6

You can define a ‘caption’ sibling of \acs as follows:

\protected\def\cacs{%
  \let\AC@hyperlink\@secondoftwo
  \acs
}

Full minimal example:

\documentclass{article}

\usepackage{acronym}

\usepackage{hyperref}

\makeatletter

\protected\def\cacs{%
  \let\AC@hyperlink\@secondoftwo
  \acs
}

\makeatother

\AtBeginDocument{%
  \pdfstringdefDisableCommands{%
    \let\cacs\acs
  }%
}

\begin{document}

\tableofcontents

\section{Acronyms}

\begin{acronym}
  \acro{AA}{An Acronym}
\end{acronym}

\section{\cacs{AA}}

\end{document}

Analogously, you could define a ‘caption’ sibling of \ac. But, obviously, it’s advisable to use the context-independent commands \acs, \acl etc. in captions and section headings.

mhp
  • 8,692