文内引用样式与最终参考书目引用样式不同

文内引用样式与最终参考书目引用样式不同

我正在使用natbib带有 BibTeX 的软件包来管理和引用我的参考书目。我希望文内引用被引用为[2][3]等,这可以使用 来实现\bibliographystyle{unsrt}。但是,我希望我的最终参考书目是harvard引用(见下图),这只有使用 才能实现\bibliographystyle{agsm}。但是,这种样式会将文内引用更改为(authors, (year of publication))

有没有办法让我的文内引用符合该unsrt风格,而最终的参考书目也符合该agsm风格?

在此处输入图片描述

答案1

agsm如果您想要提供的精确的参考书目样式,但unsrt您可以修改引用和排序顺序agsm.bst以停止排序。

所需的更改比平时要长一些,因此我已将新文件上传agsm-unsrt.bsthttps://gist.github.com/moewew/c4b7c0908a69b108d13b6469f09b7a07. 区别agsm.bst在于

--- agsm.bst    2009-01-30 02:49:00.000000000 +0100
+++ agsm-unsrt.bst  2018-11-25 17:42:24.054011800 +0100
@@ -1,3 +1,6 @@
+%% `agsm-unsrt.bst' (2018-11-25) for https://tex.stackexchange.com/q/461677/
+%% removed all SORT code, and added longest.label back in
+%% original copyright header follows
 % BibTeX standard bibliography style `agsm' (one of the harvard family)
    % version 0.99a for BibTeX versions 0.99a or later, LaTeX version 2.09.
    % Copyright (C) 1991, all rights reserved.
@@ -43,7 +46,7 @@
     year
   }
   { field.used etal.allowed etal.required} %%%XXX change
-  { extra.label sort.label list.year }
+  { label }

 INTEGERS { output.state before.all mid.sentence after.sentence after.block }

@@ -675,7 +678,7 @@
   if$
   make.full.label write$
   "}{" write$
-  list.year write$
+  year write$
   "}{" write$
   cite$ write$
   "}" write$
@@ -691,7 +694,7 @@
 FUNCTION {article}
 { output.bibitem
   list.label.output
-  " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
+  " \harvardyearleft " year * "\harvardyearright " * output.nonnull
   author "author" item.check
   title.field field.used =
     { skip$ }
@@ -714,7 +717,7 @@
 FUNCTION {book}
 { output.bibitem
   list.label.output
-  " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
+  " \harvardyearleft " year * "\harvardyearright " * output.nonnull
   author empty$
     { editor "author and editor" item.check }
     { crossref missing$
@@ -747,7 +750,7 @@
 FUNCTION {booklet}
 { output.bibitem
   list.label.output
-  " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
+  " \harvardyearleft " year * "\harvardyearright " * output.nonnull
   title.field field.used =
     { skip$ }
     { format.title quote "title" output.check }
@@ -763,7 +766,7 @@
 FUNCTION {inbook}
 { output.bibitem
   list.label.output
-  " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
+  " \harvardyearleft " year * "\harvardyearright " * output.nonnull
   author empty$
     { editor "author and editor" item.check }
     { crossref missing$
@@ -797,7 +800,7 @@
 FUNCTION {incollection}
 { output.bibitem
   list.label.output
-  " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
+  " \harvardyearleft " year * "\harvardyearright " * output.nonnull
   title.field field.used =
     { skip$ }
     { format.title "title" output.check }
@@ -824,7 +827,7 @@
 FUNCTION {inproceedings}
 { output.bibitem
   list.label.output
-  " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
+  " \harvardyearleft " year * "\harvardyearright " * output.nonnull
   title.field field.used =
     { skip$ }
     { format.title "title" output.check }
@@ -859,7 +862,7 @@
 FUNCTION {manual}
 { output.bibitem
   list.label.output
-  " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
+  " \harvardyearleft " year * "\harvardyearright " * output.nonnull
   title.field field.used =
     { skip$ }
     { format.btitle "title" output.check }
@@ -884,7 +887,7 @@
 FUNCTION {mastersthesis}
 { output.bibitem
   list.label.output
-  " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
+  " \harvardyearleft " year * "\harvardyearright " * output.nonnull
   author "author" item.check
   title.field field.used =
     { skip$ }
@@ -902,7 +905,7 @@
 FUNCTION {misc}
 { output.bibitem
   list.label.output
-  " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
+  " \harvardyearleft " year * "\harvardyearright " * output.nonnull
   title.field field.used =
     { skip$ }
     { format.title quote output }
@@ -918,7 +921,7 @@
 FUNCTION {phdthesis}
 { output.bibitem
   list.label.output
-  " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
+  " \harvardyearleft " year * "\harvardyearright " * output.nonnull
   author "author" item.check
   title.field field.used =
     { skip$ }
@@ -936,7 +939,7 @@
 FUNCTION {proceedings}
 { output.bibitem
   list.label.output
-  " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
+  " \harvardyearleft " year * "\harvardyearright " * output.nonnull
   title.field field.used =
     { skip$ }
     { format.btitle "title" output.check }
@@ -968,7 +971,7 @@
 FUNCTION {techreport}
 { output.bibitem
   list.label.output
-  " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
+  " \harvardyearleft " year * "\harvardyearright " * output.nonnull
   author "author" item.check
   title.field field.used =
     { skip$ }
@@ -986,7 +989,7 @@
 FUNCTION {unpublished}
 { output.bibitem
   list.label.output
-  " \harvardyearleft " list.year * "\harvardyearright " * output.nonnull
+  " \harvardyearleft " year * "\harvardyearright " * output.nonnull
   author "author" item.check
   title.field field.used =
     { skip$ }
@@ -1067,6 +1070,31 @@

 READ

+STRINGS { longest.label }
+
+INTEGERS { number.label longest.label.width }
+
+FUNCTION {initialize.longest.label}
+{ "" 'longest.label :=
+  #1 'number.label :=
+  #0 'longest.label.width :=
+}
+
+FUNCTION {longest.label.pass}
+{ number.label int.to.str$ 'label :=
+  number.label #1 + 'number.label :=
+  label width$ longest.label.width >
+    { label 'longest.label :=
+      label width$ 'longest.label.width :=
+    }
+    'skip$
+  if$
+}
+
+EXECUTE {initialize.longest.label}
+
+ITERATE {longest.label.pass}
+
 EXECUTE {init.field.constants}

 FUNCTION {sortify}
@@ -1136,198 +1164,6 @@
   if$
 }

-FUNCTION {sort.format.title}
-{ 't :=
-  "A " #2
-    "An " #3
-      "The " #4 t chop.word
-    chop.word
-  chop.word
-  sortify
-  #1 global.max$ substring$
-}
-
-FUNCTION {calc.label} %%%XXX change
-{ make.abbr.label
-  title.field field.used =
-    { sort.format.title }
-    { sortify.names }
-  if$
-  year field.or.null purify$ #-1 #4 substring$ sortify
-  *
-  'sort.label :=
-}
-
-FUNCTION {preliminaries} %%%XXX change
-{ type$ "book" =
-  type$ "inbook" =
-  or
-    'author.editor.key.label
-    { type$ "proceedings" =
-   'editor.key.organization.label
-   { type$ "manual" =
-       'author.key.organization.label
-       'author.key.label
-     if$
-   }
-      if$
-    }
-  if$
-  author.field field.used = %%%XXX change
-    {
-      author num.names$ #2 >
-        { #1 }
-        { #0 }
-      if$
-      'etal.required :=
-    }
-    {
-      editor.field field.used = 
-        {
-          editor num.names$ #2 >
-            { #1 }
-            { #0 }
-          if$
-        }
-        { #0 }
-      if$
-      'etal.required :=
-    }
-  if$
-  #1 'etal.allowed :=
-}
-
-FUNCTION {first.presort}
-{ calc.label
-  sort.label
-  title.field field.used =
-    { skip$ }
-    { "    "
-      *
-      make.list.label sortify.names
-      *
-      "    "
-      *
-      title field.or.null
-      sort.format.title
-      *
-    }
-  if$
-  #1 entry.max$ substring$
-  'sort.key$ :=
-}
-
-ITERATE {preliminaries}
-
-ITERATE {first.presort}
-
-SORT
-
-STRINGS { last.sort.label next.extra last.full.label}
-
-INTEGERS { last.extra.num last.etal.allowed}
-
-FUNCTION {initialize.confusion}
-{ #0 int.to.chr$ 'last.sort.label :=
-  #0 int.to.chr$ 'last.full.label :=
-  #1 'last.etal.allowed :=
-}
-
-FUNCTION {confusion.pass}
-{ last.sort.label sort.label =
-    { last.etal.allowed 
-        { last.full.label make.full.label sortify.names =
-            { skip$ }
-            { #0 'etal.allowed :=
-              #0 'last.etal.allowed :=
-            }
-          if$
-        }
-        { #0 'etal.allowed := }
-      if$
-    }
-    { sort.label 'last.sort.label :=
-      make.full.label sortify.names 'last.full.label :=
-      #1 'last.etal.allowed :=
-    }
-  if$
-}
-
-EXECUTE {initialize.confusion}
-
-ITERATE {confusion.pass}
-
-EXECUTE {initialize.confusion}
-
-REVERSE {confusion.pass}
-
-FUNCTION {initialize.last.extra.num}
-{ #0 int.to.chr$ 'last.sort.label :=
-  "" 'next.extra :=
-  #0 'last.extra.num :=
-}
-
-FUNCTION {forward.pass}
-{ last.sort.label sort.label =
-    { last.extra.num #1 + 'last.extra.num :=
-      last.extra.num int.to.chr$ 'extra.label :=
-    }
-    { "a" chr.to.int$ 'last.extra.num :=
-      "" 'extra.label :=
-      sort.label 'last.sort.label :=
-    }
-  if$
-}
-
-FUNCTION {reverse.pass}
-{ next.extra "b" =
-    { "a" 'extra.label := }
-    'skip$
-  if$
-  year empty$
-    { "n.d." extra.label emphasize * 'list.year := }
-    { year extra.label emphasize * 'list.year := }
-  if$
-  extra.label 'next.extra :=
-}
-
-ITERATE {first.presort}
-
-SORT
-
-EXECUTE {initialize.last.extra.num}
-
-ITERATE {forward.pass}
-
-REVERSE {reverse.pass}
-
-FUNCTION {second.presort}
-{ make.list.label
-  title.field field.used =
-    { sort.format.title }
-    { sortify.names }
-  if$
-  "    "
-  *
-  list.year field.or.null sortify
-  *
-  "    "
-  *
-  title.field field.used =
-    { skip$ }
-    { title field.or.null
-      sort.format.title
-      *
-    }
-  if$
-  #1 entry.max$ substring$
-  'sort.key$ :=
-}
-
-ITERATE {second.presort}
-
-SORT
-
 FUNCTION {begin.bib}
 { preamble$ empty$
     'skip$
@@ -1336,7 +1172,7 @@
       "\harvardpreambletext{%" write$ newline$
       preamble$ write$ "}" write$ newline$ }
   if$
-  "\begin{thebibliography}{xx}" write$ newline$
+  "\begin{thebibliography}{"  longest.label  * "}" * write$ newline$
 }

 EXECUTE {begin.bib}

请注意,新文件必须agsm.bst由于许可原因,使用与(和其他一些)不同的名称。

这里主要有三个步骤

  1. 删除排序代码 (ll. 1139-1330)
  2. 清理排序代码中的遗留问题
    • 将所有出现的替换list.yearyear
    • 消除extra.label sort.label list.year
  3. 将测量值添加longest.label回去(只需从unsrt.bstll. 907-930 复制;这是新的 ll. 1073-1097)

然后你可以使用它作为

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage[numbers]{natbib}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{appleby,
  author  = {Humphrey Appleby},
  title   = {On the Importance of the Civil Service},
  year    = {1980},
  publisher = {C Press},
}
@book{elk,
  author  = {Anne Elk},
  title   = {A Theory on Brontosauruses},
  year    = {1972},
  publisher = {B Press},
}
@article{hacker,
  author  = {James Hacker},
  title   = {A Title},
  journal = {A Journal},
  volume  = {14},
  number  = {3},
  pages   = {110-123},
  year    = {1981},
}
\end{filecontents}


\begin{document}
\cite{elk,hacker,appleby}
\bibliographystyle{agsm-unsrt}
\bibliography{\jobname}
\end{document}

编号的 agsm 参考书目,按引用顺序排序

相关内容