[Tex/LaTex] How to generate a “named destination” in PDF

bookmarkshyperreflabelspdfviewers

According to the Evince help, one can open a PDF at the location of a "named destination":

SYNTAX
       evince [--help]  [--page-label=PAGE |  --page-index=NUM‐
       BER | --named-dest=DEST] [--fullscreen] [--presentation]
       [--preview] [--find=STRING] [filename(s)...]
...
       -n, --named-dest=DEST
              Open the document on the specified named destina‐
              tion.

In Acrobat (acroread) the corresponding command is (documentation)

acroread /a "nameddest=pos2" hyperref.pdf

How can I generate such named destinations in a PDF from LaTeX?

In the past, (mainly for Acrobat) I used the zref-savepos package to open the document at a desired location (set at compilation). This doesn't seem to work well with Evince.

The question is not so much about Evince but what is that Evince calls "named destination" and how to produce them.

Below it is a series of attempts I made. When running Evince I get the following messages:

$ evince hyperref.pdf -n pos3 #or pos2
failed to look up pos3
failed to look up pos3

MWE

\documentclass[]{article}
\usepackage{hyperref}
\hypersetup{pdfstartview=FitBH \hypercalcbp{\zposy{pos2}sp}} %open at pos2 (works only in Acrobat)
\usepackage{bookmark}
\usepackage{zref-savepos}
\begin{document}

\zsavepos{pos1}

Bla

\zsavepos{pos2}

Ble

\belowpdfbookmark{Pos3}{pos3}

Bli

\end{document}

Best Answer

In my point of view, it's sufficient to set a \hypertarget{destname}{} and use the destname as argument to the evince --named-dest option. This works at least in my evince version (3.6.1, very old, I believe)

It works with Acrobat Reader as well, the calling syntax is slightly different, however:

acroread /a "nameddest=pos2" nameddestexample.pdf

to open the file at the named destination (hypertarget) "pos2".

\documentclass[]{article}

\usepackage{blindtext}
\usepackage{hyperref}
%\hypersetup{pdfstartview=FitBH \hypercalcbp{\zposy{pos2}sp}} %open at pos2 (works only in Acrobat)
\usepackage{bookmark}
\begin{document}


Bla

\blindtext[1]
\hypertarget{pos1}{}%



Ble
\blindtext[5]
\hypertarget{pos2}{}%


Bli

\blindtext[10]
\hypertarget{pos3}{Blue}

\blindtext[10]

\hypertarget{pos4}{Blofeld}



\end{document}