[Tex/LaTex] How to make indexed words clickable in the text

hyperrefimakeidxindexing

I want to make the indexed words into hyperlinks to the entries in the "Index" (something similar to the glossaries package).
I'm using xindy on TL2012 and here is my code:

\documentclass{article}

\usepackage{makeidx}
\makeindex

\usepackage{hyperref}

\begin{document}

Lorem\index{Alpha} ipsum dolor sit amet, consectetur\index{alpha}
adipiscing elit. Proin ullamcorper\index{gnat} quam magna, quis
convallis\index{gnus!good} sapien. Donecat ligula vel dolor
varius\index{bites!vegetable} lobortis id ut orci\index{gnat!size
of}. Maecenas commodo fringilla elit\index{Alphabet}, et pellentesque
purus ornare vitae.  Aenean non metus ipsum. Lorem\index{gnat!anatomy}
ipsum dolor sit amet, consectetur adipiscing\index{alphas} elit. Ut
mauris lorem, accumsan a sagittis ut, rutrum fringilla arcu. Cras
ullamcorper faucibus\index{alpha bet} quam id molestie.

\printindex

\end{document}

How can I do that?

Best Answer

Generally the indexed words do not necessarily appear in the text at all (for example there can be a fox in the text and an \index{animals} next to it). Therefore I'm not sure whether I understand your question right.

\documentclass{article}

\usepackage{makeidx}
\makeindex

\usepackage{hyperref}

\begin{document}

Lorem\index{Alpha@\hypertarget{Alpha.ind}{}Alpha}\href{\#Alpha.ind}{Alpha}
ipsum dolor sit amet, consectetur 
\index{alpha@\hypertarget{alpha.ind}{}alpha}\href{\#alpha.ind}{alpha}
adipiscing elit. Proin ullamcorper 
\index{gnat@\hypertarget{gnat.ind}{}gnat}\href{\#gnat.ind}{gnat} quam magna, quis
convallis
\index{gnus!good@\hypertarget{gnusgood.ind}{}good}\href{\#gnusgood.ind}{good} quam magna, ...

\printindex

\end{document}

Does this accomplish what you intended? (This works without xindy, but with it there can be problems.)

Related Question