![在 @book 条目上的出版商+年份上添加 doi 超链接](https://linux22.com/image/423911/%E5%9C%A8%20%40book%20%E6%9D%A1%E7%9B%AE%E4%B8%8A%E7%9A%84%E5%87%BA%E7%89%88%E5%95%86%2B%E5%B9%B4%E4%BB%BD%E4%B8%8A%E6%B7%BB%E5%8A%A0%20doi%20%E8%B6%85%E9%93%BE%E6%8E%A5.png)
我想激活参考书目的某些字段的 doi 超链接。对于@article
,这些是journal+volume+year+pages
。对于@book
,在publisher+year
。
Marco Daniel 在回答以下问题时编写了以下非常有用的代码,完全实现了第一个目标此主题。我将其复制并粘贴到下面以方便使用。不幸的是,它不处理@book
参考书目条目。我的问题是是否有人可以编辑此代码以实现字段上的 doi 超链接的附加功能出版商+年份用于@book 条目。
\documentclass{article}
\usepackage[backend=biber,backref=true]{biblatex}
\addbibresource{biblatex-examples.bib}
\usepackage[colorlinks]{hyperref}
\ExecuteBibliographyOptions{doi=false}
\ExecuteBibliographyOptions{doi=false}
\DeclareFieldFormat{doilink}{%
\iffieldundef{doi}{#1}%
{\href{http://dx.doi.org/\thefield{doi}}{#1}}}
\DeclareBibliographyDriver{article}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/translator+others}%
\setunit{\labelnamepunct}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{bytranslator+others}%
\newunit\newblock
\printfield{version}%
\newunit\newblock
\usebibmacro{in:}%
\printtext[doilink]{%
\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}%
\usebibmacro{finentry}}
\begin{document}
\cite{kastenholz}\qquad\cite{herrmann}\qquad\cite{sigfridsson}
\printbibliography
\end{document}
答案1
您可以对所有条目类型使用相同的策略:从standard.bbx
并添加\printtext[doilink]{...}
您想要链接的内容。
@article
以下代码展示了和的当前版本的方法@book
。
\documentclass{article}
\usepackage[backend=biber,backref=true]{biblatex}
\usepackage[colorlinks]{hyperref}
\ExecuteBibliographyOptions{doi=false}
\DeclareFieldFormat{doilink}{%
\iffieldundef{doi}{#1}%
{\href{https://doi.org/\thefield{doi}}
{#1}}}
\DeclareBibliographyDriver{article}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/translator+others}%
\setunit{\printdelim{nametitledelim}}\newblock
\usebibmacro{title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{bytranslator+others}%
\newunit\newblock
\printfield{version}%
\newunit\newblock
\usebibmacro{in:}%
\printtext[doilink]{%
\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}}
\DeclareBibliographyDriver{book}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/editor+others/translator+others}%
\setunit{\printdelim{nametitledelim}}\newblock
\usebibmacro{maintitle+title}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{byeditor+others}%
\newunit\newblock
\printfield{edition}%
\newunit
\iffieldundef{maintitle}
{\printfield{volume}%
\printfield{part}}
{}%
\newunit
\printfield{volumes}%
\newunit\newblock
\usebibmacro{series+number}%
\newunit\newblock
\printfield{note}%
\newunit\newblock
\printtext[doilink]{%
\usebibmacro{publisher+location+date}}%
\newunit\newblock
\usebibmacro{chapter+pages}%
\newunit
\printfield{pagetotal}%
\newunit\newblock
\iftoggle{bbx:isbn}
{\printfield{isbn}}
{}%
\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}
@book{elk,
author = {Anne Elk},
title = {A Theory on Brontosauruses},
year = {1972},
publisher = {Monthy \& Co.},
location = {London},
doi = {10.0001/12345},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}
\begin{document}
\cite{kastenholz,herrmann,sigfridsson,elk}
\printbibliography
\end{document}