# List the citation key shown by \citep in the references.

Some months ago, I asked a question regarding bibliography hyphenation issue here. In a nutshell, when I was having problems with the hyphenation of the citation keys in the text, I included the natbib package and the problem was solved. However, the list of references at the end of the article does not show the key that appears in the text as before.

Here is an example:

With the following code:

\documentclass[12pt,a5paper]{article}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{microtype}
\usepackage[square]{natbib}

\title{Test}
\author{Tester}
\date{\today}

\begin{document}
\maketitle

asd asd Hello world \citep{SaCouto:2010:HemodynamicBirth},
\citep{SaCouto:2010:HemodynamicBirth},
\citep{SaCouto:2010:HemodynamicBirth}

\bibliographystyle{apalike}
\bibliography{fullbiblio}

\end{document}


I get:

When commenting the natbib package, and changing \citep to \cite, I get:

What I would like is:

• Correct hyphenation (possible when including natbib)
• That the references include the key that is shown in the text (possible when not including natbib). This key should be [Lastname, year].

So my question is, how can I achieve this?

-

\makeatletter
\def\@lbibitem[#1]#2{%
\if\relax\@extra@b@citeb\relax\else
\@ifundefined{br@#2\@extra@b@citeb}{}{%
\@namedef{br@#2}{\@nameuse{br@#2\@extra@b@citeb}}}\fi
\@ifundefined{b@#2\@extra@b@citeb}{\def\NAT@num{}}{\NAT@parse{#2}}%
\item[\hfil\hyper@natanchorstart{#2\@extra@b@citeb}\citep{#2}%
\hyper@natanchorend]%
\NAT@ifcmd#1(@)(@)\@nil{#2}}
\makeatother

-
Excellent! This is exactly what I was looking for! I did not like the identation so I redefined \thebibliography as well, as shown on this link: latex-community.org/forum/… –  YuppieNetworking Nov 22 '10 at 16:39

I had a similar question some times ago. Natbib does not put the citation keys in the reference section as a default.

The couple author+year should be enough to pick out the correct reference.

One way to do what you are asking is getting hands on the .bst file. I know it can be a little tricky, but I think that the LaTeX Companion may help in this case (I recently edited the palinnat.bst file with a trial-and error technique, and get what I want).

-
I agree that author+year should be enough, but I prefer showing the citation key. Many publications do this and I think it is easier to search the references. –  YuppieNetworking Oct 18 '10 at 9:24
did you already try the numbers option? –  Alessandro Cuttin Oct 19 '10 at 12:45
Yes. But this way the citation key is not Lastname-year (I realize now that my question should clarify this) –  YuppieNetworking Oct 25 '10 at 8:40

Taking the same idea that @jpz presented here's a different version. With \citep there's a problem if you use hyperref.

This is the workaround I've came up with:

\makeatletter

\def\mysplit#1(#2)#3\@nil{%
\ifthenelse{\equal{#2}{}}%
{\def\mycitep{#1}}
{\def\mycitep{#1, #2}}
}

\def\@lbibitem[#1]#2{%
\mysplit#1\@nil
\if\relax\@extra@b@citeb\relax\else
\@ifundefined{br@#2\@extra@b@citeb}{}{%
\@namedef{br@#2}{\@nameuse{br@#2\@extra@b@citeb}}}\fi
\@ifundefined{b@#2\@extra@b@citeb}{\def\NAT@num{}}{\NAT@parse{#2}}%
\item[\hfil\hyper@natanchorstart{#2\@extra@b@citeb}{[{\mycitep}]}%
\hyper@natanchorend]%
\NAT@ifcmd#1(@)(@)\@nil{#2}}
\makeatother


I hope it's helpful for others

-