# Named destinations by hyperref broken for XeTeX 3.14159265-2.6-0.99992 (TeX Live 2015/dev/Debian)

We have this testcase which works fine with pdflatex

\documentclass[en]{article}
\usepackage[
pdfauthor={Silly testcase maker},
pdftitle=,
pdfsubject=,
]{hyperref}

\newcommand{\pdfLabel}[1]{\hyperdef{marker}{#1}{}}

\begin{document}

Hello folks
\newpage
haha this is funny
\newpage
lets do another page
\newpage
now we have a working testcase for real huh
\newpage
but rly
this is the label \pdfLabel{hahalulz} that was the label
\newpage
but does it jump
\newpage
that is the question folks

\end{document}


The purpose is to define a named destination within the PDF document called marker.hahalulz. This used to work with xetex when using debian squeeze, but now with debian Jessy it fails with xelatex (but still works with pdflatex) and we have no idea what the reason might be.

The failure-symptoms are that we are unable to jump to the named destination, for example with the command

\$ evince -n "marker.hahalulz" testcase.pdf


Output of xelatex

This is XeTeX, Version 3.14159265-2.6-0.99992 (TeX Live 2015/dev/Debian) (preloaded format=xelatex)
restricted \write18 enabled.
entering extended mode
(./testcase.tex
LaTeX2e <2014/05/01>
Babel <3.9l> and hyphenation patterns for 79 languages loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/minimal.cls
Document Class: minimal 2001/05/25 Standard LaTeX minimal class
) (/usr/share/texlive/texmf-dist/tex/latex/hyperref/hyperref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-hyperref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/hobsub-generic.sty))
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty)
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/auxhook.sty)
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty)
(/usr/share/texlive/texmf-dist/tex/latex/hyperref/pd1enc.def)
(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/hyperref.cfg)

Package hyperref Warning: XeTeX driver only supports unicode.
(hyperref)                Enabling option unicode'.

(/usr/share/texlive/texmf-dist/tex/latex/hyperref/puenc.def)
(/usr/share/texlive/texmf-dist/tex/latex/url/url.sty))

Package hyperref Message: Driver (autodetected): hxetex.

(/usr/share/texlive/texmf-dist/tex/latex/hyperref/hxetex.def
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/stringenc.sty)
(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/rerunfilecheck.sty))
(./testcase.aux)

Package hyperref Warning: Height of page (\paperheight) is invalid (0.0pt),
(hyperref)                using 11in.

(/usr/share/texlive/texmf-dist/tex/latex/hyperref/nameref.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/gettitlestring.sty))
(./testcase.out) (./testcase.out) [1] [2] [3] [4] [5] [6] [7] (./testcase.aux)
)
Output written on testcase.pdf (7 pages).
Transcript written on testcase.log.

• You should never use the minimal class. – egreg Oct 30 '15 at 16:25
• @egreg ah I was just trying to produce a minimal testcase. Since I've not worked with (latex|xetex)-from-scratch, I already forgot that. Thanks for noting this. I changed the class to article, but the problem remains. – Johannes Schaub - litb Oct 30 '15 at 16:42
• I don't think that's the problem, though. Unfortunately the evince I installed on my machine with Homebrew refuses to open PDF files. :( – egreg Oct 30 '15 at 16:43
• @JohannesSchaub-litb: I can confirm this with xelatex on my Vanilla TL 2015 -- it works with pdflatex, as you stated already – user31729 Oct 30 '15 at 17:29
• – Jonathan Komar May 25 '16 at 13:13

In dvipdfmx.cfg search for Dvipdfmx Compatibility Flags, and you can see:

%% Dvipdfmx Compatibility Flags
%%
%%   0x0002  Use semi-transparent filling for tpic shading command,
%%           instead of opaque gray color. (requires PDF 1.4)
%%   0x0004  Treat all CIDFont as fixed-pitch font.
%%           This is only for backward compatibility. Don't use that.
%%   0x0008  Do not replace duplicate fontmap entries.
%%           Dvipdfm's (not 'x') behaviour.
%%   0x0010  Do not optimize PDF destinations. Use this if you want to
%%           refer from other files to destinations in the current file.

%C  0x0000


Add this line after %C 0x0000, and then named destinations will work as expected:

C  0x0010


Tested with MiKTeX 2.9 on Windows 7. For MiKTeX it's better to edit the user's configuration file dvipdfmx.cfg with:

initexmf --edit-config-file dvipdfmx


, and add the C 0x0010 line into this file.

• Ah nice. Any idea why it worked in prior versions without modifications to that file? – Johannes Schaub - litb Dec 25 '15 at 10:16
• Without digging into the source (too daunting for a newbie like me), I believe this is an optimization added later. As long as the named destinations don't have to be predictable, the driver (dvipdfmx) is free to assign short strings and get a smaller PDF. It's a quite fair tradeoff. In my laptop I just found a PDF generated in 2009 with xdvipdfmx 0.7.8, which used verbatim named destination strings. This must be the default behavior at that time and no other options were likely available. – wdscxsj Dec 25 '15 at 10:51
• And these threads may be related: tug.org/mailman/htdig/xetex/2014-September/025563.html (complaint about the optimization), tug.org/mailman/htdig/xetex/2011-November/021870.html (encoding of non-ASCII characters). – wdscxsj Dec 25 '15 at 10:52
• I had the same problem using \hypertarget{}{}`and created a bug report on SourceForge. – Mik Sep 21 '16 at 11:00