Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 16 down vote accepted

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.

share|improve this answer
    
Beautiful, thank you! –  texnic Mar 28 '12 at 10:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.