# [pdftex] exact \pdfdest location?

Ross Moore ross at ics.mq.edu.au
Sun Aug 10 13:28:06 CEST 2003

```Hi Karl,

On Sat, 9 Aug 2003, Karl Berry wrote:

> Forgive my ignorance, but is it possible to make an exact destination
> target location?
>
> I received a bug report for Texinfo about toc entries in the outlines
> (aka bookmarks) not going to the actual place where the section started,
> but instead to the top of the page.
>
> Which is perhaps explained by this statement in the pdftex manual under
>     This location is tied to the page, not the exact location on
>     the page. The main reason for this is that pdf maintains a dedicated
>     list of these annotations --and some more when optimized-- for the sole
>     purpose of speed.
>
> But I find it hard to completely believe this.  PDF format inherently
> does not let you define a given location on a page (for example, right
> beginning of the whole page?  This seems unlikely to me.

You are right; there is no inherent limitation imposed by either
the PDF format or pdfTeX itself.

The difficulty lies solely in positioning the \pdfdest so that it
occurs in exactly the right place, and in setting appropriate
view parameters so that the material that you wish to display gets
appropriate prominence within the browser window.

For an example of where this kind of this has been done,
have a look at the PDF preprints from the TUG 1999 meeting (Vancouver).
Here are some examples:
http://www-texdev.ics.mq.edu.au/TUG/PDF/tug99/ross/ross.pdf
http://www-texdev.ics.mq.edu.au/TUG/PDF/tug99/downes/downes.pdf
http://www-texdev.ics.mq.edu.au/TUG/PDF/tug99/doumont1/doumont1.pdf

(The full set should be available on tug.org .)

Check out all the cross-referencing/hyperlink features in these examples,
including the Bookmarks and Article threads (also, back-referenced
citations).

> In looking through the pdftex archives, I found some suggestions that
> \pdfannot doesn't have this limitation, but I couldn't find any actual
> examples of how to do that.  What's the \pdfannot equivalent of \pdfdest
> name{foo} xyz?  (That is, if \pdfannot can really gives you exact locations.)
>
> Or in fact how you actually link to a \pdfannot.  Does \pdfstartlink
> goto ... suffice?

No, not directly; because it is a question of *where* does it go on the
PDF page, and how do you get it there, within the context of LaTeX
document source.
e.g. if you place the \pdfdest *before* a \section command, then it is
logically part of the preceding section or chapter. If you put it *after*
then the destination is after the heading, not before it.

So it is necessary to include placement of the \pdfdest as part of the
tasks performed by the \section macro itself.
(Ideally the destination is slightly raised above the title, and kerned to
the left so as to leave a small margin for comfortable viewing.)

To do this within a useable LaTeX document-class means hacking at
quite a few internal macros. New length variables need to be added,
for this kind of specialised use.

This kind of *hacking* work was done by me, for the TUG'99 papers.
Some of the lessons were conveyed to Heiko Oberdiek for inclusion within
hyperref.sty  but others have not been adapted for this yet.
(In particular, the handling of Article beads changed in pdfTeX,

>
> Anyway, FWIW, attached is a sample pdf document showing the problem.  If
> you view the second page under acrobat at high magnification (400%,
> 800%), and click the `Setting flags...' section link in the bookmarks,
> you'll end up at the top of the page of the text, and in fact the given
> section title will not be visible.  Similarly if you click the xref to
> the first section that's at the bottom of the page ...

Yep.
Been there; done that.

>

I can send you the file of *hacks* to LaTeX internals that I used in '99.
You will have to sort out for yourself how to adapt it for your own use;
it is most certainly *not* in a particularly user-friendly form.

Cheers

Ross

> karl
>
>
>
```