如何防止 biburlnumpenalty 在 DOI 中创建孤儿

如何防止 biburlnumpenalty 在 DOI 中创建孤儿

我正在撰写论文,并使用 biblatex 的 ext-authoryear 格式。(不幸的是,我必须进行大量手动调整才能满足委员会的“风格”要求。)

在我的参考书目中,我使用biburlnumpenalty拆分 DOI 来防止它比文本的其余部分更长。不幸的是,这在某些情况下会产生孤立字符 - 有时新行上会出现一位数字。有没有办法防止这些孤立字符?或者我必须忍受这两种不雅观中的一种?

与 biburlnumpenalty

无罚款

平均能量损失

\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

我认为没有简单的方法可以避免这种情况。

如果你运行 MWE 而不\setcounter{biburlnumpenalty}{100}添加\overfullrule=1em标记超满框,你会看到

\overfullrule=1em

.log表演

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$[]. |
[]

因此,两条线都过满,但第二条线的效果要小得多。

只要您允许 DOI 在数字处换行,第二个条目就会接受您的提议,因为要避免出现框过满的情况。此处的选择不是在稍微压缩一些且没有不合适的换行符的行和具有更自然空格且有不合适的换行符的行之间进行选择,而是在框过满且没有换行符或排版良好的行和糟糕的换行符之间进行选择。

此外,URL、DOI 等换行符的实现相当简单,只需在每个(数字/大写/小写)字符后插入惩罚即可。没有关于后续字符数量的信息,也没有像连字符模式这样复杂的功能,可以尝试避免单字母单词结尾转到下一页。

我可能会接受这个不幸的换行符。人们知道 URL、DOI 等很难打破,所以大多数人可能不会介意。当然,你可以尝试在如何调整参考书目的断行?更大程度地改变参考书目中的换行行为,这可能会或可能不会对这些 URL、DOI 等产生积极影响。


以下是针对这一特殊情况我可以提供的一种解决方法。

biblatex3.13 版起,你可以在 URL、DOI 等字符之间添加一些可伸缩的空间。请参阅尽管使用了 biburllcpenalty,BibLaTeX 长 URL 仍延伸到边框。 所以在这里

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

不仅允许换行,还会在 URL 中的每个数字字符后添加一些可收缩和可拉伸的微小空间。幸运的是,这些微小的空间在这里就足够了(但一般不要指望这一点!)。

\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}

完美分解的 DOI。

相关内容