3

I'm try to open a .pdf to a specific page from my pdf generate using pdflatex, this is a valid urlthat do what I want in my browser:

http://www.icomos.org/charters/venice_e.pdf#page=4

#page=4 indicate the page I want to open, but it seems that when I use it in a \footnotedoesn't work:

\footnote{\url{http://www.icomos.org/charters/venice_e.pdf#page=4}}

In my LaTeX document, doesn't work I've got this error:

Illegal parameter number in definition of \Hy@tempa.<to be read again>p ....icomos.org/charters/venice_e.pdf#page=4}}

Caused by #page=4. This is a MWE:

\documentclass[12pt,a4paper]{book}
\usepackage{hyperref}
\begin{document}
words words words \footnote{\url{http://www.icomos.org/charters/venice_e.pdf#page=4}}
\end{document}

How can I solve the problem?

G M
  • 2,225
  • Could you please provide a MWE? If you use the url package with your \url{http://www.icomos.org/charters/venice_e.pdf#page=4}, there is no error... – Mario S. E. Oct 21 '13 at 15:39
  • Are you using \url{<something with #>} in an argument to another macro? – Qrrbrbirlbel Oct 21 '13 at 15:40
  • 1
    Well, as a quick fix you can enable it by using \. Like this: \footnote{\url{http://www.icomos.org/charters/venice_e.pdf\#page=4}} – Mario S. E. Oct 21 '13 at 16:19
  • You should take a look at these couple of questions (possible duplicate?): http://tex.stackexchange.com/questions/13224/how-to-use-a-link-as-footnote-that-has-special-characters-inside http://tex.stackexchange.com/questions/12230/getting-percent-sign-into-an-url-in-a-footnote and http://tex.stackexchange.com/questions/12855/getting-those-signs-in-the-footnote – Mario S. E. Oct 21 '13 at 16:23
  • @Mario Yes I think i should delate the question... – G M Oct 21 '13 at 16:24
  • Don't worry, it will be marked as duplicate. It's better, since this will allow people who ask questions like you follow the same answer :) – Mario S. E. Oct 21 '13 at 16:25

1 Answers1

1

Three possible solutions

  1. Using \ to scape the special character, i.e., \footnote{\url{http://www.icomos.org/charters/venice_e.pdf\#page=4}}

  2. Use a new command named \urlfootnote, as described by the following code in your preamble:

Code

\makeatletter
\newcommand\urlfootnote@[1]{\footnote{\url@{#1}}}
\DeclareRobustCommand{\urlfootnote}{\hyper@normalise\urlfootnote@}
\makeatother
  1. Define it at the beginning of your code, like this:

Code

\documentclass{article}
\usepackage{url}
\urldef\myurl\url{foo%.com}
\begin{document}
text\footnote{WWW: \myurl}
\end{document}
  1. Martin's complete answer here: https://tex.stackexchange.com/a/12864/27833
Mario S. E.
  • 18,609