# [OS X TeX] xelatex bookmarks don't work in Preview.app

Joe Chan firstian at rcn.com
Fri Apr 20 21:40:50 EDT 2007

I posted this question, and subsequently a partial cause of the
behavior in the TeXShop forum. Herb asked me to report to the list.
The original observation is:

> While converting one of my docs to TeX format, I use hyperref to
> enable PDF bookmark generation like this:
>
> \usepackage[bookmarks]{hyperref}
>
> and I'm using the xelatex template of TeXShop.
>
> For some reason, when I load the PDF in MacOS's Preview, the
> bookmarks are all in the drawer, but clicking on them does nothing.
> Likewise, cross reference links in the doc highlights, but does
> nothing. Then I tried loading up the PDF in Acrobat, and the
> bookmarks and links work as expected.

While waiting for some suggestions, I went digging on my own. It
appears that the problem is an interaction between xelatex and Cocoa
PDFKit. I wrote a short sample and ran it through xelatex and
pdflatex. The bookmarks from the latter consistently work, but not
the latter. The sample is:

\documentclass[12pt]{article}
\usepackage[bookmarks=true]{hyperref}
\begin{document}
\section{First}
\pagebreak
\section{Second}
\pagebreak
\section{Third}
\end{document}

Then I built the PDFViewer sample code from the Developer directory,
and set a breakpoint where the outline item is selected. The reason
that the bookmarks didn't work is because the call to the
"destination" method of PDFOutline for the item selected returns
NULL. I looked through the PDFKit docs and the mailing list and
couldn't find an explanation for it. My best guess right now is that
there is a bug in PDFKit in Tiger.

-----------
Joe Chan