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

Bruno Voisin bvoisin at mac.com
Sat Apr 21 09:45:23 CEST 2007


Le 21 avr. 07 à 03:40, Joe Chan a écrit :

> 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. [...] 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.

That's a known problem when using XeTeX's built-in XDV-to-PDF  
converter xdv2pdf (XDV is the extended DVI format used by XeTeX). I'm  
not sure what can be done about it.

Because of it, I tend to use more and more often the external XDV-to- 
PDF converter xdvipdfmx, creating bookmarks compatible not only with  
Adobe Reader but also with Preview. Jin-Hwan Cho, one developer of  
dvipdfmx on which xdvipdfmx is based, posted once a fix to that effect:

> De : Jin-Hwan Cho
> Date : 7 février 2007 08:21:33 HNEC
> À : TeX OS X Mailing List on Mac
> Objet : [OS X TeX] bookmark problem with DVIPDFM(x)
>
> It is possible to insert bookmarks with DVIPDFM(x) as well as
> DVIPS and pdfTeX. With \usepackage[dvipdfm,bookmark]{hyperref}
> bookmarks can be generated automatically with DVIPDFM(x).
>
> Even though the bookmark worked well in Adobe Reader, it did not
> work on Preview.
>
> The reason is in the hdvipdfm.def file in the hyperref package.
> The line 64 looks as follows:
>
>   \@pdfm at mark{dest (#1) [@thispage /\@pdfview\space @xpos @ypos]}%
>
> After modifying the line as follows
>
>   \@pdfm at mark{dest (#1) [@thispage /\@pdfview\space @xpos @ypos  
> null]}%
>
> you can get bookmarks working with Preview as well as Adobe Reader.
>
> Best, ChoF.

That fix has since been incorporated in hdvipfm.def (currently at  
version 6.75t in TeXLive-2007 and gwTeX), inside the definition of  
\@pdfm at dest at line 110 I think.

However, even though the hdvipdfm.def file is used automatically when  
running XeTeX, the fix seems to affect xdvipdfmx but not xdv2pdf.

How to make XeTeX use xdvipdfmx instead of xdv2pdf in TeXShop?  
Activate the engine ~/Library/TeXShop/Engines/Inactive/XeTeX/XeLaTeX- 
xdvipdfmx.engine, by moving it to ~/Library/TeXShop/Engines/, and  
then select it from within TeXShop.

Beware though: on a Mac, the cross-platform xdvipdfmx offers less  
functionality than the OS-X-specific xdv2pdf:

- Regarding fonts: xdvipdfmx supports OpenType fonts, but not AAT fonts.

- Regarding graphics: xdv2pdf allows including in a XeTeX document  
any graphical file format recognized by Quartz, while xdvipdfmx  
doesn't. As a consequence, for example, with xdv2pdf you can use  
\includegraphics with a TIFF file, while with xdvipdfmx you can't.

Hope this helps,

Bruno Voisin


More information about the XeTeX mailing list