views:

629

answers:

4

Hi,

I have a latex document. I am using hyperref, makeidx and glossary packages for my document.

Every thing is created fine; table of content (all references works nicely), glossary and index except that page numbers printed in the glossary and index are correct but they point to page numbers starting from the beginning of the document where initial 10 pages are in arabic numbers and then roman numbers from 1 starts.

e.g. I have 10 pages for initial front matter (abstract, declaration, table of contents etc etc). After that, mainmatter begins and so does the page numbers in roman from 1. So on this page 1, I have an index entry "hello"

Now in the index, it prints "hello 1" which is correct except that when one clicks on 1, then it goes to the right at the beginning of the document rather then numbered page 1.

Your help would be much appreciated.

Thanks, Omer

+3  A: 

OK, googlefu(*) provides http://www.tex.ac.uk/cgi-bin/texfaq2html?label=pdfpagelabels where is says that this is a know problem, and suggests two options to the hyperref package:

  • plainpages=false
  • pdfpagelabels

though it warns that these will not work in every situation (but I believe it will in yours). The application would look something like:

\usepackage[plainpages=false,pdfpagelabels,pagebackref]{hyperref}

in your preamble.

Failing that http://en.wikibooks.org/wiki/LaTeX/Hyperlinks provides clunkier trick which will work in places where the above fails. (Scroll down to the "Problems with Links" section.)

Hope that helps.

(*) Turns out I found this stuff due to a typo, and asked google for "hyperef frontmatter" rather than "hyperref frontmatter". Some days you just get lucky.

dmckee
I am trying out...plainpages=fasle didn't workI am not sure how to use pdfpagelables and where??
Here: `\usepackage[pdfpagelabels]{hyperref}`.
Thomas
I have tried all the options including "Problems with links" but it didn't work..
I guess I'm out of ideas then. Sorry.
dmckee
Considering that TOC works perfectly...I am wondering if the problem is with hyperref.Since \makeindex and \makeglossary are called in the frontmatter section, I think this creates wrong linking although (strangely) page numbers printed correctly in the index and glossary.
+1  A: 

I wrote a blog post about this a while ago, explaining how to simply number your pages 1...n, getting rid of the Roman numerals. This solves your problem, and makes for sensible page numbering within the PDF reader as well. If this is what you want, put the following code in your preamble:

\let\oldsetcounter=\setcounter
\renewcommand\setcounter[2]{%
  \ifx\not{#1}{page}\oldsetcounter{#1}{#2}\fi}
Thomas
Thanks Thomas...But i need arabic and roman numbers for my document for different sections.
A: 

i am not sure if this will work at all, but have you tried adding

\frontmatter

\mainmatter

\backmatter

in the appropriate places?

note that this only applies to the book & book-like classes, not article, letter, etc.

Mica
Yes! That is all working. It's not an issue of frontmatter, mainmatter and backmatter; if you read my first message I described that every thing is fine except the hyperrefs in the glossary and index which print pages correctly but links wrongly.
sounds like a page counter problem. have you tried setting a counter at the beginning of \frontmatter, then another counter at \mainmatter?
Mica
A: 

This is a dirty trick, but it works

\newcounter{glshyperpage}%
\def\glshyper#1#2{%
\setcounter{glshyperpage}{#2}%
\addtocounter{glshyperpage}{6}%number of front-matter pages
(\hyperlink{#1.\theglshyperpage}{#2})}
Javier