I am writing a document in latex and I have a big .bib file and a large number of citations. I want to have citations in the form [Author, year] format and am using the package natbib, but can't get citep or citet working, though plain cite is working fine. The error I get is:
! Undefined control sequence.
l.3 lets cite \citet{cayton05}
I am using Ubuntu texlive package and use \input{<file>}
latex command to input the chapters to the main .tex file.
What's surprising is that instead of using \input{<file>}
if I just have text in the main .tex file then all the cite commands are working.
Any help would be highly appreciated.
The working version is like this:
\usepackage{cite}
\usepackage[square,sort]{natbib}
%% lot of other packages and formatting %%
\begin{document}
\chapter{Testing citations}
\begin{enumerate}
\item this is the first citation \cite{belkin02}.
\item this is the second citation \citep{belkin02}.
\item this is the third citation \cite{shlens03}.
\end{enumerate}
\phantomsection\addcontentsline{toc}{chapter}{Bibliography}
\begin{spacing}{1.5}
\nocite{*}
\bibliographystyle{apalike}
\bibliography{testnb.bib}
\end{spacing}
\end{document}
In the real .tex file, I input the chapter text from another .tex file, and citep
and citet
won't work in that giving the aforesaid error, though plain cite
will work fine.
I forgot to mention earlier I was using plain numbered bibliography style and everything was working, so there is no error in the input .tex files.
If \citep
and \citet
do not work, then you probably did not load natbib
.
From a document I currently work on:
\usepackage[authoryear,round,longnamesfirst]{natbib}
You may want different options -- see the handy reference sheet for natbib for details.
You should only include \usepackage[square,sort]{natbib}
.
It will work after deleting \usepackage{cite}
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With