[Tex/LaTex] Hyperref + \url: long URL with dashes won’t break

hyperrefline-breakingpunctuationurls

I've discovered a rather weird behaviour of PdfLaTeX. In this example

\documentclass{article}
\usepackage[breaklinks]{hyperref}
\begin{document}
\url{http://www.emarketer.com/blog/index.php/quick-stat-smartphone-users-account-38-mobile-phone-users/}
\end{document}

PdfLaTeX won't break the URL and create a too long line. However, if I replace \url with \href like this:

\documentclass{article}
\usepackage{hyperref}
\begin{document}
\href{http://www.emarketer.com/blog/index.php/quick-stat-smartphone-users-account-38-mobile-phone-users/}{http://www.emarketer.com/blog/index.php/quick-stat-smartphone-users-account-38-mobile-phone-users/}
\end{document}

I get the line broken, but the font of the link is not right any more of course (normal instead of texttt). Why doesn't URL break the line at dashes and what could I do to get a nicely typeset line-broken link?

Best Answer

Load the url package explicitly with the hyphens option:

\usepackage[hyphens]{url}
\usepackage{hyperref}

By default, the url package does not consider hyphens as legal break points.