0

With the following MWE:

\documentclass[a4paper]{report}
\usepackage{hyperref}

\begin{document}
\href{en.wikipedia.org}{\emph{gungumapu}}
\href{en.wikipedia.org}{gungumapu}
\end{document}

I would expect "gungumapu" to appear in emph (italic) typeface and in plain upright typeface, both times with a link under it, i.e. if I click on either appearance of "gungumapu", I'd expect en.wikipedia.org to open in my browser. Only that doesn't happen. Why is that? Is my expectation wrong? If so, how do I put a hyperlink in my document?

1
  • 3
    en.wikipedia.org is not a URL: http://en.wikipedia.org works.
    – egreg
    Jul 18, 2014 at 15:02

2 Answers 2

4

The protocol is missing. \href tries to detect different protocols (URL links, file links, links to PDF files, ...). As egreg has written in his comment, specifying the correct, complete URL helps:

\documentclass[a4paper]{report}
\usepackage{hyperref}

\begin{document}
\href{http://en.wikipedia.org/}{\emph{gungumapu}}
\href{http://en.wikipedia.org/}{gungumapu}
\end{document}
9
  • OK. This solves the problem in the given MWE. The actual problem was with \href{http://www.wolframalpha.com/input/?i=sum_{n\%3D1}^{infinity}\%28arctan\%282\%2F\%28n^2\%29\%29\%29}{\emph{questo}}. In this case, http:// is there, but still the link won't open, even removing the \ from \% at each appearance in the URL. What do I do with this?
    – MickG
    Jul 18, 2014 at 15:53
  • 1
    @MickG: The URL is correctly written into the PDF file. It seems there is a bug in firefox. If I directly use the URL in firefox, then its get scrambled (no parentheses, ...). The URL in chromium or opera works. Jul 18, 2014 at 16:13
  • OK, but on my Mac http://www.wolframalpha.com/input/?i=sum_1^infinity+arctan(2/n^2) works in Firefox and gives the same problem as the other one with \href{http://www.wolframalpha.com/input/?i=sum_1^infinity+arctan(2/n^2)}{questo}.
    – MickG
    Jul 18, 2014 at 18:32
  • Same problem with \href{http://www.wolframalpha.com/input/?i=sum_1^infinity+arctan\%282\%2Fn^2\%29}{questo}: working URL in Firefox, but no URL in the pdf.
    – MickG
    Jul 18, 2014 at 18:34
  • 1
    @MickG: \040 is the octal notation for a byte in a PDF string, use %20 instead. Try a URL shortening service to get a better URL, which works with buggy programs. Jul 19, 2014 at 12:25
2

What's your question here? You say that "that doesn't happen," but don't tell us which: the italic and plain upright typeface, or the opening of the link in your browser?

If the latter, then Heiko's answer (from the package developer, no less!) covers your issue.

If the former, then you've got bigger problems. :-) The two links appear in italic and upright, but they are surrounded with the default colored box to indicate that they're links. If this is what bothers you, you can control the appearance of links with options that you pass to hyperref. If you do:

\usepackage[colorlinks]{hyperref}

You'll get colored text instead of the boxes. You can choose which color the links are with linkcolor:

\usepackage[colorlinks,linkcolor=blue]{hyperref}

Or, since your links are to URLs and not internal:

\usepackage[colorlinks,urlcolor=blue]{hyperref}

The hyperref manual is excellent and gives more information about this.

You must log in to answer this question.

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