biblatex:如何使 \fullcite 成为可点击的链接

biblatex:如何使 \fullcite 成为可点击的链接

我用来biblatex在文中引用带有完整参考文献的文章,因此没有参考文献部分。

我使用的设置biblatex如下

\documentclass{article}
\usepackage{filecontents}

\begin{filecontents}{bibliography.bib}
    @article{reference,
    author = {F Author and S Author}, 
    journal = {Obsc. J.},
    title = {Article Title},
    pages = {13},
    volume = {400},
    year = {2013},
    month = {Oct},
    doi = {10.1111/123},
    URL = {http://dx.doi.org/10.1111/123}}
\end{filecontents}

\usepackage[maxnames=1,backend=bibtex,doi=false,isbn=false,url=false,firstinits=true,uniquename=false,useprefix=true]{biblatex}
\addbibresource{bibliography.bib}
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}}
\DeclareFieldFormat[article]{year}{\mkbibparens{#1}}
\DeclareFieldFormat{journaltitle}{\mkbibemph{#1}} % italic journal title 
\DeclareFieldFormat{pages}{#1}
\renewbibmacro{in:}{} % remove "in:"
\renewcommand{\newunitpunct}{, }
\renewcommand{\newblockpunct}{, }
% remove first name
\DeclareNameFormat{first-last}{\usebibmacro{name:last}{#1}{#3}{#5}{#7}\usebibmacro{name:andothers}}
\AtEveryCitekey{\clearfield{title}} % remove title


\begin{document}
Cite the article \fullcite{reference}.
\end{document}

这样,引用的参考文献\fullcite就会给出类似“作者等,注释J.400(2013年),13英寸。

到目前为止一切顺利,但现在我想将引文(或者至少是第一作者,如果这样更容易)设为指向文章 URL 的超链接(bib 文件中的每个文章条目都有一个 URL 条目和/或 DOI)。有办法吗?

编辑:一些期刊的参考文献部分使用了类似的东西,例如这篇开放获取文章

答案1

您可能更喜欢这种更通用的方法来重新定义命令,而不是重新定义每个字段格式\fullcite

\DeclareCiteCommand{\fullcite}
  {\usebibmacro{prenote}}
  {\iffieldundef{doi}
    {\iffieldundef{url}
      {\usedriver
       {\DeclareNameAlias{sortname}{default}}
       {\thefield{entrytype}}}
      {\href{\thefield{url}}
        {\usedriver
          {\DeclareNameAlias{sortname}{default}}
          {\thefield{entrytype}}}}}
    {\href{http://dx.doi.org/\thefield{doi}}{\usedriver
     {\DeclareNameAlias{sortname}{default}}
     {\thefield{entrytype}}}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

这会将 bibdriver 打印的完整引用链接到DOI-URL 或URL(按优先顺序)。

数学家协会

\documentclass{article}
\usepackage{filecontents}

\begin{filecontents}{bibliography.bib}
@article{reference,
  author = {F Author and S Author}, 
  journal = {Obsc. J.},
  title = {Article Title},
  pages = {13},
  volume = {400},
  year = {2013},
  month = {10},
  url = {http://dx.doi.org/10.1111/123},
  doi = {10.1111/123},
}
\end{filecontents}

\usepackage[maxnames=1,backend=bibtex,doi=false,isbn=false,url=false,firstinits=true,uniquename=false,useprefix=true]{biblatex}
\addbibresource{bibliography.bib}
\DeclareFieldFormat[article]{number}{\mkbibparens{#1}}
\DeclareFieldFormat[article]{year}{\mkbibparens{#1}}
\DeclareFieldFormat{journaltitle}{\mkbibemph{#1}} % italic journal title 
\DeclareFieldFormat{pages}{#1}
\renewbibmacro{in:}{} % remove "in:"
\renewcommand{\newunitpunct}{\addcomma\space}
\renewcommand{\newblockpunct}{\addcomma\space}
\DeclareNameFormat{first-last}{\usebibmacro{name:last}{#1}{#3}{#5}{#7}\usebibmacro{name:andothers}}
\AtEveryCitekey{\clearfield{title}} % remove title

\DeclareCiteCommand{\fullcite}
  {\usebibmacro{prenote}}
  {\iffieldundef{doi}
    {\iffieldundef{url}
      {\usedriver
       {\DeclareNameAlias{sortname}{default}}
       {\thefield{entrytype}}}
      {\href{\thefield{url}}
        {\usedriver
          {\DeclareNameAlias{sortname}{default}}
          {\thefield{entrytype}}}}}
    {\href{http://dx.doi.org/\thefield{doi}}{\usedriver
     {\DeclareNameAlias{sortname}{default}}
     {\thefield{entrytype}}}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\usepackage{hyperref}

\begin{document}
Cite the article \fullcite{reference}.
\end{document}

产量

在此处输入图片描述

答案2

我找到了一个折中的解决方案:添加hyperref包并用以下代码替换上述声明

\DeclareFieldFormat[article]{volume}{\href{http://dx.doi.org/\thefield{doi}}{#1}}
\DeclareFieldFormat{date}{\href{http://dx.doi.org/\thefield{doi}}{#1}}
\DeclareFieldFormat{journaltitle}{\mkbibemph{\href{http://dx.doi.org/\thefield{doi}}{#1}}}
\DeclareFieldFormat{pages}{\href{http://dx.doi.org/\thefield{doi}}{#1}}
\DeclareNameFormat{first-last}{\href{http://dx.doi.org/\thefield{doi}}{\usebibmacro{name:last}{#1}{#3}{#5}{#7}\usebibmacro{name:andothers}}}

将作者姓名、期刊名称、年份、页码和卷号设为单独的 URL。它并不完美,但可以完成工作。

相关内容