# Avoiding inelegant splits on URLs

I am using biber and biblatex to process my bibliography. URLs are handled with breaklinks=true under hyperref.

I have found an inelegant breakup of a hyperlink resulting in a reference like this

Is there a way to enforce a more elegant breakup of a URL link where the h is not split from the ttp?

-
It seems that the author of biblatex has decided that, since URLs tend to give bad paragraphs, they should be split at any point, for the sake of good line breaking. –  egreg Oct 7 '11 at 17:59
@egreg Looks like he changed his mind in version 1.7. Numbers and letters are no longer breakpoints by default. They can be re-introduced by setting values for the breakpoint penalties. –  Audrey Nov 14 '11 at 15:47
@Audrey Nice to know; that choice may be interesting, but the author must be allowed to choose easily between the two possibilities –  egreg Nov 14 '11 at 16:02
From the Biblatex release notes: Version 1.7 adds counters which control the penalties associated with the additional breakpoints. They are disabled by default but may be helpful (as a last resort) if you need to deal with long and/or tricky DOIs. See 'biburlnumpenalty' etc. in the manual for details. –  matth Nov 17 '11 at 12:50

biblatex breaks URLs using the url package. Breakpoints are configured with \biburlsetup, discussed in this question. Version 1.7 of biblatex makes improvements to this command. By default it avoids breaks at lowercase letters entirely. The example below demonstrates how you could alter the breakpoint penalty for selected entries in a category.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{csquotes}
\usepackage[american]{babel}
\usepackage{biblatex}

% Set low penalties for breaks at numbers, uppercase letters and lowercase letters
\setcounter{biburlnumpenalty}{100}
\setcounter{biburlucpenalty}{100}
\setcounter{biburllcpenalty}{100}

% Define a category to selectively print entries with a higher lowercase penalty

\AtEveryBibitem{%
{\defcounter{biburllcpenalty}{9000}}
{}}


Thank you @Audrey. Your solution works. I take it that the commented lines were uncommented in the original definition and that putting them in the preamble after the invocation of biblatex accomplishes URL non-breaks at lowercase letters. Please correct me if I have misunderstood this. –  chandra Oct 8 '11 at 5:43
@chandra That is correct. You could prevent breaks at selected characters instead. In the code provided, for example, omitting \do\t from the original definition would have the same effect. Other ways to avoid dealing with breaks are to hyperlink the title or insert a break before printing the URL. –  Audrey Oct 8 '11 at 15:13