[Tex/LaTex] I cannot get a (properly) underlined hyperlink in blue

hyperreflinkspackage-options

First I just ignored the hyperref package and just wanted something that 'looked' like a link:

\underline{\color{Blue} http://soundcloud.com}

but I end up getting an underline about 3mm below the link, which looks extremely ugly. After loading hyperref, I messed about with the variables but there is no underline feature. The best I could do was get it in blue:

\hypersetup{colorlinks=true,urlcolor=blue}
\urlstyle{same}
\url{http://soundcloud.com}

Question: Can I get a blue, underlined link so that the line is directly underneath the text (with or without an actual hotlink)?

Best Answer

If you don't use hyperref:

\documentclass{article}
\usepackage{color}
\usepackage[normalem]{ulem}
\usepackage{url}

\DeclareUrlCommand\ULurl{%
  \renewcommand\UrlFont{\ttfamily\color{blue}}%
  \renewcommand\UrlLeft{\uline\bgroup}%
  \renewcommand\UrlRight{\egroup}}

\begin{document}

\ULurl{http://foo.bar/%12%34}

\end{document}

If you use hyperref, you may want to click on the URLs:

\documentclass{article}
\usepackage{xcolor}
\usepackage[normalem]{ulem}
\usepackage{hyperref}
\hypersetup{colorlinks,urlcolor=blue}
%% or
% \hypersetup{colorlinks=false,pdfborder=000}

% hack into hyperref
\makeatletter
\DeclareUrlCommand\ULurl@@{%
  \def\UrlFont{\ttfamily\color{blue}}%
  \def\UrlLeft{\uline\bgroup}%
  \def\UrlRight{\egroup}}
\def\ULurl@#1{\hyper@linkurl{\ULurl@@{#1}}{#1}}
\DeclareRobustCommand*\ULurl{\hyper@normalise\ULurl@}
\makeatother

\begin{document}

\ULurl{http://foo.bar/%12%34}

\end{document}