I'm trying to use BibTeX with a letter; I hope this is not too eccentric. The letter class doesn't have BibTeX support, though. I found Environment thebibliography undefined when using letter. However, the solution described does not work perfectly. The bibliography appears on its own page (in my case it is just two entries), and the numbering is out of order with the plain style ie. [2] appears before [1] in the letter.
Can these issues be fixed? Alternatively, what are my choices? Could I use another letter class? Some time ago I posted to comp.text.tex, and the people there were rather despising about the letter class, and pointed me to various alternatives which they said were better. Do any of these alternatives have built-in BibTeX support?
EDIT1: Both the problems mentioned above were user error.
-
The wrong order, as pointed out by Joseph, was because I was using the
plain
style. -
The bibliography on a separate page was because I put the
\bibliographystyle
and\bibliography
entries after closing theletter
environment instead of
before. Again, Joseph's example was helpful in setting me straight.
In summary, there is nothing wrong with the original post, though no doubt Joseph's version is an improvement, and is certainly shorter. Both the original version and Joseph's version work fine for me. I put the text in Joseph's post between \makeatletter
and \makeatother
into a separate sty file when using it with my letter.
EDIT2: Adding \usepackage{natbib}
to the preamble breaks the compile. Whether I put it before or after the "homemade" bib sty file doesn't make a difference. I get
ERROR: LaTeX Error: Environment thebibliography undefined.
Best Answer
Taking the definition from the
article
class, I get good results withI've used the
unsrt
style here, asplain
would put the references in alphabetical rather than citation order. I've also modified the definition ofthebiliography
a little, removing the section-related stuff as this does not really seem relevant to a letter. (I also took out the code related to theopenbib
option for thearticle
class, again as it does not seem relevant.)The second edit to the question asks about
natbib
. For me, this works if I loadnatbib
after definingthebiliography
and if I make\bibsection
'safe':