I want to do amsalpha style citation with BibTeX, except that I want to have manual control over the key/labels (e.g., [ABC09]). Is there an option for this?

  • Welcome to TeX.SX! Can you give a small example, with a sample of a bib entry and what you really need to do?
    – egreg
    Sep 21, 2012 at 8:42

2 Answers 2


One of the optional fields of a BibTeX entry is key which is used for put in alphabetical order, cross-references and as label when the author or editor information is not available. Thus one can use the key field for the value of records for which one wants to manually control the label.

To this end one has to modify the amsalpha.bst, in particular the FUNCTION {output.bibitem}. (Please create a copy of amsalpha.bst and change the name to it, let us say myamsalpha.bst) This function can be modified as follows

FUNCTION {output.bibitem}
{ newline$
  "\bibitem[" write$
  key empty$
    {label write$}
    {key write$}
  "]{" write$
  cite$ write$
  "}" write$
  before.all 'output.state :=

Then, you can use it as follows:

  author = "Last, First",
  title = "First Title",
  journal = "Journal Name",
  year = 2012
  key = {ABC12},
  author = "Last, First",
  title = "Second Title",
  journal = "Journal Name",
  year = 2011
  author = "More, First",
  title = "Third Title",
  journal = "Journal Name",
  year = 2011
Testing citations


enter image description here


While Guido's solution was quite helpful to me, it resulted in incorrect sorting of the bibliography. To have consistent sorting it is better to only modify the calc.label function in the custom bibtex style (e.g. myamsalpha.bst) as follows.

FUNCTION {calc.label}
{ key empty$
  { type$ "book" =
    type$ "inbook" =
      { type$ "proceedings" =
          { type$ "manual" =
    year field.or.null purify$ #-1 #2 substring$
    'label :=
    year field.or.null purify$ #-1 #4 substring$
    sortify 'sort.label :=
  { key 'label :=
    key sortify 'sort.label :=

This will yield in addition to the custom labels also the correct sorting of the labels in the bibliography. However I must admit that using this solution the user is responsible himself for avoiding duplicate keys.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .