1 % The UCW Macro Collection: Destinations and links
2 % Written by Martin Mares <mj@ucw.cz> in 2018 and placed into public domain
3 % -------------------------------------------------------------------------
7 % Should clickable links be produced?
11 % Common style of all clickable links
13 \def\commonlinkargs{height \the\dimexpr\ht\strutbox-0.5pt\relax depth \the\dimexpr\dp\strutbox-0.5pt\relax attr {/C [0 0 0.5] /Border [0 0 2]}}
15 % Define a PDF destination for the current position at the page
16 \def\destpos#1{\ifclickable\pdfdest name {#1} xyz\relax\fi}
18 % Define a PDF destination for the current page
19 \def\destpage#1{\ifclickable\pdfdest name {#1} fit\relax\fi}
21 % Typeset a clickable link to the given destination
25 \pdfstartlink\commonlinkargs goto name {#1}\relax
33 % Typeset a clickable link to the given page number
34 % (This does not use named destinations. We use it in tables of contents and indices,
35 % where absolute page numbers are known from other sources.)
36 % \linkpage{page}{text}
37 \def\linkpage#1#2{\ifclickable\pdfstartlink\commonlinkargs goto page #1 {/Fit}\relax #2\pdfendlink\else #2\fi}
39 % Typeset a clickable URL
40 % Currently, all weird characters must be properly escaped.
44 \pdfstartlink\commonlinkargs user {/Subtype/Link /A << /Type/Action /S/URI /URI(#1) >>}\relax
51 \def\xurl#1:#2#3^^X{{\I #1:#2\ifx#2/\kern-0.1em\fi#3}}