对 doi 进行内嵌引用 link(而不是参考书目项目)?

Making in-line citations link to doi (instead of bibliography item)?

我的朋友给了我一个解决方案,可以将 links 添加到 doi(或 url)到我的参考书目项目中,这是通过修改 format.title 宏来完成的在 apa.bst:

FUNCTION {format.title}
{ title empty$
    { "" }
    { title "t" change.case$
      doi empty$
        {url empty$
            { }
            { "\href{" url * "}{" * swap$ * "}" * }
         if$}
        { "\href{http://dx.doi.org/" doi * "}{" * swap$ * "}" * }
      if$
    }
  if$
}

效果很好,但现在我想这样做,这样当我单击内嵌引用(由 \cite 或 \citep 生成)时,它 links 到相同的 url(或 doi)作为参考书目项目(以便能够执行“浏览器中的文本-> doi”而不是“浏览器中的文本->参考书目-> doi”,每次我想查看时它都会在 pdf 中失去位置参考...)

有谁知道 natbib/hyperref 互动发生在哪里以及如何将其“破解”到 link 我的 url/doi 而不是围兜项目标签?

如评论中所述,如果 bibtex 样式不能恰好产生您正在寻找的结果,您最好使用 biblatex - 事情更容易定制。

这里是一个简单的例子,如何将 a link 包装到引用周围的 doi 中。年份仍然指向参考书目,所以你可以选择你想去的地方:

\documentclass{article}

\usepackage[style=apa]{biblatex}
\usepackage{hyperref}

\addbibresource{biblatex-examples.bib}

\makeatletter
\renewbibmacro*{cite}{%
  \iffieldequals{fullhash}{\cbx@lasthash}
% Multiple cites in one command
   {\setunit{\compcitedelim}%
    \usebibmacro{cite:plabelyear+extradate}}%
% Single cite
   {\ifnameundef{labelname}
% No author/editor
     {\usebibmacro{cite:noname}%
       \setunit{\printdelim{nameyeardelim}}%
       \usebibmacro{cite:plabelyear+extradate}%
       \savefield{fullhash}{\cbx@lasthash}}
% Normal cite
     {  \href{http://dx.doi.org/\thefield{doi}}{\ifnameundef{shortauthor}
       {\printnames{labelname}}%
       {\cbx@apa@ifnamesaved
         {\printnames{shortauthor}}
         {\ifnameundef{groupauthor}
           {\printnames[labelname]{author}}
           {\printnames[labelname]{groupauthor}}%
          \addspace\printnames[sabrackets]{shortauthor}}}%
       \setunit{\printdelim{nameyeardelim}}%
      \usebibmacro{cite:plabelyear+extradate}%
      \savefield{fullhash}{\cbx@lasthash}}}}%
   \setunit{\multicitedelim}}
\makeatother

\begin{document}

\cite{kastenholz,sigfridsson}

\printbibliography

\end{document}