## Friday, July 6, 2012

### hyperref, ToCs and incorrect page numbers and bookmarks

I was having trouble with page numbers in my table of contents and hyperref.Basically the page numbers would occasionally be the page before, or the section before, and the link in the ToC or in the document layout would take you to the wrong part of the document.

The culprit was probably most likely the lines I had in there that pushed sections and subsections onto right-hand (odd) pages.
\newcommand*\stdsection{}
\let\stdsection\section
\renewcommand*\section{%
\clearpage\ifodd\value{page}\else\mbox{}\clearpage\fi
\stdsection}
If I add in a \phantomsection prior to the final \stdsection, problem (mostly!) solved:
\newcommand*\stdsection{}
\let\stdsection\section
\renewcommand*\section{%
\clearpage\ifodd\value{page}\else\mbox{}\clearpage\fi
\phantomsection\stdsection}
I still can't get it to put my Glossary entry on the right page...

But finally, success ! Putting a \cleardoublepage between my \listoftables and my glossary \printglossaries for some reason fixed it... a \null\newpage or a \newpage, or \clearpage didn't work (despite putting it on the same page as a \cleardoublepage).

To add a bookmark to the location of the ToC but without actually adding a reference in the ToC,