[Tex/LaTex] How to add the citation keys to the bibliography

bibliographiesbibtexcitingnatbib

How can I add the citation key to the bibliography?

Let's take this entry as an example:

@book{Fowler1999,
  address = {Boston, MA, USA},
  author = {Fowler, Martin},
  description = {AOEvolutionchapter short paper},
  isbn = {0-201-48567-2},
  publisher = {Addison-Wesley},
  title = {Refactoring: Improving the Design of Existing Code},
  year = 1999
}

I would now want the bibliography in my PDF document to look like this:

[Fowler1999] Martin Fowler. Refactoring: Improving the Design of Existing Code. Addison-Wesley,
Boston, MA, USA, 1999. ISBN 0-201-48567-2.

Can someone please help me? I'm using natbib and bibliographystyle plainnat.
And since it's the last day before deadline and I'm not that familiar with LaTeX, I'd prefer a solution where I don't need to change those two…

EDIT:
apparently I did not express myself well.
I don't want those keys in the text.
There I already have them.
I want them to appear in my bibliography as well.

Instead of:

Martin Fowler. Refactoring: Improving the Design of Existing Code. Addison-Wesley,
Boston, MA, USA, 1999. ISBN 0-201-48567-2.

I want:

[Fowler1999] Martin Fowler. Refactoring: Improving the Design of Existing Code. Addison-Wesley,
Boston, MA, USA, 1999. ISBN 0-201-48567-2.

Note that Fowler1999 is the citation key I used.

Best Answer

If you use the authoryear and square options of natbib, the keys in your text show up as desired, if you use the \citep-command

\documentclass{article}

\usepackage{blindtext}
\usepackage[square,authoryear]{natbib}
\usepackage{filecontents}

\begin{filecontents}{library.bib}
@book{Fowler1999,
  address = {Boston, MA, USA},
  author = {Fowler, Martin},
  description = {AOEvolutionchapter short paper},
  isbn = {0-201-48567-2},
  publisher = {Addison-Wesley},
  title = {Refactoring: Improving the Design of Existing Code},
  year = 1999
}

@book{Doe2000,
  address = {Somewhere},
  author = {Doe, John},
  title = {Awesome title},
  year = 2000
}
\end{filecontents}

\setcitestyle{aysep={}}

\begin{document}
\blindtext\citep{Fowler1999}

\blindtext\cite{Doe2000}

\bibliography{library}
\bibliographystyle{unsrtnat}

\end{document}

Or you could use the alpha bibliography style.

\documentclass{article}

\usepackage{blindtext}
\usepackage{filecontents}

\begin{filecontents}{library.bib}
@book{Fowler1999,
  address = {Boston, MA, USA},
  author = {Fowler, Martin},
  description = {AOEvolutionchapter short paper},
  isbn = {0-201-48567-2},
  publisher = {Addison-Wesley},
  title = {Refactoring: Improving the Design of Existing Code},
  year = 1999
}

@book{Doe2000,
  address = {Somewhere},
  author = {Doe, John},
  title = {Awesome title},
  year = 2000
}
\end{filecontents}

\begin{document}
\blindtext\cite{Fowler1999}

\blindtext\cite{Doe2000}

\bibliography{library}
\bibliographystyle{alpha}

\end{document}
Related Question