This has been on my to-do list for a while, but I finally found out how to embed hyperlinks in a PDF file generated from LaTeX.
Short answer: put \usepackage{hyperref} in your header, and when you want to link to a page, use the command \href{URL}{anchor text}. For example,
\documentclass{article}
\usepackage{hyperref}
\begin{document}
Here's a link to \href{http://twitter.com/home}{Twitter}.
\end{document}
For much more detail on links in LaTeX documents, see Patrick Jöckel’s LaTeX-PDF page and the hyperref package documentation.


{ 1 trackback }
{ 17 comments… read them below or add one }
Carlos Hidalgo 02.22.09 at 11:24
Thanks a lot. This is the simple statement about how to use \href I was looking for!
Much clearer than the ’short’ documentation of the hyperref package.
Manuel 04.09.10 at 09:11
It is not working now(2010) ¿what is happening?
Jensse 04.22.10 at 04:07
Manuel… and others… you have probably forgotten to add the:
\usepackage{hyperref}
Just place it below the
documentclassstatementcagatay 05.25.10 at 02:33
Thank you for this information Jensse
It has really helped me.
cagatay 05.25.10 at 02:34
not just Jensse; John i meant, infact
anonymous 06.27.10 at 12:42
thank you.
very nice post.
clean, simple AND effective
Rafael Beraldo 07.29.10 at 08:58
John,
Can I translate some of your posts on LaTeX to Portuguese and post them in my own blog, of course referring to the original post? They’re quite straightforward.
Thanks!
John 07.29.10 at 09:08
Rafael: Yes, that would be fine. Thanks.
Greg 11.12.10 at 04:48
hi,
I managed to use \href to add a weblink to my pdf. however i want the anchor text to be equal to the url (in order to also enable someone who printed the doc get to that web page). so I do:
\href{}{}
The problem is that the URL is much longer than the textwidth. how can i make the link use multiple lines?
Thanks in advance!
greg
Greg2 11.12.10 at 05:16
Actually I found the solution myself:
\usepackage{url}
\usepackage{hyperref}
\usepackage{breakurl}
\url{http://www.thereallyreallyverylonglink.com/pointing/to/some/interesting/stuff/in/the/web}
it seems to be important to import the packages in this order!
HTH
g
billy bob 11.16.10 at 14:21
If you use dvipdfm to make your pdf, you’ll need to use the following command:
\usepackage[dvipdfm]{hyperref}
in place of
\usepackage{hyperref}
Best!
Anomalie 02.19.11 at 13:02
An address like http://googlesystem.blogspot.com/2009/09/google-docs-has-equation-editor-oh-i-am-so-excited-this-has-been-a-long-time-coming-goodness-gracious-me-blah-blah-blah-someobody-shoot-me.html is not going to be solved even with all of these in effect
\usepackage{url}
\usepackage{hyperref}
\usepackage{breakurl}
because it’s not allowed to break at a hyphen, at least I couldn’t get it to. Help, please?
John 02.19.11 at 13:06
One way around the problem is to shrink the URL first through a service like bit.ly or goo.gl.
Anomalie 02.19.11 at 15:13
Thanks for that suggestion. I still feel that it should be possible to address the url wrapping problem within latex. I mean I suspect some of the above packages deliberately avoid breaking at hyphens because it creates ambiguity as to whether the hyphen is meant as a breaking hyphen or is actually a non-breaking hyphen that is part of the original URL.
The conflicts and overrides generated by successively calling on multiple packages really means you have to rack your brain to figure out the right order to call packages. Ultimately it may not be possible to manipulate the order so all commands provided by these packages work as they are intended to.
I’m using all of
\usepackage{url}
\usepackage{hyperref}
\usepackage{breakurl}
Can John or somebody else suggest a Latex solution, for a long URL with many hyphens?
Raz Ofek 11.16.11 at 15:22
I want to have the effect of an \hyperref but I don’t really want to link it to a web site. What I want is to have a box, with the text I provide, open whenever the cursor is on the supposed link. Nothing more. Any idea how I can do that?
pal2 11.18.11 at 20:57
it’s too good …simple …..
Ed Feng 12.19.11 at 11:10
John,
Thanks, made my life easy. You showed up in my Twitter feed last week. How about a follow as thanks?
Ed