7

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?
0

2 Answers 2

3

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} 
1
  • 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, 2012 at 23:49
0

For me It worked well by just using \hyperref directly with the \addcontentsline. For example I want to add Introduction into the table of contents, we can just do this : \addcontentsline{toc}{chapter}{\hyperref[chap:Introduction]{Introduction}}. chap:Introduction is the label name for specific chapter and Introduction is the custom label.

\documentclass{book}

\usepackage{hyperref}


\begin{document}

\chapter*{Introduction}
\label{chap:Introduction}

\tableofcontents
\addcontentsline{toc}{chapter}{\hyperref[chap:Introduction]{Introduction}}

\end{document} 

You must log in to answer this question.

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