Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
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. –  Tobi Apr 2 '13 at 11:10
    
Do you really mean \\# Beispiele and not \# Beispiele (single backslash)? –  Tobi Apr 2 '13 at 11:11
add comment

2 Answers

up vote 6 down vote accepted

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

share|improve this answer
2  
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 2 '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 2 '13 at 11:11
add comment

use \url instead:

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.