[Tex/LaTex] Forcing linebreaks in \url


This question led to a new package:

I wish to typeset some relatively long URLs in a piece of text, and when I use \url{..}, the resulting text does not respect the margin boundaries that govern the main text body, instead going all the way to the edge of the paper before wrapping around.

For reference, my preamble looks like this:


and example of the url I'm including is:

\item Some text


I'm compiling using pdflatex, although I doubt this makes a difference.

Best Answer

(converting a previous comment to an answer)

A quick google search (alas, too quick) reveals one solution. Use the [hyphens] option with the url package:


Some recommendations also include inserting \sloppy in case latex is trying too hard to align things.