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.

2
  • Welcome to TeX.sx! Please note that you can mark inline code with back ticks like `code`. Furthermore I made a minimal working example (MWE) of your code but adding a documentclass. Commented Apr 2, 2013 at 11:10
  • Do you really mean \\# Beispiele and not \# Beispiele (single backslash)? Commented Apr 2, 2013 at 11:11

2 Answers 2

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 ;)

2
  • 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. Commented Apr 2, 2013 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. Commented Apr 2, 2013 at 11:11
10

use \url instead:

\documentclass{article} \usepackage{hyperref} \begin{document} \url{http://de.wikipedia.org/wiki/Hybridorbital#Beispiele} \end{document} 
2
  • 1
    Didn't think of that :) Note that \url typesets the url in typewriter font by default. Commented Apr 2, 2013 at 11:04
  • 7
    Just use \urlstyle{same} to change this behaviour. @Micha may like to add this to the answer. Commented Apr 2, 2013 at 11:06

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.