# Is it possible to automatically add an index entry each time an acronym/glossaries command is used in the document? [duplicate]

Possible Duplicate:
Automatically index acronyms

I am using glossaries package for acronyms (\usepackage[acronym]{glossaries}). I have a separate .tex file for a list of \newacronym{key}{label}{description} and for a list of \newglossaryentry{key}{name=,description=,type=}. I have used the necessary command for generating index such as \usepackage{makeidx}, \makeindex, \printindex.

I want all the list of acronyms to appear in the index. But i don't want to use the command \index{} in the document every time where i use \acs or \acf or \gls or etc, which also looks ugly full of commands. Can anybody help/suggest me how to generate index automatically every time i use the command of acronyms or glossary in the document without writing the command \index{}?

-

## marked as duplicate by tohecz, Martin Schröder, Marco Daniel, Tom Bombadil, diabonasAug 24 '12 at 18:03

Probably this can inspire you: tex.stackexchange.com/a/62228/10898 –  azetina Jul 6 '12 at 14:58
Welcome to TeX.SX! Would you please be more specific about what should go in the index? Just the acronym or also its extended form? Each occurrence or just the first? –  egreg Jul 6 '12 at 15:04
Lets say, we just put the abbreviation from the acronyms in the index. –  Shyam Jul 6 '12 at 15:11
Related: Automatically index acronyms –  cgnieder Jul 6 '12 at 15:14
@tohecz The linked question is about the acronym package, not glossaries. –  egreg Jul 12 '12 at 14:39

Here's a first attempt:

\documentclass{article}
\usepackage[acronym,shortcuts]{glossaries}

\usepackage{etoolbox}
\makeatletter
\apptocmd{\@gls@}{\shyam@index{#2}}{}{}
\def\shyam@index#1{%
\expandafter\expandafter\expandafter\shyam@index@aux\csname glo@#1@index\endcsname\shyam@index
}
\def\shyam@index@aux#1?#2\shyam@index{\index{#1}}
\makeatother

\newacronym[longplural={diagonal matrices}]{dm}{DM}{diagonal matrix}
\newacronym{idn}{IDN}{identification number}

\makeglossaries

\usepackage{makeidx}

\makeindex

\begin{document}

\ac{dm}
\ac{idn}

\newpage

\ac{dm}
\ac{idn}

\printglossaries
\printindex

\end{document}


However, more work could be needed in case you use other commands for calling acronyms in the text. Without a minimal example covering the needs it's difficult to say more.

-
I could really use a solution that works for the whole family of \gls macros (e.g. \gls, \glspl, \Gls, Glspl, etc.). Since I'm not a LaTeX guru (yet!), I do not understand your trick between the \makeatletter and \makeatother commands. Does your code work only for acronyms? Would it work for the \gls commands as well? Thanks in advance! –  jvriesem Nov 19 '13 at 7:31