4

Somehow, the following code is not compiling:

\documentclass[10pt,a4paper]{article}
\usepackage{hyperref}
\usepackage{xcolor}
\definecolor{medium-blue}{rgb}{0,0,1}
\hypersetup{colorlinks, urlcolor={medium-blue}}

\begin{document}
Text\footnote{\href{http://google.co.in}}
\end{document}

If I replace \href with \url, the code seems to work. However, I insist on using \href because I like its output better.

2 Answers 2

8

This is nothing to do with the footnote. The \href macro takes two arguments. The first is the link destination, and the second is what's displayed.

\documentclass[10pt,a4paper]{article}
\usepackage{hyperref}
\usepackage{xcolor}
\definecolor{medium-blue}{rgb}{0,0,1}
\hypersetup{colorlinks, urlcolor={medium-blue}}

\begin{document}
Text\footnote{Click \href{http://google.co.in}{here}.}
\end{document}
7
  • Gosh! I have been using \href for so long now. Yet, I completely forgot about the second argument this time. I had myself convinced that this has something to do with the \footnote command. Thanks! Nov 8, 2014 at 15:40
  • 1
    Do you suggest that I delete/remove this question since it kinda wrong, misleading and silly? Nov 8, 2014 at 15:41
  • @vkarve --- It's entirely up to you. Nov 8, 2014 at 15:45
  • 2
    @vkarve, I just stumbled upon this. It was of no help to me. Maybe, yes, you could have the question deleted.
    – florland
    Nov 19, 2018 at 10:14
  • Actually \href{}{} does not work in the footnote if the link includes a %.
    – bkocsis
    Oct 12, 2023 at 22:50
2

Make sure that special characters are properly escaped. For example:

  • #, %, &
  • or accidentally encoded special characters like round brackets (, ) .
This \footnote{
\href{https://kit.svelte.dev/docs/load\#page-data}
{SvelteKit docs: Loading data - Page data}
}
That \footnote{
\href{https://en.wikipedia.org/wiki/Constructivism_(philosophy_of_education)}
{philo of edu with round brackets}
}
Those \footnote{
\href{https://en.wikipedia.org/wiki/Constructivism_\%28philosophy_of_education\%29}
{philo of edu with encoded round brackets}
}
(encoded with JS function \verb|URIComponent|)

The produced result will look like this: enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .