[Tex/LaTex] Bibliography and Index \label for cross-reference

bibliographiescross-referencingindexing

I have each chapter of my book class in a different file all linked up in a master file. I also have bibliography in refs.bib file and also have an index. I'm trying to create a cross-reference to the Bibliography and Index special chapters of the book.

\usepackage{natbib}
\renewcommand\bibname{References}

\bibliographystyle{unsrt}
\bibliography{./tex/refs}

\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{Index}
\printindex

In my introduction, I would like to say to summarise my content where I say, "Chapter 1 descibes so and so, Chapter 2 .. etc. The end of the book also contains the list of references which you can link to by clicking on the numbers in the square brackets. An Index is contained at the very end of the book to make finding concepts and key words easy by clicking on the concept, which shoudl take you to the place in the book it is described in."

I have struggled to find a way to provide cross-reference links to both Bibliography and Index. I know how to use the \label command and have no problem with it. But I don't know where or how to put a \label command in the above mentioned special chapters.

I've tried labels like so:

\bibliography{./tex/refs}\label{cha:refs}
\addcontentsline{toc}{chapter}{Index}\label{cha:index}

but that seems to have put the wrong reference number – the number of the conclusion chapter was displayed for both links, but each one actually correctly taken me to each pseudo chapter!

Can anyone advise

  1. if this is the correct way of doing it
  2. if it is, how can I display either proper numbers or ideally show References and Index as links themselves so I don't confuse the reader by giving numbers to the chapters that don't have numbers in the TOC?

Best Answer

A possible solution is to use the facilities provided by etoolbox to patch the \bibliography and \printindex commands. Using hyperref you can use something like:

\documentclass{book}
\usepackage{natbib}
\usepackage{makeidx}
\usepackage{hyperref}

\usepackage{etoolbox}
\patchcmd{\thebibliography}{\list}{\label{bib}\list}{}{}
\appto{\theindex}{\phantomsection\label{idx}}

\makeindex

\begin{document}
Test: \hyperref[bib]{bibliography} starting at page \pageref{bib}, and 
\hyperref[idx]{Index} starting at page \pageref{idx}

test\index{test}

\nocite{*}

\bibliographystyle{<bibstyle>}
\bibliography{<bibfile(s)>}

\printindex

\end{document} 
Related Question