3

I used an author-year citation style with Book class, it seems to be working fine if we looked at the produced Pdf but the Text editor (Texmaker in our case) returns some errors:

! Undefined control sequence.
<argument> \citeauthoryear
{Arasaratnam and Haykin}{ 2009}
l.15 ...au est la structure \cite{Arasaratnam2009}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
[1{C:/ProgramData/MiKTeX/2.9/pdftex/config/pdftex.map}
]

! Undefined control sequence.
<argument> \protect \citeauthoryear
{Arasaratnam and Haykin}{ 2009}
l.20 ...atnam and Haykin}{ 2009}]{Arasaratnam2009}
Arasaratnam, I., Haykin, ...
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

How can I fix this problem?

MWE:

\documentclass[a4paper,french,11pt,oneside,natbib]{book}
\usepackage[left=20mm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{graphicx}

%--------------------------------------------------------------------------------
\usepackage[colorlinks=true,linkcolor=blue, citecolor=cyan]{hyperref}
%--------------------------------------------------------------------------------

\begin{document}
%------------ ----PAGE DE GARDE ---------------------------------------

Le cerveau est la structure \cite{Arasaratnam2009} 

\begin{thebibliography}{}
% and use \bibitem to create references. Consult the Instructions for authors for reference list style.

\bibitem[\protect\citeauthoryear{Arasaratnam and Haykin}{ 2009}]{Arasaratnam2009} Arasaratnam, I., Haykin, S.: Cubature Kalman filters. IEEE Trans. Autom. Control. 54, 1254--1269 (2011)
\end{thebibliography}

\end{document}
  • 2
    natbib is not a class option, it's a package that must be loaded with \usepackage{natbib}. But why are you doing the bibliography manually? This is not really how natbib is designed to be used. – Alan Munn Jun 2 '18 at 15:46
  • The command \citeauthoryear is not defined in your document. It seems that the bib entries were produced by or are modelled after a .bst style that works together with a bibliography package that defines this command. If you don't want author-year citations you can simply remove the optional argument of \bibitem so that only \bibitem{Arasaratnam2009} remains. – moewe Jun 2 '18 at 15:46
  • @moewe natbib defines the command, but is not being loaded. – Alan Munn Jun 2 '18 at 15:46
  • @AlanMunn Indeed I saw the natbib in the class options too late. – moewe Jun 2 '18 at 15:51
1

The issue you've raised is related (a) the structure of the information provided in the optional argument of \bibitem and (b) the failure to load the natbib citation management package correctly. Specifying a document class option named natbib doesn't work, I'm afraid.

enter image description here

Aside: I'm familiar with the saying that there's no arguing about tastes. (De gustibus non est ...) Nevertheless, you may want to reconsider the wisdom of using cyan as the color for citation call-outs. :-)

\documentclass[a4paper,french,11pt,oneside]{book}
\usepackage[left=20mm]{geometry} % what about the other 3 margins?
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[french]{babel}
\usepackage{graphicx}
\usepackage[authoryear]{natbib}  % <-- new
\usepackage[colorlinks=true, linkcolor=blue, citecolor=cyan]{hyperref}

\begin{document}

Le cerveau est la structure \citep{Arasaratnam2009}.

Ou: \citet{Arasaratnam2009} ont dit que \dots

\begin{thebibliography}{9}

\bibitem[Arasaratnam and Haykin(2009)]{Arasaratnam2009} 
Arasaratnam, I., Haykin, S.: Cubature Kalman filters. 
IEEE Trans. Autom. Control. 54, 1254--1269 (2011)

\end{thebibliography}

\end{document}
  • Of course with natbib it would have been fine to keep the \protect\citeauthoryear{Arasaratnam and Haykin}{ 2009}. Although the space before the year looks a bit off to me... – moewe Jun 2 '18 at 15:52
  • @moewe - I know this too. :-) In my opinion, though, if the OP is going to build the bibliography entirely by hand (as seems to be the case), he or she should at least try to cut down on the code clutter. – Mico Jun 2 '18 at 15:55
  • That is a fair point. I was assuming this came from a copy-paste job on a .bbl file and wanted to point out that there is no need to go for Arasaratnam and Haykin(2009) instead of \protect\citeauthoryear{Arasaratnam and Haykin}{ 2009}. Although the former is definitely more readable. – moewe Jun 2 '18 at 15:57
  • @moewe - Interestingly, the user guide of the natbib package does not list \citeauthoryear as a user-level macro. The macro is mentioned only quite late in the manual, in conjunction with some specific bibliography styles. I suspect its continued existence is a matter of maintaining backward compatibility, e.g., as a hold-over from a much earlier version of the package, when interoperability with the newapa bibliography style and package wasn't as robust as it's now (and, frankly, has been for a decade or more...). – Mico Jun 2 '18 at 16:00
  • I didn't check the manual. I only looked at the beginning of natbib.sty where \protect\citeauthoryear{<author>}{<year>} is listed as valid way to give author and year. – moewe Jun 2 '18 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.