PDF Named-Destinations are made by Hyperref. This shows how to change them by using hyperref option destlabel=true, then redefining using /label. Unfortunately, it does not seem to work.

answer:---Its Lyx--- (but not a solution)

(should have looked in the latex, my bad). The document->settings->pdf properties->options field on PDF Preferences is put into \hypersetup{ destlabel=true}, not the \usepackage[destlabel=true]{hyperref}. As Heiko originally noted, that doesn't work.

Preamble from Lyx:

   breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false]
\hypersetup{ destlabel=true}

When I directly \usepackage[destlabel=true]{hyperref} in the preamble it works.

Unfortunately other packages that lyx loads, are dependent on being loaded after Hyperref, so usepackage hyperref, can't be moved to the preamble.

So what is needed is for the Lyx Preamble to be:

   breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false,

Unfortunately that is a lyx UI change.

Is there any other way to make the destlabel=true work in hypersetup, or elsewhere?

  • Welcome to TeX.SX! Please provide a compilable document (and I don't mean the LyX file!) – user31729 Jul 30 '16 at 15:18
  • RenamedIt is being added to the PDF list of anchors, but it is not being assigned to the same location as section.3 (or section.1 in my case). – John Kormylo Jul 30 '16 at 15:45
  • What exactly would you like the preamble to look like in LyX? If you could specify the \usepackage{hyperref} line and tell LyX not to add it, would that work for you? What exactly would you like the \usepackage{hyperref} line to look line? – scottkosty Aug 4 '16 at 4:41
  • @scottkosty I have edited the question above, to show what the lyx generated preamble should look like. It seems that hyperref requires 2 option lines to be used fully: "additional hyperref options" (new) and "additional hypersetup options" (the existing editbox) – Henry Crun Aug 4 '16 at 8:08
  • @HenryCrun regarding "Unfortunately other packages that [LyX] loads, are dependent on being loaded after hyperref", can you please upload a minimal example showing the particular problem that happens for you? It is not that i don't believe you (in fact I know this statement is correct), but the solution depends on the particular conflict you are facing. – scottkosty Aug 4 '16 at 18:47

There is an option destlabel, which uses the name of the first \label after the anchor creation to name the anchor:

\ifx\pdfobjcompresslevel\undefined\else\pdfobjcompresslevel=0 \fi % Debug



The first line is just for pdfLaTeX to make it easier to read the PDF file via a text viewer (or editor) to find the destination names in the PDF file (in short, /Catalog/Names/Dests). The /Dests object references object 21 in the generated PDF file:

21 0 obj
/Names [(Doc-Start) 10 0 R (intro) 2 0 R (page.1) 9 0 R]
/Limits [(Doc-Start) (page.1)]

There are three names: Doc-Start is added by hyperref at the begin of the document. page.1 is the automatically created page label (controlled by option pageanchor). The destination for \section{Introduction} is intro, named by \label{intro}.

  • Interestingly, it takes two runs. – John Kormylo Jul 30 '16 at 16:28
  • @JohnKormylo Of course. At the time of \section with the anchor setting it is not yet known that there will be a \label command. LaTeX's \label feature needs two runs anyway, thus this is not a drawback. – Heiko Oberdiek Jul 30 '16 at 16:59
  • Actually, the reason is that the aux file contains \hyper@newdestlabel{oldname}{newname} which does all the work. – John Kormylo Jul 31 '16 at 21:03
  • @heiko I now think that LyX is misusing Hypersetup in the preamble (immediately after /usepackage hyperref ). Could you have a look at my comment here: lyx.org/trac/ticket/10319#comment:7 and comment on whether I am correct to think this? – Henry Crun Aug 16 '16 at 8:50
  • @HenryCrun Yes, destlabel should go to the options of usepackage, because destlabel is used at package loading time. Later uses of destlabel should give a warning. – Heiko Oberdiek Aug 16 '16 at 16:54

You need destlabel=true in the preamble, but you cannot use a \label AND \HyperDestRename, not even if you use the label name instead of \@currentHref.



\lipsum[1-5]% skip first page



\section{Development}% new \@currentHref

\hyperlink{ExternalName}{same target}

  • Sorry John, I don't quite see what you are doing. – Henry Crun Jul 30 '16 at 22:17
  • When I try this I get a visible hyperlink labelled "test", which jumps to "intro" within the pdf. It does not result in a named-destination (external anchor for hyperlinks from outside the pdf) however. What I think I want to do is make a hypertarget and label with the text of the section (but spaces changed to underscores). – Henry Crun Jul 30 '16 at 23:11
  • I am not understanding why the hyperdest macro. Why does '\HyperDestRename{\@currentHref}{ExternalName}' not work, when '\HyperDestRename{\myname}{ExternalName}' does work? [nor does '{@currentHref}' , '{currentHref}' , '{\currentHref}' – Henry Crun Aug 4 '16 at 9:21
  • The @ symbol is used in sty files to create macro names that users will not accidentally redefine, or use. The \makeatletter ... \makeatother overcomes this restriction. \csname @currentHref\endcsname will also work. – John Kormylo Aug 4 '16 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.