# URL linebreaks W/O \sloppy

Hours of reading the different articles on url linebreaking did not reveal a solution for the following problem:

I've got a long url, which I do not intend to short using online services. The url package and pdfLaTeX output is used. The line break occurs at a place, that looks ugly and that I cannot understand, why a tool that fortunately takes proper layout so serious, wraps here.

My MWE is:

\documentclass[10pt,a5paper]{book} % Regular text font size is 10 pt.

\usepackage{lipsum} % load paragraphs of filler text

\setlength{\oddsidemargin}{20mm}
\setlength{\textwidth}{108.5mm}

\usepackage{url}
\makeatletter
\makeatother

\begin{document}

\lipsum[2]

\end{document}


As can be seen, the "d" in the second last line is already overlength (compared to the paragraph above), still LaTeX adds the "f" instead of wrapping after the "d".

I fully understand, that the second last line cannot be perfectly justified as there are no spaces that can be enlarged (I've read about a package that enlarges the letters in these cases) - my question is just, why LaTeX makes things even worse with adding the "f" instead of making it the first letter in the last line, and what I can do about that without using the sloppy workaround, which makes the rest look far worse than just wrapping before the "f"?

I would say the best way is to reduce the places where an url can be broken.

Your given MWE reduced to only break the url after character d runs without problems and the wanted result on my MiKTeX 2.9:

\documentclass[10pt,a5paper]{book} % Regular text font size is 10 pt.

\usepackage{lipsum} % load paragraphs of filler text

\setlength{\oddsidemargin}{20mm}
\setlength{\textwidth}{108.5mm}

\usepackage{url}
\makeatletter
\do\/\do\d%
}
\makeatother

\begin{document}

\lipsum[2]


• Yes, I guess you are referring to your post here. The thing is just: If I use your suggestion with \usepackage[newcommands,newparameters]{ragged2e}, then the whole paragraph is ragged right (there is more text before the "Available"), which looks awful. So, why does LaTeX not break after the "d", even if it is explicitly told that this is possible and even though the hbox is already overfull? – Ben Aug 5 '13 at 9:41