I am very much committed to the natbib package, but still want to cite different fields of my bibliography items. For this I am using this code found in a google forum.
\begin{filecontents}{mytestbib.bib}
@book{author00,
title = {{A Title}},
publisher = {Alpha},
year = {2008},
editor = {Author, A},
address = {London}
}
@book{buthor00,
title = {{B Title}},
publisher = {Bravo},
year = {1990},
author = {Buthor, B},
address = {New York}
}
\end{filecontents}
\documentclass{article}
\usepackage{natbib}
\usepackage{hyperref}
\usepackage{keyval}
\input{https://groups.google.com/forum}% symbolically, for readability's sake
\newbibfield{editor}
\bibinput{mytestbib}
\begin{document}
\usebibentry{author00}{editor} has edited `\usebibentry{author00}{title}'
\citeauthor{buthor00} has written `\usebibentry{buthor00}{title}'
\bibliographystyle{plainnat}
\bibliography{mytestbib}
\end{document}
This results in

and poses problems I cannot solve:
- I would like
\usebibentry{author00}{editor}to result in 'Author', analog to\citeauthor{buthor00} - Is it possible to have the
\usebibentry{key}{field}also create a hyperlink, analog to\citeauthor? - %% LaTeX2e file `mytestbib.bib' ... is being put into the document and causes an error, can that be avoided?
- The bibitem 'author00' does not appear in 'References' (a minor problem, since also
\cited regularly in my document)
Below is an amendment in response to egreg's answer
JabRef produces .bib files that look in principle the same as if produced by \begin{filecontents}, i.e.
% This file was created with JabRef 2.7.
% Encoding: Cp1252
@book{author00,
title = {{A Title}},
publisher = {Alpha},
year = {2008},
editor = {Author, A},
address = {London}
}
@book{buthor00,
title = {{B Title}},
publisher = {Bravo},
year = {1990},
author = {Buthor, B},
address = {New York}
}
My question regarding the hyperlink was imprecise, indeed. It should point at the entry in the 'References', which I now create as follows:
\newcommand{\editorlastname}[1]{\nocite{#1}%
\begingroup\edef\x{\usebibentry{#1}{editor}}%
\expandafter\endgroup\expandafter\removename\x\removename}
\def\removename#1,#2\removename{#1}
By the way, the \editorlastname works fine for me, but in case of multiple editors only the first editor is printed. (Should that be of importance to another user)
filecontents*environment together with thefilecontentspackage - so put that in your preamble, not before\documentclass; 4. Try adding\nocite{author00}in your document. – Werner Apr 28 '12 at 16:53usebib. – egreg Apr 28 '12 at 20:17