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.

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?
share|improve this question
add comment

1 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} 
share|improve this answer
    
Thanks for that. Although the etoolbox part of this didn't quite work for me, but what I really took away is \hyperref[bib]{bibliography} part. Because the links already work in my solution properly, it was the numbers that were wrong. So now everything works. Thanks a lot :) –  alex Oct 17 '12 at 23:49
add comment

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.