18

I want to add a hyperlink

\documentclass{article}

\usepackage{hyperref}

\begin{document}
\href{http://de.wikipedia.org/wiki/Hybridorbital#Beispiele}
     {http://de.wikipedia.org/wiki/Hybridorbital#Beispiele}
\end{document}

which has a # in the link, however if I enter it as \# Beispiele it won't open the link in the PDF and only if I leave the section after # will it open the page. However, I want it to open at a specific section in the webpage, which is coded by the # part.

gasserv
  • 253

2 Answers2

15

You have to prefix the hash with a backslash:

\href{http://de.wikipedia.org/wiki/Hybridorbital#Beispiele}
{http://de.wikipedia.org/wiki/Hybridorbital\#Beispiele}

Now it should work ;)

  • 3
    Note that the prefixed backslash is only necessary in the second argument which is the on to be typset by the TeX engin and therefore must respect TeX special symbols (which # is one of). The first argument is the verbatim link an though doesn’t need special cares on symbols. – Tobi Apr 02 '13 at 11:05
  • 1
    I got it now! My mistake was that I wrote # Beispiel instead of #Beispiel (without space in between) because I thought it wouldn't recognise the second command. – gasserv Apr 02 '13 at 11:11
10

use \url instead:

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\url{http://de.wikipedia.org/wiki/Hybridorbital#Beispiele}
\end{document}
Micha
  • 2,869