[Tex/LaTex] Footnote in input file – missing number treated as zero

errorsfootnotesinputurls

Let's say I have a document Foo.tex:

\documentclass[a4paper,11pt,titlepage]{article}
%...
%%Packages
\usepackage[utf8]{inputenc}
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{hyperref}
\usepackage{float}
\usepackage{caption}
\usepackage[]{algorithm2e}
%...
\begin{document}
\nocite{*}
\maketitle
\pagestyle{headings}
%...
\input{bar}

and bar.tex:

\section*{Bar}
Blah, blah and some such.
Very interesting thing\footnote{\href{http://whatever}}.
More blah.

then I get an error on the line with the footnote when trying to parse Foo.tex:

Missing number, treated as zero. \endgroup …{http://whatever}}

Removing the footnote will make the error disappear, so my guess is that even though we input the Bar.tex-file, Latex (usign TexLive with Texmaker, btw.) cannot discern the number of preceding \footnote{...} commands.

Any way to circumvent this?

Best Answer

A minimal example reproducing the error is:

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\footnote{\href{http://whatever}}
\end{document}

The solution: hyperref's \href has two arguments: \href{URL}{text}. Either use both or use \url{URL}:

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\footnote{\href{http://whatever}{some text}} or\footnote{\url{http://whatever}}
\end{document}