使用elsarticle.cls時,如何使每個參考書目項目成為可點擊的超連結?

使用elsarticle.cls時,如何使每個參考書目項目成為可點擊的超連結?

我打算向計算物理學雜誌由愛思唯爾。儘管出版商沒有為初次提交明確指定參考書目格式要求,但我有興趣複製該期刊中已發表文章的最終 PDF 的實際參考書目風格。

要求是每個參考書目項目(即整行條目)成為可單擊的超連結(doi如果可用,則使用該字段,否則使用文件url中相關鍵的字段bib)。

既然我正在使用elsarticle.cls,我就無法使用biblatex。因此natbib/bibtex需要一個基於的解決方案。

下面是一個 MWE:

\documentclass[number]{elsarticle}
\begin{document}

\begin{frontmatter}

    \title{Dummy document \tnoteref{t1,t2}}

    \tnotetext[t1]{Title footnote 1}
    \tnotetext[t2]{Title footnote 2}
    \author[a]{First Author\fnref{fn1}}
    \ead{firstemail_id@insti_1.edu}
    \author[b]{Second Author\fnref{fn2}}
    \ead{secondemail_id@insti_2.edu}
    \address[a]{Address of author with affiliation `a'}
    \address[b]{Address of author with affiliation `b'}
    \fntext[fn1]{This is a footnote.}
    \fntext[fn2]{Another author footnote}

    \begin{abstract}
        Dummy abstract.
    \end{abstract}

    % Research highlights
    \begin{highlights}
    \item Research highlight 1
    \item Research highlight 2
    \end{highlights}

    \begin{keyword}
        Some \sep keywords
    \end{keyword}

\end{frontmatter}

\section{Introduction}{\label{sec:intro}}
Intro

\section{Next}{\label{sec:blah}}
More blah

\nocite{*}   % Temporary placeholder. Comment out after bib file is populated and \cite commands issued
\bibliographystyle{elsarticle-num} 
\bibliography{manuscript_references.bib}

\end{document}

答案1

正如我在該問題下的評論中所寫的那樣,我不一定認為這是提交給愛思唯爾期刊的最佳想法,但如果您.bst稍微修改一下文件就可以做到。

我確信還有其他方法可以實現這一目標,但這就是我所做的。

elsarticle-num-names.bst已經有一種方法可以將參考文獻的某些部分排版為 URL 的連結(@misc帶有字段的條目標題url已經直接連結到 URL),因此我們可以使用此機制並將其擴展以將連結區域擴展到完整的文章並考慮DOI。

DOI 的擴展或多或少是簡單的。擴充連結區域需要對巨集和函數進行一些改組。

elsarticle-num-names.bst與(v2.1 [2019-04-15],CTAN 上的當前版本)的差異是

--- elsarticle-num.bst  2019-04-05 15:29:24.000000000 +0200
+++ link-elsarticle-num.bst 2020-03-26 21:55:15.423852900 +0100
@@ -114,32 +114,51 @@
 }

 FUNCTION {setup.inlinelink}
-{ makeinlinelink
-    { hrefform #1 = % hypertex
-        { "\special {html:<a href=" quote$ * url * quote$ * "> }{" * 'openinlinelink :=
+{
+  doi empty$
+    {
+      url empty$
+        { "" }
+        { url }
+      if$
+    }
+    { doiurl doi * }
+  if$
+  duplicate$ empty$
+    'pop$
+    { 
+      hrefform #1 = % hypertex
+        { "\special {html:<a href=" quote$ * swap$ * quote$ * "> }" * 'openinlinelink :=
           "\special {html:</a>}" 'closeinlinelink :=
           }
         { hrefform #2 = % hyperref
-            { "\href{" url * "}{" * 'openinlinelink :=
+            { "\href{" swap$ * "}{" * 'openinlinelink :=
               "}" 'closeinlinelink :=
               }
-            'skip$
+            'pop$
           if$ % hrefform #2 =
         }
       if$ % hrefform #1 =
       #0 'makeinlinelink :=
     }
-    'skip$
- if$ % makeinlinelink
+  if$
 }
-FUNCTION {add.inlinelink}
+FUNCTION {add.openinlinelink}
 { openinlinelink empty$
     'skip$
-    { openinlinelink swap$ * closeinlinelink *
+    { openinlinelink write$
       "" 'openinlinelink :=
       }
   if$
 }
+FUNCTION {add.closeinlinelink}
+{ closeinlinelink empty$
+    'skip$
+    { closeinlinelink write$
+      "" 'closeinlinelink :=
+      }
+  if$
+}
 FUNCTION {output.nonnull}
 { % Save the thing we've been asked to output
   's :=
@@ -157,7 +176,6 @@
       % Write out what's currently at the top of the stack, using the
       % original output.nonnull function.
       s
-      add.inlinelink
       output.nonnull.original % invoke the original output.nonnull
     }
     { % Still in brackets.  Add open-bracket or (continuation) comma, add the
@@ -203,12 +221,6 @@
   if$
 }

-FUNCTION {fin.entry.original}
-{ add.period$
-  write$
-  newline$
-}
-
 FUNCTION {new.block}
 { output.state before.all =
     'skip$
@@ -472,7 +484,7 @@
 FUNCTION {write.url}
 { url empty$
     { skip$ }
-    { "\newline\urlprefix\url{" url * "}" * write$ newline$ }
+    { "\newline\urlprefix\nolinkurl{" url * "}" * write$ newline$ }
   if$
 }

@@ -1032,13 +1044,11 @@
 }
 FUNCTION {make.href.hypertex}
 {
-  "\special {html:<a href=" quote$ *
-  swap$ * quote$ * "> }" * swap$ *
-  "\special {html:</a>}" *
+  pop$
 }
 FUNCTION {make.href.hyperref}
 {
-  "\href {" swap$ * "} {\path{" * swap$ * "}}" *
+  pop$ "\path{" swap$ * "}" *
 }
 FUNCTION {make.href}
 { hrefform #2 =
@@ -1054,12 +1064,7 @@
 FUNCTION {format.url}
 { inlinelinks #1 = url empty$ or
    { "" }
-   { hrefform #1 =
-       { % special case -- add HyperTeX specials
-         urlintro "\url{" url * "}" * url make.href.hypertex * }
-       { urlintro "\url{" * url * "}" * }
-     if$
-   }
+   {  urlintro "\nolinkurl{" * url * "}" * }
   if$
 }

@@ -1104,14 +1109,13 @@
 FUNCTION {output.bibitem}
 { outside.brackets 'bracket.state :=
   output.bibitem.original
-  inlinelinks url empty$ not and
-    { #1 'makeinlinelink := }
-    { #0 'makeinlinelink := }
-  if$
+  setup.inlinelink
+  add.openinlinelink
 }

 FUNCTION {fin.entry}
-{ output.web.refs  % urlbst
+{ 
+  output.web.refs  % urlbst
   makeinlinelink       % ooops, it appears we didn't have a title for inlinelink
     { setup.inlinelink % add some artificial link text here, as a fallback
       "[link]" output.nonnull }
@@ -1121,7 +1125,14 @@
     { "]" * }
     'skip$
   if$
-  fin.entry.original
+  add.period$
+  write$
+  type$ "webpage" =
+    'skip$
+    'write.url
+  if$
+  add.closeinlinelink
+  newline$
 }

 FUNCTION {webpage}
@@ -1139,7 +1150,6 @@
     }
   if$
   new.block
-  title empty$ 'skip$ 'setup.inlinelink if$
   format.title "title" output.check
   inbrackets "online" output
   new.block
@@ -1159,7 +1169,6 @@
 FUNCTION {article}
 { output.bibitem
   format.authors "author" output.check
-  title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
   format.title "title" output.check
   crossref missing$
     { journal
@@ -1179,7 +1188,6 @@
     'skip$ 
   if$
   fin.entry
-  write.url
 }

 FUNCTION {book}
@@ -1194,7 +1202,6 @@
       if$
     }
   if$
-  title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
   format.btitle "title" output.check
   crossref missing$
     { format.edition output
@@ -1208,20 +1215,17 @@
   if$
   format.note output
   fin.entry
-  write.url
 }

 FUNCTION {booklet}
 { output.bibitem
   format.authors output
-  title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
   format.title "title" output.check
   howpublished output
   address output
   format.note output
   format.date "year" output.check
   fin.entry
-  write.url
 }

 FUNCTION {inbook}
@@ -1236,7 +1240,6 @@
       if$
     }
   if$
-  title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
   format.btitle "title" output.check
   crossref missing$
     {
@@ -1254,13 +1257,11 @@
   format.pages "pages" output.check
   format.note output
   fin.entry
-  write.url
 }

 FUNCTION {incollection}
 { output.bibitem
   format.authors "author" output.check
-  title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
   format.title "title" output.check
   crossref missing$
     { format.in.ed.booktitle "booktitle" output.check
@@ -1277,13 +1278,11 @@
   format.pages "pages" output.check
   format.note output
   fin.entry
-  write.url
 }

 FUNCTION {inproceedings}
 { output.bibitem
   format.authors "author" output.check
-  title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
   format.title "title" output.check
   crossref missing$
     { format.in.ed.booktitle "booktitle" output.check
@@ -1303,7 +1302,6 @@
   format.pages "pages" output.check
   format.note output
   fin.entry
-  write.url
 }

 FUNCTION {conference} { inproceedings }
@@ -1320,7 +1318,6 @@
     }
     { format.authors output.nonnull }
   if$
-  title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
   format.btitle "title" output.check
   author empty$
     { organization empty$
@@ -1339,13 +1336,11 @@
   format.note output
   format.date "year" output.check
   fin.entry
-  write.url
 }

 FUNCTION {mastersthesis}
 { output.bibitem
   format.authors "author" output.check
-  title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
   format.title "title" output.check
   bbl.mthesis format.thesis.type output.nonnull
   school "school" output.check
@@ -1353,26 +1348,22 @@
   format.note output
   format.date "year" output.check
   fin.entry
-  write.url
 }

 FUNCTION {misc}
 { output.bibitem
   format.authors output
-  title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
   format.title output
   howpublished output
   format.note output
   format.date "year" output.check
   fin.entry
-  write.url
   empty.misc.check
 }

 FUNCTION {phdthesis}
 { output.bibitem
   format.authors "author" output.check
-  title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
   format.title "title" output.check
   bbl.phdthesis format.thesis.type output.nonnull
   school "school" output.check
@@ -1380,7 +1371,6 @@
   format.note output
   format.date "year" output.check
   fin.entry
-  write.url
 }

 FUNCTION {proceedings}
@@ -1389,7 +1379,6 @@
     { organization output }
     { format.editors output.nonnull }
   if$
-  title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
   format.btitle "title" output.check
   format.bvolume output
   format.number.series output
@@ -1413,13 +1402,11 @@
   if$
   format.note output
   fin.entry
-  write.url
 }

 FUNCTION {techreport}
 { output.bibitem
   format.authors "author" output.check
-  title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
   format.title "title" output.check
   format.tr.number output.nonnull
   institution "institution" output.check
@@ -1427,18 +1414,15 @@
   format.note output
   format.date "year" output.check
   fin.entry
-  write.url
 }

 FUNCTION {unpublished}
 { output.bibitem
   format.authors "author" output.check
-  title empty$ 'skip$ 'setup.inlinelink if$ % urlbst
   format.title "title" output.check
   format.note "note" output.check
   format.date "year" output.check
   fin.entry
-  write.url
 }

 FUNCTION {default.type} { misc }
@@ -1487,6 +1471,8 @@
   write$ newline$
   "  \def\href#1#2{#2} \def\path#1{#1}\fi"
   write$ newline$
+  "\providecommand*{\nolinkurl}{\url}"
+  write$ newline$
 }

 EXECUTE {begin.bib}

修改後的檔案link-elsarticle-num.bst可以從以下網址下載https://gist.github.com/moeew/1519006f9de5500db470bcc4701edeb5(該頁面與原始頁面也有很好的差異)。

有了link-elsarticle-num.bst以下 MWE

\documentclass[number]{elsarticle}
\usepackage[T1]{fontenc}
\usepackage[colorlinks]{hyperref}

\begin{filecontents}{\jobname.bib}
@article{sigfridsson,
  author       = {Sigfridsson, Emma and Ryde, Ulf},
  title        = {Comparison of Methods for Deriving Atomic Charges from the
                  Electrostatic Potential and Moments},
  journal      = {Journal of Computational Chemistry},
  year         = 1998,
  volume       = 19,
  number       = 4,
  pages        = {377-395},
  doi          = {10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P},
}
@misc{elk,
  author  = {Anne Elk},
  title   = {A Theory on {Brontosauruses}},
  year    = {1971},
  url     = {https://example.edu/~elk/bronto.pdf},
}
@book{nussbaum,
  author       = {Nussbaum, Martha},
  title        = {{Aristotle's} {`De Motu Animalium'}},
  year         = 1978,
  publisher    = {Princeton University Press},
  address      = {Princeton},
}
\end{filecontents}

\begin{document}
\nocite{*}
\bibliographystyle{link-elsarticle-num}
\bibliography{\jobname}
\end{document}

產生

完全連結的號碼布條目


如果您想要抑制 URL 和 DOI 的明確輸出,請刪除

  output.web.refs  % urlbst

  type$ "webpage" =
    'skip$
    'write.url
  if$

阻止從 FUNCTION {fin.entry}inlink-elsarticle-num.bst讀取

FUNCTION {fin.entry}
{ 
  makeinlinelink       % ooops, it appears we didn't have a title for inlinelink
    { setup.inlinelink % add some artificial link text here, as a fallback
      "[link]" output.nonnull }
    'skip$
  if$
  bracket.state close.brackets = % urlbst
    { "]" * }
    'skip$
  if$
  add.period$
  write$
  add.closeinlinelink
  newline$
}

答案2

要將引用的參考書目轉換為帶有elsarticle類別的可點擊連結(隱式使用bibtex引用管理器),您可以使用\usepackage{hyperref}.輸出的第二頁如下圖所示:

在此輸入影像描述

輸入的tex檔是

\documentclass[number]{elsarticle}
\usepackage[hidelinks, colorlinks=true]{hyperref} %% ADDS LINKS TO REFERENCES, YOU CAN IGNORE THE OPTIONS [hidelinks, colorlinks=true] IF YOU LIKE.

\begin{document}

\begin{frontmatter}

\title{Dummy document \tnoteref{t1,t2}}

\tnotetext[t1]{Title footnote 1}
\tnotetext[t2]{Title footnote 2}
\author[a]{First Author\fnref{fn1}}
\ead{firstemail_id@insti_1.edu}
\author[b]{Second Author\fnref{fn2}}
\ead{secondemail_id@insti_2.edu}
\address[a]{Address of author with affiliation `a'}
\address[b]{Address of author with affiliation `b'}
\fntext[fn1]{This is a footnote.}
\fntext[fn2]{Another author footnote}

\begin{abstract}
    Dummy abstract.
\end{abstract}

% Research highlights
\begin{highlights}
    \item Research highlight 1
    \item Research highlight 2
\end{highlights}

\begin{keyword}
    Some \sep keywords
\end{keyword}

\end{frontmatter}

\section{Introduction}{\label{sec:intro}}
Intro

\section{Next}{\label{sec:blah}}
More blah in example of citation here \cite{Tenis_2000}. Another example of citation \cite{kilde}. Here is a third citation for a real article with doi and url \cite{Aalbersberg_2014}.

\nocite{*}   % Temporary placeholder. Comment out after bib file is populated and \cite commands issued
\bibliographystyle{elsarticle-num}
\bibliography{reference} %%% DON’T ADD EXTENSION OF FILE

\end{document}

這裡使用的參考文件是 reference.bib

@Book{kilde,
  author    = {John Doe},
  publisher = {John Wiley},
  title     = {Differential equations : an introduction to modern methods and applications},
  year      = {2020},
  address   = {New Jersey},
  isbn      = {9780471651413},
  keywords  = {Differential equations},
  language  = {In English},
}

@Article{Tenis_2000,
  author  = {Michael Tenis},
  journal = {Jounal of Energy},
  title   = {New article about something},
  year    = {2000},
  month   = aug,
  number  = {7},
  pages   = {66--88},
  volume  = {2},
}

@Article{Aalbersberg_2014,
  author    = {IJsbrand Jan Aalbersberg and Sophia Atzeni and Hylke Koers and Beate Specker and Elena Zudilova-Seinstra},
  journal   = {{LIBER} Quarterly},
  title     = {Bringing Digital Science Deep Inside the Scientific Article: the Elsevier Article of the Future Project},
  year      = {2014},
  month     = {apr},
  number    = {4},
  pages     = {274},
  volume    = {23},
  doi       = {10.18352/lq.8446},
  publisher = {Uopen Journals},
  url       = {https://doi.org/10.18352/lq.8446},
}

可以\usepackage{hyperref}與許多選項一起使用來調整連結的連結。例如更改連結顏色、放置下劃線或框等。手動的。這是為了將引文連結到參考書目部分的參考文獻。

若要將參考書目部分中的參考文獻連結到其發佈網站,您應該在文件中使用urldoi或兩者都使用欄位reference.bib。網站交叉引用對此有很大幫助,因為您可以直接從那裡複製所有參考信息,Actions>Cite包括urldoi, 到您的reference.bib文件中。

注意使用\bibliography指令後面要跟bib檔名沒有像這樣的擴充\bibliography{reference}

相關內容