citep and citet not working even when using natbib package [closed]
Asked Answered
T

2

12

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.

Topheavy answered 9/12, 2010 at 1:41 Comment(1)
Just in case you arent aware, there is a more focussed Q&A site for Tex / latex - tex.stackexchange.comBibelot
S
18

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.

Servitude answered 9/12, 2010 at 1:45 Comment(3)
Can you post a small self-contained example which fails to illustrate the issue?Servitude
I have loaded the natbib package like this: \usepackage[square,sort]{natbib}. I copied the same .tex and .bib file to a different directory and wrote some citations (citep and citet) in the .tex file itself (instead of using \input{}), and they are working fine. Thanks for answering.Topheavy
Never mind ... the problem fixed itself. I never got to know what was wrong.Topheavy
M
5

You should only include \usepackage[square,sort]{natbib}.

It will work after deleting \usepackage{cite}.

Morrison answered 1/10, 2012 at 18:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.