[Tex/LaTex] Changing from apacite to natbib package

cite-packagecitingnatbib

I'm currently using the apacite-package for references in my thesis. However, I'd like to change the format of the references, which is currently on the form (Author, Year), to numbered style citation within square brackets ([10] for instance).

Looking at the documentation of the apacite package, it seems that it doesn't support this format. Instead, I'm looking to change to the natbib package. Can I do this without too much effort? For instance, can I use the same bib-file?

I tried changing the apacite referencing commands \cite or \citeauthor & \citeyear to \citep and \citet, respectively. However, I ended up with a lot of Undefined control sequence errors. Not sure where the problem lies, is it within the bib-file or is there something I am missing in the main TeX-file?

Edit: To illustrate, here's an example of what happens. I previously used the following code to reference an article: \cite{Dempster1977} or \citeauthor{Dempster1977} \citeyear{Dempster1977} depending on the format I wanted it on. This would result in the following references (Dempster et al., 1977) or Dempster et al. (1977).

Now I would instead have the following format:
Just the numbered of the reference in squared bracket, e.g. [10] or
Dempster et al. [10].

Here's the reference in the .bib-file.

 @article{Dempster1977,
author = "Dempster, A. P. and Laird, N. M. and Rubin, D. B.",
year = "1977",
title = "{Maximum Likelihood from Incomplete Data via the EM algorithm}",
journal = "{Journal of the Royal Statistical Society}",
volume = "39",
pages = "1--38"} 

To get this format, I tried using the natbib-package. So I include (after removing \usepackage{apacite}) \usepackage[square,numbers]{natbib}.

Then, in accordance with the documentation, I use \citep{Demspter1977} or \citet{Dempster1977}. But the error message for the line where I use \citet{Dempster1977} is

Undefined control sequence ...the seminal paper by \citet{Dempster1977}
Undefined control sequence ...the seminal paper by \citet{Dempster1977}
Missing = inserted for \ifnum ...the seminal paper by \citet{Dempster1977}
Missing number, treated as zero ...the seminal paper by \citet{Dempster1977}

These error messages appear throughout the file. Not sure what is causing them. Also, in the end I previously used

\bibliographystyle{apacite}
\bibliography{bibfile}

but I've changed this to

\bibliographystyle{plain}
\bibliography{bibfile}.

Best Answer

You have a few options. Here's what I'd do. I'm very picky about how citations are handled, so I'm going for fine grained control over how each of the citations is in handled in and outside of text by specifying a boolean and self-made citation commands. Switching the boolean sometimes requires you to plow throw errors, but these will resolve after running through the full document once (just to be sure: this will require you to continue compilation regardless of the errors. If you have over 100 citations, remove your aux and bib files).

\documentclass{article}

\newif\ifnatbib \natbibfalse

\ifnatbib
  \usepackage[numbers]{natbib}
  \let\mycitep\citep
  \let\mycitet\citet
  \bibliographystyle{unsrtnat}
\else
  \usepackage[apaciteclassic]{apacite}
  \let\mycitep\cite
  \let\mycitet\citeA
  \bibliographystyle{apacite}
\fi
\let\mycite\cite

\usepackage{filecontents}

\begin{filecontents*}{\jobname.bib}
@article{KamerlinghOnnes:1911p1320,
author = {Heike Kamerlingh-Onnes}, 
journal = {Communications from the Physical Laboratory of the University of Leiden},
title = {Further experiments with liquid Helium G. On the electrical resistance of pure metals, etc. VI. On the sudden change in the rate at which the resistance of Mercury disappears},
pages = {799--802},
volume = {124},
year = {1911},
month = {Feb},
date-added = {2009-02-05 11:13:59 +0100},
date-modified = {2011-10-05 15:29:37 +0200},
local-url = {file://localhost/Users/Shared/AndyDropbox/Dropbox/Library/Papers/1911/Kamerlingh-Onnes/Communications%20from%20the%20Physical%20Laboratory%20of%20the%20University%20of%20Leiden1911%20124%20799-802.pdf},
uri = {papers://1C9DCAE7-AE34-4220-9FE3-8B3A37855B8A/Paper/p1320},
rating = {0}
}
\end{filecontents*}

\begin{document}

A reference\mycite{KamerlinghOnnes:1911p1320}. \mycitet{KamerlinghOnnes:1911p1320} said that and that, but I don't agree because of this and that.

\bibliography{\jobname}

\end{document}
Related Question