1

I would like to have hyperlink in the index list, like if I press the page 8 it will move me to the page 8.

I use the package

\usepackage[xindy]{imakeidx} 

where [xindy] makes it in alphabetical order. Here is for my hyperlinks

\usepackage[hidelinks]{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    filecolor=blue,
    urlcolor=blue,
    citecolor=blue,
    pdftitle={Alessandro Lin}
}
\hypersetup{linktocpage}

enter image description here

2
  • 2
    Please provide more information about how you make the index and the hyperref setting. It would be better if you provide a MWE. Commented Jan 7, 2023 at 2:31
  • 1
    Teddy has asked you for a minimal working example not only some code snippets. And because the shown settings already produce links in the Index (see my edited answer), is seems you are still not showing the root of your problem. So please read the page, I've linked in this comment and show a real working example, that can be used to reproduce your problem.
    – cabohah
    Commented Jan 7, 2023 at 12:49

1 Answer 1

1

You can use packages imakeidx and hyperref to get the page links automatically:

\begin{filecontents}[force]{\jobname.ist}
headings_flag 1
heading_prefix "\\par\\penalty-50\\textbf{"
heading_suffix "}\\par\\nobreak"
\end{filecontents}

\documentclass{article}
\usepackage{imakeidx}
\makeindex[options={-s \jobname.ist}]
\usepackage{hyperref}

\begin{document}
\setcounter{page}{5}
Parity\index{Parity}
\newpage\mbox{}\newpage\mbox{}\newpage
Acquaintances\index{Acquaintances}
Coprime\index{Coprime}
lattice\index{lattice}
\printindex
\end{document}

Index with page links

Note: The red frames are only shown in PDF-viewers, they will not be printed. hyperref also provides options to use underlining or colored links instead of frames or to not visualize the links. See the manual for more information.


Edit: With the settings you've shown in your edited question, your also already get links in the index:

\documentclass{article}
\usepackage[xindy]{imakeidx}% Note: With xindy you have to run pdflatex with option --shell-escape. See section 4 of the imakeidx manual.
\makeindex
\usepackage[hidelinks]{hyperref}% Option hidelinks does not make much sense, because the options set by \hyperset below will overwrite it.
\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    filecolor=blue,
    urlcolor=blue,
    citecolor=blue,
    pdftitle={Alessandro Lin}
}
\hypersetup{linktocpage}

\begin{document}
\setcounter{page}{5}
Parity\index{Parity}
\newpage\mbox{}\newpage\mbox{}\newpage
Acquaintances\index{Acquaintances}
Coprime\index{Coprime}
lattice\index{lattice}
\printindex
\end{document}

with imakeidx and xindy

4
  • Nice. What does filecontents do, why is it required? Thanks
    – MS-SPO
    Commented Jan 7, 2023 at 10:36
  • 1
    @MS-SPO The filecontents environment writes the index style file, that is used by imakeidx via options={-s \jobname.ist}. It activates the letter headings in the index. See the MakeIndex manual for more information about index style files.
    – cabohah
    Commented Jan 7, 2023 at 12:37
  • Thanks for your help! Yeah, it did not work before because I have put \makeindexafter \usepackage[hidelinks]{hyperref} now is working thanks! Commented Jan 7, 2023 at 14:02
  • @AlessandroLin My example would also work with \makeindex after \usepackage[hidelinks]{hyperref}. You just have to load hyperref after imakeidx. hyperref should always be loaded after other packages except if the manual of hyperref or the other package explicitly says something else.
    – cabohah
    Commented Jan 7, 2023 at 15:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .