0

I'm writing my thesis and use the ext-authoryear stile with biblatex. (Unfortunately I have to make a lot of manual adjustments to fulfill the committee's "style" requirements.)

In my bibliography I use biburlnumpenalty to break the DOI to prevent it from being longer than the rest of the text. Unfortunately this does produce orphans in some cases - sometimes single digits on a new line. Is there a way to prevent those orphans? Or do I have to live with one of those two unelegant looks?

with biburlnumpenalty

without biburlnumpenalty

MWE

\documentclass[
paper=a4,                   
12pt,                           
BCOR=0.5cm,                     
twoside=false,                  
bibliography=totoc,             
abstract=true,                      
%draft,                         
open=right,                     
headings=normal,                
]
{scrreprt}

%

\usepackage[english]{babel}     
\usepackage[utf8]{inputenc}                 
\usepackage{lmodern}                            
\usepackage{microtype}

\usepackage{setspace}                           
\onehalfspacing                                 

\usepackage{scrlayer-scrpage}                   
\clearpairofpagestyles                          
\ofoot*{\pagemark}                          

\usepackage[autostyle]{csquotes}
\usepackage{etoolbox}       


\usepackage[
backend=biber,
style=ext-authoryear, 
useprefix=true,     
urldate=iso,            
seconds=true,           
articlein=false,        
innamebeforetitle=true, 
introcite=label,
sorting=nyt,
dashed=false,
maxcitenames=2,
mincitenames=1,
maxbibnames=999,
giveninits=true,
terseinits=true,
uniquename=init,
uniquelist=false,
isbn=false,
url=false       
]
{biblatex}              

\setlength{\bibitemsep}{6pt}        

\DeclareNameAlias{sortname}{family-given}       
\DeclareNameAlias{default}{family-given}

\DeclareFieldFormat[article, incollection, online]{title}{#1}       
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}}              
\DeclareFieldFormat{biblabeldate}{#1}                               
\DeclareFieldFormat{journaltitle}{#1\isdot}                         
\DeclareFieldFormat{booktitle}{#1}                                  
\DeclareFieldFormat[article]{volume}{#1}                             
\DeclareFieldFormat{pages}{#1}                                  
\DeclareNameAlias{default}{family-given}

\AtEveryBibitem{\clearfield{note}}      
\AtEveryBibitem{\clearfield{abstract}}  
\AtEveryBibitem{\clearfield{month}}     
\AtEveryBibitem{\clearfield{extradate}}  
\AtEveryCitekey{\clearfield{doi}} 

%\setcounter{biburlnumpenalty}{100}         % <---------------------------

\urlstyle{same}

\patchcmd{\bibsetup}{\interlinepenalty=5000}{\interlinepenalty=10000}{}{}

\DeclareDelimFormat{multicitedelim}{\addcomma\addspace}
\DeclareDelimFormat[bib]{finalnamedelim}{\addcomma\addspace}
\renewcommand{\revsdnamepunct}{}
\DeclareDelimFormat{volnumdelim}{}  
\DeclareDelimFormat[bib]{nameyeardelim}{\adddot\space}  
\DeclareDelimFormat{jourvoldelim}{\addcomma\addspace}

\renewcommand*{\bibpagespunct}{                             
    \ifboolexpr{(test {\ifentrytype{article}})}
    {\addcolon}
    {\addcomma\space}}

\DeclareFieldFormat{bbx@introcite}{\mkbibbrackets{#1}}
\DeclareDelimFormat[bbx@introcite]{nameyeardelim}{\space}
\UndeclareInnerCiteDelims{bbx@introcite}
\renewcommand*{\introcitepunct}{\quad}
\setlength\bibitemsep{1.5\itemsep}

\AtIntrocite{\DeclareFieldFormat{linkallcite}{#1}}


\DeclareFieldFormat{linkallcite}{%
    \DeclareFieldFormat{bibhyperref}{##1}%
    \bibhyperref{#1}%
}

\letbibmacro{cite:orig}{cite}
\renewbibmacro{cite}{%
    \printtext[linkallcite]{%
        \usebibmacro{cite:orig}}}



\usepackage[%
unicode=true,
linkcolor=red,
citecolor=green,
%pdfborderstyle={/S/U/W 1}, 
bookmarksopen=true,         
bookmarksopenlevel=2,    
%bookmarksnumbered=true,    
pdfdisplaydoctitle=true,    
%hidelinks=true,
linktoc=all,                
hypertexnames=false,                                
breaklinks=true 
]
{hyperref}                  

\begin{filecontents}{bib.bib}
    @Article{Shen2016,
    author    = {Shen, H. N. and Lu, C. L. and Yang, H. H.},
    journal   = {Critical Care Medicine},
    title     = {Risk of Recurrence After Surviving Severe Sepsis: A Matched Cohort Study},
    year      = {2016},
    issn      = {1530-0293 (Electronic)
        0090-3493 (Linking)},
    month     = oct,
    number    = {10},
    pages     = {1833--1841},
    volume    = {44},
    doi       = {10.1097/CCM.0000000000001824},
    publisher = {Ovid Technologies (Wolters Kluwer Health)},
    type      = {Journal Article},
    url       = {https://www.ncbi.nlm.nih.gov/pubmed/27120256},
    }

    @InCollection{Ferrans2004,
    author    = {Ferrans, Carol Estwing},
    booktitle = {Outcomes Assessment in Cancer: Measures, Methods and Applications},
    publisher = {Cambridge University Press},
    title     = {Definitions and conceptual models of quality of life},
    year      = {2004},
    address   = {Cambridge},
    editor    = {Lipscomb, Joseph and Gota, Carolyn C. and Snyder, Claire},
    month     = dec,
    pages     = {14--30},
    doi       = {10.1017/CBO9780511545856.002},
    }


\end{filecontents}

\bibliography{bib}

\begin{document}

\pagenumbering{arabic}              

Citing \parencite{Ferrans2004}

Citing \parencite{Shen2016}




\printbibliography              


\end{document}

1 Answer 1

0

I don't think there is a straightforward way to avoid this.

If you run the MWE without \setcounter{biburlnumpenalty}{100} and add \overfullrule=1em to mark overfull boxes, you'll see

\overfullrule=1em

and the .log shows

Overfull \hbox (15.55984pt too wide) in paragraph at lines 176--176
\OT1/lmr/m/n/12 (-20) Cam-bridge Uni-ver-sity Press, 14{30. \OT1/lmr/m/sc/12 (-
20) doi\OT1/lmr/m/n/12 (-20) : []$10 . 1017 / CBO9780511545856 .|
[]


Overfull \hbox (3.12871pt too wide) in paragraph at lines 176--176
\OT1/lmr/m/n/12 (-20) Medicine, 44(10):1833{1841. \OT1/lmr/m/sc/12 (-20) doi\OT
1/lmr/m/n/12 (-20) : []$10 . 1097 / CCM . 0000000000001824$[]. |
[]

So both lines are overfull, but the effect is much smaller in the second entry.

As soon as you allow your DOIs to break at numbers, the second entry will take you up on this offer, since the overfull box is to be avoided. The choice here is not between a slightly more compressed line without unfortunate line break and a line with more natural spaces and an unfortunate line break – the choice is between an overfull box and no line break or a nicely typeset line and a bad break.

What's more URLs, DOIs etc. line breaks are implemented fairly simplistic by inserting a penalty after each (numeric/uppercase/lowercase) character. There is no information about the number of following characters and there is nothing as complex as hyphenation patterns that could try and avoid one-letter word-ends going to the next page.

I'd probably accept the unfortunate line break. People know that URLs, DOIs etc. are hard to break, so most people will probably not mind. Of course you could try one of the more radical methods shown in How to adjust the breaking in the bibliography? to change the line breaking behaviour in your bibliography more drastically, which may or may not have a positive effect on these URLs, DOIs etc.


Here is a workaround I can offer for this particular case.

Since biblatex 3.13 you can add some stretchable and shrinkable space between characters in URLs, DOIs etc. See BibLaTeX long URL extending into border despite using biburllcpenalty. So here

\setcounter{biburlnumpenalty}{100}
\biburlnumskip=0mu plus 1mu minus 1mu\relax

would not only allow line breaks but would also add some tiny bit of shrinkable and stretchable space after each numeric character in URLs. As luck would have it that tiny space is enough here (but don't count on that in general!).

\documentclass[
paper=a4,
12pt,
BCOR=0.5cm,
twoside=false,
bibliography=totoc,
abstract=true,
%draft,
open=right,
headings=normal,
]
{scrreprt}
%

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{microtype}

\usepackage{setspace}
\onehalfspacing

\usepackage{scrlayer-scrpage}
\clearpairofpagestyles
\ofoot*{\pagemark}

\usepackage[autostyle]{csquotes}
\usepackage{etoolbox}


\usepackage[
backend=biber,
style=ext-authoryear,
useprefix=true,
urldate=iso,
seconds=true,
articlein=false,
innamebeforetitle=true,
introcite=label,
sorting=nyt,
dashed=false,
maxcitenames=2,
mincitenames=1,
maxbibnames=999,
giveninits=true,
terseinits=true,
uniquename=init,
uniquelist=false,
isbn=false,
url=false
]
{biblatex}

\DeclareNameAlias{sortname}{family-given}
\DeclareNameAlias{default}{family-given}

\DeclareFieldFormat[article, incollection, online]{title}{#1}
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}}
\DeclareFieldFormat{biblabeldate}{#1}
\DeclareFieldFormat{journaltitle}{#1\isdot}
\DeclareFieldFormat{booktitle}{#1}
\DeclareFieldFormat[article]{volume}{#1}
\DeclareFieldFormat{pages}{#1}
\DeclareNameAlias{default}{family-given}

\AtEveryBibitem{\clearfield{note}}
\AtEveryBibitem{\clearfield{abstract}}
\AtEveryBibitem{\clearfield{month}}
\AtEveryBibitem{\clearfield{extradate}}
\AtEveryCitekey{\clearfield{doi}}

\setcounter{biburlnumpenalty}{100}
\biburlnumskip=0mu plus 1mu minus 1mu\relax



\urlstyle{same}


\patchcmd{\bibsetup}{\interlinepenalty=5000}{\interlinepenalty=10000}{}{}

\DeclareDelimFormat{multicitedelim}{\addcomma\addspace}
\DeclareDelimFormat[bib]{finalnamedelim}{\addcomma\addspace}
\renewcommand{\revsdnamepunct}{}
\DeclareDelimFormat{volnumdelim}{}
\DeclareDelimFormat[bib]{nameyeardelim}{\adddot\space}
\DeclareDelimFormat{jourvoldelim}{\addcomma\addspace}

\renewcommand*{\bibpagespunct}{%
  \ifentrytype{article}
    {\addcolon}
    {\addcomma\space}}

\DeclareFieldFormat{bbx@introcite}{\mkbibbrackets{#1}}
\DeclareDelimFormat[bbx@introcite]{nameyeardelim}{\addspace}
\UndeclareInnerCiteDelims{bbx@introcite}

\setlength\bibitemsep{1.5\itemsep}

\AtIntrocite{\DeclareFieldFormat{linkallcite}{#1}}


\DeclareFieldFormat{linkallcite}{%
  \DeclareFieldFormat{bibhyperref}{##1}%
  \bibhyperref{#1}%
}

\letbibmacro{cite:orig}{cite}
\renewbibmacro{cite}{%
  \printtext[linkallcite]{%
    \usebibmacro{cite:orig}}}



\usepackage[%
unicode=true,
linkcolor=red,
citecolor=green,
%pdfborderstyle={/S/U/W 1},
bookmarksopen=true,
bookmarksopenlevel=2,
%bookmarksnumbered=true,
pdfdisplaydoctitle=true,
%hidelinks=true,
linktoc=all,
hypertexnames=false,
breaklinks=true
]
{hyperref}

\begin{filecontents}{\jobname.bib}
@Article{Shen2016,
  author    = {Shen, H. N. and Lu, C. L. and Yang, H. H.},
  journal   = {Critical Care Medicine},
  title     = {Risk of Recurrence After Surviving Severe Sepsis: A Matched Cohort Study},
  year      = {2016},
  issn      = {1530-0293 (Electronic)
               0090-3493 (Linking)},
  month     = oct,
  number    = {10},
  pages     = {1833--1841},
  volume    = {44},
  doi       = {10.1097/CCM.0000000000001824},
  publisher = {Ovid Technologies (Wolters Kluwer Health)},
  type      = {Journal Article},
  url       = {https://www.ncbi.nlm.nih.gov/pubmed/27120256},
}
@InCollection{Ferrans2004,
  author    = {Ferrans, Carol Estwing},
  booktitle = {Outcomes Assessment in Cancer: Measures, Methods and Applications},
  publisher = {Cambridge University Press},
  title     = {Definitions and conceptual models of quality of life},
  year      = {2004},
  address   = {Cambridge},
  editor    = {Lipscomb, Joseph and Gota, Carolyn C. and Snyder, Claire},
  month     = dec,
  pages     = {14--30},
  doi       = {10.1017/CBO9780511545856.002},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
Citing \parencite{Ferrans2004}

Citing \parencite{Shen2016}

\printbibliography
\end{document}

Nicely broken DOIs.

2
  • Thanks for your excellent answer. I think I'll go with \biburlnumskip for now before trying more radical measures - I'll have to check again when the bibliography is complete. Could you please explain the syntax a bit more, because for me \biburlnumskip=0mu plus 1mu minus 1mu adds up to 0 and I don't understand why it does something at all. Commented Jun 28, 2020 at 10:18
  • @ChristianKönig 0mu plus 1mu minus 1mu is a space of 0mu that can (if required for example for nicer line breaking) stretch by up to 1mu (that's the plus bit) and shrink by up to 1mu (the minus bit). See for example tex.stackexchange.com/q/64756/35864.
    – moewe
    Commented Jun 28, 2020 at 11:01

You must log in to answer this question.

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