TeX - LaTeX Asked by Clement C. on May 17, 2021
I am using natbib with the style alpha:
usepackage[numbers,round,longnamesfirst]{natbib}
bibliographystyle{alpha}
However, what this produces, for papers with more than three authors, is a citation key of the form [ABC⁺00]
instead of, say, [ABCDEF00]
.
Is there a package option I can use to obtain the latter behaviour?
There is no natbib
option to do this. You can only influence the alphabetic label produced by alpha
if you modify (a copy of) alpha.bst
directly.
(Note that alpha
isn't even a natbib
style and that natbib
supports mainly numeric and author-year citations, but not alphabetic styles. It probably works well enough if you don't try to use citet
or citeauthor
and friends, but I thought I should mention this.)
Locate alpha.bst
on your machine. You can do this by typing kpsewhich alpha.bst
into the command line/terminal. Alternatively, obtain a copy of the file from CTAN http://mirrors.ctan.org/biblio/bibtex/base/alpha.bst
Copy the file to a location where TeX can find it. The document directory will do fine. See also https://texfaq.org/FAQ-inst-wlcf
Rename the file to alpha-all.bst
, say (the license of the file only allows distribution of modified copies if they bear a different name)
Find FUNCTION {format.lab.names}
(ll. 934-973) and replace the complete function definition with
FUNCTION {format.lab.names}
{ 's :=
s num.names$ 'numnames :=
numnames #1 >
{ numnames 'namesleft :=
#1 'nameptr :=
""
{ namesleft #0 > }
{ nameptr numnames =
{ s nameptr "{ff }{vv }{ll}{ jj}" format.name$ "others" =
{ "{etalchar{+}}" *
#1 'et.al.char.used :=
}
{ s nameptr "{v{}}{l{}}" format.name$ * }
if$
}
{ s nameptr "{v{}}{l{}}" format.name$ * }
if$
nameptr #1 + 'nameptr :=
namesleft #1 - 'namesleft :=
}
while$
}
{ s #1 "{v{}}{l{}}" format.name$
duplicate$ text.length$ #2 <
{ pop$ s #1 "{ll}" format.name$ #3 text.prefix$ }
'skip$
if$
}
if$
}
Add a comment with your name, the current date and a short description of the changes to the top of the file.
Use bibliographystyle{alpha-all}
instead of bibliographystyle{alpha}
in your document.
As alternative for steps 1 to 5 you can obtain the patched version of the file at https://gist.github.com/moewew/372397ed6d91f516ba71eec0097a376a
The diff between alpha.bst
and the new alpha-all.bst
should look roughly like this
--- alpha.bst 2010-12-09 04:18:56.000000000 +0100
+++ alpha-all.bst 2021-02-16 17:49:17.801451700 +0100
@@ -1,3 +1,14 @@
+%%%%% alpha-all.bst
+%%%%%
+%%%%% for https://tex.stackexchange.com/q/583586/35864
+%%%%%
+%%%%% 2021-02-16 MW
+%%%%%
+%%%%% modification of alpha.bst
+%%%%% that displays all author letters in the alphabetic label
+%%%%% and does not truncate the list with etalchar{+}
+%%%%% the only change is a slight simplification of format.lab.names
+%%%%%
% 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.
@@ -935,10 +946,7 @@
{ 's :=
s num.names$ 'numnames :=
numnames #1 >
- { numnames #4 >
- { #3 'namesleft := }
- { numnames 'namesleft := }
- if$
+ { numnames 'namesleft :=
#1 'nameptr :=
""
{ namesleft #0 > }
@@ -956,12 +964,6 @@
namesleft #1 - 'namesleft :=
}
while$
- numnames #4 >
- { "{etalchar{+}}" *
- #1 'et.al.char.used :=
- }
- 'skip$
- if$
}
{ s #1 "{v{}}{l{}}" format.name$
duplicate$ text.length$ #2 <
Now
documentclass[british]{article}
usepackage[T1]{fontenc}
usepackage{babel}
usepackage[numbers,round,longnamesfirst]{natbib}
begin{filecontents}{jobname.bib}
@book{elk,
author = {Anne Elk and Annie Hacker and Humphrey Appleby and Bernard Woolley and James Hacker},
title = {A Theory on Brontosauruses},
year = {1972},
publisher = {Monthy & Co.},
location = {London},
}
end{filecontents}
begin{document}
Lorem citep{elk}
bibliographystyle{alpha-all}
bibliography{jobname}
end{document}
Produces
Here's how you would do the same thing with biblatex
, which does have an option for this (maxalphanames
).
documentclass[british]{article}
usepackage[T1]{fontenc}
usepackage{babel}
usepackage[backend=biber, style=alphabetic, maxbibnames=999, maxalphanames=999]{biblatex}
begin{filecontents}{jobname.bib}
@book{elk,
author = {Anne Elk and Annie Hacker and Humphrey Appleby and Bernard Woolley and James Hacker},
title = {A Theory on Brontosauruses},
year = {1972},
publisher = {Monthy & Co.},
location = {London},
}
end{filecontents}
addbibresource{jobname.bib}
begin{document}
Lorem autocite{elk}
printbibliography
end{document}
Correct answer by moewe on May 17, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP