Document ClassesEnvironment thebibliography undefined when using letter

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
hany.azzam
Posts: 1
Joined: Mon Dec 08, 2008 1:52 am

Environment thebibliography undefined when using letter

Post by hany.azzam »

Greetings,
I am using the letter document class, and I want to include some citations. From what I have gathered the letter document class doesn't allow having bibliography items in the letter body. If that's the case, is there a workaround?
Here is the code that I am trying to run:

Code: Select all

\documentclass{letter}

\signature{} 
\begin{document}
\begin{letter}{} 

\begin{center}{} 
\end{center} \vfill 

\opening{Dear}
 
\closing{Sincerely yours,}
  
\encl{}			
\end{letter}
\bibliographystyle{plain}
\bibliography{bibdb}
\end{document} 
I receive the following error:
Latex Error: Environment thebibliography undefined.

The purpose of using a letter class and citations is because I want to write a cover letter and I need to refer to some citations inside of the letter's body.

Thank you,
h.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

lwaldron
Posts: 2
Joined: Thu Feb 11, 2010 7:26 am

Environment thebibliography undefined when using letter

Post by lwaldron »

It's not quite so simple, as there are a number of things that must be defined to get the bibliography to work. I got it working with the following code copied from article.cls into a file "letterbib.sty" then the command \usepackage{letterbib} in the preamble:

Code: Select all

\setlength \labelsep {.5em} 
\newcommand\newblock{\hskip
  .11em\@plus.33em\@minus.07em} \let\@openbib@code\@empty
\newcommand\refname{References} 
\newcommand\section{\@startsection
  {section}{1}{\z@}%
  {-3.5ex \@plus -1ex \@minus -.2ex}%
  {2.3ex \@plus.2ex}%
  {\normalfont\Large\bfseries}} 
\newenvironment{thebibliography}[1]
{\section*{\refname}%
  \@mkboth{\MakeUppercase\refname}{\MakeUppercase\refname}%
  \list{\@biblabel{\@arabic\c@enumiv}}%
  {\settowidth\labelwidth{\@biblabel{#1}}%
    \leftmargin\labelwidth \advance\leftmargin\labelsep \@openbib@code
    \usecounter{enumiv}%
    \let\p@enumiv\@empty \renewcommand\theenumiv{\@arabic\c@enumiv}}%
  \sloppy \clubpenalty4000 \@clubpenalty \clubpenalty
  \widowpenalty4000%
  \sfcode`\.\@m} {\def\@noitemerr {\@latex@warning{Empty
      `thebibliography' environment}}%
      \endlist}
mikeg
Posts: 2
Joined: Wed Mar 17, 2010 11:08 pm

Re: Environment thebibliography undefined when using letter

Post by mikeg »

Hi lwaldron,

Just wanted to thank you for posting your solution to the problem. It came in very handy.

Best,

Mike
lwaldron
Posts: 2
Joined: Thu Feb 11, 2010 7:26 am

Re: Environment thebibliography undefined when using letter

Post by lwaldron »

You're welcome Mike, it's nice to hear that posting it was worthwhile.
-Levi
acfrery
Posts: 1
Joined: Tue Jan 29, 2013 3:32 pm

Re: Environment thebibliography undefined when using letter

Post by acfrery »

Thank you very much for the solution of an issue that has been bothering me for years!
Alejandro
Benjamin B
Posts: 1
Joined: Fri May 31, 2013 9:19 pm

Re: Environment thebibliography undefined when using letter

Post by Benjamin B »

Yeah, thanks lwaldron. Very helpful!
geomorphdog
Posts: 1
Joined: Thu Aug 29, 2013 8:39 pm

Environment thebibliography undefined when using letter

Post by geomorphdog »

This worked beautifully. Thanks so much! Maybe it's obvious, but I also had to load the natbib package:

Code: Select all

\usepackage{letterbib}
\usepackage{natbib}
Last edited by cgnieder on Fri Aug 30, 2013 10:35 am, edited 1 time in total.
Post Reply