51

Normally, I'm basically OK with BibTeX's choice of citation key (by which I mean, the short symbol it shows in the final document, like [2] or [Hil05], not the one one types in the tex file), but every once in a while there's a paper that cries out for a particular key (such as the paper of Freyd, Hoste, Lickorish, Millet, Ocneano and Yetter in which the HOMFLY polynomial is defined clearly should have the key [HOMFLY], not [FHL+95]), or BibTeX picks a particularly bad one.

In these cases, is there a field one can insert into the bibtex entry to override the key choice, or something one can do other than editing the .bbl file?

lockstep
  • 250,273
Ben Webster
  • 1,915
  • 3
  • 14
  • 15

7 Answers7

38

Using biblatex, you may add the shorthand field:

\documentclass{article}

\usepackage[style=alphabetic]{biblatex}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@misc{A01,
  shorthand = {Author},
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
@misc{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {Bravo},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\nocite{*}

\begin{document}

\printbibliography

\end{document}

enter image description here

lockstep
  • 250,273
20

If you use the natbib package, you can declare an "alias" or alternative citation for a source:

For example, the following .bib entry:

@techreport{caltrans2002,
    Author = {{California Department of Transportation}},
    Title = {{Humboldt Bay Bridges Seismic Substructure Retrofit Environmental  Assessment/Finding of No Significant Impact (EA/FONSI)}},
    Year = {2002}}

Produces the following output when \citep{caltrans2002} used in a document:


Example citation without alias.


Having a citation that spans most of a line can be pretty bothersome- especially when the full name has to appear in the bibliography but there is a nice shorthand that should be used when citing in the text. By including \usepackage{natbib} in your preamble, you have access to citation aliases:

\defcitealias{caltrans2002}{\scshape CalTrans, 2002}

Then using \citepalias{caltrans2002} instead of \citep{caltrans2002} produces the following output:


Example citation using an alias.


In both cases, the associated entry in the bibliography looks like this:


Example bibliography text.


The LaTeX and BibTeX source I used to create this example can be obtained from GitHub.

lockstep
  • 250,273
Sharpie
  • 12,844
  • 6
  • 48
  • 58
  • 1
    Is there a way to use an alias w/multiple citations, i.e., in a situation where one would use \citep[][]{key1,key2,...,keyN? – thomp45793 Jan 20 '17 at 03:49
9

There's actually a pretty good answer over at Stack Overflow: Is there a way to override a bibtex style file for a particular entry?.

The fact that the programming language BibTeX style files (.bst) are written in is called BAFLL may alert you to the fact that this sort of problem is a pain to deal with.

Scott Morrison
  • 7,553
  • 6
  • 33
  • 32
5

Alternatively, you can modify your .bbl file by hand. You could even use sed to automatically make the desired change after each time you regenerate the .bbl file using BibTeX --- I can show you the details if you like (ask a new question?).

lockstep
  • 250,273
Scott Morrison
  • 7,553
  • 6
  • 33
  • 32
  • 6
    Just edit the sed-fu into this answer. – Phil Miller Jul 27 '10 at 01:03
  • I don't see how this is possible; a bibtex produced .bbl file contains nothing at all about (shorthand) cite labels; see e.g. http://tex.stackexchange.com/questions/154215/biblatex-biber-to-bibitem/199642#199642 ... if you meant changes in the .bst, that is something else altogether. – sdaau Sep 05 '14 at 20:26
2

Here is a really hacky solution, if one just needs to change maybe one or two labels and wants to stick with bibtex and avoid editing the bst file.

The only changes are in the .bib file, where we add two macros.

@preamble{"\newcommand\HOlabel{}"}
@preamble{"\newcommand\HO[2]{HOMFLY}"}
@article{HOMFLY,
  author  = {\HOlabel{P.~Freyd, D.~Yetter, J.~Hoste, W.~B.~R.~Lickorish, K.~Millett, and A.~Ocneanu}},
  title   = {{A new polynomial invariant of knots and links}},
  journal = {Bull. Amer. Math. Soc. (N.S.)},
  volume  = {12},
  Year    = {1985}
}

The entry in the generated bbl file will look like

\bibitem[\HO85]{HOMFLY}
\HOlabel{P.~Freyd, D.~Yetter, J.~Hoste, W.~B.~R.~Lickorish, K.~Millett, and A.~Ocneanu}.
\newblock {A new polynomial invariant of knots and links}.
\newblock {\em Bull. Amer. Math. Soc. (N.S.)}, 12, 1985.

The first macro tricks bibtex into thinking that \HO is the first three letters of author's name, so the label becomes \HO85. Then the second macro eats the two digits and outputs the desired label.

Also, this entry will be sorted as HO (i.e., it will appear under the letter H instead of F)

fewfold
  • 133
1

If you want to avoid using natbib and biblatex (sometimes I have compilation issues with these packages), you can simple use the abstract style, as it uses they bibtex keys as cite keys. This was pointed out by this answer.


Alternatively, this is also addressed by this alternative_answer, however it involves more steps:

1) download this style: http://ftp.math.utah.edu/pub/tex/bibtex/alpha.bst

2) place it in your project's directory, preferentially under a different name (e.g. keystyle.bst).

3) in the file, replace the output.bibitem entry to:

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

This answer

  • 2
    With biblatex you use no bst file. Can you add an MWE please (best!) or explain with own words how that should work? – Mensch Jan 30 '16 at 14:18
  • I know that biblatex does not use bst file. The solution that I presented is for NOT using biblatex nor natbib. Maybe I should edit the answer to make it more clear. Do you wish a MWE for the proposed solution? – João Matos Jan 30 '16 at 14:24
1

I also had to avoid natbib and biblatex as I was already given a template which had thesis_style.bst by Patrick W. Daly based on alpha.bst.

It already had support for the key field in bibtex entries, but the key was used as citation label only in case author was empty. I modified the following code

FUNCTION {author.key.label}
{ key empty$
    { author empty$
        { cite$ #1 #3 substring$ }
        { author format.lab.names }
      if$
    }
    { key #3 text.prefix$ }
  if$
}
%{ author empty$
%    { key empty$
%        { cite$ #1 #3 substring$ }
%        { key #3 text.prefix$ }
%      if$
%    }
%    { author format.lab.names }
%  if$
%}

which makes it first prefer the key field and only then the author.

Johu
  • 299