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.

How can I reference the index created by the package makeidx?

Minimal working example:

\documentclass{scrbook}

\usepackage{hyperref} % creates links on refs
\usepackage{makeidx}
\makeindex

\begin{document}
    % add something to the index...
    The foobar\index{foobar} is quite impressive!

    % some reference to the index...
    Please follow the \ref{index}.

    % print index...
    \printindex 
\end{document}

The obvious \label{index} does neither work before nor after \printindex.

Edit (thanks to daleif): An important fact I forgot to tell: I want the index to be linked at \ref{index}. That's why I cannot just say See index.

share|improve this question
1  
As long as it is listed in the TOC, I don't think a direct link to it is necessary. See the index ought to be reference enough. –  daleif Jun 2 at 9:02
1  
Thanks - good point! I edited my question regarding this... –  matheburg Jun 2 at 9:15

2 Answers 2

up vote 7 down vote accepted

You can do it with imakeidx:

\documentclass{scrbook}

\usepackage{imakeidx}
\usepackage{hyperref} % creates links on refs

\makeindex[title={Index\label{index}}]

\begin{document}
% add something to the index...
The foobar\index{foobar} is quite impressive!

% some reference to the index...
Please follow the \hyperref[index]{index}.

% print index...
\printindex

\end{document}
share|improve this answer

There is a hook \setindexpreamble in the scr classes to add material at the beginning of the index. You can use this to set your label. Using just \ref will give a blank link, you need either a \pageref or a \nameref.

Sample output

\documentclass{scrbook}

\usepackage{makeidx}
\usepackage{hyperref} % creates links on refs
\makeindex

\setindexpreamble{\label{index}}

\begin{document}
\label{start}
    % add something to the index...
    The foobar\index{foobar} is quite impressive!

    % some reference to the index...
    Please follow the \nameref{index}.

    % print index...
    \printindex 
\end{document}
share|improve this answer
    
@egreg Of course! It just happened to work in this case in the wrong order. Code updated. –  Andrew Swann Jun 3 at 6:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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