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.

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{}?

share|improve this question

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
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
2  
Related: Automatically index acronyms –  cgnieder Jul 6 '12 at 15:14
1  
@tohecz The linked question is about the acronym package, not glossaries. –  egreg Jul 12 '12 at 14:39

1 Answer 1

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.

share|improve this answer
    
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

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