# Fixing the bibliography key margin when using AMSALPHA

I'm using the following bibliography code at the end of my document:

\documentclass[...]{book}
...
\begin{singlespace}
\begin{footnotesize}
\bibliographystyle{amsalpha}
\renewcommand{\bibname}{References}
\bibliography{thesis}
\end{footnotesize}
\end{singlespace}

But, I would like to widen a little the margin between the citation Key and the Full Entry, because some of the citation keys are big and protrude intro the description. For example:

UPDATE: Using Lev's answer, I almost got it working:

But now the left square bracket always appear right aligned, with an empty space in the reference key.

Bonus question: If possible, amsalpha also seems to only use the + sufix when the number of authors is greater than 4 (e.g. [SAJ+02]). Is it possible to decrease the threshold to 3?

-

I guess the problem is that amsalpha.bst uses the bibtex width\$ primitive for calculating the longest label. But this calculation is based on "using cmr10 of June 1987". If you are using a font with different metrics then this doesn't always work. There are various ways to work around this, the simplest probably being to edit the .bbl file \begin{thebibliography}{longestlabel} line. A "better" solution would be to use the eqparbox package. For example, using natbib this is as easy as putting in the preamble:

\usepackage{eqparbox}
\usepackage[numbers]{natbib}
\renewcommand*{\bibnumfmt}[1]{\eqparbox[t]{bblnm}{[#1]}}

To change the number of authors before abbreviation, you can edit amsalpha.bst. The format.lab.names function seems to be the place to do this.

-
I've noticed your answer while pasting my solution to the site: it's overlapping with your concise and correct advice. Perhaps my longish remarks might still be of some use. – Stefan Kottwitz Sep 2 '10 at 17:14
It almost worked :-) Can you please see the new screenshot I attached to the original post? Thanks! – Hugo S Ferreira Sep 2 '10 at 17:35
edited my original response to make the whitespace outside the square brackets... – Lev Bishop Sep 2 '10 at 18:31
Duh! Of course... :D Thx.. – Hugo S Ferreira Sep 2 '10 at 19:04

The widths of the labels and the left margins should be determined by the widest label. But you might specify it yourself.

To check what happened, you could look at the file with the extension .bbl, created by BibTeX. There you would see a line like this:

\begin{thebibliography}{WYWB09}

Here WYWB09 is the model for the label width. That argument can be changed, you could even prepare that in your preamble:

\let\stdthebibliography\thebibliography
\let\stdendthebibliography\endthebibliography
\renewenvironment*{thebibliography}[1]{%
\stdthebibliography{WYWBJ07}}
{\stdendthebibliography}

Here I used a common workaround: I saved the original thebibliography environment and redefined it. The redefinition uses the original environment commands but use a fixed label. You may choose the label you wish, or state just dummy text as place holder, this way you could adjust the margin.

Regarding several authors:

Have a look at the file amsalpha.bst. You could find it by

kpsewhich amsalpha.bst

at the command prompt, the location could be like C:\texlive\2009\texmf-dist\bibtex\bst\amscls\amsalpha.bst or C:\Program Files\MiKTeX 2.8\bibtex\bst\amscls\amsalpha.bst or the like, depending on your installation. In that file you would find a function called format.lab.names, this could be the place for the desired modification. A brief glance might show that such modifications are sometimes a bit difficult. I would prefer to use that style unmodified as many authors use it this way, as long as there's not a very important reason to deviate from it.

-

Regarding your bonus question (decreased author threshold): Stefan has already provided part of the solution. Copy amsalpha.bst to your working directory. In the copy, search for the string (which occurs two times)

numnames #4 >

and replace both incidents with

numnames #3 >
-
I should had splited this post in two, in order to accept two answers :D – Hugo S Ferreira Sep 2 '10 at 22:45