[Tex/LaTex] How to make a bibtex style file compatible with natbib author citations

bibtexnatbib

I'm trying to convert my manuscript to PloS Comp Bio style. They provide a BibTeX style file. This works fine for inline citations with \usepackage[numbers,sort&compress]{natbib} (i.e. \citep{FooYear} -> [1]).

However, this style file does not seem to be compatible with the natbib \citet command. Whenever I use this I get \citet{FooYear} -> "(author?) [1]" (the reference to the author's name is unresolved). What I want is to display a reference to the author (i.e. "Foo & Smith [1]". Obviously, I could fix this manually, but I have quite a large number of cases in the manuscript.

If I use a different BibTeX style then the citations work fine but then the bibliography is not formatted correctly.

Minimum example

As suggested below here is a minimum example.

\documentclass{article}
\usepackage[numbers]{natbib}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{A01,
   author = {Test, A. and Foo, B.},
   year = {2001},
   title = {Alpha},
}
@misc{A02,
   author = {Alex, A. and Bar, B.},
   year = {2005},
   title = {Alpha},
}
\end{filecontents}

\begin{document}

% These citations will work but in the apalike bibstyle they will not be sorted
% in citation order (the first citation is [2]).
\citep{A01}, \citep{A02}, \citet{A02} 

% The author name will be undefined with the unsrt bibtex style
\citeauthor{A02}, \citet{A01}

\bibliography{\jobname}
\bibliographystyle{unsrt}
%\bibliographystyle{apalike}

\end{document}

Best Answer

You observe:

However, [the plos.bst] style file does not seem to be compatible with the natbib \citet command.

You may be mixing up two aspects of the process of creating (i) a bibliography and (ii) citations to entries in the bibliography. The first aspect -- determining how entries are typeset in the bibliography -- is handled by the bibliography style file (plos.bst in your case). The second aspect -- how citations/references to entries in the bibliography are formatted -- is handled by natbib.

By loading natbib with the numbers option, you are actually instructing the package to create numeric-style citations. If you want authoryear-style citations -- as would seem to be indicated by your attempted use of the \citet command -- you must specify the authoryear option instead.

Incidentally, when natbib is set to perform authoryear-style citations, specifying the option sort&compress is not necessary (and has no effect).

Addendum: From the OP's follow-up comments, I gather that a hybrid between "pure" numeric and authoryear citation styles -- viz., a combination of the author's (or authors') name and the associated citation number -- is what's needed. If this interpretation is correct, the following command may be of use (to be placed in the preamble):

\newcommand{\hybridcite}[1]{\citeauthor{#1} \citenum{#1}}

Invoking \hybridcite{People} (assuming that People is the key to an entry which is listed first in the references and which has two authors, named Author1 and Author 2) will then generate the citation Author1 and Author2 [1].

Related Question