Based on Avoiding inelegant splits on URLs, I have this MWE:

  author = {Author, A. and Buthor, B.  },
  year = {2001},
  title = {Alpha aaa},
  url = {http://www.thewebsiteurl.com/ab/XC/PYR12337.pdf},
  author = {Authoq, A. and Buthoq, B.  },
  year = {2002},
  title = {Betaa bbb},
  url = {http://www.trythesesites.com/cx/AB/KXY0012C.pdf},

\def\mybiburlval{0}% 0 is otherwise the default
% \def\mybiburlval{1}% uncomment this to set to 1

% hyphenation does not work in URLs:
% so use as per:
% https://tex.stackexchange.com/questions/30857/avoiding-inelegant-splits-on-urls

% Set low penalties for breaks at numbers, uppercase letters and lowercase letters

% Define a category to selectively print entries with a higher lowercase penalty
\addtocategory{badbreaks}{A01} % only A01 here



A: \fullcite{A01}

B: \fullcite{A02}



Compiled this with pdflatex test.tex && biber test && pdflatex test.tex && pdflatex test.tex, using Texlive 2014 frozen. Here is a screenshot of how evince renders this output:


So the links mostly "leak"/"spill over" the margin, except the second one, which is line-broken at a period/dot.

Now uncomment the \def\mybiburlval{1} line, and recompile again; the output now is:


Notice how all links are line-broken here at lowercase characters - even if I've only added the first (A01) citation to the badbreaks category; and even if I've set the lower case breaking penalty to the smallest possible value (1)!

So my question is - how can I selectively choose to have a URL break only for the citations which are in the badbreaks category (in this case, only A01); and otherwise typeset links as in the usual case (even if they spill over the margin)?

Maybe of note would be to recall:

$ texdef -t latex -p biblatex -f setcounter
\setcounter is defined by (La)TeX.

macro:#1#2->\@ifundefined {c@#1}{\@nocounterr {#1}}{\global \csname c@#1\endcsname #2\relax }

$ texdef -t latex -p biblatex -f defcounter
\defcounter first defined in "etoolbox.sty".

\protected macro:#1#2->\ifcsundef {c@#1} {\etb@noglobal \@nocounterr {#1}}{\csname c@#1\endcsname \numexpr #2\relax }

So, apparently, \setcounter is global, and \defcounter is not (is local) - but I get the same output (i.e. breaking applied nonselectively everywhere), even if I use \setcounter instead of \defcounter in the switch - and even if I specifically set a 0 in the "else" part, as in:

    {\setcounter{biburllcpenalty}{0}   }}

So how can I apply url breaking at lowercase characters selectively - only to some citations?

1 Answer 1


The penalties are not used in a bibitem, but only in \biburlsetup which is done at the begin of the bibliography. If you want to change the settings for one bibitem, you should call the url setup again:


Output with OP MWE (\def\mybiburlval{0}):


  • Many thanks for that, @UlrikeFischer - seems to work, added image to the answer; however, I'm slightly puzzled: \ifcategory by definition should have the true clause be written first; yet in the output, the A01 url (which is added to category) is not broken at lowercase; while only the A02 url (which is not in category, so should not be broken) is in fact line-broken. Any ideas why?
    – sdaau
    May 29, 2015 at 14:59
  • 1
    A01 is the entry with the author "Author" and the title alpha. So the output is correct. It would naturally be easier to see, if you hadn't chosen so similar names ... May 29, 2015 at 15:26
  • Thanks again, @UlrikeFischer - that was indeed it; while trying to write a separate question, I could confirm that if I specify \printbibliography[sorting=none] (and then, if I want also the citation numbers to be in order, I also have to do \usepackage[backend=biber,defernumbers=true]{biblatex} along with \printbibliography[sorting=none,resetnumbers=true]). Cheers!
    – sdaau
    May 29, 2015 at 15:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .