\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[backend=biber,hyperref,style=chem-angew,subentry]{biblatex}
\usepackage{doi}
% https://tex.stackexchange.com/questions/464215/biblatex-hyperlink-entire-bib-entry-to-doi-url-or-isbn-if-available
\newbibmacro{string+doiurl}[1]{%
\iffieldundef{doi}
{\iffieldundef{url}
{#1}
{\href{\thefield{url}}{#1}}}
{\href{https://doi.org/\thefield{doi}}{#1}}}
\makeatletter
\def\blx@driver#1{%
\ifcsdef{blx@bbx@#1}
{\usebibmacro{string+doiurl}{\csuse{blx@bbx@#1}}}
{\ifcsdef{blx@bbx@*}
{\blx@warning{%
No driver for entry type '#1'.\MessageBreak
Using fallback driver}%
\usebibmacro{string+doiurl}{\csuse{blx@bbx@*}}}
{\blx@error
{No driver found}
{I can't find a driver for the entry type
'\abx@field@entrytype'\MessageBreak
and there is no fallback driver either}}}}
\makeatother
\begin{filecontents}{\jobname.bib}
@article{Salsi2020,
author = {Salsi, Federico and Neville, Michael and Drance, Myles and Hagenbach, Adelheid and Chan, Chinglin and Figueroa, Joshua S. and Abram, Ulrich},
date = {2020},
doi = {10.1039/D0CC03043K},
journaltitle = {Chem. Commun.},
volume = {56},
pages = {7009-7012},
}
@article{Claude2020,
author = {Claude, Guilhem and Salsi, Federico and Hagenbach, Adelheid and Gembicky, Milan and Neville, Michael and Chan, Chinglin and Figueroa, Joshua S. and Abram, Ulrich},
date = {2020},
doi = {10.1021/acs.organomet.0c00238},
journaltitle = {Organometallics},
volume = {12},
pages = {2287–2294},
}
@article{Figueroa2020,
author = {Figueroa, Joshua S. and Abram, Ulrich},
date = {2020},
doi = {10.1002/zaac.202000147},
journaltitle = {Z. Anorg. Allg. Chem.},
pages = {1--7},
volume = {646},
}
@article{Hoffmann1990,
author = {Hoffmann, Roald},
date = {1991},
doi = {10.2307/431761},
journaltitle = {Interdiscipl. Sci. Rev.},
pages = {301--312},
volume = {16},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\defbibentryset{set}{Salsi2020,Claude2020,Figueroa2020}
Cite it.\supercite{set} And do it again.\supercite{Hoffmann1990}
\printbibliography
\end{document}
我从以下答案中获取了将 doi 超链接添加到参考文献的代码:用户 moewe。不幸的是,我不够聪明,无法弄清楚他(或她)在那里做了什么,但对我来说效果很好。有一个例外:如果参考书目中有一组参考文献,则在所有分号和句号之前会以某种方式出现额外的空格(参见参考文献 1)。如果引用单个参考文献则不会出现这种情况,参见参考文献 2。有人可以帮我解决这个问题吗?引入的空格看起来不美观,在某些情况下会导致换行问题。如果文件编译时注释掉了从到的行,则不会出现这些\newbibmacro{string+doiurl}[1]{%
空格\makeatother
。
答案1
该空格是由于的驱动程序%
中缺少 造成的。请参阅chem-angew
@article
https://github.com/josephwright/biblatex-chem/pull/19。
直到上述拉取请求合并并且biblatex-chem
发布修复的新版本之前,您可以将驱动程序的修复版本添加到您的序言中。
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[backend=biber,style=chem-angew,subentry]{biblatex}
\usepackage{hyperref}
\newbibmacro{string+doiurl}[1]{%
\iffieldundef{doi}
{\iffieldundef{url}
{#1}
{\href{\thefield{url}}{#1}}}
{\href{https://doi.org/\thefield{doi}}{#1}}}
\makeatletter
\def\blx@driver#1{%
\ifcsdef{blx@bbx@#1}
{\usebibmacro{string+doiurl}{\csuse{blx@bbx@#1}}}
{\ifcsdef{blx@bbx@*}
{\blx@warning{%
No driver for entry type '#1'.\MessageBreak
Using fallback driver}%
\usebibmacro{string+doiurl}{\csuse{blx@bbx@*}}}
{\blx@error
{No driver found}
{I can't find a driver for the entry type
'\abx@field@entrytype'\MessageBreak
and there is no fallback driver either}}}}
\makeatother
\DeclareBibliographyDriver{article}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/translator+others}%
\setunit{\labelnamepunct}\newblock
\iftoggle{bbx:articletitle}
{%
\usebibmacro{title}%
\newunit
}
{}%
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{bytranslator+others}%
\newunit\newblock
\printfield{version}%
\newunit\newblock
\usebibmacro{journal+issuetitle}%
\newunit
\usebibmacro{byeditor+others}%
\newunit
\usebibmacro{note+pages}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{issn}}
{}%
\newunit\newblock
\usebibmacro{doi+eprint+url}%
\newunit\newblock
\usebibmacro{addendum+pubstate}%
\setunit{\bibpagerefpunct}\newblock
\usebibmacro{pageref}%
\newunit\newblock
\iftoggle{bbx:related}
{\usebibmacro{related:init}%
\usebibmacro{related}}
{}%
\usebibmacro{finentry}%
}
\begin{filecontents}{\jobname.bib}
@article{Salsi2020,
author = {Salsi, Federico and Neville, Michael and Drance, Myles and Hagenbach, Adelheid and Chan, Chinglin and Figueroa, Joshua S. and Abram, Ulrich},
date = {2020},
doi = {10.1039/D0CC03043K},
journaltitle = {Chem. Commun.},
volume = {56},
pages = {7009-7012},
}
@article{Claude2020,
author = {Claude, Guilhem and Salsi, Federico and Hagenbach, Adelheid and Gembicky, Milan and Neville, Michael and Chan, Chinglin and Figueroa, Joshua S. and Abram, Ulrich},
date = {2020},
doi = {10.1021/acs.organomet.0c00238},
journaltitle = {Organometallics},
volume = {12},
pages = {2287–2294},
}
@article{Figueroa2020,
author = {Figueroa, Joshua S. and Abram, Ulrich},
date = {2020},
doi = {10.1002/zaac.202000147},
journaltitle = {Z. Anorg. Allg. Chem.},
pages = {1--7},
volume = {646},
}
@article{Hoffmann1990,
author = {Hoffmann, Roald},
date = {1991},
doi = {10.2307/431761},
journaltitle = {Interdiscipl. Sci. Rev.},
pages = {301--312},
volume = {16},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\defbibentryset{set}{Salsi2020,Claude2020,Figueroa2020}
Cite it.\supercite{set} And do it again.\supercite{Hoffmann1990}
\printbibliography
\end{document}