I am using TeXmaker on windows 7 (if this matters).

I would like to know how to add bibliography (under the title, References) to a letter.

(I created this letter using the default template available.)

I saw in one of the questions here the following snippet, but it fails for me.

% Some Preamble that comes with the default letter Template
\begin{document}
\begin{letter}{--To whom is it written--}
Some Text is here.
\printbibliography
\end{letter}
\end{document}

%Bibfile
@Article{,
author = {•},
title = {•},
journal = {•},
year = {•},
OPTkey = {•},
OPTvolume = {•},
OPTnumber = {•},
OPTpages = {•},
OPTmonth = {•},
OPTnote = {•},
OPTannote = {•}
}


I have two other doubts as well:

• Is the keyword that I'll use to cite this reference written

1. in place of • in OPTkey={•} (in which case, I am wondering how is that OPTional?) or
2. preceding the , that is on the first line?
• When I press clean, all those OPTional fields for which I have entered some value also disappear. Is this the normal behaviour and in which case, will they show up on my reference?

(P.S.: I am sorry if I packed in a lot to my question. And, as I'm a newbie here, I welcome any suggestions about the style of the question. )

-
Please post an Example code as an answer. Any other answer will also be appreciated. –  kan Feb 20 '12 at 0:13
If you want to add a bibliography to a letter this question might help you: tex.stackexchange.com/questions/18033/… –  Philipp Feb 20 '12 at 1:16
The code there gives me some error too. There are undefined references, it says. How do I get rid of that error? –  kan Feb 20 '12 at 1:22
When you want to compile an document containing bibtex references for the first time you have to compile once with LaTeX, then with BibTeX, and again twice with LaTeX to get all the references right. That's why latexmk is very popular as it automates the process. –  Philipp Feb 20 '12 at 1:26
@Philipp Still the same after I tried running it with latexmk available on TeXmaker –  kan Feb 20 '12 at 1:30

Here's a step-by-step example of how to create a document with a bibliography using TeXMaker.

Create a bib file

Using the Bibliography menu, enter your bibliography entries. Save these as (Here I've chosen the name mybibfile.bib).

Here is a sample screen shot:

The first element of any bib file entry is the citekey. This must be unique for each entry in the file. I use keys based on the authors and the year of publication, but this scheme is up to you.

The "optional" fields in the entry are fields that basically won't cause any errors if they are missing. Many of them are required for proper bibliographic referencing, though, for example, the volume and pages are almost always required. You should put as much information as you have in a .bib entry.

Create a LaTeX document

Next, create a LaTeX document which uses \cite commands that refer to the citekeys in your .bib file.

The letter document class is not designed to support a bibliography, so I would suggest using the article class instead. Here's a simple example:

The code of the document can be found here:

\documentclass[12pt]{article} % using article instead of letter class
\usepackage{natbib} % for the bibliography
\usepackage{parskip} % blank lines to separate paragraphs (common for letters, but not required)
\usepackage[small]{titlesec} % make section heading small
\begin{document}
\thispagestyle{empty}

\today

Dr. Joe Smith\\
Department of Linguistics\\
Somewhere in the World

Dear Dr. Smith:

The first analysis of the \textit{that}-trace effect as a filter was given by \cite{chomsky-lasnik1977}.

Sincerely\\
Me
\bibliographystyle{apalike} % this is one type of author-year style
\bibliography{mybibfile} % this prints the bibliography section based on the \cite commands
\end{document}


Now you need to run pdflatex on this document, then bibtex, then pdflatex two more times. The final result should be:

-
I missed the final running-bibtex process... Finally see the hint here. Thanks! –  Farticle Pilter Aug 25 '13 at 4:14

To print the bibliography, you need to use the command \printbibliography and not \print bibliography. The fields that are optional are key, volume, etc, without the OPT prefix.

Main reference: http://en.wikibooks.org/wiki/LaTeX/Bibliography_Management

%%% File: a.tex
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc} % Set the input encoding
\usepackage[pdftex]{hyperref} % Make links in a pdf document
\usepackage{biblatex} % A library for bibliography commands.

\bibliography{a} % Use the bilbiography file a.bib

\begin{document}
Some test: \cite{someref}.
\printbibliography
\end{document}

%%% File: a.bib
@Article{someref,
title = {Hello world},
author = {Kru},
}


To compile the file, run pdflatex a.tex; bibtex a; pdflatex a.tex (compile the document, compile the bibliography used in the document, recompile the document to include the bibliography).

-
I used $\printbibliography$ but it says: Undefined Control Sequence. Further, I was referred to the Wikipedia link but I am not pretty comfortable with how is it done in TeXmaker. You may leave the entries blank but leave a sample code indicating where is what added and brief sketch of packages required (if any) and how to compile if different from ordinary. (+1) –  kan Feb 20 '12 at 1:13
I've added an example using the package biblatex. There are other packages too, but I find it more intuitive. –  Kru Feb 20 '12 at 9:01