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 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?

share|improve this question
8  
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
1  
@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
add comment

1 Answer 1

up vote 12 down vote accepted

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

share|improve this answer
    
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
1  
@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
    
Thanks for the explanation and the two links. In my particular case, the author, via a citation note on the website, requires the URL to be cited in the bibliography, precluding hyperlinking the title, but a break before the URL is a good alternative solution here. –  chandra Oct 8 '11 at 17:22
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.