# How to create internet link in PDF?

Let us consider the following example :

\documentclass[11pt,twoside,a4paper]{book}
\usepackage{hyperref}
\begin{document}
\href{url}{http://www.texample.net/tikz/resources/}
\end{document}


This gives :

When I click on the link on the PDF file it is not working. What is the way to go webpage clicking on the link ?

• Looks like you have your parameters backwards. Try \href{http://www.texample.net/tikz/resources/}{url}. The second parameter is the text to display, the first is the url to link to. – Peter Grill Apr 10 '13 at 2:01
• I am using 'Document viewer' on the system 'ubuntu 10.04' – Soumitra Sen Apr 10 '13 at 2:06
• Please add the viewer info to the question, and try switching the order of the paramaters. – Peter Grill Apr 10 '13 at 2:08
• It is do to the wrong order; I use Fedora with "Document Viewer" and I have no problems at all. – Svend Tveskæg Apr 10 '13 at 2:12
• Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. – jub0bs May 9 '13 at 12:43

You have the two parameters backwards. The correct syntax is:

\href{<url>}{<text to display>}.


The first parameter is the url to link to, the second is the text to display.

Also it should be noted that you need to ensure that your PDF viewer is capable of opening a link in a browser.

## Code:

\documentclass[11pt,twoside,a4paper]{book}
\usepackage{hyperref}
\begin{document}
\href{http://www.texample.net/tikz/resources/}{Tex Example Site}
\end{document}


Although this question is only about linking to external URLs, one can use \href to open other types of files as well. So with the example below (assuming that there exists a foo.pdf, foo.tex, foo.png files in the current directory), and viewing with TeXShop's PDF viewer, all the files can be opened by clicking on the links.

However, with TeXWorks and Mac Preview only the web url link works. All the links also work with Acrobat once you accept the security warning.

## Code:

\documentclass{article}
\usepackage{hyperref}

\begin{document}

• Why do you say TeXworks doesn't open external links? On my computer it seems to work fine. – Ari Brodsky Apr 10 '13 at 2:23