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 am compiling a book in memoir class using xelatex and am having problems getting the TOC entry and PDF bookmark to match. Moreover, both point to the wrong page. Here is my MWE:

\documentclass[12pt]{memoir}
\usepackage[bookmarksopen=true]{hyperref}
\usepackage{bookmark}
\begin{document}
\frontmatter
\tableofcontents
%
\mainmatter
\chapter{One}
    \section{Sample}
    Here is some text.
\chapter{Two}
    \section{Follow up}
    Here is some more text.
\chapter{Three}
    \section{More follow up}
    Here is still more text.
\backmatter
\bookmarksetup{startatroot}
{\centering\Large\bfseries Colophon\\}
\noindent This is the start of the colophon.
\addcontentsline{toc}{chapter}{Colophon}
\end{document}

I wish the Colophon to be at the same level as a chapter in both the TOC and the PDF bookmark hierarchy.

Can someone please assist?

share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

You need \phantomsection:

\documentclass{book}
\usepackage[bookmarksopen=true]{hyperref}
\usepackage{bookmark}
\begin{document}
\frontmatter

\tableofcontents

\mainmatter

\chapter{One}
    \section{Sample}
    Here is some text.
\chapter{Two}
    \section{Follow up}
    Here is some more text.
\chapter{Three}
    \section{More follow up}
    Here is still more text.

\backmatter

\phantomsection
\addcontentsline{toc}{chapter}{Colophon}%
{\centering\Large\bfseries Colophon\par}
\noindent This is the start of the colophon.
\end{document}

\bookmarksetup is not needed, because the level is set by \addcontentsline

share|improve this answer
    
Thank you @egreg. It works perfectly! I wonder why this very useful \phantomsection command is not more prominently documented. –  chandra Dec 21 '12 at 14:33
    
It is even mentioned in the memoir manual. Memoir uses it in several places even when hyperref is not used. –  daleif Dec 27 '12 at 12:54
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.