0

When I have to use \hyperlink{hypertarget}{AAA \href{URL}{BBB}} the whole string becomes a link to the "hypertarget" disregarding the inner link to the "URL" (except the colors: the color of \href somehow persists and shows through!).

I would like the \href to fully survive and take precedence. So when I press AAA it's hyperlinked, but when I press BBB, it sends me to the URL. Is this possible?

UPDATE: Thanks to Ulrike Fischer for trying this. We find that this works already in sumatra and adobe, and the problem appears only when viewed in qpdfview using Poppler PDF library for Linux.

1
  • 1
    \hyperlink{hypertarget}{AAA}\href{URL}{BBB}?
    – DG'
    Commented Nov 15, 2019 at 7:55

1 Answer 1

4

It works fine for me. Both links work in sumatra and adobe:

\documentclass[]{article}
\usepackage{l3pdf}
\ExplSyntaxOn
\pdf_uncompress:
\ExplSyntaxOff
\usepackage{hyperref}
\begin{document}
\hypertarget{hypertarget}{Target}
\newpage
\hyperlink{hypertarget}{AAA \href{https://tex.stackexchange.com/}{BBB}} some

\end{document}

enter image description here

You can also check that the pdf contains two annotations:

10 0 obj
<<
/Type /Annot
/Subtype /Link
/Border[0 0 1]/H/I/C[1 0 0]
/Rect [147.716 656.239 196.616 665.039]
/A << /S /GoTo /D (hypertarget) >>
>>
endobj
11 0 obj
<<
/Type /Annot
/Border[0 0 1]/H/I/C[0 1 1]
/Rect [173.453 656.239 196.616 665.039]
/Subtype/Link/A<</Type/Action/S/URI/URI(https://tex.stackexchange.com/)>>
>>
endobj

But the rectangles of the annotations overlap and so it depends on the pdf viewer how it handles this. It is better to create non-overlapping annotations.

1
  • Thank you, indeed it actually works in SumatraPDF. And unfortunately it does not work in qpdfview which uses Poppler on linux.
    – user612313
    Commented Nov 15, 2019 at 10:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .