[Tex/LaTex] Natbib setcitestyle causes “undefined control sequence error”

natbib

The following test code works if I comment out the \setcitestyle line. If I don't it throws a "undefined control sequence error." What's wrong? (I'm using the MacTeX-2011 distribution.)

\documentclass{article}
\usepackage{etoolbox}

\def\bibfile{refs}

\usepackage{natbib}
\setcitestyle{numbers}
\setcitestyle{notesep={: },aysep={}}

\ifdefmacro{\bibname}{}{\newcommand{\biname}{References}}   % Default bibliography name
\ifdefmacro{\bibfile}{}{\newcommand{\bibfile}{references}}  % Default name of references file, references.bib
 %\input{mmd-local-chicagoAD}

\begin{document} 
Hello \citep{KandR}

Kernighan wrote, \citet{gary_a._dymski_afterword:_2009}

Goodbye \citep[][222]{gary_a._dymski_afterword:_2009}
\renewcommand\bibname{References}
\bibliographystyle{mcbride}
\bibliography{refs}
%\input{mmd-local-bibmake}
\end{document}

Best Answer

Well, I finally figured this out. Thanks egreg for telling me you didn't get any error. This pointed me in the right direction.

The problem was that a few years ago I had installed the Copernicus package, and it includes a natbib.sty file dating from 2006. Since I installed it in my ~/Library/texmf path, which comes before the directory for the systemwide files in the LaTeX search path, LaTeX was finding this file instead of the up-to-date one that comes with MacTeX-2011.

Once egreg told me it works, I looked more closely at the log file and noticed that a 2006 version of natbib was being loaded, instead of the 2010 version that comes with MacTeX. I'd infer that \setcitestyle was not implemented in 2006.

Lots of lessons here.

Thanks again.