1

I am trying to customize the bibliography style alpha, preferably in amsart (or ams class, in general), while I'm using BibTeX, since I'm using reference management software like Bibdesk. In the alpha style we have something like the following example:

[Ein05] Albert Einstein, Zur Elektrodynamik ..., 1905.

Now, I want to reorder the author name as follows:

[Ein05] Einstein, A.: Zur Elektrodynamik ..., 1905.

That is, the last name should come first, then the first letter of the first name, and then colon. The rest could be kept as it is in the alpha style.

How can I customize it such that anyone could see the result? Because I don't want to customize it just on my machine.

7
  • Oh sorry! I just made bold the changes so that the changes are clear. I am interested in your solution, however it would be great to replace the comma with colon after the abbreviated name.
    – Astrolabe
    Jun 20 '20 at 13:05
  • If I do that then no one else could run the source. I am sharing the tex file, so I need a solution that can be applied on the current tex file, independent of the distribution.
    – Astrolabe
    Jun 20 '20 at 13:35
  • 1
    Ok. Thanks a lot!
    – Astrolabe
    Jun 20 '20 at 13:47
  • 1
    No, I can share bst file. That's not a problem. I thought these changes would be applicable at just the local machine.
    – Astrolabe
    Jun 20 '20 at 13:55
  • @Mico Can I edit another style to achieve my favourite style I gave in my post? I played around with the bst file to change the dot to colon after the author names, but I wasn't successful.
    – Astrolabe
    Jun 20 '20 at 18:11
2

While the name format changes are quite straightforward once you are familiar with the arcane BibTeX language, the colon thing is a bit more difficult to achieve within the framework of alpha.bst.

For the name format you replace

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

with

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

See for example also How to modify the alpha bibliography style to show truncated first names after the surnames?.

Here's what I would do. It's a bit tricky to describe in words, so here is the diff to alpha.bst (including the one-line change for the name format)

--- 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

The idea is to add a new punctuation state for the colon to the punctuation handling of the style. We then define a new function that sets this colon state and call that function after format.authors/format.editors.

You can download the modified alpha-fg.bst from https://gist.github.com/moewew/98f5aee969725d21d1f8da0355d50081.

With that file

\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}

gives

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


Just for fun, here's how you would apply the same changes with biblatex, where styles can be customised directly from the document preamble.

\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}
7
  • Although I don't understand anything in the code of the bst file, I think this is a great answer! Thank you very much!
    – Astrolabe
    Jun 20 '20 at 21:13
  • Just a short question: I see that the title of the papers (or other elements) are italic. How can I remove it and have normal font?
    – Astrolabe
    Jun 20 '20 at 21:20
  • Another question: how can I make the volume number bold?
    – Astrolabe
    Jun 20 '20 at 22:24
  • 1
    @Astrolabe It is preferred to ask about only one thing per question on this site. I suggest you open up new questions about those two points.
    – moewe
    Jun 21 '20 at 5:37
  • 1
    @Mico I decided to leave it in, but make the change more explicit and link to your answer. Most people who are interested in the code will probably be able to tell what does what with that info. I'm not a big fan of retroactively changing questions and answers, so I'd to leave it at that.
    – moewe
    Jun 21 '20 at 14:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.