TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm creating a beamer presentation. I want to put a link to a source which has a hash-tag in it (#). When I try to compile this I get an error:

! Illegal parameter number in definition of \test.
<to be read again> 
l.91 \end{itemize}
                   % ends low level
? x

This is the line I'm using:


Is there a way around this?

share|improve this question
This \href line is ok. Find out which piece of code actually causes the error and post that here. – Stefan Kottwitz Feb 16 '12 at 9:43
The frame should be marked as fragile: \begin{frame}[fragile]. On the other hand, a hash symbol at the end of a link appears to be ignored. – egreg Feb 16 '12 at 11:17
@egreg: That is hyperref's rule, for good reason. \href@ $1->\expandafter \href@split $1##\$1<-http://example.com/ala.do?foo=bar&showSelfStudyTree=true# {\expandafter} \href@split $1#$2#$3\\$4->\hyper@@link {$1}{$2}{$4}\endgroup $1<-http://example.com/ala.do?foo=bar&showSelfStudyTree=true $2<- $3<-# $4<-source – Ahmed Musa Feb 16 '12 at 19:04
up vote 20 down vote accepted

Be careful to escape the hash character #:

\href{http://example.com/ala.do?foo=bar&showSelfStudyTree=true\#}{source} % # truncated

I have to admit that in this case (hash at the very end of the link), this achieves successful compilation, but the hash character is lost upon opening the link from my pdf-viewer (evince). If the hash is somewhere inside the link, it is preserved:

\href{http://example.com/ala.do?showSelfStudyTree=true\#&foo=bar}{source} % # perserved
share|improve this answer
Thanks. Turns out that I can simply remove the has and the link still works – Yotam Feb 16 '12 at 11:40

Your Answer


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.