[Tex/LaTex] Avoiding inelegant splits on URLs

biblatexhyperrefurls

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 this citation

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

Best Answer

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
\DeclareBibliographyCategory{badbreaks}
\addtocategory{badbreaks}{ctan}

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

\addbibresource{biblatex-examples.bib}
\begin{document}
\cite{ctan,markey,wassenberg}
\printbibliography
\end{document}

enter image description here