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 am trying to include a URL in my Latex document which contains a pound sign, #, in it. If I run it without escaping the # sign, I get an error. If I escape it, then the escape character is printed out in the URL also. ("\#" instead of "#") Any ideas on how to fix this?

\documentclass[12pt, a4paper, twoside]{article}
Hello World\endnote{\url{http://www.rossettiarchive.org/docs/nb0005.duke.rad.html#0.1.19}}
share|improve this question
Your code works OK in my system. What error do you get? What version of LaTeX system are you using? – Gonzalo Medina Jul 21 '12 at 19:26
I am using TexStudio and I get "Illegal Parameter number in definition of" then url string. The log file says "you meant to type ## instead of # right?" – Mike Stumpf Jul 21 '12 at 19:55
Did you get that error with the exact code you posted in your question? – Gonzalo Medina Jul 21 '12 at 19:59
add \listfiles and see what you get, it works for me and I get: File List article.cls 2007/10/19 v1.4h Standard LaTeX document class size12.clo 2007/10/19 v1.4h Standard LaTeX file (size option) fontenc.sty t1enc.def 2005/09/27 v1.99g Standard LaTeX file url.sty 2006/04/12 ver 3.3 Verb mode for urls, etc. t1cmtt.fd 1999/05/25 v2.5h Standard LaTeX font definitions – David Carlisle Jul 21 '12 at 20:07
In case it turns out that it's something TeXStudio does to the \footnote command, say, then defining a command for typesetting the url first using \urldef might help. – Harald Hanche-Olsen Jul 21 '12 at 20:25
up vote 9 down vote accepted

As you noticed, the # confuses TeX, because the endnotes are eventually read in as a macro replacement text.

Use \urldef for the problematic entry:

\documentclass[12pt, a4paper, twoside]{article}

Hello World\endnote{\rossetti}

Alternative way: put this in the preamble

\newcommand\specialendnote{\begingroup\catcode`\#=12 \specialendnoteaux}

and call

share|improve this answer
Thank you, it worked perfectly! – Mike Stumpf Jul 22 '12 at 20:52

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.