使用 BibTeX 时自定义参考书目样式 alpha

使用 BibTeX 时自定义参考书目样式 alpha

我正在尝试自定义参考书目样式 alpha,最好是 in amsart(或一般是 ams 类),而我正在使用 BibTeX,因为我正在使用reference management software类似Bibdesk。在 alpha 样式中,我们有类似以下示例的内容:

[Ein05] 阿尔伯特·爱因斯坦,《电动力学...》,1905 年。

现在,我想按如下方式重新排列作者姓名:

[Ein05] 爱因斯坦,A.:《电动力学...》,1905年。

即,姓氏应放在第一位,然后是名字的第一个字母,最后是冒号。其余部分可以保持原样alpha

我该如何定制它以便任何人都可以看到结果?因为我不想只在我的计算机上定制它。

答案1

一旦熟悉了神秘的 BibTeX 语言,名称格式的更改就非常简单了,但是在框架内实现冒号就有点困难了alpha.bst

对于您替换的名称格式

    { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't :=

    { s nameptr "{vv~}{ll}{, f.}{, jj}" format.name$ 't :=

例如另请参阅如何修改字母书目样式以在姓氏后显示截断的名字?

以下是我要做的事情。用文字描述起来有点困难,所以这里是diff方法alpha.bst(包括名称格式的一行更改)

--- alpha.bst   2010-12-09 04:18:56.000000000 +0100
+++ alpha-fg.bst    2020-06-20 21:23:26.062881200 +0200
@@ -1,3 +1,7 @@
+%% alpha-fg
+%% 2020-06-20 MW
+%% https://tex.stackexchange.com/q/550269/35864
+%% alpha.bst with family, given order, given initials and colon
 % BibTeX standard bibliography style `alpha'
    % Version 0.99b (8-Dec-10 release) for BibTeX versions 0.99a or later.
    % Copyright (C) 1984, 1985, 1988, 2010 Howard Trickey and Oren Patashnik.
@@ -35,13 +39,14 @@
   {}
   { label extra.label sort.label }
 
-INTEGERS { output.state before.all mid.sentence after.sentence after.block }
+INTEGERS { output.state before.all mid.sentence after.sentence after.block after.colon }
 
 FUNCTION {init.state.consts}
 { #0 'before.all :=
   #1 'mid.sentence :=
   #2 'after.sentence :=
   #3 'after.block :=
+  #4 'after.colon :=
 }
 
 STRINGS { s t }
@@ -50,14 +55,20 @@
 { 's :=
   output.state mid.sentence =
     { ", " * write$ }
-    { output.state after.block =
-        { add.period$ write$
+    { output.state after.colon =
+        { ": " * write$
           newline$
-          "\newblock " write$
-        }
-        { output.state before.all =
-            'write$
-            { add.period$ " " * write$ }
+          "\newblock " write$ }
+        { output.state after.block =
+            { add.period$ write$
+              newline$
+              "\newblock " write$
+            }
+            { output.state before.all =
+               'write$
+               { add.period$ " " * write$ }
+              if$
+            }
           if$
         }
       if$
@@ -107,6 +118,13 @@
   if$
 }
 
+FUNCTION {new.colon.block}
+{ output.state before.all =
+    'skip$
+    { after.colon 'output.state := }
+  if$
+}
+
 FUNCTION {new.sentence}
 { output.state after.block =
     'skip$
@@ -190,7 +208,7 @@
   s num.names$ 'numnames :=
   numnames 'namesleft :=
     { namesleft #0 > }
-    { s nameptr "{ff~}{vv~}{ll}{, jj}" format.name$ 't :=
+    { s nameptr "{vv~}{ll}{, f.}{, jj}" format.name$ 't :=
       nameptr #1 >
         { namesleft #1 >
             { ", " * t * }
@@ -540,7 +558,7 @@
 FUNCTION {article}
 { output.bibitem
   format.authors "author" output.check
-  new.block
+  new.colon.block
   format.title "title" output.check
   new.block
   crossref missing$
@@ -568,7 +586,7 @@
       if$
     }
   if$
-  new.block
+  new.colon.block
   format.btitle "title" output.check
   crossref missing$
     { format.bvolume output
@@ -592,7 +610,7 @@
 FUNCTION {booklet}
 { output.bibitem
   format.authors output
-  new.block
+  new.colon.block
   format.title "title" output.check
   howpublished address new.block.checkb
   howpublished output
@@ -614,7 +632,7 @@
       if$
     }
   if$
-  new.block
+  new.colon.block
   format.btitle "title" output.check
   crossref missing$
     { format.bvolume output
@@ -640,7 +658,7 @@
 FUNCTION {incollection}
 { output.bibitem
   format.authors "author" output.check
-  new.block
+  new.colon.block
   format.title "title" output.check
   new.block
   crossref missing$
@@ -666,7 +684,7 @@
 FUNCTION {inproceedings}
 { output.bibitem
   format.authors "author" output.check
-  new.block
+  new.colon.block
   format.title "title" output.check
   new.block
   crossref missing$
@@ -711,7 +729,7 @@
     }
     { format.authors output.nonnull }
   if$
-  new.block
+  new.colon.block
   format.btitle "title" output.check
   author empty$
     { organization empty$
@@ -736,7 +754,7 @@
 FUNCTION {mastersthesis}
 { output.bibitem
   format.authors "author" output.check
-  new.block
+  new.colon.block
   format.title "title" output.check
   new.block
   "Master's thesis" format.thesis.type output.nonnull
@@ -751,6 +769,7 @@
 FUNCTION {misc}
 { output.bibitem
   format.authors output
+  new.colon.block
   title howpublished new.block.checkb
   format.title output
   howpublished new.block.checka
@@ -765,7 +784,7 @@
 FUNCTION {phdthesis}
 { output.bibitem
   format.authors "author" output.check
-  new.block
+  new.colon.block
   format.btitle "title" output.check
   new.block
   "PhD thesis" format.thesis.type output.nonnull
@@ -783,7 +802,7 @@
     { organization output }
     { format.editors output.nonnull }
   if$
-  new.block
+  new.colon.block
   format.btitle "title" output.check
   format.bvolume output
   format.number.series output
@@ -815,7 +834,7 @@
 FUNCTION {techreport}
 { output.bibitem
   format.authors "author" output.check
-  new.block
+  new.colon.block
   format.title "title" output.check
   new.block
   format.tr.number output.nonnull
@@ -830,7 +849,7 @@
 FUNCTION {unpublished}
 { output.bibitem
   format.authors "author" output.check
-  new.block
+  new.colon.block
   format.title "title" output.check
   new.block
   note "note" output.check

这个想法是将冒号的新标点状态添加到样式的标点处理中。然后我们定义一个设置此冒号状态的新函数,并在format.authors/之后调用该函数format.editors

alpha-fg.bst您可以从下载修改后的https://gist.github.com/moewew/98f5aee969725d21d1f8da0355d50081

使用该文件

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

\begin{filecontents}{\jobname.bib}
@book{uthor,
  author    = {Anne Uthor and Anne Elk},
  title     = {Lorem Ipsum Dolor Sit Amet},
  publisher = {Pub \& Co.},
  year      = {1980},
}
\end{filecontents}


\begin{document}
\cite{uthor}
\bibliographystyle{alpha-fg}
\bibliography{\jobname}
\end{document}

给出

[UE80] Uthor,A. 和 Elk,A.:Lorem Ipsum Dolor Sit Amet。 Pub & Co.,1980 年。


只是为了好玩,这里是你如何应用相同的更改biblatex,其中可以直接从文档序言中定制样式。

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

\usepackage[backend=biber,
  style=alphabetic,
  giveninits=true,
]{biblatex}

\DeclareNameAlias{author}{sortname}
\DeclareNameAlias{editor}{sortname}
\DeclareNameAlias{translator}{sortname}

\DeclareNameAlias{sortname}{family-given}

\DeclareDelimFormat[bib]{nametitledelim}{\addcolon\space}

\begin{filecontents}{\jobname.bib}
@book{uthor,
  author    = {Anne Uthor and Anne Elk},
  title     = {Lorem Ipsum Dolor Sit Amet},
  publisher = {Pub \& Co.},
  year      = {1980},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\autocite{uthor}
\printbibliography
\end{document}

相关内容