所以我有一个 mendeley 个人资料,我在其中创建了我的论文的 bib 文件。对于多篇论文,我提供了多个 URL(例如 arxiv 和 github repo)。
当我引用一篇包含多个 URL 的论文时,参考文献中的 URL 键会变得混乱。具体来说,两个 URL 之间没有空格,而且上面的链接也不正确。
有没有办法来解决这个问题 ?
围兜参赛样本:
@article{ControlNet,
title = {{Adding Conditional Control to Text-to-Image Diffusion Models}},
year = {2023},
author = {Zhang, Lvmin and Rao, Anyi and Agrawala, Maneesh},
month = {2},
url = {http://arxiv.org/abs/2302.05543 https://github.com/lllyasviel/ControlNet},
arxivId = {2302.05543}
}
biblatex 设置:
\usepackage[style=numeric]{biblatex}
\addbibresource{references.bib}
引用:
\cite{ControlNet}
============== 编辑
根据评论中提供的链接进行相应调整:github.com/plk/biblatex/issues/229#issuecomment-279766334
bibtex 设置如下:
%% Setup Bibliography
\usepackage[style=numeric, datamodel=urls]{biblatex}
\DeclareListFormat{urls}{%
\url{#1}%
\ifthenelse{\value{listcount}<\value{liststop}}
{\addcomma\space}
{}}
\renewbibmacro*{url}{\iffieldundef{url}{\printlist{urls}}{\printfield{url}}}
\addbibresource{references.bib}
urls.dbx 文件:
\DeclareDatamodelFields[type=list, datatype=uri]{urls}
\DeclareDatamodelEntryfields{urls}
问题仍然存在-我做错了什么?
答案1
仅适用于由空格分隔的 URL。
\documentclass[paper=a5,DIV=16,parskip=half-,fontsize=10pt]{scrreprt}
\usepackage[british]{babel}
\usepackage[autostyle]{csquotes}
\begin{filecontents}[force,noheader]{\jobname.bib}
@article{ControlNet,
title = {{Adding Conditional Control to Text-to-Image Diffusion Models}},
year = {2023},
author = {Zhang, Lvmin and Rao, Anyi and Agrawala, Maneesh},
month = {2},
url = {http://arxiv.org/abs/2302.05543 https://github.com/lllyasviel/ControlNet},
arxivId = {2302.05543}
}\end{filecontents}
\usepackage[style=authoryear]{biblatex}
\def\URLA#1 #2 #3!!{\url{#1}\ifx\relax#2\relax\else, \url{#2}\fi
\ifx\relax#3\relax \else, \URLA#3 !!\fi}
\DeclareFieldFormat{url}{%
\mkbibacro{URL}(s)\addcolon\addspace
\begingroup\edef\x{\endgroup\noexpand\URLA\thefield{urlraw} !!}\x}
\addbibresource{\jobname.bib}
\begin{document}
\cite{ControlNet}
\printbibliography
\end{document}