[Tex/LaTex] Underscore in URL breaks link in pdf

footnotesunderscoreurl

I have a footnote with a long url containing an underscore, like this:

\footnote{\url{http://www.example.com/somethinglong_somethingotherlong}}

The link appears in the pdf, but it is broken off after the underscore and redirects to http://www.example.com/somethinglong_, which of course gives a page not found error.

How do I solve this? Adding a \ before the underscore doesn't do anything (the backslash just shows up in the pdf). It seems that the same problem was encountered here

URL linebreak in footnote

but I see no answer here as well.

EDIT: I can't use hyperref. Added MWE below.

\documentclass{article}
\usepackage{ismir,amsmath,cite,url}
\usepackage{graphicx}
\usepackage{color}
\usepackage[capitalise]{cleveref}
\usepackage{array}
\usepackage{alltt}
\usepackage{fixltx2e}

\begin{document}

Some text with a footnote.\footnote{\url{https://en.wikipedia.org/wiki/Hidden_Markov_model}}

\end{document}

Best Answer

Typesetting URL strings in footnotes is known to be tricky at times. It's best to use a defined-URL macro in such cases, using the \urldef machinery of the url package.

enter image description here

Feel free to load the hyperref package as well, so that clicking on the URL string (in a suitable pdf browser, naturally) takes you to the URL in question.

\documentclass{article}
\usepackage[hyphens,spaces,obeyspaces]{url}
\urldef{\footurl}\url{http://www.example.com/somethinglong_somethingotherlong}

\begin{document}
\footnote{\footurl}  % Use a "defined-URL macro" in the argument of "\footnote"
\end{document} 
Related Question