3

I’m trying to typeset a lengthy URL in ConTeXt MKIV. The URL appears correctly in the resulting PDF when I use hyphenatedurl, but the hyperlink is wrong in two ways. First, only the first line of the URL in the PDF is a hyperlink. Second, the hyperlink target is incorrectly set to be just the first line of the URL.

Here is some example code that produces this problem for me:

% !TEX TS-program = ConTeXt (LuaTeX)

\starttext
\hyphenatedurl{http://cocatalog.loc.gov/cgi-bin/Pwebrecon.cgi?Search_Arg=TX0008128881&Search_Code=REGS&PID=H2kE07My-dH7holsSiJLceSpl&SEQ=20170626171039&CNT=25&HIST=1}
\stoptext

On my system, this generates a PDF containing the URL printed over three lines, with line breaks as follows:

http://cocatalog.loc.gov/cgi-bin/Pwebrecon.cgi?Search_Arg=TX0008128881&Search
_Code=REGS&PID=H2kE07My-dH7holsSiJLceSpl&SEQ=20170626171039&CNT
=25&HIST=1

Of these three lines, only the first line is clickable/interactive, and its target is incorrectly set to http://cocatalog.loc.gov/cgi-bin/Pwebrecon.cgi?Search_Arg=TX0008128881&Search, rather than the full URL.

How can I set the hyperlink correctly? Alternatively, how can I turn off the hyperlink altogether?

5

Actually, I get no hyperlink at all, which is what I expect because \hyphenatedurl only typesets the URL and doesn't make a link. And even if I made a link using \goto{<text>}[url(<link>)] it wouldn't work because interaction is not turned on. It seems to me that some heuristic of your PDF viewer is trying to detect the link and transform it into something clickable. This however fails on the line break.

It is very easy though to set up a clickable link from within ConTeXt. I also put an empty style because I don't like bold links. See the Garden for further configuration.

\setupinteraction[state=start,style=]

\define[1]\hyperlink{\goto{\hyphenatedurl{#1}}[url(#1)]}

\starttext

\hyperlink{http://cocatalog.loc.gov/cgi-bin/Pwebrecon.cgi?Search_Arg=TX0008128881&Search_Code=REGS&PID=H2kE07My-dH7holsSiJLceSpl&SEQ=20170626171039&CNT=25&HIST=1}

\stoptext

enter image description here

| improve this answer | |
  • Thank you! I had been using \setupinteraction to try to turn OFF the hyperlink, but it never occurred to me that my PDF viewer may have been interpreting the text as a hyperlink on its own. Your explanation makes perfect sense. – J. King Jun 26 '17 at 22:38

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.