我正在使用biblatex
以下选项
\usepackage[backend=biber,style=numeric-comp,sorting=none,%
isbn=false,url=false,doi=false,firstinits=true]{biblatex}
因此,我的参考书目既不包含url
也不doi
包含字段,使其简洁明了。然而,这样做的缺点是参考文献不再包含指向特定来源下载位置的可点击链接。
有办法改变这种情况吗?
答案1
编辑:添加了可点击的标题(1.仅可点击标题 2.可点击整个参考资料)
1. 仅可点击标题参考
您可以重新定义title
宏并使用将其添加\href
到。我在文件中编辑了默认定义。title
DeclareFieldFormat
biblatex.def
\DeclareFieldFormat{title}{\myhref{\mkbibemph{#1}}}
\DeclareFieldFormat
[article,inbook,incollection,inproceedings,patent,thesis,unpublished]
{title}{\myhref{\mkbibquote{#1\isdot}}}
宏如下:
\newcommand{\doiorurl}{%
\iffieldundef{doi}
{\iffieldundef{url}
{}
{\strfield{url}}}
{http://dx.doi.org/\strfield{doi}}%
}
\newcommand{\myhref}[1]{%
\ifboolexpr{%
test {\ifhyperref}
and
not test {\iftoggle{bbx:url}}
and
not test {\iftoggle{bbx:doi}}
}
{\href{\doiorurl}{#1}}
{#1}%
}
平均能量损失
\documentclass{article}
\usepackage[backend=biber,style=numeric-comp,sorting=none,%
isbn=false,url=false,doi=false,firstinits=true]{biblatex}
\usepackage{filecontents}
\usepackage{hyperref}
\begin{filecontents}{\jobname.bib}
@Article{usingdoi,
author={The First Author},
title={Using DOI},
year={2014},
journal={J. Med. Sc.},
publisher={Springer},
doi={10.1103/PhysRevLett.77.3865},
pages={1-2},
}
@Article{usingurl,
author={The Other Authors},
title={Using URL},
number={2},
year={1998},
month={4},
journal={ACM Trans. Inf. Sys.},
publisher={Springer},
volume={16},
pages={127-160},
url={https://www.google.com}
}
@Article{nodoiurl,
author={The Author},
title={Neither doi or url},
number={2},
year={1998},
month={4},
journal={ACM Trans. Inf. Sys.},
publisher={Springer},
volume={16},
pages={127-160},
}
\end{filecontents}
\newcommand{\doiorurl}{%
\iffieldundef{doi}
{\iffieldundef{url}
{}
{\strfield{url}}}
{http://dx.doi.org/\strfield{doi}}%
}
\newcommand{\myhref}[1]{%
\ifboolexpr{%
test {\ifhyperref}
and
not test {\iftoggle{bbx:url}}
and
not test {\iftoggle{bbx:doi}}
}
{\href{\doiorurl}{#1}}
{#1}%
}
\DeclareFieldFormat{title}{\myhref{\mkbibemph{#1}}}
\DeclareFieldFormat
[article,inbook,incollection,inproceedings,patent,thesis,unpublished]
{title}{\myhref{\mkbibquote{#1\isdot}}}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}%XXIII
2. 整个参考可点击
我找到了一种可以让参考文献可点击的方法(参考文献的整个文本都是可点击的)
为此,我修改了的定义,以DeclareBibliographyDriver
将其添加\href
到完整参考中。
这是必要的 biblatex
在加载书目格式。
默认情况下,在加载样式文件之前,biblatex
先尝试加载文件biblatex-dm.cfg
(biblatex 自定义数据模型),那么就可以DeclareBibliographyDriver
使用此文件进行修改。
我在工作目录中创建了文件(biblatex-dm.cfg
),其内容如下:
\newcommand{\doiorurl}{%
\iffieldundef{doi}
{\iffieldundef{url}
{}
{\strfield{url}}}
{http://dx.doi.org/\strfield{doi}}%
}
\newcommand{\bibdrivercontent}[1]{%
\ifboolexpr{%
test {\ifhyperref}
and
not test {\iftoggle{bbx:url}}
and
not test {\iftoggle{bbx:doi}}
}
{\href{\doiorurl}{#1}}
{#1}%
}
\let\OldDeclareBibliographyDriver\DeclareBibliographyDriver
\renewcommand{\DeclareBibliographyDriver}[2]{\OldDeclareBibliographyDriver{#1}{\bibdrivercontent{#2}}}
此代码\href
仅当hyperref
已加载并且doi
选项url
为时才使用false
。
妇女权利委员会:
\documentclass{article}
\usepackage[backend=biber,style=numeric-comp,sorting=none,%
isbn=false,url=false,doi=false,firstinits=true]{biblatex}
\usepackage{filecontents}
\usepackage{hyperref}
\begin{filecontents}{\jobname.bib}
@Article{usingdoi,
author={The First Author},
title={Using DOI},
year={2014},
journal={J. Med. Sc.},
publisher={Springer},
doi={10.1007/0000-0xz},
pages={1-2},
}
@Article{usingurl,
author={The Other Authors},
title={Using URL},
number={2},
year={1998},
month={4},
journal={ACM Trans. Inf. Sys.},
publisher={Springer},
volume={16},
pages={127-160},
url={https://www.google.com}
}
@Article{nodoiurl,
author={The Author},
title={Neither doi or url},
number={2},
year={1998},
month={4},
journal={ACM Trans. Inf. Sys.},
publisher={Springer},
volume={16},
pages={127-160},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
结果如下: